public static void AddNetgraph() { int i; int in_renamed; int ping; if (SCR.scr_debuggraph.value == 0F || SCR.scr_timegraph.value == 0F) { return; } for (i = 0; i < Globals.cls.netchan.dropped; i++) { SCR.DebugGraph(30, 0x40); } for (i = 0; i < Globals.cl.surpressCount; i++) { SCR.DebugGraph(30, 0xdf); } in_renamed = Globals.cls.netchan.incoming_acknowledged & (Defines.CMD_BACKUP - 1); ping = (int)(Globals.cls.realtime - Globals.cl.cmd_time[in_renamed]); ping /= 30; if (ping > 30) { ping = 30; } SCR.DebugGraph(ping, 0xd0); }
public override void Execute( ) { SCR.EndLoadingPlaque(); if (Globals.cl.attractloop) { Cbuf.AddText("killserver\\n"); return; } if (Globals.cls.state == Defines.ca_disconnected) { Cbuf.AddText("d1\\n"); return; } Key.ClearTyping(); Con.ClearNotify(); if (Globals.cls.key_dest == Defines.key_console) { Menu.ForceMenuOff(); Cvar.Set("paused", "0"); } else { Menu.ForceMenuOff(); Globals.cls.key_dest = Defines.key_console; if (Cvar.VariableValue("maxclients") == 1 && Globals.server_state != 0) { Cvar.Set("paused", "1"); } } }
/* * ================= * * CL_PrepRefresh * * Call before entering a new level, or after changing dlls * ================= */ public static void PrepRefresh() { string mapname; int i; string name; float rotate; var axis = new float[3]; if ((i = Globals.cl.configstrings[Defines.CS_MODELS + 1].Length) == 0) { return; // no map loaded } SCR.AddDirtyPoint(0, 0); SCR.AddDirtyPoint(Globals.viddef.getWidth() - 1, Globals.viddef.getHeight() - 1); // let the render dll load the map mapname = Globals.cl.configstrings[Defines.CS_MODELS + 1].Substring(5, i - 9); // skip "maps/" // cut off ".bsp" // register models, pics, and skins Com.Printf("Map: " + mapname + "\r"); SCR.UpdateScreen(); Globals.re.BeginRegistration(mapname); Com.Printf(" \r"); // precache status bar pics Com.Printf("pics\r"); SCR.UpdateScreen(); SCR.TouchPics(); Com.Printf(" \r"); CL_tent.RegisterTEntModels(); CL_view.num_cl_weaponmodels = 1; CL_view.cl_weaponmodels[0] = "weapon.md2"; for (i = 1; i < Defines.MAX_MODELS && Globals.cl.configstrings[Defines.CS_MODELS + i].Length != 0; i++) { name = new(Globals.cl.configstrings[Defines.CS_MODELS + i]); if (name.Length > 37) { name = name[..36];
public static void ParseServerData( ) { Com.DPrintf("ParseServerData():Serverdata packet received.\\n"); CL.ClearState(); Globals.cls.state = Defines.ca_connected; var i = MSG.ReadLong(Globals.net_message); Globals.cls.serverProtocol = i; if (Globals.server_state != 0 && Defines.PROTOCOL_VERSION == 34) { } else if (i != Defines.PROTOCOL_VERSION) { Com.Error(Defines.ERR_DROP, "Server returned version " + i + ", not " + Defines.PROTOCOL_VERSION); } Globals.cl.servercount = MSG.ReadLong(Globals.net_message); Globals.cl.attractloop = MSG.ReadByte(Globals.net_message) != 0; var str = MSG.ReadString(Globals.net_message); Globals.cl.gamedir = str; Com.Dprintln("gamedir=" + str); if (str.Length > 0 && (FS.fs_gamedirvar.string_renamed == null || FS.fs_gamedirvar.string_renamed.Length == 0 || FS.fs_gamedirvar.string_renamed.Equals(str)) || (str.Length == 0 && (FS.fs_gamedirvar.string_renamed != null || FS.fs_gamedirvar.string_renamed.Length == 0))) { Cvar.Set("game", str); } Globals.cl.playernum = MSG.ReadShort(Globals.net_message); Com.Dprintln("numplayers=" + Globals.cl.playernum); str = MSG.ReadString(Globals.net_message); Com.Dprintln("levelname=" + str); if (Globals.cl.playernum == -1) { SCR.PlayCinematic(str); } else { Com.Printf("Levelname:" + str + "\\n"); Globals.cl.refresh_prepped = false; } }
/* * ===================================================================== * * SERVER CONNECTING MESSAGES * * ===================================================================== */ /* * ================== CL_ParseServerData ================== */ //checked once, was ok. public static void ParseServerData() { Com.DPrintf("ParseServerData():Serverdata packet received.\n"); // // wipe the client_state_t struct // Cl.ClearState(); Globals.cls.state = Defines.ca_connected; // parse protocol version number var i = MSG.ReadLong(Globals.net_message); Globals.cls.serverProtocol = i; // BIG HACK to let demos from release work with the 3.0x patch!!! if (Globals.server_state != 0 && Defines.PROTOCOL_VERSION == 34) { } else if (i != Defines.PROTOCOL_VERSION) { Com.Error(Defines.ERR_DROP, "Server returned version " + i + ", not " + Defines.PROTOCOL_VERSION); } Globals.cl.servercount = MSG.ReadLong(Globals.net_message); Globals.cl.attractloop = MSG.ReadByte(Globals.net_message) != 0; // game directory var str = MSG.ReadString(Globals.net_message); Globals.cl.gamedir = str; Com.dprintln("gamedir=" + str); // set gamedir if ((str.Length > 0 && (FS.fs_gamedirvar.@string == null || [email protected] == 0 || [email protected](str))) || (str.Length == 0 && (FS.fs_gamedirvar.@string != null || [email protected] == 0))) { Cvar.Set("game", str); } // parse player entity number Globals.cl.playernum = MSG.ReadShort(Globals.net_message); Com.dprintln("numplayers=" + Globals.cl.playernum); // get the full level name str = MSG.ReadString(Globals.net_message); Com.dprintln("levelname=" + str); if (Globals.cl.playernum == -1) { // playing a cinematic or showing a // pic, not a level SCR.PlayCinematic(str); } else { // seperate the printfs so the server message can have a color // Com.Printf( // "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); // Com.Printf('\02' + str + "\n"); Com.Printf("Levelname:" + str + "\n"); // need to prep refresh at next oportunity Globals.cl.refresh_prepped = false; } }
public static void DrawInventory() { int i, j; int num, selected_num, item; var index = new int[Defines.MAX_ITEMS]; string @string; int x, y; string binding; string bind; int selected; int top; selected = Globals.cl.frame.playerstate.stats[Defines.STAT_SELECTED_ITEM]; num = 0; selected_num = 0; for (i = 0; i < Defines.MAX_ITEMS; i++) { if (i == selected) { selected_num = num; } if (Globals.cl.inventory[i] != 0) { index[num] = i; num++; } } // determine scroll point top = selected_num - CL_inv.DISPLAY_ITEMS / 2; if (num - top < CL_inv.DISPLAY_ITEMS) { top = num - CL_inv.DISPLAY_ITEMS; } if (top < 0) { top = 0; } x = (Globals.viddef.getWidth() - 256) / 2; y = (Globals.viddef.getHeight() - 240) / 2; // repaint everything next frame SCR.DirtyScreen(); Globals.re.DrawPic(x, y + 8, "inventory"); y += 24; x += 24; CL_inv.Inv_DrawString(x, y, "hotkey ### item"); CL_inv.Inv_DrawString(x, y + 8, "------ --- ----"); y += 16; for (i = top; i < num && i < top + CL_inv.DISPLAY_ITEMS; i++) { item = index[i]; // search for a binding //Com_sprintf (binding, sizeof(binding), "use %s", // cl.configstrings[CS_ITEMS+item]); binding = "use " + Globals.cl.configstrings[Defines.CS_ITEMS + item]; bind = ""; for (j = 0; j < 256; j++) { if (Globals.keybindings[j] != null && Globals.keybindings[j].Equals(binding)) { bind = Key.KeynumToString(j); break; } } @string = Com.sprintf( "%6s %3i %s", bind, Globals.cl.inventory[item], Globals.cl.configstrings[Defines.CS_ITEMS + item] ); if (item != selected) { @string = CL_inv.getHighBitString(@string); } else // draw a blinky cursor by the selected item { if (((int)(Globals.cls.realtime * 10) & 1) != 0) { Globals.re.DrawChar(x - 8, y, 15); } } CL_inv.Inv_DrawString(x, y, @string); y += 8; } }
public static void SendCmd() { int i; usercmd_t cmd, oldcmd; int checksumIndex; i = Globals.cls.netchan.outgoing_sequence & (Defines.CMD_BACKUP - 1); cmd = Globals.cl.cmds[i]; Globals.cl.cmd_time[i] = (int)Globals.cls.realtime; CreateCmd(cmd); Globals.cl.cmd.Set(cmd); if (Globals.cls.state == Defines.ca_disconnected || Globals.cls.state == Defines.ca_connecting) { return; } if (Globals.cls.state == Defines.ca_connected) { if (Globals.cls.netchan.message.cursize != 0 || Globals.curtime - Globals.cls.netchan.last_sent > 1000) { Netchan.Transmit(Globals.cls.netchan, 0, new byte[0]); } return; } if (Globals.userinfo_modified) { CL.FixUpGender(); Globals.userinfo_modified = false; MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_userinfo); MSG.WriteString(Globals.cls.netchan.message, Cvar.Userinfo()); } SZ.Init(buf, data, data.Length); if (cmd.buttons != 0 && Globals.cl.cinematictime > 0 && !Globals.cl.attractloop && Globals.cls.realtime - Globals.cl.cinematictime > 1000) { SCR.FinishCinematic(); } MSG.WriteByte(buf, Defines.clc_move); checksumIndex = buf.cursize; MSG.WriteByte(buf, 0); if (cl_nodelta.value != 0F || !Globals.cl.frame.valid || Globals.cls.demowaiting) { MSG.WriteLong(buf, -1); } else { MSG.WriteLong(buf, Globals.cl.frame.serverframe); } i = (Globals.cls.netchan.outgoing_sequence - 2) & (Defines.CMD_BACKUP - 1); cmd = Globals.cl.cmds[i]; nullcmd.Clear(); MSG.WriteDeltaUsercmd(buf, nullcmd, cmd); oldcmd = cmd; i = (Globals.cls.netchan.outgoing_sequence - 1) & (Defines.CMD_BACKUP - 1); cmd = Globals.cl.cmds[i]; MSG.WriteDeltaUsercmd(buf, oldcmd, cmd); oldcmd = cmd; i = (Globals.cls.netchan.outgoing_sequence) & (Defines.CMD_BACKUP - 1); cmd = Globals.cl.cmds[i]; MSG.WriteDeltaUsercmd(buf, oldcmd, cmd); buf.data[checksumIndex] = Com.BlockSequenceCRCByte(buf.data, checksumIndex + 1, buf.cursize - checksumIndex - 1, Globals.cls.netchan.outgoing_sequence); Netchan.Transmit(Globals.cls.netchan, buf.cursize, buf.data); }
public static void ParseFrame( ) { Int32 cmd; Int32 len; frame_t old; Globals.cl.frame.Reset(); Globals.cl.frame.serverframe = MSG.ReadLong(Globals.net_message); Globals.cl.frame.deltaframe = MSG.ReadLong(Globals.net_message); Globals.cl.frame.servertime = Globals.cl.frame.serverframe * 100; if (Globals.cls.serverProtocol != 26) { Globals.cl.surpressCount = MSG.ReadByte(Globals.net_message); } if (Globals.cl_shownet.value == 3) { Com.Printf(" frame:" + Globals.cl.frame.serverframe + " delta:" + Globals.cl.frame.deltaframe + "\\n"); } if (Globals.cl.frame.deltaframe <= 0) { Globals.cl.frame.valid = true; old = null; Globals.cls.demowaiting = false; } else { old = Globals.cl.frames[Globals.cl.frame.deltaframe & Defines.UPDATE_MASK]; if (!old.valid) { Com.Printf("Delta from invalid frame (not supposed to happen!).\\n"); } if (old.serverframe != Globals.cl.frame.deltaframe) { Com.Printf("Delta frame too old.\\n"); } else if (Globals.cl.parse_entities - old.parse_entities > Defines.MAX_PARSE_ENTITIES - 128) { Com.Printf("Delta parse_entities too old.\\n"); } else { Globals.cl.frame.valid = true; } } if (Globals.cl.time > Globals.cl.frame.servertime) { Globals.cl.time = Globals.cl.frame.servertime; } else if (Globals.cl.time < Globals.cl.frame.servertime - 100) { Globals.cl.time = Globals.cl.frame.servertime - 100; } len = MSG.ReadByte(Globals.net_message); MSG.ReadData(Globals.net_message, Globals.cl.frame.areabits, len); cmd = MSG.ReadByte(Globals.net_message); CL_parse.SHOWNET(CL_parse.svc_strings[cmd]); if (cmd != Defines.svc_playerinfo) { Com.Error(Defines.ERR_DROP, "CL_ParseFrame: not playerinfo"); } ParsePlayerstate(old, Globals.cl.frame); cmd = MSG.ReadByte(Globals.net_message); CL_parse.SHOWNET(CL_parse.svc_strings[cmd]); if (cmd != Defines.svc_packetentities) { Com.Error(Defines.ERR_DROP, "CL_ParseFrame: not packetentities"); } ParsePacketEntities(old, Globals.cl.frame); Globals.cl.frames[Globals.cl.frame.serverframe & Defines.UPDATE_MASK].Set(Globals.cl.frame); if (Globals.cl.frame.valid) { if (Globals.cls.state != Defines.ca_active) { Globals.cls.state = Defines.ca_active; Globals.cl.force_refdef = true; Globals.cl.predicted_origin[0] = Globals.cl.frame.playerstate.pmove.origin[0] * 0.125F; Globals.cl.predicted_origin[1] = Globals.cl.frame.playerstate.pmove.origin[1] * 0.125F; Globals.cl.predicted_origin[2] = Globals.cl.frame.playerstate.pmove.origin[2] * 0.125F; Math3D.VectorCopy(Globals.cl.frame.playerstate.viewangles, Globals.cl.predicted_angles); if (Globals.cls.disable_servercount != Globals.cl.servercount && Globals.cl.refresh_prepped) { SCR.EndLoadingPlaque(); } } Globals.cl.sound_prepped = true; FireEntityEvents(Globals.cl.frame); CL_pred.CheckPredictionError(); } }
public static void ParseServerMessage( ) { while (true) { if (Globals.net_message.readcount > Globals.net_message.cursize) { Com.Error(Defines.ERR_FATAL, "CL_ParseServerMessage: Bad server message:"); break; } var cmd = MSG.ReadByte(Globals.net_message); if (cmd == -1) { SHOWNET("END OF MESSAGE"); break; } if (Globals.cl_shownet.value >= 2) { if (null == svc_strings[cmd]) { Com.Printf(Globals.net_message.readcount - 1 + ":BAD CMD " + cmd + "\\n"); } else { SHOWNET(svc_strings[cmd]); } } switch (cmd) { default: Com.Error(Defines.ERR_DROP, "CL_ParseServerMessage: Illegible server message\\n"); break; case Defines.svc_nop: break; case Defines.svc_disconnect: Com.Error(Defines.ERR_DISCONNECT, "Server disconnected\\n"); break; case Defines.svc_reconnect: Com.Printf("Server disconnected, reconnecting\\n"); if (Globals.cls.download != null) { try { Globals.cls.download.Close(); } catch (IOException e) { } Globals.cls.download = null; } Globals.cls.state = Defines.ca_connecting; Globals.cls.connect_time = -99999; break; case Defines.svc_print: var i = MSG.ReadByte(Globals.net_message); if (i == Defines.PRINT_CHAT) { S.StartLocalSound("misc/talk.wav"); Globals.con.ormask = 128; } Com.Printf(MSG.ReadString(Globals.net_message)); Globals.con.ormask = 0; break; case Defines.svc_centerprint: SCR.CenterPrint(MSG.ReadString(Globals.net_message)); break; case Defines.svc_stufftext: var s = MSG.ReadString(Globals.net_message); Com.DPrintf("stufftext: " + s + "\\n"); Cbuf.AddText(s); break; case Defines.svc_serverdata: Cbuf.Execute(); ParseServerData(); break; case Defines.svc_configstring: ParseConfigString(); break; case Defines.svc_sound: ParseStartSoundPacket(); break; case Defines.svc_spawnbaseline: ParseBaseline(); break; case Defines.svc_temp_entity: CL_tent.ParseTEnt(); break; case Defines.svc_muzzleflash: CL_fx.ParseMuzzleFlash(); break; case Defines.svc_muzzleflash2: CL_fx.ParseMuzzleFlash2(); break; case Defines.svc_download: ParseDownload(); break; case Defines.svc_frame: CL_ents.ParseFrame(); break; case Defines.svc_inventory: CL_inv.ParseInventory(); break; case Defines.svc_layout: Globals.cl.layout = MSG.ReadString(Globals.net_message); break; case Defines.svc_playerinfo: case Defines.svc_packetentities: case Defines.svc_deltapacketentities: Com.Error(Defines.ERR_DROP, "Out of place frame data"); break; } } CL_view.AddNetgraph(); if (Globals.cls.demorecording && !Globals.cls.demowaiting) { CL.WriteDemoMessage(); } }
public static void RenderView(Single stereo_separation) { if (cls.state != ca_active) { return; } if (!cl.refresh_prepped) { return; } if (cl_timedemo.value != 0F) { if (cl.timedemo_start == 0) { cl.timedemo_start = Timer.Milliseconds(); } cl.timedemo_frames++; } if (cl.frame.valid && (cl.force_refdef || cl_paused.value == 0F)) { cl.force_refdef = false; V.ClearScene(); CL_ents.AddEntities(); if (cl_testparticles.value != 0F) { TestParticles(); } if (cl_testentities.value != 0F) { TestEntities(); } if (cl_testlights.value != 0F) { TestLights(); } if (cl_testblend.value != 0F) { cl.refdef.blend[0] = 1F; cl.refdef.blend[1] = 0.5F; cl.refdef.blend[2] = 0.25F; cl.refdef.blend[3] = 0.5F; } if (stereo_separation != 0) { Single[] tmp = new Single[3]; Math3D.VectorScale(cl.v_right, stereo_separation, tmp); Math3D.VectorAdd(cl.refdef.vieworg, tmp, cl.refdef.vieworg); } cl.refdef.vieworg[0] += 1 / 16; cl.refdef.vieworg[1] += 1 / 16; cl.refdef.vieworg[2] += 1 / 16; cl.refdef.x = scr_vrect.x; cl.refdef.y = scr_vrect.y; cl.refdef.width = scr_vrect.width; cl.refdef.height = scr_vrect.height; cl.refdef.fov_y = Math3D.CalcFov(cl.refdef.fov_x, cl.refdef.width, cl.refdef.height); cl.refdef.time = cl.time * 0.001F; cl.refdef.areabits = cl.frame.areabits; if (cl_add_entities.value == 0F) { r_numentities = 0; } if (cl_add_particles.value == 0F) { r_numparticles = 0; } if (cl_add_lights.value == 0F) { r_numdlights = 0; } if (cl_add_blend.value == 0) { Math3D.VectorClear(cl.refdef.blend); } cl.refdef.num_entities = r_numentities; cl.refdef.entities = r_entities; cl.refdef.num_particles = r_numparticles; cl.refdef.num_dlights = r_numdlights; cl.refdef.dlights = r_dlights; cl.refdef.lightstyles = r_lightstyles; cl.refdef.rdflags = cl.frame.playerstate.rdflags; } re.RenderFrame(cl.refdef); if (cl_stats.value != 0F) { Com.Printf("ent:%i lt:%i part:%i\\n", r_numentities, r_numdlights, r_numparticles); } if (log_stats.value != 0F && (log_stats_file != null)) { try { log_stats_file.Write(r_numentities + "," + r_numdlights + "," + r_numparticles); } catch (Exception e) { } } SCR.AddDirtyPoint(scr_vrect.x, scr_vrect.y); SCR.AddDirtyPoint(scr_vrect.x + scr_vrect.width - 1, scr_vrect.y + scr_vrect.height - 1); SCR.DrawCrosshair(); }
public static void DrawConsole(Single frac) { var width = viddef.GetWidth(); var height = viddef.GetHeight(); var lines = ( Int32 )(height * frac); if (lines <= 0) { return; } if (lines > height) { lines = height; } re.DrawStretchPic(0, -height + lines, width, height, "conback"); SCR.AddDirtyPoint(0, 0); SCR.AddDirtyPoint(width - 1, lines - 1); var version = Com.Sprintf("v%4.2f", 1, VERSION); var x = 0; for (x = 0; x < 5; x++) { re.DrawChar(width - 44 + x * 8, lines - 12, 128 + version[x]); } con.vislines = lines; var rows = (lines - 22) >> 3; var y = lines - 30; if (con.display != con.current) { for (x = 0; x < con.linewidth; x += 4) { re.DrawChar((x + 1) << 3, y, '^'); } y -= 8; rows--; } Int32 i, j, n; x = 0; var row = con.display; for (i = 0; i < rows; i++, y -= 8, row--) { if (row < 0) { break; } if (con.current - row >= con.totallines) { break; } var first = (row % con.totallines) * con.linewidth; for (x = 0; x < con.linewidth; x++) { re.DrawChar((x + 1) << 3, y, con.text[x + first]); } } if (cls.download != null) { Int32 text; if ((text = cls.downloadname.LastIndexOf('/')) != 0) { text++; } else { text = 0; } x = con.linewidth - ((con.linewidth * 7) / 40); y = x - (cls.downloadname.Length - text) - 8; i = con.linewidth / 3; StringBuffer dlbar = new StringBuffer(512); if (cls.downloadname.Length - text > i) { y = x - i - 11; var end = text + i - 1; dlbar.Append(cls.downloadname.Substring(text, end)); dlbar.Append("..."); } else { dlbar.Append(cls.downloadname.Substring(text)); } dlbar.Append(": "); dlbar.Append(( Char )0x80); if (cls.downloadpercent == 0) { n = 0; } else { n = y * cls.downloadpercent / 100; } for (j = 0; j < y; j++) { if (j == n) { dlbar.Append(( Char )0x83); } else { dlbar.Append(( Char )0x81); } } dlbar.Append(( Char )0x82); dlbar.Append((cls.downloadpercent < 10) ? " 0" : " "); dlbar.Append(cls.downloadpercent).Append('%'); y = con.vislines - 12; for (i = 0; i < dlbar.Length; i++) { re.DrawChar((i + 1) << 3, y, dlbar[i]); } } DrawInput(); }
public static void DrawNotify( ) { Int32 x, v; Int32 text; Int32 i; Int32 time; String s; Int32 skip; v = 0; for (i = con.current - NUM_CON_TIMES + 1; i <= con.current; i++) { if (i < 0) { continue; } time = ( Int32 )con.times[i % NUM_CON_TIMES]; if (time == 0) { continue; } time = ( Int32 )(cls.realtime - time); if (time > con_notifytime.value * 1000) { continue; } text = (i % con.totallines) * con.linewidth; for (x = 0; x < con.linewidth; x++) { re.DrawChar((x + 1) << 3, v, con.text[text + x]); } v += 8; } if (cls.key_dest == key_message) { if (chat_team) { DrawString(8, v, "say_team:"); skip = 11; } else { DrawString(8, v, "say:"); skip = 5; } s = chat_buffer; if (chat_bufferlen > (viddef.GetWidth() >> 3) - (skip + 1)) { s = s.Substring(chat_bufferlen - ((viddef.GetWidth() >> 3) - (skip + 1))); } for (x = 0; x < s.Length; x++) { re.DrawChar((x + skip) << 3, v, s[x]); } re.DrawChar((x + skip) << 3, v, ( Int32 )(10 + ((cls.realtime >> 8) & 1))); v += 8; } if (v != 0) { SCR.AddDirtyPoint(0, 0); SCR.AddDirtyPoint(viddef.GetWidth() - 1, v); } }
public static void SV_Map(Boolean attractloop, String levelstring, Boolean loadgame) { Int32 l; String level, ch, spawnpoint; var pos = 0; sv.loadgame = loadgame; sv.attractloop = attractloop; if (sv.state == Defines.ss_dead && !sv.loadgame) { SV_InitGame(); } level = levelstring; var c = level.IndexOf('+'); if (c != -1) { Cvar.Set("nextserver", "gamemap \\\"" + level.Substring(c + 1) + "\\\""); level = level.Substring(0, c); } else { Cvar.Set("nextserver", ""); } if (firstmap.Length == 0) { if (!levelstring.EndsWith(".cin") && !levelstring.EndsWith(".pcx") && !levelstring.EndsWith(".dm2")) { pos = levelstring.IndexOf('+'); firstmap = levelstring.Substring(pos + 1); } } if (Cvar.VariableValue("coop") != 0 && level.Equals("victory.pcx")) { Cvar.Set("nextserver", "gamemap \\\"*" + firstmap + "\\\""); } pos = level.IndexOf('$'); if (pos != -1) { spawnpoint = level.Substring(pos + 1); level = level.Substring(0, pos); } else { spawnpoint = ""; } if (level[0] == '*') { level = level.Substring(1); } l = level.Length; if (l > 4 && level.EndsWith(".cin")) { SCR.BeginLoadingPlaque(); SV_SEND.SV_BroadcastCommand("changing\\n"); SV_SpawnServer(level, spawnpoint, Defines.ss_cinematic, attractloop, loadgame); } else if (l > 4 && level.EndsWith(".dm2")) { SCR.BeginLoadingPlaque(); SV_SEND.SV_BroadcastCommand("changing\\n"); SV_SpawnServer(level, spawnpoint, Defines.ss_demo, attractloop, loadgame); } else if (l > 4 && level.EndsWith(".pcx")) { SCR.BeginLoadingPlaque(); SV_SEND.SV_BroadcastCommand("changing\\n"); SV_SpawnServer(level, spawnpoint, Defines.ss_pic, attractloop, loadgame); } else { SCR.BeginLoadingPlaque(); SV_SEND.SV_BroadcastCommand("changing\\n"); SV_SEND.SV_SendClientMessages(); SV_SpawnServer(level, spawnpoint, Defines.ss_game, attractloop, loadgame); Cbuf.CopyToDefer(); } SV_SEND.SV_BroadcastCommand("reconnect\\n"); }
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(); } }
/* * ================== V_RenderView * * ================== */ public static void RenderView(float stereo_separation) { // extern int entitycmpfnc( const entity_t *, const entity_t * ); // if (Globals.cls.state != Defines.ca_active) { return; } if (!Globals.cl.refresh_prepped) { return; // still loading } if (Globals.cl_timedemo.value != 0.0f) { if (Globals.cl.timedemo_start == 0) { Globals.cl.timedemo_start = Timer.Milliseconds(); } Globals.cl.timedemo_frames++; } // an invalid frame will just use the exact previous refdef // we can't use the old frame if the video mode has changed, though... if (Globals.cl.frame.valid && (Globals.cl.force_refdef || Globals.cl_paused.value == 0.0f)) { Globals.cl.force_refdef = false; V.ClearScene(); // build a refresh entity list and calc cl.sim* // this also calls CL_CalcViewValues which loads // v_forward, etc. CL_ents.AddEntities(); if (V.cl_testparticles.value != 0.0f) { V.TestParticles(); } if (V.cl_testentities.value != 0.0f) { V.TestEntities(); } if (V.cl_testlights.value != 0.0f) { V.TestLights(); } if (V.cl_testblend.value != 0.0f) { Globals.cl.refdef.blend[0] = 1.0f; Globals.cl.refdef.blend[1] = 0.5f; Globals.cl.refdef.blend[2] = 0.25f; Globals.cl.refdef.blend[3] = 0.5f; } // offset vieworg appropriately if we're doing stereo separation if (stereo_separation != 0) { var tmp = new float[3]; Math3D.VectorScale(Globals.cl.v_right, stereo_separation, tmp); Math3D.VectorAdd(Globals.cl.refdef.vieworg, tmp, Globals.cl.refdef.vieworg); } // never let it sit exactly on a node line, because a water plane // can // dissapear when viewed with the eye exactly on it. // the server protocol only specifies to 1/8 pixel, so add 1/16 in // each axis Globals.cl.refdef.vieworg[0] += 1.0f / 16; Globals.cl.refdef.vieworg[1] += 1.0f / 16; Globals.cl.refdef.vieworg[2] += 1.0f / 16; Globals.cl.refdef.x = Globals.scr_vrect.x; Globals.cl.refdef.y = Globals.scr_vrect.y; Globals.cl.refdef.width = Globals.scr_vrect.width; Globals.cl.refdef.height = Globals.scr_vrect.height; Globals.cl.refdef.fov_y = Math3D.CalcFov(Globals.cl.refdef.fov_x, Globals.cl.refdef.width, Globals.cl.refdef.height); Globals.cl.refdef.time = Globals.cl.time * 0.001f; Globals.cl.refdef.areabits = Globals.cl.frame.areabits; if (Globals.cl_add_entities.value == 0.0f) { V.r_numentities = 0; } if (Globals.cl_add_particles.value == 0.0f) { V.r_numparticles = 0; } if (Globals.cl_add_lights.value == 0.0f) { V.r_numdlights = 0; } if (Globals.cl_add_blend.value == 0) { Math3D.VectorClear(Globals.cl.refdef.blend); } Globals.cl.refdef.num_entities = V.r_numentities; Globals.cl.refdef.entities = V.r_entities; Globals.cl.refdef.num_particles = V.r_numparticles; Globals.cl.refdef.num_dlights = V.r_numdlights; Globals.cl.refdef.dlights = V.r_dlights; Globals.cl.refdef.lightstyles = V.r_lightstyles; Globals.cl.refdef.rdflags = Globals.cl.frame.playerstate.rdflags; } Globals.re.RenderFrame(Globals.cl.refdef); if (V.cl_stats.value != 0.0f) { Com.Printf("ent:%i lt:%i part:%i\n", V.r_numentities, V.r_numdlights, V.r_numparticles); } if (Globals.log_stats.value != 0.0f && Globals.log_stats_file != null) { try { Globals.log_stats_file.Write(V.r_numentities + "," + V.r_numdlights + "," + V.r_numparticles); } catch (Exception) { } } SCR.AddDirtyPoint(Globals.scr_vrect.x, Globals.scr_vrect.y); SCR.AddDirtyPoint(Globals.scr_vrect.x + Globals.scr_vrect.width - 1, Globals.scr_vrect.y + Globals.scr_vrect.height - 1); SCR.DrawCrosshair(); }
public static void DrawInventory() { int i, j; int num, selected_num, item; int[] index = new int[Defines.MAX_ITEMS]; string string_renamed; int x, y; string binding; string bind; int selected; int top; selected = Globals.cl.frame.playerstate.stats[Defines.STAT_SELECTED_ITEM]; num = 0; selected_num = 0; for (i = 0; i < Defines.MAX_ITEMS; i++) { if (i == selected) { selected_num = num; } if (Globals.cl.inventory[i] != 0) { index[num] = i; num++; } } top = selected_num - DISPLAY_ITEMS / 2; if (num - top < DISPLAY_ITEMS) { top = num - DISPLAY_ITEMS; } if (top < 0) { top = 0; } x = (Globals.viddef.GetWidth() - 256) / 2; y = (Globals.viddef.GetHeight() - 240) / 2; SCR.DirtyScreen(); Globals.re.DrawPic(x, y + 8, "inventory"); y += 24; x += 24; Inv_DrawString(x, y, "hotkey ### item"); Inv_DrawString(x, y + 8, "------ --- ----"); y += 16; for (i = top; i < num && i < top + DISPLAY_ITEMS; i++) { item = index[i]; binding = "use " + Globals.cl.configstrings[Defines.CS_ITEMS + item]; bind = ""; for (j = 0; j < 256; j++) { if (Globals.keybindings[j] != null && Globals.keybindings[j].Equals(binding)) { bind = Key.KeynumToString(j); break; } } string_renamed = Com.Sprintf("%6s %3i %s", bind, Globals.cl.inventory[item], Globals.cl.configstrings[Defines.CS_ITEMS + item]); if (item != selected) { string_renamed = GetHighBitString(string_renamed); } else { if (((int)(Globals.cls.realtime * 10) & 1) != 0) { Globals.re.DrawChar(x - 8, y, 15); } } Inv_DrawString(x, y, string_renamed); y += 8; } }
/** * 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 Console(int key) { switch (key) { case K_KP_SLASH: key = '/'; break; case K_KP_MINUS: key = '-'; break; case K_KP_PLUS: key = '+'; break; case K_KP_HOME: key = '7'; break; case K_KP_UPARROW: key = '8'; break; case K_KP_PGUP: key = '9'; break; case K_KP_LEFTARROW: key = '4'; break; case K_KP_5: key = '5'; break; case K_KP_RIGHTARROW: key = '6'; break; case K_KP_END: key = '1'; break; case K_KP_DOWNARROW: key = '2'; break; case K_KP_PGDN: key = '3'; break; case K_KP_INS: key = '0'; break; case K_KP_DEL: key = '.'; break; } if (key == 'l') { if (Globals.keydown[K_CTRL]) { Cbuf.AddText("clear\\n"); return; } } if (key == K_ENTER || key == K_KP_ENTER) { if (Globals.key_lines[Globals.edit_line][1] == '\\' || Globals.key_lines[Globals.edit_line][1] == '/') { Cbuf.AddText(Encoding.ASCII.GetString(Globals.key_lines[Globals.edit_line], 2, Lib.Strlen(Globals.key_lines[Globals.edit_line]) - 2)); } else { Cbuf.AddText(Encoding.ASCII.GetString(Globals.key_lines[Globals.edit_line], 1, Lib.Strlen(Globals.key_lines[Globals.edit_line]) - 1)); } Cbuf.AddText("\\n"); Com.Printf(Encoding.ASCII.GetString(Globals.key_lines[Globals.edit_line], 0, Lib.Strlen(Globals.key_lines[Globals.edit_line])) + "\\n"); Globals.edit_line = (Globals.edit_line + 1) & 31; history_line = Globals.edit_line; Globals.key_lines[Globals.edit_line][0] = (byte)']'; Globals.key_linepos = 1; if (Globals.cls.state == Defines.ca_disconnected) { SCR.UpdateScreen(); } return; } if (key == K_TAB) { CompleteCommand(); return; } if ((key == K_BACKSPACE) || (key == K_LEFTARROW) || (key == K_KP_LEFTARROW) || ((key == 'h') && (Globals.keydown[K_CTRL]))) { if (Globals.key_linepos > 1) { Globals.key_linepos--; } return; } if ((key == K_UPARROW) || (key == K_KP_UPARROW) || ((key == 'p') && Globals.keydown[K_CTRL])) { do { history_line = (history_line - 1) & 31; }while (history_line != Globals.edit_line && Globals.key_lines[history_line][1] == 0); if (history_line == Globals.edit_line) { history_line = (Globals.edit_line + 1) & 31; } System.Array.Copy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].Length); Globals.key_linepos = Lib.Strlen(Globals.key_lines[Globals.edit_line]); return; } if ((key == K_DOWNARROW) || (key == K_KP_DOWNARROW) || ((key == 'n') && Globals.keydown[K_CTRL])) { if (history_line == Globals.edit_line) { return; } do { history_line = (history_line + 1) & 31; }while (history_line != Globals.edit_line && Globals.key_lines[history_line][1] == 0); if (history_line == Globals.edit_line) { Globals.key_lines[Globals.edit_line][0] = (byte)']'; Globals.key_linepos = 1; } else { System.Array.Copy(Globals.key_lines[history_line], 0, Globals.key_lines[Globals.edit_line], 0, Globals.key_lines[Globals.edit_line].Length); Globals.key_linepos = Lib.Strlen(Globals.key_lines[Globals.edit_line]); } return; } if (key == K_PGUP || key == K_KP_PGUP) { Globals.con.display -= 2; return; } if (key == K_PGDN || key == K_KP_PGDN) { Globals.con.display += 2; if (Globals.con.display > Globals.con.current) { Globals.con.display = Globals.con.current; } return; } if (key == K_HOME || key == K_KP_HOME) { Globals.con.display = Globals.con.current - Globals.con.totallines + 10; return; } if (key == K_END || key == K_KP_END) { Globals.con.display = Globals.con.current; return; } if (key < 32 || key > 127) { return; } if (Globals.key_linepos < Defines.MAXCMDLINE - 1) { Globals.key_lines[Globals.edit_line][Globals.key_linepos] = (byte)key; Globals.key_linepos++; Globals.key_lines[Globals.edit_line][Globals.key_linepos] = 0; } }
public static void Init(String[] args) { try { Com.InitArgv(args); Cbuf.Init(); Cmd.Init(); Cvar.Init(); Key.Init(); Cbuf.AddEarlyCommands(false); Cbuf.Execute(); if (Globals.dedicated.value != 1F) { Program.Q2Dialog.SetStatus("initializing filesystem..."); } FS.InitFilesystem(); if (Globals.dedicated.value != 1F) { Program.Q2Dialog.SetStatus("loading config..."); } Reconfigure(false); FS.SetCDDir(); FS.MarkBaseSearchPaths(); if (Globals.dedicated.value != 1F) { Program.Q2Dialog.TestQ2Data(); } Reconfigure(true); Cmd.AddCommand("error", Com.Error_f); Globals.host_speeds = Cvar.Get("host_speeds", "0", 0); Globals.log_stats = Cvar.Get("log_stats", "0", 0); Globals.developer = Cvar.Get("developer", "0", CVAR_ARCHIVE); Globals.timescale = Cvar.Get("timescale", "0", 0); Globals.fixedtime = Cvar.Get("fixedtime", "0", 0); Globals.logfile_active = Cvar.Get("logfile", "0", 0); Globals.showtrace = Cvar.Get("showtrace", "0", 0); Globals.dedicated = Cvar.Get("dedicated", "0", CVAR_NOSET); var s = Com.Sprintf("%4.2f %s %s %s", Globals.VERSION, CPUSTRING, Globals.__DATE__, BUILDSTRING); Cvar.Get("version", s, CVAR_SERVERINFO | CVAR_NOSET); if (Globals.dedicated.value != 1F) { Program.Q2Dialog.SetStatus("initializing network subsystem..."); } NET.Init(); Netchan.Netchan_Init(); if (Globals.dedicated.value != 1F) { Program.Q2Dialog.SetStatus("initializing server subsystem..."); } SV_MAIN.SV_Init(); if (Globals.dedicated.value != 1F) { Program.Q2Dialog.SetStatus("initializing client subsystem..."); } CL.Init(); if (!Cbuf.AddLateCommands()) { if (Globals.dedicated.value == 0) { Cbuf.AddText("d1\\n"); } else { Cbuf.AddText("dedicated_start\\n"); } Cbuf.Execute(); } else { SCR.EndLoadingPlaque(); } Com.Printf("====== Quake2 Initialized ======\\n\\n"); CL.WriteConfiguration(); if (Globals.dedicated.value != 1F) { Program.Q2Dialog.Dispose(); } } catch (longjmpException e) { CoreSys.Error("Error during initialization"); } }
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; }
/** * This function initializes the different subsystems of * the game engine. The setjmp/longjmp mechanism of the original * was replaced with exceptions. * @param args the original unmodified command line arguments */ public static void Init(string[] args) { try { // prepare enough of the subsystems to handle // cvar and command buffer management Com.InitArgv(args); Cbuf.Init(); Cmd.Init(); Cvar.Init(); Key.Init(); // we need to add the early commands twice, because // a basedir or cddir needs to be set before execing // config files, but we want other parms to override // the settings of the config files Cbuf.AddEarlyCommands(false); Cbuf.Execute(); if (Globals.dedicated.value != 1.0f) { Console.WriteLine("initializing filesystem..."); } FS.InitFilesystem(); if (Globals.dedicated.value != 1.0f) { Console.WriteLine("loading config..."); } Qcommon.reconfigure(false); FS.markBaseSearchPaths(); // mark the default search paths Qcommon.reconfigure(true); // reload default.cfg and config.cfg // // init commands and vars // Cmd.AddCommand("error", Com.Error_f); Globals.host_speeds = Cvar.Get("host_speeds", "0", 0); Globals.log_stats = Cvar.Get("log_stats", "0", 0); Globals.developer = Cvar.Get("developer", "0", Defines.CVAR_ARCHIVE); Globals.timescale = Cvar.Get("timescale", "0", 0); Globals.fixedtime = Cvar.Get("fixedtime", "0", 0); Globals.logfile_active = Cvar.Get("logfile", "0", 0); Globals.showtrace = Cvar.Get("showtrace", "0", 0); Globals.dedicated = Cvar.Get("dedicated", "0", Defines.CVAR_NOSET); var s = Com.sprintf("%4.2f %s %s %s", Globals.VERSION, Qcommon.CPUSTRING, Globals.__DATE__, Qcommon.BUILDSTRING); Cvar.Get("version", s, Defines.CVAR_SERVERINFO | Defines.CVAR_NOSET); if (Globals.dedicated.value != 1.0f) { Console.WriteLine("initializing network subsystem..."); } NET.Init(); //ok Netchan.Netchan_Init(); //ok if (Globals.dedicated.value != 1.0f) { Console.WriteLine("initializing server subsystem..."); } SV_MAIN.SV_Init(); //ok if (Globals.dedicated.value != 1.0f) { Console.WriteLine("initializing client subsystem..."); } Cl.Init(); // add + commands from command line if (!Cbuf.AddLateCommands()) { // if the user didn't give any commands, run default action if (Globals.dedicated.value == 0) { Cbuf.AddText("d1\n"); } else { Cbuf.AddText("dedicated_start\n"); } Cbuf.Execute(); } else { // the user asked for something explicit // so drop the loading plaque SCR.EndLoadingPlaque(); } Com.Printf("====== Quake2 Initialized ======\n\n"); // save config when configuration is completed Cl.WriteConfiguration(); } catch (Exception) { Sys.Error("Error during initialization"); } }