ref: 771b944d1719cefbfeaced882a8d73cf9a556e04
parent: 564d42dbd23a369d7d575b176e93fc0721fb407d
author: Gabriel Ravier <gabravier@gmail.com>
date: Mon Jun 29 14:52:04 EDT 2020
src: Some cleanup for the MAX_PATH std::string PR Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
--- a/src/ArmsItem.cpp
+++ b/src/ArmsItem.cpp
@@ -1,6 +1,5 @@
#include "ArmsItem.h"
-#include <stdlib.h>
#include <string.h>
#include "WindowsWrapper.h"
@@ -418,7 +417,7 @@
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
// Save the current script path (to restore it when we get out of the inventory)
- std::string old_script_path = GetTextScriptPath();
+ auto old_script_path = GetTextScriptPath();
// Load the inventory script
LoadTextScript2("ArmsItem.tsc");
--- a/src/Backends/Platform/WiiU.cpp
+++ b/src/Backends/Platform/WiiU.cpp
@@ -12,8 +12,6 @@
#include <whb/proc.h>
#include <whb/sdcard.h>
-#include "../../Helpers/Asprintf.h"
-
static unsigned long ticks_per_second;
bool Backend_Init(void)
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -250,7 +250,7 @@
// TODO - Inaccurate stack frame
BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
{
- std::string path = gDataPath + '/' + name + ".pbm";
+ auto path = gDataPath + '/' + name + ".pbm";
if (!IsEnableBitmap(path.c_str()))
{
@@ -340,7 +340,7 @@
// TODO - Inaccurate stack frame
BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
{
- std::string path = gDataPath + '/' + name + ".pbm";
+ auto path = gDataPath + '/' + name + ".pbm";
if (!IsEnableBitmap(path.c_str()))
{
--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -225,7 +225,7 @@
}
// Open file
- std::string path = gDataPath + '/' + credit_script;
+ auto path = gDataPath + '/' + credit_script;
Credit.size = GetFileSizeLong(path.c_str());
if (Credit.size == -1)
return FALSE;
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -701,9 +701,7 @@
PlaySoundObject(7, -1);
- std::string path = gDataPath + "/npc.tbl";
-
- if (!LoadNpcTable(path.c_str()))
+ if (!LoadNpcTable((gDataPath + "/npc.tbl").c_str()))
{
#ifdef JAPANESE
Backend_ShowMessageBox("エラー", "NPCテーブルが読めない");
--- a/src/Generic.cpp
+++ b/src/Generic.cpp
@@ -2,7 +2,6 @@
#include <stddef.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include "WindowsWrapper.h"
@@ -94,7 +93,7 @@
BOOL ErrorLog(const char *string, int value)
{
- std::string path = gModulePath + "/error.log";
+ auto 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());
--- a/src/GenericLoad.cpp
+++ b/src/GenericLoad.cpp
@@ -294,8 +294,8 @@
pt_size += MakePixToneObject(&gPtpTable[138], 1, 7);
/*
- * char str[0x40];
- * sprintf(str, "PixTone = %d byte", pt_size);
+ * 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
@@ -222,12 +222,18 @@
if (conf.display_mode == 1)
{
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 0))
+ {
+ Backend_Deinit();
return EXIT_FAILURE;
+ }
}
else
{
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 1))
+ {
+ Backend_Deinit();
return EXIT_FAILURE;
+ }
}
#else
// Doesn't handle StartDirectDraw failing
@@ -248,7 +254,10 @@
#ifdef FIX_BUGS
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2))
+ {
+ Backend_Deinit();
return EXIT_FAILURE;
+ }
#else
// Doesn't handle StartDirectDraw failing
StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2);
@@ -316,7 +325,10 @@
// Draw to screen
if (!Flip_SystemTask())
- return EXIT_SUCCESS;
+ {
+ Backend_Deinit();
+ return EXIT_FAILURE;
+ }
// Initialize sound
InitDirectSound();
@@ -339,6 +351,8 @@
EndTextObject();
EndDirectSound();
EndDirectDraw();
+
+ Backend_Deinit();
return EXIT_SUCCESS;
}
--- a/src/MycParam.cpp
+++ b/src/MycParam.cpp
@@ -441,7 +441,7 @@
return TRUE;
// Get last time
- std::string path = gModulePath + "/290.rec";
+ auto path = gModulePath + "/290.rec";
FILE *fp = fopen(path.c_str(), "rb");
if (fp != NULL)
--- a/src/SelStage.cpp
+++ b/src/SelStage.cpp
@@ -1,6 +1,5 @@
#include "SelStage.h"
-#include <stdlib.h>
#include <string.h>
#include "WindowsWrapper.h"
@@ -161,7 +160,7 @@
gSelectedStage = 0;
BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcFull);
- std::string old_script_path = GetTextScriptPath();
+ auto 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
@@ -139,7 +139,7 @@
bError = FALSE;
// Load tileset
- std::string path = std::string{"Stage/Prt"} + gTMT[no].parts;
+ auto path = std::string{"Stage/Prt"} + gTMT[no].parts;
if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_TILESET))
bError = TRUE;
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -126,7 +126,7 @@
FILE *fp;
// Get path
- std::string path = gDataPath + '/' + name;
+ auto path = gDataPath + '/' + name;
gTS.size = GetFileSizeLong(path.c_str());
if (gTS.size == -1)
@@ -159,7 +159,7 @@
long body_size;
// Open Head.tsc
- std::string path = gDataPath + "/Head.tsc";
+ auto path = gDataPath + "/Head.tsc";
head_size = GetFileSizeLong(path.c_str());
if (head_size == -1)
return FALSE;