Merge branch 'master' from windows

This commit is contained in:
2015-06-26 12:33:54 -04:00
8 changed files with 45 additions and 34 deletions

View File

@@ -2831,19 +2831,17 @@ static void run_waterfalls(short mode){ // mode 0 - town, 1 - outdoors
}
bool outd_move_party(location destination,bool forced) {
short boat_num,horse_num,spec_num;
short boat_num,horse_num;
location real_dest, sector_p_in;
bool keep_going = true,check_f;
location store_corner,store_iwc;
ter_num_t ter;
keep_going = check_special_terrain(destination,eSpecCtx::OUT_MOVE,univ.party[0],&spec_num,&check_f);
keep_going = check_special_terrain(destination,eSpecCtx::OUT_MOVE,univ.party[0],&check_f);
if(check_f)
forced = true;
if(in_scen_debug && ghost_mode)
forced = keep_going = true;
if(spec_num == 50)
forced = true;
// If not blocked and not put in town by a special, process move
if(keep_going && overall_mode == MODE_OUTDOORS) {
@@ -3030,7 +3028,7 @@ 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,spec_num;
short boat_there,horse_there;
ter_num_t ter;
bool check_f = false;
@@ -3040,14 +3038,12 @@ bool town_move_party(location destination,short forced) {
}
if(univ.target_there(destination, TARG_MONST) == nullptr)
keep_going = check_special_terrain(destination,eSpecCtx::TOWN_MOVE,univ.party[0],&spec_num,&check_f);
keep_going = check_special_terrain(destination,eSpecCtx::TOWN_MOVE,univ.party[0],&check_f);
if(check_f)
forced = true;
if(in_scen_debug && ghost_mode)
forced = keep_going = true;
if(spec_num == 50)
forced = true;
ter = univ.town->terrain(destination.x,destination.y);
if(keep_going) {

View File

@@ -378,7 +378,6 @@ bool pc_combat_move(location destination) {
short s1,s2,i,monst_exist;
bool keep_going = true,forced = false,check_f = false;
location monst_loc,store_loc;
short spec_num;
eDirection dir;
iLiving* monst_hit = univ.target_there(destination, TARG_MONST);
@@ -390,7 +389,7 @@ bool pc_combat_move(location destination) {
}
if(monst_hit == nullptr)
keep_going = check_special_terrain(destination,eSpecCtx::COMBAT_MOVE,univ.party[current_pc],&spec_num,&check_f);
keep_going = check_special_terrain(destination,eSpecCtx::COMBAT_MOVE,univ.party[current_pc],&check_f);
if(check_f)
forced = true;
@@ -452,7 +451,7 @@ bool pc_combat_move(location destination) {
switch_pc.combat_pos = store_loc;
univ.party[current_pc].direction = dir;
take_ap(1);
check_special_terrain(store_loc,eSpecCtx::COMBAT_MOVE,switch_pc,&spec_num,&check_f);
check_special_terrain(store_loc,eSpecCtx::COMBAT_MOVE,switch_pc,&check_f);
move_sound(univ.town->terrain(destination.x,destination.y),univ.party[current_pc].ap);
return true;
}

View File

@@ -116,8 +116,7 @@ bool handle_wandering_specials (short /*which*/,short mode) {
// returns true if can enter this space
// sets forced to true if definitely can enter
bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,short *spec_num,
bool *forced) {
bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,bool *forced) {
ter_num_t ter;
short r1,i,door_pc,pic_type = 0,ter_pic = 0;
eTerSpec ter_special;
@@ -128,7 +127,7 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
location out_where,from_loc,to_loc;
short s1 = 0,s2 = 0,s3 = 0;
*spec_num = -1;
short spec_num = -1;
*forced = false;
switch(mode) {
@@ -173,9 +172,9 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
for(i = 0; i < univ.out->special_locs.size(); i++)
if(out_where == univ.out->special_locs[i]) {
*spec_num = univ.out->special_locs[i].spec;
spec_num = univ.out->special_locs[i].spec;
// call special
run_special(mode,1,univ.out->special_locs[i].spec,out_where,&s1,&s2,&s3);
run_special(mode,1,spec_num,out_where,&s1,&s2,&s3);
if(s1 > 0)
can_enter = false;
else if(s2 > 0)
@@ -204,18 +203,18 @@ bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,
&& can_enter && univ.town.is_special(where_check.x,where_check.y)) {
for(i = 0; i < univ.town->special_locs.size(); i++)
if(where_check == univ.town->special_locs[i]) {
*spec_num = univ.town->special_locs[i].spec;
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;
if(ter_special == eTerSpec::CALL_SPECIAL) runSpecial = true;
if(univ.town->specials[*spec_num].type == eSpecType::CANT_ENTER)
if(univ.town->specials[spec_num].type == eSpecType::CANT_ENTER)
runSpecial = true;
if(!PSD[SDF_NO_BOAT_SPECIALS] && univ.party.in_boat >= 0 && univ.scenario.ter_types[ter].boat_over)
runSpecial = true;
if(runSpecial) {
give_help(54,0);
run_special(mode,2,*spec_num,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)
@@ -1786,7 +1785,7 @@ void push_things() {
}
void special_increase_age(long length, bool queue) {
unsigned short i;
size_t i;
short s1,s2,s3;
bool redraw = false,stat_area = false;
location trigger_loc;
@@ -1877,13 +1876,14 @@ void special_increase_age(long length, bool queue) {
redraw = true;
}
univ.party.age = current_age;
for(i = 0; i < univ.party.party_event_timers.size(); i++) {
if(univ.party.party_event_timers[i].time <= length) {
univ.party.age = age_before + univ.party.party_event_timers[i].time;
short which_type = univ.party.party_event_timers[i].node_type;
auto party_timers = univ.party.party_event_timers;
for(i = 0; i < party_timers.size(); i++) {
if(party_timers[i].time <= length) {
univ.party.age = age_before + party_timers[i].time;
short which_type = party_timers[i].node_type;
if(queue)
queue_special(eSpecCtx::PARTY_TIMER, which_type, univ.party.party_event_timers[i].node, trigger_loc);
else run_special(eSpecCtx::PARTY_TIMER,which_type,univ.party.party_event_timers[i].node,trigger_loc,&s1,&s2,&s3);
queue_special(eSpecCtx::PARTY_TIMER, which_type, party_timers[i].node, trigger_loc);
else run_special(eSpecCtx::PARTY_TIMER, which_type, party_timers[i].node, trigger_loc, &s1, &s2, &s3);
univ.party.party_event_timers[i].time = 0;
univ.party.party_event_timers[i].node = -1;
stat_area = true;

View File

@@ -2,8 +2,7 @@
#include "creature.hpp"
bool handle_wandering_specials (short which,short mode);
bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,short *spec_num,
bool *forced);
bool check_special_terrain(location where_check,eSpecCtx mode,cPlayer& which_pc,bool *forced);
void check_fields(location where_check,eSpecCtx mode,cPlayer& which_pc);
void use_spec_item(short item);
void use_item(short pc,short item);

View File

@@ -68,6 +68,7 @@ void cSpecial::append(legacy::special_node_type& old){
case 57: case 60: // Large dialogs with monster graphics
if(pic >= 400 && pic < 1000)
pic -= 400;
if(pic == 122) pic = 119;
pictype = PIC_MONST;
m3 = m2;
m2 = -1;

View File

@@ -3346,17 +3346,19 @@ void edit_custom_sheets() {
// First, make sure we even have custom graphics! Also make sure they're not legacy format.
bool must_init_spec_g = false;
if(max_pic < 0) {
if(spec_scen_g.is_old) {
if(cChoiceDlog("convert-pics-now", {"cancel", "convert"}).show() == "cancel")
return;
spec_scen_g.convert_sheets();
all_pics.resize(spec_scen_g.numSheets);
std::iota(all_pics.begin(), all_pics.end(), 0);
} else if(max_pic < 0) {
if(cChoiceDlog("have-no-pics", {"cancel", "new"}).show() == "cancel")
return;
must_init_spec_g = true;
} else if(max_pic >= 0 && spec_scen_g.numSheets < 1) {
if(cChoiceDlog("have-only-full-pics", {"cancel", "new"}).show() == "new")
must_init_spec_g = true;
} else if(spec_scen_g.is_old) {
if(cChoiceDlog("convert-pics-now", {"cancel", "convert"}).show() == "cancel")
return;
spec_scen_g.convert_sheets();
}
if(must_init_spec_g) {

View File

@@ -2153,6 +2153,8 @@ bool tryLoadPictFromResourceFile(fs::path& gpath, sf::Image& graphics_store);
void load_spec_graphics_v1(fs::path scen_file) {
static const char*const noGraphics = "The game will still work without the custom graphics, but some things will not look right.";
fs::remove_all(tempDir/"scenario/graphics");
fs::remove_all(tempDir/"scenario/sounds");
fs::path path(scen_file);
std::cout << "Loading scenario graphics... (" << path << ")\n";
// Tried path.replace_extension, but that only deleted the extension, so I have to do it manually
@@ -2181,7 +2183,13 @@ void load_spec_graphics_v1(fs::path scen_file) {
graphics_store.createMaskFromColor(sf::Color::White);
spec_scen_g.is_old = true;
spec_scen_g.sheets = new sf::Texture[1];
spec_scen_g.sheets[0].loadFromImage(graphics_store);
spec_scen_g.numSheets = 1;
if(!spec_scen_g.sheets[0].loadFromImage(graphics_store)) {
giveError("An error occurred while converting old-style graphics into the new format.",noGraphics);
spec_scen_g.is_old = false;
spec_scen_g.numSheets = 0;
delete[] spec_scen_g.sheets;
}
}
}
reload_core_graphics();

View File

@@ -498,6 +498,8 @@ void cCustomGraphics::convert_sheets() {
numSheets = num_graphics / 100;
if(num_graphics % 100) numSheets++;
sheets = new sf::Texture[numSheets];
extern fs::path tempDir;
fs::path pic_dir = tempDir/"scenario/graphics";
for(size_t i = 0; i < numSheets; i++) {
sf::IntRect subrect;
subrect.top = i * 280;
@@ -510,7 +512,11 @@ void cCustomGraphics::convert_sheets() {
sheets[i].create(280, 360);
sheets[i].update(sheet);
fs::path sheetPath = pic_dir/("sheet" + std::to_string(i) + ".png");
sheets[i].copyToImage().saveToFile(sheetPath.string().c_str());
}
ResMgr::pushPath<ImageRsrc>(pic_dir);
}
void cCustomGraphics::replace_sheet(size_t num, sf::Image& newSheet) {