Prevent party from getting a victory dialog if they die during special node processing in a chain that contains an end scenario node

This commit is contained in:
2014-12-14 02:11:04 -05:00
parent 402065fa80
commit c8889a9989
6 changed files with 62 additions and 61 deletions

View File

@@ -2194,6 +2194,13 @@ void general_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
*a = (spec.ex1a == 0) ? 1 : 0;
break;
case eSpecType::END_SCENARIO:
// If party died at some point during the special node, they shouldn't get a victory.
// (Adapted from Windows version)
store_val = 6;
for(i = 0; i < 6; i++)
if(univ.party[i].main_status != eMainStatus::ALIVE)
store_val--;
if(store_val == 0) break;
end_scenario = true;
break;
case eSpecType::SET_POINTER:
@@ -3309,6 +3316,8 @@ void set_terrain(location l, ter_num_t terrain_type)
combat_terrain[l.x][l.y] = terrain_type;
if(scenario.ter_types[terrain_type].special == eTerSpec::CONVEYOR)
belt_present = true;
if(scenario.ter_types[former].light_radius != scenario.ter_types[terrain_type].light_radius)
univ.town->set_up_lights();
}
// TODO: What was next_spec_type for? Is it still needed?
@@ -3650,9 +3659,11 @@ void townmode_spec(eSpecCtx which_mode,cSpecial cur_node,short cur_spec_type,
break;
// OBoE: Change town lighting
case eSpecType::TOWN_CHANGE_LIGHTING:
// Change bulk town lighting
if ((spec.ex1a >= 0) && (spec.ex1a <= 3))
// Change global town lighting
if(spec.ex1a >= 0 && spec.ex1a <= 3) {
univ.town->lighting_type = (eLighting) spec.ex1a;
draw_terrain();
}
// Change party light level
if (spec.ex2a > 0) {
if (spec.ex2b == 0)

View File

@@ -183,3 +183,48 @@ bool cTown::cWandering::isNull(){
return false;
return true;
}
void cTown::set_up_lights() {
using namespace std::placeholders;
short rad;
location where,l;
bool where_lit[64][64] = {0};
auto get_obscurity = std::bind(&cTown::light_obscurity, this, _1, _2);
// Find bonfires, braziers, etc.
for(short i = 0; i < this->max_dim(); i++)
for(short j = 0; j < this->max_dim(); j++) {
l.x = i;
l.y = j;
rad = scenario.ter_types[this->terrain(i,j)].light_radius;
if(rad > 0) {
for(where.x = std::max(0,i - rad); where.x < std::min(this->max_dim(),short(i + rad + 1)); where.x++)
for(where.y = std::max(0,j - rad); where.y < std::min(this->max_dim(),short(j + rad + 1)); where.y++)
if((where_lit[where.x][where.y] == 0) && (dist(where,l) <= rad) && (can_see(l,where,get_obscurity) < 5))
where_lit[where.x][where.y] = 1;
}
}
for(short i = 0; i < 8; i++)
for(short j = 0; j < 64; j++)
this->lighting(i,j) = 0;
for(where.x = 0; where.x < this->max_dim(); where.x++)
for(where.y = 0; where.y < this->max_dim(); where.y++) {
if(where_lit[where.x][where.y] > 0) {
this->lighting(where.x / 8,where.y) = this->lighting(where.x / 8,where.y) | (1 << (where.x % 8));
}
}
}
short cTown::light_obscurity(short x,short y) {
ter_num_t what_terrain;
eTerObstruct store;
what_terrain = this->terrain(x,y);
store = scenario.ter_types[what_terrain].blockage;
if(store == eTerObstruct::BLOCK_SIGHT || store == eTerObstruct::BLOCK_MOVE_AND_SIGHT)
return 5;
if(store == eTerObstruct::BLOCK_MOVE_AND_SHOOT)
return 1;
return 0;
}

View File

@@ -121,6 +121,8 @@ public:
virtual short max_dim() = 0;
virtual short max_monst() = 0;
virtual short max_items() = 0;
void set_up_lights();
short light_obscurity(short x,short y); // Obscurity function used for calculating lighting
cTown();
cTown(short size);

View File

@@ -1471,47 +1471,6 @@ void handle_keystroke(char chr,char chr2,sf::Event event) {
//void set_info_strings() {
//}
void set_up_lights() {
short i,j,rad;
location where,l;
//location light_locs[40];
short num_lights = 0;
bool where_lit[64][64];
// Find bonfires, braziers, etc.
num_lights = 0;
for (i = 0; i < 64; i++)
for (j = 0; j < 64; j++)
where_lit[i][j] = 0;
for (i = 0; i < town->max_dim(); i++)
for (j = 0; j < town->max_dim(); j++) {
l.x = i;
l.y = j;
rad = scenario.ter_types[town->terrain(i,j)].light_radius;
if (rad > 0) {
for (where.x = max(0,i - rad); where.x < min(town->max_dim(),i + rad + 1); where.x++)
for (where.y = max(0,j - rad); where.y < min(town->max_dim(),j + rad + 1); where.y++)
if ((where_lit[where.x][where.y] == 0) && (dist(where,l) <= rad) && (can_see(l,where,light_obscurity) < 5))
where_lit[where.x][where.y] = 1;
}
}
for (i = 0; i < 8; i++)
for (j = 0; j < 64; j++)
town->lighting(i,j) = 0;
for (where.x = 0; where.x < town->max_dim(); where.x++)
for (where.y = 0; where.y < town->max_dim(); where.y++) {
if (where_lit[where.x][where.y] > 0) {
town->lighting(where.x / 8,where.y) = town->lighting(where.x / 8,where.y) | (char) (s_pow(2,where.x % 8));
}
}
}
bool is_wall(short i,short j) {
ter_num_t ter;
bool answer = false;
@@ -3421,7 +3380,7 @@ bool save_check(std::string which_dlog) {
return true;
else if(choice == "cancel")
return false;
set_up_lights();
town->set_up_lights();
save_scenario();
return true;
}
@@ -3432,20 +3391,6 @@ bool is_lava(short x,short y) {
else return false;
}
short light_obscurity(short x,short y) {
ter_num_t what_terrain;
eTerObstruct store;
what_terrain = coord_to_ter(x,y);
store = scenario.ter_types[what_terrain].blockage;
if(store == eTerObstruct::BLOCK_SIGHT || store == eTerObstruct::BLOCK_MOVE_AND_SIGHT)
return 5;
if(store == eTerObstruct::BLOCK_MOVE_AND_SHOOT)
return 1;
return 0;
}
ter_num_t coord_to_ter(short x,short y) {
ter_num_t what_terrain;

View File

@@ -10,7 +10,6 @@ void get_town_info();
void get_sign_resource();
void set_info_strings();
cTown::cItem edit_item(cTown::cItem item);
void set_up_lights();
bool is_wall(short i,short j);
bool is_correctable_wall(short i,short j);
bool is_mountain(short i,short j);
@@ -40,7 +39,6 @@ bool out_fix_water(location l);
void adjust_space(location l);
bool is_lava(short x,short y);
ter_num_t coord_to_ter(short x,short y);
short light_obscurity(short x,short y);
bool place_item(location spot_hit,short which_item,short property,short always,short odds);
void place_items_in_town();
void set_up_start_screen();

View File

@@ -243,7 +243,7 @@ void handle_file_menu(int item_hit) {
}
break;
case 2: // save
set_up_lights();
town->set_up_lights();
save_scenario();
break;
case 3: // new scen