* Removed some useless memset calls onto newly hunk allocated memory.

Hunk_Alloc() already clears the memory before returning it.
* Some minor cleanups.

git-svn-id: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@465 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2011-07-05 06:28:42 +00:00
parent b6913f5348
commit 55cc159297
2 changed files with 33 additions and 39 deletions

View file

@ -1782,30 +1782,28 @@ typedef struct
short x, y; short x, y;
} floodfill_t; } floodfill_t;
extern unsigned d_8to24table[];
// must be a power of 2 // must be a power of 2
#define FLOODFILL_FIFO_SIZE 0x1000 #define FLOODFILL_FIFO_SIZE 0x1000
#define FLOODFILL_FIFO_MASK (FLOODFILL_FIFO_SIZE - 1) #define FLOODFILL_FIFO_MASK (FLOODFILL_FIFO_SIZE - 1)
#define FLOODFILL_STEP( off, dx, dy ) \ #define FLOODFILL_STEP( off, dx, dy ) \
{ \ do { \
if (pos[off] == fillcolor) \ if (pos[off] == fillcolor) \
{ \ { \
pos[off] = 255; \ pos[off] = 255; \
fifo[inpt].x = x + (dx), fifo[inpt].y = y + (dy); \ fifo[inpt].x = x + (dx), fifo[inpt].y = y + (dy); \
inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; \ inpt = (inpt + 1) & FLOODFILL_FIFO_MASK; \
} \ } \
else if (pos[off] != 255) fdc = pos[off]; \ else if (pos[off] != 255) fdc = pos[off]; \
} } while (0)
void Mod_FloodFillSkin( byte *skin, int skinwidth, int skinheight ) void Mod_FloodFillSkin( byte *skin, int skinwidth, int skinheight )
{ {
byte fillcolor = *skin; // assume this is the pixel to fill byte fillcolor = *skin; // assume this is the pixel to fill
floodfill_t fifo[FLOODFILL_FIFO_SIZE]; floodfill_t fifo[FLOODFILL_FIFO_SIZE];
int inpt = 0, outpt = 0; int inpt = 0, outpt = 0;
int filledcolor = -1; int filledcolor = -1;
int i; int i;
if (filledcolor == -1) if (filledcolor == -1)
{ {
@ -1852,13 +1850,13 @@ Mod_LoadAllSkins
*/ */
void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype) void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype)
{ {
int i, j, k, size, groupskins; int i, j, k, size, groupskins;
char name[32]; char name[32];
byte *skin, *texels; byte *skin, *texels;
daliasskingroup_t *pinskingroup; daliasskingroup_t *pinskingroup;
daliasskininterval_t *pinskinintervals; daliasskininterval_t *pinskinintervals;
char fbr_mask_name[64]; //johnfitz -- added for fullbright support char fbr_mask_name[64]; //johnfitz -- added for fullbright support
src_offset_t offset; //johnfitz src_offset_t offset; //johnfitz
skin = (byte *)(pskintype + 1); skin = (byte *)(pskintype + 1);
@ -2231,9 +2229,6 @@ void * Mod_LoadSpriteFrame (void * pin, mspriteframe_t **ppframe, int framenum)
size = width * height; size = width * height;
pspriteframe = (mspriteframe_t *) Hunk_AllocName (sizeof (mspriteframe_t),loadname); pspriteframe = (mspriteframe_t *) Hunk_AllocName (sizeof (mspriteframe_t),loadname);
Q_memset (pspriteframe, 0, sizeof (mspriteframe_t));
*ppframe = pspriteframe; *ppframe = pspriteframe;
pspriteframe->width = width; pspriteframe->width = width;
@ -2254,8 +2249,9 @@ void * Mod_LoadSpriteFrame (void * pin, mspriteframe_t **ppframe, int framenum)
sprintf (name, "%s:frame%i", loadmodel->name, framenum); sprintf (name, "%s:frame%i", loadmodel->name, framenum);
offset = (src_offset_t)(pinframe+1) - (src_offset_t)mod_base; //johnfitz offset = (src_offset_t)(pinframe+1) - (src_offset_t)mod_base; //johnfitz
pspriteframe->gltexture = pspriteframe->gltexture =
TexMgr_LoadImage (loadmodel, name, width, height, SRC_INDEXED, (byte *)(pinframe + 1), TexMgr_LoadImage (loadmodel, name, width, height, SRC_INDEXED,
loadmodel->name, offset, TEXPREF_PAD | TEXPREF_ALPHA | TEXPREF_NOPICMIP); //johnfitz -- TexMgr (byte *)(pinframe + 1), loadmodel->name, offset,
TEXPREF_PAD | TEXPREF_ALPHA | TEXPREF_NOPICMIP); //johnfitz -- TexMgr
return (void *)((byte *)pinframe + sizeof (dspriteframe_t) + size); return (void *)((byte *)pinframe + sizeof (dspriteframe_t) + size);
} }
@ -2376,14 +2372,12 @@ void Mod_LoadSpriteModel (model_t *mod, void *buffer)
if (frametype == SPR_SINGLE) if (frametype == SPR_SINGLE)
{ {
pframetype = (dspriteframetype_t *) pframetype = (dspriteframetype_t *)
Mod_LoadSpriteFrame (pframetype + 1, Mod_LoadSpriteFrame (pframetype + 1, &psprite->frames[i].frameptr, i);
&psprite->frames[i].frameptr, i);
} }
else else
{ {
pframetype = (dspriteframetype_t *) pframetype = (dspriteframetype_t *)
Mod_LoadSpriteGroup (pframetype + 1, Mod_LoadSpriteGroup (pframetype + 1, &psprite->frames[i].frameptr, i);
&psprite->frames[i].frameptr, i);
} }
} }

View file

@ -26,14 +26,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.h" #include "quakedef.h"
#include "net_defs.h" /* for struct qsocket_s details */ #include "net_defs.h" /* for struct qsocket_s details */
server_t sv; server_t sv;
server_static_t svs; server_static_t svs;
char localmodels[MAX_MODELS][8]; // inline model names for precache static char localmodels[MAX_MODELS][8]; // inline model names for precache
int sv_protocol = PROTOCOL_FITZQUAKE; //johnfitz int sv_protocol = PROTOCOL_FITZQUAKE; //johnfitz
extern qboolean pr_alpha_supported; //johnfitz extern qboolean pr_alpha_supported; //johnfitz
//============================================================================ //============================================================================
@ -1315,10 +1315,9 @@ void SV_SpawnServer (const char *server)
// //
// set up the new server // set up the new server
// //
//memset (&sv, 0, sizeof(sv));
Host_ClearMemory (); Host_ClearMemory ();
memset (&sv, 0, sizeof(sv));
strcpy (sv.name, server); strcpy (sv.name, server);
sv.protocol = sv_protocol; // johnfitz sv.protocol = sv_protocol; // johnfitz
@ -1327,6 +1326,7 @@ void SV_SpawnServer (const char *server)
PR_LoadProgs (); PR_LoadProgs ();
// allocate server memory // allocate server memory
/* Host_ClearMemory() called above already cleared the whole sv structure */
sv.max_edicts = CLAMP (MIN_EDICTS,(int)max_edicts.value,MAX_EDICTS); //johnfitz -- max_edicts cvar sv.max_edicts = CLAMP (MIN_EDICTS,(int)max_edicts.value,MAX_EDICTS); //johnfitz -- max_edicts cvar
sv.edicts = (edict_t *) Hunk_AllocName (sv.max_edicts*pr_edict_size, "edicts"); sv.edicts = (edict_t *) Hunk_AllocName (sv.max_edicts*pr_edict_size, "edicts");