Skip to content

Commit 163be06

Browse files
committed
repo: try to fix a few warnings
1 parent 120baa1 commit 163be06

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ On the next startup the ghostinj will update holylib to use the new file.
8383
\- [#] Optimized `CCvar::FindVar` (50x faster in average).
8484
\- [#] Fixed `pvs.RemoveAllEntityFromTransmit` possibly causing stack issues.
8585
\- [#] Completely changed how we Push/Manage Lua userdata to reduce memory leaks.
86+
\- [#] Fixed a filesystem issue which could rarely result in a crash. (Issue: #23)
8687
\- [-] Removed `holylib_filesystem_optimizedfixpath` since it was implemented into gmod itself.
8788

8889
You can see all changes here:

source/lua/CLuaInterface.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
#include "GarrysMod/Lua/LuaShared.h"
1111
#include "lua/PooledStrings.h"
1212

13+
#if defined(__clang__) || defined(__GNUC__)
14+
#define POINT_UNREACHABLE __builtin_unreachable()
15+
#else
16+
#define POINT_UNREACHABLE __assume(false)
17+
#endif
1318

1419
int g_iTypeNum = 0;
1520

@@ -261,10 +266,11 @@ void* CLuaInterface::NewUserdata(unsigned int iSize)
261266
return lua_newuserdata(state, iSize);
262267
}
263268

264-
void CLuaInterface::ThrowError(const char* strError)
269+
[[noreturn]] void CLuaInterface::ThrowError(const char* strError)
265270
{
266271
::DebugPrint(2, "CLuaInterface::ThrowError %s\n", strError);
267272
luaL_error(state, "%s", strError);
273+
POINT_UNREACHABLE;
268274
}
269275

270276
void CLuaInterface::CheckType(int iStackPos, int iType)
@@ -279,10 +285,11 @@ void CLuaInterface::CheckType(int iStackPos, int iType)
279285
}
280286
}
281287

282-
void CLuaInterface::ArgError(int iArgNum, const char* strMessage)
288+
[[noreturn]] void CLuaInterface::ArgError(int iArgNum, const char* strMessage)
283289
{
284290
::DebugPrint(2, "CLuaInterface::ArgError\n");
285291
luaL_argerror(state, iArgNum, strMessage);
292+
POINT_UNREACHABLE;
286293
}
287294

288295
void CLuaInterface::RawGet(int iStackPos)

source/lua/ILuaInterface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@ namespace GarrysMod::Lua
529529
virtual const char* CheckStringOpt( int iStackPos, const char* def ) = 0;
530530
virtual double CheckNumberOpt( int iStackPos, double def ) = 0;
531531
virtual void RegisterMetaTable( const char* name, ILuaObject* obj ) = 0;
532+
533+
// Not in gmod? Anyways.
534+
virtual ~ILuaInterface() {}
532535
};
533536
}
534537
#endif

source/modules/networking.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ bool entityHasOverride[MAX_EDICTS] {};
610610
class SendpropOverrideModule : public EntityModule, public AutoList<SendpropOverrideModule>
611611
{
612612
public:
613-
SendpropOverrideModule(CBaseEntity *entity) : EntityModule(entity), entity(entity) {}
613+
SendpropOverrideModule(CBaseEntity *pEntity) : EntityModule(pEntity), m_pEntity(pEntity) {}
614614

615615
~SendpropOverrideModule();
616616

@@ -619,13 +619,13 @@ class SendpropOverrideModule : public EntityModule, public AutoList<SendpropOver
619619

620620
void RemoveOverride(int id);
621621

622-
CBaseEntity *entity;
622+
CBaseEntity *m_pEntity;
623623
std::vector<PropOverride> propOverrides;
624624
};
625625

626626
SendpropOverrideModule::~SendpropOverrideModule()
627627
{
628-
entityHasOverride[entity->entindex()] = false;
628+
entityHasOverride[m_pEntity->entindex()] = false;
629629
}
630630

631631
struct DatatableProxyOffset
@@ -719,14 +719,14 @@ int FindSendPropPrecalcIndex(SendTable *table, const std::string &name, int inde
719719
int SendpropOverrideModule::AddOverride(SendPropOverrideCallback callback, const std::string &name, int index, uintptr_t data)
720720
{
721721
SendProp *prop = nullptr;
722-
return this->AddOverride(callback, FindSendPropPrecalcIndex(entity->GetServerClass()->m_pTable, name, index, prop), prop, data);
722+
return this->AddOverride(callback, FindSendPropPrecalcIndex(m_pEntity->GetServerClass()->m_pTable, name, index, prop), prop, data);
723723
}
724724

725725
int SendpropOverrideModule::AddOverride(SendPropOverrideCallback callback, int indexProp, SendProp *prop, uintptr_t data)
726726
{
727727
if (indexProp != -1) {
728728
if (prop == nullptr) {
729-
prop = (SendProp *) entity->GetServerClass()->m_pTable->m_pPrecalc->m_Props[indexProp];
729+
prop = (SendProp *) m_pEntity->GetServerClass()->m_pTable->m_pPrecalc->m_Props[indexProp];
730730
}
731731
auto insertPos = propOverrides.end();
732732
for (auto it = propOverrides.begin(); it != propOverrides.end(); it++) {
@@ -735,7 +735,7 @@ int SendpropOverrideModule::AddOverride(SendPropOverrideCallback callback, int i
735735
PropOverride overr {++propOverrideId, callback, prop, indexProp, data};
736736
propOverrides.insert(insertPos, overr);
737737

738-
entityHasOverride[entity->entindex()] = true;
738+
entityHasOverride[m_pEntity->entindex()] = true;
739739
return propOverrideId;
740740
}
741741
return -1;
@@ -1057,6 +1057,7 @@ int hook_SendTable_CalcDelta(
10571057
return count;
10581058
}
10591059

1060+
#if 0
10601061
thread_local PackedEntity *preOldPack = nullptr;
10611062
thread_local CEntityWriteInfo *writeInfo = nullptr;
10621063
static Detouring::Hook detour_SV_DetermineUpdateType;
@@ -1112,6 +1113,7 @@ int hook_PackedEntity_GetPropsChangedAfterTick(PackedEntity* pPacked, int tick,
11121113

11131114
return result;
11141115
}
1116+
#endif
11151117

11161118
static Detouring::Hook detour_CGameServer_SendClientMessages;
11171119
static Symbols::CGameServer_SendClientMessages CGameServer_SendClientMessages_func;
@@ -1128,7 +1130,7 @@ void hook_CGameServer_SendClientMessages(CBaseServer* pServer, bool sendSnapshot
11281130
}
11291131

11301132
if (mod->propOverrides.empty())
1131-
entityHasOverride[mod->entity->entindex()] = false;
1133+
entityHasOverride[mod->m_pEntity->entindex()] = false;
11321134
}
11331135
}
11341136

@@ -1280,6 +1282,11 @@ inline bool CCServerNetworkProperty::IsInPVS( const CCheckTransmitInfo *pInfo )
12801282
return false; // not visible
12811283
}
12821284

1285+
inline CBaseEntity* CCServerNetworkProperty::GetBaseEntity()
1286+
{
1287+
return m_pOuter;
1288+
}
1289+
12831290
/*
12841291
* For now this is called from the pvs module meaning we RELY on it.
12851292
* What did we change? basicly nothing yet. I'm just testing around.

0 commit comments

Comments
 (0)