Several bugfixes

- Fix light mask not rendering correctly
- Fix terrain-sourced lighting not being calculated on scenario load
- Fix light-removing items incorrectly applying their ability strength
- Fix smash patterns not affecting opaque tiles (such as mouldy walls)
- Fix monsters outside the light range not being rendered when fog is lifted
- Fix town timers not being cancelled when you leave town
- Fix non-existent outdoor wandering encounters sometimes triggering due to uninitialized data
- Hard-wrap some doc lines
This commit is contained in:
2015-06-04 21:50:08 -04:00
parent 5bcf220204
commit 80f95ba9ae
9 changed files with 40 additions and 20 deletions

View File

@@ -1068,7 +1068,8 @@ taken.</dd>
<dt>Jump To:</dt><dd>Otherwise, this special is called.</dd>
<dt>Uses:</dt><dd>If someone is selling, say, Strength improvement, you can first use this
to see if the party has enough gold to afford it.</dd>
<dt>Note:</dt><dd>This node (and the next four) are the only If-Then nodes that (potentially) actually have an effect in the game.</dd></dd>
<dt>Note:</dt><dd>This node (and the next four) are the only If-Then nodes that
(potentially) actually have an effect in the game.</dd></dd>
<dt>Type 138: Has Food?</dt><dd>Result depends on whether the party has enough food.
<dl>
@@ -1290,8 +1291,19 @@ is called.
<dt>Type 156: If Context?</dt><dd>Result depends on how the special node was called.
<dl>
<dt>Extra 1a:</dt><dd>The context to test for. Click Choose to select one. If you want to check whether the party is in town, in combat, or outdoors, you probably want one of the first three options. To test for Ritual of Sanctification, use the Targeting Spell option and set Extra 1b to 108. Most of these contexts arise from special nodes assigned while editing monsters, items, town details, and other things, rather than special nodes assigned to a terrain space.</dd>
<dt>Extra 1b:</dt><dd>The meaning of this field depends on the context. Usually it's not used. For the three movement contexts, 0 means you can enter the space and 1 means you can't. For the targeting spell context, setting this to something other than -1 means that the special in Extra 1c will only be called if the spell that was cast is equal to the spell that has the given number. Add 100 to indicate a priest spell. Item-only spells such as Wrack or Strengthen Target can also be tested for; just enter the same spell ID you would enter for the item ability.</dd></dd>
<dt>Extra 1a:</dt><dd>The context to test for. Click Choose to select one. If you want to
check whether the party is in town, in combat, or outdoors, you probably want one of the
first three options. To test for Ritual of Sanctification, use the Targeting Spell option
and set Extra 1b to 108. Most of these contexts arise from special nodes assigned while
editing monsters, items, town details, and other things, rather than special nodes
assigned to a terrain space.</dd>
<dt>Extra 1b:</dt><dd>The meaning of this field depends on the context. Usually it's not
used. For the three movement contexts, 0 means you can enter the space and 1 means you
can't. For the targeting spell context, setting this to something other than -1 means that
the special in Extra 1c will only be called if the spell that was cast is equal to the
spell that has the given number. Add 100 to indicate a priest spell. Item-only spells such
as Wrack or Strengthen Target can also be tested for; just enter the same spell ID you
would enter for the item ability.</dd></dd>
<dt>Type 157: If Numeric Response?</dt><dd>Result depends on a number entered by the player.
<!-- TODO: Document this. -->

View File

