Skip to content

Commit

Permalink
fix some crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
rafradek committed May 22, 2022
1 parent d5569f3 commit e09e715
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ MSVC/Report*.csv
*.sublime-project
*.sublime-workspace

libs/lua/
libs/lua/
sigsegv-mvm.kdev4
2 changes: 1 addition & 1 deletion PackageScript
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ CopyFiles('scripts', 'custom/sigsegv/scripts',
CopyFiles('src/lua', 'custom/sigsegv/scripts',
[
'globals.lua',
'natives.lua'
'library.lua'
]
)

Expand Down
4 changes: 2 additions & 2 deletions src/mod/etc/extra_player_slots.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ namespace Mod::Etc::Extra_Player_Slots

DETOUR_DECL_MEMBER(CBaseClient *, CBaseServer_GetFreeClient, netadr_t &adr)
{
if ((!ExtraSlotsEnabled() || gpGlobals->maxClients < 34) && force_create_at_slot == -1) return DETOUR_MEMBER_CALL(CBaseServer_GetFreeClient)(adr);
auto server = reinterpret_cast<CBaseServer *>(this);
if (server == hltv || (!ExtraSlotsEnabled() || gpGlobals->maxClients < 34) && force_create_at_slot == -1) return DETOUR_MEMBER_CALL(CBaseServer_GetFreeClient)(adr);

if (rc_CBaseServer_CreateFakeClient || force_create_at_slot != -1) {
static ConVarRef tv_enable("tv_enable");
std::vector<CBaseClient *> clientList;
auto server = reinterpret_cast<CBaseServer *>(this);

// Make sure all slots are taken
if (server->GetClientCount() != server->GetMaxClients()) {
Expand Down
19 changes: 3 additions & 16 deletions src/mod/etc/mapentity_additions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,6 @@ namespace Mod::Etc::Mapentity_Additions
"Summon Skeletons"
};

struct SendPropCacheEntry {
ServerClass *serverClass;
std::string name;
int offset;
bool isVecAxis;
SendProp *prop;
};

struct DatamapCacheEntry {
datamap_t *datamap;
std::string name;
int offset;
fieldtype_t fieldType;
int size;
};

std::vector<ServerClass *> send_prop_cache_classes;
std::vector<std::pair<std::vector<std::string>, std::vector<PropCacheEntry>>> send_prop_cache;

Expand Down Expand Up @@ -243,6 +227,7 @@ namespace Mod::Etc::Mapentity_Additions
}

PropCacheEntry &GetSendPropOffset(ServerClass *serverClass, std::string &name) {
TIME_SCOPE2(Sendproptime);
size_t classIndex = 0;
for (; classIndex < send_prop_cache_classes.size(); classIndex++) {
if (send_prop_cache_classes[classIndex] == serverClass) {
Expand Down Expand Up @@ -1778,7 +1763,9 @@ namespace Mod::Etc::Mapentity_Additions
{
sendproxies = gamedll->GetStandardSendProxies();
send_prop_cache.clear();
send_prop_cache_classes.clear();
datamap_cache.clear();
datamap_cache_classes.clear();
entity_listeners.clear();
}
};
Expand Down
3 changes: 3 additions & 0 deletions src/stub/extraentitydata.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ inline float CBaseEntity::GetCustomVariableFloat(float defValue)
auto &attrs = data->GetCustomVariables();
for (auto &var : attrs) {
if (var.key == pooled) {
if (var.value.FieldType() != FIELD_FLOAT) var.value.Convert(FIELD_FLOAT);
return var.value.Float();
}
}
Expand All @@ -418,6 +419,7 @@ inline Vector CBaseEntity::GetCustomVariableVector(const Vector &defValue)
for (auto &var : attrs) {
if (var.key == pooled) {
Vector vec;
if (var.value.FieldType() != FIELD_VECTOR) var.value.Convert(FIELD_VECTOR);
var.value.Vector3D(vec);
return vec;
}
Expand All @@ -437,6 +439,7 @@ inline QAngle CBaseEntity::GetCustomVariableAngle(const QAngle &defValue)
if (var.key == pooled) {
QAngle ang;

if (var.value.FieldType() != FIELD_VECTOR) var.value.Convert(FIELD_VECTOR);
var.value.Vector3D(*((Vector *)ang.Base()));

return ang;
Expand Down

0 comments on commit e09e715

Please sign in to comment.