Client: Fix network error when receiving shake event as spectator.

This commit is contained in:
Marco Cawthorne 2022-12-21 13:46:55 -08:00
parent 2d911109cc
commit 30bbede463
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
7 changed files with 142 additions and 84 deletions

View File

@ -27,7 +27,7 @@ font_s g_fntChat;
string g_chatbuffer_final;
void
Chat_Init(void)
Chat_Reload(void)
{
Font_Load("fonts/chat.font", g_fntChat);
}

View File

@ -63,7 +63,7 @@ DetailTex_Parse(string maptex, string detailtex, float xscale, float yscale)
}
void
DetailTex_Init(void)
DetailTex_Reload(void)
{
filestream fh;
string line;

View File

@ -114,7 +114,7 @@ CSQC_RendererRestarted(string rstr)
precache_pic("gfx/vgui/icntlk_pl");
/* View */
Chat_Init();
Chat_Reload();
#ifndef NEW_INVENTORY
Weapons_Init();
@ -126,11 +126,11 @@ CSQC_RendererRestarted(string rstr)
HUD_Init();
/* GS-Entbase */
Fade_Init();
Fade_Reload();
Decal_Reload();
Sky_Update(TRUE);
Entities_RendererRestarted();
DetailTex_Init();
DetailTex_Reload();
//g_shellchrome = spriteframe("sprites/shellchrome.spr", 0, 0.0f);
g_shellchromeshader = shaderforname("shellchrome", sprintf("{\ndeformVertexes bulge 1.25 1.25 0\n{\nmap %s\ntcMod scroll -0.1 0.1\ntcGen environment\nrgbGen entity\n}\n}", "textures/sfx/reflection.tga"));

View File

@ -15,46 +15,132 @@
*/
void
Event_Parse(float type)
EV_Damage(void)
{
vector vecDmgPos;
int iDmgTake;
int iDmgFlags;
vecDmgPos[0] = readcoord();
vecDmgPos[1] = readcoord();
vecDmgPos[2] = readcoord();
iDmgTake = readint();
iDmgFlags = readint();
CSQC_Parse_Damage_New(vecDmgPos, iDmgTake, iDmgFlags);
}
void
EV_Intermission(void)
{
int cam;
vector pos, ang;
cam = (int)readbyte();
if (cam) {
ang[0] = readfloat();
ang[1] = readfloat();
ang[2] = readfloat();
pos[0] = readcoord();
pos[1] = readcoord();
pos[2] = readcoord();
} else {
pos = getproperty(VF_ORIGIN);
ang = getproperty(VF_ANGLES);
}
pSeat->m_vecCameraOrigin = pos;
pSeat->m_vecCameraAngle = ang;
g_iIntermission = TRUE;
}
void
EV_Speak(void)
{
string msg;
float pit;
entity t = findfloat(world, entnum, readentitynum());
msg = readstring();
pit = readfloat();
sound(t, CHAN_VOICE, msg, 1.0, ATTN_NORM, pit);
}
void
EV_HUDHint(void)
{
string hint;
hint = readstring();
/* TODO: Handle the event properly */
Chat_Parse(sprintf("Hint: %s", hint));
}
void
EV_CameraTrigger(void)
{
vector cam_newpos;
cam_newpos[0] = readcoord();
cam_newpos[1] = readcoord();
cam_newpos[2] = readcoord();
pSeat->m_vecCameraAngle[0] = readcoord();
pSeat->m_vecCameraAngle[1] = readcoord();
pSeat->m_vecCameraAngle[2] = readcoord();
pSeat->m_flCameraTime = time + readfloat();
/* if the same camera as last-time (hack) is still active,
then make sure it becomes inactive... */
if (pSeat->m_vecCameraOrigin == cam_newpos) {
pSeat->m_flCameraTime = 0.0f;
} else {
pSeat->m_vecCameraOrigin = cam_newpos;
}
}
void
EV_Angle(void)
{
vector a;
a[0] = readfloat();
a[1] = readfloat();
a[2] = readfloat();
g_view.SetCameraAngle(a);
g_view.SetClientAngle(a);
}
void
EV_Shake(void)
{
entity me = pSeat->m_ePlayer;
float duration;
float amplitude;
float frequency;
duration = readfloat();
amplitude = readfloat();
frequency = readfloat();
if (me.classname == "spectator")
return;
pSeat->m_flShakeDuration = duration;
pSeat->m_flShakeAmp = amplitude;
pSeat->m_flShakeFreq = frequency;
pSeat->m_flShakeTime = pSeat->m_flShakeDuration;
}
void
Event_Parse(float type)
{
switch (type) {
case EV_DAMAGE:
vector vecDmgPos;
int iDmgTake;
int iDmgFlags;
vecDmgPos[0] = readcoord();
vecDmgPos[1] = readcoord();
vecDmgPos[2] = readcoord();
iDmgTake = readint();
iDmgFlags = readint();
CSQC_Parse_Damage_New(vecDmgPos, iDmgTake, iDmgFlags);
EV_Damage();
break;
case EV_HITNOTIFY:
break;
case EV_INTERMISSION:
int cam;
vector pos, ang;
cam = (int)readbyte();
if (cam) {
ang[0] = readfloat();
ang[1] = readfloat();
ang[2] = readfloat();
pos[0] = readcoord();
pos[1] = readcoord();
pos[2] = readcoord();
} else {
pos = getproperty(VF_ORIGIN);
ang = getproperty(VF_ANGLES);
}
pSeat->m_vecCameraOrigin = pos;
pSeat->m_vecCameraAngle = ang;
g_iIntermission = TRUE;
EV_Intermission();
break;
case EV_MUSICTRACK:
Music_ParseTrack();
@ -63,21 +149,13 @@ Event_Parse(float type)
Music_ParseLoop();
break;
case EV_SPEAK:
string msg;
float pit;
entity t = findfloat(world, entnum, readentitynum());
msg = readstring();
pit = readfloat();
sound(t, CHAN_VOICE, msg, 1.0, ATTN_NORM, pit);
EV_Speak();
break;
case EV_SENTENCE:
NSTalkMonster_ParseSentence();
break;
case EV_HUDHINT:
string hint;
hint = readstring();
/* TODO: Handle the event properly */
Chat_Parse(sprintf("Hint: %s", hint));
EV_HUDHint();
break;
case EV_FADE:
Fade_Parse();
@ -92,33 +170,10 @@ Event_Parse(float type)
GameMessage_Parse();
break;
case EV_CAMERATRIGGER:
vector cam_newpos;
cam_newpos[0] = readcoord();
cam_newpos[1] = readcoord();
cam_newpos[2] = readcoord();
pSeat->m_vecCameraAngle[0] = readcoord();
pSeat->m_vecCameraAngle[1] = readcoord();
pSeat->m_vecCameraAngle[2] = readcoord();
pSeat->m_flCameraTime = time + readfloat();
/* if the same camera as last-time (hack) is still active,
then make sure it becomes inactive... */
if (pSeat->m_vecCameraOrigin == cam_newpos) {
pSeat->m_flCameraTime = 0.0f;
} else {
pSeat->m_vecCameraOrigin = cam_newpos;
}
EV_CameraTrigger();
break;
case EV_ANGLE:
vector a;
a[0] = readfloat();
a[1] = readfloat();
a[2] = readfloat();
g_view.SetCameraAngle(a);
g_view.SetClientAngle(a);
EV_Angle();
break;
case EV_SURFIMPACT:
SurfData_Impact_Parse();
@ -130,12 +185,7 @@ Event_Parse(float type)
CMD_Cleardecals();
break;
case EV_SHAKE:
if (me.classname == "spectator")
break;
pSeat->m_flShakeDuration = readfloat();
pSeat->m_flShakeAmp = readfloat();
pSeat->m_flShakeFreq = readfloat();
pSeat->m_flShakeTime = pSeat->m_flShakeDuration;
EV_Shake();
break;
case EV_BREAKMODEL:
BreakModel_Receive();

View File

@ -14,7 +14,11 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void Fade_Init(void);
void Fade_Update (int x, int y, int w, int h);
/** Called upon every vid_reload to cache the material definitions required for fade effects. */
void Fade_Reload(void);
/** Called every frame to update the actively running fade effects. */
void Fade_Update(int x, int y, int w, int h);
/** Called by the worldspawn key "startdark" to gradually fade in the game view upon map start. */
void Fade_StartDark(void);
/** Called whenever the client receives a EV_FADE from the server. */
void Fade_Parse(void);

View File

@ -39,12 +39,14 @@ const string mat_fade_modulate =
"}\n" \
"}\n";
/* needs to be called on every vid_reload */
void
Fade_Init(void)
Fade_Reload(void)
{
shaderforname("fade_modulate", mat_fade_modulate);
}
/* run every frame to update the actively running fade effects */
void
Fade_Update (int x, int y, int w, int h)
{
@ -85,6 +87,8 @@ Fade_Update (int x, int y, int w, int h)
pSeat->m_flFadeTime += clframetime;
}
/* called by a worldspawn key,
will cause the game to fade-in over the course of 4 seconds */
void
Fade_StartDark(void)
{

View File

@ -26,6 +26,7 @@ Propagate our pmove state to whatever the current frame before its stomped on
void
Predict_EntityUpdate(player pl, float new)
{
/* people expect a static camera when paused */
if (Util_IsPaused())
return;
@ -33,10 +34,10 @@ Predict_EntityUpdate(player pl, float new)
if (new || self.classname != "player") {
spawnfunc_player();
pl.classname = "player";
/* is this **us** ? */
if (pl.entnum == player_localentnum) {
//pl.solid = SOLID_SLIDEBOX;
//pl.movetype = MOVETYPE_NONE;
/* this will prevent the client-game from running its own physics between updates */
pl.customphysics = Empty;
} else {
/* other players will act like missiles for interpolation purposes */
@ -62,5 +63,4 @@ Predict_EntityUpdate(player pl, float new)
pl.Physics_Run();
}
}
}