setsize -> shrink

setsizenodelete -> setsize
deletecontentsa -> deletearrays
deletecontentsp -> deletecontents
vrealloc -> growbuf



git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4787 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2010-03-11 23:06:26 +00:00
parent a971c0b5ab
commit be94c703f2
28 changed files with 85 additions and 85 deletions
+5 -5
View File
@@ -232,9 +232,9 @@ void audiomanager::soundcleanup()
// destroy consuming code
stopsound();
DELETEP(gamemusic);
mapsounds.setsize(0);
locations.deletecontentsp();
gamesounds.setsize(0);
mapsounds.shrink(0);
locations.deletecontents();
gamesounds.shrink(0);
bufferpool.clear();
// kill scheduler
@@ -250,13 +250,13 @@ void audiomanager::soundcleanup()
void audiomanager::clearworldsounds(bool fullclean)
{
stopsound();
if(fullclean) mapsounds.setsize(0);
if(fullclean) mapsounds.shrink(0);
locations.deleteworldobjsounds();
}
void audiomanager::mapsoundreset()
{
mapsounds.setsize(0);
mapsounds.shrink(0);
locations.deleteworldobjsounds();
}
+1 -1
View File
@@ -545,7 +545,7 @@ void gets2c() // get updates from the server
cvector securemaps;
void resetsecuremaps() { securemaps.deletecontentsa(); }
void resetsecuremaps() { securemaps.deletearrays(); }
void securemap(char *map) { if(map) securemaps.add(newstring(map)); }
bool securemapcheck(const char *map, bool msg)
{
+2 -2
View File
@@ -445,7 +445,7 @@ void addsleep_(char *msec, char *cmd)
void resetsleep()
{
loopv(sleeps) DELETEA(sleeps[i].cmd);
sleeps.setsize(0);
sleeps.shrink(0);
}
COMMANDN(sleep, addsleep_, ARG_2STR);
@@ -1152,7 +1152,7 @@ void *kickmenu = NULL, *banmenu = NULL, *forceteammenu = NULL, *giveadminmenu =
void refreshsopmenu(void *menu, bool init)
{
menureset(menu);
mlines.setsize(0);
mlines.shrink(0);
mlines.reserve(players.length());
loopv(players) if(players[i])
{
+1 -1
View File
@@ -604,7 +604,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p)
case SV_DISCSCORES:
{
discscores.setsize(0);
discscores.shrink(0);
int team;
while((team = getint(p)) >= 0)
{
+2 -2
View File
@@ -522,7 +522,7 @@ struct completeval
vector<char *> list;
completeval(int type, const char *dir, const char *ext) : type(type), dir(dir && dir[0] ? newstring(dir) : NULL), ext(ext && ext[0] ? newstring(ext) : NULL) {}
~completeval() { DELETEA(dir); DELETEA(ext); dirlist.deletecontentsa(); list.deletecontentsa(); }
~completeval() { DELETEA(dir); DELETEA(ext); dirlist.deletearrays(); list.deletearrays(); }
};
static inline bool htcmp(const completekey &x, const completekey &y)
@@ -627,7 +627,7 @@ void commandcomplete(char *s)
}
if(init && cdata && cdata->type==COMPLETE_FILE)
{
cdata->list.deletecontentsa();
cdata->list.deletearrays();
loopv(cdata->dirlist) listfiles(cdata->dirlist[i], cdata->ext, cdata->list);
}
+2 -2
View File
@@ -594,7 +594,7 @@ int msectionsort(const msection *a, const msection *b)
void renderdocsection(void *menu, bool init)
{
static vector<msection> msections;
msections.setsize(0);
msections.shrink(0);
loopv(sections)
{
@@ -618,7 +618,7 @@ struct maction { string cmd; };
void renderdocmenu(void *menu, bool init)
{
static vector<maction> actions;
actions.setsize(0);
actions.shrink(0);
menureset(menu);
loopv(sections)
{
+1 -1
View File
@@ -600,7 +600,7 @@ static void checkmousemotion(int &dx, int &dy)
dx += event.motion.xrel;
dy += event.motion.yrel;
}
events.setsizenodelete(0);
events.setsize(0);
SDL_Event event;
while(SDL_PollEvent(&event))
{
+1 -1
View File
@@ -43,7 +43,7 @@ struct md2 : vertmodel
int numvertex = *command++;
bool isfan = numvertex<0;
if(isfan) numvertex = -numvertex;
idxs.setsizenodelete(0);
idxs.setsize(0);
loopi(numvertex)
{
union { int i; float f; } u, v;
+5 -5
View File
@@ -176,7 +176,7 @@ struct mitemmanual : mitem
if(result >= 0 && oldmenu == curmenu)
{
menuset(NULL, false);
menustack.setsize(0);
menustack.shrink(0);
}
}
}
@@ -634,7 +634,7 @@ void newmenu(char *name, char *hotkeys, char *forwardkeys)
void menureset(void *menu)
{
gmenu &m = *(gmenu *)menu;
m.items.deletecontentsp();
m.items.deletecontents();
}
void menumanual(void *menu, char *text, char *action, color *bgcolor, const char *desc)
@@ -1002,7 +1002,7 @@ void gmenu::init()
{
if(dirlist)
{
items.deletecontentsp();
items.deletecontents();
cvector files;
listfiles(dirlist->dir, dirlist->ext, files);
files.sort(stringsort);
@@ -1133,7 +1133,7 @@ void addchange(const char *desc, int type)
void clearchanges(int type)
{
if(type!=CHANGE_GFX) return;
needsapply.setsize(0);
needsapply.shrink(0);
closemenu("apply");
}
@@ -1141,7 +1141,7 @@ void refreshapplymenu(void *menu, bool init)
{
gmenu *m = (gmenu *) menu;
if(!m || (!init && needsapply.length() != m->items.length()-3)) return;
m->items.deletecontentsp();
m->items.deletecontents();
loopv(needsapply) m->items.add(new mitemtext(m, newstring(needsapply[i]), NULL, NULL, NULL));
m->items.add(new mitemtext(m, newstring(""), NULL, NULL, NULL));
m->items.add(new mitemtext(m, newstring("Yes"), newstring("resetgl"), NULL, NULL));
+1 -1
View File
@@ -170,7 +170,7 @@ struct gmenu
DELETEA(mdl);
DELETEP(dirlist);
DELETEA(initaction);
items.deletecontentsp();
items.deletecontents();
}
void render();
+7 -7
View File
@@ -40,8 +40,8 @@ extern int ati_mda_bug;
{ \
if(hasMDA && !ati_mda_bug) glMultiDrawArrays_(type, strips.first.getbuf(), strips.count.getbuf(), strips.first.length()); \
else loopv(strips.first) glDrawArrays(type, strips.first[i], strips.count[i]); \
strips.first.setsizenodelete(0); \
strips.count.setsizenodelete(0); \
strips.first.setsize(0); \
strips.count.setsize(0); \
}
void renderstripssky()
@@ -202,7 +202,7 @@ void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l4, sqr
&& abs(ol1g-l3->g)<lighterr && abs(ol2g-l4->g)<lighterr
&& abs(ol1b-l3->b)<lighterr && abs(ol2b-l4->b)<lighterr) || !wtex)
{
verts.setsizenodelete(verts.length()-2);
verts.setsize(verts.length()-2);
nquads--;
}
else
@@ -359,7 +359,7 @@ void render_square(int wtex, float floor1, float floor2, float ceil1, float ceil
if((!hf && !ohf)
&& ((abs(ol1r-l2->r)<lighterr && abs(ol1g-l2->g)<lighterr && abs(ol1b-l2->b)<lighterr) || !wtex)) // skip vertices if light values are close enough
{
verts.setsizenodelete(verts.length()-2);
verts.setsize(verts.length()-2);
nquads--;
}
else
@@ -393,7 +393,7 @@ void render_square(int wtex, float floor1, float floor2, float ceil1, float ceil
void resetcubes()
{
verts.setsizenodelete(0);
verts.setsize(0);
striptype = 0;
nquads = 0;
@@ -409,7 +409,7 @@ vector<shadowvertex> shadowverts;
static void resetshadowverts()
{
shadowverts.setsizenodelete(0);
shadowverts.setsize(0);
striptype = 0;
}
@@ -484,7 +484,7 @@ static void rendershadow_flat(int x, int y, int h) // floor quads
}
else // continue strip
{
shadowverts.setsizenodelete(shadowverts.length()-2);
shadowverts.setsize(shadowverts.length()-2);
}
shadowvert(x+1, y+1, h);
+3 -3
View File
@@ -92,7 +92,7 @@ void mapmodel(char *rad, char *h, char *zoff, char *snap, char *name)
void mapmodelreset()
{
if(execcontext==IEXC_MAPCFG) mapmodels.setsize(0);
if(execcontext==IEXC_MAPCFG) mapmodels.shrink(0);
}
mapmodelinfo &getmminfo(int i) { return mapmodels.inrange(i) ? mapmodels[i] : *(mapmodelinfo *)0; }
@@ -167,7 +167,7 @@ static int numbatches = -1;
void startmodelbatches()
{
numbatches = 0;
modelattached.setsizenodelete(0);
modelattached.setsize(0);
}
batchedmodel &addbatchedmodel(model *m)
@@ -179,7 +179,7 @@ batchedmodel &addbatchedmodel(model *m)
if(numbatches<batches.length())
{
b = batches[numbatches];
b->batched.setsizenodelete(0);
b->batched.setsize(0);
}
else b = batches.add(new modelbatch);
b->m = m;
+1 -1
View File
@@ -20,7 +20,7 @@ void newfont(char *name, char *tex, char *defaultw, char *defaulth, char *offset
}
f->tex = textureload(tex);
f->chars.setsize(0);
f->chars.shrink(0);
f->defaultw = ATOI(defaultw);
f->defaulth = ATOI(defaulth);
f->offsetx = ATOI(offsetx);
+1 -1
View File
@@ -154,7 +154,7 @@ void renderscores(void *menu, bool init)
modeline[0] = '\0';
serverline[0] = '\0';
scorelines.setsize(0);
scorelines.shrink(0);
vector<playerent *> scores;
if(!watchingdemo) scores.add(player1);
+11 -11
View File
@@ -155,7 +155,7 @@ bool buildworldstate()
if(!packet->referenceCount) enet_packet_destroy(packet);
else { ++ws.uses; packet->freeCallback = cleanworldstate; }
}
c.position.setsizenodelete(0);
c.position.setsize(0);
if(msize && (pkt[i].msgoff<0 || msize-pkt[i].msglen>0))
{
@@ -166,7 +166,7 @@ bool buildworldstate()
if(!packet->referenceCount) enet_packet_destroy(packet);
else { ++ws.uses; packet->freeCallback = cleanworldstate; }
}
c.messages.setsizenodelete(0);
c.messages.setsize(0);
}
reliablemessages = false;
if(!ws.uses)
@@ -511,7 +511,7 @@ static void cleardemos(int n)
if(!n)
{
loopv(demofiles) delete[] demofiles[i].data;
demofiles.setsize(0);
demofiles.shrink(0);
sendservmsg("cleared all demos");
}
else if(demofiles.inrange(n-1))
@@ -944,7 +944,7 @@ void distributeteam(int team)
int numsp = team == 100 ? smapstats.spawns[2] : smapstats.spawns[team];
if(!numsp) numsp = 30; // no spawns: try to distribute anyway
twoint ti;
tdistrib.setsize(0);
tdistrib.shrink(0);
loopv(clients) if(clients[i]->type!=ST_EMPTY)
{
if(team == 100 || team == clients[i]->team)
@@ -954,7 +954,7 @@ void distributeteam(int team)
}
}
tdistrib.sort(cmpscore); // random player order
sdistrib.setsize(0);
sdistrib.shrink(0);
loopi(numsp)
{
ti.index = i;
@@ -1320,7 +1320,7 @@ void serverdamage(client *target, client *actor, int damage, int gun, bool gib,
actor->state.flagscore--;
sendf(-1, 1, "riii", SV_FLAGCNT, actor->clientnum, actor->state.flagscore);
}
target->position.setsizenodelete(0);
target->position.setsize(0);
ts.state = CS_DEAD;
ts.lastdeath = gamemillis;
if(!suic) logline(ACLOG_INFO, "[%s] %s %s%s %s", actor->hostname, actor->name, gib ? (gun==GUN_GRENADE?"splattered":"gibbed") : "fragged", tk ? " his teammate" : "", target->name);
@@ -1493,7 +1493,7 @@ void shuffleteams(int ftr = FTR_AUTOTEAM)
}
else
{ // skill sorted
shuffle.setsize(0);
shuffle.shrink(0);
sums /= 4 * numplayers + 2;
team = rnd(2);
loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->isonrightmap && !team_isspect(clients[i]->team))
@@ -1601,12 +1601,12 @@ void resetserver(const char *newname, int newmode, int newtime)
interm = 0;
if(!laststatus) laststatus = servmillis-61*1000;
lastfillup = servmillis;
sents.setsize(0);
sents.shrink(0);
if(mastermode == MM_PRIVATE)
{
loopv(savedscores) savedscores[i].valid = false;
}
else savedscores.setsize(0);
else savedscores.shrink(0);
ctfreset();
nextmapname[0] = '\0';
@@ -2603,7 +2603,7 @@ void process(ENetPacket *packet, int sender, int chan)
if(!cl->isonrightmap) break;
if(cl->type==ST_TCPIP && (cl->state.state==CS_ALIVE || cl->state.state==CS_EDITING))
{
cl->position.setsizenodelete(0);
cl->position.setsize(0);
while(curmsg<p.length()) cl->position.add(p.buf[curmsg++]);
}
if(maplayout && !m_demo && !m_coop) checkclientpos(cl);
@@ -2644,7 +2644,7 @@ void process(ENetPacket *packet, int sender, int chan)
cl->state.o[2] = zt / DMF;
if(cl->type==ST_TCPIP && (cl->state.state==CS_ALIVE || cl->state.state==CS_EDITING))
{
cl->position.setsizenodelete(0);
cl->position.setsize(0);
while(curmsg<p.length()) cl->position.add(p.buf[curmsg++]);
}
if(maplayout && !m_demo && !m_coop) checkclientpos(cl);
+3 -3
View File
@@ -239,7 +239,7 @@ struct client // server side version of "dynent" type
void mapchange(bool getmap = false)
{
state.reset();
events.setsizenodelete(0);
events.setsize(0);
overflow = 0;
timesync = false;
isonrightmap = false;
@@ -261,8 +261,8 @@ struct client // server side version of "dynent" type
bottomRTT = ping = 9999;
team = TEAM_SPECT;
loopi(2) skin[i] = 0;
position.setsizenodelete(0);
messages.setsizenodelete(0);
position.setsize(0);
messages.setsize(0);
isauthed = haswelcome = false;
role = CR_DEFAULT;
lastvotecall = 0;
+1 -1
View File
@@ -187,7 +187,7 @@ struct banaction : playeraction
struct removebansaction : serveraction
{
void perform() { bans.setsize(0); }
void perform() { bans.shrink(0); }
removebansaction()
{
role = roleconf('B');
+6 -6
View File
@@ -101,8 +101,8 @@ void resolverclear()
if(resolverthreads.empty()) return;
SDL_LockMutex(resolvermutex);
resolverqueries.setsize(0);
resolverresults.setsize(0);
resolverqueries.shrink(0);
resolverresults.shrink(0);
loopv(resolverthreads)
{
resolverthread &rt = resolverthreads[i];
@@ -501,13 +501,13 @@ void checkpings()
{
switch(query)
{
#define RESETINFOLINES() si->infotexts.setsizenodelete(0); \
#define RESETINFOLINES() si->infotexts.setsize(0); \
ucharbuf q(si->textdata, sizeof(si->textdata))
#define ADDINFOLINE(msg) si->infotexts.add((char *)si->textdata + q.length()); \
sendstring(msg, q)
case EXTPING_NAMELIST:
{
si->playernames.setsizenodelete(0);
si->playernames.setsize(0);
ucharbuf q(si->namedata, sizeof(si->namedata));
loopi(si->numplayers)
{
@@ -884,7 +884,7 @@ bool assignserverfavourites()
{
int alxn[FC_NUM];
const char *alx[FC_NUM], *sep = " \t\n\r";
favcattags.setsizenodelete(0);
favcattags.setsize(0);
bool res = false;
loopv(servers) { servers[i]->favcat = -1; servers[i]->weight = 0; }
loopvj(favcats)
@@ -1265,7 +1265,7 @@ bool serverinfokey(void *menu, int code, bool isdown, int unicode)
void clearservers()
{
resolverclear();
servers.deletecontentsp();
servers.deletecontents();
}
VARP(masterupdatefrequency, 1, 60*60, 24*60*60);
+6 -6
View File
@@ -243,7 +243,7 @@ struct servermaprot : serverconfigfile
void read()
{
if(getfilesize(filename) == filelen) return;
configsets.setsize(0);
configsets.shrink(0);
if(!load()) return;
const char *sep = ": ";
@@ -337,7 +337,7 @@ struct serveripblacklist : serverconfigfile
void read()
{
if(getfilesize(filename) == filelen) return;
ipranges.setsize(0);
ipranges.shrink(0);
if(!load()) return;
iprange ir;
@@ -409,11 +409,11 @@ struct servernickblacklist : serverconfigfile
void destroylists()
{
whitelistranges.setsizenodelete(0);
whitelistranges.setsize(0);
enumeratek(whitelist, const char *, key, delete key);
whitelist.clear(false);
blfraglist.deletecontentsp();
blacklines.setsizenodelete(0);
blfraglist.deletecontents();
blacklines.setsize(0);
}
void read()
@@ -598,7 +598,7 @@ struct serverpasswords : serverconfigfile
void read()
{
if(getfilesize(filename) == filelen) return;
adminpwds.setsize(staticpasses);
adminpwds.shrink(staticpasses);
if(!load()) return;
pwddetail c;
+1 -1
View File
@@ -53,7 +53,7 @@ void sourcescheduler::init(int numsoundchannels)
void sourcescheduler::reset()
{
loopv(sources) sources[i]->reset();
sources.deletecontentsp();
sources.deletecontents();
}
// returns a free sound source (channel)
+1 -1
View File
@@ -385,7 +385,7 @@ struct Slot
vector<Slot> slots;
void texturereset() { slots.setsizenodelete(0); }
void texturereset() { slots.setsize(0); }
void texture(char *aframe, char *name)
{
+12 -12
View File
@@ -322,33 +322,33 @@ template <class T> struct vector
*this = v;
}
~vector() { setsize(0); if(buf) delete[] (uchar *)buf; }
~vector() { shrink(0); if(buf) delete[] (uchar *)buf; }
vector<T> &operator=(const vector<T> &v)
{
setsize(0);
if(v.length() > alen) vrealloc(v.length());
shrink(0);
if(v.length() > alen) growbuf(v.length());
loopv(v) add(v[i]);
return *this;
}
T &add(const T &x)
{
if(ulen==alen) vrealloc(ulen+1);
if(ulen==alen) growbuf(ulen+1);
new (&buf[ulen]) T(x);
return buf[ulen++];
}
T &add()
{
if(ulen==alen) vrealloc(ulen+1);
if(ulen==alen) growbuf(ulen+1);
new (&buf[ulen]) T;
return buf[ulen++];
}
T &dup()
{
if(ulen==alen) vrealloc(ulen+1);
if(ulen==alen) growbuf(ulen+1);
new (&buf[ulen]) T(buf[ulen-1]);
return buf[ulen++];
}
@@ -365,11 +365,11 @@ template <class T> struct vector
T &operator[](int i) { ASSERT(i>=0 && i<ulen); return buf[i]; }
const T &operator[](int i) const { ASSERT(i >= 0 && i<ulen); return buf[i]; }
void setsize(int i) { ASSERT(i<=ulen); while(ulen>i) drop(); }
void setsizenodelete(int i) { ASSERT(i<=ulen); ulen = i; }
void shrink(int i) { ASSERT(i<=ulen); while(ulen>i) drop(); }
void setsize(int i) { ASSERT(i<=ulen); ulen = i; }
void deletecontentsp() { while(!empty()) delete pop(); }
void deletecontentsa() { while(!empty()) delete[] pop(); }
void deletecontents() { while(!empty()) delete pop(); }
void deletearrays() { while(!empty()) delete[] pop(); }
T *getbuf() { return buf; }
const T *getbuf() const { return buf; }
@@ -387,7 +387,7 @@ template <class T> struct vector
return (T *) bsearch(key, &buf[i], n<0 ? ulen : n, sizeof(T), (int (__cdecl *)(const void *,const void *))cf);
}
void vrealloc(int sz)
void growbuf(int sz)
{
int olen = alen;
if(!alen) alen = max(MINSIZE, sz);
@@ -404,7 +404,7 @@ template <class T> struct vector
databuf<T> reserve(int sz)
{
if(ulen+sz > alen) vrealloc(ulen+sz);
if(ulen+sz > alen) growbuf(ulen+sz);
return databuf<T>(&buf[ulen], sz);
}
+2 -2
View File
@@ -77,7 +77,7 @@ struct tristrip
void findconnectivity()
{
hashtable<edge, ushort> edges;
nodes.setsizenodelete(0);
nodes.setsize(0);
loopv(triangles)
{
triangle &tri = triangles[i];
@@ -109,7 +109,7 @@ struct tristrip
}
}
}
loopi(4) connectivity[i].setsizenodelete(0);
loopi(4) connectivity[i].setsize(0);
loopv(triangles) connectivity[triangles[i].numlinks()].add(i);
if(dbgts) conoutf("no connections: %d", connectivity[0].length());
}
+3 -3
View File
@@ -316,7 +316,7 @@ struct vertmodel : model
else d->prev.fr1 = -1;
static vector<uchar> side;
side.setsizenodelete(0);
side.setsize(0);
loopi(numtris)
{
@@ -653,7 +653,7 @@ struct vertmodel : model
virtual ~part()
{
DELETEA(filename);
meshes.deletecontentsp();
meshes.deletecontents();
DELETEA(anims);
DELETEA(links);
DELETEA(tags);
@@ -1213,7 +1213,7 @@ struct vertmodel : model
~vertmodel()
{
delete[] loadname;
parts.deletecontentsp();
parts.deletecontents();
}
char *name() { return loadname; }
+3 -3
View File
@@ -735,7 +735,7 @@ void grenadeent::explode()
if(nadestate!=NS_ACTIVATED && nadestate!=NS_THROWED ) return;
nadestate = NS_EXPLODED;
static vec n(0,0,0);
hits.setsizenodelete(0);
hits.setsize(0);
splash();
if(local)
addmsg(SV_EXPLODE, "ri3iv", lastmillis, GUN_GRENADE, millis, // fixme
@@ -993,7 +993,7 @@ bool gun::attack(vec &targ)
attackphysics(from, to);
hits.setsizenodelete(0);
hits.setsize(0);
raydamage(from, to, owner);
attackfx(from, to, 0);
@@ -1199,7 +1199,7 @@ bool knife::attack(vec &targ)
to = from;
to.add(unitv);
hits.setsizenodelete(0);
hits.setsize(0);
raydamage(from, to, owner);
attackfx(from, to, 0);
sendshoot(from, to);
+1 -1
View File
@@ -464,7 +464,7 @@ bool empty_world(int factor, bool force) // main empty world creation routine
setwatercolor();
loopi(sizeof(hdr.reserved)/sizeof(hdr.reserved[0])) hdr.reserved[i] = 0;
loopk(3) loopi(256) hdr.texlists[k][i] = i;
ents.setsize(0);
ents.shrink(0);
block b = { 8, 8, ssize-16, ssize-16 };
edittypexy(SPACE, b);
}
+1 -1
View File
@@ -488,7 +488,7 @@ bool load_world(char *mname) // still supports all map formats that have
//else conoutf("this map works with the vanilla release");
// TODO: output the requirements into a file for easy user-retrieval & -action - needs a base-URL where we will hold the mediapacks
}
ents.setsize(0);
ents.shrink(0);
loopi(3) numspawn[i] = 0;
loopi(2) numflagspawn[i] = 0;
loopi(hdr.numents)
+1 -1
View File
@@ -256,7 +256,7 @@ void adddynlight(physent *owner, const vec &o, int reach, int expire, int fade,
void cleardynlights()
{
loopv(dlights) freeblock(dlights[i].area);
dlights.setsize(0);
dlights.shrink(0);
}
void removedynlights(physent *owner)