bug: enemie movement sometimes deref nullptr when calling get_pos()

fixed level gen
This commit is contained in:
2024-07-15 00:23:12 -04:00
parent 6768d73d16
commit 93f68e3969
3 changed files with 6 additions and 2 deletions

View File

@ -79,6 +79,10 @@ void new_enemy(RNG *rng, std::unique_ptr<enemy_base> &p,
p = make_unique<merchant>(rng, enabled_features, pos, which_room); p = make_unique<merchant>(rng, enabled_features, pos, which_room);
break; break;
case rhalfling:
p = make_unique<halfling>(rng, enabled_features, pos, which_room);
break;
default: default:
break; break;
} }

View File

@ -31,7 +31,7 @@ game_command file_input::get_command() {
return (game_command)((tmp = get_direction(cmd)) == return (game_command)((tmp = get_direction(cmd)) ==
game_command_panic game_command_panic
? tmp : tmp - move_north + ? tmp : tmp +
(use ? apply_north : attack_north)); (use ? apply_north : attack_north));
} else if (cmd == "yes") { } else if (cmd == "yes") {
return game_command::enter; return game_command::enter;

View File

@ -122,7 +122,7 @@ long_result player_base::interpret_command(level *lvl, game_command cmd) {
lvl->get_elist()); lvl->get_elist());
auto res = attack((character *)tmp); auto res = attack((character *)tmp);
if (tmp->is_dead()) if (tmp != nullptr && tmp->is_dead())
tmp->dies(lvl, this); tmp->dies(lvl, this);
return res; return res;