Added pSeatLocal, which is like pSeat but games no longer break if upstream

Nuclide expects new fields. You might have to migrate some fields over.
This commit is contained in:
Marco Cawthorne 2021-03-31 13:40:27 +02:00
parent 6f49e81d56
commit e5ba0406fd
6 changed files with 99 additions and 213 deletions

View File

@ -20,40 +20,6 @@ vector g_hudres;
struct
{
/* viewmodel stuff */
entity m_eViewModel;
entity m_eMuzzleflash;
int m_iVMBones;
void(void) m_pEventCall;
float m_flEventTime;
float m_flEventFrame;
int m_iLastWeapon;
int m_iOldWeapon;
float m_flBobTime;
float m_flBob;
/* damage overlay */
float m_flDamageAlpha;
vector m_vecDamagePos;
/* +zoomin cmd */
int m_iZoomed;
float m_flZoomTime;
/* player fields */
entity m_ePlayer;
vector m_vecPredictedOrigin;
vector m_vecPredictedOriginOld;
vector m_vecPredictedVelocity;
float m_flPredictedFlags;
/* camera fields */
vector m_vecCameraOrigin;
vector m_vecCameraAngle;
float m_flCameraTime;
/* hud.c */
int m_iHealthOld;
float m_flHealthAlpha;
@ -67,46 +33,4 @@ struct
float m_flAmmo3Alpha;
int m_iPickupWeapon;
float m_flPickupAlpha;
int m_iScoresVisible;
int m_iHUDWeaponSelected;
float m_flHUDWeaponSelectTime;
/* saturn controller */
int m_iSaturnMenu;
/* centerprint related */
float m_flCenterprintAlpha;
float m_flCenterprintTime;
float m_iCenterprintLines;
string m_strCenterprintBuffer[18];
/* chat related */
float m_flPrintTime;
string m_strPrintBuffer[5];
int m_iPrintLines;
int m_iInputAttack2;
int m_iInputReload;
int m_iInputUse;
int m_iInputDuck;
float m_flInputBlockTime;
/* fading */
float m_flFadeDuration;
float m_flFadeHold;
float m_flFadeMaxAlpha;
float m_flFadeStyle;
float m_flFadeAlpha;
float m_flFadeTime;
vector m_vecFadeColor;
int m_iFadeActive;
/* shake */
float m_flShakeFreq;
float m_flShakeDuration;
float m_flShakeTime;
float m_flShakeAmp;
entity m_pWeaponFX;
} g_seats[4], *pSeat;
} g_seatslocal[4], *pSeatLocal;

View File

@ -42,108 +42,3 @@ Player_PreDraw(base_player pl, int thirdperson)
}
}
}
void
Player_ReceiveEntity(float new)
{
float fl;
player pl = (player)self;
if (new == TRUE) {
spawnfunc_player();
pl.classname = "player";
pl.solid = SOLID_SLIDEBOX;
pl.drawmask = MASK_ENGINE;
pl.customphysics = Empty;
setsize(pl, VEC_HULL_MIN, VEC_HULL_MAX);
} else {
/* Go through all the physics code between the last received frame
* and the newest frame and keep the changes this time around instead
* of rolling back, because we'll apply the new server-verified values
* right after anyway. */
/* FIXME: splitscreen */
if (pl.entnum == player_localentnum) {
/* FIXME: splitscreen */
pSeat = &g_seats[0];
for (int i = pl.sequence+1; i <= servercommandframe; i++) {
/* ...maybe the input state is too old? */
if (!getinputstate(i)) {
break;
}
input_sequence = i;
PMove_Run();
}
/* any differences in things that are read below are now
* officially from prediction misses. */
}
}
/* seed for our prediction table */
pl.sequence = servercommandframe;
fl = readfloat();
/* HACK: we need to make this more reliable */
if (fl == UPDATE_ALL) {
/* we respawned */
pl.gravity = __NULL__;
}
if (fl & PLAYER_MODELINDEX)
pl.modelindex = readshort();
if (fl & PLAYER_ORIGIN) {
pl.origin[0] = readcoord();
pl.origin[1] = readcoord();
}
if (fl & PLAYER_ORIGIN_Z)
pl.origin[2] = readcoord();
if (fl & PLAYER_ANGLES_X)
pl.pitch = readfloat();
if (fl & PLAYER_ANGLES_Y)
pl.angles[1] = readfloat();
if (fl & PLAYER_ANGLES_Z)
pl.angles[2] = readfloat();
if (fl & PLAYER_VELOCITY) {
pl.velocity[0] = readcoord();
pl.velocity[1] = readcoord();
}
if (fl & PLAYER_VELOCITY_Z)
pl.velocity[2] = readcoord();
if (fl & PLAYER_FLAGS) {
pl.flags = readfloat();
pl.gflags = readfloat();
}
if (fl & PLAYER_WEAPON)
pl.activeweapon = readbyte();
if (fl & PLAYER_ITEMS)
pl.g_items = (__variant)readfloat();
if (fl & PLAYER_HEALTH)
pl.health = readbyte();
if (fl & PLAYER_ARMOR)
pl.armor = readbyte();
if (fl & PLAYER_MOVETYPE)
pl.movetype = readbyte();
if (fl & PLAYER_VIEWOFS)
pl.view_ofs[2] = readfloat();
if (fl & PLAYER_BASEFRAME)
pl.baseframe = readbyte();
if (fl & PLAYER_FRAME) {
pl.frame = readbyte();
pl.frame1time = 0.0f;
pl.frame2time = 0.0f;
}
if (fl & PLAYER_AMMO1)
pl.a_ammo1 = readbyte();
if (fl & PLAYER_AMMO2)
pl.a_ammo2 = readbyte();
if (fl & PLAYER_AMMO3)
pl.a_ammo3 = readbyte();
setorigin(pl, pl.origin);
}

View File

@ -76,29 +76,6 @@ void
player::ReceiveEntity(float new)
{
float fl;
if (new == FALSE) {
/* Go through all the physics code between the last received frame
* and the newest frame and keep the changes this time around instead
* of rolling back, because we'll apply the new server-verified values
* right after anyway. */
/* FIXME: splitscreen */
if (entnum == player_localentnum) {
/* FIXME: splitscreen */
pSeat = &g_seats[0];
for (int i = sequence+1; i <= servercommandframe; i++) {
/* ...maybe the input state is too old? */
if (!getinputstate(i)) {
break;
}
input_sequence = i;
PMove_Run();
}
/* any differences in things that are read below are now
* officially from prediction misses. */
}
}
/* seed for our prediction table */
sequence = servercommandframe;

View File

@ -61,9 +61,6 @@ var int MUZZLE_SMALL;
var int MUZZLE_RIFLE;
var int MUZZLE_WEIRD;
var int SHELL_DEFAULT;
var int SHELL_SHOTGUN;
/* misc globals */
vector video_mins;
vector video_res;
@ -121,3 +118,83 @@ void drawrect(vector pos, vector sz, float thickness, vector rgb, float al, opti
/* right */
drawfill(pos + [sz[0] - thickness, thickness], [thickness, sz[1] - (thickness * 2)], rgb, al, dfl);
}
struct
{
/* viewmodel stuff */
entity m_eViewModel;
entity m_eMuzzleflash;
int m_iVMBones;
void(void) m_pEventCall;
float m_flEventTime;
float m_flEventFrame;
int m_iLastWeapon;
int m_iOldWeapon;
float m_flBobTime;
float m_flBob;
/* damage overlay */
float m_flDamageAlpha;
vector m_vecDamagePos;
/* +zoomin cmd */
int m_iZoomed;
float m_flZoomTime;
/* player fields */
entity m_ePlayer;
vector m_vecPredictedOrigin;
vector m_vecPredictedOriginOld;
vector m_vecPredictedVelocity;
float m_flPredictedFlags;
/* camera fields */
vector m_vecCameraOrigin;
vector m_vecCameraAngle;
float m_flCameraTime;
int m_iHUDWeaponSelected;
float m_flHUDWeaponSelectTime;
int m_iScoresVisible;
/* saturn controller */
int m_iSaturnMenu;
/* centerprint related */
float m_flCenterprintAlpha;
float m_flCenterprintTime;
float m_iCenterprintLines;
string m_strCenterprintBuffer[18];
/* chat related */
float m_flPrintTime;
string m_strPrintBuffer[5];
int m_iPrintLines;
int m_iInputAttack2;
int m_iInputReload;
int m_iInputUse;
int m_iInputDuck;
float m_flInputBlockTime;
/* fading */
float m_flFadeDuration;
float m_flFadeHold;
float m_flFadeMaxAlpha;
float m_flFadeStyle;
float m_flFadeAlpha;
float m_flFadeTime;
vector m_vecFadeColor;
int m_iFadeActive;
/* shake */
float m_flShakeFreq;
float m_flShakeDuration;
float m_flShakeTime;
float m_flShakeAmp;
entity m_pWeaponFX;
} g_seats[4], *pSeat;

View File

@ -22,6 +22,7 @@ CSQC_Init(float apilevel, string enginename, float engineversion)
{
Sound_Init();
pSeat = &g_seats[0];
pSeatLocal = &g_seatslocal[0];
registercommand("getpos");
registercommand("callvote");
@ -193,11 +194,13 @@ CSQC_UpdateView(float w, float h, float focus)
for (s = g_seats.length; s-- > numclientseats;) {
pSeat = &g_seats[s];
pSeatLocal = &g_seatslocal[s];
pSeat->m_ePlayer = world;
}
for (s = numclientseats; s-- > 0;) {
pSeat = &g_seats[s];
pSeatLocal = &g_seatslocal[s];
View_CalcViewport(s, w, h);
setproperty(VF_ACTIVESEAT, (float)s);
@ -277,6 +280,7 @@ CSQC_UpdateView(float w, float h, float focus)
setproperty(VF_ANGLES, view_angles);
} else {
if (self.classname == "player") {
pl = (player)self;
if (pl.health) {
if (autocvar_cl_thirdperson == TRUE) {
makevectors(view_angles);
@ -301,6 +305,7 @@ CSQC_UpdateView(float w, float h, float focus)
}
setproperty(VF_ANGLES, view_angles + pl.punchangle);
} else if (self.classname == "spectator") {
spec = (spectator)self;
switch (spec.spec_mode) {
case SPECMODE_THIRDPERSON:
makevectors(view_angles);
@ -315,11 +320,11 @@ CSQC_UpdateView(float w, float h, float focus)
setproperty(VF_ORIGIN, trace_endpos + (v_forward * 5));
break;
case SPECMODE_FIRSTPERSON:
entity b;
b = findfloat(world, ::entnum, spec.spec_ent);
entity c;
c = findfloat(world, ::entnum, spec.spec_ent);
if (b.classname == "player") {
player bp = (player)b;
if (c.classname == "player") {
player bp = (player)c;
setproperty(VF_ORIGIN, pSeat->m_vecPredictedOrigin + bp.view_ofs);
setproperty(VF_ANGLES, bp.v_angle);
setproperty(VF_CL_VIEWANGLES, [bp.pitch, bp.angles[1], bp.angles[2]]);
@ -401,6 +406,7 @@ CSQC_UpdateView(float w, float h, float focus)
DSP_UpdateListener();
pSeat = (void*)0x70000000i;
pSeatLocal = (void*)0x70000000i;
Vox_Update();
}
@ -417,6 +423,7 @@ CSQC_InputEvent(float fEventType, float fKey, float fCharacter, float fDeviceID)
{
int s = (float)getproperty(VF_ACTIVESEAT);
pSeat = &g_seats[s];
pSeatLocal = &g_seatslocal[s];
switch (fEventType) {
case IE_KEYDOWN:
@ -470,6 +477,7 @@ CSQC_Input_Frame(void)
{
int s = (float)getproperty(VF_ACTIVESEAT);
pSeat = &g_seats[s];
pSeatLocal = &g_seatslocal[s];
/* If we are inside a VGUI, don't let the client do stuff outside */
if (g_vguiWidgetCount > 0) {
@ -538,6 +546,7 @@ CSQC_Parse_Event(void)
/* always 0, unless it was sent with a MULTICAST_ONE or MULTICAST_ONE_R to p2+ */
int s = (float)getproperty(VF_ACTIVESEAT);
pSeat = &g_seats[s];
pSeatLocal = &g_seatslocal[s];
float fHeader = readbyte();
@ -648,6 +657,7 @@ CSQC_ConsoleCommand(string sCMD)
/* the engine will hide the p1 etc commands... which is fun... */
int s = (float)getproperty(VF_ACTIVESEAT);
pSeat = &g_seats[s];
pSeatLocal = &g_seatslocal[s];
tokenize(sCMD);
@ -804,6 +814,7 @@ CSQC_Parse_Print(string sMessage, float fLevel)
{
int s = (float)getproperty(VF_ACTIVESEAT);
pSeat = &g_seats[s];
pSeatLocal = &g_seatslocal[s];
/* This gives messages other than chat an orange tint */
if (fLevel == PRINT_CHAT) {
@ -842,6 +853,7 @@ CSQC_Parse_CenterPrint(string sMessage)
{
int s = (float)getproperty(VF_ACTIVESEAT);
pSeat = &g_seats[s];
pSeatLocal = &g_seatslocal[s];
pSeat->m_iCenterprintLines = tokenizebyseparator(sMessage, "\n");
@ -882,6 +894,7 @@ CSQC_Ent_Update(float new)
/* splitscreen */
int s = (float)getproperty(VF_ACTIVESEAT);
pSeat = &g_seats[s];
pSeatLocal = &g_seatslocal[s];
if (new || self.classname != "player") {
spawnfunc_player();

View File

@ -64,7 +64,7 @@ Predict_PlayerPreFrame(player pl)
input_sequence = i;
/* run our custom physics */
PMove_Run(FALSE);
PMove_Run();
}
}