Skip to content

Commit

Permalink
Simplify Character::height
Browse files Browse the repository at this point in the history
This function was overly complicated and had corner-cases which did the
wrong thing.  Make it much simpler.
  • Loading branch information
jbytheway committed Apr 13, 2020
1 parent 9b62400 commit f56636e
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6945,28 +6945,21 @@ std::string Character::height_string() const

int Character::height() const
{
int height = init_height;
int height_pos = 15;

const static std::array<int, 5> v = {{ 290, 240, 190, 140, 90 }};
for( const int up_bound : v ) {
if( up_bound >= init_height && up_bound - init_height < 40 ) {
height_pos = up_bound - init_height;
}
}

if( get_size() == MS_TINY ) {
height = 90 - height_pos;
} else if( get_size() == MS_SMALL ) {
height = 140 - height_pos;
} else if( get_size() == MS_LARGE ) {
height = 240 - height_pos;
} else if( get_size() == MS_HUGE ) {
height = 290 - height_pos;
}

// TODO: Make this a player creation option
return height;
switch( get_size() ) {
case MS_TINY:
return init_height - 100;
case MS_SMALL:
return init_height - 50;
case MS_MEDIUM:
return init_height;
case MS_LARGE:
return init_height + 50;
case MS_HUGE:
return init_height + 100;
}

debugmsg( "Invalid size class" );
abort();
}

int Character::get_bmr() const
Expand Down

0 comments on commit f56636e

Please sign in to comment.