@@ -4057,9 +4057,9 @@ static void place_spell_pattern(effect_pat_type pat,location center,unsigned sho
// First actually make barriers, then draw them, then inflict damaging effects.
for(i = minmax(0,univ.town->max_dim() - 1,center.x - 4); i <= minmax(0,univ.town->max_dim() - 1,center.x + 4); i++)
for(j = minmax(0,univ.town->max_dim() - 1,center.y - 4); j <= minmax(0,univ.town->max_dim() - 1,center.y + 4); j++)
if(sight_obscurity(i,j) < 5) {
effect = pat.pattern[i - center.x + 4][j - center.y + 4];
for(j = minmax(0,univ.town->max_dim() - 1,center.y - 4); j <= minmax(0,univ.town->max_dim() - 1,center.y + 4); j++) {
effect = pat.pattern[i - center.x + 4][j - center.y + 4];
if(effect == FIELD_SMASH || sight_obscurity(i,j) < 5) {
switch(effect) {
case FIELD_WEB:
web_space(i,j);
@@ -4138,6 +4138,7 @@ static void place_spell_pattern(effect_pat_type pat,location center,unsigned sho
break;
}
}
}
draw_terrain(0);
if(is_town()) // now make things move faster if in town
fast_bang = 2;

View File

@@ -469,6 +469,7 @@ static void put_item_graphics(cDialog& me, size_t& first_item_shown, short& curr
std::string key = sout.str() + "-key";
key_stash[0] = 'a' + i;
// TODO: Rework this so that no exceptions are required
try {
if(item_array.at(i + first_item_shown)->variety == eItemType::NO_ITEM)
throw std::out_of_range("");

View File

@@ -16,7 +16,7 @@ extern eGameMode overall_mode;
extern eGameMode store_pre_shop_mode, store_pre_talk_mode;
extern location center;
extern cUniverse univ;
extern bool cartoon_happening;
extern bool cartoon_happening, fog_lifted;
location light_locs[40];
short num_lights = 0;
@@ -238,6 +238,7 @@ bool is_container(location loc) {
}
void update_explored(location dest) {
if(cartoon_happening) return;
location shortdest,look;
location look2;
@@ -543,6 +544,8 @@ short party_can_see(location where) {
return 1;
else return 6;
}
if(fog_lifted)
return point_onscreen(univ.town.p_loc,where) ? 1 : 6;
if(is_town()) {
if( ((point_onscreen(univ.town.p_loc,where)) || (overall_mode == MODE_LOOK_TOWN)) && (pt_in_light(univ.town.p_loc,where) )
&& (can_see_light(univ.town.p_loc,where,sight_obscurity) < 5))

View File

@@ -152,7 +152,7 @@ void apply_light_mask(bool onWindow) {
rectangle temp = {0,0,108,84},paint_rect,base_rect = {0,0,36,28};
rectangle big_to = {13,13,337,265};
short i,j;
bool is_dark = false,same_mask = true;
bool same_mask = true;
if(PSD[SDF_NO_FRILLS] > 0 || fog_lifted)
return;
if(is_out() || overall_mode == MODE_RESTING)
@@ -167,15 +167,6 @@ void apply_light_mask(bool onWindow) {
}
// Process the light array
for(i = 2; i < 11; i++)
for(j = 2; j < 11; j++)
if(light_area[i][j] == 0) is_dark = true;
if(!is_dark) {
for(i = 2; i < 11; i++)
for(j = 2; j < 11; j++)
last_light_mask[i][j] = 0;
return;
}
for(i = 1; i < 12; i++)
for(j = 1; j < 12; j++)
if((light_area[i - 1][j - 1] >= 1) && (light_area[i + 1][j - 1] >= 1) &&
@@ -201,6 +192,14 @@ void apply_light_mask(bool onWindow) {
if(same_mask) {
return;
}
std::cout << "Current light mask:\n";
for(i = 0; i < 13; i++) {
for(j = 0; j < 13; j++)
std::cout << int(light_area[j][i]) << ' ';
std::cout << '\n';
}
dark_mask_region.clear();
dark_mask_region.addRect(big_to);
for(i = 0; i < 13; i++)
@@ -218,6 +217,8 @@ void apply_light_mask(bool onWindow) {
if(light_area[i][j] == 3) {
paint_rect = base_rect;
paint_rect.offset(13 + 28 * (i - 2),13 + 36 * (j - 2));
paint_rect.right += 28;
paint_rect.bottom += 36;
Region temp_rect_rgn;
temp_rect_rgn.addRect(paint_rect);
dark_mask_region -= temp_rect_rgn;

View File

@@ -1023,7 +1023,7 @@ void use_item(short pc,short item) {
increase_light(50 * str);
} else {
ASB(" It gets darker.");
increase_light(-50 & str);
increase_light(-50 * str);
}
break;
case eItemAbil::AFFECT_PARTY_STATUS:

View File

@@ -602,7 +602,7 @@ location end_town_mode(short switching_level,location destination) { // returns
to_return = univ.party.p_loc;
std::remove_if(univ.party.party_event_timers.begin(), univ.party.party_event_timers.end(), [](const cTimer& t) {
erase_if(univ.party.party_event_timers, [](const cTimer& t) {
return t.node_type == 2;
});

View File

@@ -51,7 +51,7 @@ public:
};
class cCreature { // formerly outdoor_creature_type
public:
bool exists;
bool exists = false;
short direction;
cWandering what_monst;
location which_sector,m_loc,home_sector; // home_sector is the sector it was spawned in

View File

@@ -1727,6 +1727,8 @@ static void loadTownMapData(map_data&& data, int which, cScenario& scen) {
}
}
}
// Don't forget to set up lighting!
town.set_up_lights();
}
static void readSpecialNodesFromStream(std::istream& stream, std::vector<cSpecial>& nodes) {