Even more conversion, lots of superfluous macro removal
This commit is contained in:
+116
-338
@@ -22,6 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
// common.c -- misc functions used in client and server
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "quakedef.hpp"
|
||||
#include "q_ctype.hpp"
|
||||
#include <errno.h>
|
||||
@@ -37,9 +39,9 @@ int safemode;
|
||||
convar registered = {"registered", "1", {.rom = true}}; /* set to correct value in COM_CheckRegistered() */
|
||||
convar cmdline = {"cmdline", "", {.rom = true}/*|CVAR_SERVERINFO*/}; /* sending cmdline upon CCREQ_RULE_INFO is evil */
|
||||
|
||||
static qboolean com_modified; // set true if using non-id files
|
||||
static bool com_modified; // set true if using non-id files
|
||||
|
||||
qboolean fitzmode;
|
||||
bool fitzmode;
|
||||
|
||||
static void COM_Path_f(void);
|
||||
|
||||
@@ -58,7 +60,7 @@ char **com_argv;
|
||||
#define CMDLINE_LENGTH 256 /* johnfitz -- mirrored in cmd.c */
|
||||
char com_cmdline[CMDLINE_LENGTH];
|
||||
|
||||
qboolean standard_quake = true, rogue, hipnotic;
|
||||
bool standard_quake = true, rogue, hipnotic;
|
||||
|
||||
// this graphic needs to be in the pak file to use registered features
|
||||
static unsigned short pop[] =
|
||||
@@ -309,232 +311,6 @@ int q_snprintf(char *str, size_t size, const char *format, ...) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Q_memset(void *dest, int fill, size_t count) {
|
||||
size_t i;
|
||||
|
||||
if ((((uintptr_t) dest | count) & 3) == 0) {
|
||||
count >>= 2;
|
||||
fill = fill | (fill << 8) | (fill << 16) | (fill << 24);
|
||||
for (i = 0; i < count; i++)
|
||||
((int *) dest)[i] = fill;
|
||||
} else
|
||||
for (i = 0; i < count; i++)
|
||||
((byte *) dest)[i] = fill;
|
||||
}
|
||||
|
||||
void Q_memcpy(void *dest, const void *src, size_t count) {
|
||||
size_t i;
|
||||
|
||||
if ((((uintptr_t) dest | (uintptr_t) src | count) & 3) == 0) {
|
||||
count >>= 2;
|
||||
for (i = 0; i < count; i++)
|
||||
((int *) dest)[i] = ((int *) src)[i];
|
||||
} else
|
||||
for (i = 0; i < count; i++)
|
||||
((byte *) dest)[i] = ((byte *) src)[i];
|
||||
}
|
||||
|
||||
int Q_memcmp(const void *m1, const void *m2, size_t count) {
|
||||
while (count) {
|
||||
count--;
|
||||
if (((byte *) m1)[count] != ((byte *) m2)[count])
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Q_strcpy(char *dest, const char *src) {
|
||||
while (*src) {
|
||||
*dest++ = *src++;
|
||||
}
|
||||
*dest++ = 0;
|
||||
}
|
||||
|
||||
void Q_strncpy(char *dest, const char *src, int count) {
|
||||
while (*src && count--) {
|
||||
*dest++ = *src++;
|
||||
}
|
||||
if (count)
|
||||
*dest++ = 0;
|
||||
}
|
||||
|
||||
int Q_strlen(const char *str) {
|
||||
int count;
|
||||
|
||||
count = 0;
|
||||
while (str[count])
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
char *Q_strrchr(const char *s, char c) {
|
||||
int len = Q_strlen(s);
|
||||
s += len;
|
||||
while (len--) {
|
||||
if (*--s == c)
|
||||
return (char *) s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Q_strcat(char *dest, const char *src) {
|
||||
dest += Q_strlen(dest);
|
||||
Q_strcpy(dest, src);
|
||||
}
|
||||
|
||||
int Q_strcmp(const char *s1, const char *s2) {
|
||||
while (1) {
|
||||
if (*s1 != *s2)
|
||||
return -1; // strings not equal
|
||||
if (!*s1)
|
||||
return 0; // strings are equal
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Q_strncmp(const char *s1, const char *s2, int count) {
|
||||
while (1) {
|
||||
if (!count--)
|
||||
return 0;
|
||||
if (*s1 != *s2)
|
||||
return -1; // strings not equal
|
||||
if (!*s1)
|
||||
return 0; // strings are equal
|
||||
s1++;
|
||||
s2++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int Q_atoi(const char *str) {
|
||||
int val;
|
||||
int sign;
|
||||
int c;
|
||||
|
||||
while (q_isspace(*str))
|
||||
++str;
|
||||
|
||||
if (*str == '-') {
|
||||
sign = -1;
|
||||
str++;
|
||||
} else
|
||||
sign = 1;
|
||||
|
||||
val = 0;
|
||||
|
||||
//
|
||||
// check for hex
|
||||
//
|
||||
if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) {
|
||||
str += 2;
|
||||
while (1) {
|
||||
c = *str++;
|
||||
if (c >= '0' && c <= '9')
|
||||
val = (val << 4) + c - '0';
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
val = (val << 4) + c - 'a' + 10;
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
val = (val << 4) + c - 'A' + 10;
|
||||
else
|
||||
return val * sign;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// check for character
|
||||
//
|
||||
if (str[0] == '\'') {
|
||||
return sign * str[1];
|
||||
}
|
||||
|
||||
//
|
||||
// assume decimal
|
||||
//
|
||||
while (1) {
|
||||
c = *str++;
|
||||
if (c < '0' || c > '9')
|
||||
return val * sign;
|
||||
val = val * 10 + c - '0';
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
float Q_atof(const char *str) {
|
||||
double val;
|
||||
int sign;
|
||||
int c;
|
||||
int decimal, total;
|
||||
|
||||
while (q_isspace(*str))
|
||||
++str;
|
||||
|
||||
if (*str == '-') {
|
||||
sign = -1;
|
||||
str++;
|
||||
} else
|
||||
sign = 1;
|
||||
|
||||
val = 0;
|
||||
|
||||
//
|
||||
// check for hex
|
||||
//
|
||||
if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) {
|
||||
str += 2;
|
||||
while (1) {
|
||||
c = *str++;
|
||||
if (c >= '0' && c <= '9')
|
||||
val = (val * 16) + c - '0';
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
val = (val * 16) + c - 'a' + 10;
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
val = (val * 16) + c - 'A' + 10;
|
||||
else
|
||||
return val * sign;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// check for character
|
||||
//
|
||||
if (str[0] == '\'') {
|
||||
return sign * str[1];
|
||||
}
|
||||
|
||||
//
|
||||
// assume decimal
|
||||
//
|
||||
decimal = -1;
|
||||
total = 0;
|
||||
while (1) {
|
||||
c = *str++;
|
||||
if (c == '.') {
|
||||
decimal = total;
|
||||
continue;
|
||||
}
|
||||
if (c < '0' || c > '9')
|
||||
break;
|
||||
val = val * 10 + c - '0';
|
||||
total++;
|
||||
}
|
||||
|
||||
if (decimal == -1)
|
||||
return val * sign;
|
||||
while (total > decimal) {
|
||||
val /= 10;
|
||||
total--;
|
||||
}
|
||||
|
||||
return val * sign;
|
||||
}
|
||||
|
||||
/*
|
||||
============================================================================
|
||||
|
||||
@@ -543,7 +319,7 @@ float Q_atof(const char *str) {
|
||||
============================================================================
|
||||
*/
|
||||
|
||||
qboolean host_bigendian;
|
||||
bool host_bigendian;
|
||||
|
||||
short (*BigShort)(short l);
|
||||
|
||||
@@ -680,7 +456,7 @@ void MSG_WriteString(sizebuf_t *sb, const char *s) {
|
||||
if (!s)
|
||||
SZ_Write(sb, "", 1);
|
||||
else
|
||||
SZ_Write(sb, s, Q_strlen(s) + 1);
|
||||
SZ_Write(sb, s, std::strlen(s) + 1);
|
||||
}
|
||||
|
||||
//johnfitz -- original behavior, 13.3 fixed point coords, max range +-4096
|
||||
@@ -730,7 +506,7 @@ void MSG_WriteAngle16(sizebuf_t *sb, float f, unsigned int flags) {
|
||||
// reading functions
|
||||
//
|
||||
int msg_readcount;
|
||||
qboolean msg_badread;
|
||||
bool msg_badread;
|
||||
|
||||
void MSG_BeginReading(void) {
|
||||
msg_readcount = 0;
|
||||
@@ -924,18 +700,18 @@ void *SZ_GetSpace(sizebuf_t *buf, int length) {
|
||||
}
|
||||
|
||||
void SZ_Write(sizebuf_t *buf, const void *data, int length) {
|
||||
Q_memcpy(SZ_GetSpace(buf, length), data, length);
|
||||
std::memcpy(SZ_GetSpace(buf, length), data, length);
|
||||
}
|
||||
|
||||
void SZ_Print(sizebuf_t *buf, const char *data) {
|
||||
int len = Q_strlen(data) + 1;
|
||||
int len = std::strlen(data) + 1;
|
||||
|
||||
if (buf->data[buf->cursize - 1]) {
|
||||
/* no trailing 0 */
|
||||
Q_memcpy((byte *) SZ_GetSpace(buf, len), data, len);
|
||||
std::memcpy(SZ_GetSpace(buf, len), data, len);
|
||||
} else {
|
||||
/* write over trailing 0 */
|
||||
Q_memcpy((byte *) SZ_GetSpace(buf, len - 1) - 1, data, len);
|
||||
std::memcpy(static_cast<byte *>(SZ_GetSpace(buf, len - 1)) - 1, data, len);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1090,6 +866,66 @@ void COM_AddExtension(char *path, const char *extension, size_t len) {
|
||||
|
||||
|
||||
namespace common {
|
||||
|
||||
void init() {
|
||||
int i = 0x12345678;
|
||||
/* U N I X */
|
||||
|
||||
/*
|
||||
BE_ORDER: 12 34 56 78
|
||||
U N I X
|
||||
|
||||
LE_ORDER: 78 56 34 12
|
||||
X I N U
|
||||
|
||||
PDP_ORDER: 34 12 78 56
|
||||
N U X I
|
||||
*/
|
||||
if (*reinterpret_cast<char *>(&i) == 0x12) {
|
||||
host_bigendian = true;
|
||||
}
|
||||
else if (*reinterpret_cast<char *>(&i) == 0x78) {
|
||||
host_bigendian = false;
|
||||
}
|
||||
else {
|
||||
Sys_Error("Unsupported endianism.");
|
||||
}
|
||||
|
||||
if (host_bigendian) {
|
||||
BigShort = ShortNoSwap;
|
||||
LittleShort = ShortSwap;
|
||||
BigLong = LongNoSwap;
|
||||
LittleLong = LongSwap;
|
||||
BigFloat = FloatNoSwap;
|
||||
LittleFloat = FloatSwap;
|
||||
} else /* assumed LITTLE_ENDIAN. */
|
||||
{
|
||||
BigShort = ShortSwap;
|
||||
LittleShort = ShortNoSwap;
|
||||
BigLong = LongSwap;
|
||||
LittleLong = LongNoSwap;
|
||||
BigFloat = FloatSwap;
|
||||
LittleFloat = FloatNoSwap;
|
||||
}
|
||||
|
||||
if (check_param("-fitz").has_value()) {
|
||||
fitzmode = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<size_t> check_param(std::string_view parm) {
|
||||
for (auto i = 1; i < com_argc; i++) {
|
||||
if (!com_argv[i]) {
|
||||
continue; // NEXTSTEP sometimes clears appkit vars.
|
||||
}
|
||||
if (parm == com_argv[i]) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a single token from a string-stream.
|
||||
*
|
||||
@@ -1214,27 +1050,6 @@ namespace common {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
COM_CheckParm
|
||||
|
||||
Returns the position (1 to argc-1) in the program's argument list
|
||||
where the given parameter apears, or 0 if not present
|
||||
================
|
||||
*/
|
||||
int COM_CheckParm(const char *parm) {
|
||||
int i;
|
||||
|
||||
for (i = 1; i < com_argc; i++) {
|
||||
if (!com_argv[i])
|
||||
continue; // NEXTSTEP sometimes clears appkit vars.
|
||||
if (!Q_strcmp(parm, com_argv[i]))
|
||||
return i;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
COM_CheckRegistered
|
||||
@@ -1318,73 +1133,25 @@ void COM_InitArgv(int argc, char **argv) {
|
||||
|
||||
for (com_argc = 0; (com_argc < MAX_NUM_ARGVS) && (com_argc < argc); com_argc++) {
|
||||
largv[com_argc] = argv[com_argc];
|
||||
if (!Q_strcmp("-safe", argv[com_argc]))
|
||||
if (!std::strcmp("-safe", argv[com_argc]))
|
||||
safemode = 1;
|
||||
}
|
||||
|
||||
largv[com_argc] = argvdummy;
|
||||
com_argv = largv;
|
||||
|
||||
if (COM_CheckParm("-rogue")) {
|
||||
if (common::check_param("-rogue").has_value()) {
|
||||
rogue = true;
|
||||
standard_quake = false;
|
||||
}
|
||||
|
||||
if (COM_CheckParm("-hipnotic") || COM_CheckParm("-quoth")) //johnfitz -- "-quoth" support
|
||||
if (common::check_param("-hipnotic").has_value() || common::check_param("-quoth").has_value()) //johnfitz -- "-quoth" support
|
||||
{
|
||||
hipnotic = true;
|
||||
standard_quake = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
COM_Init
|
||||
================
|
||||
*/
|
||||
void COM_Init(void) {
|
||||
int i = 0x12345678;
|
||||
/* U N I X */
|
||||
|
||||
/*
|
||||
BE_ORDER: 12 34 56 78
|
||||
U N I X
|
||||
|
||||
LE_ORDER: 78 56 34 12
|
||||
X I N U
|
||||
|
||||
PDP_ORDER: 34 12 78 56
|
||||
N U X I
|
||||
*/
|
||||
if (*(char *) &i == 0x12)
|
||||
host_bigendian = true;
|
||||
else if (*(char *) &i == 0x78)
|
||||
host_bigendian = false;
|
||||
else /* if ( *(char *)&i == 0x34 ) */
|
||||
Sys_Error("Unsupported endianism.");
|
||||
|
||||
if (host_bigendian) {
|
||||
BigShort = ShortNoSwap;
|
||||
LittleShort = ShortSwap;
|
||||
BigLong = LongNoSwap;
|
||||
LittleLong = LongSwap;
|
||||
BigFloat = FloatNoSwap;
|
||||
LittleFloat = FloatSwap;
|
||||
} else /* assumed LITTLE_ENDIAN. */
|
||||
{
|
||||
BigShort = ShortSwap;
|
||||
LittleShort = ShortNoSwap;
|
||||
BigLong = LongSwap;
|
||||
LittleLong = LongNoSwap;
|
||||
BigFloat = FloatSwap;
|
||||
LittleFloat = FloatNoSwap;
|
||||
}
|
||||
|
||||
if (COM_CheckParm("-fitz"))
|
||||
fitzmode = true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
va
|
||||
@@ -1632,7 +1399,7 @@ COM_FileExists
|
||||
Returns whether the file is found in the quake filesystem.
|
||||
===========
|
||||
*/
|
||||
qboolean COM_FileExists(const char *filename, unsigned int *path_id) {
|
||||
bool COM_FileExists(const char *filename, unsigned int *path_id) {
|
||||
int ret = COM_FindFile(filename, NULL, NULL, path_id);
|
||||
return (ret == -1) ? false : true;
|
||||
}
|
||||
@@ -1927,7 +1694,7 @@ static void COM_AddGameDirectory(const char *base, const char *dir) {
|
||||
searchpath_t *search;
|
||||
pack_t *pak, *qspak;
|
||||
char pakfile[MAX_OSPATH];
|
||||
qboolean been_here = false;
|
||||
bool been_here = false;
|
||||
|
||||
q_strlcpy(com_gamedir, va("%s/%s", base, dir), sizeof(com_gamedir));
|
||||
|
||||
@@ -1951,7 +1718,7 @@ _add_path:
|
||||
if (i != 0 || path_id != 1 || fitzmode)
|
||||
qspak = NULL;
|
||||
else {
|
||||
qboolean old = com_modified;
|
||||
bool old = com_modified;
|
||||
if (been_here) base = host_parms->userdir;
|
||||
q_snprintf(pakfile, sizeof(pakfile), "%s/quakespasm.pak", base);
|
||||
qspak = COM_LoadPackFile(pakfile);
|
||||
@@ -2110,8 +1877,8 @@ static void COM_Game_f(void) {
|
||||
Con_Printf("\"game\" changed to \"%s\"\n", COM_SkipPath(com_gamedir));
|
||||
|
||||
VID_Lock();
|
||||
Cbuf_AddText("exec quake.rc\n");
|
||||
Cbuf_AddText("vid_unlock\n");
|
||||
command::buffer::add_text("exec quake.rc\n");
|
||||
command::buffer::add_text("vid_unlock\n");
|
||||
} else //Diplay the current gamedir
|
||||
Con_Printf("\"game\" is \"%s\"\n", COM_SkipPath(com_gamedir));
|
||||
}
|
||||
@@ -2123,23 +1890,24 @@ COM_InitFilesystem
|
||||
*/
|
||||
void COM_InitFilesystem(void) //johnfitz -- modified based on topaz's tutorial
|
||||
{
|
||||
int i, j;
|
||||
|
||||
registered.inscribe();
|
||||
cmdline.inscribe();
|
||||
command::add("path", COM_Path_f);
|
||||
command::add("game", COM_Game_f); //johnfitz
|
||||
|
||||
i = COM_CheckParm("-basedir");
|
||||
if (i && i < com_argc - 1)
|
||||
q_strlcpy(com_basedir, com_argv[i + 1], sizeof(com_basedir));
|
||||
else
|
||||
auto i = common::check_param("-basedir");
|
||||
if (i.has_value() && i.value() < com_argc - 1) {
|
||||
q_strlcpy(com_basedir, com_argv[i.value() + 1], sizeof(com_basedir));
|
||||
}
|
||||
else {
|
||||
q_strlcpy(com_basedir, host_parms->basedir, sizeof(com_basedir));
|
||||
}
|
||||
|
||||
j = strlen(com_basedir);
|
||||
const auto j = strlen(com_basedir);
|
||||
if (j < 1) Sys_Error("Bad argument to -basedir");
|
||||
if ((com_basedir[j - 1] == '\\') || (com_basedir[j - 1] == '/'))
|
||||
if ((com_basedir[j - 1] == '\\') || (com_basedir[j - 1] == '/')) {
|
||||
com_basedir[j - 1] = 0;
|
||||
}
|
||||
|
||||
// start up with GAMENAME by default (id1)
|
||||
COM_AddGameDirectory(com_basedir, GAMENAME);
|
||||
@@ -2151,24 +1919,34 @@ void COM_InitFilesystem(void) //johnfitz -- modified based on topaz's tutorial
|
||||
com_base_searchpaths = com_searchpaths;
|
||||
|
||||
// add mission pack requests (only one should be specified)
|
||||
if (COM_CheckParm("-rogue"))
|
||||
if (common::check_param("-rogue").has_value()) {
|
||||
COM_AddGameDirectory(com_basedir, "rogue");
|
||||
if (COM_CheckParm("-hipnotic"))
|
||||
}
|
||||
if (common::check_param("-hipnotic").has_value()) {
|
||||
COM_AddGameDirectory(com_basedir, "hipnotic");
|
||||
if (COM_CheckParm("-quoth"))
|
||||
}
|
||||
if (common::check_param("-quoth").has_value()) {
|
||||
COM_AddGameDirectory(com_basedir, "quoth");
|
||||
}
|
||||
|
||||
i = COM_CheckParm("-game");
|
||||
if (i && i < com_argc - 1) {
|
||||
const char *p = com_argv[i + 1];
|
||||
if (!*p || !strcmp(p, ".") || strstr(p, "..") || strstr(p, "/") || strstr(p, "\\") || strstr(p, ":"))
|
||||
i = common::check_param("-game");
|
||||
if (i.has_value() && i.value() < com_argc - 1) {
|
||||
const char *p = com_argv[i.value() + 1];
|
||||
if (!*p || !strcmp(p, ".") || strstr(p, "..") || strstr(p, "/") || strstr(p, "\\") || strstr(p, ":")) {
|
||||
Sys_Error("gamedir should be a single directory name, not a path\n");
|
||||
}
|
||||
com_modified = true;
|
||||
// don't load mission packs twice
|
||||
if (COM_CheckParm("-rogue") && !q_strcasecmp(p, "rogue")) p = NULL;
|
||||
if (p && COM_CheckParm("-hipnotic") && !q_strcasecmp(p, "hipnotic")) p = NULL;
|
||||
if (p && COM_CheckParm("-quoth") && !q_strcasecmp(p, "quoth")) p = NULL;
|
||||
if (p != NULL) {
|
||||
if (common::check_param("-rogue").has_value() && !q_strcasecmp(p, "rogue")) {
|
||||
p = nullptr;
|
||||
}
|
||||
if (p && common::check_param("-hipnotic").has_value() && !q_strcasecmp(p, "hipnotic")) {
|
||||
p = nullptr;
|
||||
}
|
||||
if (p && common::check_param("-quoth").has_value() && !q_strcasecmp(p, "quoth")) {
|
||||
p = nullptr;
|
||||
}
|
||||
if (p != nullptr) {
|
||||
COM_AddGameDirectory(com_basedir, p);
|
||||
// QuakeSpasm extension: treat '-game missionpack' as '-missionpack'
|
||||
if (!q_strcasecmp(p, "rogue")) {
|
||||
@@ -2509,8 +2287,8 @@ void LOC_LoadFile(const char *file) {
|
||||
Con_DPrintf("LOC_LoadFile: malformed comment on line %d\n", lineno);
|
||||
} else if (equals) {
|
||||
char *key_end = equals;
|
||||
qboolean leading_quote;
|
||||
qboolean trailing_quote;
|
||||
bool leading_quote;
|
||||
bool trailing_quote;
|
||||
locentry_t *entry;
|
||||
char *value_src;
|
||||
char *value_dst;
|
||||
@@ -2675,7 +2453,7 @@ const char *LOC_GetRawString(const char *key) {
|
||||
return NULL;
|
||||
|
||||
entry = &localization.entries[idx - 1];
|
||||
if (!Q_strcmp(entry->key, key))
|
||||
if (!std::strcmp(entry->key, key))
|
||||
return entry->value;
|
||||
|
||||
++pos;
|
||||
@@ -2733,7 +2511,7 @@ static int LOC_ParseArg(const char **pstr) {
|
||||
LOC_HasPlaceholders
|
||||
================
|
||||
*/
|
||||
qboolean LOC_HasPlaceholders(const char *str) {
|
||||
bool LOC_HasPlaceholders(const char *str) {
|
||||
if (!localization.numindices)
|
||||
return false;
|
||||
while (*str) {
|
||||
@@ -2778,14 +2556,14 @@ size_t LOC_Format(const char *format, const char * (*getarg_fn)(int idx, void *u
|
||||
|
||||
insert = getarg_fn(argindex, userdata);
|
||||
space_left = len - written;
|
||||
insert_len = Q_strlen(insert);
|
||||
insert_len = std::strlen(insert);
|
||||
|
||||
if (insert_len > space_left) {
|
||||
Con_DPrintf("LOC_Format: overflow at argument #%d\n", numargs);
|
||||
insert_len = space_left;
|
||||
}
|
||||
|
||||
Q_memcpy(out + written, insert, insert_len);
|
||||
std::memcpy(out + written, insert, insert_len);
|
||||
written += insert_len;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user