Skip to content

Commit

Permalink
Convert stored_calories on character template load
Browse files Browse the repository at this point in the history
Before CleverRaven#46906, character templates were saved with stored_calories equal
to total kilocalories (55,000 being the "healthy" baseline).

Now, stored_calories is in units of small-c calories, being 55,000,000
for the healthy baseline. This led to a bug CleverRaven#46995 where new characters
created from older-version templates would spawn with too few calories,
by a factor of 1,000.

Detect this when templates are loaded, and multiply stored_calories if
its value appears to be way too small.
  • Loading branch information
wapcaplet authored and Ramza13 committed Apr 12, 2021
1 parent c4eaaa0 commit 5fe824e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/newcharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3633,6 +3633,12 @@ bool avatar::load_template( const std::string &template_name, points_left &point

deserialize( jsin );

// If stored_calories the template is under a million (kcals < 1000), assume it predates the
// kilocalorie-to-literal-calorie conversion and is off by a factor of 1000.
if( get_stored_kcal() < 1000 ) {
set_stored_kcal( 1000 * get_stored_kcal() );
}

if( MAP_SHARING::isSharing() ) {
// just to make sure we have the right name
name = MAP_SHARING::getUsername();
Expand Down

0 comments on commit 5fe824e

Please sign in to comment.