From 7b5bed8c696c5f25f7eabeaae5df2a986a364281 Mon Sep 17 00:00:00 2001 From: Charlie Gunyon Date: Tue, 26 Apr 2016 00:15:40 -0400 Subject: [PATCH] Fix dehacked loading 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 --- build.sh | 1 + dumpdemo.sh | 109 +++++++++++++++++++++++++++++++++++++++++++++---- src/cl_main.c | 52 ++++++++++++++++++++--- src/cl_main.h | 1 + src/d_dump.c | 88 ++++++++++++++++++++++++++++----------- src/d_main.c | 40 ++++++++++++------ src/g_game.c | 25 +++++++++++- src/p_cmd.c | 27 ++++++++---- src/p_cmd.h | 2 +- src/p_mobj.c | 44 ++++++++++---------- src/p_pspr.c | 51 +++++++++++++---------- src/p_saveg.c | 12 +++--- src/p_spec.h | 6 +-- src/p_user.c | 12 +++--- src/s_sndnew.c | 41 +++++++++++++++---- src/s_sound.c | 12 +++--- 16 files changed, 387 insertions(+), 136 deletions(-) diff --git a/build.sh b/build.sh index 01ae03c..69276dc 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,7 @@ #!/bin/sh BUILD_TYPE=Debug +BUILD_TYPE=Release if [ ! -d cbuild ] then diff --git a/dumpdemo.sh b/dumpdemo.sh index 6508194..36be3d6 100755 --- a/dumpdemo.sh +++ b/dumpdemo.sh @@ -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 diff --git a/src/cl_main.c b/src/cl_main.c index 222c8fb..5d79c23 100644 --- a/src/cl_main.c +++ b/src/cl_main.c @@ -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 */ @@ -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) { diff --git a/src/cl_main.h b/src/cl_main.h index c97d87b..195db4e 100644 --- a/src/cl_main.h +++ b/src/cl_main.h @@ -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); diff --git a/src/d_dump.c b/src/d_dump.c index 09e801e..6f1b3eb 100644 --- a/src/d_dump.c +++ b/src/d_dump.c @@ -93,13 +93,16 @@ static void dump_line_index(pbuf_t *savebuffer, line_t *li, const char *fn) { uint_64_t line_index; if (li < lines) { - I_Error("%s: Invalid line %p", fn, li); + // I_Error("%s: Invalid line %p < %p", fn, li, lines); + line_index = 0; + } + else { + line_index = li - lines; } - - line_index = li - lines; if (line_index > numlines) { - I_Error("%s: Invalid line %p", fn, li); + // I_Error("%s: Invalid line %p", fn, li); + line_index = 0; } M_PBufWriteULong(savebuffer, line_index + 1); @@ -151,9 +154,12 @@ void D_Dump(pbuf_t *savebuffer) { M_PBufWriteInt(savebuffer, weapon_recoil); M_PBufWriteInt(savebuffer, allow_pushers); M_PBufWriteInt(savebuffer, player_bobbing); - M_PBufWriteInt(savebuffer, respawnparm); - M_PBufWriteInt(savebuffer, fastparm); - M_PBufWriteInt(savebuffer, nomonsters); + /* [CG] respawnparm is > 1 in some demos */ + M_PBufWriteInt(savebuffer, respawnparm ? 1 : 0); + /* [CG] fastparm is > 1 in some demos */ + M_PBufWriteInt(savebuffer, fastparm ? 1 : 0); + /* [CG] nomonsters is > 1 in some demos */ + M_PBufWriteInt(savebuffer, nomonsters ? 1 : 0); M_PBufWriteInt(savebuffer, demo_insurance); M_PBufWriteUInt(savebuffer, rngseed); M_PBufWriteInt(savebuffer, monster_infighting); @@ -217,9 +223,12 @@ void D_Dump(pbuf_t *savebuffer) { M_PBufWriteInt(savebuffer, weapon_recoil); M_PBufWriteInt(savebuffer, allow_pushers); M_PBufWriteInt(savebuffer, player_bobbing); - M_PBufWriteInt(savebuffer, respawnparm); - M_PBufWriteInt(savebuffer, fastparm); - M_PBufWriteInt(savebuffer, nomonsters); + /* [CG] respawnparm is > 1 in some demos */ + M_PBufWriteInt(savebuffer, respawnparm ? 1 : 0); + /* [CG] fastparm is > 1 in some demos */ + M_PBufWriteInt(savebuffer, fastparm ? 1 : 0); + /* [CG] nomonsters is > 1 in some demos */ + M_PBufWriteInt(savebuffer, nomonsters ? 1 : 0); M_PBufWriteInt(savebuffer, demo_insurance); M_PBufWriteUInt(savebuffer, rngseed); M_PBufWriteInt(savebuffer, monster_infighting); @@ -272,9 +281,12 @@ void D_Dump(pbuf_t *savebuffer) { M_PBufWriteInt(savebuffer, gameepisode); M_PBufWriteInt(savebuffer, gamemap); M_PBufWriteInt(savebuffer, deathmatch); - M_PBufWriteInt(savebuffer, respawnparm); - M_PBufWriteInt(savebuffer, fastparm); - M_PBufWriteInt(savebuffer, nomonsters); + /* [CG] respawnparm is > 1 in some demos */ + M_PBufWriteInt(savebuffer, respawnparm ? 1 : 0); + /* [CG] fastparm is > 1 in some demos */ + M_PBufWriteInt(savebuffer, fastparm ? 1 : 0); + /* [CG] nomonsters is > 1 in some demos */ + M_PBufWriteInt(savebuffer, nomonsters ? 1 : 0); M_PBufWriteInt(savebuffer, consoleplayer); } @@ -290,6 +302,24 @@ void D_Dump(pbuf_t *savebuffer) { // killough 11/98: save revenant tracer state M_PBufWriteInt(savebuffer, basetic); + for (int i = 0; i < VANILLA_MAXPLAYERS; i++) { + M_PBufWriteInt(savebuffer, playerstarts[i].x); + M_PBufWriteInt(savebuffer, playerstarts[i].y); + M_PBufWriteInt(savebuffer, playerstarts[i].angle); + M_PBufWriteInt(savebuffer, playerstarts[i].type); + M_PBufWriteInt(savebuffer, playerstarts[i].options); + } + + M_PBufWriteInt(savebuffer, deathmatch_p - deathmatchstarts); + + for (int i = 0; i < (deathmatch_p - deathmatchstarts); i++) { + M_PBufWriteInt(savebuffer, deathmatchstarts[i].x); + M_PBufWriteInt(savebuffer, deathmatchstarts[i].y); + M_PBufWriteInt(savebuffer, deathmatchstarts[i].angle); + M_PBufWriteInt(savebuffer, deathmatchstarts[i].type); + M_PBufWriteInt(savebuffer, deathmatchstarts[i].options); + } + /** RNG **/ M_PBufWriteInt(savebuffer, rng.rndindex); @@ -619,7 +649,7 @@ void D_Dump(pbuf_t *savebuffer) { M_PBufWriteInt(savebuffer, tc_ceiling); M_PBufWriteInt(savebuffer, ceiling->type); - dump_sector_index(savebuffer, ceiling->sector, __func__); + dump_sector_index(savebuffer, ceiling->sector, "ceiling"); M_PBufWriteInt(savebuffer, ceiling->bottomheight); M_PBufWriteInt(savebuffer, ceiling->topheight); M_PBufWriteInt(savebuffer, ceiling->speed); @@ -640,13 +670,13 @@ void D_Dump(pbuf_t *savebuffer) { M_PBufWriteInt(savebuffer, tc_door); M_PBufWriteInt(savebuffer, door->type); - dump_sector_index(savebuffer, door->sector, __func__); + dump_sector_index(savebuffer, door->sector, "verticaldoor"); M_PBufWriteInt(savebuffer, door->topheight); M_PBufWriteInt(savebuffer, door->speed); M_PBufWriteInt(savebuffer, door->direction); M_PBufWriteInt(savebuffer, door->topwait); M_PBufWriteInt(savebuffer, door->topcountdown); - dump_line_index(savebuffer, door->line, __func__); + dump_line_index(savebuffer, door->line, "verticaldoor"); M_PBufWriteInt(savebuffer, door->lighttag); continue; @@ -658,7 +688,7 @@ void D_Dump(pbuf_t *savebuffer) { M_PBufWriteInt(savebuffer, tc_floor); M_PBufWriteInt(savebuffer, floor->type); M_PBufWriteInt(savebuffer, floor->crush); - dump_sector_index(savebuffer, floor->sector, __func__); + dump_sector_index(savebuffer, floor->sector, "floor"); M_PBufWriteInt(savebuffer, floor->direction); M_PBufWriteInt(savebuffer, floor->newspecial); M_PBufWriteInt(savebuffer, floor->oldspecial); @@ -677,7 +707,7 @@ void D_Dump(pbuf_t *savebuffer) { plat = (plat_t *)th; M_PBufWriteInt(savebuffer, tc_plat); - dump_sector_index(savebuffer, plat->sector, __func__); + dump_sector_index(savebuffer, plat->sector, "plat"); M_PBufWriteInt(savebuffer, plat->speed); M_PBufWriteInt(savebuffer, plat->low); M_PBufWriteInt(savebuffer, plat->high); @@ -696,7 +726,7 @@ void D_Dump(pbuf_t *savebuffer) { lightflash_t *flash = (lightflash_t *)th; M_PBufWriteInt(savebuffer, tc_flash); - dump_sector_index(savebuffer, flash->sector, __func__); + dump_sector_index(savebuffer, flash->sector, "lightflash"); M_PBufWriteInt(savebuffer, flash->count); M_PBufWriteInt(savebuffer, flash->maxlight); M_PBufWriteInt(savebuffer, flash->minlight); @@ -710,7 +740,7 @@ void D_Dump(pbuf_t *savebuffer) { strobe_t *strobe = (strobe_t *)th; M_PBufWriteInt(savebuffer, tc_strobe); - dump_sector_index(savebuffer, strobe->sector, __func__); + dump_sector_index(savebuffer, strobe->sector, "strobeflash"); M_PBufWriteInt(savebuffer, strobe->count); M_PBufWriteInt(savebuffer, strobe->minlight); M_PBufWriteInt(savebuffer, strobe->maxlight); @@ -724,7 +754,7 @@ void D_Dump(pbuf_t *savebuffer) { glow_t *glow = (glow_t *)th; M_PBufWriteInt(savebuffer, tc_glow); - dump_sector_index(savebuffer, glow->sector, __func__); + dump_sector_index(savebuffer, glow->sector, "glow"); M_PBufWriteInt(savebuffer, glow->maxlight); M_PBufWriteInt(savebuffer, glow->minlight); M_PBufWriteInt(savebuffer, glow->direction); @@ -737,7 +767,7 @@ void D_Dump(pbuf_t *savebuffer) { fireflicker_t *flicker = (fireflicker_t *)th; M_PBufWriteInt(savebuffer, tc_flicker); - dump_sector_index(savebuffer, flicker->sector, __func__); + dump_sector_index(savebuffer, flicker->sector, "fireflicker"); M_PBufWriteInt(savebuffer, flicker->count); M_PBufWriteInt(savebuffer, flicker->maxlight); M_PBufWriteInt(savebuffer, flicker->minlight); @@ -751,7 +781,7 @@ void D_Dump(pbuf_t *savebuffer) { M_PBufWriteInt(savebuffer, tc_elevator); M_PBufWriteInt(savebuffer, elevator->type); - dump_sector_index(savebuffer, elevator->sector, __func__); + dump_sector_index(savebuffer, elevator->sector, "elevator"); M_PBufWriteInt(savebuffer, elevator->direction); M_PBufWriteInt(savebuffer, elevator->floordestheight); M_PBufWriteInt(savebuffer, elevator->ceilingdestheight); @@ -769,7 +799,17 @@ void D_Dump(pbuf_t *savebuffer) { M_PBufWriteInt(savebuffer, scroll->dy); M_PBufWriteInt(savebuffer, scroll->affectee); M_PBufWriteInt(savebuffer, scroll->control); - M_PBufWriteInt(savebuffer, scroll->last_height); + /* + * [CG] scroll->last_height is uninitialized in Add_Scroller if there is + * no control sector, so only dump this if there is a control + * sector. + */ + if (scroll->control == -1) { + M_PBufWriteInt(savebuffer, 0); + } + else { + M_PBufWriteInt(savebuffer, scroll->last_height); + } M_PBufWriteInt(savebuffer, scroll->vdx); M_PBufWriteInt(savebuffer, scroll->vdy); M_PBufWriteInt(savebuffer, scroll->accel); diff --git a/src/d_main.c b/src/d_main.c index 0ea35bf..f7ffdb4 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -937,23 +937,19 @@ void D_AddDEH(const char *filename, int lumpnum) { deh_file_t *dehfile; const char *deh_out = D_dehout(); - if (filename == NULL && lumpnum == 0) + if ((!filename) && lumpnum == 0) { I_Error("D_AddDEH: No filename or lumpnum given\n"); + } if (!filename) { - /* - if (lumpnum > numlumps) - I_Error("D_AddDEH: lumpnum out of range (%d/%d)\n", lumpnum, numlumps); - - deh_path = strdup(lumpinfo[lumpnum].name); - */ deh_path = NULL; } else { deh_path = I_FindFile(filename, NULL); - if (deh_path == NULL) + if (!deh_path) { I_Error("D_AddDEH: Couldn't find %s\n", filename); + } } for (unsigned int i = 0; i < deh_files->len; i++) { @@ -969,25 +965,33 @@ void D_AddDEH(const char *filename, int lumpnum) { continue; } + if (!stored_deh_file->filename) { + continue; + } + if (strcmp(deh_path, stored_deh_file->filename) == 0) { D_Msg(MSG_INFO, "D_AddDEH: Skipping %s (already added).\n", deh_path); return; } } - if (deh_path) + if (deh_path) { D_Msg(MSG_INFO, "D_AddDEH: Adding %s.\n", deh_path); + } dehfile = malloc(sizeof(deh_file_t)); - if (dehfile == NULL) + if (!dehfile) { I_Error("D_AddDEH: Error allocating DEH file info"); + } dehfile->filename = deh_path; - if (deh_out != NULL) + if (deh_out) { dehfile->outfilename = strdup(deh_out); - else + } + else { dehfile->outfilename = NULL; + } dehfile->lumpnum = lumpnum; g_ptr_array_add(deh_files, dehfile); @@ -2211,6 +2215,18 @@ static void D_DoomMainSetup(void) { } } + if (!CLIENT) { + for (unsigned int i = 0; i < deh_files->len; i++) { + deh_file_t *stored_deh_file = g_ptr_array_index(deh_files, i); + + ProcessDehFile( + stored_deh_file->filename, + stored_deh_file->outfilename, + stored_deh_file->lumpnum + ); + } + } + V_InitColorTranslation(); //jff 4/24/98 load color translation lumps // killough 2/22/98: copyright / "modified game" / SPA banners removed diff --git a/src/g_game.c b/src/g_game.c index c43b241..1a566cf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1594,7 +1594,7 @@ void G_PlayerReborn(int player) { p->extralight = 0; p->fixedcolormap = 0; p->colormap = 0; - memset(p->psprites, 0, sizeof(pspdef_t) * NUMPSPRITES); + memset(p->psprites, 0, sizeof(p->psprites)); p->didsecret = 0; p->momx = 0; p->momy = 0; @@ -1711,7 +1711,28 @@ static bool G_CheckSpot(int playernum, mapthing_t *mthing) { /* BUG: an can end up negative, because mthing->angle is (signed) short. * We have to emulate original Doom's behaviour, deferencing past the start * of the array, into the previous array (finetangent) */ - an = (ANG45 * ((signed int)mthing->angle / 45)) >> ANGLETOFINESHIFT; + + // an = (ANG45 * ((signed)mthing->angle / 45)) >> ANGLETOFINESHIFT; + + /* + * [CG] Shifting these signed values is implementation-defined, and it turns + * out that clang will (if so configured) will mess this up. + */ + + an = ANG45 * ((signed)mthing->angle / 45); + + switch (an) { + case 0x80000000: + case 0xA0000000: + case 0xC0000000: + case 0xE0000000: + an = -((-an) >> ANGLETOFINESHIFT); + break; + default: + an >>= ANGLETOFINESHIFT; + break; + } + xa = finecosine[an]; ya = finesine[an]; diff --git a/src/p_cmd.c b/src/p_cmd.c index 07cda85..3b4e145 100644 --- a/src/p_cmd.c +++ b/src/p_cmd.c @@ -40,6 +40,7 @@ #include "p_map.h" #include "p_mobj.h" #include "p_pspr.h" +#include "p_spec.h" #include "p_user.h" #include "s_sound.h" #include "sv_main.h" @@ -61,7 +62,7 @@ static void print_command(gpointer data, gpointer user_data) { } #endif -static void run_player_command(player_t *player) { +static bool run_player_command(player_t *player) { ticcmd_t *cmd = &player->cmd; weapontype_t newweapon; @@ -82,8 +83,10 @@ static void run_player_command(player_t *player) { player->mo->flags &= ~MF_JUSTATTACKED; } - if (player->playerstate == PST_DEAD) - return; + if (player->playerstate == PST_DEAD) { + P_DeathThink(player); + return false; + } if (player->jumpTics) player->jumpTics--; @@ -100,6 +103,11 @@ static void run_player_command(player_t *player) { P_CalcHeight(player); // Determines view height and bobbing + // Determine if there's anything about the sector you're in that's + // going to affect you, like painful floors. + if (player->mo->subsector->sector->special) + P_PlayerInSpecialSector(player); + // Check for weapon change. if (cmd->buttons & BT_CHANGE) { // The actual changing of the weapon is done @@ -158,6 +166,8 @@ static void run_player_command(player_t *player) { // cycle psprites P_MovePsprites(player); + + return true; } static void process_queued_command(gpointer data, gpointer user_data) { @@ -228,7 +238,7 @@ static void process_queued_command(gpointer data, gpointer user_data) { player->commands_run_this_tic++; - if (player->mo) + if (MULTINET && player->mo) P_MobjThinker(player->mo); N_LogPlayerPosition(player); @@ -617,20 +627,18 @@ void P_BuildCommand(void) { CL_MarkServerOutdated(); } -void P_RunPlayerCommands(int playernum) { +bool P_RunPlayerCommands(int playernum) { player_t *player = &players[playernum]; if (!MULTINET) { - run_player_command(player); - return; + return run_player_command(player); } if (CLIENT && playernum != consoleplayer && playernum != 0) { unsigned int command_count = P_GetCommandCount(playernum); if (command_count == 0) { - if (!extrapolate_player_position(playernum)) - return; + return extrapolate_player_position(playernum); } #if EXTRAPOLATION == COPIED_COMMAND else { @@ -646,6 +654,7 @@ void P_RunPlayerCommands(int playernum) { } run_queued_player_commands(playernum); + return player->playerstate != PST_DEAD; } void P_PrintCommands(int playernum) { diff --git a/src/p_cmd.h b/src/p_cmd.h index 309ad39..47a3615 100644 --- a/src/p_cmd.h +++ b/src/p_cmd.h @@ -41,7 +41,7 @@ void P_TrimCommands(int playernum, TrimFunc should_trim, void P_TrimCommandsByTic(int playernum, int tic); void P_TrimCommandsByIndex(int playernum, int command_index); void P_BuildCommand(void); -void P_RunPlayerCommands(int playernum); +bool P_RunPlayerCommands(int playernum); void P_PrintCommands(int playernum); #endif diff --git a/src/p_mobj.c b/src/p_mobj.c index 6e19924..29a36c1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1289,34 +1289,34 @@ mobj_t* P_SpawnMapThing (const mapthing_t* mthing, int index) // count deathmatch start positions // doom2.exe has at most 10 deathmatch starts - if (thingtype == 11) - { - if (!(!compatibility || deathmatch_p-deathmatchstarts < 10)) { - return NULL; - } else { - // 1/11/98 killough -- new code removes limit on deathmatch starts: + if (thingtype == 11) { + if (!(!compatibility || deathmatch_p - deathmatchstarts < 10)) { + return NULL; + } + else { + // 1/11/98 killough -- new code removes limit on deathmatch starts: - size_t offset = deathmatch_p - deathmatchstarts; + size_t offset = deathmatch_p - deathmatchstarts; - if (compatibility && deathmatch_p-deathmatchstarts >= 10) - return NULL; //e6y - if (offset >= num_deathmatchstarts) - { - num_deathmatchstarts = num_deathmatchstarts ? - num_deathmatchstarts*2 : 16; - deathmatchstarts = realloc(deathmatchstarts, - num_deathmatchstarts * - sizeof(*deathmatchstarts)); - deathmatch_p = deathmatchstarts + offset; + if (compatibility && deathmatch_p - deathmatchstarts >= 10) { + return NULL; //e6y } - memcpy(deathmatch_p++, mthing, sizeof(*mthing)); - (deathmatch_p-1)->options = 1; + if (offset >= num_deathmatchstarts) { + num_deathmatchstarts = num_deathmatchstarts ? num_deathmatchstarts * 2 : 16; + deathmatchstarts = realloc( + deathmatchstarts, num_deathmatchstarts * sizeof(*deathmatchstarts) + ); + deathmatch_p = deathmatchstarts + offset; + } + memcpy(deathmatch_p, mthing, sizeof(*mthing)); + deathmatch_p->options = 1; + deathmatch_p++; - TracerAddDeathmatchStart(deathmatch_p - deathmatchstarts - 1, index); + TracerAddDeathmatchStart(deathmatch_p - deathmatchstarts - 1, index); - return NULL; - } + return NULL; } + } // check for players specially diff --git a/src/p_pspr.c b/src/p_pspr.c index 9efaa95..a4953fc 100644 --- a/src/p_pspr.c +++ b/src/p_pspr.c @@ -82,32 +82,39 @@ static const int recoil_values[] = { // phares static void P_SetPsprite(player_t *player, int position, statenum_t stnum) { pspdef_t *psp = &player->psprites[position]; - do { - state_t *state; - - if (!stnum) { // object removed itself - psp->state = NULL; - break; - } + do + { + state_t *state; + + if (!stnum) + { + // object removed itself + psp->state = NULL; + break; + } - state = &states[stnum]; - psp->state = state; - psp->tics = state->tics; // could be 0 + state = &states[stnum]; + psp->state = state; + psp->tics = state->tics; // could be 0 - if (state->misc1) { // coordinate set - psp->sx = state->misc1 << FRACBITS; - psp->sy = state->misc2 << FRACBITS; - } + if (state->misc1) + { + // coordinate set + psp->sx = state->misc1 << FRACBITS; + psp->sy = state->misc2 << FRACBITS; + } - // Call action routine. - // Modified handling. - if (state->action) { - state->action(player, psp); - if (!psp->state) - break; + // Call action routine. + // Modified handling. + if (state->action) + { + state->action(player, psp); + if (!psp->state) + break; + } + stnum = psp->state->nextstate; } - stnum = psp->state->nextstate; - } while (!psp->tics); // an initial state of 0 could cycle through + while (!psp->tics); // an initial state of 0 could cycle through } // diff --git a/src/p_saveg.c b/src/p_saveg.c index 9f715a9..c8039c0 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1616,7 +1616,7 @@ void P_ArchiveCeiling(pbuf_t *savebuffer, ceiling_t *ceiling) { M_PBufWriteInt(savebuffer, ceiling->topheight); M_PBufWriteInt(savebuffer, ceiling->speed); M_PBufWriteInt(savebuffer, ceiling->oldspeed); - M_PBufWriteBool(savebuffer, ceiling->crush); + M_PBufWriteInt(savebuffer, ceiling->crush); M_PBufWriteInt(savebuffer, ceiling->newspecial); M_PBufWriteInt(savebuffer, ceiling->oldspecial); M_PBufWriteShort(savebuffer, ceiling->texture); @@ -1632,7 +1632,7 @@ void P_UnArchiveCeiling(pbuf_t *savebuffer, ceiling_t *ceiling) { M_PBufReadInt(savebuffer, &ceiling->topheight); M_PBufReadInt(savebuffer, &ceiling->speed); M_PBufReadInt(savebuffer, &ceiling->oldspeed); - M_PBufReadBool(savebuffer, &ceiling->crush); + M_PBufReadInt(savebuffer, &ceiling->crush); M_PBufReadInt(savebuffer, &ceiling->newspecial); M_PBufReadInt(savebuffer, &ceiling->oldspecial); M_PBufReadShort(savebuffer, &ceiling->texture); @@ -1667,7 +1667,7 @@ void P_UnArchiveDoor(pbuf_t *savebuffer, vldoor_t *door) { void P_ArchiveFloor(pbuf_t *savebuffer, floormove_t *floor) { M_PBufWriteInt(savebuffer, floor->type); - M_PBufWriteBool(savebuffer, floor->crush); + M_PBufWriteInt(savebuffer, floor->crush); P_ArchiveSectorIndex(savebuffer, floor->sector, __func__); M_PBufWriteInt(savebuffer, floor->direction); M_PBufWriteInt(savebuffer, floor->newspecial); @@ -1679,7 +1679,7 @@ void P_ArchiveFloor(pbuf_t *savebuffer, floormove_t *floor) { void P_UnArchiveFloor(pbuf_t *savebuffer, floormove_t *floor) { M_PBufReadInt(savebuffer, (int *)&floor->type); - M_PBufReadBool(savebuffer, &floor->crush); + M_PBufReadInt(savebuffer, &floor->crush); P_UnArchiveSectorIndex(savebuffer, &floor->sector, __func__); M_PBufReadInt(savebuffer, &floor->direction); M_PBufReadInt(savebuffer, &floor->newspecial); @@ -1698,7 +1698,7 @@ void P_ArchivePlat(pbuf_t *savebuffer, plat_t *plat) { M_PBufWriteInt(savebuffer, plat->count); M_PBufWriteInt(savebuffer, plat->status); M_PBufWriteInt(savebuffer, plat->oldstatus); - M_PBufWriteBool(savebuffer, plat->crush); + M_PBufWriteInt(savebuffer, plat->crush); M_PBufWriteInt(savebuffer, plat->tag); M_PBufWriteInt(savebuffer, plat->type); } @@ -1712,7 +1712,7 @@ void P_UnArchivePlat(pbuf_t *savebuffer, plat_t *plat) { M_PBufReadInt(savebuffer, &plat->count); M_PBufReadInt(savebuffer, (int *)&plat->status); M_PBufReadInt(savebuffer, (int *)&plat->oldstatus); - M_PBufReadBool(savebuffer, &plat->crush); + M_PBufReadInt(savebuffer, &plat->crush); M_PBufReadInt(savebuffer, &plat->tag); M_PBufReadInt(savebuffer, (int *)&plat->type); } diff --git a/src/p_spec.h b/src/p_spec.h index da9f249..9eff682 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -628,7 +628,7 @@ typedef struct int count; plat_e status; plat_e oldstatus; - bool crush; + int crush; int tag; plattype_e type; @@ -679,7 +679,7 @@ typedef struct fixed_t topheight; fixed_t speed; fixed_t oldspeed; - bool crush; + int crush; //jff 02/04/98 add these to support ceiling changers int newspecial; @@ -706,7 +706,7 @@ typedef struct { thinker_t thinker; floor_e type; - bool crush; + int crush; sector_t* sector; int direction; int newspecial; diff --git a/src/p_user.c b/src/p_user.c index 398f8e5..43f26fd 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -467,17 +467,15 @@ void P_PlayerThink(int playernum) { else player->mo->flags &= ~MF_NOCLIP; - P_RunPlayerCommands(playernum); + if (!P_RunPlayerCommands(playernum)) { + return; + } + /* if (player->playerstate == PST_DEAD) { - P_DeathThink(player); return; } - - // Determine if there's anything about the sector you're in that's - // going to affect you, like painful floors. - if (player->mo->subsector->sector->special) - P_PlayerInSpecialSector(player); + */ // Counters, time dependent power ups. diff --git a/src/s_sndnew.c b/src/s_sndnew.c index 266488c..0c27e23 100644 --- a/src/s_sndnew.c +++ b/src/s_sndnew.c @@ -266,7 +266,7 @@ static bool already_played(mobj_t *origin, sfxinfo_t *sfx, bool is_pickup) { ); log_played_sound(sound); - D_Msg(MSG_SOUND, "\n"); + D_Msg(MSG_SOUND, "(%d) \n", CL_OccurredDuringRePrediction(sound->tic)); if (sound->origin_id == 0 && origin != NULL) continue; @@ -314,8 +314,9 @@ static int get_channel(mobj_t *mobj, sfxinfo_t *sfxinfo, int is_pickup) { D_Msg(MSG_SOUND, "(%d) %s: calling stop_channel (1)\n", gametic, __func__ ); - log_channel(i); + D_Msg(MSG_SOUND, "\n"); + stop_channel(c); init_channel(c, mobj, sfxinfo, is_pickup); @@ -340,8 +341,9 @@ static int get_channel(mobj_t *mobj, sfxinfo_t *sfxinfo, int is_pickup) { D_Msg(MSG_SOUND, "(%d) %s: calling stop_channel (1)\n", gametic, __func__ ); - log_channel(i); + D_Msg(MSG_SOUND, "\n"); + stop_channel(c); init_channel(c, mobj, sfxinfo, is_pickup); @@ -357,8 +359,9 @@ static int get_channel(mobj_t *mobj, sfxinfo_t *sfxinfo, int is_pickup) { D_Msg(MSG_SOUND, "(%d) %s: calling stop_channel (2)\n", gametic, __func__ ); - log_channel(i); + D_Msg(MSG_SOUND, "\n"); + stop_channel(c); init_channel(c, mobj, sfxinfo, is_pickup); @@ -534,8 +537,9 @@ static void start_sound(mobj_t *origin, int sfx_id, int volume) { continue; D_Msg(MSG_SOUND, "(%d) %s: calling stop_channel\n", gametic, __func__); - log_channel(i); + D_Msg(MSG_SOUND, "\n"); + stop_channel(channel); break; @@ -557,9 +561,16 @@ static void start_sound(mobj_t *origin, int sfx_id, int volume) { if (sfx->usefulness++ < 0) sfx->usefulness = 1; - D_Msg(MSG_SOUND, "(%d | %d) Starting sound: ", - gametic, CL_GetCurrentCommandIndex() - ); + if (CL_RePredicting()) { + D_Msg(MSG_SOUND, "||| (%d | %d) Repredicting sound: ", + gametic, CL_GetCurrentCommandIndex() + ); + } + else { + D_Msg(MSG_SOUND, "||| (%d | %d) Starting sound: ", + gametic, CL_GetCurrentCommandIndex() + ); + } log_channel(cnum); D_Msg(MSG_SOUND, "\n"); @@ -591,8 +602,12 @@ static void silence_actor(mobj_t *mobj) { channel_t *channel = &g_array_index(channels, channel_t, i); if (channel->sfxinfo && channel->origin_id == mobj->id) { - D_Msg(MSG_SOUND, "(%d) %s: calling stop_channel\n", gametic, __func__); + D_Msg(MSG_SOUND, "(%d) (silencing actor %u) %s: calling stop_channel\n", + gametic, mobj->id, __func__ + ); log_channel(i); + D_Msg(MSG_SOUND, "\n"); + stop_channel(channel); break; } @@ -606,6 +621,8 @@ static void stop_sounds(void) { if (channel->sfxinfo) { D_Msg(MSG_SOUND, "(%d) %s: calling stop_channel\n", gametic, __func__); log_channel(i); + D_Msg(MSG_SOUND, "\n"); + stop_channel(channel); } } @@ -803,6 +820,8 @@ static void reposition_sounds(mobj_t *listener) { gametic, __func__ ); log_channel(i); + D_Msg(MSG_SOUND, "\n"); + stop_channel(channel); continue; } @@ -820,6 +839,8 @@ static void reposition_sounds(mobj_t *listener) { gametic, __func__ ); log_channel(i); + D_Msg(MSG_SOUND, "\n"); + stop_channel(channel); continue; } @@ -841,6 +862,8 @@ static void reposition_sounds(mobj_t *listener) { gametic, __func__ ); log_channel(i); + D_Msg(MSG_SOUND, "\n"); + stop_channel(channel); } else { diff --git a/src/s_sound.c b/src/s_sound.c index 4689e7d..66aa8a5 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -31,7 +31,7 @@ #include "sounds.h" #include "s_sound.h" -#define DEBUG_SOUND 0 +#define DEBUG_SOUND 1 static int saved_sfx_volume; @@ -58,12 +58,12 @@ void S_Init(int sfxVolume, int musicVolume) { int i; #if DEBUG_SOUND - if (!MULTINET) - D_EnableLogChannel(LOG_SOUND, "sound.log"); - else if (CLIENT) - D_EnableLogChannel(LOG_SOUND, "client-sound.log"); + if (CLIENT) + D_MsgActivateWithFile(MSG_SOUND, "client-sound.log"); else if (SERVER) - D_EnableLogChannel(LOG_SOUND, "server-sound.log"); + D_MsgActivateWithFile(MSG_SOUND, "server-sound.log"); + else + D_MsgActivateWithFile(MSG_SOUND, "sound.log"); #endif idmusnum = -1; //jff 3/17/98 insure idmus number is blank