fix(filesystem): use correct os path length

This commit is contained in:
Diavolo 2022-08-16 15:18:21 +02:00
parent 078165ed26
commit e40747625b
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
2 changed files with 10 additions and 7 deletions

View File

@ -196,9 +196,12 @@ namespace game
extern int* sys_timeBase; extern int* sys_timeBase;
extern unsigned __int64* sys_counterBase; extern unsigned __int64* sys_counterBase;
// PM Global Definitions & Functions // Global Definitions & Functions
constexpr auto JUMP_LAND_SLOWDOWN_TIME = 1800; constexpr auto JUMP_LAND_SLOWDOWN_TIME = 1800;
constexpr auto MAX_QPATH = 64;
constexpr auto MAX_OSPATH = 256;
// From Quake III, to match game's assembly // From Quake III, to match game's assembly
template <typename T, typename R> template <typename T, typename R>
constexpr auto VectorScale(T v, R s, T out) { out[0] = v[0] * s; out[1] = v[1] * s; out[2] = v[2] * s; } constexpr auto VectorScale(T v, R s, T out) { out[0] = v[0] * s; out[1] = v[1] * s; out[2] = v[2] * s; }

View File

@ -12,7 +12,7 @@ static utils::hook::detour sys_default_install_path_hook;
static const game::native::dvar_t** fs_homepath; static const game::native::dvar_t** fs_homepath;
static const game::native::dvar_t** fs_debug; static const game::native::dvar_t** fs_debug;
static FILE* file_for_handle(int f) static FILE* file_for_handle(const int f)
{ {
assert(!game::native::fsh[f].zipFile); assert(!game::native::fsh[f].zipFile);
assert(game::native::fsh[f].handleFiles.file.o); assert(game::native::fsh[f].handleFiles.file.o);
@ -20,9 +20,9 @@ static FILE* file_for_handle(int f)
return game::native::fsh[f].handleFiles.file.o; return game::native::fsh[f].handleFiles.file.o;
} }
static unsigned int file_write(const void* ptr, unsigned int len, FILE* stream) static unsigned int file_write(const void* ptr, const unsigned int len, FILE* stream)
{ {
return std::fwrite(ptr, 1, len, stream); return std::fwrite(ptr, sizeof(char), len, stream);
} }
static FILE* file_open_append_text(const char* filename) static FILE* file_open_append_text(const char* filename)
@ -94,7 +94,7 @@ static void build_os_path_for_thread(const char* base, const char* game, const c
auto len_base = std::strlen(base); auto len_base = std::strlen(base);
auto len_game = std::strlen(game); auto len_game = std::strlen(game);
auto len_qpath = std::strlen(qpath); auto len_qpath = std::strlen(qpath);
if (len_game + 1 + len_base + len_qpath + 1 >= 256) if (len_game + 1 + len_base + len_qpath + 1 >= game::native::MAX_OSPATH)
{ {
if (thread) if (thread)
{ {
@ -147,7 +147,7 @@ static int handle_for_file_current_thread()
static int open_file_append(const char* filename) static int open_file_append(const char* filename)
{ {
char ospath[MAX_PATH]{}; char ospath[game::native::MAX_OSPATH]{};
game::native::FS_CheckFileSystemStarted(); game::native::FS_CheckFileSystemStarted();
const auto* basepath = (*fs_homepath)->current.string; const auto* basepath = (*fs_homepath)->current.string;
@ -203,7 +203,7 @@ static int get_handle_and_open_file(const char* filename, const char* ospath, ga
static int open_file_write_to_dir_for_thread(const char* filename, const char* dir, const char* osbasepath, game::native::FsThread thread) static int open_file_write_to_dir_for_thread(const char* filename, const char* dir, const char* osbasepath, game::native::FsThread thread)
{ {
char ospath[MAX_PATH]{}; char ospath[game::native::MAX_OSPATH]{};
game::native::FS_CheckFileSystemStarted(); game::native::FS_CheckFileSystemStarted();