public static void ParseConfigString( ) { Int32 i = MSG.ReadShort(Globals.net_message); if (i < 0 || i >= Defines.MAX_CONFIGSTRINGS) { Com.Error(Defines.ERR_DROP, "configstring > MAX_CONFIGSTRINGS"); } var s = MSG.ReadString(Globals.net_message); var olds = Globals.cl.configstrings[i]; Globals.cl.configstrings[i] = s; 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); } } }
public static void Flashlight(int ent, float[] pos) { CL_fx.cdlight_t dl; dl = CL_fx.AllocDlight(ent); Math3D.VectorCopy(pos, dl.origin); dl.radius = 400; dl.minlight = 250; dl.die = Globals.cl.time + 100; dl.color[0] = 1; dl.color[1] = 1; dl.color[2] = 1; }
public static void FireEntityEvents(frame_t frame) { entity_state_t s1; Int32 pnum, num; for (pnum = 0; pnum < frame.num_entities; pnum++) { num = (frame.parse_entities + pnum) & (Defines.MAX_PARSE_ENTITIES - 1); s1 = Globals.cl_parse_entities[num]; if (s1.event_renamed != 0) { CL_fx.EntityEvent(s1); } if ((s1.effects & Defines.EF_TELEPORTER) != 0) { CL_fx.TeleporterParticles(s1); } } }
public static void ColorFlash(float[] pos, int ent, int intensity, float r, float g, float b) { CL_fx.cdlight_t dl; if ((Globals.vidref_val == Defines.VIDREF_SOFT) && ((r < 0) || (g < 0) || (b < 0))) { intensity = -intensity; r = -r; g = -g; b = -b; } dl = CL_fx.AllocDlight(ent); Math3D.VectorCopy(pos, dl.origin); dl.radius = intensity; dl.minlight = 250; dl.die = Globals.cl.time + 100; dl.color[0] = r; dl.color[1] = g; dl.color[2] = b; }
public static void AddEntities( ) { if (Globals.cls.state != Defines.ca_active) { return; } if (Globals.cl.time > Globals.cl.frame.servertime) { if (Globals.cl_showclamp.value != 0) { Com.Printf("high clamp " + (Globals.cl.time - Globals.cl.frame.servertime) + "\\n"); } Globals.cl.time = Globals.cl.frame.servertime; Globals.cl.lerpfrac = 1F; } else if (Globals.cl.time < Globals.cl.frame.servertime - 100) { if (Globals.cl_showclamp.value != 0) { Com.Printf("low clamp " + (Globals.cl.frame.servertime - 100 - Globals.cl.time) + "\\n"); } Globals.cl.time = Globals.cl.frame.servertime - 100; Globals.cl.lerpfrac = 0; } else { Globals.cl.lerpfrac = 1F - (Globals.cl.frame.servertime - Globals.cl.time) * 0.01F; } if (Globals.cl_timedemo.value != 0) { Globals.cl.lerpfrac = 1F; } CalcViewValues(); AddPacketEntities(Globals.cl.frame); CL_tent.AddTEnts(); CL_fx.AddParticles(); CL_fx.AddDLights(); CL_fx.AddLightStyles(); }
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(); } }
static void AddPacketEntities(frame_t frame) { entity_state_t s1; Single autorotate; Int32 i; Int32 pnum; centity_t cent; Int32 autoanim; clientinfo_t ci; Int32 effects, renderfx; autorotate = Math3D.Anglemod(Globals.cl.time / 10); autoanim = 2 * Globals.cl.time / 1000; ent.Clear(); for (pnum = 0; pnum < frame.num_entities; pnum++) { s1 = Globals.cl_parse_entities[(frame.parse_entities + pnum) & (Defines.MAX_PARSE_ENTITIES - 1)]; cent = Globals.cl_entities[s1.number]; effects = s1.effects; renderfx = s1.renderfx; if ((effects & Defines.EF_ANIM01) != 0) { ent.frame = autoanim & 1; } else if ((effects & Defines.EF_ANIM23) != 0) { ent.frame = 2 + (autoanim & 1); } else if ((effects & Defines.EF_ANIM_ALL) != 0) { ent.frame = autoanim; } else if ((effects & Defines.EF_ANIM_ALLFAST) != 0) { ent.frame = Globals.cl.time / 100; } else { ent.frame = s1.frame; } if ((effects & Defines.EF_PENT) != 0) { effects &= ~Defines.EF_PENT; effects |= Defines.EF_COLOR_SHELL; renderfx |= Defines.RF_SHELL_RED; } if ((effects & Defines.EF_QUAD) != 0) { effects &= ~Defines.EF_QUAD; effects |= Defines.EF_COLOR_SHELL; renderfx |= Defines.RF_SHELL_BLUE; } if ((effects & Defines.EF_DOUBLE) != 0) { effects &= ~Defines.EF_DOUBLE; effects |= Defines.EF_COLOR_SHELL; renderfx |= Defines.RF_SHELL_DOUBLE; } if ((effects & Defines.EF_HALF_DAMAGE) != 0) { effects &= ~Defines.EF_HALF_DAMAGE; effects |= Defines.EF_COLOR_SHELL; renderfx |= Defines.RF_SHELL_HALF_DAM; } ent.oldframe = cent.prev.frame; ent.backlerp = 1F - Globals.cl.lerpfrac; if ((renderfx & (Defines.RF_FRAMELERP | Defines.RF_BEAM)) != 0) { Math3D.VectorCopy(cent.current.origin, ent.origin); Math3D.VectorCopy(cent.current.old_origin, ent.oldorigin); } else { for (i = 0; i < 3; i++) { ent.origin[i] = ent.oldorigin[i] = cent.prev.origin[i] + Globals.cl.lerpfrac * (cent.current.origin[i] - cent.prev.origin[i]); } } if ((renderfx & Defines.RF_BEAM) != 0) { ent.alpha = 0.3F; ent.skinnum = ( Int32 )(s1.skinnum >> ((Globals.rnd.Next(4)) * 8)) & 0xff; //Math.Random(); ent.model = null; } else { if (s1.modelindex == 255) { ent.skinnum = 0; ci = Globals.cl.clientinfo[s1.skinnum & 0xff]; ent.skin = ci.skin; ent.model = ci.model; if (null == ent.skin || null == ent.model) { ent.skin = Globals.cl.baseclientinfo.skin; ent.model = Globals.cl.baseclientinfo.model; } if ((renderfx & Defines.RF_USE_DISGUISE) != 0) { if (ent.skin.name.StartsWith("players/male")) { ent.skin = Globals.re.RegisterSkin("players/male/disguise.pcx"); ent.model = Globals.re.RegisterModel("players/male/tris.md2"); } else if (ent.skin.name.StartsWith("players/female")) { ent.skin = Globals.re.RegisterSkin("players/female/disguise.pcx"); ent.model = Globals.re.RegisterModel("players/female/tris.md2"); } else if (ent.skin.name.StartsWith("players/cyborg")) { ent.skin = Globals.re.RegisterSkin("players/cyborg/disguise.pcx"); ent.model = Globals.re.RegisterModel("players/cyborg/tris.md2"); } } } else { ent.skinnum = ( Int32 )s1.skinnum; ent.skin = null; ent.model = Globals.cl.model_draw[s1.modelindex]; } } if (renderfx == Defines.RF_TRANSLUCENT) { ent.alpha = 0.7F; } if ((effects & Defines.EF_COLOR_SHELL) != 0) { ent.flags = 0; } else { ent.flags = renderfx; } if ((effects & Defines.EF_ROTATE) != 0) { ent.angles[0] = 0; ent.angles[1] = autorotate; ent.angles[2] = 0; } else if ((effects & Defines.EF_SPINNINGLIGHTS) != 0) { ent.angles[0] = 0; ent.angles[1] = Math3D.Anglemod(Globals.cl.time / 2) + s1.angles[1]; ent.angles[2] = 180; { Single[] forward = new Single[] { 0, 0, 0 }; Single[] start = new Single[] { 0, 0, 0 }; Math3D.AngleVectors(ent.angles, forward, null, null); Math3D.VectorMA(ent.origin, 64, forward, start); V.AddLight(start, 100, 1, 0, 0); } } else { Single a1, a2; for (i = 0; i < 3; i++) { a1 = cent.current.angles[i]; a2 = cent.prev.angles[i]; ent.angles[i] = Math3D.LerpAngle(a2, a1, Globals.cl.lerpfrac); } } if (s1.number == Globals.cl.playernum + 1) { ent.flags |= Defines.RF_VIEWERMODEL; if ((effects & Defines.EF_FLAG1) != 0) { V.AddLight(ent.origin, 225, 1F, 0.1F, 0.1F); } else if ((effects & Defines.EF_FLAG2) != 0) { V.AddLight(ent.origin, 225, 0.1F, 0.1F, 1F); } else if ((effects & Defines.EF_TAGTRAIL) != 0) { V.AddLight(ent.origin, 225, 1F, 1F, 0F); } else if ((effects & Defines.EF_TRACKERTRAIL) != 0) { V.AddLight(ent.origin, 225, -1F, -1F, -1F); } continue; } if (s1.modelindex == 0) { continue; } if ((effects & Defines.EF_BFG) != 0) { ent.flags |= Defines.RF_TRANSLUCENT; ent.alpha = 0.3F; } if ((effects & Defines.EF_PLASMA) != 0) { ent.flags |= Defines.RF_TRANSLUCENT; ent.alpha = 0.6F; } if ((effects & Defines.EF_SPHERETRANS) != 0) { ent.flags |= Defines.RF_TRANSLUCENT; if ((effects & Defines.EF_TRACKERTRAIL) != 0) { ent.alpha = 0.6F; } else { ent.alpha = 0.3F; } } V.AddEntity(ent); if ((effects & Defines.EF_COLOR_SHELL) != 0) { if ((renderfx & Defines.RF_SHELL_HALF_DAM) != 0) { if (FS.Developer_searchpath(2) == 2) { if ((renderfx & (Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE)) != 0) { renderfx &= ~Defines.RF_SHELL_HALF_DAM; } } } if ((renderfx & Defines.RF_SHELL_DOUBLE) != 0) { if (FS.Developer_searchpath(2) == 2) { if ((renderfx & (Defines.RF_SHELL_RED | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_GREEN)) != 0) { renderfx &= ~Defines.RF_SHELL_DOUBLE; } if ((renderfx & Defines.RF_SHELL_RED) != 0) { renderfx |= Defines.RF_SHELL_BLUE; } else if ((renderfx & Defines.RF_SHELL_BLUE) != 0) { if ((renderfx & Defines.RF_SHELL_GREEN) != 0) { renderfx &= ~Defines.RF_SHELL_BLUE; } else { renderfx |= Defines.RF_SHELL_GREEN; } } } } ent.flags = renderfx | Defines.RF_TRANSLUCENT; ent.alpha = 0.3F; V.AddEntity(ent); } ent.skin = null; ent.skinnum = 0; ent.flags = 0; ent.alpha = 0; if (s1.modelindex2 != 0) { if (s1.modelindex2 == 255) { ci = Globals.cl.clientinfo[s1.skinnum & 0xff]; i = ( Int32 )(s1.skinnum >> 8); // These casts probably break something TODO if (0 == Globals.cl_vwep.value || i > Defines.MAX_CLIENTWEAPONMODELS - 1) { i = 0; } ent.model = ci.weaponmodel[i]; if (null == ent.model) { if (i != 0) { ent.model = ci.weaponmodel[0]; } if (null == ent.model) { ent.model = Globals.cl.baseclientinfo.weaponmodel[0]; } } } else { ent.model = Globals.cl.model_draw[s1.modelindex2]; } if (Globals.cl.configstrings[Defines.CS_MODELS + (s1.modelindex2)].EqualsIgnoreCase("models/items/shell/tris.md2")) { ent.alpha = 0.32F; ent.flags = Defines.RF_TRANSLUCENT; } V.AddEntity(ent); ent.flags = 0; ent.alpha = 0; } if (s1.modelindex3 != 0) { ent.model = Globals.cl.model_draw[s1.modelindex3]; V.AddEntity(ent); } if (s1.modelindex4 != 0) { ent.model = Globals.cl.model_draw[s1.modelindex4]; V.AddEntity(ent); } if ((effects & Defines.EF_POWERSCREEN) != 0) { ent.model = CL_tent.cl_mod_powerscreen; ent.oldframe = 0; ent.frame = 0; ent.flags |= (Defines.RF_TRANSLUCENT | Defines.RF_SHELL_GREEN); ent.alpha = 0.3F; V.AddEntity(ent); } if ((effects & ~Defines.EF_ROTATE) != 0) { if ((effects & Defines.EF_ROCKET) != 0) { CL_fx.RocketTrail(cent.lerp_origin, ent.origin, cent); V.AddLight(ent.origin, 200, 1, 1, 0); } else if ((effects & Defines.EF_BLASTER) != 0) { if ((effects & Defines.EF_TRACKER) != 0) { CL_newfx.BlasterTrail2(cent.lerp_origin, ent.origin); V.AddLight(ent.origin, 200, 0, 1, 0); } else { CL_fx.BlasterTrail(cent.lerp_origin, ent.origin); V.AddLight(ent.origin, 200, 1, 1, 0); } } else if ((effects & Defines.EF_HYPERBLASTER) != 0) { if ((effects & Defines.EF_TRACKER) != 0) { V.AddLight(ent.origin, 200, 0, 1, 0); } else { V.AddLight(ent.origin, 200, 1, 1, 0); } } else if ((effects & Defines.EF_GIB) != 0) { CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects); } else if ((effects & Defines.EF_GRENADE) != 0) { CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects); } else if ((effects & Defines.EF_FLIES) != 0) { CL_fx.FlyEffect(cent, ent.origin); } else if ((effects & Defines.EF_BFG) != 0) { if ((effects & Defines.EF_ANIM_ALLFAST) != 0) { CL_fx.BfgParticles(ent); i = 200; } else { i = bfg_lightramp[s1.frame]; } V.AddLight(ent.origin, i, 0, 1, 0); } else if ((effects & Defines.EF_TRAP) != 0) { ent.origin[2] += 32; CL_fx.TrapParticles(ent); i = (Globals.rnd.Next(100)) + 100; V.AddLight(ent.origin, i, 1, 0.8F, 0.1F); } else if ((effects & Defines.EF_FLAG1) != 0) { CL_fx.FlagTrail(cent.lerp_origin, ent.origin, 242); V.AddLight(ent.origin, 225, 1, 0.1F, 0.1F); } else if ((effects & Defines.EF_FLAG2) != 0) { CL_fx.FlagTrail(cent.lerp_origin, ent.origin, 115); V.AddLight(ent.origin, 225, 0.1F, 0.1F, 1); } else if ((effects & Defines.EF_TAGTRAIL) != 0) { CL_newfx.TagTrail(cent.lerp_origin, ent.origin, 220); V.AddLight(ent.origin, 225, 1F, 1F, 0F); } else if ((effects & Defines.EF_TRACKERTRAIL) != 0) { if ((effects & Defines.EF_TRACKER) != 0) { Single intensity; intensity = ( Single )(50 + (500 * (Math.Sin(Globals.cl.time / 500) + 1))); if (Globals.vidref_val == Defines.VIDREF_GL) { V.AddLight(ent.origin, intensity, -1F, -1F, -1F); } else { V.AddLight(ent.origin, -1F * intensity, 1F, 1F, 1F); } } else { CL_newfx.Tracker_Shell(cent.lerp_origin); V.AddLight(ent.origin, 155, -1F, -1F, -1F); } } else if ((effects & Defines.EF_TRACKER) != 0) { CL_newfx.TrackerTrail(cent.lerp_origin, ent.origin, 0); if (Globals.vidref_val == Defines.VIDREF_GL) { V.AddLight(ent.origin, 200, -1, -1, -1); } else { V.AddLight(ent.origin, -200, 1, 1, 1); } } else if ((effects & Defines.EF_GREENGIB) != 0) { CL_fx.DiminishingTrail(cent.lerp_origin, ent.origin, cent, effects); } else if ((effects & Defines.EF_IONRIPPER) != 0) { CL_fx.IonripperTrail(cent.lerp_origin, ent.origin); V.AddLight(ent.origin, 100, 1, 0.5F, 0.5F); } else if ((effects & Defines.EF_BLUEHYPERBLASTER) != 0) { V.AddLight(ent.origin, 200, 0, 0, 1); } else if ((effects & Defines.EF_PLASMA) != 0) { if ((effects & Defines.EF_ANIM_ALLFAST) != 0) { CL_fx.BlasterTrail(cent.lerp_origin, ent.origin); } V.AddLight(ent.origin, 130, 1, 0.5F, 0.5F); } } Math3D.VectorCopy(ent.origin, cent.lerp_origin); } }