Skip to content

Commit 78e1639

Browse files
committed
fix some bugs
1 parent 6bb6610 commit 78e1639

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

src/mod/etc/extra_player_slots.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ namespace Mod::Etc::Extra_Player_Slots
6464
ConVar sig_etc_extra_player_slots_allow_bots("sig_etc_extra_player_slots_allow_bots", "0", FCVAR_NOTIFY | FCVAR_GAMEDLL,
6565
"Allow bots to use extra player slots",
6666
[](IConVar *pConVar, const char *pOldValue, float flOldValue){
67-
if (sig_etc_extra_player_slots_allow_bots.GetBool() && flOldValue == 0.0f && ExtraSlotsEnabled() && gpGlobals->maxClients < sig_etc_extra_player_slots_count.GetInt()) {
67+
if (sig_etc_extra_player_slots_allow_bots.GetBool() && cvar_enable.GetBool() && flOldValue == 0.0f && ExtraSlotsEnabled() && gpGlobals->maxClients < sig_etc_extra_player_slots_count.GetInt()) {
6868
engine->ChangeLevel(STRING(gpGlobals->mapname), nullptr);
6969
}
7070
});
7171

7272
ConVar sig_etc_extra_player_slots_allow_players("sig_etc_extra_player_slots_allow_players", "0", FCVAR_NOTIFY,
7373
"Allow players to use extra player slots",
7474
[](IConVar *pConVar, const char *pOldValue, float flOldValue){
75-
if (sig_etc_extra_player_slots_allow_players.GetBool() && flOldValue == 0.0f && ExtraSlotsEnabled() && gpGlobals->maxClients < sig_etc_extra_player_slots_count.GetInt()) {
75+
if (sig_etc_extra_player_slots_allow_players.GetBool() && cvar_enable.GetBool() && flOldValue == 0.0f && ExtraSlotsEnabled() && gpGlobals->maxClients < sig_etc_extra_player_slots_count.GetInt()) {
7676
engine->ChangeLevel(STRING(gpGlobals->mapname), nullptr);
7777
}
7878
});

src/mod/mvm/gamemode_converter.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ namespace Mod::MvM::Gamemode_Converter
114114
bool shouldPlaceHatch = false;
115115
Vector hatchPropOrigin = vec3_origin;
116116

117-
std::list<ParsedEntity>::iterator captureZone;
117+
std::list<ParsedEntity>::iterator captureZone = parsedEntities.end();
118118

119119
for (auto it = parsedEntities.begin(); it != parsedEntities.end();) {
120120
auto &parsedEntity = *it;
@@ -591,10 +591,12 @@ namespace Mod::MvM::Gamemode_Converter
591591
hatchDestroyRelay.emplace("OnTrigger", "hatch_kill,Disable,,0.5,-1");
592592
}
593593

594-
captureZone->erase("teamnum");
595-
captureZone->emplace("teamnum", "3");
596-
captureZone->emplace("OnCapture", "bots_win,RoundWin,,0,-1");
597-
captureZone->emplace("OnCapture", "hatch_bust_relay,trigger,,1,-1");
594+
if (captureZone != parsedEntities.end()) {
595+
captureZone->erase("teamnum");
596+
captureZone->emplace("teamnum", "3");
597+
captureZone->emplace("OnCapture", "bots_win,RoundWin,,0,-1");
598+
captureZone->emplace("OnCapture", "hatch_bust_relay,trigger,,1,-1");
599+
}
598600

599601
WriteEntityString(entitiesStr, parsedEntities);
600602

src/mod/pop/wavespawn_extensions.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,10 @@ namespace Mod::Pop::WaveSpawn_Extensions
839839
// delete the temporary copy of the KV subtree
840840
kv->deleteThis();
841841

842+
if (result && wavespawn->m_totalCount > 100000 && rtti_cast<CRandomChoiceSpawner *>(wavespawn->m_Spawner)) {
843+
wavespawn->m_totalCount = 100000;
844+
Warning("Total count of wavespawn %s reduced to 100000 to reduce RandomChoice related memory leaks\n", wavespawn->m_name.Get());
845+
}
842846
if (result && hidden) {
843847
last_wavespawn_hidden = true;
844848
}
@@ -1363,6 +1367,37 @@ namespace Mod::Pop::WaveSpawn_Extensions
13631367
return DETOUR_MEMBER_CALL(NextBotManager_ShouldUpdate)(bot);
13641368
}*/
13651369

1370+
DETOUR_DECL_MEMBER(string_t, CRandomChoiceSpawner_GetClassIcon, int index)
1371+
{
1372+
auto spawner = reinterpret_cast<CRandomChoiceSpawner *>(this);
1373+
if (spawner->m_SubSpawners.IsEmpty()) return NULL_STRING;
1374+
return DETOUR_MEMBER_CALL(CRandomChoiceSpawner_GetClassIcon)(index);
1375+
}
1376+
DETOUR_DECL_MEMBER(bool, CRandomChoiceSpawner_IsMiniBoss, int index)
1377+
{
1378+
auto spawner = reinterpret_cast<CRandomChoiceSpawner *>(this);
1379+
if (spawner->m_SubSpawners.IsEmpty()) return false;
1380+
return DETOUR_MEMBER_CALL(CRandomChoiceSpawner_IsMiniBoss)(index);
1381+
}
1382+
DETOUR_DECL_MEMBER(bool, CRandomChoiceSpawner_HasAttribute, CTFBot::AttributeType attr, int index)
1383+
{
1384+
auto spawner = reinterpret_cast<CRandomChoiceSpawner *>(this);
1385+
if (spawner->m_SubSpawners.IsEmpty()) return false;
1386+
return DETOUR_MEMBER_CALL(CRandomChoiceSpawner_HasAttribute)(attr, index);
1387+
}
1388+
DETOUR_DECL_MEMBER(int, CRandomChoiceSpawner_GetClass, int index)
1389+
{
1390+
auto spawner = reinterpret_cast<CRandomChoiceSpawner *>(this);
1391+
if (spawner->m_SubSpawners.IsEmpty()) return false;
1392+
return DETOUR_MEMBER_CALL(CRandomChoiceSpawner_GetClass)(index);
1393+
}
1394+
DETOUR_DECL_MEMBER(int, CRandomChoiceSpawner_GetHealth, int index)
1395+
{
1396+
auto spawner = reinterpret_cast<CRandomChoiceSpawner *>(this);
1397+
if (spawner->m_SubSpawners.IsEmpty()) return false;
1398+
return DETOUR_MEMBER_CALL(CRandomChoiceSpawner_GetHealth)(index);
1399+
}
1400+
13661401
class CMod : public IMod, public IModCallbackListener, IFrameUpdatePostEntityThinkListener
13671402
{
13681403
public:
@@ -1399,6 +1434,13 @@ namespace Mod::Pop::WaveSpawn_Extensions
13991434
MOD_ADD_DETOUR_MEMBER(CWave_AddClassType, "CWave::AddClassType");
14001435

14011436
MOD_ADD_DETOUR_MEMBER(CRandomChoiceSpawner_Parse, "CRandomChoiceSpawner::Parse");
1437+
1438+
// Fix CRandomChoiceSpawner crashes when the block is empty
1439+
MOD_ADD_DETOUR_MEMBER(CRandomChoiceSpawner_GetClassIcon, "CRandomChoiceSpawner::GetClassIcon");
1440+
MOD_ADD_DETOUR_MEMBER(CRandomChoiceSpawner_IsMiniBoss, "CRandomChoiceSpawner::IsMiniBoss");
1441+
MOD_ADD_DETOUR_MEMBER(CRandomChoiceSpawner_HasAttribute, "CRandomChoiceSpawner::HasAttribute");
1442+
MOD_ADD_DETOUR_MEMBER(CRandomChoiceSpawner_GetClass, "CRandomChoiceSpawner::GetClass");
1443+
MOD_ADD_DETOUR_MEMBER(CRandomChoiceSpawner_GetHealth, "CRandomChoiceSpawner::GetHealth");
14021444

14031445
}
14041446

0 commit comments

Comments
 (0)