diff options
| author | xolatile | 2025-07-17 23:28:55 +0200 |
|---|---|---|
| committer | xolatile | 2025-07-17 23:28:55 +0200 |
| commit | c79dda69d6e603500a5681430172b5152041af0a (patch) | |
| tree | c1669442318e77a9ae76009edd5eefcaa69064ce /src/fpsgame | |
| parent | 5b88d873f42b1cad5c5fd03888cfe45b82da06d6 (diff) | |
| download | xolatile-badassbug-c79dda69d6e603500a5681430172b5152041af0a.tar.xz xolatile-badassbug-c79dda69d6e603500a5681430172b5152041af0a.tar.zst | |
Big changed mentioned in IRC channel...
Diffstat (limited to 'src/fpsgame')
| -rw-r--r-- | src/fpsgame/ai.cpp | 6 | ||||
| -rw-r--r-- | src/fpsgame/aiman.h | 2 | ||||
| -rw-r--r-- | src/fpsgame/client.cpp | 168 | ||||
| -rw-r--r-- | src/fpsgame/entities.cpp | 307 | ||||
| -rw-r--r-- | src/fpsgame/fps.cpp | 71 | ||||
| -rw-r--r-- | src/fpsgame/game.h | 180 | ||||
| -rw-r--r-- | src/fpsgame/game.h.gch | bin | 0 -> 76106492 bytes | |||
| -rw-r--r-- | src/fpsgame/render.cpp | 99 | ||||
| -rw-r--r-- | src/fpsgame/scoreboard.cpp | 5 | ||||
| -rw-r--r-- | src/fpsgame/server.cpp | 142 | ||||
| -rw-r--r-- | src/fpsgame/waypoint.cpp | 2 | ||||
| -rw-r--r-- | src/fpsgame/weapon.cpp | 52 |
12 files changed, 152 insertions, 882 deletions
diff --git a/src/fpsgame/ai.cpp b/src/fpsgame/ai.cpp index cfe3502..d5045fd 100644 --- a/src/fpsgame/ai.cpp +++ b/src/fpsgame/ai.cpp @@ -116,7 +116,7 @@ namespace ai { if(lastmillis >= d->ai->lastaimrnd) { - const int aiskew[NUMGUNS] = { 1, 10, 50, 5, 20, 1, 100, 10, 10, 10, 1, 1 }; + const int aiskew[NUMGUNS] = { 1, 10, 50, 5, 20, 1, 100 }; #define rndaioffset(r) ((rnd(int(r*aiskew[d->gunselect]*2)+1)-(r*aiskew[d->gunselect]))*(1.f/float(max(d->skill, 1)))) loopk(3) d->ai->aimrnd[k] = rndaioffset(e->radius); int dur = (d->skill+10)*10; @@ -167,7 +167,7 @@ namespace ai d->ownernum = ocn; d->plag = 0; d->skill = sk; - d->playermodel = chooserandomplayermodel(pm); + d->playermodel = 0; if(resetthisguy) removeweapons(d); if(d->ownernum >= 0 && player1->clientnum == d->ownernum) @@ -903,7 +903,7 @@ namespace ai float radius = 18*18; loopv(entities::ents) if(entities::ents[i]->type == JUMPPAD) { - fpsentity &e = *(fpsentity *)entities::ents[i]; + extentity &e = *(extentity *)entities::ents[i]; if(e.o.squaredist(pos) <= radius) { jump = false; break; } } } diff --git a/src/fpsgame/aiman.h b/src/fpsgame/aiman.h index a36118c..120f50b 100644 --- a/src/fpsgame/aiman.h +++ b/src/fpsgame/aiman.h @@ -119,7 +119,7 @@ namespace aiman copystring(ci->name, "bot", MAXNAMELEN+1); ci->state.state = CS_DEAD; copystring(ci->team, team, MAXTEAMLEN+1); - ci->playermodel = rnd(128); + ci->playermodel = 0; ci->aireinit = 2; ci->connected = true; dorefresh = true; 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); diff --git a/src/fpsgame/entities.cpp b/src/fpsgame/entities.cpp index c35a0d1..f199c11 100644 --- a/src/fpsgame/entities.cpp +++ b/src/fpsgame/entities.cpp @@ -14,27 +14,10 @@ namespace entities { if(ver <= 30) switch(e.type) { - case FLAG: - case MONSTER: case TELEDEST: - case RESPAWNPOINT: - case BOX: - case BARREL: - case PLATFORM: - case ELEVATOR: e.attr1 = (int(e.attr1)+180)%360; break; } - if(ver <= 31) switch(e.type) - { - case BOX: - case BARREL: - case PLATFORM: - case ELEVATOR: - int yaw = (int(e.attr1)%360 + 360)%360 + 7; - e.attr1 = yaw - yaw%15; - break; - } } #ifndef STANDALONE @@ -99,9 +82,6 @@ namespace entities case I_HEALTH: case I_BOOST: case I_GREENARMOUR: case I_YELLOWARMOUR: case I_QUAD: if(m_noitems) continue; break; - case CARROT: case RESPAWNPOINT: - if(!m_classicsp) continue; - break; } const char *mdl = entmdlname(i); if(!mdl) continue; @@ -129,10 +109,6 @@ namespace entities int revs = 10; switch(e.type) { - case CARROT: - case RESPAWNPOINT: - if(e.attr2) revs = 1; - break; case TELEPORT: if(e.attr2 < 0) continue; break; @@ -204,7 +180,7 @@ namespace entities if(ents.inrange(tp) && ents[tp]->type == TELEPORT) { extentity &e = *ents[tp]; - if(e.attr4 >= 0) + if(e.attr4 >= 0) { int snd = S_TELEPORT, flags = 0; if(e.attr4 > 0) { snd = e.attr4; flags = SND_MAP; } @@ -307,13 +283,6 @@ namespace entities break; } - case RESPAWNPOINT: - if(!m_classicsp || d!=player1 || n==respawnent) break; - respawnent = n; - conoutf(CON_GAMEINFO, "\f2respawn point set!"); - playsound(S_V_RESPAWNPOINT); - break; - case JUMPPAD: { if(d->lastpickup==e->type && lastmillis-d->lastpickupmillis<300) break; @@ -339,7 +308,7 @@ namespace entities { extentity &e = *ents[i]; if(e.type==NOTUSED) continue; - if((!e.spawned() || e.nopickup()) && e.type!=TELEPORT && e.type!=JUMPPAD && e.type!=RESPAWNPOINT) continue; + if((!e.spawned() || e.nopickup()) && e.type!=TELEPORT && e.type!=JUMPPAD) continue; float dist = e.o.dist(o); if(dist<(e.type==TELEPORT ? 16 : 12)) trypickup(i, d); } @@ -377,7 +346,7 @@ namespace entities extentity *e = ents[i]; if(e->type>=I_SHELLS && e->type<=I_QUAD && (!m_noammo || e->type<I_SHELLS || e->type>I_CARTRIDGES)) { - e->setspawned(force || m_sp || !server::delayspawn(e->type)); + e->setspawned(force || !server::delayspawn(e->type)); e->clearnopickup(); } } @@ -385,244 +354,17 @@ namespace entities void setspawn(int i, bool on) { if(ents.inrange(i)) { extentity *e = ents[i]; e->setspawned(on); e->clearnopickup(); } } - extentity *newentity() { return new fpsentity(); } - void deleteentity(extentity *e) { delete (fpsentity *)e; } + extentity *newentity() { return new extentity(); } + void deleteentity(extentity *e) { delete e; } void clearents() { while(ents.length()) deleteentity(ents.pop()); } - enum - { - TRIG_COLLIDE = 1<<0, - TRIG_TOGGLE = 1<<1, - TRIG_ONCE = 0<<2, - TRIG_MANY = 1<<2, - TRIG_DISAPPEAR = 1<<3, - TRIG_AUTO_RESET = 1<<4, - TRIG_RUMBLE = 1<<5, - TRIG_LOCKED = 1<<6, - TRIG_ENDSP = 1<<7 - }; - - static const int NUMTRIGGERTYPES = 32; - - static const int triggertypes[NUMTRIGGERTYPES] = - { - -1, - TRIG_ONCE, // 1 - TRIG_RUMBLE, // 2 - TRIG_TOGGLE, // 3 - TRIG_TOGGLE | TRIG_RUMBLE, // 4 - TRIG_MANY, // 5 - TRIG_MANY | TRIG_RUMBLE, // 6 - TRIG_MANY | TRIG_TOGGLE, // 7 - TRIG_MANY | TRIG_TOGGLE | TRIG_RUMBLE, // 8 - TRIG_COLLIDE | TRIG_TOGGLE | TRIG_RUMBLE, // 9 - TRIG_COLLIDE | TRIG_TOGGLE | TRIG_AUTO_RESET | TRIG_RUMBLE, // 10 - TRIG_COLLIDE | TRIG_TOGGLE | TRIG_LOCKED | TRIG_RUMBLE, // 11 - TRIG_DISAPPEAR, // 12 - TRIG_DISAPPEAR | TRIG_RUMBLE, // 13 - TRIG_DISAPPEAR | TRIG_COLLIDE | TRIG_LOCKED, // 14 - -1 /* reserved 15 */, - -1 /* reserved 16 */, - -1 /* reserved 17 */, - -1 /* reserved 18 */, - -1 /* reserved 19 */, - -1 /* reserved 20 */, - -1 /* reserved 21 */, - -1 /* reserved 22 */, - -1 /* reserved 23 */, - -1 /* reserved 24 */, - -1 /* reserved 25 */, - -1 /* reserved 26 */, - -1 /* reserved 27 */, - -1 /* reserved 28 */, - TRIG_DISAPPEAR | TRIG_RUMBLE | TRIG_ENDSP, // 29 - -1 /* reserved 30 */, - -1 /* reserved 31 */, - }; - - #define validtrigger(type) (triggertypes[(type) & (NUMTRIGGERTYPES-1)]>=0) - #define checktriggertype(type, flag) (triggertypes[(type) & (NUMTRIGGERTYPES-1)] & (flag)) - - static inline void cleartriggerflags(extentity &e) - { - e.flags &= ~(EF_ANIM | EF_NOVIS | EF_NOSHADOW | EF_NOCOLLIDE); - } - - static inline void setuptriggerflags(fpsentity &e) - { - cleartriggerflags(e); - e.flags |= EF_ANIM; - if(checktriggertype(e.attr3, TRIG_COLLIDE|TRIG_DISAPPEAR)) e.flags |= EF_NOSHADOW; - if(!checktriggertype(e.attr3, TRIG_COLLIDE)) e.flags |= EF_NOCOLLIDE; - switch(e.triggerstate) - { - case TRIGGERING: - if(checktriggertype(e.attr3, TRIG_COLLIDE) && lastmillis-e.lasttrigger >= 500) e.flags |= EF_NOCOLLIDE; - break; - case TRIGGERED: - if(checktriggertype(e.attr3, TRIG_COLLIDE)) e.flags |= EF_NOCOLLIDE; - break; - case TRIGGER_DISAPPEARED: - e.flags |= EF_NOVIS | EF_NOCOLLIDE; - break; - } - } - - void resettriggers() - { - loopv(ents) - { - fpsentity &e = *(fpsentity *)ents[i]; - if(e.type != ET_MAPMODEL || !validtrigger(e.attr3)) continue; - e.triggerstate = TRIGGER_RESET; - e.lasttrigger = 0; - setuptriggerflags(e); - } - } - - void unlocktriggers(int tag, int oldstate = TRIGGER_RESET, int newstate = TRIGGERING) - { - loopv(ents) - { - fpsentity &e = *(fpsentity *)ents[i]; - if(e.type != ET_MAPMODEL || !validtrigger(e.attr3)) continue; - if(e.attr4 == tag && e.triggerstate == oldstate && checktriggertype(e.attr3, TRIG_LOCKED)) - { - if(newstate == TRIGGER_RESETTING && checktriggertype(e.attr3, TRIG_COLLIDE) && overlapsdynent(e.o, 20)) continue; - e.triggerstate = newstate; - e.lasttrigger = lastmillis; - if(checktriggertype(e.attr3, TRIG_RUMBLE)) playsound(S_RUMBLE, &e.o); - } - } - } - - ICOMMAND(trigger, "ii", (int *tag, int *state), - { - if(*state) unlocktriggers(*tag); - else unlocktriggers(*tag, TRIGGERED, TRIGGER_RESETTING); - }); - - VAR(triggerstate, -1, 0, 1); - - void doleveltrigger(int trigger, int state) - { - defformatstring(aliasname, "level_trigger_%d", trigger); - if(identexists(aliasname)) - { - triggerstate = state; - execident(aliasname); - } - } - - void checktriggers() - { - if(player1->state != CS_ALIVE) return; - vec o = player1->feetpos(); - loopv(ents) - { - fpsentity &e = *(fpsentity *)ents[i]; - if(e.type != ET_MAPMODEL || !validtrigger(e.attr3)) continue; - switch(e.triggerstate) - { - case TRIGGERING: - case TRIGGER_RESETTING: - if(lastmillis-e.lasttrigger>=1000) - { - if(e.attr4) - { - if(e.triggerstate == TRIGGERING) unlocktriggers(e.attr4); - else unlocktriggers(e.attr4, TRIGGERED, TRIGGER_RESETTING); - } - if(checktriggertype(e.attr3, TRIG_DISAPPEAR)) e.triggerstate = TRIGGER_DISAPPEARED; - else if(e.triggerstate==TRIGGERING && checktriggertype(e.attr3, TRIG_TOGGLE)) e.triggerstate = TRIGGERED; - else e.triggerstate = TRIGGER_RESET; - } - setuptriggerflags(e); - break; - case TRIGGER_RESET: - if(e.lasttrigger) - { - if(checktriggertype(e.attr3, TRIG_AUTO_RESET|TRIG_MANY|TRIG_LOCKED) && e.o.dist(o)-player1->radius>=(checktriggertype(e.attr3, TRIG_COLLIDE) ? 20 : 12)) - e.lasttrigger = 0; - break; - } - else if(e.o.dist(o)-player1->radius>=(checktriggertype(e.attr3, TRIG_COLLIDE) ? 20 : 12)) break; - else if(checktriggertype(e.attr3, TRIG_LOCKED)) - { - if(!e.attr4) break; - doleveltrigger(e.attr4, -1); - e.lasttrigger = lastmillis; - break; - } - e.triggerstate = TRIGGERING; - e.lasttrigger = lastmillis; - setuptriggerflags(e); - if(checktriggertype(e.attr3, TRIG_RUMBLE)) playsound(S_RUMBLE, &e.o); - if(checktriggertype(e.attr3, TRIG_ENDSP)) endsp(false); - if(e.attr4) doleveltrigger(e.attr4, 1); - break; - case TRIGGERED: - if(e.o.dist(o)-player1->radius<(checktriggertype(e.attr3, TRIG_COLLIDE) ? 20 : 12)) - { - if(e.lasttrigger) break; - } - else if(checktriggertype(e.attr3, TRIG_AUTO_RESET)) - { - if(lastmillis-e.lasttrigger<6000) break; - } - else if(checktriggertype(e.attr3, TRIG_MANY)) - { - e.lasttrigger = 0; - break; - } - else break; - if(checktriggertype(e.attr3, TRIG_COLLIDE) && overlapsdynent(e.o, 20)) break; - e.triggerstate = TRIGGER_RESETTING; - e.lasttrigger = lastmillis; - setuptriggerflags(e); - if(checktriggertype(e.attr3, TRIG_RUMBLE)) playsound(S_RUMBLE, &e.o); - if(checktriggertype(e.attr3, TRIG_ENDSP)) endsp(false); - if(e.attr4) doleveltrigger(e.attr4, 0); - break; - } - } - } - - void animatemapmodel(const extentity &e, int &anim, int &basetime) - { - const fpsentity &f = (const fpsentity &)e; - if(validtrigger(f.attr3)) switch(f.triggerstate) - { - case TRIGGER_RESET: anim = ANIM_TRIGGER|ANIM_START; break; - case TRIGGERING: anim = ANIM_TRIGGER; basetime = f.lasttrigger; break; - case TRIGGERED: anim = ANIM_TRIGGER|ANIM_END; break; - case TRIGGER_RESETTING: anim = ANIM_TRIGGER|ANIM_REVERSE; basetime = f.lasttrigger; break; - } - } - void fixentity(extentity &e) { - switch(e.type) - { - case FLAG: - case BOX: - case BARREL: - case PLATFORM: - case ELEVATOR: - e.attr5 = e.attr4; - e.attr4 = e.attr3; - case TELEDEST: - e.attr3 = e.attr2; - case MONSTER: - e.attr2 = e.attr1; - case RESPAWNPOINT: - e.attr1 = (int)player1->yaw; - break; - } + if(e.type == TELEDEST) e.attr3 = e.attr2; } void entradius(extentity &e, bool color) @@ -641,23 +383,7 @@ namespace entities renderentarrow(e, vec((int)(char)e.attr3*10.0f, (int)(char)e.attr2*10.0f, e.attr1*12.5f).normalize(), 4); break; - case FLAG: - case MONSTER: - case TELEDEST: - case RESPAWNPOINT: - case BOX: - case BARREL: - case PLATFORM: - case ELEVATOR: - { - vec dir; - vecfromyawpitch(e.attr1, 0, 1, 0, dir); - renderentarrow(e, dir, 4); - break; - } - case MAPMODEL: - if(validtrigger(e.attr3)) renderentring(e, checktriggertype(e.attr3, TRIG_COLLIDE) ? 20 : 12); - break; + default: break; } } @@ -675,11 +401,7 @@ namespace entities "shells", "bullets", "rockets", "riflerounds", "grenades", "cartridges", "health", "healthboost", "greenarmour", "yellowarmour", "quaddamage", "teleport", "teledest", - "monster", "carrot", "jumppad", - "base", "respawnpoint", - "box", "barrel", - "platform", "elevator", - "flag", + "jumppad", "", "", "", "", }; return i>=0 && size_t(i)<sizeof(entnames)/sizeof(entnames[0]) ? entnames[i] : ""; @@ -688,22 +410,9 @@ namespace entities void editent(int i, bool local) { extentity &e = *ents[i]; - if(e.type == ET_MAPMODEL && validtrigger(e.attr3)) - { - fpsentity &f = (fpsentity &)e; - f.triggerstate = TRIGGER_RESET; - f.lasttrigger = 0; - setuptriggerflags(f); - } - else cleartriggerflags(e); if(local) addmsg(N_EDITENT, "rii3ii5", i, (int)(e.o.x*DMF), (int)(e.o.y*DMF), (int)(e.o.z*DMF), e.type, e.attr1, e.attr2, e.attr3, e.attr4, e.attr5); } - float dropheight(entity &e) - { - if(e.type==BASE || e.type==FLAG) return 0.0f; - return 4.0f; - } #endif } diff --git a/src/fpsgame/fps.cpp b/src/fpsgame/fps.cpp index 04b036f..f5ce95c 100644 --- a/src/fpsgame/fps.cpp +++ b/src/fpsgame/fps.cpp @@ -70,12 +70,6 @@ namespace game void resetgamestate() { - if(m_classicsp) - { - clearmovables(); - clearmonsters(); // all monsters back at their spawns for editing - entities::resettriggers(); - } clearprojectiles(); clearbouncers(); } @@ -222,8 +216,6 @@ namespace game } } - VARFP(slowmosp, 0, 0, 1, { if(m_sp && !slowmosp) server::forcegamespeed(100); }); - void checkslowmo() { static int lastslowmohealth = 0; @@ -251,8 +243,6 @@ namespace game ai::update(); moveragdolls(); gets2c(); - updatemovables(curtime); - updatemonsters(curtime); if(connected) { if(player1->state == CS_DEAD) @@ -270,12 +260,7 @@ namespace game moveplayer(player1, 10, true); swayhudgun(curtime); entities::checkitems(player1); - if(m_sp) - { - if(slowmosp) checkslowmo(); - if(m_classicsp) entities::checktriggers(); - } - else if(cmode) cmode->checkitems(player1); + if(cmode) cmode->checkitems(player1); } } if(player1->clientnum>=0) c2sinfo(); // do this last, to reduce the effective frame lag @@ -323,7 +308,7 @@ namespace game void pickgamespawn(fpsent *d) { - int ent = m_classicsp && d == player1 && respawnent >= 0 ? respawnent : -1; + int ent = d == player1 && respawnent >= 0 ? respawnent : -1; int tag = cmode ? cmode->getspawngroup(d) : 0; findplayerspawn(d, ent, tag); } @@ -355,13 +340,7 @@ namespace game return; } if(lastmillis < player1->lastpain + spawnwait) return; - if(m_dmsp) { changemap(clientmap, gamemode); return; } // if we die in SP we try the same map again respawnself(); - if(m_classicsp) - { - conoutf(CON_GAMEINFO, "\f2You wasted another life! The monsters stole your armour and some ammo..."); - loopi(NUMGUNS) if(i!=GUN_PISTOL && (player1->ammo[i] = savedammo[i]) > 5) player1->ammo[i] = max(player1->ammo[i]/3, 5); - } } } COMMAND(respawn, ""); @@ -413,9 +392,7 @@ namespace game } damageeffect(damage, d, d!=h); - ai::damaged(d, actor); - - if(m_sp && slowmosp && d==player1 && d->health < 1) d->health = 1; + ai::damaged(d, actor); if(d->health<=0) { if(local) killed(d, actor); } else if(d==h) playsound(S_PAIN6); @@ -514,12 +491,9 @@ namespace game if(cmode) cmode->gameover(); conoutf(CON_GAMEINFO, "\f2intermission:"); conoutf(CON_GAMEINFO, "\f2game has ended!"); - if(m_ctf) conoutf(CON_GAMEINFO, "\f2player frags: %d, flags: %d, deaths: %d", player1->frags, player1->flags, player1->deaths); - else if(m_collect) conoutf(CON_GAMEINFO, "\f2player frags: %d, skulls: %d, deaths: %d", player1->frags, player1->flags, player1->deaths); - else conoutf(CON_GAMEINFO, "\f2player frags: %d, deaths: %d", player1->frags, player1->deaths); + conoutf(CON_GAMEINFO, "\f2player frags: %d, deaths: %d", player1->frags, player1->deaths); int accuracy = (player1->totaldamage*100)/max(player1->totalshots, 1); conoutf(CON_GAMEINFO, "\f2player total damage dealt: %d, damage wasted: %d, accuracy(%%): %d", player1->totaldamage, player1->totalshots-player1->totaldamage, accuracy); - if(m_sp) spsummary(accuracy); showscores(true); disablezoom(); @@ -593,7 +567,7 @@ namespace game void initclient() { player1 = spawnstate(new fpsent); - filtertext(player1->name, "unnamed", false, false, MAXNAMELEN); + filtertext(player1->name, "Anonymous", false, false, MAXNAMELEN); players.add(player1); } @@ -601,9 +575,6 @@ namespace game void startgame() { - clearmovables(); - clearmonsters(); - clearprojectiles(); clearbouncers(); clearragdolls(); @@ -637,19 +608,8 @@ namespace game conoutf(CON_GAMEINFO, "\f2game mode is %s", server::modename(gamemode)); - if(m_sp) - { - defformatstring(scorename, "bestscore_%s", getclientmap()); - const char *best = getalias(scorename); - if(*best) conoutf(CON_GAMEINFO, "\f2try to beat your best score so far: %s", best); - } - else - { - const char *info = m_valid(gamemode) ? gamemodes[gamemode - STARTGAMEMODE].info : NULL; - if(showmodeinfo && info) conoutf(CON_GAMEINFO, "\f0%s", info); - } - - if(player1->playermodel != playermodel) switchplayermodel(playermodel); + const char *info = m_valid(gamemode) ? gamemodes[gamemode - STARTGAMEMODE].info : NULL; + if(showmodeinfo && info) conoutf(CON_GAMEINFO, "\f0%s", info); showscores(false); disablezoom(); @@ -698,11 +658,7 @@ namespace game void dynentcollide(physent *d, physent *o, const vec &dir) { - switch(d->type) - { - case ENT_AI: if(dir.z > 0) stackmonster((monster *)d, o); break; - case ENT_INANIMATE: if(dir.z > 0) stackmovable((movable *)d, o); break; - } + return; } void msgsound(int n, physent *d) @@ -720,15 +676,12 @@ namespace game } } - int numdynents() { return players.length()+monsters.length()+movables.length(); } + int numdynents() { return players.length(); } dynent *iterdynents(int i) { if(i<players.length()) return players[i]; i -= players.length(); - if(i<monsters.length()) return (dynent *)monsters[i]; - i -= monsters.length(); - if(i<movables.length()) return (dynent *)movables[i]; return NULL; } @@ -803,13 +756,9 @@ namespace game if(pl->suicided!=seq) { addmsg(N_SUICIDE, "rc", pl); pl->suicided = seq; } } } - else if(d->type==ENT_AI) suicidemonster((monster *)d); - else if(d->type==ENT_INANIMATE) suicidemovable((movable *)d); } ICOMMAND(suicide, "", (), suicide(player1)); - bool needminimap() { return m_ctf || m_protect || m_hold || m_capture || m_collect; } - void drawicon(int icon, float x, float y, float sz) { settexture("packages/hud/items.png"); @@ -1087,7 +1036,7 @@ namespace game if(ammobar) drawammobar(w, h, d); } - if(!m_edit && !m_sp) + if(!m_edit) { if(gameclock) drawgameclock(w, h); if(hudscore) drawhudscore(w, h); diff --git a/src/fpsgame/game.h b/src/fpsgame/game.h index 9c4cb16..db1d394 100644 --- a/src/fpsgame/game.h +++ b/src/fpsgame/game.h @@ -36,38 +36,12 @@ enum // static entity types I_QUAD, TELEPORT, // attr1 = idx, attr2 = model, attr3 = tag TELEDEST, // attr1 = angle, attr2 = idx - MONSTER, // attr1 = angle, attr2 = monstertype - CARROT, // attr1 = tag, attr2 = type JUMPPAD, // attr1 = zpush, attr2 = ypush, attr3 = xpush - BASE, - RESPAWNPOINT, - BOX, // attr1 = angle, attr2 = idx, attr3 = weight - BARREL, // attr1 = angle, attr2 = idx, attr3 = weight, attr4 = health - PLATFORM, // attr1 = angle, attr2 = idx, attr3 = tag, attr4 = speed - ELEVATOR, // attr1 = angle, attr2 = idx, attr3 = tag, attr4 = speed - FLAG, // attr1 = angle, attr2 = team MAXENTTYPES }; -enum -{ - TRIGGER_RESET = 0, - TRIGGERING, - TRIGGERED, - TRIGGER_RESETTING, - TRIGGER_DISAPPEARED -}; - -struct fpsentity : extentity -{ - int triggerstate, lasttrigger; - - fpsentity() : triggerstate(TRIGGER_RESET), lasttrigger(0) {} -}; - -enum { GUN_FIST = 0, GUN_SG, GUN_CG, GUN_RL, GUN_RIFLE, GUN_GL, GUN_PISTOL, GUN_FIREBALL, GUN_ICEBALL, GUN_SLIMEBALL, GUN_BITE, GUN_BARREL, NUMGUNS }; +enum { GUN_FIST = 0, GUN_SG, GUN_CG, GUN_RL, GUN_RIFLE, GUN_GL, GUN_PISTOL, NUMGUNS }; enum { A_BLUE, A_GREEN, A_YELLOW }; // armour types... take 20/40/60 % off -enum { M_NONE = 0, M_SEARCH, M_HOME, M_ATTACKING, M_PAIN, M_SLEEP, M_AIMING }; // monster states enum { @@ -76,20 +50,10 @@ enum M_NOAMMO = 1<<2, M_INSTA = 1<<3, M_EFFICIENCY = 1<<4, - M_TACTICS = 1<<5, - M_CAPTURE = 1<<6, - M_REGEN = 1<<7, - M_CTF = 1<<8, - M_PROTECT = 1<<9, - M_HOLD = 1<<10, M_EDIT = 1<<12, M_DEMO = 1<<13, M_LOCAL = 1<<14, - M_LOBBY = 1<<15, - M_DMSP = 1<<16, - M_CLASSICSP = 1<<17, - M_SLOWMO = 1<<18, - M_COLLECT = 1<<19 + M_LOBBY = 1<<15 }; static struct gamemodeinfo @@ -99,8 +63,6 @@ static struct gamemodeinfo const char *info; } gamemodes[] = { - { "SP", M_LOCAL | M_CLASSICSP, NULL }, - { "DMSP", M_LOCAL | M_DMSP, NULL }, { "demo", M_DEMO | M_LOCAL, NULL}, { "ffa", M_LOBBY, "Free For All: Collect items for ammo. Frag everyone to score points." }, { "coop edit", M_EDIT, "Cooperative Editing: Edit maps with multiple players simultaneously." }, @@ -109,25 +71,9 @@ static struct gamemodeinfo { "insta team", M_NOITEMS | M_INSTA | M_TEAM, "Instagib Team: You spawn with full rifle ammo and die instantly from one shot. There are no items. Frag \fs\f3the enemy team\fr to score points for \fs\f1your team\fr." }, { "efficiency", M_NOITEMS | M_EFFICIENCY, "Efficiency: You spawn with all weapons and armour. There are no items. Frag everyone to score points." }, { "effic team", M_NOITEMS | M_EFFICIENCY | M_TEAM, "Efficiency Team: You spawn with all weapons and armour. There are no items. Frag \fs\f3the enemy team\fr to score points for \fs\f1your team\fr." }, - { "tactics", M_NOITEMS | M_TACTICS, "Tactics: You spawn with two random weapons and armour. There are no items. Frag everyone to score points." }, - { "tac team", M_NOITEMS | M_TACTICS | M_TEAM, "Tactics Team: You spawn with two random weapons and armour. There are no items. Frag \fs\f3the enemy team\fr to score points for \fs\f1your team\fr." }, - { "capture", M_NOAMMO | M_TACTICS | M_CAPTURE | M_TEAM, "Capture: Capture neutral bases or steal \fs\f3enemy bases\fr by standing next to them. \fs\f1Your team\fr scores points for every 10 seconds it holds a base. You spawn with two random weapons and armour. Collect extra ammo that spawns at \fs\f1your bases\fr. There are no ammo items." }, - { "regen capture", M_NOITEMS | M_CAPTURE | M_REGEN | M_TEAM, "Regen Capture: Capture neutral bases or steal \fs\f3enemy bases\fr by standing next to them. \fs\f1Your team\fr scores points for every 10 seconds it holds a base. Regenerate health and ammo by standing next to \fs\f1your bases\fr. There are no items." }, - { "ctf", M_CTF | M_TEAM, "Capture The Flag: Capture \fs\f3the enemy flag\fr and bring it back to \fs\f1your flag\fr to score points for \fs\f1your team\fr. Collect items for ammo." }, - { "insta ctf", M_NOITEMS | M_INSTA | M_CTF | M_TEAM, "Instagib Capture The Flag: Capture \fs\f3the enemy flag\fr and bring it back to \fs\f1your flag\fr to score points for \fs\f1your team\fr. You spawn with full rifle ammo and die instantly from one shot. There are no items." }, - { "protect", M_CTF | M_PROTECT | M_TEAM, "Protect The Flag: Touch \fs\f3the enemy flag\fr to score points for \fs\f1your team\fr. Pick up \fs\f1your flag\fr to protect it. \fs\f1Your team\fr loses points if a dropped flag resets. Collect items for ammo." }, - { "insta protect", M_NOITEMS | M_INSTA | M_CTF | M_PROTECT | M_TEAM, "Instagib Protect The Flag: Touch \fs\f3the enemy flag\fr to score points for \fs\f1your team\fr. Pick up \fs\f1your flag\fr to protect it. \fs\f1Your team\fr loses points if a dropped flag resets. You spawn with full rifle ammo and die instantly from one shot. There are no items." }, - { "hold", M_CTF | M_HOLD | M_TEAM, "Hold The Flag: Hold \fs\f7the flag\fr for 20 seconds to score points for \fs\f1your team\fr. Collect items for ammo." }, - { "insta hold", M_NOITEMS | M_INSTA | M_CTF | M_HOLD | M_TEAM, "Instagib Hold The Flag: Hold \fs\f7the flag\fr for 20 seconds to score points for \fs\f1your team\fr. You spawn with full rifle ammo and die instantly from one shot. There are no items." }, - { "effic ctf", M_NOITEMS | M_EFFICIENCY | M_CTF | M_TEAM, "Efficiency Capture The Flag: Capture \fs\f3the enemy flag\fr and bring it back to \fs\f1your flag\fr to score points for \fs\f1your team\fr. You spawn with all weapons and armour. There are no items." }, - { "effic protect", M_NOITEMS | M_EFFICIENCY | M_CTF | M_PROTECT | M_TEAM, "Efficiency Protect The Flag: Touch \fs\f3the enemy flag\fr to score points for \fs\f1your team\fr. Pick up \fs\f1your flag\fr to protect it. \fs\f1Your team\fr loses points if a dropped flag resets. You spawn with all weapons and armour. There are no items." }, - { "effic hold", M_NOITEMS | M_EFFICIENCY | M_CTF | M_HOLD | M_TEAM, "Efficiency Hold The Flag: Hold \fs\f7the flag\fr for 20 seconds to score points for \fs\f1your team\fr. You spawn with all weapons and armour. There are no items." }, - { "collect", M_COLLECT | M_TEAM, "Skull Collector: Frag \fs\f3the enemy team\fr to drop \fs\f3skulls\fr. Collect them and bring them to \fs\f3the enemy base\fr to score points for \fs\f1your team\fr or steal back \fs\f1your skulls\fr. Collect items for ammo." }, - { "insta collect", M_NOITEMS | M_INSTA | M_COLLECT | M_TEAM, "Instagib Skull Collector: Frag \fs\f3the enemy team\fr to drop \fs\f3skulls\fr. Collect them and bring them to \fs\f3the enemy base\fr to score points for \fs\f1your team\fr or steal back \fs\f1your skulls\fr. You spawn with full rifle ammo and die instantly from one shot. There are no items." }, - { "effic collect", M_NOITEMS | M_EFFICIENCY | M_COLLECT | M_TEAM, "Efficiency Skull Collector: Frag \fs\f3the enemy team\fr to drop \fs\f3skulls\fr. Collect them and bring them to \fs\f3the enemy base\fr to score points for \fs\f1your team\fr or steal back \fs\f1your skulls\fr. You spawn with all weapons and armour. There are no items." } }; -#define STARTGAMEMODE (-3) +#define STARTGAMEMODE (-1) #define NUMGAMEMODES ((int)(sizeof(gamemodes)/sizeof(gamemodes[0]))) #define m_valid(mode) ((mode) >= STARTGAMEMODE && (mode) < STARTGAMEMODE + NUMGAMEMODES) @@ -139,16 +85,7 @@ static struct gamemodeinfo #define m_noitems (m_check(gamemode, M_NOITEMS)) #define m_noammo (m_check(gamemode, M_NOAMMO|M_NOITEMS)) #define m_insta (m_check(gamemode, M_INSTA)) -#define m_tactics (m_check(gamemode, M_TACTICS)) #define m_efficiency (m_check(gamemode, M_EFFICIENCY)) -#define m_capture (m_check(gamemode, M_CAPTURE)) -#define m_capture_only (m_checkonly(gamemode, M_CAPTURE, M_REGEN)) -#define m_regencapture (m_checkall(gamemode, M_CAPTURE | M_REGEN)) -#define m_ctf (m_check(gamemode, M_CTF)) -#define m_ctf_only (m_checkonly(gamemode, M_CTF, M_PROTECT | M_HOLD)) -#define m_protect (m_checkall(gamemode, M_CTF | M_PROTECT)) -#define m_hold (m_checkall(gamemode, M_CTF | M_HOLD)) -#define m_collect (m_check(gamemode, M_COLLECT)) #define m_teammode (m_check(gamemode, M_TEAM)) #define isteam(a,b) (m_teammode && strcmp(a, b)==0) @@ -159,10 +96,6 @@ static struct gamemodeinfo #define m_botmode (m_checknot(gamemode, M_DEMO|M_LOCAL)) #define m_mp(mode) (m_checknot(mode, M_LOCAL)) -#define m_sp (m_check(gamemode, M_DMSP | M_CLASSICSP)) -#define m_dmsp (m_check(gamemode, M_DMSP)) -#define m_classicsp (m_check(gamemode, M_CLASSICSP)) - enum { MM_AUTH = -1, MM_OPEN = 0, MM_VETO, MM_LOCKED, MM_PRIVATE, MM_PASSWORD, MM_START = MM_AUTH }; static const char * const mastermodenames[] = { "auth", "open", "veto", "locked", "private", "password" }; @@ -178,6 +111,7 @@ enum S_PAIN1, S_PAIN2, S_PAIN3, S_PAIN4, S_PAIN5, S_PAIN6, S_DIE1, S_DIE2, S_FLAUNCH, S_FEXPLODE, + S_SPLASH1, S_SPLASH2, S_JUMPPAD, S_PISTOL, S_V_FIGHT, @@ -207,11 +141,9 @@ enum N_TIMEUP, N_FORCEINTERMISSION, N_SERVMSG, N_ITEMLIST, N_RESUME, N_EDITMODE, N_EDITENT, N_EDITF, N_EDITT, N_EDITM, N_FLIP, N_COPY, N_PASTE, N_ROTATE, N_REPLACE, N_DELCUBE, N_REMIP, N_EDITVSLOT, N_UNDO, N_REDO, N_NEWMAP, N_GETMAP, N_SENDMAP, N_CLIPBOARD, N_EDITVAR, - N_MASTERMODE, N_KICK, N_CLEARBANS, N_CURRENTMASTER, N_SPECTATOR, N_SETMASTER, N_SETTEAM, - N_BASES, N_BASEINFO, N_BASESCORE, N_REPAMMO, N_BASEREGEN, N_ANNOUNCE, + N_MASTERMODE, N_KICK, N_CLEARBANS, N_CURRENTMASTER, N_SPECTATOR, N_SETMASTER, N_SETTEAM, N_ANNOUNCE, N_LISTDEMOS, N_SENDDEMOLIST, N_GETDEMO, N_SENDDEMO, N_DEMOPLAYBACK, N_RECORDDEMO, N_STOPDEMO, N_CLEARDEMOS, - N_TAKEFLAG, N_RETURNFLAG, N_RESETFLAG, N_INVISFLAG, N_TRYDROPFLAG, N_DROPFLAG, N_SCOREFLAG, N_INITFLAGS, N_SAYTEAM, N_CLIENT, N_AUTHTRY, N_AUTHKICK, N_AUTHCHAL, N_AUTHANS, N_REQAUTH, @@ -237,11 +169,9 @@ static const int msgsizes[] = // size inclusive message token, 0 f N_TIMEUP, 2, N_FORCEINTERMISSION, 1, N_SERVMSG, 0, N_ITEMLIST, 0, N_RESUME, 0, N_EDITMODE, 2, N_EDITENT, 11, N_EDITF, 16, N_EDITT, 16, N_EDITM, 16, N_FLIP, 14, N_COPY, 14, N_PASTE, 14, N_ROTATE, 15, N_REPLACE, 17, N_DELCUBE, 14, N_REMIP, 1, N_EDITVSLOT, 16, N_UNDO, 0, N_REDO, 0, N_NEWMAP, 2, N_GETMAP, 1, N_SENDMAP, 0, N_EDITVAR, 0, - N_MASTERMODE, 2, N_KICK, 0, N_CLEARBANS, 1, N_CURRENTMASTER, 0, N_SPECTATOR, 3, N_SETMASTER, 0, N_SETTEAM, 0, - N_BASES, 0, N_BASEINFO, 0, N_BASESCORE, 0, N_REPAMMO, 1, N_BASEREGEN, 6, N_ANNOUNCE, 2, + N_MASTERMODE, 2, N_KICK, 0, N_CLEARBANS, 1, N_CURRENTMASTER, 0, N_SPECTATOR, 3, N_SETMASTER, 0, N_SETTEAM, 0, N_ANNOUNCE, 2, N_LISTDEMOS, 1, N_SENDDEMOLIST, 0, N_GETDEMO, 3, N_SENDDEMO, 0, N_DEMOPLAYBACK, 3, N_RECORDDEMO, 2, N_STOPDEMO, 1, N_CLEARDEMOS, 2, - N_TAKEFLAG, 3, N_RETURNFLAG, 4, N_RESETFLAG, 6, N_INVISFLAG, 3, N_TRYDROPFLAG, 1, N_DROPFLAG, 7, N_SCOREFLAG, 10, N_INITFLAGS, 0, N_SAYTEAM, 0, N_CLIENT, 0, N_AUTHTRY, 0, N_AUTHKICK, 0, N_AUTHCHAL, 0, N_AUTHANS, 0, N_REQAUTH, 0, @@ -290,10 +220,6 @@ enum HICON_QUAD, - HICON_RED_FLAG, - HICON_BLUE_FLAG, - HICON_NEUTRAL_FLAG, - HICON_TOKEN, HICON_X = 20, @@ -319,25 +245,21 @@ static struct itemstat { int add, max, sound; const char *name; int icon, info; {20000, 30000, S_ITEMPUP, "Q", HICON_QUAD, -1}, }; -#define MAXRAYS 20 +#define MAXRAYS 12 #define EXP_SELFDAMDIV 2 #define EXP_SELFPUSH 2.5f #define EXP_DISTSCALE 1.5f static const struct guninfo { int sound, attackdelay, damage, spread, projspeed, kickamount, range, rays, hitpush, exprad, ttl; const char *name, *file; short part; } guns[NUMGUNS] = { - { S_PUNCH1, 250, 50, 0, 0, 0, 14, 1, 80, 0, 0, "fist", "fist", 0 }, - { S_SG, 1400, 10, 400, 0, 20, 1024, 20, 80, 0, 0, "shotgun", "shotg", 0 }, - { S_CG, 100, 30, 100, 0, 7, 1024, 1, 80, 0, 0, "chaingun", "chaing", 0 }, - { S_RLFIRE, 800, 120, 0, 320, 10, 1024, 1, 160, 40, 0, "rocketlauncher", "rocket", 0 }, - { S_RIFLE, 1500, 100, 0, 0, 30, 2048, 1, 80, 0, 0, "rifle", "rifle", 0 }, - { S_FLAUNCH, 600, 90, 0, 200, 10, 1024, 1, 250, 45, 1500, "grenadelauncher", "gl", 0 }, - { S_PISTOL, 500, 35, 50, 0, 7, 1024, 1, 80, 0, 0, "pistol", "pistol", 0 }, - { S_FLAUNCH, 200, 20, 0, 200, 1, 1024, 1, 80, 40, 0, "fireball", NULL, PART_FIREBALL1 }, - { S_ICEBALL, 200, 40, 0, 120, 1, 1024, 1, 80, 40, 0, "iceball", NULL, PART_FIREBALL2 }, - { S_SLIMEBALL, 200, 30, 0, 640, 1, 1024, 1, 80, 40, 0, "slimeball", NULL, PART_FIREBALL3 }, - { S_PIGR1, 250, 50, 0, 0, 1, 12, 1, 80, 0, 0, "bite", NULL, 0 }, - { -1, 0, 120, 0, 0, 0, 0, 1, 80, 40, 0, "barrel", NULL, 0 } + // delay| dmg| spr| spd| kck| rng| ray| pus| exp| + { S_PUNCH1, 100, 30, 0, 0, 0, 30, 1, 80, 0, 0, "fist", "fist", 0 }, + { S_SG, 1000, 20, 280, 0, 20, 1024, MAXRAYS, 80, 0, 0, "shotgun", "shotg", 0 }, + { S_CG, 100, 20, 70, 0, 10, 1024, 1, 80, 0, 0, "chaingun", "chaing", 0 }, + { S_RLFIRE, 800, 120, 0, 270, 10, 1024, 1, 160, 40, 0, "rocketlauncher", "rocket", 0 }, + { S_RIFLE, 1200, 120, 0, 0, 30, 2048, 1, 80, 0, 0, "rifle", "rifle", 0 }, + { S_FLAUNCH, 600, 90, 0, 300, 20, 1024, 1, 250, 45, 1500, "grenadelauncher", "gl", 0 }, + { S_PISTOL, 400, 60, 160, 0, 10, 1024, 1, 80, 0, 0, "pistol", "pistol", 0 }, }; #include "ai.h" @@ -439,30 +361,6 @@ struct fpsstate gunselect = GUN_RIFLE; ammo[GUN_RIFLE] = 100; } - else if(m_regencapture) - { - extern int regenbluearmour; - if(regenbluearmour) - { - armourtype = A_BLUE; - armour = 25; - } - gunselect = GUN_PISTOL; - ammo[GUN_PISTOL] = 40; - ammo[GUN_GL] = 1; - } - else if(m_tactics) - { - armourtype = A_GREEN; - armour = 100; - ammo[GUN_PISTOL] = 40; - int spawngun1 = rnd(5)+1, spawngun2; - gunselect = spawngun1; - baseammo(spawngun1, m_noitems ? 2 : 1); - do spawngun2 = rnd(5)+1; while(spawngun1==spawngun2); - baseammo(spawngun2, m_noitems ? 2 : 1); - if(m_noitems) ammo[GUN_GL] += 1; - } else if(m_efficiency) { armourtype = A_GREEN; @@ -471,23 +369,6 @@ struct fpsstate gunselect = GUN_CG; ammo[GUN_CG] /= 2; } - else if(m_ctf || m_collect) - { - armourtype = A_BLUE; - armour = 50; - ammo[GUN_PISTOL] = 40; - ammo[GUN_GL] = 1; - } - else if(m_sp) - { - if(m_dmsp) - { - armourtype = A_BLUE; - armour = 25; - } - ammo[GUN_PISTOL] = 80; - ammo[GUN_GL] = 1; - } else { armourtype = A_BLUE; @@ -635,8 +516,6 @@ namespace entities extern void preloadentities(); extern void renderentities(); - extern void resettriggers(); - extern void checktriggers(); extern void checkitems(fpsent *d); extern void checkquad(int time, fpsent *d); extern void resetspawns(); @@ -736,7 +615,6 @@ namespace game extern bool addmsg(int type, const char *fmt = NULL, ...); extern void switchname(const char *name); extern void switchteam(const char *name); - extern void switchplayermodel(int playermodel); extern void sendmapinfo(); extern void stopdemo(); extern void changemap(const char *name, int mode); @@ -744,32 +622,6 @@ namespace game extern void c2sinfo(bool force = false); extern void sendposition(fpsent *d, bool reliable = false); - // monster - struct monster; - extern vector<monster *> monsters; - - extern void clearmonsters(); - extern void preloadmonsters(); - extern void stackmonster(monster *d, physent *o); - extern void updatemonsters(int curtime); - extern void rendermonsters(); - extern void suicidemonster(monster *m); - extern void hitmonster(int damage, monster *m, fpsent *at, const vec &vel, int gun); - extern void monsterkilled(); - extern void endsp(bool allkilled); - extern void spsummary(int accuracy); - - // movable - struct movable; - extern vector<movable *> movables; - - extern void clearmovables(); - extern void stackmovable(movable *d, physent *o); - extern void updatemovables(int curtime); - extern void rendermovables(); - extern void suicidemovable(movable *m); - extern void hitmovable(int damage, movable *m, fpsent *at, const vec &vel, int gun); - // weapon extern int getweapon(const char *name); extern void shoot(fpsent *d, const vec &targ); @@ -818,9 +670,7 @@ namespace game extern void saveragdoll(fpsent *d); extern void clearragdolls(); extern void moveragdolls(); - extern void changedplayermodel(); extern const playermodelinfo &getplayermodelinfo(fpsent *d); - extern int chooserandomplayermodel(int seed); extern void swayhudgun(int curtime); extern vec hudgunorigin(int gun, const vec &from, const vec &to, fpsent *d); } diff --git a/src/fpsgame/game.h.gch b/src/fpsgame/game.h.gch Binary files differnew file mode 100644 index 0000000..b1bc4a9 --- /dev/null +++ b/src/fpsgame/game.h.gch diff --git a/src/fpsgame/render.cpp b/src/fpsgame/render.cpp index d6c8b91..4c06e07 100644 --- a/src/fpsgame/render.cpp +++ b/src/fpsgame/render.cpp @@ -4,15 +4,14 @@ struct spawninfo { const extentity *e; float weight; }; extern float gatherspawninfos(dynent *d, int tag, vector<spawninfo> &spawninfos); namespace game -{ +{ vector<fpsent *> bestplayers; vector<const char *> bestteams; VARP(ragdoll, 0, 1, 1); VARP(ragdollmillis, 0, 10000, 300000); VARP(ragdollfade, 0, 1000, 300000); - VARFP(playermodel, 0, 0, 4, changedplayermodel()); - VARP(forceplayermodels, 0, 0, 1); + VARP(playermodel, 0, 0, 0); VARP(hidedead, 0, 0, 2); vector<fpsent *> ragdolls; @@ -27,7 +26,7 @@ namespace game r->attackchan = r->idlechan = -1; if(d==player1) r->playermodel = playermodel; ragdolls.add(r); - d->ragdoll = NULL; + d->ragdoll = NULL; } void clearragdolls() @@ -49,81 +48,38 @@ namespace game } } - static const playermodelinfo playermodels[5] = + static const playermodelinfo playermodels[1] = { { "mrfixit", "mrfixit/blue", "mrfixit/red", "mrfixit/hudguns", NULL, "mrfixit/horns", { "mrfixit/armor/blue", "mrfixit/armor/green", "mrfixit/armor/yellow" }, "mrfixit", "mrfixit_blue", "mrfixit_red", true }, - { "snoutx10k", "snoutx10k/blue", "snoutx10k/red", "snoutx10k/hudguns", NULL, "snoutx10k/wings", { "snoutx10k/armor/blue", "snoutx10k/armor/green", "snoutx10k/armor/yellow" }, "snoutx10k", "snoutx10k_blue", "snoutx10k_red", true }, - //{ "ogro/green", "ogro/blue", "ogro/red", "mrfixit/hudguns", "ogro/vwep", NULL, { NULL, NULL, NULL }, "ogro", "ogro_blue", "ogro_red", false }, - { "ogro2", "ogro2/blue", "ogro2/red", "mrfixit/hudguns", NULL, "ogro2/quad", { "ogro2/armor/blue", "ogro2/armor/green", "ogro2/armor/yellow" }, "ogro", "ogro_blue", "ogro_red", true }, - { "inky", "inky/blue", "inky/red", "inky/hudguns", NULL, "inky/quad", { "inky/armor/blue", "inky/armor/green", "inky/armor/yellow" }, "inky", "inky_blue", "inky_red", true }, - { "captaincannon", "captaincannon/blue", "captaincannon/red", "captaincannon/hudguns", NULL, "captaincannon/quad", { "captaincannon/armor/blue", "captaincannon/armor/green", "captaincannon/armor/yellow" }, "captaincannon", "captaincannon_blue", "captaincannon_red", true } }; - int chooserandomplayermodel(int seed) - { - return (seed&0xFFFF)%(sizeof(playermodels)/sizeof(playermodels[0])); - } - const playermodelinfo *getplayermodelinfo(int n) { - if(size_t(n) >= sizeof(playermodels)/sizeof(playermodels[0])) return NULL; - return &playermodels[n]; + (void) n; + return &playermodels[0]; } const playermodelinfo &getplayermodelinfo(fpsent *d) { - const playermodelinfo *mdl = getplayermodelinfo(d==player1 || forceplayermodels ? playermodel : d->playermodel); + const playermodelinfo *mdl = getplayermodelinfo(0); if(!mdl) mdl = getplayermodelinfo(playermodel); return *mdl; } - void changedplayermodel() - { - if(player1->clientnum < 0) player1->playermodel = playermodel; - if(player1->ragdoll) cleanragdoll(player1); - loopv(ragdolls) - { - fpsent *d = ragdolls[i]; - if(!d->ragdoll) continue; - if(!forceplayermodels) - { - const playermodelinfo *mdl = getplayermodelinfo(d->playermodel); - if(mdl) continue; - } - cleanragdoll(d); - } - loopv(players) - { - fpsent *d = players[i]; - if(d == player1 || !d->ragdoll) continue; - if(!forceplayermodels) - { - const playermodelinfo *mdl = getplayermodelinfo(d->playermodel); - if(mdl) continue; - } - cleanragdoll(d); - } - } - void preloadplayermodel() { - loopi(sizeof(playermodels)/sizeof(playermodels[0])) + const playermodelinfo *mdl = getplayermodelinfo(0); + if(m_teammode) { - const playermodelinfo *mdl = getplayermodelinfo(i); - if(!mdl) break; - if(i != playermodel && (!multiplayer(false) || forceplayermodels)) continue; - if(m_teammode) - { - preloadmodel(mdl->blueteam); - preloadmodel(mdl->redteam); - } - else preloadmodel(mdl->ffa); - if(mdl->vwep) preloadmodel(mdl->vwep); - if(mdl->quad) preloadmodel(mdl->quad); - loopj(3) if(mdl->armour[j]) preloadmodel(mdl->armour[j]); + preloadmodel(mdl->blueteam); + preloadmodel(mdl->redteam); } + else preloadmodel(mdl->ffa); + if(mdl->vwep) preloadmodel(mdl->vwep); + if(mdl->quad) preloadmodel(mdl->quad); + loopj(3) if(mdl->armour[j]) preloadmodel(mdl->armour[j]); } - + VAR(testquad, 0, 0, 1); VAR(testarmour, 0, 0, 1); VAR(testteam, 0, 0, 3); @@ -180,13 +136,6 @@ namespace game case 2: mdlname = mdl.redteam; break; } renderclient(d, mdlname, a[0].tag ? a : NULL, hold, attack, delay, lastaction, intermission && d->state!=CS_DEAD ? 0 : d->lastpain, fade, ragdoll && mdl.ragdoll); -#if 0 - if(d->state!=CS_DEAD && d->quadmillis) - { - entitylight light; - rendermodel(&light, "quadrings", ANIM_MAPMODEL|ANIM_LOOP, vec(d->o).sub(vec(0, 0, d->eyeheight/2)), 360*lastmillis/1000.0f, 0, MDL_DYNSHADOW | MDL_CULL_VFC | MDL_CULL_DIST); - } -#endif } VARP(teamskins, 0, 0, 1); @@ -336,13 +285,11 @@ namespace game int team = 0; if(teamskins || m_teammode) team = isteam(player1->team, d->team) ? 1 : 2; float fade = 1.0f; - if(ragdollmillis && ragdollfade) + if(ragdollmillis && ragdollfade) fade -= clamp(float(lastmillis - (d->lastupdate + max(ragdollmillis - ragdollfade, 0)))/min(ragdollmillis, ragdollfade), 0.0f, 1.0f); renderplayer(d, getplayermodelinfo(d), team, fade, mainpass); - } + } if(isthirdperson() && !followingplayer() && (player1->state!=CS_DEAD || hidedead != 1)) renderplayer(player1, getplayermodelinfo(player1), teamskins || m_teammode ? 1 : 0, 1, mainpass); - rendermonsters(); - rendermovables(); entities::renderentities(); renderbouncers(); renderprojectiles(); @@ -444,8 +391,8 @@ namespace game void drawhudgun() { fpsent *d = hudplayer(); - if(d->state==CS_SPECTATOR || d->state==CS_EDITING || !hudgun || editmode) - { + if(d->state==CS_SPECTATOR || d->state==CS_EDITING || !hudgun || editmode) + { d->muzzle = player1->muzzle = vec(-1, -1, -1); return; } @@ -540,10 +487,7 @@ namespace game void preloadsounds() { - for(int i = S_JUMP; i <= S_SPLASH2; i++) preloadsound(i); - for(int i = S_JUMPPAD; i <= S_PISTOL; i++) preloadsound(i); - for(int i = S_V_BOOST; i <= S_V_QUAD10; i++) preloadsound(i); - for(int i = S_BURN; i <= S_HIT; i++) preloadsound(i); + for(int i = S_JUMP; i <= S_HIT; i++) preloadsound(i); } void preload() @@ -553,7 +497,6 @@ namespace game preloadplayermodel(); preloadsounds(); entities::preloadentities(); - if(m_sp) preloadmonsters(); } } diff --git a/src/fpsgame/scoreboard.cpp b/src/fpsgame/scoreboard.cpp index ec99dda..40a1246 100644 --- a/src/fpsgame/scoreboard.cpp +++ b/src/fpsgame/scoreboard.cpp @@ -37,11 +37,6 @@ namespace game else return false; } else if(b->state==CS_SPECTATOR) return true; - if(m_ctf || m_collect) - { - if(a->flags > b->flags) return true; - if(a->flags < b->flags) return false; - } if(a->frags > b->frags) return true; if(a->frags < b->frags) return false; return strcmp(a->name, b->name) < 0; diff --git a/src/fpsgame/server.cpp b/src/fpsgame/server.cpp index fb02c5e..158772f 100644 --- a/src/fpsgame/server.cpp +++ b/src/fpsgame/server.cpp @@ -271,15 +271,15 @@ namespace server void setexceeded() { if(state.state==CS_ALIVE && !exceeded && !checkpushed(gamemillis, calcpushrange())) exceeded = gamemillis; - scheduleexceeded(); + scheduleexceeded(); } - + void setpushed() { pushed = max(pushed, gamemillis); if(exceeded && checkpushed(exceeded, calcpushrange())) exceeded = 0; } - + bool checkexceeded() { return state.state==CS_ALIVE && exceeded && gamemillis > exceeded + calcpushrange(); @@ -421,13 +421,13 @@ namespace server if(getclientip(c.clientnum) == ip) disconnect_client(c.clientnum, DISC_KICK); } } - + struct maprotation { static int exclude; int modes; string map; - + int calcmodemask() const { return modes&(1<<NUMGAMEMODES) ? modes & ~exclude : modes; } bool hasmode(int mode, int offset = STARTGAMEMODE) const { return (calcmodemask() & (1 << (mode-offset))) != 0; } @@ -510,7 +510,7 @@ namespace server for(; *h && *n; h++) { if(*h == *n) n++; - else if(*h != ' ') break; + else if(*h != ' ') break; } if(!*n) return true; if(*n == '.') return !*h; @@ -555,7 +555,7 @@ namespace server } return modemask; } - + bool addmaprotation(int modemask, const char *map) { if(!map[0]) loopk(NUMGAMEMODES) if(modemask&(1<<k) && !m_check(k+STARTGAMEMODE, M_EDIT)) modemask &= ~(1<<k); @@ -566,7 +566,7 @@ namespace server copystring(rot.map, map); return true; } - + void addmaprotations(tagval *args, int numargs) { vector<char *> modes, maps; @@ -587,7 +587,7 @@ namespace server rot.map[0] = '\0'; } } - + COMMAND(maprotationreset, ""); COMMANDN(maprotation, addmaprotations, "ss2V"); @@ -653,7 +653,7 @@ namespace server teamkillkick &kick = teamkillkicks.add(); kick.modes = genmodemask(modes); kick.limit = *limit; - kick.ban = *ban > 0 ? *ban*60000 : (*ban < 0 ? 0 : 30*60000); + kick.ban = *ban > 0 ? *ban*60000 : (*ban < 0 ? 0 : 30*60000); modes.deletearrays(); } @@ -673,8 +673,8 @@ namespace server if(!m_timed || actor->state.aitype != AI_NONE || actor->local || actor->privilege || (victim && victim->state.aitype != AI_NONE)) return; shouldcheckteamkills = true; uint ip = getclientip(actor->clientnum); - loopv(teamkills) if(teamkills[i].ip == ip) - { + loopv(teamkills) if(teamkills[i].ip == ip) + { teamkills[i].teamkills += n; return; } @@ -785,7 +785,7 @@ namespace server int numclients(int exclude = -1, bool nospec = true, bool noai = true, bool priv = false) { int n = 0; - loopv(clients) + loopv(clients) { clientinfo *ci = clients[i]; if(ci->clientnum!=exclude && (!nospec || ci->state.state!=CS_SPECTATOR || (priv && (ci->privilege || ci->local))) && (!noai || ci->state.aitype == AI_NONE)) n++; @@ -842,20 +842,12 @@ namespace server }; #define SERVMODE 1 - #include "capture.h" - #include "ctf.h" - #include "collect.h" - - captureservmode capturemode; - ctfservmode ctfmode; - collectservmode collectmode; servmode *smode = NULL; bool canspawnitem(int type) { return !m_noitems && (type>=I_SHELLS && type<=I_QUAD && (!m_noammo || type<I_SHELLS || type>I_CARTRIDGES)); } int spawntime(int type) { - if(m_classicsp) return INT_MAX; int np = numclients(-1, true, false); np = np<3 ? 4 : (np>4 ? 2 : 3); // spawn times are dependent on number of players int sec = 0; @@ -882,7 +874,6 @@ namespace server { case I_GREENARMOUR: case I_YELLOWARMOUR: - return !m_classicsp; case I_BOOST: case I_QUAD: return true; @@ -890,7 +881,7 @@ namespace server return false; } } - + bool pickup(int i, int sender) // server side item pickup, acknowledge first client that gets it { if((m_timed && gamemillis>=gamelimit) || !sents.inrange(i) || !sents[i].spawned) return false; @@ -1045,7 +1036,7 @@ namespace server loopi(n) delete[] demos[i].data; demos.remove(0, n); } - + void adddemo() { if(!demotmp) return; @@ -1062,7 +1053,7 @@ namespace server demotmp->read(d.data, len); DELETEP(demotmp); } - + void enddemorecord() { if(!demorecord) return; @@ -1374,7 +1365,7 @@ namespace server { char *name; char *desc; - + userkey() : name(NULL), desc(NULL) {} userkey(char *name, char *desc) : name(name), desc(desc) {} }; @@ -1449,7 +1440,7 @@ namespace server if(wantpriv <= ci->privilege) return true; else if(wantpriv <= PRIV_MASTER && !force) { - if(ci->state.state==CS_SPECTATOR) + if(ci->state.state==CS_SPECTATOR) { sendf(ci->clientnum, 1, "ris", N_SERVMSG, "Spectators may not claim master."); return false; @@ -1484,11 +1475,11 @@ namespace server allowedips.shrink(0); } string msg; - if(val && authname) + if(val && authname) { if(authdesc && authdesc[0]) formatstring(msg, "%s claimed %s as '\fs\f5%s\fr' [\fs\f0%s\fr]", colorname(ci), name, authname, authdesc); else formatstring(msg, "%s claimed %s as '\fs\f5%s\fr'", colorname(ci), name, authname); - } + } else formatstring(msg, "%s %s %s", colorname(ci), val ? "claimed" : "relinquished", name); packetbuf p(MAXTRANS, ENET_PACKET_FLAG_RELIABLE); putint(p, N_SERVMSG); @@ -1592,7 +1583,12 @@ namespace server } uchar operator[](int msg) const { return msg >= 0 && msg < NUMMSG ? msgmask[msg] : 0; } - } msgfilter(-1, N_CONNECT, N_SERVINFO, N_INITCLIENT, N_WELCOME, N_MAPCHANGE, N_SERVMSG, N_DAMAGE, N_HITPUSH, N_SHOTFX, N_EXPLODEFX, N_DIED, N_SPAWNSTATE, N_FORCEDEATH, N_TEAMINFO, N_ITEMACC, N_ITEMSPAWN, N_TIMEUP, N_CDIS, N_CURRENTMASTER, N_PONG, N_RESUME, N_BASESCORE, N_BASEINFO, N_BASEREGEN, N_ANNOUNCE, N_SENDDEMOLIST, N_SENDDEMO, N_DEMOPLAYBACK, N_SENDMAP, N_DROPFLAG, N_SCOREFLAG, N_RETURNFLAG, N_RESETFLAG, N_INVISFLAG, N_CLIENT, N_AUTHCHAL, N_INITAI, N_EXPIRETOKENS, N_DROPTOKENS, N_STEALTOKENS, N_DEMOPACKET, -2, N_REMIP, N_NEWMAP, N_GETMAP, N_SENDMAP, N_CLIPBOARD, -3, N_EDITENT, N_EDITF, N_EDITT, N_EDITM, N_FLIP, N_COPY, N_PASTE, N_ROTATE, N_REPLACE, N_DELCUBE, N_EDITVAR, N_EDITVSLOT, N_UNDO, N_REDO, -4, N_POS, NUMMSG), + } msgfilter(-1, N_CONNECT, N_SERVINFO, N_INITCLIENT, N_WELCOME, N_MAPCHANGE, N_SERVMSG, N_DAMAGE, N_HITPUSH, N_SHOTFX, N_EXPLODEFX, N_DIED, + N_SPAWNSTATE, N_FORCEDEATH, N_TEAMINFO, N_ITEMACC, N_ITEMSPAWN, N_TIMEUP, N_CDIS, N_CURRENTMASTER, N_PONG, N_RESUME, + N_ANNOUNCE, N_SENDDEMOLIST, N_SENDDEMO, N_DEMOPLAYBACK, N_SENDMAP, + N_CLIENT, N_AUTHCHAL, N_INITAI, N_EXPIRETOKENS, N_DROPTOKENS, N_STEALTOKENS, N_DEMOPACKET, -2, N_REMIP, + N_NEWMAP, N_GETMAP, N_SENDMAP, N_CLIPBOARD, -3, N_EDITENT, N_EDITF, N_EDITT, N_EDITM, N_FLIP, N_COPY, N_PASTE, N_ROTATE, N_REPLACE, + N_DELCUBE, N_EDITVAR, N_EDITVSLOT, N_UNDO, N_REDO, -4, N_POS, NUMMSG), connectfilter(-1, N_CONNECT, -2, N_AUTHANS, -3, N_PING, NUMMSG); int checktype(int type, clientinfo *ci) @@ -1928,7 +1924,7 @@ namespace server if(t.frags) { sendstring(t.team, p); putint(p, t.frags); } ); sendstring("", p); - } + } if(ci) { putint(p, N_SETTEAM); @@ -2030,7 +2026,7 @@ namespace server } notgotitems = false; } - + void changemap(const char *s, int mode) { stopdemo(); @@ -2059,10 +2055,7 @@ namespace server sendf(-1, 1, "risii", N_MAPCHANGE, smapname, gamemode, 1); - if(m_capture) smode = &capturemode; - else if(m_ctf) smode = &ctfmode; - else if(m_collect) smode = &collectmode; - else smode = NULL; + smode = NULL; clearteaminfo(); if(m_teammode) autoteam(); @@ -2098,7 +2091,7 @@ namespace server changemap("", 1); return; } - if(next) + if(next) { curmaprotation = findmaprotation(gamemode, smapname); if(curmaprotation >= 0) nextmaprotation(); @@ -2107,7 +2100,7 @@ namespace server maprotation &rot = maprotations[curmaprotation]; changemap(rot.map, rot.findmode(gamemode)); } - + struct votecount { char *map; @@ -2154,7 +2147,7 @@ namespace server void forcemap(const char *map, int mode) { stopdemo(); - if(!map[0] && !m_check(mode, M_EDIT)) + if(!map[0] && !m_check(mode, M_EDIT)) { int idx = findmaprotation(mode, smapname); if(idx < 0 && smapname[0]) idx = findmaprotation(mode, ""); @@ -2170,14 +2163,14 @@ namespace server clientinfo *ci = getinfo(sender); if(!ci || (ci->state.state==CS_SPECTATOR && !ci->privilege && !ci->local) || (!ci->local && !m_mp(reqmode))) return; if(!m_valid(reqmode)) return; - if(!map[0] && !m_check(reqmode, M_EDIT)) + if(!map[0] && !m_check(reqmode, M_EDIT)) { int idx = findmaprotation(reqmode, smapname); if(idx < 0 && smapname[0]) idx = findmaprotation(reqmode, ""); if(idx < 0) return; map = maprotations[idx].map; } - if(lockmaprotation && !ci->local && ci->privilege < (lockmaprotation > 1 ? PRIV_ADMIN : PRIV_MASTER) && findmaprotation(reqmode, map) < 0) + if(lockmaprotation && !ci->local && ci->privilege < (lockmaprotation > 1 ? PRIV_ADMIN : PRIV_MASTER) && findmaprotation(reqmode, map) < 0) { sendf(sender, 1, "ris", N_SERVMSG, "This server has locked the map rotation."); return; @@ -2283,13 +2276,13 @@ namespace server actor->state.effectiveness += fragvalue*friends/float(max(enemies, 1)); } teaminfo *t = m_teammode ? teaminfos.access(actor->team) : NULL; - if(t) t->frags += fragvalue; + if(t) t->frags += fragvalue; sendf(-1, 1, "ri5", N_DIED, target->clientnum, actor->clientnum, actor->state.frags, t ? t->frags : 0); target->position.setsize(0); if(smode) smode->died(target, actor); ts.state = CS_DEAD; ts.lastdeath = gamemillis; - if(actor!=target && isteam(actor->team, target->team)) + if(actor!=target && isteam(actor->team, target->team)) { actor->state.teamkills++; addteamkill(actor, target, 1); @@ -2507,7 +2500,7 @@ namespace server if(nextexceeded && gamemillis > nextexceeded && (!m_timed || gamemillis < gamelimit)) { nextexceeded = 0; - loopvrev(clients) + loopvrev(clients) { clientinfo &c = *clients[i]; if(c.state.aitype != AI_NONE) continue; @@ -2670,7 +2663,7 @@ namespace server void clientdisconnect(int n) { clientinfo *ci = getinfo(n); - loopv(clients) if(clients[i]->authkickvictim == ci->clientnum) clients[i]->cleanauth(); + loopv(clients) if(clients[i]->authkickvictim == ci->clientnum) clients[i]->cleanauth(); if(ci->connected) { if(ci->privilege) setmaster(ci, false); @@ -2710,7 +2703,7 @@ namespace server verifybans(); } - } ipbans, gbans; + } ipbans, gbans; bool checkbans(uint ip) { @@ -2730,7 +2723,7 @@ namespace server ICOMMAND(clearipbans, "", (), ipbans.clear()); ICOMMAND(ipban, "s", (const char *ipname), ipbans.add(ipname)); - + int allowconnect(clientinfo *ci, const char *pwd = "") { if(ci->local) return DISC_NONE; @@ -2782,7 +2775,7 @@ namespace server if(ci->authkickvictim >= 0) { if(setmaster(ci, true, "", ci->authname, NULL, PRIV_AUTH, false, true)) - trykick(ci, ci->authkickvictim, ci->authkickreason, ci->authname, NULL, PRIV_AUTH); + trykick(ci, ci->authkickvictim, ci->authkickreason, ci->authname, NULL, PRIV_AUTH); ci->cleanauthkick(); } else setmaster(ci, true, "", ci->authname, NULL, PRIV_AUTH); @@ -2807,7 +2800,7 @@ namespace server if(ci->authdesc[0]) { userinfo *u = users.access(userkey(ci->authname, ci->authdesc)); - if(u) + if(u) { uint seed[3] = { ::hthash(serverauth) + detrnd(size_t(ci) + size_t(user) + size_t(desc), 0x10000), uint(totalmillis), randomMT() }; vector<char> buf; @@ -2828,7 +2821,7 @@ namespace server bool answerchallenge(clientinfo *ci, uint id, char *val, const char *desc) { - if(ci->authreq != id || strcmp(ci->authdesc, desc)) + if(ci->authreq != id || strcmp(ci->authdesc, desc)) { ci->cleanauth(); return !ci->connectauth; @@ -2842,7 +2835,7 @@ namespace server if(ci->authchallenge && checkchallenge(val, ci->authchallenge)) { userinfo *u = users.access(userkey(ci->authname, ci->authdesc)); - if(u) + if(u) { if(ci->connectauth) connected(ci); if(ci->authkickvictim >= 0) @@ -2853,8 +2846,8 @@ namespace server else setmaster(ci, true, "", ci->authname, ci->authdesc, u->privilege); } } - ci->cleanauth(); - } + ci->cleanauth(); + } else if(!requestmasterf("confauth %u %s\n", id, val)) { ci->cleanauth(); @@ -2872,7 +2865,7 @@ namespace server loopvrev(clients) { clientinfo *ci = clients[i]; - if(ci->authreq) authfailed(ci); + if(ci->authreq) authfailed(ci); } } @@ -2966,9 +2959,9 @@ namespace server { getstring(text, p); filtertext(text, text, false, false, MAXNAMELEN); - if(!text[0]) copystring(text, "unnamed"); + if(!text[0]) copystring(text, "Anonymous"); copystring(ci->name, text, MAXNAMELEN+1); - ci->playermodel = getint(p); + ci->playermodel = 0; string password, authdesc, authname; getstring(password, p, sizeof(password)); @@ -2994,7 +2987,7 @@ namespace server getstring(desc, p, sizeof(desc)); uint id = (uint)getint(p); getstring(ans, p, sizeof(ans)); - if(!answerchallenge(ci, id, ans, desc)) + if(!answerchallenge(ci, id, ans, desc)) { disconnect_client(sender, ci->connectauth); return; @@ -3036,8 +3029,8 @@ namespace server { case N_POS: { - int pcn = getuint(p); - p.get(); + int pcn = getuint(p); + p.get(); uint flags = getuint(p); clientinfo *cp = getinfo(pcn); if(cp && pcn != sender && cp->ownernum != sender) cp = NULL; @@ -3080,7 +3073,7 @@ namespace server if(cp && (!ci->local || demorecord || hasnonlocalclients()) && (cp->state.state==CS_ALIVE || cp->state.state==CS_EDITING)) { flushclientposition(*cp); - sendf(-1, 0, "ri4x", N_TELEPORT, pcn, teleport, teledest, cp->ownernum); + sendf(-1, 0, "ri4x", N_TELEPORT, pcn, teleport, teledest, cp->ownernum); } break; } @@ -3098,7 +3091,7 @@ namespace server } break; } - + case N_FROMAI: { int qcn = getint(p); @@ -3230,7 +3223,7 @@ namespace server hit.rays = getint(p); loopk(3) hit.dir[k] = getint(p)/DNF; } - if(cq) + if(cq) { cq->addevent(shot); cq->setpushed(); @@ -3303,14 +3296,14 @@ namespace server QUEUE_MSG; getstring(text, p); filtertext(ci->name, text, false, false, MAXNAMELEN); - if(!ci->name[0]) copystring(ci->name, "unnamed"); + if(!ci->name[0]) copystring(ci->name, "Anonymous"); QUEUE_STR(ci->name); break; } case N_SWITCHMODEL: { - ci->playermodel = getint(p); + ci->playermodel = 0; QUEUE_MSG; break; } @@ -3495,7 +3488,7 @@ namespace server { int val = getint(p); if(ci->privilege < (restrictdemos ? PRIV_ADMIN : PRIV_MASTER) && !ci->local) break; - if(!maxdemos || !maxdemosize) + if(!maxdemos || !maxdemosize) { sendf(ci->clientnum, 1, "ris", N_SERVMSG, "the server has disabled demo recording"); break; @@ -3630,7 +3623,7 @@ namespace server { ci->authkickvictim = victim; ci->authkickreason = newstring(text); - } + } break; } @@ -3668,17 +3661,17 @@ namespace server case N_PASTE: if(ci->state.state!=CS_SPECTATOR) sendclipboard(ci); goto genericmsg; - + case N_CLIPBOARD: { - int unpacklen = getint(p), packlen = getint(p); + int unpacklen = getint(p), packlen = getint(p); ci->cleanclipboard(false); if(ci->state.state==CS_SPECTATOR) { if(packlen > 0) p.subbuf(packlen); break; } - if(packlen <= 0 || packlen > (1<<16) || unpacklen <= 0) + if(packlen <= 0 || packlen > (1<<16) || unpacklen <= 0) { if(packlen > 0) p.subbuf(packlen); packlen = unpacklen = 0; @@ -3687,12 +3680,12 @@ namespace server putint(q, N_CLIPBOARD); putint(q, ci->clientnum); putint(q, unpacklen); - putint(q, packlen); + putint(q, packlen); if(packlen > 0) p.get(q.subbuf(packlen).buf, packlen); ci->clipboard = q.finalize(); ci->clipboard->referenceCount++; break; - } + } case N_EDITT: case N_REPLACE: @@ -3732,12 +3725,7 @@ namespace server case N_SERVCMD: getstring(text, p); break; - - #define PARSEMESSAGES 1 - #include "capture.h" - #include "ctf.h" - #include "collect.h" - #undef PARSEMESSAGES + case -1: disconnect_client(sender, DISC_MSGERR); diff --git a/src/fpsgame/waypoint.cpp b/src/fpsgame/waypoint.cpp index ed504e9..b59b388 100644 --- a/src/fpsgame/waypoint.cpp +++ b/src/fpsgame/waypoint.cpp @@ -616,7 +616,7 @@ namespace ai extentity &e = *entities::ents[i]; switch(e.type) { - case PLAYERSTART: case TELEPORT: case JUMPPAD: case FLAG: case BASE: + case PLAYERSTART: case TELEPORT: case JUMPPAD: addwaypoint(e.o); break; default: diff --git a/src/fpsgame/weapon.cpp b/src/fpsgame/weapon.cpp index 3c7f575..b062609 100644 --- a/src/fpsgame/weapon.cpp +++ b/src/fpsgame/weapon.cpp @@ -3,7 +3,6 @@ namespace game { - static const int MONSTERDAMAGEFACTOR = 4; static const int OFFSETMILLIS = 500; vec rays[MAXRAYS]; @@ -15,7 +14,6 @@ namespace game vector<hitmsg> hits; VARP(maxdebris, 10, 25, 1000); - VARP(maxbarreldebris, 5, 10, 1000); ICOMMAND(getweapon, "", (), intret(player1->gunselect)); @@ -135,7 +133,7 @@ namespace game loopi(guns[gun].rays) offsetray(from, to, guns[gun].spread, guns[gun].range, rays[i]); } - enum { BNC_GRENADE, BNC_GIBS, BNC_DEBRIS, BNC_BARRELDEBRIS }; + enum { BNC_GRENADE, BNC_GIBS, BNC_DEBRIS }; struct bouncer : physent { @@ -171,7 +169,7 @@ namespace game if(bouncetype == BNC_GRENADE && offsetmillis > 0 && offset.z < 0) offsetheight = raycube(vec(o.x + offset.x, o.y + offset.y, o.z), vec(0, 0, -1), -offset.z); else offsetheight = -1; - } + } }; vector<bouncer *> bouncers; @@ -195,7 +193,7 @@ namespace game switch(type) { case BNC_GRENADE: bnc.collidetype = COLLIDE_ELLIPSE_PRECISE; break; - case BNC_DEBRIS: case BNC_BARRELDEBRIS: bnc.variant = rnd(4); break; + case BNC_DEBRIS: bnc.variant = rnd(4); break; case BNC_GIBS: bnc.variant = rnd(3); break; } @@ -227,7 +225,7 @@ namespace game b->bounces++; adddecal(DECAL_BLOOD, vec(b->o).sub(vec(surface).mul(b->radius)), surface, 2.96f/b->bounces, bvec(0x60, 0xFF, 0xFF), rnd(4)); } - + void updatebouncers(int time) { loopv(bouncers) @@ -358,12 +356,6 @@ namespace game lasthit = lastmillis; } - if(d->type==ENT_INANIMATE) - { - hitmovable(damage, (movable *)d, at, vel, gun); - return; - } - fpsent *f = (fpsent *)d; f->lastpain = lastmillis; @@ -371,8 +363,7 @@ namespace game if(f->type==ENT_AI || !m_mp(gamemode) || f==at) f->hitpush(damage, vel, at, gun); - if(f->type==ENT_AI) hitmonster(damage, (monster *)f, at, vel, gun); - else if(!m_mp(gamemode)) damaged(damage, f, at); + if(!m_mp(gamemode)) damaged(damage, f, at); else { hitmsg &h = hits.add(); @@ -435,7 +426,7 @@ namespace game if(gun==GUN_RL) adddynlight(v, 1.15f*guns[gun].exprad, vec(2, 1.5f, 1), 700, 100, 0, guns[gun].exprad/2, vec(1, 0.75f, 0.5f)); else if(gun==GUN_GL) adddynlight(v, 1.15f*guns[gun].exprad, vec(0.5f, 1.5f, 2), 600, 100, 0, 8, vec(0.25f, 1, 1)); else adddynlight(v, 1.15f*guns[gun].exprad, vec(2, 1.5f, 1), 700, 100); - int numdebris = gun==GUN_BARREL ? rnd(max(maxbarreldebris-5, 1))+5 : rnd(maxdebris-5)+5; + int numdebris = rnd(maxdebris-5)+5; vec debrisvel = vec(owner->o).sub(v).safenormalize(), debrisorigin(v); if(gun==GUN_RL) debrisorigin.add(vec(debrisvel).mul(8)); if(numdebris) @@ -443,7 +434,7 @@ namespace game entitylight light; lightreaching(debrisorigin, light.color, light.dir); loopi(numdebris) - spawnbouncer(debrisorigin, debrisvel, owner, gun==GUN_BARREL ? BNC_BARRELDEBRIS : BNC_DEBRIS, &light); + spawnbouncer(debrisorigin, debrisvel, owner, BNC_DEBRIS, &light); } if(!local) return; int numdyn = numdynents(); @@ -527,9 +518,8 @@ namespace game projectile &p = projs[i]; p.offsetmillis = max(p.offsetmillis-time, 0); int qdam = guns[p.gun].damage*(p.owner->quadmillis ? 4 : 1); - if(p.owner->type==ENT_AI) qdam /= MONSTERDAMAGEFACTOR; vec dv; - float dist = p.to.dist(p.o, dv); + float dist = p.to.dist(p.o, dv); dv.mul(time/max(dist*1000/p.speed, float(time))); vec v = vec(p.o).add(dv); bool exploded = false; @@ -560,17 +550,7 @@ namespace game { vec pos(v); pos.add(vec(p.offset).mul(p.offsetmillis/float(OFFSETMILLIS))); - if(guns[p.gun].part) - { - regular_particle_splash(PART_SMOKE, 2, 300, pos, 0x404040, 0.6f, 150, -20); - int color = 0xFFFFFF; - switch(guns[p.gun].part) - { - case PART_FIREBALL1: color = 0xFFC8C8; break; - } - particle_splash(guns[p.gun].part, 1, 1, pos, color, 4.8f, 150, 20); - } - else regular_particle_splash(PART_SMOKE, 2, 300, pos, 0x404040, 2.4f, 50, -20); + regular_particle_splash(PART_SMOKE, 2, 300, pos, 0x404040, 2.4f, 50, -20); } } if(exploded) @@ -628,11 +608,7 @@ namespace game case GUN_RL: if(muzzleflash && d->muzzle.x >= 0) particle_flare(d->muzzle, d->muzzle, 250, PART_MUZZLE_FLASH2, 0xFFFFFF, 3.0f, d); - case GUN_FIREBALL: - case GUN_ICEBALL: - case GUN_SLIMEBALL: pspeed = guns[gun].projspeed; - if(d->type==ENT_AI) pspeed /= 2; newprojectile(from, to, (float)pspeed, local, id, d, gun); break; @@ -739,14 +715,13 @@ namespace game { int qdam = guns[d->gunselect].damage; if(d->quadmillis) qdam *= 4; - if(d->type==ENT_AI) qdam /= MONSTERDAMAGEFACTOR; dynent *o; float dist; if(guns[d->gunselect].rays > 1) { dynent *hits[MAXRAYS]; int maxrays = guns[d->gunselect].rays; - loopi(maxrays) + loopi(maxrays) { if((hits[i] = intersectclosest(from, rays[i], d, dist))) shorten(from, rays[i], dist); else adddecal(DECAL_BULLET, rays[i], vec(from).sub(rays[i]).safenormalize(), 2.0f); @@ -769,7 +744,7 @@ namespace game shorten(from, to, dist); hitpush(qdam, o, d, from, to, d->gunselect, 1); } - else if(d->gunselect!=GUN_FIST && d->gunselect!=GUN_BITE) adddecal(DECAL_BULLET, to, vec(from).sub(to).safenormalize(), d->gunselect==GUN_RIFLE ? 3.0f : 2.0f); + else if(d->gunselect!=GUN_FIST) adddecal(DECAL_BULLET, to, vec(from).sub(to).safenormalize(), d->gunselect==GUN_RIFLE ? 3.0f : 2.0f); } void shoot(fpsent *d, const vec &targ) @@ -849,14 +824,12 @@ namespace game static const char * const projnames[2] = { "projectiles/grenade", "projectiles/rocket" }; static const char * const gibnames[3] = { "gibs/gib01", "gibs/gib02", "gibs/gib03" }; static const char * const debrisnames[4] = { "debris/debris01", "debris/debris02", "debris/debris03", "debris/debris04" }; - static const char * const barreldebrisnames[4] = { "barreldebris/debris01", "barreldebris/debris02", "barreldebris/debris03", "barreldebris/debris04" }; - + void preloadbouncers() { loopi(sizeof(projnames)/sizeof(projnames[0])) preloadmodel(projnames[i]); loopi(sizeof(gibnames)/sizeof(gibnames[0])) preloadmodel(gibnames[i]); loopi(sizeof(debrisnames)/sizeof(debrisnames[0])) preloadmodel(debrisnames[i]); - loopi(sizeof(barreldebrisnames)/sizeof(barreldebrisnames[0])) preloadmodel(barreldebrisnames[i]); } void renderbouncers() @@ -887,7 +860,6 @@ namespace game { case BNC_GIBS: mdl = gibnames[bnc.variant]; cull |= MDL_LIGHT|MDL_LIGHT_FAST|MDL_DYNSHADOW; break; case BNC_DEBRIS: mdl = debrisnames[bnc.variant]; break; - case BNC_BARRELDEBRIS: mdl = barreldebrisnames[bnc.variant]; break; default: continue; } rendermodel(&bnc.light, mdl, ANIM_MAPMODEL|ANIM_LOOP, pos, yaw, pitch, cull, NULL, NULL, 0, 0, fade); |
