diff --git a/osx/Blades of Exile Char Editor/pc.main.cpp b/osx/Blades of Exile Char Editor/pc.main.cpp index 51c7cd4c..f34f02a4 100644 --- a/osx/Blades of Exile Char Editor/pc.main.cpp +++ b/osx/Blades of Exile Char Editor/pc.main.cpp @@ -133,6 +133,7 @@ int main(void) start_time = TickCount(); Initialize(); + init_fileio(); init_main_buttons(); Set_up_win(); Point p = {0,0}; diff --git a/osx/Blades of Exile-Info.plist b/osx/Blades of Exile-Info.plist index 489a6824..71fb089a 100644 --- a/osx/Blades of Exile-Info.plist +++ b/osx/Blades of Exile-Info.plist @@ -96,6 +96,6 @@ CFBundleSignature blx! CFBundleVersion - 1.0 + 2.0b1 diff --git a/osx/BoE.xcodeproj/project.pbxproj b/osx/BoE.xcodeproj/project.pbxproj index 6bdba020..12680c9d 100644 --- a/osx/BoE.xcodeproj/project.pbxproj +++ b/osx/BoE.xcodeproj/project.pbxproj @@ -394,7 +394,6 @@ 91E5C7A60F9F615400C21460 /* fileio.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = fileio.cpp; path = misc/fileio.cpp; sourceTree = ""; }; 91E5C7B60F9F619D00C21460 /* talking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = talking.h; sourceTree = ""; }; 91E5C7B70F9F619D00C21460 /* talking.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = talking.cpp; sourceTree = ""; }; - 91EBE8AC0F9A2BF2002356F2 /* scen.locutils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = scen.locutils.h; path = "Scenario Editor/scen.locutils.h"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -577,7 +576,6 @@ 91B3EEDC0F969BA700BF5B67 /* headers */ = { isa = PBXGroup; children = ( - 91EBE8AC0F9A2BF2002356F2 /* scen.locutils.h */, 91B3EEDE0F969BA700BF5B67 /* scen.global.h */, 91B3EEE00F969BA700BF5B67 /* scen.keydlgs.h */, 91B3EEE10F969BA700BF5B67 /* scen.core.h */, diff --git a/osx/Scenario Editor/scen.core.cpp b/osx/Scenario Editor/scen.core.cpp index be27f1d7..80d9b5c8 100644 --- a/osx/Scenario Editor/scen.core.cpp +++ b/osx/Scenario Editor/scen.core.cpp @@ -865,7 +865,7 @@ void init_scenario() { scenario.ter_types[i].blockage = ter_block[i]; scenario.ter_types[i].special = (eTerSpec) ter_traits[i]; get_str(temp_str,1,i + 1); - sprintf((char *)scenario.ter_names[i], "%s", temp_str); + sprintf((char *)scenario.ter_types[i].name.c_str(), "%s", temp_str); scenario.scen_specials[i] = null_spec_node; } @@ -894,9 +894,10 @@ void init_scenario() { } void put_ter_info_in_dlog() { Str255 str; + strcpy((char*)str,(char*)scenario.ter_types[store_which_ter].name.c_str()); cdsin(813,12,store_which_ter); - CDST(813,2,scenario.ter_names[store_which_ter]); + CDST(813,2,(char*)str); CDSN(813,5,store_ter.picture); cd_set_led_range(813,19,24,store_ter.blockage); cd_set_led(813,25,store_ter.fly_over); @@ -975,7 +976,7 @@ bool save_ter_info() { CDGT(813,2,(char *) str); str[29] = 0; - sprintf(scenario.ter_names[store_which_ter],"%s",str); + scenario.ter_types[store_which_ter].name = (char*)str; scenario.ter_types[store_which_ter] = store_ter; return true; diff --git a/osx/Scenario Editor/scen.fileio.cpp b/osx/Scenario Editor/scen.fileio.cpp index bc70f223..752defa3 100644 --- a/osx/Scenario Editor/scen.fileio.cpp +++ b/osx/Scenario Editor/scen.fileio.cpp @@ -1320,7 +1320,7 @@ void start_data_dump() { fout << "Scenario data for " << scen_name << ':' << endl << endl; fout << "Terrain types for " << scen_name << ':' << endl; for(i = 0; i < 256; i++) - fout << " Terrain type " << i << ": " << scenario.ter_names[i] << endl; + fout << " Terrain type " << i << ": " << scenario.ter_types[i].name << endl; fout << endl << "Monster types for " << scen_name << ':' << endl; for(i = 0; i < 256; i++) fout << " Monster type " << i << ": " << scenario.scen_monsters[i].m_name << endl; diff --git a/osx/Scenario Editor/scen.graphics.cpp b/osx/Scenario Editor/scen.graphics.cpp index bbd47a47..6f5b4d8d 100644 --- a/osx/Scenario Editor/scen.graphics.cpp +++ b/osx/Scenario Editor/scen.graphics.cpp @@ -463,50 +463,58 @@ void set_up_terrain_buttons() { FillCRect(&terrain_buttons_rect,bg[17]); FrameRect(&terrain_buttons_rect); - // first make terrain buttons - for (i = 0; i < 256; i++) { - ter_from = ter_from_base; - pic = scenario.ter_types[i].picture; - if (pic >= 1000) { - ter_from = get_custom_rect(pic % 1000); - rect_draw_some_item(spec_scen_g, - ter_from,terrain_buttons_gworld,terrain_rects[i],0,0); - } - else if (pic < 400) { - pic = pic % 50; - OffsetRect(&ter_from,28 * (pic % 10), 36 * (pic / 10)); - rect_draw_some_item(terrain_gworld[scenario.ter_types[i].picture/50], - ter_from,terrain_buttons_gworld,terrain_rects[i],0,0); - } - else { - pic = pic % 50; - ter_from.left = 112 * (pic / 5); - ter_from.right = ter_from.left + 28; - ter_from.top = 36 * (pic % 5); - ter_from.bottom = ter_from.top + 36; - rect_draw_some_item(anim_gworld, - ter_from,terrain_buttons_gworld,terrain_rects[i],0,0); - - } - small_i = small_icons[scenario.ter_types[i].special]; - if ((small_i == 30) && (scenario.ter_types[i].flag2 >= 5)) - small_i = 31; - if ((small_i == 31) && (scenario.ter_types[i].flag2 == 10)) - small_i = 32; - if (i == 82) - small_i = 3; - if (i == 83) - small_i = 2; - if ((i == 7) || (i == 10) || (i == 13) || (i == 16)) - small_i = 23; - tiny_from = base_small_button_from; - OffsetRect(&tiny_from,7 * (small_i % 10),7 * (small_i / 10)); - tiny_to = terrain_rects[i]; - tiny_to.top = tiny_to.bottom - 7; - tiny_to.left = tiny_to.right - 7; - if (small_i > 0) - rect_draw_some_item(editor_mixed, - tiny_from,terrain_buttons_gworld,tiny_to,0,0); + // first make terrain buttons + switch(draw_mode){ + case DRAW_TERRAIN: + for (i = 0; i < 256; i++) { + ter_from = ter_from_base; + pic = scenario.ter_types[i].picture; + if (pic >= 1000) { + ter_from = get_custom_rect(pic % 1000); + rect_draw_some_item(spec_scen_g, + ter_from,terrain_buttons_gworld,terrain_rects[i],0,0); + } + else if (pic < 400) { + pic = pic % 50; + OffsetRect(&ter_from,28 * (pic % 10), 36 * (pic / 10)); + rect_draw_some_item(terrain_gworld[scenario.ter_types[i].picture/50], + ter_from,terrain_buttons_gworld,terrain_rects[i],0,0); + } + else { + pic = pic % 50; + ter_from.left = 112 * (pic / 5); + ter_from.right = ter_from.left + 28; + ter_from.top = 36 * (pic % 5); + ter_from.bottom = ter_from.top + 36; + rect_draw_some_item(anim_gworld, + ter_from,terrain_buttons_gworld,terrain_rects[i],0,0); + + } + small_i = small_icons[scenario.ter_types[i].special]; + if ((small_i == 30) && (scenario.ter_types[i].flag2 >= 5)) + small_i = 31; + if ((small_i == 31) && (scenario.ter_types[i].flag2 == 10)) + small_i = 32; + if (i == 82) + small_i = 3; + if (i == 83) + small_i = 2; + if ((i == 7) || (i == 10) || (i == 13) || (i == 16)) + small_i = 23; + tiny_from = base_small_button_from; + OffsetRect(&tiny_from,7 * (small_i % 10),7 * (small_i / 10)); + tiny_to = terrain_rects[i]; + tiny_to.top = tiny_to.bottom - 7; + tiny_to.left = tiny_to.right - 7; + if (small_i > 0) + rect_draw_some_item(editor_mixed, + tiny_from,terrain_buttons_gworld,tiny_to,0,0); + } + break; + case DRAW_MONST: + break; + case DRAW_ITEM: + break; } if (overall_mode < MODE_MAIN_SCREEN) { diff --git a/osx/Scenario Editor/scen.locutils.cpp b/osx/Scenario Editor/scen.locutils.cpp deleted file mode 100644 index b56caca5..00000000 --- a/osx/Scenario Editor/scen.locutils.cpp +++ /dev/null @@ -1,135 +0,0 @@ - -#include "mathutil.h" -#include "scen.global.h" -#include "scen.locutils.h" -//#include "boe.monster.h" -//#include "boe.fields.h" -#include "scen.graphics.h" -#include "mathutil.h" - - -char terrain_blocked[256]; - - -short short_can_see(); -bool combat_pt_in_light(); -//extern short town_size[3]; -location obs_sec; -location which_party_sec; - -//extern party_record_type party; -//extern current_town_type c_town; -extern short /*overall_mode,which_combat_type,*/current_pc,town_type; -extern big_tr_type t_d; -//extern outdoor_record_type outdoors[2][2]; -extern unsigned char combat_terrain[64][64]; -extern unsigned char out[96][96], out_e[96][96]; -extern location pc_pos[6],center; -//extern pc_record_type adven[6]; -extern bool belt_present,web,crate,barrel,fire_barrier,force_barrier,quickfire,force_wall,fire_wall,antimagic,scloud,ice_wall,blade_wall; -extern unsigned char map_graphic_placed[8][64]; // keeps track of what's been filled on map -extern scenario_data_type scenario; -extern bool editing_town; -extern outdoor_record_type current_terrain; - -location light_locs[40]; -short num_lights = 0; -char d_s[60]; - -//// -void set_terrain_blocked() -{ - short i; - - for (i = 0; i < 256; i++) - terrain_blocked[i] = scenario.ter_types[i].blockage; -} - -short vdist(location p1,location p2) { - short i,j; - i = abs((short) (p1.x - p2.x)); j = abs((short) (p1.y - p2.y)); - return max(i,j); -} - -bool adjacent(location p1,location p2) -{ - if ((abs((short) (p1.x - p2.x)) <= 1) && (abs((short) (p1.y - p2.y)) <= 1)) - return true; - else return false; -} - -bool point_onscreen(location center,location check) -{ - if ((abs((short) (center.x - check.x)) <=4) && (abs((short) (center.y - check.y)) <= 4)) - return true; - else return false; -} - - -short set_direction (location old_pt, location new_pt) -{ - if (old_pt.x == new_pt.x) - if (old_pt.y > new_pt.y) - return 0; - else return 4; - if (old_pt.x > new_pt.x) { - if (old_pt.y > new_pt.y) - return 7; - if (old_pt.y < new_pt.y) - return 5; - return 6; - } - if (old_pt.y > new_pt.y) - return 1; - if (old_pt.y < new_pt.y) - return 3; - return 2; -} -bool is_container(location loc) -{ - unsigned char ter; - - if ((is_barrel(loc.x,loc.y)) || (is_crate(loc.x,loc.y))) - return true; - ter = coord_to_ter(loc.x,loc.y); - if (scenario.ter_types[ter].special == 14) - return true; - return false; -} - -bool special_which_blocks_monst(location to_check) -{ - if (terrain_blocked[coord_to_ter(to_check.x,to_check.y)] == 2) - return true; - else return false; -} - -// Checks if space is a special that prevents movement into or placement of a PC on -bool is_special(location to_check) -{ - unsigned char which_ter; - - if (special_which_blocks_monst(to_check) == false) - return false; - which_ter = coord_to_ter(to_check.x,to_check.y); - if (terrain_blocked[which_ter] == 2) - return true; - else return false; -} - -bool impassable(unsigned char terrain_to_check) -{ - if (terrain_blocked[terrain_to_check] > 2) - return true; - else return false; -} - -bool spot_impassable(short i,short j) -{ - unsigned char ter; - - ter = coord_to_ter(i,j); - if (terrain_blocked[ter] == 5) - return true; - else return false; -} \ No newline at end of file diff --git a/osx/Scenario Editor/scen.locutils.h b/osx/Scenario Editor/scen.locutils.h deleted file mode 100644 index 2955a0ab..00000000 --- a/osx/Scenario Editor/scen.locutils.h +++ /dev/null @@ -1,42 +0,0 @@ -void set_terrain_blocked(); -short dist(location p1,location p2); -short ex_sqrt(short val); -short vdist(location p1,location p2) ; -bool adjacent(location p1,location p2); -bool point_onscreen(location center,location check); -short set_direction (location old_pt, location new_pt); -location global_to_local(location global); -location local_to_global(location local); -bool loc_off_world(location p1); -bool loc_off_act_area(location p1); -location get_cur_loc(); -bool is_lava(short x,short y); -short can_see(location p1,location p2,short mode); -short get_obscurity(short x,short y); -unsigned char coord_to_ter(short x,short y); -bool is_container(location loc); -void update_explored(location dest); -bool is_blocked(location to_check); -bool monst_on_space(location loc,short m_num); -short monst_there(location where) ; -bool monst_can_be_there(location loc,short m_num); -bool monst_adjacent(location loc,short m_num); -bool monst_can_see(short m_num,location l); -bool party_can_see_monst(short m_num); -bool can_see_monst(location l,short m_num); -bool outd_is_blocked(location to_check); -bool special_which_blocks_monst(location to_check); -bool is_special(location to_check); -bool outd_is_special(location to_check); -bool impassable(unsigned char terrain_to_check); -short get_blockage(unsigned char terrain_type); -short light_radius(); -bool pt_in_light(location from_where,location to_where) ;// Assumes, of course, in town or combat -bool combat_pt_in_light(location to_where); -bool party_sees_a_monst(); // Returns true is a hostile monster is in sight. -short party_can_see(location where); -location push_loc(location from_where,location to_where); -bool spot_impassable(short i,short j); -void swap_ter(short i,short j,unsigned char ter1,unsigned char ter2); -void alter_space(short i,short j,unsigned char ter); -bool same_point(location p1,location p2); diff --git a/osx/Scenario Editor/scen.main.cpp b/osx/Scenario Editor/scen.main.cpp index fbfdfa73..c4fb710e 100644 --- a/osx/Scenario Editor/scen.main.cpp +++ b/osx/Scenario Editor/scen.main.cpp @@ -100,6 +100,7 @@ int main(void) { init_directories(); Initialize(); + init_fileio(); init_snd_tool(); load_graphics(); diff --git a/osx/boe.actions.cpp b/osx/boe.actions.cpp index e4f8e618..b8d7612f 100644 --- a/osx/boe.actions.cpp +++ b/osx/boe.actions.cpp @@ -1286,7 +1286,7 @@ bool handle_action(EventRecord event) // If in combat and pc delayed, jump forward a step if (pc_delayed == true) { - initiate_redraw(); + draw_terrain(); //pause(2); current_pc++; combat_next_step(); @@ -1307,7 +1307,7 @@ bool handle_action(EventRecord event) break; } if (s3 > 0) - initiate_redraw(); + draw_terrain(); } // Handle non-PC stuff (like monsters) if the party actually did something @@ -1326,7 +1326,7 @@ bool handle_action(EventRecord event) else { if (need_redraw == true) { - initiate_redraw(); + draw_terrain(); if ((combat_active_pc == 6) || (pc_moves[combat_active_pc] > 0)) need_redraw = false; } @@ -1383,7 +1383,7 @@ bool handle_action(EventRecord event) } if (need_redraw == true) { - initiate_redraw(); + draw_terrain(); } @@ -1426,7 +1426,7 @@ bool handle_action(EventRecord event) center = univ.town.p_loc; } menu_activate(1); - initiate_redraw(); + draw_terrain(); put_pc_screen(); put_item_screen(stat_window,0); if (party_toast() == true) { @@ -1524,7 +1524,7 @@ void initiate_outdoor_combat(short i) short m,n; location to_place; - initiate_redraw(); + draw_terrain(); // Is combat too easy? if ((party_total_level() > ((out_enc_lev_tot(i) * 5) / 3) ) && (out_enc_lev_tot(i) < 200) @@ -1552,17 +1552,9 @@ void initiate_outdoor_combat(short i) overall_mode = MODE_COMBAT; center = pc_pos[current_pc]; - initiate_redraw(); + draw_terrain(); } -void initiate_redraw() -// Draw changes in terrain, but only if terrain is onscreen -{ - if ((overall_mode < MODE_TALKING) || (overall_mode >= MODE_LOOK_OUTDOORS/*30*/)) - draw_terrain(0); -} - - bool handle_keystroke(char chr,char chr2,EventRecord event) { bool are_done = false; @@ -1786,7 +1778,7 @@ bool handle_keystroke(char chr,char chr2,EventRecord event) damage_monst(i, 7,1000,0, DAMAGE_UNBLOCKABLE,0); } // kill_monst(&c_town.monst.dudes[i],6); - initiate_redraw(); + draw_terrain(); add_string_to_buf("Debug: Kill things. "); print_buf(); } @@ -2029,7 +2021,7 @@ void post_load() HideControl(shop_sbar); set_stat_window(0); put_pc_screen(); - initiate_redraw(); + draw_terrain(); draw_buttons(0); draw_text_bar(1); @@ -2054,17 +2046,17 @@ void do_save(short mode) } FSSpec file; try{ - if(mode == 1) file = nav_put_party(); - else file = univ.file; - save_party(file); + if(mode == 1) univ.file = nav_put_party(); + save_party(univ.file); } catch(no_file_chosen){} pause(6); SetPort(GetWindowPort(mainPtr)); - initiate_redraw(); - put_pc_screen(); - put_item_screen(stat_window,0); - print_buf(); +// initiate_redraw(); +// put_pc_screen(); +// put_item_screen(stat_window,0); +// print_buf(); + redraw_screen(); } void increase_age()//// @@ -2681,7 +2673,7 @@ bool outd_move_party(location destination,bool forced) univ.party.p_loc.y += 2; univ.party.loc_in_sec.y += 2; update_explored(univ.party.p_loc); - initiate_redraw(); + draw_terrain(); print_buf(); if ((cave_lore_present() > 0) && (get_ran(1,0,1) == 0)) add_string_to_buf(" (No supplies lost.)"); @@ -2853,7 +2845,7 @@ bool town_move_party(location destination,short forced)//// destination.y += 2; univ.town.p_loc.y += 2; update_explored(univ.party.p_loc); - initiate_redraw(); + draw_terrain(); print_buf(); if ((cave_lore_present() > 0) && (get_ran(1,0,1) == 0)) add_string_to_buf(" (No supplies lost.)"); diff --git a/osx/boe.actions.h b/osx/boe.actions.h index e9bf74c8..49cb0330 100644 --- a/osx/boe.actions.h +++ b/osx/boe.actions.h @@ -7,7 +7,6 @@ void flash_round_rect(Rect to_flash,short radius); void button_flash_rect(Rect to_flash); void handle_menu_spell(short spell_picked,short spell_type) ; void initiate_outdoor_combat(short i); -void initiate_redraw(); bool handle_keystroke(char chr,char chr2,EventRecord event); void menu_activate( short type); void do_load(); diff --git a/osx/boe.graphics.cpp b/osx/boe.graphics.cpp index d410b055..405243c7 100644 --- a/osx/boe.graphics.cpp +++ b/osx/boe.graphics.cpp @@ -1784,7 +1784,10 @@ void draw_terrain(short mode) bool off_terrain = false,draw_trim = true; short i,j,short_spec_terrain; GrafPtr old_port; - + + if(overall_mode == MODE_TALKING || overall_mode == MODE_SHOPPING || overall_mode == MODE_STARTUP) + return; + if (mode == 2) { if (current_working_monster < 0) return; supressing_some_spaces = true; diff --git a/osx/boe.graphics.h b/osx/boe.graphics.h index 4c16e43f..e8edffcd 100644 --- a/osx/boe.graphics.h +++ b/osx/boe.graphics.h @@ -39,7 +39,7 @@ void load_town_graphics(); void update_pc_graphics(); void put_graphics_in_template(); //GWorldPtr load_pict(short picture_to_get); -void draw_terrain(short mode); +void draw_terrain(short mode = 0); void place_trim(short q,short r,location where,unsigned char ter_type); void draw_trim(short q,short r,short which_trim,short which_mode); bool extend_road_terrain(unsigned char ter); diff --git a/osx/boe.main.cpp b/osx/boe.main.cpp index 0f752ee7..ecb8d03e 100644 --- a/osx/boe.main.cpp +++ b/osx/boe.main.cpp @@ -177,6 +177,7 @@ int main(void) item_sbar_UPP = NewControlActionProc(item_sbar_action); shop_sbar_UPP = NewControlActionProc(shop_sbar_action); #endif + init_fileio(); init_graph_tool(redraw_screen,&ul); Set_Window_Drag_Bdry(); @@ -353,7 +354,7 @@ void Handle_One_Event() if ((cur_time % 40 == 0) && (in_startup_mode == false) && (anim_onscreen == true) && (PSD[SDF_NO_TER_ANIM] == 0) && ((FrontWindow() == mainPtr) || (FrontWindow() ==GetDialogWindow(modeless_dialogs[5]))) && (!gInBackground)) { last_anim_time = cur_time; - initiate_redraw(); + draw_terrain(); } if ((cur_time - last_anim_time > 20) && (in_startup_mode == true) && (app_started_normally == true) && (FrontWindow() == mainPtr)) { @@ -793,13 +794,14 @@ void handle_file_menu(int item_hit) do_save(0); break; case 3: - if (in_startup_mode == true){ - try{ - FSSpec file = nav_put_party(); - save_party(file); - } catch(no_file_chosen){} - } - else do_save(1); +// if (in_startup_mode == true){ +// try{ +// FSSpec file = nav_put_party(); +// save_party(file); +// } catch(no_file_chosen){} +// } +// else + do_save(1); break; case 4: if (in_startup_mode == false) { @@ -853,7 +855,7 @@ void handle_options_menu(int item_hit) if (choice < 6) pick_pc_graphic(choice,1,0); update_pc_graphics(); - initiate_redraw(); + draw_terrain(); break; case 4: @@ -868,7 +870,7 @@ void handle_options_menu(int item_hit) kill_pc(choice,MAIN_STATUS_ABSENT); } update_pc_graphics(); - initiate_redraw(); + draw_terrain(); } break; diff --git a/osx/misc/fileio.cpp b/osx/misc/fileio.cpp index 97c5848d..1ccb8ea7 100644 --- a/osx/misc/fileio.cpp +++ b/osx/misc/fileio.cpp @@ -10,7 +10,7 @@ #include #include //#include "scen.global.h" -#include +#include #include "classes.h" //#include "scen.fileio.h" //#include "scen.keydlgs.h" @@ -80,7 +80,7 @@ Boolean party_file_filter(AEDesc* item, void* info, void * dummy, NavFilterModes void init_fileio(){ OSErr err; - NavDialogCreationOptions opts = { + static NavDialogCreationOptions opts = { kNavDialogCreationOptionsVersion, kNavNoTypePopup, {-2,-2}, @@ -97,9 +97,10 @@ void init_fileio(){ }; err = NavCreatePutFileDialog (&opts, 'BETM', 'BlEd', NULL, NULL, &dlg_put_scen); err = NavCreateGetFileDialog (&opts, NULL, NULL, NULL, scen_file_filter, NULL, &dlg_get_scen); - NavDialogCreationOptions opts2 = opts; + static NavDialogCreationOptions opts2 = opts; opts2.clientName = CFSTR("com.spidweb.bladesofexile"); opts2.windowTitle = CFSTR("Blades of Exile"); + opts2.modality = kWindowModalityAppModal; err = NavCreatePutFileDialog (&opts2, 'beSV', 'blx!', NULL, NULL, &dlg_put_game); err = NavCreateGetFileDialog (&opts2, NULL, NULL, NULL, party_file_filter, NULL, &dlg_get_game); } @@ -159,13 +160,13 @@ FSSpec nav_get_party() throw(no_file_chosen) { FSSpec nav_put_party() throw(no_file_chosen) { NavReplyRecord s_reply; AEKeyword keyword; - DescType descType; + DescType actualType; Size actualSize; FSSpec file_to_save; OSStatus error; long descCount; - NavDialogRun(dlg_put_game); + error = NavDialogRun(dlg_put_game); NavUserAction e = NavDialogGetUserAction(dlg_put_game); if (e == kNavUserActionCancel || e == kNavUserActionNone) throw no_file_chosen(); @@ -181,19 +182,15 @@ FSSpec nav_put_party() throw(no_file_chosen) { if (error == noErr){ long index = 1; //for (index = 1; index <= 1; index++){ - AEKeyword theKeyword; - DescType actualType; - Size actualSize; - FSSpec documentFSSpec; // Get a pointer to selected file error = AEGetNthPtr(&(s_reply.selection), index, - typeFSS, &theKeyword, - &actualType,&documentFSSpec, - sizeof(documentFSSpec), + typeFSS, &keyword, + &actualType,&file_to_save, + sizeof(file_to_save), &actualSize); if (error == noErr){ FSRef tempRef; - FSpMakeFSRef(&documentFSSpec,&tempRef); + FSpMakeFSRef(&file_to_save,&tempRef); UniChar uniname[256]; CFRange range = {0,255}; CFStringGetCharacters (s_reply.saveFileName,range,uniname); @@ -259,6 +256,8 @@ header_posix_ustar generateTarHeader(const std::string& fileName, unsigned long if(fileName.length()>=100) throw length_error("Specified file name longer than 99 characters."); header_posix_ustar header; + char* init = (char*) &header; + for(int i = 0; i < sizeof(header); i++) init[i] = 0; sprintf(header.name,"%s",fileName.c_str()); sprintf(header.mode,"%07o",0600); @@ -1006,7 +1005,7 @@ bool load_party(FSSpec file_to_load){ //file_size = sizeof(legacy::party_record_type); // 45368 - len = sizeof(flags); // 2 + len = sizeof(flags); // 10 // sprintf((char *) debug, " Len %d ", (short) len); // add_string_to_buf((char *) debug); @@ -1045,38 +1044,42 @@ bool load_party(FSSpec file_to_load){ flip_short((short*)&flags.a); flip_short((short*)&flags.b); flip_short((short*)&flags.c); - if(flags.b == win_flags[0][1]) town_restore = true; - else if(flags.b != win_flags[0][0]) format = unknown; - if(flags.c == win_flags[1][0]) in_scen = true; - else if(flags.c != win_flags[1][1]) format = unknown; - if(flags.d == win_flags[2][1]) maps_there = true; - else if(flags.d != win_flags[2][0]) format = unknown; + format = old_win; + if(flags.a == win_flags[0][1]) town_restore = true; + else if(flags.a != win_flags[0][0]) format = unknown; + if(flags.b == win_flags[1][0]) in_scen = true; + else if(flags.b != win_flags[1][1]) format = unknown; + if(flags.c == win_flags[2][1]) maps_there = true; + else if(flags.c != win_flags[2][0]) format = unknown; }else{ // mac save - if(flags.b == mac_flags[0][1]) town_restore = true; - else if(flags.b != mac_flags[0][0]) format = unknown; - if(flags.c == mac_flags[1][0]) in_scen = true; - else if(flags.c != mac_flags[1][1]) format = unknown; - if(flags.d == mac_flags[2][1]) maps_there = true; - else if(flags.d != mac_flags[2][0]) format = unknown; + format = old_mac; + if(flags.a == mac_flags[0][1]) town_restore = true; + else if(flags.a != mac_flags[0][0]) format = unknown; + if(flags.b == mac_flags[1][0]) in_scen = true; + else if(flags.b != mac_flags[1][1]) format = unknown; + if(flags.c == mac_flags[2][1]) maps_there = true; + else if(flags.c != mac_flags[2][0]) format = unknown; } }else if(flags.a == win_flags[0][0] || flags.a == win_flags[0][1]){ // old format if(mac_is_intel){ // it's actually a macintosh save flip_short((short*)&flags.a); flip_short((short*)&flags.b); flip_short((short*)&flags.c); - if(flags.b == mac_flags[0][1]) town_restore = true; - else if(flags.b != mac_flags[0][0]) format = unknown; - if(flags.c == mac_flags[1][0]) in_scen = true; - else if(flags.c != mac_flags[1][1]) format = unknown; - if(flags.d == mac_flags[2][1]) maps_there = true; - else if(flags.d != mac_flags[2][0]) format = unknown; - }else{ // mac save - if(flags.b == win_flags[0][1]) town_restore = true; - else if(flags.b != win_flags[0][0]) format = unknown; - if(flags.c == win_flags[1][0]) in_scen = true; - else if(flags.c != win_flags[1][1]) format = unknown; - if(flags.d == win_flags[2][1]) maps_there = true; - else if(flags.d != win_flags[2][0]) format = unknown; + format = old_mac; + if(flags.a == mac_flags[0][1]) town_restore = true; + else if(flags.a != mac_flags[0][0]) format = unknown; + if(flags.b == mac_flags[1][0]) in_scen = true; + else if(flags.b != mac_flags[1][1]) format = unknown; + if(flags.c == mac_flags[2][1]) maps_there = true; + else if(flags.c != mac_flags[2][0]) format = unknown; + }else{ // win save + format = old_win; + if(flags.a == win_flags[0][1]) town_restore = true; + else if(flags.a != win_flags[0][0]) format = unknown; + if(flags.b == win_flags[1][0]) in_scen = true; + else if(flags.b != win_flags[1][1]) format = unknown; + if(flags.c == win_flags[2][1]) maps_there = true; + else if(flags.c != win_flags[2][0]) format = unknown; } }else format = unknown; @@ -1126,13 +1129,20 @@ bool load_party(FSSpec file_to_load){ } bool load_party_v1(FSSpec file_to_load, bool town_restore, bool in_scen, bool maps_there, bool must_port){ - short file_id,i; - OSErr error = FSpOpenDF(&file_to_load,1,&file_id); - if (error != 0) { - FCD(1064,0); - SysBeep(2); - return false; - } + FSRef dest_ref; + char* path = new char[200]; + FSpMakeFSRef(&file_to_load, &dest_ref); + FSRefMakePath(&dest_ref, (UInt8*) path, 200); + ifstream fin(path); + fin.seekg(3*sizeof(short),ios_base::beg); // skip the header, which is 6 bytes in the old format + //short flags[3]; + //fin.read((char*)flags,3*sizeof(short)); +// OSErr error = FSpOpenDF(&file_to_load,1,&file_id); +// if (error != 0) { +// FCD(1064,0); +// SysBeep(2); +// return false; +// } legacy::party_record_type store_party; legacy::setup_save_type store_setup; @@ -1152,12 +1162,14 @@ bool load_party_v1(FSSpec file_to_load, bool town_restore, bool in_scen, bool ma // LOAD PARTY len = (long) sizeof(legacy::party_record_type); // 45368 store_len = len; - if ((error = FSRead(file_id, &len, (char *) &store_party)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)&store_party, len); +// error = FSRead(file_id, &len, (char *) &store_party) +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } if(must_port) port_party(&store_party); party_ptr = (char*) &store_party; for (count = 0; count < store_len; count++) @@ -1165,24 +1177,27 @@ bool load_party_v1(FSSpec file_to_load, bool town_restore, bool in_scen, bool ma // LOAD SETUP len = (long) sizeof(legacy::setup_save_type); - if ((error = FSRead(file_id, &len, (char *) &store_setup)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)&store_setup, len); +// error = FSRead(file_id, &len, (char *) &store_setup) +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } // LOAD PCS store_len = (long) sizeof(legacy::pc_record_type); - for (i = 0; i < 6; i++) { + for (int i = 0; i < 6; i++) { len = store_len; - error = FSRead(file_id, &len, (char *) &store_pc[i]); - if (error != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)&store_pc[i], len); +// error = FSRead(file_id, &len, (char *) &store_pc[i]); +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } if(must_port) port_pc(&store_pc[i]); pc_ptr = (char*) &store_pc[i]; for (count = 0; count < store_len; count++) @@ -1193,102 +1208,122 @@ bool load_party_v1(FSSpec file_to_load, bool town_restore, bool in_scen, bool ma // LOAD OUTDOOR MAP len = (long) sizeof(legacy::out_info_type); - if ((error = FSRead(file_id, &len, (char *) &store_out_info)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)&store_out_info, len); +// error = FSRead(file_id, &len, (char *) &store_out_info) +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } if(univ.town.loaded()) univ.town.unload(); // LOAD TOWN if (town_restore) { len = (long) sizeof(legacy::current_town_type); - if ((error = FSRead(file_id, &len, (char *) &store_c_town)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)&store_c_town, len); +// error = FSRead(file_id, &len, (char *) &store_c_town) +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } if(must_port) port_c_town(&store_c_town); len = (long) sizeof(legacy::big_tr_type); - if ((error = FSRead(file_id, &len, (char *) &t_d)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)&t_d, len); +// error = FSRead(file_id, &len, (char *) &t_d) +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } if(must_port) port_t_d(&t_d); len = (long) sizeof(legacy::town_item_list); - if ((error = FSRead(file_id, &len, (char *) &t_i)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)&t_i, len); +// error = FSRead(file_id, &len, (char *) &t_i) +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } }else univ.town.num = 200; // LOAD STORED ITEMS - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { len = (long) sizeof(legacy::stored_items_list_type); - if ((error = FSRead(file_id, &len, (char *) &stored_items[i])) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)&stored_items[i], len); +// error = FSRead(file_id, &len, (char *) &stored_items[i]) +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } } // LOAD SAVED MAPS if (maps_there) { len = (long) sizeof(legacy::stored_town_maps_type); - if ((error = FSRead(file_id, &len, (char *) &(town_maps))) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)&town_maps, len); +// error = FSRead(file_id, &len, (char *) &(town_maps)) +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } len = (long) sizeof(legacy::stored_outdoor_maps_type); - if ((error = FSRead(file_id, &len, (char *) &o_maps)) != 0) { - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)&o_maps, len); +// error = FSRead(file_id, &len, (char *) &o_maps) +// if (error != 0) { +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } } // LOAD SFX & MISC_I len = (long) (64 * 64); - if ((error = FSRead(file_id, &len, (char *) sfx)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } - if ((error = FSRead(file_id, &len, (char *) misc_i)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return false; - } + fin.read((char*)sfx, len); +// error = FSRead(file_id, &len, (char *) sfx) +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } + fin.read((char*)misc_i, len); +// error = FSRead(file_id, &len, (char *) misc_i) +// if (error != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return false; +// } } // end if_scen - if ((error = FSClose(file_id)) != 0){ - give_error("Load: Can't close file.","",0); - SysBeep(2); - return false; - } + fin.close(); +// error = FSClose(file_id) +// if (error != 0){ +// give_error("Load: Can't close file.","",0); +// SysBeep(2); +// return false; +// } univ.party = store_party; univ.party.append(store_setup); univ.party.void_pcs(); - for(i = 0; i < 6; i++) + for(int i = 0; i < 6; i++) univ.party.add_pc(store_pc[i]); if(in_scen){ univ.out.append(store_out_info); @@ -1297,7 +1332,7 @@ bool load_party_v1(FSSpec file_to_load, bool town_restore, bool in_scen, bool ma univ.town.append(t_d); univ.town.append(t_i); } - for(i = 0; i < 3; i++) + for(int i = 0; i < 3; i++) univ.party.append(stored_items[i],i); univ.append(town_maps); univ.append(o_maps); @@ -1308,7 +1343,7 @@ bool load_party_v1(FSSpec file_to_load, bool town_restore, bool in_scen, bool ma FSSpec file_spec; std::string path; path = progDir + "/Blades of Exile Scenarios/" + univ.party.scen_name; - std::cout<> cur_health; else if(cur == "MANA") sin >> cur_sp; - else if(cur = "EXPERIENCE") + else if(cur == "EXPERIENCE") sin >> experience; else if(cur == "SKILLPTS") sin >> skill_pts; @@ -353,3 +353,15 @@ void cPlayer::readFrom(istream& file){ sin >> weap_poisoned; } } + +ostream& operator << (ostream& out, eMainStatus& e){ + out << (int) e; +} + +istream& operator >> (istream& in, eMainStatus& e){ + int i; + in >> i; + if(i > 0 && i < 18 && i !=8 && i != 9) + e = (eMainStatus) i; + else e = MAIN_STATUS_ABSENT; +} diff --git a/osx/pc.h b/osx/pc.h index 7c7e2b38..c96ab67d 100644 --- a/osx/pc.h +++ b/osx/pc.h @@ -65,3 +65,5 @@ public: void operator += (eMainStatus& stat, eMainStatus othr); void operator -= (eMainStatus& stat, eMainStatus othr); +ostream& operator << (ostream& out, eMainStatus& e); +istream& operator >> (istream& in, eMainStatus& e); diff --git a/osx/town.h b/osx/town.h index 1207f1e8..9124b181 100644 --- a/osx/town.h +++ b/osx/town.h @@ -21,12 +21,12 @@ class cTown { // formerly town_record_type public: class cCreature { // formerly creature_start_type public: - unsigned char number; + unsigned short number; unsigned char start_attitude; location start_loc; - unsigned char mobile; - unsigned char time_flag; - unsigned char extra1,extra2; + unsigned char mobile; + unsigned char time_flag; + unsigned char extra1,extra2; short spec1, spec2; char spec_enc_code,time_code; short monster_time,personality; diff --git a/osx/universe.cpp b/osx/universe.cpp index b35cf721..cdb46ac6 100644 --- a/osx/universe.cpp +++ b/osx/universe.cpp @@ -710,7 +710,7 @@ void cCurTown::readFrom(istream& file){ case 32: record = new cTinyTown; break; - case 48; + case 48: record = new cMedTown; break; case 64: @@ -730,3 +730,10 @@ void cCurOut::readFrom(istream& file){ file >> out_e[i][j]; } +cCurTown::cCurTown(){ + record = NULL; + num = 200; + for(int i = 0; i < 64; i++) + for(int j = 0; j < 64; j++) + fields[i][j] = 0L; +} diff --git a/osx/universe.h b/osx/universe.h index 26145890..1e1b3ea3 100644 --- a/osx/universe.h +++ b/osx/universe.h @@ -44,6 +44,7 @@ public: unsigned char sfx(char x, char y) const; cTown* operator -> (); + cCurTown(); bool loaded() const; void unload();