src: Some cleanup for the MAX_PATH std::string PR

Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
This commit is contained in:
Gabriel Ravier 2020-06-29 18:52:04 +02:00
parent 564d42dbd2
commit 771b944d17
12 changed files with 28 additions and 21 deletions

View file

@ -1,6 +1,5 @@
#include "ArmsItem.h"
#include <stdlib.h>
#include <string.h>
#include "WindowsWrapper.h"
@ -418,7 +417,7 @@ int CampLoop(void)
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");

View file

@ -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)

View file

@ -250,7 +250,7 @@ BOOL MakeSurface_Resource(const char *name, SurfaceID surf_no)
// 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 @@ BOOL ReloadBitmap_Resource(const char *name, SurfaceID surf_no)
// 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()))
{

View file

@ -225,7 +225,7 @@ BOOL StartCreditScript(void)
}
// 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;

View file

@ -701,9 +701,7 @@ BOOL Game(void)
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テーブルが読めない");

View file

@ -2,7 +2,6 @@
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "WindowsWrapper.h"
@ -94,7 +93,7 @@ long GetFileSizeLong(const char *path)
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());

View file

@ -222,13 +222,19 @@ int main(int argc, char *argv[])
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
if (conf.display_mode == 1)
@ -248,7 +254,10 @@ int main(int argc, char *argv[])
#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 @@ int main(int argc, char *argv[])
// Draw to screen
if (!Flip_SystemTask())
return EXIT_SUCCESS;
{
Backend_Deinit();
return EXIT_FAILURE;
}
// Initialize sound
InitDirectSound();
@ -340,6 +352,8 @@ int main(int argc, char *argv[])
EndDirectSound();
EndDirectDraw();
Backend_Deinit();
return EXIT_SUCCESS;
}

View file

@ -441,7 +441,7 @@ BOOL SaveTimeCounter(void)
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)

View file

@ -1,6 +1,5 @@
#include "SelStage.h"
#include <stdlib.h>
#include <string.h>
#include "WindowsWrapper.h"
@ -161,7 +160,7 @@ int StageSelectLoop(int *p_event)
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);

View file

@ -139,7 +139,7 @@ BOOL TransferStage(int no, int w, int x, int y)
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;

View file

@ -126,7 +126,7 @@ BOOL LoadTextScript2(const char *name)
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 @@ BOOL LoadTextScript_Stage(const char *name)
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;