grenades fix, newmap spawn fix, removebans fix, findlist cmd, menumdl fix, spect hud, scoreboard server stats refresh limit

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1566 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2008-01-05 16:35:04 +00:00
parent 051db88f74
commit 33dc34d076
10 changed files with 78 additions and 34 deletions
+27 -16
View File
@@ -291,26 +291,29 @@ float nearestenemy(vec place, char *team)
else return nearestenemydist;
}
void findplayerstart(playerent *d)
void findplayerstart(playerent *d, bool mapcenter)
{
int r = fixspawn-->0 ? 4 : rnd(10)+1;
entity *e = NULL;
if(m_teammode || m_arena)
if(!mapcenter)
{
int type = m_teammode ? team_int(d->team) : 100;
loopi(r) spawncycle = findentity(PLAYERSTART, spawncycle+1, type);
if(spawncycle >= 0) e = &ents[spawncycle];
}
else
{
float bestdist = -1;
loopi(r)
if(m_teammode || m_arena)
{
spawncycle = findentity(PLAYERSTART, spawncycle+1);
if(spawncycle < 0) continue;
float dist = nearestenemy(vec(ents[spawncycle].x, ents[spawncycle].y, ents[spawncycle].z), d->team);
if(!e || dist < 0 || (bestdist >= 0 && dist > bestdist)) { e = &ents[spawncycle]; bestdist = dist; }
int type = m_teammode ? team_int(d->team) : 100;
loopi(r) spawncycle = findentity(PLAYERSTART, spawncycle+1, type);
if(spawncycle >= 0) e = &ents[spawncycle];
}
else
{
float bestdist = -1;
loopi(r)
{
spawncycle = findentity(PLAYERSTART, spawncycle+1);
if(spawncycle < 0) continue;
float dist = nearestenemy(vec(ents[spawncycle].x, ents[spawncycle].y, ents[spawncycle].z), d->team);
if(!e || dist < 0 || (bestdist >= 0 && dist > bestdist)) { e = &ents[spawncycle]; bestdist = dist; }
}
}
}
@@ -672,6 +675,7 @@ void callvote(int type, char *arg1, char *arg2)
putint(p, nextmode);
break;
case SA_STOPDEMO:
case SA_REMBANS:
break;
default:
putint(p, atoi(arg1));
@@ -795,6 +799,7 @@ void refreshsopmenu(void *menu, bool init)
void followplayer(int i)
{
showscores(false);
player1->spectating = SM_FOLLOWPLAYER;
if(players.length())
{
@@ -808,6 +813,12 @@ void followplayer(int i)
player1->spectating = SM_FLY;
}
void spectate()
{
showscores(false);
player1->spectating = SM_FLY;
}
void toggledeathcam()
{
showscores(false);
@@ -820,7 +831,7 @@ void toggledeathcam()
}
COMMAND(followplayer, ARG_1INT);
COMMAND(toggledeathcam, ARG_NONE);
COMMAND(spectate, ARG_NONE);
int isalive() { return player1->state==CS_ALIVE ? 1 : 0; }
COMMANDN(alive, isalive, ARG_1EXP);
+25
View File
@@ -479,6 +479,30 @@ void at(char *s, char *pos)
commandret = indexlist(s, ATOI(pos));
}
int find(const char *s, const char *key)
{
whitespaceskip;
for(int i = 0; *s; i++)
{
const char *a = s, *e = s;
elementskip;
if(*e=='"')
{
e++;
if(s[-1]=='"') --s;
}
if(!strncmp(e, key, s-e)) return i;
else s = a;
elementskip, whitespaceskip;
}
return -1;
}
void findlist(char *s, char *key)
{
intret(find(s, key));
}
COMMANDN(loop, loopa, ARG_3STR);
COMMANDN(while, whilea, ARG_2STR);
COMMANDN(if, ifthen, ARG_3STR);
@@ -488,6 +512,7 @@ COMMAND(concatword, ARG_VARIW);
COMMAND(result, ARG_1STR);
COMMAND(at, ARG_2STR);
COMMAND(listlen, ARG_1EST);
COMMAND(findlist, ARG_2STR);
int add(int a, int b) { return a+b; } COMMANDN(+, add, ARG_2EXP);
int mul(int a, int b) { return a*b; } COMMANDN(*, mul, ARG_2EXP);
-1
View File
@@ -593,7 +593,6 @@ void rendermenumdl()
glPushMatrix();
glLoadIdentity();
glTranslatef(0, 1.5f, -1.0f);
glRotatef(90+180, 0, -1, 0);
glRotatef(90, -1, 0, 0);
glScalef(1, -1, 1);
+1 -1
View File
@@ -258,7 +258,7 @@ extern void flaginbase(int flag, int action, int act);
extern void flagmsg(int flag, int action);
extern void arenarespawn();
extern bool tryrespawn();
extern void findplayerstart(playerent *d);
extern void findplayerstart(playerent *d, bool mapcenter=false);
extern void serveropcommand(int cmd, int arg1);
extern void refreshsopmenu(void *menu, bool init);
extern char *colorname(playerent *d, int num = 0, char *name = NULL, const char *prefix = "");
+1 -1
View File
@@ -136,7 +136,7 @@ VAR(mergestrips, 0, 1, 1);
void finishstrips() { stripend(); }
sqr sbright, sdark;
VARP(lighterror,1,8,100);
VARP(lighterror, 1, 4, 100);
void render_flat(int wtex, int x, int y, int size, int h, sqr *l1, sqr *l2, sqr *l3, sqr *l4, bool isceil) // floor/ceil quads
{
+2 -2
View File
@@ -447,8 +447,8 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat
glLoadIdentity();
glOrtho(0, VIRTW*3/2, VIRTH*3/2, 0, -1, 1);
const int left = (VIRTW*3/2)*6/8, top = (VIRTH*3/2)*3/4;
draw_textf("jump or switch weapons", left, top);
draw_textf("to enter spectator mode", left, top+80);
draw_textf("F7 spectate", left, top);
draw_textf("F8 followplayer", left, top+80);
}
if(player1->state==CS_SPECTATE || (player1->state==CS_DEAD && player1->spectating!=SM_NONE))
+7 -1
View File
@@ -154,6 +154,12 @@ void renderscores(void *menu, bool init)
loopv(scorelines) menumanual(menu, i, scorelines[i].s, NULL, scorelines[i].bgcolor);
menuheader(menu, modeline, serverline);
refreshservers(NULL, init); // update server stats
// update server stats
static int lastrefresh = 0;
if(!lastrefresh || lastrefresh+5000<lastmillis)
{
refreshservers(NULL, init);
lastrefresh = lastmillis;
}
}
+2 -2
View File
@@ -110,7 +110,7 @@ void stopsound()
}
}
VARF(soundchans, 0, 32, 128, initwarning());
VARF(soundchans, 0, 64, 128, initwarning());
VARF(soundfreq, 0, MIX_DEFAULT_FREQUENCY, 44100, initwarning());
VARF(soundbufferlen, 128, 1024, 4096, initwarning());
@@ -419,7 +419,7 @@ void updatevol()
#endif
}
VARP(maxsoundsatonce, 0, 5, 100);
VARP(maxsoundsatonce, 0, 40, 100);
void playsound(int n, physent *p, entity *ent, const vec *loc)
{
+8 -9
View File
@@ -44,11 +44,7 @@ void selectweapon(weapon *w)
void selectweaponi(int w)
{
if(player1->state == CS_ALIVE)
{
if(w >= 0 && w < NUMGUNS) selectweapon(player1->weapons[w]);
}
else toggledeathcam();
if(player1->state == CS_ALIVE && w >= 0 && w < NUMGUNS) selectweapon(player1->weapons[w]);
}
void shiftweapon(int s)
@@ -62,7 +58,6 @@ void shiftweapon(int s)
selectweapon(player1->weapons[trygun]);
}
}
else toggledeathcam();
}
int currentprimary() { return player1->primweap->type; }
@@ -718,10 +713,14 @@ struct grenades : weapon
0);
playsound(S_GRENADEPULL);
}
else if(inhandnade && attackmillis>info.attackdelay && (!owner->attacking || !inhandnade->isalive(lastmillis)))
else if(inhandnade && attackmillis>info.attackdelay)
{
vec n(0,0,0);
thrownade(owner->o, n, inhandnade);
if(!owner->attacking) thrownade(); // throw
else if(!inhandnade->isalive(lastmillis)) // drop & have fun
{
vec n(0,0,0);
thrownade(owner->o, n, inhandnade);
}
}
return true;
}
+5 -1
View File
@@ -323,7 +323,11 @@ void empty_world(int factor, bool force) // main empty world creation routine
}
calclight();
if(factor>=0) startmap("");
if(factor>=0)
{
findplayerstart(player1, true);
startmap("");
}
if(oldworld)
{
delete[] oldworld;