shithub: cstory

Download patch

ref: 0c245b995f3702ace7d7c3f3be56097176d89278
parent: 02f6972ef863078b07ccbec59a64406bab2aaf21
author: Clownacy <Clownacy@users.noreply.github.com>
date: Fri Nov 15 07:56:47 EST 2019

Clean-up MapName.cpp

--- a/src/MapName.cpp
+++ b/src/MapName.cpp
@@ -6,6 +6,13 @@
 #include "Draw.h"
 #include "WindowsWrapper.h"
 
+typedef struct MAP_NAME
+{
+	BOOL flag;
+	int wait;
+	char name[0x20];
+} MAP_NAME;
+
 MAP_NAME gMapName;
 RECT rc = { 0, 0, 160, 12 };
 
@@ -67,7 +74,7 @@
 	};
 
 	// Reset map name flags
-	gMapName.flag = 0;
+	gMapName.flag = FALSE;
 	gMapName.wait = 0;
 
 	if (!strcmp(str, "u"))
@@ -84,13 +91,13 @@
 	// Draw the text to the surface
 	a = (int)strlen(gMapName.name);
 	CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
-	PutText2((160 - 6 * a) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
-	PutText2((160 - 6 * a) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
+	PutText2(((160 - (a * 6)) / 2) + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
+	PutText2(((160 - (a * 6)) / 2) + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
 }
 
 void PutMapName(BOOL bMini)
 {
-	// 'unused_rect' isn't the original name. The Linux port optimised this out, so there's no name for it.
+	// 'unused_rect' isn't the original name. The Linux port optimised this out, so there's no known name for it.
 	RECT unused_rect = {0, 0, 160, 16};
 
 	if (bMini)
@@ -103,28 +110,28 @@
 		rcBack.bottom = 24;
 
 		CortBox(&rcBack, 0x000000);
-		PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, 10, &rc, SURFACE_ID_ROOM_NAME);
+		PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 86, 10, &rc, SURFACE_ID_ROOM_NAME);
 	}
 	else if (gMapName.flag)
 	{
 		// MNA
-		PutBitmap3(&grcGame, (WINDOW_WIDTH - 172) / 2, (WINDOW_HEIGHT - 80) / 2, &rc, SURFACE_ID_ROOM_NAME);
+		PutBitmap3(&grcGame, (WINDOW_WIDTH / 2) - 86, (WINDOW_HEIGHT / 2) - 40, &rc, SURFACE_ID_ROOM_NAME);
 		if (++gMapName.wait > 160)
-			gMapName.flag = 0;
+			gMapName.flag = FALSE;
 	}
 }
 
-void StartMapName()
+void StartMapName(void)
 {
-	gMapName.flag = 1;
+	gMapName.flag = TRUE;
 	gMapName.wait = 0;
 }
 
-void RestoreMapName()
+void RestoreMapName(void)
 {
 	int len = (int)strlen(gMapName.name);
 
 	CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
-	PutText2((160 - 6 * len) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
-	PutText2((160 - 6 * len) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
+	PutText2(((160 - (len * 6)) / 2) + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
+	PutText2(((160 - (len * 6)) / 2) + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
 }
--- a/src/MapName.h
+++ b/src/MapName.h
@@ -2,14 +2,7 @@
 
 #include "WindowsWrapper.h"
 
-struct MAP_NAME
-{
-	int flag;
-	int wait;
-	char name[0x20];
-};
-
 void ReadyMapName(const char *str);
 void PutMapName(BOOL bMini);
-void StartMapName();
-void RestoreMapName();
+void StartMapName(void);
+void RestoreMapName(void);