mirror of
https://github.com/nzp-team/glquake.git
synced 2024-11-10 06:31:35 +00:00
Match cl_parse.c with dquakeplus
This commit is contained in:
parent
648170fd26
commit
44600071d6
1 changed files with 208 additions and 131 deletions
|
@ -24,6 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
extern qboolean domaxammo;
|
||||
qboolean crosshair_pulse_grenade;
|
||||
|
||||
extern int EN_Find(int num,char *string);
|
||||
|
||||
char *svc_strings[] =
|
||||
{
|
||||
"svc_bad",
|
||||
|
@ -75,9 +77,8 @@ char *svc_strings[] =
|
|||
"svc_fog", // 41 // [byte] start [byte] end [byte] red [byte] green [byte] blue [float] time
|
||||
"svc_bspdecal", //42 // [string] name [byte] decal_size [coords] pos
|
||||
"svc_achievement", //43
|
||||
"svc_songegg", //44 [string] track name
|
||||
"svc_maxammo", //45
|
||||
"svc_pulse" //46
|
||||
"svc_maxammo" //44
|
||||
//"svc_pulse" //45
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
@ -148,6 +149,36 @@ void CL_ParseStartSoundPacket(void)
|
|||
S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation);
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_ParseBSPDecal
|
||||
|
||||
Spawn decals on map
|
||||
Crow_bar.
|
||||
==================
|
||||
*/
|
||||
void CL_ParseBSPDecal (void)
|
||||
{
|
||||
#ifdef __PSP__
|
||||
vec3_t pos;
|
||||
int decal_size;
|
||||
char *texname;
|
||||
|
||||
texname = MSG_ReadString ();
|
||||
decal_size = MSG_ReadByte ();
|
||||
pos[0] = MSG_ReadCoord ();
|
||||
pos[1] = MSG_ReadCoord ();
|
||||
pos[2] = MSG_ReadCoord ();
|
||||
|
||||
if(!texname)
|
||||
return;
|
||||
|
||||
Con_Printf("BSPDECAL[tex: %s size: %i pos: %f %f %f]\n", texname, decal_size, pos[0], pos[1], pos[2]);
|
||||
|
||||
R_SpawnDecalBSP(pos, texname, decal_size);
|
||||
#endif // __PSP__
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_KeepaliveMessage
|
||||
|
@ -158,20 +189,30 @@ so the server doesn't disconnect.
|
|||
*/
|
||||
void CL_KeepaliveMessage (void)
|
||||
{
|
||||
float time;
|
||||
static float lastmsg;
|
||||
double time;
|
||||
static double lastmsg;//BLUBSFIX, this was a float
|
||||
int ret;
|
||||
sizebuf_t old;
|
||||
byte olddata[8192];
|
||||
|
||||
if (sv.active)
|
||||
{
|
||||
//Con_Printf("Active Server...exit keepalive\n");
|
||||
return; // no need if server is local
|
||||
}
|
||||
if (cls.demoplayback)
|
||||
{
|
||||
//Con_Printf("Demo Playback...exit keepalive\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// read messages from server, should just be nops
|
||||
old = net_message;
|
||||
memcpy (olddata, net_message.data, net_message.cursize);
|
||||
#ifdef PSP_VFPU
|
||||
memcpy_vfpu(olddata, net_message.data, net_message.cursize);
|
||||
#else
|
||||
memcpy(olddata, net_message.data, net_message.cursize);
|
||||
#endif // PSP_VFPU
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -193,12 +234,18 @@ void CL_KeepaliveMessage (void)
|
|||
} while (ret);
|
||||
|
||||
net_message = old;
|
||||
memcpy (net_message.data, olddata, net_message.cursize);
|
||||
#ifdef PSP_VFPU
|
||||
memcpy_vfpu(net_message.data, olddata, net_message.cursize);
|
||||
#else
|
||||
memcpy(net_message.data, olddata, net_message.cursize);
|
||||
#endif // PSP_VFPU
|
||||
|
||||
// check time
|
||||
time = Sys_FloatTime ();
|
||||
if (time - lastmsg < 5)
|
||||
return;
|
||||
//Con_Printf("Time since last keepAlive msg = %f\n",time - lastmsg);
|
||||
|
||||
lastmsg = time;
|
||||
|
||||
// write out a nop
|
||||
|
@ -214,15 +261,29 @@ void CL_KeepaliveMessage (void)
|
|||
CL_ParseServerInfo
|
||||
==================
|
||||
*/
|
||||
int has_pap;
|
||||
int has_perk_revive;
|
||||
int has_perk_juggernog;
|
||||
int has_perk_speedcola;
|
||||
int has_perk_doubletap;
|
||||
int has_perk_staminup;
|
||||
int has_perk_flopper;
|
||||
int has_perk_deadshot;
|
||||
int has_perk_mulekick;
|
||||
void CL_ParseServerInfo (void)
|
||||
{
|
||||
char *str;
|
||||
char *str, tempname[MAX_QPATH];;
|
||||
int i;
|
||||
int nummodels, numsounds;
|
||||
char model_precache[MAX_MODELS][MAX_QPATH];
|
||||
char sound_precache[MAX_SOUNDS][MAX_QPATH];
|
||||
|
||||
//void R_PreMapLoad (char *);
|
||||
|
||||
//char mapname[MAX_QPATH];
|
||||
|
||||
Con_DPrintf ("Serverinfo packet received.\n");
|
||||
//Con_Printf ("Serverinfo packet received.\n");
|
||||
//
|
||||
// wipe the client_state_t struct
|
||||
//
|
||||
|
@ -266,19 +327,36 @@ void CL_ParseServerInfo (void)
|
|||
for (i=0 ; i<NUM_MODELINDEX ; i++)
|
||||
cl_modelindex[i] = -1;
|
||||
|
||||
has_pap = EN_Find(0,"perk_pap");
|
||||
has_perk_revive = EN_Find(0, "perk_revive");
|
||||
has_perk_juggernog = EN_Find(0, "perk_juggernog");
|
||||
has_perk_speedcola = EN_Find(0, "perk_speed");
|
||||
has_perk_doubletap = EN_Find(0, "perk_double");
|
||||
has_perk_staminup = EN_Find(0, "perk_staminup");
|
||||
has_perk_flopper = EN_Find(0, "perk_flopper");
|
||||
has_perk_deadshot = EN_Find(0, "perk_deadshot");
|
||||
has_perk_mulekick = EN_Find(0, "perk_mule");
|
||||
|
||||
|
||||
// precache models
|
||||
memset (cl.model_precache, 0, sizeof(cl.model_precache));
|
||||
//Con_Printf("GotModelsToLoad: ");
|
||||
for (nummodels=1 ; ; nummodels++)
|
||||
{
|
||||
str = MSG_ReadString ();
|
||||
|
||||
if (!str[0])
|
||||
break;
|
||||
|
||||
if (nummodels==MAX_MODELS)
|
||||
{
|
||||
Con_Printf ("Server sent too many model precaches\n");
|
||||
return;
|
||||
}
|
||||
strcpy (model_precache[nummodels], str);
|
||||
|
||||
Q_strncpyz (model_precache[nummodels], str, sizeof(model_precache[nummodels]));
|
||||
//Con_Printf("%i,",nummodels);
|
||||
|
||||
Mod_TouchModel (str);
|
||||
|
||||
if (!strcmp(model_precache[nummodels], "models/player.mdl"))
|
||||
|
@ -290,9 +368,11 @@ void CL_ParseServerInfo (void)
|
|||
}
|
||||
|
||||
// precache sounds
|
||||
//Con_Printf("Got Sounds to load: ");
|
||||
memset (cl.sound_precache, 0, sizeof(cl.sound_precache));
|
||||
for (numsounds=1 ; ; numsounds++)
|
||||
{
|
||||
|
||||
str = MSG_ReadString ();
|
||||
if (!str[0])
|
||||
break;
|
||||
|
@ -303,7 +383,11 @@ void CL_ParseServerInfo (void)
|
|||
}
|
||||
strcpy (sound_precache[numsounds], str);
|
||||
S_TouchSound (str);
|
||||
//Con_Printf("%i,",numsounds);
|
||||
}
|
||||
//Con_Printf("\n");
|
||||
//COM_StripExtension (COM_SkipPath(model_precache[1]), mapname);
|
||||
//R_PreMapLoad (mapname);
|
||||
|
||||
//
|
||||
// now we try to load everything else until a cache allocation fails
|
||||
|
@ -312,6 +396,8 @@ void CL_ParseServerInfo (void)
|
|||
loading_num_step = loading_num_step +nummodels + numsounds;
|
||||
loading_step = 1;
|
||||
|
||||
//Con_Printf("Loaded Model: ");
|
||||
|
||||
for (i=1 ; i<nummodels ; i++)
|
||||
{
|
||||
cl.model_precache[i] = Mod_ForName (model_precache[i], false);
|
||||
|
@ -319,28 +405,40 @@ void CL_ParseServerInfo (void)
|
|||
{
|
||||
Con_Printf("Model %s not found\n", model_precache[i]);
|
||||
loading_cur_step++;
|
||||
//return;
|
||||
return;
|
||||
}
|
||||
CL_KeepaliveMessage ();
|
||||
loading_cur_step++;
|
||||
strcpy(loading_name, model_precache[i]);
|
||||
//Con_Printf("%i,",i);
|
||||
SCR_UpdateScreen ();
|
||||
}
|
||||
|
||||
//Con_Printf("\n");
|
||||
//Con_Printf("Total Models loaded: %i\n",nummodels);
|
||||
SCR_UpdateScreen ();
|
||||
|
||||
// load the extra "no-flamed-torch" model
|
||||
//cl.model_precache[nummodels] = Mod_ForName ("progs/flame0.mdl", false);
|
||||
//cl_modelindex[mi_flame0] = nummodels++;
|
||||
|
||||
loading_step = 4;
|
||||
|
||||
S_BeginPrecaching ();
|
||||
//Con_Printf("Loaded Sounds: ");
|
||||
for (i=1 ; i<numsounds ; i++)
|
||||
{
|
||||
cl.sound_precache[i] = S_PrecacheSound (sound_precache[i]);
|
||||
CL_KeepaliveMessage ();
|
||||
loading_cur_step++;
|
||||
//Con_Printf("%i,",i);
|
||||
strcpy(loading_name, sound_precache[i]);
|
||||
SCR_UpdateScreen ();
|
||||
}
|
||||
S_EndPrecaching ();
|
||||
|
||||
//Con_Printf("...\n");
|
||||
//Con_Printf("Total Sounds Loaded: %i\n",numsounds);
|
||||
SCR_UpdateScreen ();
|
||||
|
||||
Clear_LoadingFill ();
|
||||
|
@ -376,13 +474,16 @@ void CL_ParseUpdate (int bits)
|
|||
qboolean forcelink;
|
||||
entity_t *ent;
|
||||
int num;
|
||||
int skin;
|
||||
//int skin;
|
||||
|
||||
if (cls.signon == SIGNONS - 1)
|
||||
{ // first update is the final signon stage
|
||||
Con_DPrintf("First Update\n");
|
||||
cls.signon = SIGNONS;
|
||||
CL_SignonReply ();
|
||||
CL_SignonReply (); //disabling this temp-mortem
|
||||
}
|
||||
//Con_Printf("2\n");
|
||||
|
||||
|
||||
if (bits & U_MOREBITS)
|
||||
{
|
||||
|
@ -409,8 +510,8 @@ void CL_ParseUpdate (int bits)
|
|||
|
||||
ent = CL_EntityNum (num);
|
||||
|
||||
for (i=0 ; i<16 ; i++)
|
||||
if (bits&(1<<i))
|
||||
for (i=0 ; i<16 ; i++)
|
||||
if (bits&(1<<i))
|
||||
bitcounts[i]++;
|
||||
|
||||
if (ent->msgtime != cl.mtime[1])
|
||||
|
@ -444,10 +545,6 @@ if (bits&(1<<i))
|
|||
}
|
||||
else
|
||||
forcelink = true; // hack to make null model players work
|
||||
#ifdef GLQUAKE
|
||||
if (num > 0 && num <= cl.maxclients)
|
||||
R_TranslatePlayerSkin (num - 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (bits & U_FRAME)
|
||||
|
@ -480,7 +577,6 @@ if (bits&(1<<i))
|
|||
// shift the known values for interpolation
|
||||
VectorCopy (ent->msg_origins[0], ent->msg_origins[1]);
|
||||
VectorCopy (ent->msg_angles[0], ent->msg_angles[1]);
|
||||
|
||||
if (bits & U_ORIGIN1)
|
||||
ent->msg_origins[0][0] = MSG_ReadCoord ();
|
||||
else
|
||||
|
@ -507,7 +603,6 @@ if (bits&(1<<i))
|
|||
ent->msg_angles[0][2] = MSG_ReadAngle();
|
||||
else
|
||||
ent->msg_angles[0][2] = ent->baseline.angles[2];
|
||||
|
||||
// Tomaz - QC Alpha Scale Glow Begin
|
||||
if (bits & U_RENDERAMT)
|
||||
ent->renderamt = MSG_ReadFloat();
|
||||
|
@ -540,7 +635,7 @@ if (bits&(1<<i))
|
|||
else
|
||||
ent->scale = ENTSCALE_DEFAULT;
|
||||
|
||||
if ( bits & U_NOLERP )
|
||||
if ( bits & U_NOLERP )//there's no data for nolerp, it is the value itself
|
||||
ent->forcelink = true;
|
||||
|
||||
if ( forcelink )
|
||||
|
@ -573,7 +668,6 @@ void CL_ParseBaseline (entity_t *ent)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_ParseClientdata
|
||||
|
@ -957,7 +1051,6 @@ void CL_ParseStaticSound (void)
|
|||
S_StaticSound (cl.sound_precache[sound_num], org, vol, atten);
|
||||
}
|
||||
|
||||
|
||||
extern double Hitmark_Time;
|
||||
extern int crosshair_spread;
|
||||
extern double crosshair_spread_time;
|
||||
|
@ -980,8 +1073,8 @@ void CL_ParseWeaponFire (void)
|
|||
cl.gun_kick[0] += kick[0];
|
||||
cl.gun_kick[1] += kick[1];
|
||||
cl.gun_kick[2] += kick[2];
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
===================
|
||||
CL_ParseLimbUpdate
|
||||
|
@ -1007,15 +1100,20 @@ void CL_ParseLimbUpdate (void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#define SHOWNET(x) if(cl_shownet.value==2)Con_Printf ("%3i:%s\n", msg_readcount-1, x);
|
||||
|
||||
/*
|
||||
=====================
|
||||
CL_ParseServerMessage
|
||||
=====================
|
||||
*/
|
||||
extern double bettyprompt_time;
|
||||
extern qboolean doubletap_has_damage_buff;
|
||||
void CL_ParseServerMessage (void)
|
||||
{
|
||||
int cmd;
|
||||
int i;
|
||||
int total, j, lastcmd; //johnfitz
|
||||
|
||||
//
|
||||
// if recording demos, copy the message out
|
||||
|
@ -1045,10 +1143,10 @@ void CL_ParseServerMessage (void)
|
|||
}
|
||||
|
||||
// if the high bit of the command byte is set, it is a fast update
|
||||
if (cmd & 128)
|
||||
if (cmd & 128)//checking if it's an entity update, if it is the 7th bit will be on, this is checking for that
|
||||
{
|
||||
SHOWNET("fast update");
|
||||
CL_ParseUpdate (cmd&127);
|
||||
CL_ParseUpdate (cmd&127);//here we strip the cmd from the value of the 7th (128) bit, to only give the rest of the commands
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1058,11 +1156,10 @@ void CL_ParseServerMessage (void)
|
|||
switch (cmd)
|
||||
{
|
||||
default:
|
||||
Host_Error ("CL_ParseServerMessage: Illegible server message: cmd = %d\n", cmd);
|
||||
Host_Error ("CL_ParseServerMessage: Illegible server message (%i)\n", cmd);
|
||||
break;
|
||||
|
||||
case svc_nop:
|
||||
// Con_Printf ("svc_nop\n");
|
||||
break;
|
||||
|
||||
case svc_time:
|
||||
|
@ -1095,7 +1192,6 @@ void CL_ParseServerMessage (void)
|
|||
case svc_useprint:
|
||||
SCR_UsePrint (MSG_ReadByte (),MSG_ReadShort (),MSG_ReadByte ());
|
||||
break;
|
||||
|
||||
case svc_maxammo:
|
||||
domaxammo = true;
|
||||
break;
|
||||
|
@ -1140,11 +1236,6 @@ void CL_ParseServerMessage (void)
|
|||
case svc_stufftext:
|
||||
Cbuf_AddText (MSG_ReadString ());
|
||||
break;
|
||||
|
||||
case svc_damage:
|
||||
V_ParseDamage ();
|
||||
break;
|
||||
|
||||
case svc_serverinfo:
|
||||
CL_ParseServerInfo ();
|
||||
vid.recalc_refdef = true; // leave intermission full screen
|
||||
|
@ -1163,23 +1254,8 @@ void CL_ParseServerMessage (void)
|
|||
i = MSG_ReadByte ();
|
||||
if (i >= MAX_LIGHTSTYLES)
|
||||
Sys_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
|
||||
q_strlcpy (cl_lightstyle[i].map, MSG_ReadString(), MAX_STYLESTRING);
|
||||
Q_strcpy (cl_lightstyle[i].map, MSG_ReadString());
|
||||
cl_lightstyle[i].length = Q_strlen(cl_lightstyle[i].map);
|
||||
//johnfitz -- save extra info
|
||||
if (cl_lightstyle[i].length)
|
||||
{
|
||||
total = 0;
|
||||
cl_lightstyle[i].peak = 'a';
|
||||
for (j=0; j<cl_lightstyle[i].length; j++)
|
||||
{
|
||||
total += cl_lightstyle[i].map[j] - 'a';
|
||||
cl_lightstyle[i].peak = fmax(cl_lightstyle[i].peak, cl_lightstyle[i].map[j]);
|
||||
}
|
||||
cl_lightstyle[i].average = total / cl_lightstyle[i].length + 'a';
|
||||
}
|
||||
else
|
||||
cl_lightstyle[i].average = cl_lightstyle[i].peak = 'm';
|
||||
//johnfitz
|
||||
break;
|
||||
|
||||
case svc_sound:
|
||||
|
@ -1192,13 +1268,27 @@ void CL_ParseServerMessage (void)
|
|||
break;
|
||||
|
||||
case svc_updatename:
|
||||
Sbar_Changed ();
|
||||
i = MSG_ReadByte ();
|
||||
if (i >= cl.maxclients)
|
||||
Host_Error ("CL_ParseServerMessage: svc_updatename > MAX_SCOREBOARD");
|
||||
strcpy (cl.scores[i].name, MSG_ReadString ());
|
||||
break;
|
||||
|
||||
case svc_updatepoints:
|
||||
i = MSG_ReadByte ();
|
||||
if (i >= cl.maxclients)
|
||||
Host_Error ("CL_ParseServerMessage: svc_updatepoints > MAX_SCOREBOARD");
|
||||
cl.scores[i].points = MSG_ReadLong ();
|
||||
break;
|
||||
|
||||
case svc_updatekills:
|
||||
i = MSG_ReadByte ();
|
||||
if (i >= cl.maxclients)
|
||||
Host_Error ("CL_ParseServerMessage: svc_updatepoints > MAX_SCOREBOARD");
|
||||
cl.scores[i].kills = MSG_ReadShort ();
|
||||
break;
|
||||
|
||||
|
||||
case svc_particle:
|
||||
R_ParseParticleEffect ();
|
||||
break;
|
||||
|
@ -1222,16 +1312,10 @@ void CL_ParseServerMessage (void)
|
|||
if (cl.paused)
|
||||
{
|
||||
CDAudio_Pause ();
|
||||
#ifdef _WIN32
|
||||
VID_HandlePause (true);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
CDAudio_Resume ();
|
||||
#ifdef _WIN32
|
||||
VID_HandlePause (false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1241,6 +1325,7 @@ void CL_ParseServerMessage (void)
|
|||
if (i <= cls.signon)
|
||||
Host_Error ("Received signon %i when at %i", i, cls.signon);
|
||||
cls.signon = i;
|
||||
Con_DPrintf("Signon: %i \n",i);
|
||||
CL_SignonReply ();
|
||||
break;
|
||||
|
||||
|
@ -1248,7 +1333,7 @@ void CL_ParseServerMessage (void)
|
|||
i = MSG_ReadByte ();
|
||||
if (i < 0 || i >= MAX_CL_STATS)
|
||||
Sys_Error ("svc_updatestat: %i is invalid", i);
|
||||
cl.stats[i] = MSG_ReadLong ();;
|
||||
cl.stats[i] = MSG_ReadLong ();
|
||||
break;
|
||||
|
||||
case svc_spawnstaticsound:
|
||||
|
@ -1258,10 +1343,6 @@ void CL_ParseServerMessage (void)
|
|||
case svc_cdtrack:
|
||||
cl.cdtrack = MSG_ReadByte ();
|
||||
cl.looptrack = MSG_ReadByte ();
|
||||
if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
|
||||
CDAudio_Play ((byte)cls.forcetrack, true);
|
||||
else
|
||||
CDAudio_Play ((byte)cl.cdtrack, true);
|
||||
break;
|
||||
|
||||
case svc_intermission:
|
||||
|
@ -1288,6 +1369,13 @@ void CL_ParseServerMessage (void)
|
|||
Cmd_ExecuteString ("help", src_command);
|
||||
break;
|
||||
|
||||
case svc_skybox:
|
||||
Sky_LoadSkyBox(MSG_ReadString());
|
||||
break;
|
||||
case svc_fog:
|
||||
Fog_ParseServerMessage ();
|
||||
break;
|
||||
|
||||
case svc_achievement:
|
||||
HUD_Parse_Achievement (MSG_ReadByte());
|
||||
break;
|
||||
|
@ -1304,19 +1392,8 @@ void CL_ParseServerMessage (void)
|
|||
CL_ParseLimbUpdate();
|
||||
break;
|
||||
|
||||
case svc_updatepoints:
|
||||
i = MSG_ReadByte ();
|
||||
if (i >= cl.maxclients)
|
||||
Host_Error ("CL_ParseServerMessage: svc_updatepoints > MAX_SCOREBOARD");
|
||||
cl.scores[i].points = MSG_ReadLong ();
|
||||
|
||||
break;
|
||||
|
||||
case svc_updatekills:
|
||||
i = MSG_ReadByte ();
|
||||
if (i >= cl.maxclients)
|
||||
Host_Error ("CL_ParseServerMessage: svc_updatekills > MAX_SCOREBOARD");
|
||||
cl.scores[i].kills = MSG_ReadShort ();
|
||||
case svc_bspdecal:
|
||||
CL_ParseBSPDecal ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue