/* * =============================================================================== * * OPERATOR CONSOLE ONLY COMMANDS * * These commands can only be entered from stdin or by a remote operator datagram * =============================================================================== */ /* * ==================== * SV_SetMaster_f * * Specify a list of master servers * ==================== */ public static void SV_SetMaster_f() { int i, slot; // only dedicated servers send heartbeats if (Globals.dedicated.value == 0) { Com.Printf("Only dedicated servers use masters.\n"); return; } // make sure the server is listed public Cvar.Set("public", "1"); for (i = 1; i < Defines.MAX_MASTERS; i++) { SV_MAIN.master_adr[i] = new(); } slot = 1; // slot 0 will always contain the id master for (i = 1; i < Cmd.Argc(); i++) { if (slot == Defines.MAX_MASTERS) { break; } if (!NET.StringToAdr(Cmd.Argv(i), SV_MAIN.master_adr[i])) { Com.Printf("Bad address: " + Cmd.Argv(i) + "\n"); continue; } if (SV_MAIN.master_adr[slot].port == 0) { SV_MAIN.master_adr[slot].port = Defines.PORT_MASTER; } Com.Printf("Master server at " + NET.AdrToString(SV_MAIN.master_adr[slot]) + "\n"); Com.Printf("Sending a ping.\n"); Netchan.OutOfBandPrint(Defines.NS_SERVER, SV_MAIN.master_adr[slot], "ping"); slot++; } SV_INIT.svs.last_heartbeat = -9999999; }
/** * SV_InitGame. * * A brand new game has been started. */ public static void SV_InitGame() { int i; edict_t ent; //char idmaster[32]; string idmaster; if (SV_INIT.svs.initialized) { // cause any connected clients to reconnect SV_MAIN.SV_Shutdown("Server restarted\n", true); } else { // make sure the client is down Cl.Drop(); SCR.BeginLoadingPlaque(); } // get any latched variable changes (maxclients, etc) Cvar.GetLatchedVars(); SV_INIT.svs.initialized = true; if (Cvar.VariableValue("coop") != 0 && Cvar.VariableValue("deathmatch") != 0) { Com.Printf("Deathmatch and Coop both set, disabling Coop\n"); Cvar.FullSet("coop", "0", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } // dedicated servers are can't be single player and are usually DM // so unless they explicity set coop, force it to deathmatch if (Globals.dedicated.value != 0) { if (0 == Cvar.VariableValue("coop")) { Cvar.FullSet("deathmatch", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } } // init clients if (Cvar.VariableValue("deathmatch") != 0) { if (SV_MAIN.maxclients.value <= 1) { Cvar.FullSet("maxclients", "8", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } else if (SV_MAIN.maxclients.value > Defines.MAX_CLIENTS) { Cvar.FullSet("maxclients", "" + Defines.MAX_CLIENTS, Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } } else if (Cvar.VariableValue("coop") != 0) { if (SV_MAIN.maxclients.value <= 1 || SV_MAIN.maxclients.value > 4) { Cvar.FullSet("maxclients", "4", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } } else // non-deathmatch, non-coop is one player { Cvar.FullSet("maxclients", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } SV_INIT.svs.spawncount = Lib.rand(); SV_INIT.svs.clients = new client_t[(int)SV_MAIN.maxclients.value]; for (var n = 0; n < SV_INIT.svs.clients.Length; n++) { SV_INIT.svs.clients[n] = new(); SV_INIT.svs.clients[n].serverindex = n; } SV_INIT.svs.num_client_entities = (int)SV_MAIN.maxclients.value * Defines.UPDATE_BACKUP * 64; //ok. SV_INIT.svs.client_entities = new entity_state_t[SV_INIT.svs.num_client_entities]; for (var n = 0; n < SV_INIT.svs.client_entities.Length; n++) { SV_INIT.svs.client_entities[n] = new(null); } // init network stuff NET.ConfigServer(SV_MAIN.maxclients.value > 1); // heartbeats will always be sent to the id master SV_INIT.svs.last_heartbeat = -99999; // send immediately idmaster = "192.246.40.37:" + Defines.PORT_MASTER; NET.StringToAdr(idmaster, SV_MAIN.master_adr[0]); // init game SV_GAME.SV_InitGameProgs(); for (i = 0; i < SV_MAIN.maxclients.value; i++) { ent = GameBase.g_edicts[i + 1]; SV_INIT.svs.clients[i].edict = ent; SV_INIT.svs.clients[i].lastcmd = new(); } }
public static void SV_InitGame( ) { Int32 i; edict_t ent; String idmaster; if (svs.initialized) { SV_MAIN.SV_Shutdown("Server restarted\\n", true); } else { CL.Drop(); SCR.BeginLoadingPlaque(); } Cvar.GetLatchedVars(); svs.initialized = true; if (Cvar.VariableValue("coop") != 0 && Cvar.VariableValue("deathmatch") != 0) { Com.Printf("Deathmatch and Coop both set, disabling Coop\\n"); Cvar.FullSet("coop", "0", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } if (Globals.dedicated.value != 0) { if (0 == Cvar.VariableValue("coop")) { Cvar.FullSet("deathmatch", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } } if (Cvar.VariableValue("deathmatch") != 0) { if (SV_MAIN.maxclients.value <= 1) { Cvar.FullSet("maxclients", "8", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } else if (SV_MAIN.maxclients.value > Defines.MAX_CLIENTS) { Cvar.FullSet("maxclients", "" + Defines.MAX_CLIENTS, Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } } else if (Cvar.VariableValue("coop") != 0) { if (SV_MAIN.maxclients.value <= 1 || SV_MAIN.maxclients.value > 4) { Cvar.FullSet("maxclients", "4", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } } else { Cvar.FullSet("maxclients", "1", Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH); } svs.spawncount = Lib.Rand(); svs.clients = new client_t[( Int32 )SV_MAIN.maxclients.value]; for (var n = 0; n < svs.clients.Length; n++) { svs.clients[n] = new client_t(); svs.clients[n].serverindex = n; } svs.num_client_entities = (( Int32 )SV_MAIN.maxclients.value) * Defines.UPDATE_BACKUP * 64; svs.client_entities = new entity_state_t[svs.num_client_entities]; for (var n = 0; n < svs.client_entities.Length; n++) { svs.client_entities[n] = new entity_state_t(null); } NET.Config((SV_MAIN.maxclients.value > 1)); svs.last_heartbeat = -99999; idmaster = "192.246.40.37:" + Defines.PORT_MASTER; NET.StringToAdr(idmaster, SV_MAIN.master_adr[0]); SV_GAME.SV_InitGameProgs(); for (i = 0; i < SV_MAIN.maxclients.value; i++) { ent = GameBase.g_edicts[i + 1]; svs.clients[i].edict = ent; svs.clients[i].lastcmd = new usercmd_t(); } }