Skip to content

Commit

Permalink
Fix dehacked loading
Browse files Browse the repository at this point in the history
Fix undefined behavior in G_CheckSpot causing clang to compute an invalid angle

Fix various sequencing problems in
P_PlayerThink/P_RunPlayerCommand/run_player_commands causing desyncs

crush field of ceiling_t, floormove_t, and plat_t needs to be an int, even
though it was dboolean before.

Keep track of re-prediction start and end TICs; this might aid sound woes

Some updates to demo state dumps to accommodate various idiosyncrasies

Start dumping playerstarts and deathmatchstarts
  • Loading branch information
camgunz committed Apr 26, 2016
1 parent 8ef9f11 commit 7b5bed8
Show file tree
Hide file tree
Showing 16 changed files with 387 additions and 136 deletions.
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

BUILD_TYPE=Debug
BUILD_TYPE=Release

if [ ! -d cbuild ]
then
Expand Down
109 changes: 102 additions & 7 deletions dumpdemo.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,107 @@
#!/bin/sh

CMD="cbuild/d2k -iwad doom2.wad -file gothicdm.wad -nodraw -nosfx -nomouse -fastdemo DEMO1 -dumpdemo d2kdump.bin"
DEMODIR=/home/charlie/demos

./build.sh || exit 1
$CMD
# gdb --args $CMD
# gdb -ex run --args $CMD
# gdb -ex "source gdbdemo.txt" --args $CMD
# PORT='/home/charlie/bin/prboom-plus -nosfx -nomusic -nomouse -nodraw'
# DEMOCMD=fastdemo

mv d2kdump.bin ../democomp/d2kdump.bin
# PORT=/home/charlie/bin/odamex
# DEMOCMD=playdemo

PORT='/home/charlie/code/d2k/cbuild/d2k -nosfx -nomusic -nomouse -nodraw'
DEMOCMD=fastdemo
DUMPDIR='/home/charlie/code/democomp/d2k'

# ${PORT} -iwad doom2.wad -file chextc.wad -deh chex.deh -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/chex-demo1.bin
# ${PORT} -iwad doom2.wad -file chextc.wad -deh chex.deh -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/chex-demo2.bin
# ${PORT} -iwad doom2.wad -file chextc.wad -deh chex.deh -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/chex-demo3.bin

