Merge pull request #130 from GabrielRavier/portableSupportPathsAboveFilenameMax
Support paths above PATH_MAX (for portable)
This commit is contained in:
commit
78da025796
25 changed files with 152 additions and 141 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "ArmsItem.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -414,12 +415,12 @@ void PutCampObject(void)
|
|||
|
||||
int CampLoop(void)
|
||||
{
|
||||
char old_script_path[MAX_PATH];
|
||||
std::string old_script_path;
|
||||
|
||||
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
||||
|
||||
// Save the current script path (to restore it when we get out of the inventory)
|
||||
GetTextScriptPath(old_script_path);
|
||||
old_script_path = GetTextScriptPath();
|
||||
|
||||
// Load the inventory script
|
||||
LoadTextScript2("ArmsItem.tsc");
|
||||
|
@ -498,7 +499,7 @@ int CampLoop(void)
|
|||
}
|
||||
|
||||
// Resume original script
|
||||
LoadTextScript_Stage(old_script_path);
|
||||
LoadTextScript_Stage(old_script_path.c_str());
|
||||
gArmsEnergyX = 32; // Displays weapon rotation animation in case the weapon was changed
|
||||
return enum_ESCRETURN_continue; // Go to game
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#ifdef __GNUC__
|
||||
|
||||
#define ATTRIBUTE_HOT __attribute__((hot))
|
||||
#define ATTRIBUTE_OPTIMIZE(optString) __attribute__((optimize(optString)))
|
||||
#define LIKELY(condition) __builtin_expect((condition), 1)
|
||||
#define UNLIKELY(condition) __builtin_expect((condition), 0)
|
||||
#define PREFETCH(address, isWrite, locality) __builtin_prefetch((address), (isWrite), (locality))
|
||||
|
@ -21,7 +20,6 @@
|
|||
#else
|
||||
|
||||
#define ATTRIBUTE_HOT
|
||||
#define ATTRIBUTE_OPTIMIZE(optString)
|
||||
#define LIKELY(condition) condition
|
||||
#define UNLIKELY(condition) condition
|
||||
#define PREFETCH(address, isWrite, locality)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -25,10 +26,9 @@ BOOL InitBack(const char *fName, int type)
|
|||
color_black = GetCortBoxColor(RGB(0, 0, 0x10));
|
||||
|
||||
// Get width and height
|
||||
char path[MAX_PATH];
|
||||
sprintf(path, "%s/%s.pbm", gDataPath, fName);
|
||||
std::string path = gDataPath + '/' + fName + ".pbm";
|
||||
|
||||
FILE *fp = fopen(path, "rb");
|
||||
FILE *fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "../Attributes.h"
|
||||
|
||||
enum
|
||||
|
@ -86,7 +88,7 @@ enum
|
|||
bool Backend_Init(void);
|
||||
void Backend_Deinit(void);
|
||||
void Backend_PostWindowCreation(void);
|
||||
bool Backend_GetBasePath(char *string_buffer);
|
||||
bool Backend_GetBasePath(std::string *string_buffer);
|
||||
void Backend_HideMouse(void);
|
||||
void Backend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
|
||||
void Backend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
|
@ -181,7 +182,7 @@ void Backend_PostWindowCreation(void)
|
|||
glfwSetWindowSizeCallback(window, WindowSizeCallback);
|
||||
}
|
||||
|
||||
bool Backend_GetBasePath(char *string_buffer)
|
||||
bool Backend_GetBasePath(std::string *string_buffer)
|
||||
{
|
||||
(void)string_buffer;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "../Misc.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
bool Backend_Init(void)
|
||||
{
|
||||
return true;
|
||||
|
@ -15,7 +17,7 @@ void Backend_PostWindowCreation(void)
|
|||
|
||||
}
|
||||
|
||||
bool Backend_GetBasePath(char *string_buffer)
|
||||
bool Backend_GetBasePath(std::string *string_buffer)
|
||||
{
|
||||
(void)string_buffer;
|
||||
|
||||
|
|
|
@ -84,13 +84,15 @@ void Backend_PostWindowCreation(void)
|
|||
|
||||
}
|
||||
|
||||
bool Backend_GetBasePath(char *string_buffer)
|
||||
bool Backend_GetBasePath(std::string *string_buffer)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// SDL_GetBasePath returns a UTF-8 string, but Windows' fopen uses (extended?) ASCII.
|
||||
// This is apparently a problem for accented characters, as they will make fopen fail.
|
||||
// So, instead, we rely on argv[0], as that will put the accented characters in a
|
||||
// format Windows will understand.
|
||||
(void)string_buffer;
|
||||
|
||||
return false;
|
||||
#else
|
||||
char *base_path = SDL_GetBasePath();
|
||||
|
@ -100,7 +102,7 @@ bool Backend_GetBasePath(char *string_buffer)
|
|||
// Trim the trailing '/'
|
||||
size_t base_path_length = strlen(base_path);
|
||||
base_path[base_path_length - 1] = '\0';
|
||||
strcpy(string_buffer, base_path);
|
||||
*string_buffer = base_path;
|
||||
SDL_free(base_path);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include <coreinit/thread.h>
|
||||
#include <padscore/kpad.h>
|
||||
|
@ -54,13 +55,13 @@ void Backend_PostWindowCreation(void)
|
|||
|
||||
}
|
||||
|
||||
bool Backend_GetBasePath(char *string_buffer)
|
||||
bool Backend_GetBasePath(std::string *string_buffer)
|
||||
{
|
||||
strcpy(string_buffer, WHBGetSdCardMountPath());
|
||||
*string_buffer = WHBGetSdCardMountPath();
|
||||
#ifdef JAPANESE
|
||||
strcat(string_buffer, "/CSE2-portable-jp");
|
||||
*string_buffer += "/CSE2-portable-jp";
|
||||
#else
|
||||
strcat(string_buffer, "/CSE2-portable-en");
|
||||
*string_buffer += "/CSE2-portable-en";
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -17,11 +18,10 @@ BOOL LoadConfigData(CONFIG *conf)
|
|||
memset(conf, 0, sizeof(CONFIG));
|
||||
|
||||
// Get path
|
||||
char path[MAX_PATH];
|
||||
sprintf(path, "%s/%s", gModulePath, gConfigName);
|
||||
std::string path = gModulePath + '/' + gConfigName;
|
||||
|
||||
// Open file
|
||||
FILE *fp = fopen(path, "rb");
|
||||
FILE *fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
|
28
src/Draw.cpp
28
src/Draw.cpp
|
@ -4,6 +4,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -250,12 +251,11 @@ BOOL MakeSurface_Resource(const char *name, SurfaceID surf_no)
|
|||
// TODO - Inaccurate stack frame
|
||||
BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
sprintf(path, "%s/%s.pbm", gDataPath, name);
|
||||
std::string path = gDataPath + '/' + name + ".pbm";
|
||||
|
||||
if (!IsEnableBitmap(path))
|
||||
if (!IsEnableBitmap(path.c_str()))
|
||||
{
|
||||
ErrorLog(path, 0);
|
||||
ErrorLog(path.c_str(), 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -276,11 +276,11 @@ BOOL MakeSurface_File(const char *name, SurfaceID surf_no)
|
|||
}
|
||||
|
||||
unsigned int width, height;
|
||||
unsigned char *image_buffer = DecodeBitmapFromFile(path, &width, &height);
|
||||
unsigned char *image_buffer = DecodeBitmapFromFile(path.c_str(), &width, &height);
|
||||
|
||||
if (image_buffer == NULL)
|
||||
{
|
||||
ErrorLog(path, 1);
|
||||
ErrorLog(path.c_str(), 1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -341,12 +341,11 @@ BOOL ReloadBitmap_Resource(const char *name, SurfaceID surf_no)
|
|||
// TODO - Inaccurate stack frame
|
||||
BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
sprintf(path, "%s/%s.pbm", gDataPath, name);
|
||||
std::string path = gDataPath + '/' + name + ".pbm";
|
||||
|
||||
if (!IsEnableBitmap(path))
|
||||
if (!IsEnableBitmap(path.c_str()))
|
||||
{
|
||||
ErrorLog(path, 0);
|
||||
ErrorLog(path.c_str(), 0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -361,11 +360,11 @@ BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
|
|||
}
|
||||
|
||||
unsigned int width, height;
|
||||
unsigned char *image_buffer = DecodeBitmapFromFile(path, &width, &height);
|
||||
unsigned char *image_buffer = DecodeBitmapFromFile(path.c_str(), &width, &height);
|
||||
|
||||
if (image_buffer == NULL)
|
||||
{
|
||||
ErrorLog(path, 1);
|
||||
ErrorLog(path.c_str(), 1);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -647,8 +646,7 @@ void InitTextObject(const char *name)
|
|||
{
|
||||
(void)name; // Unused in this branch
|
||||
|
||||
char path[MAX_PATH];
|
||||
sprintf(path, "%s/Font/font", gDataPath);
|
||||
std::string path = gDataPath + "/Font/font";
|
||||
|
||||
// Get font size
|
||||
unsigned int width, height;
|
||||
|
@ -666,7 +664,7 @@ void InitTextObject(const char *name)
|
|||
break;
|
||||
}
|
||||
|
||||
font = LoadFont(path, width, height);
|
||||
font = LoadFont(path.c_str(), width, height);
|
||||
}
|
||||
|
||||
void PutText(int x, int y, const char *text, unsigned long color)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -216,7 +217,7 @@ void ReleaseCreditScript(void)
|
|||
BOOL StartCreditScript(void)
|
||||
{
|
||||
FILE *fp;
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
|
||||
// Clear previously existing credits data
|
||||
if (Credit.pData != NULL)
|
||||
|
@ -226,9 +227,9 @@ BOOL StartCreditScript(void)
|
|||
}
|
||||
|
||||
// Open file
|
||||
sprintf(path, "%s/%s", gDataPath, credit_script);
|
||||
path = gDataPath + '/' + credit_script;
|
||||
|
||||
Credit.size = GetFileSizeLong(path);
|
||||
Credit.size = GetFileSizeLong(path.c_str());
|
||||
if (Credit.size == -1)
|
||||
return FALSE;
|
||||
|
||||
|
@ -237,7 +238,7 @@ BOOL StartCreditScript(void)
|
|||
if (Credit.pData == NULL)
|
||||
return FALSE;
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
{
|
||||
free(Credit.pData);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -701,10 +702,9 @@ BOOL Game(void)
|
|||
|
||||
PlaySoundObject(7, -1);
|
||||
|
||||
char path[MAX_PATH];
|
||||
sprintf(path, "%s/npc.tbl", gDataPath);
|
||||
std::string path = gDataPath + "/npc.tbl";
|
||||
|
||||
if (!LoadNpcTable(path))
|
||||
if (!LoadNpcTable(path.c_str()))
|
||||
{
|
||||
#ifdef JAPANESE
|
||||
Backend_ShowMessageBox("エラー", "NPCテーブルが読めない");
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -49,19 +50,19 @@ BOOL GetCompileVersion(int *v1, int *v2, int *v3, int *v4)
|
|||
|
||||
void DeleteLog(void)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
|
||||
sprintf(path, "%s/debug.txt", gModulePath);
|
||||
remove(path);
|
||||
path = gModulePath + "/debug.txt";
|
||||
remove(path.c_str());
|
||||
}
|
||||
|
||||
BOOL WriteLog(const char *string, int value1, int value2, int value3)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
FILE *fp;
|
||||
|
||||
sprintf(path, "%s/debug.txt", gModulePath);
|
||||
fp = fopen(path, "a+");
|
||||
path = gModulePath + "/debug.txt";
|
||||
fp = fopen(path.c_str(), "a+");
|
||||
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
@ -73,11 +74,9 @@ BOOL WriteLog(const char *string, int value1, int value2, int value3)
|
|||
|
||||
BOOL IsKeyFile(const char *name)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
std::string path = gModulePath + '/' + name;
|
||||
|
||||
sprintf(path, "%s/%s", gModulePath, name);
|
||||
|
||||
FILE *file = fopen(path, "rb");
|
||||
FILE *file = fopen(path.c_str(), "rb");
|
||||
|
||||
if (file == NULL)
|
||||
return FALSE;
|
||||
|
@ -105,15 +104,15 @@ long GetFileSizeLong(const char *path)
|
|||
|
||||
BOOL ErrorLog(const char *string, int value)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
FILE *fp;
|
||||
|
||||
sprintf(path, "%s/%s", gModulePath, "error.log");
|
||||
path = gModulePath + "/error.log";
|
||||
|
||||
if (GetFileSizeLong(path) > 0x19000) // Purge the error log if it gets too big, I guess
|
||||
remove(path);
|
||||
if (GetFileSizeLong(path.c_str()) > 0x19000) // Purge the error log if it gets too big, I guess
|
||||
remove(path.c_str());
|
||||
|
||||
fp = fopen(path, "a+");
|
||||
fp = fopen(path.c_str(), "a+");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -293,8 +293,9 @@ BOOL LoadGenericData(void)
|
|||
pt_size += MakePixToneObject(&gPtpTable[137], 1, 6);
|
||||
pt_size += MakePixToneObject(&gPtpTable[138], 1, 7);
|
||||
|
||||
char str[0x40];
|
||||
sprintf(str, "PixTone = %d byte", pt_size);
|
||||
// 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;
|
||||
}
|
||||
|
|
16
src/Main.cpp
16
src/Main.cpp
|
@ -4,6 +4,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -25,8 +26,8 @@
|
|||
#include "Sound.h"
|
||||
#include "Triangle.h"
|
||||
|
||||
char gModulePath[MAX_PATH];
|
||||
char gDataPath[MAX_PATH];
|
||||
std::string gModulePath;
|
||||
std::string gDataPath;
|
||||
|
||||
BOOL bFullscreen;
|
||||
BOOL gbUseJoystick = FALSE;
|
||||
|
@ -93,24 +94,23 @@ int main(int argc, char *argv[])
|
|||
return EXIT_FAILURE;
|
||||
|
||||
// Get executable's path
|
||||
if (!Backend_GetBasePath(gModulePath))
|
||||
if (!Backend_GetBasePath(&gModulePath))
|
||||
{
|
||||
// Fall back on argv[0] if the backend cannot provide a path
|
||||
strcpy(gModulePath, argv[0]);
|
||||
gModulePath = argv[0];
|
||||
|
||||
for (size_t i = strlen(gModulePath);; --i)
|
||||
for (size_t i = gModulePath.length();; --i)
|
||||
{
|
||||
if (i == 0 || gModulePath[i] == '\\' || gModulePath[i] == '/')
|
||||
{
|
||||
gModulePath[i] = '\0';
|
||||
gModulePath.resize(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get path of the data folder
|
||||
strcpy(gDataPath, gModulePath);
|
||||
strcat(gDataPath, "/data");
|
||||
gDataPath = gModulePath + "/data";
|
||||
|
||||
CONFIG conf;
|
||||
if (!LoadConfigData(&conf))
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
extern char gModulePath[MAX_PATH];
|
||||
extern char gDataPath[MAX_PATH];
|
||||
extern std::string gModulePath;
|
||||
extern std::string gDataPath;
|
||||
|
||||
extern BOOL bFullscreen;
|
||||
extern BOOL gbUseJoystick;
|
||||
|
|
13
src/Map.cpp
13
src/Map.cpp
|
@ -4,6 +4,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -29,13 +30,13 @@ BOOL LoadMapData2(const char *path_map)
|
|||
{
|
||||
FILE *fp;
|
||||
char check[3];
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
|
||||
// Get path
|
||||
sprintf(path, "%s/%s", gDataPath, path_map);
|
||||
path = gDataPath + '/' + path_map;
|
||||
|
||||
// Open file
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -69,12 +70,12 @@ BOOL LoadMapData2(const char *path_map)
|
|||
BOOL LoadAttributeData(const char *path_atrb)
|
||||
{
|
||||
FILE *fp;
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
|
||||
// Open file
|
||||
sprintf(path, "%s/%s", gDataPath, path_atrb);
|
||||
path = gDataPath + '/' + path_atrb;
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "MycParam.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -436,16 +437,16 @@ BOOL SaveTimeCounter(void)
|
|||
unsigned char p[4];
|
||||
REC rec;
|
||||
FILE *fp;
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
|
||||
// Quit if player doesn't have the Nikumaru Counter
|
||||
if (!(gMC.equip & EQUIP_NIKUMARU_COUNTER))
|
||||
return TRUE;
|
||||
|
||||
// Get last time
|
||||
sprintf(path, "%s/290.rec", gModulePath);
|
||||
path = gModulePath + "/290.rec";
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (fp != NULL)
|
||||
{
|
||||
// Read data
|
||||
|
@ -485,7 +486,7 @@ BOOL SaveTimeCounter(void)
|
|||
rec.counter[i] = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
|
||||
}
|
||||
|
||||
fp = fopen(path, "wb");
|
||||
fp = fopen(path.c_str(), "wb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -508,12 +509,12 @@ int LoadTimeCounter(void)
|
|||
unsigned char p[4];
|
||||
REC rec;
|
||||
FILE *fp;
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
|
||||
// Open file
|
||||
sprintf(path, "%s/290.rec", gModulePath);
|
||||
path = gModulePath + "/290.rec";
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -59,10 +60,9 @@ BOOL LoadEvent(const char *path_event)
|
|||
char code[4];
|
||||
EVENT eve;
|
||||
|
||||
char path[MAX_PATH];
|
||||
sprintf(path, "%s/%s", gDataPath, path_event);
|
||||
std::string path = gDataPath + '/' + path_event;
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -28,10 +29,9 @@ const char* const gProfileCode = "Do041220";
|
|||
|
||||
BOOL IsProfile(void)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
sprintf(path, "%s/%s", gModulePath, gDefaultName);
|
||||
std::string path = gModulePath + '/' + gDefaultName;
|
||||
|
||||
FILE *file = fopen(path, "rb");
|
||||
FILE *file = fopen(path.c_str(), "rb");
|
||||
if (file == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -45,16 +45,16 @@ BOOL SaveProfile(const char *name)
|
|||
PROFILE profile;
|
||||
const char *FLAG = "FLAG";
|
||||
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
|
||||
// Get path
|
||||
if (name != NULL)
|
||||
sprintf(path, "%s/%s", gModulePath, name);
|
||||
path = gModulePath + '/' + name;
|
||||
else
|
||||
sprintf(path, "%s/%s", gModulePath, gDefaultName);
|
||||
path = gModulePath + '/' + gDefaultName;
|
||||
|
||||
// Open file
|
||||
fp = fopen(path, "wb");
|
||||
fp = fopen(path.c_str(), "wb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -124,16 +124,16 @@ BOOL LoadProfile(const char *name)
|
|||
{
|
||||
FILE *fp;
|
||||
PROFILE profile;
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
|
||||
// Get path
|
||||
if (name != NULL)
|
||||
sprintf(path, "%s", name);
|
||||
path = name;
|
||||
else
|
||||
sprintf(path, "%s/%s", gModulePath, gDefaultName);
|
||||
path = gModulePath + '/' + gDefaultName;
|
||||
|
||||
// Open file
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "SelStage.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -156,13 +157,13 @@ void PutStageSelectObject(void)
|
|||
|
||||
int StageSelectLoop(int *p_event)
|
||||
{
|
||||
char old_script_path[MAX_PATH];
|
||||
std::string old_script_path;
|
||||
|
||||
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
|
||||
|
||||
gSelectedStage = 0;
|
||||
BackupSurface(SURFACE_ID_SCREEN_GRAB, &grcFull);
|
||||
GetTextScriptPath(old_script_path);
|
||||
old_script_path = GetTextScriptPath();
|
||||
LoadTextScript2("StageSelect.tsc");
|
||||
gStageSelectTitleY = (WINDOW_HEIGHT / 2) - 66;
|
||||
StartTextScript(gPermitStage[gSelectedStage].index + 1000);
|
||||
|
@ -211,7 +212,7 @@ int StageSelectLoop(int *p_event)
|
|||
else if (gKeyTrg & gKeyCancel)
|
||||
{
|
||||
StopTextScript();
|
||||
LoadTextScript_Stage(old_script_path);
|
||||
LoadTextScript_Stage(old_script_path.c_str());
|
||||
*p_event = 0;
|
||||
return enum_ESCRETURN_continue;
|
||||
}
|
||||
|
@ -222,7 +223,7 @@ int StageSelectLoop(int *p_event)
|
|||
return enum_ESCRETURN_exit;
|
||||
}
|
||||
|
||||
LoadTextScript_Stage(old_script_path);
|
||||
LoadTextScript_Stage(old_script_path.c_str());
|
||||
*p_event = gPermitStage[gSelectedStage].event;
|
||||
return enum_ESCRETURN_continue;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -131,8 +132,8 @@ const STAGE_TABLE gTMT[95] = {
|
|||
|
||||
BOOL TransferStage(int no, int w, int x, int y)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
char path_dir[20];
|
||||
std::string path;
|
||||
std::string path_dir;
|
||||
BOOL bError;
|
||||
|
||||
// Move character
|
||||
|
@ -141,47 +142,47 @@ BOOL TransferStage(int no, int w, int x, int y)
|
|||
bError = FALSE;
|
||||
|
||||
// Get path
|
||||
strcpy(path_dir, "Stage");
|
||||
path_dir = "Stage";
|
||||
|
||||
// Load tileset
|
||||
sprintf(path, "%s/Prt%s", path_dir, gTMT[no].parts);
|
||||
if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_TILESET))
|
||||
path = path_dir + "/Prt" + gTMT[no].parts;
|
||||
if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_TILESET))
|
||||
bError = TRUE;
|
||||
|
||||
sprintf(path, "%s/%s.pxa", path_dir, gTMT[no].parts);
|
||||
if (!LoadAttributeData(path))
|
||||
path = path_dir + '/' + gTMT[no].parts + ".pxa";
|
||||
if (!LoadAttributeData(path.c_str()))
|
||||
bError = TRUE;
|
||||
|
||||
// Load tilemap
|
||||
sprintf(path, "%s/%s.pxm", path_dir, gTMT[no].map);
|
||||
if (!LoadMapData2(path))
|
||||
path = path_dir + '/' + gTMT[no].map + ".pxm";
|
||||
if (!LoadMapData2(path.c_str()))
|
||||
bError = TRUE;
|
||||
|
||||
// Load NPCs
|
||||
sprintf(path, "%s/%s.pxe", path_dir, gTMT[no].map);
|
||||
if (!LoadEvent(path))
|
||||
path = path_dir + '/' + gTMT[no].map + ".pxe";
|
||||
if (!LoadEvent(path.c_str()))
|
||||
bError = TRUE;
|
||||
|
||||
// Load script
|
||||
sprintf(path, "%s/%s.tsc", path_dir, gTMT[no].map);
|
||||
if (!LoadTextScript_Stage(path))
|
||||
path = path_dir + '/' + gTMT[no].map + ".tsc";
|
||||
if (!LoadTextScript_Stage(path.c_str()))
|
||||
bError = TRUE;
|
||||
|
||||
// Load background
|
||||
sprintf(path, "%s", gTMT[no].back);
|
||||
if (!InitBack(path, gTMT[no].bkType))
|
||||
path = gTMT[no].back;
|
||||
if (!InitBack(path.c_str(), gTMT[no].bkType))
|
||||
bError = TRUE;
|
||||
|
||||
// Get path
|
||||
strcpy(path_dir, "Npc");
|
||||
path_dir = "Npc";
|
||||
|
||||
// Load NPC sprite sheets
|
||||
sprintf(path, "%s/Npc%s", path_dir, gTMT[no].npc);
|
||||
if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_SPRITESET_1))
|
||||
path = path_dir + "/Npc" + gTMT[no].npc;
|
||||
if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_SPRITESET_1))
|
||||
bError = TRUE;
|
||||
|
||||
sprintf(path, "%s/Npc%s", path_dir, gTMT[no].boss);
|
||||
if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_SPRITESET_2))
|
||||
path = path_dir + "/Npc" + gTMT[no].boss;
|
||||
if (!ReloadBitmap_File(path.c_str(), SURFACE_ID_LEVEL_SPRITESET_2))
|
||||
bError = TRUE;
|
||||
|
||||
if (bError)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
|
@ -124,17 +125,17 @@ void EncryptionBinaryData2(unsigned char *pData, long size)
|
|||
BOOL LoadTextScript2(const char *name)
|
||||
{
|
||||
FILE *fp;
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
|
||||
// Get path
|
||||
sprintf(path, "%s/%s", gDataPath, name);
|
||||
path = gDataPath + '/' + name;
|
||||
|
||||
gTS.size = GetFileSizeLong(path);
|
||||
gTS.size = GetFileSizeLong(path.c_str());
|
||||
if (gTS.size == -1)
|
||||
return FALSE;
|
||||
|
||||
// Open file
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -144,7 +145,7 @@ BOOL LoadTextScript2(const char *name)
|
|||
fclose(fp);
|
||||
|
||||
// Set path
|
||||
strcpy(gTS.path, name);
|
||||
gTS.path = name;
|
||||
|
||||
// Decrypt data
|
||||
EncryptionBinaryData2((unsigned char*)gTS.data, gTS.size);
|
||||
|
@ -156,18 +157,18 @@ BOOL LoadTextScript2(const char *name)
|
|||
BOOL LoadTextScript_Stage(const char *name)
|
||||
{
|
||||
FILE *fp;
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
long head_size;
|
||||
long body_size;
|
||||
|
||||
// Open Head.tsc
|
||||
sprintf(path, "%s/%s", gDataPath, "Head.tsc");
|
||||
path = gDataPath + "/Head.tsc";
|
||||
|
||||
head_size = GetFileSizeLong(path);
|
||||
head_size = GetFileSizeLong(path.c_str());
|
||||
if (head_size == -1)
|
||||
return FALSE;
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -178,13 +179,13 @@ BOOL LoadTextScript_Stage(const char *name)
|
|||
fclose(fp);
|
||||
|
||||
// Open stage's .tsc
|
||||
sprintf(path, "%s/%s", gDataPath, name);
|
||||
path = gDataPath + '/' + name;
|
||||
|
||||
body_size = GetFileSizeLong(path);
|
||||
body_size = GetFileSizeLong(path.c_str());
|
||||
if (body_size == -1)
|
||||
return FALSE;
|
||||
|
||||
fp = fopen(path, "rb");
|
||||
fp = fopen(path.c_str(), "rb");
|
||||
if (fp == NULL)
|
||||
return FALSE;
|
||||
|
||||
|
@ -196,15 +197,15 @@ BOOL LoadTextScript_Stage(const char *name)
|
|||
|
||||
// Set parameters
|
||||
gTS.size = head_size + body_size;
|
||||
strcpy(gTS.path, name);
|
||||
gTS.path = name;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Get current path
|
||||
void GetTextScriptPath(char *path)
|
||||
std::string GetTextScriptPath(void)
|
||||
{
|
||||
strcpy(path, gTS.path);
|
||||
return gTS.path;
|
||||
}
|
||||
|
||||
// Get 4 digit number from TSC data
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
typedef struct TEXT_SCRIPT
|
||||
{
|
||||
// Path (reload when exit teleporter menu/inventory)
|
||||
char path[MAX_PATH];
|
||||
std::string path;
|
||||
|
||||
// Script buffer
|
||||
long size;
|
||||
|
@ -62,7 +64,7 @@ void EndTextScript(void);
|
|||
void EncryptionBinaryData2(unsigned char *pData, long size);
|
||||
BOOL LoadTextScript2(const char *name);
|
||||
BOOL LoadTextScript_Stage(const char *name);
|
||||
void GetTextScriptPath(char *path);
|
||||
std::string GetTextScriptPath(void);
|
||||
BOOL StartTextScript(int no);
|
||||
void StopTextScript(void);
|
||||
void PutTextScript(void);
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
#undef FindResource
|
||||
#else
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define RGB(r,g,b) ((r) | ((g) << 8) | ((b) << 16))
|
||||
|
||||
typedef bool BOOL;
|
||||
|
@ -23,6 +21,4 @@ struct RECT
|
|||
long bottom;
|
||||
};
|
||||
|
||||
#define MAX_PATH FILENAME_MAX
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue