Fix several bugs introduced by refactoring
This commit is contained in:
@@ -396,12 +396,12 @@ static void handle_pause(bool& did_something, bool& need_redraw) {
|
||||
}
|
||||
} else {
|
||||
// The above could leave you stranded in a single-tile passable area, so pausing again should re-enter the boat.
|
||||
int boat = univ.party.boats.size();
|
||||
if(overall_mode == MODE_OUTDOORS && (boat = out_boat_there(univ.party.out_loc)) < univ.party.boats.size())
|
||||
univ.party.in_boat = boat;
|
||||
else if(overall_mode == MODE_TOWN && (boat = town_boat_there(univ.party.town_loc)) < univ.party.boats.size())
|
||||
univ.party.in_boat = boat;
|
||||
if(boat < univ.party.boats.size())
|
||||
cVehicle* boat = nullptr;
|
||||
if(overall_mode == MODE_OUTDOORS && (boat = out_boat_there(univ.party.out_loc)))
|
||||
univ.party.in_boat = boat - &univ.party.boats[0];
|
||||
else if(overall_mode == MODE_TOWN && (boat = town_boat_there(univ.party.town_loc)))
|
||||
univ.party.in_boat = boat - &univ.party.boats[0];
|
||||
if(boat)
|
||||
ASB("You board the boat.");
|
||||
}
|
||||
put_pc_screen();
|
||||
@@ -2788,7 +2788,6 @@ static void run_waterfalls(short mode){ // mode 0 - town, 1 - outdoors
|
||||
}
|
||||
|
||||
bool outd_move_party(location destination,bool forced) {
|
||||
short boat_num,horse_num;
|
||||
location real_dest, sector_p_in;
|
||||
bool keep_going = true,check_f;
|
||||
location store_corner,store_iwc;
|
||||
@@ -2866,7 +2865,7 @@ bool outd_move_party(location destination,bool forced) {
|
||||
univ.party.in_boat = -1;
|
||||
}
|
||||
else if(((real_dest.x != univ.party.out_loc.x) && (real_dest.y != univ.party.out_loc.y))
|
||||
|| (!forced && (out_boat_there(destination) < 30)))
|
||||
|| (!forced && out_boat_there(destination)))
|
||||
return false;
|
||||
else if(!outd_is_blocked(real_dest)
|
||||
&& univ.scenario.ter_types[ter].boat_over
|
||||
@@ -2886,14 +2885,15 @@ bool outd_move_party(location destination,bool forced) {
|
||||
|
||||
univ.party.direction = set_direction(univ.party.out_loc, destination);
|
||||
std::string dir_str = dir_string[univ.party.direction];
|
||||
if(((boat_num = out_boat_there(real_dest)) < 30) && (univ.party.in_boat < 0) && (univ.party.in_horse < 0)) {
|
||||
cVehicle* enter;
|
||||
if((enter = out_boat_there(real_dest)) && univ.party.in_boat < 0 && univ.party.in_horse < 0) {
|
||||
if(flying()) {
|
||||
add_string_to_buf("You land first.");
|
||||
univ.party.status[ePartyStatus::FLIGHT] = 0;
|
||||
}
|
||||
give_help(61,0);
|
||||
add_string_to_buf("Move: You board the boat.");
|
||||
univ.party.in_boat = boat_num;
|
||||
univ.party.in_boat = enter - &univ.party.boats[0];
|
||||
|
||||
univ.party.out_loc = real_dest;
|
||||
univ.party.i_w_c.x = (univ.party.out_loc.x > 48) ? 1 : 0;
|
||||
@@ -2906,7 +2906,7 @@ bool outd_move_party(location destination,bool forced) {
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(((horse_num = out_horse_there(real_dest)) < 30) && (univ.party.in_boat < 0) && (univ.party.in_horse < 0)) {
|
||||
else if((enter = out_horse_there(real_dest)) && univ.party.in_boat < 0 && univ.party.in_horse < 0) {
|
||||
if(flying()) {
|
||||
add_string_to_buf("Land before mounting horses.");
|
||||
return false;
|
||||
@@ -2915,7 +2915,7 @@ bool outd_move_party(location destination,bool forced) {
|
||||
give_help(60,0);
|
||||
add_string_to_buf("Move: You mount the horses.");
|
||||
play_sound(84);
|
||||
univ.party.in_horse = horse_num;
|
||||
univ.party.in_horse = enter - &univ.party.horses[0];
|
||||
|
||||
univ.party.out_loc = real_dest;
|
||||
univ.party.i_w_c.x = (univ.party.out_loc.x > 48) ? 1 : 0;
|
||||
@@ -2984,7 +2984,6 @@ bool outd_move_party(location destination,bool forced) {
|
||||
|
||||
bool town_move_party(location destination,short forced) {
|
||||
bool keep_going = true;
|
||||
short boat_there,horse_there;
|
||||
ter_num_t ter;
|
||||
bool check_f = false;
|
||||
|
||||
@@ -3023,7 +3022,7 @@ bool town_move_party(location destination,short forced) {
|
||||
}
|
||||
}
|
||||
// boat in destination
|
||||
else if(town_boat_there(destination) < 30) {
|
||||
else if(town_boat_there(destination)) {
|
||||
add_string_to_buf(" Boat there already.");
|
||||
return false;
|
||||
}
|
||||
@@ -3034,29 +3033,30 @@ bool town_move_party(location destination,short forced) {
|
||||
|
||||
univ.party.direction = set_direction(univ.party.town_loc, destination);
|
||||
std::string dir_str = dir_string[univ.party.direction];
|
||||
if(((boat_there = town_boat_there(destination)) < 30) && (univ.party.in_boat < 0)) {
|
||||
if(univ.party.boats[boat_there].property) {
|
||||
cVehicle* there;
|
||||
if((there = town_boat_there(destination)) && univ.party.in_boat < 0 && univ.party.in_horse < 0) {
|
||||
if(there->property) {
|
||||
add_string_to_buf(" Not your boat.");
|
||||
return false;
|
||||
}
|
||||
give_help(61,0);
|
||||
add_string_to_buf("Move: You board the boat.");
|
||||
univ.party.in_boat = boat_there;
|
||||
univ.party.in_boat = there - &univ.party.boats[0];
|
||||
|
||||
univ.party.town_loc = destination;
|
||||
center = univ.party.town_loc;
|
||||
|
||||
return true;
|
||||
}
|
||||
else if(((horse_there = town_horse_there(destination)) < 30) && (univ.party.in_horse < 0)) {
|
||||
if(univ.party.horses[horse_there].property) {
|
||||
else if((there = town_horse_there(destination)) && univ.party.in_boat < 0 && univ.party.in_horse < 0) {
|
||||
if(there->property) {
|
||||
add_string_to_buf(" Not your horses.");
|
||||
return false;
|
||||
}
|
||||
give_help(60,0);
|
||||
add_string_to_buf("Move: You mount the horses.");
|
||||
play_sound(84);
|
||||
univ.party.in_horse = horse_there;
|
||||
univ.party.in_horse = there - &univ.party.horses[0];
|
||||
|
||||
univ.party.town_loc = destination;
|
||||
center = univ.party.town_loc;
|
||||
|
||||
@@ -227,7 +227,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
|
||||
}
|
||||
|
||||
// TODO: Just verify that yes, it works with this and doesn't work without it.
|
||||
if(mode == eSpecCtx::COMBAT_MOVE && town_boat_there(where_check) < 3) {
|
||||
if(mode == eSpecCtx::COMBAT_MOVE && town_boat_there(where_check)) {
|
||||
add_string_to_buf("Blocked: Can't enter boats in combat");
|
||||
can_enter = false;
|
||||
}
|
||||
@@ -304,9 +304,9 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
|
||||
// if the party is flying, in a boat, or entering a boat, they cannot be harmed by terrain
|
||||
if(flying() || univ.party.in_boat >= 0)
|
||||
break;
|
||||
if(mode == eSpecCtx::TOWN_MOVE && town_boat_there(where_check) < 30)
|
||||
if(mode == eSpecCtx::TOWN_MOVE && town_boat_there(where_check))
|
||||
break;
|
||||
if(mode == eSpecCtx::OUT_MOVE && out_boat_there(where_check) < 30)
|
||||
if(mode == eSpecCtx::OUT_MOVE && out_boat_there(where_check))
|
||||
break;
|
||||
if(ter_flag3 > 0 && ter_flag3 < 8)
|
||||
dam_type = (eDamageType) ter_flag3;
|
||||
@@ -363,9 +363,9 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
|
||||
// if the party is flying, in a boat, or entering a boat, they cannot be harmed by terrain
|
||||
if(flying() || univ.party.in_boat >= 0)
|
||||
break;
|
||||
if(mode == eSpecCtx::TOWN_MOVE && town_boat_there(where_check) < 30)
|
||||
if(mode == eSpecCtx::TOWN_MOVE && town_boat_there(where_check))
|
||||
break;
|
||||
if(mode == eSpecCtx::OUT_MOVE && out_boat_there(where_check) < 30)
|
||||
if(mode == eSpecCtx::OUT_MOVE && out_boat_there(where_check))
|
||||
break;
|
||||
//one_sound(17);
|
||||
for(short i = mode == eSpecCtx::COMBAT_MOVE ? univ.get_target_i(which_pc) : 0 ; i < 6; i++)
|
||||
|
||||
@@ -743,9 +743,9 @@ short do_look(location space) {
|
||||
|
||||
if(univ.out->roads[space.x][space.y])
|
||||
add_string_to_buf(" Road");
|
||||
if(out_boat_there(space) < 30)
|
||||
if(out_boat_there(space))
|
||||
add_string_to_buf(" Boat");
|
||||
if(out_horse_there(space) < 30)
|
||||
if(out_horse_there(space))
|
||||
add_string_to_buf(" Horse");
|
||||
if(univ.out->special_spot[space.x][space.y])
|
||||
add_string_to_buf(" Special Encounter");
|
||||
@@ -754,9 +754,9 @@ short do_look(location space) {
|
||||
if((overall_mode == MODE_LOOK_TOWN) || (overall_mode == MODE_LOOK_COMBAT)) {
|
||||
if(univ.town.is_road(space.x,space.y))
|
||||
add_string_to_buf(" Track");
|
||||
if(town_boat_there(space) < 30)
|
||||
if(town_boat_there(space))
|
||||
add_string_to_buf(" Boat");
|
||||
if(town_horse_there(space) < 30)
|
||||
if(town_horse_there(space))
|
||||
add_string_to_buf(" Horse");
|
||||
|
||||
if(univ.town.is_web(space.x,space.y))
|
||||
@@ -844,36 +844,36 @@ short do_look(location space) {
|
||||
return print_terrain(space);
|
||||
}
|
||||
|
||||
short town_boat_there(location where) {
|
||||
cVehicle* town_boat_there(location where) {
|
||||
for(short i = 0; i < univ.party.boats.size(); i++)
|
||||
if(univ.party.boats[i].exists && univ.party.boats[i].which_town == univ.party.town_num
|
||||
&& (where == univ.party.boats[i].loc))
|
||||
return i;
|
||||
return univ.party.boats.size();
|
||||
return &univ.party.boats[i];
|
||||
return nullptr;
|
||||
}
|
||||
short out_boat_there(location where) {
|
||||
cVehicle* out_boat_there(location where) {
|
||||
where = global_to_local(where);
|
||||
for(short i = 0; i < univ.party.boats.size(); i++)
|
||||
if((univ.party.boats[i].exists) && (where == univ.party.boats[i].loc)
|
||||
&& (univ.party.boats[i].which_town == 200))
|
||||
return i;
|
||||
return univ.party.boats.size();
|
||||
return &univ.party.boats[i];
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
short town_horse_there(location where) {
|
||||
cVehicle* town_horse_there(location where) {
|
||||
for(short i = 0; i < univ.party.horses.size(); i++)
|
||||
if(univ.party.horses[i].exists && univ.party.horses[i].which_town == univ.party.town_num
|
||||
&& (where == univ.party.horses[i].loc))
|
||||
return i;
|
||||
return univ.party.horses.size();
|
||||
return &univ.party.horses[i];
|
||||
return nullptr;
|
||||
}
|
||||
short out_horse_there(location where) {
|
||||
cVehicle* out_horse_there(location where) {
|
||||
where = global_to_local(where);
|
||||
for(short i = 0; i < univ.party.horses.size(); i++)
|
||||
if((univ.party.horses[i].exists) && (where == univ.party.horses[i].loc)
|
||||
&& (univ.party.horses[i].which_town == 200))
|
||||
return i;
|
||||
return univ.party.horses.size();
|
||||
return &univ.party.horses[i];
|
||||
return nullptr;
|
||||
}
|
||||
void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) {
|
||||
std::string msg;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include <string>
|
||||
|
||||
class cVehicle;
|
||||
|
||||
void put_pc_screen();
|
||||
void place_buy_button(short position,short pc_num,short item_num);
|
||||
void put_item_screen(short screen_num);
|
||||
@@ -12,10 +14,10 @@ short total_encumbrance(short pc_num);
|
||||
void draw_pc_effects(short pc);
|
||||
void print_party_stats() ;
|
||||
short do_look(location space);
|
||||
short town_boat_there(location where);
|
||||
short out_boat_there(location where);
|
||||
short town_horse_there(location where);
|
||||
short out_horse_there(location where);
|
||||
cVehicle* town_boat_there(location where);
|
||||
cVehicle* out_boat_there(location where);
|
||||
cVehicle* town_horse_there(location where);
|
||||
cVehicle* out_horse_there(location where);
|
||||
void notify_out_combat_began(cOutdoors::cWandering encounter,short *nums) ;
|
||||
std::string get_m_name(mon_num_t num);
|
||||
std::string get_ter_name(ter_num_t num);
|
||||
|
||||
@@ -18,11 +18,8 @@
|
||||
const short cCreature::charm_odds[21] = {90,90,85,80,78, 75,73,60,40,30, 20,10,4,1,0, 0,0,0,0,0, 0};
|
||||
|
||||
cCreature::cCreature() {
|
||||
active = 0;
|
||||
attitude = eAttitude::DOCILE;
|
||||
cur_loc.x = cur_loc.y = targ_loc.x = targ_loc.y = 80;
|
||||
summon_time = 0;
|
||||
target = 6;
|
||||
}
|
||||
|
||||
cCreature::cCreature(int num) : cCreature() {
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
class cCreature : public cMonster, public cTownperson, public iLiving {
|
||||
public:
|
||||
static const short charm_odds[21];
|
||||
short active;
|
||||
short active = 0;
|
||||
eAttitude attitude;
|
||||
location cur_loc;
|
||||
short summon_time;
|
||||
short summon_time = 0;
|
||||
bool party_summoned;
|
||||
short target;
|
||||
short target = 6;
|
||||
location targ_loc;
|
||||
short health;
|
||||
short mp;
|
||||
short max_mp;
|
||||
short morale,m_morale; // these are calculated in-game based on the level
|
||||
short health = 0;
|
||||
short mp = 0;
|
||||
short max_mp = 0;
|
||||
short morale = 0,m_morale = 0; // these are calculated in-game based on the level
|
||||
|
||||
cCreature();
|
||||
cCreature(int num);
|
||||
|
||||
@@ -42,6 +42,7 @@ void cCurTown::import_legacy(legacy::big_tr_type& old){
|
||||
for(short i = 0; i < record()->max_dim; i++)
|
||||
for(short j = 0; j < record()->max_dim; j++)
|
||||
record()->terrain(i,j) = old.terrain[i][j];
|
||||
record()->area_desc.resize(16);
|
||||
for(short i = 0; i < 16; i++){
|
||||
record()->area_desc[i].top = old.room_rect[i].top;
|
||||
record()->area_desc[i].left = old.room_rect[i].left;
|
||||
|
||||
@@ -1896,6 +1896,7 @@ void loadOutMapData(map_data&& data, location which, cScenario& scen) {
|
||||
case eMapFeature::BOAT:
|
||||
is_boat = true;
|
||||
case eMapFeature::HORSE:
|
||||
(is_boat ? scen.boats : scen.horses).resize(abs(feat.second));
|
||||
what = &(is_boat ? scen.boats : scen.horses)[abs(feat.second) - 1];
|
||||
what->which_town = 200;
|
||||
what->sector = which;
|
||||
@@ -1943,6 +1944,7 @@ void loadTownMapData(map_data&& data, int which, cScenario& scen) {
|
||||
case eMapFeature::BOAT:
|
||||
is_boat = true;
|
||||
case eMapFeature::HORSE:
|
||||
(is_boat ? scen.boats : scen.horses).resize(abs(feat.second));
|
||||
what = &(is_boat ? scen.boats : scen.horses)[abs(feat.second) - 1];
|
||||
what->which_town = which;
|
||||
what->loc = loc(x,y);
|
||||
|
||||
Reference in New Issue
Block a user