src: Some cleanup for the MAX_PATH std::string PR
Signed-off-by: Gabriel Ravier <gabravier@gmail.com>
This commit is contained in:
parent
564d42dbd2
commit
771b944d17
12 changed files with 28 additions and 21 deletions
|
@ -1,6 +1,5 @@
|
||||||
#include "ArmsItem.h"
|
#include "ArmsItem.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
@ -418,7 +417,7 @@ int CampLoop(void)
|
||||||
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
||||||
|
|
||||||
// Save the current script path (to restore it when we get out of the inventory)
|
// 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
|
// Load the inventory script
|
||||||
LoadTextScript2("ArmsItem.tsc");
|
LoadTextScript2("ArmsItem.tsc");
|
||||||
|
|
|
@ -12,8 +12,6 @@
|
||||||
#include <whb/proc.h>
|
#include <whb/proc.h>
|
||||||
#include <whb/sdcard.h>
|
#include <whb/sdcard.h>
|
||||||
|
|
||||||
#include "../../Helpers/Asprintf.h"
|
|
||||||
|
|
||||||
static unsigned long ticks_per_second;
|
static unsigned long ticks_per_second;
|
||||||
|
|
||||||
bool Backend_Init(void)
|
bool Backend_Init(void)
|
||||||
|
|
|
@ -250,7 +250,7 @@ BOOL MakeSurface_Resource(const char *name, SurfaceID surf_no)
|
||||||
// TODO - Inaccurate stack frame
|
// TODO - Inaccurate stack frame
|
||||||
BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
|
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()))
|
if (!IsEnableBitmap(path.c_str()))
|
||||||
{
|
{
|
||||||
|
@ -340,7 +340,7 @@ BOOL ReloadBitmap_Resource(const char *name, SurfaceID surf_no)
|
||||||
// TODO - Inaccurate stack frame
|
// TODO - Inaccurate stack frame
|
||||||
BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
|
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()))
|
if (!IsEnableBitmap(path.c_str()))
|
||||||
{
|
{
|
||||||
|
|
|
@ -225,7 +225,7 @@ BOOL StartCreditScript(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open file
|
// Open file
|
||||||
std::string path = gDataPath + '/' + credit_script;
|
auto path = gDataPath + '/' + credit_script;
|
||||||
Credit.size = GetFileSizeLong(path.c_str());
|
Credit.size = GetFileSizeLong(path.c_str());
|
||||||
if (Credit.size == -1)
|
if (Credit.size == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -701,9 +701,7 @@ BOOL Game(void)
|
||||||
|
|
||||||
PlaySoundObject(7, -1);
|
PlaySoundObject(7, -1);
|
||||||
|
|
||||||
std::string path = gDataPath + "/npc.tbl";
|
if (!LoadNpcTable((gDataPath + "/npc.tbl").c_str()))
|
||||||
|
|
||||||
if (!LoadNpcTable(path.c_str()))
|
|
||||||
{
|
{
|
||||||
#ifdef JAPANESE
|
#ifdef JAPANESE
|
||||||
Backend_ShowMessageBox("エラー", "NPCテーブルが読めない");
|
Backend_ShowMessageBox("エラー", "NPCテーブルが読めない");
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
@ -94,7 +93,7 @@ long GetFileSizeLong(const char *path)
|
||||||
|
|
||||||
BOOL ErrorLog(const char *string, int value)
|
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
|
if (GetFileSizeLong(path.c_str()) > 0x19000) // Purge the error log if it gets too big, I guess
|
||||||
remove(path.c_str());
|
remove(path.c_str());
|
||||||
|
|
|
@ -294,8 +294,8 @@ BOOL LoadGenericData(void)
|
||||||
pt_size += MakePixToneObject(&gPtpTable[138], 1, 7);
|
pt_size += MakePixToneObject(&gPtpTable[138], 1, 7);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* char str[0x40];
|
* char str[0x40];
|
||||||
* sprintf(str, "PixTone = %d byte", pt_size);
|
* sprintf(str, "PixTone = %d byte", pt_size);
|
||||||
* // There must have been some kind of console print function here or something
|
* // There must have been some kind of console print function here or something
|
||||||
*/
|
*/
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
16
src/Main.cpp
16
src/Main.cpp
|
@ -222,12 +222,18 @@ int main(int argc, char *argv[])
|
||||||
if (conf.display_mode == 1)
|
if (conf.display_mode == 1)
|
||||||
{
|
{
|
||||||
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 0))
|
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 0))
|
||||||
|
{
|
||||||
|
Backend_Deinit();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 1))
|
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 1))
|
||||||
|
{
|
||||||
|
Backend_Deinit();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Doesn't handle StartDirectDraw failing
|
// Doesn't handle StartDirectDraw failing
|
||||||
|
@ -248,7 +254,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2))
|
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2))
|
||||||
|
{
|
||||||
|
Backend_Deinit();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// Doesn't handle StartDirectDraw failing
|
// Doesn't handle StartDirectDraw failing
|
||||||
StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2);
|
StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2);
|
||||||
|
@ -316,7 +325,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// Draw to screen
|
// Draw to screen
|
||||||
if (!Flip_SystemTask())
|
if (!Flip_SystemTask())
|
||||||
return EXIT_SUCCESS;
|
{
|
||||||
|
Backend_Deinit();
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize sound
|
// Initialize sound
|
||||||
InitDirectSound();
|
InitDirectSound();
|
||||||
|
@ -340,6 +352,8 @@ int main(int argc, char *argv[])
|
||||||
EndDirectSound();
|
EndDirectSound();
|
||||||
EndDirectDraw();
|
EndDirectDraw();
|
||||||
|
|
||||||
|
Backend_Deinit();
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -441,7 +441,7 @@ BOOL SaveTimeCounter(void)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
// Get last time
|
// Get last time
|
||||||
std::string path = gModulePath + "/290.rec";
|
auto path = gModulePath + "/290.rec";
|
||||||
|
|
||||||
FILE *fp = fopen(path.c_str(), "rb");
|
FILE *fp = fopen(path.c_str(), "rb");
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "SelStage.h"
|
#include "SelStage.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
@ -161,7 +160,7 @@ int StageSelectLoop(int *p_event)
|
||||||
|
|
||||||
gSelectedStage = 0;
|
gSelectedStage = 0;
|
||||||
BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcFull);
|
BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcFull);
|
||||||
std::string old_script_path = GetTextScriptPath();
|
auto old_script_path = GetTextScriptPath();
|
||||||
LoadTextScript2("StageSelect.tsc");
|
LoadTextScript2("StageSelect.tsc");
|
||||||
gStageSelectTitleY = (WINDOW_HEIGHT / 2) - 66;
|
gStageSelectTitleY = (WINDOW_HEIGHT / 2) - 66;
|
||||||
StartTextScript(gPermitStage[gSelectedStage].index + 1000);
|
StartTextScript(gPermitStage[gSelectedStage].index + 1000);
|
||||||
|
|
|
@ -139,7 +139,7 @@ BOOL TransferStage(int no, int w, int x, int y)
|
||||||
bError = FALSE;
|
bError = FALSE;
|
||||||
|
|
||||||
// Load tileset
|
// 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))
|
if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_TILESET))
|
||||||
bError = TRUE;
|
bError = TRUE;
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ BOOL LoadTextScript2(const char *name)
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
// Get path
|
// Get path
|
||||||
std::string path = gDataPath + '/' + name;
|
auto path = gDataPath + '/' + name;
|
||||||
|
|
||||||
gTS.size = GetFileSizeLong(path.c_str());
|
gTS.size = GetFileSizeLong(path.c_str());
|
||||||
if (gTS.size == -1)
|
if (gTS.size == -1)
|
||||||
|
@ -159,7 +159,7 @@ BOOL LoadTextScript_Stage(const char *name)
|
||||||
long body_size;
|
long body_size;
|
||||||
|
|
||||||
// Open Head.tsc
|
// Open Head.tsc
|
||||||
std::string path = gDataPath + "/Head.tsc";
|
auto path = gDataPath + "/Head.tsc";
|
||||||
head_size = GetFileSizeLong(path.c_str());
|
head_size = GetFileSizeLong(path.c_str());
|
||||||
if (head_size == -1)
|
if (head_size == -1)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
Loading…
Add table
Reference in a new issue