New constant for unused special locations. fix #752
This commit is contained in:
@@ -26,6 +26,13 @@ enum {
|
||||
AREA_HUGE = 128,
|
||||
};
|
||||
|
||||
// x of 100 used to be used to indicate an unused location
|
||||
// or a place to temporarily move monsters out of the tile grid completely.
|
||||
// I don't know why a negative number wasn't used instead?
|
||||
// But in case there is a good reason for that, I'm shifting the placeholder
|
||||
// value to a new, much larger, positive constant, that we *could* change again later.
|
||||
const int LOC_UNUSED = AREA_HUGE * 2;
|
||||
|
||||
class cArea {
|
||||
public:
|
||||
const size_t max_dim;
|
||||
|
@@ -72,8 +72,10 @@ void cOutdoors::import_legacy(legacy::outdoor_record_type& old){
|
||||
for(short i = 0; i < 18; i++){
|
||||
special_locs[i].x = old.special_locs[i].x;
|
||||
special_locs[i].y = old.special_locs[i].y;
|
||||
if(old.special_locs[i].x == 100)
|
||||
if(old.special_locs[i].x == 100){
|
||||
special_locs[i].x = LOC_UNUSED;
|
||||
special_locs[i].spec = -1;
|
||||
}
|
||||
else special_locs[i].spec = old.special_id[i];
|
||||
}
|
||||
city_locs.resize(8);
|
||||
|
@@ -38,8 +38,10 @@ void cTown::import_legacy(legacy::town_record_type& old){
|
||||
for(short i = 0; i < 50; i++){
|
||||
special_locs[i].x = old.special_locs[i].x;
|
||||
special_locs[i].y = old.special_locs[i].y;
|
||||
if(old.special_locs[i].x == 100)
|
||||
if(old.special_locs[i].x == 100){
|
||||
special_locs[i].x = LOC_UNUSED;
|
||||
special_locs[i].spec = -1;
|
||||
}
|
||||
else special_locs[i].spec = old.spec_id[i];
|
||||
cField temp;
|
||||
temp.import_legacy(old.preset_fields[i]);
|
||||
@@ -83,13 +85,13 @@ cTown::cTown(cScenario& scenario, size_t dim) : cArea(dim), scenario(&scenario),
|
||||
town_chop_key = -1;
|
||||
for(short i = 0; i < wandering.size(); i++) {
|
||||
wandering[i] = d_wan;
|
||||
// x of 100 indicates an unset wandering monster location
|
||||
wandering_locs[i].x = 100;
|
||||
// unset wandering monster location
|
||||
wandering_locs[i].x = LOC_UNUSED;
|
||||
}
|
||||
lighting_type = LIGHT_NORMAL;
|
||||
for(short i = 0; i < 4; i++) {
|
||||
// x of 100 indicates an unset starting location
|
||||
start_locs[i].x = 100;
|
||||
// unset starting location
|
||||
start_locs[i].x = LOC_UNUSED;
|
||||
exits[i].spec = -1;
|
||||
exits[i].x = -1;
|
||||
exits[i].y = -1;
|
||||
|
@@ -2401,8 +2401,7 @@ void set_terrain(location l,ter_num_t terrain_type,stroke_ter_changes_t& stroke_
|
||||
auto iter = std::find(signs.begin(), signs.end(), l);
|
||||
if(iter == signs.end()) {
|
||||
iter = std::find_if(signs.begin(), signs.end(), [cur_area](const sign_loc_t& sign) {
|
||||
// TODO x of 100 is no longer a valid way to represent nonexistence
|
||||
if(sign.x == 100) return true;
|
||||
if(sign.x == LOC_UNUSED) return true;
|
||||
ter_num_t ter = cur_area->terrain(sign.x,sign.y);
|
||||
return scenario.ter_types[ter].special != eTerSpec::IS_A_SIGN;
|
||||
});
|
||||
|
Reference in New Issue
Block a user