Make a lot of code stop relying on hard-coded sizes
This commit is contained in:
@@ -1417,12 +1417,13 @@ void cast_town_spell(location where) {
|
||||
}
|
||||
|
||||
bool cast_spell_on_space(location where, eSpell spell) {
|
||||
short i,s1 = 0,s2 = 0,s3 = 0;
|
||||
short s1 = 0,s2 = 0,s3 = 0;
|
||||
|
||||
for(i = 0; i < 50; i++)
|
||||
for(size_t i = 0; i < univ.town->special_locs.size(); i++)
|
||||
if(where == univ.town->special_locs[i]) {
|
||||
if(univ.town->specials[univ.town->spec_id[i]].type == eSpecType::IF_CONTEXT)
|
||||
run_special(eSpecCtx::TARGET,2,univ.town->spec_id[i],where,&s1,&s2,&s3);
|
||||
// TODO: Is there a way to skip this condition without breaking compatibility?
|
||||
if(univ.town->specials[univ.town->special_locs[i].spec].type == eSpecType::IF_CONTEXT)
|
||||
run_special(eSpecCtx::TARGET,2,univ.town->special_locs[i].spec,where,&s1,&s2,&s3);
|
||||
if(s3) redraw_terrain();
|
||||
return !s1;
|
||||
}
|
||||
|
@@ -162,11 +162,11 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
|
||||
if(mode == eSpecCtx::OUT_MOVE) {
|
||||
out_where = global_to_local(where_check);
|
||||
|
||||
for(i = 0; i < 18; i++)
|
||||
for(i = 0; i < univ.out->special_locs.size(); i++)
|
||||
if(out_where == univ.out->special_locs[i]) {
|
||||
*spec_num = univ.out->special_id[i];
|
||||
*spec_num = univ.out->special_locs[i].spec;
|
||||
// call special
|
||||
run_special(mode,1,univ.out->special_id[i],out_where,&s1,&s2,&s3);
|
||||
run_special(mode,1,univ.out->special_locs[i].spec,out_where,&s1,&s2,&s3);
|
||||
if(s1 > 0)
|
||||
can_enter = false;
|
||||
else if(s2 > 0)
|
||||
@@ -193,9 +193,9 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
|
||||
add_string_to_buf(" Force cage!");
|
||||
return false;
|
||||
}
|
||||
for(i = 0; i < 50; i++)
|
||||
for(i = 0; i < univ.town->special_locs.size(); i++)
|
||||
if(where_check == univ.town->special_locs[i]) {
|
||||
*spec_num = univ.town->spec_id[i];
|
||||
*spec_num = univ.town->special_locs[i].spec;
|
||||
bool runSpecial = false;
|
||||
if(!is_blocked(where_check)) runSpecial = true;
|
||||
if(ter_special == eTerSpec::CHANGE_WHEN_STEP_ON) runSpecial = true;
|
||||
@@ -206,7 +206,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
|
||||
runSpecial = true;
|
||||
if(runSpecial) {
|
||||
give_help(54,0);
|
||||
run_special(mode,2,univ.town->spec_id[i],where_check,&s1,&s2,&s3);
|
||||
run_special(mode,2,*spec_num,where_check,&s1,&s2,&s3);
|
||||
if(s1 > 0)
|
||||
can_enter = false;
|
||||
else if(s2 > 0)
|
||||
@@ -1286,14 +1286,14 @@ bool adj_town_look(location where) {
|
||||
if(!adjacent(univ.town.p_loc,where))
|
||||
add_string_to_buf(" Not close enough to search.");
|
||||
else {
|
||||
for(i = 0; i < 50; i++)
|
||||
for(i = 0; i < univ.town->special_locs.size(); i++)
|
||||
if(where == univ.town->special_locs[i]) {
|
||||
if(get_blockage(univ.town->terrain(where.x,where.y)) > 0) {
|
||||
// tell party you find something, if looking at a space they can't step in
|
||||
add_string_to_buf(" Search: You find something!");
|
||||
}
|
||||
|
||||
run_special(eSpecCtx::TOWN_LOOK,2,univ.town->spec_id[i],where,&s1,&s2,&s3);
|
||||
run_special(eSpecCtx::TOWN_LOOK,2,univ.town->special_locs[i].spec,where,&s1,&s2,&s3);
|
||||
if(s1 > 0)
|
||||
can_open = false;
|
||||
got_special = true;
|
||||
@@ -1314,39 +1314,6 @@ bool adj_town_look(location where) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// PSOE - place_special_outdoor_encounter
|
||||
// if always, stuff_done_val is NULL
|
||||
void PSOE(short which_special,unsigned char *stuff_done_val,short where_put) {
|
||||
short i,j,graphic_num = 0;
|
||||
|
||||
if(stuff_done_val != NULL) {
|
||||
if(*stuff_done_val > 0)
|
||||
return;
|
||||
else *stuff_done_val = 20;
|
||||
}
|
||||
for(i = 0; i < 18; i++)
|
||||
if(univ.out->special_id[i] == where_put) {
|
||||
for(j = 0; j < 7; j++)
|
||||
if(univ.out->special_enc[which_special].monst[j] > 0) {
|
||||
graphic_num = get_monst_picnum(univ.out->special_enc[which_special].monst[j]);
|
||||
j = 7;
|
||||
}
|
||||
//display_strings( str1a, str1b, str2a, str2b,
|
||||
//// "Encounter!",57, graphic_num, 0);
|
||||
draw_terrain(0);
|
||||
pause(15);
|
||||
//if(univ.out.outdoors[univ.party.i_w_c.x][univ.party.i_w_c.y].special_enc[which_special].spec_code == 0)
|
||||
// univ.out.outdoors[univ.party.i_w_c.x][univ.party.i_w_c.y].special_enc[which_special].spec_code = 1;
|
||||
//place_outd_wand_monst(univ.out.outdoors[univ.party.i_w_c.x][univ.party.i_w_c.y].special_locs[i],
|
||||
// univ.out.outdoors[univ.party.i_w_c.x][univ.party.i_w_c.y].special_enc[which_special]);
|
||||
|
||||
i = 18;
|
||||
}
|
||||
draw_terrain(0);
|
||||
play_sound(61);
|
||||
//play_sound(0);
|
||||
}
|
||||
|
||||
void out_move_party(short x,short y) {
|
||||
location l;
|
||||
|
||||
@@ -2119,25 +2086,23 @@ void run_special(eSpecCtx which_mode,short which_type,short start_spec,location
|
||||
|
||||
cSpecial get_node(short cur_spec,short cur_spec_type) {
|
||||
cSpecial dummy_node;
|
||||
|
||||
dummy_node = univ.scenario.scen_specials[0];
|
||||
dummy_node.type = eSpecType::INVALID;
|
||||
if(cur_spec_type == 0) {
|
||||
if(cur_spec != minmax(0,255,cur_spec)) {
|
||||
if(cur_spec != minmax(0,univ.scenario.scen_specials.size() - 1,cur_spec)) {
|
||||
giveError("The scenario called a scenario special node out of range.");
|
||||
return dummy_node;
|
||||
}
|
||||
return univ.scenario.scen_specials[cur_spec];
|
||||
}
|
||||
if(cur_spec_type == 1) {
|
||||
if(cur_spec != minmax(0,59,cur_spec)) {
|
||||
if(cur_spec != minmax(0,univ.out->specials.size() - 1,cur_spec)) {
|
||||
giveError("The scenario called an outdoor special node out of range.");
|
||||
return dummy_node;
|
||||
}
|
||||
return univ.out->specials[cur_spec];
|
||||
}
|
||||
if(cur_spec_type == 2) {
|
||||
if(cur_spec != minmax(0,99,cur_spec)) {
|
||||
if(cur_spec != minmax(0,univ.town->specials.size() - 1,cur_spec)) {
|
||||
giveError("The scenario called a town special node out of range.");
|
||||
return dummy_node;
|
||||
}
|
||||
|
@@ -9,7 +9,6 @@ void use_spec_item(short item);
|
||||
void use_item(short pc,short item);
|
||||
bool use_space(location where);
|
||||
bool adj_town_look(location where);
|
||||
void PSOE(short which_special,unsigned char *stuff_done_val,short where_put);
|
||||
bool damage_monst(short which_m, short who_hit, short how_much, eDamageType dam_type, short sound_type, bool do_print = true);
|
||||
void kill_monst(cCreature *which_m,short who_killed,eMainStatus type = eMainStatus::DEAD);
|
||||
void special_increase_age(long length = 1, bool queue = false);
|
||||
|
@@ -1225,29 +1225,21 @@ void erase_specials() {
|
||||
return;
|
||||
if(!is_town() && !is_combat())
|
||||
return;
|
||||
for(k = 0; k < 50; k++) {
|
||||
for(k = 0; k < univ.town->special_locs.size(); k++) {
|
||||
//if(univ.town->spec_id[k] >= 0) {
|
||||
sn = univ.town->specials[univ.town->spec_id[k]];
|
||||
sn = univ.town->specials[univ.town->special_locs[k].spec];
|
||||
sd1 = sn.sd1; sd2 = sn.sd2;
|
||||
if((univ.party.sd_legit(sd1,sd2)) && (PSD[sd1][sd2] == 250)) {
|
||||
long spec = univ.town->special_locs[k].spec;
|
||||
where = univ.town->special_locs[k];
|
||||
if((where.x != 100) && ((where.x > univ.town->max_dim()) || (where.y > univ.town->max_dim())
|
||||
|| (where.x < 0) || (where.y < 0))) {
|
||||
if(spec >= 0 && (where.x > univ.town->max_dim() || where.y > univ.town->max_dim() || where.x < 0 || where.y < 0)) {
|
||||
beep();
|
||||
add_string_to_buf("Town corrupt. Problem fixed.");
|
||||
print_nums(where.x,where.y,k);
|
||||
univ.town->special_locs[k].x = 0;
|
||||
univ.town->special_locs[k].spec = -1;
|
||||
}
|
||||
|
||||
if(where.x != 100) {
|
||||
// switch(scenario.ter_types[univ.town->terrain(where.x,where.y)].picture) {
|
||||
// case 207: univ.town->terrain(where.x,where.y) = 0; break;
|
||||
// case 208: univ.town->terrain(where.x,where.y) = 170; break;
|
||||
// case 209: univ.town->terrain(where.x,where.y) = 210; break;
|
||||
// case 210: univ.town->terrain(where.x,where.y) = 217; break;
|
||||
// case 211: univ.town->terrain(where.x,where.y) = 2; break;
|
||||
// case 212: univ.town->terrain(where.x,where.y) = 36; break;
|
||||
// }
|
||||
if(spec >= 0) {
|
||||
univ.town.set_spot(where.x,where.y,false);
|
||||
}
|
||||
}
|
||||
@@ -1268,7 +1260,7 @@ void erase_out_specials() {
|
||||
for(short j = 0; j < 2; j++)
|
||||
if(quadrant_legal(i,j)) {
|
||||
cOutdoors& sector = *univ.scenario.outdoors[univ.party.outdoor_corner.x + i][univ.party.outdoor_corner.y + j];
|
||||
for(short k = 0; k < 18; k++) {
|
||||
for(short k = 0; k < sector.special_locs.size(); k++) {
|
||||
if(k < 8 && sector.exit_dests[k] >= 0 &&
|
||||
univ.scenario.ter_types[sector.terrain[sector.exit_locs[k].x][sector.exit_locs[k].y]].special == eTerSpec::TOWN_ENTRANCE &&
|
||||
(sector.exit_locs[k].x == minmax(0,47,sector.exit_locs[k].x)) &&
|
||||
@@ -1283,18 +1275,17 @@ void erase_out_specials() {
|
||||
|
||||
}
|
||||
}
|
||||
if(sector.special_id[k] < 0) continue; // TODO: Is this needed? Seems to be important, so why was it commented out?
|
||||
if(sector.special_locs[k].spec < 0) continue; // TODO: Is this needed? Seems to be important, so why was it commented out?
|
||||
out_num = univ.scenario.outdoors.width() * (univ.party.outdoor_corner.y + j) + univ.party.outdoor_corner.x + i;
|
||||
|
||||
sn = sector.specials[sector.special_id[k]];
|
||||
sn = sector.specials[sector.special_locs[k].spec];
|
||||
sd1 = sn.sd1; sd2 = sn.sd2;
|
||||
if((univ.party.sd_legit(sd1,sd2)) && (PSD[sd1][sd2] == 250)) {
|
||||
where = sector.special_locs[k];
|
||||
if((where.x > 48) || (where.y > 48)
|
||||
|| (where.x < 0) || (where.y < 0)) {
|
||||
if(where.x > 48 || where.y > 48 || where.x < 0 || where.y < 0) {
|
||||
beep();
|
||||
add_string_to_buf("Outdoor section corrupt. Problem fixed.");
|
||||
sector.special_id[k] = -1; // TODO: Again, was there a reason for commenting this out?
|
||||
sector.special_locs[k].spec = -1; // TODO: Again, was there a reason for commenting this out?
|
||||
}
|
||||
|
||||
sector.special_spot[where.x][where.y] = false;
|
||||
@@ -1303,15 +1294,6 @@ void erase_out_specials() {
|
||||
}
|
||||
}
|
||||
|
||||
// returns id # of special at where, or 50 if there is none.
|
||||
short get_town_spec_id(location where) {
|
||||
short i = 0;
|
||||
|
||||
while((univ.town->special_locs[i] != where) && (i < 50))
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
// TODO: I don't think we need this
|
||||
void clear_map() {
|
||||
rectangle map_world_rect(map_gworld);
|
||||
|
@@ -23,7 +23,6 @@ void pick_lock(location where,short pc_num);
|
||||
void bash_door(location where,short pc_num);
|
||||
void erase_specials();
|
||||
void erase_out_specials();
|
||||
short get_town_spec_id(location where);
|
||||
void clear_map();
|
||||
void draw_map(bool need_refresh);
|
||||
bool is_door(location destination);
|
||||
|
@@ -163,8 +163,8 @@ location get_spec_loc(short which) {
|
||||
location where;
|
||||
short i;
|
||||
|
||||
for(i = 0; i < 50; i++)
|
||||
if(univ.town->spec_id[i] == which)
|
||||
for(i = 0; i < univ.town->special_locs.size(); i++)
|
||||
if(univ.town->special_locs[i].spec == which)
|
||||
return univ.town->special_locs[i];
|
||||
return where;
|
||||
}
|
||||
|
@@ -80,6 +80,20 @@ struct info_rect_t : public rectangle {
|
||||
std::string descr;
|
||||
};
|
||||
|
||||
struct spec_loc_t : public location {
|
||||
long spec;
|
||||
|
||||
spec_loc_t(const location& loc) : location(loc) {}
|
||||
spec_loc_t& operator=(const location& loc) {*this = spec_loc_t(loc); return *this;}
|
||||
// Declaring one constructor suppresses all implicit constructors, so declare them explicitly
|
||||
spec_loc_t() = default;
|
||||
spec_loc_t(const spec_loc_t& other) = default;
|
||||
spec_loc_t(spec_loc_t&& other) = default;
|
||||
// Ditto for assignment operators
|
||||
spec_loc_t& operator=(const spec_loc_t& other) = default;
|
||||
spec_loc_t& operator=(spec_loc_t&& other) = default;
|
||||
};
|
||||
|
||||
bool operator == (location p1,location p2);
|
||||
bool operator != (location p1,location p2);
|
||||
bool operator == (rectangle r1, rectangle r2);
|
||||
|
@@ -69,7 +69,9 @@ void cOutdoors::append(legacy::outdoor_record_type& old){
|
||||
for(i = 0; i < 18; i++){
|
||||
special_locs[i].x = old.special_locs[i].x;
|
||||
special_locs[i].y = old.special_locs[i].y;
|
||||
special_id[i] = old.special_id[i];
|
||||
if(old.special_locs[i].x == 100)
|
||||
special_locs[i].spec = -1;
|
||||
else special_locs[i].spec = old.special_id[i];
|
||||
}
|
||||
for(i = 0; i < 8; i++){
|
||||
exit_locs[i].x = old.exit_locs[i].x;
|
||||
@@ -119,7 +121,7 @@ cOutdoors::cWandering::cWandering() {
|
||||
|
||||
cOutdoors::cOutdoors(cScenario& scenario, bool init_strings) : scenario(scenario) {
|
||||
short i,j;
|
||||
location d_loc(100,0);;
|
||||
location d_loc(100,0);
|
||||
location locs[4] = {loc(8,8),loc(32,8),loc(8,32),loc(32,32)};
|
||||
bg_out = bg_fight = bg_town = bg_dungeon = -1;
|
||||
|
||||
@@ -129,12 +131,11 @@ cOutdoors::cOutdoors(cScenario& scenario, bool init_strings) : scenario(scenario
|
||||
}
|
||||
|
||||
for(i = 0; i < 18; i++) {
|
||||
special_locs[i] = d_loc;
|
||||
special_locs[i].spec = -1;
|
||||
}
|
||||
for(i = 0; i < 8; i++) {
|
||||
exit_locs[i] = d_loc;
|
||||
sign_locs[i] = d_loc;
|
||||
sign_locs[i].x = 100;
|
||||
}
|
||||
for(i = 0; i < 4; i++) {
|
||||
wandering_locs[i] = locs[i];
|
||||
|
@@ -60,8 +60,7 @@ public:
|
||||
};
|
||||
short x,y; // Used while loading legacy scenarios.
|
||||
ter_num_t terrain[48][48];
|
||||
location special_locs[18];
|
||||
unsigned short special_id[18];
|
||||
std::array<spec_loc_t,18> special_locs;
|
||||
location exit_locs[8];
|
||||
short exit_dests[8];
|
||||
location sign_locs[8];
|
||||
|
@@ -55,17 +55,17 @@ void cTinyTown::append(legacy::tiny_tr_type& old, int town_num){
|
||||
}
|
||||
if(found_spec >= 0) {
|
||||
if(!unused_special_slots.empty()) {
|
||||
int found_spec_id = spec_id[found_spec], use_slot = unused_special_slots.back();
|
||||
int found_spec_id = special_locs[found_spec].spec, use_slot = unused_special_slots.back();
|
||||
unused_special_slots.pop_back();
|
||||
cSpecial& 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
|
||||
spec_id[found_spec] = use_slot;
|
||||
special_locs[found_spec].spec = use_slot;
|
||||
} else {
|
||||
std::stringstream sout;
|
||||
sout << "In town \"" << town_num << "\" at (" << i << ',' << j << "); special node ID " << spec_id[found_spec];
|
||||
sout << "In town \"" << town_num << "\" at (" << i << ',' << j << "); special node ID " << special_locs[found_spec].spec;
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -120,17 +120,17 @@ void cMedTown::append(legacy::ave_tr_type& old, int town_num){
|
||||
}
|
||||
if(found_spec >= 0) {
|
||||
if(!unused_special_slots.empty()) {
|
||||
int found_spec_id = spec_id[found_spec], use_slot = unused_special_slots.back();
|
||||
int found_spec_id = special_locs[found_spec].spec, use_slot = unused_special_slots.back();
|
||||
unused_special_slots.pop_back();
|
||||
cSpecial& 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
|
||||
spec_id[found_spec] = use_slot;
|
||||
special_locs[found_spec].spec = use_slot;
|
||||
} else {
|
||||
std::stringstream sout;
|
||||
sout << "In town " << town_num << " at (" << i << ',' << j << "); special node ID " << spec_id[found_spec];
|
||||
sout << "In town " << town_num << " at (" << i << ',' << j << "); special node ID " << special_locs[found_spec].spec;
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -185,17 +185,17 @@ void cBigTown::append(legacy::big_tr_type& old, int town_numo){
|
||||
}
|
||||
if(found_spec >= 0) {
|
||||
if(!unused_special_slots.empty()) {
|
||||
int found_spec_id = spec_id[found_spec], use_slot = unused_special_slots.back();
|
||||
int found_spec_id = special_locs[found_spec].spec, use_slot = unused_special_slots.back();
|
||||
unused_special_slots.pop_back();
|
||||
cSpecial& 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
|
||||
spec_id[found_spec] = use_slot;
|
||||
special_locs[found_spec].spec = use_slot;
|
||||
} else {
|
||||
std::stringstream sout;
|
||||
sout << "In town " << town_numo << " at (" << i << ',' << j << "); special node ID " << spec_id[found_spec];
|
||||
sout << "In town " << town_numo << " at (" << i << ',' << j << "); special node ID " << special_locs[found_spec].spec;
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@@ -38,7 +38,9 @@ void cTown::append(legacy::town_record_type& old){
|
||||
for(i = 0; i < 50; i++){
|
||||
special_locs[i].x = old.special_locs[i].x;
|
||||
special_locs[i].y = old.special_locs[i].y;
|
||||
spec_id[i] = old.spec_id[i];
|
||||
if(old.special_locs[i].x == 100)
|
||||
special_locs[i].spec = -1;
|
||||
else special_locs[i].spec = old.spec_id[i];
|
||||
cField temp;
|
||||
temp.append(old.preset_fields[i]);
|
||||
preset_fields.push_back(temp);
|
||||
@@ -82,8 +84,7 @@ cTown::cTown(cScenario& scenario, bool init_strings) : scenario(scenario) {
|
||||
wandering_locs[i] = d_loc;
|
||||
}
|
||||
for(i = 0; i < 50; i++) {
|
||||
special_locs[i] = d_loc;
|
||||
spec_id[i] = 0;
|
||||
special_locs[i].spec = -1;
|
||||
}
|
||||
lighting_type = LIGHT_NORMAL;
|
||||
for(i = 0; i < 4; i++) {
|
||||
|
@@ -73,8 +73,7 @@ public:
|
||||
int bg_town, bg_fight;
|
||||
cWandering wandering[4];
|
||||
location wandering_locs[4];
|
||||
location special_locs[50];
|
||||
unsigned short spec_id[50];
|
||||
std::array<spec_loc_t,50> special_locs;
|
||||
location sign_locs[15];
|
||||
eLighting lighting_type;
|
||||
location start_locs[4];
|
||||
|
@@ -239,8 +239,9 @@ bool cCurTown::is_spot(short x, short y) const{
|
||||
|
||||
bool cCurTown::is_special(short x, short y) const{
|
||||
if(x > record()->max_dim() || y > record()->max_dim()) return false;
|
||||
for(int i = 0; i < 50; i++)
|
||||
if(x == record()->special_locs[i].x && y == record()->special_locs[i].y)
|
||||
location check(x,y);
|
||||
for(int i = 0; i < record()->special_locs.size(); i++)
|
||||
if(check == record()->special_locs[i] && record()->special_locs[i].spec >= 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@@ -744,16 +744,16 @@ bool handle_action(location the_point,sf::Event /*event*/) {
|
||||
break;
|
||||
case MODE_COPY_SPECIAL: //copy special
|
||||
if(editing_town) {
|
||||
for(x = 0; x < 50; x++)
|
||||
if((town->special_locs[x].x == spot_hit.x) && (town->special_locs[x].y == spot_hit.y)) {
|
||||
copied_spec = town->spec_id[x];
|
||||
for(x = 0; x < town->special_locs.size(); x++)
|
||||
if(town->special_locs[x] == spot_hit && town->special_locs[x].spec >= 0) {
|
||||
copied_spec = town->special_locs[x].spec;
|
||||
x = 500;
|
||||
}
|
||||
}
|
||||
if(!editing_town) {
|
||||
for(x = 0; x < 18; x++)
|
||||
if((current_terrain->special_locs[x].x == spot_hit.x) && (current_terrain->special_locs[x].y == spot_hit.y)) {
|
||||
copied_spec = current_terrain->special_id[x];
|
||||
for(x = 0; x < current_terrain->special_locs.size(); x++)
|
||||
if(current_terrain->special_locs[x] == spot_hit && current_terrain->special_locs[x].spec >= 0) {
|
||||
copied_spec = current_terrain->special_locs[x].spec;
|
||||
x = 500;
|
||||
}
|
||||
}
|
||||
@@ -768,10 +768,10 @@ bool handle_action(location the_point,sf::Event /*event*/) {
|
||||
break;
|
||||
}
|
||||
if(editing_town) {
|
||||
for(x = 0; x < 50; x++)
|
||||
if(town->special_locs[x].x == 100) {
|
||||
for(x = 0; x < town->special_locs.size(); x++)
|
||||
if(town->special_locs[x].spec < 0) {
|
||||
town->special_locs[x] = spot_hit;
|
||||
town->spec_id[x] = copied_spec ;
|
||||
town->special_locs[x].spec = copied_spec;
|
||||
x = 500;
|
||||
}
|
||||
}
|
||||
@@ -780,10 +780,10 @@ bool handle_action(location the_point,sf::Event /*event*/) {
|
||||
cChoiceDlog("not-at-edge").show();
|
||||
break;
|
||||
}
|
||||
for(x = 0; x < 18; x++)
|
||||
if(current_terrain->special_locs[x].x == 100) {
|
||||
for(x = 0; x < current_terrain->special_locs.size(); x++)
|
||||
if(current_terrain->special_locs[x].spec < 0) {
|
||||
current_terrain->special_locs[x] = spot_hit;
|
||||
current_terrain->special_id[x] = copied_spec;
|
||||
current_terrain->special_locs[x].spec = copied_spec;
|
||||
x = 500;
|
||||
}
|
||||
}
|
||||
@@ -796,16 +796,18 @@ bool handle_action(location the_point,sf::Event /*event*/) {
|
||||
break;
|
||||
case MODE_ERASE_SPECIAL: //erase special
|
||||
if(editing_town) {
|
||||
for(x = 0; x < 50; x++)
|
||||
if((town->special_locs[x].x == spot_hit.x) && (town->special_locs[x].y == spot_hit.y)) {
|
||||
town->special_locs[x].x = 100;
|
||||
for(x = 0; x < town->special_locs.size(); x++)
|
||||
if(town->special_locs[x] == spot_hit && town->special_locs[x].spec >= 0) {
|
||||
town->special_locs[x] = {-1,-1};
|
||||
town->special_locs[x].spec = -1;
|
||||
x = 500;
|
||||
}
|
||||
}
|
||||
if(!editing_town) {
|
||||
for(x = 0; x < 18; x++)
|
||||
if((current_terrain->special_locs[x].x == spot_hit.x) && (current_terrain->special_locs[x].y == spot_hit.y)) {
|
||||
current_terrain->special_locs[x].x = 100;
|
||||
for(x = 0; x < current_terrain->special_locs.size(); x++)
|
||||
if(current_terrain->special_locs[x] == spot_hit && current_terrain->special_locs[x].spec >= 0) {
|
||||
current_terrain->special_locs[x] = {-1,-1};
|
||||
current_terrain->special_locs[x].spec = -1;
|
||||
x = 500;
|
||||
}
|
||||
}
|
||||
@@ -2750,9 +2752,9 @@ void place_edit_special(location loc) {
|
||||
short i,spec;
|
||||
|
||||
if(editing_town) {
|
||||
for(i = 0; i < 50; i++)
|
||||
if((town->special_locs[i].x == loc.x) && (town->special_locs[i].y == loc.y)) {
|
||||
edit_spec_enc(town->spec_id[i],2,nullptr);
|
||||
for(i = 0; i < town->special_locs.size(); i++)
|
||||
if(town->special_locs[i] == loc && town->special_locs[i].spec >= 0) {
|
||||
edit_spec_enc(town->special_locs[i].spec,2,nullptr);
|
||||
i = 500;
|
||||
}
|
||||
if(i < 500) { // new special
|
||||
@@ -2761,14 +2763,12 @@ void place_edit_special(location loc) {
|
||||
giveError("You are out of special nodes in this town. Select Edit Special Nodes from the Town menu to clear out some of the special nodes.");
|
||||
return;
|
||||
}
|
||||
for(i = 0; i < 50; i++)
|
||||
if(town->special_locs[i].x == 100) {
|
||||
town->special_locs[i] = loc;
|
||||
town->spec_id[i] = spec;
|
||||
edit_spec_enc(spec,2,nullptr);
|
||||
|
||||
if(town->specials[spec].pic < 0)
|
||||
town->special_locs[i].x = 100;
|
||||
for(i = 0; i < town->special_locs.size(); i++)
|
||||
if(town->special_locs[i].spec < 0) {
|
||||
if(edit_spec_enc(spec,2,nullptr)) {
|
||||
town->special_locs[i] = loc;
|
||||
town->special_locs[i].spec = spec;
|
||||
}
|
||||
i = 500;
|
||||
}
|
||||
if(i < 500) {
|
||||
@@ -2783,9 +2783,9 @@ void place_edit_special(location loc) {
|
||||
cChoiceDlog("not-at-edge").show();
|
||||
return;
|
||||
}
|
||||
for(i = 0; i < 18; i++)
|
||||
if((current_terrain->special_locs[i].x == loc.x) && (current_terrain->special_locs[i].y == loc.y)) {
|
||||
edit_spec_enc(current_terrain->special_id[i],1,nullptr);
|
||||
for(i = 0; i < current_terrain->special_locs.size(); i++)
|
||||
if(current_terrain->special_locs[i] == loc && current_terrain->special_locs[i].spec >= 0) {
|
||||
edit_spec_enc(current_terrain->special_locs[i].spec,1,nullptr);
|
||||
i = 500;
|
||||
}
|
||||
if(i < 500) { // new special
|
||||
@@ -2794,14 +2794,12 @@ void place_edit_special(location loc) {
|
||||
giveError("You are out of special nodes in this outdoor section. Select Edit Special Nodes from the Outdoor menu to clear out some of the special nodes.");
|
||||
return;
|
||||
}
|
||||
for(i = 0; i < 18; i++)
|
||||
if(current_terrain->special_locs[i].x == 100) {
|
||||
current_terrain->special_locs[i] = loc;
|
||||
current_terrain->special_id[i] = spec;
|
||||
edit_spec_enc(spec,1,nullptr);
|
||||
|
||||
if(current_terrain->specials[spec].pic < 0)
|
||||
current_terrain->special_locs[i].x = 100;
|
||||
for(i = 0; i < current_terrain->special_locs.size(); i++)
|
||||
if(current_terrain->special_locs[i].spec < 0) {
|
||||
if(edit_spec_enc(spec,1,nullptr)) {
|
||||
current_terrain->special_locs[i] = loc;
|
||||
current_terrain->special_locs[i].spec = spec;
|
||||
}
|
||||
i = 500;
|
||||
}
|
||||
if(i < 500) {
|
||||
@@ -2817,19 +2815,19 @@ void set_special(location spot_hit) {
|
||||
short x,y;
|
||||
|
||||
if(editing_town) {
|
||||
for(x = 0; x < 50; x++)
|
||||
if((town->special_locs[x].x == spot_hit.x) && (town->special_locs[x].y == spot_hit.y)) {
|
||||
y = edit_special_num(2,town->spec_id[x]);
|
||||
if(y >= 0) town->spec_id[x] = y;
|
||||
for(x = 0; x < town->special_locs.size(); x++)
|
||||
if(town->special_locs[x] == spot_hit && town->special_locs[x].spec >= 0) {
|
||||
y = edit_special_num(2,town->special_locs[x].spec);
|
||||
if(y >= 0) town->special_locs[x].spec = y;
|
||||
x = 500;
|
||||
}
|
||||
if(x < 500) {
|
||||
for(x = 0; x < 50; x++)
|
||||
if(town->special_locs[x].x == 100) {
|
||||
for(x = 0; x < town->special_locs.size(); x++)
|
||||
if(town->special_locs[x].spec < 0) {
|
||||
y = edit_special_num(2,0);
|
||||
if(y >= 0) {
|
||||
town->special_locs[x] = spot_hit;
|
||||
town->spec_id[x] = y;
|
||||
town->special_locs[x].spec = y;
|
||||
}
|
||||
x = 500;
|
||||
}
|
||||
@@ -2842,19 +2840,19 @@ void set_special(location spot_hit) {
|
||||
cChoiceDlog("not-at-edge").show();
|
||||
return;
|
||||
}
|
||||
for(x = 0; x < 18; x++)
|
||||
if((current_terrain->special_locs[x].x == spot_hit.x) && (current_terrain->special_locs[x].y == spot_hit.y)) {
|
||||
y = edit_special_num(1,current_terrain->special_id[x]);
|
||||
if(y >= 0) current_terrain->special_id[x] = y;
|
||||
for(x = 0; x < current_terrain->special_locs.size(); x++)
|
||||
if(current_terrain->special_locs[x] == spot_hit && current_terrain->special_locs[x].spec >= 0) {
|
||||
y = edit_special_num(1,current_terrain->special_locs[x].spec);
|
||||
if(y >= 0) current_terrain->special_locs[x].spec = y;
|
||||
x = 500;
|
||||
}
|
||||
if(x < 500) {
|
||||
for(x = 0; x < 18; x++)
|
||||
if(current_terrain->special_locs[x].x == 100) {
|
||||
y = edit_special_num(1,current_terrain->special_id[x]);
|
||||
for(x = 0; x < current_terrain->special_locs.size(); x++)
|
||||
if(current_terrain->special_locs[x].spec < 0) {
|
||||
y = edit_special_num(1,current_terrain->special_locs[x].spec);
|
||||
if(y >= 0) {
|
||||
current_terrain->special_locs[x] = spot_hit;
|
||||
current_terrain->special_id[x] = y;
|
||||
current_terrain->special_locs[x].spec = y;
|
||||
}
|
||||
x = 500;
|
||||
}
|
||||
@@ -3180,8 +3178,13 @@ void start_string_editing(short mode,short just_redo_text) {
|
||||
void start_special_editing(short mode,short just_redo_text) {
|
||||
short i;
|
||||
char str[256];
|
||||
short num_specs[3] = {256,60,100};
|
||||
size_t num_specs;
|
||||
bool draw_full = false;
|
||||
switch(mode) {
|
||||
case 0: num_specs = scenario.scen_specials.size(); break;
|
||||
case 1: num_specs = current_terrain->specials.size(); break;
|
||||
case 2: num_specs = town->specials.size(); break;
|
||||
}
|
||||
|
||||
if(just_redo_text == 0) {
|
||||
if(overall_mode < MODE_MAIN_SCREEN)
|
||||
@@ -3192,10 +3195,10 @@ void start_special_editing(short mode,short just_redo_text) {
|
||||
right_sbar->show();
|
||||
|
||||
reset_rb();
|
||||
right_sbar->setMaximum(num_specs[mode] - NRSONPAGE);
|
||||
right_sbar->setMaximum(num_specs - NRSONPAGE);
|
||||
}
|
||||
|
||||
for(i = 0; i < num_specs[mode]; i++) {
|
||||
for(size_t i = 0; i < num_specs; i++) {
|
||||
std::ostringstream strb;
|
||||
switch(mode) {
|
||||
case 0:
|
||||
|
@@ -686,9 +686,9 @@ map_data buildOutMapData(location which) {
|
||||
terrain.addFeature(x, y, eMapFeature::FIELD, SPECIAL_SPOT);
|
||||
}
|
||||
}
|
||||
for(size_t i = 0; i < 18; i++) {
|
||||
if(sector.special_id[i] >= 0)
|
||||
terrain.addFeature(sector.special_locs[i].x, sector.special_locs[i].y, eMapFeature::SPECIAL_NODE, sector.special_id[i]);
|
||||
for(size_t i = 0; i < sector.special_locs.size(); i++) {
|
||||
if(sector.special_locs[i].spec >= 0)
|
||||
terrain.addFeature(sector.special_locs[i].x, sector.special_locs[i].y, eMapFeature::SPECIAL_NODE, sector.special_locs[i].spec);
|
||||
}
|
||||
for(size_t i = 0; i < 8; i++) {
|
||||
if(sector.exit_dests[i] >= 0)
|
||||
@@ -724,9 +724,9 @@ map_data buildTownMapData(size_t which) {
|
||||
terrain.set(x, y, town.terrain(x,y));
|
||||
}
|
||||
}
|
||||
for(size_t i = 0; i < 50; i++) {
|
||||
if(town.spec_id[i] >= 0)
|
||||
terrain.addFeature(town.special_locs[i].x, town.special_locs[i].y, eMapFeature::SPECIAL_NODE, town.spec_id[i]);
|
||||
for(size_t i = 0; i < town.special_locs.size(); i++) {
|
||||
if(town.special_locs[i].spec >= 0)
|
||||
terrain.addFeature(town.special_locs[i].x, town.special_locs[i].y, eMapFeature::SPECIAL_NODE, town.special_locs[i].spec);
|
||||
}
|
||||
for(size_t i = 0; i < town.sign_strs.size(); i++) {
|
||||
if(!town.sign_strs[i].empty())
|
||||
|
@@ -1249,14 +1249,15 @@ void draw_cur_string() {
|
||||
|
||||
bool is_special(short i,short j) {
|
||||
short k;
|
||||
location check(i,j);
|
||||
|
||||
if(editing_town)
|
||||
for(k = 0; k < 50; k++)
|
||||
if((town->special_locs[k].x == i) && (town->special_locs[k].y == j))
|
||||
for(k = 0; k < town->special_locs.size(); k++)
|
||||
if(town->special_locs[k] == check && town->special_locs[k].spec >= 0)
|
||||
return true;
|
||||
if(!editing_town)
|
||||
for(k = 0; k < 18; k++)
|
||||
if((current_terrain->special_locs[k].x == i) && (current_terrain->special_locs[k].y == j))
|
||||
for(k = 0; k < current_terrain->special_locs.size(); k++)
|
||||
if(current_terrain->special_locs[k] == check && current_terrain->special_locs[k].spec >= 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@@ -23,7 +23,6 @@ extern ter_num_t template_terrain[64][64];
|
||||
extern cScenario scenario;
|
||||
extern cOutdoors* current_terrain;
|
||||
extern cCustomGraphics spec_scen_g;
|
||||
short num_specs[3] = {256,60,100};
|
||||
|
||||
std::vector<pic_num_t> field_pics = {0,3,5,6,7,8,9,10,11,12,13,14,15,24,25,26,27,28,29,30,31};
|
||||
std::vector<pic_num_t> boom_pics = {0,1,2,3,4,8,16,24,32};
|
||||
@@ -869,10 +868,15 @@ bool edit_spec_enc(short which_node,short mode,cDialog* parent) {
|
||||
}
|
||||
|
||||
short get_fresh_spec(short which_mode) {
|
||||
short i;
|
||||
cSpecial store_node;
|
||||
size_t num_specs;
|
||||
switch(which_mode) {
|
||||
case 0: num_specs = scenario.scen_specials.size(); break;
|
||||
case 1: num_specs = current_terrain->specials.size(); break;
|
||||
case 2: num_specs = town->specials.size(); break;
|
||||
}
|
||||
|
||||
for(i = 0; i < num_specs[which_mode]; i++) {
|
||||
for(size_t i = 0; i < num_specs; i++) {
|
||||
if(which_mode == 0)
|
||||
store_node = scenario.scen_specials[i];
|
||||
if(which_mode == 1)
|
||||
@@ -1221,12 +1225,18 @@ void edit_dialog_text(short mode,short *str1,cDialog* parent) {
|
||||
|
||||
static bool edit_special_num_event_filter(cDialog& me, std::string item_hit, short spec_mode) {
|
||||
short i;
|
||||
size_t num_specs;
|
||||
switch(spec_mode) {
|
||||
case 0: num_specs = scenario.scen_specials.size();
|
||||
case 1: num_specs = current_terrain->specials.size();
|
||||
case 2: num_specs = town->specials.size();
|
||||
}
|
||||
|
||||
if(item_hit == "cancel") me.setResult<short>(-1);
|
||||
else if(item_hit == "okay") {
|
||||
i = me["num"].getTextAsNum();
|
||||
if((i < 0) || (i >= num_specs[spec_mode])) {
|
||||
giveError("There is no special node with that number. Legal ranges are 0 to 255 for scenario specials, 0 to 59 for outdoor specials, and 0 to 99 for town specials.","",&me);
|
||||
if(i < 0 || i >= num_specs) {
|
||||
giveError("There is no special node with that number. The available range is 0 to " + std::to_string(num_specs - 1) + ".",&me);
|
||||
}
|
||||
me.setResult(i);
|
||||
me.toast(true);
|
||||
|
Reference in New Issue
Block a user