Fix units that should have zero max mp being given one mp

Corrects a cut & paste typo in 66a282a96b.
This commit is contained in:
Steve Cotton 2021-03-25 23:58:01 +01:00 committed by Steve Cotton
parent 20eb001be3
commit 884fa9ca6f
3 changed files with 17 additions and 1 deletions

View file

@ -16,6 +16,7 @@
* Minor adjustments to the sidebar's minimap area in the default game theme to reclaim empty and uneven space back. Note that this WILL break custom WML themes that use the same sidebar graphics as the default theme.
### WML Engine
### Miscellaneous and Bug Fixes
* Fixed units with max movement set to zero being given one max movement point by `[unstore_unit]` or when loading a saved game
## Version 1.15.11
### AI

View file

@ -115,6 +115,21 @@
{ASSERT_VISION_EFFECTIVELY equals 0}
{ASSERT_ALICE_STAT jamming equals 0}
# Test that unit.cpp's unit::init() successfully loads a unit with max_moves set to zero
[store_unit]
[filter]
id=alice
[/filter]
variable=temp_alice
[/store_unit]
[unstore_unit]
variable=temp_alice
[/unstore_unit]
{CLEAR_VARIABLE temp_alice}
{ASSERT_ALICE_STAT max_moves equals 0}
{ASSERT_VISION_EFFECTIVELY equals 0}
{ASSERT_ALICE_STAT jamming equals 0}
{SUCCEED}
[/event]
)}

View file

@ -514,7 +514,7 @@ void unit::init(const config& cfg, bool use_traits, const vconfig* vcfg)
set_max_hitpoints(std::max(1, v->to_int(max_hit_points_)));
}
if(const config::attribute_value* v = cfg.get("max_moves")) {
set_total_movement(std::max(1, v->to_int(max_movement_)));
set_total_movement(std::max(0, v->to_int(max_movement_)));
}
if(const config::attribute_value* v = cfg.get("max_experience")) {
set_max_experience(std::max(1, v->to_int(max_experience_)));