From 50ac0921d9970bba75e32c5c2de50a763bc82ee4 Mon Sep 17 00:00:00 2001 From: daftfad Date: Wed, 16 Jan 2013 11:24:04 -0500 Subject: [PATCH 1/2] Fixed wildlife over-spawning --- game.cpp | 29 ++++++++++++++--------------- mongroup.h | 2 ++ overmap.cpp | 14 ++++++++++---- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/game.cpp b/game.cpp index 69be2efe20842..bfa8ee0651b7f 100644 --- a/game.cpp +++ b/game.cpp @@ -572,7 +572,8 @@ bool game::do_turn() int group = valid_group((mon_id)(z[i].type->id), levx, levy); if (group != -1) { cur_om.zg[group].population++; - if (cur_om.zg[group].population / pow(cur_om.zg[group].radius, 2.0) > 5) + if (cur_om.zg[group].population / pow(cur_om.zg[group].radius, 2.0) > 5 && + !cur_om.zg[group].diffuse) cur_om.zg[group].radius++; } } @@ -1389,10 +1390,6 @@ input_ret game::get_input(int timeout_ms) use_item(); break; - case ACTION_USE_WIELDED: - use_wielded_item(); - break; - case ACTION_WEAR: wear(); break; @@ -3344,7 +3341,8 @@ void game::monmove() int group = valid_group((mon_id)(z[i].type->id), levx, levy); if (group != -1) { cur_om.zg[group].population++; - if (cur_om.zg[group].population / pow(cur_om.zg[group].radius, 2.0) > 5) + if (cur_om.zg[group].population / pow(cur_om.zg[group].radius, 2.0) > 5 && + !cur_om.zg[group].diffuse ) cur_om.zg[group].radius++; } else if (mt_to_mc((mon_id)(z[i].type->id)) != mcat_null) { cur_om.zg.push_back(mongroup(mt_to_mc((mon_id)(z[i].type->id)), @@ -4117,11 +4115,6 @@ void game::use_item() u.use(this, ch); } -void game::use_wielded_item() -{ - u.use_wielded(this); -} - bool game::pl_choose_vehicle (int &x, int &y) { refresh_all(); @@ -7139,7 +7132,8 @@ void game::update_map(int &x, int &y) group = valid_group((mon_id)(z[i].type->id), levx + shiftx, levy + shifty); if (group != -1) { cur_om.zg[group].population++; - if (cur_om.zg[group].population / pow(cur_om.zg[group].radius, 2.0) > 5) + if (cur_om.zg[group].population / pow(cur_om.zg[group].radius, 2.0) > 5 && + !cur_om.zg[group].diffuse) cur_om.zg[group].radius++; } /* Removing adding new groups for now. Haha! @@ -7439,14 +7433,18 @@ void game::spawn_mon(int shiftx, int shifty) if (dist <= rad) { // (The area of the group's territory) in (population/square at this range) // chance of adding one monster; cap at the population OR 16 - while (long((1.0 - double(dist / rad)) * pop) > rng(0, pow(rad, 2.0)) && + while ( (cur_om.zg[i].diffuse ? + long( pop) : + long((1.0 - double(dist / rad)) * pop) ) + > rng(0, pow(rad, 2.0)) && rng(0, MAPSIZE * 4) > group && group < pop && group < MAPSIZE * 3) group++; cur_om.zg[i].population -= group; // Reduce group radius proportionally to remaining // population to maintain a minimal population density. - if (cur_om.zg[i].population / pow(cur_om.zg[i].radius, 2.0) < 1.0) + if (cur_om.zg[i].population / pow(cur_om.zg[i].radius, 2.0) < 1.0 && + !cur_om.zg[i].diffuse) cur_om.zg[i].radius--; if (group > 0) // If we spawned some zombies, advance the timer @@ -7552,7 +7550,8 @@ int game::valid_group(mon_id type, int x, int y) // If there's a group that's ALMOST big enough, expand that group's radius // by one and absorb into that group. int semi = rng(0, semi_valid.size() - 1); - cur_om.zg[semi_valid[semi]].radius++; + if (!cur_om.zg[semi_valid[semi]].diffuse) + cur_om.zg[semi_valid[semi]].radius++; return semi_valid[semi]; } } diff --git a/mongroup.h b/mongroup.h index 30ee15ba63653..f88b06c890099 100644 --- a/mongroup.h +++ b/mongroup.h @@ -34,6 +34,7 @@ struct mongroup { unsigned char radius; unsigned int population; bool dying; + bool diffuse; // group size ind. of dist. from center and radius invariant mongroup(moncat_id ptype, int pposx, int pposy, unsigned char prad, unsigned int ppop) { type = ptype; @@ -42,6 +43,7 @@ struct mongroup { radius = prad; population = ppop; dying = false; + diffuse = false; } bool is_safe() { return moncat_is_safe(type); }; }; diff --git a/overmap.cpp b/overmap.cpp index 3e113cfb70bb3..90fe5546fddef 100644 --- a/overmap.cpp +++ b/overmap.cpp @@ -2280,15 +2280,19 @@ void overmap::place_mongroups() zg.push_back( mongroup(mcat_forest, 0, OMAPY, OMAPY, rng(2000, 12000))); + zg.back().diffuse = true; zg.push_back( mongroup(mcat_forest, 0, OMAPY * 2 - 1, OMAPY, rng(2000, 12000))); + zg.back().diffuse = true; zg.push_back( mongroup(mcat_forest, OMAPX, 0, OMAPX, rng(2000, 12000))); + zg.back().diffuse = true; zg.push_back( mongroup(mcat_forest, OMAPX * 2 - 1, 0, OMAPX, rng(2000, 12000))); + zg.back().diffuse = true; } void overmap::place_radios() @@ -2336,7 +2340,8 @@ void overmap::save(std::string name, int x, int y, int z) fout << std::endl; for (int i = 0; i < zg.size(); i++) fout << "Z " << zg[i].type << " " << zg[i].posx << " " << zg[i].posy << " " << - int(zg[i].radius) << " " << zg[i].population << std::endl; + int(zg[i].radius) << " " << zg[i].population << " " << zg[i].diffuse << + std::endl; for (int i = 0; i < cities.size(); i++) fout << "t " << cities[i].x << " " << cities[i].y << " " << cities[i].s << std::endl; @@ -2358,7 +2363,7 @@ void overmap::open(game *g, int x, int y, int z) std::stringstream plrfilename, terfilename; std::ifstream fin; char datatype; - int ct, cx, cy, cs, cp; + int ct, cx, cy, cs, cp, cd; city tmp; std::vector npc_inventory; @@ -2381,9 +2386,10 @@ void overmap::open(game *g, int x, int y, int z) } } while (fin >> datatype) { - if (datatype == 'Z') { // Monster group - fin >> ct >> cx >> cy >> cs >> cp; + if (datatype == 'Z') { // Monster group + fin >> ct >> cx >> cy >> cs >> cp >> cd; zg.push_back(mongroup(moncat_id(ct), cx, cy, cs, cp)); + zg.back().diffuse = cd; nummg++; } else if (datatype == 't') { // City fin >> cx >> cy >> cs; From 72c344be5a2384ba31571cc83efe7b56ff8adec1 Mon Sep 17 00:00:00 2001 From: daftfad Date: Wed, 16 Jan 2013 12:58:32 -0500 Subject: [PATCH 2/2] Fixed accidental removal of wield-action code in wilderness patch --- game.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/game.cpp b/game.cpp index bfa8ee0651b7f..8c067533d03d8 100644 --- a/game.cpp +++ b/game.cpp @@ -1390,6 +1390,10 @@ input_ret game::get_input(int timeout_ms) use_item(); break; + case ACTION_USE_WIELDED: + use_wielded_item(); + break; + case ACTION_WEAR: wear(); break; @@ -4115,6 +4119,11 @@ void game::use_item() u.use(this, ch); } +void game::use_wielded_item() +{ + u.use_wielded(this); +} + bool game::pl_choose_vehicle (int &x, int &y) { refresh_all();