From 9e6862623370f53d1b78e4bd167152b840e28884 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 13 Aug 2006 23:24:50 +0000 Subject: Verify the gender to prevent crashing when something is wrong with the communication. --- src/player.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/player.cpp') diff --git a/src/player.cpp b/src/player.cpp index 3fe608c7..b864dd0e 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -26,6 +26,7 @@ #include "animatedsprite.h" #include "game.h" #include "graphics.h" +#include "log.h" #include "utils/tostring.h" @@ -85,6 +86,13 @@ Player::drawName(Graphics *graphics, Sint32 offsetX, Sint32 offsetY) void Player::setSex(Uint8 sex) { + // Players can only be male or female + if (sex > 1) + { + logger->log("Warning: unsupported gender %i, assuming male.", sex); + sex = 0; + } + if (sex != mSex) { delete mSprites[BASE_SPRITE]; @@ -98,8 +106,9 @@ Player::setSex(Uint8 sex) mSprites[BASE_SPRITE] = new AnimatedSprite( "graphics/sprites/player_female_base.xml", 0); } + + Being::setSex(sex); } - Being::setSex(sex); } void -- cgit v1.2.3-70-g09d2