fix: remove _s poison
All checks were successful
check-formatting / check-formatting (push) Successful in 3m25s
All checks were successful
check-formatting / check-formatting (push) Successful in 3m25s
This commit is contained in:
parent
b8e12abf89
commit
3c02e1c24c
@ -22,7 +22,7 @@ game::define_s* define_from_string(const char* string) {
|
||||
string, static_cast<int>(std::strlen(string)), "*extern");
|
||||
// create a new source
|
||||
std::memset(&src, 0, sizeof(game::source_s));
|
||||
strncpy_s(src.filename, "*extern", _TRUNCATE);
|
||||
game::I_strncpyz(src.filename, "*extern", sizeof(src.filename));
|
||||
|
||||
src.scriptstack = script;
|
||||
src.definehash = static_cast<game::define_s**>(
|
||||
@ -160,7 +160,7 @@ game::source_s* load_source_file(const char* filename) {
|
||||
static_cast<game::source_s*>(game::GetMemory(sizeof(game::source_s)));
|
||||
std::memset(source, 0, sizeof(game::source_s));
|
||||
|
||||
strncpy_s(source->filename, filename, _TRUNCATE);
|
||||
game::I_strncpyz(source->filename, filename, sizeof(source->filename));
|
||||
source->scriptstack = script;
|
||||
source->tokens = nullptr;
|
||||
source->defines = nullptr;
|
||||
|
@ -130,10 +130,10 @@ void set_script_punctuations(game::script_s* script) {
|
||||
}
|
||||
|
||||
game::script_s* load_script_file(const char* filename) {
|
||||
int fp;
|
||||
int fp{};
|
||||
char pathname[game::MAX_QPATH];
|
||||
|
||||
sprintf_s(pathname, "%s", filename);
|
||||
game::Com_sprintf(pathname, sizeof(pathname), "%s", filename);
|
||||
const auto length = game::FS_FOpenFileRead(pathname, &fp);
|
||||
if (!fp) {
|
||||
return nullptr;
|
||||
@ -141,7 +141,7 @@ game::script_s* load_script_file(const char* filename) {
|
||||
|
||||
auto* buffer = game::GetClearedMemory(sizeof(game::script_s) + length + 1);
|
||||
auto* script = static_cast<game::script_s*>(buffer);
|
||||
strncpy_s(script->filename, filename, _TRUNCATE);
|
||||
game::I_strncpyz(script->filename, filename, sizeof(script->filename));
|
||||
|
||||
script->buffer = static_cast<char*>(buffer) + sizeof(game::script_s);
|
||||
script->buffer[length] = '\0';
|
||||
@ -172,7 +172,7 @@ game::script_s* load_script_memory(const char* ptr, int length,
|
||||
auto* buffer = game::GetClearedMemory(sizeof(game::script_s) + length + 1);
|
||||
auto* script = static_cast<game::script_s*>(buffer);
|
||||
|
||||
strncpy_s(script->filename, name, _TRUNCATE);
|
||||
game::I_strncpyz(script->filename, name, sizeof(script->filename));
|
||||
script->buffer = static_cast<char*>(buffer) + sizeof(game::script_s);
|
||||
script->buffer[length] = '\0';
|
||||
script->length = length;
|
||||
|
@ -31,8 +31,8 @@ void com_bug_f(const command::params& params) {
|
||||
bug = dvars::bug_name->current.string;
|
||||
}
|
||||
|
||||
sprintf_s(new_file_name, "%s_%s.log", bug,
|
||||
game::Live_GetLocalClientName(game::CONTROLLER_INDEX_0));
|
||||
game::Com_sprintf(new_file_name, sizeof(new_file_name), "%s_%s.log", bug,
|
||||
game::Live_GetLocalClientName(game::CONTROLLER_INDEX_0));
|
||||
|
||||
game::engine::scoped_critical_section lock(game::CRITSECT_CONSOLE,
|
||||
game::SCOPED_CRITSECT_NORMAL);
|
||||
@ -71,7 +71,7 @@ void com_bug_name_inc_f() {
|
||||
}
|
||||
|
||||
const auto n = std::strtol(dvars::bug_name->current.string + 3, nullptr, 10);
|
||||
sprintf_s(buf, "bug%d", n + 1);
|
||||
game::Com_sprintf(buf, sizeof(buf), "bug%d", n + 1);
|
||||
game::Dvar_SetString(dvars::bug_name, buf);
|
||||
}
|
||||
|
||||
|
@ -11,27 +11,27 @@ bool is_using_mods() {
|
||||
}
|
||||
|
||||
void db_build_os_path_from_source(const char* zone_name, game::FF_DIR source,
|
||||
unsigned int size, char* filename) {
|
||||
const int size, char* filename) {
|
||||
char user_map[game::MAX_QPATH]{};
|
||||
switch (source) {
|
||||
case game::FFD_DEFAULT:
|
||||
(void)sprintf_s(filename, size, "%s\\%s%s.ff",
|
||||
std::filesystem::current_path().string().c_str(),
|
||||
game::Sys_GetMapZoneDir(zone_name), zone_name);
|
||||
(void)game::Com_sprintf(filename, size, "%s\\%s%s.ff",
|
||||
std::filesystem::current_path().string().c_str(),
|
||||
game::Sys_GetMapZoneDir(zone_name), zone_name);
|
||||
break;
|
||||
case game::FFD_MOD_DIR:
|
||||
assert(is_using_mods());
|
||||
|
||||
(void)sprintf_s(filename, size, "%s\\%s\\%s.ff",
|
||||
std::filesystem::current_path().string().c_str(),
|
||||
(*dvars::fs_gameDirVar)->current.string, zone_name);
|
||||
(void)game::Com_sprintf(filename, size, "%s\\%s\\%s.ff",
|
||||
std::filesystem::current_path().string().c_str(),
|
||||
(*dvars::fs_gameDirVar)->current.string, zone_name);
|
||||
break;
|
||||
case game::FFD_USER_MAP:
|
||||
game::I_strncpyz(user_map, zone_name, sizeof(user_map));
|
||||
|
||||
(void)sprintf_s(filename, size, "%s\\%s\\%s\\%s.ff",
|
||||
std::filesystem::current_path().string().c_str(),
|
||||
"usermaps", user_map, zone_name);
|
||||
(void)game::Com_sprintf(filename, size, "%s\\%s\\%s\\%s.ff",
|
||||
std::filesystem::current_path().string().c_str(),
|
||||
"usermaps", user_map, zone_name);
|
||||
break;
|
||||
default:
|
||||
assert(false && "inconceivable");
|
||||
|
@ -46,10 +46,12 @@ bool file_wrapper_rotate(const char* ospath) {
|
||||
}
|
||||
|
||||
if (current_index == MAX_BACKUPS) {
|
||||
(void)sprintf_s(renamed_path, "%s.%03i", ospath, oldest_index);
|
||||
(void)game::Com_sprintf(renamed_path, sizeof(renamed_path), "%s.%03i",
|
||||
ospath, oldest_index);
|
||||
(void)std::remove(renamed_path); // Remove the oldest backup file
|
||||
} else {
|
||||
(void)sprintf_s(renamed_path, "%s.%03i", ospath, current_index);
|
||||
(void)game::Com_sprintf(renamed_path, sizeof(renamed_path), "%s.%03i",
|
||||
ospath, current_index);
|
||||
}
|
||||
|
||||
// Rename the original file to the selected backup slot
|
||||
|
@ -28,7 +28,7 @@ void g_scr_log_print() {
|
||||
break;
|
||||
}
|
||||
|
||||
strncat_s(string, psz_token, _TRUNCATE);
|
||||
game::I_strncat(string, sizeof(string), psz_token);
|
||||
}
|
||||
|
||||
log_printf("%s", string);
|
||||
@ -83,12 +83,14 @@ void log_printf(const char* fmt, ...) {
|
||||
}
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf_s(string2, _TRUNCATE, fmt, ap);
|
||||
vsnprintf(string2, sizeof(string2), fmt, ap);
|
||||
va_end(ap);
|
||||
string2[sizeof(string2) - 1] = '\0';
|
||||
|
||||
const auto time = game::level->time / 1000;
|
||||
const auto len = sprintf_s(string, "%3i:%i%i %s", time / 60, time % 60 / 10,
|
||||
time % 60 % 10, string2);
|
||||
const auto len =
|
||||
game::Com_sprintf(string, sizeof(string), "%3i:%i%i %s", time / 60,
|
||||
time % 60 / 10, time % 60 % 10, string2);
|
||||
game::FS_Write(string, len, log_file);
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ void add_source_buffer_internal(const char* ext_filename, const char* code_pos,
|
||||
auto* buf = static_cast<char*>(hunk::alloc_debug_mem(
|
||||
static_cast<int>(new_len))); // Scr_AddSourceBufferInternal
|
||||
|
||||
strncpy_s(buf, new_len, ext_filename, _TRUNCATE);
|
||||
game::I_strncpyz(buf, ext_filename, static_cast<int>(new_len));
|
||||
auto* source_buf2 = source_buf ? buf + str_len : nullptr;
|
||||
auto* source = source_buf;
|
||||
auto* dest = source_buf2;
|
||||
@ -525,8 +525,9 @@ unsigned int load_script_internal_stub(const char* filename,
|
||||
game::GetNewVariable(game::scrCompilePub->loadedscripts, name);
|
||||
game::SL_RemoveRefToString(name);
|
||||
|
||||
sprintf_s(ext_filename, "%s.gsc",
|
||||
game::SL_ConvertToString(static_cast<unsigned short>(name)));
|
||||
game::Com_sprintf(
|
||||
ext_filename, sizeof(ext_filename), "%s.gsc",
|
||||
game::SL_ConvertToString(static_cast<unsigned short>(name)));
|
||||
|
||||
const auto* old_source_buf = parser_pub_.sourceBuf;
|
||||
const auto* source_buffer = add_source_buffer(
|
||||
@ -837,8 +838,9 @@ void compile_error(unsigned int source_pos, const char* msg, ...) {
|
||||
va_list argptr;
|
||||
|
||||
va_start(argptr, msg);
|
||||
vsnprintf_s(text, _TRUNCATE, msg, argptr);
|
||||
(void)vsnprintf(text, sizeof(text), msg, argptr);
|
||||
va_end(argptr);
|
||||
text[sizeof(text) - 1] = '\0';
|
||||
|
||||
if (game::scrVarPub->evaluate) {
|
||||
if (!game::scrVarPub->error_message) {
|
||||
@ -892,8 +894,9 @@ void compile_error2(const char* code_pos, const char* msg, ...) {
|
||||
"******* script compile error *******\n");
|
||||
|
||||
va_start(argptr, msg);
|
||||
vsnprintf_s(text, _TRUNCATE, msg, argptr);
|
||||
(void)vsnprintf(text, sizeof(text), msg, argptr);
|
||||
va_end(argptr);
|
||||
text[sizeof(text) - 1] = '\0';
|
||||
|
||||
game::Com_PrintError(game::CON_CHANNEL_PARSERSCRIPT, "%s: ", text);
|
||||
|
||||
|
@ -19,8 +19,8 @@ void load_scripts_from_folder(const char* dir) {
|
||||
game::Com_Printf(game::CON_CHANNEL_SERVER,
|
||||
"Scanning directory '%s' for custom GSC scripts...\n", dir);
|
||||
|
||||
strncpy_s(search_path, dir, _TRUNCATE);
|
||||
strncat_s(search_path, "/", _TRUNCATE);
|
||||
game::I_strncpyz(search_path, dir, sizeof(search_path));
|
||||
game::I_strncat(search_path, sizeof(search_path), "/");
|
||||
|
||||
auto num_files = 0;
|
||||
const auto** files =
|
||||
@ -31,7 +31,8 @@ void load_scripts_from_folder(const char* dir) {
|
||||
game::Com_Printf(game::CON_CHANNEL_SERVER, "Loading script %s...\n",
|
||||
script_file);
|
||||
|
||||
const auto len = sprintf_s(path, "%s/%s", dir, script_file);
|
||||
const auto len =
|
||||
game::Com_sprintf(path, sizeof(path), "%s/%s", dir, script_file);
|
||||
if (len == -1) {
|
||||
continue;
|
||||
}
|
||||
|
@ -48,20 +48,6 @@ int PC_Float_Parse(int handle, float* f);
|
||||
void Menu_FreeItemMemory(itemDef_s* item);
|
||||
|
||||
char* Com_GetCommandLine();
|
||||
|
||||
// Global definitions
|
||||
constexpr auto CMD_MAX_NESTING = 8;
|
||||
|
||||
constexpr auto MAX_POSSIBLE_LOCAL_CLIENTS = 1;
|
||||
|
||||
constexpr std::size_t MAX_LOCAL_CLIENTS = 1;
|
||||
|
||||
constexpr auto MAX_QPATH = 64;
|
||||
constexpr auto MAX_OSPATH = 256;
|
||||
|
||||
constexpr auto MAX_OPCODE_LOOKUP_SIZE = 0x1000000;
|
||||
constexpr auto MAX_SOURCEPOS_LOOKUP_SIZE = 0x800000;
|
||||
constexpr auto MAX_SOURCEBUF_LOOKUP_SIZE = 0x40000;
|
||||
} // namespace game
|
||||
|
||||
#include "symbols.hpp"
|
||||
|
@ -4,6 +4,20 @@
|
||||
#pragma warning(disable : 4324)
|
||||
|
||||
namespace game {
|
||||
// Global definitions
|
||||
constexpr auto CMD_MAX_NESTING = 8;
|
||||
|
||||
constexpr auto MAX_POSSIBLE_LOCAL_CLIENTS = 1;
|
||||
|
||||
constexpr std::size_t MAX_LOCAL_CLIENTS = 1;
|
||||
|
||||
constexpr auto MAX_QPATH = 64;
|
||||
constexpr auto MAX_OSPATH = 256;
|
||||
|
||||
constexpr auto MAX_OPCODE_LOOKUP_SIZE = 0x1000000;
|
||||
constexpr auto MAX_SOURCEPOS_LOOKUP_SIZE = 0x800000;
|
||||
constexpr auto MAX_SOURCEBUF_LOOKUP_SIZE = 0x40000;
|
||||
|
||||
typedef float vec_t;
|
||||
typedef vec_t vec2_t[2];
|
||||
typedef vec_t vec3_t[3];
|
||||
@ -540,8 +554,8 @@ struct indent_s {
|
||||
};
|
||||
|
||||
struct source_s {
|
||||
char filename[64];
|
||||
char includepath[64];
|
||||
char filename[MAX_QPATH];
|
||||
char includepath[MAX_QPATH];
|
||||
punctuation_s* punctuations;
|
||||
script_s* scriptstack;
|
||||
token_s* tokens;
|
||||
|
@ -18,6 +18,8 @@ WEAK symbol<void()> Com_ServerPacketEvent{0x47FD30};
|
||||
WEAK symbol<void(const char* filename)> Com_BeginParseSession{0x4A5C90};
|
||||
WEAK symbol<void()> Com_EndParseSession{0x4D12C0};
|
||||
WEAK symbol<const char*(const char** data_p)> Com_Parse{0x486600};
|
||||
WEAK symbol<int(char* dest, int size, const char* fmt, ...)> Com_sprintf{
|
||||
0x4E85A0};
|
||||
|
||||
WEAK symbol<const char*(const char* fmt, ...)> va{0x4869F0};
|
||||
|
||||
@ -274,6 +276,7 @@ WEAK symbol<int(const char* s0, const char* s1)> I_stricmp{0x409B80};
|
||||
WEAK symbol<int(const char* s0, const char* s1, int n)> I_strnicmp{0x491E60};
|
||||
WEAK symbol<void(char* dest, const char* src, int destsize)> I_strncpyz{
|
||||
0x416920};
|
||||
WEAK symbol<void(char* dest, int size, const char* src)> I_strncat{0x45CA00};
|
||||
|
||||
WEAK symbol<void(field_t* edit)> Field_Clear{0x45C350};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user