From 9dcab4bd49cb65b89694f281955b2cf881713e37 Mon Sep 17 00:00:00 2001 From: s1lent Date: Tue, 31 Oct 2017 04:29:22 +0700 Subject: [PATCH] Refactoring minor Refactoring unicode_strtools --- regamedll/build.gradle | 26 +- regamedll/common/stdc++compat.cpp | 52 + regamedll/dlls/API/CSPlayerItem.cpp | 12 - regamedll/dlls/addons/item_airbox.cpp | 10 - regamedll/dlls/addons/item_airbox.h | 10 - regamedll/dlls/addons/trigger_setorigin.cpp | 10 - regamedll/dlls/addons/trigger_setorigin.h | 10 - regamedll/dlls/bot/cs_bot.cpp | 10 +- regamedll/dlls/cbase.cpp | 1 - regamedll/dlls/client.cpp | 35 +- regamedll/dlls/client.h | 2 +- regamedll/dlls/cmdhandler.cpp | 14 +- regamedll/dlls/effects.h | 2 +- regamedll/dlls/hostage/hostage_improv.cpp | 6 +- regamedll/dlls/plats.cpp | 117 +- regamedll/dlls/player.cpp | 10 +- regamedll/dlls/trains.h | 4 +- regamedll/dlls/triggers.cpp | 2 +- regamedll/dlls/util.h | 18 + regamedll/dlls/vehicle.cpp | 64 +- regamedll/dlls/weapons.cpp | 110 +- regamedll/dlls/weapons.h | 17 +- regamedll/dlls/world.cpp | 2 +- regamedll/dlls/wpn_shared/wpn_ak47.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_aug.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_awp.cpp | 6 +- regamedll/dlls/wpn_shared/wpn_c4.cpp | 7 +- regamedll/dlls/wpn_shared/wpn_deagle.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_elite.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_famas.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_fiveseven.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_flashbang.cpp | 6 +- regamedll/dlls/wpn_shared/wpn_g3sg1.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_galil.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_glock18.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_hegrenade.cpp | 6 +- regamedll/dlls/wpn_shared/wpn_knife.cpp | 10 +- regamedll/dlls/wpn_shared/wpn_m249.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_m3.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_m4a1.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_mac10.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_mp5navy.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_p228.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_p90.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_scout.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_sg550.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_sg552.cpp | 5 +- .../dlls/wpn_shared/wpn_smokegrenade.cpp | 6 +- regamedll/dlls/wpn_shared/wpn_tmp.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_ump45.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_usp.cpp | 5 +- regamedll/dlls/wpn_shared/wpn_xm1014.cpp | 6 +- regamedll/engine/unicode_strtools.cpp | 1120 +++++++++++------ regamedll/engine/unicode_strtools.h | 66 +- regamedll/msvc/ReGameDLL.vcxproj | 14 +- regamedll/msvc/ReGameDLL.vcxproj.filters | 19 +- regamedll/public/strtools.h | 15 +- .../regamedll/RegameDLLRuntimeConfig.cpp | 131 -- regamedll/regamedll/hookchains_impl.h | 6 +- regamedll/regamedll/precompiled.h | 1 - ...untimeConfig.h => public_amalgamation.cpp} | 17 +- 61 files changed, 1205 insertions(+), 885 deletions(-) create mode 100644 regamedll/common/stdc++compat.cpp delete mode 100644 regamedll/regamedll/RegameDLLRuntimeConfig.cpp rename regamedll/regamedll/{RegameDLLRuntimeConfig.h => public_amalgamation.cpp} (81%) diff --git a/regamedll/build.gradle b/regamedll/build.gradle index 7f4bf4da..4e46ebce 100644 --- a/regamedll/build.gradle +++ b/regamedll/build.gradle @@ -102,7 +102,7 @@ void setupToolchain(NativeBinarySpec b) b.lib LazyNativeDepSet.create(dep_cppunitlite, 'cppunitlite', b.buildType.name, true) } - cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'DEDICATED', 'REGAMEDLL_SELF', 'REGAMEDLL_API', 'CLIENT_WEAPONS', 'USE_QSTRING' + cfg.singleDefines 'USE_BREAKPAD_HANDLER', 'REGAMEDLL_SELF', 'REGAMEDLL_API', 'CLIENT_WEAPONS', 'USE_QSTRING' if (cfg instanceof MsvcToolchainConfig) { @@ -160,7 +160,7 @@ void setupToolchain(NativeBinarySpec b) } if (regamedllFixes) { - cfg.singleDefines 'REGAMEDLL_FIXES', 'REGAMEDLL_CHECKS', 'REGAMEDLL_ADD', 'NDEBUG' + cfg.singleDefines 'REGAMEDLL_FIXES', 'REGAMEDLL_CHECKS', 'REGAMEDLL_ADD', 'UNICODE_FIXES', 'NDEBUG' } else { cfg.singleDefines 'PLAY_GAMEDLL' } @@ -173,12 +173,19 @@ void setupToolchain(NativeBinarySpec b) class RegamedllSrc { static void regamedll_src(def h) { - h.regamedll_src(CppSourceSet) { - + h.engine_src(CppSourceSet) { source { - srcDirs "engine", "dlls", "dlls/API", "dlls/addons", "game_shared", "pm_shared", "regamedll", "public", "version" + srcDir "engine" + include "unicode_strtools.cpp" + } + } + + h.shared_src(CppSourceSet) { + source { + srcDirs "game_shared", "pm_shared", "regamedll", "public", "version" include "**/*.cpp" + exclude "precompiled.cpp" exclude "tier0/dbg.cpp", "utlsymbol.cpp", "utlbuffer.cpp" @@ -193,12 +200,19 @@ class RegamedllSrc { } } } + + h.gamedll_src(CppSourceSet) { + source { + srcDirs "dlls", "dlls/API", "dlls/addons" + include "**/*.cpp" + } + } } static void regamedll_pch(def h) { h.regamedll_pch(CppSourceSet) { source { - srcDirs "regamedll" + srcDir "regamedll" include "precompiled.cpp" } } diff --git a/regamedll/common/stdc++compat.cpp b/regamedll/common/stdc++compat.cpp new file mode 100644 index 00000000..27dc579e --- /dev/null +++ b/regamedll/common/stdc++compat.cpp @@ -0,0 +1,52 @@ +#include + +#if !defined(_WIN32) +void NORETURN Sys_Error(const char *error, ...); + +// This file adds the necessary compatibility tricks to avoid symbols with +// version GLIBCXX_3.4.16 and bigger, keeping binary compatibility with libstdc++ 4.6.1. +namespace std +{ + // We shouldn't be throwing exceptions at all, but it sadly turns out we call STL (inline) functions that do. + void __throw_out_of_range_fmt(const char *fmt, ...) + { + va_list ap; + char buf[1024]; // That should be big enough. + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + buf[sizeof(buf) - 1] = '\0'; + va_end(ap); + + Sys_Error(buf); + } +}; // namespace std + +// Technically, this symbol is not in GLIBCXX_3.4.20, but in CXXABI_1.3.8, +// but that's equivalent, version-wise. Those calls are added by the compiler +// itself on `new Class[n]` calls. +extern "C" +void __cxa_throw_bad_array_new_length() +{ + Sys_Error("Bad array new length."); +} + +#if __cplusplus >= 201402L +// This operator delete sized deallocations was added in c++14 +// and required at least not less than CXXABI_1.3.9 +// we should to keep CXXABI_1.3.8 for binary compatibility with oldest libstdc++. +// G++ and clang allow to compile C++14 code with -fno-sized-deallocation to disable the new feature, +// so that our C++14 library code would never call that version of operator delete, +// for other compilers we must override those operators for static linking to the library. +void operator delete[](void *ptr, std::size_t size) noexcept +{ + ::operator delete(ptr); +} + +void operator delete(void *ptr, std::size_t size) noexcept +{ + ::operator delete(ptr); +} +#endif + +#endif // !defined(_WIN32) diff --git a/regamedll/dlls/API/CSPlayerItem.cpp b/regamedll/dlls/API/CSPlayerItem.cpp index cab6817c..2cd0ec35 100644 --- a/regamedll/dlls/API/CSPlayerItem.cpp +++ b/regamedll/dlls/API/CSPlayerItem.cpp @@ -32,15 +32,3 @@ EXT_FUNC void CCSPlayerItem::SetItemInfo(ItemInfo *pInfo) { Q_memcpy(&m_ItemInfo, pInfo, sizeof(m_ItemInfo)); } - -#ifdef REGAMEDLL_API -int CBasePlayerItem::iPosition() const { return CSPlayerItem()->m_ItemInfo.iPosition; } -const char *CBasePlayerItem::pszAmmo1() const { return CSPlayerItem()->m_ItemInfo.pszAmmo1; } -int CBasePlayerItem::iMaxAmmo1() const { return CSPlayerItem()->m_ItemInfo.iMaxAmmo1; } -const char *CBasePlayerItem::pszAmmo2() const { return CSPlayerItem()->m_ItemInfo.pszAmmo2; } -int CBasePlayerItem::iMaxAmmo2() const { return CSPlayerItem()->m_ItemInfo.iMaxAmmo2; } -const char *CBasePlayerItem::pszName() const { return CSPlayerItem()->m_ItemInfo.pszName; } -int CBasePlayerItem::iMaxClip() const { return CSPlayerItem()->m_ItemInfo.iMaxClip; } -int CBasePlayerItem::iWeight() const { return CSPlayerItem()->m_ItemInfo.iWeight; } -int CBasePlayerItem::iFlags() const { return CSPlayerItem()->m_ItemInfo.iFlags; } -#endif diff --git a/regamedll/dlls/addons/item_airbox.cpp b/regamedll/dlls/addons/item_airbox.cpp index 3b3b79ee..c342899c 100644 --- a/regamedll/dlls/addons/item_airbox.cpp +++ b/regamedll/dlls/addons/item_airbox.cpp @@ -14,16 +14,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* */ #include "precompiled.h" diff --git a/regamedll/dlls/addons/item_airbox.h b/regamedll/dlls/addons/item_airbox.h index 4e11595b..2ced811b 100644 --- a/regamedll/dlls/addons/item_airbox.h +++ b/regamedll/dlls/addons/item_airbox.h @@ -14,16 +14,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* */ #pragma once diff --git a/regamedll/dlls/addons/trigger_setorigin.cpp b/regamedll/dlls/addons/trigger_setorigin.cpp index 436d9dca..2c709272 100644 --- a/regamedll/dlls/addons/trigger_setorigin.cpp +++ b/regamedll/dlls/addons/trigger_setorigin.cpp @@ -14,16 +14,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* */ #include "precompiled.h" diff --git a/regamedll/dlls/addons/trigger_setorigin.h b/regamedll/dlls/addons/trigger_setorigin.h index 517fc7d6..835ed935 100644 --- a/regamedll/dlls/addons/trigger_setorigin.h +++ b/regamedll/dlls/addons/trigger_setorigin.h @@ -14,16 +14,6 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* */ #pragma once diff --git a/regamedll/dlls/bot/cs_bot.cpp b/regamedll/dlls/bot/cs_bot.cpp index db69829f..f480b2d1 100644 --- a/regamedll/dlls/bot/cs_bot.cpp +++ b/regamedll/dlls/bot/cs_bot.cpp @@ -340,19 +340,19 @@ void CCSBot::BotDeathThink() CBasePlayer *CCSBot::FindNearbyPlayer() { - CBaseEntity *pEntity = nullptr; + CBasePlayer *pPlayer = nullptr; Vector vecSrc = pev->origin; const float flRadius = 800.0f; - while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, flRadius))) + while ((pPlayer = UTIL_FindEntityInSphere(pPlayer, vecSrc, flRadius))) { - if (!pEntity->IsPlayer()) + if (!pPlayer->IsPlayer()) continue; - if (!(pEntity->pev->flags & FL_FAKECLIENT)) + if (!(pPlayer->pev->flags & FL_FAKECLIENT)) continue; - return static_cast(pEntity); + return pPlayer; } return nullptr; diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index 4db098b0..c8ea5afb 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -361,7 +361,6 @@ int DispatchSpawn(edict_t *pent) gGlobalState.EntityAdd(pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON); } } - } return 0; diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 3dd2f62f..cd0a8a57 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -773,7 +773,11 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) p = szTemp; } - // remove quotes if present +#ifdef REGAMEDLL_FIXES + Q_StripPrecedingAndTrailingWhitespace(p); +#endif + + // remove quotes (leading & trailing) if present if (*p == '"') { p++; @@ -806,11 +810,11 @@ void Host_Say(edict_t *pEntity, BOOL teamonly) Place playerPlace = TheNavAreaGrid.GetPlace(&pPlayer->pev->origin); const BotPhraseList *placeList = TheBotPhrases->GetPlaceList(); - for (auto it : *placeList) + for (auto phrase : *placeList) { - if (it->GetID() == playerPlace) + if (phrase->GetID() == playerPlace) { - placeName = it->GetName(); + placeName = phrase->GetName(); break; } } @@ -4033,6 +4037,11 @@ void ClientPrecache() PRECACHE_MODEL("sprites/black_smoke2.spr"); PRECACHE_MODEL("sprites/black_smoke3.spr"); PRECACHE_MODEL("sprites/black_smoke4.spr"); + +#ifdef REGAMEDLL_FIXES + PRECACHE_MODEL("sprites/gas_puff_01.spr"); +#endif + PRECACHE_MODEL("sprites/fast_wallpuff1.spr"); PRECACHE_MODEL("sprites/pistol_smoke1.spr"); PRECACHE_MODEL("sprites/pistol_smoke2.spr"); @@ -4219,16 +4228,16 @@ bool CheckEntityRecentlyInPVS(int clientnum, int entitynum, float currenttime) return false; } -int EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet) +BOOL EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, BOOL player, unsigned char *pSet) { if ((ent->v.effects & EF_NODRAW) == EF_NODRAW && ent != host) - return 0; + return FALSE; if (!ent->v.modelindex || !STRING(ent->v.model)) - return 0; + return FALSE; if ((ent->v.flags & FL_SPECTATOR) == FL_SPECTATOR && ent != host) - return 0; + return FALSE; int i; int hostnum = ENTINDEX(host) - 1; @@ -4242,7 +4251,7 @@ int EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, ed if (!ENGINE_CHECK_VISIBILITY(ent, pSet)) { MarkEntityInPVS(hostnum, e, 0, false); - return 0; + return FALSE; } MarkEntityInPVS(hostnum, e, gpGlobals->time, true); @@ -4250,7 +4259,7 @@ int EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, ed } if ((ent->v.flags & FL_SKIPLOCALHOST) == FL_SKIPLOCALHOST && (hostflags & 1) && ent->v.owner == host) - return 0; + return FALSE; if (host->v.groupinfo) { @@ -4261,12 +4270,12 @@ int EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, ed if (g_groupop == GROUP_OP_AND) { if (!(ent->v.groupinfo & host->v.groupinfo)) - return 0; + return FALSE; } else if (g_groupop == GROUP_OP_NAND) { if (ent->v.groupinfo & host->v.groupinfo) - return 0; + return FALSE; } } @@ -4351,7 +4360,7 @@ int EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, ed state->playerclass = ent->v.playerclass; state->iuser4 = ent->v.iuser4; - return 1; + return TRUE; } // Creates baselines used for network encoding, especially for player data since players are not spawned until connect time. diff --git a/regamedll/dlls/client.h b/regamedll/dlls/client.h index f5f0b006..d00252e8 100644 --- a/regamedll/dlls/client.h +++ b/regamedll/dlls/client.h @@ -177,7 +177,7 @@ void ResetPlayerPVS(edict_t *client, int clientnum); bool CheckPlayerPVSLeafChanged(edict_t *client, int clientnum); void MarkEntityInPVS(int clientnum, int entitynum, float time, bool inpvs); bool CheckEntityRecentlyInPVS(int clientnum, int entitynum, float currenttime); -int AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet); +BOOL AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, BOOL player, unsigned char *pSet); void CreateBaseline(int player, int eindex, struct entity_state_s *baseline, edict_t *entity, int playermodelindex, Vector player_mins, Vector player_maxs); void Entity_FieldInit(struct delta_s *pFields); void Entity_Encode(struct delta_s *pFields, const unsigned char *from, const unsigned char *to); diff --git a/regamedll/dlls/cmdhandler.cpp b/regamedll/dlls/cmdhandler.cpp index 38e94cd8..e11ec7d0 100644 --- a/regamedll/dlls/cmdhandler.cpp +++ b/regamedll/dlls/cmdhandler.cpp @@ -130,7 +130,7 @@ void SV_LoopPerformance_f() start = loopCounter.GetCurTime(); - for (i = 0; i < 100; ++i) + for (i = 0; i < 100; i++) { CBaseEntity *pSpot; for (pSpot = UTIL_FindEntityByString_Old(nullptr, "classname", "info_player_start"); pSpot; pSpot = UTIL_FindEntityByString_Old(pSpot, "classname", "info_player_start")) @@ -152,19 +152,19 @@ void SV_LoopPerformance_f() // check time new search loop start = loopCounter.GetCurTime(); - for (i = 0; i < 100; ++i) + for (i = 0; i < 100; i++) { CBaseEntity *pSpot; - for (pSpot = UTIL_FindEntityByString(nullptr, "classname", "info_player_start"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "info_player_start")) + for (pSpot = UTIL_FindEntityByClassname(nullptr, "info_player_start"); pSpot; pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start")) ; - for (pSpot = UTIL_FindEntityByString(nullptr, "classname", "info_player_deathmatch"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "info_player_deathmatch")) + for (pSpot = UTIL_FindEntityByClassname(nullptr, "info_player_deathmatch"); pSpot; pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_deathmatch")) ; - for (pSpot = UTIL_FindEntityByString(nullptr, "classname", "player"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "player")) + for (pSpot = UTIL_FindEntityByClassname(nullptr, "player"); pSpot; pSpot = UTIL_FindEntityByClassname(pSpot, "player")) ; - for (pSpot = UTIL_FindEntityByString(nullptr, "classname", "bodyque"); pSpot; pSpot = UTIL_FindEntityByString(pSpot, "classname", "bodyque")) + for (pSpot = UTIL_FindEntityByClassname(nullptr, "bodyque"); pSpot; pSpot = UTIL_FindEntityByClassname(pSpot, "bodyque")) ; } @@ -174,7 +174,7 @@ void SV_LoopPerformance_f() void SV_PrintEntities_f() { - for (int i = 0; i < stringsHashTable.Count(); ++i) + for (int i = 0; i < stringsHashTable.Count(); i++) { hash_item_t *item = &stringsHashTable[i]; diff --git a/regamedll/dlls/effects.h b/regamedll/dlls/effects.h index a47ae484..d681705d 100644 --- a/regamedll/dlls/effects.h +++ b/regamedll/dlls/effects.h @@ -214,7 +214,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; CSprite *m_pSprite; - int m_iszSpriteName; + string_t m_iszSpriteName; Vector m_firePosition; }; diff --git a/regamedll/dlls/hostage/hostage_improv.cpp b/regamedll/dlls/hostage/hostage_improv.cpp index 43600c90..d4701a26 100644 --- a/regamedll/dlls/hostage/hostage_improv.cpp +++ b/regamedll/dlls/hostage/hostage_improv.cpp @@ -1066,15 +1066,13 @@ void CHostageImprov::UpdateGrenadeReactions() if (m_grenadeTimer.IsElapsed()) { - CBaseEntity *pEntity = nullptr; + CGrenade *pGrenade = nullptr; const float watchGrenadeRadius = 500.0f; m_grenadeTimer.Start(RANDOM_FLOAT(0.4f, 0.6f)); - while ((pEntity = UTIL_FindEntityInSphere(pEntity, GetCentroid(), watchGrenadeRadius))) + while ((pGrenade = UTIL_FindEntityInSphere(pGrenade, GetCentroid(), watchGrenadeRadius))) { - CGrenade *pGrenade = static_cast(pEntity); - if (!FClassnameIs(pGrenade->pev, "grenade") || pGrenade->m_SGSmoke > 1) continue; diff --git a/regamedll/dlls/plats.cpp b/regamedll/dlls/plats.cpp index df86fbe8..2fe31c98 100644 --- a/regamedll/dlls/plats.cpp +++ b/regamedll/dlls/plats.cpp @@ -1380,12 +1380,12 @@ void CFuncTrackTrain::Find() void CFuncTrackTrain::NearestPath() { - CBaseEntity *pTrack = nullptr; - CBaseEntity *pNearest = nullptr; + CPathTrack *pTrack = nullptr; + CPathTrack *pNearest = nullptr; float_precision dist; - float closest = 1024; + float closest = 1024.0f; - while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024))) + while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024.0f))) { // filter out non-tracks if (!(pTrack->pev->flags & (FL_CLIENT | FL_MONSTER)) && FClassnameIs(pTrack->pev, "path_track")) @@ -1410,7 +1410,7 @@ void CFuncTrackTrain::NearestPath() ALERT(at_aiconsole, "TRAIN: %s, Nearest track is %s\n", STRING(pev->targetname), STRING(pNearest->pev->targetname)); // If I'm closer to the next path_track on this path, then it's my real path - pTrack = ((CPathTrack *)pNearest)->GetNext(); + pTrack = pNearest->GetNext(); if (pTrack) { @@ -1420,7 +1420,7 @@ void CFuncTrackTrain::NearestPath() } } - m_ppath = static_cast(pNearest); + m_ppath = pNearest; if (pev->speed != 0) { @@ -1435,11 +1435,11 @@ void CFuncTrackTrain::OverrideReset() SetThink(&CFuncTrackTrain::NearestPath); } -CFuncTrackTrain *CFuncTrackTrain::Instance(edict_t *pent) +CFuncTrackTrain *CFuncTrackTrain::Instance(edict_t *pEdict) { - if (FClassnameIs(pent, "func_tracktrain")) + if (FClassnameIs(pEdict, "func_tracktrain")) { - return (CFuncTrackTrain *)GET_PRIVATE(pent); + return GET_PRIVATE(pEdict); } return nullptr; @@ -1471,8 +1471,8 @@ void CFuncTrackTrain::Spawn() pev->solid = SOLID_BSP; pev->movetype = MOVETYPE_PUSH; - SET_MODEL(ENT(pev), STRING(pev->model)); + SET_MODEL(ENT(pev), STRING(pev->model)); UTIL_SetSize(pev, pev->mins, pev->maxs); UTIL_SetOrigin(pev, pev->origin); @@ -1498,6 +1498,7 @@ void CFuncTrackTrain::Restart() pev->velocity = g_vecZero; pev->avelocity = g_vecZero; pev->impulse = int(m_speed); + m_dir = 1; if (FStringNull(pev->target)) @@ -1506,6 +1507,7 @@ void CFuncTrackTrain::Restart() } UTIL_SetOrigin(pev, pev->oldorigin); + NextThink(pev->ltime + 0.1f, FALSE); SetThink(&CFuncTrackTrain::Find); } @@ -1539,22 +1541,20 @@ LINK_ENTITY_TO_CLASS(func_traincontrols, CFuncTrainControls, CCSFuncTrainControl void CFuncTrainControls::Find() { - edict_t *pTarget = nullptr; - - do + CFuncTrackTrain *pTrain = nullptr; + while ((pTrain = UTIL_FindEntityByTargetname(pTrain, pev->target))) { - pTarget = FIND_ENTITY_BY_TARGETNAME(pTarget, STRING(pev->target)); + if (FClassnameIs(pTrain->pev, "func_tracktrain")) + break; } - while (!FNullEnt(pTarget) && !FClassnameIs(pTarget, "func_tracktrain")); - if (FNullEnt(pTarget)) + if (FNullEnt(pTrain)) { ALERT(at_console, "No train %s\n", STRING(pev->target)); return; } - CFuncTrackTrain *ptrain = CFuncTrackTrain::Instance(pTarget); - ptrain->SetControls(pev); + pTrain->SetControls(pev); UTIL_Remove(this); } @@ -1562,7 +1562,7 @@ void CFuncTrainControls::Spawn() { pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - SET_MODEL(ENT(pev), STRING(pev->model)); + SET_MODEL(ENT(pev), pev->model); UTIL_SetSize(pev, pev->mins, pev->maxs); UTIL_SetOrigin(pev, pev->origin); @@ -1668,47 +1668,48 @@ void CFuncTrackChange::OverrideReset() void CFuncTrackChange::Find() { // Find track entities - edict_t *target; - - target = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trackTopName)); - if (!FNullEnt(target)) + edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trackTopName)); + if (FNullEnt(pTarget)) { - m_trackTop = CPathTrack::Instance(target); - target = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trackBottomName)); - - if (!FNullEnt(target)) - { - m_trackBottom = CPathTrack::Instance(target); - target = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trainName)); - - if (!FNullEnt(target)) - { - m_train = CFuncTrackTrain::Instance(FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trainName))); - - if (!m_train) - { - ALERT(at_error, "Can't find train for track change! %s\n", STRING(m_trainName)); - return; - } - - Vector center = (pev->absmin + pev->absmax) * 0.5f; - m_trackBottom = m_trackBottom->Nearest(center); - m_trackTop = m_trackTop->Nearest(center); - UpdateAutoTargets(m_toggle_state); - SetThink(NULL); - return; - } - else - { - ALERT(at_error, "Can't find train for track change! %s\n", STRING(m_trainName)); - target = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trainName)); - } - } - else - ALERT(at_error, "Can't find bottom track for track change! %s\n", STRING(m_trackBottomName)); - } - else ALERT(at_error, "Can't find top track for track change! %s\n", STRING(m_trackTopName)); + return; + } + + m_trackTop = CPathTrack::Instance(pTarget); + pTarget = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trackBottomName)); + + if (FNullEnt(pTarget)) + { + ALERT(at_error, "Can't find bottom track for track change! %s\n", STRING(m_trackBottomName)); + return; + } + + m_trackBottom = CPathTrack::Instance(pTarget); + pTarget = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trainName)); + + if (FNullEnt(pTarget)) + { + ALERT(at_error, "Can't find train for track change! %s\n", STRING(m_trainName)); + + // TODO: this call has no effect + // pTarget = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trainName)); + return; + } + + m_train = CFuncTrackTrain::Instance(FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(m_trainName))); + + if (!m_train) + { + ALERT(at_error, "Can't find train for track change! %s\n", STRING(m_trainName)); + return; + } + + Vector center = (pev->absmin + pev->absmax) * 0.5f; + m_trackBottom = m_trackBottom->Nearest(center); + m_trackTop = m_trackTop->Nearest(center); + UpdateAutoTargets(m_toggle_state); + SetThink(nullptr); + return; } TRAIN_CODE CFuncTrackChange::EvaluateTrain(CPathTrack *pcurrent) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index ba08f939..8391a6fe 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -1252,7 +1252,7 @@ void packPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) // pack the ammo if (packAmmo) { - pWeaponBox->PackAmmo(MAKE_STRING(CBasePlayerItem::m_ItemInfoArray[pItem->m_iId].pszAmmo1), pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]); + pWeaponBox->PackAmmo(MAKE_STRING(pItem->pszAmmo1()), pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]); } SET_MODEL(ENT(pWeaponBox->pev), modelName); @@ -1315,7 +1315,7 @@ void packPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) // pack the ammo if (packAmmo) { - pWeaponBox->PackAmmo(MAKE_STRING(CBasePlayerItem::m_ItemInfoArray[pItem->m_iId].pszAmmo1), pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]); + pWeaponBox->PackAmmo(MAKE_STRING(pItem->pszAmmo1()), pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]); } SET_MODEL(ENT(pWeaponBox->pev), modelName); @@ -1412,9 +1412,9 @@ void EXT_FUNC CBasePlayer::__API_HOOK(GiveDefaultItems)() #ifdef REGAMEDLL_ADD auto GiveWeapon = [&](int ammo, char* pszWeaponName) { GiveNamedItem(pszWeaponName); - const WeaponInfoStruct *info = GetWeaponInfo(pszWeaponName); - if (info) { - GiveAmmo(refill_bpammo_weapons.value != 0.0f ? info->maxRounds : ammo, info->ammoName2); + const WeaponInfoStruct *pInfo = GetWeaponInfo(pszWeaponName); + if (pInfo) { + GiveAmmo(refill_bpammo_weapons.value != 0.0f ? pInfo->maxRounds : ammo, pInfo->ammoName2); } }; diff --git a/regamedll/dlls/trains.h b/regamedll/dlls/trains.h index d82b28d2..35a84b2b 100644 --- a/regamedll/dlls/trains.h +++ b/regamedll/dlls/trains.h @@ -105,7 +105,7 @@ public: void StopSound(); void UpdateSound(); - static CFuncTrackTrain *Instance(edict_t *pent); + static CFuncTrackTrain *Instance(edict_t *pEdict); static TYPEDESCRIPTION m_SaveData[]; CPathTrack *m_ppath; @@ -163,7 +163,7 @@ public: void UpdateSound(); public: - static CFuncVehicle *Instance(edict_t *pent); + static CFuncVehicle *Instance(edict_t *pEdict); static TYPEDESCRIPTION m_SaveData[]; CPathTrack *m_ppath; diff --git a/regamedll/dlls/triggers.cpp b/regamedll/dlls/triggers.cpp index eb0c5abc..1d5b97db 100644 --- a/regamedll/dlls/triggers.cpp +++ b/regamedll/dlls/triggers.cpp @@ -2068,7 +2068,7 @@ void CTriggerChangeTarget::Spawn() void CTriggerChangeTarget::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { - CBaseEntity *pTarget = UTIL_FindEntityByString(nullptr, "targetname", STRING(pev->target)); + CBaseEntity *pTarget = UTIL_FindEntityByTargetname(nullptr, pev->target); if (pTarget) { pTarget->pev->target = m_iszNewTarget; diff --git a/regamedll/dlls/util.h b/regamedll/dlls/util.h index 941a595a..8874e1aa 100644 --- a/regamedll/dlls/util.h +++ b/regamedll/dlls/util.h @@ -311,6 +311,24 @@ inline T *UTIL_FindEntityByTargetname(T *pStartEntity, const char *szName) return (T *)UTIL_FindEntityByString(pStartEntity, "targetname", szName); } +template +inline T *UTIL_FindEntityInSphere(T *pStartEntity, const Vector &vecCenter, float flRadius) +{ + edict_t *pentEntity; + if (pStartEntity) + pentEntity = pStartEntity->edict(); + else + pentEntity = nullptr; + + pentEntity = FIND_ENTITY_IN_SPHERE(pentEntity, vecCenter, flRadius); + if (!FNullEnt(pentEntity)) + { + return (T *)CBaseEntity::Instance(pentEntity); + } + + return nullptr; +} + template void UTIL_StripToken(const char *pKey, char (&pDest)[nSize]) { diff --git a/regamedll/dlls/vehicle.cpp b/regamedll/dlls/vehicle.cpp index 417f158e..762e2565 100644 --- a/regamedll/dlls/vehicle.cpp +++ b/regamedll/dlls/vehicle.cpp @@ -756,13 +756,14 @@ void CFuncVehicle::Find() void CFuncVehicle::NearestPath() { - CBaseEntity *pTrack = nullptr; - CBaseEntity *pNearest = nullptr; + CPathTrack *pTrack = nullptr; + CPathTrack *pNearest = nullptr; float_precision dist; - float closest = 1024; + float closest = 1024.0f; - while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024))) + while ((pTrack = UTIL_FindEntityInSphere(pTrack, pev->origin, 1024.0f))) { + // filter out non-tracks if (!(pTrack->pev->flags & (FL_CLIENT | FL_MONSTER)) && FClassnameIs(pTrack->pev, "path_track")) { dist = (pev->origin - pTrack->pev->origin).Length(); @@ -784,7 +785,9 @@ void CFuncVehicle::NearestPath() ALERT(at_aiconsole, "TRAIN: %s, Nearest track is %s\n", STRING(pev->targetname), STRING(pNearest->pev->targetname)); - pTrack = ((CPathTrack *)pNearest)->GetNext(); + // If I'm closer to the next path_track on this path, then it's my real path + pTrack = pNearest->GetNext(); + if (pTrack) { if ((pev->origin - pTrack->pev->origin).Length() < (pev->origin - pNearest->pev->origin).Length()) @@ -793,10 +796,11 @@ void CFuncVehicle::NearestPath() } } - m_ppath = static_cast(pNearest); + m_ppath = pNearest; + if (pev->speed != 0) { - NextThink(pev->ltime + 0.1, FALSE); + NextThink(pev->ltime + 0.1f, FALSE); SetThink(&CFuncVehicle::Next); } } @@ -807,11 +811,11 @@ void CFuncVehicle::OverrideReset() SetThink(&CFuncVehicle::NearestPath); } -CFuncVehicle *CFuncVehicle::Instance(edict_t *pent) +CFuncVehicle *CFuncVehicle::Instance(edict_t *pEdict) { - if (FClassnameIs(pent, "func_vehicle")) + if (FClassnameIs(pEdict, "func_vehicle")) { - return (CFuncVehicle *)GET_PRIVATE(pent); + return GET_PRIVATE(pEdict); } return nullptr; @@ -860,13 +864,16 @@ void CFuncVehicle::Spawn() UTIL_SetSize(pev, pev->mins, pev->maxs); UTIL_SetOrigin(pev, pev->origin); + // Cache off placed origin for vehicle controls pev->oldorigin = pev->origin; m_controlMins = pev->mins; m_controlMaxs = pev->maxs; m_controlMaxs.z += 72; - NextThink(pev->ltime + 0.1, FALSE); + // start vehicle on the next frame, to make sure their targets have had + // a chance to spawn/activate + NextThink(pev->ltime + 0.1f, FALSE); SetThink(&CFuncVehicle::Find); Precache(); } @@ -878,11 +885,11 @@ void CFuncVehicle::Restart() pev->speed = 0; pev->velocity = g_vecZero; pev->avelocity = g_vecZero; - pev->impulse = int(m_speed); + + m_dir = 1; m_flTurnStartTime = -1; m_flUpdateSound = -1; - m_dir = 1; m_pDriver = nullptr; if (FStringNull(pev->target)) @@ -893,7 +900,7 @@ void CFuncVehicle::Restart() UTIL_SetOrigin(pev, pev->oldorigin); STOP_SOUND(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noise)); - NextThink(pev->ltime + 0.1, FALSE); + NextThink(pev->ltime + 0.1f, FALSE); SetThink(&CFuncVehicle::Find); } @@ -904,12 +911,12 @@ void CFuncVehicle::Precache() switch (m_sounds) { - case 1: PRECACHE_SOUND("plats/vehicle1.wav");pev->noise = MAKE_STRING("plats/vehicle1.wav"); break; - case 2: PRECACHE_SOUND("plats/vehicle2.wav");pev->noise = MAKE_STRING("plats/vehicle2.wav"); break; - case 3: PRECACHE_SOUND("plats/vehicle3.wav");pev->noise = MAKE_STRING("plats/vehicle3.wav"); break; - case 4: PRECACHE_SOUND("plats/vehicle4.wav");pev->noise = MAKE_STRING("plats/vehicle4.wav"); break; - case 5: PRECACHE_SOUND("plats/vehicle6.wav");pev->noise = MAKE_STRING("plats/vehicle6.wav"); break; - case 6: PRECACHE_SOUND("plats/vehicle7.wav");pev->noise = MAKE_STRING("plats/vehicle7.wav"); break; + case 1: PRECACHE_SOUND("plats/vehicle1.wav"); pev->noise = MAKE_STRING("plats/vehicle1.wav"); break; + case 2: PRECACHE_SOUND("plats/vehicle2.wav"); pev->noise = MAKE_STRING("plats/vehicle2.wav"); break; + case 3: PRECACHE_SOUND("plats/vehicle3.wav"); pev->noise = MAKE_STRING("plats/vehicle3.wav"); break; + case 4: PRECACHE_SOUND("plats/vehicle4.wav"); pev->noise = MAKE_STRING("plats/vehicle4.wav"); break; + case 5: PRECACHE_SOUND("plats/vehicle6.wav"); pev->noise = MAKE_STRING("plats/vehicle6.wav"); break; + case 6: PRECACHE_SOUND("plats/vehicle7.wav"); pev->noise = MAKE_STRING("plats/vehicle7.wav"); break; } PRECACHE_SOUND("plats/vehicle_brake1.wav"); @@ -922,23 +929,20 @@ LINK_ENTITY_TO_CLASS(func_vehiclecontrols, CFuncVehicleControls, CCSFuncVehicleC void CFuncVehicleControls::Find() { - edict_t *pTarget = nullptr; - - do + CFuncVehicle *pVehicle = nullptr; + while ((pVehicle = UTIL_FindEntityByTargetname(pVehicle, pev->target))) { - pTarget = FIND_ENTITY_BY_TARGETNAME(pTarget, STRING(pev->target)); + if (FClassnameIs(pVehicle->pev, "func_vehicle")) + break; } - while (!FNullEnt(pTarget) && !FClassnameIs(pTarget, "func_vehicle")); - if (FNullEnt(pTarget)) + if (FNullEnt(pVehicle)) { ALERT(at_console, "No vehicle %s\n", STRING(pev->target)); return; } - CFuncVehicle *pvehicle = CFuncVehicle::Instance(pTarget); - - pvehicle->SetControls(pev); + pVehicle->SetControls(pev); UTIL_Remove(this); } @@ -946,7 +950,7 @@ void CFuncVehicleControls::Spawn() { pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - SET_MODEL(ENT(pev), STRING(pev->model)); + SET_MODEL(ENT(pev), pev->model); UTIL_SetSize(pev, pev->mins, pev->maxs); UTIL_SetOrigin(pev, pev->origin); diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 3d53ef39..10ca5135 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -260,7 +260,7 @@ void UTIL_PrecacheOtherWeapon(const char *szClassname) } // Called by worldspawn -void W_Precache() +void WeaponsPrecache() { Q_memset(CBasePlayerItem::m_ItemInfoArray, 0, sizeof(CBasePlayerItem::m_ItemInfoArray)); Q_memset(CBasePlayerItem::m_AmmoInfoArray, 0, sizeof(CBasePlayerItem::m_AmmoInfoArray)); @@ -1076,6 +1076,16 @@ void CBasePlayerItem::AttachToPlayer(CBasePlayer *pPlayer) SetTouch(nullptr); } +void CBasePlayerWeapon::Spawn() +{ + ItemInfo info; + Q_memset(&info, 0, sizeof(info)); + + if (GetItemInfo(&info)) { + CSPlayerItem()->SetItemInfo(&info); + } +} + // CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal int CBasePlayerWeapon::AddDuplicate(CBasePlayerItem *pOriginal) { @@ -1455,6 +1465,35 @@ float CBasePlayerWeapon::GetNextAttackDelay(float delay) return flNextAttack; } +// true - keep the amount of bpammo +// false - let take away bpammo +void CBasePlayerWeapon::InstantReload(bool bCanRefillBPAmmo) +{ + // if you already reload + //if (m_fInReload) + // return; + + if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + return; + + m_fInReload = FALSE; + m_pPlayer->m_flNextAttack = 0; + + // complete the reload. + int j = Q_min(iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + if (j == 0) + return; + + // Add them to the clip + m_iClip += j; + + if (!bCanRefillBPAmmo) { + m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j; + } + + m_pPlayer->TabulateAmmo(); +} + TYPEDESCRIPTION CWeaponBox::m_SaveData[] = { DEFINE_ARRAY(CWeaponBox, m_rgAmmo, FIELD_INTEGER, MAX_AMMO_SLOTS), @@ -2299,31 +2338,48 @@ void CArmoury::SetObjectCollisionBox() LINK_ENTITY_TO_CLASS(armoury_entity, CArmoury, CCSArmoury) -// true - keep the amount of bpammo -// false - let take away bpammo -void CBasePlayerWeapon::InstantReload(bool bCanRefillBPAmmo) +#ifdef REGAMEDLL_API +#define m_ItemInfoEx CSPlayerItem()->m_ItemInfo +#else +#define m_ItemInfoEx m_ItemInfoArray[m_iId] +#endif + +const char *CBasePlayerItem::pszAmmo1() const { - // if you already reload - //if (m_fInReload) - // return; - - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) - return; - - m_fInReload = FALSE; - m_pPlayer->m_flNextAttack = 0; - - // complete the reload. - int j = Q_min(iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); - if (j == 0) - return; - - // Add them to the clip - m_iClip += j; - - if (!bCanRefillBPAmmo) { - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j; - } - - m_pPlayer->TabulateAmmo(); + return m_ItemInfoEx.pszAmmo1; +} + +int CBasePlayerItem::iMaxAmmo1() const +{ + return m_ItemInfoEx.iMaxAmmo1; +} + +const char *CBasePlayerItem::pszAmmo2() const +{ + return m_ItemInfoEx.pszAmmo2; +} + +int CBasePlayerItem::iMaxAmmo2() const +{ + return m_ItemInfoEx.iMaxAmmo2; +} + +const char *CBasePlayerItem::pszName() const +{ + return m_ItemInfoEx.pszName; +} + +int CBasePlayerItem::iMaxClip() const +{ + return m_ItemInfoEx.iMaxClip; +} + +int CBasePlayerItem::iWeight() const +{ + return m_ItemInfoEx.iWeight; +} + +int CBasePlayerItem::iFlags() const +{ + return m_ItemInfoEx.iFlags; } diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index 24952125..1f9dd73b 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -286,11 +286,10 @@ public: void CheckRespawn(); public: - #ifdef REGAMEDLL_API CCSPlayerItem *CSPlayerItem() const; +#endif - int iPosition() const; const char *pszAmmo1() const; int iMaxAmmo1() const; const char *pszAmmo2() const; @@ -299,17 +298,6 @@ public: int iMaxClip() const; int iWeight() const; int iFlags() const; -#else - int iPosition() const { return m_ItemInfoArray[m_iId].iPosition; } - const char *pszAmmo1() const { return m_ItemInfoArray[m_iId].pszAmmo1; } - int iMaxAmmo1() const { return m_ItemInfoArray[m_iId].iMaxAmmo1; } - const char *pszAmmo2() const { return m_ItemInfoArray[m_iId].pszAmmo2; } - int iMaxAmmo2() const { return m_ItemInfoArray[m_iId].iMaxAmmo2; } - const char *pszName() const { return m_ItemInfoArray[m_iId].pszName; } - int iMaxClip() const { return m_ItemInfoArray[m_iId].iMaxClip; } - int iWeight() const { return m_ItemInfoArray[m_iId].iWeight; } - int iFlags() const { return m_ItemInfoArray[m_iId].iFlags; } -#endif public: static TYPEDESCRIPTION m_SaveData[]; @@ -332,6 +320,7 @@ inline CCSPlayerItem *CBasePlayerItem::CSPlayerItem() const class CBasePlayerWeapon: public CBasePlayerItem { public: + virtual void Spawn(); virtual int Save(CSave &save); virtual int Restore(CRestore &restore); @@ -1960,6 +1949,7 @@ extern short g_sModelIndexC4Glow; extern short g_sModelIndexRadio; extern MULTIDAMAGE gMultiDamage; +void WeaponsPrecache(); void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity); void AnnounceFlashInterval(float interval, float offset = 0); @@ -1976,5 +1966,4 @@ void EjectBrass(const Vector &vecOrigin, const Vector &vecLeft, const Vector &ve void EjectBrass2(const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype, entvars_t *pev); void AddAmmoNameToAmmoRegistry(const char *szAmmoname); void UTIL_PrecacheOtherWeapon(const char *szClassname); -void W_Precache(); BOOL CanAttack(float attack_time, float curtime, BOOL isPredicted); diff --git a/regamedll/dlls/world.cpp b/regamedll/dlls/world.cpp index 46f63f01..291aaae5 100644 --- a/regamedll/dlls/world.cpp +++ b/regamedll/dlls/world.cpp @@ -328,7 +328,7 @@ void CWorld::Precache() // player precaches // get weapon precaches - W_Precache(); + WeaponsPrecache(); ClientPrecache(); BotPrecache(); diff --git a/regamedll/dlls/wpn_shared/wpn_ak47.cpp b/regamedll/dlls/wpn_shared/wpn_ak47.cpp index adc38031..cfc8ac3a 100644 --- a/regamedll/dlls/wpn_shared/wpn_ak47.cpp +++ b/regamedll/dlls/wpn_shared/wpn_ak47.cpp @@ -13,8 +13,11 @@ void CAK47::Spawn() m_flAccuracy = 0.2f; m_iShotsFired = 0; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CAK47::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_aug.cpp b/regamedll/dlls/wpn_shared/wpn_aug.cpp index b7576e76..82fba6ae 100644 --- a/regamedll/dlls/wpn_shared/wpn_aug.cpp +++ b/regamedll/dlls/wpn_shared/wpn_aug.cpp @@ -13,8 +13,11 @@ void CAUG::Spawn() m_flAccuracy = 0.2f; m_iShotsFired = 0; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CAUG::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_awp.cpp b/regamedll/dlls/wpn_shared/wpn_awp.cpp index 462f1487..a4e9a4aa 100644 --- a/regamedll/dlls/wpn_shared/wpn_awp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_awp.cpp @@ -10,8 +10,12 @@ void CAWP::Spawn() SET_MODEL(ENT(pev), "models/w_awp.mdl"); m_iDefaultAmmo = AWP_DEFAULT_GIVE; + + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CAWP::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_c4.cpp b/regamedll/dlls/wpn_shared/wpn_c4.cpp index 1295cf22..ce4bb777 100644 --- a/regamedll/dlls/wpn_shared/wpn_c4.cpp +++ b/regamedll/dlls/wpn_shared/wpn_c4.cpp @@ -23,10 +23,13 @@ void CC4::Spawn() return; } + // Get ready to fall down FallInit(); SetThink(&CBasePlayerItem::FallThink); pev->nextthink = UTIL_WeaponTimeBase() + 0.1f; - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CC4::Precache() @@ -329,7 +332,7 @@ void CC4::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, f CGrenade::ShootSatchelCharge(pPlayer->pev, pev->origin, Vector(0, 0, 0)); CGrenade *pBomb = nullptr; - while ((pBomb = (CGrenade *)UTIL_FindEntityByClassname(pBomb, "grenade"))) + while ((pBomb = UTIL_FindEntityByClassname(pBomb, "grenade"))) { if (pBomb->m_bIsC4 && pBomb->m_flNextFreq == gpGlobals->time) { diff --git a/regamedll/dlls/wpn_shared/wpn_deagle.cpp b/regamedll/dlls/wpn_shared/wpn_deagle.cpp index ad6f7e59..363291ba 100644 --- a/regamedll/dlls/wpn_shared/wpn_deagle.cpp +++ b/regamedll/dlls/wpn_shared/wpn_deagle.cpp @@ -14,8 +14,11 @@ void CDEAGLE::Spawn() m_fMaxSpeed = DEAGLE_MAX_SPEED; m_flAccuracy = 0.9f; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CDEAGLE::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_elite.cpp b/regamedll/dlls/wpn_shared/wpn_elite.cpp index 32e0671e..42d30d18 100644 --- a/regamedll/dlls/wpn_shared/wpn_elite.cpp +++ b/regamedll/dlls/wpn_shared/wpn_elite.cpp @@ -12,8 +12,11 @@ void CELITE::Spawn() m_iDefaultAmmo = ELITE_DEFAULT_GIVE; m_flAccuracy = 0.88f; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CELITE::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_famas.cpp b/regamedll/dlls/wpn_shared/wpn_famas.cpp index 87eb7925..38009245 100644 --- a/regamedll/dlls/wpn_shared/wpn_famas.cpp +++ b/regamedll/dlls/wpn_shared/wpn_famas.cpp @@ -13,8 +13,11 @@ void CFamas::Spawn() m_iFamasShotsFired = 0; m_flFamasShoot = 0; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CFamas::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp b/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp index dd3157a8..552e2e19 100644 --- a/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp +++ b/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp @@ -13,8 +13,11 @@ void CFiveSeven::Spawn() m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; m_flAccuracy = 0.92f; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CFiveSeven::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_flashbang.cpp b/regamedll/dlls/wpn_shared/wpn_flashbang.cpp index 16111669..514ccfb1 100644 --- a/regamedll/dlls/wpn_shared/wpn_flashbang.cpp +++ b/regamedll/dlls/wpn_shared/wpn_flashbang.cpp @@ -16,9 +16,11 @@ void CFlashbang::Spawn() m_flReleaseThrow = -1.0f; m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; - // get ready to fall down. + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CFlashbang::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp b/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp index 6b9c4843..39d307aa 100644 --- a/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp +++ b/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp @@ -12,8 +12,11 @@ void CG3SG1::Spawn() m_iDefaultAmmo = G3SG1_DEFAULT_GIVE; m_flLastFire = 0; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CG3SG1::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_galil.cpp b/regamedll/dlls/wpn_shared/wpn_galil.cpp index 7205e5c3..baf3fc3c 100644 --- a/regamedll/dlls/wpn_shared/wpn_galil.cpp +++ b/regamedll/dlls/wpn_shared/wpn_galil.cpp @@ -11,8 +11,11 @@ void CGalil::Spawn() m_iDefaultAmmo = GALIL_DEFAULT_GIVE; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CGalil::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_glock18.cpp b/regamedll/dlls/wpn_shared/wpn_glock18.cpp index 077e353b..f7438370 100644 --- a/regamedll/dlls/wpn_shared/wpn_glock18.cpp +++ b/regamedll/dlls/wpn_shared/wpn_glock18.cpp @@ -17,8 +17,11 @@ void CGLOCK18::Spawn() m_flGlock18Shoot = 0; m_flAccuracy = 0.9f; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CGLOCK18::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_hegrenade.cpp b/regamedll/dlls/wpn_shared/wpn_hegrenade.cpp index a883f6c7..19fd20f0 100644 --- a/regamedll/dlls/wpn_shared/wpn_hegrenade.cpp +++ b/regamedll/dlls/wpn_shared/wpn_hegrenade.cpp @@ -16,9 +16,11 @@ void CHEGrenade::Spawn() m_flReleaseThrow = -1.0f; m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; - // get ready to fall down. + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CHEGrenade::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_knife.cpp b/regamedll/dlls/wpn_shared/wpn_knife.cpp index 34fe79fd..f8ddcf29 100644 --- a/regamedll/dlls/wpn_shared/wpn_knife.cpp +++ b/regamedll/dlls/wpn_shared/wpn_knife.cpp @@ -12,8 +12,11 @@ void CKnife::Spawn() m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; m_iClip = WEAPON_NOCLIP; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CKnife::Precache() @@ -46,10 +49,7 @@ int CKnife::GetItemInfo(ItemInfo *p) p->iSlot = 2; p->iPosition = 1; p->iId = WEAPON_KNIFE; - - // TODO: it is not being used - //p->iFlags = 0; - + p->iFlags = 0; p->iWeight = KNIFE_WEIGHT; return 1; diff --git a/regamedll/dlls/wpn_shared/wpn_m249.cpp b/regamedll/dlls/wpn_shared/wpn_m249.cpp index 0ad66dc7..cbf5f2a1 100644 --- a/regamedll/dlls/wpn_shared/wpn_m249.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m249.cpp @@ -13,8 +13,11 @@ void CM249::Spawn() m_flAccuracy = 0.2f; m_iShotsFired = 0; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CM249::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_m3.cpp b/regamedll/dlls/wpn_shared/wpn_m3.cpp index a522c6a8..81ae9b5f 100644 --- a/regamedll/dlls/wpn_shared/wpn_m3.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m3.cpp @@ -11,8 +11,11 @@ void CM3::Spawn() m_iDefaultAmmo = M3_DEFAULT_GIVE; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CM3::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_m4a1.cpp b/regamedll/dlls/wpn_shared/wpn_m4a1.cpp index e40ba98e..736234ff 100644 --- a/regamedll/dlls/wpn_shared/wpn_m4a1.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m4a1.cpp @@ -14,8 +14,11 @@ void CM4A1::Spawn() m_iShotsFired = 0; m_bDelayFire = true; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CM4A1::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_mac10.cpp b/regamedll/dlls/wpn_shared/wpn_mac10.cpp index 8f9a003a..b64eba86 100644 --- a/regamedll/dlls/wpn_shared/wpn_mac10.cpp +++ b/regamedll/dlls/wpn_shared/wpn_mac10.cpp @@ -13,8 +13,11 @@ void CMAC10::Spawn() m_flAccuracy = 0.15f; m_bDelayFire = false; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CMAC10::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp b/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp index 49633a41..3a8b9a93 100644 --- a/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp +++ b/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp @@ -13,8 +13,11 @@ void CMP5N::Spawn() m_flAccuracy = 0.0f; m_bDelayFire = false; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CMP5N::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_p228.cpp b/regamedll/dlls/wpn_shared/wpn_p228.cpp index 3fdfcd14..8c3d0c65 100644 --- a/regamedll/dlls/wpn_shared/wpn_p228.cpp +++ b/regamedll/dlls/wpn_shared/wpn_p228.cpp @@ -13,8 +13,11 @@ void CP228::Spawn() m_iDefaultAmmo = P228_DEFAULT_GIVE; m_flAccuracy = 0.9f; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CP228::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_p90.cpp b/regamedll/dlls/wpn_shared/wpn_p90.cpp index 1419778b..62299368 100644 --- a/regamedll/dlls/wpn_shared/wpn_p90.cpp +++ b/regamedll/dlls/wpn_shared/wpn_p90.cpp @@ -14,8 +14,11 @@ void CP90::Spawn() m_iShotsFired = 0; m_bDelayFire = false; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CP90::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_scout.cpp b/regamedll/dlls/wpn_shared/wpn_scout.cpp index 351d826a..39ab846f 100644 --- a/regamedll/dlls/wpn_shared/wpn_scout.cpp +++ b/regamedll/dlls/wpn_shared/wpn_scout.cpp @@ -11,8 +11,11 @@ void CSCOUT::Spawn() m_iDefaultAmmo = SCOUT_DEFAULT_GIVE; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CSCOUT::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_sg550.cpp b/regamedll/dlls/wpn_shared/wpn_sg550.cpp index f631b3f5..71982ed6 100644 --- a/regamedll/dlls/wpn_shared/wpn_sg550.cpp +++ b/regamedll/dlls/wpn_shared/wpn_sg550.cpp @@ -16,8 +16,11 @@ void CSG550::Spawn() m_flAccuracy = 0.2f; #endif + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CSG550::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_sg552.cpp b/regamedll/dlls/wpn_shared/wpn_sg552.cpp index 344203fd..062e80ee 100644 --- a/regamedll/dlls/wpn_shared/wpn_sg552.cpp +++ b/regamedll/dlls/wpn_shared/wpn_sg552.cpp @@ -13,8 +13,11 @@ void CSG552::Spawn() m_flAccuracy = 0.2f; m_iShotsFired = 0; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CSG552::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_smokegrenade.cpp b/regamedll/dlls/wpn_shared/wpn_smokegrenade.cpp index 80e6660d..d3b67f23 100644 --- a/regamedll/dlls/wpn_shared/wpn_smokegrenade.cpp +++ b/regamedll/dlls/wpn_shared/wpn_smokegrenade.cpp @@ -16,9 +16,11 @@ void CSmokeGrenade::Spawn() m_flReleaseThrow = -1; m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN; - // get ready to fall down. + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CSmokeGrenade::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_tmp.cpp b/regamedll/dlls/wpn_shared/wpn_tmp.cpp index fa8cc2ea..217d073a 100644 --- a/regamedll/dlls/wpn_shared/wpn_tmp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_tmp.cpp @@ -14,8 +14,11 @@ void CTMP::Spawn() m_iShotsFired = 0; m_bDelayFire = false; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CTMP::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_ump45.cpp b/regamedll/dlls/wpn_shared/wpn_ump45.cpp index 5a894268..fd7fec94 100644 --- a/regamedll/dlls/wpn_shared/wpn_ump45.cpp +++ b/regamedll/dlls/wpn_shared/wpn_ump45.cpp @@ -13,8 +13,11 @@ void CUMP45::Spawn() m_flAccuracy = 0.0f; m_bDelayFire = false; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CUMP45::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_usp.cpp b/regamedll/dlls/wpn_shared/wpn_usp.cpp index a2ee1169..efc3d3db 100644 --- a/regamedll/dlls/wpn_shared/wpn_usp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_usp.cpp @@ -13,8 +13,11 @@ void CUSP::Spawn() m_iDefaultAmmo = USP_DEFAULT_GIVE; m_flAccuracy = 0.92f; + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CUSP::Precache() diff --git a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp index d179bddb..c2931da9 100644 --- a/regamedll/dlls/wpn_shared/wpn_xm1014.cpp +++ b/regamedll/dlls/wpn_shared/wpn_xm1014.cpp @@ -11,9 +11,11 @@ void CXM1014::Spawn() m_iDefaultAmmo = XM1014_DEFAULT_GIVE; - // get ready to fall + // Get ready to fall down FallInit(); - CSPlayerItem()->SetItemInfo(&m_ItemInfoArray[m_iId]); + + // extend + CBasePlayerWeapon::Spawn(); } void CXM1014::Precache() diff --git a/regamedll/engine/unicode_strtools.cpp b/regamedll/engine/unicode_strtools.cpp index 1647da44..d7d5ad42 100644 --- a/regamedll/engine/unicode_strtools.cpp +++ b/regamedll/engine/unicode_strtools.cpp @@ -28,9 +28,275 @@ #include "precompiled.h" -//----------------------------------------------------------------------------- -// Purpose: determine if a uchar32 represents a valid Unicode code point -//----------------------------------------------------------------------------- +// Table for Q_iswprint +#pragma region PrintTable_Region +static const uint32_t g_isPrintTable[2048] = +{ + 0x00000200, 0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF, 0x00000000, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xF9FFFFFF, 0x00030003, 0x0000401F, + 0x00000000, 0x00000000, 0x00000000, 0x7CCF0000, 0xFFFFD7C0, 0xFFFFFFFB, 0xFFFFFFFF, 0xFFBFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFC03, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFE000F, 0xFE7FFFFF, 0xFFFFFFFE, 0x000006FF, 0x40000000, 0xFFFF0049, 0x001F07FF, + 0xC8003600, 0xFFFFFFFE, 0x000007FF, 0xFFFEFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x003FFFFF, 0x9FFFC060, + 0xFFFD3FFF, 0x0000FFFF, 0xFFFFE000, 0xFFFFFFFF, 0xFFFFFFFF, 0x0002003F, 0xFFFFFFFF, 0x07B007FF, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFFFFFFF0, 0x23FFFFFF, 0xFF010000, 0xF807FFF3, 0xFFF99FE0, 0x23C5FDFF, 0xB0004000, 0x0003FFC3, + 0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001CFFC0, 0xFFFBBFE0, 0x23EDFDFF, 0x00010000, 0x0000FFC3, + 0xFFF99FE0, 0x23EDFDFF, 0xB0000000, 0x0002FFC3, 0xD63DC7E8, 0x03FFC718, 0x00010000, 0x0000FFC0, + 0xFFFDDFE0, 0x23EFFDFF, 0x03000000, 0x0000FFC3, 0xFFFDDFE0, 0x23EFFDFF, 0x40000000, 0x0000FFC3, + 0xFFFDDFE0, 0x23FFFDFF, 0x00000000, 0xFC00FFC3, 0xFC7FFFE0, 0x2FFBFFFF, 0x0000007F, 0x00100000, + 0xFFFFFFFE, 0x07FFFFFF, 0x0FFFFFFF, 0x00000000, 0xFEF02596, 0x200DECAE, 0x33FF005F, 0x00000000, + 0x0007FFF1, 0x3C0003FF, 0xFFFFFEFF, 0x00001FFF, 0x00000F20, 0x00000000, 0x001F0000, 0x00000000, + 0xFFFFFFFF, 0x800007FF, 0x3C3FFFFF, 0xFFE1C062, 0x03FF4003, 0xFFFFFFFF, 0xFFFF003F, 0x1FFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFF07, 0xFFFFFFFF, 0x03FFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0x3D7F3DFF, 0xFFFFFFFF, 0xFFFF3DFF, 0x7F3DFFFF, 0xFF7FFF3D, 0xFFFFFFFF, + 0xFF3DFFFF, 0xFFFFFFFF, 0x07FFFFFF, 0x000001FE, 0x0000FFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x001FFFFF, + 0xFFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x007FFFFF, 0x1FFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0x0001FFFF, + 0x0003DFFF, 0x0063FFFF, 0x0003FFFF, 0x0001DFFF, 0xFFFFFFFF, 0x000FFFFF, 0x17F00000, 0x000003FF, + 0x03FF07FF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00FFFFFF, 0xFFFFFFFF, 0x000005FF, 0x00000000, 0x00000000, + 0x1FFFFFFF, 0x00000000, 0xFFFFFFF0, 0x001F3FFF, 0xFFFFFFFF, 0x000003FF, 0xC3FF00FE, 0x00000000, + 0xC07FFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFFFFFFE0, 0x000FFFFF, 0xFFFF0FE0, 0x00000001, 0xFFFFFFF8, 0x03FFC001, 0x00000000, 0x00000000, + 0xFFFFFFFF, 0xF800000F, 0xFFFFE3FF, 0xFFFFFFFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x00000000, 0x00000000, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF, 0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF, + 0xFFFF0000, 0xFFFF00FF, 0x7FFBFFEF, 0xE0020000, 0x001F6000, 0x00000000, 0x00000000, 0x00000000, + 0x3E2FFC84, 0xF3FFBD50, 0x000043E0, 0xFFFFFFFF, 0x000001FF, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000600, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x003FFF00, 0x00000000, 0x00000000, 0x00000060, 0x0000FFC0, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x01FFFFF8, 0x00000000, 0x0F000000, 0x30000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFFFFFFFF, 0xFFFF7FFF, 0x7FFFFFFF, 0x3FFEFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xDE00001F, + 0xFFFFFFFF, 0xFFFF003F, 0xFFFFFFFF, 0x0000803F, 0x007FFFFF, 0x7F7F7F7F, 0x7F7F7F7F, 0x00000000, + 0xFFFFFFFF, 0x00017FFF, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFFF3FFEF, 0x3F3F03FE, 0xFFFFFFFE, 0xFFFFFFFF, 0xE07FFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFE0, 0xFFFE3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000, 0x00000000, + 0x00000000, 0xFFFFFFFC, 0xFFFFFFFF, 0xFFFFFFFF, 0x000018FF, 0x00000000, 0x00000000, 0xF8000000, + 0xFFFFF7BB, 0x00000007, 0xFFFFFFFF, 0x00FFFFFF, 0xFFFFFFFC, 0x000FFFFF, 0x03FFC000, 0x00000000, + 0xFFFFFFFF, 0xFFFFC03F, 0x8000007F, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFFFFFFFF, 0x000001FF, 0xF3FF0FF7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 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FFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFF3FFF, 0xFFFFFFFF, 0xFFFF07FF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF, 0x00000000, + 0xA0F8007F, 0x5F7FFDFF, 0xFFFFFFDB, 0xFFFFFFFF, 0xFFFFFFFF, 0x0003FFFF, 0xFFF80000, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, + 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFF0000, 0xFFFFFFFF, 0xFFFCFFFF, 0xFFFFFFFF, 0x000000FF, 0x0FFF0000, + 0x03FF0000, 0xFFFF0000, 0xFFF7FFFF, 0xFFDF0D0B, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x9FFFFFFF, + 0x8FFFF7EE, 0xBFFFFFFF, 0xAFFFFFFE, 0xFFFFFFFF, 0xFFFFFFFF, 0x7FFFFFFF, 0x1CFCFCFC, 0x00000000 +}; +#pragma endregion + +bool Q_iswprint(uchar16 c) +{ + return (g_isPrintTable[c / 32] & (1 << (c % 32))) != 0; +} + +// Determine if a uchar32 represents a valid Unicode code point bool Q_IsValidUChar32(uchar32 uVal) { // Values > 0x10FFFF are explicitly invalid; ditto for UTF-16 surrogate halves, @@ -38,249 +304,290 @@ bool Q_IsValidUChar32(uchar32 uVal) return (uVal < 0x110000u) && ((uVal - 0x00D800u) > 0x7FFu) && ((uVal & 0xFFFFu) < 0xFFFEu) && ((uVal - 0x00FDD0u) > 0x1Fu); } -int Q_UTF32ToUChar32(const uchar32 *pUTF32, uchar32 &uVal, bool &bErr) +// Returns true if a wide character is a "mean" space; that is, +// if it is technically a space or punctuation, but causes disruptive +// behavior when used in names, web pages, chat windows, etc. +// +// Characters in this set are removed from the beginning and/or end of strings +// by Q_AggressiveStripPrecedingAndTrailingWhitespaceW() +bool Q_IsMeanSpaceW(uchar16 wch) { - if (Q_IsValidUChar32(pUTF32[0])) + bool bIsMean = false; + + switch (wch) { - uVal = pUTF32[0]; - bErr = false; - return 1; - } - else if (pUTF32[0] - 55296 >= 0x400 || (pUTF32[1] - 56320) >= 0x400) - { - uVal = 63; - bErr = true; - return 1; - } - else - { - uVal = pUTF32[1] + ((uchar32)(pUTF32[0] - 55287) << 10); - if (Q_IsValidUChar32(uVal)) - { - bErr = false; - } - else - { - uVal = 63; - bErr = true; - } - return 2; + case 0x0082: // BREAK PERMITTED HERE + case 0x0083: // NO BREAK PERMITTED HERE + case 0x00A0: // NO-BREAK SPACE + case 0x034F: // COMBINING GRAPHEME JOINER + case 0x2000: // EN QUAD + case 0x2001: // EM QUAD + case 0x2002: // EN SPACE + case 0x2003: // EM SPACE + case 0x2004: // THICK SPACE + case 0x2005: // MID SPACE + case 0x2006: // SIX SPACE + case 0x2007: // FIGURE SPACE + case 0x2008: // PUNCTUATION SPACE + case 0x2009: // THIN SPACE + case 0x200A: // HAIR SPACE + case 0x200B: // ZERO-WIDTH SPACE + case 0x200C: // ZERO-WIDTH NON-JOINER + case 0x200D: // ZERO WIDTH JOINER + case 0x2028: // LINE SEPARATOR + case 0x2029: // PARAGRAPH SEPARATOR + case 0x202F: // NARROW NO-BREAK SPACE + case 0x2060: // WORD JOINER + case 0x3000: // IDEOGRAPHIC SPACE + case 0xFEFF: // ZERO-WIDTH NO BREAK SPACE + case 0xFFFC: // OBJECT REPLACEMENT CHARACTER + bIsMean = true; + break; } + + return bIsMean; } -int Q_UChar32ToUTF32Len(uchar32 uVal) +bool Q_IsUnprintableW(uchar16 c) { - return (uVal > 0xFFFF) ? 2 : 1; +#ifdef UNICODE_FIXES + return !Q_iswprint(c); +#else + switch (c) + { + case 0x202A: + case 0x202B: + case 0x202C: + case 0x202D: + case 0x202E: + case 0x206A: + case 0x206B: + case 0x206C: + case 0x206D: + case 0x206E: + case 0x206F: + return true; + + default: + return false; + } +#endif // UNICODE_FIXES +} + +// Returns false if UTF-8 string contains invalid sequences. +bool Q_UnicodeValidate(const char *pUTF8) +{ + bool bError = false; + while (*pUTF8) + { + uchar32 uVal; + // Our UTF-8 decoder silently fixes up 6-byte CESU-8 (improperly re-encoded UTF-16) sequences. + // However, these are technically not valid UTF-8. So if we eat 6 bytes at once, it's an error. + int nCharSize = Q_UTF8ToUChar32(pUTF8, uVal, bError); + if (bError || nCharSize == 6) + return false; + pUTF8 += nCharSize; + } + + return true; +} + +// Strips trailing whitespace; returns pointer inside string just past +// any leading whitespace. +// +// bAggressive = true causes this function to also check for "mean" spaces, +// which we don't want in persona names or chat strings as they're disruptive +// to the user experience. +static uchar16 *StripWhitespaceWorker(uchar16 *pwch, int cchLength, bool *pbStrippedWhitespace, bool bAggressive) +{ + // walk backwards from the end of the string, killing any whitespace + *pbStrippedWhitespace = false; + + uchar16 *pwchEnd = pwch + cchLength; + while (--pwchEnd >= pwch) + { + if (!iswspace(*pwchEnd) && (!bAggressive || !Q_IsMeanSpaceW(*pwchEnd))) + break; + + *pwchEnd = 0; + *pbStrippedWhitespace = true; + } + + // walk forward in the string + while (pwch < pwchEnd) + { + if (!iswspace(*pwch)) + break; + + *pbStrippedWhitespace = true; + pwch++; + } + + return pwch; +} + +static uchar16 *StripUnprintableWorker(uchar16 *pwch, bool *pStripped) +{ + uchar16 *rPos = pwch; + uchar16 *wPos = pwch; + *pStripped = false; + + while(*rPos) + { + uchar16 cc = *rPos; + if (*rPos >= 0x20u && !Q_IsUnprintableW(cc) && cc != 0x2026) + { + *wPos = cc; + wPos++; + } + + rPos++; + } + + *wPos = 0; + *pStripped = rPos != wPos; + return pwch; +} + +// Strips leading and trailing whitespace +bool Q_StripPrecedingAndTrailingWhitespace(char *pch) +{ + int cch = Q_strlen(pch); + + // Early out and don't convert if we don't have any chars or leading/trailing ws. + if ((cch < 1) || (!isspace((unsigned char)pch[0]) && !isspace((unsigned char)pch[cch - 1]))) + return false; + + // convert to unicode + int cubDest = (cch + 1) * sizeof(uchar16); + uchar16 *pwch = (uchar16 *)alloca(cubDest); + int cwch = (unsigned int)Q_UTF8ToUTF16(pch, (uchar16 *)pwch, cubDest, _STRINGCONVERTFLAG_ASSERT) >> 1; + + bool bStrippedWhitespace = false; + pwch = StripWhitespaceWorker(pwch, cwch - 1, &bStrippedWhitespace, false /* not aggressive */); + + // copy back, if necessary + if (bStrippedWhitespace) + { + Q_UTF16ToUTF8(pwch, pch, cch, STRINGCONVERT_ASSERT_REPLACE); + } + + return bStrippedWhitespace; +} + +// Strips leading and trailing whitespace, +// also all non-printable characters (ie. zero-width no-break space) from a string. +bool Q_StripUnprintableAndSpace(char *pch) +{ + // duplicate on stack + int cch = Q_strlen(pch); + int cubDest = (cch + 1) * sizeof(uchar16); + uchar16 *pwch = (uchar16 *)alloca(cubDest); + int cwch = (unsigned int)Q_UTF8ToUTF16(pch, (uchar16 *)pwch, cubDest, _STRINGCONVERTFLAG_ASSERT) >> 1; + + bool bStrippedAny = false; + pwch = StripUnprintableWorker(pwch, &bStrippedAny); + + bool bStrippedWhitespace = false; + pwch = StripWhitespaceWorker(pwch, cwch - 1, &bStrippedWhitespace, true /* is aggressive */); + + // copy back, if necessary + if (bStrippedWhitespace || bStrippedAny) + { + Q_UTF16ToUTF8(pwch, pch, cch, STRINGCONVERT_ASSERT_REPLACE); + } + + return bStrippedAny; } int Q_UChar32ToUTF32(uchar32 uVal, uchar32 *pUTF32) { if (uVal <= 0xFFFF) { - pUTF32[0] = uVal; + pUTF32[0] = (uchar32)uVal; return 1; } - else + + pUTF32[0] = (uchar32)((uVal - 0x10000) >> 10) | 0xD800; + pUTF32[1] = (uchar32)(uVal & 0x3FF) | 0xDC00; + return 2; +} + +int Q_UChar32ToUTF32Len(uchar32 uVal) +{ + if (uVal <= 0xFFFF) + return 1; + + return 2; +} + +// Encode Unicode code point as UTF-16, returns number of elements written +int Q_UChar32ToUTF16(uchar32 uVal, uchar16 *pUTF16Out) +{ + if (uVal <= 0xFFFF) { - pUTF32[1] = uVal & 0x3FF | 0xDC00; - pUTF32[0] = ((uVal - 0x10000) >> 10) | 0xD800; + pUTF16Out[0] = (uchar16)uVal; + return 1; + } + + pUTF16Out[0] = (uchar16)((uVal - 0x10000) >> 10) | 0xD800; + pUTF16Out[1] = (uchar16)(uVal & 0x3FF) | 0xDC00; + return 2; +} + +// Return number of UTF-16 elements required to encode a Unicode code point +int Q_UChar32ToUTF16Len(uchar32 uVal) +{ + if (uVal <= 0xFFFF) + return 1; + + return 2; +} + +// Encode Unicode code point as UTF-8, returns number of bytes written +int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out) +{ + if (uVal <= 0x7F) + { + pUTF8Out[0] = (unsigned char)uVal; + return 1; + } + + if (uVal <= 0x7FF) + { + pUTF8Out[0] = (unsigned char)(uVal >> 6) | 0xC0; + pUTF8Out[1] = (unsigned char)(uVal & 0x3F) | 0x80; return 2; } -} -template< - typename T_IN, - typename T_OUT, - bool UNK, - qboolean(*IN_TO_UCHAR32)(const T_IN *pUTF8, uchar32 &uValueOut, bool &bErrorOut), - int(UCHAR32_TO_OUT_LEN)(uchar32 uVal), - int(UCHAR32_TO_OUT)(uchar32 uVal, T_OUT *pUTF8Out) -> -int Q_UnicodeConvertT(const T_IN *pIn, T_OUT *pOut, int nOutBytes, EStringConvertErrorPolicy ePolicy) -{ - if (nOutBytes == 0) - return 0; - - int nOut = 0; - if (pOut) + if (uVal <= 0xFFFF) { - int nMaxOut = nOutBytes / sizeof(T_OUT) - 1; // print symbols count - - while (*pIn) - { - bool bErr; - uchar32 uVal; - pIn += IN_TO_UCHAR32(pIn, uVal, bErr); - int nOutElems = UCHAR32_TO_OUT_LEN(uVal); - if (nOutElems + nOut > nMaxOut) - break; - nOut += UCHAR32_TO_OUT(uVal, &pOut[nOut]); - if (bErr) - { - if (ePolicy & STRINGCONVERT_SKIP) - { - nOut -= nOutElems; - } - else if (ePolicy & STRINGCONVERT_FAIL) - { - pOut[0] = 0; - return 0; - } - - } - } - - pOut[nOut] = 0; - } - else - { - while (*pIn) - { - bool bErr; - uchar32 uVal; - pIn += IN_TO_UCHAR32(pIn, uVal, bErr); - int nOutElems = UCHAR32_TO_OUT_LEN(uVal); - if (bErr) - { - if (ePolicy & STRINGCONVERT_SKIP) - { - nOut -= nOutElems; - } - else if (ePolicy & STRINGCONVERT_FAIL) - { -#ifndef REGAMEDLL_FIXES - pOut[0] = 0; //FIXME: pOut is always null there - //TODO: V522 Dereferencing of the null pointer 'pOut' might take place. -#endif - return 0; - } - - } - } + pUTF8Out[0] = (unsigned char)(uVal >> 12) | 0xE0; + pUTF8Out[1] = (unsigned char)(uVal >> 6) & 0x3F | 0x80; + pUTF8Out[2] = (unsigned char)(uVal & 0x3F) | 0x80; + return 3; } - return (nOut + 1) * sizeof(T_OUT); + pUTF8Out[0] = (unsigned char)((uVal >> 18) & 0x07) | 0xF0; + pUTF8Out[1] = (unsigned char)((uVal >> 12) & 0x3F) | 0x80; + pUTF8Out[2] = (unsigned char)((uVal >> 6) & 0x3F) | 0x80; + pUTF8Out[3] = (unsigned char)(uVal & 0x3F) | 0x80; + return 4; } +// Return number of UTF-8 bytes required to encode a Unicode code point int Q_UChar32ToUTF8Len(uchar32 uVal) { if (uVal <= 0x7F) return 1; - if (uVal > 0x7FF) - return (uVal > 0xFFFF) + 3; - else + if (uVal <= 0x7FF) return 2; -} -int Q_UChar32ToUTF16Len(uchar32 uVal) -{ - return (uVal > 0xFFFF) ? 2 : 1; -} - -int Q_UChar32ToUTF16(uchar32 uVal, uchar16 *pUTF16Out) -{ if (uVal <= 0xFFFF) - { - pUTF16Out[0] = uVal; - return 1; - } - else - { - pUTF16Out[1] = uVal & 0x3FF | 0xDC00; - pUTF16Out[0] = ((uVal - 0x10000) >> 10) | 0xD800; - return 2; - } -} - -int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out) -{ - if (uVal <= 0x7F) - { - *pUTF8Out = uVal; - return 1; - } - else if (uVal <= 0x7FF) - { - *pUTF8Out = (uVal >> 6) | 0xC0; - pUTF8Out[1] = uVal & 0x3F | 0x80; - return 2; - } - else if (uVal <= 0xFFFF) - { - *pUTF8Out = (uVal >> 12) | 0xE0; - pUTF8Out[2] = uVal & 0x3F | 0x80; - pUTF8Out[1] = (uVal >> 6) & 0x3F | 0x80; return 3; - } - else - { - *pUTF8Out = (uVal >> 18) & 7 | 0xF0; - pUTF8Out[1] = (uVal >> 12) & 0x3F | 0x80; - pUTF8Out[3] = uVal & 0x3F | 0x80; - pUTF8Out[2] = (uVal >> 6) & 0x3F | 0x80; - return 4; - } -} -int Q_UTF16ToUChar32(const uchar16 *pUTF16, uchar32 &uValueOut, bool &bErrorOut) -{ - if (Q_IsValidUChar32(pUTF16[0])) - { - uValueOut = pUTF16[0]; - bErrorOut = false; - return 1; - } - else if (pUTF16[0] - 55296 >= 0x400 || (pUTF16[1] - 56320) >= 0x400) - { - uValueOut = 63; - bErrorOut = true; - return 1; - } - else - { - uValueOut = pUTF16[1] + ((uchar32)(pUTF16[0] - 55287) << 10); - if (Q_IsValidUChar32(uValueOut)) - { - bErrorOut = false; - } - else - { - uValueOut = 63; - bErrorOut = true; - } - return 2; - } -} - -int Q_UTF8ToUTF16(const char *pUTF8, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) -{ - return Q_UnicodeConvertT(pUTF8, pUTF16, cubDestSizeInBytes, ePolicy); -} - -int Q_UTF8ToUTF32(const char *pUTF8, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) -{ - return Q_UnicodeConvertT(pUTF8, pUTF32, cubDestSizeInBytes, ePolicy); -} - -int Q_UTF16ToUTF8(const uchar16 *pUTF16, char *pUTF8, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) -{ - return Q_UnicodeConvertT(pUTF16, pUTF8, cubDestSizeInBytes, ePolicy); -} - -NOXREF int Q_UTF16ToUTF32(const uchar16 *pUTF16, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) -{ - return Q_UnicodeConvertT(pUTF16, pUTF32, cubDestSizeInBytes, ePolicy); -} - -int Q_UTF32ToUTF8(const uchar32 *pUTF32, char *pUTF8, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) -{ - return Q_UnicodeConvertT(pUTF32, pUTF8, cubDestSizeInBytes, ePolicy); -} - -NOXREF int Q_UTF32ToUTF16(const uchar32 *pUTF32, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) -{ - return Q_UnicodeConvertT(pUTF32, pUTF16, cubDestSizeInBytes, ePolicy); + return 4; } // Decode one character from a UTF-8 encoded string. Treats 6-byte CESU-8 sequences @@ -330,7 +637,6 @@ int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut) uMinValue = 0x10000; // 11110... four-byte lead byte. fall through to finished. - decodeFinished: if (uValue >= uMinValue && Q_IsValidUChar32(uValue)) { @@ -339,6 +645,7 @@ int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut) bErrorOut = false; return nBytes; } + decodeError: uValueOut = '?'; bErrorOut = true; @@ -353,219 +660,228 @@ int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut) nBytes = 6; uMinValue = 0x10000; } + goto decodeFinished; } -//----------------------------------------------------------------------------- -// Purpose: Returns false if UTF-8 string contains invalid sequences. -//----------------------------------------------------------------------------- -qboolean Q_UnicodeValidate(const char *pUTF8) +// Decode one character from a UTF-16 encoded string +int Q_UTF16ToUChar32(const uchar16 *pUTF16, uchar32 &uValueOut, bool &bErrorOut) { - bool bError = false; - while (*pUTF8) + if (Q_IsValidUChar32(pUTF16[0])) { - uchar32 uVal; - // Our UTF-8 decoder silently fixes up 6-byte CESU-8 (improperly re-encoded UTF-16) sequences. - // However, these are technically not valid UTF-8. So if we eat 6 bytes at once, it's an error. - int nCharSize = Q_UTF8ToUChar32(pUTF8, uVal, bError); - if (bError || nCharSize == 6) - return false; - pUTF8 += nCharSize; + uValueOut = pUTF16[0]; + bErrorOut = false; + return 1; + } + else if (pUTF16[0] - 0xD800u < 0x400u && (pUTF16[1] - 0xDC00u) < 0x400u) + { + // Valid surrogate pair, but maybe not encoding a valid Unicode code point... + uchar32 uVal = 0x010000 + ((pUTF16[0] - 0xD800u) << 10) + (pUTF16[1] - 0xDC00u); + if (Q_IsValidUChar32(uValueOut)) + { + uValueOut = uVal; + bErrorOut = false; + return 2; + } + else + { + uValueOut = '?'; + bErrorOut = true; + return 2; + } + + } + else + { + uValueOut = '?'; + bErrorOut = true; + return 1; } - return true; } -NOXREF int Q_UnicodeLength(const char *pUTF8) +// Decode one character from a UTF-32 encoded string +int Q_UTF32ToUChar32(const uchar32 *pUTF32, uchar32 &uValueOut, bool &bErrorOut) +{ + if (Q_IsValidUChar32(pUTF32[0])) + { + uValueOut = pUTF32[0]; + bErrorOut = false; + return 1; + } + else if (pUTF32[0] - 0xD800u < 0x400u && (pUTF32[1] - 0xDC00u) < 0x400u) + { + // Valid surrogate pair, but maybe not encoding a valid Unicode code point... + uchar32 uVal = 0x010000 + ((pUTF32[0] - 0xD800u) << 10) + (pUTF32[1] - 0xDC00u); + if (Q_IsValidUChar32(uVal)) + { + uValueOut = uVal; + bErrorOut = false; + return 2; + } + else + { + uValueOut = '?'; + bErrorOut = true; + return 2; + } + } + else + { + uValueOut = '?'; + bErrorOut = true; + return 1; + } +} + +// A generic Unicode processing loop: decode one character from input to uchar32, handle errors, encode uchar32 to output +template +int Q_UnicodeConvertT(const SrcType *pIn, int nInChars, DstType *pOut, int nOutBytes, EStringConvertErrorPolicy ePolicy) +{ + if (nOutBytes == 0) + return 0; + + int nOut = 0; + if (!pOut) + { + while (bStopAtNull ? (*pIn) : (nInChars-- > 0)) + { + uchar32 uVal; + bool bErr = false; // Initialize in order to avoid /analyze warnings. + + pIn += DecodeSrc(pIn, uVal, bErr); + nOut += EncodeDstLen(uVal); + + if (bErr) + { +#ifdef _DEBUG + AssertMsg(!(ePolicy & _STRINGCONVERTFLAG_ASSERT), "invalid Unicode byte sequence"); +#endif + if (ePolicy & _STRINGCONVERTFLAG_SKIP) + { + nOut -= EncodeDstLen(uVal); + } + else if (ePolicy & _STRINGCONVERTFLAG_FAIL) + { + return 0; + } + } + } + } + else + { + int nOutElems = nOutBytes / sizeof(DstType); + if (nOutElems <= 0) + { + pOut[0] = 0; + return 0; + } + + int nMaxOut = nOutElems - 1; // print symbols count + while (bStopAtNull ? (*pIn) : (nInChars-- > 0)) + { + uchar32 uVal; + bool bErr = false; // Initialize in order to avoid /analyze warnings. + + pIn += DecodeSrc(pIn, uVal, bErr); + + if (nOut + EncodeDstLen(uVal) > nMaxOut) + break; + + nOut += EncodeDst(uVal, pOut + nOut); + if (bErr) + { +#ifdef _DEBUG + AssertMsg(!(ePolicy & _STRINGCONVERTFLAG_ASSERT), "invalid Unicode byte sequence"); +#endif + if (ePolicy & _STRINGCONVERTFLAG_SKIP) + { + nOut -= EncodeDstLen(uVal); + } + else if (ePolicy & _STRINGCONVERTFLAG_FAIL) + { + pOut[0] = 0; + return 0; + } + + } + } + + pOut[nOut] = 0; + } + + return (nOut + 1) * sizeof(DstType); +} + +// Perform conversion. Returns number of *bytes* required if output pointer is NULL. +int Q_UTF8ToUTF16(const char *pUTF8, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) +{ + return Q_UnicodeConvertT(pUTF8, 0, pUTF16, cubDestSizeInBytes, ePolicy); +} + +// Perform conversion. Returns number of *bytes* required if output pointer is NULL. +int Q_UTF8ToUTF32(const char *pUTF8, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) +{ + return Q_UnicodeConvertT(pUTF8, 0, pUTF32, cubDestSizeInBytes, ePolicy); +} + +// Perform conversion. Returns number of *bytes* required if output pointer is NULL. +int Q_UTF16ToUTF8(const uchar16 *pUTF16, char *pUTF8, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) +{ + return Q_UnicodeConvertT(pUTF16, 0, pUTF8, cubDestSizeInBytes, ePolicy); +} + +// Perform conversion. Returns number of *bytes* required if output pointer is NULL. +int Q_UTF16ToUTF32(const uchar16 *pUTF16, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) +{ + return Q_UnicodeConvertT(pUTF16, 0, pUTF32, cubDestSizeInBytes, ePolicy); +} + +// Perform conversion. Returns number of *bytes* required if output pointer is NULL. +int Q_UTF32ToUTF8(const uchar32 *pUTF32, char *pUTF8, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) +{ + return Q_UnicodeConvertT(pUTF32, 0, pUTF8, cubDestSizeInBytes, ePolicy); +} + +// Perform conversion. Returns number of *bytes* required if output pointer is NULL. +int Q_UTF32ToUTF16(const uchar32 *pUTF32, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy) +{ + return Q_UnicodeConvertT(pUTF32, 0, pUTF16, cubDestSizeInBytes, ePolicy); +} + +// Repair a UTF-8 string by removing or replacing invalid seqeuences. Returns non-zero on success. +int Q_UnicodeRepair(char *pUTF8) +{ + return Q_UnicodeConvertT(pUTF8, 0, pUTF8, 65535, STRINGCONVERT_SKIP); +} + +// Returns number of Unicode code points (aka glyphs / characters) encoded in the UTF-8 string +int Q_UnicodeLength(const char *pUTF8) { int nChars = 0; - while (*pUTF8) { bool bError; uchar32 uVal; - pUTF8 += Q_UTF8ToUChar32(pUTF8, uVal, bError); - - ++nChars; + nChars++; } return nChars; } -NOXREF char *Q_UnicodeAdvance(char *pUTF8, int nChars) +// Advance a UTF-8 string pointer by a certain number of Unicode code points, stopping at end of string +char *Q_UnicodeAdvance(char *pUTF8, int nChars) { - uchar32 uVal = 0; - bool bError = false; - while (nChars > 0 && *pUTF8) { + bool bError; + uchar32 uVal; pUTF8 += Q_UTF8ToUChar32(pUTF8, uVal, bError); - --nChars; + nChars--; } return pUTF8; } - -//----------------------------------------------------------------------------- -// Purpose: returns true if a wide character is a "mean" space; that is, -// if it is technically a space or punctuation, but causes disruptive -// behavior when used in names, web pages, chat windows, etc. -// -// characters in this set are removed from the beginning and/or end of strings -// by Q_AggressiveStripPrecedingAndTrailingWhitespaceW() -//----------------------------------------------------------------------------- -bool Q_IsMeanSpaceW(uchar32 wch) -{ - bool bIsMean = false; - - switch (wch) - { - case 0x0082: // BREAK PERMITTED HERE - case 0x0083: // NO BREAK PERMITTED HERE - case 0x00A0: // NO-BREAK SPACE - case 0x034F: // COMBINING GRAPHEME JOINER - case 0x2000: // EN QUAD - case 0x2001: // EM QUAD - case 0x2002: // EN SPACE - case 0x2003: // EM SPACE - case 0x2004: // THICK SPACE - case 0x2005: // MID SPACE - case 0x2006: // SIX SPACE - case 0x2007: // figure space - case 0x2008: // PUNCTUATION SPACE - case 0x2009: // THIN SPACE - case 0x200A: // HAIR SPACE - case 0x200B: // ZERO-WIDTH SPACE - case 0x200C: // ZERO-WIDTH NON-JOINER - case 0x200D: // ZERO WIDTH JOINER - case 0x2028: // LINE SEPARATOR - case 0x2029: // PARAGRAPH SEPARATOR - case 0x202F: // NARROW NO-BREAK SPACE - case 0x2060: // word joiner - case 0xFEFF: // ZERO-WIDTH NO BREAK SPACE - case 0xFFFC: // OBJECT REPLACEMENT CHARACTER - bIsMean = true; - break; - } - - return bIsMean; -} - -bool Q_IsDeprecatedW(uchar16 wch) -{ - bool bIsDeprecated = false; - - switch (wch) - { - case 0x202A: - case 0x202B: - case 0x202C: - case 0x202D: - case 0x202E: - case 0x206A: - case 0x206B: - case 0x206C: - case 0x206D: - case 0x206E: - case 0x206F: - bIsDeprecated = true; - break; - } - - return bIsDeprecated; -} - -//----------------------------------------------------------------------------- -// Purpose: strips trailing whitespace; returns pointer inside string just past -// any leading whitespace. -// -// bAggresive = true causes this function to also check for "mean" spaces, -// which we don't want in persona names or chat strings as they're disruptive -// to the user experience. -//----------------------------------------------------------------------------- -static uchar16 *StripWhitespaceWorker(uchar16 *pwch, int cchLength, bool *pbStrippedWhitespace) -{ - // walk backwards from the end of the string, killing any whitespace - *pbStrippedWhitespace = false; - - uchar16 *pwchEnd = pwch + cchLength; - while (--pwchEnd >= pwch) - { - if (!iswspace(*pwchEnd) && !Q_IsMeanSpaceW(*pwchEnd)) - break; - - *pwchEnd = 0; - *pbStrippedWhitespace = true; - } - - // walk forward in the string - while (pwch < pwchEnd) - { - if (!iswspace(*pwch)) - break; - - *pbStrippedWhitespace = true; - pwch++; - } - - return pwch; -} - -uchar16 *StripUnprintableWorker(uchar16 *pwch, bool *pbStrippedAny) -{ - uchar16 *pwchSource = pwch; - uchar16 *pwchDest = pwch; - *pbStrippedAny = 0; - - while (*pwchSource) - { - uchar16 cc = *pwchSource; - if (*pwchSource >= 0x20u && !Q_IsDeprecatedW(cc) && cc != 0x2026) - { - *pwchDest = cc; - ++pwchDest; - } - ++pwchSource; - } - - *pwchDest = 0; - *pbStrippedAny = pwchSource != pwchDest; - return pwch; -} - -qboolean Q_StripUnprintableAndSpace(char *pch) -{ - bool bStrippedAny; - bool bStrippedWhitespace; - - int cch = Q_strlen(pch); - int cubDest = (cch + 1) * sizeof(uchar16); - - uchar16 *pwch_alloced = (uchar16 *)alloca(cubDest); - bStrippedAny = false; - bStrippedWhitespace = false; - - // TODO: here is using Q_UTF8ToUTF32 by DWARF - int cwch = (unsigned int)Q_UTF8ToUTF16(pch, (uchar16 *)pwch_alloced, cubDest, _STRINGCONVERTFLAG_ASSERT) >> 1; - uchar16 *pwch = StripUnprintableWorker(pwch_alloced, &bStrippedAny); - pwch = StripWhitespaceWorker(pwch, cwch - 1, &bStrippedWhitespace); - if (bStrippedWhitespace || bStrippedAny) - { - // TODO: here is using Q_UTF32ToUTF8 by DWARF - Q_UTF16ToUTF8(pwch, pch, cch, STRINGCONVERT_ASSERT_REPLACE); - } - - return bStrippedAny; -} - -NOXREF qboolean V_UTF8ToUChar32(const char *pUTF8_, uchar32 *uValueOut) -{ - bool bError = false; - Q_UTF8ToUChar32(pUTF8_, *uValueOut, bError); - return bError; -} - -NOXREF int Q_UnicodeRepair(char *pUTF8) -{ - return Q_UnicodeConvertT(pUTF8, pUTF8, 65535, STRINGCONVERT_SKIP); -} diff --git a/regamedll/engine/unicode_strtools.h b/regamedll/engine/unicode_strtools.h index 82f234a0..203b8f80 100644 --- a/regamedll/engine/unicode_strtools.h +++ b/regamedll/engine/unicode_strtools.h @@ -26,63 +26,57 @@ * */ -#ifndef UNICODE_STR_TOOLS_H -#define UNICODE_STR_TOOLS_H -#ifdef _WIN32 #pragma once -#endif + +#include "maintypes.h" #ifdef _WIN32 - typedef wchar_t uchar16; typedef unsigned int uchar32; - #else - typedef unsigned short uchar16; typedef wchar_t uchar32; +#endif -#endif // _WIN32 - -enum EStringConvertErrorPolicy -{ - _STRINGCONVERTFLAG_SKIP = 1, - _STRINGCONVERTFLAG_FAIL = 2, - _STRINGCONVERTFLAG_ASSERT = 4, - - STRINGCONVERT_REPLACE = 0, - STRINGCONVERT_SKIP = 1, - STRINGCONVERT_FAIL = 2, - +enum EStringConvertErrorPolicy { + _STRINGCONVERTFLAG_SKIP = 1, + _STRINGCONVERTFLAG_FAIL = 2, + _STRINGCONVERTFLAG_ASSERT = 4, + STRINGCONVERT_REPLACE = 0, + STRINGCONVERT_SKIP = 1, + STRINGCONVERT_FAIL = 2, STRINGCONVERT_ASSERT_REPLACE = 4, - STRINGCONVERT_ASSERT_SKIP = 5, - STRINGCONVERT_ASSERT_FAIL = 6, + STRINGCONVERT_ASSERT_SKIP = 5, + STRINGCONVERT_ASSERT_FAIL = 6, }; +bool Q_iswprint(uchar16 c); bool Q_IsValidUChar32(uchar32 uVal); -int Q_UTF32ToUChar32(const uchar32 *pUTF32, uchar32 &uVal, bool &bErr); -int Q_UChar32ToUTF32Len(uchar32 uVal); +bool Q_IsMeanSpaceW(uchar16 wch); +bool Q_IsUnprintableW(uchar16 wch); +bool Q_UnicodeValidate(const char *pUTF8); +bool Q_StripUnprintableAndSpace(char *pch); +bool Q_StripPrecedingAndTrailingWhitespace(char *pch); + int Q_UChar32ToUTF32(uchar32 uVal, uchar32 *pUTF32); -int Q_UChar32ToUTF8Len(uchar32 uVal); -int Q_UChar32ToUTF16Len(uchar32 uVal); +int Q_UChar32ToUTF32Len(uchar32 uVal); int Q_UChar32ToUTF16(uchar32 uVal, uchar16 *pUTF16Out); +int Q_UChar32ToUTF16Len(uchar32 uVal); int Q_UChar32ToUTF8(uchar32 uVal, char *pUTF8Out); +int Q_UChar32ToUTF8Len(uchar32 uVal); + +int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut); int Q_UTF16ToUChar32(const uchar16 *pUTF16, uchar32 &uValueOut, bool &bErrorOut); +int Q_UTF32ToUChar32(const uchar32 *pUTF32, uchar32 &uVal, bool &bErrorOut); + int Q_UTF8ToUTF16(const char *pUTF8, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy); int Q_UTF8ToUTF32(const char *pUTF8, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy); int Q_UTF16ToUTF8(const uchar16 *pUTF16, char *pUTF8, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy); int Q_UTF16ToUTF32(const uchar16 *pUTF16, uchar32 *pUTF32, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy); int Q_UTF32ToUTF8(const uchar32 *pUTF32, char *pUTF8, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy); int Q_UTF32ToUTF16(const uchar32 *pUTF32, uchar16 *pUTF16, int cubDestSizeInBytes, EStringConvertErrorPolicy ePolicy); -int Q_UTF8ToUChar32(const char *pUTF8_, uchar32 &uValueOut, bool &bErrorOut); -qboolean Q_UnicodeValidate(const char *pUTF8); -int Q_UnicodeLength(const char *pUTF8); -char *Q_UnicodeAdvance(char *pUTF8, int nChars); -//bool Q_IsMeanSpaceW(uchar16 wch); -bool Q_IsDeprecatedW(uchar16 wch); -uchar16 *StripUnprintableWorker(uchar16 *pwch, bool *pbStrippedAny); -qboolean Q_StripUnprintableAndSpace(char *pch); -qboolean V_UTF8ToUChar32(const char *pUTF8_, uchar32 *uValueOut); -int Q_UnicodeRepair(char *pUTF8); -#endif // UNICODE_STR_TOOLS_H +int Q_UnicodeRepair(char *pUTF8); +int Q_UnicodeLength(const char *pUTF8); + +char *Q_UnicodeAdvance(char *pUTF8, int nChars); diff --git a/regamedll/msvc/ReGameDLL.vcxproj b/regamedll/msvc/ReGameDLL.vcxproj index 574e628d..21ca9637 100644 --- a/regamedll/msvc/ReGameDLL.vcxproj +++ b/regamedll/msvc/ReGameDLL.vcxproj @@ -550,13 +550,8 @@ Create precompiled.h + - - true - true - true - true - true @@ -778,7 +773,6 @@ - @@ -911,7 +905,7 @@ Level3 Disabled true - REGAMEDLL_ADD;REGAMEDLL_API;REGAMEDLL_XYUNYA;REGAMEDLL_FIXES;REGAMEDLL_SELF;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + REGAMEDLL_ADD;REGAMEDLL_API;REGAMEDLL_FIXES;REGAMEDLL_SELF;UNICODE_FIXES;REGAMEDLL_CHECKS;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;_DEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) Precise /arch:IA32 %(AdditionalOptions) MultiThreadedDebug @@ -947,7 +941,7 @@ Level3 Full true - REGAMEDLL_ADD;REGAMEDLL_FIXES;REGAMEDLL_SELF;REGAMEDLL_CHECKS;REGAMEDLL_API;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;NDEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) + REGAMEDLL_ADD;REGAMEDLL_API;REGAMEDLL_FIXES;REGAMEDLL_SELF;REGAMEDLL_CHECKS;UNICODE_FIXES;CLIENT_WEAPONS;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;NDEBUG;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions) Fast /arch:IA32 %(AdditionalOptions) MultiThreaded @@ -1073,7 +1067,7 @@ Level3 Disabled true - REGAMEDLL_SELF;REGAMEDLL_FIXES;DEDICATED;REGAMEDLL_SELF;HOOK_GAMEDLL;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;USE_QSTRING;DEDICATED;_CRT_SECURE_NO_WARNINGS;_ITERATOR_DEBUG_LEVEL=0;_DEBUG;%(PreprocessorDefinitions) + REGAMEDLL_FIXES;REGAMEDLL_SELF;UNICODE_FIXES;_BUILD_FROM_IDE;USE_BREAKPAD_HANDLER;USE_QSTRING;_CRT_SECURE_NO_WARNINGS;_ITERATOR_DEBUG_LEVEL=0;_DEBUG;%(PreprocessorDefinitions) MultiThreadedDebug Use precompiled.h diff --git a/regamedll/msvc/ReGameDLL.vcxproj.filters b/regamedll/msvc/ReGameDLL.vcxproj.filters index 0cdd99cd..20ec22a6 100644 --- a/regamedll/msvc/ReGameDLL.vcxproj.filters +++ b/regamedll/msvc/ReGameDLL.vcxproj.filters @@ -1,13 +1,6 @@  - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {7be88557-a49b-4c62-8df3-d7134a578201} - {eeaac718-712b-453f-9d34-4cefc9e0fe59} @@ -66,9 +59,6 @@ {d1cb44c6-0982-4410-a099-0b3666ace636} - - {e0c6021c-de51-464f-b971-89942190e545} - {8f5a4004-ab6b-4802-a23b-091948576ad0} @@ -524,9 +514,6 @@ dlls - - regamedll - dlls @@ -560,6 +547,9 @@ dlls\API + + regamedll + @@ -1012,9 +1002,6 @@ game_shared - - regamedll - dlls diff --git a/regamedll/public/strtools.h b/regamedll/public/strtools.h index 8b414bf3..8baec82b 100644 --- a/regamedll/public/strtools.h +++ b/regamedll/public/strtools.h @@ -145,9 +145,12 @@ inline char *_strlwr(char *start) #endif // #if defined(ASMLIB_H) && defined(HAVE_OPT_STRTOOLS) // a safe variant of strcpy that truncates the result to fit in the destination buffer -template -char *Q_strlcpy(char (&dest)[size], const char *src) { - Q_strncpy(dest, src, size - 1); +template +T *Q_strlcpy(T (&dest)[size], const char *src) +{ + static_assert(sizeof(T) == sizeof(char), "invalid size of type != sizeof(char)"); + + Q_strncpy((char *)dest, src, size - 1); dest[size - 1] = '\0'; return dest; } @@ -160,9 +163,11 @@ inline char *Q_strnlcpy(char *dest, const char *src, size_t n) { // safely concatenate two strings. // a variant of strcat that truncates the result to fit in the destination buffer -template -size_t Q_strlcat(char (&dest)[size], const char *src) +template +size_t Q_strlcat(T (&dest)[size], const char *src) { + static_assert(sizeof(T) == sizeof(char), "invalid size of type != sizeof(char)"); + size_t srclen; // Length of source string size_t dstlen; // Length of destination string diff --git a/regamedll/regamedll/RegameDLLRuntimeConfig.cpp b/regamedll/regamedll/RegameDLLRuntimeConfig.cpp deleted file mode 100644 index 9b2cca4b..00000000 --- a/regamedll/regamedll/RegameDLLRuntimeConfig.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2 of the License, or (at -* your option) any later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software Foundation, -* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -* -* In addition, as a special exception, the author gives permission to -* link the code of this program with the Half-Life Game Engine ("HL -* Engine") and Modified Game Libraries ("MODs") developed by Valve, -* L.L.C ("Valve"). You must obey the GNU General Public License in all -* respects for all of the code used other than the HL Engine and MODs -* from Valve. If you modify this file, you may extend this exception -* to your version of the file, but you are not obligated to do so. If -* you do not wish to do so, delete this exception statement from your -* version. -* -*/ - -#include "precompiled.h" - -CRegameDLLRuntimeConfig g_ReGameDLLRuntimeConfig; - -CRegameDLLRuntimeConfig::CRegameDLLRuntimeConfig() -{ - bIsZero = false; -} - -void CRegameDLLRuntimeConfig::parseFromCommandLine(const char *cmdLine) -{ - char localBuf[2048]; - if (strlen(cmdLine) >= sizeof(localBuf)) - { - Sys_Error("%s: too long cmdline", __func__); - } - - strcpy(localBuf, cmdLine); - char *cpos = localBuf; - - getNextToken(&cpos); // skip executable path - - const char *token = getNextToken(&cpos); - while (token != NULL) - { - if (!strcmp(token, "-game")) - { - const char *gameMod = getNextToken(&cpos); - - if (gameMod != NULL && !strcmp(gameMod, "czero")) - bIsZero = true; - } - - token = getNextToken(&cpos); - } -} - -const char *CRegameDLLRuntimeConfig::getNextToken(char **pBuf) -{ - char *rpos = *pBuf; - if (*rpos == 0) - return NULL; - - // skip spaces at the beginning - while (*rpos != 0 && isspace(*rpos)) - rpos++; - - if (*rpos == 0) - { - *pBuf = rpos; - return NULL; - } - - const char *res = rpos; - char *wpos = rpos; - char inQuote = 0; - while (*rpos != 0) - { - char cc = *rpos; - if (inQuote) - { - if (inQuote == cc) - { - inQuote = 0; - rpos++; - } - else - { - if (rpos != wpos) - *wpos = cc; - rpos++; - wpos++; - } - } - else - { - if (isspace(cc)) - { - break; - } - else if (cc == '\'' || cc == '"') - { - inQuote = cc; - rpos++; - } - else - { - if (rpos != wpos) - *wpos = cc; - rpos++; - wpos++; - } - } - } - if (*rpos != 0) - { - rpos++; - } - - *pBuf = rpos; - *wpos = 0; - return res; -} diff --git a/regamedll/regamedll/hookchains_impl.h b/regamedll/regamedll/hookchains_impl.h index 9aa37d0b..96452b4a 100644 --- a/regamedll/regamedll/hookchains_impl.h +++ b/regamedll/regamedll/hookchains_impl.h @@ -53,7 +53,7 @@ public: IHookChainImpl(void** hooks, origfunc_t orig) : m_Hooks(hooks), m_OriginalFunc(orig) { - if (orig == NULL && !is_void(orig)) + if (orig == nullptr && !is_void(orig)) Sys_Error("%s: Non-void HookChain without original function.", __func__); } @@ -89,7 +89,7 @@ public: IHookChainClassImpl(void** hooks, origfunc_t orig) : m_Hooks(hooks), m_OriginalFunc(orig) { - if (orig == NULL && !is_void(orig)) + if (orig == nullptr && !is_void(orig)) Sys_Error("%s: Non-void HookChain without original function.", __func__); } @@ -125,7 +125,7 @@ public: IHookChainClassEmptyImpl(void** hooks, origfunc_t orig, t_class *object) : m_Hooks(hooks), m_OriginalFunc(orig), m_Object(object) { - if (orig == NULL && !is_void(orig)) + if (orig == nullptr && !is_void(orig)) Sys_Error("%s: Non-void HookChain without original function.", __func__); } diff --git a/regamedll/regamedll/precompiled.h b/regamedll/regamedll/precompiled.h index 18ba5db5..f3799aea 100644 --- a/regamedll/regamedll/precompiled.h +++ b/regamedll/regamedll/precompiled.h @@ -40,7 +40,6 @@ #include "MemPool.h" #include "engine.h" -#include "RegameDLLRuntimeConfig.h" // Valve libs stuff #include "tier0/platform.h" diff --git a/regamedll/regamedll/RegameDLLRuntimeConfig.h b/regamedll/regamedll/public_amalgamation.cpp similarity index 81% rename from regamedll/regamedll/RegameDLLRuntimeConfig.h rename to regamedll/regamedll/public_amalgamation.cpp index 6a6caeb5..117a0875 100644 --- a/regamedll/regamedll/RegameDLLRuntimeConfig.h +++ b/regamedll/regamedll/public_amalgamation.cpp @@ -26,19 +26,6 @@ * */ -#pragma once +#include "precompiled.h" -class CRegameDLLRuntimeConfig -{ -private: - bool bIsZero; - const char *getNextToken(char **pBuf); - -public: - CRegameDLLRuntimeConfig(); - - bool IsCzero() const { return bIsZero; } - void parseFromCommandLine(const char *cmdLine); -}; - -extern CRegameDLLRuntimeConfig g_ReGameDLLRuntimeConfig; +#include "stdc++compat.cpp"