Skip to content

Commit 1b51b6e

Browse files
committed
Stack mystery rounds
1 parent 43aa813 commit 1b51b6e

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

src/engine/server.h

+1
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ class IServer : public IInterface
276276
virtual void ReadAnnouncementsFile(const char *pFileName) = 0;
277277
virtual const char *GetMysteryRoundLine() = 0;
278278
virtual void ReadMysteryRoundsFile(const char *pFileName) = 0;
279+
virtual size_t GetMysteryRoundsSize() = 0;
279280
virtual bool ClientPrevIngame(int ClientId) = 0;
280281
virtual const char *GetNetErrorString(int ClientId) = 0;
281282
virtual void ResetNetErrorString(int ClientId) = 0;

src/engine/server/server.h

+1
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ class CServer : public IServer
452452

453453
const char *GetMysteryRoundLine() override;
454454
void ReadMysteryRoundsFile(const char *pFileName) override;
455+
size_t GetMysteryRoundsSize() override { return m_vMysteryRounds.size(); }
455456

456457
int *GetIdMap(int ClientId) override;
457458

src/game/server/gamemodes/Bomb.cpp

+17-3
Original file line numberDiff line numberDiff line change
@@ -504,18 +504,32 @@ void CGameControllerBomb::EndBombRound(bool RealEnd)
504504
GameServer()->SendChat(-1, TEAM_ALL, "Noone won the round!");
505505
}
506506

507-
if(g_Config.m_BombtagMysteryChance && rand() % 101 <= g_Config.m_BombtagMysteryChance)
507+
std::vector<std::string> vTemp;
508+
while(g_Config.m_BombtagMysteryChance && rand() % 101 <= g_Config.m_BombtagMysteryChance)
508509
{
510+
if(vTemp.size() == Server()->GetMysteryRoundsSize())
511+
{
512+
break;
513+
}
514+
if(!m_WasMysteryRound)
515+
{
516+
GameServer()->SendChat(-1, TEAM_ALL, "MYSTERY ROUND!");
517+
}
509518
const char *pLine = GameServer()->Server()->GetMysteryRoundLine();
510519
if(pLine)
511520
{
512-
GameServer()->SendChat(-1, TEAM_ALL, "MYSTERY ROUND!");
521+
if(std::find(vTemp.begin(), vTemp.end(), pLine) != vTemp.end())
522+
{
523+
continue;
524+
}
525+
513526
GameServer()->Console()->ExecuteFile(g_Config.m_SvMysteryRoundsResetFileName);
514527
GameServer()->Console()->ExecuteLine(pLine);
515528
m_WasMysteryRound = true;
529+
vTemp.emplace_back(pLine);
516530
}
517531
}
518-
else if(m_WasMysteryRound)
532+
if(m_WasMysteryRound)
519533
{
520534
GameServer()->Console()->ExecuteFile(g_Config.m_SvMysteryRoundsResetFileName);
521535
m_WasMysteryRound = false;

0 commit comments

Comments
 (0)