Client: Fix network error when receiving shake event as spectator.
This commit is contained in:
parent
2d911109cc
commit
30bbede463
7 changed files with 142 additions and 84 deletions
|
@ -27,7 +27,7 @@ font_s g_fntChat;
|
||||||
string g_chatbuffer_final;
|
string g_chatbuffer_final;
|
||||||
|
|
||||||
void
|
void
|
||||||
Chat_Init(void)
|
Chat_Reload(void)
|
||||||
{
|
{
|
||||||
Font_Load("fonts/chat.font", g_fntChat);
|
Font_Load("fonts/chat.font", g_fntChat);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ DetailTex_Parse(string maptex, string detailtex, float xscale, float yscale)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
DetailTex_Init(void)
|
DetailTex_Reload(void)
|
||||||
{
|
{
|
||||||
filestream fh;
|
filestream fh;
|
||||||
string line;
|
string line;
|
||||||
|
|
|
@ -114,7 +114,7 @@ CSQC_RendererRestarted(string rstr)
|
||||||
precache_pic("gfx/vgui/icntlk_pl");
|
precache_pic("gfx/vgui/icntlk_pl");
|
||||||
|
|
||||||
/* View */
|
/* View */
|
||||||
Chat_Init();
|
Chat_Reload();
|
||||||
|
|
||||||
#ifndef NEW_INVENTORY
|
#ifndef NEW_INVENTORY
|
||||||
Weapons_Init();
|
Weapons_Init();
|
||||||
|
@ -126,11 +126,11 @@ CSQC_RendererRestarted(string rstr)
|
||||||
HUD_Init();
|
HUD_Init();
|
||||||
|
|
||||||
/* GS-Entbase */
|
/* GS-Entbase */
|
||||||
Fade_Init();
|
Fade_Reload();
|
||||||
Decal_Reload();
|
Decal_Reload();
|
||||||
Sky_Update(TRUE);
|
Sky_Update(TRUE);
|
||||||
Entities_RendererRestarted();
|
Entities_RendererRestarted();
|
||||||
DetailTex_Init();
|
DetailTex_Reload();
|
||||||
|
|
||||||
//g_shellchrome = spriteframe("sprites/shellchrome.spr", 0, 0.0f);
|
//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"));
|
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"));
|
||||||
|
|
|
@ -15,46 +15,132 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
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;
|
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) {
|
switch (type) {
|
||||||
case EV_DAMAGE:
|
case EV_DAMAGE:
|
||||||
vector vecDmgPos;
|
EV_Damage();
|
||||||
int iDmgTake;
|
|
||||||
int iDmgFlags;
|
|
||||||
vecDmgPos[0] = readcoord();
|
|
||||||
vecDmgPos[1] = readcoord();
|
|
||||||
vecDmgPos[2] = readcoord();
|
|
||||||
iDmgTake = readint();
|
|
||||||
iDmgFlags = readint();
|
|
||||||
CSQC_Parse_Damage_New(vecDmgPos, iDmgTake, iDmgFlags);
|
|
||||||
break;
|
break;
|
||||||
case EV_HITNOTIFY:
|
case EV_HITNOTIFY:
|
||||||
break;
|
break;
|
||||||
case EV_INTERMISSION:
|
case EV_INTERMISSION:
|
||||||
int cam;
|
EV_Intermission();
|
||||||
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;
|
|
||||||
break;
|
break;
|
||||||
case EV_MUSICTRACK:
|
case EV_MUSICTRACK:
|
||||||
Music_ParseTrack();
|
Music_ParseTrack();
|
||||||
|
@ -63,21 +149,13 @@ Event_Parse(float type)
|
||||||
Music_ParseLoop();
|
Music_ParseLoop();
|
||||||
break;
|
break;
|
||||||
case EV_SPEAK:
|
case EV_SPEAK:
|
||||||
string msg;
|
EV_Speak();
|
||||||
float pit;
|
|
||||||
entity t = findfloat(world, entnum, readentitynum());
|
|
||||||
msg = readstring();
|
|
||||||
pit = readfloat();
|
|
||||||
sound(t, CHAN_VOICE, msg, 1.0, ATTN_NORM, pit);
|
|
||||||
break;
|
break;
|
||||||
case EV_SENTENCE:
|
case EV_SENTENCE:
|
||||||
NSTalkMonster_ParseSentence();
|
NSTalkMonster_ParseSentence();
|
||||||
break;
|
break;
|
||||||
case EV_HUDHINT:
|
case EV_HUDHINT:
|
||||||
string hint;
|
EV_HUDHint();
|
||||||
hint = readstring();
|
|
||||||
/* TODO: Handle the event properly */
|
|
||||||
Chat_Parse(sprintf("Hint: %s", hint));
|
|
||||||
break;
|
break;
|
||||||
case EV_FADE:
|
case EV_FADE:
|
||||||
Fade_Parse();
|
Fade_Parse();
|
||||||
|
@ -92,33 +170,10 @@ Event_Parse(float type)
|
||||||
GameMessage_Parse();
|
GameMessage_Parse();
|
||||||
break;
|
break;
|
||||||
case EV_CAMERATRIGGER:
|
case EV_CAMERATRIGGER:
|
||||||
vector cam_newpos;
|
EV_CameraTrigger();
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case EV_ANGLE:
|
case EV_ANGLE:
|
||||||
vector a;
|
EV_Angle();
|
||||||
a[0] = readfloat();
|
|
||||||
a[1] = readfloat();
|
|
||||||
a[2] = readfloat();
|
|
||||||
g_view.SetCameraAngle(a);
|
|
||||||
g_view.SetClientAngle(a);
|
|
||||||
break;
|
break;
|
||||||
case EV_SURFIMPACT:
|
case EV_SURFIMPACT:
|
||||||
SurfData_Impact_Parse();
|
SurfData_Impact_Parse();
|
||||||
|
@ -130,12 +185,7 @@ Event_Parse(float type)
|
||||||
CMD_Cleardecals();
|
CMD_Cleardecals();
|
||||||
break;
|
break;
|
||||||
case EV_SHAKE:
|
case EV_SHAKE:
|
||||||
if (me.classname == "spectator")
|
EV_Shake();
|
||||||
break;
|
|
||||||
pSeat->m_flShakeDuration = readfloat();
|
|
||||||
pSeat->m_flShakeAmp = readfloat();
|
|
||||||
pSeat->m_flShakeFreq = readfloat();
|
|
||||||
pSeat->m_flShakeTime = pSeat->m_flShakeDuration;
|
|
||||||
break;
|
break;
|
||||||
case EV_BREAKMODEL:
|
case EV_BREAKMODEL:
|
||||||
BreakModel_Receive();
|
BreakModel_Receive();
|
||||||
|
|
|
@ -14,7 +14,11 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Fade_Init(void);
|
/** Called upon every vid_reload to cache the material definitions required for fade effects. */
|
||||||
void Fade_Update (int x, int y, int w, int h);
|
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);
|
void Fade_StartDark(void);
|
||||||
|
/** Called whenever the client receives a EV_FADE from the server. */
|
||||||
void Fade_Parse(void);
|
void Fade_Parse(void);
|
||||||
|
|
|
@ -39,12 +39,14 @@ const string mat_fade_modulate =
|
||||||
"}\n" \
|
"}\n" \
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
|
/* needs to be called on every vid_reload */
|
||||||
void
|
void
|
||||||
Fade_Init(void)
|
Fade_Reload(void)
|
||||||
{
|
{
|
||||||
shaderforname("fade_modulate", mat_fade_modulate);
|
shaderforname("fade_modulate", mat_fade_modulate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* run every frame to update the actively running fade effects */
|
||||||
void
|
void
|
||||||
Fade_Update (int x, int y, int w, int h)
|
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;
|
pSeat->m_flFadeTime += clframetime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* called by a worldspawn key,
|
||||||
|
will cause the game to fade-in over the course of 4 seconds */
|
||||||
void
|
void
|
||||||
Fade_StartDark(void)
|
Fade_StartDark(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,7 @@ Propagate our pmove state to whatever the current frame before its stomped on
|
||||||
void
|
void
|
||||||
Predict_EntityUpdate(player pl, float new)
|
Predict_EntityUpdate(player pl, float new)
|
||||||
{
|
{
|
||||||
|
/* people expect a static camera when paused */
|
||||||
if (Util_IsPaused())
|
if (Util_IsPaused())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -33,10 +34,10 @@ Predict_EntityUpdate(player pl, float new)
|
||||||
if (new || self.classname != "player") {
|
if (new || self.classname != "player") {
|
||||||
spawnfunc_player();
|
spawnfunc_player();
|
||||||
pl.classname = "player";
|
pl.classname = "player";
|
||||||
|
|
||||||
|
/* is this **us** ? */
|
||||||
if (pl.entnum == player_localentnum) {
|
if (pl.entnum == player_localentnum) {
|
||||||
//pl.solid = SOLID_SLIDEBOX;
|
/* this will prevent the client-game from running its own physics between updates */
|
||||||
//pl.movetype = MOVETYPE_NONE;
|
|
||||||
pl.customphysics = Empty;
|
pl.customphysics = Empty;
|
||||||
} else {
|
} else {
|
||||||
/* other players will act like missiles for interpolation purposes */
|
/* other players will act like missiles for interpolation purposes */
|
||||||
|
@ -62,5 +63,4 @@ Predict_EntityUpdate(player pl, float new)
|
||||||
pl.Physics_Run();
|
pl.Physics_Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue