mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-22 18:31:27 +00:00
Fix an unhealthy pile of gcc 8 warnings.
While some of the warnings were merely annoying, some where actual bugs or unearthed bugs in related code.
This commit is contained in:
parent
81202d7b29
commit
4f58429137
20 changed files with 178 additions and 151 deletions
|
@ -90,7 +90,7 @@ typedef struct instsurf_s {
|
||||||
} instsurf_t;
|
} instsurf_t;
|
||||||
|
|
||||||
typedef struct texture_s {
|
typedef struct texture_s {
|
||||||
char name[16];
|
char *name;
|
||||||
unsigned int width, height;
|
unsigned int width, height;
|
||||||
int gl_texturenum;
|
int gl_texturenum;
|
||||||
int gl_fb_texturenum;
|
int gl_fb_texturenum;
|
||||||
|
@ -445,7 +445,7 @@ mleaf_t *Mod_PointInLeaf (const vec3_t p, model_t *model);
|
||||||
byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
|
byte *Mod_LeafPVS (mleaf_t *leaf, model_t *model);
|
||||||
model_t *Mod_FindName (const char *name);
|
model_t *Mod_FindName (const char *name);
|
||||||
int Mod_CalcFullbright (byte *in, byte *out, int pixels);
|
int Mod_CalcFullbright (byte *in, byte *out, int pixels);
|
||||||
int Mod_Fullbright (byte * skin, int width, int height, char *name);
|
int Mod_Fullbright (byte * skin, int width, int height, const char *name);
|
||||||
|
|
||||||
void *Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame,
|
void *Mod_LoadAliasFrame (void *pin, int *posenum, maliasframedesc_t *frame,
|
||||||
int extra);
|
int extra);
|
||||||
|
|
|
@ -43,7 +43,7 @@ void Team_Init_Cvars (void);
|
||||||
void Team_BestWeaponImpulse (void);
|
void Team_BestWeaponImpulse (void);
|
||||||
void Team_Dead (void);
|
void Team_Dead (void);
|
||||||
void Team_NewMap (void);
|
void Team_NewMap (void);
|
||||||
const char *Team_ParseSay (const char *);
|
const char *Team_ParseSay (struct dstring_s *buf, const char *);
|
||||||
void Locs_Init (void);
|
void Locs_Init (void);
|
||||||
void Team_ParseChat (const char *string);
|
void Team_ParseChat (const char *string);
|
||||||
void Team_ResetTimers (void);
|
void Team_ResetTimers (void);
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
# include <strings.h>
|
# include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "QF/dstring.h"
|
||||||
#include "QF/image.h"
|
#include "QF/image.h"
|
||||||
#include "QF/qendian.h"
|
#include "QF/qendian.h"
|
||||||
#include "QF/quakefs.h"
|
#include "QF/quakefs.h"
|
||||||
|
@ -56,8 +57,9 @@ gl_Mod_LoadSkin (byte * skin, int skinsize, int snum, int gnum, qboolean group,
|
||||||
maliasskindesc_t *skindesc)
|
maliasskindesc_t *skindesc)
|
||||||
{
|
{
|
||||||
byte *pskin;
|
byte *pskin;
|
||||||
char name[32], modname[MAX_QPATH + 4];
|
char modname[MAX_QPATH + 4];
|
||||||
int fb_texnum = 0, texnum = 0;
|
int fb_texnum = 0, texnum = 0;
|
||||||
|
dstring_t *name = dstring_new ();
|
||||||
|
|
||||||
pskin = Hunk_AllocName (skinsize, loadname);
|
pskin = Hunk_AllocName (skinsize, loadname);
|
||||||
skindesc->skin = (byte *) pskin - (byte *) pheader;
|
skindesc->skin = (byte *) pskin - (byte *) pheader;
|
||||||
|
@ -75,27 +77,26 @@ gl_Mod_LoadSkin (byte * skin, int skinsize, int snum, int gnum, qboolean group,
|
||||||
|
|
||||||
if (!loadmodel->fullbright) {
|
if (!loadmodel->fullbright) {
|
||||||
if (group) {
|
if (group) {
|
||||||
snprintf (name, sizeof (name), "fb_%s_%i_%i", modname,
|
dsprintf (name, "fb_%s_%i_%i", modname, snum, gnum);
|
||||||
snum, gnum);
|
|
||||||
} else {
|
} else {
|
||||||
snprintf (name, sizeof (name), "fb_%s_%i", modname, snum);
|
dsprintf (name, "fb_%s_%i", modname, snum);
|
||||||
}
|
}
|
||||||
fb_texnum = Mod_Fullbright (pskin, pheader->mdl.skinwidth,
|
fb_texnum = Mod_Fullbright (pskin, pheader->mdl.skinwidth,
|
||||||
pheader->mdl.skinheight, name);
|
pheader->mdl.skinheight, name->str);
|
||||||
Sys_MaskPrintf (SYS_GLT, "%s %d\n", name, fb_texnum);
|
Sys_MaskPrintf (SYS_GLT, "%s %d\n", name->str, fb_texnum);
|
||||||
}
|
}
|
||||||
if (group) {
|
if (group) {
|
||||||
snprintf (name, sizeof (name), "%s_%i_%i", modname, snum,
|
dsprintf (name, "%s_%i_%i", modname, snum, gnum);
|
||||||
gnum);
|
|
||||||
} else {
|
} else {
|
||||||
snprintf (name, sizeof (name), "%s_%i", modname, snum);
|
dsprintf (name, "%s_%i", modname, snum);
|
||||||
}
|
}
|
||||||
texnum = GL_LoadTexture (name, pheader->mdl.skinwidth,
|
texnum = GL_LoadTexture (name->str, pheader->mdl.skinwidth,
|
||||||
pheader->mdl.skinheight, pskin, true, false, 1);
|
pheader->mdl.skinheight, pskin, true, false, 1);
|
||||||
Sys_MaskPrintf (SYS_GLT, "%s %d\n", name, texnum);
|
Sys_MaskPrintf (SYS_GLT, "%s %d\n", name->str, texnum);
|
||||||
skindesc->texnum = texnum;
|
skindesc->texnum = texnum;
|
||||||
skindesc->fb_texnum = fb_texnum;
|
skindesc->fb_texnum = fb_texnum;
|
||||||
loadmodel->hasfullbrights = fb_texnum;
|
loadmodel->hasfullbrights = fb_texnum;
|
||||||
|
dstring_delete (name);
|
||||||
// alpha param was true for non group skins
|
// alpha param was true for non group skins
|
||||||
return skin + skinsize;
|
return skin + skinsize;
|
||||||
}
|
}
|
||||||
|
@ -151,10 +152,11 @@ Mod_LoadExternalSkin (maliasskindesc_t *pskindesc, char *filename)
|
||||||
void
|
void
|
||||||
gl_Mod_LoadExternalSkins (model_t *mod)
|
gl_Mod_LoadExternalSkins (model_t *mod)
|
||||||
{
|
{
|
||||||
char filename[MAX_QPATH + 4], modname[MAX_QPATH + 4];
|
char modname[MAX_QPATH + 4];
|
||||||
int i, j;
|
int i, j;
|
||||||
maliasskindesc_t *pskindesc;
|
maliasskindesc_t *pskindesc;
|
||||||
maliasskingroup_t *pskingroup;
|
maliasskingroup_t *pskingroup;
|
||||||
|
dstring_t *filename = dstring_new ();
|
||||||
|
|
||||||
QFS_StripExtension (mod->name, modname);
|
QFS_StripExtension (mod->name, modname);
|
||||||
|
|
||||||
|
@ -162,16 +164,15 @@ gl_Mod_LoadExternalSkins (model_t *mod)
|
||||||
pskindesc = ((maliasskindesc_t *)
|
pskindesc = ((maliasskindesc_t *)
|
||||||
((byte *) pheader + pheader->skindesc)) + i;
|
((byte *) pheader + pheader->skindesc)) + i;
|
||||||
if (pskindesc->type == ALIAS_SKIN_SINGLE) {
|
if (pskindesc->type == ALIAS_SKIN_SINGLE) {
|
||||||
snprintf (filename, sizeof (filename), "%s_%i", modname, i);
|
dsprintf (filename, "%s_%i", modname, i);
|
||||||
Mod_LoadExternalSkin (pskindesc, filename);
|
Mod_LoadExternalSkin (pskindesc, filename->str);
|
||||||
} else {
|
} else {
|
||||||
pskingroup = (maliasskingroup_t *)
|
pskingroup = (maliasskingroup_t *)
|
||||||
((byte *) pheader + pskindesc->skin);
|
((byte *) pheader + pskindesc->skin);
|
||||||
|
|
||||||
for (j = 0; j < pskingroup->numskins; j++) {
|
for (j = 0; j < pskingroup->numskins; j++) {
|
||||||
snprintf (filename, sizeof (filename), "%s_%i_%i",
|
dsprintf (filename, "%s_%i_%i", modname, i, j);
|
||||||
modname, i, j);
|
Mod_LoadExternalSkin (pskingroup->skindescs + j, filename->str);
|
||||||
Mod_LoadExternalSkin (pskingroup->skindescs + j, filename);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,11 +55,11 @@
|
||||||
void
|
void
|
||||||
gl_Mod_ProcessTexture (texture_t *tx)
|
gl_Mod_ProcessTexture (texture_t *tx)
|
||||||
{
|
{
|
||||||
char name[32];
|
const char *name;
|
||||||
|
|
||||||
if (!strncmp (tx->name, "sky", 3))
|
if (!strncmp (tx->name, "sky", 3))
|
||||||
return;
|
return;
|
||||||
snprintf (name, sizeof (name), "fb_%s", tx->name);
|
name = va ("fb_%s", tx->name);
|
||||||
tx->gl_fb_texturenum =
|
tx->gl_fb_texturenum =
|
||||||
Mod_Fullbright ((byte *) (tx + 1), tx->width, tx->height, name);
|
Mod_Fullbright ((byte *) (tx + 1), tx->width, tx->height, name);
|
||||||
tx->gl_texturenum =
|
tx->gl_texturenum =
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
|
|
||||||
#include "QF/checksum.h"
|
#include "QF/checksum.h"
|
||||||
#include "QF/cvar.h"
|
#include "QF/cvar.h"
|
||||||
|
#include "QF/dstring.h"
|
||||||
#include "QF/model.h"
|
#include "QF/model.h"
|
||||||
#include "QF/qendian.h"
|
#include "QF/qendian.h"
|
||||||
#include "QF/quakefs.h"
|
#include "QF/quakefs.h"
|
||||||
|
@ -132,25 +133,28 @@ Mod_LeafPVS (mleaf_t *leaf, model_t *model)
|
||||||
static void
|
static void
|
||||||
mod_unique_miptex_name (texture_t **textures, texture_t *tx, int ind)
|
mod_unique_miptex_name (texture_t **textures, texture_t *tx, int ind)
|
||||||
{
|
{
|
||||||
char name[17];
|
char *name;
|
||||||
int num = 0, i;
|
int num = 0, i;
|
||||||
const char *tag;
|
dstring_t *tag = 0;
|
||||||
|
|
||||||
strncpy (name, tx->name, 16);
|
name = tx->name;
|
||||||
name[16] = 0;
|
|
||||||
do {
|
do {
|
||||||
for (i = 0; i < ind; i++)
|
for (i = 0; i < ind; i++)
|
||||||
if (textures[i] && !strcmp (textures[i]->name, tx->name))
|
if (textures[i] && !strcmp (textures[i]->name, tx->name))
|
||||||
break;
|
break;
|
||||||
if (i == ind)
|
if (i == ind)
|
||||||
break;
|
break;
|
||||||
tag = va ("~%x", num++);
|
if (!tag) {
|
||||||
strncpy (tx->name, name, 16);
|
tag = dstring_new ();
|
||||||
if (strlen (name) + strlen (tag) <= 15)
|
}
|
||||||
strcat (tx->name, tag);
|
dsprintf (tag, "%s~%x", name, num++);
|
||||||
else
|
tx->name = tag->str;
|
||||||
strcpy (tx->name + 15 - strlen (tag), tag);
|
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
|
if (tag) {
|
||||||
|
tx->name = dstring_freeze (tag);
|
||||||
|
free(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -188,7 +192,7 @@ Mod_LoadTextures (bsp_t *bsp)
|
||||||
|
|
||||||
loadmodel->textures[i] = tx;
|
loadmodel->textures[i] = tx;
|
||||||
|
|
||||||
memcpy (tx->name, mt->name, sizeof (tx->name));
|
tx->name = strndup(mt->name, sizeof (mt->name));
|
||||||
mod_unique_miptex_name (loadmodel->textures, tx, i);
|
mod_unique_miptex_name (loadmodel->textures, tx, i);
|
||||||
tx->width = mt->width;
|
tx->width = mt->width;
|
||||||
tx->height = mt->height;
|
tx->height = mt->height;
|
||||||
|
|
|
@ -59,7 +59,7 @@ Mod_CalcFullbright (byte *in, byte *out, int pixels)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Mod_Fullbright (byte *skin, int width, int height, char *name)
|
Mod_Fullbright (byte *skin, int width, int height, const char *name)
|
||||||
{
|
{
|
||||||
byte *ptexels;
|
byte *ptexels;
|
||||||
int pixels;
|
int pixels;
|
||||||
|
|
|
@ -161,7 +161,7 @@ pack_create (const char *name)
|
||||||
pack_del (pack);
|
pack_del (pack);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
strncpy (pack->header.id, "PACK", sizeof (pack->header.id));
|
memcpy (pack->header.id, "PACK", sizeof (pack->header.id));
|
||||||
|
|
||||||
Qwrite (pack->handle, &pack->header, sizeof (pack->header));
|
Qwrite (pack->handle, &pack->header, sizeof (pack->header));
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ wad_create (const char *name)
|
||||||
wad_del (wad);
|
wad_del (wad);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
strncpy (wad->header.id, "WAD2", sizeof (wad->header.id));
|
memcpy (wad->header.id, "WAD2", sizeof (wad->header.id));
|
||||||
|
|
||||||
Qwrite (wad->handle, &wad->header, sizeof (wad->header));
|
Qwrite (wad->handle, &wad->header, sizeof (wad->header));
|
||||||
|
|
||||||
|
|
|
@ -256,7 +256,8 @@ gl_Draw_CachePic (const char *path, qboolean alpha)
|
||||||
} else
|
} else
|
||||||
Sys_Error ("Draw_CachePic: failed to load %s", path);
|
Sys_Error ("Draw_CachePic: failed to load %s", path);
|
||||||
|
|
||||||
strncpy (pic->name, path, sizeof (pic->name));
|
memset (pic->name, 0, sizeof (pic->name));
|
||||||
|
strncpy (pic->name, path, sizeof (pic->name) - 1);
|
||||||
|
|
||||||
// Now lets mark this cache entry as used..
|
// Now lets mark this cache entry as used..
|
||||||
pic->dirty = false;
|
pic->dirty = false;
|
||||||
|
|
|
@ -56,15 +56,15 @@ typedef struct {
|
||||||
double fps;
|
double fps;
|
||||||
} td_stats_t;
|
} td_stats_t;
|
||||||
|
|
||||||
int demo_timeframes_isactive;
|
static int demo_timeframes_isactive;
|
||||||
int demo_timeframes_index;
|
static int demo_timeframes_index;
|
||||||
char demoname[1024];
|
static dstring_t *demoname;
|
||||||
double *demo_timeframes_array;
|
static double *demo_timeframes_array;
|
||||||
#define CL_TIMEFRAMES_ARRAYBLOCK 4096
|
#define CL_TIMEFRAMES_ARRAYBLOCK 4096
|
||||||
|
|
||||||
int timedemo_count;
|
static int timedemo_count;
|
||||||
int timedemo_runs;
|
static int timedemo_runs;
|
||||||
td_stats_t *timedemo_data;
|
static td_stats_t *timedemo_data;
|
||||||
|
|
||||||
static void CL_FinishTimeDemo (void);
|
static void CL_FinishTimeDemo (void);
|
||||||
static void CL_TimeFrames_DumpLog (void);
|
static void CL_TimeFrames_DumpLog (void);
|
||||||
|
@ -450,7 +450,7 @@ CL_StartDemo (void)
|
||||||
CL_Disconnect ();
|
CL_Disconnect ();
|
||||||
|
|
||||||
// open the demo file
|
// open the demo file
|
||||||
name = dstring_strdup (demoname);
|
name = dstring_strdup (demoname->str);
|
||||||
QFS_DefaultExtension (name, ".dem");
|
QFS_DefaultExtension (name, ".dem");
|
||||||
|
|
||||||
Sys_Printf ("Playing demo from %s.\n", name->str);
|
Sys_Printf ("Playing demo from %s.\n", name->str);
|
||||||
|
@ -499,7 +499,7 @@ CL_PlayDemo_f (void)
|
||||||
|
|
||||||
switch (Cmd_Argc ()) {
|
switch (Cmd_Argc ()) {
|
||||||
case 1:
|
case 1:
|
||||||
if (!demoname[0])
|
if (!demoname->str[0])
|
||||||
goto playdemo_error;
|
goto playdemo_error;
|
||||||
// fall through
|
// fall through
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -519,7 +519,7 @@ playdemo_error:
|
||||||
timedemo_runs = timedemo_count = 1; // make sure looped timedemos stop
|
timedemo_runs = timedemo_count = 1; // make sure looped timedemos stop
|
||||||
|
|
||||||
if (Cmd_Argc () > 1)
|
if (Cmd_Argc () > 1)
|
||||||
strncpy (demoname, Cmd_Argv (1), sizeof (demoname));
|
dstring_copystr (demoname, Cmd_Argv (1));
|
||||||
CL_StartDemo ();
|
CL_StartDemo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -627,7 +627,7 @@ CL_TimeDemo_f (void)
|
||||||
timedemo_data = 0;
|
timedemo_data = 0;
|
||||||
}
|
}
|
||||||
timedemo_data = calloc (timedemo_runs, sizeof (td_stats_t));
|
timedemo_data = calloc (timedemo_runs, sizeof (td_stats_t));
|
||||||
strncpy (demoname, Cmd_Argv (1), sizeof (demoname));
|
dstring_copystr (demoname, Cmd_Argv (1));
|
||||||
CL_StartTimeDemo ();
|
CL_StartTimeDemo ();
|
||||||
timedemo_runs = timedemo_count = max (count, 1);
|
timedemo_runs = timedemo_count = max (count, 1);
|
||||||
timedemo_data = calloc (timedemo_runs, sizeof (td_stats_t));
|
timedemo_data = calloc (timedemo_runs, sizeof (td_stats_t));
|
||||||
|
@ -636,6 +636,7 @@ CL_TimeDemo_f (void)
|
||||||
void
|
void
|
||||||
CL_Demo_Init (void)
|
CL_Demo_Init (void)
|
||||||
{
|
{
|
||||||
|
demoname = dstring_newstr ();
|
||||||
demo_timeframes_isactive = 0;
|
demo_timeframes_isactive = 0;
|
||||||
demo_timeframes_index = 0;
|
demo_timeframes_index = 0;
|
||||||
demo_timeframes_array = NULL;
|
demo_timeframes_array = NULL;
|
||||||
|
|
|
@ -352,7 +352,7 @@ draw_num (view_t *view, int x, int y, int num, int digits, int color)
|
||||||
static inline void
|
static inline void
|
||||||
draw_smallnum (view_t *view, int x, int y, int n, int packed, int colored)
|
draw_smallnum (view_t *view, int x, int y, int n, int packed, int colored)
|
||||||
{
|
{
|
||||||
char num[4];
|
char num[12];
|
||||||
|
|
||||||
packed = packed != 0; // ensure 0 or 1
|
packed = packed != 0; // ensure 0 or 1
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ typedef struct {
|
||||||
unsigned int model_player_checksum;
|
unsigned int model_player_checksum;
|
||||||
unsigned int eyes_player_checksum;
|
unsigned int eyes_player_checksum;
|
||||||
|
|
||||||
char name[64]; // map name
|
char *name; // map name
|
||||||
char modelname[MAX_QPATH]; // maps/<name>.bsp, for model_precache[0]
|
char modelname[MAX_QPATH]; // maps/<name>.bsp, for model_precache[0]
|
||||||
struct model_s *worldmodel;
|
struct model_s *worldmodel;
|
||||||
const char *model_precache[MAX_MODELS]; // NULL terminated
|
const char *model_precache[MAX_MODELS]; // NULL terminated
|
||||||
|
|
|
@ -37,12 +37,33 @@
|
||||||
|
|
||||||
#include "QF/cbuf.h"
|
#include "QF/cbuf.h"
|
||||||
#include "QF/cmd.h"
|
#include "QF/cmd.h"
|
||||||
|
#include "QF/dstring.h"
|
||||||
#include "QF/msg.h"
|
#include "QF/msg.h"
|
||||||
#include "QF/sys.h"
|
#include "QF/sys.h"
|
||||||
#include "QF/teamplay.h"
|
#include "QF/teamplay.h"
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
send_say (const char *str)
|
||||||
|
{
|
||||||
|
static dstring_t *teambuf;
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
if (!teambuf) {
|
||||||
|
teambuf = dstring_newstr ();
|
||||||
|
}
|
||||||
|
|
||||||
|
s = Team_ParseSay (teambuf, Cmd_Args (1));
|
||||||
|
if (*s && *s < 32 && *s != 10) {
|
||||||
|
// otherwise the server would eat leading characters
|
||||||
|
// less than 32 or greater than 127
|
||||||
|
SZ_Print (&cls.netchan.message, "\"");
|
||||||
|
SZ_Print (&cls.netchan.message, s);
|
||||||
|
SZ_Print (&cls.netchan.message, "\"");
|
||||||
|
} else
|
||||||
|
SZ_Print (&cls.netchan.message, s);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CL_Cmd_ForwardToServer
|
CL_Cmd_ForwardToServer
|
||||||
|
@ -70,21 +91,10 @@ CL_Cmd_ForwardToServer (void)
|
||||||
|
|
||||||
if (!strcasecmp (Cmd_Argv (0), "say") ||
|
if (!strcasecmp (Cmd_Argv (0), "say") ||
|
||||||
!strcasecmp (Cmd_Argv (0), "say_team")) {
|
!strcasecmp (Cmd_Argv (0), "say_team")) {
|
||||||
const char *s;
|
send_say(Cmd_Args (1));
|
||||||
|
} else {
|
||||||
s = Team_ParseSay (Cmd_Args (1));
|
SZ_Print (&cls.netchan.message, Cmd_Args (1));
|
||||||
if (*s && *s < 32 && *s != 10) {
|
|
||||||
// otherwise the server would eat leading characters
|
|
||||||
// less than 32 or greater than 127
|
|
||||||
SZ_Print (&cls.netchan.message, "\"");
|
|
||||||
SZ_Print (&cls.netchan.message, s);
|
|
||||||
SZ_Print (&cls.netchan.message, "\"");
|
|
||||||
} else
|
|
||||||
SZ_Print (&cls.netchan.message, s);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SZ_Print (&cls.netchan.message, Cmd_Args (1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,14 +69,14 @@ typedef struct {
|
||||||
double fps;
|
double fps;
|
||||||
} td_stats_t;
|
} td_stats_t;
|
||||||
|
|
||||||
int demo_timeframes_isactive;
|
static int demo_timeframes_isactive;
|
||||||
int demo_timeframes_index;
|
static int demo_timeframes_index;
|
||||||
static int demotime_cached;
|
static int demotime_cached;
|
||||||
static float cached_demotime;
|
static float cached_demotime;
|
||||||
static byte cached_newtime;
|
static byte cached_newtime;
|
||||||
float nextdemotime;
|
static float nextdemotime;
|
||||||
char demoname[1024];
|
static dstring_t *demoname;
|
||||||
double *demo_timeframes_array;
|
static double *demo_timeframes_array;
|
||||||
#define CL_TIMEFRAMES_ARRAYBLOCK 4096
|
#define CL_TIMEFRAMES_ARRAYBLOCK 4096
|
||||||
|
|
||||||
int timedemo_count;
|
int timedemo_count;
|
||||||
|
@ -990,12 +990,12 @@ CL_StartDemo (void)
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
// open the demo file
|
// open the demo file
|
||||||
name = dstring_strdup (demoname);
|
name = dstring_strdup (demoname->str);
|
||||||
|
|
||||||
QFS_DefaultExtension (name, ".mvd");
|
QFS_DefaultExtension (name, ".mvd");
|
||||||
cls.demofile = QFS_FOpenFile (name->str);
|
cls.demofile = QFS_FOpenFile (name->str);
|
||||||
if (!cls.demofile) {
|
if (!cls.demofile) {
|
||||||
dstring_copystr (name, demoname);
|
dstring_copystr (name, demoname->str);
|
||||||
QFS_DefaultExtension (name, ".qwd");
|
QFS_DefaultExtension (name, ".qwd");
|
||||||
cls.demofile = QFS_FOpenFile (name->str);
|
cls.demofile = QFS_FOpenFile (name->str);
|
||||||
}
|
}
|
||||||
|
@ -1050,7 +1050,7 @@ CL_PlayDemo_f (void)
|
||||||
{
|
{
|
||||||
switch (Cmd_Argc ()) {
|
switch (Cmd_Argc ()) {
|
||||||
case 1:
|
case 1:
|
||||||
if (!demoname[0])
|
if (!demoname->str[0])
|
||||||
goto playdemo_error;
|
goto playdemo_error;
|
||||||
// fall through
|
// fall through
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -1072,7 +1072,7 @@ playdemo_error:
|
||||||
CL_Disconnect ();
|
CL_Disconnect ();
|
||||||
|
|
||||||
if (Cmd_Argc () > 1)
|
if (Cmd_Argc () > 1)
|
||||||
strncpy (demoname, Cmd_Argv (1), sizeof (demoname));
|
dstring_copystr (demoname, Cmd_Argv (1));
|
||||||
CL_StartDemo ();
|
CL_StartDemo ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1182,7 +1182,7 @@ CL_TimeDemo_f (void)
|
||||||
timedemo_data = 0;
|
timedemo_data = 0;
|
||||||
}
|
}
|
||||||
timedemo_data = calloc (timedemo_runs, sizeof (td_stats_t));
|
timedemo_data = calloc (timedemo_runs, sizeof (td_stats_t));
|
||||||
strncpy (demoname, Cmd_Argv (1), sizeof (demoname));
|
dstring_copystr (demoname, Cmd_Argv (1));
|
||||||
CL_StartTimeDemo ();
|
CL_StartTimeDemo ();
|
||||||
timedemo_runs = timedemo_count = max (count, 1);
|
timedemo_runs = timedemo_count = max (count, 1);
|
||||||
timedemo_data = calloc (timedemo_runs, sizeof (td_stats_t));
|
timedemo_data = calloc (timedemo_runs, sizeof (td_stats_t));
|
||||||
|
@ -1191,6 +1191,8 @@ CL_TimeDemo_f (void)
|
||||||
void
|
void
|
||||||
CL_Demo_Init (void)
|
CL_Demo_Init (void)
|
||||||
{
|
{
|
||||||
|
demoname = dstring_newstr ();
|
||||||
|
|
||||||
demo_timeframes_isactive = 0;
|
demo_timeframes_isactive = 0;
|
||||||
demo_timeframes_index = 0;
|
demo_timeframes_index = 0;
|
||||||
demo_timeframes_array = NULL;
|
demo_timeframes_array = NULL;
|
||||||
|
|
|
@ -476,7 +476,7 @@ draw_solo (view_t *view)
|
||||||
static inline void
|
static inline void
|
||||||
draw_smallnum (view_t *view, int x, int y, int n, int packed, int colored)
|
draw_smallnum (view_t *view, int x, int y, int n, int packed, int colored)
|
||||||
{
|
{
|
||||||
char num[4];
|
char num[12];
|
||||||
|
|
||||||
packed = packed != 0; // ensure 0 or 1
|
packed = packed != 0; // ensure 0 or 1
|
||||||
|
|
||||||
|
|
|
@ -341,6 +341,9 @@ SV_SpawnServer (const char *server)
|
||||||
so_buffers = sv.signon_buffers;
|
so_buffers = sv.signon_buffers;
|
||||||
so_sizes = sv.signon_buffer_size;
|
so_sizes = sv.signon_buffer_size;
|
||||||
|
|
||||||
|
if (sv.name) {
|
||||||
|
free (sv.name);
|
||||||
|
}
|
||||||
memset (&sv, 0, sizeof (sv));
|
memset (&sv, 0, sizeof (sv));
|
||||||
|
|
||||||
sv.recorders = recorders;
|
sv.recorders = recorders;
|
||||||
|
@ -363,7 +366,7 @@ SV_SpawnServer (const char *server)
|
||||||
|
|
||||||
SV_NextSignon ();
|
SV_NextSignon ();
|
||||||
|
|
||||||
strcpy (sv.name, server);
|
sv.name = strdup(server);
|
||||||
|
|
||||||
// load progs to get entity field count which determines how big each
|
// load progs to get entity field count which determines how big each
|
||||||
// edict is
|
// edict is
|
||||||
|
@ -384,7 +387,6 @@ SV_SpawnServer (const char *server)
|
||||||
|
|
||||||
sv.time = 1.0;
|
sv.time = 1.0;
|
||||||
|
|
||||||
strncpy (sv.name, server, sizeof (sv.name));
|
|
||||||
snprintf (sv.modelname, sizeof (sv.modelname), "maps/%s.bsp", server);
|
snprintf (sv.modelname, sizeof (sv.modelname), "maps/%s.bsp", server);
|
||||||
map_cfg (sv.modelname, 0);
|
map_cfg (sv.modelname, 0);
|
||||||
sv.worldmodel = Mod_ForName (sv.modelname, true);
|
sv.worldmodel = Mod_ForName (sv.modelname, true);
|
||||||
|
|
|
@ -1430,7 +1430,7 @@ SV_AddIP_f (void)
|
||||||
// FIXME: this should boot any matching clients
|
// FIXME: this should boot any matching clients
|
||||||
for (i = 0; i < MAX_CLIENTS; i++) {
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
||||||
client_t *cl = &svs.clients[i];
|
client_t *cl = &svs.clients[i];
|
||||||
char text[1024];
|
const char *text;
|
||||||
const char *typestr;
|
const char *typestr;
|
||||||
char timestr[1024];
|
char timestr[1024];
|
||||||
|
|
||||||
|
@ -1461,9 +1461,9 @@ SV_AddIP_f (void)
|
||||||
bantime / 60);
|
bantime / 60);
|
||||||
else
|
else
|
||||||
strncpy (timestr, "permanently", sizeof (timestr));
|
strncpy (timestr, "permanently", sizeof (timestr));
|
||||||
snprintf (text, sizeof (text), "You are %s %s\n%s",
|
text = va ("You are %s %s\n%s",
|
||||||
typestr, timestr, type == ft_ban ? "" :
|
typestr, timestr, type == ft_ban ? "" :
|
||||||
"\nReconnecting won't help...");
|
"\nReconnecting won't help...");
|
||||||
MSG_ReliableWrite_Begin (&cl->backbuf, svc_centerprint,
|
MSG_ReliableWrite_Begin (&cl->backbuf, svc_centerprint,
|
||||||
strlen (text) + 2);
|
strlen (text) + 2);
|
||||||
MSG_ReliableWrite_String (&cl->backbuf, text);
|
MSG_ReliableWrite_String (&cl->backbuf, text);
|
||||||
|
|
|
@ -148,6 +148,20 @@ SV_EndRedirect (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAXPRINTMSG 4096
|
#define MAXPRINTMSG 4096
|
||||||
|
static int
|
||||||
|
find_userid (const char *name)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
||||||
|
if (!svs.clients[i].state)
|
||||||
|
continue;
|
||||||
|
if (!strcmp (svs.clients[i].name, name)) {
|
||||||
|
return svs.clients[i].userid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
SV_Printf
|
SV_Printf
|
||||||
|
@ -158,10 +172,11 @@ SV_EndRedirect (void)
|
||||||
void
|
void
|
||||||
SV_Print (const char *fmt, va_list args)
|
SV_Print (const char *fmt, va_list args)
|
||||||
{
|
{
|
||||||
|
static dstring_t *premsg;
|
||||||
|
static dstring_t *msg;
|
||||||
|
static dstring_t *msg2;
|
||||||
static int pending = 0; // partial line being printed
|
static int pending = 0; // partial line being printed
|
||||||
char premsg[MAXPRINTMSG];
|
|
||||||
unsigned char msg[MAXPRINTMSG];
|
|
||||||
char msg2[MAXPRINTMSG];
|
|
||||||
char msg3[MAXPRINTMSG];
|
char msg3[MAXPRINTMSG];
|
||||||
|
|
||||||
time_t mytime = 0;
|
time_t mytime = 0;
|
||||||
|
@ -169,50 +184,42 @@ SV_Print (const char *fmt, va_list args)
|
||||||
qboolean timestamps = false;
|
qboolean timestamps = false;
|
||||||
|
|
||||||
char *in;
|
char *in;
|
||||||
unsigned char *out;
|
|
||||||
|
|
||||||
vsnprintf (premsg, sizeof (premsg), fmt, args);
|
if (!premsg) {
|
||||||
in = premsg;
|
premsg = dstring_newstr ();
|
||||||
out = msg;
|
msg = dstring_new ();
|
||||||
|
msg2 = dstring_new ();
|
||||||
|
}
|
||||||
|
dstring_clearstr (msg);
|
||||||
|
|
||||||
if (!*premsg)
|
dvsprintf (premsg, fmt, args);
|
||||||
|
in = premsg->str;
|
||||||
|
|
||||||
|
if (!*premsg->str)
|
||||||
return;
|
return;
|
||||||
// expand FFnickFF to nick <userid>
|
// expand FFnickFF to nick <userid>
|
||||||
do {
|
do {
|
||||||
switch ((byte) *in) {
|
char *beg = strchr (in, 0xFF);
|
||||||
case 0xFF: {
|
if (beg) {
|
||||||
char *end = strchr (in + 1, 0xFF);
|
char *name = beg + 1;
|
||||||
int userid = 0;
|
char *end = strchr (name, 0xFF);
|
||||||
int len;
|
if (!end) {
|
||||||
int i;
|
end = beg + strlen (name);
|
||||||
|
|
||||||
if (!end)
|
|
||||||
end = in + strlen (in);
|
|
||||||
*end = '\0';
|
|
||||||
for (i = 0; i < MAX_CLIENTS; i++) {
|
|
||||||
if (!svs.clients[i].state)
|
|
||||||
continue;
|
|
||||||
if (!strcmp (svs.clients[i].name, in + 1)) {
|
|
||||||
userid = svs.clients[i].userid;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
len = snprintf ((char *) out, sizeof (msg) - (out - msg),
|
|
||||||
"%s <%d>", in + 1, userid);
|
|
||||||
out += len;
|
|
||||||
in = end + 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
*end = 0;
|
||||||
*out++ = *in++;
|
dstring_appendsubstr (msg, in, beg - in);
|
||||||
|
dasprintf (msg, "%s <%d>", name, find_userid (name));
|
||||||
|
in = end + 1;
|
||||||
|
} else {
|
||||||
|
dstring_appendstr (msg, in);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} while (sizeof (msg) - (out - msg) > 0 && *in);
|
} while (*in);
|
||||||
*out = '\0';
|
|
||||||
|
|
||||||
if (sv_redirected) { // Add to redirected message
|
if (sv_redirected) { // Add to redirected message
|
||||||
dstring_appendstr (&outputbuf, (char *) msg);
|
dstring_appendstr (&outputbuf, msg->str);
|
||||||
}
|
}
|
||||||
if (*msg && !con_printf_no_log) {
|
if (*msg->str && !con_printf_no_log) {
|
||||||
// We want to output to console and maybe logfile
|
// We want to output to console and maybe logfile
|
||||||
if (sv_timestamps && sv_timefmt && sv_timefmt->string
|
if (sv_timestamps && sv_timefmt && sv_timefmt->string
|
||||||
&& sv_timestamps->int_val && !pending)
|
&& sv_timestamps->int_val && !pending)
|
||||||
|
@ -223,17 +230,17 @@ SV_Print (const char *fmt, va_list args)
|
||||||
local = localtime (&mytime);
|
local = localtime (&mytime);
|
||||||
strftime (msg3, sizeof (msg3), sv_timefmt->string, local);
|
strftime (msg3, sizeof (msg3), sv_timefmt->string, local);
|
||||||
|
|
||||||
snprintf (msg2, sizeof (msg2), "%s%s", msg3, msg);
|
dsprintf (msg2, "%s%s", msg3, msg->str);
|
||||||
} else {
|
} else {
|
||||||
snprintf (msg2, sizeof (msg2), "%s", msg);
|
dsprintf (msg2, "%s", msg->str);
|
||||||
}
|
}
|
||||||
if (msg2[strlen (msg2) - 1] != '\n') {
|
if (msg2->str[strlen (msg2->str) - 1] != '\n') {
|
||||||
pending = 1;
|
pending = 1;
|
||||||
} else {
|
} else {
|
||||||
pending = 0;
|
pending = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Con_Printf ("%s", msg2); // also echo to debugging console
|
Con_Printf ("%s", msg2->str); // also echo to debugging console
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,13 +117,12 @@ Team_BestWeaponImpulse (void)
|
||||||
in_impulse = best;
|
in_impulse = best;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//FIXME slow use of dstring
|
||||||
const char *
|
const char *
|
||||||
Team_ParseSay (const char *s)
|
Team_ParseSay (dstring_t *buf, const char *s)
|
||||||
{
|
{
|
||||||
char chr, t2[128], t3[128];
|
char chr, t2[128], t3[2];
|
||||||
const char *t1;
|
const char *t1;
|
||||||
static char buf[1024];
|
|
||||||
size_t i, bracket;
|
size_t i, bracket;
|
||||||
static location_t *location = NULL;
|
static location_t *location = NULL;
|
||||||
|
|
||||||
|
@ -213,8 +212,9 @@ Team_ParseSay (const char *s)
|
||||||
|
|
||||||
snprintf (t2, sizeof (t2), "%sa:%i", t3,
|
snprintf (t2, sizeof (t2), "%sa:%i", t3,
|
||||||
cl.stats[STAT_ARMOR]);
|
cl.stats[STAT_ARMOR]);
|
||||||
} else
|
} else {
|
||||||
snprintf (t2, sizeof (t2), "%i", cl.stats[STAT_ARMOR]);
|
snprintf (t2, sizeof (t2), "%i", cl.stats[STAT_ARMOR]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
bracket = 0;
|
bracket = 0;
|
||||||
|
@ -254,29 +254,24 @@ Team_ParseSay (const char *s)
|
||||||
t1 = t2;
|
t1 = t2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bracket)
|
if (bracket) {
|
||||||
buf[i++] = 0x90; // '['
|
dstring_appendstr (buf, "\x90"); // '['
|
||||||
|
|
||||||
if (t1) {
|
|
||||||
int len;
|
|
||||||
|
|
||||||
len = strlen (t1);
|
|
||||||
if (i + len >= sizeof (buf))
|
|
||||||
continue; // No more space in buffer, icky.
|
|
||||||
strncpy (buf + i, t1, len);
|
|
||||||
i += len;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bracket)
|
if (t1) {
|
||||||
buf[i++] = 0x91; // ']'
|
dstring_appendstr (buf, t1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bracket) {
|
||||||
|
dstring_appendstr (buf, "\x91"); // ']'
|
||||||
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
buf[i++] = *s++;
|
dstring_appendsubstr (buf, s++, 1);
|
||||||
}
|
}
|
||||||
buf[i] = 0;
|
|
||||||
|
|
||||||
return buf;
|
return buf->str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "QF/dstring.h"
|
||||||
#include "QF/image.h"
|
#include "QF/image.h"
|
||||||
#include "QF/pcx.h"
|
#include "QF/pcx.h"
|
||||||
#include "QF/qendian.h"
|
#include "QF/qendian.h"
|
||||||
|
@ -42,8 +43,8 @@
|
||||||
tex_t *image;
|
tex_t *image;
|
||||||
dsprite_t sprite;
|
dsprite_t sprite;
|
||||||
byte *lumpbuffer, *plump;
|
byte *lumpbuffer, *plump;
|
||||||
char spritedir[1024];
|
dstring_t *spritedir;
|
||||||
char spriteoutname[1024];
|
dstring_t *spriteoutname;
|
||||||
int framesmaxs[2];
|
int framesmaxs[2];
|
||||||
int framecount;
|
int framecount;
|
||||||
|
|
||||||
|
@ -444,7 +445,7 @@ Cmd_Spritename (void)
|
||||||
FinishSprite ();
|
FinishSprite ();
|
||||||
|
|
||||||
Script_GetToken (&scr, false);
|
Script_GetToken (&scr, false);
|
||||||
sprintf (spriteoutname, "%s%s.spr", spritedir, Script_Token (&scr));
|
dsprintf (spriteoutname, "%s%s.spr", spritedir->str, Script_Token (&scr));
|
||||||
memset (&sprite, 0, sizeof(sprite));
|
memset (&sprite, 0, sizeof(sprite));
|
||||||
framecount = 0;
|
framecount = 0;
|
||||||
|
|
||||||
|
@ -472,14 +473,14 @@ FinishSprite (void)
|
||||||
if (sprite.numframes == 0)
|
if (sprite.numframes == 0)
|
||||||
Sys_Error ("no frames\n");
|
Sys_Error ("no frames\n");
|
||||||
|
|
||||||
if (!strlen(spriteoutname))
|
if (!spriteoutname->str)
|
||||||
Sys_Error ("Didn't name sprite file");
|
Sys_Error ("Didn't name sprite file");
|
||||||
|
|
||||||
if ((plump - lumpbuffer) > MAX_BUFFER_SIZE)
|
if ((plump - lumpbuffer) > MAX_BUFFER_SIZE)
|
||||||
Sys_Error ("Sprite package too big; increase MAX_BUFFER_SIZE");
|
Sys_Error ("Sprite package too big; increase MAX_BUFFER_SIZE");
|
||||||
|
|
||||||
spriteouthandle = Qopen (spriteoutname, "wb");
|
spriteouthandle = Qopen (spriteoutname->str, "wb");
|
||||||
printf ("saving in %s\n", spriteoutname);
|
printf ("saving in %s\n", spriteoutname->str);
|
||||||
WriteSprite (spriteouthandle);
|
WriteSprite (spriteouthandle);
|
||||||
Qclose (spriteouthandle);
|
Qclose (spriteouthandle);
|
||||||
|
|
||||||
|
@ -487,7 +488,7 @@ FinishSprite (void)
|
||||||
printf ("%d frame(s)\n", sprite.numframes);
|
printf ("%d frame(s)\n", sprite.numframes);
|
||||||
printf ("%d ungrouped frame(s), including group headers\n", framecount);
|
printf ("%d ungrouped frame(s), including group headers\n", framecount);
|
||||||
|
|
||||||
spriteoutname[0] = 0; // clear for a new sprite
|
dstring_clearstr (spriteoutname); // clear for a new sprite
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -505,6 +506,9 @@ int main (int argc, char **argv)
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
Sys_Error ("usage: spritegen file.qc");
|
Sys_Error ("usage: spritegen file.qc");
|
||||||
|
|
||||||
|
spritedir = dstring_newstr ();
|
||||||
|
spriteoutname = dstring_newstr ();
|
||||||
|
|
||||||
i = 1;
|
i = 1;
|
||||||
|
|
||||||
//SetQdirFromPath (argv[i]);
|
//SetQdirFromPath (argv[i]);
|
||||||
|
|
Loading…
Reference in a new issue