shithub: cstory

Download patch

ref: c838e8ebcb81ef81412ca2832f6ceff0b65972fb
parent: b5ad6f51545ffc49dfafd4df613debd37efdaa9f
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Jan 6 14:16:57 EST 2020

Add and apply the enum_ESCRETURN enum

Restored from the original source code, as it survived in the Linux
port's debug data.

--- a/src/ArmsItem.cpp
+++ b/src/ArmsItem.cpp
@@ -446,10 +446,11 @@
 		{
 			switch (Call_Escape(ghWnd))
 			{
-				case 0:
-					return 0;	// Quit game
-				case 2:
-					return 2;	// Go to game intro
+				case enum_ESCRETURN_exit:
+					return enum_ESCRETURN_exit;	// Quit game
+
+				case enum_ESCRETURN_restart:
+					return enum_ESCRETURN_restart;	// Go to game intro
 			}
 		}
 
@@ -458,10 +459,11 @@
 
 		switch (TextScriptProc())
 		{
-			case 0:
-				return 0;	// Quit game
-			case 2:
-				return 2;	// Go to game intro
+			case enum_ESCRETURN_exit:
+				return enum_ESCRETURN_exit;	// Quit game
+
+			case enum_ESCRETURN_restart:
+				return enum_ESCRETURN_restart;	// Go to game intro
 		}
 
 		// Get currently displayed image
@@ -489,13 +491,13 @@
 		}
 
 		if (!Flip_SystemTask(ghWnd))
-			return 0;	// Quit game
+			return enum_ESCRETURN_exit;	// Quit game
 	}
 
 	// Resume original script
 	LoadTextScript_Stage(old_script_path);
 	gArmsEnergyX = 32; // Displays weapon rotation animation in case the weapon was changed
-	return 1;	// Go to game
+	return enum_ESCRETURN_continue;	// Go to game
 }
 
 BOOL CheckItem(long a)
--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -466,10 +466,11 @@
 		{
 			switch (Call_Escape(hWnd))
 			{
-				case 0:
-					return 0;
-				case 2:
-					return 2;
+				case enum_ESCRETURN_exit:
+					return enum_ESCRETURN_exit;
+
+				case enum_ESCRETURN_restart:
+					return enum_ESCRETURN_restart;
 			}
 		}
 
@@ -515,8 +516,8 @@
 		// Draw window
 		PutFramePerSecound();
 		if (!Flip_SystemTask(hWnd))
-			return 0;
+			return enum_ESCRETURN_exit;
 	}
 
-	return 1;
+	return enum_ESCRETURN_continue;
 }
--- a/src/Escape.cpp
+++ b/src/Escape.cpp
@@ -19,17 +19,17 @@
 		if (gKeyTrg & KEY_ESCAPE) // Escape is pressed, quit game
 		{
 			gKeyTrg = 0;
-			return 0;
+			return enum_ESCRETURN_exit;
 		}
 		if (gKeyTrg & KEY_F1) // F1 is pressed, continue
 		{
 			gKeyTrg = 0;
-			return 1;
+			return enum_ESCRETURN_continue;
 		}
 		if (gKeyTrg & KEY_F2) // F2 is pressed, reset
 		{
 			gKeyTrg = 0;
-			return 2;
+			return enum_ESCRETURN_restart;
 		}
 
 		// Draw screen
@@ -41,9 +41,9 @@
 		{
 			// Quit if window is closed
 			gKeyTrg = 0;
-			return 0;
+			return enum_ESCRETURN_exit;
 		}
 	}
 
-	return 0;
+	return enum_ESCRETURN_exit;
 }
--- a/src/Escape.h
+++ b/src/Escape.h
@@ -2,4 +2,11 @@
 
 #include "WindowsWrapper.h"
 
+enum enum_ESCRETURN
+{
+	enum_ESCRETURN_exit,
+	enum_ESCRETURN_continue,
+	enum_ESCRETURN_restart
+};
+
 int Call_Escape(HWND hWnd);
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -152,9 +152,10 @@
 		{
 			switch (Call_Escape(ghWnd))
 			{
-				case 0:
+				case enum_ESCRETURN_exit:
 					return 0;
-				case 2:
+
+				case enum_ESCRETURN_restart:
 					return 1;
 			}
 		}
