PATH_LENGTH is actually Windows's MAX_PATH

When MAX_PATH isn't available, use FILENAME_MAX. This might be a bad
idea.
This commit is contained in:
Clownacy 2019-08-31 01:34:51 +01:00
parent 070e4b1455
commit 03e513365b
19 changed files with 39 additions and 43 deletions

View file

@ -365,7 +365,7 @@ void PutCampObject()
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};

View file

@ -25,7 +25,7 @@ BOOL InitBack(const char *fName, int type)
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");

View file

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

View file

@ -4,7 +4,6 @@
#include "WindowsWrapper.h"
#include "CommonDefines.h"
#include "Config.h"
#include "File.h"
#include "Tags.h"
@ -18,7 +17,7 @@ BOOL LoadConfigData(CONFIG *conf)
memset(conf, 0, sizeof(CONFIG));
// Get path
char path[PATH_LENGTH];
char path[MAX_PATH];
sprintf(path, "%s/%s", gModulePath, config_filename);
// Open file

View file

@ -290,7 +290,7 @@ static unsigned char* LoadFileToMemory(const char *path, size_t *size)
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;

View file

@ -189,7 +189,7 @@ BOOL StartCreditScript()
}
// Open file
char path[PATH_LENGTH];
char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, credit_script);
Credit.size = GetFileSizeLong(path);

View file

@ -702,7 +702,7 @@ BOOL Game(HWND hWnd)
PlaySoundObject(7, -1);
char path[PATH_LENGTH];
char path[MAX_PATH];
sprintf(path, "%s/npc.tbl", gDataPath);
if (!LoadNpcTable(path))

View file

@ -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 @@ BOOL GetCompileVersion(int *v1, int *v2, int *v3, int *v4)
VS_FIXEDFILEINFO *lpBuffer;
DWORD dwHandle;
DWORD dwLen;
char path[PATH_LENGTH];
char path[MAX_PATH];
LPVOID lpData;
BOOL bResult;
@ -112,9 +111,9 @@ BOOL GetCompileVersion(int *v1, int *v2, int *v3, int *v4)
// 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 @@ BOOL OpenVolumeConfiguration(HWND hWnd)
#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 @@ void DeleteDebugLog(void)
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 @@ int CheckTime(SYSTEMTIME *system_time_low, SYSTEMTIME *system_time_high)
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 @@ long GetFileSizeLong(const char *path)
#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 @@ BOOL CenterWindow(HWND hWnd)
// 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 LoadWindowRect(HWND hWnd, char *filename, BOOL unknown)
BOOL SaveWindowRect(HWND hWnd, const char *filename)
{
char path[PATH_LENGTH];
char path[MAX_PATH];
WINDOWPLACEMENT wndpl;
FILE *fp;
RECT rect;

View file

@ -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];

View file

@ -30,7 +30,7 @@ BOOL LoadMapData2(const char *path_map)
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 LoadMapData2(const char *path_map)
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");

View file

@ -445,7 +445,7 @@ BOOL SaveTimeCounter()
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 LoadTimeCounter()
int i;
// Open file
char path[PATH_LENGTH];
char path[MAX_PATH];
sprintf(path, "%s/290.rec", gModulePath);
FILE *fp = fopen(path, "rb");

View file

@ -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 @@ BOOL LoadEvent(const char *path_event)
int n;
EVENT eve;
char path[PATH_LENGTH];
char path[MAX_PATH];
sprintf(path, "%s/%s", gDataPath, path_event);
fp = fopen(path, "rb");

View file

@ -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 @@ const char *gProfileCode = "Do041220";
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 @@ BOOL SaveProfile(const char *name)
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 SaveProfile(const char *name)
BOOL LoadProfile(const char *name)
{
// Get path
char path[PATH_LENGTH];
char path[MAX_PATH];
if (name)
sprintf(path, "%s", name);

View file

@ -21,7 +21,6 @@ equivalents.
#include "WindowsWrapper.h"
#include "CommonDefines.h"
#include "Organya.h"
#include "PixTone.h"
#include "Tags.h"
@ -132,7 +131,7 @@ BOOL InitSoundObject(LPCSTR resname, int no)
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];

View file

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

View file

@ -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];

View file

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

View file

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

View file

@ -8,6 +8,8 @@
#undef CreateWindow
#else
#include <stdio.h>
typedef int HWND;
typedef int BOOL;
@ -35,6 +37,10 @@ struct RECT
rect.right = r; \
rect.bottom = b;
#ifndef MAX_PATH
#define MAX_PATH FILENAME_MAX
#endif
int rep_rand();
void rep_srand(unsigned int seed);