?? cl.java
字號:
/* * CL.java * Copyright (C) 2004 * * $Id: CL.java,v 1.29 2005/12/18 22:10:10 cawe Exp $ *//* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */package jake2.client;import jake2.Defines;import jake2.Globals;import jake2.game.*;import jake2.qcommon.*;import jake2.server.SV_MAIN;import jake2.sound.S;import jake2.sys.*;import jake2.util.*;import java.io.IOException;import java.io.RandomAccessFile;import java.nio.ByteBuffer;import java.nio.ByteOrder;/** * CL */public final class CL { static int precache_check; // for autodownload of precache items static int precache_spawncount; static int precache_tex; static int precache_model_skin; static byte precache_model[]; // used for skin checking in alias models public static final int PLAYER_MULT = 5; public static class cheatvar_t { String name; String value; cvar_t var; } public static String cheatvarsinfo[][] = { { "timescale", "1" }, { "timedemo", "0" }, { "r_drawworld", "1" }, { "cl_testlights", "0" }, { "r_fullbright", "0" }, { "r_drawflat", "0" }, { "paused", "0" }, { "fixedtime", "0" }, { "sw_draworder", "0" }, { "gl_lightmap", "0" }, { "gl_saturatelighting", "0" }, { null, null } }; public static cheatvar_t cheatvars[]; static { cheatvars = new cheatvar_t[cheatvarsinfo.length]; for (int n = 0; n < cheatvarsinfo.length; n++) { cheatvars[n] = new cheatvar_t(); cheatvars[n].name = cheatvarsinfo[n][0]; cheatvars[n].value = cheatvarsinfo[n][1]; } } static int numcheatvars; /** * Stop_f * * Stop recording a demo. */ static xcommand_t Stop_f = new xcommand_t() { public void execute() { try { int len; if (!Globals.cls.demorecording) { Com.Printf("Not recording a demo.\n"); return; } // finish up len = -1; Globals.cls.demofile.writeInt(EndianHandler.swapInt(len)); Globals.cls.demofile.close(); Globals.cls.demofile = null; Globals.cls.demorecording = false; Com.Printf("Stopped demo.\n"); } catch (IOException e) { } } }; static entity_state_t nullstate = new entity_state_t(null); /** * Record_f * * record <demoname> * Begins recording a demo from the current position. */ static xcommand_t Record_f = new xcommand_t() { public void execute() { try { String name; byte buf_data[] = new byte[Defines.MAX_MSGLEN]; sizebuf_t buf = new sizebuf_t(); int i; entity_state_t ent; if (Cmd.Argc() != 2) { Com.Printf("record <demoname>\n"); return; } if (Globals.cls.demorecording) { Com.Printf("Already recording.\n"); return; } if (Globals.cls.state != Defines.ca_active) { Com.Printf("You must be in a level to record.\n"); return; } // // open the demo file // name = FS.Gamedir() + "/demos/" + Cmd.Argv(1) + ".dm2"; Com.Printf("recording to " + name + ".\n"); FS.CreatePath(name); Globals.cls.demofile = new RandomAccessFile(name, "rw"); if (Globals.cls.demofile == null) { Com.Printf("ERROR: couldn't open.\n"); return; } Globals.cls.demorecording = true; // don't start saving messages until a non-delta compressed // message is received Globals.cls.demowaiting = true; // // write out messages to hold the startup information // SZ.Init(buf, buf_data, Defines.MAX_MSGLEN); // send the serverdata MSG.WriteByte(buf, Defines.svc_serverdata); MSG.WriteInt(buf, Defines.PROTOCOL_VERSION); MSG.WriteInt(buf, 0x10000 + Globals.cl.servercount); MSG.WriteByte(buf, 1); // demos are always attract loops MSG.WriteString(buf, Globals.cl.gamedir); MSG.WriteShort(buf, Globals.cl.playernum); MSG.WriteString(buf, Globals.cl.configstrings[Defines.CS_NAME]); // configstrings for (i = 0; i < Defines.MAX_CONFIGSTRINGS; i++) { if (Globals.cl.configstrings[i].length() > 0) { if (buf.cursize + Globals.cl.configstrings[i].length() + 32 > buf.maxsize) { // write it out Globals.cls.demofile.writeInt(EndianHandler.swapInt(buf.cursize)); Globals.cls.demofile .write(buf.data, 0, buf.cursize); buf.cursize = 0; } MSG.WriteByte(buf, Defines.svc_configstring); MSG.WriteShort(buf, i); MSG.WriteString(buf, Globals.cl.configstrings[i]); } } // baselines nullstate.clear(); for (i = 0; i < Defines.MAX_EDICTS; i++) { ent = Globals.cl_entities[i].baseline; if (ent.modelindex == 0) continue; if (buf.cursize + 64 > buf.maxsize) { // write it out Globals.cls.demofile.writeInt(EndianHandler.swapInt(buf.cursize)); Globals.cls.demofile.write(buf.data, 0, buf.cursize); buf.cursize = 0; } MSG.WriteByte(buf, Defines.svc_spawnbaseline); MSG.WriteDeltaEntity(nullstate, Globals.cl_entities[i].baseline, buf, true, true); } MSG.WriteByte(buf, Defines.svc_stufftext); MSG.WriteString(buf, "precache\n"); // write it to the demo file Globals.cls.demofile.writeInt(EndianHandler.swapInt(buf.cursize)); Globals.cls.demofile.write(buf.data, 0, buf.cursize); // the rest of the demo file will be individual frames } catch (IOException e) { } } }; /** * ForwardToServer_f */ static xcommand_t ForwardToServer_f = new xcommand_t() { public void execute() { if (Globals.cls.state != Defines.ca_connected && Globals.cls.state != Defines.ca_active) { Com.Printf("Can't \"" + Cmd.Argv(0) + "\", not connected\n"); return; } // don't forward the first argument if (Cmd.Argc() > 1) { MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd); SZ.Print(Globals.cls.netchan.message, Cmd.Args()); } } }; /** * Pause_f */ static xcommand_t Pause_f = new xcommand_t() { public void execute() { // never pause in multiplayer if (Cvar.VariableValue("maxclients") > 1 || Globals.server_state == 0) { Cvar.SetValue("paused", 0); return; } Cvar.SetValue("paused", Globals.cl_paused.value); } }; /** * Quit_f */ static xcommand_t Quit_f = new xcommand_t() { public void execute() { Disconnect(); Com.Quit(); } }; /** * Connect_f */ static xcommand_t Connect_f = new xcommand_t() { public void execute() { String server; if (Cmd.Argc() != 2) { Com.Printf("usage: connect <server>\n"); return; } if (Globals.server_state != 0) { // if running a local server, kill it and reissue SV_MAIN.SV_Shutdown("Server quit\n", false); } else { Disconnect(); } server = Cmd.Argv(1); NET.Config(true); // allow remote Disconnect(); Globals.cls.state = Defines.ca_connecting; //strncpy (cls.servername, server, sizeof(cls.servername)-1); Globals.cls.servername = server; Globals.cls.connect_time = -99999; // CL_CheckForResend() will fire immediately } }; /** * Rcon_f * * Send the rest of the command line over as an unconnected command. */ static xcommand_t Rcon_f = new xcommand_t() { public void execute() { if (Globals.rcon_client_password.string.length() == 0) { Com.Printf("You must set 'rcon_password' before\nissuing an rcon command.\n"); return; } StringBuffer message = new StringBuffer(1024); // connection less packet message.append('\u00ff'); message.append('\u00ff'); message.append('\u00ff'); message.append('\u00ff'); // allow remote NET.Config(true); message.append("rcon "); message.append(Globals.rcon_client_password.string); message.append(" "); for (int i = 1; i < Cmd.Argc(); i++) { message.append(Cmd.Argv(i)); message.append(" "); } netadr_t to = new netadr_t(); if (Globals.cls.state >= Defines.ca_connected) to = Globals.cls.netchan.remote_address; else { if (Globals.rcon_address.string.length() == 0) { Com.Printf("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands\n"); return; } NET.StringToAdr(Globals.rcon_address.string, to); if (to.port == 0) to.port = Defines.PORT_SERVER; } message.append('\0'); String b = message.toString(); NET.SendPacket(Defines.NS_CLIENT, b.length(), Lib.stringToBytes(b), to); } }; static xcommand_t Disconnect_f = new xcommand_t() { public void execute() { Com.Error(Defines.ERR_DROP, "Disconnected from server"); } }; /** * Changing_f * * Just sent as a hint to the client that they should drop to full console. */ static xcommand_t Changing_f = new xcommand_t() { public void execute() { //ZOID //if we are downloading, we don't change! // This so we don't suddenly stop downloading a map if (Globals.cls.download != null) return; SCR.BeginLoadingPlaque(); Globals.cls.state = Defines.ca_connected; // not active anymore, but // not disconnected Com.Printf("\nChanging map...\n"); } }; /** * Reconnect_f * * The server is changing levels. */ static xcommand_t Reconnect_f = new xcommand_t() { public void execute() { //ZOID //if we are downloading, we don't change! This so we don't suddenly // stop downloading a map if (Globals.cls.download != null) return; S.StopAllSounds(); if (Globals.cls.state == Defines.ca_connected) { Com.Printf("reconnecting...\n"); Globals.cls.state = Defines.ca_connected; MSG.WriteChar(Globals.cls.netchan.message, Defines.clc_stringcmd);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -