From ee191f068101a97f4d1528b2521b169f724df484 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Sun, 1 Mar 2020 16:33:06 +0100
Subject: [PATCH] - SW: map cheat partially reimplemented.

---
 source/sw/src/cheats.cpp |  4 +++-
 source/sw/src/game.cpp   | 16 ++++++++++------
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/source/sw/src/cheats.cpp b/source/sw/src/cheats.cpp
index 39aa46aab..9bf9e1c40 100644
--- a/source/sw/src/cheats.cpp
+++ b/source/sw/src/cheats.cpp
@@ -52,6 +52,7 @@ BEGIN_SW_NS
 SWBOOL CheatInputMode = FALSE;
 SWBOOL EveryCheat = FALSE;
 SWBOOL ResCheat = FALSE;
+SWBOOL mapcheat = false;
 
 const char *CheatKeyType;
 void KeysCheat(PLAYERp pp, const char *cheat_string);
@@ -96,8 +97,9 @@ void PrevCheat(PLAYERp pp, const char *)
 
 void MapCheat(PLAYERp pp, const char *)
 {
+    mapcheat = !mapcheat;
     // Need to do this differently. The code here was completely broken.
-    PutStringInfo(pp, GStrings(automapping ? "TXT_AMON" : "TXT_AMOFF"));
+    PutStringInfo(pp, GStrings(mapcheat ? "TXT_AMON" : "TXT_AMOFF"));
 }
 
 void LocCheat(PLAYERp pp, const char *)
diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp
index 19a29cc27..1bdb863c8 100644
--- a/source/sw/src/game.cpp
+++ b/source/sw/src/game.cpp
@@ -111,6 +111,7 @@ signed char MNU_InputSmallString(char*, short);
 signed char MNU_InputString(char*, short);
 SWBOOL IsCommand(const char* str);
 SWBOOL MNU_StartNetGame(void);
+extern SWBOOL mapcheat;
 
 extern SWBOOL MultiPlayQuitFlag;
 
@@ -3558,10 +3559,13 @@ void drawoverheadmap(int cposx, int cposy, int czoom, short cang)
             if ((unsigned)k >= MAXWALLS)
                 continue;
 
-            if ((show2dwall[j >> 3] & (1 << (j & 7))) == 0)
-                continue;
-            if ((k > j) && ((show2dwall[k >> 3] & (1 << (k & 7))) > 0))
-                continue;
+            if (!mapcheat)
+            {
+                if ((show2dwall[j >> 3] & (1 << (j & 7))) == 0)
+                    continue;
+                if ((k > j) && ((show2dwall[k >> 3] & (1 << (k & 7))) > 0))
+                    continue;
+            }
 
             if (sector[wal->nextsector].ceilingz == z1)
                 if (sector[wal->nextsector].floorz == z2)
@@ -3616,7 +3620,7 @@ void drawoverheadmap(int cposx, int cposy, int czoom, short cang)
                     goto SHOWSPRITE;
                 }
             }
-            if ((show2dsprite[j >> 3] & (1 << (j & 7))) > 0)
+            if (mapcheat || (show2dsprite[j >> 3] & (1 << (j & 7))) > 0)
             {
 SHOWSPRITE:
                 spr = &sprite[j];
@@ -3811,7 +3815,7 @@ SHOWSPRITE:
             if ((uint16_t)wal->nextwall < MAXWALLS)
                 continue;
 
-            if ((show2dwall[j >> 3] & (1 << (j & 7))) == 0)
+            if (!mapcheat && (show2dwall[j >> 3] & (1 << (j & 7))) == 0)
                 continue;
 
             if (tilesiz[wal->picnum].x == 0)