From 33dc34d076c260ba7503d70ed97bf0097fcdd1b0 Mon Sep 17 00:00:00 2001 From: driAn Date: Sat, 5 Jan 2008 16:35:04 +0000 Subject: [PATCH] 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 --- source/src/clientgame.cpp | 43 ++++++++++++++++++++++++-------------- source/src/command.cpp | 25 ++++++++++++++++++++++ source/src/menus.cpp | 1 - source/src/protos.h | 2 +- source/src/rendercubes.cpp | 2 +- source/src/renderhud.cpp | 4 ++-- source/src/scoreboard.cpp | 8 ++++++- source/src/sound.cpp | 4 ++-- source/src/weapon.cpp | 17 +++++++-------- source/src/world.cpp | 6 +++++- 10 files changed, 78 insertions(+), 34 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 3f295ae2..e181e356 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -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); diff --git a/source/src/command.cpp b/source/src/command.cpp index 461b5d2c..c59cc9b8 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -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); diff --git a/source/src/menus.cpp b/source/src/menus.cpp index 3a5becd4..3d1a24f5 100644 --- a/source/src/menus.cpp +++ b/source/src/menus.cpp @@ -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); diff --git a/source/src/protos.h b/source/src/protos.h index e8200469..d56bef27 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -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 = ""); diff --git a/source/src/rendercubes.cpp b/source/src/rendercubes.cpp index 912bcfc7..e5d0b7ee 100644 --- a/source/src/rendercubes.cpp +++ b/source/src/rendercubes.cpp @@ -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 { diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 86420e93..f491634a 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -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)) diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index 8d4c755f..32bed1d7 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -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+5000state == 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; } diff --git a/source/src/world.cpp b/source/src/world.cpp index ca314801..420e8700 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -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;