Revert more unnecessary edits

This commit is contained in:
Clownacy 2020-06-30 13:48:46 +01:00
parent 2970242ff7
commit 27a1fd900f
21 changed files with 144 additions and 55 deletions

View file

@ -2,6 +2,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string>
#include "WindowsWrapper.h"
@ -25,7 +26,9 @@ BOOL InitBack(const char *fName, int type)
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;

View file

@ -1,8 +1,9 @@
#pragma once
#include "../Attributes.h"
#include <string>
#include "../Attributes.h"
enum
{
// Based on US QWERTY

View file

@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <thread>
#include <GLFW/glfw3.h>

View file

@ -1,4 +1,5 @@
#include "../Misc.h"
#include <string>
bool Backend_Init(void)

View file

@ -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 @@ void Backend_PostWindowCreation(void)
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;
}

View file

@ -1,6 +1,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -17,7 +18,9 @@ BOOL LoadConfigData(CONFIG *conf)
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;

View file

@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -250,7 +251,7 @@ BOOL MakeSurface_Resource(const char *name, SurfaceID surf_no)
// 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 @@ BOOL ReloadBitmap_Resource(const char *name, SurfaceID surf_no)
// 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 @@ BOOL ReloadBitmap_File(const char *name, SurfaceID surf_no)
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 InitTextObject(const char *name)
{
(void)name; // Unused in this branch
std::string path = gDataPath + "/Font/font";
// Get font size
unsigned int width, height;
@ -660,7 +664,7 @@ void InitTextObject(const char *name)
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)

View file

@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -216,6 +217,7 @@ void ReleaseCreditScript(void)
BOOL StartCreditScript(void)
{
FILE *fp;
std::string path;
// Clear previously existing credits data
if (Credit.pData != NULL)
@ -225,7 +227,8 @@ BOOL StartCreditScript(void)
}
// Open file
auto path = gDataPath + '/' + credit_script;
path = gDataPath + '/' + credit_script;
Credit.size = GetFileSizeLong(path.c_str());
if (Credit.size == -1)
return FALSE;

View file

@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "WindowsWrapper.h"
@ -701,7 +702,9 @@ BOOL Game(void)
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テーブルが読めない");

View file

@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -49,12 +50,18 @@ BOOL GetCompileVersion(int *v1, int *v2, int *v3, int *v4)
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 WriteLog(const char *string, int value1, int value2, int value3)
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 @@ long GetFileSizeLong(const char *path)
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;

View file

@ -293,10 +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);
* // 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;
}

View file

@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -327,7 +328,7 @@ int main(int argc, char *argv[])
if (!Flip_SystemTask())
{
Backend_Deinit();
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
// Initialize sound

View file

@ -1,8 +1,9 @@
#pragma once
#include "WindowsWrapper.h"
#include <string>
#include "WindowsWrapper.h"
extern std::string gModulePath;
extern std::string gDataPath;

View file

@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -27,10 +28,15 @@ BOOL InitMapData2(void)
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 LoadMapData2(const char *path_map)
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;

View file

@ -1,6 +1,7 @@
#include "MycParam.h"
#include <stdio.h>
#include <string>
#include "WindowsWrapper.h"
@ -435,15 +436,17 @@ BOOL SaveTimeCounter(void)
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))
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 LoadTimeCounter(void)
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;

View file

@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -54,11 +55,14 @@ void InitNpChar(void)
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;

View file

@ -3,6 +3,7 @@
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -28,7 +29,9 @@ const char* const gProfileCode = "Do041220";
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 IsProfile(void)
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 SaveProfile(const char *name)
BOOL LoadProfile(const char *name)
{
FILE *fp;
PROFILE profile;
std::string path;
// Get path
if (name != NULL)
path = name;
else
path = gModulePath + '/' + gDefaultName;
// Open file
FILE *fp;
if (name != NULL)
fp = fopen(name, "rb");
else
fp = fopen((gModulePath + '/' + gDefaultName).c_str(), "rb");
fp = fopen(path.c_str(), "rb");
if (fp == NULL)
return FALSE;

View file

@ -1,6 +1,7 @@
#include "SelStage.h"
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -156,11 +157,13 @@ void PutStageSelectObject(void)
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);

View file

@ -2,6 +2,7 @@
#include <stdio.h>
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -131,6 +132,8 @@ const STAGE_TABLE gTMT[95] = {
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 @@ BOOL TransferStage(int no, int w, int x, int y)
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;

View file

@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "WindowsWrapper.h"
@ -124,9 +125,10 @@ void EncryptionBinaryData2(unsigned char *pData, long size)
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 LoadTextScript2(const char *name)
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 @@ BOOL LoadTextScript_Stage(const char *name)
// Open stage's .tsc
path = gDataPath + '/' + name;
body_size = GetFileSizeLong(path.c_str());
if (body_size == -1)
return FALSE;
@ -198,7 +203,7 @@ BOOL LoadTextScript_Stage(const char *name)
}
// Get current path
std::string GetTextScriptPath()
std::string GetTextScriptPath(void)
{
return gTS.path;
}
@ -1277,13 +1282,11 @@ int TextScriptProc(void)
}
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

View file

@ -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 EndTextScript(void);
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);