Misc minor fixups.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5973 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
9d8b442cf3
commit
0e6a0b789e
14 changed files with 90 additions and 30 deletions
|
@ -1246,7 +1246,7 @@ static const char *PM_ParsePackage(struct packagesourceinfo_s *source, const cha
|
|||
if (relurl)
|
||||
{
|
||||
for (m = 0; m < source->nummirrors; m++)
|
||||
p->mirror[m] = Z_StrDup(va("%s%s%s", source->mirror[m], relurl, ext));
|
||||
p->mirror[m] = Z_StrDupf("%s%s%s", source->mirror[m], relurl, ext);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3922,7 +3922,7 @@ static qboolean PM_DeclinedPackages(char *out, size_t outsize)
|
|||
if (declinedpackages)
|
||||
{
|
||||
char *t = declinedpackages;
|
||||
declinedpackages = Z_StrDup(va("%s;%s", declinedpackages, tok));
|
||||
declinedpackages = Z_StrDupf("%s;%s", declinedpackages, tok);
|
||||
Z_Free(t);
|
||||
}
|
||||
else
|
||||
|
@ -4587,12 +4587,12 @@ void PM_AddManifestPackages(ftemanifest_t *man)
|
|||
p = Z_Malloc(sizeof(*p));
|
||||
p->name = Z_StrDup(pack->path);
|
||||
p->title = Z_StrDup(pack->path);
|
||||
p->category = Z_StrDup(va("%s/", man->formalname));
|
||||
p->category = Z_StrDupf("%s/", man->formalname);
|
||||
p->priority = PM_DEFAULTPRIORITY;
|
||||
p->fsroot = FS_ROOT;
|
||||
strcpy(p->version, "");
|
||||
p->flags = DPF_FORGETONUNINSTALL|DPF_MANIFEST|DPF_GUESSED;
|
||||
p->qhash = pack->crcknown?Z_StrDup(va("%#x", pack->crc)):NULL;
|
||||
p->qhash = pack->crcknown?Z_StrDupf("%#x", pack->crc):NULL;
|
||||
|
||||
{
|
||||
char *c = p->name;
|
||||
|
@ -4940,7 +4940,7 @@ static void MD_Draw (int x, int y, struct menucustom_s *c, struct emenu_s *m)
|
|||
// if (&m->selecteditem->common == &c->common)
|
||||
// Draw_AltFunString (x+48, y, n);
|
||||
// else
|
||||
Draw_FunString(x+48, y, n);
|
||||
Draw_FunStringU8(CON_WHITEMASK, x+48, y, n);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5110,7 +5110,7 @@ static void MD_Source_Draw (int x, int y, struct menucustom_s *c, struct emenu_s
|
|||
|
||||
text = va("%s%s", (pm_source[c->dint].flags & (SRCFL_ENABLED|SRCFL_DISABLED))?"":"^b",
|
||||
pm_source[c->dint].url);
|
||||
Draw_FunString (x+48, y, text);
|
||||
Draw_FunStringU8 (CON_WHITEMASK, x+48, y, text);
|
||||
}
|
||||
static qboolean MD_Source_Key (struct menucustom_s *c, struct emenu_s *m, int key, unsigned int unicode)
|
||||
{
|
||||
|
@ -5294,9 +5294,9 @@ static int MD_AddItemsToDownloadMenu(emenu_t *m, int y, const char *pathprefix)
|
|||
#endif
|
||||
|
||||
if (head && desc)
|
||||
desc = va("%s\n%s", head, desc);
|
||||
desc = va(U8("%s\n%s"), head, desc);
|
||||
else if (head)
|
||||
desc = head;
|
||||
desc = va(U8("%s"), head);
|
||||
|
||||
c = MC_AddCustom(m, 0, y, p, downloadablessequence, desc);
|
||||
c->draw = MD_Draw;
|
||||
|
|
|
@ -3911,9 +3911,9 @@ static void M_ModelViewerDraw(int x, int y, struct menucustom_s *c, struct emenu
|
|||
break;
|
||||
}
|
||||
if (*mods->shaderfile)
|
||||
mods->shadertext = Z_StrDup(va("\n\nPress space to view+edit the shader\n\n%s", body));
|
||||
mods->shadertext = Z_StrDupf("\n\nPress space to view+edit the shader\n\n%s", body);
|
||||
else
|
||||
mods->shadertext = Z_StrDup(va("{%s",body));
|
||||
mods->shadertext = Z_StrDupf("{%s",body);
|
||||
}
|
||||
R_DrawTextField(r_refdef.grect.x, r_refdef.grect.y+16, r_refdef.grect.width, r_refdef.grect.height-16, mods->shadertext, CON_WHITEMASK, CPRINT_TALIGN|CPRINT_LALIGN, font_default, fs);
|
||||
|
||||
|
|
|
@ -210,6 +210,7 @@ struct galiasbone_s *Mod_GetBoneInfo(struct model_s *model, int *numbones);
|
|||
const char *Mod_GetBoneName(struct model_s *model, int bonenum);
|
||||
|
||||
void Draw_FunString(float x, float y, const void *str);
|
||||
void Draw_FunStringU8(unsigned int flags, float x, float y, const void *str);
|
||||
void Draw_AltFunString(float x, float y, const void *str);
|
||||
void Draw_FunStringWidthFont(struct font_s *font, float x, float y, const void *str, int width, int rightalign, qboolean highlight);
|
||||
#define Draw_FunStringWidth(x,y,str,width,rightalign,highlight) Draw_FunStringWidthFont(font_default,x,y,str,width,rightalign,highlight)
|
||||
|
|
|
@ -199,6 +199,13 @@ void Draw_FunString(float x, float y, const void *str)
|
|||
|
||||
Draw_ExpandedString(font_default, x, y, buffer);
|
||||
}
|
||||
void Draw_FunStringU8(unsigned int flags, float x, float y, const void *str)
|
||||
{
|
||||
conchar_t buffer[2048];
|
||||
COM_ParseFunString(flags, str, buffer, sizeof(buffer), PFS_FORCEUTF8);
|
||||
|
||||
Draw_ExpandedString(font_default, x, y, buffer);
|
||||
}
|
||||
//Draws a marked up string using the alt char set (legacy mode would be |128)
|
||||
void Draw_AltFunString(float x, float y, const void *str)
|
||||
{
|
||||
|
|
|
@ -4282,7 +4282,7 @@ char *COM_ParseStringSet (const char *data, char *out, size_t outsize)
|
|||
}
|
||||
|
||||
|
||||
char *COM_ParseType (const char *data, char *out, int outlen, com_tokentype_t *toktype)
|
||||
char *COM_ParseType (const char *data, char *out, size_t outlen, com_tokentype_t *toktype)
|
||||
{
|
||||
int c;
|
||||
int len;
|
||||
|
|
|
@ -428,7 +428,7 @@ extern com_tokentype_t com_tokentype;
|
|||
//char *COM_Parse (const char *data);
|
||||
#define COM_Parse(d) COM_ParseOut(d,com_token, sizeof(com_token))
|
||||
#define COM_ParseOut(d,o,l) COM_ParseType(d,o,l,NULL)
|
||||
char *COM_ParseType (const char *data, char *out, int outlen, com_tokentype_t *toktype);
|
||||
char *COM_ParseType (const char *data, char *out, size_t outlen, com_tokentype_t *toktype);
|
||||
char *COM_ParseStringSet (const char *data, char *out, size_t outlen); //whitespace or semi-colon separators
|
||||
char *COM_ParseStringSetSep (const char *data, char sep, char *out, size_t outsize); //single-char-separator, no whitespace
|
||||
char *COM_ParseCString (const char *data, char *out, size_t maxoutlen, size_t *writtenlen);
|
||||
|
|
|
@ -522,9 +522,9 @@ mirror:
|
|||
else if (legacyextractname)
|
||||
{
|
||||
if (!strcmp(legacyextractname, "xz") || !strcmp(legacyextractname, "gz"))
|
||||
mirror[mirrors++] = Z_StrDup(va("%s:%s", legacyextractname, a));
|
||||
mirror[mirrors++] = Z_StrDupf("%s:%s", legacyextractname, a);
|
||||
else
|
||||
mirror[mirrors++] = Z_StrDup(va("unzip:%s,%s", legacyextractname, a));
|
||||
mirror[mirrors++] = Z_StrDupf("unzip:%s,%s", legacyextractname, a);
|
||||
}
|
||||
else
|
||||
mirror[mirrors++] = Z_StrDup(a);
|
||||
|
@ -669,7 +669,7 @@ static qboolean FS_Manifest_ParseTokens(ftemanifest_t *man)
|
|||
{
|
||||
Z_Free(man->mainconfig);
|
||||
if (strcmp(".cfg", COM_GetFileExtension(Cmd_Argv(1),NULL)))
|
||||
man->mainconfig = Z_StrDup(va("%s.cfg", Cmd_Argv(1)));
|
||||
man->mainconfig = Z_StrDupf("%s.cfg", Cmd_Argv(1));
|
||||
else
|
||||
man->mainconfig = Z_StrDup(Cmd_Argv(1));
|
||||
}
|
||||
|
|
|
@ -333,12 +333,12 @@ static struct icestate_s *QDECL ICE_Create(void *module, const char *conname, co
|
|||
{
|
||||
int rnd[1]; //'must have at least 24 bits randomness'
|
||||
Sys_RandomBytes((void*)rnd, sizeof(rnd));
|
||||
con->lufrag = Z_StrDup(va("%08x", rnd[0]));
|
||||
con->lufrag = Z_StrDupf("%08x", rnd[0]);
|
||||
}
|
||||
{
|
||||
int rnd[4]; //'must have at least 128 bits randomness'
|
||||
Sys_RandomBytes((void*)rnd, sizeof(rnd));
|
||||
con->lpwd = Z_StrDup(va("%08x%08x%08x%08x", rnd[0], rnd[1], rnd[2], rnd[3]));
|
||||
con->lpwd = Z_StrDupf("%08x%08x%08x%08x", rnd[0], rnd[1], rnd[2], rnd[3]);
|
||||
}
|
||||
|
||||
Sys_RandomBytes((void*)&con->tiehigh, sizeof(con->tiehigh));
|
||||
|
|
|
@ -213,6 +213,26 @@ void *Z_Malloc(size_t size)
|
|||
}
|
||||
#endif
|
||||
|
||||
char *Z_StrDupf(const char *format, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char *string;
|
||||
int n;
|
||||
|
||||
va_start (argptr, format);
|
||||
n = vsnprintf (NULL,0, format,argptr);
|
||||
va_end (argptr);
|
||||
if (n < 0)
|
||||
n = 1024; //windows bullshit. whatever. good luck with that.
|
||||
|
||||
string = Z_Malloc(n+1);
|
||||
va_start (argptr, format);
|
||||
vsnprintf (string,n, format,argptr);
|
||||
va_end (argptr);
|
||||
string[n] = 0;
|
||||
|
||||
return string;
|
||||
}
|
||||
void Z_StrCat(char **ptr, const char *append)
|
||||
{
|
||||
size_t oldlen = *ptr?strlen(*ptr):0;
|
||||
|
|
|
@ -148,6 +148,7 @@ void ZG_FreeGroup(zonegroup_t *ctx);
|
|||
#define Z_StrDup(s) strcpy(Z_Malloc(strlen(s)+1), s)
|
||||
#define Z_StrDupPtr(v,s) do{Z_Free(*v),*(v) = strcpy(Z_Malloc(strlen(s)+1), s);}while(0)
|
||||
|
||||
char *Z_StrDupf(const char *format, ...);
|
||||
void Z_StrCat(char **ptr, const char *append);
|
||||
|
||||
/*
|
||||
|
|
|
@ -1492,12 +1492,12 @@ static struct charcache_s *Font_GetChar(font_t *f, unsigned int codepoint)
|
|||
//not being a language specialist, I'm just going to use that mapping, with the high bit truncated to ascii (which mostly exists in the quake charset).
|
||||
//this exact table is from ezquake. because I'm too lazy to figure out the proper mapping. (beware of triglyphs)
|
||||
static char *wc2koi_table =
|
||||
"?3??4?67??" "??" "??" ">?"
|
||||
"abwgdevzijklmnop"
|
||||
"rstufhc~{}/yx|`q"
|
||||
"ABWGDEVZIJKLMNOP"
|
||||
"RSTUFHC^[]_YX\\@Q"
|
||||
"?#??$?&'??" "??" "??.?";
|
||||
"?3??4?67??" "??" "??" ">?" //400
|
||||
"abwgdevzijklmnop" //410
|
||||
"rstufhc~{}/yx|`q" //420
|
||||
"ABWGDEVZIJKLMNOP" //430
|
||||
"RSTUFHC^[]_YX\\@Q" //440
|
||||
"?#??$?&'??" "??" "??.?"; //450
|
||||
charidx = wc2koi_table[charidx - 0x400];
|
||||
if (charidx != '?')
|
||||
{
|
||||
|
@ -1506,6 +1506,35 @@ static struct charcache_s *Font_GetChar(font_t *f, unsigned int codepoint)
|
|||
c = Font_TryLoadGlyph(f, charidx);
|
||||
}
|
||||
}
|
||||
|
||||
if (!c && charidx >= 0xA0 && charidx <= 0x17F)
|
||||
{ //try to make sense of iso8859-1
|
||||
//(mostly for zerstorer's o-umlout...)
|
||||
static char *latin_table =
|
||||
" ?c###|S?c?<??R?" //A0
|
||||
"??""??""'u?.,??"">??""??" //B0
|
||||
"AAAAAAECEEEEIIII" //C0
|
||||
"DNOOOOO*OUUUUYYs" //D0
|
||||
"aaaaaaeceeeeiiii" //E0
|
||||
"onooooo/ouuuuyyy" //F0
|
||||
|
||||
"AaAaAaCcCcCcCcDd" //100
|
||||
"DdEeEeEeEeEeGgGg" //110
|
||||
"GgGgHhHhIiIiIiIi" //120
|
||||
"IiIiJjKkkLlLlLlL" //130
|
||||
"lllNnNnNnnNnOoOo" //140
|
||||
"OoEeRrRrRrSsSsSs" //150
|
||||
"SsTtTtTtUuUuUuUu" //160
|
||||
"UuUuWwYyYZzZzZzf"; //170
|
||||
charidx = latin_table[charidx - 0xA0];
|
||||
if (charidx != '?')
|
||||
{
|
||||
c = Font_GetCharIfLoaded(f, charidx);
|
||||
if (!c)
|
||||
c = Font_TryLoadGlyph(f, charidx);
|
||||
}
|
||||
}
|
||||
|
||||
if (!c)
|
||||
c = Font_LoadPlaceholderGlyph(f, charidx);
|
||||
if (!c)
|
||||
|
|
|
@ -475,7 +475,7 @@ void COM_EnumerateFiles (const char *match, int (*func)(const char *, qofs_t, ti
|
|||
}
|
||||
#endif
|
||||
|
||||
char *COM_ParseType (const char *data, char *out, int outlen, com_tokentype_t *toktype)
|
||||
char *COM_ParseType (const char *data, char *out, size_t outlen, com_tokentype_t *toktype)
|
||||
{
|
||||
int c;
|
||||
int len;
|
||||
|
|
|
@ -1267,12 +1267,12 @@ MSV_OpenUserDatabase();
|
|||
memset(&sv.strings, 0, sizeof(sv.strings));
|
||||
|
||||
if (deathmatch.value)
|
||||
sv.strings.configstring[Q2CS_AIRACCEL] = Z_StrDup(va("%g", sv_airaccelerate.value));
|
||||
sv.strings.configstring[Q2CS_AIRACCEL] = Z_StrDupf("%g", sv_airaccelerate.value);
|
||||
else
|
||||
sv.strings.configstring[Q2CS_AIRACCEL] = Z_StrDup("0");
|
||||
|
||||
// init map checksum config string but only for Q2/Q3 maps
|
||||
sv.strings.configstring[Q2CS_MAPCHECKSUM] = Z_StrDup(va("%i", sv.world.worldmodel->checksum));
|
||||
sv.strings.configstring[Q2CS_MAPCHECKSUM] = Z_StrDupf("%i", sv.world.worldmodel->checksum);
|
||||
|
||||
subs = sv.world.worldmodel->numsubmodels;
|
||||
if (subs > MAX_PRECACHE_MODELS-1)
|
||||
|
@ -1284,12 +1284,12 @@ MSV_OpenUserDatabase();
|
|||
sv.strings.configstring[Q2CS_MODELS+1] = Z_StrDup(sv.modelname);
|
||||
for (i=1; i<subs && i < Q2MAX_MODELS-2; i++)
|
||||
{
|
||||
sv.strings.configstring[Q2CS_MODELS+1+i] = Z_StrDup(va("*%u", i));
|
||||
sv.strings.configstring[Q2CS_MODELS+1+i] = Z_StrDupf("*%u", i);
|
||||
sv.models[i+1] = Mod_ForName (Mod_FixName(sv.strings.configstring[Q2CS_MODELS+1+i], sv.modelname), MLV_WARN);
|
||||
}
|
||||
for ( ; i<subs; i++)
|
||||
{
|
||||
sv.strings.q2_extramodels[1+i] = Z_StrDup(va("*%u", i));
|
||||
sv.strings.q2_extramodels[1+i] = Z_StrDupf("*%u", i);
|
||||
sv.models[i+1] = Mod_ForName (Mod_FixName(sv.strings.q2_extramodels[1+i], sv.modelname), MLV_WARN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ void Sys_Error (const char *error, ...)
|
|||
vsnprintf (string,sizeof(string)-1, error,argptr);
|
||||
va_end (argptr);
|
||||
COM_WorkerAbort(string);
|
||||
printf ("Fatal error: %s\n",string);
|
||||
fprintf(stderr, "Fatal error: %s\n",string);
|
||||
|
||||
if (!noconinput)
|
||||
{
|
||||
|
@ -1192,8 +1192,10 @@ static int Sys_EnumerateFiles2 (const char *truepath, int apathofs, const char *
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else if (lstat(file, &st) == 0)
|
||||
;//okay, so bad symlink, just mute it
|
||||
else
|
||||
printf("Stat failed for \"%s\"\n", file);
|
||||
fprintf(stderr, "Stat failed for \"%s\"\n", file);
|
||||
}
|
||||
}
|
||||
} while(1);
|
||||
|
|
Loading…
Reference in a new issue