mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-26 14:45:38 +03:00
Refactoring minor
Refactoring unicode_strtools
This commit is contained in:
parent
32df585edc
commit
9dcab4bd49
@ -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"
|
||||
}
|
||||
}
|
||||
|
52
regamedll/common/stdc++compat.cpp
Normal file
52
regamedll/common/stdc++compat.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#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)
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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<CBasePlayer *>(pEntity);
|
||||
return pPlayer;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -361,7 +361,6 @@ int DispatchSpawn(edict_t *pent)
|
||||
gGlobalState.EntityAdd(pEntity->pev->globalname, gpGlobals->mapname, GLOBAL_ON);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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];
|
||||
|
||||
|
@ -214,7 +214,7 @@ public:
|
||||
static TYPEDESCRIPTION m_SaveData[];
|
||||
|
||||
CSprite *m_pSprite;
|
||||
int m_iszSpriteName;
|
||||
string_t m_iszSpriteName;
|
||||
Vector m_firePosition;
|
||||
};
|
||||
|
||||
|
@ -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<CGrenade *>(pEntity);
|
||||
|
||||
if (!FClassnameIs(pGrenade->pev, "grenade") || pGrenade->m_SGSmoke > 1)
|
||||
continue;
|
||||
|
||||
|
@ -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<CPathTrack *>(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<CFuncTrackTrain>(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)
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -311,6 +311,24 @@ inline T *UTIL_FindEntityByTargetname(T *pStartEntity, const char *szName)
|
||||
return (T *)UTIL_FindEntityByString(pStartEntity, "targetname", szName);
|
||||
}
|
||||
|
||||
template <typename T = CBaseEntity>
|
||||
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 <size_t nSize>
|
||||
void UTIL_StripToken(const char *pKey, char (&pDest)[nSize])
|
||||
{
|
||||
|
@ -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<CPathTrack *>(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<CFuncVehicle>(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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -328,7 +328,7 @@ void CWorld::Precache()
|
||||
// player precaches
|
||||
// get weapon precaches
|
||||
|
||||
W_Precache();
|
||||
WeaponsPrecache();
|
||||
ClientPrecache();
|
||||
BotPrecache();
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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);
|
||||
|
@ -550,13 +550,8 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Tests|Win32'">precompiled.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\regamedll\public_amalgamation.cpp" />
|
||||
<ClCompile Include="..\regamedll\regamedll.cpp" />
|
||||
<ClCompile Include="..\regamedll\RegameDLLRuntimeConfig.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release Play|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug Play|Win32'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\regamedll\sse_mathfun.cpp" />
|
||||
<ClCompile Include="..\unittests\animation_tests.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
@ -778,7 +773,6 @@
|
||||
<ClInclude Include="..\regamedll\hookchains_impl.h" />
|
||||
<ClInclude Include="..\regamedll\precompiled.h" />
|
||||
<ClInclude Include="..\regamedll\regamedll.h" />
|
||||
<ClInclude Include="..\regamedll\RegameDLLRuntimeConfig.h" />
|
||||
<ClInclude Include="..\regamedll\sse_mathfun.h" />
|
||||
<ClInclude Include="..\version\version.h" />
|
||||
</ItemGroup>
|
||||
@ -911,7 +905,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
|
||||
<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)</PreprocessorDefinitions>
|
||||
<FloatingPointModel>Precise</FloatingPointModel>
|
||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
@ -947,7 +941,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Full</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
|
||||
<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)</PreprocessorDefinitions>
|
||||
<FloatingPointModel>Fast</FloatingPointModel>
|
||||
<AdditionalOptions>/arch:IA32 %(AdditionalOptions)</AdditionalOptions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
@ -1073,7 +1067,7 @@
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
|
||||
<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)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>precompiled.h</PrecompiledHeaderFile>
|
||||
|
@ -1,13 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="hookers">
|
||||
<UniqueIdentifier>{7be88557-a49b-4c62-8df3-d7134a578201}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="engine">
|
||||
<UniqueIdentifier>{eeaac718-712b-453f-9d34-4cefc9e0fe59}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@ -66,9 +59,6 @@
|
||||
<Filter Include="dlls\hostage\states">
|
||||
<UniqueIdentifier>{d1cb44c6-0982-4410-a099-0b3666ace636}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="hookers\stl">
|
||||
<UniqueIdentifier>{e0c6021c-de51-464f-b971-89942190e545}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="public\regamedll">
|
||||
<UniqueIdentifier>{8f5a4004-ab6b-4802-a23b-091948576ad0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@ -524,9 +514,6 @@
|
||||
<ClCompile Include="..\dlls\mapinfo.cpp">
|
||||
<Filter>dlls</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\regamedll\RegameDLLRuntimeConfig.cpp">
|
||||
<Filter>regamedll</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\dlls\cmdhandler.cpp">
|
||||
<Filter>dlls</Filter>
|
||||
</ClCompile>
|
||||
@ -560,6 +547,9 @@
|
||||
<ClCompile Include="..\dlls\API\CSPlayerItem.cpp">
|
||||
<Filter>dlls\API</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\regamedll\public_amalgamation.cpp">
|
||||
<Filter>regamedll</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\version\version.h">
|
||||
@ -1012,9 +1002,6 @@
|
||||
<ClInclude Include="..\game_shared\counter.h">
|
||||
<Filter>game_shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\regamedll\RegameDLLRuntimeConfig.h">
|
||||
<Filter>regamedll</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\dlls\revert_saved.h">
|
||||
<Filter>dlls</Filter>
|
||||
</ClInclude>
|
||||
|
@ -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 <size_t size>
|
||||
char *Q_strlcpy(char (&dest)[size], const char *src) {
|
||||
Q_strncpy(dest, src, size - 1);
|
||||
template <typename T, size_t size>
|
||||
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 size>
|
||||
size_t Q_strlcat(char (&dest)[size], const char *src)
|
||||
template <typename T, size_t size>
|
||||
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
|
||||
|
||||
|
@ -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;
|
||||
}
|
@ -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__);
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "MemPool.h"
|
||||
|
||||
#include "engine.h"
|
||||
#include "RegameDLLRuntimeConfig.h"
|
||||
|
||||
// Valve libs stuff
|
||||
#include "tier0/platform.h"
|
||||
|
@ -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"
|
Loading…
Reference in New Issue
Block a user