public static void ParseConfigString( ) { Int32 i = MSG.ReadShort(Globals.net_message); if (i < 0 || i >= Defines.MAX_CONFIGSTRINGS) { Com.Error(Defines.ERR_DROP, "configstring > MAX_CONFIGSTRINGS"); } var s = MSG.ReadString(Globals.net_message); var olds = Globals.cl.configstrings[i]; Globals.cl.configstrings[i] = s; if (i >= Defines.CS_LIGHTS && i < Defines.CS_LIGHTS + Defines.MAX_LIGHTSTYLES) { CL_fx.SetLightstyle(i - Defines.CS_LIGHTS); } else if (i >= Defines.CS_MODELS && i < Defines.CS_MODELS + Defines.MAX_MODELS) { if (Globals.cl.refresh_prepped) { Globals.cl.model_draw[i - Defines.CS_MODELS] = Globals.re.RegisterModel(Globals.cl.configstrings[i]); if (Globals.cl.configstrings[i].StartsWith("*")) { Globals.cl.model_clip[i - Defines.CS_MODELS] = CM.InlineModel(Globals.cl.configstrings[i]); } else { Globals.cl.model_clip[i - Defines.CS_MODELS] = null; } } } else if (i >= Defines.CS_SOUNDS && i < Defines.CS_SOUNDS + Defines.MAX_MODELS) { if (Globals.cl.refresh_prepped) { Globals.cl.sound_precache[i - Defines.CS_SOUNDS] = S.RegisterSound(Globals.cl.configstrings[i]); } } else if (i >= Defines.CS_IMAGES && i < Defines.CS_IMAGES + Defines.MAX_MODELS) { if (Globals.cl.refresh_prepped) { Globals.cl.image_precache[i - Defines.CS_IMAGES] = Globals.re.RegisterPic(Globals.cl.configstrings[i]); } } else if (i >= Defines.CS_PLAYERSKINS && i < Defines.CS_PLAYERSKINS + Defines.MAX_CLIENTS) { if (Globals.cl.refresh_prepped && !olds.Equals(s)) { ParseClientinfo(i - Defines.CS_PLAYERSKINS); } } }
public static void PF_setmodel(edict_t ent, string name) { int i; cmodel_t mod; if (name == null) { Com.Error(Defines.ERR_DROP, "PF_setmodel: NULL"); } i = SV_INIT.SV_ModelIndex(name); ent.s.modelindex = i; if (name.StartsWith("*")) { mod = CM.InlineModel(name); Math3D.VectorCopy(mod.mins, ent.mins); Math3D.VectorCopy(mod.maxs, ent.maxs); SV_WORLD.SV_LinkEdict(ent); } }
public static void PrepRefresh() { string mapname; int i; string name; float rotate; float[] axis = new float[3]; if ((i = Globals.cl.configstrings[Defines.CS_MODELS + 1].Length) == 0) { return; } SCR.AddDirtyPoint(0, 0); SCR.AddDirtyPoint(Globals.viddef.GetWidth() - 1, Globals.viddef.GetHeight() - 1); mapname = Globals.cl.configstrings[Defines.CS_MODELS + 1].Substring(5, i - 4); Com.Printf("Map: " + mapname + "\\r"); SCR.UpdateScreen(); Globals.re.BeginRegistration(mapname); Com.Printf(" \\r"); Com.Printf("pics\\r"); SCR.UpdateScreen(); SCR.TouchPics(); Com.Printf(" \\r"); CL_tent.RegisterTEntModels(); num_cl_weaponmodels = 1; cl_weaponmodels[0] = "weapon.md2"; for (i = 1; i < Defines.MAX_MODELS && Globals.cl.configstrings[Defines.CS_MODELS + i].Length != 0; i++) { name = new string (Globals.cl.configstrings[Defines.CS_MODELS + i]); if (name.Length > 37) { name = name.Substring(0, 36); } if (name[0] != '*') { Com.Printf(name + "\\r"); } SCR.UpdateScreen(); CoreSys.SendKeyEvents(); if (name[0] == '#') { if (num_cl_weaponmodels < Defines.MAX_CLIENTWEAPONMODELS) { cl_weaponmodels[num_cl_weaponmodels] = Globals.cl.configstrings[Defines.CS_MODELS + i].Substring(1); num_cl_weaponmodels++; } } else { Globals.cl.model_draw[i] = Globals.re.RegisterModel(Globals.cl.configstrings[Defines.CS_MODELS + i]); if (name[0] == '*') { Globals.cl.model_clip[i] = CM.InlineModel(Globals.cl.configstrings[Defines.CS_MODELS + i]); } else { Globals.cl.model_clip[i] = null; } } if (name[0] != '*') { Com.Printf(" \\r"); } } Com.Printf("images\\r"); SCR.UpdateScreen(); for (i = 1; i < Defines.MAX_IMAGES && Globals.cl.configstrings[Defines.CS_IMAGES + i].Length > 0; i++) { Globals.cl.image_precache[i] = Globals.re.RegisterPic(Globals.cl.configstrings[Defines.CS_IMAGES + i]); CoreSys.SendKeyEvents(); } Com.Printf(" \\r"); for (i = 0; i < Defines.MAX_CLIENTS; i++) { if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i].Length == 0) { continue; } Com.Printf("client " + i + '\\'); SCR.UpdateScreen(); CoreSys.SendKeyEvents(); CL_parse.ParseClientinfo(i); Com.Printf(" \\r"); } CL_parse.LoadClientinfo(Globals.cl.baseclientinfo, "unnamed\\\\male/grunt"); Com.Printf("sky\\r"); SCR.UpdateScreen(); rotate = float.Parse(Globals.cl.configstrings[Defines.CS_SKYROTATE]); StringTokenizer st = new StringTokenizer(Globals.cl.configstrings[Defines.CS_SKYAXIS]); st.MoveNext(); axis[0] = float.Parse(st.Current); st.MoveNext(); axis[1] = float.Parse(st.Current); st.MoveNext(); axis[2] = float.Parse(st.Current); Globals.re.SetSky(Globals.cl.configstrings[Defines.CS_SKY], rotate, axis); Com.Printf(" \\r"); Globals.re.EndRegistration(); Con.ClearNotify(); SCR.UpdateScreen(); Globals.cl.refresh_prepped = true; Globals.cl.force_refdef = true; }
/** * SV_SpawnServer. * * Change the server to a new map, taking all connected clients along with * it. */ public static void SV_SpawnServer(string server, string spawnpoint, int serverstate, bool attractloop, bool loadgame) { int i; var checksum = 0; if (attractloop) { Cvar.Set("paused", "0"); } Com.Printf("------- Server Initialization -------\n"); Com.DPrintf("SpawnServer: " + server + "\n"); if (SV_INIT.sv.demofile != null) { try { SV_INIT.sv.demofile.Close(); } catch (Exception) { } } // any partially connected client will be restarted SV_INIT.svs.spawncount++; SV_INIT.sv.state = Defines.ss_dead; Globals.server_state = SV_INIT.sv.state; // wipe the entire per-level structure SV_INIT.sv = new(); SV_INIT.svs.realtime = 0; SV_INIT.sv.loadgame = loadgame; SV_INIT.sv.attractloop = attractloop; // save name for levels that don't set message SV_INIT.sv.configstrings[Defines.CS_NAME] = server; if (Cvar.VariableValue("deathmatch") != 0) { SV_INIT.sv.configstrings[Defines.CS_AIRACCEL] = "" + SV_MAIN.sv_airaccelerate.value; PMove.pm_airaccelerate = SV_MAIN.sv_airaccelerate.value; } else { SV_INIT.sv.configstrings[Defines.CS_AIRACCEL] = "0"; PMove.pm_airaccelerate = 0; } SZ.Init(SV_INIT.sv.multicast, SV_INIT.sv.multicast_buf, SV_INIT.sv.multicast_buf.Length); SV_INIT.sv.name = server; // leave slots at start for clients only for (i = 0; i < SV_MAIN.maxclients.value; i++) { // needs to reconnect if (SV_INIT.svs.clients[i].state > Defines.cs_connected) { SV_INIT.svs.clients[i].state = Defines.cs_connected; } SV_INIT.svs.clients[i].lastframe = -1; } SV_INIT.sv.time = 1000; SV_INIT.sv.name = server; SV_INIT.sv.configstrings[Defines.CS_NAME] = server; int[] iw = { checksum }; if (serverstate != Defines.ss_game) { SV_INIT.sv.models[1] = CM.CM_LoadMap("", false, iw); // no real map } else { SV_INIT.sv.configstrings[Defines.CS_MODELS + 1] = "maps/" + server + ".bsp"; SV_INIT.sv.models[1] = CM.CM_LoadMap(SV_INIT.sv.configstrings[Defines.CS_MODELS + 1], false, iw); } checksum = iw[0]; SV_INIT.sv.configstrings[Defines.CS_MAPCHECKSUM] = "" + checksum; // clear physics interaction links SV_WORLD.SV_ClearWorld(); for (i = 1; i < CM.CM_NumInlineModels(); i++) { SV_INIT.sv.configstrings[Defines.CS_MODELS + 1 + i] = "*" + i; // copy references SV_INIT.sv.models[i + 1] = CM.InlineModel(SV_INIT.sv.configstrings[Defines.CS_MODELS + 1 + i]); } // spawn the rest of the entities on the map // precache and static commands can be issued during // map initialization SV_INIT.sv.state = Defines.ss_loading; Globals.server_state = SV_INIT.sv.state; // load and spawn all other entities GameSpawn.SpawnEntities(SV_INIT.sv.name, CM.CM_EntityString(), spawnpoint); // run two frames to allow everything to settle GameBase.G_RunFrame(); GameBase.G_RunFrame(); // all precaches are complete SV_INIT.sv.state = serverstate; Globals.server_state = SV_INIT.sv.state; // create a baseline for more efficient communications SV_INIT.SV_CreateBaseline(); // check for a savegame SV_INIT.SV_CheckForSavegame(); // set serverinfo variable Cvar.FullSet("mapname", SV_INIT.sv.name, Defines.CVAR_SERVERINFO | Defines.CVAR_NOSET); }
public static void SV_SpawnServer(String server, String spawnpoint, Int32 serverstate, Boolean attractloop, Boolean loadgame) { Int32 i; var checksum = 0; if (attractloop) { Cvar.Set("paused", "0"); } Com.Printf("------- Server Initialization -------\\n"); Com.DPrintf("SpawnServer: " + server + "\\n"); if (sv.demofile != null) { try { sv.demofile.Close(); } catch (Exception e) { } } svs.spawncount++; sv.state = Defines.ss_dead; Globals.server_state = sv.state; sv = new server_t(); svs.realtime = 0; sv.loadgame = loadgame; sv.attractloop = attractloop; sv.configstrings[Defines.CS_NAME] = server; if (Cvar.VariableValue("deathmatch") != 0) { sv.configstrings[Defines.CS_AIRACCEL] = "" + SV_MAIN.sv_airaccelerate.value; PMove.pm_airaccelerate = SV_MAIN.sv_airaccelerate.value; } else { sv.configstrings[Defines.CS_AIRACCEL] = "0"; PMove.pm_airaccelerate = 0; } SZ.Init(sv.multicast, sv.multicast_buf, sv.multicast_buf.Length); sv.name = server; for (i = 0; i < SV_MAIN.maxclients.value; i++) { if (svs.clients[i].state > Defines.cs_connected) { svs.clients[i].state = Defines.cs_connected; } svs.clients[i].lastframe = -1; } sv.time = 1000; sv.name = server; sv.configstrings[Defines.CS_NAME] = server; Int32[] iw = new[] { checksum }; if (serverstate != Defines.ss_game) { sv.models[1] = CM.CM_LoadMap("", false, iw); } else { sv.configstrings[Defines.CS_MODELS + 1] = "maps/" + server + ".bsp"; sv.models[1] = CM.CM_LoadMap(sv.configstrings[Defines.CS_MODELS + 1], false, iw); } checksum = iw[0]; sv.configstrings[Defines.CS_MAPCHECKSUM] = "" + checksum; SV_WORLD.SV_ClearWorld(); for (i = 1; i < CM.CM_NumInlineModels(); i++) { sv.configstrings[Defines.CS_MODELS + 1 + i] = "*" + i; sv.models[i + 1] = CM.InlineModel(sv.configstrings[Defines.CS_MODELS + 1 + i]); } sv.state = Defines.ss_loading; Globals.server_state = sv.state; GameSpawn.SpawnEntities(sv.name, CM.CM_EntityString(), spawnpoint); GameBase.G_RunFrame(); GameBase.G_RunFrame(); sv.state = serverstate; Globals.server_state = sv.state; SV_CreateBaseline(); SV_CheckForSavegame(); Cvar.FullSet("mapname", sv.name, Defines.CVAR_SERVERINFO | Defines.CVAR_NOSET); }