Skip to content

Commit

Permalink
MapRotation: Keep the data on map disabled (missing in new maprotation)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaffeine committed Mar 24, 2024
1 parent 15e840e commit bcdbbe2
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions src/game/server/gamecontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class CMapInfo
class CMapInfoEx : public CMapInfo
{
public:
int mTimestamp = 0;
int mTimestamp{};
bool mEnabled{};

const char *Name() const { return aMapName; }
void SetName(const char *pMapName);
Expand Down Expand Up @@ -518,11 +519,12 @@ void IGameController::GetMapRotationInfo(CMapRotationInfo *pMapRotationInfo)

void IGameController::SyncSmartMapRotationData()
{
s_aMapInfo.Clear();
// Disable all maps
for (CMapInfoEx &info : s_aMapInfo) {
info.mEnabled = false;
}

// handle maprotation
const char *pMapRotation = Config()->m_SvMaprotation;

const char *pNextMap = pMapRotation;
char aMapNameBuffer[64];
while(*pNextMap)
Expand All @@ -535,7 +537,15 @@ void IGameController::SyncSmartMapRotationData()
}
aMapNameBuffer[WordLen] = 0;

OnMapAdded(aMapNameBuffer);
CMapInfoEx *pInfo = GetMapInfo(aMapNameBuffer);
if(pInfo)
{
pInfo->mEnabled = true;
}
else
{
OnMapAdded(aMapNameBuffer);
}

pNextMap += WordLen + 1;
}
Expand Down Expand Up @@ -571,6 +581,9 @@ void IGameController::ConSmartMapRotationStatus()
if(NameLength > MaxMapNameLength)
MaxMapNameLength = NameLength;

if(!Info.mEnabled)
continue;

if(CurrentActivePlayers < Info.MinimumPlayers)
continue;

Expand All @@ -586,6 +599,8 @@ void IGameController::ConSmartMapRotationStatus()
for(int i = 0; i < s_aMapInfo.Size(); ++i)
{
const CMapInfoEx &Info = s_aMapInfo.At(i);
if(!Info.mEnabled)
continue;

bool Skipped = false;

Expand Down Expand Up @@ -916,6 +931,9 @@ void IGameController::SmartMapCycle()

for(const CMapInfoEx &Info : s_aMapInfo)
{
if(!Info.mEnabled)
continue;

if(CurrentActivePlayers < Info.MinimumPlayers)
continue;

Expand All @@ -931,6 +949,8 @@ void IGameController::SmartMapCycle()
for(int i = 0; i < s_aMapInfo.Size(); ++i)
{
const CMapInfoEx &Info = s_aMapInfo.At(i);
if(!Info.mEnabled)
continue;

if(CurrentActivePlayers < Info.MinimumPlayers)
continue;
Expand Down

0 comments on commit bcdbbe2

Please sign in to comment.