diff options
Diffstat (limited to 'src/fpsgame/client.cpp')
| -rw-r--r-- | src/fpsgame/client.cpp | 168 |
1 files changed, 16 insertions, 152 deletions
diff --git a/src/fpsgame/client.cpp b/src/fpsgame/client.cpp index 3717a58..55da8d0 100644 --- a/src/fpsgame/client.cpp +++ b/src/fpsgame/client.cpp @@ -2,118 +2,11 @@ namespace game { - VARP(minradarscale, 0, 384, 10000); - VARP(maxradarscale, 1, 1024, 10000); - VARP(radarteammates, 0, 1, 1); - FVARP(minimapalpha, 0, 1, 1); - - float calcradarscale() - { - return clamp(max(minimapradius.x, minimapradius.y)/3, float(minradarscale), float(maxradarscale)); - } - - void drawminimap(fpsent *d, float x, float y, float s) - { - vec pos = vec(d->o).sub(minimapcenter).mul(minimapscale).add(0.5f), dir; - vecfromyawpitch(camera1->yaw, 0, 1, 0, dir); - float scale = calcradarscale(); - gle::defvertex(2); - gle::deftexcoord0(); - gle::begin(GL_TRIANGLE_FAN); - loopi(16) - { - vec v = vec(0, -1, 0).rotate_around_z(i/16.0f*2*M_PI); - gle::attribf(x + 0.5f*s*(1.0f + v.x), y + 0.5f*s*(1.0f + v.y)); - vec tc = vec(dir).rotate_around_z(i/16.0f*2*M_PI); - gle::attribf(pos.x + tc.x*scale*minimapscale.x, pos.y + tc.y*scale*minimapscale.y); - } - gle::end(); - } - - void drawradar(float x, float y, float s) - { - gle::defvertex(2); - gle::deftexcoord0(); - gle::begin(GL_TRIANGLE_STRIP); - gle::attribf(x, y); gle::attribf(0, 0); - gle::attribf(x+s, y); gle::attribf(1, 0); - gle::attribf(x, y+s); gle::attribf(0, 1); - gle::attribf(x+s, y+s); gle::attribf(1, 1); - gle::end(); - } - - void drawteammate(fpsent *d, float x, float y, float s, fpsent *o, float scale) - { - vec dir = d->o; - dir.sub(o->o).div(scale); - float dist = dir.magnitude2(), maxdist = 1 - 0.05f - 0.05f; - if(dist >= maxdist) dir.mul(maxdist/dist); - dir.rotate_around_z(-camera1->yaw*RAD); - float bs = 0.06f*s, - bx = x + s*0.5f*(1.0f + dir.x), - by = y + s*0.5f*(1.0f + dir.y); - vec v(-0.5f, -0.5f, 0); - v.rotate_around_z((90+o->yaw-camera1->yaw)*RAD); - gle::attribf(bx + bs*v.x, by + bs*v.y); gle::attribf(0, 0); - gle::attribf(bx + bs*v.y, by - bs*v.x); gle::attribf(1, 0); - gle::attribf(bx - bs*v.x, by - bs*v.y); gle::attribf(1, 1); - gle::attribf(bx - bs*v.y, by + bs*v.x); gle::attribf(0, 1); - } - - void drawteammates(fpsent *d, float x, float y, float s) - { - if(!radarteammates) return; - float scale = calcradarscale(); - int alive = 0, dead = 0; - loopv(players) - { - fpsent *o = players[i]; - if(o != d && o->state == CS_ALIVE && isteam(o->team, d->team)) - { - if(!alive++) - { - settexture(isteam(d->team, player1->team) ? "packages/hud/blip_blue_alive.png" : "packages/hud/blip_red_alive.png"); - gle::defvertex(2); - gle::deftexcoord0(); - gle::begin(GL_QUADS); - } - drawteammate(d, x, y, s, o, scale); - } - } - if(alive) gle::end(); - loopv(players) - { - fpsent *o = players[i]; - if(o != d && o->state == CS_DEAD && isteam(o->team, d->team)) - { - if(!dead++) - { - settexture(isteam(d->team, player1->team) ? "packages/hud/blip_blue_dead.png" : "packages/hud/blip_red_dead.png"); - gle::defvertex(2); - gle::deftexcoord0(); - gle::begin(GL_QUADS); - } - drawteammate(d, x, y, s, o, scale); - } - } - if(dead) gle::end(); - } - - #include "capture.h" - #include "ctf.h" - #include "collect.h" - clientmode *cmode = NULL; - captureclientmode capturemode; - ctfclientmode ctfmode; - collectclientmode collectmode; void setclientmode() { - if(m_capture) cmode = &capturemode; - else if(m_ctf) cmode = &ctfmode; - else if(m_collect) cmode = &collectmode; - else cmode = NULL; + cmode = NULL; } bool senditemstoserver = false, sendcrc = false; // after a map change, since server doesn't have map data @@ -128,7 +21,7 @@ namespace game void switchname(const char *name) { filtertext(player1->name, name, false, false, MAXNAMELEN); - if(!player1->name[0]) copystring(player1->name, "unnamed"); + if(!player1->name[0]) copystring(player1->name, "Anonymous"); addmsg(N_SWITCHNAME, "rs", player1->name); } void printname() @@ -160,12 +53,6 @@ namespace game }); ICOMMAND(getteam, "", (), result(player1->team)); - void switchplayermodel(int playermodel) - { - player1->playermodel = playermodel; - addmsg(N_SWITCHMODEL, "ri", player1->playermodel); - } - struct authkey { char *name, *key, *desc; @@ -292,13 +179,6 @@ namespace game } ICOMMAND(getclientteam, "i", (int *cn), result(getclientteam(*cn))); - int getclientmodel(int cn) - { - fpsent *d = getclient(cn); - return d ? d->playermodel : -1; - } - ICOMMAND(getclientmodel, "i", (int *cn), intret(getclientmodel(*cn))); - const char *getclienticon(int cn) { fpsent *d = getclient(cn); @@ -411,7 +291,7 @@ namespace game { authkey *a = findauthkey(desc); int vn = parseplayer(victim); - if(a && vn>=0 && vn!=player1->clientnum) + if(a && vn>=0 && vn!=player1->clientnum) { a->lastauth = lastmillis; addmsg(N_AUTHKICK, "rssis", a->desc, a->name, vn, reason); @@ -442,7 +322,7 @@ namespace game bool isignored(int cn) { return ignores.find(cn) >= 0; } ICOMMAND(ignore, "s", (char *arg), ignore(parseplayer(arg))); - ICOMMAND(unignore, "s", (char *arg), unignore(parseplayer(arg))); + ICOMMAND(unignore, "s", (char *arg), unignore(parseplayer(arg))); ICOMMAND(isignored, "s", (char *arg), intret(isignored(parseplayer(arg)) ? 1 : 0)); void setteam(const char *arg1, const char *arg2) @@ -472,7 +352,7 @@ namespace game } string hash = ""; if(!arg[1] && isdigit(arg[0])) val = parseint(arg); - else + else { if(cn != player1->clientnum) return; server::hashpassword(player1->clientnum, sessionid, arg, hash); @@ -541,7 +421,7 @@ namespace game } ICOMMAND(mode, "i", (int *val), setmode(*val)); ICOMMAND(getmode, "", (), intret(gamemode)); - ICOMMAND(timeremaining, "i", (int *formatted), + ICOMMAND(timeremaining, "i", (int *formatted), { int val = max(maplimit - lastmillis + 999, 0)/1000; if(*formatted) @@ -554,21 +434,11 @@ namespace game ICOMMANDS("m_noitems", "i", (int *mode), { int gamemode = *mode; intret(m_noitems); }); ICOMMANDS("m_noammo", "i", (int *mode), { int gamemode = *mode; intret(m_noammo); }); ICOMMANDS("m_insta", "i", (int *mode), { int gamemode = *mode; intret(m_insta); }); - ICOMMANDS("m_tactics", "i", (int *mode), { int gamemode = *mode; intret(m_tactics); }); ICOMMANDS("m_efficiency", "i", (int *mode), { int gamemode = *mode; intret(m_efficiency); }); - ICOMMANDS("m_capture", "i", (int *mode), { int gamemode = *mode; intret(m_capture); }); - ICOMMANDS("m_regencapture", "i", (int *mode), { int gamemode = *mode; intret(m_regencapture); }); - ICOMMANDS("m_ctf", "i", (int *mode), { int gamemode = *mode; intret(m_ctf); }); - ICOMMANDS("m_protect", "i", (int *mode), { int gamemode = *mode; intret(m_protect); }); - ICOMMANDS("m_hold", "i", (int *mode), { int gamemode = *mode; intret(m_hold); }); - ICOMMANDS("m_collect", "i", (int *mode), { int gamemode = *mode; intret(m_collect); }); ICOMMANDS("m_teammode", "i", (int *mode), { int gamemode = *mode; intret(m_teammode); }); ICOMMANDS("m_demo", "i", (int *mode), { int gamemode = *mode; intret(m_demo); }); ICOMMANDS("m_edit", "i", (int *mode), { int gamemode = *mode; intret(m_edit); }); ICOMMANDS("m_lobby", "i", (int *mode), { int gamemode = *mode; intret(m_lobby); }); - ICOMMANDS("m_sp", "i", (int *mode), { int gamemode = *mode; intret(m_sp); }); - ICOMMANDS("m_dmsp", "i", (int *mode), { int gamemode = *mode; intret(m_dmsp); }); - ICOMMANDS("m_classicsp", "i", (int *mode), { int gamemode = *mode; intret(m_classicsp); }); void changemap(const char *name, int mode) // request map change, server may ignore { @@ -737,7 +607,7 @@ namespace game int val = *id->storage.i; string str; if(val < 0) - formatstring(str, "%d", val); + formatstring(str, "%d", val); else if(id->flags&IDF_HEX && id->maxval==0xFFFFFF) formatstring(str, "0x%.6X (%d, %d, %d)", val, (val>>16)&0xFF, (val>>8)&0xFF, val&0xFF); else @@ -783,10 +653,10 @@ namespace game } ICOMMAND(pausegame, "i", (int *val), pausegame(*val > 0)); ICOMMAND(paused, "iN$", (int *val, int *numargs, ident *id), - { - if(*numargs > 0) pausegame(clampvar(id, *val, 0, 1) > 0); + { + if(*numargs > 0) pausegame(clampvar(id, *val, 0, 1) > 0); else if(*numargs < 0) intret(gamepaused ? 1 : 0); - else printvar(id, gamepaused ? 1 : 0); + else printvar(id, gamepaused ? 1 : 0); }); bool ispaused() { return gamepaused; } @@ -1291,7 +1161,7 @@ namespace game gamepaused = val; player1->attacking = false; } - if(a) conoutf("%s %s the game", colorname(a), val ? "paused" : "resumed"); + if(a) conoutf("%s %s the game", colorname(a), val ? "paused" : "resumed"); else conoutf("game is %s", val ? "paused" : "resumed"); break; } @@ -1302,12 +1172,11 @@ namespace game fpsent *a = cn >= 0 ? getclient(cn) : NULL; if(!demopacket) gamespeed = val; extern int slowmosp; - if(m_sp && slowmosp) break; if(a) conoutf("%s set gamespeed to %d", colorname(a), val); else conoutf("gamespeed is %d", val); break; } - + case N_CLIENT: { int cn = getint(p), len = getuint(p); @@ -1396,7 +1265,7 @@ namespace game } getstring(text, p); filtertext(text, text, false, false, MAXNAMELEN); - if(!text[0]) copystring(text, "unnamed"); + if(!text[0]) copystring(text, "Anonymous"); if(d->name[0]) // already connected { if(strcmp(d->name, text) && !isignored(d->clientnum)) @@ -1411,6 +1280,7 @@ namespace game getstring(text, p); filtertext(d->team, text, false, false, MAXTEAMLEN); d->playermodel = getint(p); + d->playermodel = 0; break; } @@ -1419,7 +1289,7 @@ namespace game if(d) { filtertext(text, text, false, false, MAXNAMELEN); - if(!text[0]) copystring(text, "unnamed"); + if(!text[0]) copystring(text, "Anonymous"); if(strcmp(text, d->name)) { if(!isignored(d->clientnum)) conoutf("%s is now known as %s", colorname(d), colorname(d, text)); @@ -1433,7 +1303,7 @@ namespace game int model = getint(p); if(d) { - d->playermodel = model; + d->playermodel = 0; if(d->ragdoll) cleanragdoll(d); } break; @@ -1884,12 +1754,6 @@ namespace game break; } - #define PARSEMESSAGES 1 - #include "capture.h" - #include "ctf.h" - #include "collect.h" - #undef PARSEMESSAGES - case N_ANNOUNCE: { int t = getint(p); |
