ref: 27a1fd900f813796f20c1c9ca569f17eb2ff958a
parent: 2970242ff7126d3ea4c1aa04f66ab4679a041763
author: Clownacy <Clownacy@users.noreply.github.com>
date: Tue Jun 30 09:48:46 EDT 2020
Revert more unnecessary edits
--- a/src/Back.cpp
+++ b/src/Back.cpp
@@ -2,6 +2,7 @@
#include <stddef.h>
#include <stdio.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -25,7 +26,9 @@
color_black = GetCortBoxColor(RGB(0, 0, 0x10));
// Get width and height
- FILE *fp = fopen((gDataPath + '/' + fName + ".pbm").c_str(), "rb");
+ std::string path = gDataPath + '/' + fName + ".pbm";
+
+ FILE *fp = fopen(path.c_str(), "rb");
if (fp == NULL)
return FALSE;
--- a/src/Backends/Misc.h
+++ b/src/Backends/Misc.h
@@ -1,7 +1,8 @@
#pragma once
-#include "../Attributes.h"
#include <string>
+
+#include "../Attributes.h"
enum
{
--- a/src/Backends/Platform/GLFW3.cpp
+++ b/src/Backends/Platform/GLFW3.cpp
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <string>
#include <thread>
#include <GLFW/glfw3.h>
--- a/src/Backends/Platform/Null.cpp
+++ b/src/Backends/Platform/Null.cpp
@@ -1,4 +1,5 @@
#include "../Misc.h"
+
#include <string>
bool Backend_Init(void)
--- a/src/Backends/Platform/WiiU.cpp
+++ b/src/Backends/Platform/WiiU.cpp
@@ -3,6 +3,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
+#include <string>
#include <coreinit/thread.h>
#include <padscore/kpad.h>
@@ -57,10 +58,11 @@
bool Backend_GetBasePath(std::string *string_buffer)
{
#ifdef JAPANESE
- *string_buffer = std::string{WHBGetSdCardMountPath()} + "/CSE-portable-jp";
+ *string_buffer = std::string{WHBGetSdCardMountPath()} + "/CSE2-portable-jp";
#else
- *string_buffer = std::string{WHBGetSdCardMountPath()} + "/CSE-portable-en";
+ *string_buffer = std::string{WHBGetSdCardMountPath()} + "/CSE2-portable-en";
#endif
+
return true;
}
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -1,6 +1,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -17,7 +18,9 @@
memset(conf, 0, sizeof(CONFIG));
// Open file
- FILE *fp = fopen((gModulePath + '/' + gConfigName).c_str(), "rb");
+ std::string path = gModulePath + '/' + gConfigName;
+
+ FILE *fp = fopen(path.c_str(), "rb");
if (fp == NULL)
return FALSE;
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -250,7 +251,7 @@
// TODO - Inaccurate stack frame
BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
{
- auto path = gDataPath + '/' + name + ".pbm";
+ std::string path = gDataPath + '/' + name + ".pbm";
if (!IsEnableBitmap(path.c_str()))
{
@@ -340,7 +341,7 @@
// TODO - Inaccurate stack frame
BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
{
- auto path = gDataPath + '/' + name + ".pbm";
+ std::string path = gDataPath + '/' + name + ".pbm";
if (!IsEnableBitmap(path.c_str()))
{
@@ -376,6 +377,7 @@
FreeBitmap(image_buffer);
surface_metadata[surf_no].type = SURFACE_SOURCE_FILE;
strcpy(surface_metadata[surf_no].name, name);
+
return TRUE;
}
@@ -644,6 +646,8 @@
{
(void)name; // Unused in this branch
+ std::string path = gDataPath + "/Font/font";
+
// Get font size
unsigned int width, height;
@@ -660,7 +664,7 @@
break;
}
- font = LoadFont((gDataPath + "/Font/font").c_str(), width, height);
+ font = LoadFont(path.c_str(), width, height);
}
void PutText(int x, int y, const char *text, unsigned long color)
--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -216,6 +217,7 @@
BOOL StartCreditScript(void)
{
FILE *fp;
+ std::string path;
// Clear previously existing credits data
if (Credit.pData != NULL)
@@ -225,7 +227,8 @@
}
// Open file
- auto path = gDataPath + '/' + credit_script;
+ path = gDataPath + '/' + credit_script;
+
Credit.size = GetFileSizeLong(path.c_str());
if (Credit.size == -1)
return FALSE;
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -701,7 +702,9 @@
PlaySoundObject(7, -1);
- if (!LoadNpcTable((gDataPath + "/npc.tbl").c_str()))
+ std::string path = gDataPath + "/npc.tbl";
+
+ if (!LoadNpcTable(path.c_str()))
{
#ifdef JAPANESE
Backend_ShowMessageBox("エラー", "NPCテーブルが読めない");
--- a/src/Generic.cpp
+++ b/src/Generic.cpp
@@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -49,12 +50,18 @@
void DeleteLog(void)
{
- remove((gModulePath + "/debug.txt").c_str());
+ std::string path = gModulePath + "/debug.txt";
+ remove(path.c_str());
}
BOOL WriteLog(const char *string, int value1, int value2, int value3)
{
- FILE *fp = fopen((gModulePath + "/debug.txt").c_str(), "a+");
+ std::string path;
+ FILE *fp;
+
+ path = gModulePath + "/debug.txt";
+ fp = fopen(path.c_str(), "a+");
+
if (fp == NULL)
return FALSE;
@@ -65,7 +72,10 @@
BOOL IsKeyFile(const char *name)
{
- FILE *file = fopen((gModulePath + '/' + name).c_str(), "rb");
+ std::string path = gModulePath + '/' + name;
+
+ FILE *file = fopen(path.c_str(), "rb");
+
if (file == NULL)
return FALSE;
@@ -93,12 +103,15 @@
BOOL ErrorLog(const char *string, int value)
{
- auto path = gModulePath + "/error.log";
+ std::string path;
+ FILE *fp;
+ path = gModulePath + "/error.log";
+
if (GetFileSizeLong(path.c_str()) > 0x19000) // Purge the error log if it gets too big, I guess
remove(path.c_str());
- FILE *fp = fopen(path.c_str(), "a+");
+ fp = fopen(path.c_str(), "a+");
if (fp == NULL)
return FALSE;
--- a/src/GenericLoad.cpp
+++ b/src/GenericLoad.cpp
@@ -293,10 +293,9 @@
pt_size += MakePixToneObject(&gPtpTable[137], 1, 6);
pt_size += MakePixToneObject(&gPtpTable[138], 1, 7);
- /*
- * char str[0x40];
- * sprintf(str, "PixTone = %d byte", pt_size);
- * // There must have been some kind of console print function here or something
- */
+ // Commented-out, since ints *technically* have an undefined length
+ // char str[0x40];
+ // sprintf(str, "PixTone = %d byte", pt_size);
+ // There must have been some kind of console print function here or something
return TRUE;
}
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -327,7 +328,7 @@
if (!Flip_SystemTask())
{
Backend_Deinit();
- return EXIT_FAILURE;
+ return EXIT_SUCCESS;
}
// Initialize sound
--- a/src/Main.h
+++ b/src/Main.h
@@ -1,7 +1,8 @@
#pragma once
-#include "WindowsWrapper.h"
#include <string>
+
+#include "WindowsWrapper.h"
extern std::string gModulePath;
extern std::string gDataPath;
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -27,10 +28,15 @@
BOOL LoadMapData2(const char *path_map)
{
+ FILE *fp;
char check[3];
+ std::string path;
+ // Get path
+ path = gDataPath + '/' + path_map;
+
// Open file
- FILE *fp = fopen((gDataPath + '/' + path_map).c_str(), "rb");
+ fp = fopen(path.c_str(), "rb");
if (fp == NULL)
return FALSE;
@@ -63,8 +69,13 @@
BOOL LoadAttributeData(const char *path_atrb)
{
+ FILE *fp;
+ std::string path;
+
// Open file
- FILE *fp = fopen((gDataPath + '/' + path_atrb).c_str(), "rb");
+ path = gDataPath + '/' + path_atrb;
+
+ fp = fopen(path.c_str(), "rb");
if (fp == NULL)
return FALSE;
--- a/src/MycParam.cpp
+++ b/src/MycParam.cpp
@@ -1,6 +1,7 @@
#include "MycParam.h"
#include <stdio.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -435,6 +436,8 @@
int i;
unsigned char p[4];
REC rec;
+ FILE *fp;
+ std::string path;
// Quit if player doesn't have the Nikumaru Counter
if (!(gMC.equip & EQUIP_NIKUMARU_COUNTER))
@@ -441,9 +444,9 @@
return TRUE;
// Get last time
- auto path = gModulePath + "/290.rec";
+ path = gModulePath + "/290.rec";
- FILE *fp = fopen(path.c_str(), "rb");
+ fp = fopen(path.c_str(), "rb");
if (fp != NULL)
{
// Read data
@@ -505,9 +508,13 @@
int i;
unsigned char p[4];
REC rec;
+ FILE *fp;
+ std::string path;
// Open file
- FILE *fp = fopen((gModulePath + "/290.rec").c_str(), "rb");
+ path = gModulePath + "/290.rec";
+
+ fp = fopen(path.c_str(), "rb");
if (fp == NULL)
return 0;
--- a/src/NpChar.cpp
+++ b/src/NpChar.cpp
@@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -54,11 +55,14 @@
BOOL LoadEvent(const char *path_event)
{
int i, n;
+ FILE *fp;
int count;
char code[4];
EVENT eve;
- FILE *fp = fopen((gDataPath + '/' + path_event).c_str(), "rb");
+ std::string path = gDataPath + '/' + path_event;
+
+ fp = fopen(path.c_str(), "rb");
if (fp == NULL)
return FALSE;
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -28,7 +29,9 @@
BOOL IsProfile(void)
{
- FILE *file = fopen((gModulePath + '/' + gDefaultName).c_str(), "rb");
+ std::string path = gModulePath + '/' + gDefaultName;
+
+ FILE *file = fopen(path.c_str(), "rb");
if (file == NULL)
return FALSE;
@@ -38,15 +41,24 @@
BOOL SaveProfile(const char *name)
{
+ FILE *fp;
+ PROFILE profile;
const char *FLAG = "FLAG";
+ std::string path;
+
+ // Get path
+ if (name != NULL)
+ path = gModulePath + '/' + name;
+ else
+ path = gModulePath + '/' + gDefaultName;
+
// Open file
- FILE *fp = fopen((gModulePath + '/' + ((name != NULL) ? name : gDefaultName)).c_str(), "wb");
+ fp = fopen(path.c_str(), "wb");
if (fp == NULL)
return FALSE;
// Set up profile
- PROFILE profile;
memset(&profile, 0, sizeof(PROFILE));
memcpy(profile.code, gProfileCode, sizeof(profile.code));
memcpy(profile.FLAG, FLAG, sizeof(profile.FLAG));
@@ -110,15 +122,18 @@
BOOL LoadProfile(const char *name)
{
+ FILE *fp;
PROFILE profile;
+ std::string path;
- // Open file
- FILE *fp;
+ // Get path
if (name != NULL)
- fp = fopen(name, "rb");
+ path = name;
else
- fp = fopen((gModulePath + '/' + gDefaultName).c_str(), "rb");
-
+ path = gModulePath + '/' + gDefaultName;
+
+ // Open file
+ fp = fopen(path.c_str(), "rb");
if (fp == NULL)
return FALSE;
--- a/src/SelStage.cpp
+++ b/src/SelStage.cpp
@@ -1,6 +1,7 @@
#include "SelStage.h"
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -156,11 +157,13 @@
int StageSelectLoop(int *p_event)
{
+ std::string old_script_path;
+
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
gSelectedStage = 0;
BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcFull);
- auto old_script_path = GetTextScriptPath();
+ old_script_path = GetTextScriptPath();
LoadTextScript2("StageSelect.tsc");
gStageSelectTitleY = (WINDOW_HEIGHT / 2) - 66;
StartTextScript(gPermitStage[gSelectedStage].index + 1000);
--- a/src/Stage.cpp
+++ b/src/Stage.cpp
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -131,6 +132,8 @@
BOOL TransferStage(int no, int w, int x, int y)
{
+ std::string path;
+ std::string path_dir;
BOOL bError;
// Move character
@@ -138,40 +141,47 @@
bError = FALSE;
+ // Get path
+ path_dir = "Stage";
+
// Load tileset
- auto path = std::string{"Stage/Prt"} + gTMT[no].parts;
+ path = path_dir + "/Prt" + gTMT[no].parts;
if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_TILESET))
bError = TRUE;
- path = std::string{"Stage/"} + gTMT[no].parts + ".pxa";
+ path = path_dir + "Stage/" + gTMT[no].parts + ".pxa";
if (!LoadAttributeData(path.c_str()))
bError = TRUE;
// Load tilemap
- path = std::string{"Stage/"} + gTMT[no].map + ".pxm";
+ path = path_dir + "Stage/" + gTMT[no].map + ".pxm";
if (!LoadMapData2(path.c_str()))
bError = TRUE;
// Load NPCs
- path = std::string{"Stage/"} + gTMT[no].map + ".pxe";
+ path = path_dir + "Stage/" + gTMT[no].map + ".pxe";
if (!LoadEvent(path.c_str()))
bError = TRUE;
// Load script
- path = std::string{"Stage/"} + gTMT[no].map + ".tsc";
+ path = path_dir + "Stage/" + gTMT[no].map + ".tsc";
if (!LoadTextScript_Stage(path.c_str()))
bError = TRUE;
// Load background
- if (!InitBack(gTMT[no].back, gTMT[no].bkType))
+ path = gTMT[no].back;
+ if (!InitBack(path.c_str(), gTMT[no].bkType))
bError = TRUE;
+ // Get path
+ path_dir = "Npc";
+
// Load NPC sprite sheets
- path = std::string{"Npc/Npc"} + gTMT[no].npc;
+ path = path_dir + "/Npc" + gTMT[no].npc;
if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_SPRITESET_1))
bError = TRUE;
- path = std::string{"Npc/Npc"} + gTMT[no].boss;
+ path = path_dir + "/Npc" + gTMT[no].boss;
if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_SPRITESET_2))
bError = TRUE;
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <string>
#include "WindowsWrapper.h"
@@ -124,9 +125,10 @@
BOOL LoadTextScript2(const char *name)
{
FILE *fp;
+ std::string path;
// Get path
- auto path = gDataPath + '/' + name;
+ path = gDataPath + '/' + name;
gTS.size = GetFileSizeLong(path.c_str());
if (gTS.size == -1)
@@ -155,11 +157,13 @@
BOOL LoadTextScript_Stage(const char *name)
{
FILE *fp;
+ std::string path;
long head_size;
long body_size;
// Open Head.tsc
- auto path = gDataPath + "/Head.tsc";
+ path = gDataPath + "/Head.tsc";
+
head_size = GetFileSizeLong(path.c_str());
if (head_size == -1)
return FALSE;
@@ -176,6 +180,7 @@
// Open stage's .tsc
path = gDataPath + '/' + name;
+
body_size = GetFileSizeLong(path.c_str());
if (body_size == -1)
return FALSE;
@@ -198,7 +203,7 @@
}
// Get current path
-std::string GetTextScriptPath()
+std::string GetTextScriptPath(void)
{
return gTS.path;
}
@@ -1277,13 +1282,11 @@
}
else
{
- // The size of str_0 is the size of the format string (includes null terminator so that's the space we'll be using for ours) + the 3 chars from the format string
+ char str_0[0x40];
#ifdef JAPANESE
- char str_0[sizeof("不明のコード:<") + (sizeof(char) * 3)];
sprintf(str_0, "不明のコード:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
Backend_ShowMessageBox("エラー", str_0);
#else
- char str_0[sizeof("Unknown code:<%c%c%c") + (sizeof(char) * 3)];
sprintf(str_0, "Unknown code:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
Backend_ShowMessageBox("Error", str_0);
#endif
--- a/src/TextScr.h
+++ b/src/TextScr.h
@@ -1,8 +1,9 @@
#pragma once
-#include "WindowsWrapper.h"
#include <string>
+#include "WindowsWrapper.h"
+
typedef struct TEXT_SCRIPT
{
// Path (reload when exit teleporter menu/inventory)
@@ -63,7 +64,7 @@
void EncryptionBinaryData2(unsigned char *pData, long size);
BOOL LoadTextScript2(const char *name);
BOOL LoadTextScript_Stage(const char *name);
-std::string GetTextScriptPath();
+std::string GetTextScriptPath(void);
BOOL StartTextScript(int no);
void StopTextScript(void);
void PutTextScript(void);