From da70c719368b46e708bcd91e785689f9a7eeeec3 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Sat, 25 Oct 2008 18:08:27 +0000 Subject: [PATCH] made next primary weapon a persistent variable (will now save across restart) git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3250 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/entities.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/src/entities.cpp b/source/src/entities.cpp index 4eaa0795..99cd480b 100644 --- a/source/src/entities.cpp +++ b/source/src/entities.cpp @@ -289,7 +289,7 @@ void resetspawns() } void setspawn(int i, bool on) { if(ents.inrange(i)) ents[i].spawned = on; } -void selectnextprimary(int num) +bool selectnextprimary(int num) { switch(num) { @@ -299,15 +299,18 @@ void selectnextprimary(int num) case GUN_ASSAULT: player1->setnextprimary(num); addmsg(SV_PRIMARYWEAP, "ri", player1->nextprimweap->type); - break; + return true; default: conoutf("this is not a valid primary weapon"); - break; + return false; } } -COMMANDN(nextprimary, selectnextprimary, ARG_1INT); +VARFP(nextprimary, 0, GUN_ASSAULT, NUMGUNS, +{ + if(!selectnextprimary(nextprimary)) selectnextprimary((nextprimary = GUN_ASSAULT)); +}); // flag ent actions done by the local player