MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / HookChangeLevel

Method HookChangeLevel

core/NextMap.cpp:117–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115void NextMapManager::HookChangeLevel(const char *map, const char *unknown)
116#else
117void NextMapManager::HookChangeLevel(const char *map, const char *unknown, const char *video, bool bLongLoading)
118#endif
119{
120 if (g_forcedChange)
121 {
122 logger->LogMessage("[SM] Changed map to \"%s\"", map);
123 RETURN_META(MRES_IGNORED);
124 }
125
126 const char *newmap = sm_nextmap.GetString();
127 if (newmap[0] != '\0') {
128 ke::SafeStrcpy(g_nextMap, sizeof(g_nextMap), newmap);
129 newmap = g_nextMap;
130
131 // Clear the value so that if the map load fails later we don't get stuck in a loop.
132 // This might cause us to go off-cycle for a map, but nextmap will get us back on track.
133 sm_nextmap.SetValue("");
134 }
135
136 if (newmap[0] == '\0' || !g_HL2.IsMapValid(newmap))
137 {
138 RETURN_META(MRES_IGNORED);
139 }
140
141 logger->LogMessage("[SM] Changed map to \"%s\"", newmap);
142
143 ke::SafeStrcpy(m_tempChangeInfo.m_mapName, sizeof(m_tempChangeInfo.m_mapName), newmap);
144 ke::SafeStrcpy(m_tempChangeInfo.m_changeReason, sizeof(m_tempChangeInfo.m_changeReason), "Normal level change");
145
146#if SOURCE_ENGINE != SE_DARKMESSIAH
147 RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::ChangeLevel, (newmap, unknown));
148#else
149 RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::ChangeLevel, (newmap, unknown, video, bLongLoading));
150#endif
151}
152
153void NextMapManager::OnSourceModLevelChange( const char *mapName )
154{

Callers

nothing calls this directly

Calls 4

SetValueMethod · 0.80
IsMapValidMethod · 0.80
LogMessageMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected