Replace MAX_PATH with COMPAT_MAX_PATH

This commit is contained in:
Alexander Batalov 2022-05-28 12:34:49 +03:00
parent 4bac829739
commit b1216967c0
52 changed files with 166 additions and 154 deletions

View File

@ -6,7 +6,6 @@
#include "game_config.h"
#include "memory.h"
#include "object.h"
#include "platform_compat.h"
#include "proto.h"
#include <stdio.h>
@ -75,7 +74,7 @@ char gArtLanguage[32];
Cache gArtCache;
// 0x56C9E4
char _art_name[MAX_PATH];
char _art_name[COMPAT_MAX_PATH];
// head_info
// 0x56CAE8
@ -92,7 +91,7 @@ int* gArtCritterFidShoudRunData;
// 0x418840
int artInit()
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
int i;
File* stream;
char str[200];
@ -897,7 +896,7 @@ int artCacheGetFileSizeImpl(int fid, int* sizePtr)
char* str;
char* ptr;
int result;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
bool loaded;
int fileSize;
@ -955,7 +954,7 @@ int artCacheReadDataImpl(int fid, int* sizePtr, unsigned char* data)
char* str;
char* ptr;
int result;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
bool loaded;
v4 = -1;

View File

@ -5,11 +5,9 @@
#include "db.h"
#include "heap.h"
#include "obj_types.h"
#include "platform_compat.h"
#include "proto_types.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef enum Head {
HEAD_INVALID,
HEAD_MARCUS,
@ -136,7 +134,7 @@ extern int _art_mapper_blank_tile;
extern char gArtLanguage[32];
extern Cache gArtCache;
extern char _art_name[MAX_PATH];
extern char _art_name[COMPAT_MAX_PATH];
extern HeadDescription* gHeadDescriptions;
extern int* _anon_alias;
extern int* gArtCritterFidShoudRunData;

View File

@ -2,6 +2,7 @@
#include "debug.h"
#include "memory_manager.h"
#include "platform_compat.h"
#include "sound.h"
#include <assert.h>
@ -9,9 +10,6 @@
#include <stdio.h>
#include <string.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
// 0x5108C0
AudioFileIsCompressedProc* _queryCompressedFunc_2 = _defaultCompressionFunc__;
@ -41,7 +39,7 @@ int audioFileSoundDecoderReadHandler(int fileHandle, void* buffer, unsigned int
// 0x41A88C
int audioFileOpen(const char* fname, int flags, ...)
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
strcpy(path, fname);
int compression;

View File

@ -15,6 +15,7 @@
#include "map.h"
#include "memory.h"
#include "object.h"
#include "platform_compat.h"
#include "text_font.h"
#include "window_manager.h"
@ -232,7 +233,7 @@ void automapExit()
{
char* masterPatchesPath;
if (configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &masterPatchesPath)) {
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\%s\\%s", masterPatchesPath, "MAPS", AUTOMAP_DB);
remove(path);
}
@ -864,7 +865,7 @@ int automapLoadEntry(int map, int elevation)
{
gAutomapEntry.compressedData = NULL;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\%s", "MAPS", AUTOMAP_DB);
bool success = true;
@ -1039,7 +1040,7 @@ int automapCreate()
gAutomapHeader.dataSize = 1925;
memcpy(gAutomapHeader.offsets, _defam, sizeof(_defam));
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\%s", "MAPS", AUTOMAP_DB);
File* stream = fileOpen(path, "wb");
@ -1094,7 +1095,7 @@ int _copy_file_data(File* stream1, File* stream2, int length)
// 0x41CE74
int automapGetHeader(AutomapHeader** automapHeaderPtr)
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\%s", "MAPS", AUTOMAP_DB);
File* stream = fileOpen(path, "rb");

View File

@ -988,7 +988,7 @@ int characterEditorWindowInit()
int i;
int v1;
int v3;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
int fid;
char* str;
int len;
@ -3745,7 +3745,7 @@ int _OptionWindow()
}
} else if (keyCode == 501 || keyCode == KEY_UPPERCASE_L || keyCode == KEY_LOWERCASE_L) {
// LOAD
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
path[0] = '\0';
strcat(path, "*.");
strcat(path, "GCD");

View File

@ -11,7 +11,8 @@
#include "stat_defs.h"
#include "trait_defs.h"
#define DIALOG_PICKER_NUM_OPTIONS max(PERK_COUNT, TRAIT_COUNT)
// TODO: Should be MAX(PERK_COUNT, TRAIT_COUNT).
#define DIALOG_PICKER_NUM_OPTIONS PERK_COUNT
#define TOWN_REPUTATION_COUNT 19
#define ADDICTION_REPUTATION_COUNT 8

View File

@ -14,6 +14,7 @@
#include "object.h"
#include "options.h"
#include "palette.h"
#include "platform_compat.h"
#include "proto.h"
#include "skill.h"
#include "stat.h"
@ -613,7 +614,7 @@ void characterSelectorWindowFree()
// 0x4A7D58
bool characterSelectorWindowRefresh()
{
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s.gcd", gPremadeCharacterDescriptions[gCurrentPremadeCharacter].fileName);
if (_proto_dude_init(path) == -1) {
debugPrint("\n ** Error in dude init! **\n");
@ -919,7 +920,7 @@ bool characterSelectorWindowRenderBio()
int oldFont = fontGetCurrent();
fontSetCurrent(101);
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s.bio", gPremadeCharacterDescriptions[gCurrentPremadeCharacter].fileName);
File* stream = fileOpen(path, "rt");

View File

@ -24,6 +24,7 @@
#include "object.h"
#include "perk.h"
#include "pipboy.h"
#include "platform_compat.h"
#include "proto.h"
#include "queue.h"
#include "random.h"
@ -1864,7 +1865,7 @@ Attack _explosion_ctd;
int combatInit()
{
int max_action_points;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
_combat_turn_running = 0;
_combatNumTurns = 0;

View File

@ -3252,7 +3252,7 @@ int aiMessageListInit()
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "combatai.msg");
if (!messageListLoad(&gCombatAiMessageList, path)) {

View File

@ -10,6 +10,7 @@
#include "memory.h"
#include "message.h"
#include "palette.h"
#include "platform_compat.h"
#include "sound.h"
#include "text_font.h"
#include "window_manager.h"
@ -52,7 +53,7 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
soundContinueAll();
char localizedPath[MAX_PATH];
char localizedPath[COMPAT_MAX_PATH];
if (_message_make_path(localizedPath, filePath)) {
gCreditsFile = fileOpen(localizedPath, "rt");
if (gCreditsFile != NULL) {

View File

@ -14,6 +14,7 @@
#include "memory.h"
#include "object.h"
#include "party_member.h"
#include "platform_compat.h"
#include "proto.h"
#include "queue.h"
#include "random.h"
@ -124,7 +125,7 @@ int critterInit()
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%sscrname.msg", asc_5186C8);
if (!messageListLoad(&gCritterMessageList, path)) {

View File

@ -8,6 +8,7 @@
#include "game.h"
#include "game_sound.h"
#include "message.h"
#include "platform_compat.h"
#include "text_font.h"
#include "window_manager.h"
#include "word_wrap.h"
@ -205,7 +206,7 @@ int showDialogBox(const char* title, const char** body, int bodyLength, int x, i
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "DBOX.MSG");
if (!messageListLoad(&messageList, path)) {
@ -303,7 +304,7 @@ int showDialogBox(const char* title, const char** body, int bodyLength, int x, i
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "DBOX.MSG");
if (!messageListLoad(&messageList, path)) {
@ -492,7 +493,7 @@ int _save_file_dialog(char* a1, char** fileList, char* fileName, int fileListLen
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "DBOX.MSG");
if (!messageListLoad(&messageList, path)) {

View File

@ -1,8 +1,7 @@
#ifndef DFILE_H
#define DFILE_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "platform_compat.h"
#include <stdio.h>
#include <zlib.h>
@ -116,13 +115,13 @@ typedef struct DFile {
typedef struct DFileFindData {
// The name of file that was found during previous search.
char fileName[MAX_PATH];
char fileName[COMPAT_MAX_PATH];
// The pattern to search.
//
// This value is set automatically when [dbaseFindFirstEntry] succeeds so
// that subsequent calls to [dbaseFindNextEntry] know what to look for.
char pattern[MAX_PATH];
char pattern[COMPAT_MAX_PATH];
// The index of entry that was found during previous search.
//

View File

@ -1,6 +1,7 @@
#include "electronic_registration.h"
#include "game_config.h"
#include "platform_compat.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -11,7 +12,7 @@ void runElectronicRegistration()
int timesRun = 0;
configGetInt(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_TIMES_RUN_KEY, &timesRun);
if (timesRun > 0 && timesRun < 5) {
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
if (GetModuleFileNameA(NULL, path, sizeof(path)) != 0) {
char* pch = strrchr(path, '\\');
if (pch == NULL) {

View File

@ -87,7 +87,7 @@ char gEndgameDeathEndingFileName[40];
bool gEndgameEndingVoiceOverSpeechLoaded;
// 0x570ABC
char gEndgameEndingSubtitlesLocalizedPath[MAX_PATH];
char gEndgameEndingSubtitlesLocalizedPath[COMPAT_MAX_PATH];
// The flag used to denote voice over speech for current slide has ended.
//
@ -580,7 +580,7 @@ void endgameEndingSlideshowWindowFree()
// 0x4401A0
void endgameEndingVoiceOverInit(const char* fileBaseName)
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
// NOTE: Uninline.
endgameEndingVoiceOverFree();
@ -666,7 +666,7 @@ void endgameEndingLoadPalette(int type, int id)
}
if (strlen(fileName) <= 8) {
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\%s.pal", "art\\intrface", fileName);
colorPaletteLoad(path);
}

View File

@ -1,9 +1,7 @@
#ifndef ENDGAME_H
#define ENDGAME_H
// Provides [MAX_PATH].
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "platform_compat.h"
typedef enum EndgameDeathEndingReason {
// Dude died.
@ -46,7 +44,7 @@ extern int gEndgameDeathEndingsLength;
extern char gEndgameDeathEndingFileName[40];
extern bool gEndgameEndingVoiceOverSpeechLoaded;
extern char gEndgameEndingSubtitlesLocalizedPath[MAX_PATH];
extern char gEndgameEndingSubtitlesLocalizedPath[COMPAT_MAX_PATH];
extern bool gEndgameEndingSpeechEnded;
extern EndgameEnding* gEndgameEndings;
extern char** gEndgameEndingSubtitles;

View File

@ -111,7 +111,7 @@ int _critter_db_handle;
// 0x442580
int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int a4, int argc, char** argv)
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
if (gameMemoryInit() == -1) {
return -1;
@ -725,7 +725,7 @@ int gameHandleKey(int eventCode, bool isInCombatMode)
MessageList messageList;
if (messageListInit(&messageList)) {
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "editor.msg");
if (messageListLoad(&messageList, path)) {
@ -1162,7 +1162,7 @@ int gameDbInit()
char* main_file_name;
char* patch_file_name;
int patch_index;
char filename[MAX_PATH];
char filename[COMPAT_MAX_PATH];
hashing = 0;
main_file_name = NULL;

View File

@ -1,6 +1,7 @@
#include "game_config.h"
#include "main.h"
#include "platform_compat.h"
#include <stdio.h>
#include <string.h>
@ -19,7 +20,7 @@ Config gGameConfig;
// probably means it's size is 264 bytes.
//
// 0x58E978
char gGameConfigFilePath[FILENAME_MAX];
char gGameConfigFilePath[COMPAT_MAX_PATH];
// Inits main game config.
//

View File

@ -11,7 +11,6 @@
#include "movie.h"
#include "movie_effect.h"
#include "palette.h"
#include "platform_compat.h"
#include "text_font.h"
#include "widget.h"
#include "window_manager.h"
@ -77,7 +76,7 @@ bool gGameMovieFaded = false;
unsigned char gGameMoviesSeen[MOVIE_COUNT];
// 0x596C89
char gGameMovieSubtitlesFilePath[MAX_PATH];
char gGameMovieSubtitlesFilePath[COMPAT_MAX_PATH];
// gmovie_init
// 0x44E5C0
@ -145,7 +144,7 @@ int gameMoviePlay(int movie, int flags)
return -1;
}
char movieFilePath[MAX_PATH];
char movieFilePath[COMPAT_MAX_PATH];
int movieFileSize;
bool movieFound = false;

View File

@ -2,9 +2,7 @@
#define GAME_MOVIE_H
#include "db.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "platform_compat.h"
typedef enum GameMovieFlags {
GAME_MOVIE_FADE_IN = 0x01,
@ -41,7 +39,7 @@ extern char* gMoviePaletteFilePaths[MOVIE_COUNT];
extern bool gGameMovieIsPlaying;
extern bool gGameMovieFaded;
extern char gGameMovieSubtitlesFilePath[MAX_PATH];
extern char gGameMovieSubtitlesFilePath[COMPAT_MAX_PATH];
extern unsigned char gGameMoviesSeen[MOVIE_COUNT];
int gameMoviesInit();

View File

@ -13,7 +13,6 @@
#include "memory.h"
#include "movie.h"
#include "object.h"
#include "platform_compat.h"
#include "proto.h"
#include "queue.h"
#include "random.h"
@ -125,7 +124,7 @@ int _detectDevices = -1;
int _lastTime_1 = 0;
// 0x596EB0
char _background_fname_copied[MAX_PATH];
char _background_fname_copied[COMPAT_MAX_PATH];
// 0x596FB5
char _sfx_file_name[13];
@ -614,7 +613,7 @@ int backgroundSoundLoad(const char* fileName, int a2, int a3, int a4)
return -1;
}
char path[MAX_PATH + 1];
char path[COMPAT_MAX_PATH + 1];
if (a3 == 13) {
rc = gameSoundFindBackgroundSoundPath(path, fileName);
} else if (a3 == 14) {
@ -838,7 +837,7 @@ int speechGetDuration()
// 0x450CA0
int speechLoad(const char* fname, int a2, int a3, int a4)
{
char path[MAX_PATH + 1];
char path[COMPAT_MAX_PATH + 1];
if (!gGameSoundInitialized) {
return -1;
@ -1064,7 +1063,7 @@ Sound* soundEffectLoad(const char* name, Object* object)
++_gsound_active_effect_counter;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s%s", _sound_sfx_path, name, ".ACM");
if (soundLoad(sound, path) == 0) {
@ -1675,7 +1674,7 @@ int _gsound_background_allocate(Sound** soundPtr, int a2, int a3)
int gameSoundFindBackgroundSoundPathWithCopy(char* dest, const char* src)
{
size_t len = strlen(src) + strlen(".ACM");
if (strlen(_sound_music_path1) + len > MAX_PATH || strlen(_sound_music_path2) + len > MAX_PATH) {
if (strlen(_sound_music_path1) + len > COMPAT_MAX_PATH || strlen(_sound_music_path2) + len > COMPAT_MAX_PATH) {
if (gGameSoundDebugEnabled) {
debugPrint("Full background path too long.\n");
}
@ -1687,11 +1686,11 @@ int gameSoundFindBackgroundSoundPathWithCopy(char* dest, const char* src)
debugPrint(" finding background sound ");
}
char outPath[MAX_PATH];
char outPath[COMPAT_MAX_PATH];
sprintf(outPath, "%s%s%s", _sound_music_path1, src, ".ACM");
if (_gsound_file_exists_f(outPath)) {
strncpy(dest, outPath, MAX_PATH);
dest[MAX_PATH] = '\0';
strncpy(dest, outPath, COMPAT_MAX_PATH);
dest[COMPAT_MAX_PATH] = '\0';
return 0;
}
@ -1701,7 +1700,7 @@ int gameSoundFindBackgroundSoundPathWithCopy(char* dest, const char* src)
gameSoundDeleteOldMusicFile();
char inPath[MAX_PATH];
char inPath[COMPAT_MAX_PATH];
sprintf(inPath, "%s%s%s", _sound_music_path2, src, ".ACM");
FILE* inStream = fopen(inPath, "rb");
@ -1764,8 +1763,8 @@ int gameSoundFindBackgroundSoundPathWithCopy(char* dest, const char* src)
strcpy(_background_fname_copied, src);
strncpy(dest, outPath, MAX_PATH);
dest[MAX_PATH] = '\0';
strncpy(dest, outPath, COMPAT_MAX_PATH);
dest[COMPAT_MAX_PATH] = '\0';
return 0;
}
@ -1773,11 +1772,11 @@ int gameSoundFindBackgroundSoundPathWithCopy(char* dest, const char* src)
// 0x451E2C
int gameSoundFindBackgroundSoundPath(char* dest, const char* src)
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
int len;
len = strlen(src) + strlen(".ACM");
if (strlen(_sound_music_path1) + len > MAX_PATH || strlen(_sound_music_path2) + len > MAX_PATH) {
if (strlen(_sound_music_path1) + len > COMPAT_MAX_PATH || strlen(_sound_music_path2) + len > COMPAT_MAX_PATH) {
if (gGameSoundDebugEnabled) {
debugPrint("Full background path too long.\n");
}
@ -1791,8 +1790,8 @@ int gameSoundFindBackgroundSoundPath(char* dest, const char* src)
sprintf(path, "%s%s%s", _sound_music_path1, src, ".ACM");
if (_gsound_file_exists_f(path)) {
strncpy(dest, path, MAX_PATH);
dest[MAX_PATH] = '\0';
strncpy(dest, path, COMPAT_MAX_PATH);
dest[COMPAT_MAX_PATH] = '\0';
return 0;
}
@ -1802,8 +1801,8 @@ int gameSoundFindBackgroundSoundPath(char* dest, const char* src)
sprintf(path, "%s%s%s", _sound_music_path2, src, ".ACM");
if (_gsound_file_exists_f(path)) {
strncpy(dest, path, MAX_PATH);
dest[MAX_PATH] = '\0';
strncpy(dest, path, COMPAT_MAX_PATH);
dest[COMPAT_MAX_PATH] = '\0';
return 0;
}
@ -1817,9 +1816,9 @@ int gameSoundFindBackgroundSoundPath(char* dest, const char* src)
// 0x451F94
int gameSoundFindSpeechSoundPath(char* dest, const char* src)
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
if (strlen(_sound_speech_path) + strlen(".acm") > MAX_PATH) {
if (strlen(_sound_speech_path) + strlen(".acm") > COMPAT_MAX_PATH) {
if (gGameSoundDebugEnabled) {
// FIXME: The message is wrong (notes background path, but here
// we're dealing with speech path).
@ -1845,8 +1844,8 @@ int gameSoundFindSpeechSoundPath(char* dest, const char* src)
return -1;
}
strncpy(dest, path, MAX_PATH);
dest[MAX_PATH] = '\0';
strncpy(dest, path, COMPAT_MAX_PATH);
dest[COMPAT_MAX_PATH] = '\0';
return 0;
}
@ -1856,7 +1855,7 @@ int gameSoundFindSpeechSoundPath(char* dest, const char* src)
void gameSoundDeleteOldMusicFile()
{
if (_background_fname_copied[0] != '\0') {
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s%s", "sound\\music\\", _background_fname_copied, ".ACM");
if (remove(path)) {
if (gGameSoundDebugEnabled) {

View File

@ -2,6 +2,7 @@
#define GAME_SOUND_H
#include "obj_types.h"
#include "platform_compat.h"
#include "sound.h"
#define WIN32_LEAN_AND_MEAN
@ -71,7 +72,7 @@ extern int gSoundEffectsVolume;
extern int _detectDevices;
extern int _lastTime_1;
extern char _background_fname_copied[MAX_PATH];
extern char _background_fname_copied[COMPAT_MAX_PATH];
extern char _sfx_file_name[13];
extern char gBackgroundSoundFileName[270];

View File

@ -18,6 +18,7 @@
#include "item.h"
#include "memory.h"
#include "object.h"
#include "platform_compat.h"
#include "proto.h"
#include "proto_instance.h"
#include "proto_types.h"
@ -2318,7 +2319,7 @@ int indicatorBarInit()
rc = -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "intrface.msg");
if (rc != -1) {

View File

@ -23,6 +23,7 @@
#include "map.h"
#include "object.h"
#include "perk.h"
#include "platform_compat.h"
#include "proto.h"
#include "proto_instance.h"
#include "random.h"
@ -356,7 +357,7 @@ void _inven_reset_dude()
// 0x46E73C
int inventoryMessageListInit()
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
if (!messageListInit(&gInventoryMessageList))
return -1;

View File

@ -14,6 +14,7 @@
#include "memory.h"
#include "object.h"
#include "perk.h"
#include "platform_compat.h"
#include "proto.h"
#include "proto_instance.h"
#include "queue.h"
@ -110,7 +111,7 @@ int itemsInit()
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "item.msg");
if (!messageListLoad(&gItemsMessageList, path)) {

View File

@ -5,6 +5,7 @@
#include "debug.h"
#include "game_sound.h"
#include "memory.h"
#include "platform_compat.h"
#include "sound.h"
#include <stdio.h>
@ -393,7 +394,7 @@ int _lips_make_speech()
gLipsData.field_14 = NULL;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
char* v1 = _lips_fix_string(gLipsData.field_50, sizeof(gLipsData.field_50));
sprintf(path, "%s%s\\%s.%s", "SOUND\\SPEECH\\", _lips_subdir_name, v1, "ACM");

View File

@ -190,22 +190,22 @@ unsigned char* gLoadSaveFrmData[LOAD_SAVE_FRM_COUNT];
unsigned char* _snapshot;
// 0x6142F0
char _str2[MAX_PATH];
char _str2[COMPAT_MAX_PATH];
// 0x6143F4
char _str0[MAX_PATH];
char _str0[COMPAT_MAX_PATH];
// 0x6144F8
char _str1[MAX_PATH];
char _str1[COMPAT_MAX_PATH];
// 0x6145FC
char _str[MAX_PATH];
char _str[COMPAT_MAX_PATH];
// 0x614700
unsigned char* gLoadSaveWindowBuffer;
// 0x614704
char _gmpath[MAX_PATH];
char _gmpath[COMPAT_MAX_PATH];
// 0x614808
File* _flptr;
@ -289,7 +289,7 @@ int lsgSaveGame(int mode)
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "LSGAME.MSG");
if (!messageListLoad(&gLoadSaveMessageList, path)) {
return -1;
@ -687,7 +687,7 @@ int lsgLoadGame(int mode)
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\%s", asc_5186C8, "LSGAME.MSG");
if (!messageListLoad(&gLoadSaveMessageList, path)) {
return -1;
@ -2132,7 +2132,7 @@ int _GameMap2Slot(File* stream)
continue;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
if (_proto_list_str(pid, path) != 0) {
continue;
}
@ -2268,7 +2268,7 @@ int _SlotMap2Game(File* stream)
for (int index = 1; index < gPartyMemberDescriptionsLength; index += 1) {
int pid = gPartyMemberPids[index];
if (pid != -2) {
char protoPath[MAX_PATH];
char protoPath[COMPAT_MAX_PATH];
if (_proto_list_str(pid, protoPath) == 0) {
const char* basePath = pid >> 24 == OBJ_TYPE_CRITTER
? "PROTO\\CRITTERS"
@ -2429,7 +2429,7 @@ out:
// 0x48000C
void lsgInit()
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\", "MAPS");
_MapDirErase(path, "SAV");
}
@ -2437,7 +2437,7 @@ void lsgInit()
// 0x480040
int _MapDirErase(const char* relativePath, const char* extension)
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s*.%s", relativePath, extension);
char** fileList;
@ -2454,7 +2454,7 @@ int _MapDirErase(const char* relativePath, const char* extension)
// 0x4800C8
int _MapDirEraseFile_(const char* a1, const char* a2)
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\%s%s", _patches, a1, a2);
if (remove(path) != 0) {

View File

@ -5,9 +5,7 @@
#include "db.h"
#include "geometry.h"
#include "message.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "platform_compat.h"
#define LOAD_SAVE_DESCRIPTION_LENGTH (30)
#define LOAD_SAVE_HANDLER_COUNT (27)
@ -103,12 +101,12 @@ extern int _dbleclkcntr;
extern int gLoadSaveWindow;
extern unsigned char* gLoadSaveFrmData[LOAD_SAVE_FRM_COUNT];
extern unsigned char* _snapshot;
extern char _str2[MAX_PATH];
extern char _str0[MAX_PATH];
extern char _str1[MAX_PATH];
extern char _str[MAX_PATH];
extern char _str2[COMPAT_MAX_PATH];
extern char _str0[COMPAT_MAX_PATH];
extern char _str1[COMPAT_MAX_PATH];
extern char _str[COMPAT_MAX_PATH];
extern unsigned char* gLoadSaveWindowBuffer;
extern char _gmpath[MAX_PATH];
extern char _gmpath[COMPAT_MAX_PATH];
extern File* _flptr;
extern int _ls_error_code;
extern int gLoadSaveWindowOldFont;

View File

@ -20,6 +20,7 @@
#include "object.h"
#include "options.h"
#include "palette.h"
#include "platform_compat.h"
#include "random.h"
#include "scripts.h"
#include "sfall_config.h"
@ -510,7 +511,7 @@ int _mainDeathGrabTextFile(const char* fileName, char* dest)
language = _aEnglish_2;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "text\\%s\\cuts\\%s%s", language, p + 1, ".TXT");
File* stream = fileOpen(path, "rt");

View File

@ -23,7 +23,6 @@
#include "object.h"
#include "palette.h"
#include "pipboy.h"
#include "platform_compat.h"
#include "proto.h"
#include "proto_instance.h"
#include "queue.h"
@ -131,7 +130,7 @@ char _scratchStr[40];
// Last map file name.
//
// 0x631E78
char _map_path[MAX_PATH];
char _map_path[COMPAT_MAX_PATH];
// iso_init
// 0x481CA0
@ -261,7 +260,7 @@ void _map_init()
}
if (messageListInit(&gMapMessageList)) {
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
sprintf(path, "%smap.msg", asc_5186C8);
if (!messageListLoad(&gMapMessageList, path)) {
@ -876,7 +875,7 @@ int mapLoad(File* stream)
gMapHeader.field_34 = mapGetIndexByFileName(gMapHeader.name);
if ((gMapHeader.flags & 1) == 0) {
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "maps\\%s", gMapHeader.name);
char* extension = strstr(path, ".MAP");
@ -1443,7 +1442,7 @@ int _map_save_in_game(bool a1)
// 0x483E28
void mapMakeMapsDirectory()
{
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
char* masterPatchesPath;
if (configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &masterPatchesPath)) {

View File

@ -6,9 +6,7 @@
#include "geometry.h"
#include "map_defs.h"
#include "message.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "platform_compat.h"
#define ORIGINAL_ISO_WINDOW_WIDTH 640
#define ORIGINAL_ISO_WINDOW_HEIGHT 380
@ -91,7 +89,7 @@ extern MapHeader gMapHeader;
extern TileData* _square[ELEVATION_COUNT];
extern int gIsoWindow;
extern char _scratchStr[40];
extern char _map_path[MAX_PATH];
extern char _map_path[COMPAT_MAX_PATH];
int isoInit();
void isoReset();

View File

@ -167,7 +167,7 @@ bool messageListFree(MessageList* messageList)
bool messageListLoad(MessageList* messageList, const char* path)
{
char* language;
char localized_path[FILENAME_MAX];
char localized_path[COMPAT_MAX_PATH];
File* file_ptr;
char num[1024];
char audio[1024];

View File

@ -8,6 +8,7 @@
#include "memory_manager.h"
#include "movie_effect.h"
#include "movie_lib.h"
#include "platform_compat.h"
#include "sound.h"
#include "text_font.h"
#include "window_manager.h"
@ -521,7 +522,7 @@ void movieLoadSubtitles(char* filePath)
filePath = gMovieBuildSubtitleFilePathProc(filePath);
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
strcpy(path, filePath);
debugPrint("Opening subtitle file %s\n", path);

View File

@ -93,7 +93,7 @@ int movieEffectsLoad(const char* filePath)
int rc = -1;
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
strcpy(path, filePath);
char* pch = strrchr(path, '.');

View File

@ -14,6 +14,7 @@
#include "grayscale.h"
#include "loadsave.h"
#include "memory.h"
#include "platform_compat.h"
#include "scripts.h"
#include "text_font.h"
#include "text_object.h"
@ -453,7 +454,7 @@ int optionsWindowInit()
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "options.msg");
if (!messageListLoad(&gOptionsMessageList, path)) {
return -1;
@ -633,7 +634,7 @@ int showPause(bool a1)
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "options.msg");
if (!messageListLoad(&gOptionsMessageList, path)) {
// FIXME: Leaking graphics.

View File

@ -6,6 +6,7 @@
#include "memory.h"
#include "object.h"
#include "party_member.h"
#include "platform_compat.h"
#include "skill.h"
#include "stat.h"
@ -164,7 +165,7 @@ int perksInit()
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "perk.msg");
if (!messageListLoad(&gPerksMessageList, path)) {

View File

@ -19,6 +19,7 @@
#include "map.h"
#include "memory.h"
#include "object.h"
#include "platform_compat.h"
#include "queue.h"
#include "random.h"
#include "scripts.h"
@ -315,7 +316,7 @@ int pipboyWindowInit(bool forceRest)
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "pipboy.msg");
if (!(messageListLoad(&gPipboyMessageList, path))) {

View File

@ -4,6 +4,12 @@
// TODO: This is compatibility cross-platform layer. Designed to have minimal
// impact on the codebase. Remove once it's no longer needed.
// A naive cross-platform MAX_PATH/PATH_MAX/MAX_PATH drop-in replacement.
//
// TODO: Remove when we migrate to use std::filesystem::path or std::string to
// represent paths across the codebase.
#define COMPAT_MAX_PATH 260
int compat_stricmp(const char* string1, const char* string2);
int compat_strnicmp(const char* string1, const char* string2, size_t size);
char* compat_strupr(char* string);

View File

@ -33,7 +33,7 @@ char _aDrugStatSpecia[] = "Drug Stat (Special)";
char _aNone_1[] = "None";
// 0x51C18C
char _cd_path_base[MAX_PATH];
char _cd_path_base[COMPAT_MAX_PATH];
// 0x51C290
ProtoList _protoLists[11] = {
@ -173,8 +173,8 @@ char** _critter_stats_list;
// 0x49E758
int _proto_list_str(int pid, char* proto_path)
{
char path[MAX_PATH];
char str[MAX_PATH];
char path[COMPAT_MAX_PATH];
char str[COMPAT_MAX_PATH];
char* pch;
File* stream;
int i;
@ -1037,7 +1037,7 @@ int protoInit()
char* master_patches;
int len;
MessageListItem messageListItem;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
int i;
if (!configGetString(&gGameConfig, GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY, &master_patches)) {
@ -1215,7 +1215,7 @@ int _proto_header_load()
ptr->length = 0;
ptr->max_entries_num = 1;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
strcpy(path, _cd_path_base);
strcat(path, _proto_path_base);
strcat(path, artGetObjectTypeName(index));
@ -1654,7 +1654,7 @@ int _proto_save_pid(int pid)
// 0x4A1C3C
int _proto_load_pid(int pid, Proto** protoPtr)
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
strcpy(path, _cd_path_base);
strcat(path, "proto\\");

View File

@ -5,13 +5,11 @@
#include "message.h"
#include "obj_types.h"
#include "perk_defs.h"
#include "platform_compat.h"
#include "proto_types.h"
#include "skill_defs.h"
#include "stat_defs.h"
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
typedef enum ItemDataMember {
ITEM_DATA_MEMBER_PID = 0,
ITEM_DATA_MEMBER_NAME = 1,
@ -97,7 +95,7 @@ typedef enum PrototypeMessage {
extern char _aProto_0[];
extern char _cd_path_base[MAX_PATH];
extern char _cd_path_base[COMPAT_MAX_PATH];
extern ProtoList _protoLists[11];
extern const size_t _proto_sizes[11];
extern int _protos_been_initialized;

View File

@ -16,6 +16,7 @@
#include "game_movie.h"
#include "memory.h"
#include "object.h"
#include "platform_compat.h"
#include "proto.h"
#include "proto_instance.h"
#include "queue.h"
@ -596,7 +597,7 @@ int scriptSetActionBeingUsed(int sid, int value)
// 0x4A3B74
Program* scriptsCreateProgramByName(const char* name)
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
strcpy(path, _cd_path_base);
strcat(path, gScriptsBasePath);
@ -1291,7 +1292,7 @@ bool scriptHasProc(int sid, int proc)
// 0x4A4D50
int scriptsLoadScriptsList()
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", "scripts\\", "scripts.lst");
File* stream = fileOpen(path, "rt");
@ -1477,7 +1478,7 @@ int _scr_reset()
int _scr_game_init()
{
int i;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
if (!messageListInit(&gScrMessageList)) {
debugPrint("\nError initing script message file!");
@ -1666,7 +1667,7 @@ int _scr_header_load()
{
_num_script_indexes = 0;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
strcpy(path, _cd_path_base);
strcat(path, gScriptsBasePath);
strcat(path, "scripts.lst");
@ -2590,7 +2591,7 @@ int scriptsGetMessageList(int a1, MessageList** messageListPtr)
*pch = '\0';
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "dialog\\%s.msg", scriptName);
if (!messageListLoad(messageList, path)) {

View File

@ -1,5 +1,7 @@
#include "sfall_config.h"
#include "platform_compat.h"
#include <stdio.h>
#include <string.h>
@ -21,7 +23,7 @@ bool sfallConfigInit(int argc, char** argv)
// Initialize defaults.
configSetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_STARTING_MAP_KEY, "");
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
char* executable = argv[0];
char* ch = strrchr(executable, '\\');
if (ch != NULL) {

View File

@ -15,6 +15,7 @@
#include "party_member.h"
#include "perk.h"
#include "pipboy.h"
#include "platform_compat.h"
#include "proto.h"
#include "random.h"
#include "scripts.h"
@ -96,7 +97,7 @@ int skillsInit()
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "skill.msg");
if (!messageListLoad(&gSkillsMessageList, path)) {

View File

@ -12,6 +12,7 @@
#include "map.h"
#include "memory.h"
#include "object.h"
#include "platform_compat.h"
#include "skill.h"
#include "text_font.h"
#include "window_manager.h"
@ -122,7 +123,7 @@ int skilldexWindowInit()
return -1;
}
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "skilldex.msg");
if (!messageListLoad(&gSkilldexMessageList, path)) {

View File

@ -50,7 +50,7 @@ bool soundEffectsListIsValidTag(int a1)
// 0x4A98F4
int soundEffectsListInit(const char* soundEffectsPath, int a2, int debugLevel)
{
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
// TODO: What for?
// memcpy(path, byte_4A97E0, 0xFF);

View File

@ -11,6 +11,7 @@
#include "memory.h"
#include "object.h"
#include "perk.h"
#include "platform_compat.h"
#include "proto.h"
#include "random.h"
#include "scripts.h"
@ -92,7 +93,7 @@ int statsInit()
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "stat.msg");
if (!messageListLoad(&gStatsMessageList, path)) {

View File

@ -3,13 +3,11 @@
#include "color.h"
#include "db.h"
#include "memory.h"
#include "platform_compat.h"
#include <stdio.h>
#include <string.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
// 0x4D5530
FontManager gTextFontManager = {
0,
@ -112,7 +110,7 @@ int textFontLoad(int font)
{
int rc = -1;
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "font%d.fon", font);
// NOTE: Original code is slightly different. It uses deep nesting and

View File

@ -2,6 +2,7 @@
#include "game.h"
#include "object.h"
#include "platform_compat.h"
#include "skill.h"
#include "stat.h"
@ -42,7 +43,7 @@ int traitsInit()
return -1;
}
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s%s", asc_5186C8, "trait.msg");
if (!messageListLoad(&gTraitsMessageList, path)) {

View File

@ -498,7 +498,7 @@ void _removeProgramReferences_3(Program* program)
// 0x4B9190
void _initWindow(int resolution, int a2)
{
char err[MAX_PATH];
char err[COMPAT_MAX_PATH];
int rc;
int i, j;

View File

@ -612,7 +612,7 @@ int gEncounterTablesLength;
// 0x4BC89C
int worldmapInit()
{
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
if (_wmGenDataInit() == -1) {
return -1;
@ -4028,7 +4028,7 @@ int _wmGrabTileWalkMask(int tile)
return -1;
}
char path[MAX_PATH];
char path[COMPAT_MAX_PATH];
sprintf(path, "data\\%s.msk", tileInfo->walkMaskName);
File* stream = fileOpen(path, "rb");

View File

@ -1,7 +1,6 @@
#include "xfile.h"
#include "file_find.h"
#include "platform_compat.h"
#include <assert.h>
#include <direct.h>
@ -60,7 +59,7 @@ XFile* xfileOpen(const char* filePath, const char* mode)
char dir[_MAX_DIR];
_splitpath(filePath, drive, dir, NULL, NULL);
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
if (drive[0] != '\0' || dir[0] == '\\' || dir[0] == '/' || dir[0] == '.') {
// [filePath] is an absolute path. Attempt to open as plain stream.
stream->file = fopen(filePath, mode);
@ -505,8 +504,8 @@ bool xbaseOpen(const char* path)
return true;
}
char workingDirectory[FILENAME_MAX];
if (getcwd(workingDirectory, FILENAME_MAX) == NULL) {
char workingDirectory[COMPAT_MAX_PATH];
if (getcwd(workingDirectory, COMPAT_MAX_PATH) == NULL) {
// FIXME: Leaking xbase and path.
return false;
}
@ -600,7 +599,7 @@ bool xlistEnumerate(const char* pattern, XListEnumerationHandler* handler, XList
dbaseFindClose(xbase->dbase, &dbaseFindData);
}
} else {
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
sprintf(path, "%s\\%s", xbase->path, pattern);
if (fileFindFirst(path, &directoryFileFindData)) {
@ -704,8 +703,8 @@ void xlistFree(XList* xlist)
// 0x4DFFAC
int xbaseMakeDirectory(const char* filePath)
{
char workingDirectory[FILENAME_MAX];
if (getcwd(workingDirectory, FILENAME_MAX) == NULL) {
char workingDirectory[COMPAT_MAX_PATH];
if (getcwd(workingDirectory, COMPAT_MAX_PATH) == NULL) {
return -1;
}
@ -713,7 +712,7 @@ int xbaseMakeDirectory(const char* filePath)
char dir[_MAX_DIR];
_splitpath(filePath, drive, dir, NULL, NULL);
char path[FILENAME_MAX];
char path[COMPAT_MAX_PATH];
if (drive[0] != '\0' || dir[0] == '\\' || dir[0] == '/' || dir[0] == '.') {
// [filePath] is an absolute path.
strcpy(path, filePath);

View File

@ -3,6 +3,8 @@
#include "dfile.h"
#include "platform_compat.h"
#include <stdio.h>
#include <zlib.h>
@ -51,7 +53,7 @@ typedef enum XFileEnumerationEntryType {
} XFileEnumerationEntryType;
typedef struct XListEnumerationContext {
char name[FILENAME_MAX];
char name[COMPAT_MAX_PATH];
unsigned char type;
XList* xlist;
} XListEnumerationContext;