/// <summary> /// SV_SpawnServer /// </summary> public static void SpawnServer(string server) { // let's not have any servers with no name if (String.IsNullOrEmpty(Net.HostName)) { Cvar.Set("hostname", "UNNAMED"); } Scr.CenterTimeOff = 0; Con.DPrint("SpawnServer: {0}\n", server); svs.changelevel_issued = false; // now safe to issue another // // tell all connected clients that we are going to a new level // if (sv.active) { SendReconnect(); } // // make cvars consistant // if (Host.IsCoop) { Cvar.Set("deathmatch", 0); } Host.CurrentSkill = (int)(Host.Skill + 0.5); if (Host.CurrentSkill < 0) { Host.CurrentSkill = 0; } if (Host.CurrentSkill > 3) { Host.CurrentSkill = 3; } Cvar.Set("skill", (float)Host.CurrentSkill); // // set up the new server // Host.ClearMemory(); sv.Clear(); sv.name = server; // load progs to get entity field count Progs.LoadProgs(); // allocate server memory sv.max_edicts = QDef.MAX_EDICTS; sv.edicts = new edict_t[sv.max_edicts]; for (int i = 0; i < sv.edicts.Length; i++) { sv.edicts[i] = new edict_t(); } // leave slots at start for clients only sv.num_edicts = svs.maxclients + 1; edict_t ent; for (int i = 0; i < svs.maxclients; i++) { ent = EdictNum(i + 1); svs.clients[i].edict = ent; } sv.state = server_state_t.Loading; sv.paused = false; sv.time = 1.0; sv.modelname = String.Format("maps/{0}.bsp", server); sv.worldmodel = Mod.ForName(sv.modelname, false); if (sv.worldmodel == null) { Con.Print("Couldn't spawn server {0}\n", sv.modelname); sv.active = false; return; } sv.models[1] = sv.worldmodel; // // clear world interaction links // ClearWorld(); sv.sound_precache[0] = String.Empty; sv.model_precache[0] = String.Empty; sv.model_precache[1] = sv.modelname; for (int i = 1; i < sv.worldmodel.numsubmodels; i++) { sv.model_precache[1 + i] = _LocalModels[i]; sv.models[i + 1] = Mod.ForName(_LocalModels[i], false); } // // load the rest of the entities // ent = EdictNum(0); ent.Clear(); ent.v.model = Progs.StringOffset(sv.worldmodel.name); if (ent.v.model == -1) { ent.v.model = Progs.NewString(sv.worldmodel.name); } ent.v.modelindex = 1; // world model ent.v.solid = Solids.SOLID_BSP; ent.v.movetype = Movetypes.MOVETYPE_PUSH; if (Host.IsCoop) { Progs.GlobalStruct.coop = 1; //coop.value; } else { Progs.GlobalStruct.deathmatch = Host.Deathmatch; } int offset = Progs.NewString(sv.name); Progs.GlobalStruct.mapname = offset; // serverflags are for cross level information (sigils) Progs.GlobalStruct.serverflags = svs.serverflags; Progs.LoadFromFile(sv.worldmodel.entities); sv.active = true; // all setup is completed, any further precache statements are errors sv.state = server_state_t.Active; // run two frames to allow everything to settle Host.FrameTime = 0.1; Physics(); Physics(); // create a baseline for more efficient communications CreateBaseline(); // send serverinfo to all connected clients for (int i = 0; i < svs.maxclients; i++) { Host.HostClient = svs.clients[i]; if (Host.HostClient.active) { SendServerInfo(Host.HostClient); } } GC.Collect(); Con.DPrint("Server spawned.\n"); }
/// <summary> /// Host_FindMaxClients /// </summary> static void FindMaxClients() { server_static_t svs = Server.svs; client_static_t cls = Client.cls; svs.maxclients = 1; int i = Common.CheckParm("-dedicated"); if (i > 0) { cls.state = cactive_t.ca_dedicated; if (i != (Common.Argc - 1)) { svs.maxclients = Common.atoi(Common.Argv(i + 1)); } else { svs.maxclients = 8; } } else { cls.state = cactive_t.ca_disconnected; } i = Common.CheckParm("-listen"); if (i > 0) { if (cls.state == cactive_t.ca_dedicated) { Sys.Error("Only one of -dedicated or -listen can be specified"); } if (i != (Common.Argc - 1)) { svs.maxclients = Common.atoi(Common.Argv(i + 1)); } else { svs.maxclients = 8; } } if (svs.maxclients < 1) { svs.maxclients = 8; } else if (svs.maxclients > QDef.MAX_SCOREBOARD) { svs.maxclients = QDef.MAX_SCOREBOARD; } svs.maxclientslimit = svs.maxclients; if (svs.maxclientslimit < 4) { svs.maxclientslimit = 4; } svs.clients = new client_t[svs.maxclientslimit]; // Hunk_AllocName (svs.maxclientslimit*sizeof(client_t), "clients"); for (i = 0; i < svs.clients.Length; i++) { svs.clients[i] = new client_t(); } if (svs.maxclients > 1) { Cvar.Set("deathmatch", 1.0f); } else { Cvar.Set("deathmatch", 0.0f); } }
/// <summary> /// _Datagram_CheckNewConnections /// </summary> public qsocket_t InternalCheckNewConnections() { Socket acceptsock = Net.LanDriver.CheckNewConnections(); if (acceptsock == null) { return(null); } EndPoint clientaddr = new IPEndPoint(IPAddress.Any, 0); Net.Message.FillFrom(acceptsock, ref clientaddr); if (Net.Message.Length < sizeof(int)) { return(null); } Net.Reader.Reset(); int control = Common.BigLong(Net.Reader.ReadLong()); if (control == -1) { return(null); } if ((control & (~NetFlags.NETFLAG_LENGTH_MASK)) != NetFlags.NETFLAG_CTL) { return(null); } if ((control & NetFlags.NETFLAG_LENGTH_MASK) != Net.Message.Length) { return(null); } int command = Net.Reader.ReadByte(); if (command == CCReq.CCREQ_SERVER_INFO) { string tmp = Net.Reader.ReadString(); if (tmp != "QUAKE") { return(null); } Net.Message.Clear(); // save space for the header, filled in later Net.Message.WriteLong(0); Net.Message.WriteByte(CCRep.CCREP_SERVER_INFO); EndPoint newaddr = acceptsock.LocalEndPoint; //dfunc.GetSocketAddr(acceptsock, &newaddr); Net.Message.WriteString(newaddr.ToString()); // dfunc.AddrToString(&newaddr)); Net.Message.WriteString(Net.HostName); Net.Message.WriteString(Server.sv.name); Net.Message.WriteByte(Net.ActiveConnections); Net.Message.WriteByte(Server.svs.maxclients); Net.Message.WriteByte(Net.NET_PROTOCOL_VERSION); Common.WriteInt(Net.Message.Data, 0, Common.BigLong(NetFlags.NETFLAG_CTL | (Net.Message.Length & NetFlags.NETFLAG_LENGTH_MASK))); Net.LanDriver.Write(acceptsock, Net.Message.Data, Net.Message.Length, clientaddr); Net.Message.Clear(); return(null); } if (command == CCReq.CCREQ_PLAYER_INFO) { int playerNumber = Net.Reader.ReadByte(); int clientNumber, activeNumber = -1; client_t client = null; for (clientNumber = 0; clientNumber < Server.svs.maxclients; clientNumber++) { client = Server.svs.clients[clientNumber]; if (client.active) { activeNumber++; if (activeNumber == playerNumber) { break; } } } if (clientNumber == Server.svs.maxclients) { return(null); } Net.Message.Clear(); // save space for the header, filled in later Net.Message.WriteLong(0); Net.Message.WriteByte(CCRep.CCREP_PLAYER_INFO); Net.Message.WriteByte(playerNumber); Net.Message.WriteString(client.name); Net.Message.WriteLong(client.colors); Net.Message.WriteLong((int)client.edict.v.frags); Net.Message.WriteLong((int)(Net.Time - client.netconnection.connecttime)); Net.Message.WriteString(client.netconnection.address); Common.WriteInt(Net.Message.Data, 0, Common.BigLong(NetFlags.NETFLAG_CTL | (Net.Message.Length & NetFlags.NETFLAG_LENGTH_MASK))); Net.LanDriver.Write(acceptsock, Net.Message.Data, Net.Message.Length, clientaddr); Net.Message.Clear(); return(null); } if (command == CCReq.CCREQ_RULE_INFO) { // find the search start location string prevCvarName = Net.Reader.ReadString(); Cvar var; if (!String.IsNullOrEmpty(prevCvarName)) { var = Cvar.Find(prevCvarName); if (var == null) { return(null); } var = var.Next; } else { var = Cvar.First; } // search for the next server cvar while (var != null) { if (var.IsServer) { break; } var = var.Next; } // send the response Net.Message.Clear(); // save space for the header, filled in later Net.Message.WriteLong(0); Net.Message.WriteByte(CCRep.CCREP_RULE_INFO); if (var != null) { Net.Message.WriteString(var.Name); Net.Message.WriteString(var.String); } Common.WriteInt(Net.Message.Data, 0, Common.BigLong(NetFlags.NETFLAG_CTL | (Net.Message.Length & NetFlags.NETFLAG_LENGTH_MASK))); Net.LanDriver.Write(acceptsock, Net.Message.Data, Net.Message.Length, clientaddr); Net.Message.Clear(); return(null); } if (command != CCReq.CCREQ_CONNECT) { return(null); } if (Net.Reader.ReadString() != "QUAKE") { return(null); } if (Net.Reader.ReadByte() != Net.NET_PROTOCOL_VERSION) { Net.Message.Clear(); // save space for the header, filled in later Net.Message.WriteLong(0); Net.Message.WriteByte(CCRep.CCREP_REJECT); Net.Message.WriteString("Incompatible version.\n"); Common.WriteInt(Net.Message.Data, 0, Common.BigLong(NetFlags.NETFLAG_CTL | (Net.Message.Length & NetFlags.NETFLAG_LENGTH_MASK))); Net.LanDriver.Write(acceptsock, Net.Message.Data, Net.Message.Length, clientaddr); Net.Message.Clear(); return(null); } #if BAN_TEST // check for a ban if (clientaddr.sa_family == AF_INET) { unsigned long testAddr; testAddr = ((struct sockaddr_in *)&clientaddr)->sin_addr.s_addr;
// SCR_SizeDown_f // // Keybinding command static void SizeDown_f() { Cvar.Set("viewsize", _ViewSize.Value - 10); _VidDef.recalc_refdef = true; }
// SCR_CalcRefdef // // Must be called whenever vid changes // Internal use only static void CalcRefdef() { Scr.FullUpdate = 0; // force a background redraw _VidDef.recalc_refdef = false; // force the status bar to redraw Sbar.Changed(); // bound viewsize if (_ViewSize.Value < 30) { Cvar.Set("viewsize", "30"); } if (_ViewSize.Value > 120) { Cvar.Set("viewsize", "120"); } // bound field of view if (_Fov.Value < 10) { Cvar.Set("fov", "10"); } if (_Fov.Value > 170) { Cvar.Set("fov", "170"); } // intermission is always full screen float size; if (Client.cl.intermission > 0) { size = 120; } else { size = _ViewSize.Value; } //if (size >= 120) // Sbar.Lines = 0; // no status bar at all //else if (size >= 110) // Sbar.Lines = 24; // no inventory //else Sbar.Lines = 24 + 16 + 8; bool full = false; if (_ViewSize.Value >= 100.0) { full = true; size = 100.0f; } else { size = _ViewSize.Value; } if (Client.cl.intermission > 0) { full = true; size = 100; Sbar.Lines = 0; } size /= 100.0f; int h = _VidDef.height;// - Sbar.Lines; refdef_t rdef = Render.RefDef; rdef.vrect.width = (int)(_VidDef.width * size); if (rdef.vrect.width < 96) { size = 96.0f / rdef.vrect.width; rdef.vrect.width = 96; // min for icons } rdef.vrect.height = (int)(_VidDef.height * size); if (rdef.vrect.height > _VidDef.height /* - Sbar.Lines*/) { rdef.vrect.height = _VidDef.height /* - Sbar.Lines*/; } if (rdef.vrect.height > _VidDef.height) { rdef.vrect.height = _VidDef.height; } rdef.vrect.x = (_VidDef.width - rdef.vrect.width) / 2; if (full) { rdef.vrect.y = 0; } else { rdef.vrect.y = (h - rdef.vrect.height) / 2; } rdef.fov_x = _Fov.Value; rdef.fov_y = CalcFov(rdef.fov_x, rdef.vrect.width, rdef.vrect.height); _VRect = rdef.vrect; }
/// <summary> /// UDP_Init /// </summary> public bool Init() { _IsInitialized = false; if (Common.HasParam("-noudp")) { return(false); } // determine my name string hostName; try { hostName = Dns.GetHostName(); } catch (SocketException se) { Con.DPrint("Cannot get host name: {0}\n", se.Message); return(false); } // if the quake hostname isn't set, set it to the machine name if (Net.HostName == "UNNAMED") { IPAddress addr; if (!IPAddress.TryParse(hostName, out addr)) { int i = hostName.IndexOf('.'); if (i != -1) { hostName = hostName.Substring(0, i); } } Cvar.Set("hostname", hostName); } int i2 = Common.CheckParm("-ip"); if (i2 > 0) { if (i2 < Common.Argc - 1) { string ipaddr = Common.Argv(i2 + 1); if (!IPAddress.TryParse(ipaddr, out _MyAddress)) { Sys.Error("{0} is not a valid IP address!", ipaddr); } Net.MyTcpIpAddress = ipaddr; } else { Sys.Error("Net.Init: you must specify an IP address after -ip"); } } else { _MyAddress = IPAddress.Any; Net.MyTcpIpAddress = "INADDR_ANY"; } _ControlSocket = OpenSocket(0); if (_ControlSocket == null) { Con.Print("TCP/IP: Unable to open control socket\n"); return(false); } _BroadcastAddress = new IPEndPoint(IPAddress.Broadcast, Net.HostPort); _IsInitialized = true; Con.Print("TCP/IP Initialized\n"); return(true); }
// Draw_Init public static void Init() { for (int i = 0; i < _MenuCachePics.Length; i++) { _MenuCachePics[i] = new cachepic_t(); } if (_glNoBind == null) { _glNoBind = new Cvar("gl_nobind", "0"); _glMaxSize = new Cvar("gl_max_size", "1024"); _glPicMip = new Cvar("gl_picmip", "0"); } // 3dfx can only handle 256 wide textures string renderer = GL.GetString(StringName.Renderer); if (renderer.Contains("3dfx") || renderer.Contains("Glide")) { Cvar.Set("gl_max_size", "256"); } Cmd.Add("gl_texturemode", TextureMode_f); // load the console background and the charset // by hand, because we need to write the version // string into the background before turning // it into a texture int offset = Wad.GetLumpNameOffset("conchars"); byte[] draw_chars = Wad.Data; // draw_chars for (int i = 0; i < 256 * 64; i++) { if (draw_chars[offset + i] == 0) { draw_chars[offset + i] = 255; // proper transparent color } } // now turn them into textures _CharTexture = LoadTexture("charset", 128, 128, new ByteArraySegment(draw_chars, offset), false, true); byte[] buf = Common.LoadFile("gfx/conback.lmp"); if (buf == null) { Sys.Error("Couldn't load gfx/conback.lmp"); } dqpicheader_t cbHeader = Sys.BytesToStructure <dqpicheader_t>(buf, 0); Wad.SwapPic(cbHeader); // hack the version number directly into the pic string ver = String.Format("(c# {0,7:F2}) {1,7:F2}", (float)QDef.CSQUAKE_VERSION, (float)QDef.VERSION); int offset2 = Marshal.SizeOf(typeof(dqpicheader_t)) + 320 * 186 + 320 - 11 - 8 * ver.Length; int y = ver.Length; for (int x = 0; x < y; x++) { CharToConback(ver[x], new ByteArraySegment(buf, offset2 + (x << 3)), new ByteArraySegment(draw_chars, offset)); } _ConBack = new glpic_t(); _ConBack.width = cbHeader.width; _ConBack.height = cbHeader.height; int ncdataIndex = Marshal.SizeOf(typeof(dqpicheader_t)); // cb->data; SetTextureFilters(TextureMinFilter.Nearest, TextureMagFilter.Nearest); _ConBack.texnum = LoadTexture("conback", _ConBack.width, _ConBack.height, new ByteArraySegment(buf, ncdataIndex), false, false); _ConBack.width = Scr.vid.width; _ConBack.height = Scr.vid.height; // save a texture slot for translated picture _TranslateTexture = _TextureExtensionNumber++; // save slots for scraps _ScrapTexNum = _TextureExtensionNumber; _TextureExtensionNumber += MAX_SCRAPS; // // get the other pics we need // _Disc = PicFromWad("disc"); _BackTile = PicFromWad("backtile"); }
/// <summary> /// Key_Console /// Interactive line editing and console scrollback /// </summary> static void KeyConsole(int key) { if (key == K_ENTER) { string line = new String(_Lines[_EditLine]).TrimEnd('\0', ' '); string cmd = line.Substring(1); Cbuf.AddText(cmd); // skip the > Cbuf.AddText("\n"); Con.Print("{0}\n", line); _EditLine = (_EditLine + 1) & 31; _HistoryLine = _EditLine; _Lines[_EditLine][0] = ']'; Key.LinePos = 1; if (Client.cls.state == cactive_t.ca_disconnected) { Scr.UpdateScreen(); // force an update, because the command } // may take some time return; } if (key == K_TAB) { // command completion string txt = new String(_Lines[_EditLine], 1, MAXCMDLINE - 1).TrimEnd('\0', ' '); string[] cmds = Cmd.Complete(txt); string[] vars = Cvar.CompleteName(txt); string match = null; if (cmds != null) { if (cmds.Length > 1 || vars != null) { Con.Print("\nCommands:\n"); foreach (string s in cmds) { Con.Print(" {0}\n", s); } } else { match = cmds[0]; } } if (vars != null) { if (vars.Length > 1 || cmds != null) { Con.Print("\nVariables:\n"); foreach (string s in vars) { Con.Print(" {0}\n", s); } } else if (match == null) { match = vars[0]; } } if (!String.IsNullOrEmpty(match)) { int len = Math.Min(match.Length, MAXCMDLINE - 3); for (int i = 0; i < len; i++) { _Lines[_EditLine][i + 1] = match[i]; } Key.LinePos = len + 1; _Lines[_EditLine][Key.LinePos] = ' '; Key.LinePos++; _Lines[_EditLine][Key.LinePos] = '\0'; return; } } if (key == K_BACKSPACE || key == K_LEFTARROW) { if (Key.LinePos > 1) { Key.LinePos--; } return; } if (key == K_UPARROW) { do { _HistoryLine = (_HistoryLine - 1) & 31; } while (_HistoryLine != _EditLine && (_Lines[_HistoryLine][1] == 0)); if (_HistoryLine == _EditLine) { _HistoryLine = (_EditLine + 1) & 31; } Array.Copy(_Lines[_HistoryLine], _Lines[_EditLine], MAXCMDLINE); Key.LinePos = 0; while (_Lines[_EditLine][Key.LinePos] != '\0' && Key.LinePos < MAXCMDLINE) { Key.LinePos++; } return; } if (key == K_DOWNARROW) { if (_HistoryLine == _EditLine) { return; } do { _HistoryLine = (_HistoryLine + 1) & 31; }while (_HistoryLine != _EditLine && (_Lines[_HistoryLine][1] == '\0')); if (_HistoryLine == _EditLine) { _Lines[_EditLine][0] = ']'; Key.LinePos = 1; } else { Array.Copy(_Lines[_HistoryLine], _Lines[_EditLine], MAXCMDLINE); Key.LinePos = 0; while (_Lines[_EditLine][Key.LinePos] != '\0' && Key.LinePos < MAXCMDLINE) { Key.LinePos++; } } return; } if (key == K_PGUP || key == K_MWHEELUP) { Con.BackScroll += 2; if (Con.BackScroll > Con.TotalLines - (Scr.vid.height >> 3) - 1) { Con.BackScroll = Con.TotalLines - (Scr.vid.height >> 3) - 1; } return; } if (key == K_PGDN || key == K_MWHEELDOWN) { Con.BackScroll -= 2; if (Con.BackScroll < 0) { Con.BackScroll = 0; } return; } if (key == K_HOME) { Con.BackScroll = Con.TotalLines - (Scr.vid.height >> 3) - 1; return; } if (key == K_END) { Con.BackScroll = 0; return; } if (key < 32 || key > 127) { return; // non printable } if (Key.LinePos < MAXCMDLINE - 1) { _Lines[_EditLine][Key.LinePos] = (char)key; Key.LinePos++; _Lines[_EditLine][Key.LinePos] = '\0'; } }
/// <summary> /// Host_Status_f /// </summary> static void Status_f() { bool flag = true; if (Cmd.Source == cmd_source_t.src_command) { if (!Server.sv.active) { Cmd.ForwardToServer(); return; } } else { flag = false; } StringBuilder sb = new StringBuilder(256); sb.Append(String.Format("host: {0}\n", Cvar.GetString("hostname"))); sb.Append(String.Format("version: {0:F2}\n", QDef.VERSION)); if (Net.TcpIpAvailable) { sb.Append("tcp/ip: "); sb.Append(Net.MyTcpIpAddress); sb.Append('\n'); } sb.Append("map: "); sb.Append(Server.sv.name); sb.Append('\n'); sb.Append(String.Format("players: {0} active ({1} max)\n\n", Net.ActiveConnections, Server.svs.maxclients)); for (int j = 0; j < Server.svs.maxclients; j++) { client_t client = Server.svs.clients[j]; if (!client.active) { continue; } int seconds = (int)(Net.Time - client.netconnection.connecttime); int hours, minutes = seconds / 60; if (minutes > 0) { seconds -= (minutes * 60); hours = minutes / 60; if (hours > 0) { minutes -= (hours * 60); } } else { hours = 0; } sb.Append(String.Format("#{0,-2} {1,-16} {2} {2}:{4,2}:{5,2}", j + 1, client.name, (int)client.edict.v.frags, hours, minutes, seconds)); sb.Append(" "); sb.Append(client.netconnection.address); sb.Append('\n'); } if (flag) { Con.Print(sb.ToString()); } else { Server.ClientPrint(sb.ToString()); } }
/// <summary> /// Host_Loadgame_f /// </summary> static void Loadgame_f() { if (Cmd.Source != cmd_source_t.src_command) { return; } if (Cmd.Argc != 2) { Con.Print("load <savename> : load a game\n"); return; } Client.cls.demonum = -1; // stop demo loop in case this fails string name = Path.ChangeExtension(Path.Combine(Common.GameDir, Cmd.Argv(1)), ".sav"); // we can't call SCR_BeginLoadingPlaque, because too much stack space has // been used. The menu calls it before stuffing loadgame command // SCR_BeginLoadingPlaque (); Con.Print("Loading game from {0}...\n", name); FileStream fs = Sys.FileOpenRead(name); if (fs == null) { Con.Print("ERROR: couldn't open.\n"); return; } using (StreamReader reader = new StreamReader(fs, Encoding.ASCII)) { string line = reader.ReadLine(); int version = Common.atoi(line); if (version != SAVEGAME_VERSION) { Con.Print("Savegame is version {0}, not {1}\n", version, SAVEGAME_VERSION); return; } line = reader.ReadLine(); float[] spawn_parms = new float[Server.NUM_SPAWN_PARMS]; for (int i = 0; i < spawn_parms.Length; i++) { line = reader.ReadLine(); spawn_parms[i] = Common.atof(line); } // this silliness is so we can load 1.06 save files, which have float skill values line = reader.ReadLine(); float tfloat = Common.atof(line); Host.CurrentSkill = (int)(tfloat + 0.1); Cvar.Set("skill", (float)Host.CurrentSkill); string mapname = reader.ReadLine(); line = reader.ReadLine(); float time = Common.atof(line); Client.Disconnect_f(); Server.SpawnServer(mapname); if (!Server.sv.active) { Con.Print("Couldn't load map\n"); return; } Server.sv.paused = true; // pause until all clients connect Server.sv.loadgame = true; // load the light styles for (int i = 0; i < QDef.MAX_LIGHTSTYLES; i++) { line = reader.ReadLine(); Server.sv.lightstyles[i] = line; } // load the edicts out of the savegame file int entnum = -1; // -1 is the globals StringBuilder sb = new StringBuilder(32768); while (!reader.EndOfStream) { line = reader.ReadLine(); if (line == null) { Sys.Error("EOF without closing brace"); } sb.AppendLine(line); int idx = line.IndexOf('}'); if (idx != -1) { int length = 1 + sb.Length - (line.Length - idx); string data = Common.Parse(sb.ToString(0, length)); if (String.IsNullOrEmpty(Common.Token)) { break; // end of file } if (Common.Token != "{") { Sys.Error("First token isn't a brace"); } if (entnum == -1) { // parse the global vars Progs.ParseGlobals(data); } else { // parse an edict edict_t ent = Server.EdictNum(entnum); ent.Clear(); Progs.ParseEdict(data, ent); // link it into the bsp tree if (!ent.free) { Server.LinkEdict(ent, false); } } entnum++; sb.Remove(0, length); } } Server.sv.num_edicts = entnum; Server.sv.time = time; for (int i = 0; i < Server.NUM_SPAWN_PARMS; i++) { Server.svs.clients[0].spawn_parms[i] = spawn_parms[i]; } } if (Client.cls.state != cactive_t.ca_dedicated) { Client.EstablishConnection("local"); Reconnect_f(); } }