registersound fix, + new "showgrid" variable

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6729 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lucas GAUTHERON
2011-12-10 18:03:04 +00:00
parent 3746c0a430
commit 37efdcdb3e
2 changed files with 47 additions and 38 deletions
+15 -10
View File
@@ -193,10 +193,24 @@ void audiomanager::registermusic(char *name)
musics.add(newstring(name));
}
int audiomanager::findsound(char *name, int vol, vector<soundconfig> &sounds)
{
loopv(sounds)
{
if(!strcmp(sounds[i].buf->name, name) && (!vol || sounds[i].vol==vol)) return i;
}
return -1;
}
int audiomanager::addsound(char *name, int vol, int maxuses, bool loop, vector<soundconfig> &sounds, bool load, int audibleradius)
{
if(nosound) return -1;
if(!soundvol) return -1;
// check if the sound was already registered
int index = findsound(name, vol, sounds);
if(index > -1) return index;
sbuffer *b = bufferpool.find(name);
if(!b)
{
@@ -211,15 +225,6 @@ int audiomanager::addsound(char *name, int vol, int maxuses, bool loop, vector<s
return sounds.length()-1;
}
int audiomanager::findsound(char *name, int vol, vector<soundconfig> &sounds)
{
loopv(sounds)
{
if(!strcmp(sounds[i].buf->name, name) && (!vol || sounds[i].vol==vol)) return i;
}
return -1;
}
void audiomanager::preloadmapsound(entity &e)
{
if(e.type!=SOUND || !mapsounds.inrange(e.attr1)) return;
@@ -783,7 +788,7 @@ VARFP(soundvol, 0, 128, 255, audiomgr.setlistenervol(soundvol); );
COMMANDF(registersound, ARG_4STR, (char *name, char *vol, char *loop, char *audibleradius)
{
audiomgr.addsound(name, atoi(vol), -1, atoi(loop) != 0, gamesounds, true, atoi(audibleradius));
intret(audiomgr.addsound(name, atoi(vol), -1, atoi(loop) != 0, gamesounds, true, atoi(audibleradius)));
});
COMMANDF(mapsound, ARG_2STR, (char *name, char *maxuses)
+32 -28
View File
@@ -146,6 +146,7 @@ COMMANDF(selys, ARG_NONE, (void) { SEL_ATTR(ys); });
VAR(flrceil,0,0,2);
VAR(editaxis,0,0,13);
VARP(showgrid,0,1,1);
// VC8 optimizer screws up rendering somehow if this is an actual function
#define sheight(s,t,z) (!flrceil ? (s->type==FHF ? s->floor-t->vdelta/4.0f : (float)s->floor) : (s->type==CHF ? s->ceil+t->vdelta/4.0f : (float)s->ceil))
@@ -187,37 +188,40 @@ void cursorupdate() // called every frame fr
// render editing grid
for(int ix = cx-GRIDSIZE; ix<=cx+GRIDSIZE; ix++) for(int iy = cy-GRIDSIZE; iy<=cy+GRIDSIZE; iy++)
if(showgrid)
{
for(int ix = cx-GRIDSIZE; ix<=cx+GRIDSIZE; ix++) for(int iy = cy-GRIDSIZE; iy<=cy+GRIDSIZE; iy++)
{
if(OUTBORD(ix, iy)) continue;
sqr *s = S(ix,iy);
if(SOLID(s)) continue;
float h1 = sheight(s, s, z);
float h2 = sheight(s, SWS(s,1,0,sfactor), z);
float h3 = sheight(s, SWS(s,1,1,sfactor), z);
float h4 = sheight(s, SWS(s,0,1,sfactor), z);
if(s->tag) linestyle(GRIDW, 0xFF, 0x40, 0x40);
else if(s->type==FHF || s->type==CHF) linestyle(GRIDW, 0x80, 0xFF, 0x80);
else linestyle(GRIDW, 0x80, 0x80, 0x80);
block b = { ix, iy, 1, 1 };
box(b, h1, h2, h3, h4);
linestyle(GRID8, 0x40, 0x40, 0xFF);
if(!(ix&GRIDM)) line(ix, iy, h1, ix, iy+1, h4);
if(!((ix+1)&GRIDM)) line(ix+1, iy, h2, ix+1, iy+1, h3);
if(!(iy&GRIDM)) line(ix, iy, h1, ix+1, iy, h2);
if(!((iy+1)&GRIDM)) line(ix, iy+1, h4, ix+1, iy+1, h3);
}
if(OUTBORD(ix, iy)) continue;
sqr *s = S(ix,iy);
if(SOLID(s)) continue;
float h1 = sheight(s, s, z);
float h2 = sheight(s, SWS(s,1,0,sfactor), z);
float h3 = sheight(s, SWS(s,1,1,sfactor), z);
float h4 = sheight(s, SWS(s,0,1,sfactor), z);
if(s->tag) linestyle(GRIDW, 0xFF, 0x40, 0x40);
else if(s->type==FHF || s->type==CHF) linestyle(GRIDW, 0x80, 0xFF, 0x80);
else linestyle(GRIDW, 0x80, 0x80, 0x80);
block b = { ix, iy, 1, 1 };
box(b, h1, h2, h3, h4);
linestyle(GRID8, 0x40, 0x40, 0xFF);
if(!(ix&GRIDM)) line(ix, iy, h1, ix, iy+1, h4);
if(!((ix+1)&GRIDM)) line(ix+1, iy, h2, ix+1, iy+1, h3);
if(!(iy&GRIDM)) line(ix, iy, h1, ix+1, iy, h2);
if(!((iy+1)&GRIDM)) line(ix, iy+1, h4, ix+1, iy+1, h3);
}
if(!SOLID(s))
{
float ih = sheight(s, s, z);
linestyle(GRIDS, 0xFF, 0xFF, 0xFF);
block b = { cx, cy, 1, 1 };
box(b, ih, sheight(s, SWS(s,1,0,sfactor), z), sheight(s, SWS(s,1,1,sfactor), z), sheight(s, SWS(s,0,1,sfactor), z));
linestyle(GRIDS, 0xFF, 0x00, 0x00);
dot(cx, cy, ih);
ch = (int)ih;
if(!SOLID(s))
{
float ih = sheight(s, s, z);
linestyle(GRIDS, 0xFF, 0xFF, 0xFF);
block b = { cx, cy, 1, 1 };
box(b, ih, sheight(s, SWS(s,1,0,sfactor), z), sheight(s, SWS(s,1,1,sfactor), z), sheight(s, SWS(s,0,1,sfactor), z));
linestyle(GRIDS, 0xFF, 0x00, 0x00);
dot(cx, cy, ih);
ch = (int)ih;
}
}
if(selset())