2015-05-19 21:54:34 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
|
|
|
|
|
|
|
This file is part of Shadow Warrior version 1.2
|
|
|
|
|
|
|
|
Shadow Warrior is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
Original Source: 1997 - Frank Maddin and Jim Norwood
|
|
|
|
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
#include "ns.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
//#define MAIN
|
|
|
|
#define QUIET
|
|
|
|
#include "build.h"
|
|
|
|
|
|
|
|
#include "names2.h"
|
|
|
|
#include "panel.h"
|
|
|
|
#include "game.h"
|
2019-03-21 02:24:19 +00:00
|
|
|
#include "network.h"
|
2015-05-19 21:54:34 +00:00
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
BEGIN_SW_NS
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
SWBOOL PredictionOn = TRUE;
|
|
|
|
SWBOOL Prediction = FALSE;
|
2015-05-19 21:54:34 +00:00
|
|
|
PLAYER PredictPlayer;
|
|
|
|
USER PredictUser;
|
|
|
|
PLAYERp ppp = &PredictPlayer;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2020-03-28 11:31:02 +00:00
|
|
|
int x,y,z;
|
2020-09-01 13:00:35 +00:00
|
|
|
fixed_t q16horiz, q16ang;
|
2020-03-29 08:03:00 +00:00
|
|
|
short filler;
|
2015-05-19 21:54:34 +00:00
|
|
|
} PREDICT, *PREDICTp;
|
|
|
|
|
2020-09-02 18:56:09 +00:00
|
|
|
PREDICT Predict[/*MOVEFIFOSIZ*/256];
|
2015-05-19 21:54:34 +00:00
|
|
|
int predictmovefifoplc;
|
|
|
|
|
2015-05-19 21:58:29 +00:00
|
|
|
void DoPlayerSectorUpdatePreMove(PLAYERp);
|
|
|
|
void DoPlayerSectorUpdatePostMove(PLAYERp);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
InitPrediction(PLAYERp pp)
|
|
|
|
{
|
|
|
|
if (!PredictionOn)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// make a copy of player struct and sprite
|
|
|
|
*ppp = *pp;
|
|
|
|
PredictUser = *User[pp->PlayerSprite];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
DoPrediction(PLAYERp ppp)
|
|
|
|
{
|
2020-09-02 18:56:09 +00:00
|
|
|
#if 0
|
2015-05-19 21:54:34 +00:00
|
|
|
USERp u;
|
|
|
|
SPRITE spr;
|
|
|
|
int bakrandomseed;
|
|
|
|
|
|
|
|
// routine called from MoveLoop
|
|
|
|
|
|
|
|
if (!PredictionOn)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ppp->input = Player[myconnectindex].inputfifo[predictmovefifoplc & (MOVEFIFOSIZ-1)];
|
|
|
|
|
|
|
|
// get rid of input bits so it doesn't go into other code branches that would
|
|
|
|
// get it out of sync
|
2020-08-28 20:51:05 +00:00
|
|
|
ppp->input.actions &= ~(SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_INVNEXT|SB_INVPREV|SB_INVUSE|SB_HOLSTER|SB_CENTERVIEW|SB_FIRE|SB_OPEN);;
|
|
|
|
ppp->KeyPressBits |= (SB_WEAPONMASK_BITS|SB_ITEMUSE_BITS|SB_INVNEXT|SB_INVPREV|SB_INVUSE|SB_HOLSTER|SB_CENTERVIEW|SB_FIRE|SB_OPEN);
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// back up things so they won't get stepped on
|
|
|
|
bakrandomseed = randomseed;
|
|
|
|
spr = sprite[Player[myconnectindex].PlayerSprite];
|
|
|
|
sprite[Player[myconnectindex].PlayerSprite].cstat = 0;
|
|
|
|
|
|
|
|
u = User[ppp->PlayerSprite];
|
|
|
|
User[ppp->PlayerSprite] = &PredictUser;
|
|
|
|
|
2020-03-29 08:03:00 +00:00
|
|
|
ppp->oq16ang = ppp->q16ang;
|
2015-05-19 21:54:34 +00:00
|
|
|
ppp->oposx = ppp->posx;
|
|
|
|
ppp->oposy = ppp->posy;
|
|
|
|
ppp->oposz = ppp->posz;
|
2020-03-28 11:31:02 +00:00
|
|
|
ppp->oq16horiz = ppp->q16horiz;
|
2015-05-19 21:54:34 +00:00
|
|
|
|
|
|
|
// go through the player MOVEMENT code only
|
|
|
|
Prediction = TRUE;
|
|
|
|
DoPlayerSectorUpdatePreMove(ppp);
|
|
|
|
(*ppp->DoPlayerAction)(ppp);
|
|
|
|
DoPlayerSectorUpdatePostMove(ppp);
|
|
|
|
Prediction = FALSE;
|
|
|
|
|
|
|
|
// restore things
|
|
|
|
User[ppp->PlayerSprite] = u;
|
|
|
|
sprite[Player[myconnectindex].PlayerSprite] = spr;
|
|
|
|
randomseed = bakrandomseed;
|
|
|
|
|
2020-03-29 08:03:00 +00:00
|
|
|
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].q16ang = ppp->q16ang;
|
2015-05-19 21:54:34 +00:00
|
|
|
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].x = ppp->posx;
|
|
|
|
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].y = ppp->posy;
|
|
|
|
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].z = ppp->posz;
|
2020-03-28 11:31:02 +00:00
|
|
|
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].q16horiz = ppp->q16horiz;
|
2015-05-19 21:54:34 +00:00
|
|
|
predictmovefifoplc++;
|
2020-09-02 18:56:09 +00:00
|
|
|
#endif
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CorrectPrediction(int actualfifoplc)
|
|
|
|
{
|
2020-09-02 18:56:09 +00:00
|
|
|
#if 0
|
2015-05-19 21:54:34 +00:00
|
|
|
PREDICTp predict = &Predict[actualfifoplc & (MOVEFIFOSIZ-1)];
|
|
|
|
|
|
|
|
if (!PredictionOn)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!CommEnabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// see if player position is predicted position
|
2020-03-29 08:03:00 +00:00
|
|
|
if (predict->q16ang == Player[myconnectindex].q16ang &&
|
2015-05-19 21:54:34 +00:00
|
|
|
predict->x == Player[myconnectindex].posx &&
|
|
|
|
predict->y == Player[myconnectindex].posy &&
|
|
|
|
predict->z == Player[myconnectindex].posz &&
|
2020-03-28 11:31:02 +00:00
|
|
|
predict->q16horiz == Player[myconnectindex].q16horiz
|
2015-05-19 21:54:34 +00:00
|
|
|
)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
// //DSPRINTF(ds,"PREDICT ERROR: %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", FixedToInt(predict->q16ang), FixedToInt(Player[myconnectindex].q16ang), predict->x, Player[myconnectindex].posx, predict->y, Player[myconnectindex].posy, predict->z, Player[myconnectindex].posz, FixedToInt(predict->q16horiz),FixedToInt(Player[myconnectindex].q16horiz));
|
2015-05-19 21:54:34 +00:00
|
|
|
// MONO_PRINT(ds);
|
|
|
|
|
|
|
|
InitPrediction(&Player[myconnectindex]);
|
|
|
|
// puts the predicted pos back to actual pos
|
|
|
|
predictmovefifoplc = movefifoplc;
|
|
|
|
|
|
|
|
while (predictmovefifoplc < Player[myconnectindex].movefifoend)
|
|
|
|
{
|
|
|
|
DoPrediction(ppp);
|
|
|
|
}
|
2020-09-02 18:56:09 +00:00
|
|
|
#endif
|
2015-05-19 21:54:34 +00:00
|
|
|
}
|
|
|
|
|
2019-10-09 16:09:05 +00:00
|
|
|
END_SW_NS
|