📄 cl_parse.java
字号:
if (Globals.cl_noskins.value != 0 || s.length() == 0) { model_filename = ("players/male/tris.md2"); weapon_filename = ("players/male/weapon.md2"); skin_filename = ("players/male/grunt.pcx"); ci.iconname = ("/players/male/grunt_i.pcx"); ci.model = Globals.re.RegisterModel(model_filename); ci.weaponmodel = new model_t[Defines.MAX_CLIENTWEAPONMODELS]; ci.weaponmodel[0] = Globals.re.RegisterModel(weapon_filename); ci.skin = Globals.re.RegisterSkin(skin_filename); ci.icon = Globals.re.RegisterPic(ci.iconname); } else { // isolate the model name int pos = s.indexOf('/'); if (pos == -1) pos = s.indexOf('/'); if (pos == -1) { pos = 0; Com.Error(Defines.ERR_FATAL, "Invalid model name:" + s); } model_name = s.substring(0, pos); // isolate the skin name skin_name = s.substring(pos + 1, s.length()); // model file model_filename = "players/" + model_name + "/tris.md2"; ci.model = Globals.re.RegisterModel(model_filename); if (ci.model == null) { model_name = "male"; model_filename = "players/male/tris.md2"; ci.model = Globals.re.RegisterModel(model_filename); } // skin file skin_filename = "players/" + model_name + "/" + skin_name + ".pcx"; ci.skin = Globals.re.RegisterSkin(skin_filename); // if we don't have the skin and the model wasn't male, // see if the male has it (this is for CTF's skins) if (ci.skin == null && !model_name.equalsIgnoreCase("male")) { // change model to male model_name = "male"; model_filename = "players/male/tris.md2"; ci.model = Globals.re.RegisterModel(model_filename); // see if the skin exists for the male model skin_filename = "players/" + model_name + "/" + skin_name + ".pcx"; ci.skin = Globals.re.RegisterSkin(skin_filename); } // if we still don't have a skin, it means that the male model // didn't have // it, so default to grunt if (ci.skin == null) { // see if the skin exists for the male model skin_filename = "players/" + model_name + "/grunt.pcx"; ci.skin = Globals.re.RegisterSkin(skin_filename); } // weapon file for (i = 0; i < CL_view.num_cl_weaponmodels; i++) { weapon_filename = "players/" + model_name + "/" + CL_view.cl_weaponmodels[i]; ci.weaponmodel[i] = Globals.re.RegisterModel(weapon_filename); if (null == ci.weaponmodel[i] && model_name.equals("cyborg")) { // try male weapon_filename = "players/male/" + CL_view.cl_weaponmodels[i]; ci.weaponmodel[i] = Globals.re .RegisterModel(weapon_filename); } if (0 == Globals.cl_vwep.value) break; // only one when vwep is off } // icon file ci.iconname = "/players/" + model_name + "/" + skin_name + "_i.pcx"; ci.icon = Globals.re.RegisterPic(ci.iconname); } // must have loaded all data types to be valud if (ci.skin == null || ci.icon == null || ci.model == null || ci.weaponmodel[0] == null) { ci.skin = null; ci.icon = null; ci.model = null; ci.weaponmodel[0] = null; return; } } /* * ================ CL_ParseClientinfo * * Load the skin, icon, and model for a client ================ */ public static void ParseClientinfo(int player) { String s; clientinfo_t ci; s = Globals.cl.configstrings[player + Defines.CS_PLAYERSKINS]; ci = Globals.cl.clientinfo[player]; LoadClientinfo(ci, s); } /* * ================ CL_ParseConfigString ================ */ public static void ParseConfigString() { int i; String s; String olds; i = MSG.ReadShort(Globals.net_message); if (i < 0 || i >= Defines.MAX_CONFIGSTRINGS) Com.Error(Defines.ERR_DROP, "configstring > MAX_CONFIGSTRINGS"); s = MSG.ReadString(Globals.net_message); olds = Globals.cl.configstrings[i]; Globals.cl.configstrings[i] = s; //Com.dprintln("ParseConfigString(): configstring[" + i + "]=<"+s+">"); // do something apropriate 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); } } /* * ===================================================================== * * ACTION MESSAGES * * ===================================================================== */ private static final float[] pos_v = { 0, 0, 0 }; /* * ================== CL_ParseStartSoundPacket ================== */ public static void ParseStartSoundPacket() { float pos[]; int channel, ent; int sound_num; float volume; float attenuation; int flags; float ofs; flags = MSG.ReadByte(Globals.net_message); sound_num = MSG.ReadByte(Globals.net_message); if ((flags & Defines.SND_VOLUME) != 0) volume = MSG.ReadByte(Globals.net_message) / 255.0f; else volume = Defines.DEFAULT_SOUND_PACKET_VOLUME; if ((flags & Defines.SND_ATTENUATION) != 0) attenuation = MSG.ReadByte(Globals.net_message) / 64.0f; else attenuation = Defines.DEFAULT_SOUND_PACKET_ATTENUATION; if ((flags & Defines.SND_OFFSET) != 0) ofs = MSG.ReadByte(Globals.net_message) / 1000.0f; else ofs = 0; if ((flags & Defines.SND_ENT) != 0) { // entity reletive channel = MSG.ReadShort(Globals.net_message); ent = channel >> 3; if (ent > Defines.MAX_EDICTS) Com.Error(Defines.ERR_DROP, "CL_ParseStartSoundPacket: ent = " + ent); channel &= 7; } else { ent = 0; channel = 0; } if ((flags & Defines.SND_POS) != 0) { // positioned in space MSG.ReadPos(Globals.net_message, pos_v); // is ok. sound driver copies pos = pos_v; } else // use entity number pos = null; if (null == Globals.cl.sound_precache[sound_num]) return; S.StartSound(pos, ent, channel, Globals.cl.sound_precache[sound_num], volume, attenuation, ofs); } public static void SHOWNET(String s) { if (Globals.cl_shownet.value >= 2) Com.Printf(Globals.net_message.readcount - 1 + ":" + s + "\n"); } /* * ===================== CL_ParseServerMessage ===================== */ public static void ParseServerMessage() { int cmd; String s; int i; // // if recording demos, copy the message out // //if (cl_shownet.value == 1) //Com.Printf(net_message.cursize + " "); //else if (cl_shownet.value >= 2) //Com.Printf("------------------\n"); // // parse the message // while (true) { if (Globals.net_message.readcount > Globals.net_message.cursize) { Com.Error(Defines.ERR_FATAL, "CL_ParseServerMessage: Bad server message:"); break; } 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]); } // other commands switch (cmd) { default: Com.Error(Defines.ERR_DROP, "CL_ParseServerMessage: Illegible server message\n"); break; case Defines.svc_nop: // Com.Printf ("svc_nop\n"); 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) { //ZOID, close download try { Globals.cls.download.close(); } catch (IOException e) { } Globals.cls.download = null; } Globals.cls.state = Defines.ca_connecting; Globals.cls.connect_time = -99999; // CL_CheckForResend() will // fire immediately break; case Defines.svc_print: 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: s = MSG.ReadString(Globals.net_message); Com.DPrintf("stufftext: " + s + "\n"); Cbuf.AddText(s); break; case Defines.svc_serverdata: Cbuf.Execute(); // make sure any stuffed commands are done 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: s = MSG.ReadString(Globals.net_message); Globals.cl.layout = s; 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(); // // we don't know if it is ok to save a demo message until // after we have parsed the frame // if (Globals.cls.demorecording && !Globals.cls.demowaiting) CL.WriteDemoMessage(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -