From ea3ca4a4ead56f0bad3a06bd21275d9aaa88ae41 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Thu, 8 Sep 2022 20:47:21 +1000 Subject: [PATCH] - Duke: Tidy up old multiplayer variables to modern standards. --- source/games/duke/src/animatesprites_d.cpp | 4 +- source/games/duke/src/animatesprites_r.cpp | 4 +- source/games/duke/src/game_misc.cpp | 2 +- source/games/duke/src/prediction.cpp | 57 +++++++++++----------- source/games/duke/src/prediction.h | 3 +- 5 files changed, 33 insertions(+), 37 deletions(-) diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index 9616f3fef..6234646e5 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -305,9 +305,7 @@ void animatesprites_d(tspriteArray& tsprites, int x, int y, int a, double interp #if 0 // multiplayer only if (screenpeek == myconnectindex && numplayers >= 2) { - t->x = interpolatedvalue(omyx, myx, interpfrac); - t->y = interpolatedvalue(omyy, myy, interpfrac); - t->z = interpolatedvalue(omyz, myz, interpfrac) + gs_playerheight; + t->pos = interpolatedvalue(omypos, mypos, interpfrac).plusZ(gs_playerheight); t->ang = interpolatedvalue(omyang, myang, interpfrac).asbuild(); t->sector = mycursectnum; } diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 94a9f7a2e..d23f222b0 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -347,9 +347,7 @@ void animatesprites_r(tspriteArray& tsprites, int x, int y, int a, double interp #if 0 // multiplayer only if (screenpeek == myconnectindex && numplayers >= 2) { - t->x = interpolatedvalue(omyx, myx, interpfrac); - t->y = interpolatedvalue(omyy, myy, interpfrac); - t->z = interpolatedvalue(omyz, myz, interpfrac) + gs.playerheight; + t->pos = interpolatedvalue(omypos, mypos, interpfrac).plusZ(gs_playerheight); t->ang = interpolatedvalue(omyang, myang, interpfrac).asbuild(); t->sector = mycursectnum; } diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 31683715c..61a548de6 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -266,7 +266,7 @@ void drawoverlays(double interpfrac) { if (screenpeek == myconnectindex && numplayers > 1) { - cposxy = DVector2(interpolatedvalue(omyx, myx, interpfrac), interpolatedvalue(omyy, myy, interpfrac)) * inttoworld; + cposxy = interpolatedvalue(omypos, mypos, interpfrac).XY(); cang = !SyncInput() ? myang : interpolatedvalue(omyang, myang, interpfrac); } else diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index e709298ea..d81032fdd 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -36,7 +36,8 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) BEGIN_DUKE_NS -int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; +DVector3 omypos, mypos; +int myxvel, myyvel, myzvel; int globalskillsound; DAngle myang, omyang; fixedhoriz myhoriz, omyhoriz, myhorizoff, omyhorizoff; @@ -50,9 +51,7 @@ short myangbak[MOVEFIFOSIZ]; void resetmys() { - myx = omyx = ps[myconnectindex].pos.X; - myy = omyy = ps[myconnectindex].pos.Y; - myz = omyz = ps[myconnectindex].pos.Z; + mypos = omypos = ps[myconnectindex].pos; myxvel = myyvel = myzvel = 0; myang = ps[myconnectindex].angle.ang; myhoriz = omyhoriz = ps[myconnectindex].horizon.horiz; @@ -67,32 +66,34 @@ void resetmys() #if 0 // todo: fix this when networking works again void fakedomovethingscorrect(void) { - int i; - player_struct* p; + int i; + player_struct* p; - if (numplayers < 2) return; + if (numplayers < 2) return; - i = ((movefifoplc-1)&(MOVEFIFOSIZ-1)); - p = &ps[myconnectindex]; + i = ((movefifoplc-1)&(MOVEFIFOSIZ-1)); + p = &ps[myconnectindex]; - if (p->pos.x == myxbak[i] && p->pos.y == myybak[i] && p->pos.z == myzbak[i] - && p->horiz == myhorizbak[i] && p->ang == myangbak[i]) return; + if (p->pos.x == myxbak[i] && p->pos.y == myybak[i] && p->pos.z == myzbak[i] + && p->horiz == myhorizbak[i] && p->ang == myangbak[i]) return; - myx = p->pos.x; omyx = p->oposx; myxvel = p->posxv; - myy = p->pos.y; omyy = p->oposy; myyvel = p->posyv; - myz = p->pos.z; omyz = p->oposz; myzvel = p->poszv; - myang = p->ang; omyang = p->oang; - mycursectnum = p->cursector; - myhoriz = p->horiz; omyhoriz = p->ohoriz; - myhorizoff = p->horizoff; omyhorizoff = p->ohorizoff; - myjumpingcounter = p->jumping_counter; - myjumpingtoggle = p->jumping_toggle; - myonground = p->on_ground; - myhardlanding = p->hard_landing; + omypos = p->opos; + mypos = p->pos; + myxvel = p->vel.X; + myyvel = p->vel.Y; + myzvel = p->vel.Z; + myang = p->ang; omyang = p->oang; + mycursectnum = p->cursector; + myhoriz = p->horiz; omyhoriz = p->ohoriz; + myhorizoff = p->horizoff; omyhorizoff = p->ohorizoff; + myjumpingcounter = p->jumping_counter; + myjumpingtoggle = p->jumping_toggle; + myonground = p->on_ground; + myhardlanding = p->hard_landing; - fakemovefifoplc = movefifoplc; - while (fakemovefifoplc < movefifoend[myconnectindex]) - fakedomovethings(); + fakemovefifoplc = movefifoplc; + while (fakemovefifoplc < movefifoend[myconnectindex]) + fakedomovethings(); } @@ -124,13 +125,11 @@ void fakedomovethings(void) if( ud.clipping == 0 && ( psect->floorpicnum == MIRROR || psect == nullptr) ) { - myx = omyx; - myy = omyy; + mypos.XY() = omypos.XY(); } else { - omyx = myx; - omyy = myy; + omypos.XY() = mypos.XY(); } omyhoriz = myhoriz; diff --git a/source/games/duke/src/prediction.h b/source/games/duke/src/prediction.h index 84b21b34a..ce9a5f605 100644 --- a/source/games/duke/src/prediction.h +++ b/source/games/duke/src/prediction.h @@ -2,7 +2,8 @@ BEGIN_DUKE_NS -extern int myx, omyx, myxvel, myy, omyy, myyvel, myz, omyz, myzvel; +extern DVector3 omypos, mypos; +extern int myxvel, myyvel, myzvel; extern int globalskillsound; extern int mycursectnum, myjumpingcounter; extern DAngle myang, omyang;