MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / Session_Map_f

Function Session_Map_f

neo/framework/Session.cpp:106–145  ·  view source on GitHub ↗

================== Session_Map_f Restart the server on a different map ================== */

Source from the content-addressed store, hash-verified

104==================
105*/
106static void Session_Map_f( const idCmdArgs &args ) {
107 idStr map, string;
108 findFile_t ff;
109 idCmdArgs rl_args;
110
111 map = args.Argv(1);
112 if ( !map.Length() ) {
113 // DG: if the map command is called without any arguments, print the current map
114 // TODO: could check whether we're currently in a game, otherwise the last loaded
115 // map is printed.. but OTOH, who cares
116 const char* curmap = sessLocal.mapSpawnData.serverInfo.GetString( "si_map" );
117 if ( curmap[0] != '\0' ) {
118 common->Printf( "Current Map: %s\n", curmap );
119 }
120 return;
121 }
122 map.StripFileExtension();
123
124 // make sure the level exists before trying to change, so that
125 // a typo at the server console won't end the game
126 // handle addon packs through reloadEngine
127 sprintf( string, "maps/%s.map", map.c_str() );
128 ff = fileSystem->FindFile( string, true );
129 switch ( ff ) {
130 case FIND_NO:
131 common->Printf( "Can't find map %s\n", string.c_str() );
132 return;
133 case FIND_ADDON:
134 common->Printf( "map %s is in an addon pak - reloading\n", string.c_str() );
135 rl_args.AppendArg( "map" );
136 rl_args.AppendArg( map );
137 cmdSystem->SetupReloadEngine( rl_args );
138 return;
139 default:
140 break;
141 }
142
143 cvarSystem->SetCVarBool( "developer", false );
144 sessLocal.StartNewGame( map, true );
145}
146
147/*
148==================

Callers

nothing calls this directly

Calls 11

sprintfFunction · 0.85
ArgvMethod · 0.80
FindFileMethod · 0.80
AppendArgMethod · 0.80
SetupReloadEngineMethod · 0.80
SetCVarBoolMethod · 0.80
StartNewGameMethod · 0.80
LengthMethod · 0.45
GetStringMethod · 0.45
PrintfMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected