fixed bug where merchants are not moving

reading map data from file will now generate only the specified entities (if none are specified, randomly generate them
This commit is contained in:
2024-07-25 18:55:18 -04:00
parent b04884e44a
commit d61342b9f1
3 changed files with 15 additions and 5 deletions

View File

@ -91,7 +91,7 @@ character *game::move_enemies() {
continue;
}
if (ch->get_race() == MERCHANT) {
if (the_world && ch->get_race() == MERCHANT) {
if (!hostile_merchants)
continue;
} else if (the_world &&

View File

@ -41,6 +41,12 @@ level::level(const level_data &lvl, character *player, RNG *rng,
if (enabled_features & FEATURE_READ_MAP)
fill(lvl, tiles, rng);
if (enabled_features & FEATURE_READ_MAP &&
(lvl.enemies.size() ||
lvl.potions.size() ||
lvl.gold_piles.size()))
return;
gen_potions(rng, tiles);
gen_gold(rng, tiles);
gen_enemies(lvl, rng, tiles);
@ -109,9 +115,9 @@ bool level::is_in_glist(gold &g, const gold_list &gl) {
void level::gen_enemies(const level_data &lvl, RNG *rng,
std::vector<position_list> &tiles) {
auto dhoard = dragon_hoard(lvl);
int cnt = enabled_features & FEATURE_EXTRA_STUFF ?
int cnt = (enabled_features & FEATURE_EXTRA_STUFF ?
rng->rand_between(MIN_ENEMIE_CNT, MAX_ENEMIE_CNT + 1) :
MIN_ENEMIE_CNT + dhoard.size();
MIN_ENEMIE_CNT) + dhoard.size();
elist.reserve(cnt);
pelist.reserve(cnt);

View File

@ -29,9 +29,13 @@ int main(int argc, char **argv) {
CC3K game_proc(enabled_features, in.get(), out.get(), rng.get(), data);
while (1)
while (true) {
if (game_proc.run() == game_status::TERMINATED)
break;
if (enabled_features & FEATURE_IN_FILE)
getchar();
}
return RETURN_FINE;
}