📄 cl.java
字号:
MSG.WriteString(Globals.cls.netchan.message, "new"); return; } if (Globals.cls.servername != null) { if (Globals.cls.state >= Defines.ca_connected) { Disconnect(); Globals.cls.connect_time = Globals.cls.realtime - 1500; } else Globals.cls.connect_time = -99999; // fire immediately Globals.cls.state = Defines.ca_connecting; Com.Printf("reconnecting...\n"); } } }; /** * PingServers_f */ static xcommand_t PingServers_f = new xcommand_t() { public void execute() { int i; netadr_t adr = new netadr_t(); //char name[32]; String name; String adrstring; cvar_t noudp; cvar_t noipx; NET.Config(true); // allow remote // send a broadcast packet Com.Printf("pinging broadcast...\n"); noudp = Cvar.Get("noudp", "0", Defines.CVAR_NOSET); if (noudp.value == 0.0f) { adr.type = Defines.NA_BROADCAST; adr.port = Defines.PORT_SERVER; //adr.port = BigShort(PORT_SERVER); Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "info " + Defines.PROTOCOL_VERSION); } // we use no IPX noipx = Cvar.Get("noipx", "1", Defines.CVAR_NOSET); if (noipx.value == 0.0f) { adr.type = Defines.NA_BROADCAST_IPX; //adr.port = BigShort(PORT_SERVER); adr.port = Defines.PORT_SERVER; Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "info " + Defines.PROTOCOL_VERSION); } // send a packet to each address book entry for (i = 0; i < 16; i++) { //Com_sprintf (name, sizeof(name), "adr%i", i); name = "adr" + i; adrstring = Cvar.VariableString(name); if (adrstring == null || adrstring.length() == 0) continue; Com.Printf("pinging " + adrstring + "...\n"); if (!NET.StringToAdr(adrstring, adr)) { Com.Printf("Bad address: " + adrstring + "\n"); continue; } if (adr.port == 0) //adr.port = BigShort(PORT_SERVER); adr.port = Defines.PORT_SERVER; Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "info " + Defines.PROTOCOL_VERSION); } } }; /** * Skins_f * * Load or download any custom player skins and models. */ static xcommand_t Skins_f = new xcommand_t() { public void execute() { int i; for (i = 0; i < Defines.MAX_CLIENTS; i++) { if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i] == null) continue; Com.Printf("client " + i + ": " + Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i] + "\n"); SCR.UpdateScreen(); Sys.SendKeyEvents(); // pump message loop CL_parse.ParseClientinfo(i); } } }; /** * Userinfo_f */ static xcommand_t Userinfo_f = new xcommand_t() { public void execute() { Com.Printf("User info settings:\n"); Info.Print(Cvar.Userinfo()); } }; /** * Snd_Restart_f * * Restart the sound subsystem so it can pick up new parameters and flush * all sounds. */ static xcommand_t Snd_Restart_f = new xcommand_t() { public void execute() { S.Shutdown(); S.Init(); CL_parse.RegisterSounds(); } }; // ENV_CNT is map load, ENV_CNT+1 is first env map public static final int ENV_CNT = (Defines.CS_PLAYERSKINS + Defines.MAX_CLIENTS * CL.PLAYER_MULT); public static final int TEXTURE_CNT = (ENV_CNT + 13); static String env_suf[] = { "rt", "bk", "lf", "ft", "up", "dn" }; /** * The server will send this command right before allowing the client into * the server. */ static xcommand_t Precache_f = new xcommand_t() { public void execute() { // Yet another hack to let old demos work the old precache sequence. if (Cmd.Argc() < 2) { int iw[] = { 0 }; // for detecting cheater maps CM.CM_LoadMap(Globals.cl.configstrings[Defines.CS_MODELS + 1], true, iw); CL_parse.RegisterSounds(); CL_view.PrepRefresh(); return; } CL.precache_check = Defines.CS_MODELS; CL.precache_spawncount = Lib.atoi(Cmd.Argv(1)); CL.precache_model = null; CL.precache_model_skin = 0; RequestNextDownload(); } }; private static int extratime; // ============================================================================ /** * Shutdown * * FIXME: this is a callback from Sys_Quit and Com_Error. It would be better * to run quit through here before the final handoff to the sys code. */ static boolean isdown = false; /** * WriteDemoMessage * * Dumps the current net message, prefixed by the length */ static void WriteDemoMessage() { int swlen; // the first eight bytes are just packet sequencing stuff swlen = Globals.net_message.cursize - 8; try { Globals.cls.demofile.writeInt(EndianHandler.swapInt(swlen)); Globals.cls.demofile.write(Globals.net_message.data, 8, swlen); } catch (IOException e) { } } /** * SendConnectPacket * * We have gotten a challenge from the server, so try and connect. */ static void SendConnectPacket() { netadr_t adr = new netadr_t(); int port; if (!NET.StringToAdr(Globals.cls.servername, adr)) { Com.Printf("Bad server address\n"); Globals.cls.connect_time = 0; return; } if (adr.port == 0) adr.port = Defines.PORT_SERVER; // adr.port = BigShort(PORT_SERVER); port = (int) Cvar.VariableValue("qport"); Globals.userinfo_modified = false; Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "connect " + Defines.PROTOCOL_VERSION + " " + port + " " + Globals.cls.challenge + " \"" + Cvar.Userinfo() + "\"\n"); } /** * CheckForResend * * Resend a connect message if the last one has timed out. */ static void CheckForResend() { netadr_t adr = new netadr_t(); // if the local server is running and we aren't // then connect if (Globals.cls.state == Defines.ca_disconnected && Globals.server_state != 0) { Globals.cls.state = Defines.ca_connecting; Globals.cls.servername = "localhost"; // we don't need a challenge on the localhost SendConnectPacket(); return; } // resend if we haven't gotten a reply yet if (Globals.cls.state != Defines.ca_connecting) return; if (Globals.cls.realtime - Globals.cls.connect_time < 3000) return; if (!NET.StringToAdr(Globals.cls.servername, adr)) { Com.Printf("Bad server address\n"); Globals.cls.state = Defines.ca_disconnected; return; } if (adr.port == 0) adr.port = Defines.PORT_SERVER; // for retransmit requests Globals.cls.connect_time = Globals.cls.realtime; Com.Printf("Connecting to " + Globals.cls.servername + "...\n"); Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "getchallenge\n"); } /** * ClearState * */ static void ClearState() { S.StopAllSounds(); CL_fx.ClearEffects(); CL_tent.ClearTEnts(); // wipe the entire cl structure Globals.cl = new client_state_t(); for (int i = 0; i < Globals.cl_entities.length; i++) { Globals.cl_entities[i] = new centity_t(); } SZ.Clear(Globals.cls.netchan.message); } /** * Disconnect * * Goes from a connected state to full screen console state Sends a * disconnect message to the server This is also called on Com_Error, so it * shouldn't cause any errors. */ static void Disconnect() { String fin; if (Globals.cls.state == Defines.ca_disconnected) return; if (Globals.cl_timedemo != null && Globals.cl_timedemo.value != 0.0f) { int time; time = (int) (Timer.Milliseconds() - Globals.cl.timedemo_start); if (time > 0) Com.Printf("%i frames, %3.1f seconds: %3.1f fps\n", new Vargs(3).add(Globals.cl.timedemo_frames).add( time / 1000.0).add( Globals.cl.timedemo_frames * 1000.0 / time)); } Math3D.VectorClear(Globals.cl.refdef.blend); Globals.re.CinematicSetPalette(null); Menu.ForceMenuOff(); Globals.cls.connect_time = 0; SCR.StopCinematic(); if (Globals.cls.demorecording) Stop_f.execute(); // send a disconnect message to the server fin = (char) Defines.clc_stringcmd + "disconnect"; Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin)); Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin)); Netchan.Transmit(Globals.cls.netchan, fin.length(), Lib.stringToBytes(fin)); ClearState(); // stop download if (Globals.cls.download != null) { Lib.fclose(Globals.cls.download); Globals.cls.download = null; } Globals.cls.state = Defines.ca_disconnected; } /** * ParseStatusMessage * * Handle a reply from a ping. */ static void ParseStatusMessage() { String s; s = MSG.ReadString(Globals.net_message); Com.Printf(s + "\n"); Menu.AddToServerList(Globals.net_from, s); } /** * ConnectionlessPacket * * Responses to broadcasts, etc */ static void ConnectionlessPacket() { String s; String c; MSG.BeginReading(Globals.net_message); MSG.ReadLong(Globals.net_message); // skip the -1 s = MSG.ReadStringLine(Globals.net_message); Cmd.TokenizeString(s.toCharArray(), false); c = Cmd.Argv(0); Com.Println(Globals.net_from.toString() + ": " + c); // server connection if (c.equals("client_connect")) { if (Globals.cls.state == Defines.ca_connected) { Com.Printf("Dup connect received. Ignored.\n"); return; } Netchan.Setup(Defines.NS_CLIENT, Globals.cls.netchan, Globals.net_from, Globals.cls.quakePort); MSG.WriteChar(Globals.cls.netchan.message, Defines.clc_stringcmd); MSG.WriteString(Globals.cls.netchan.message, "new"); Globals.cls.state = Defines.ca_connected; return; } // server responding to a status broadcast if (c.equals("info")) { ParseStatusMessage(); return; } // remote command from gui front end if (c.equals("cmd")) { if (!NET.IsLocalAddress(Globals.net_from)) { Com.Printf("Command packet from remote host. Ignored.\n"); return; } s = MSG.ReadString(Globals.net_message); Cbuf.AddText(s); Cbuf.AddText("\n"); return; } // print command from somewhere if (c.equals("print")) { s = MSG.ReadString(Globals.net_message); if (s.length() > 0) Com.Printf(s); return; } // ping from somewhere if (c.equals("ping")) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -