| 151 | } |
| 152 | |
| 153 | void NextMapManager::OnSourceModLevelChange( const char *mapName ) |
| 154 | { |
| 155 | // If we were controlling the map change, reset sm_nextmap to be the name of the map we successfully changed to. |
| 156 | // This maintains an old API contract on the plugin side. We use the real map name even if it was different from |
| 157 | // the expected map name as if the expected map failed to load we let the game take over instead, but the nextmap |
| 158 | // plugin compares the sm_nextmap value to the current map to decide if it should advance the mapcycle. |
| 159 | if (g_nextMap[0] != '\0') { |
| 160 | sm_nextmap.SetValue(mapName); |
| 161 | g_nextMap[0] = '\0'; |
| 162 | } |
| 163 | |
| 164 | /* Skip the first 'mapchange' when the server starts up */ |
| 165 | if (m_tempChangeInfo.startTime != 0) |
| 166 | { |
| 167 | if (strcmp(mapName, m_tempChangeInfo.m_mapName) == 0) |
| 168 | { |
| 169 | /* The map change was as we expected */ |
| 170 | m_mapHistory.push_back(new MapChangeData(lastMap, m_tempChangeInfo.m_changeReason, m_tempChangeInfo.startTime)); |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | /* Something intercepted the mapchange */ |
| 175 | char newReason[255]; |
| 176 | ke::SafeSprintf(newReason, sizeof(newReason), "%s (Map overridden)", m_tempChangeInfo.m_changeReason); |
| 177 | m_mapHistory.push_back(new MapChangeData(lastMap, newReason, m_tempChangeInfo.startTime)); |
| 178 | } |
| 179 | |
| 180 | int historydiff = sm_maphistory_size.GetInt(); |
| 181 | if (historydiff > 0) |
| 182 | { |
| 183 | historydiff -= m_mapHistory.size(); |
| 184 | } else if (historydiff < 0) |
| 185 | { |
| 186 | historydiff = (m_mapHistory.size() * -1); |
| 187 | } |
| 188 | |
| 189 | for (SourceHook::List<MapChangeData *>::iterator iter = m_mapHistory.begin(); historydiff++ < 0; iter = m_mapHistory.erase(iter)) |
| 190 | { |
| 191 | delete (MapChangeData *)*iter; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | m_tempChangeInfo.m_mapName[0] ='\0'; |
| 196 | m_tempChangeInfo.m_changeReason[0] = '\0'; |
| 197 | m_tempChangeInfo.startTime = time(NULL); |
| 198 | ke::SafeStrcpy(lastMap, sizeof(lastMap), mapName); |
| 199 | } |
| 200 | |
| 201 | void NextMapManager::ForceChangeLevel( const char *mapName, const char* changeReason ) |
| 202 | { |