mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-18 02:12:03 +00:00
83936bf5eb
This reverts commite878c5bab8
. Revert "SW: Use Q16.16 for horiz." This reverts commitf07a0ae01e
. Revert "SW: Use Q16.16 for angle." This reverts commit1ecc74c2ec
. Revert "SW: Minor repairs for Q16.16 implementation." This reverts commitd78d046bad
. Revert "SW: Process input at frame rate." This reverts commitc162014dab
. Revert "SW: Amendments to accommodate changes in master." This reverts commiteaa51138ad
. Revert "SW: Fix incorrectly declared function input type." This reverts commit1cdd5b08d8
. Revert "SW: Amend scaleAdjustmentToInterval() with correct value for SW." This reverts commitd4dd737cd5
. Revert "SW: Refinements to new input code." This reverts commit5ebc65a1fb
. Revert "SW: Adjust look and snap up/down keys and slightly tune PLAYER_TURN_AMOUNT." This reverts commit2852536dbf
. Revert "SW: Get PLAYER_TURN_SCALE to be just right." This reverts commit4630c8a0b7
. Revert "SW: Make map follow mode work better." This reverts commit8e94c48eff
. Revert "SW: Remove line accidentally left from 'MoveScrollMode2D()'." This reverts commit5db8047b41
. Revert "Fix multiplayer desync after the change to q16 angle and horiz." This reverts commit3bc46078b8
. Revert "SW: Revert commented out horiz->q16horiz renames in DSPRINTF strings" This reverts commit537313f620
. Revert "sw/src/draw.cpp:drawscreen: We can set the pp->si* fields just once," This reverts commitd2e9595980
. Revert "sw/src/game.cpp:LoadLevel: Rename q16ang -> ang" This reverts commita178961a3e
. Revert "SW: Minor tweaks." This reverts commit377ba68344
. Revert "SW: Further refine turning and optimise horizon adjustment." This reverts commit039022d9ac
. Revert "SW: Don't process input at frame rate if ScrollMode2D is true." This reverts commit1aa1e62c4d
. Revert "SW: Use a bit more Q16.16 in places." This reverts commit40ca656f38
. Revert "SW: Use the old interpolation path in drawscreen if player is dead" This reverts commit2d73466425
. Revert "SW: Smooth out 180 degree turn landing and replace some fix16_min/max with fix16_clamp." This reverts commit0996e87f79
. Revert "Change Next/Previous Weapon button handling for Shadow Warrior." This reverts commitf6b8ca6a22
. Revert "SW: Make "Center_View" key return smoothly." This reverts commit23c401fbc2
. Revert "SW: Use the old interpolation path in drawscreen if player is dead" This reverts commit43ec16eb55
. Revert "Interpolation fixes for SW:" This reverts commitac8a7ecfbd
. Revert "SW: Reset the number of interpolations on level load" This reverts commit04bf8499e7
. Revert "Another change modifying saved game format in SW:" This reverts commite80888523e
. Revert "SW: Interpolate sector objects in non-demo, single player games." This reverts commit996ab77cf4
. Revert "- fixed merge errors in SW." This reverts commitb8cfa94568
. Revert "- fix interpolation stutters when opening console for SW." This reverts commit99fdbfb6cb
. Revert "- reset buttonMap button states after returning from pause for SW (stops keys acting stuck down if down prior to pausing)." This reverts commit693b6955da
. Revert "SW: fix stupid input scaling bug" This reverts commit1c79e6e17c
. Revert "SW: Make vehicle input better." This reverts commit670a53c402
. Revert "SW: Change fix16_from_float() to fix16_from_int() that was changed in4630c8a0b7
but should have been reverted in 377ba68344e34495638c6fa7685ff78c9a0ed6f8." This reverts commit423c9da071
. Revert "SW: Remove ScrollMode2D extern boolean and move into PLAYERp struct." This reverts commit31eb55c1fa
.
224 lines
5.9 KiB
C++
224 lines
5.9 KiB
C++
//-------------------------------------------------------------------------
|
|
/*
|
|
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
|
|
*/
|
|
//-------------------------------------------------------------------------
|
|
|
|
#include "ns.h"
|
|
//#define MAIN
|
|
#define QUIET
|
|
#include "build.h"
|
|
|
|
#include "keys.h"
|
|
#include "names2.h"
|
|
#include "panel.h"
|
|
#include "game.h"
|
|
#include "network.h"
|
|
|
|
BEGIN_SW_NS
|
|
|
|
SWBOOL PredictionOn = TRUE;
|
|
SWBOOL Prediction = FALSE;
|
|
PLAYER PredictPlayer;
|
|
USER PredictUser;
|
|
PLAYERp ppp = &PredictPlayer;
|
|
|
|
typedef struct
|
|
{
|
|
int x,y,z,horiz;
|
|
short ang,filler;
|
|
} PREDICT, *PREDICTp;
|
|
|
|
PREDICT Predict[MOVEFIFOSIZ];
|
|
int predictmovefifoplc;
|
|
|
|
void DoPlayerSectorUpdatePreMove(PLAYERp);
|
|
void DoPlayerSectorUpdatePostMove(PLAYERp);
|
|
|
|
extern SWBOOL GamePaused;
|
|
|
|
#define PREDICT_DEBUG 0
|
|
|
|
#if PREDICT_DEBUG
|
|
void (*pred_last_func)(PLAYERp) = NULL;
|
|
#endif
|
|
|
|
void
|
|
InitPrediction(PLAYERp pp)
|
|
{
|
|
if (!PredictionOn)
|
|
return;
|
|
|
|
#if PREDICT_DEBUG
|
|
pred_last_func = pp->DoPlayerAction;
|
|
#endif
|
|
|
|
// make a copy of player struct and sprite
|
|
*ppp = *pp;
|
|
PredictUser = *User[pp->PlayerSprite];
|
|
}
|
|
|
|
#if PREDICT_DEBUG
|
|
PredictDebug(PLAYERp ppp)
|
|
{
|
|
static FILE *fout = NULL;
|
|
static char pred_sym_name[80];
|
|
|
|
if (SymCountCode == 0)
|
|
LoadSymTable("swcode.sym", &SymTableCode, &SymCountCode);
|
|
|
|
if (SymCountCode <= 0)
|
|
return;
|
|
|
|
if (!fout)
|
|
{
|
|
if ((fout = fopen("dbgpred.txt", "wb")) == NULL)
|
|
return;
|
|
}
|
|
|
|
if (ppp->DoPlayerAction != pred_last_func)
|
|
{
|
|
extern uint32_t MoveThingsCount;
|
|
SYM_TABLEp st_ptr;
|
|
uint32_t unrelocated_offset;
|
|
uint32_t offset_from_symbol;
|
|
|
|
unrelocated_offset = SymCodePtrToOffset((void *)ppp->DoPlayerAction);
|
|
st_ptr = SearchSymTableByOffset(SymTableCode, SymCountCode, unrelocated_offset, &offset_from_symbol);
|
|
ASSERT(st_ptr);
|
|
strcpy(pred_sym_name, st_ptr->Name);
|
|
|
|
fprintf(fout, "%s, %d\n", pred_sym_name, MoveThingsCount);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
|
|
void
|
|
DoPrediction(PLAYERp ppp)
|
|
{
|
|
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
|
|
RESET(ppp->input.bits,
|
|
BIT(SK_SHOOT)|BIT(SK_OPERATE)|BIT(SK_INV_LEFT)|BIT(SK_INV_RIGHT)|
|
|
BIT(SK_INV_USE)|BIT(SK_HIDE_WEAPON)|
|
|
BIT(SK_AUTO_AIM)|
|
|
BIT(SK_CENTER_VIEW)|
|
|
SK_WEAPON_MASK|
|
|
SK_INV_HOTKEY_MASK
|
|
);
|
|
|
|
SET(ppp->KeyPressFlags,
|
|
BIT(SK_SHOOT)|BIT(SK_OPERATE)|BIT(SK_INV_LEFT)|BIT(SK_INV_RIGHT)|
|
|
BIT(SK_INV_USE)|BIT(SK_HIDE_WEAPON)|
|
|
BIT(SK_AUTO_AIM)|
|
|
BIT(SK_CENTER_VIEW)|
|
|
SK_WEAPON_MASK|
|
|
SK_INV_HOTKEY_MASK
|
|
);
|
|
|
|
// 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;
|
|
|
|
ppp->oang = ppp->pang;
|
|
ppp->oposx = ppp->posx;
|
|
ppp->oposy = ppp->posy;
|
|
ppp->oposz = ppp->posz;
|
|
ppp->ohoriz = ppp->horiz;
|
|
|
|
#if PREDICT_DEBUG
|
|
PredictDebug(ppp);
|
|
#endif
|
|
|
|
// 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;
|
|
|
|
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].ang = ppp->pang;
|
|
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].x = ppp->posx;
|
|
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].y = ppp->posy;
|
|
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].z = ppp->posz;
|
|
Predict[predictmovefifoplc & (MOVEFIFOSIZ-1)].horiz = ppp->horiz;
|
|
predictmovefifoplc++;
|
|
}
|
|
|
|
void
|
|
CorrectPrediction(int actualfifoplc)
|
|
{
|
|
PREDICTp predict = &Predict[actualfifoplc & (MOVEFIFOSIZ-1)];
|
|
|
|
if (!PredictionOn)
|
|
return;
|
|
|
|
if (!CommEnabled)
|
|
return;
|
|
|
|
// see if player position is predicted position
|
|
if (predict->ang == Player[myconnectindex].pang &&
|
|
predict->x == Player[myconnectindex].posx &&
|
|
predict->y == Player[myconnectindex].posy &&
|
|
predict->z == Player[myconnectindex].posz &&
|
|
predict->horiz == Player[myconnectindex].horiz
|
|
)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// //DSPRINTF(ds,"PREDICT ERROR: %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld", predict->ang, Player[myconnectindex].pang, predict->x, Player[myconnectindex].posx, predict->y, Player[myconnectindex].posy, predict->z, Player[myconnectindex].posz, predict->horiz,Player[myconnectindex].horiz);
|
|
// MONO_PRINT(ds);
|
|
|
|
InitPrediction(&Player[myconnectindex]);
|
|
// puts the predicted pos back to actual pos
|
|
predictmovefifoplc = movefifoplc;
|
|
|
|
while (predictmovefifoplc < Player[myconnectindex].movefifoend)
|
|
{
|
|
DoPrediction(ppp);
|
|
}
|
|
}
|
|
|
|
END_SW_NS
|