diff --git a/source/src/command.cpp b/source/src/command.cpp index eccce14a..dfe9e831 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -628,6 +628,7 @@ int sub(int a, int b) { return a-b; } COMMANDN(-, sub, ARG_2EXP); int divi(int a, int b) { return b ? a/b : 0; } COMMANDN(div, divi, ARG_2EXP); int mod(int a, int b) { return b ? a%b : 0; } COMMAND(mod, ARG_2EXP); int equal(int a, int b) { return (int)(a==b); } COMMANDN(=, equal, ARG_2EXP); +int notequal(int a, int b) { return (int)(a!=b); } COMMANDN(!=, notequal, ARG_2EXP); int lt(int a, int b) { return (int)(ab); } COMMANDN(>, gt, ARG_2EXP); diff --git a/source/src/entity.h b/source/src/entity.h index 8e87b6dd..780c260f 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -355,7 +355,7 @@ struct playerent : dynent, playerstate bool allowmove() { return state!=CS_DEAD || spectatemode==SM_FLY; } weapon *weapons[NUMGUNS]; - weapon *weaponsel, *nextweaponsel, *primweap, *nextprimweap, *lastattackweapon; + weapon *prevweaponsel, *weaponsel, *nextweaponsel, *primweap, *nextprimweap, *lastattackweapon; poshist history; // Previous stored locations of this player @@ -364,7 +364,7 @@ struct playerent : dynent, playerstate playerent() : clientnum(-1), lastupdate(0), plag(0), ping(0), lifesequence(0), frags(0), flagscore(0), deaths(0), lastpain(0), lastvoicecom(0), clientrole(CR_DEFAULT), skin(0), nextskin(0), spectatemode(SM_NONE), followplayercn(-1), eardamagemillis(0), respawnoffset(0), - weaponsel(NULL), nextweaponsel(NULL), primweap(NULL), nextprimweap(NULL), lastattackweapon(NULL), + prevweaponsel(NULL), weaponsel(NULL), nextweaponsel(NULL), primweap(NULL), nextprimweap(NULL), lastattackweapon(NULL), smoothmillis(-1) { type = ENT_PLAYER; @@ -421,12 +421,12 @@ struct playerent : dynent, playerstate void spawnstate(int gamemode) { playerstate::spawnstate(gamemode); - weaponsel = weapons[gunselect]; + prevweaponsel = weaponsel = weapons[gunselect]; primweap = weapons[primary]; nextprimweap = weapons[nextprimary]; } - void selectweapon(int w) { weaponsel = weapons[(gunselect = w)]; } + void selectweapon(int w) { prevweaponsel = weaponsel = weapons[(gunselect = w)]; } void setprimary(int w) { primweap = weapons[(primary = w)]; } void setnextprimary(int w) { nextprimweap = weapons[(nextprimary = w)]; } bool isspectating() { return state==CS_SPECTATE || (state==CS_DEAD && spectatemode > SM_NONE); } @@ -436,6 +436,7 @@ struct playerent : dynent, playerstate extern int lastmillis; weaponsel->ondeselecting(); weaponchanging = lastmillis; + prevweaponsel = weaponsel; nextweaponsel = w; w->onselecting(); } diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index ad36ebb0..5492d4b1 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -24,7 +24,10 @@ void checkweaponswitch() addmsg(SV_WEAPCHANGE, "ri", player1->weaponsel->type); player1->weaponchanging = 0; } - else if(timeprogress>weapon::weaponchangetime/2) player1->weaponsel = player1->nextweaponsel; + else if(timeprogress>weapon::weaponchangetime/2) + { + player1->weaponsel = player1->nextweaponsel; + } } void selectweapon(weapon *w) @@ -94,6 +97,7 @@ void shiftweapon(int s) } int currentprimary() { return player1->primweap->type; } +int prevweapon() { return player1->prevweaponsel->type; } int curweapon() { return player1->weaponsel->type; } int magcontent(int w) { if(w > 0 && w < NUMGUNS) return player1->weapons[w]->mag; else return -1;} @@ -102,6 +106,7 @@ int magreserve(int w) { if(w > 0 && w < NUMGUNS) return player1->weapons[w]->amm COMMANDN(weapon, selectweaponi, ARG_1INT); COMMAND(shiftweapon, ARG_1INT); COMMAND(currentprimary, ARG_IVAL); +COMMAND(prevweapon, ARG_IVAL); COMMAND(curweapon, ARG_IVAL); COMMAND(magcontent, ARG_1EXP); COMMAND(magreserve, ARG_1EXP);