@@ -195,9 +196,10 @@
 		// Update Text Script
 		switch (TextScriptProc())
 		{
-			case 0:
+			case enum_ESCRETURN_exit:
 				return 0;
-			case 2:
+
+			case enum_ESCRETURN_restart:
 				return 1;
 		}
 
@@ -362,9 +364,10 @@
 		{
 			switch (Call_Escape(ghWnd))
 			{
-				case 0:
+				case enum_ESCRETURN_exit:
 					return 0;
-				case 2:
+
+				case enum_ESCRETURN_restart:
 					return 1;
 			}
 		}
@@ -525,9 +528,10 @@
 		{
 			switch (Call_Escape(ghWnd))
 			{
-				case 0:
+				case enum_ESCRETURN_exit:
 					return 0;
-				case 2:
+
+				case enum_ESCRETURN_restart:
 					return 1;
 			}
 		}
@@ -605,9 +609,10 @@
 
 				switch (CampLoop())
 				{
-					case 0:
+					case enum_ESCRETURN_exit:
 						return 0;
-					case 2:
+
+					case enum_ESCRETURN_restart:
 						return 1;
 				}
 
@@ -619,9 +624,10 @@
 
 				switch (MiniMapLoop())
 				{
-					case 0:
+					case enum_ESCRETURN_exit:
 						return 0;
-					case 2:
+
+					case enum_ESCRETURN_restart:
 						return 1;
 				}
 			}
@@ -639,9 +645,10 @@
 		{
 			switch (TextScriptProc())
 			{
-				case 0:
+				case enum_ESCRETURN_exit:
 					return 0;
-				case 2:
+
+				case enum_ESCRETURN_restart:
 					return 1;
 			}
 		}
--- a/src/MiniMap.cpp
+++ b/src/MiniMap.cpp
@@ -96,10 +96,11 @@
 		{
 			switch (Call_Escape(ghWnd))
 			{
-				case 0:
-					return 0;
-				case 2:
-					return 2;
+				case enum_ESCRETURN_exit:
+					return enum_ESCRETURN_exit;
+
+				case enum_ESCRETURN_restart:
+					return enum_ESCRETURN_restart;
 			}
 		}
 
@@ -115,7 +116,7 @@
 
 		PutFramePerSecound();
 		if (!Flip_SystemTask(ghWnd))
-			return 0;
+			return enum_ESCRETURN_exit;
 	}
 
 	rcMiniMap.left = 0;
@@ -140,10 +141,11 @@
 		{
 			switch (Call_Escape(ghWnd))
 			{
-				case 0:
-					return 0;
-				case 2:
-					return 2;
+				case enum_ESCRETURN_exit:
+					return enum_ESCRETURN_exit;
+
+				case enum_ESCRETURN_restart:
+					return enum_ESCRETURN_restart;
 			}
 		}
 
@@ -172,7 +174,7 @@
 
 		PutFramePerSecound();
 		if (!Flip_SystemTask(ghWnd))
-			return 0;
+			return enum_ESCRETURN_exit;
 	}
 
 	for (f = 8; f >= -1; --f)
@@ -183,10 +185,11 @@
 		{
 			switch (Call_Escape(ghWnd))
 			{
-				case 0:
-					return 0;
-				case 2:
-					return 2;
+				case enum_ESCRETURN_exit:
+					return enum_ESCRETURN_exit;
+
+				case enum_ESCRETURN_restart:
+					return enum_ESCRETURN_restart;
 			}
 		}
 
@@ -202,10 +205,10 @@
 
 		PutFramePerSecound();
 		if (!Flip_SystemTask(ghWnd))
-			return 0;
+			return enum_ESCRETURN_exit;
 	}
 
-	return 1;
+	return enum_ESCRETURN_continue;
 }
 
 BOOL IsMapping(void)
--- a/src/SelStage.cpp
+++ b/src/SelStage.cpp
@@ -174,10 +174,11 @@
 		{
 			switch (Call_Escape(ghWnd))
 			{
-				case 0:
-					return 0;
-				case 2:
-					return 2;
+				case enum_ESCRETURN_exit:
+					return enum_ESCRETURN_exit;
+
+				case enum_ESCRETURN_restart:
+					return enum_ESCRETURN_restart;
 			}
 		}
 
