diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp index df674c06..9ec7b54e 100644 --- a/source/src/bot/botmanager.cpp +++ b/source/src/bot/botmanager.cpp @@ -902,7 +902,7 @@ botent *CBotManager::CreateBot(const char *team, const char *skill, const char * botent *m = newbotent(); if (!m) return NULL; loopi(NUMGUNS) m->ammo[i] = m->mag[i] = 0; - m->skin = rnd(10); //fixme + setskin(m, rnd(6)); // Create new bot class, dependand on the current mod #if defined VANILLA_CUBE m->pBot = new CCubeBot; diff --git a/source/src/client.cpp b/source/src/client.cpp index 48b8f149..3099a3b3 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -68,7 +68,7 @@ void newname(char *name) } else conoutf("your name is: %s", player1->name); }; -void newskin(int skin) { player1->nextskin = max(0, min(skin, (rb_team_int(player1->team)==TEAM_CLA ? 3 : 5))); }; + void newteam(char *name) { if(name[0]) @@ -79,6 +79,8 @@ void newteam(char *name) else conoutf("your team is: %s", player1->team); }; +void newskin(int skin) { player1->nextskin = skin; }; + COMMANDN(team, newteam, ARG_1STR); COMMANDN(name, newname, ARG_1STR); COMMANDN(skin, newskin, ARG_1INT); diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index b99242f6..539b1528 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -34,6 +34,13 @@ char *getclientmap() { return clientmap; }; extern bool c2sinit; extern int dblend; +int setskin(playerent *pl, int skin) +{ + if(!pl) return; + int maxskin = rb_team_int(pl->team) == TEAM_CLA ? 3 : 5; + pl->skin = max(0, skin % (maxskin+1)); +}; + void spawnstate(playerent *d) // reset player state not persistent accross spawns { d->respawn(); @@ -44,7 +51,7 @@ void spawnstate(playerent *d) // reset player state not persistent if(player1->skin!=player1->nextskin) { c2sinit=false; - player1->skin=player1->nextskin; + setskin(player1, player1->nextskin); } setscope(false); }; @@ -57,7 +64,7 @@ playerent *newplayerent() // create a new blank player { playerent *d = new playerent; d->lastupdate = lastmillis; - d->skin = rnd(1 + rb_team_int(d->team) == TEAM_CLA ? 3 : 5); + setskin(d, rnd(6)); spawnstate(d); return d; }; @@ -66,7 +73,7 @@ botent *newbotent() // create a new blank player { botent *d = new botent; d->lastupdate = lastmillis; - d->skin = rnd(1 + rb_team_int(d->team) == TEAM_CLA ? 3 : 5); + setskin(d, rnd(6)); spawnstate(d); loopv(players) if(i!=getclientnum() && !players[i]) { diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index f4ce06aa..6de713d4 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -188,7 +188,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) s_strncpy(d->name, text, MAXNAMELEN+1); getstring(text, p); s_strncpy(d->team, text, MAXTEAMLEN+1); - d->skin = getint(p); + setskin(d, getint(p)); d->lifesequence = getint(p); c2si = true; break; diff --git a/source/src/protos.h b/source/src/protos.h index 8b7ecf05..339601e0 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -110,6 +110,7 @@ extern void timeupdate(int timeremain); extern void fixcamerarange(physent *cam = camera1); extern void respawnself(); // EDIT: AH extern void ctf_death(); +extern int setskin(playerent *pl, int skin); //game mode extras extern void arenarespawn(); extern void respawn();