Alter boat specials fix to insert new special nodes if there's no unused ones, taking advantage of the fact that the lists of special nodes are now dynamically sized

This commit is contained in:
2015-02-01 20:51:42 -05:00
parent eaeb9690c3
commit d42c4fff08

View File

@@ -54,20 +54,22 @@ void cTinyTown::append(legacy::tiny_tr_type& old, int town_num){
} }
} }
if(found_spec >= 0) { if(found_spec >= 0) {
int found_spec_id = special_locs[found_spec].spec;
cSpecial* node;
if(!unused_special_slots.empty()) { if(!unused_special_slots.empty()) {
int found_spec_id = special_locs[found_spec].spec, use_slot = unused_special_slots.back(); int use_slot = unused_special_slots.back();
unused_special_slots.pop_back(); unused_special_slots.pop_back();
cSpecial& node = specials[use_slot]; node = &specials[use_slot];
node.type = eSpecType::IF_IN_BOAT;
node.ex1b = -1; // any boat;
node.ex1c = -1; // do nothing
node.jumpto = found_spec_id; // else jump here
special_locs[found_spec].spec = use_slot; special_locs[found_spec].spec = use_slot;
} else { } else {
std::stringstream sout; special_locs[found_spec].spec = specials.size();
sout << "In town \"" << town_num << "\" at (" << i << ',' << j << "); special node ID " << special_locs[found_spec].spec; specials.emplace_back();
giveError("Warning: A special node was found that could be triggered from in a boat, which is probably not what the designer intended. An attempt to fix this has failed because there were not enough unused special nodes.", sout.str()); node = &specials.back();
} }
node->type = eSpecType::IF_IN_BOAT;
node->ex1b = -1; // any boat;
node->ex1c = -1; // do nothing
node->jumpto = found_spec_id; // else jump here
} }
} }
} }
@@ -119,20 +121,22 @@ void cMedTown::append(legacy::ave_tr_type& old, int town_num){
} }
} }
if(found_spec >= 0) { if(found_spec >= 0) {
int found_spec_id = special_locs[found_spec].spec;
cSpecial* node;
if(!unused_special_slots.empty()) { if(!unused_special_slots.empty()) {
int found_spec_id = special_locs[found_spec].spec, use_slot = unused_special_slots.back(); int use_slot = unused_special_slots.back();
unused_special_slots.pop_back(); unused_special_slots.pop_back();
cSpecial& node = specials[use_slot]; node = &specials[use_slot];
node.type = eSpecType::IF_IN_BOAT;
node.ex1b = -1; // any boat;
node.ex1c = -1; // do nothing
node.jumpto = found_spec_id; // else jump here
special_locs[found_spec].spec = use_slot; special_locs[found_spec].spec = use_slot;
} else { } else {
std::stringstream sout; special_locs[found_spec].spec = specials.size();
sout << "In town " << town_num << " at (" << i << ',' << j << "); special node ID " << special_locs[found_spec].spec; specials.emplace_back();
giveError("Warning: A special node was found that could be triggered from in a boat, which is probably not what the designer intended. An attempt to fix this has failed because there were not enough unused special nodes.", sout.str()); node = &specials.back();
} }
node->type = eSpecType::IF_IN_BOAT;
node->ex1b = -1; // any boat;
node->ex1c = -1; // do nothing
node->jumpto = found_spec_id; // else jump here
} }
} }
} }
@@ -184,20 +188,22 @@ void cBigTown::append(legacy::big_tr_type& old, int town_numo){
} }
} }
if(found_spec >= 0) { if(found_spec >= 0) {
int found_spec_id = special_locs[found_spec].spec;
cSpecial* node;
if(!unused_special_slots.empty()) { if(!unused_special_slots.empty()) {
int found_spec_id = special_locs[found_spec].spec, use_slot = unused_special_slots.back(); int use_slot = unused_special_slots.back();
unused_special_slots.pop_back(); unused_special_slots.pop_back();
cSpecial& node = specials[use_slot]; node = &specials[use_slot];
node.type = eSpecType::IF_IN_BOAT;
node.ex1b = -1; // any boat;
node.ex1c = -1; // do nothing
node.jumpto = found_spec_id; // else jump here
special_locs[found_spec].spec = use_slot; special_locs[found_spec].spec = use_slot;
} else { } else {
std::stringstream sout; special_locs[found_spec].spec = specials.size();
sout << "In town " << town_numo << " at (" << i << ',' << j << "); special node ID " << special_locs[found_spec].spec; specials.emplace_back();
giveError("Warning: A special node was found that could be triggered from in a boat, which is probably not what the designer intended. An attempt to fix this has failed because there were not enough unused special nodes.", sout.str()); node = &specials.back();
} }
node->type = eSpecType::IF_IN_BOAT;
node->ex1b = -1; // any boat;
node->ex1c = -1; // do nothing
node->jumpto = found_spec_id; // else jump here
} }
} }
} }