[util] Make va thread-safe

It now takes a context pointer (opaque data) that holds the buffers it
uses for the temporary strings. If the context pointer is null, a static
context is used (making those uses of va NOT thread-safe). Most calls to
va use the static context, but all such calls have been formatted
consistently so they are easy to find when it comes time to do a full
audit.
This commit is contained in:
Bill Currie 2021-01-31 16:01:20 +09:00
parent f523f6ba80
commit 7970525ef4
108 changed files with 505 additions and 390 deletions

View File

@ -34,9 +34,60 @@
*/
///@{
// does a varargs printf into a temp buffer
char *va(const char *format, ...) __attribute__((format(printf,1,2)));
// does a varargs printf into a malloced buffer
/** Opaque context for va so it can have per-thread data.
*/
typedef struct va_ctx_s va_ctx_t;
/** Create a va context with the specified number of buffers.
*
* Having multiple buffers allows va to be used in short chains.
*
* \param buffers The number of buffers to create in the context. va() will
* cycle through the buffers for each call.
* \return Pointer to the context. Pass to va() for thread-safe usage.
*/
va_ctx_t *va_create_context (int buffers);
/** Destroy a va context.
*
* \param ctx The context to be destroyed. Must have been created by
* va_create_context().
* \note Any pointers to strings returned by va() using the context
* referenced by \a ctx will become invalid as the backing
* memory for the strings will have been freed.
*/
void va_destroy_context (va_ctx_t *ctx);
/** Does a varargs printf into a private buffer.
*
* \param ctx Context used for storing the private buffer such that va
* can be used in a multi-threaded environment. If null then
* a static context is used, in which case va is NOT
* thread-safe.
* \param format Standard printf() format string.
* \return Pointer to the beginning of the output string. The memory
* for the returned string is owned by the context pointed to
* by \a ctx.
* \note The static context is created with 4 buffers, so va (0,...)
* can be used to produce mildly complex output (eg, 3 calls
* to va sent to a 4th) with a reduced risk of strings being
* trampled.
*/
char *va(va_ctx_t *ctx, const char *format, ...) __attribute__((format(printf,2,3)));
/** Does a varargs printf into a malloced buffer.
*
* Combines the effect of strdup and sprintf, but in a safe manner. Essentially
* the equivalent of strdup (va (ctx, format, ...));
*
* \param format Standard printf() format string.
* \return Pointer to the beginning of the output string. The caller
* is responsible for freeing the memory holding the string.
* \note As nva() creates a new buffer every time it is called, it
* is thread-safe and there is no risk of the string being
* trampled. In addition, it does not use va(), so combining
* nva() with va() is safe.
*/
char *nva(const char *format, ...) __attribute__((format(printf,1,2)));
///@}

View File

@ -50,6 +50,7 @@ typedef struct vulkan_ctx_s {
void (*create_window) (struct vulkan_ctx_s *ctx);
VkSurfaceKHR (*create_surface) (struct vulkan_ctx_s *ctx);
struct va_ctx_s *va_ctx;
struct qfv_instance_s *instance;
struct qfv_device_s *device;
struct qfv_swapchain_s *swapchain;

View File

@ -189,7 +189,7 @@ Load_Tracklist (void)
static void
I_OGGMus_SetPlayList (int track)
{
const char *trackstring = va ("%i", track);
const char *trackstring = va (0, "%i", track);
int i;
play_list = PL_ObjectForKey (tracklist, trackstring);
@ -327,7 +327,7 @@ I_OGGMus_Info (void)
/* loop, and count up the Highest key number. */
for (iter = 1, count = 0; count < keycount && iter <= 99 ; iter++) {
trackstring = va ("%i", iter);
trackstring = va (0, "%i", iter);
if (!(currenttrack = PL_ObjectForKey (tracklist, trackstring))) {
continue;
}

View File

@ -329,7 +329,7 @@ s_jack_connect (void)
jack_set_process_callback (jack_handle, snd_jack_process, 0);
jack_on_shutdown (jack_handle, snd_jack_shutdown, 0);
for (i = 0; i < 2; i++)
jack_out[i] = jack_port_register (jack_handle, va ("out_%d", i + 1),
jack_out[i] = jack_port_register (jack_handle, va (0, "out_%d", i + 1),
JACK_DEFAULT_AUDIO_TYPE,
JackPortIsOutput, 0);
snd_shm->speed = jack_get_sample_rate (jack_handle);

View File

@ -199,7 +199,7 @@ SND_PrecacheSound (const char *name)
if (!name)
Sys_Error ("SND_PrecacheSound: NULL");
sfx = SND_LoadSound (va ("sound/%s", name));
sfx = SND_LoadSound (va (0, "sound/%s", name));
if (sfx && precache->int_val) {
if (sfx->retain (sfx))
sfx->release (sfx);

View File

@ -251,7 +251,7 @@ Condump_f (void)
Sys_Printf ("invalid character in filename\n");
return;
}
name = va ("%s/%s.txt", qfs_gamedir->dir.def, Cmd_Argv (1));
name = va (0, "%s/%s.txt", qfs_gamedir->dir.def, Cmd_Argv (1));//FIXME
if (!(file = QFS_WOpen (name, 0))) {
Sys_Printf ("could not open %s for writing: %s\n", name,
@ -375,7 +375,7 @@ C_Print (const char *fmt, va_list args)
// log all messages to file
if (con_debuglog)
Sys_DebugLog (va ("%s/%s/qconsole.log", qfs_userpath,
Sys_DebugLog (va (0, "%s/%s/qconsole.log", qfs_userpath,//FIXME
qfs_gamedir->dir.def), "%s", buffer->str);
if (!con_initialized)

View File

@ -157,7 +157,7 @@ Con_BasicCompleteCommandLine (inputline_t *il)
&& strncmp (s + bound, cmd, strlen (s + bound)))
bound++;
overwrite = va("%.*s%.*s", bound, s, cmd_len, cmd);
overwrite = va (0, "%.*s%.*s", bound, s, cmd_len, cmd);
il->lines[il->edit_line][1] = '/';
strncpy (il->lines[il->edit_line] + 2, overwrite, il->line_size - 3);

View File

@ -167,7 +167,7 @@ Con_Skyboxlist_f (void)
for (j = 1; sb_endings[j]; j++) {
b = 0;
for (k = 0; k < skyboxlist->count; k++) {
if (strcmp(va("%s%s", basename->str, sb_endings[j]),
if (strcmp(va (0, "%s%s", basename->str, sb_endings[j]),
skyboxlist->list[k]) == 0) {
b = 1;
*skyboxlist->list[k] = 0;

View File

@ -311,7 +311,7 @@ EXP_ParseString (char *str)
} else {
EXP_DestroyTokens (chain);
EXP_Error (EXP_E_INVOP,
va ("Unknown operator or function '%s'.", buf));
va (0, "Unknown operator or function '%s'.", buf));
return 0;
}
}
@ -347,8 +347,7 @@ EXP_SimplifyTokens (token * chain)
cur = cur->generic.prev;
if (EXP_DoFunction (cur))
return EXP_Error (EXP_E_SYNTAX,
va
("Invalid number of arguments to function '%s'.",
va (0, "Invalid number of arguments to function '%s'.",
cur->func.func->str));
} else {
if (EXP_ContainsCommas (cur))
@ -374,8 +373,7 @@ EXP_SimplifyTokens (token * chain)
if (cur->generic.next->generic.type == TOKEN_OP)
if (EXP_DoUnary (cur->generic.next))
return EXP_Error (EXP_E_SYNTAX,
va
("Unary operator '%s' not followed by a unary operator or numerical value.",
va (0, "Unary operator '%s' not followed by a unary operator or numerical value.",
cur->generic.next->op.op->str));
if (optable[i].operands == 1
&& cur->generic.next->generic.type == TOKEN_NUM) {
@ -482,14 +480,12 @@ EXP_Validate (token * chain)
cur->generic.next->op.op = EXP_FindOpByStr ("neg");
else if (cur->generic.next->op.op->operands == 2)
return EXP_Error (EXP_E_SYNTAX,
va
("Operator '%s' does not follow a number or numerical value.",
va (0, "Operator '%s' does not follow a number or numerical value.",
cur->generic.next->op.op->str));
} else if (cur->generic.type == TOKEN_FUNC
&& cur->generic.next->generic.type != TOKEN_OPAREN)
return EXP_Error (EXP_E_SYNTAX,
va
("Function '%s' called without an argument list.",
va (0, "Function '%s' called without an argument list.",
cur->func.func->str));
else if (cur->generic.type == TOKEN_COMMA
&&
@ -501,7 +497,7 @@ EXP_Validate (token * chain)
else if (cur->generic.type == TOKEN_OP
&& cur->generic.next->generic.type == TOKEN_CPAREN)
return EXP_Error (EXP_E_SYNTAX,
va ("Operator '%s' is missing an operand.",
va (0, "Operator '%s' is missing an operand.",
cur->op.op->str));
else if (cur->generic.type == TOKEN_NUM
&& cur->generic.next->generic.type == TOKEN_NUM)

View File

@ -823,7 +823,7 @@ GIB_File_Write_f (void)
}
path = GIB_Argv (1);
QFS_WriteFile (va ("%s/%s", qfs_gamedir->dir.def, path),
QFS_WriteFile (va (0, "%s/%s", qfs_gamedir->dir.def, path),
GIB_Argv(2), GIB_Argd(2)->size-1);
}

View File

@ -612,9 +612,9 @@ static const char *g_gcbs_name;
static const char *gcbs_fname (const char *str)
{
if (g_gcbs_mode == INSTANCE)
return va ("__%s_%s__", g_gcbs_name, str);
return va (0, "__%s_%s__", g_gcbs_name, str);
else
return va ("%s::%s", g_gcbs_name, str);
return va (0, "%s::%s", g_gcbs_name, str);
}
void

View File

@ -205,7 +205,7 @@ GIB_Object_Create (const char *classname, qboolean classobj)
obj->data = malloc (sizeof (void *) * (class->depth+1));
obj->methods = classobj ? class->class_methods : class->methods;
obj->handle = classobj ? 0 : GIB_Handle_New (obj);
obj->handstr = strdup (va ("%lu", obj->handle));
obj->handstr = strdup (va (0, "%lu", obj->handle));
obj->refs = 1;
obj->signals = Hash_NewTable (128, GIB_Signal_Get_Key,
GIB_Signal_Free, NULL, 0);

View File

@ -333,7 +333,8 @@ GIB_Parse_Tokens (const char *program, unsigned int *i, unsigned int pofs)
return nodes;
ERROR:
if (c)
GIB_Parse_Error (va ("Could not find match for '%c'.", c), *i + pofs);
GIB_Parse_Error (va (0, "Could not find match for '%c'.", c),
*i + pofs);
if (nodes)
GIB_Tree_Unref (&nodes);
return 0;
@ -496,7 +497,8 @@ GIB_Parse_Embedded (gib_tree_t *token)
return lines;
ERROR:
if (c)
GIB_Parse_Error (va ("Could not find match for '%c'.", c), i + token->start);
GIB_Parse_Error (va (0, "Could not find match for '%c'.", c),
i + token->start);
if (lines)
GIB_Tree_Unref (&lines);
return 0;

View File

@ -210,7 +210,7 @@ GIB_Var_Get_Very_Complex (hashtab_t ** first, hashtab_t ** second, dstring_t *ke
key->str[i] = 0;
if ((var = GIB_Var_Get_Very_Complex (&one, &two, key, n+1+varstartskip, &index2, create))) {
if (key->str[n] == '#')
str = va("%u", var->size);
str = va (0, "%u", var->size);
else
str = var->array[index2].value->str;
key->str[i] = c;

View File

@ -122,7 +122,7 @@ Mod_LoadExternalSkin (maliasskindesc_t *pskindesc, char *filename)
tex = LoadImage (filename, 1);
if (!tex)
tex = LoadImage (va ("textures/%s", ptr + 1), 1);
tex = LoadImage (va (0, "textures/%s", ptr + 1), 1);
if (tex) {
pskindesc->texnum = GL_LoadTexture (filename, tex->width, tex->height,
tex->data, true, false,
@ -130,22 +130,22 @@ Mod_LoadExternalSkin (maliasskindesc_t *pskindesc, char *filename)
pskindesc->fb_texnum = 0;
glow = LoadImage (va ("%s_luma", filename), 1);
glow = LoadImage (va (0, "%s_luma", filename), 1);
if (!glow)
glow = LoadImage (va ("%s_glow", filename), 1);
glow = LoadImage (va (0, "%s_glow", filename), 1);
if (!glow)
glow = LoadImage (va ("textures/%s_luma", ptr + 1), 1);
glow = LoadImage (va (0, "textures/%s_luma", ptr + 1), 1);
if (!glow)
glow = LoadImage (va ("textures/%s_glow", ptr + 1), 1);
glow = LoadImage (va (0, "textures/%s_glow", ptr + 1), 1);
if (glow)
pskindesc->fb_texnum =
GL_LoadTexture (va ("fb_%s", filename), glow->width,
GL_LoadTexture (va (0, "fb_%s", filename), glow->width,
glow->height, glow->data, true, true,
glow->format > 2 ? glow->format : 1);
else if (tex->format < 3)
pskindesc->fb_texnum = Mod_Fullbright (tex->data, tex->width,
tex->height,
va ("fb_%s", filename));
va (0, "fb_%s", filename));
}
}

View File

@ -104,9 +104,9 @@ glsl_Mod_LoadSkin (byte *skin, int skinsize, int snum, int gnum,
memcpy (tskin, skin, skinsize);
Mod_FloodFillSkin (tskin, w, h);
if (group)
name = va ("%s_%i_%i", loadmodel->name, snum, gnum);
name = va (0, "%s_%i_%i", loadmodel->name, snum, gnum);
else
name = va ("%s_%i", loadmodel->name, snum);
name = va (0, "%s_%i", loadmodel->name, snum);
skindesc->texnum = GLSL_LoadQuakeTexture (name, w, h, tskin);
free (tskin);
return skin + skinsize;

View File

@ -128,19 +128,28 @@ Vulkan_Mod_LoadSkin (byte *skinpix, int skinsize, int snum, int gnum,
tex_t skin_tex = {w, h, tex_palette, 1, vid.palette, tskin + skinsize};
if (Mod_CalcFullbright (tskin, tskin + skinsize, skinsize)) {
skin->glow = Vulkan_LoadTex (ctx, &skin_tex, 1);
skin->glow = Vulkan_LoadTex (ctx, &skin_tex, 1,
va (ctx->va_ctx, "%s:%d:%d:glow",
loadmodel->name, snum, gnum));
Mod_ClearFullbright (tskin, tskin, skinsize);
}
if (Skin_CalcTopColors (tskin, tskin + skinsize, skinsize)) {
skin->colora = Vulkan_LoadTex (ctx, &skin_tex, 1);
skin->colora = Vulkan_LoadTex (ctx, &skin_tex, 1,
va (ctx->va_ctx, "%s:%d:%d:colora",
loadmodel->name, snum, gnum));
Skin_ClearTopColors (tskin, tskin, skinsize);
}
if (Skin_CalcBottomColors (tskin, tskin + skinsize, skinsize)) {
skin->colorb = Vulkan_LoadTex (ctx, &skin_tex, 1);
skin->colorb = Vulkan_LoadTex (ctx, &skin_tex, 1,
va (ctx->va_ctx, "%s:%d:%d:colorb",
loadmodel->name, snum, gnum));
Skin_ClearBottomColors (tskin, tskin, skinsize);
}
skin_tex.data = tskin;
skin->tex = Vulkan_LoadTex (ctx, &skin_tex, 1);
skin->tex = Vulkan_LoadTex (ctx, &skin_tex, 1,
va (ctx->va_ctx, "%s:%d:%d:tex",
loadmodel->name,
snum, gnum));
free (tskin);

View File

@ -63,17 +63,17 @@ Mod_LoadAnExternalTexture (char *tname, char *mname)
if (rname[0] == '*') rname[0] = '#';
image = LoadImage (va ("textures/%.*s/%s", (int) strlen (mname + 5) - 4,
image = LoadImage (va (0, "textures/%.*s/%s", (int) strlen (mname + 5) - 4,
mname + 5, rname), 1);
if (!image)
image = LoadImage (va ("maps/%.*s/%s", (int) strlen (mname + 5) - 4,
image = LoadImage (va (0, "maps/%.*s/%s", (int) strlen (mname + 5) - 4,
mname + 5, rname), 1);
// if (!image)
// image = LoadImage (va ("textures/bmodels/%s", rname));
// image = LoadImage (va (0, "textures/bmodels/%s", rname));
if (!image)
image = LoadImage (va ("textures/%s", rname), 1);
image = LoadImage (va (0, "textures/%s", rname), 1);
if (!image)
image = LoadImage (va ("maps/%s", rname), 1);
image = LoadImage (va (0, "maps/%s", rname), 1);
return image;
}
@ -93,23 +93,23 @@ Mod_LoadExternalTextures (model_t *mod, texture_t *tx)
base->data, true, false,
base->format > 2 ? base->format : 1);
luma = Mod_LoadAnExternalTexture (va ("%s_luma", tx->name),
luma = Mod_LoadAnExternalTexture (va (0, "%s_luma", tx->name),
mod->name);
if (!luma)
luma = Mod_LoadAnExternalTexture (va ("%s_glow", tx->name),
luma = Mod_LoadAnExternalTexture (va (0, "%s_glow", tx->name),
mod->name);
gltx->gl_fb_texturenum = 0;
if (luma) {
gltx->gl_fb_texturenum =
GL_LoadTexture (va ("fb_%s", tx->name), luma->width,
GL_LoadTexture (va (0, "fb_%s", tx->name), luma->width,
luma->height, luma->data, true, true,
luma->format > 2 ? luma->format : 1);
} else if (base->format < 3) {
gltx->gl_fb_texturenum =
Mod_Fullbright (base->data, base->width, base->height,
va ("fb_%s", tx->name));
va (0, "fb_%s", tx->name));
}
}
return external;
@ -133,7 +133,7 @@ gl_Mod_ProcessTexture (texture_t *tx)
return;
}
gltex_t *gltex = tx->render;
name = va ("fb_%s", tx->name);
name = va (0, "fb_%s", tx->name);
gltex->gl_fb_texturenum =
Mod_Fullbright ((byte *) (tx + 1), tx->width, tx->height, name);
gltex->gl_texturenum =

View File

@ -356,7 +356,7 @@ Vulkan_Mod_ProcessTexture (texture_t *tx, vulkan_ctx_t *ctx)
return;
}
const char *name = va ("fb_%s", tx->name);
const char *name = va (ctx->va_ctx, "fb_%s", tx->name);
int size = (tx->width * tx->height * 85) / 64;
int fullbright_mark = Hunk_LowMark ();
byte *pixels = Hunk_AllocName (size, name);

View File

@ -80,7 +80,7 @@ gl_iqm_load_textures (iqm_t *iqm)
for (i = 0; i < iqm->num_meshes; i++) {
dstring_copystr (str, iqm->text + iqm->meshes[i].material);
QFS_StripExtension (str->str, str->str);
if ((tex = LoadImage (va ("textures/%s", str->str), 1)))
if ((tex = LoadImage (va (0, "textures/%s", str->str), 1)))
gl->textures[i] = GL_LoadTexture (str->str, tex->width,
tex->height, tex->data, true,
false,

View File

@ -102,12 +102,12 @@ glsl_iqm_load_textures (iqm_t *iqm)
for (i = 0; i < iqm->num_meshes; i++) {
dstring_copystr (str, iqm->text + iqm->meshes[i].material);
QFS_StripExtension (str->str, str->str);
if ((tex = LoadImage (va ("textures/%s", str->str), 1)))
if ((tex = LoadImage (va (0, "textures/%s", str->str), 1)))
glsl->textures[i] = GLSL_LoadRGBATexture (str->str, tex->width,
tex->height, tex->data);
else
glsl->textures[i] = GLSL_LoadRGBATexture ("", 2, 2, null_texture);
if ((tex = LoadImage (va ("textures/%s_norm", str->str), 1)))
if ((tex = LoadImage (va (0, "textures/%s_norm", str->str), 1)))
glsl->normmaps[i] = GLSL_LoadRGBATexture (str->str, tex->width,
tex->height, tex->data);
else

View File

@ -174,7 +174,7 @@ sw_iqm_load_textures (iqm_t *iqm)
continue;
dstring_copystr (str, iqm->text + iqm->meshes[i].material);
QFS_StripExtension (str->str, str->str);
if ((tex = LoadImage (va ("textures/%s", str->str), 1)))
if ((tex = LoadImage (va (0, "textures/%s", str->str), 1)))
tex = sw->skins[i] = convert_tex (tex);
else
tex = sw->skins[i] = &null_texture;

View File

@ -177,7 +177,7 @@ Skin_SetSkin (skin_t *skin, int cmap, const char *skinname)
break;
}
file = QFS_FOpenFile (va ("skins/%s.pcx", name));
file = QFS_FOpenFile (va (0, "skins/%s.pcx", name));
if (!file) {
Sys_Printf ("Couldn't load skin %s\n", name);
free (name);

View File

@ -49,7 +49,7 @@ gl_Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum)
tex_t *targa;
const char *name;
targa = LoadImage (name = va ("%s_%i", loadmodel->name, framenum), 1);
targa = LoadImage (name = va (0, "%s_%i", loadmodel->name, framenum), 1);
if (targa) {
if (targa->format < 4)
pspriteframe->gl_texturenum = GL_LoadTexture (name,

View File

@ -76,7 +76,7 @@ glsl_Mod_SpriteLoadTexture (mspriteframe_t *pspriteframe, int framenum)
const char *name;
loadmodel->clear = glsl_sprite_clear;
name = va ("%s_%i", loadmodel->name, framenum);
name = va (0, "%s_%i", loadmodel->name, framenum);
pspriteframe->gl_texturenum =
GLSL_LoadQuakeTexture (name, pspriteframe->width, pspriteframe->height,
pspriteframe->pixels);

View File

@ -140,7 +140,7 @@ bi_Cvar_SetInteger (progs_t *pr)
if (!var)
var = Cvar_FindAlias (varname);
if (var)
Cvar_Set (var, va ("%d", val));
Cvar_Set (var, va (0, "%d", val));
}
static void
@ -153,7 +153,7 @@ bi_Cvar_SetFloat (progs_t *pr)
if (!var)
var = Cvar_FindAlias (varname);
if (var)
Cvar_Set (var, va ("%g", val));
Cvar_Set (var, va (0, "%g", val));
}
static void
@ -166,7 +166,7 @@ bi_Cvar_SetVector (progs_t *pr)
if (!var)
var = Cvar_FindAlias (varname);
if (var)
Cvar_Set (var, va ("%g %g %g", val[0], val[1], val[2]));
Cvar_Set (var, va (0, "%g %g %g", val[0], val[1], val[2]));
}
static void

View File

@ -146,7 +146,8 @@ bi_QFS_WriteFile (progs_t *pr)
int count = P_INT (pr, 2);
check_buffer (pr, buf, count, "QFS_WriteFile");
QFS_WriteFile (va ("%s/%s", qfs_gamedir->dir.def, filename), buf, count);
QFS_WriteFile (va (0, "%s/%s", qfs_gamedir->dir.def, filename), buf,
count);
}
static void

View File

@ -284,7 +284,7 @@ Cvar_Set (cvar_t *var, const char *value)
VISIBLE void
Cvar_SetValue (cvar_t *var, float value)
{
Cvar_Set (var, va ("%g", value));
Cvar_Set (var, va (0, "%g", value));
}
/*
@ -608,7 +608,7 @@ Cvar_CvarList_f (void)
showhelp++;
}
for (var = cvar_vars, i = 0; var; var = var->next, i++) {
flags = va ("%c%c%c%c",
flags = va (0, "%c%c%c%c",
var->flags & CVAR_ROM ? 'r' : ' ',
var->flags & CVAR_ARCHIVE ? '*' : ' ',
var->flags & CVAR_USERINFO ? 'u' : ' ',

View File

@ -90,6 +90,7 @@ typedef struct pldata_s { // Unparsed property list string
unsigned pos;
unsigned line;
plitem_t *error;
va_ctx_t *va_ctx;
} pldata_t;
// Ugly defines for fast checking and conversion from char to number
@ -533,7 +534,8 @@ PL_ParseData (pldata_t *pl, int *len)
pl->ptr[start + i * 2 + 1]);
return str;
}
pl->error = PL_NewString (va ("invalid character in data: %02x", c));
pl->error = PL_NewString (va (pl->va_ctx,
"invalid character in data: %02x", c));
return NULL;
}
pl->error = PL_NewString ("Reached end of string while parsing data");
@ -748,7 +750,7 @@ PL_ParsePropertyListItem (pldata_t *pl)
}
if (pl->ptr[pl->pos] != '=') {
pl->error = PL_NewString (va ("Unexpected character %c (expected '=')", pl->ptr[pl->pos]));
pl->error = PL_NewString (va (pl->va_ctx, "Unexpected character %c (expected '=')", pl->ptr[pl->pos]));
PL_Free (key);
PL_Free (item);
return NULL;
@ -772,7 +774,7 @@ PL_ParsePropertyListItem (pldata_t *pl)
if (pl->ptr[pl->pos] == ';') {
pl->pos++;
} else if (pl->ptr[pl->pos] != '}') {
pl->error = PL_NewString (va ("Unexpected character %c (wanted ';' or '}')", pl->ptr[pl->pos]));
pl->error = PL_NewString (va (pl->va_ctx, "Unexpected character %c (wanted ';' or '}')", pl->ptr[pl->pos]));
PL_Free (key);
PL_Free (value);
PL_Free (item);
@ -822,7 +824,7 @@ PL_ParsePropertyListItem (pldata_t *pl)
if (pl->ptr[pl->pos] == ',') {
pl->pos++;
} else if (pl->ptr[pl->pos] != ')') {
pl->error = PL_NewString (va ("Unexpected character %c (wanted ',' or ')')", pl->ptr[pl->pos]));
pl->error = PL_NewString (va (pl->va_ctx, "Unexpected character %c (wanted ',' or ')')", pl->ptr[pl->pos]));
PL_Free (value);
PL_Free (item);
return NULL;
@ -891,8 +893,10 @@ PL_GetPropertyList (const char *string)
pl->end = strlen (string);
pl->error = NULL;
pl->line = 1;
pl->va_ctx = va_create_context (4);
if ((newpl = PL_ParsePropertyListItem (pl))) {
va_destroy_context (pl->va_ctx);
free (pl);
return newpl;
} else {
@ -903,6 +907,7 @@ PL_GetPropertyList (const char *string)
}
PL_Free (pl->error);
}
va_destroy_context (pl->va_ctx);
free (pl);
return NULL;
}
@ -1093,22 +1098,25 @@ VISIBLE void
PL_Message (plitem_t *messages, const plitem_t *item, const char *fmt, ...)
{
va_list args;
dstring_t *string;
dstring_t *va_str;
dstring_t *msg_str;
char *msg;
string = dstring_new ();
va_str = dstring_new ();
msg_str = dstring_new ();
va_start (args, fmt);
dvsprintf (string, fmt, args);
dvsprintf (va_str, fmt, args);
va_end (args);
if (item) {
PL_A_AddObject (messages,
PL_NewString (va ("%d: %s", item->line, string->str)));
msg = dsprintf (msg_str, "%d: %s", item->line, va_str->str);
} else {
PL_A_AddObject (messages,
PL_NewString (va ("internal: %s", string->str)));
msg = dsprintf (msg_str, "internal: %s", va_str->str);
}
dstring_delete (string);
PL_A_AddObject (messages, PL_NewString (msg));
dstring_delete (va_str);
dstring_delete (msg_str);
}
static int

View File

@ -359,7 +359,7 @@ qfs_var_subst (const char *string, hashtab_t *vars)
dstring_appendsubstr (new, s, (e - s));
break;
}
var = va ("%.*s", (int) (e - s) - 1, s + 1);
var = va (0, "%.*s", (int) (e - s) - 1, s + 1);
sub = Hash_Find (vars, var);
if (sub)
dstring_appendstr (new, sub->val);
@ -370,7 +370,7 @@ qfs_var_subst (const char *string, hashtab_t *vars)
s = e;
while (qfs_isident (*e))
e++;
var = va ("%.*s", (int) (e - s), s);
var = va (0, "%.*s", (int) (e - s), s);
sub = Hash_Find (vars, var);
if (sub)
dstring_appendstr (new, sub->val);
@ -588,7 +588,7 @@ qfs_build_gamedir (const char **list)
gamedir = calloc (1, sizeof (gamedir_t));
path = dstring_newstr ();
while (j--) {
const char *name = va ("%s:%s", qfs_game, dir = list[j]);
const char *name = va (0, "%s:%s", qfs_game, dir = list[j]);
if (Hash_Find (dirs, name))
continue;
gdpl = qfs_find_gamedir (name, dirs);
@ -1661,7 +1661,7 @@ QFS_FilelistAdd (filelist_t *filelist, const char *fname, const char *ext)
}
str = strdup (fname);
if (ext && (s = strstr(str, va(".%s", ext))))
if (ext && (s = strstr(str, va (0, ".%s", ext))))
*s = 0;
filelist->list[filelist->count++] = str;
}
@ -1680,9 +1680,9 @@ qfs_filelistfill_do (filelist_t *list, const searchpath_t *search, const char *c
for (i = 0; i < pak->numfiles; i++) {
char *name = pak->files[i].name;
if (!fnmatch (va("%s%s*.%s", cp, separator, ext), name,
if (!fnmatch (va (0, "%s%s*.%s", cp, separator, ext), name,
FNM_PATHNAME)
|| !fnmatch (va("%s%s*.%s.gz", cp, separator, ext), name,
|| !fnmatch (va (0, "%s%s*.%s.gz", cp, separator, ext), name,
FNM_PATHNAME))
QFS_FilelistAdd (list, name, strip ? ext : 0);
}
@ -1690,12 +1690,12 @@ qfs_filelistfill_do (filelist_t *list, const searchpath_t *search, const char *c
DIR *dir_ptr;
struct dirent *dirent;
dir_ptr = opendir (va ("%s/%s", search->filename, cp));
dir_ptr = opendir (va (0, "%s/%s", search->filename, cp));
if (!dir_ptr)
return;
while ((dirent = readdir (dir_ptr)))
if (!fnmatch (va("*.%s", ext), dirent->d_name, 0)
|| !fnmatch (va("*.%s.gz", ext), dirent->d_name, 0))
if (!fnmatch (va (0, "*.%s", ext), dirent->d_name, 0)
|| !fnmatch (va (0, "*.%s.gz", ext), dirent->d_name, 0))
QFS_FilelistAdd (list, dirent->d_name, strip ? ext : 0);
closedir (dir_ptr);
}

View File

@ -40,28 +40,51 @@
#include "QF/dstring.h"
#include "QF/va.h"
struct va_ctx_s {
dstring_t **strings;
int num_strings;
int str_index;
};
/*
va
does a varargs printf into a temp buffer, so I don't need to have
varargs versions of all text functions.
*/
VISIBLE char *
va (const char *fmt, ...)
VISIBLE va_ctx_t *
va_create_context (int buffers)
{
va_ctx_t *ctx;
ctx = malloc (sizeof (va_ctx_t) + buffers * sizeof (dstring_t *));
ctx->strings = (dstring_t **) (ctx + 1);
ctx->num_strings = buffers;
ctx->str_index = 0;
for (int i = 0; i < buffers; i++) {
ctx->strings[i] = dstring_new ();
}
return ctx;
}
VISIBLE void
va_destroy_context (va_ctx_t *ctx)
{
for (int i = 0; i < ctx->num_strings; i++) {
dstring_delete (ctx->strings[i]);
}
free (ctx);
}
VISIBLE char *
va (va_ctx_t *ctx, const char *fmt, ...)
{
static va_ctx_t *_ctx;
va_list args;
static dstring_t *string[4];
#define NUM_STRINGS (sizeof (string) / sizeof (string[0]))
static int str_index;
dstring_t *dstr;
if (!string[0]) {
for (size_t i = 0; i < NUM_STRINGS; i++) {
string[i] = dstring_new ();
if (!ctx) {
if (!_ctx) {
_ctx = va_create_context (4);
}
ctx = _ctx;
}
dstr = string[str_index++ % NUM_STRINGS];
dstr = ctx->strings[ctx->str_index++ % ctx->num_strings];
va_start (args, fmt);
dvsprintf (dstr, fmt, args);

View File

@ -210,7 +210,7 @@ gl_R_ReadPointFile_f (void)
Sys_Error ("Can't duplicate mapname!");
QFS_StripExtension (mapname, mapname);
name = va ("%s.pts", mapname);
name = va (0, "%s.pts", mapname);
free (mapname);
f = QFS_FOpenFile (name);

View File

@ -152,7 +152,7 @@ gl_SCR_ScreenShot_f (void)
// find a file name to save it to
if (!QFS_NextFilename (pcxname,
va ("%s/qf", qfs_gamedir->dir.shots), ".tga")) {
va (0, "%s/qf", qfs_gamedir->dir.shots), ".tga")) {
Sys_Printf ("SCR_ScreenShot_f: Couldn't create a TGA file\n");
} else {
tex_t *tex;

View File

@ -131,11 +131,12 @@ gl_R_LoadSkys (const char *skyname)
qfglBindTexture (GL_TEXTURE_2D, SKY_TEX + i);
targa = LoadImage (name = va ("env/%s%s", skyname, suf[i]), 1);
targa = LoadImage (name = va (0, "env/%s%s", skyname, suf[i]), 1);
if (!targa || targa->format < 3) { // FIXME Can't do PCX right now
Sys_MaskPrintf (SYS_DEV, "Couldn't load %s\n", name);
// also look in gfx/env, where Darkplaces looks for skies
targa = LoadImage (name = va ("gfx/env/%s%s", skyname, suf[i]), 1);
targa = LoadImage (name = va (0, "gfx/env/%s%s", skyname,
suf[i]), 1);
if (!targa) {
Sys_MaskPrintf (SYS_DEV, "Couldn't load %s\n", name);
gl_skyloaded = false;

View File

@ -1402,7 +1402,7 @@ glsl_R_LoadSkys (const char *sky)
//blender envmap
// bk rt ft
// dn up lt
tex = LoadImage (name = va ("env/%s_map", sky), 1);
tex = LoadImage (name = va (0, "env/%s_map", sky), 1);
if (tex && tex->format >= 3 && tex->height * 3 == tex->width * 2
&& is_pow2 (tex->height)) {
tex_t *sub;
@ -1430,11 +1430,11 @@ glsl_R_LoadSkys (const char *sky)
} else {
skybox_loaded = true;
for (i = 0; i < 6; i++) {
tex = LoadImage (name = va ("env/%s%s", sky, sky_suffix[i]), 1);
tex = LoadImage (name = va (0, "env/%s%s", sky, sky_suffix[i]), 1);
if (!tex || tex->format < 3) { // FIXME pcx support
Sys_MaskPrintf (SYS_GLSL, "Couldn't load %s\n", name);
// also look in gfx/env, where Darkplaces looks for skies
tex = LoadImage (name = va ("gfx/env/%s%s", sky,
tex = LoadImage (name = va (0, "gfx/env/%s%s", sky,
sky_suffix[i]), 1);
if (!tex || tex->format < 3) { // FIXME pcx support
Sys_MaskPrintf (SYS_GLSL, "Couldn't load %s\n", name);

View File

@ -318,7 +318,7 @@ glsl_R_ReadPointFile_f (void)
Sys_Error ("Can't duplicate mapname!");
QFS_StripExtension (mapname, mapname);
name = va ("%s.pts", mapname);
name = va (0, "%s.pts", mapname);
free (mapname);
f = QFS_FOpenFile (name);

View File

@ -231,8 +231,8 @@ glsl_SCR_ScreenShot_f (void)
dstring_t *name = dstring_new ();
// find a file name to save it to
if (!QFS_NextFilename (name,
va ("%s/qf", qfs_gamedir->dir.shots), ".png")) {
if (!QFS_NextFilename (name, va (0, "%s/qf",
qfs_gamedir->dir.shots), ".png")) {
Sys_Printf ("SCR_ScreenShot_f: Couldn't create a PNG file\n");
} else {
tex_t *tex;

View File

@ -268,7 +268,7 @@ type_name (GLenum type)
case GL_FIXED:
return "fixed";
}
return va("%x", type);
return va (0, "%x", type);
}
static void

View File

@ -159,7 +159,7 @@ SCR_ScreenShot_f (void)
// find a file name to save it to
if (!QFS_NextFilename (pcxname,
va ("%s/qf", qfs_gamedir->dir.shots), ".pcx")) {
va (0, "%s/qf", qfs_gamedir->dir.shots), ".pcx")) {
Sys_Printf ("SCR_ScreenShot_f: Couldn't create a PCX");
} else {
// enable direct drawing of console to back buffer

View File

@ -88,7 +88,7 @@ R_ReadPointFile_f (void)
Sys_Error ("Can't duplicate mapname!");
QFS_StripExtension (mapname, mapname);
name = va ("maps/%s.pts", mapname);
name = va (0, "maps/%s.pts", mapname);
free (mapname);
f = QFS_FOpenFile (name);

View File

@ -103,8 +103,8 @@ sw32_SCR_ScreenShot_f (void)
int pcx_len;
// find a file name to save it to
if (!QFS_NextFilename (pcxname,
va ("%s/qf", qfs_gamedir->dir.shots), ".pcx")) {
if (!QFS_NextFilename (pcxname, va (0, "%s/qf",
qfs_gamedir->dir.shots), ".pcx")) {
Sys_Printf ("SCR_ScreenShot_f: Couldn't create a PCX");
} else {
// enable direct drawing of console to back buffer

View File

@ -93,7 +93,7 @@ sw32_R_ReadPointFile_f (void)
Sys_Error ("Can't duplicate mapname!");
QFS_StripExtension (mapname, mapname);
name = va ("maps/%s.pts", mapname);
name = va (0, "maps/%s.pts", mapname);
free (mapname);
f = QFS_FOpenFile (name);

View File

@ -40,10 +40,10 @@ VID_SetCaption (const char *text)
if (text && *text) {
char *temp = strdup (text);
SDL_WM_SetCaption (va ("%s: %s", PACKAGE_STRING, temp), NULL);
SDL_WM_SetCaption (va (0, "%s: %s", PACKAGE_STRING, temp), NULL);
free (temp);
} else {
SDL_WM_SetCaption (va ("%s", PACKAGE_STRING), NULL);
SDL_WM_SetCaption (va (0, "%s", PACKAGE_STRING), NULL);
}
}

View File

@ -566,7 +566,7 @@ X11_CreateWindow (int width, int height)
XFree (SizeHints);
}
// Set window title
X11_SetCaption (va ("%s", PACKAGE_STRING));
X11_SetCaption (va (0, "%s", PACKAGE_STRING));
// Set icon name
XSetIconName (x_disp, x_win, PACKAGE_NAME);

View File

@ -183,7 +183,7 @@ JOY_Init (void)
static void
joyamp_f (cvar_t *var)
{
Cvar_Set (var, va ("%g", max (0.0001, var->value)));
Cvar_Set (var, va (0, "%g", max (0.0001, var->value)));
}
typedef struct {

View File

@ -90,9 +90,9 @@ VID_GetWindowSize (int def_w, int def_h)
{
int pnum, conheight;
vid_width = Cvar_Get ("vid_width", va ("%d", def_w), CVAR_NONE, NULL,
vid_width = Cvar_Get ("vid_width", va (0, "%d", def_w), CVAR_NONE, NULL,
"screen width");
vid_height = Cvar_Get ("vid_height", va ("%d", def_h), CVAR_NONE, NULL,
vid_height = Cvar_Get ("vid_height", va (0, "%d", def_h), CVAR_NONE, NULL,
"screen height");
vid_aspect = Cvar_Get ("vid_aspect", "4:3", CVAR_ROM, vid_aspect_f,
"Physical screen aspect ratio in \"width:height\" format. "
@ -140,7 +140,7 @@ VID_GetWindowSize (int def_w, int def_h)
viddef.aspect = ((vid_aspect->vec[0] * viddef.height)
/ (vid_aspect->vec[1] * viddef.width));
con_width = Cvar_Get ("con_width", va ("%d", viddef.width), CVAR_NONE,
con_width = Cvar_Get ("con_width", va (0, "%d", viddef.width), CVAR_NONE,
NULL, "console effective width (GL only)");
if ((pnum = COM_CheckParm ("-conwidth"))) {
if (pnum >= com_argc - 1)
@ -148,20 +148,20 @@ VID_GetWindowSize (int def_w, int def_h)
Cvar_Set (con_width, com_argv[pnum + 1]);
}
// make con_width a multiple of 8 and >= 320
Cvar_Set (con_width, va ("%d", max (con_width->int_val & ~7, 320)));
Cvar_Set (con_width, va (0, "%d", max (con_width->int_val & ~7, 320)));
Cvar_SetFlags (con_width, con_width->flags | CVAR_ROM);
viddef.conwidth = con_width->int_val;
conheight = (viddef.conwidth * vid_aspect->vec[1]) / vid_aspect->vec[0];
con_height = Cvar_Get ("con_height", va ("%d", conheight), CVAR_NONE, NULL,
"console effective height (GL only)");
con_height = Cvar_Get ("con_height", va (0, "%d", conheight), CVAR_NONE,
NULL, "console effective height (GL only)");
if ((pnum = COM_CheckParm ("-conheight"))) {
if (pnum >= com_argc - 1)
Sys_Error ("VID: -conheight <width>");
Cvar_Set (con_height, com_argv[pnum + 1]);
}
// make con_height >= 200
Cvar_Set (con_height, va ("%d", max (con_height->int_val, 200)));
Cvar_Set (con_height, va (0, "%d", max (con_height->int_val, 200)));
Cvar_SetFlags (con_height, con_height->flags | CVAR_ROM);
viddef.conheight = con_height->int_val;
@ -258,7 +258,7 @@ VID_InitGamma (unsigned char *pal)
}
gamma = bound (0.1, gamma, 9.9);
vid_gamma = Cvar_Get ("vid_gamma", va ("%f", gamma), CVAR_ARCHIVE,
vid_gamma = Cvar_Get ("vid_gamma", va (0, "%f", gamma), CVAR_ARCHIVE,
VID_UpdateGamma, "Gamma correction");
VID_BuildGammaTable (vid_gamma->value);

View File

@ -182,10 +182,10 @@ VID_SetCaption (const char *text)
if (text && *text) {
char *temp = strdup (text);
X11_SetCaption (va ("%s: %s", PACKAGE_STRING, temp));
X11_SetCaption (va (0, "%s: %s", PACKAGE_STRING, temp));
free (temp);
} else {
X11_SetCaption (va ("%s", PACKAGE_STRING));
X11_SetCaption (va (0, "%s", PACKAGE_STRING));
}
}

View File

@ -53,6 +53,7 @@
#include "QF/cvar.h"
#include "QF/set.h"
#include "QF/sys.h"
#include "QF/va.h"
#include "QF/Vulkan/instance.h"
@ -211,6 +212,7 @@ X11_Vulkan_Context (void)
ctx->create_window = x11_vulkan_create_window;
ctx->create_surface = x11_vulkan_create_surface;
ctx->required_extensions = required_extensions;
ctx->va_ctx = va_create_context (4);
return ctx;
}

View File

@ -312,7 +312,7 @@ CL_Record_f (void)
// start up the map
if (c > 2)
Cmd_ExecuteString (va ("map %s", Cmd_Argv (2)), src_command);
Cmd_ExecuteString (va (0, "map %s", Cmd_Argv (2)), src_command);
CL_Record (Cmd_Argv (1), track);
}

View File

@ -106,7 +106,7 @@ CL_WriteConfiguration (void)
// dedicated servers initialize the host but don't parse and set the
// config.cfg cvars
if (host_initialized && !isDedicated && cl_writecfg->int_val) {
char *path = va ("%s/config.cfg", qfs_gamedir->dir.def);
char *path = va (0, "%s/config.cfg", qfs_gamedir->dir.def);
f = QFS_WOpen (path, 0);
if (!f) {
Sys_Printf ("Couldn't write config.cfg.\n");
@ -344,10 +344,11 @@ CL_SignonReply (void)
case so_spawn:
MSG_WriteByte (&cls.message, clc_stringcmd);
MSG_WriteString (&cls.message, va ("name \"%s\"\n", cl_name->string));
MSG_WriteString (&cls.message, va (0, "name \"%s\"\n",
cl_name->string));
MSG_WriteByte (&cls.message, clc_stringcmd);
MSG_WriteString (&cls.message,
va ("color %i %i\n", (cl_color->int_val) >> 4,
va (0, "color %i %i\n", (cl_color->int_val) >> 4,
(cl_color->int_val) & 15));
MSG_WriteByte (&cls.message, clc_stringcmd);
MSG_WriteString (&cls.message, "spawn");
@ -389,7 +390,8 @@ CL_NextDemo (void)
}
}
Cbuf_InsertText (host_cbuf, va ("playdemo %s\n", cls.demos[cls.demonum]));
Cbuf_InsertText (host_cbuf, va (0, "playdemo %s\n",
cls.demos[cls.demonum]));
cls.demonum++;
}

View File

@ -866,7 +866,7 @@ CL_ParseServerMessage (void)
continue;
}
SHOWNET (va ("%s(%d)", svc_strings[cmd], cmd));
SHOWNET (va (0, "%s(%d)", svc_strings[cmd], cmd));
// other commands
switch (cmd) {

View File

@ -529,7 +529,7 @@ Host_FilterTime (float time)
//FIXME not having the framerate cap is nice, but it breaks net play
timedifference = (timescale / 72.0) - (realtime - oldrealtime);
if (!cls.timedemo && (timedifference > 0))
if (0 && !cls.timedemo && (timedifference > 0))
return timedifference; // framerate is too high
host_frametime = realtime - oldrealtime;
@ -541,7 +541,7 @@ Host_FilterTime (float time)
if (host_framerate->value > 0)
host_frametime = host_framerate->value;
else // don't allow really long or short frames
host_frametime = bound (0.001, host_frametime, 0.1);
host_frametime = bound (0.000, host_frametime, 0.1);
return 0;
}
@ -696,7 +696,7 @@ _Host_Frame (float time)
if (cls.demo_capture) {
tex_t *tex = r_funcs->SCR_CaptureBGR ();
WritePNGqfs (va ("%s/qfmv%06d.png", qfs_gamedir->dir.shots,
WritePNGqfs (va (0, "%s/qfmv%06d.png", qfs_gamedir->dir.shots,
cls.demo_capture++),
tex->data, tex->width, tex->height);
free (tex);

View File

@ -239,13 +239,13 @@ nice_time (float time)
int t = time + 0.5;
if (t < 60) {
return va ("%ds", t);
return va (0, "%ds", t);
} else if (t < 3600) {
return va ("%dm%02ds", t / 60, t % 60);
return va (0, "%dm%02ds", t / 60, t % 60);
} else if (t < 86400) {
return va ("%dh%02dm%02ds", t / 3600, (t / 60) % 60, t % 60);
return va (0, "%dh%02dm%02ds", t / 3600, (t / 60) % 60, t % 60);
} else {
return va ("%dd%02dh%02dm%02ds",
return va (0, "%dd%02dh%02dm%02ds",
t / 86400, (t / 3600) % 24, (t / 60) % 60, t % 60);
}
}
@ -279,7 +279,7 @@ Host_Map_f (void)
}
// check to make sure the level exists
expanded = va ("maps/%s.bsp", Cmd_Argv (1));
expanded = va (0, "maps/%s.bsp", Cmd_Argv (1));
f = QFS_FOpenFile (expanded);
if (!f) {
Sys_Printf ("Can't find %s\n", expanded);
@ -395,7 +395,7 @@ spawn_parms_array (void)
const char *parm;
for (i = 0; i < NUM_SPAWN_PARMS; i++) {
parm = va ("%.9g", svs.clients->spawn_parms[i]);
parm = va (0, "%.9g", svs.clients->spawn_parms[i]);
PL_A_AddObject (parms, PL_NewString (parm));
}
return parms;
@ -437,15 +437,15 @@ game_dict (void)
plitem_t *game = PL_NewDictionary ();
PL_D_AddObject (game, "comment",
PL_NewString (va ("%-21s kills:%3i/%3i", cl.levelname,
PL_NewString (va (0, "%-21s kills:%3i/%3i", cl.levelname,
cl.stats[STAT_MONSTERS],
cl.stats[STAT_TOTALMONSTERS])));
PL_D_AddObject (game, "spawn_parms", spawn_parms_array ());
PL_D_AddObject (game, "current_skill",
PL_NewString (va ("%d", current_skill)));
PL_NewString (va (0, "%d", current_skill)));
PL_D_AddObject (game, "name", PL_NewString (sv.name));
// sv.time is a double, so it gets 17 digits
PL_D_AddObject (game, "time", PL_NewString (va ("%.17g", sv.time)));
PL_D_AddObject (game, "time", PL_NewString (va (0, "%.17g", sv.time)));
PL_D_AddObject (game, "lightstyles", lightstyles_array ());
PL_D_AddObject (game, "globals", ED_GlobalsDict (&sv_pr_state));
PL_D_AddObject (game, "entities", entities_array ());
@ -478,7 +478,7 @@ convert_to_game_dict (script_t *script)
// values
Script_GetToken (script, 1);
skill = (int) (atof (script->token->str) + 0.1);
PL_D_AddObject (game, "current_skill", PL_NewString (va ("%d", skill)));
PL_D_AddObject (game, "current_skill", PL_NewString (va (0, "%d", skill)));
Script_GetToken (script, 1);
PL_D_AddObject (game, "name", PL_NewString (script->token->str));
@ -752,7 +752,7 @@ Host_Name_f (void)
if (cmd_source == src_command) {
if (strcmp (cl_name->string, newName) == 0)
return;
Cvar_Set (cl_name, va ("%.15s", newName));
Cvar_Set (cl_name, va (0, "%.15s", newName));
if (cls.state >= ca_connected)
CL_Cmd_ForwardToServer ();
return;

View File

@ -1648,8 +1648,8 @@ Sbar_Init (void)
Key_KeydestCallback (sbar_keydest_callback);
for (i = 0; i < 10; i++) {
sb_nums[0][i] = r_funcs->Draw_PicFromWad (va ("num_%i", i));
sb_nums[1][i] = r_funcs->Draw_PicFromWad (va ("anum_%i", i));
sb_nums[0][i] = r_funcs->Draw_PicFromWad (va (0, "num_%i", i));
sb_nums[1][i] = r_funcs->Draw_PicFromWad (va (0, "anum_%i", i));
}
sb_nums[0][10] = r_funcs->Draw_PicFromWad ("num_minus");
@ -1676,19 +1676,19 @@ Sbar_Init (void)
for (i = 0; i < 5; i++) {
sb_weapons[2 + i][0] =
r_funcs->Draw_PicFromWad (va ("inva%i_shotgun", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_shotgun", i + 1));
sb_weapons[2 + i][1] =
r_funcs->Draw_PicFromWad (va ("inva%i_sshotgun", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_sshotgun", i + 1));
sb_weapons[2 + i][2] =
r_funcs->Draw_PicFromWad (va ("inva%i_nailgun", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_nailgun", i + 1));
sb_weapons[2 + i][3] =
r_funcs->Draw_PicFromWad (va ("inva%i_snailgun", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_snailgun", i + 1));
sb_weapons[2 + i][4] =
r_funcs->Draw_PicFromWad (va ("inva%i_rlaunch", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_rlaunch", i + 1));
sb_weapons[2 + i][5] =
r_funcs->Draw_PicFromWad (va ("inva%i_srlaunch", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_srlaunch", i + 1));
sb_weapons[2 + i][6] =
r_funcs->Draw_PicFromWad (va ("inva%i_lightng", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_lightng", i + 1));
}
sb_ammo[0] = r_funcs->Draw_PicFromWad ("sb_shells");
@ -1753,15 +1753,15 @@ Sbar_Init (void)
for (i = 0; i < 5; i++) {
hsb_weapons[2 + i][0] =
r_funcs->Draw_PicFromWad (va ("inva%i_laser", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_laser", i + 1));
hsb_weapons[2 + i][1] =
r_funcs->Draw_PicFromWad (va ("inva%i_mjolnir", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_mjolnir", i + 1));
hsb_weapons[2 + i][2] =
r_funcs->Draw_PicFromWad (va ("inva%i_gren_prox", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_gren_prox", i + 1));
hsb_weapons[2 + i][3] =
r_funcs->Draw_PicFromWad (va ("inva%i_prox_gren", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_prox_gren", i + 1));
hsb_weapons[2 + i][4] =
r_funcs->Draw_PicFromWad (va ("inva%i_prox", i + 1));
r_funcs->Draw_PicFromWad (va (0, "inva%i_prox", i + 1));
}
hsb_items[0] = r_funcs->Draw_PicFromWad ("sb_wsuit");

View File

@ -1214,7 +1214,7 @@ SV_SpawnServer (const char *server)
*sv_globals.serverflags = svs.serverflags;
*sv_globals.time = sv.time;
ent_file = QFS_VOpenFile (va ("maps/%s.ent", server), 0,
ent_file = QFS_VOpenFile (va (0, "maps/%s.ent", server), 0,
sv.worldmodel->vpath);
if ((buf = QFS_LoadFile (ent_file, 0))) {
ED_LoadFromFile (&sv_pr_state, (char *) buf);

View File

@ -1280,7 +1280,7 @@ PF_changelevel (progs_t *pr)
svs.changelevel_issued = true;
s = P_GSTRING (pr, 0);
Cbuf_AddText (host_cbuf, va ("changelevel %s\n", s));
Cbuf_AddText (host_cbuf, va (0, "changelevel %s\n", s));
}
// entity (entity ent) testentitypos

View File

@ -177,9 +177,9 @@ cl_prespawn_f (client_t *cl, void *unused)
if (buf >= sv->num_signon_buffers)
buf = 0;
if (buf == sv->num_signon_buffers - 1)
cmd = va ("cmd spawn %i 0\n", cl->server->spawncount);
cmd = va (0, "cmd spawn %i 0\n", cl->server->spawncount);
else
cmd = va ("cmd prespawn %i %i\n", cl->server->spawncount, buf + 1);
cmd = va (0, "cmd prespawn %i %i\n", cl->server->spawncount, buf + 1);
size = sv->signon_buffer_size[buf] + 1 + strlen (cmd) + 1;
msg = MSG_ReliableCheckBlock (&cl->backbuf, size);
SZ_Write (msg, sv->signon_buffers[buf], sv->signon_buffer_size[buf]);
@ -1234,7 +1234,7 @@ Client_New (client_t *cl)
MSG_WriteByte (&cl->netchan.message, sv->cdtrack);
MSG_WriteByte (&cl->netchan.message, svc_stufftext);
MSG_WriteString (&cl->netchan.message,
va ("fullserverinfo \"%s\"\n",
va (0, "fullserverinfo \"%s\"\n",
Info_MakeString (sv->info, 0)));
}

View File

@ -237,7 +237,7 @@ qtv_quit_f (void)
static void
qtv_net_init (void)
{
qtv_port = Cvar_Get ("qtv_port", va ("%d", PORT_QTV), 0, 0,
qtv_port = Cvar_Get ("qtv_port", va (0, "%d", PORT_QTV), 0, 0,
"udp port to use");
sv_timeout = Cvar_Get ("sv_timeout", "60", 0, 0, "server timeout");
NET_Init (qtv_port->int_val);

View File

@ -52,7 +52,7 @@ draw_clients (view_t *view)
const char *s;
char *d;
str = va ("[CL: %3d]", client_count);
str = va (0, "[CL: %3d]", client_count);
for (s = str, d = sb->text + view->xrel; *s; s++)
*d++ = *s;
}
@ -66,7 +66,7 @@ draw_servers (view_t *view)
const char *s;
char *d;
str = va ("[SV: %2d]", server_count);
str = va (0, "[SV: %2d]", server_count);
for (s = str, d = sb->text + view->xrel; *s; s++)
*d++ = *s;
}

View File

@ -452,7 +452,8 @@ sv_new_f (void)
sv->qport = qport->int_val;
sv->info = Info_ParseString ("", MAX_INFO_STRING, 0);
Info_SetValueForStarKey (sv->info, "*ver",
va ("%s QTV %s", QW_VERSION, PACKAGE_VERSION), 0);
va (0, "%s QTV %s", QW_VERSION, PACKAGE_VERSION),
0);
Info_SetValueForStarKey (sv->info, "*qsg_version", QW_QSG_VERSION, 0);
Info_SetValueForKey (sv->info, "name", "QTV Proxy", 0);
Hash_Add (server_hash, sv);
@ -628,7 +629,7 @@ Server_Broadcast (server_t *sv, int reliable, int all, const byte *msg,
void
Server_BroadcastCommand (server_t *sv, const char *cmd)
{
const char *msg = va ("%c%s", svc_stufftext, cmd);
const char *msg = va (0, "%c%s", svc_stufftext, cmd);
int len = strlen (msg) + 1;
Server_Broadcast (sv, 1, 1, (const byte *) msg, len);
}

View File

@ -118,7 +118,7 @@ sv_serverdata (server_t *sv, qmsg_t *msg)
MSG_WriteByte (&sv->netchan.message, qtv_stringcmd);
MSG_WriteString (&sv->netchan.message,
va ("soundlist %i %i", sv->spawncount, 0));
va (0, "soundlist %i %i", sv->spawncount, 0));
sv->next_run = realtime;
}
@ -147,11 +147,11 @@ sv_soundlist (server_t *sv, qmsg_t *msg)
if (n) {
MSG_WriteByte (&sv->netchan.message, qtv_stringcmd);
MSG_WriteString (&sv->netchan.message,
va ("soundlist %d %d", sv->spawncount, n));
va (0, "soundlist %d %d", sv->spawncount, n));
} else {
MSG_WriteByte (&sv->netchan.message, qtv_stringcmd);
MSG_WriteString (&sv->netchan.message,
va ("modellist %d %d", sv->spawncount, 0));
va (0, "modellist %d %d", sv->spawncount, 0));
}
sv->next_run = realtime;
}
@ -183,11 +183,11 @@ sv_modellist (server_t *sv, qmsg_t *msg)
if (n) {
MSG_WriteByte (&sv->netchan.message, qtv_stringcmd);
MSG_WriteString (&sv->netchan.message,
va ("modellist %d %d", sv->spawncount, n));
va (0, "modellist %d %d", sv->spawncount, n));
} else {
MSG_WriteByte (&sv->netchan.message, qtv_stringcmd);
MSG_WriteString (&sv->netchan.message,
va ("prespawn %d 0 0", sv->spawncount));
va (0, "prespawn %d 0 0", sv->spawncount));
sv->signon = 1;
}
sv->next_run = realtime;
@ -213,7 +213,7 @@ sv_skins_f (server_t *sv)
// to get everything ready at the last miniute before we start getting
// actual in-game update messages
MSG_WriteByte (&sv->netchan.message, qtv_stringcmd);
MSG_WriteString (&sv->netchan.message, va ("begin %d", sv->spawncount));
MSG_WriteString (&sv->netchan.message, va (0, "begin %d", sv->spawncount));
sv->next_run = realtime;
sv->connected = 2;
sv->delta = -1;

View File

@ -233,7 +233,7 @@ CL_ChatInfo (int val)
val = 0;
if (cls.chat != val) {
cls.chat = val;
Cbuf_AddText(cl_cbuf, va ("setinfo chat \"%d\"\n", val));
Cbuf_AddText(cl_cbuf, va (0, "setinfo chat \"%d\"\n", val));
}
}

View File

@ -53,7 +53,7 @@ Cvar_Info (cvar_t *var)
if (cls.state >= ca_connected && !cls.demoplayback) {
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
MSG_WriteString (&cls.netchan.message,
va ("setinfo \"%s\" \"%s\"\n", var->name,
va (0, "setinfo \"%s\" \"%s\"\n", var->name,
var->string));
}
}

View File

@ -697,7 +697,7 @@ demo_start_recording (int track)
// send server info string
MSG_WriteByte (&buf, svc_stufftext);
MSG_WriteString (&buf, va ("fullserverinfo \"%s\"\n",
MSG_WriteString (&buf, va (0, "fullserverinfo \"%s\"\n",
Info_MakeString (cl.serverinfo, 0)));
// flush packet
@ -803,7 +803,7 @@ demo_start_recording (int track)
}
MSG_WriteByte (&buf, svc_stufftext);
MSG_WriteString (&buf, va ("cmd spawn %i 0\n", cl.servercount));
MSG_WriteString (&buf, va (0, "cmd spawn %i 0\n", cl.servercount));
if (buf.cursize) {
CL_WriteRecordDemoMessage (&buf, seq++);
@ -863,7 +863,7 @@ demo_start_recording (int track)
// get the client to check and download skins
// when that is completed, a begin command will be issued
MSG_WriteByte (&buf, svc_stufftext);
MSG_WriteString (&buf, va ("skins\n"));
MSG_WriteString (&buf, va (0, "skins\n"));
CL_WriteRecordDemoMessage (&buf, seq++);

View File

@ -321,7 +321,7 @@ CL_CheckForResend (void)
connect_time = realtime + t2 - t1; // for retransmit requests
VID_SetCaption (va ("Connecting to %s", cls.servername->str));
VID_SetCaption (va (0, "Connecting to %s", cls.servername->str));
Sys_Printf ("Connecting to %s...\n", cls.servername->str);
Netchan_SendPacket (strlen (getchallenge), (void *) getchallenge,
cls.server_addr);
@ -785,7 +785,7 @@ CL_NextDemo (void)
}
}
Cbuf_InsertText (cl_cbuf, va ("playdemo %s\n", cls.demos[cls.demonum]));
Cbuf_InsertText (cl_cbuf, va (0, "playdemo %s\n", cls.demos[cls.demonum]));
cls.demonum++;
}
@ -1089,7 +1089,7 @@ CL_Download_f (void)
cls.downloadtype = dl_single;
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
SZ_Print (&cls.netchan.message, va ("download %s\n", Cmd_Argv (1)));
SZ_Print (&cls.netchan.message, va (0, "download %s\n", Cmd_Argv (1)));
} else {
Sys_Printf ("error downloading %s: %s\n", Cmd_Argv (1),
strerror (errno));
@ -1515,7 +1515,7 @@ Host_WriteConfiguration (void)
QFile *f;
if (host_initialized && cl_writecfg->int_val) {
char *path = va ("%s/config.cfg", qfs_gamedir->dir.def);
char *path = va (0, "%s/config.cfg", qfs_gamedir->dir.def);
f = QFS_WOpen (path, 0);
if (!f) {
@ -1700,7 +1700,7 @@ Host_Frame (float time)
if (cls.demo_capture) {
tex_t *tex = r_funcs->SCR_CaptureBGR ();
WritePNGqfs (va ("%s/qfmv%06d.png", qfs_gamedir->dir.shots,
WritePNGqfs (va (0, "%s/qfmv%06d.png", qfs_gamedir->dir.shots,
cls.demo_capture++),
tex->data, tex->width, tex->height);
free (tex);
@ -1782,7 +1782,7 @@ CL_Autoexec (int phase)
Cbuf_AddText (cl_cbuf, "exec autoexec.cfg\n");
}
Cbuf_AddText (cl_cbuf, va ("cmd_warncmd %d\n", cmd_warncmd_val));
Cbuf_AddText (cl_cbuf, va (0, "cmd_warncmd %d\n", cmd_warncmd_val));
}
void

View File

@ -265,7 +265,7 @@ CL_CheckOrDownloadFile (const char *filename)
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
MSG_WriteString (&cls.netchan.message,
va ("download \"%s\"", cls.downloadname->str));
va (0, "download \"%s\"", cls.downloadname->str));
cls.downloadnumber++;
@ -373,12 +373,13 @@ Model_NextDownload (void)
aliashdr_t *ahdr = cl.model_precache[i]->aliashdr;
if (!ahdr)
ahdr = Cache_Get (&cl.model_precache[i]->cache);
Info_SetValueForKey (cls.userinfo, info_key, va ("%d", ahdr->crc),
Info_SetValueForKey (cls.userinfo, info_key, va (0, "%d",
ahdr->crc),
0);
if (!cls.demoplayback) {
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
SZ_Print (&cls.netchan.message, va ("setinfo %s %d", info_key,
ahdr->crc));
SZ_Print (&cls.netchan.message, va (0, "setinfo %s %d",
info_key, ahdr->crc));
}
if (!cl.model_precache[i]->aliashdr)
Cache_Release (&cl.model_precache[i]->cache);
@ -402,7 +403,7 @@ Model_NextDownload (void)
if (!cls.demoplayback) {
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
MSG_WriteString (&cls.netchan.message,
va (prespawn_name, cl.servercount,
va (0, prespawn_name, cl.servercount,
cl.worldmodel->checksum2));
}
}
@ -423,7 +424,7 @@ Sound_NextDownload (void)
for (; cl.sound_name[cls.downloadnumber][0];
cls.downloadnumber++) {
s = cl.sound_name[cls.downloadnumber];
if (!CL_CheckOrDownloadFile (va ("sound/%s", s)))
if (!CL_CheckOrDownloadFile (va (0, "sound/%s", s)))
return; // started a download
}
@ -443,7 +444,7 @@ Sound_NextDownload (void)
if (!cls.demoplayback) {
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
MSG_WriteString (&cls.netchan.message,
va (modellist_name, cl.servercount, 0));
va (0, modellist_name, cl.servercount, 0));
}
}
@ -472,7 +473,7 @@ void
CL_FinishDownload (void)
{
Qclose (cls.download);
VID_SetCaption (va ("Connecting to %s", cls.servername->str));
VID_SetCaption (va (0, "Connecting to %s", cls.servername->str));
// rename the temp file to it's final name
if (strcmp (cls.downloadtempname->str, cls.downloadname->str)) {
@ -662,8 +663,8 @@ CL_ParseDownload (void)
if (percent != 100) {
// request next block
if (percent != cls.downloadpercent)
VID_SetCaption (va ("Downloading %s %d%%", cls.downloadname->str,
percent));
VID_SetCaption (va (0, "Downloading %s %d%%",
cls.downloadname->str, percent));
cls.downloadpercent = percent;
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
@ -842,7 +843,7 @@ CL_ParseServerData (void)
if (!cls.demoplayback) {
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
MSG_WriteString (&cls.netchan.message,
va (soundlist_name, cl.servercount, 0));
va (0, soundlist_name, cl.servercount, 0));
}
// now waiting for downloads, etc
@ -878,7 +879,7 @@ CL_ParseSoundlist (void)
if (n && !cls.demoplayback) {
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
MSG_WriteString (&cls.netchan.message,
va (soundlist_name, cl.servercount, n));
va (0, soundlist_name, cl.servercount, n));
return;
}
@ -929,7 +930,7 @@ CL_ParseModellist (void)
if (!cls.demoplayback) {
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
MSG_WriteString (&cls.netchan.message,
va (modellist_name, cl.servercount, n));
va (0, modellist_name, cl.servercount, n));
}
return;
}
@ -1095,7 +1096,8 @@ CL_ProcessUserInfo (int slot, player_info_t *player)
while (!(player->name = Info_Key (player->userinfo, "name"))) {
if (player->userid)
Info_SetValueForKey (player->userinfo, "name",
va ("user-%i [exploit]", player->userid), 1);
va (0, "user-%i [exploit]",
player->userid), 1);
else
Info_SetValueForKey (player->userinfo, "name", "", 1);
}
@ -1248,7 +1250,8 @@ CL_SetStat (int stat, int value)
break;
case STAT_HEALTH:
if (cl_player_health_e->func)
GIB_Event_Callback (cl_player_health_e, 1, va ("%i", value));
GIB_Event_Callback (cl_player_health_e, 1,
va (0, "%i", value));
if (value <= 0)
Team_Dead ();
break;
@ -1331,7 +1334,7 @@ CL_ParseServerMessage (void)
break; // end of message
}
SHOWNET (va ("%s(%d)", svc_strings[cmd], cmd));
SHOWNET (va (0, "%s(%d)", svc_strings[cmd], cmd));
// other commands
switch (cmd) {

View File

@ -78,7 +78,8 @@ Skin_NextDownload (void)
//XXX Skin_Find (sc);
if (noskins->int_val) //XXX FIXME
continue;
//XXX if (!CL_CheckOrDownloadFile (va ("skins/%s.pcx", sc->skin->name)))
//XXX if (!CL_CheckOrDownloadFile (va (0, "skins/%s.pcx",
// sc->skin->name)))
//XXX return; // started a download
}
@ -99,7 +100,7 @@ Skin_NextDownload (void)
// get next signon phase
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
MSG_WriteString (&cls.netchan.message,
va ("begin %i", cl.servercount));
va (0, "begin %i", cl.servercount));
Cache_Report (); // print remaining memory
}
CL_SetState (ca_active);

View File

@ -575,7 +575,7 @@ MSL_ParseServerList (const char *msl_data)
unsigned int msl_ptr;
for (msl_ptr = 0; msl_ptr < strlen (msl_data); msl_ptr = msl_ptr + 6) {
slist = SL_Add (slist, va ("%i.%i.%i.%i:%i",
slist = SL_Add (slist, va (0, "%i.%i.%i.%i:%i",
(byte) msl_data[msl_ptr],
(byte) msl_data[msl_ptr+1],
(byte) msl_data[msl_ptr+2],

View File

@ -150,7 +150,7 @@ CF_BuildQuota (void)
cf_cursize = 0;
while ((i = readdir (dir))) {
cf_cursize += CF_GetFileSize (va ("%s/%s", path->str, i->d_name));
cf_cursize += CF_GetFileSize (va (0, "%s/%s", path->str, i->d_name));
}
closedir (dir);
}

View File

@ -136,7 +136,7 @@ locs_load (const char *filename)
vec3_t loc;
QFile *file;
tmp = va ("maps/%s", filename);
tmp = va (0, "maps/%s", filename);
file = QFS_FOpenFile (tmp);
if (!file) {
Sys_Printf ("Couldn't load %s\n", tmp);
@ -196,7 +196,7 @@ locs_save (const char *filename, qboolean gz)
if (gz) {
if (strcmp (QFS_FileExtension (filename), ".gz") != 0)
filename = va ("%s.gz", filename);
filename = va (0, "%s.gz", filename);
locfd = QFS_Open (filename, "z9w+");
} else
locfd = QFS_Open (filename, "w+");

View File

@ -1605,7 +1605,7 @@ draw_net (view_t *view)
int ping = cl.players[cl.playernum].ping;
ping = bound (0, ping, 999);
draw_string (view, 0, 0, va ("%3d ms ", ping));
draw_string (view, 0, 0, va (0, "%3d ms ", ping));
}
if (hud_ping->int_val && hud_pl->int_val)
@ -1615,7 +1615,7 @@ draw_net (view_t *view)
int lost = CL_CalcNet ();
lost = bound (0, lost, 999);
draw_string (view, 56, 0, va ("%3d pl", lost));
draw_string (view, 56, 0, va (0, "%3d pl", lost));
}
}
@ -1950,8 +1950,8 @@ Sbar_Init (void)
Key_KeydestCallback (sbar_keydest_callback);
for (i = 0; i < 10; i++) {
sb_nums[0][i] = r_funcs->Draw_PicFromWad (va ("num_%i", i));
sb_nums[1][i] = r_funcs->Draw_PicFromWad (va ("anum_%i", i));
sb_nums[0][i] = r_funcs->Draw_PicFromWad (va (0, "num_%i", i));
sb_nums[1][i] = r_funcs->Draw_PicFromWad (va (0, "anum_%i", i));
}
sb_nums[0][10] = r_funcs->Draw_PicFromWad ("num_minus");
@ -1977,19 +1977,26 @@ Sbar_Init (void)
sb_weapons[1][6] = r_funcs->Draw_PicFromWad ("inv2_lightng");
for (i = 0; i < 5; i++) {
sb_weapons[2 + i][0] = r_funcs->Draw_PicFromWad (va ("inva%i_shotgun",
sb_weapons[2 + i][0] = r_funcs->Draw_PicFromWad (va (0,
"inva%i_shotgun",
i + 1));
sb_weapons[2 + i][1] = r_funcs->Draw_PicFromWad (va ("inva%i_sshotgun",
sb_weapons[2 + i][1] = r_funcs->Draw_PicFromWad (va (0,
"inva%i_sshotgun",
i + 1));
sb_weapons[2 + i][2] = r_funcs->Draw_PicFromWad (va ("inva%i_nailgun",
sb_weapons[2 + i][2] = r_funcs->Draw_PicFromWad (va (0,
"inva%i_nailgun",
i + 1));
sb_weapons[2 + i][3] = r_funcs->Draw_PicFromWad (va ("inva%i_snailgun",
sb_weapons[2 + i][3] = r_funcs->Draw_PicFromWad (va (0,
"inva%i_snailgun",
i + 1));
sb_weapons[2 + i][4] = r_funcs->Draw_PicFromWad (va ("inva%i_rlaunch",
sb_weapons[2 + i][4] = r_funcs->Draw_PicFromWad (va (0,
"inva%i_rlaunch",
i + 1));
sb_weapons[2 + i][5] = r_funcs->Draw_PicFromWad (va ("inva%i_srlaunch",
sb_weapons[2 + i][5] = r_funcs->Draw_PicFromWad (va (0,
"inva%i_srlaunch",
i + 1));
sb_weapons[2 + i][6] = r_funcs->Draw_PicFromWad (va ("inva%i_lightng",
sb_weapons[2 + i][6] = r_funcs->Draw_PicFromWad (va (0,
"inva%i_lightng",
i + 1));
}

View File

@ -250,7 +250,7 @@ SV_Fraglogfile_f (void)
}
name = dstring_new ();
if (!QFS_NextFilename (name,
va ("%s/frag_", qfs_gamedir->dir.def), ".log")) {
va (0, "%s/frag_", qfs_gamedir->dir.def), ".log")) {
SV_Printf ("Can't open any logfiles.\n");
sv_fraglogfile = NULL;
} else {
@ -396,29 +396,29 @@ nice_time (float time)
#if 0 //FIXME ditch or cvar?
if (t < 60) {
return va ("%ds", t);
return va (0, "%ds", t);
} else if (t < 600) {
return va ("%dm%02ds", t / 60, t % 60);
return va (0, "%dm%02ds", t / 60, t % 60);
} else if (t < 3600) {
return va ("%dm", t / 60);
return va (0, "%dm", t / 60);
} else if (t < 36000) {
t /= 60;
return va ("%dh%02dm", t / 60, t % 60);
return va (0, "%dh%02dm", t / 60, t % 60);
} else if (t < 86400) {
return va ("%dh", t / 3600);
return va (0, "%dh", t / 3600);
} else {
t /= 3600;
return va ("%dd%02dh", t / 24, t % 24);
return va (0, "%dd%02dh", t / 24, t % 24);
}
#endif
if (t < 60) {
return va ("%ds", t);
return va (0, "%ds", t);
} else if (t < 3600) {
return va ("%dm%02ds", t / 60, t % 60);
return va (0, "%dm%02ds", t / 60, t % 60);
} else if (t < 86400) {
return va ("%dh%02dm%02ds", t / 3600, (t / 60) % 60, t % 60);
return va (0, "%dh%02dm%02ds", t / 3600, (t / 60) % 60, t % 60);
} else {
return va ("%dd%02dh%02dm%02ds",
return va (0, "%dd%02dh%02dm%02ds",
t / 86400, (t / 3600) % 24, (t / 60) % 60, t % 60);
}
}
@ -742,15 +742,15 @@ SV_Ban_f (void)
if (argc > argr) {
reason = Cmd_Args (argr);
SV_BroadcastPrintf (PRINT_HIGH, "Admin Banned user %s %s: %s\n",
cl->name, mins ? va ("for %.1f minutes", mins)
cl->name, mins ? va (0, "for %.1f minutes", mins)
: "permanently", reason);
} else {
SV_BroadcastPrintf (PRINT_HIGH, "Admin Banned user %s %s\n",
cl->name, mins ? va ("for %.1f minutes", mins)
cl->name, mins ? va (0, "for %.1f minutes", mins)
: "permanently");
}
SV_DropClient (cl);
Cmd_ExecuteString (va ("addip %s %f",
Cmd_ExecuteString (va (0, "addip %s %f",
NET_BaseAdrToString (cl->netchan.remote_address),
mins), src_command);
}
@ -812,7 +812,7 @@ SV_ConSay (const char *prefix, client_t *client)
dbuf = SVR_WriteBegin (dem_all, 0, strlen (text->str) + 7);
MSG_WriteByte (dbuf, svc_print);
MSG_WriteByte (dbuf, PRINT_HIGH);
MSG_WriteString (dbuf, va ("%s\n", text->str));
MSG_WriteString (dbuf, va (0, "%s\n", text->str));
MSG_WriteByte (dbuf, svc_print);
MSG_WriteByte (dbuf, PRINT_CHAT);
MSG_WriteString (dbuf, "");
@ -1136,7 +1136,7 @@ SV_Snap (int uid)
cl->uploadfn = dstring_new ();
if (!QFS_NextFilename (cl->uploadfn,
va ("%s/snap/%d-", qfs_gamedir->dir.def, uid),
va (0, "%s/snap/%d-", qfs_gamedir->dir.def, uid),
".pcx")) {
SV_Printf ("Snap: Couldn't create a file, clean some out.\n");
dstring_delete (cl->uploadfn);

View File

@ -191,7 +191,7 @@ SV_Stop (int reason)
sv_redirected = RD_NONE; // onrecord script is called always
// from the console
Cmd_TokenizeString (va ("script %s \"%s\" \"%s\" \"%s\" %s",
Cmd_TokenizeString (va (0, "script %s \"%s\" \"%s\" \"%s\" %s",
sv_onrecordfinish->string, demo.path->str,
serverdemo->string,
path, p != NULL ? p + 1 : ""));
@ -454,7 +454,7 @@ SV_Record (char *name)
// send server info string
MSG_WriteByte (&buf, svc_stufftext);
MSG_WriteString (&buf, va ("fullserverinfo \"%s\"\n",
MSG_WriteString (&buf, va (0, "fullserverinfo \"%s\"\n",
Info_MakeString (svs.info, 0)));
// flush packet
@ -524,7 +524,7 @@ SV_Record (char *name)
}
MSG_WriteByte (&buf, svc_stufftext);
MSG_WriteString (&buf, va ("cmd spawn %i 0\n", svs.spawncount));
MSG_WriteString (&buf, va (0, "cmd spawn %i 0\n", svs.spawncount));
if (buf.cursize) {
SV_WriteRecordDemoMessage (&buf);
@ -576,7 +576,7 @@ SV_Record (char *name)
// get the client to check and download skins
// when that is completed, a begin command will be issued
MSG_WriteByte (&buf, svc_stufftext);
MSG_WriteString (&buf, va ("skins\n"));
MSG_WriteString (&buf, va (0, "skins\n"));
SV_WriteRecordDemoMessage (&buf);
@ -797,7 +797,7 @@ Demo_Init (void)
sv_demoPings = Cvar_Get ("sv_demoPings", "3", CVAR_NONE, 0, "FIXME");
sv_demoNoVis = Cvar_Get ("sv_demoNoVis", "1", CVAR_NONE, 0, "FIXME");
sv_demoUseCache = Cvar_Get ("sv_demoUseCache", "0", CVAR_NONE, 0, "FIXME");
sv_demoCacheSize = Cvar_Get ("sv_demoCacheSize", va ("%d", size / 1024),
sv_demoCacheSize = Cvar_Get ("sv_demoCacheSize", va (0, "%d", size / 1024),
CVAR_ROM, 0, "FIXME");
sv_demoMaxSize = Cvar_Get ("sv_demoMaxSize", "20480", CVAR_NONE, 0,
"FIXME");

View File

@ -374,7 +374,7 @@ SV_SpawnServer (const char *server)
SV_LoadProgs ();
SV_FreeAllEdictLeafs ();
SV_SetupUserCommands ();
Info_SetValueForStarKey (svs.info, "*progs", va ("%i", sv_pr_state.crc),
Info_SetValueForStarKey (svs.info, "*progs", va (0, "%i", sv_pr_state.crc),
!sv_highchars->int_val);
// leave slots at start for only clients
@ -437,7 +437,7 @@ SV_SpawnServer (const char *server)
// load and spawn all other entities
*sv_globals.time = sv.time;
ent_file = QFS_VOpenFile (va ("maps/%s.ent", server), 0,
ent_file = QFS_VOpenFile (va (0, "maps/%s.ent", server), 0,
sv.worldmodel->vpath);
if ((buf = QFS_LoadFile (ent_file, 0))) {
ED_LoadFromFile (&sv_pr_state, (char *) buf);

View File

@ -368,7 +368,7 @@ SV_DropClient (client_t *drop)
// Trigger GIB event
if (sv_client_disconnect_e->func)
GIB_Event_Callback (sv_client_disconnect_e, 1,
va ("%u", drop->userid));
va (0, "%u", drop->userid));
}
int
@ -1459,7 +1459,7 @@ SV_AddIP_f (void)
bantime / 60);
else
strncpy (timestr, "permanently", sizeof (timestr));
text = va ("You are %s %s\n%s",
text = va (0, "You are %s %s\n%s",
typestr, timestr, type == ft_ban ? "" :
"\nReconnecting won't help...");
MSG_ReliableWrite_Begin (&cl->backbuf, svc_centerprint,
@ -1884,7 +1884,7 @@ SV_CheckVars (void)
Info_SetValueForKey (svs.info, "needpass", "",
!sv_highchars->int_val);
else
Info_SetValueForKey (svs.info, "needpass", va ("%i", v),
Info_SetValueForKey (svs.info, "needpass", va (0, "%i", v),
!sv_highchars->int_val);
}

View File

@ -1411,7 +1411,7 @@ PF_changelevel (progs_t *pr)
last_spawncount = svs.spawncount;
s = P_GSTRING (pr, 0);
Cbuf_AddText (sv_cbuf, va ("map %s\n", s));
Cbuf_AddText (sv_cbuf, va (0, "map %s\n", s));
}
/*
@ -1460,13 +1460,13 @@ PF_logfrag (progs_t *pr)
snprintf(buf, sizeof(buf), "%d", u2);
GIB_Event_Callback (sv_frag_e, 4, type1, va ("%d", u1), type2, buf);
GIB_Event_Callback (sv_frag_e, 4, type1, va (0, "%d", u1), type2, buf);
}
if (e1 < 1 || e1 > MAX_CLIENTS || e2 < 1 || e2 > MAX_CLIENTS)
return;
s = va ("\\%s\\%s\\\n", svs.clients[e1 - 1].name,
s = va (0, "\\%s\\%s\\\n", svs.clients[e1 - 1].name,
svs.clients[e2 - 1].name);
SZ_Print (&svs.log[svs.logsequence & 1], s);
@ -1511,7 +1511,7 @@ PF_infokey (progs_t *pr)
else if (!strcmp (key, "ping")) {
int ping = SV_CalcPing (&svs.clients[e1 - 1]);
value = va ("%d", ping);
value = va (0, "%d", ping);
} else
value = Info_ValueForKey (svs.clients[e1 - 1].userinfo, key);
} else
@ -1862,7 +1862,7 @@ PF_SV_FreeClient (progs_t *pr)
cl->state = cs_free;
//if (sv_client_disconnect_e->func)
// GIB_Event_Callback (sv_client_disconnect_e, 2, va ("%u", cl->userid),
// GIB_Event_Callback (sv_client_disconnect_e, 2, va (0, "%u", cl->userid),
// "server");
}

View File

@ -451,7 +451,7 @@ PF_log (progs_t *pr)
char *text;
QFile *file;
name = va ("%s/%s.log", qfs_gamedir->dir.def, P_GSTRING (pr, 0));
name = va (0, "%s/%s.log", qfs_gamedir->dir.def, P_GSTRING (pr, 0));
file = QFS_Open (name, "a");
text = PF_VarString (pr, 2);

View File

@ -194,9 +194,9 @@ qtv_prespawn_f (sv_qtv_t *proxy)
buf = 0;
if (buf == sv.num_signon_buffers - 1)
command = va ("cmd spawn %i 0\n", svs.spawncount);
command = va (0, "cmd spawn %i 0\n", svs.spawncount);
else
command = va ("cmd prespawn %i %i\n", svs.spawncount, buf + 1);
command = va (0, "cmd prespawn %i %i\n", svs.spawncount, buf + 1);
size = (3 + sv.signon_buffer_size[buf]) + (1 + strlen (command) + 1);
msg = MSG_ReliableCheckBlock (&proxy->backbuf, size);
@ -534,7 +534,7 @@ SV_qtvChanging (void)
int i, len;
const char *msg;
msg = va ("%cchanging", qtv_stringcmd);
msg = va (0, "%cchanging", qtv_stringcmd);
len = strlen (msg) + 1;
for (i = 0; i < MAX_PROXIES; i++) {
proxy = proxies + i;
@ -555,7 +555,7 @@ SV_qtvReconnect (void)
int i, len;
const char *msg;
msg = va ("%creconnect", qtv_stringcmd);
msg = va (0, "%creconnect", qtv_stringcmd);
len = strlen (msg) + 1;
for (i = 0; i < MAX_PROXIES; i++) {
proxy = proxies + i;

View File

@ -55,7 +55,7 @@ draw_cpu (view_t *view)
cpu = (svs.stats.latched_active + svs.stats.latched_idle);
cpu = 100 * svs.stats.latched_active / cpu;
cpu_str = va ("[CPU: %3d%%]", (int) cpu);
cpu_str = va (0, "[CPU: %3d%%]", (int) cpu);
for (s = cpu_str, d = sb->text + view->xrel; *s; s++)
*d++ = *s;
if (cpu > 70.0) {
@ -74,7 +74,7 @@ draw_rec (view_t *view)
const char *s;
char *d;
str = va ("[REC: %d]", SVR_NumRecorders ());
str = va (0, "[REC: %d]", SVR_NumRecorders ());
for (s = str, d = sb->text + view->xrel; *s; s++)
*d++ = *s;
}

View File

@ -141,7 +141,7 @@ SV_WriteWorldVars (netchan_t *netchan)
// send server info string
MSG_WriteByte (&netchan->message, svc_stufftext);
MSG_WriteString (&netchan->message,
va ("fullserverinfo \"%s\"\n",
va (0, "fullserverinfo \"%s\"\n",
Info_MakeString (svs.info, 0)));
}
@ -194,7 +194,7 @@ SV_New_f (void *unused)
// Trigger GIB connection event
if (sv_client_connect_e->func)
GIB_Event_Callback (sv_client_connect_e, 1,
va ("%u", host_client->userid));
va (0, "%u", host_client->userid));
}
void
@ -351,9 +351,9 @@ SV_PreSpawn_f (void *unused)
host_client->prespawned = true;
if (buf == sv.num_signon_buffers - 1)
command = va ("cmd spawn %i 0\n", svs.spawncount);
command = va (0, "cmd spawn %i 0\n", svs.spawncount);
else
command = va ("cmd prespawn %i %i\n", svs.spawncount, buf + 1);
command = va (0, "cmd prespawn %i %i\n", svs.spawncount, buf + 1);
size = sv.signon_buffer_size[buf] + 1 + strlen (command) + 1;
@ -605,7 +605,7 @@ SV_Begin_f (void *unused)
// Trigger GIB events
if (sv_client_spawn_e->func)
GIB_Event_Callback (sv_client_spawn_e, 1, va ("%u",
GIB_Event_Callback (sv_client_spawn_e, 1, va (0, "%u",
host_client->userid));
}
@ -787,7 +787,7 @@ SV_BeginDownload_f (void *unused)
MSG_ReliableWrite_Short (&host_client->backbuf, DL_HTTP);
MSG_ReliableWrite_Byte (&host_client->backbuf, 0);
MSG_ReliableWrite_String (&host_client->backbuf,
va ("%s/%s", sv_http_url_base->string,
va (0, "%s/%s", sv_http_url_base->string,
ren ? qfs_foundfile.realname : name));
MSG_ReliableWrite_String (&host_client->backbuf,
ren ? qfs_foundfile.realname : "");
@ -914,7 +914,7 @@ SV_Say (qboolean team)
dsprintf (text, fmt, host_client->name);
if (sv_chat_e->func)
GIB_Event_Callback (sv_chat_e, 2, va ("%i", host_client->userid), p,
GIB_Event_Callback (sv_chat_e, 2, va (0, "%i", host_client->userid), p,
type);
dstring_appendstr (text, p);
@ -1201,7 +1201,7 @@ SV_SetUserinfo (client_t *client, const char *key, const char *value)
// trigger a GIB event
if (sv_setinfo_e->func)
GIB_Event_Callback (sv_setinfo_e, 4, va("%d", client->userid),
GIB_Event_Callback (sv_setinfo_e, 4, va (0, "%d", client->userid),
key, oldvalue, value);
if (sv_funcs.UserInfoChanged) {

View File

@ -424,7 +424,7 @@ Locs_Init (void)
static const char *
Team_F_Version (char *args)
{
return va ("say %s", PACKAGE_STRING);
return va (0, "say %s", PACKAGE_STRING);
}
static const char *
@ -446,7 +446,7 @@ Team_F_Skins (char *args)
if (l == 0) {
//XXXtotalfb = Skin_FbPercent (0);
totalfb = 0;
return va ("say Player models have %f%% brightness\n"
return va (0, "say Player models have %f%% brightness\n"
"say Average percent fullbright for all loaded skins is "
"%d.%d%%", allfb * 100, totalfb / 10, totalfb % 10);
}
@ -455,8 +455,8 @@ Team_F_Skins (char *args)
totalfb = 0;
if (totalfb >= 0)
return va ("say \"Skin %s is %d.%d%% fullbright\"", args, totalfb / 10,
totalfb % 10);
return va (0, "say \"Skin %s is %d.%d%% fullbright\"",
args, totalfb / 10, totalfb % 10);
else
return ("say \"Skin not currently loaded.\"");
}

View File

@ -102,7 +102,7 @@ load_file (progs_t *pr, const char *name, off_t *_size)
file = open_file (name, &size);
if (!file) {
file = open_file (va ("%s.gz", name), &size);
file = open_file (va (0, "%s.gz", name), &size);
if (!file) {
return 0;
}

View File

@ -79,7 +79,7 @@ load_file (progs_t *pr, const char *name, off_t *_size)
file = open_file (name, &size);
if (!file) {
file = open_file (va ("%s.gz", name), &size);
file = open_file (va (0, "%s.gz", name), &size);
if (!file) {
return 0;
}

View File

@ -347,7 +347,7 @@ CreateBrushFaces (void)
GetVectorForKey (FoundEntity, "origin", offset);
SetKeyValue (CurrentEntity, "origin",
va ("%g %g %g", VectorExpand (offset)));
va (0, "%g %g %g", VectorExpand (offset)));
}
for (i = 0; i < numbrushfaces; i++) {

View File

@ -620,7 +620,7 @@ WriteEntitiesToString (void)
dstring_appendstr (buf, "{\n");
for (ep = entities[i].epairs; ep; ep = ep->next) {
dstring_appendstr (buf, va ("\"%s\" \"%s\"\n",
dstring_appendstr (buf, va (0, "\"%s\" \"%s\"\n",
ep->key, ep->value));
}
dstring_appendstr (buf, "}\n");

View File

@ -359,13 +359,13 @@ unique_name (wad_t *wad, const char *name)
do {
strncpy (uname, name, MIPTEXNAME);
uname[(MIPTEXNAME - 1)] = 0;
tag = va ("~%x", i++);
tag = va (0, "~%x", i++);
if (strlen (uname) + strlen (tag) <= (MIPTEXNAME - 1))
strcat (uname, tag);
else
strcpy (uname + (MIPTEXNAME - 1) - strlen (tag), tag);
} while (wad_find_lump (wad, uname));
return va ("%s", uname); // just to make a safe returnable that doesn't
return va (0, "%s", uname); // just to make a safe returnable that doesn't
// need to be freed
}

View File

@ -301,7 +301,7 @@ TEX_InitFromWad (const char *path)
wad = wad_open (path);
#ifdef HAVE_ZLIB
if (!wad)
wad = wad_open (path = va ("%s.gz", path));
wad = wad_open (path = va (0, "%s.gz", path));
#endif
if (!wad)
return -1;

View File

@ -258,7 +258,8 @@ emit_static_instances (const char *classname)
}
instances_struct[1].type = array_type (&type_pointer,
data.num_instances + 1);
instances_def = emit_structure (va ("_OBJ_STATIC_INSTANCES_%s", classname),
instances_def = emit_structure (va (0, "_OBJ_STATIC_INSTANCES_%s",
classname),
's', instances_struct, 0, &data,
0, sc_static);
free (data.instances);
@ -538,16 +539,16 @@ get_class_name (class_type_t *class_type, int pretty)
if (pretty)
return class_type->c.class->name;
else
return va ("%s_", class_type->c.class->name);
return va (0, "%s_", class_type->c.class->name);
case ct_category:
if (pretty)
return va ("%s (%s)", class_type->c.category->class->name,
return va (0, "%s (%s)", class_type->c.category->class->name,
class_type->c.category->name);
else
return va ("%s_%s", class_type->c.category->class->name,
return va (0, "%s_%s", class_type->c.category->class->name,
class_type->c.category->name);
case ct_protocol:
return va ("<%s>", class_type->c.protocol->name);
return va (0, "<%s>", class_type->c.protocol->name);
}
return "???";
}
@ -561,13 +562,13 @@ class_symbol (class_type_t *class_type, int external)
switch (class_type->type) {
case ct_category:
name = va ("_OBJ_CATEGORY_%s_%s",
name = va (0, "_OBJ_CATEGORY_%s_%s",
class_type->c.category->class->name,
class_type->c.category->name);
type = &type_category;
break;
case ct_class:
name = va ("_OBJ_CLASS_%s", class_type->c.class->name);
name = va (0, "_OBJ_CLASS_%s", class_type->c.class->name);
type = &type_class;
break;
case ct_protocol:
@ -710,7 +711,8 @@ begin_category (category_t *category)
EMIT_STRING (space, pr_category->class_name, class->name);
EMIT_DEF (space, pr_category->protocols,
emit_protocol_list (category->protocols,
va ("%s_%s", class->name, category->name)));
va (0, "%s_%s", class->name,
category->name)));
}
typedef struct {
@ -786,7 +788,7 @@ emit_ivars (symtab_t *ivars, const char *name)
}
ivar_list_struct[1].type = array_type (&type_ivar, ivar_data.count);
def = emit_structure (va ("_OBJ_INSTANCE_VARIABLES_%s", name), 's',
def = emit_structure (va (0, "_OBJ_INSTANCE_VARIABLES_%s", name), 's',
ivar_list_struct, 0, &ivar_data, 0, sc_static);
dstring_delete (ivar_data.encoding);
@ -803,7 +805,7 @@ begin_class (class_t *class)
def_t *def;
defspace_t *space;
sym = make_symbol (va ("_OBJ_METACLASS_%s", class->name),
sym = make_symbol (va (0, "_OBJ_METACLASS_%s", class->name),
&type_class, pr.far_data, sc_static);
meta_def = sym->s.def;
meta_def->initialized = meta_def->constant = meta_def->nosave = 1;
@ -872,15 +874,15 @@ emit_class_ref (const char *class_name)
def_t *ref_def;
def_t *name_def;
ref_sym = make_symbol (va (".obj_class_ref_%s", class_name), &type_pointer,
pr.far_data, sc_static);
ref_sym = make_symbol (va (0, ".obj_class_ref_%s", class_name),
&type_pointer, pr.far_data, sc_static);
if (!ref_sym->table)
symtab_addsymbol (pr.symtab, ref_sym);
ref_def = ref_sym->s.def;
if (ref_def->initialized)
return;
ref_def->initialized = ref_def->constant = ref_def->nosave = 1;
name_sym = make_symbol (va (".obj_class_name_%s", class_name),
name_sym = make_symbol (va (0, ".obj_class_name_%s", class_name),
&type_pointer, pr.far_data, sc_extern);
if (!name_sym->table)
symtab_addsymbol (pr.symtab, name_sym);
@ -896,7 +898,7 @@ emit_class_name (const char *class_name)
symbol_t *name_sym;
def_t *name_def;
name_sym = make_symbol (va (".obj_class_name_%s", class_name),
name_sym = make_symbol (va (0, ".obj_class_name_%s", class_name),
&type_pointer, pr.far_data, sc_global);
if (!name_sym->table)
symtab_addsymbol (pr.symtab, name_sym);
@ -916,9 +918,9 @@ emit_category_ref (const char *class_name, const char *category_name)
def_t *ref_def;
def_t *name_def;
ref_sym = make_symbol (va (".obj_category_ref_%s_%s",
class_name, category_name),
&type_pointer, pr.far_data, sc_static);
ref_sym = make_symbol (va (0, ".obj_category_ref_%s_%s",
class_name, category_name),
&type_pointer, pr.far_data, sc_static);
if (!ref_sym->table)
symtab_addsymbol (pr.symtab, ref_sym);
ref_def = ref_sym->s.def;
@ -926,9 +928,9 @@ emit_category_ref (const char *class_name, const char *category_name)
return;
ref_def->initialized = ref_def->constant = 1;
ref_def->nosave = 1;
name_sym = make_symbol (va (".obj_category_name_%s_%s",
class_name, category_name),
&type_pointer, pr.far_data, sc_extern);
name_sym = make_symbol (va (0, ".obj_category_name_%s_%s",
class_name, category_name),
&type_pointer, pr.far_data, sc_extern);
if (!name_sym->table)
symtab_addsymbol (pr.symtab, name_sym);
name_def = name_sym->s.def;
@ -943,7 +945,7 @@ emit_category_name (const char *class_name, const char *category_name)
symbol_t *name_sym;
def_t *name_def;
name_sym = make_symbol (va (".obj_category_name_%s_%s",
name_sym = make_symbol (va (0, ".obj_category_name_%s_%s",
class_name, category_name),
&type_pointer, pr.far_data, sc_global);
if (!name_sym->table)
@ -1374,9 +1376,8 @@ class_pointer_symbol (class_t *class)
class_type.c.class = class;
sym = make_symbol (va ("_OBJ_CLASS_POINTER_%s", class->name),
&type_Class,
pr.near_data, sc_static);
sym = make_symbol (va (0, "_OBJ_CLASS_POINTER_%s", class->name),
&type_Class, pr.near_data, sc_static);
if (!sym->table)
symtab_addsymbol (pr.symtab, sym);
def = sym->s.def;
@ -1716,7 +1717,7 @@ emit_protocol (protocol_t *protocol)
pr_protocol_t *proto;
defspace_t *space;
proto_def = make_symbol (va ("_OBJ_PROTOCOL_%s", protocol->name),
proto_def = make_symbol (va (0, "_OBJ_PROTOCOL_%s", protocol->name),
&type_protocol, pr.far_data, sc_static)->s.def;
if (proto_def->initialized)
return proto_def;
@ -1728,7 +1729,7 @@ emit_protocol (protocol_t *protocol)
EMIT_STRING (space, proto->protocol_name, protocol->name);
EMIT_DEF (space, proto->protocol_list,
emit_protocol_list (protocol->protocols,
va ("PROTOCOL_%s", protocol->name)));
va (0, "PROTOCOL_%s", protocol->name)));
EMIT_DEF (space, proto->instance_methods,
emit_method_descriptions (protocol->methods, protocol->name, 1));
EMIT_DEF (space, proto->class_methods,
@ -1786,7 +1787,7 @@ emit_protocol_list (protocollist_t *protocols, const char *name)
if (!protocols)
return 0;
proto_list_struct[2].type = array_type (&type_pointer, protocols->count);
return emit_structure (va ("_OBJ_PROTOCOLS_%s", name), 's',
return emit_structure (va (0, "_OBJ_PROTOCOLS_%s", name), 's',
proto_list_struct, 0, protocols, 0, sc_static);
}

View File

@ -187,7 +187,7 @@ alias_def (def_t *def, type_t *type, int offset)
return alias;
}
ALLOC (16384, def_t, defs, alias);
alias->name = save_string (va ("[%s:%d]", def->name, offset));
alias->name = save_string (va (0, "[%s:%d]", def->name, offset));
alias->return_addr = __builtin_return_address (0);
alias->offset = offset;
alias->offset_reloc = 1;
@ -222,7 +222,7 @@ temp_def (type_t *type)
temp->offset = defspace_alloc_aligned_loc (space, size, alignment);
*space->def_tail = temp;
space->def_tail = &temp->next;
temp->name = save_string (va (".tmp%d", current_func->temp_num++));
temp->name = save_string (va (0, ".tmp%d", current_func->temp_num++));
}
temp->return_addr = __builtin_return_address (0);
temp->type = type;
@ -424,7 +424,7 @@ init_vector_components (symbol_t *vector_sym, int is_field)
symbol_t *sym;
const char *name;
name = va ("%s_%s", vector_sym->name, fields[i]);
name = va (0, "%s_%s", vector_sym->name, fields[i]);
sym = symtab_lookup (current_symtab, name);
if (sym) {
if (sym->table == current_symtab) {

View File

@ -180,13 +180,13 @@ print_bool (dstring_t *dstr, expr_t *e, int level, int id, expr_t *next)
for ( ; i < tl_count; i++)
dasprintf (dstr, "%*s<tr><td port=\"t%d\">t</td>%s</tr>\n",
indent, "", i,
i == count ? va ("<td rowspan=\"%d\"></td>",
i == count ? va (0, "<td rowspan=\"%d\"></td>",
bool->true_list->size - count)
: "");
for ( ; i < fl_count; i++)
dasprintf (dstr, "%*s<tr>%s<td port=\"f%d\">f</td></tr>\n",
indent, "",
i == count ? va ("<td rowspan=\"%d\"></td>",
i == count ? va (0, "<td rowspan=\"%d\"></td>",
bool->false_list->size - count)
: "",
i);
@ -449,22 +449,23 @@ print_value (dstring_t *dstr, expr_t *e, int level, int id, expr_t *next)
switch (e->e.value->lltype) {
case ev_string:
label = va ("\\\"%s\\\"", quote_string (e->e.value->v.string_val));
label = va (0, "\\\"%s\\\"",
quote_string (e->e.value->v.string_val));
break;
case ev_double:
label = va ("f %g", e->e.value->v.double_val);
label = va (0, "f %g", e->e.value->v.double_val);
break;
case ev_float:
label = va ("f %g", e->e.value->v.float_val);
label = va (0, "f %g", e->e.value->v.float_val);
break;
case ev_vector:
label = va ("'%g %g %g'",
label = va (0, "'%g %g %g'",
e->e.value->v.vector_val[0],
e->e.value->v.vector_val[1],
e->e.value->v.vector_val[2]);
break;
case ev_quat:
label = va ("'%g %g %g %g'",
label = va (0, "'%g %g %g %g'",
e->e.value->v.quaternion_val[0],
e->e.value->v.quaternion_val[1],
e->e.value->v.quaternion_val[2],
@ -477,32 +478,32 @@ print_value (dstring_t *dstr, expr_t *e, int level, int id, expr_t *next)
print_type_str (type_str, type);
}
if (e->e.value->v.pointer.def)
label = va ("(*%s)[%d]<%s>",
label = va (0, "(*%s)[%d]<%s>",
type ? type_str->str : "???",
e->e.value->v.pointer.val,
e->e.value->v.pointer.def->name);
else
label = va ("(*%s)[%d]",
label = va (0, "(*%s)[%d]",
type ? type_str->str : "???",
e->e.value->v.pointer.val);
break;
case ev_field:
label = va ("field %d", e->e.value->v.pointer.val);
label = va (0, "field %d", e->e.value->v.pointer.val);
break;
case ev_entity:
label = va ("ent %d", e->e.value->v.integer_val);
label = va (0, "ent %d", e->e.value->v.integer_val);
break;
case ev_func:
label = va ("func %d", e->e.value->v.integer_val);
label = va (0, "func %d", e->e.value->v.integer_val);
break;
case ev_integer:
label = va ("i %d", e->e.value->v.integer_val);
label = va (0, "i %d", e->e.value->v.integer_val);
break;
case ev_uinteger:
label = va ("u %u", e->e.value->v.uinteger_val);
label = va (0, "u %u", e->e.value->v.uinteger_val);
break;
case ev_short:
label = va ("s %d", e->e.value->v.short_val);
label = va (0, "s %d", e->e.value->v.short_val);
break;
case ev_void:
label = "<void>";

View File

@ -114,7 +114,7 @@ print_flow_node_dag (dstring_t *dstr, flowgraph_t *graph, flownode_t *node,
int level)
{
if (node->dag)
print_dag (dstr, node->dag, va ("%d (%d)", node->id, node->dfn));
print_dag (dstr, node->dag, va (0, "%d (%d)", node->id, node->dfn));
else
print_flow_node (dstr, graph, node, level);
}

View File

@ -175,7 +175,7 @@ print_struct (dstring_t *dstr, type_t *t, int level, int id)
continue;
}
val = sym->s.offset;
port = va (" port=\"f%d\"", pnum++);
port = va (0, " port=\"f%d\"", pnum++);
}
dasprintf (dstr, "%*s<tr><td>%s</td><td%s>%d</td></tr>\n",
indent + 4, "",

View File

@ -93,20 +93,20 @@ dump_def (progs_t *pr, pr_def_t *def, int indent)
if (string < 0
|| (pr_uint_t) string >= pr->progs->numstrings) {
str = "invalid string offset";
comment = va (" %d %s", string, str);
comment = va (0, " %d %s", string, str);
} else {
str = quote_string (pr->pr_strings + G_INT (pr, offset));
comment = va (" %d \"%s\"", string, str);
comment = va (0, " %d \"%s\"", string, str);
}
break;
case ev_float:
comment = va (" %g", G_FLOAT (pr, offset));
comment = va (0, " %g", G_FLOAT (pr, offset));
break;
case ev_double:
comment = va (" %.17g", G_DOUBLE (pr, offset));
comment = va (0, " %.17g", G_DOUBLE (pr, offset));
break;
case ev_vector:
comment = va (" '%g %g %g'",
comment = va (0, " '%g %g %g'",
G_VECTOR (pr, offset)[0],
G_VECTOR (pr, offset)[1],
G_VECTOR (pr, offset)[2]);
@ -114,7 +114,7 @@ dump_def (progs_t *pr, pr_def_t *def, int indent)
case ev_entity:
break;
case ev_field:
comment = va (" %x", G_INT (pr, offset));
comment = va (0, " %x", G_INT (pr, offset));
break;
case ev_func:
{
@ -123,26 +123,26 @@ dump_def (progs_t *pr, pr_def_t *def, int indent)
if (func < pr->progs->numfunctions) {
start = pr->pr_functions[func].first_statement;
if (start > 0)
comment = va (" %d @ %x", func, start);
comment = va (0, " %d @ %x", func, start);
else
comment = va (" %d = #%d", func, -start);
comment = va (0, " %d = #%d", func, -start);
} else {
comment = va (" %d = illegal function", func);
comment = va (0, " %d = illegal function", func);
}
}
break;
case ev_pointer:
comment = va (" %x", G_INT (pr, offset));
comment = va (0, " %x", G_INT (pr, offset));
break;
case ev_quat:
comment = va (" '%g %g %g %g'",
comment = va (0, " '%g %g %g %g'",
G_QUAT (pr, offset)[0],
G_QUAT (pr, offset)[1],
G_QUAT (pr, offset)[2],
G_QUAT (pr, offset)[3]);
break;
case ev_integer:
comment = va (" %d", G_INT (pr, offset));
comment = va (0, " %d", G_INT (pr, offset));
break;
case ev_short:
break;
@ -255,9 +255,9 @@ dump_functions (progs_t *pr)
start = func->first_statement;
if (start > 0)
comment = va (" @ %x", start);
comment = va (0, " @ %x", start);
else
comment = va (" = #%d", -start);
comment = va (0, " = #%d", -start);
printf ("%-5d %s%s: %d (", i, name, comment, func->numparms);
if (func->numparms < 0)
@ -537,7 +537,7 @@ dump_qfo_types (qfo_t *qfo, int base_address)
continue;
}
if (type->meta < 0 || type->meta >= NUM_META)
meta = va ("invalid meta: %d", type->meta);
meta = va (0, "invalid meta: %d", type->meta);
else
meta = ty_meta_names[type->meta];
printf ("%-5x %-9s %-20s", type_ptr + base_address, meta,

View File

@ -479,7 +479,7 @@ new_label_name (void)
const char *fname = current_func->sym->name;
const char *lname;
lname = save_string (va ("$%s_%d", fname, lnum));
lname = save_string (va (0, "$%s_%d", fname, lnum));
return lname;
}
@ -543,7 +543,8 @@ named_label_expr (symbol_t *label)
return sym->s.expr;
}
l = new_label_expr ();
l->e.label.name = save_string (va ("%s_%s", l->e.label.name, label->name));
l->e.label.name = save_string (va (0, "%s_%s", l->e.label.name,
label->name));
l->e.label.symbol = label;
label->sy_type = sy_expr;
label->s.expr = l;
@ -1268,7 +1269,7 @@ new_ret_expr (type_t *type)
expr_t *
new_param_expr (type_t *type, int num)
{
return param_expr (va (".param_%d", num), type);
return param_expr (va (0, ".param_%d", num), type);
}
expr_t *

View File

@ -1607,7 +1607,7 @@ flow_build_graph (function_t *func)
flow_make_edges (graph);
flow_build_dfst (graph);
if (options.block_dot.flow)
dump_dot (va ("flow-%d", pass), graph, dump_dot_flow);
dump_dot (va (0, "flow-%d", pass), graph, dump_dot_flow);
pass++;
} while (flow_remove_unreachable_nodes (graph));
flow_find_predecessors (graph);

View File

@ -249,7 +249,7 @@ get_function (const char *name, const type_t *type, int overload, int create)
name = save_string (name);
full_name = save_string (va ("%s|%s", name, encode_params (type)));
full_name = save_string (va (0, "%s|%s", name, encode_params (type)));
func = Hash_Find (overloaded_functions, full_name);
if (func) {
@ -382,7 +382,7 @@ find_function (expr_t *fexpr, expr_t *params)
dummy.type = find_type (&type);
qsort (funcs, func_count, sizeof (void *), func_compare);
dummy.full_name = save_string (va ("%s|%s", fexpr->e.symbol->name,
dummy.full_name = save_string (va (0, "%s|%s", fexpr->e.symbol->name,
encode_params (&type)));
dummy_p = bsearch (&dummy_p, funcs, func_count, sizeof (void *),
func_compare);
@ -526,7 +526,7 @@ build_scope (symbol_t *fsym, symtab_t *parent)
if (args) {
while (i < MAX_PARMS) {
param = new_symbol_type (va (".par%d", i), &type_param);
param = new_symbol_type (va (0, ".par%d", i), &type_param);
initialize_def (param, 0, symtab->space, sc_param);
i++;
}

View File

@ -1106,7 +1106,7 @@ linker_add_lib (const char *libname)
if (strncmp (libname, "-l", 2) == 0) {
while (path) {
path_name = va ("%s/lib%s.a", path->path, libname + 2);
path_name = va (0, "%s/lib%s.a", path->path, libname + 2);
pack = pack_open (path_name);
if (pack)
break;

View File

@ -609,7 +609,7 @@ emit_methods (methodlist_t *methods, const char *name, int instance)
methods->instance = instance;
methods_struct[2].type = array_type (&type_method, count);
return emit_structure (va ("_OBJ_%s_METHODS_%s", type, name), 's',
return emit_structure (va (0, "_OBJ_%s_METHODS_%s", type, name), 's',
methods_struct, 0, methods, 0, sc_static);
}
@ -677,7 +677,7 @@ emit_method_descriptions (methodlist_t *methods, const char *name,
methods->instance = instance;
method_list_struct[1].type = array_type (&type_method_description, count);
return emit_structure (va ("_OBJ_%s_METHODS_%s", type, name), 's',
return emit_structure (va (0, "_OBJ_%s_METHODS_%s", type, name), 's',
method_list_struct, 0, methods, 0, sc_static);
}

View File

@ -455,7 +455,7 @@ qfo_write (qfo_t *qfo, const char *filename)
file = Qopen (filename, options.gzip ? "wbz9" : "wb");
if (!file) {
perror (va ("failed to open %s for writing", filename));
perror (va (0, "failed to open %s for writing", filename));
return -1;
}
@ -1168,7 +1168,7 @@ qfo_to_progs (qfo_t *qfo, int *size)
if (options.verbosity >= 0) {
const char *big_function = "";
if (big_func)
big_function = va (" (%s)", strings + qfo->funcs[big_func].name);
big_function = va (0, " (%s)", strings + qfo->funcs[big_func].name);
printf ("%6i strofs\n", progs->numstrings);
printf ("%6i statements\n", progs->numstatements);
printf ("%6i functions\n", progs->numfunctions);

View File

@ -341,7 +341,7 @@ DecodeArgs (int argc, char **argv)
}
break;
case 'l': // lib file
add_file (va ("-l%s", NORMALIZE (optarg)));
add_file (va (0, "-l%s", NORMALIZE (optarg)));
break;
case 'L':
linker_add_path (NORMALIZE (optarg));

Some files were not shown because too many files have changed in this diff Show More