# ${PORT} -iwad doom.wad -${DEMOCMD} ${DEMODIR}/bohfight.lmp -dumpdemo ${DUMPDIR}/doom-bohfight.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} ${DEMODIR}/d1shock.lmp -dumpdemo ${DUMPDIR}/doom-d1shock.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} ${DEMODIR}/d1slide.lmp -dumpdemo ${DUMPDIR}/doom-d1slide.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/doom-demo1.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/doom-demo2.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/doom-demo3.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} ${DEMODIR}/impfight.lmp -dumpdemo ${DUMPDIR}/doom-impfight.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} ${DEMODIR}/speedbmp.lmp -dumpdemo ${DUMPDIR}/doom-speedbmp.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} ${DEMODIR}/stilhere.lmp -dumpdemo ${DUMPDIR}/doom-stilhere.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} ${DEMODIR}/stuckimp.lmp -dumpdemo ${DUMPDIR}/doom-stuckimp.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} ${DEMODIR}/tapfocus.lmp -dumpdemo ${DUMPDIR}/doom-tapfocus.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} ${DEMODIR}/wallrun.lmp -dumpdemo ${DUMPDIR}/doom-wallrun.bin
#
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/02noview.lmp -dumpdemo ${DUMPDIR}/doom2-02noview.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/07intowr.lmp -dumpdemo ${DUMPDIR}/doom2-07intowr.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/07tower.lmp -dumpdemo ${DUMPDIR}/doom2-07tower.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/2ghosts.lmp -dumpdemo ${DUMPDIR}/doom2-2ghosts.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/doom2-demo1.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/doom2-demo2.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/doom2-demo3.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/bfgdemo.lmp -dumpdemo ${DUMPDIR}/doom2-bfgdemo.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/bounce1.lmp -dumpdemo ${DUMPDIR}/doom2-bounce1.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/bounce2.lmp -dumpdemo ${DUMPDIR}/doom2-bounce2.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/burnthru.lmp -dumpdemo ${DUMPDIR}/doom2-burnthru.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/cacofit2.lmp -dumpdemo ${DUMPDIR}/doom2-cacofit.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/cacofite.lmp -dumpdemo ${DUMPDIR}/doom2-cacofite.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/d2shock.lmp -dumpdemo ${DUMPDIR}/doom2-d2shock.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/d2slide.lmp -dumpdemo ${DUMPDIR}/doom2-d2slide.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/dedngone.lmp -dumpdemo ${DUMPDIR}/doom2-dedngone.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/firewall.lmp -dumpdemo ${DUMPDIR}/doom2-firewall.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/flicker.lmp -dumpdemo ${DUMPDIR}/doom2-flicker.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/fusedem.lmp -dumpdemo ${DUMPDIR}/doom2-fusedem.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/ghostpe1.lmp -dumpdemo ${DUMPDIR}/doom2-ghostpe1.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/ghostpe2.lmp -dumpdemo ${DUMPDIR}/doom2-ghostpe2.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/impghost.lmp -dumpdemo ${DUMPDIR}/doom2-impghost.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/impmiss.lmp -dumpdemo ${DUMPDIR}/doom2-impmiss.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/lv04-028.lmp -dumpdemo ${DUMPDIR}/doom2-lv04-028.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/lv07-046.lmp -dumpdemo ${DUMPDIR}/doom2-lv07-046.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/lv12-043.lmp -dumpdemo ${DUMPDIR}/doom2-lv12-043.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/lv15s032.lmp -dumpdemo ${DUMPDIR}/doom2-lv15s032.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/revorbit.lmp -dumpdemo ${DUMPDIR}/doom2-revorbit.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/smpunch.lmp -dumpdemo ${DUMPDIR}/doom2-smpunch.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/soulpop.lmp -dumpdemo ${DUMPDIR}/doom2-soulpop.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/tallbomb.lmp -dumpdemo ${DUMPDIR}/doom2-tallbomb.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/thingrun.lmp -dumpdemo ${DUMPDIR}/doom2-thingrun.bin
# ${PORT} -iwad doom2.wad -file av.wad -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/doom2-av-demo1.bin
# ${PORT} -iwad doom2.wad -file av.wad -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/doom2-av-demo2.bin
# ${PORT} -iwad doom2.wad -file av.wad -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/doom2-av-demo3.bin
${PORT} -iwad doom2.wad -file gothicdm.wad -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/doom2-gothicdm-demo1.bin
${PORT} -iwad doom2.wad -file gothicdm.wad -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/doom2-gothicdm-demo2.bin
# ${PORT} -iwad doom2.wad -file gothicdm.wad -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/doom2-gothicdm-demo3.bin
# ${PORT} -iwad doom2.wad -file gothicdm.wad -${DEMOCMD} demo4 -dumpdemo ${DUMPDIR}/doom2-gothicdm-demo4.bin
# ${PORT} -iwad doom2.wad -file hr.wad -${DEMOCMD} ${DEMODIR}/hf21tysn.lmp -dumpdemo ${DUMPDIR}/doom2-hr-hf21tysn.bin
# ${PORT} -iwad doom2.wad -file hr2final.wad -${DEMOCMD} ${DEMODIR}/hr2-lv01.lmp -dumpdemo ${DUMPDIR}/doom2-hr2final-hr2-lv01.bin
# ${PORT} -iwad doom2.wad -file icarus.wad -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/doom2-icarus-demo1.bin
# ${PORT} -iwad doom2.wad -file icarus.wad -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/doom2-icarus-demo2.bin
# ${PORT} -iwad doom2.wad -file icarus.wad -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/doom2-icarus-demo3.bin
# ${PORT} -iwad doom2.wad -file mm2.wad -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/doom2-mm2-demo1.bin
# ${PORT} -iwad doom2.wad -file mm2.wad -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/doom2-mm2-demo2.bin
# ${PORT} -iwad doom2.wad -file mm2.wad -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/doom2-mm2-demo3.bin
# ${PORT} -iwad doom2.wad -file hacx.wad -deh hacx.deh -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/doom2-hacx-demo1.bin
# ${PORT} -iwad doom2.wad -file hacx.wad -deh hacx.deh -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/doom2-hacx-demo2.bin
# ${PORT} -iwad doom2.wad -file hacx.wad -deh hacx.deh -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/doom2-hacx-demo3.bin
# ${PORT} -iwad doom2.wad -file tntgrvnc.wad -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/doom2-tntgrvnc-demo1.bin
${PORT} -iwad doom2.wad -file tntgrvnc.wad -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/doom2-tntgrvnc-demo2.bin
# ${PORT} -iwad doom2.wad -file tntgrvnc.wad -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/doom2-tntgrvnc-demo3.bin
# ${PORT} -iwad plutonia.wad -${DEMOCMD} ${DEMODIR}/blindav.lmp -dumpdemo ${DUMPDIR}/plutonia-blindav.bin
# ${PORT} -iwad plutonia.wad -${DEMOCMD} ${DEMODIR}/deadlift.lmp -dumpdemo ${DUMPDIR}/plutonia-deadlift.bin
# ${PORT} -iwad plutonia.wad -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/plutonia-demo1.bin
# ${PORT} -iwad plutonia.wad -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/plutonia-demo2.bin
# ${PORT} -iwad plutonia.wad -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/plutonia-demo3.bin
# ${PORT} -iwad plutonia.wad -${DEMOCMD} ${DEMODIR}/nontoxic.lmp -dumpdemo ${DUMPDIR}/plutonia-nontoxic.bin
# ${PORT} -iwad plutonia.wad -${DEMOCMD} ${DEMODIR}/revfight.lmp -dumpdemo ${DUMPDIR}/plutonia-revfight.bin
# ${PORT} -iwad tnt.wad -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/tnt-demo1.bin
# ${PORT} -iwad tnt.wad -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/tnt-demo2.bin
# ${PORT} -iwad tnt.wad -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/tnt-demo3.bin
# ${PORT} -iwad tnt.wad -${DEMOCMD} ${DEMODIR}/soulfrag.lmp -dumpdemo ${DUMPDIR}/tnt-soulfrag.bin

# ${PORT} -iwad doom2.wad -file requiem.wad -${DEMOCMD} demo1 -dumpdemo ${DUMPDIR}/doom2-requiem-demo1.bin
# ${PORT} -iwad doom2.wad -file requiem.wad -${DEMOCMD} demo2 -dumpdemo ${DUMPDIR}/doom2-requiem-demo2.bin

## Long

# ${PORT} -iwad doom2.wad -file requiem.wad -${DEMOCMD} demo3 -dumpdemo ${DUMPDIR}/doom2-requiem-demo3.bin
# ${PORT} -iwad doom.wad -${DEMOCMD} ${DEMODIR}/ep1-0500.lmp -dumpdemo ${DUMPDIR}/doom-ep1-0500.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/30nm4048.lmp -dumpdemo ${DUMPDIR}/doom2-30nm4048.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/nm30cop1.lmp -dumpdemo ${DUMPDIR}/doom2-nm30cop1.bin
# ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/nm30cop2.lmp -dumpdemo ${DUMPDIR}/doom2-nm30cop2.bin
## ${PORT} -iwad doom2.wad -${DEMOCMD} ${DEMODIR}/coopuv30.lmp -dumpdemo ${DUMPDIR}/doom2-coopuv30.bin
52 changes: 46 additions & 6 deletions src/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ static bool cl_synchronizing = false;
*/
static bool cl_repredicting = false;

/*
* The TIC at which reprediction started.
*/
static int cl_repredicting_start_tic = 0;

/*
* The TIC at which reprediction will finish.
*/
static int cl_repredicting_end_tic = 0;

/*
* The TIC of the last state received from the server
*/
Expand Down Expand Up @@ -162,27 +172,57 @@ static bool cl_load_new_state(netpeer_t *server) {
return true;
}

static void cl_set_repredicting(int start_tic, int end_tic) {
cl_repredicting_start_tic = start_tic;
cl_repredicting_end_tic = end_tic;
cl_repredicting = true;
}

static void cl_clear_repredicting(void) {
cl_repredicting_start_tic = 0;
cl_repredicting_end_tic = 0;
cl_repredicting = false;
}

static void cl_predict(int saved_gametic) {
player_t *player = &players[consoleplayer];
int latest_command_index;

if (gametic == -1)
if (gametic == -1) {
return;
}

latest_command_index = P_GetLatestCommandIndex(consoleplayer);

if (latest_command_index == -1)
if (latest_command_index == -1) {
return;
}

while (players[consoleplayer].latest_command_run_index <
latest_command_index) {
cl_repredicting = true;
cl_set_repredicting(player->latest_command_run_index, latest_command_index);
while (player->latest_command_run_index < latest_command_index) {
N_RunTic();
if (players[displayplayer].mo != NULL) {
R_InterpolateView(&players[displayplayer]);
R_RestoreInterpolations();
}
cl_repredicting = false;
}
cl_clear_repredicting();
}

bool CL_OccurredDuringRePrediction(int tic) {
if (!cl_repredicting) {
return false;
}

if (tic < cl_repredicting_start_tic) {
return false;
}

if (tic > cl_repredicting_end_tic) {
return false;
}

return true;
}

void CL_CheckForStateUpdates(void) {
Expand Down
1 change: 1 addition & 0 deletions src/cl_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ bool CL_ReceivedSetup(void);
void CL_SetReceivedSetup(bool new_received_setup);
void CL_SetAuthorizationLevel(auth_level_e level);
void CL_MarkServerOutdated(void);
bool CL_OccurredDuringRePrediction(int tic);
void CL_CheckForStateUpdates(void);
void CL_UpdateReceivedCommandIndex(int command_index);
void CL_Init(void);
Expand Down
Loading

0 comments on commit 7b5bed8

Please sign in to comment.