From d677ba383780c340fc4cf218b18b269bcfeba061 Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 5 Sep 2020 20:02:27 -0700 Subject: [PATCH] Remove checks to prevent having both warp lines/BGs in editor It's perfectly acceptable to have both warp lines and a warping background in the same room. Many levels do this exact thing, I would say at least 30 or so levels, many of them popular and played by many, and this has never caused any issues at all. All that having both warp lines and warp BG does is make it so the warping of the warping background gets overriden by the warp lines, but make it so the background is still a warp background. So in effect, you can have a warp background without any warping. This is perfectly defined behavior. Except, for whatever reason, it's unintentional, and the editor tries to prevent you from doing it. Key word being "tries". The code to prevent having both warp types is bugged (at least when you change the warp BG. The check when you place warp lines seems to be solid). It compares the p1 and p2 attributes of warp lines to the x-coordinate and y-coordinate of the room, despite p1 and p2 having nothing to do with room coordinates. p1 is the type of the warp line and should be treated as an enum, and p2 is the offset of the warp line from the top/left of the screen. This results in this check sometimes working if you're unlucky, but never actually working properly most of the time. This means people can first place warp lines, and then change the warp background later, to have both warp lines and a warp background. Having these checks just further complicates the code, makes it more error-prone, and just inconveniences people when they want to do something that's perfectly fine to do. So it's best if we just remove these checks. --- desktop_version/src/editor.cpp | 99 ++++++++++++---------------------- 1 file changed, 35 insertions(+), 64 deletions(-) diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index 84d5087e..991e34da 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -4572,51 +4572,30 @@ void editorinput() if(key.keymap[SDLK_w]) { - int j=0, tx=0, ty=0; - for(size_t i=0; i0) - { - ed.note="ERROR: Cannot have both warp types"; + ed.note="Room warping disabled"; ed.notedelay=45; + graphics.backgrounddrawn=false; } - else + else if(ed.level[ed.levx+(ed.levy*ed.maxwidth)].warpdir==1) { - ed.level[ed.levx+(ed.levy*ed.maxwidth)].warpdir=(ed.level[ed.levx+(ed.levy*ed.maxwidth)].warpdir+1)%4; - if(ed.level[ed.levx+(ed.levy*ed.maxwidth)].warpdir==0) - { - ed.note="Room warping disabled"; - ed.notedelay=45; - graphics.backgrounddrawn=false; - } - else if(ed.level[ed.levx+(ed.levy*ed.maxwidth)].warpdir==1) - { - ed.note="Room warps horizontally"; - ed.notedelay=45; - graphics.backgrounddrawn=false; - } - else if(ed.level[ed.levx+(ed.levy*ed.maxwidth)].warpdir==2) - { - ed.note="Room warps vertically"; - ed.notedelay=45; - graphics.backgrounddrawn=false; - } - else if(ed.level[ed.levx+(ed.levy*ed.maxwidth)].warpdir==3) - { - ed.note="Room warps in all directions"; - ed.notedelay=45; - graphics.backgrounddrawn=false; - } + ed.note="Room warps horizontally"; + ed.notedelay=45; + graphics.backgrounddrawn=false; + } + else if(ed.level[ed.levx+(ed.levy*ed.maxwidth)].warpdir==2) + { + ed.note="Room warps vertically"; + ed.notedelay=45; + graphics.backgrounddrawn=false; + } + else if(ed.level[ed.levx+(ed.levy*ed.maxwidth)].warpdir==3) + { + ed.note="Room warps in all directions"; + ed.notedelay=45; + graphics.backgrounddrawn=false; } ed.keydelay=6; } @@ -5198,33 +5177,25 @@ void editorinput() else if(ed.drawmode==14) { //Warp lines - if(ed.level[ed.levx+(ed.maxwidth*ed.levy)].warpdir==0) + if(ed.tilex==0) { - if(ed.tilex==0) - { - addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,0); - } - else if(ed.tilex==39) - { - addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,1); - } - else if(ed.tiley==0) - { - addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,2); - } - else if(ed.tiley==29) - { - addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,3); - } - else - { - ed.note="ERROR: Warp lines must be on edges"; - ed.notedelay=45; - } + addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,0); + } + else if(ed.tilex==39) + { + addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,1); + } + else if(ed.tiley==0) + { + addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,2); + } + else if(ed.tiley==29) + { + addedentity(ed.tilex+ (ed.levx*40),ed.tiley+ (ed.levy*30),50,3); } else { - ed.note="ERROR: Cannot have both warp types"; + ed.note="ERROR: Warp lines must be on edges"; ed.notedelay=45; } ed.lclickdelay=1;