ref: 03e513365b530983d27dfc57cc61ab37e21a4cb2
parent: 070e4b145564440eb93444ccacbcb4f67a6cfbda
author: Clownacy <Clownacy@users.noreply.github.com>
date: Fri Aug 30 21:34:51 EDT 2019
PATH_LENGTH is actually Windows's MAX_PATH When MAX_PATH isn't available, use FILENAME_MAX. This might be a bad idea.
--- a/src/ArmsItem.cpp
+++ b/src/ArmsItem.cpp
@@ -365,7 +365,7 @@
int CampLoop()
{
int arms_num;
- char old_script_path[PATH_LENGTH];
+ char old_script_path[MAX_PATH];
RECT rcView = {0, 0, WINDOW_WIDTH, WINDOW_HEIGHT};
--- a/src/Back.cpp
+++ b/src/Back.cpp
@@ -25,7 +25,7 @@
color_black = GetCortBoxColor(RGB(0, 0, 0x10));
// Get width and height
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/%s.pbm", gDataPath, fName);
FILE *fp = fopen(path, "rb");
--- a/src/CommonDefines.h
+++ b/src/CommonDefines.h
@@ -1,6 +1,4 @@
#pragma once
-#define PATH_LENGTH 260 // Pixel had the path size locked to 260 (dangerously low), if you tried to open the executable in a path with more than around 220 characters, it'd crash.
-
#define WINDOW_WIDTH 320
#define WINDOW_HEIGHT 240
--- a/src/Config.cpp
+++ b/src/Config.cpp
@@ -4,7 +4,6 @@
#include "WindowsWrapper.h"
-#include "CommonDefines.h"
#include "Config.h"
#include "File.h"
#include "Tags.h"
@@ -18,7 +17,7 @@
memset(conf, 0, sizeof(CONFIG));
// Get path
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/%s", gModulePath, config_filename);
// Open file
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -290,7 +290,7 @@
static BOOL LoadBitmap_File(const char *name, SurfaceID surf_no, BOOL create_surface)
{
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
unsigned char *data;
size_t size;
--- a/src/Ending.cpp
+++ b/src/Ending.cpp
@@ -189,7 +189,7 @@
}
// Open file
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, credit_script);
Credit.size = GetFileSizeLong(path);
--- a/src/Game.cpp
+++ b/src/Game.cpp
@@ -702,7 +702,7 @@
PlaySoundObject(7, -1);
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/npc.tbl", gDataPath);
if (!LoadNpcTable(path))
--- a/src/Generic.cpp
+++ b/src/Generic.cpp
@@ -6,7 +6,6 @@
#include "WindowsWrapper.h"
-#include "CommonDefines.h"
#include "Tags.h"
void GetCompileDate(int *year, int *month, int *day)
@@ -45,7 +44,7 @@
VS_FIXEDFILEINFO *lpBuffer;
DWORD dwHandle;
DWORD dwLen;
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
LPVOID lpData;
BOOL bResult;
@@ -112,9 +111,9 @@
// TODO - Inaccurate stack frame
BOOL OpenVolumeConfiguration(HWND hWnd)
{
- char path[PATH_LENGTH];
- char path2[PATH_LENGTH];
- char path3[PATH_LENGTH];
+ char path[MAX_PATH];
+ char path2[MAX_PATH];
+ char path3[MAX_PATH];
int error1;
int error2;
size_t i;
@@ -142,7 +141,7 @@
#ifdef WINDOWS
void DeleteDebugLog(void)
{
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s\\debug.txt", gModulePath);
DeleteFileA(path);
@@ -150,7 +149,7 @@
BOOL PrintDebugLog(const char *string, int value1, int value2, int value3)
{
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
FILE *fp;
sprintf(path, "%s\\debug.txt", gModulePath);
@@ -198,7 +197,7 @@
BOOL CheckFileExists(const char *name)
{
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
#ifdef NONPORTABLE
sprintf(path, "%s\\%s", gModulePath, name);
@@ -250,7 +249,7 @@
#ifdef WINDOWS
BOOL PrintBitmapError(char *string, int value)
{
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
FILE *fp;
sprintf(path, "%s\\%s", gModulePath, "error.log");
@@ -320,7 +319,7 @@
// TODO - Inaccurate stack frame
BOOL LoadWindowRect(HWND hWnd, char *filename, BOOL unknown)
{
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
int min_window_width;
int min_window_height;
int max_window_width;
@@ -399,7 +398,7 @@
BOOL SaveWindowRect(HWND hWnd, const char *filename)
{
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
WINDOWPLACEMENT wndpl;
FILE *fp;
RECT rect;
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -26,8 +26,8 @@
extern SDL_Window *gWindow;
extern SDL_Renderer *gRenderer;
-char gModulePath[PATH_LENGTH];
-char gDataPath[PATH_LENGTH];
+char gModulePath[MAX_PATH];
+char gDataPath[MAX_PATH];
int gJoystickButtonTable[8];
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -30,7 +30,7 @@
unsigned char dum;
// Get path
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, path_map);
// Open file
@@ -80,7 +80,7 @@
BOOL LoadAttributeData(const char *path_atrb)
{
// Open file
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, path_atrb);
FILE *fp = fopen(path, "rb");
--- a/src/MycParam.cpp
+++ b/src/MycParam.cpp
@@ -445,7 +445,7 @@
return TRUE;
// Get last time
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/290.rec", gModulePath);
FILE *fp = fopen(path, "rb");
@@ -530,7 +530,7 @@
int i;
// Open file
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/290.rec", gModulePath);
FILE *fp = fopen(path, "rb");
--- a/src/NpChar.cpp
+++ b/src/NpChar.cpp
@@ -7,7 +7,6 @@
#include "WindowsWrapper.h"
#include "ArmsItem.h"
-#include "CommonDefines.h"
#include "Caret.h"
#include "Draw.h"
#include "File.h"
@@ -60,7 +59,7 @@
int n;
EVENT eve;
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, path_event);
fp = fopen(path, "rb");
--- a/src/Profile.cpp
+++ b/src/Profile.cpp
@@ -10,7 +10,6 @@
#include "ArmsItem.h"
#include "BossLife.h"
-#include "CommonDefines.h"
#include "Fade.h"
#include "File.h"
#include "Flags.h"
@@ -30,7 +29,7 @@
BOOL IsProfile()
{
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/%s", gModulePath, gDefaultName);
FILE *fp = fopen(path, "rb");
@@ -46,7 +45,7 @@
PROFILE profile;
FILE *fp;
const char *FLAG = "FLAG";
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
// Get path
if (name)
@@ -128,7 +127,7 @@
BOOL LoadProfile(const char *name)
{
// Get path
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
if (name)
sprintf(path, "%s", name);
--- a/src/Sound.cpp
+++ b/src/Sound.cpp
@@ -21,7 +21,6 @@
#include "WindowsWrapper.h"
-#include "CommonDefines.h"
#include "Organya.h"
#include "PixTone.h"
#include "Tags.h"
@@ -132,7 +131,7 @@
BOOL LoadSoundObject(LPCSTR file_name, int no)
{
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
DWORD i;
DWORD file_size = 0;
char check_box[58];
--- a/src/Stage.cpp
+++ b/src/Stage.cpp
@@ -9,7 +9,6 @@
#include "Boss.h"
#include "Bullet.h"
#include "Caret.h"
-#include "CommonDefines.h"
#include "Draw.h"
#include "Flash.h"
#include "Frame.h"
@@ -139,7 +138,7 @@
strcpy(path_dir, "Stage");
//Load tileset
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/Prt%s", path_dir, gTMT[no].parts);
if (!ReloadBitmap_File(path, SURFACE_ID_LEVEL_TILESET))
bError = TRUE;
--- a/src/Tags.h
+++ b/src/Tags.h
@@ -1,6 +1,6 @@
#pragma once
-#include "CommonDefines.h"
+#include "WindowsWrapper.h"
-extern char gModulePath[PATH_LENGTH];
-extern char gDataPath[PATH_LENGTH];
+extern char gModulePath[MAX_PATH];
+extern char gDataPath[MAX_PATH];
--- a/src/TextScr.cpp
+++ b/src/TextScr.cpp
@@ -146,7 +146,7 @@
BOOL LoadTextScript_Stage(const char *name)
{
//Open Head.tsc
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, "Head.tsc");
long head_size = GetFileSizeLong(path);
--- a/src/TextScr.h
+++ b/src/TextScr.h
@@ -2,12 +2,10 @@
#include "WindowsWrapper.h"
-#include "CommonDefines.h"
-
struct TEXT_SCRIPT
{
//Path (reload when exit teleporter menu/inventory)
- char path[PATH_LENGTH];
+ char path[MAX_PATH];
//Script buffer
int size;
--- a/src/WindowsWrapper.h
+++ b/src/WindowsWrapper.h
@@ -8,6 +8,8 @@
#undef CreateWindow
#else
+#include <stdio.h>
+
typedef int HWND;
typedef int BOOL;
@@ -34,6 +36,10 @@
rect.top = t; \
rect.right = r; \
rect.bottom = b;
+
+#ifndef MAX_PATH
+#define MAX_PATH FILENAME_MAX
+#endif
int rep_rand();
void rep_srand(unsigned int seed);
--
⑨