From 4be6d58b82423ac7e521288344f9f4bca3d4bb91 Mon Sep 17 00:00:00 2001 From: Info Teddy Date: Thu, 30 Jan 2020 19:06:16 -0800 Subject: [PATCH] Reset warp directions when exiting playtesting This fixes a bug where if warpdir() was used during in-editor playtesting, the changed warp direction would persist even when leaving playtesting. This would be very annoying to correct back every time you playtested and warpdir() was used, so I've added some kludge to store the actual warp direction of each room when entering playtesting, and then set the warp directions back when leaving playtesting. --- desktop_version/src/Input.cpp | 8 ++++++++ desktop_version/src/Script.cpp | 8 ++++++++ desktop_version/src/editor.cpp | 1 + desktop_version/src/editor.h | 1 + 4 files changed, 18 insertions(+) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index e4bf705f..83717357 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -1913,6 +1913,14 @@ void gameinput(KeyPoll& key, Graphics& dwgfx, Game& game, mapclass& map, dwgfx.backgrounddrawn=false; music.fadeout(); + //If warpdir() is used during playtesting, we need to set it back after! + for (int j = 0; j < ed.maxheight; j++) + { + for (int i = 0; i < ed.maxwidth; i++) + { + ed.level[i+(j*ed.maxwidth)].warpdir=ed.kludgewarpdir[i+(j*ed.maxwidth)]; + } + } } } } diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 5a09c8fd..5e7f826c 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -3181,6 +3181,14 @@ void scriptclass::startgamemode( int t, KeyPoll& key, Graphics& dwgfx, Game& gam game.gamestate = GAMEMODE; music.fadeout(); hardreset(key, dwgfx, game, map, obj, help, music); + //If warpdir() is used during playtesting, we need to set it back after! + for (int j = 0; j < ed.maxheight; j++) + { + for (int i = 0; i < ed.maxwidth; i++) + { + ed.kludgewarpdir[i+(j*ed.maxwidth)]=ed.level[i+(j*ed.maxwidth)].warpdir; + } + } game.customstart(obj, music); game.jumpheld = true; diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index b591bc4a..b5c3774f 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -309,6 +309,7 @@ void editorclass::reset() level[i+(j*maxwidth)].enemyy2=240; level[i+(j*maxwidth)].enemytype=0; level[i+(j*maxwidth)].directmode=0; + kludgewarpdir[i+(j*maxwidth)]=0; } } diff --git a/desktop_version/src/editor.h b/desktop_version/src/editor.h index 51a7c85f..f28709e9 100644 --- a/desktop_version/src/editor.h +++ b/desktop_version/src/editor.h @@ -158,6 +158,7 @@ class editorclass{ int numtrinkets; int numcrewmates; edlevelclass level[400]; //Maxwidth*maxheight + int kludgewarpdir[400]; //Also maxwidth*maxheight int temp; int notedelay;