@@ -185,10 +186,11 @@
 
 		switch (TextScriptProc())
 		{
-			case 0:
-				return 0;
-			case 2:
-				return 2;
+			case enum_ESCRETURN_exit:
+				return enum_ESCRETURN_exit;
+
+			case enum_ESCRETURN_restart:
+				return enum_ESCRETURN_restart;
 		}
 
 #ifdef FIX_BUGS
@@ -210,16 +212,16 @@
 			StopTextScript();
 			LoadTextScript_Stage(old_script_path);
 			*p_event = 0;
-			return 1;
+			return enum_ESCRETURN_continue;
 		}
 
 		PutFramePerSecound();
 
 		if (!Flip_SystemTask(ghWnd))
-			return 0;
+			return enum_ESCRETURN_exit;
 	}
 
 	LoadTextScript_Stage(old_script_path);
 	*p_event = gPermitStage[gSelectedStage].event;
-	return 1;
+	return enum_ESCRETURN_continue;
 }
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -12,6 +12,7 @@
 #include "CommonDefines.h"
 #include "Draw.h"
 #include "Ending.h"
+#include "Escape.h"
 #include "Fade.h"
 #include "Flags.h"
 #include "Flash.h"
@@ -719,7 +720,7 @@
 						if (!TransferStage(z, w, x, y))
 						{
 							MessageBoxA(ghWnd, "\x83\x58\x83\x65\x81\x5B\x83\x57\x82\xCC\x93\xC7\x82\xDD\x8D\x9E\x82\xDD\x82\xC9\x8E\xB8\x94\x73", "\x83\x47\x83\x89\x81\x5B", MB_OK);	// 'ステージの読み込みに失敗' and 'エラー' ('Failed to load stage' and 'Error') in Shift-JIS
-							return 0;
+							return enum_ESCRETURN_exit;
 						}
 					}
 					else if (IS_COMMAND('M','O','V'))
@@ -1054,10 +1055,11 @@
 
 						switch (MiniMapLoop())
 						{
-							case 0:
-								return 0;
-							case 2:
-								return 2;
+							case enum_ESCRETURN_exit:
+								return enum_ESCRETURN_exit;
+
+							case enum_ESCRETURN_restart:
+								return enum_ESCRETURN_restart;
 						}
 					}
 					else if (IS_COMMAND('S','L','P'))
@@ -1066,10 +1068,11 @@
 
 						switch (StageSelectLoop(&z))
 						{
-							case 0:
-								return 0;
-							case 2:
-								return 2;
+							case enum_ESCRETURN_exit:
+								return enum_ESCRETURN_exit;
+
+							case enum_ESCRETURN_restart:
+								return enum_ESCRETURN_restart;
 						}
 
 						JumpTextScript(z);
@@ -1251,10 +1254,11 @@
 
 						switch (Scene_DownIsland(ghWnd, z))
 						{
-							case 0:
-								return 0;
-							case 2:
-								return 2;
+							case enum_ESCRETURN_exit:
+								return enum_ESCRETURN_exit;
+
+							case enum_ESCRETURN_restart:
+								return enum_ESCRETURN_restart;
 						}
 
 						gTS.p_read += 8;
@@ -1261,7 +1265,7 @@
 					}
 					else if (IS_COMMAND('E','S','C'))
 					{
-						return 2;
+						return enum_ESCRETURN_restart;
 					}
 					else
 					{
@@ -1268,7 +1272,7 @@
 						char str_0[0x40];
 						sprintf(str_0, "\x95\x73\x96\xBE\x82\xCC\x83\x52\x81\x5B\x83\x68:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);	// '不明のコード:<%c%c%c' (Unknown code:<%c%c%c) in Shift-JIS
 						MessageBoxA(NULL, str_0, "\x83\x47\x83\x89\x81\x5B", MB_OK);	// 'エラー' (Error) in Shift-JIS
-						return 0;
+						return enum_ESCRETURN_exit;
 					}
 				}
 				else
@@ -1468,7 +1472,7 @@
 	else
 		g_GameFlags |= 4;
 
-	return 1;
+	return enum_ESCRETURN_continue;
 }
 
 void RestoreTextScript(void)