diff --git a/osx/Blades of Exile Char Editor/pc.action.cpp b/osx/Blades of Exile Char Editor/pc.action.cpp index ca1ab41d..aa09664d 100644 --- a/osx/Blades of Exile Char Editor/pc.action.cpp +++ b/osx/Blades of Exile Char Editor/pc.action.cpp @@ -2,6 +2,7 @@ #include "pc.graphics.h" #include "pc.global.h" +#include "classes.h" #include "pc.editors.h" #include "pc.fileio.h" #include "pc.action.h" @@ -13,25 +14,26 @@ #include "dlgutil.h" /* Adventure globals */ -extern party_record_type party; -extern pc_record_type adven[6]; -extern outdoor_record_type outdoors[2][2]; -extern current_town_type c_town; -extern big_tr_type t_d; -extern town_item_list t_i; -extern unsigned char out[96][96],out_e[96][96]; -extern setup_save_type setup_save; -extern stored_items_list_type stored_items[3]; -extern stored_town_maps_type town_maps; -extern stored_outdoor_maps_type o_maps; +//extern party_record_type party; +//extern pc_record_type ADVEN[6]; +//extern outdoor_record_type outdoors[2][2]; +//extern current_town_type c_town; +//extern big_tr_type t_d; +//extern town_item_list t_i; +//extern unsigned char out[96][96],out_e[96][96]; +//extern setup_save_type setup_save; +//extern stored_items_list_type stored_items[3]; +//extern stored_town_maps_type town_maps; +//extern stored_outdoor_maps_type o_maps; +extern cUniverse univ; -extern Boolean ed_reg; -extern long ed_flag,ed_key; +//extern Boolean ed_reg; +//extern long ed_flag,ed_key; extern WindowPtr mainPtr; extern Boolean file_in_mem; extern short current_cursor,dialog_answer; -extern long register_flag; +//extern long register_flag; extern GWorldPtr pc_gworld; extern Boolean diff_depth_ok,save_blocked; @@ -51,7 +53,7 @@ extern Rect edit_rect[5][2]; short store_trait_mode,store_train_pc; -pc_record_type *store_xp_pc; +cPlayer *store_xp_pc; // Variables for spending xp Boolean talk_done = FALSE; @@ -91,7 +93,7 @@ Boolean handle_action(EventRecord event,short mode) for (i = 0; i < 6; i++) if ((PtInRect(the_point,&pc_area_buttons[i][0]) == TRUE) && - (adven[i].main_status > 0)) { + (ADVEN[i].main_status > 0)) { do_button_action(0,i); current_active_pc = i; display_party(6,1); @@ -99,9 +101,9 @@ Boolean handle_action(EventRecord event,short mode) } for (i = 0; i < 5; i++) if ((PtInRect(the_point,&edit_rect[i][0]) == TRUE) && - (adven[current_active_pc].main_status > 0)) { + (ADVEN[current_active_pc].main_status > 0)) { do_button_action(0,i + 10); - if ((ed_reg == FALSE) && (save_blocked == FALSE)) + if (save_blocked == FALSE) if ((choice = FCD(904,0)) == 1) return to_return; else save_blocked = TRUE; @@ -113,29 +115,29 @@ Boolean handle_action(EventRecord event,short mode) display_pc(current_active_pc,1,0); break; case 2: - pick_race_abil(&adven[current_active_pc],0,0); + pick_race_abil(&ADVEN[current_active_pc],0,0); break; case 3: spend_xp(current_active_pc,1,0); break; case 4: - edit_xp(&adven[current_active_pc]); + edit_xp(&ADVEN[current_active_pc]); break; } } for (i = 0; i < 24; i++) if ((PtInRect(the_point,&item_string_rects[i][1]) == TRUE) && // drop item - (adven[current_active_pc].items[i].variety > 0)) { // variety = 0 no item in slot/ non 0 item exists + (ADVEN[current_active_pc].items[i].variety > 0)) { // variety = 0 no item in slot/ non 0 item exists flash_rect(item_string_rects[i][1]); take_item(current_active_pc,i); draw_items(1); } for (i = 0; i < 24; i++) if ((PtInRect(the_point,&item_string_rects[i][2]) == TRUE) && // identify item - (adven[current_active_pc].items[i].variety > 0)) { + (ADVEN[current_active_pc].items[i].variety > 0)) { flash_rect(item_string_rects[i][2]); - adven[current_active_pc].items[i].item_properties = adven[current_active_pc].items[i].item_properties | 1; + ADVEN[current_active_pc].items[i].item_properties = ADVEN[current_active_pc].items[i].item_properties | 1; draw_items(1); } @@ -183,16 +185,16 @@ void edit_gold_or_food(short which_to_edit) make_cursor_sword(); cd_create_dialog((which_to_edit == 0) ? 1012 : 947, mainPtr); - sprintf((char *) sign_text,"%d",(short) ((which_to_edit == 0) ? party.gold : party.food)); + sprintf((char *) sign_text,"%d",(short) ((which_to_edit == 0) ? univ.party.gold : univ.party.food)); cd_set_text_edit_str((which_to_edit == 0) ? 1012 : 947,2,(char *) sign_text); item_hit = cd_run_dialog(); cd_kill_dialog((which_to_edit == 0) ? 1012 : 947,0); dialog_answer = minmax(0,25000,dialog_answer); if (which_to_edit == 0) - party.gold = dialog_answer; + univ.party.gold = dialog_answer; else - party.food = dialog_answer; + univ.party.food = dialog_answer; } void edit_day_event_filter (short item_hit) @@ -224,7 +226,7 @@ void edit_day() cd_create_dialog(917,mainPtr); - sprintf((char *) sign_text,"%d",(short) ( ((party.age) / 3700) + 1)); + sprintf((char *) sign_text,"%d",(short) ( ((univ.party.age) / 3700) + 1)); cd_set_text_edit_str(917,2,(char *) sign_text); item_hit = cd_run_dialog(); @@ -233,7 +235,7 @@ void edit_day() dialog_answer = minmax(0,500,dialog_answer); - party.age = (long) (3700) * (long) (dialog_answer); + univ.party.age = (long long) (3700) * (long long) (dialog_answer); } @@ -242,13 +244,13 @@ void put_pc_graphics() short item_hit,what_talk_field,i; for (i = 3; i < 65; i++) { - if (((store_trait_mode == 0) && (adven[which_pc_displayed].mage_spells[i - 3] == TRUE)) || - ((store_trait_mode == 1) && (adven[which_pc_displayed].priest_spells[i - 3] == TRUE))) + if (((store_trait_mode == 0) && (ADVEN[which_pc_displayed].mage_spells[i - 3] == TRUE)) || + ((store_trait_mode == 1) && (ADVEN[which_pc_displayed].priest_spells[i - 3] == TRUE))) cd_set_led(991,i,1); else cd_set_led(991,i,0); } - cd_set_item_text(991,69,adven[which_pc_displayed].name); + cd_set_item_text(991,69,ADVEN[which_pc_displayed].name); } void display_pc_event_filter (short item_hit) { @@ -263,25 +265,25 @@ void display_pc_event_filter (short item_hit) case 66: do { pc_num = (pc_num == 0) ? 5 : pc_num - 1; - } while (adven[pc_num].main_status == 0); + } while (ADVEN[pc_num].main_status == 0); which_pc_displayed = pc_num; put_pc_graphics(); break; case 67: do { pc_num = (pc_num == 5) ? 0 : pc_num + 1; - } while (adven[pc_num].main_status == 0); + } while (ADVEN[pc_num].main_status == 0); which_pc_displayed = pc_num; put_pc_graphics(); break; default: if (store_trait_mode == 0) - adven[which_pc_displayed].mage_spells[item_hit - 3] = - 1 - adven[which_pc_displayed].mage_spells[item_hit - 3]; + ADVEN[which_pc_displayed].mage_spells[item_hit - 3] = + 1 - ADVEN[which_pc_displayed].mage_spells[item_hit - 3]; else - adven[which_pc_displayed].priest_spells[item_hit - 3] = - 1 - adven[which_pc_displayed].priest_spells[item_hit - 3]; + ADVEN[which_pc_displayed].priest_spells[item_hit - 3] = + 1 - ADVEN[which_pc_displayed].priest_spells[item_hit - 3]; put_pc_graphics(); break; } @@ -292,9 +294,9 @@ void display_pc(short pc_num,short mode,short parent) short i,item_hit; Str255 label_str; - if (adven[pc_num].main_status == 0) { + if (ADVEN[pc_num].main_status == 0) { for (pc_num = 0; pc_num < 6; pc_num++) - if (adven[pc_num].main_status == 1) + if (ADVEN[pc_num].main_status == 1) break; } which_pc_displayed = pc_num; @@ -326,12 +328,12 @@ void display_alchemy_event_filter (short item_hit) toast_dialog(); break; default: - party.alchemy[item_hit - 4] = 1 - party.alchemy[item_hit - 4]; + univ.party.alchemy[item_hit - 4] = 1 - univ.party.alchemy[item_hit - 4]; break; } for (i = 0; i < 20; i++) { - if (party.alchemy[i] > 0) + if (univ.party.alchemy[i] > 0) cd_set_led(996,i + 4,1); else cd_set_led(996,i + 4,0); } @@ -356,7 +358,7 @@ void display_alchemy() for (i = 0; i < 20; i++) { cd_add_label(996,i + 4,alch_names[i],1083); - if (party.alchemy[i] > 0) + if (univ.party.alchemy[i] > 0) cd_set_led(996,i + 4,1); else cd_set_led(996,i + 4,0); } @@ -370,11 +372,11 @@ void display_alchemy() void do_xp_keep(short pc_num,short mode) { for (i = 0; i < 20; i++) - adven[pc_num].skills[i] = store_skills[i]; - adven[pc_num].cur_health += store_h - adven[pc_num].max_health; - adven[pc_num].max_health = store_h; - adven[pc_num].cur_sp += store_sp - adven[pc_num].max_sp; - adven[pc_num].max_sp = store_sp; + ADVEN[pc_num].skills[i] = store_skills[i]; + ADVEN[pc_num].cur_health += store_h - ADVEN[pc_num].max_health; + ADVEN[pc_num].max_health = store_h; + ADVEN[pc_num].cur_sp += store_sp - ADVEN[pc_num].max_sp; + ADVEN[pc_num].max_sp = store_sp; } @@ -409,15 +411,15 @@ void do_xp_draw() pc_num = store_train_pc; - sprintf((char *) get_text, "%s",(char *) adven[pc_num].name); + sprintf((char *) get_text, "%s",(char *) ADVEN[pc_num].name); cd_set_item_text (1010, 51,get_text); for (i = 0; i < 20; i++) - store_skills[i] = adven[pc_num].skills[i]; - store_h = adven[pc_num].max_health; - store_sp = adven[pc_num].max_sp; + store_skills[i] = ADVEN[pc_num].skills[i]; + store_h = ADVEN[pc_num].max_health; + store_sp = ADVEN[pc_num].max_sp; store_g = 12000; store_skp = 10000; @@ -508,7 +510,7 @@ void spend_xp_event_filter (short item_hit) do_xp_keep(pc_num,0); do { pc_num = (pc_num == 0) ? 5 : pc_num - 1; - } while (adven[pc_num].main_status != 1); + } while (ADVEN[pc_num].main_status != 1); store_train_pc = pc_num; do_xp_draw(); break; @@ -518,7 +520,7 @@ void spend_xp_event_filter (short item_hit) do_xp_keep(pc_num,0); do { pc_num = (pc_num == 5) ? 0 : pc_num + 1; - } while (adven[pc_num].main_status != 1); + } while (ADVEN[pc_num].main_status != 1); store_train_pc = pc_num; do_xp_draw(); break; @@ -651,7 +653,7 @@ void edit_xp_event_filter (short item_hit) toast_dialog(); } -void edit_xp(pc_record_type *pc) +void edit_xp(cPlayer *pc) { short item_hit; @@ -666,7 +668,7 @@ void edit_xp(pc_record_type *pc) sprintf((char *) sign_text,"%d",(short)pc->experience); cd_set_text_edit_str(1024,2,(char *) sign_text); - item_hit = get_tnl(store_xp_pc); + item_hit = store_xp_pc->get_tnl(); cdsin(1024,8,item_hit); item_hit = cd_run_dialog(); diff --git a/osx/Blades of Exile Char Editor/pc.action.h b/osx/Blades of Exile Char Editor/pc.action.h index 0e0a2ca4..1f8e974b 100644 --- a/osx/Blades of Exile Char Editor/pc.action.h +++ b/osx/Blades of Exile Char Editor/pc.action.h @@ -20,4 +20,4 @@ void do_registration(); void edit_day(); void edit_day_event_filter (short item_hit); void edit_xp_event_filter (short item_hit); -void edit_xp(pc_record_type *pc); +void edit_xp(cPlayer *pc); diff --git a/osx/Blades of Exile Char Editor/pc.editors.cpp b/osx/Blades of Exile Char Editor/pc.editors.cpp index d5f6ee62..da26a4c6 100644 --- a/osx/Blades of Exile Char Editor/pc.editors.cpp +++ b/osx/Blades of Exile Char Editor/pc.editors.cpp @@ -1,20 +1,22 @@ #include "pc.graphics.h" #include "pc.global.h" +#include "classes.h" #include "pc.editors.h" #include "graphtool.h" #include "dlgtool.h" /* Adventure globals */ -extern party_record_type party; -extern pc_record_type adven[6]; -extern outdoor_record_type outdoors[2][2]; -extern current_town_type c_town; -extern big_tr_type t_d; -extern town_item_list t_i; -extern unsigned char out[96][96],out_e[96][96]; -extern setup_save_type setup_save; -extern stored_items_list_type stored_items[3]; +//extern party_record_type party; +//extern pc_record_type ADVEN[6]; +//extern outdoor_record_type outdoors[2][2]; +//extern current_town_type c_town; +//extern big_tr_type t_d; +//extern town_item_list t_i; +//extern unsigned char out[96][96],out_e[96][96]; +//extern setup_save_type setup_save; +//extern stored_items_list_type stored_items[3]; +extern cUniverse univ; extern short dialog_answer; @@ -40,7 +42,7 @@ Boolean choice_active[6]; extern short store_trait_mode; -pc_record_type *store_pc; +cPlayer *store_pc; GWorldPtr button_num_gworld; @@ -51,49 +53,49 @@ void combine_things(short pc_num) short i,j,test; for (i = 0; i < 24; i++) { - if ((adven[pc_num].items[i].variety > 0) && - (adven[pc_num].items[i].type_flag > 0) && (adven[pc_num].items[i].item_properties & 254 != 0)) { + if ((ADVEN[pc_num].items[i].variety > 0) && + (ADVEN[pc_num].items[i].type_flag > 0) && (ADVEN[pc_num].items[i].item_properties & 254 != 0)) { for (j = i + 1; j < 24; j++) - if ((adven[pc_num].items[j].variety > 0) && - (adven[pc_num].items[j].type_flag == adven[pc_num].items[i].type_flag) - && (adven[pc_num].items[j].item_properties & 254 != 0)) { + if ((ADVEN[pc_num].items[j].variety > 0) && + (ADVEN[pc_num].items[j].type_flag == ADVEN[pc_num].items[i].type_flag) + && (ADVEN[pc_num].items[j].item_properties & 254 != 0)) { add_string_to_buf("(items combined)"); - test = (short) (adven[pc_num].items[i].charges) + (short) (adven[pc_num].items[j].charges); + test = (short) (ADVEN[pc_num].items[i].charges) + (short) (ADVEN[pc_num].items[j].charges); if (test > 125) { - adven[pc_num].items[i].charges = 125; + ADVEN[pc_num].items[i].charges = 125; ASB("Can have at most 125 of any item."); } - else adven[pc_num].items[i].charges += adven[pc_num].items[j].charges; - if (adven[pc_num].equip[j] == TRUE) { - adven[pc_num].equip[i] = TRUE; - adven[pc_num].equip[j] = FALSE; + else ADVEN[pc_num].items[i].charges += ADVEN[pc_num].items[j].charges; + if (ADVEN[pc_num].equip[j] == TRUE) { + ADVEN[pc_num].equip[i] = TRUE; + ADVEN[pc_num].equip[j] = FALSE; } take_item(pc_num,j); } } - if ((adven[pc_num].items[i].variety > 0) && (adven[pc_num].items[i].charges < 0)) - adven[pc_num].items[i].charges = 1; + if ((ADVEN[pc_num].items[i].variety > 0) && (ADVEN[pc_num].items[i].charges < 0)) + ADVEN[pc_num].items[i].charges = 1; } } -Boolean give_to_pc(short pc_num,item_record_type item, short print_result) +Boolean give_to_pc(short pc_num,cItemRec item, short print_result) { short free_space; char announce_string[60]; if (item.variety == 0) return TRUE; - if (((free_space = pc_has_space(pc_num)) == 24 ) || (adven[pc_num].main_status != 1)) + if (((free_space = pc_has_space(pc_num)) == 24 ) || (ADVEN[pc_num].main_status != 1)) return FALSE; else { - adven[pc_num].items[free_space] = item; + ADVEN[pc_num].items[free_space] = item; combine_things(pc_num); return TRUE; } return FALSE; } -Boolean give_to_party(item_record_type item,short print_result) +Boolean give_to_party(cItemRec item,short print_result) { short free_space, i = 0; @@ -107,14 +109,14 @@ Boolean give_to_party(item_record_type item,short print_result) void give_gold(short amount,Boolean print_result) { - party.gold = party.gold + amount; + univ.party.gold = univ.party.gold + amount; } Boolean take_gold(short amount,Boolean print_result) { - if (party.gold < amount) + if (univ.party.gold < amount) return FALSE; - party.gold = party.gold - amount; + univ.party.gold = univ.party.gold - amount; return TRUE; } @@ -124,7 +126,7 @@ short pc_has_space(short pc_num) short i = 0; while (i < 24) { - if (adven[pc_num].items[i].variety == 0) + if (ADVEN[pc_num].items[i].variety == 0) return i; i++; } @@ -138,48 +140,48 @@ void take_item(short pc_num,short which_item) short i; Boolean do_print = TRUE; - if ((adven[pc_num].weap_poisoned == which_item) && (adven[pc_num].status[0] > 0)) { + if ((ADVEN[pc_num].weap_poisoned == which_item) && (ADVEN[pc_num].status[0] > 0)) { // add_string_to_buf(" Poison lost. "); - adven[pc_num].status[0] = 0; + ADVEN[pc_num].status[0] = 0; } - if ((adven[pc_num].weap_poisoned > which_item) && (adven[pc_num].status[0] > 0)) - adven[pc_num].weap_poisoned--; + if ((ADVEN[pc_num].weap_poisoned > which_item) && (ADVEN[pc_num].status[0] > 0)) + ADVEN[pc_num].weap_poisoned--; for (i = which_item; i < 23; i++) { - adven[pc_num].items[i] = adven[pc_num].items[i + 1]; - adven[pc_num].equip[i] = adven[pc_num].equip[i + 1]; + ADVEN[pc_num].items[i] = ADVEN[pc_num].items[i + 1]; + ADVEN[pc_num].equip[i] = ADVEN[pc_num].equip[i + 1]; } - adven[pc_num].items[23].variety = 0; - adven[pc_num].equip[23] = FALSE; + ADVEN[pc_num].items[23].variety = 0; + ADVEN[pc_num].equip[23] = FALSE; } -void fancy_choice_dialog_event_filter (short item_hit) -{ - toast_dialog(); - dialog_answer = item_hit; -} - -short fancy_choice_dialog(short which_dlog,short parent) -// ignore parent in Mac version -{ - short item_hit,i,store_dialog_answer; - Str255 temp_str; - - store_dialog_answer = dialog_answer; - make_cursor_sword(); - - cd_create_dialog_parent_num(which_dlog,parent); - - item_hit = cd_run_dialog(); - cd_kill_dialog(which_dlog,0); - - i = dialog_answer; - dialog_answer = store_dialog_answer; - - return i; -} +//void fancy_choice_dialog_event_filter (short item_hit) +//{ +// toast_dialog(); +// dialog_answer = item_hit; +//} +// +//short fancy_choice_dialog(short which_dlog,short parent) +//// ignore parent in Mac version +//{ +// short item_hit,i,store_dialog_answer; +// Str255 temp_str; +// +// store_dialog_answer = dialog_answer; +// make_cursor_sword(); +// +// cd_create_dialog_parent_num(which_dlog,parent); +// +// item_hit = cd_run_dialog(); +// cd_kill_dialog(which_dlog,0); +// +// i = dialog_answer; +// dialog_answer = store_dialog_answer; +// +// return i; +//} void select_pc_event_filter (short item_hit) { @@ -203,13 +205,13 @@ short char_select_pc(short active_only,short free_inv_only,char *title) else csit( 1018,15,title); for (i = 0; i < 6; i++) { - if ((adven[i].main_status == 0) || - ((active_only == TRUE) && (adven[i].main_status > 1)) || - ((free_inv_only == 1) && (pc_has_space(i) == 24)) || (adven[i].main_status == 5)) { + if ((ADVEN[i].main_status == 0) || + ((active_only == TRUE) && (ADVEN[i].main_status > 1)) || + ((free_inv_only == 1) && (pc_has_space(i) == 24)) || (ADVEN[i].main_status == 5)) { cd_activate_item(1018, 3 + i, 0); } - if (adven[i].main_status != 0) { - csit(1018,9 + i,adven[i].name); + if (ADVEN[i].main_status != 0) { + csit(1018,9 + i,ADVEN[i].name); } else cd_activate_item(1018, 9 + i, 0); } @@ -285,8 +287,8 @@ short party_total_level() short i,j = 0; for (i = 0; i < 6; i++) - if (adven[i].main_status == 1) - j += adven[i].level; + if (ADVEN[i].main_status == 1) + j += ADVEN[i].level; return j; } @@ -297,8 +299,8 @@ short luck_total() short i = 0; for (i = 0; i < 6; i++) - if (adven[i].main_status == 1) - i += adven[i].skills[18]; + if (ADVEN[i].main_status == 1) + i += ADVEN[i].skills[18]; return i; } @@ -317,14 +319,14 @@ void display_traits_graphics() cd_set_led(1013,36 + i,(store_pc->traits[10 + i] > 0) ? 1 : 0); } - store = get_tnl(store_pc); + store = store_pc->get_tnl(); cdsin(1013,18,store); } void pick_race_abil_event_filter(short item_hit) { Str255 abil_str; - pc_record_type *pc; + cPlayer *pc; pc = store_pc; switch (item_hit) { @@ -358,7 +360,7 @@ void pick_race_abil_event_filter(short item_hit) } -void pick_race_abil(pc_record_type *pc,short mode,short parent_num) +void pick_race_abil(cPlayer *pc,short mode,short parent_num) //mode; // 0 - edit 1 - just display 2 - can't change race { char *start_str1 = "Click on advantage button for description."; @@ -383,22 +385,22 @@ void pick_race_abil(pc_record_type *pc,short mode,short parent_num) } -short get_tnl(pc_record_type *pc) -{ - short tnl = 100,i,store_per = 100; - short rp[3] = {0,12,20}; - short ap[15] = {10,20,8,10,4, 6,10,7,12,15, -10,-8,-8,-20,-8}; - - tnl = (tnl * (100 + rp[pc->race])) / 100; - for (i = 0; i < 15; i++) - if (pc->traits[i] == TRUE) - store_per = store_per + ap[i]; - - tnl = (tnl * store_per) / 100; - - return tnl; -} - +//short get_tnl(pc_record_type *pc) +//{ +// short tnl = 100,i,store_per = 100; +// short rp[3] = {0,12,20}; +// short ap[15] = {10,20,8,10,4, 6,10,7,12,15, -10,-8,-8,-20,-8}; +// +// tnl = (tnl * (100 + rp[pc->race])) / 100; +// for (i = 0; i < 15; i++) +// if (pc->traits[i] == TRUE) +// store_per = store_per + ap[i]; +// +// tnl = (tnl * store_per) / 100; +// +// return tnl; +//} +// //display_strings(20,7,0,0,"Editing party",57,707,916); diff --git a/osx/Blades of Exile Char Editor/pc.editors.h b/osx/Blades of Exile Char Editor/pc.editors.h index 8561e4d7..e1eaa301 100644 --- a/osx/Blades of Exile Char Editor/pc.editors.h +++ b/osx/Blades of Exile Char Editor/pc.editors.h @@ -1,11 +1,11 @@ -Boolean give_to_pc(short pc_num,item_record_type item, short print_result); -Boolean give_to_party(item_record_type item,short print_result); +Boolean give_to_pc(short pc_num,cItemRec item, short print_result); +Boolean give_to_party(cItemRec item,short print_result); void give_gold(short amount,Boolean print_result); Boolean take_gold(short amount,Boolean print_result); short pc_has_space(short pc_num); void take_item(short pc_num,short which_item); -void fancy_choice_dialog_event_filter (short item_hit); -short fancy_choice_dialog(short which_dlog,short parent); +//void fancy_choice_dialog_event_filter (short item_hit); +//short fancy_choice_dialog(short which_dlog,short parent); void select_pc_event_filter (short item_hit); short char_select_pc(short active_only,short free_inv_only,char *title); short select_pc(short active_only,short free_inv_only); @@ -16,7 +16,7 @@ short party_total_level(); short luck_total(); void display_traits_graphics(); void pick_race_abil_event_filter(short item_hit); -void pick_race_abil(pc_record_type *pc,short mode,short parent_num); -short get_tnl(pc_record_type *pc); +void pick_race_abil(cPlayer *pc,short mode,short parent_num); +//short get_tnl(pc_record_type *pc); void reset_boats(); void combine_things(short pc_num); diff --git a/osx/Blades of Exile Char Editor/pc.fileio.cpp b/osx/Blades of Exile Char Editor/pc.fileio.cpp index b8416462..7025abd0 100644 --- a/osx/Blades of Exile Char Editor/pc.fileio.cpp +++ b/osx/Blades of Exile Char Editor/pc.fileio.cpp @@ -3,6 +3,7 @@ #include #include "pc.global.h" +#include "classes.h" #include "pc.fileio.h" #include "pc.graphics.h" #include "graphtool.h" @@ -18,26 +19,27 @@ DialogPtr the_dialog; /* Adventure globals */ -extern party_record_type party; -extern pc_record_type adven[6]; -extern outdoor_record_type outdoors[2][2]; -extern current_town_type c_town; -extern big_tr_type t_d; -extern town_item_list t_i; -extern unsigned char misc_i[64][64],sfx[64][64]; -extern unsigned char out[96][96],out_e[96][96]; -extern setup_save_type setup_save; -extern stored_items_list_type stored_items[3]; +//extern party_record_type party; +//extern pc_record_type ADVEN[6]; +//extern outdoor_record_type outdoors[2][2]; +//extern current_town_type c_town; +//extern big_tr_type t_d; +//extern town_item_list t_i; +//extern unsigned char misc_i[64][64],sfx[64][64]; +//extern unsigned char out[96][96],out_e[96][96]; +//extern setup_save_type setup_save; +//extern stored_items_list_type stored_items[3]; -extern stored_town_maps_type town_maps; -extern stored_outdoor_maps_type o_maps; +//extern stored_town_maps_type town_maps; +//extern stored_outdoor_maps_type o_maps; extern Boolean play_sounds,save_blocked; extern short current_active_pc; extern long stored_key; extern WindowPtr mainPtr; -extern item_record_type item_list[400]; +extern cItemRec item_list[400]; +extern cUniverse univ; extern Boolean file_in_mem,party_in_scen,scen_items_loaded; @@ -63,295 +65,295 @@ FSSpec file_to_load; void load_base_item_defs(); bool load_scen_item_defs(char scen_name[256]); -void load_file() -{ - //SFReply reply; - //StandardFileReply s_reply; - Point where = {40,40}; - Str255 message = "Select saved game:"; - long file_size; - OSErr error; - NavTypeListHandle type_list; - NavDialogCreationOptions dialogOptions; - NavDialogRef theDialog; - NavUserAction theAction; - NavReplyRecord dialogReply; - AEKeyword dummyKeyword; - long descCount; - long descNum; - FSRef fileRef; - short file_id,i,j,k; - Boolean town_restore = FALSE; - Boolean maps_there = FALSE; - Boolean map_doh = FALSE; - Boolean in_scen = FALSE; - - flag_type fred; - flag_type *store; - char flag_data[8]; - - town_item_list *item_ptr; - long len,store_len,count; - out_info_type *explored_ptr; - char *party_ptr; - char *pc_ptr; - flag_type flag; - flag_type *flag_ptr; - stored_items_list_type *items_ptr; - - short flags[3][2] = {{5790,1342}, // slot 0 ... 5790 - out 1342 - town - {100,200}, // slot 1 100 in scenario, 200 not in - {3422,5567}}; // slot 2 ... 3422 - no maps 5567 - maps - - OSType typeList[2] = {'beSV','TEXT'}; - type_list = (NavTypeListHandle)NewHandle(sizeof(NavTypeList) + 2 * sizeof(OSType)); - - if (type_list != NULL){ - (*type_list)->componentSignature = 'blx!'; - (*type_list)->osTypeCount = 2; - BlockMoveData(&typeList, (*type_list)->osType, 2 * sizeof(OSType)); - } - - if (ae_loading == FALSE) { - //StandardGetFile(NULL,1,type_list,&s_reply); - // StandardGetFile is not available in Carbon -jmr - /* XXX FIXME general lack of error checking in these nav services calls */ - NavGetDefaultDialogCreationOptions(&dialogOptions); - NavCreateChooseFileDialog(&dialogOptions, type_list, NULL, - NULL, NULL, NULL, &theDialog); - NavDialogRun(theDialog); - theAction = NavDialogGetUserAction(theDialog); - if (theAction == kNavUserActionCancel || theAction == kNavUserActionNone) { - NavDialogDispose(theDialog); - return; - } - NavDialogGetReply(theDialog, &dialogReply); - - AECountItems(&(dialogReply.selection), &descCount); - for (descNum = 1 ; descNum <= descCount ; descNum++) { - DescType returnedType; - Size actualSize; - AEGetNthPtr(&(dialogReply.selection), descNum, typeWildCard, - &dummyKeyword, &returnedType, (Ptr)(&fileRef), - sizeof(fileRef), &actualSize); - /* we'd get typeFSS on classic Mac OS, but I have omitted that check due to laziness -jmr */ - if (returnedType == typeFSRef) - break; - } - if (descNum > descCount) { - /* no valid file reference came back from the dialog - shouldn't happen... */ - NavDisposeReply(&dialogReply); - NavDialogDispose(theDialog); - return; - } - - FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, - NULL, &file_to_load, NULL); - - NavDisposeReply(&dialogReply); - NavDialogDispose(theDialog); - } - - if ((error = FSpOpenDF(&file_to_load,1,&file_id)) != 0) { - FCD(1064,0); - SysBeep(2); - return; - } - - file_size = sizeof(party_record_type); - - len = sizeof(flag_type); - - // sprintf((char *) debug, " Len %d ", (short) len); - // add_string_to_buf((char *) debug); - - for (i = 0; i < 3; i++) { - if ((error = FSRead(file_id, &len, (char *) flag_data)) != 0) { - FSClose(file_id); - FCD(1064,0); - return; - } - flag_ptr = (flag_type *) flag_data; - flag = *flag_ptr; - store_flags[i] = (short) flag.i; - if ((flag.i != flags[i][0]) && (flag.i != flags[i][1])) { // OK BoE save file? - FSClose(file_id); - FCD(1063,0); - return; - } - - if ((i == 0) && (flag.i == flags[i][1])) - town_restore = TRUE; - if ((i == 1) && (flag.i == flags[i][0])) { - in_scen = TRUE; - } - if ((i == 2) && (flag.i == flags[i][1])) - maps_there = TRUE; - } - - // LOAD PARTY - len = (long) sizeof(party_record_type); - store_len = len; - party_ptr = (char *) &party; - if ((error = FSRead(file_id, &len, (char *) party_ptr)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - for (count = 0; count < store_len; count++) - party_ptr[count] ^= 0x5C; - - // LOAD SETUP - len = (long) sizeof(setup_save_type); - if ((error = FSRead(file_id, &len, (char *) &setup_save)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - - // LOAD PCS - store_len = (long) sizeof(pc_record_type); - for (i = 0; i < 6; i++) { - len = store_len; - pc_ptr = (char *) &adven[i]; - if ((error = FSRead(file_id, &len, (char *) pc_ptr)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - for (count = 0; count < store_len; count++) - pc_ptr[count] ^= 0x6B; - } - - if (in_scen == TRUE) { - // LOAD OUTDOOR MAP - len = (long) sizeof(out_info_type); - if ((error = FSRead(file_id, &len, (char *) out_e)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - - // LOAD TOWN - if (town_restore == TRUE) { - len = (long) sizeof(current_town_type); - if ((error = FSRead(file_id, &len, (char *) &c_town)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - - len = (long) sizeof(big_tr_type); - if ((error = FSRead(file_id, &len, (char *) &t_d)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - - len = (long) sizeof(town_item_list); - if ((error = FSRead(file_id, &len, (char *) &t_i)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - - } - - // LOAD STORED ITEMS - for (i = 0; i < 3; i++) { - len = (long) sizeof(stored_items_list_type); - if ((error = FSRead(file_id, &len, (char *) &stored_items[i])) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - } - - // LOAD SAVED MAPS - if (maps_there == TRUE) { - len = (long) sizeof(stored_town_maps_type); - if ((error = FSRead(file_id, &len, (char *) &(town_maps))) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - - len = (long) sizeof(stored_outdoor_maps_type); - if ((error = FSRead(file_id, &len, (char *) &o_maps)) != 0) { - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - } - - // 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; - } - if ((error = FSRead(file_id, &len, (char *) misc_i)) != 0){ - FSClose(file_id); - SysBeep(2); - FCD(1064,0); - return; - } - - } // end if_scen - - if ((error = FSClose(file_id)) != 0){ - add_string_to_buf("Load: Can't close file. "); - SysBeep(2); - return; - } - - for (i = 0; i < 6; i++){ - if (adven[i].main_status > 0) { - current_active_pc = i; - i = 6; - } - } - file_in_mem = TRUE; - save_blocked = FALSE; - party_in_scen = in_scen; - - if (ae_loading == FALSE) { - /* not reached with Carbon */ - /*strcpy ((char *) last_load_file, (char *) reply.fName);*/ - } else { - strcpy ((char *) last_load_file, (char *) file_to_load.name); - store_file_reply = file_to_load; - } - - //load item definitions - if(party_in_scen){ - if(!load_scen_item_defs(party.scen_name)){ - load_base_item_defs(); - scen_items_loaded = false; - } - else - scen_items_loaded = true; - } - else{ - load_base_item_defs(); - scen_items_loaded = false; - } - update_item_menu(); - - redraw_screen(); -} +//void load_file() +//{ +// //SFReply reply; +// //StandardFileReply s_reply; +// Point where = {40,40}; +// Str255 message = "Select saved game:"; +// long file_size; +// OSErr error; +// NavTypeListHandle type_list; +// NavDialogCreationOptions dialogOptions; +// NavDialogRef theDialog; +// NavUserAction theAction; +// NavReplyRecord dialogReply; +// AEKeyword dummyKeyword; +// long descCount; +// long descNum; +// FSRef fileRef; +// short file_id,i,j,k; +// Boolean town_restore = FALSE; +// Boolean maps_there = FALSE; +// Boolean map_doh = FALSE; +// Boolean in_scen = FALSE; +// +// flag_type fred; +// flag_type *store; +// char flag_data[8]; +// +// town_item_list *item_ptr; +// long len,store_len,count; +// out_info_type *explored_ptr; +// char *party_ptr; +// char *pc_ptr; +// flag_type flag; +// flag_type *flag_ptr; +// stored_items_list_type *items_ptr; +// +// short flags[3][2] = {{5790,1342}, // slot 0 ... 5790 - out 1342 - town +// {100,200}, // slot 1 100 in scenario, 200 not in +// {3422,5567}}; // slot 2 ... 3422 - no maps 5567 - maps +// +// OSType typeList[2] = {'beSV','TEXT'}; +// type_list = (NavTypeListHandle)NewHandle(sizeof(NavTypeList) + 2 * sizeof(OSType)); +// +// if (type_list != NULL){ +// (*type_list)->componentSignature = 'blx!'; +// (*type_list)->osTypeCount = 2; +// BlockMoveData(&typeList, (*type_list)->osType, 2 * sizeof(OSType)); +// } +// +// if (ae_loading == FALSE) { +// //StandardGetFile(NULL,1,type_list,&s_reply); +// // StandardGetFile is not available in Carbon -jmr +// /* XXX FIXME general lack of error checking in these nav services calls */ +// NavGetDefaultDialogCreationOptions(&dialogOptions); +// NavCreateChooseFileDialog(&dialogOptions, type_list, NULL, +// NULL, NULL, NULL, &theDialog); +// NavDialogRun(theDialog); +// theAction = NavDialogGetUserAction(theDialog); +// if (theAction == kNavUserActionCancel || theAction == kNavUserActionNone) { +// NavDialogDispose(theDialog); +// return; +// } +// NavDialogGetReply(theDialog, &dialogReply); +// +// AECountItems(&(dialogReply.selection), &descCount); +// for (descNum = 1 ; descNum <= descCount ; descNum++) { +// DescType returnedType; +// Size actualSize; +// AEGetNthPtr(&(dialogReply.selection), descNum, typeWildCard, +// &dummyKeyword, &returnedType, (Ptr)(&fileRef), +// sizeof(fileRef), &actualSize); +// /* we'd get typeFSS on classic Mac OS, but I have omitted that check due to laziness -jmr */ +// if (returnedType == typeFSRef) +// break; +// } +// if (descNum > descCount) { +// /* no valid file reference came back from the dialog - shouldn't happen... */ +// NavDisposeReply(&dialogReply); +// NavDialogDispose(theDialog); +// return; +// } +// +// FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, +// NULL, &file_to_load, NULL); +// +// NavDisposeReply(&dialogReply); +// NavDialogDispose(theDialog); +// } +// +// if ((error = FSpOpenDF(&file_to_load,1,&file_id)) != 0) { +// FCD(1064,0); +// SysBeep(2); +// return; +// } +// +// file_size = sizeof(party_record_type); +// +// len = sizeof(flag_type); +// +// // sprintf((char *) debug, " Len %d ", (short) len); +// // add_string_to_buf((char *) debug); +// +// for (i = 0; i < 3; i++) { +// if ((error = FSRead(file_id, &len, (char *) flag_data)) != 0) { +// FSClose(file_id); +// FCD(1064,0); +// return; +// } +// flag_ptr = (flag_type *) flag_data; +// flag = *flag_ptr; +// store_flags[i] = (short) flag.i; +// if ((flag.i != flags[i][0]) && (flag.i != flags[i][1])) { // OK BoE save file? +// FSClose(file_id); +// FCD(1063,0); +// return; +// } +// +// if ((i == 0) && (flag.i == flags[i][1])) +// town_restore = TRUE; +// if ((i == 1) && (flag.i == flags[i][0])) { +// in_scen = TRUE; +// } +// if ((i == 2) && (flag.i == flags[i][1])) +// maps_there = TRUE; +// } +// +// // LOAD PARTY +// len = (long) sizeof(party_record_type); +// store_len = len; +// party_ptr = (char *) &party; +// if ((error = FSRead(file_id, &len, (char *) party_ptr)) != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// for (count = 0; count < store_len; count++) +// party_ptr[count] ^= 0x5C; +// +// // LOAD SETUP +// len = (long) sizeof(setup_save_type); +// if ((error = FSRead(file_id, &len, (char *) &setup_save)) != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// +// // LOAD PCS +// store_len = (long) sizeof(pc_record_type); +// for (i = 0; i < 6; i++) { +// len = store_len; +// pc_ptr = (char *) &ADVEN[i]; +// if ((error = FSRead(file_id, &len, (char *) pc_ptr)) != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// for (count = 0; count < store_len; count++) +// pc_ptr[count] ^= 0x6B; +// } +// +// if (in_scen == TRUE) { +// // LOAD OUTDOOR MAP +// len = (long) sizeof(out_info_type); +// if ((error = FSRead(file_id, &len, (char *) out_e)) != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// +// // LOAD TOWN +// if (town_restore == TRUE) { +// len = (long) sizeof(current_town_type); +// if ((error = FSRead(file_id, &len, (char *) &c_town)) != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// +// len = (long) sizeof(big_tr_type); +// if ((error = FSRead(file_id, &len, (char *) &t_d)) != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// +// len = (long) sizeof(town_item_list); +// if ((error = FSRead(file_id, &len, (char *) &t_i)) != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// +// } +// +// // LOAD STORED ITEMS +// for (i = 0; i < 3; i++) { +// len = (long) sizeof(stored_items_list_type); +// if ((error = FSRead(file_id, &len, (char *) &stored_items[i])) != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// } +// +// // LOAD SAVED MAPS +// if (maps_there == TRUE) { +// len = (long) sizeof(stored_town_maps_type); +// if ((error = FSRead(file_id, &len, (char *) &(town_maps))) != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// +// len = (long) sizeof(stored_outdoor_maps_type); +// if ((error = FSRead(file_id, &len, (char *) &o_maps)) != 0) { +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// } +// +// // 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; +// } +// if ((error = FSRead(file_id, &len, (char *) misc_i)) != 0){ +// FSClose(file_id); +// SysBeep(2); +// FCD(1064,0); +// return; +// } +// +// } // end if_scen +// +// if ((error = FSClose(file_id)) != 0){ +// add_string_to_buf("Load: Can't close file. "); +// SysBeep(2); +// return; +// } +// +// for (i = 0; i < 6; i++){ +// if (ADVEN[i].main_status > 0) { +// current_active_pc = i; +// i = 6; +// } +// } +// file_in_mem = TRUE; +// save_blocked = FALSE; +// party_in_scen = in_scen; +// +// if (ae_loading == FALSE) { +// /* not reached with Carbon */ +// /*strcpy ((char *) last_load_file, (char *) reply.fName);*/ +// } else { +// strcpy ((char *) last_load_file, (char *) file_to_load.name); +// store_file_reply = file_to_load; +// } +// +// //load item definitions +// if(party_in_scen){ +// if(!load_scen_item_defs(party.scen_name)){ +// load_base_item_defs(); +// scen_items_loaded = false; +// } +// else +// scen_items_loaded = true; +// } +// else{ +// load_base_item_defs(); +// scen_items_loaded = false; +// } +// update_item_menu(); +// +// redraw_screen(); +//} bool select_save_location(FSSpec* to_save_ptr){ if(to_save_ptr==NULL) @@ -441,215 +443,215 @@ bool select_save_location(FSSpec* to_save_ptr){ return(true); } -void save_file(FSSpec to_save) -{ - long file_size; - OSErr error; - - short file_id; - Boolean got_error = FALSE,in_scen = FALSE,town_save = FALSE,save_maps = FALSE; - FSRef fileRef; - - if ((error = FSpOpenDF(&to_save,3,&file_id)) != 0) { - printf("Save: Couldn't open file, error %i.\n",error); - add_string_to_buf("Save: Couldn't open file. "); - SysBeep(2); - return; - } - strcpy ((char *) last_load_file, (char *) to_save.name); - - short i,j; - - long len,store_len,count; - flag_type flag; - flag_type *store; - - char* party_encryptor; - char debug[60]; - - if (file_in_mem == FALSE) - return; - - if (save_blocked == TRUE) { - FCD(903,0); - return; - } - - if (store_flags[0] == 1342) - town_save = TRUE; - else - town_save = FALSE; - if (store_flags[1] == 100) - in_scen = TRUE; - else - in_scen = FALSE; - if (store_flags[2] == 5567) - save_maps = TRUE; - else - save_maps = FALSE; - - store = &flag; - - len = sizeof(flag_type); - - flag.i = store_flags[0]; - if ((error = FSWrite(file_id, &len, (char *) store)) != 0){ - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - } - flag.i = store_flags[1]; - if ((error = FSWrite(file_id, &len, (char *) store)) != 0) { - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - flag.i = store_flags[2]; - if ((error = FSWrite(file_id, &len, (char *) store)) != 0){ - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - - // SAVE PARTY - party_record_type* party_ptr = &party; - len = sizeof(party_record_type); - - store_len = len; - party_encryptor = (char *) party_ptr; - for (count = 0; count < store_len; count++) - party_encryptor[count] ^= 0x5C; - if ((error = FSWrite(file_id, &len, (char *) party_ptr)) != 0) { - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - for (count = 0; count < store_len; count++) - party_encryptor[count] ^= 0x5C; - SysBeep(2); - return; - } - for (count = 0; count < store_len; count++) - party_encryptor[count] ^= 0x5C; - - // SAVE SETUP - setup_save_type* setup_ptr = &setup_save; - len = sizeof(setup_save_type); - if ((error = FSWrite(file_id, &len, (char *) setup_ptr)) != 0){ - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - - // SAVE PCS - store_len = sizeof(pc_record_type); - for (i = 0; i < 6; i++) { - pc_record_type* pc_ptr = &adven[i]; - - len = store_len; - party_encryptor = (char *) pc_ptr; - for (count = 0; count < store_len; count++) - party_encryptor[count] ^= 0x6B; - if ((error = FSWrite(file_id, &len, (char *) pc_ptr)) != 0){ - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - for (count = 0; count < store_len; count++) - party_encryptor[count] ^= 0x6B; - SysBeep(2); - return; - } - for (count = 0; count < store_len; count++) - party_encryptor[count] ^= 0x6B; - } - - if (party_in_scen == TRUE) { - // SAVE OUT DATA - len = sizeof(out_info_type); - if ((error = FSWrite(file_id, &len, (char *) out_e)) != 0) { - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - if (town_save == TRUE) { - current_town_type* town_ptr = &c_town; - len = sizeof(current_town_type); - if ((error = FSWrite(file_id, &len, (char *) town_ptr)) != 0) { - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - big_tr_type* town_data_ptr = &t_d; - len = sizeof(big_tr_type); - if ((error = FSWrite(file_id, &len, (char *) town_data_ptr)) != 0) { - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - town_item_list* item_ptr = &t_i; - len = sizeof(town_item_list); - if ((error = FSWrite(file_id, &len, (char *) item_ptr)) != 0) { - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - } - // Save stored items - for (i = 0; i < 3; i++) { - stored_items_list_type* items_ptr = &stored_items[i]; - len = (long) sizeof(stored_items_list_type); - if ((error = FSWrite(file_id, &len, (char *) items_ptr)) != 0){ - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - } - // If saving maps, save maps - if (save_maps == TRUE) { - stored_town_maps_type* maps_ptr = &(town_maps); - len = (long) sizeof(stored_town_maps_type); - if ((error = FSWrite(file_id, &len, (char *) maps_ptr)) != 0){ - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - stored_outdoor_maps_type* o_maps_ptr = &o_maps; - len = (long) sizeof(stored_outdoor_maps_type); - if ((error = FSWrite(file_id, &len, (char *) o_maps_ptr)) != 0) { - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - } - // SAVE SFX and MISC_I - len = (long) (64 * 64); - if ((error = FSWrite(file_id, &len, (char *) sfx)) != 0){ - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - if ((error = FSWrite(file_id, &len, (char *) misc_i)) != 0){ - add_string_to_buf("Save: Couldn't write to file. "); - FSClose(file_id); - SysBeep(2); - return; - } - } - if ((error = FSClose(file_id)) != 0) { - add_string_to_buf("Save: Couldn't close file. "); - SysBeep(2); - return; - } - file_to_load = to_save; -} +//void save_file(FSSpec to_save) +//{ +// long file_size; +// OSErr error; +// +// short file_id; +// Boolean got_error = FALSE,in_scen = FALSE,town_save = FALSE,save_maps = FALSE; +// FSRef fileRef; +// +// if ((error = FSpOpenDF(&to_save,3,&file_id)) != 0) { +// printf("Save: Couldn't open file, error %i.\n",error); +// add_string_to_buf("Save: Couldn't open file. "); +// SysBeep(2); +// return; +// } +// strcpy ((char *) last_load_file, (char *) to_save.name); +// +// short i,j; +// +// long len,store_len,count; +// flag_type flag; +// flag_type *store; +// +// char* party_encryptor; +// char debug[60]; +// +// if (file_in_mem == FALSE) +// return; +// +// if (save_blocked == TRUE) { +// FCD(903,0); +// return; +// } +// +// if (store_flags[0] == 1342) +// town_save = TRUE; +// else +// town_save = FALSE; +// if (store_flags[1] == 100) +// in_scen = TRUE; +// else +// in_scen = FALSE; +// if (store_flags[2] == 5567) +// save_maps = TRUE; +// else +// save_maps = FALSE; +// +// store = &flag; +// +// len = sizeof(flag_type); +// +// flag.i = store_flags[0]; +// if ((error = FSWrite(file_id, &len, (char *) store)) != 0){ +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// } +// flag.i = store_flags[1]; +// if ((error = FSWrite(file_id, &len, (char *) store)) != 0) { +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// flag.i = store_flags[2]; +// if ((error = FSWrite(file_id, &len, (char *) store)) != 0){ +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// +// // SAVE PARTY +// party_record_type* party_ptr = &party; +// len = sizeof(party_record_type); +// +// store_len = len; +// party_encryptor = (char *) party_ptr; +// for (count = 0; count < store_len; count++) +// party_encryptor[count] ^= 0x5C; +// if ((error = FSWrite(file_id, &len, (char *) party_ptr)) != 0) { +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// for (count = 0; count < store_len; count++) +// party_encryptor[count] ^= 0x5C; +// SysBeep(2); +// return; +// } +// for (count = 0; count < store_len; count++) +// party_encryptor[count] ^= 0x5C; +// +// // SAVE SETUP +// setup_save_type* setup_ptr = &setup_save; +// len = sizeof(setup_save_type); +// if ((error = FSWrite(file_id, &len, (char *) setup_ptr)) != 0){ +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// +// // SAVE PCS +// store_len = sizeof(pc_record_type); +// for (i = 0; i < 6; i++) { +// pc_record_type* pc_ptr = &ADVEN[i]; +// +// len = store_len; +// party_encryptor = (char *) pc_ptr; +// for (count = 0; count < store_len; count++) +// party_encryptor[count] ^= 0x6B; +// if ((error = FSWrite(file_id, &len, (char *) pc_ptr)) != 0){ +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// for (count = 0; count < store_len; count++) +// party_encryptor[count] ^= 0x6B; +// SysBeep(2); +// return; +// } +// for (count = 0; count < store_len; count++) +// party_encryptor[count] ^= 0x6B; +// } +// +// if (party_in_scen == TRUE) { +// // SAVE OUT DATA +// len = sizeof(out_info_type); +// if ((error = FSWrite(file_id, &len, (char *) out_e)) != 0) { +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// if (town_save == TRUE) { +// current_town_type* town_ptr = &c_town; +// len = sizeof(current_town_type); +// if ((error = FSWrite(file_id, &len, (char *) town_ptr)) != 0) { +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// big_tr_type* town_data_ptr = &t_d; +// len = sizeof(big_tr_type); +// if ((error = FSWrite(file_id, &len, (char *) town_data_ptr)) != 0) { +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// town_item_list* item_ptr = &t_i; +// len = sizeof(town_item_list); +// if ((error = FSWrite(file_id, &len, (char *) item_ptr)) != 0) { +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// } +// // Save stored items +// for (i = 0; i < 3; i++) { +// stored_items_list_type* items_ptr = &stored_items[i]; +// len = (long) sizeof(stored_items_list_type); +// if ((error = FSWrite(file_id, &len, (char *) items_ptr)) != 0){ +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// } +// // If saving maps, save maps +// if (save_maps == TRUE) { +// stored_town_maps_type* maps_ptr = &(town_maps); +// len = (long) sizeof(stored_town_maps_type); +// if ((error = FSWrite(file_id, &len, (char *) maps_ptr)) != 0){ +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// stored_outdoor_maps_type* o_maps_ptr = &o_maps; +// len = (long) sizeof(stored_outdoor_maps_type); +// if ((error = FSWrite(file_id, &len, (char *) o_maps_ptr)) != 0) { +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// } +// // SAVE SFX and MISC_I +// len = (long) (64 * 64); +// if ((error = FSWrite(file_id, &len, (char *) sfx)) != 0){ +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// if ((error = FSWrite(file_id, &len, (char *) misc_i)) != 0){ +// add_string_to_buf("Save: Couldn't write to file. "); +// FSClose(file_id); +// SysBeep(2); +// return; +// } +// } +// if ((error = FSClose(file_id)) != 0) { +// add_string_to_buf("Save: Couldn't close file. "); +// SysBeep(2); +// return; +// } +// file_to_load = to_save; +//} void leave_town() { @@ -902,13 +904,13 @@ bool load_scen_item_defs(char scen_name[256]){ char cPath[768]; CFBundleRef mainBundle=CFBundleGetMainBundle(); CFURLRef progURL = CFBundleCopyBundleURL(mainBundle); - CFStringRef progPath = CFURLCopyFileSystemPath(progURL, kCFURLPOSIXPathStyle); + CFStringRef progDir = CFURLCopyFileSystemPath(progURL, kCFURLPOSIXPathStyle); CFRange findRes; - if(!CFStringFindWithOptions(progPath, CFSTR("/"), CFRangeMake(0, CFStringGetLength(progPath)), kCFCompareBackwards, &findRes)){ + if(!CFStringFindWithOptions(progDir, CFSTR("/"), CFRangeMake(0, CFStringGetLength(progDir)), kCFCompareBackwards, &findRes)){ printf("Error: Unable to find scenario directory\n"); return(false); } - CFStringRef scenPath = CFStringCreateWithFormat(NULL,NULL,CFSTR("%@/Blades of Exile Scenarios/%s"),CFStringCreateWithSubstring(NULL, progPath, CFRangeMake(0,findRes.location)),scen_name); + CFStringRef scenPath = CFStringCreateWithFormat(NULL,NULL,CFSTR("%@/Blades of Exile Scenarios/%s"),CFStringCreateWithSubstring(NULL, progDir, CFRangeMake(0,findRes.location)),scen_name); CFStringGetCString(scenPath, cPath, 768, kCFStringEncodingUTF8); FSRef scenRef; FSPathMakeRef((UInt8*)cPath, &scenRef, false); diff --git a/osx/Blades of Exile Char Editor/pc.fileio.h b/osx/Blades of Exile Char Editor/pc.fileio.h index 86c9dd7d..1dae92f7 100644 --- a/osx/Blades of Exile Char Editor/pc.fileio.h +++ b/osx/Blades of Exile Char Editor/pc.fileio.h @@ -1,10 +1,10 @@ bool select_save_location(FSSpec* to_save_ptr); -void save_file(FSSpec to_save); -void load_file(); +//void save_file(FSSpec to_save); +//void load_file(); void leave_town(); long do_waterfall(long flag); short init_data(short flag); -long open_pref_file(); -void make_pref_file(FSSpec pref); -void save_prefs(); +//long open_pref_file(); +//void make_pref_file(FSSpec pref); +//void save_prefs(); void remove_party_from_scen(); diff --git a/osx/Blades of Exile Char Editor/pc.global.h b/osx/Blades of Exile Char Editor/pc.global.h index db8d6b07..421206a7 100644 --- a/osx/Blades of Exile Char Editor/pc.global.h +++ b/osx/Blades of Exile Char Editor/pc.global.h @@ -30,7 +30,8 @@ #define TEXT_WIN_UL_Y 283 #define NUM_BUTTONS 15 #define ASB add_string_to_buf -#define PSD party.stuff_done +#define PSD univ.party.stuff_done +#define ADVEN univ.party.adven #define DES display_enc_string #define D2ES display_2_enc_string @@ -49,385 +50,385 @@ #define printFlag() printf("%s %i\n",__FILE__,__LINE__) -typedef struct { - char x,y; - } location; -typedef struct { - short x,y;} shortloc; +//typedef struct { +// char x,y; +// } location; +//typedef struct { +// short x,y;} shortloc; -typedef struct { - short type,sd1,sd2,pic,m1,m2,ex1a,ex1b,ex2a,ex2b,jumpto; - } special_node_type; +//typedef struct { +// short type,sd1,sd2,pic,m1,m2,ex1a,ex1b,ex2a,ex2b,jumpto; +// } special_node_type; -typedef struct { - short personality,type; - char link1[4],link2[4]; - short extras[4]; - } talking_node_type; +//typedef struct { +// short personality,type; +// char link1[4],link2[4]; +// short extras[4]; +// } talking_node_type; -typedef struct { - unsigned char strlens[200]; - talking_node_type talk_nodes[60]; - } talking_record_type; +//typedef struct { +// unsigned char strlens[200]; +// talking_node_type talk_nodes[60]; +// } talking_record_type; -typedef struct { - short picture; - unsigned char blockage,flag1,flag2,special,trans_to_what,fly_over,boat_over; - unsigned char block_horse,light_radius,step_sound,shortcut_key,res1,res2,res3; - } terrain_type_type; +//typedef struct { +// short picture; +// unsigned char blockage,flag1,flag2,special,trans_to_what,fly_over,boat_over; +// unsigned char block_horse,light_radius,step_sound,shortcut_key,res1,res2,res3; +// } terrain_type_type; -typedef struct { - unsigned char monst[4]; - } wandering_type; +//typedef struct { +// unsigned char monst[4]; +// } wandering_type; -typedef struct { - unsigned char monst[7]; - unsigned char friendly[3]; - short spec_on_meet,spec_on_win,spec_on_flee,cant_flee; - short end_spec1,end_spec2; -} out_wandering_type; +//typedef struct { +// unsigned char monst[7]; +// unsigned char friendly[3]; +// short spec_on_meet,spec_on_win,spec_on_flee,cant_flee; +// short end_spec1,end_spec2; +//} out_wandering_type; -typedef struct { - unsigned char terrain[48][48]; - location special_locs[18]; - unsigned char special_id[18]; - location exit_locs[8]; - char exit_dests[8]; - location sign_locs[8]; - out_wandering_type wandering[4],special_enc[4]; - location wandering_locs[4]; - Rect info_rect[8]; - unsigned char strlens[180]; - special_node_type specials[60]; - } outdoor_record_type; +//typedef struct { +// unsigned char terrain[48][48]; +// location special_locs[18]; +// unsigned char special_id[18]; +// location exit_locs[8]; +// char exit_dests[8]; +// location sign_locs[8]; +// out_wandering_type wandering[4],special_enc[4]; +// location wandering_locs[4]; +// Rect info_rect[8]; +// unsigned char strlens[180]; +// special_node_type specials[60]; +// } outdoor_record_type; -typedef struct { - unsigned char number; - unsigned char start_attitude; - location start_loc; - unsigned char mobile; - unsigned char time_flag; - unsigned char extra1,extra2; - short spec1, spec2; - char spec_enc_code,time_code; - short monster_time,personality; - short special_on_kill,facial_pic; +//typedef struct { +// unsigned char number; +// unsigned char start_attitude; +// location start_loc; +// unsigned char mobile; +// unsigned char time_flag; +// unsigned char extra1,extra2; +// short spec1, spec2; +// char spec_enc_code,time_code; +// short monster_time,personality; +// short special_on_kill,facial_pic; +// +// } creature_start_type; + + +//typedef struct { +// short variety, item_level; +// char awkward, bonus, protection, charges, type; +// unsigned char graphic_num,ability, type_flag, is_special; +// short value; +// Boolean identified, magic; +// unsigned char weight, description_flag; +// char full_name[25], name[15]; +// unsigned char reserved1,reserved2; +// unsigned char magic_use_type, ability_strength, treas_class, real_abil; +// +//} short_item_record_type; + + +//typedef struct { +// short variety, item_level; +// char awkward, bonus, protection, charges, type, magic_use_type; +// unsigned char graphic_num,ability, ability_strength,type_flag, is_special; +// short value; +// unsigned char weight, special_class; +// location item_loc; +// char full_name[25], name[15]; +// unsigned char treas_class,item_properties,reserved1,reserved2; +//} item_record_type; + +//typedef struct { +// location item_loc; +// short item_code,ability; +// unsigned char charges,always_there,property,contained; +// } preset_item_type; - } creature_start_type; - - -typedef struct { - short variety, item_level; - char awkward, bonus, protection, charges, type; - unsigned char graphic_num,ability, type_flag, is_special; - short value; - Boolean identified, magic; - unsigned char weight, description_flag; - char full_name[25], name[15]; - unsigned char reserved1,reserved2; - unsigned char magic_use_type, ability_strength, treas_class, real_abil; +//typedef struct { +// location field_loc; +// short field_type; +// } preset_field_type; -} short_item_record_type; +//typedef struct { +// short town_chop_time,town_chop_key; +// wandering_type wandering[4]; +// location wandering_locs[4]; +// location special_locs[50]; +// unsigned char spec_id[50]; +// location sign_locs[15]; +// short lighting; +// location start_locs[4]; +// location exit_locs[4]; +// short exit_specs[4]; +// Rect in_town_rect; +// preset_item_type preset_items[64]; +// short max_num_monst; +// preset_field_type preset_fields[50]; +// short spec_on_entry,spec_on_entry_if_dead; +// short timer_spec_times[8]; +// short timer_specs[8]; +// unsigned char strlens[180]; +// special_node_type specials[100]; +// unsigned char specials1,specials2,res1,res2; +// short difficulty; +// } town_record_type; -typedef struct { - short variety, item_level; - char awkward, bonus, protection, charges, type, magic_use_type; - unsigned char graphic_num,ability, ability_strength,type_flag, is_special; - short value; - unsigned char weight, special_class; - location item_loc; - char full_name[25], name[15]; - unsigned char treas_class,item_properties,reserved1,reserved2; -} item_record_type; -typedef struct { - location item_loc; - short item_code,ability; - unsigned char charges,always_there,property,contained; - } preset_item_type; +//typedef struct { +// unsigned char terrain[64][64]; +// Rect room_rect[16]; +// creature_start_type creatures[60]; +// unsigned char lighting[8][64]; +// } big_tr_type; + +//typedef struct { +// unsigned char terrain[48][48]; +// Rect room_rect[16]; +// creature_start_type creatures[40]; +// unsigned char lighting[6][48]; +// } ave_tr_type; -typedef struct { - location field_loc; - short field_type; - } preset_field_type; +//typedef struct { +// unsigned char terrain[32][32]; +// Rect room_rect[16]; +// creature_start_type creatures[30]; +// unsigned char lighting[4][32]; +// } tiny_tr_type; + +//typedef struct { +// short block_type; +// short block_destroy_time; +// char block_alignment; +// char block_key_time; +// location block_loc; +// } city_block_type; -typedef struct { - short town_chop_time,town_chop_key; - wandering_type wandering[4]; - location wandering_locs[4]; - location special_locs[50]; - unsigned char spec_id[50]; - location sign_locs[15]; - short lighting; - location start_locs[4]; - location exit_locs[4]; - short exit_specs[4]; - Rect in_town_rect; - preset_item_type preset_items[64]; - short max_num_monst; - preset_field_type preset_fields[50]; - short spec_on_entry,spec_on_entry_if_dead; - short timer_spec_times[8]; - short timer_specs[8]; - unsigned char strlens[180]; - special_node_type specials[100]; - unsigned char specials1,specials2,res1,res2; - short difficulty; - } town_record_type; - - - -typedef struct { - unsigned char terrain[64][64]; - Rect room_rect[16]; - creature_start_type creatures[60]; - unsigned char lighting[8][64]; - } big_tr_type; - -typedef struct { - unsigned char terrain[48][48]; - Rect room_rect[16]; - creature_start_type creatures[40]; - unsigned char lighting[6][48]; - } ave_tr_type; +//typedef struct { +// Rect what_rect; +// unsigned char ter_type; +// unsigned char hollow; +// } city_ter_rect_type; -typedef struct { - unsigned char terrain[32][32]; - Rect room_rect[16]; - creature_start_type creatures[30]; - unsigned char lighting[4][32]; - } tiny_tr_type; +//typedef struct { +// creature_start_type creatures[30]; +// city_block_type city_block[15]; +// city_ter_rect_type city_ter_rect[10]; +// } template_town_type; -typedef struct { - short block_type; - short block_destroy_time; - char block_alignment; - char block_key_time; - location block_loc; - } city_block_type; - -typedef struct { - Rect what_rect; - unsigned char ter_type; - unsigned char hollow; - } city_ter_rect_type; - -typedef struct { - creature_start_type creatures[30]; - city_block_type city_block[15]; - city_ter_rect_type city_ter_rect[10]; - } template_town_type; +//typedef struct { +// item_record_type scen_items[400]; +// char monst_names[256][20]; +// char ter_names[256][30]; +// } scen_item_data_type; -typedef struct { - item_record_type scen_items[400]; - char monst_names[256][20]; - char ter_names[256][30]; - } scen_item_data_type; +//typedef struct { +// short ter_type,item_num[10],item_odds[10],property; +// } item_storage_shortcut_type; -typedef struct { - short ter_type,item_num[10],item_odds[10],property; - } item_storage_shortcut_type; - -typedef struct { - unsigned char m_num,level,m_name[26]; - short health,m_health,mp,max_mp; - unsigned char armor,skill; - short a[3]; - unsigned char a1_type,a23_type,m_type,speed,ap,mu,cl,breath,breath_type,treasure,spec_skill,poison; - short morale,m_morale; - short corpse_item,corpse_item_chance; - short status[15]; - unsigned char direction,immunities,x_width,y_width,radiate_1,radiate_2; - unsigned char default_attitude,summon_type,default_facial_pic,res1,res2,res3; - short picture_num; +//typedef struct { +// unsigned char m_num,level,m_name[26]; +// short health,m_health,mp,max_mp; +// unsigned char armor,skill; +// short a[3]; +// unsigned char a1_type,a23_type,m_type,speed,ap,mu,cl,breath,breath_type,treasure,spec_skill,poison; +// short morale,m_morale; +// short corpse_item,corpse_item_chance; +// short status[15]; +// unsigned char direction,immunities,x_width,y_width,radiate_1,radiate_2; +// unsigned char default_attitude,summon_type,default_facial_pic,res1,res2,res3; +// short picture_num; +// +// } monster_record_type; - } monster_record_type; - -typedef struct { - short active,attitude; - unsigned char number; - location m_loc; - monster_record_type m_d; - Boolean mobile; - short summoned; - creature_start_type monst_start; - } creature_data_type; +//typedef struct { +// short active,attitude; +// unsigned char number; +// location m_loc; +// monster_record_type m_d; +// Boolean mobile; +// short summoned; +// creature_start_type monst_start; +// } creature_data_type; -typedef struct { - location horse_loc,horse_loc_in_sec,horse_sector; - short which_town; - Boolean exists,property; - } horse_record_type; -typedef struct { - location boat_loc,boat_loc_in_sec,boat_sector; - short which_town; - Boolean exists,property; -} boat_record_type; +//typedef struct { +// location horse_loc,horse_loc_in_sec,horse_sector; +// short which_town; +// Boolean exists,property; +// } horse_record_type; +//typedef struct { +// location boat_loc,boat_loc_in_sec,boat_sector; +// short which_town; +// Boolean exists,property; +//} boat_record_type; -typedef struct { - unsigned char flag1, flag2, flag3, flag4; - unsigned char ver[3],min_run_ver,prog_make_ver[3],num_towns; - unsigned char out_width,out_height,difficulty,intro_pic,default_ground; - } scen_header_type; +//typedef struct { +// unsigned char flag1, flag2, flag3, flag4; +// unsigned char ver[3],min_run_ver,prog_make_ver[3],num_towns; +// unsigned char out_width,out_height,difficulty,intro_pic,default_ground; +// } scen_header_type; - typedef struct { - unsigned char flag1, flag2, flag3, flag4; - unsigned char ver[3],min_run_ver,prog_make_ver[3],num_towns; - unsigned char out_width,out_height,difficulty,intro_pic,default_ground; - unsigned char town_size[200]; - unsigned char town_hidden[200]; - short flag_a; - short intro_mess_pic,intro_mess_len; - location where_start,out_sec_start,out_start; - short which_town_start; - short flag_b; - short town_data_size[200][5]; - short town_to_add_to[10]; - short flag_to_add_to_town[10][2]; - short flag_c; - short out_data_size[100][2]; - Rect store_item_rects[3]; - short store_item_towns[3]; - short flag_e; - short special_items[50]; - short special_item_special[50]; - short rating,uses_custom_graphics; - short flag_f; - monster_record_type scen_monsters[256]; - boat_record_type scen_boats[30]; - horse_record_type scen_horses[30]; - short flag_g; - terrain_type_type ter_types[256]; - short scenario_timer_times[20]; - short scenario_timer_specs[20]; - short flag_h; - special_node_type scen_specials[256]; - item_storage_shortcut_type storage_shortcuts[10]; - short flag_d; - unsigned char scen_str_len[300]; - short flag_i; - location last_out_edited; - short last_town_edited; - - } scenario_data_type; +// typedef struct { +// unsigned char flag1, flag2, flag3, flag4; +// unsigned char ver[3],min_run_ver,prog_make_ver[3],num_towns; +// unsigned char out_width,out_height,difficulty,intro_pic,default_ground; +// unsigned char town_size[200]; +// unsigned char town_hidden[200]; +// short flag_a; +// short intro_mess_pic,intro_mess_len; +// location where_start,out_sec_start,out_start; +// short which_town_start; +// short flag_b; +// short town_data_size[200][5]; +// short town_to_add_to[10]; +// short flag_to_add_to_town[10][2]; +// short flag_c; +// short out_data_size[100][2]; +// Rect store_item_rects[3]; +// short store_item_towns[3]; +// short flag_e; +// short special_items[50]; +// short special_item_special[50]; +// short rating,uses_custom_graphics; +// short flag_f; +// monster_record_type scen_monsters[256]; +// boat_record_type scen_boats[30]; +// horse_record_type scen_horses[30]; +// short flag_g; +// terrain_type_type ter_types[256]; +// short scenario_timer_times[20]; +// short scenario_timer_specs[20]; +// short flag_h; +// special_node_type scen_specials[256]; +// item_storage_shortcut_type storage_shortcuts[10]; +// short flag_d; +// unsigned char scen_str_len[300]; +// short flag_i; +// location last_out_edited; +// short last_town_edited; +// +// } scenario_data_type; // for game -typedef struct { - short personality; - short town_num; - short str1,str2; - } talk_save_type; +//typedef struct { +// short personality; +// short town_num; +// short str1,str2; +// } talk_save_type; -typedef struct { - creature_data_type dudes[60]; - short which_town; - short friendly; - } creature_list_type; +//typedef struct { +// creature_data_type dudes[60]; +// short which_town; +// short friendly; +// } creature_list_type; -typedef struct { - short town_num, difficulty; - town_record_type town; - char explored[64][64]; - Boolean hostile; - creature_list_type monst; - Boolean in_boat; - location p_loc; - } current_town_type; +//typedef struct { +// short town_num, difficulty; +// town_record_type town; +// char explored[64][64]; +// Boolean hostile; +// creature_list_type monst; +// Boolean in_boat; +// location p_loc; +// } current_town_type; -typedef struct { - Boolean exists; - short direction; - out_wandering_type what_monst; - location which_sector,m_loc; - } outdoor_creature_type; +//typedef struct { +// Boolean exists; +// short direction; +// out_wandering_type what_monst; +// location which_sector,m_loc; +// } outdoor_creature_type; -typedef struct { - long age; - short gold,food; - unsigned char stuff_done[310][10],item_taken[200][8]; - short light_level; - location outdoor_corner,i_w_c,p_loc,loc_in_sec; - boat_record_type boats[30]; - horse_record_type horses[30]; - creature_list_type creature_save[4]; - short in_boat,in_horse; - outdoor_creature_type out_c[10]; - item_record_type magic_store_items[5][10]; - short imprisoned_monst[4]; - char m_seen[256]; - char journal_str[50]; - short journal_day[50]; - short special_notes_str[140][2]; - talk_save_type talk_save[120]; - short direction,at_which_save_slot; - char alchemy[20]; - Boolean can_find_town[200]; - short key_times[100]; - short party_event_timers[30]; - short global_or_town[30]; - short node_to_call[30]; - char spec_items[50],help_received[120]; - short m_killed[200]; - long total_m_killed,total_dam_done,total_xp_gained,total_dam_taken; - char scen_name[256]; - } party_record_type; +//typedef struct { +// long age; +// short gold,food; +// unsigned char stuff_done[310][10],item_taken[200][8]; +// short light_level; +// location outdoor_corner,i_w_c,p_loc,loc_in_sec; +// boat_record_type boats[30]; +// horse_record_type horses[30]; +// creature_list_type creature_save[4]; +// short in_boat,in_horse; +// outdoor_creature_type out_c[10]; +// item_record_type magic_store_items[5][10]; +// short imprisoned_monst[4]; +// char m_seen[256]; +// char journal_str[50]; +// short journal_day[50]; +// short special_notes_str[140][2]; +// talk_save_type talk_save[120]; +// short direction,at_which_save_slot; +// char alchemy[20]; +// Boolean can_find_town[200]; +// short key_times[100]; +// short party_event_timers[30]; +// short global_or_town[30]; +// short node_to_call[30]; +// char spec_items[50],help_received[120]; +// short m_killed[200]; +// long total_m_killed,total_dam_done,total_xp_gained,total_dam_taken; +// char scen_name[256]; +// } party_record_type; -typedef struct { - char town_maps[200][8][64]; - } stored_town_maps_type; -typedef struct { - char town_strs[180][256]; - //char out_strs[120][256]; - char scen_strs[270][256]; - char talk_strs[170][256]; - char scen_header_strs[25][3][80]; - Str255 scen_names[25]; - scen_item_data_type scen_item_list; - stored_town_maps_type town_maps; - } piles_of_stuff_dumping_type; -typedef struct { - char out_strs[9][256]; - } outdoor_strs_type; -typedef struct { - short main_status; - char name[20]; - short skills[30]; - short max_health,cur_health,max_sp,cur_sp,experience,skill_pts,level; - short status[15]; - item_record_type items[24]; - Boolean equip[24]; - Boolean priest_spells[62],mage_spells[62]; - short which_graphic,weap_poisoned; - Boolean advan[15],traits[15]; - short race,exp_adj,direction; - } pc_record_type; +//typedef struct { +// char town_maps[200][8][64]; +// } stored_town_maps_type; +//typedef struct { +// char town_strs[180][256]; +// //char out_strs[120][256]; +// char scen_strs[270][256]; +// char talk_strs[170][256]; +// char scen_header_strs[25][3][80]; +// Str255 scen_names[25]; +// scen_item_data_type scen_item_list; +// stored_town_maps_type town_maps; +// } piles_of_stuff_dumping_type; +//typedef struct { +// char out_strs[9][256]; +// } outdoor_strs_type; +//typedef struct { +// short main_status; +// char name[20]; +// short skills[30]; +// short max_health,cur_health,max_sp,cur_sp,experience,skill_pts,level; +// short status[15]; +// item_record_type items[24]; +// Boolean equip[24]; +// Boolean priest_spells[62],mage_spells[62]; +// short which_graphic,weap_poisoned; +// Boolean advan[15],traits[15]; +// short race,exp_adj,direction; +// } pc_record_type; -typedef struct { - unsigned char setup[4][64][64]; - } setup_save_type; +//typedef struct { +// unsigned char setup[4][64][64]; +// } setup_save_type; -typedef struct { - item_record_type items[NUM_TOWN_ITEMS]; - } town_item_list; +//typedef struct { +// item_record_type items[NUM_TOWN_ITEMS]; +// } town_item_list; -typedef struct {short i;} flag_type; +//typedef struct {short i;} flag_type; typedef struct {unsigned char pattern[9][9];} effect_pat_type; -typedef struct { - item_record_type items[NUM_TOWN_ITEMS]; - } stored_items_list_type; +//typedef struct { +// item_record_type items[NUM_TOWN_ITEMS]; +// } stored_items_list_type; -typedef struct { - char outdoor_maps[100][6][48]; - } stored_outdoor_maps_type; +//typedef struct { +// char outdoor_maps[100][6][48]; +// } stored_outdoor_maps_type; typedef struct { long l[10]; diff --git a/osx/Blades of Exile Char Editor/pc.graphics.cpp b/osx/Blades of Exile Char Editor/pc.graphics.cpp index 565d04ad..d1c422c1 100644 --- a/osx/Blades of Exile Char Editor/pc.graphics.cpp +++ b/osx/Blades of Exile Char Editor/pc.graphics.cpp @@ -2,6 +2,7 @@ #include #include #include "pc.global.h" +#include "classes.h" #include "pc.graphics.h" #include "pc.editors.h" #include "pc.action.h" @@ -9,19 +10,21 @@ #include "graphtool.h" #include "dlgtool.h" #include "dlglowlevel.h" +#include "dlgutil.h" /* Adventure globals */ -extern party_record_type party; -extern pc_record_type adven[6]; -extern outdoor_record_type outdoors[2][2]; -extern current_town_type c_town; -extern big_tr_type t_d; -extern town_item_list t_i; -extern unsigned char out[96][96],out_e[96][96]; -extern setup_save_type setup_save; -extern stored_items_list_type stored_items[3]; -extern stored_town_maps_type maps; -extern stored_outdoor_maps_type o_maps; +//extern party_record_type party; +//extern pc_record_type ADVEN[6]; +//extern outdoor_record_type outdoors[2][2]; +//extern current_town_type c_town; +//extern big_tr_type t_d; +//extern town_item_list t_i; +//extern unsigned char out[96][96],out_e[96][96]; +//extern setup_save_type setup_save; +//extern stored_items_list_type stored_items[3]; +//extern stored_town_maps_type maps; +//extern stored_outdoor_maps_type o_maps; +extern cUniverse univ; extern WindowPtr mainPtr; extern Boolean play_sounds,file_in_mem,party_in_scen,scen_items_loaded; @@ -29,10 +32,10 @@ extern Boolean play_sounds,file_in_mem,party_in_scen,scen_items_loaded; extern short store_flags[3]; extern GWorldPtr button_num_gworld; extern short current_active_pc; -extern Boolean ed_reg; +//extern Boolean ed_reg; -extern long register_flag,stored_key; -extern long ed_flag,ed_key; +//extern long register_flag,stored_key; +//extern long ed_flag,ed_key; GWorldPtr title_gworld,pc_gworld,dlogpics_gworld; GWorldPtr mixed_gworld,buttons_gworld; @@ -64,6 +67,7 @@ short store_page_on,store_num_i; Rect ed_buttons_from[2] = {{0,0,57,57},{0,57,57,114}}; short current_pressed_button = -1; Boolean init_once = FALSE; +GWorldPtr spec_scen_g; // not actually needed; just here to silence compiler because it's reference in fileio.h void init_dialogs(){ cd_init_dialogs(NULL,NULL,NULL,NULL,NULL,&dlogpics_gworld,NULL,NULL,NULL,NULL,NULL,NULL/*,NULL,NULL,NULL,NULL,NULL,NULL,NULL*/,NULL,NULL); @@ -353,7 +357,7 @@ void draw_main_screen() TextSize(10); TextFace(0); OffsetRect(&dest_rect,300,0); - char_win_draw_string(mainPtr,dest_rect,"Copyright 1997, Spiderweb Software, Inc.",0,10,true); + char_win_draw_string(mainPtr,dest_rect,"Created in 1997 by Spiderweb Software, Inc.",0,10,true); TextFace(bold); @@ -362,11 +366,6 @@ void draw_main_screen() reg_rect.top += 8; reg_rect.right -= 3; - - if (ed_reg == FALSE) { - sprintf((char *)temp_str,"Unregistered Copy |To find out how to order, |select How To Order from File Menu."); - win_draw_string(GetWindowPort(mainPtr),reg_rect,temp_str,0,12,true); - } } void do_button_action(short which_pc,short which_button) @@ -453,28 +452,28 @@ void draw_items(short clear_first) } // First, draw "Fred's Items:" - //sprintf((char *)to_draw,"%s items:",adven[current_active_pc].name); + //sprintf((char *)to_draw,"%s items:",ADVEN[current_active_pc].name); //TextSize(12); //ClipRect(&dest_rect); //win_draw_string(mainPtr,item_string_rects[0][0],to_draw,0,12); //undo_clip(); //TextSize(10); - if (adven[current_active_pc].main_status != 1){ + if (ADVEN[current_active_pc].main_status != 1){ frame_dlog_rect(GetWindowPort(mainPtr),pc_info_rect,1); // re draw entire frame frame_dlog_rect(GetWindowPort(mainPtr),info_area_rect,1); // draw the frame frame_dlog_rect(GetWindowPort(mainPtr),pc_race_rect,1); // draw the frame return; // If PC is dead, it has no items } for (i = 0; i < 24; i++) // Loop through items and draw each - if (adven[current_active_pc].items[i].variety > 0) { // i.e. does item exist + if (ADVEN[current_active_pc].items[i].variety > 0) { // i.e. does item exist sprintf((char *) to_draw, ""); - if (adven[current_active_pc].items[i].item_properties & 1 == 0) - sprintf((char *) to_draw, "%d. %s ",i + 1,adven[current_active_pc].items[i].name); - else if (adven[current_active_pc].items[i].charges > 0) - sprintf((char *) to_draw, "%d. %s (%d)",i + 1,adven[current_active_pc].items[i].full_name, - adven[current_active_pc].items[i].charges); - else sprintf((char *) to_draw, "%d. %s ",i + 1,adven[current_active_pc].items[i].full_name); + if (ADVEN[current_active_pc].items[i].item_properties & 1 == 0) + sprintf((char *) to_draw, "%d. %s ",i + 1,ADVEN[current_active_pc].items[i].name); + else if (ADVEN[current_active_pc].items[i].charges > 0) + sprintf((char *) to_draw, "%d. %s (%d)",i + 1,ADVEN[current_active_pc].items[i].full_name, + ADVEN[current_active_pc].items[i].charges); + else sprintf((char *) to_draw, "%d. %s ",i + 1,ADVEN[current_active_pc].items[i].full_name); //if (i % 2 == 0) // sprintf((char *) to_draw, "%d %d %d %d", @@ -507,7 +506,7 @@ void display_party(short mode,short clear_first) // lots of stuff is global. Like ... // Boolean file_in_mem // short current_active_pc - // pc_record_type adven[6] + // pc_record_type ADVEN[6] if (clear_first == 1) { // first erase what's already there for (i = 0; i < 6; i++) FillCRect(&pc_area_buttons[i][0],bg[12]); @@ -541,24 +540,24 @@ void display_party(short mode,short clear_first) rect_draw_some_item(buttons_gworld,from_rect,buttons_gworld,pc_area_buttons[i][0],0,1); ForeColor(blackColor); - // pc_record_type adven[6] is the records that contains chaarcters + // pc_record_type ADVEN[6] is the records that contains chaarcters // main_status determins 0 - not exist, 1 - alive, OK, 2 - dead, 3 - stoned, 4 - dust - if (adven[i].main_status != 0) { // PC exists? + if (ADVEN[i].main_status != 0) { // PC exists? from_rect = from_base; // draw PC graphic - OffsetRect(&from_rect,56 * (adven[i].which_graphic / 8),36 * (adven[i].which_graphic % 8)); + OffsetRect(&from_rect,56 * (ADVEN[i].which_graphic / 8),36 * (ADVEN[i].which_graphic % 8)); rect_draw_some_item(pc_gworld,from_rect,pc_gworld,pc_area_buttons[i][1],1,1); //frame_dlog_rect(GetWindowPort(mainPtr),pc_area_buttons[i][1],0); // draw name TextSize(9); - if( (strlen(adven[i].name)) >= 10) { + if( (strlen(ADVEN[i].name)) >= 10) { TextFace(0); - sprintf((char *) to_draw, "%-s ", (char *) adven[i].name); + sprintf((char *) to_draw, "%-s ", (char *) ADVEN[i].name); TextSize(6); } else { - sprintf((char *) to_draw, "%-s ", (char *) adven[i].name); + sprintf((char *) to_draw, "%-s ", (char *) ADVEN[i].name); } ForeColor(whiteColor); @@ -567,31 +566,31 @@ void display_party(short mode,short clear_first) TextSize(10); if (i == current_active_pc){ - sprintf((char *) to_draw, "%-.18s ", (char *) adven[i].name); - if( (strlen(adven[i].name)) > 12) + sprintf((char *) to_draw, "%-.18s ", (char *) ADVEN[i].name); + if( (strlen(ADVEN[i].name)) > 12) TextSize(8); ForeColor(blackColor); win_draw_string(GetWindowPort(mainPtr),name_rect,to_draw,1,10,true); TextSize(10); } if ((current_pressed_button < 0) || (current_pressed_button == i)) - switch (adven[i].main_status) { + switch (ADVEN[i].main_status) { // draw statistics case 1: if (i == current_active_pc) { //Draw in race - if (adven[i].race == 0) + if (ADVEN[i].race == 0) char_win_draw_string(mainPtr,pc_race_rect,"Human ",1,10,true); - if (adven[i].race == 1) + if (ADVEN[i].race == 1) char_win_draw_string(mainPtr,pc_race_rect,"Nephilim ",1,10,true); - if (adven[i].race == 2) + if (ADVEN[i].race == 2) char_win_draw_string(mainPtr,pc_race_rect,"Slithzerikai ",1,10,true); // Draw in skills sprintf((char *) to_draw, "Skills:"); win_draw_string(GetWindowPort(mainPtr),skill_rect,to_draw,0,10,true); - sprintf((char *) to_draw, "Hp: %d/%d Sp: %d/%d",adven[i].cur_health,adven[i].max_health,adven[i].cur_sp, - adven[i].max_sp); + sprintf((char *) to_draw, "Hp: %d/%d Sp: %d/%d",ADVEN[i].cur_health,ADVEN[i].max_health,ADVEN[i].cur_sp, + ADVEN[i].max_sp); win_draw_string(GetWindowPort(mainPtr),hp_sp_rect,to_draw,0,10,true); @@ -606,7 +605,7 @@ void display_party(short mode,short clear_first) get_str(to_draw,9,string_num); win_draw_string(GetWindowPort(mainPtr),pc_skills_rect[k],to_draw,0,9,true); - sprintf((char *) skill_value,"%d",adven[i].skills[k]); + sprintf((char *) skill_value,"%d",ADVEN[i].skills[k]); win_draw_string(GetWindowPort(mainPtr),temp_rect,skill_value,0,9,true); //frame_dlog_rect(GetWindowPort(mainPtr),pc_skills_rect[k],0); string_num+=2; @@ -623,82 +622,82 @@ void display_party(short mode,short clear_first) TextFace(0); //for(k = 0 ; k < 10; k++) //frame_dlog_rect(GetWindowPort(mainPtr),pc_status_rect[k],0); - if (adven[i].status[0] > 0) + if (ADVEN[i].status[0] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned Weap.",0,9,true); cur_rect++; } - if (adven[i].status[1] > 0) + if (ADVEN[i].status[1] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Blessed",0,9,true); cur_rect++; } - else if(adven[i].status[1] < 0) + else if(ADVEN[i].status[1] < 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Cursed",0,9,true); cur_rect++; } - if (adven[i].status[2] > 0) + if (ADVEN[i].status[2] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Poisoned",0,9,true); cur_rect++; } - if (adven[i].status[3] > 0) + if (ADVEN[i].status[3] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Hasted",0,9,true); cur_rect++; } - else if(adven[i].status[3] < 0) + else if(ADVEN[i].status[3] < 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Slowed",0,9,true); cur_rect++; } - if (adven[i].status[4] > 0) + if (ADVEN[i].status[4] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Invulnerable",0,9,true); cur_rect++; } - if (adven[i].status[5] > 0) + if (ADVEN[i].status[5] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Magic Resistant",0,9,true); cur_rect++; } - if (adven[i].status[6] > 0) + if (ADVEN[i].status[6] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Webbed",0,9,true); cur_rect++; } - if (adven[i].status[7] > 0) + if (ADVEN[i].status[7] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Diseased",0,9,true); cur_rect++; } - if (adven[i].status[8] > 0) + if (ADVEN[i].status[8] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Sanctury",0,9,true); cur_rect++; } - if (adven[i].status[9] > 0) + if (ADVEN[i].status[9] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Dumbfounded",0,9,true); cur_rect++; } - if (adven[i].status[10] > 0) + if (ADVEN[i].status[10] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Martyr's Shield",0,9,true); cur_rect++; } - if (adven[i].status[11] > 0) + if (ADVEN[i].status[11] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Asleep",0,9,true); cur_rect++; } - if (adven[i].status[12] > 0) + if (ADVEN[i].status[12] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Paralyzed",0,9,true); cur_rect++; } - if (adven[i].status[13] > 0) + if (ADVEN[i].status[13] > 0) if(cur_rect <= 9) { char_win_draw_string(mainPtr,pc_status_rect[cur_rect],"Acid",0,9,true); cur_rect++; @@ -715,78 +714,78 @@ void display_party(short mode,short clear_first) TextSize(9); TextFace(0); cur_rect=0; - if (adven[i].traits[0] == 1) + if (ADVEN[i].traits[0] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Toughness",0,9,true); cur_rect++; } - if (adven[i].traits[1] == 1) + if (ADVEN[i].traits[1] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Apt",0,9,true); cur_rect++; } - if (adven[i].traits[2] == 1) + if (ADVEN[i].traits[2] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Ambidextrous",0,9,true); cur_rect++; } - if (adven[i].traits[3] == 1) + if (ADVEN[i].traits[3] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Nimble Fingers",0,9,true); cur_rect++; } - if (adven[i].traits[4] == 1) + if (ADVEN[i].traits[4] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Cave Lore",0,9,true); cur_rect++; } - if (adven[i].traits[5] == 1) + if (ADVEN[i].traits[5] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Woodsman",0,9,true); cur_rect++; } - if (adven[i].traits[6] == 1) + if (ADVEN[i].traits[6] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Good Constitution",0,9,true); cur_rect++; } - if (adven[i].traits[7] == 1) + if (ADVEN[i].traits[7] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Highly Alert",0,9,true); cur_rect++; } - if (adven[i].traits[8] == 1) + if (ADVEN[i].traits[8] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Exceptional Str.",0,9,true); cur_rect++; } - if (adven[i].traits[9] == 1) + if (ADVEN[i].traits[9] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Recuperation",0,9,true); cur_rect++; } - if (adven[i].traits[10] == 1) + if (ADVEN[i].traits[10] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Sluggish",0,9,true); cur_rect++; } - if (adven[i].traits[11] == 1) + if (ADVEN[i].traits[11] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Magically Inept",0,9,true); cur_rect++; } - if (adven[i].traits[12] == 1) + if (ADVEN[i].traits[12] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Frail",0,9,true); cur_rect++; } - if (adven[i].traits[13] == 1) + if (ADVEN[i].traits[13] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Chronic Disease",0,9,true); cur_rect++; } - if (adven[i].traits[14] == 1) + if (ADVEN[i].traits[14] == 1) if(cur_rect <= 15) { char_win_draw_string(mainPtr,pc_traits_rect[cur_rect],"Bad Back",0,9,true); cur_rect++; @@ -1097,69 +1096,69 @@ void add_string_to_buf(char *str) { // SetPort(old_port); //} -void display_strings_event_filter (short item_hit) -{ - short i; - Boolean had1 = FALSE, had2 = FALSE; - - switch (item_hit) { - case 1: - toast_dialog(); - break; - } -} +//void display_strings_event_filter (short item_hit) +//{ +// short i; +// Boolean had1 = FALSE, had2 = FALSE; +// +// switch (item_hit) { +// case 1: +// toast_dialog(); +// break; +// } +//} void record_display_strings(){} -void display_strings(short str1a,short str1b,short str2a,short str2b, - char *title,short sound_num,short graphic_num,short graphic_type,short parent_num) -{ - short item_hit; - Str255 text; - location view_loc; - Boolean sound_done = FALSE; +//void display_strings(short str1a,short str1b,short str2a,short str2b, +// char *title,short sound_num,short graphic_num,short graphic_type,short parent_num) +//{ +// short item_hit; +// Str255 text; +// location view_loc; +// Boolean sound_done = FALSE; +// +// make_cursor_sword(); +// +// store_str1a = str1a; +// store_str1b = str1b; +// store_str2a = str2a; +// store_str2b = str2b; +// +// if ((str1a <= 0) || (str1b <= 0)) +// return; +// store_which_string_dlog = 970; +// if (strlen(title) > 0) +// store_which_string_dlog += 2; +// if ((str2a > 0) && (str2b > 0)) +// store_which_string_dlog++; +// cd_create_dialog_parent_num(store_which_string_dlog,parent_num); +// +// cd_activate_item(store_which_string_dlog,2,0); +// +// csp(store_which_string_dlog,store_which_string_dlog,graphic_num,graphic_type); +// +// get_str(text,str1a,str1b); +// csit(store_which_string_dlog,4,(char *) text); +// if ((str2a > 0) && (str2b > 0)) { +// get_str(text,str2a,str2b); +// csit(store_which_string_dlog,5,(char *) text); +// } +// if (strlen(title) > 0) +// csit(store_which_string_dlog,6,title); +// csp(store_which_string_dlog,3,graphic_num,graphic_type); +// if (sound_num >= 0) +// play_sound(sound_num); +// +// item_hit = cd_run_dialog(); +// cd_kill_dialog(store_which_string_dlog,0); +//} - make_cursor_sword(); - - store_str1a = str1a; - store_str1b = str1b; - store_str2a = str2a; - store_str2b = str2b; - - if ((str1a <= 0) || (str1b <= 0)) - return; - store_which_string_dlog = 970; - if (strlen(title) > 0) - store_which_string_dlog += 2; - if ((str2a > 0) && (str2b > 0)) - store_which_string_dlog++; - cd_create_dialog_parent_num(store_which_string_dlog,parent_num); - - cd_activate_item(store_which_string_dlog,2,0); - - csp(store_which_string_dlog,store_which_string_dlog,graphic_num,graphic_type); - - get_str(text,str1a,str1b); - csit(store_which_string_dlog,4,(char *) text); - if ((str2a > 0) && (str2b > 0)) { - get_str(text,str2a,str2b); - csit(store_which_string_dlog,5,(char *) text); - } - if (strlen(title) > 0) - csit(store_which_string_dlog,6,title); - csp(store_which_string_dlog,3,graphic_num,graphic_type); - if (sound_num >= 0) - play_sound(sound_num); - - item_hit = cd_run_dialog(); - cd_kill_dialog(store_which_string_dlog,0); -} - -void get_str(Str255 str,short i, short j) -{ - GetIndString(str, i, j); - p2cstr(str); -} +//void get_str(Str255 str,short i, short j) +//{ +// GetIndString(str, i, j); +// p2cstr(str); +//} void make_cursor_sword() { diff --git a/osx/Blades of Exile Char Editor/pc.graphics.h b/osx/Blades of Exile Char Editor/pc.graphics.h index f297e3cf..87829591 100644 --- a/osx/Blades of Exile Char Editor/pc.graphics.h +++ b/osx/Blades of Exile Char Editor/pc.graphics.h @@ -8,10 +8,9 @@ void draw_items(short clear_first); void display_party(short mode,short clear_first); void undo_clip(); void add_string_to_buf(char *str) ; -void display_strings_event_filter (short item_hit); -void display_strings(short str1a,short str1b,short str2a,short str2b, - char *title,short sound_num,short graphic_num,short graphic_type,short parent_num); -void get_str(Str255 str,short i, short j); +//void display_strings_event_filter (short item_hit); +//void display_strings(short str1a,short str1b,short str2a,short str2b, char *title,short sound_num,short graphic_num,short graphic_type,short parent_num); +//void get_str(Str255 str,short i, short j); short string_length(char *str); void make_cursor_sword(); void init_dialogs(); diff --git a/osx/Blades of Exile Char Editor/pc.main.cpp b/osx/Blades of Exile Char Editor/pc.main.cpp index 13547e9b..a327f5fa 100644 --- a/osx/Blades of Exile Char Editor/pc.main.cpp +++ b/osx/Blades of Exile Char Editor/pc.main.cpp @@ -1,8 +1,9 @@ //#include -#include +#include #include #include "pc.global.h" +#include "classes.h" #include "pc.graphics.h" #include "pc.editors.h" #include "pc.action.h" @@ -13,6 +14,9 @@ #include "graphtool.h" #include "boe.consts.h" #include "dlgutil.h" +#include "fileio.h" + +cUniverse univ; Rect pc_area_buttons[6][4] ; // 0 - whole 1 - pic 2 - name 3 - stat strs 4,5 - later Rect item_string_rects[24][4]; // 0 - name 1 - drop 2 - id 3 - @@ -30,7 +34,7 @@ Rect pc_race_rect; //Holds current pc's race Rect edit_rect[5][2]; //Buttons that bring up pc edit dialog boxs short current_active_pc = 0; -short dialog_answer; +//short dialog_answer; /* Mac stuff globals */ Rect windRect, Drag_Rect; @@ -45,27 +49,27 @@ Boolean party_in_scen = FALSE; Boolean scen_items_loaded = FALSE; /* Adventure globals */ -party_record_type party; -pc_record_type adven[6]; -outdoor_record_type outdoors[2][2]; -current_town_type c_town; -big_tr_type t_d; -town_item_list t_i; -unsigned char out[96][96],out_e[96][96]; -setup_save_type setup_save; -unsigned char misc_i[64][64],sfx[64][64]; -unsigned char template_terrain[64][64]; +//party_record_type party; +//pc_record_type ADVEN[6]; +//outdoor_record_type outdoors[2][2]; +//current_town_type c_town; +//big_tr_type t_d; +//town_item_list t_i; +//unsigned char out[96][96],out_e[96][96]; +//setup_save_type setup_save; +//unsigned char misc_i[64][64],sfx[64][64]; +//unsigned char template_terrain[64][64]; short store_flags[3]; extern short sword_curs; -town_record_type anim_town; -tiny_tr_type anim_t_d; +//town_record_type anim_town; +//tiny_tr_type anim_t_d; -stored_items_list_type stored_items[3]; -stored_town_maps_type maps; -stored_town_maps_type town_maps; -stored_outdoor_maps_type o_maps; +//stored_items_list_type stored_items[3]; +//stored_town_maps_type maps; +//stored_town_maps_type town_maps; +//stored_outdoor_maps_type o_maps; short old_depth = 16; extern FSSpec file_to_load; @@ -101,15 +105,17 @@ void set_up_apple_events(); void set_pixel_depth(); void restore_depth(); void handle_item_menu(int item_hit); -item_record_type convert_item (short_item_record_type s_item); - +//item_record_type convert_item (short_item_record_type s_item); +bool cur_scen_is_mac, mac_is_intel; +std::string progDir; // File io short specials_res_id; Str255 start_name; ResFileRefNum graphicsRef, soundRef, mainRef; //#include "pc.itemdata.h" -item_record_type item_list[400]; +cItemRec item_list[400]; +cScenario scenario; // // Main body of program Exile @@ -222,6 +228,22 @@ void Initialize(void) ExitToShell(); } + CFStringRef progURL = CFURLCopyFileSystemPath(CFBundleCopyBundleURL(mainBundle), kCFURLPOSIXPathStyle); + const char* tmp = CFStringGetCStringPtr(progURL, kCFStringEncodingASCII);//kCFStringEncodingUTF8); + if(tmp == NULL){ + bool success = CFStringGetCString(progURL, cPath, sizeof(cPath), kCFStringEncodingUTF8); + if(success) { + progDir = cPath; + std::cout << cPath << "\n\n" << progDir << "\n\n"; + } else { + std::cout << "Couldn't retrieve application path.\n"; + exit(1); + } + }else progDir = tmp; + //progDir = cPath; + size_t last_slash = progDir.find_last_of('/'); + progDir.erase(last_slash); + std::cout<= 10) - adven[i].main_status -= 10; + if (ADVEN[i].main_status >= 10) + ADVEN[i].main_status -= 10; break; case 6: display_strings(20,20,0,0,"Editing party",57,7,PICT_DLG,0); for (i = 0; i < 4; i++) - party.creature_save[i].which_town = 200; + univ.party.creature_save[i].which_town = 200; break; case 8: // damage display_strings(20,1,0,0,"Editing party",57,15,PICT_DLG,0); for (i = 0; i < 6; i++) - adven[i].cur_health = adven[i].max_health; + ADVEN[i].cur_health = ADVEN[i].max_health; break; case 9: // spell pts display_strings(20,2,0,0,"Editing party",57,15,PICT_DLG,0); for (i = 0; i < 6; i++) - adven[i].cur_sp = adven[i].max_sp; + ADVEN[i].cur_sp = ADVEN[i].max_sp; break; case 10: // raise dead display_strings(20,3,0,0,"Editing party",57,15,PICT_DLG,0); for (i = 0; i < 6; i++) - if ((adven[i].main_status == 2) || (adven[i].main_status == 3) || - (adven[i].main_status == 4)) - adven[i].main_status = 1; + if ((ADVEN[i].main_status == 2) || (ADVEN[i].main_status == 3) || + (ADVEN[i].main_status == 4)) + ADVEN[i].main_status = 1; break; case 11: // conditions display_strings(20,4,0,0,"Editing party",57,15,PICT_DLG,0); for (i = 0; i < 6; i++) { - adven[i].status[2] = 0; - if (adven[i].status[3] < 0) - adven[i].status[3] = 0; - adven[i].status[6] = 0; - adven[i].status[7] = 0; - adven[i].status[9] = 0; - adven[i].status[11] = 0; - adven[i].status[12] = 0; - adven[i].status[13] = 0; + ADVEN[i].status[2] = 0; + if (ADVEN[i].status[3] < 0) + ADVEN[i].status[3] = 0; + ADVEN[i].status[6] = 0; + ADVEN[i].status[7] = 0; + ADVEN[i].status[9] = 0; + ADVEN[i].status[11] = 0; + ADVEN[i].status[12] = 0; + ADVEN[i].status[13] = 0; } break; @@ -640,8 +665,8 @@ void handle_edit_menu(int item_hit) case 2: // all property display_strings(20,6,0,0,"Editing party",57,7,PICT_DLG,0); for (i = 0; i < 30; i++) { - party.boats[i].property = FALSE; - party.horses[i].property = FALSE; + univ.party.boats[i].property = FALSE; + univ.party.horses[i].property = FALSE; } break; case 4: // edit day @@ -656,7 +681,7 @@ void handle_edit_menu(int item_hit) for (i = 0; i < 100; i++) for (j = 0; j < 6; j++) for (k = 0; k < 48; k++) - o_maps.outdoor_maps[i][j][k] = 255; + univ.out.maps[i][j][k] = 255; break; case 7: // town maps if (party_in_scen == FALSE) { @@ -667,7 +692,7 @@ void handle_edit_menu(int item_hit) for (i = 0; i < 200; i++) for (j = 0; j < 8; j++) for (k = 0; k < 64; k++) - town_maps.town_maps[i][j][k] = 255; + univ.town.maps[i][j][k] = 255; break; case 9: display_pc(current_active_pc,0,0); @@ -676,73 +701,73 @@ void handle_edit_menu(int item_hit) display_pc(current_active_pc,1,0); break; case 11: - pick_race_abil(&adven[current_active_pc],0,0); + pick_race_abil(&ADVEN[current_active_pc],0,0); break; case 12: spend_xp(current_active_pc,1,0); break; case 13: - edit_xp(&adven[current_active_pc]); + edit_xp(&ADVEN[current_active_pc]); break; } } -item_record_type convert_item (short_item_record_type s_item) { - item_record_type i; - location l = {0,0}; - short temp_val; - - i.variety = (short) s_item.variety; - i.item_level = (short) s_item.item_level; - i.awkward = (short) s_item.awkward; - i.bonus = (short) s_item.bonus; - i.protection = (short) s_item.protection; - i.charges = (short) s_item.charges; - i.type = (short) s_item.type; - i.graphic_num = (short) s_item.graphic_num; - if (i.graphic_num >= 25) - i.graphic_num += 20; - i.ability = (short) s_item.real_abil; - i.type_flag = (short) s_item.type_flag; - i.is_special = (short) s_item.is_special; - i.value = (short) s_item.value; - i.weight = s_item.weight; - i.special_class = 0; - i.item_loc = l; - strcpy((char *)i.full_name,(char *)s_item.full_name); - strcpy((char *)i.name,(char *)s_item.name); - - if (i.charges > 0) - temp_val = i.value * i.charges; - else temp_val = i.value; - if (temp_val >= 15) - i.treas_class = 1; - if (temp_val >= 100) - i.treas_class = 2; - if (temp_val >= 900) - i.treas_class = 3; - if (temp_val >= 2400) - i.treas_class = 4; - - i.magic_use_type = s_item.magic_use_type; - i.ability_strength = s_item.ability_strength; - i.reserved1 = 0; - i.reserved2 = 0; - i.item_properties = 0; - if (s_item.identified == TRUE) - i.item_properties = i.item_properties | 1; - if ((s_item.ability == 14) || (s_item.ability == 129) || (s_item.ability == 95)) - i.item_properties = i.item_properties | 16; - if (s_item.magic == TRUE) - i.item_properties = i.item_properties | 4; - - return i; -} +//item_record_type convert_item (short_item_record_type s_item) { +// item_record_type i; +// location l = {0,0}; +// short temp_val; +// +// i.variety = (short) s_item.variety; +// i.item_level = (short) s_item.item_level; +// i.awkward = (short) s_item.awkward; +// i.bonus = (short) s_item.bonus; +// i.protection = (short) s_item.protection; +// i.charges = (short) s_item.charges; +// i.type = (short) s_item.type; +// i.graphic_num = (short) s_item.graphic_num; +// if (i.graphic_num >= 25) +// i.graphic_num += 20; +// i.ability = (short) s_item.real_abil; +// i.type_flag = (short) s_item.type_flag; +// i.is_special = (short) s_item.is_special; +// i.value = (short) s_item.value; +// i.weight = s_item.weight; +// i.special_class = 0; +// i.item_loc = l; +// strcpy((char *)i.full_name,(char *)s_item.full_name); +// strcpy((char *)i.name,(char *)s_item.name); +// +// if (i.charges > 0) +// temp_val = i.value * i.charges; +// else temp_val = i.value; +// if (temp_val >= 15) +// i.treas_class = 1; +// if (temp_val >= 100) +// i.treas_class = 2; +// if (temp_val >= 900) +// i.treas_class = 3; +// if (temp_val >= 2400) +// i.treas_class = 4; +// +// i.magic_use_type = s_item.magic_use_type; +// i.ability_strength = s_item.ability_strength; +// i.reserved1 = 0; +// i.reserved2 = 0; +// i.item_properties = 0; +// if (s_item.identified == TRUE) +// i.item_properties = i.item_properties | 1; +// if ((s_item.ability == 14) || (s_item.ability == 129) || (s_item.ability == 95)) +// i.item_properties = i.item_properties | 16; +// if (s_item.magic == TRUE) +// i.item_properties = i.item_properties | 4; +// +// return i; +//} void handle_item_menu(int item_hit) { short choice; - item_record_type store_i; + cItemRec store_i; if (file_in_mem == FALSE) { display_strings(20,5,0,0,"Editing party",57,7,PICT_DLG,0); @@ -918,7 +943,7 @@ Boolean verify_restore_quit(short mode) return FALSE; if (choice == 2) return TRUE; - save_file(file_to_load); + save_party(file_to_load); return TRUE; } diff --git a/osx/BoE.xcodeproj/project.pbxproj b/osx/BoE.xcodeproj/project.pbxproj index f2a89067..1b77dae8 100644 --- a/osx/BoE.xcodeproj/project.pbxproj +++ b/osx/BoE.xcodeproj/project.pbxproj @@ -97,6 +97,8 @@ 91AC620B0FA2853700EEAE67 /* creatlist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91AC620A0FA2853700EEAE67 /* creatlist.cpp */; }; 91AC620C0FA2853700EEAE67 /* creatlist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91AC620A0FA2853700EEAE67 /* creatlist.cpp */; }; 91AC620D0FA2853700EEAE67 /* creatlist.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91AC620A0FA2853700EEAE67 /* creatlist.cpp */; }; + 91AC65520FA3441B00EEAE67 /* universe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91AC61C50FA2729900EEAE67 /* universe.cpp */; }; + 91AC65AD0FA34AC600EEAE67 /* universe.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 91AC61C50FA2729900EEAE67 /* universe.cpp */; }; 91B3EF1E0F969C4B00BF5B67 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2BF04DE80BF7A6FE006C0831 /* Carbon.framework */; }; 91B3EF1F0F969C9C00BF5B67 /* BoECharEd.icns in Resources */ = {isa = PBXBuildFile; fileRef = 91B3EF110F969BD300BF5B67 /* BoECharEd.icns */; }; 91B3EF200F969C9C00BF5B67 /* bladespced.rsrc in Resources */ = {isa = PBXBuildFile; fileRef = 91B3EF120F969BD300BF5B67 /* bladespced.rsrc */; }; @@ -1014,6 +1016,7 @@ 91AC60820FA26A3B00EEAE67 /* regtown.cpp in Sources */, 91AC60AA0FA26C1B00EEAE67 /* tmpltown.cpp in Sources */, 91AC620D0FA2853700EEAE67 /* creatlist.cpp in Sources */, + 91AC65AD0FA34AC600EEAE67 /* universe.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1054,6 +1057,7 @@ 91AC60810FA26A3B00EEAE67 /* regtown.cpp in Sources */, 91AC60A90FA26C1B00EEAE67 /* tmpltown.cpp in Sources */, 91AC620C0FA2853700EEAE67 /* creatlist.cpp in Sources */, + 91AC65520FA3441B00EEAE67 /* universe.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1146,10 +1150,6 @@ 2BF04AC50BF518D4006C0831 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - ); COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1180,10 +1180,6 @@ 2BF04AC60BF518D4006C0831 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - ); COPY_PHASE_STRIP = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1267,7 +1263,6 @@ 91B3EF1B0F969C2300BF5B67 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ppc; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1298,7 +1293,6 @@ 91B3EF1C0F969C2300BF5B67 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ppc; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( @@ -1328,10 +1322,6 @@ 91B3EF420F969F0100BF5B67 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - ); CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)/Scenario Editor"; COPY_PHASE_STRIP = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -1367,10 +1357,6 @@ 91B3EF430F969F0100BF5B67 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = ( - i386, - ppc, - ); CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)/$(CONFIGURATION)/Scenario Editor"; COPY_PHASE_STRIP = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; diff --git a/osx/Scenario Editor/scen.actions.h b/osx/Scenario Editor/scen.actions.h index e46b480b..de0f598e 100644 --- a/osx/Scenario Editor/scen.actions.h +++ b/osx/Scenario Editor/scen.actions.h @@ -22,7 +22,7 @@ Boolean is_water(short i,short j); Boolean is_correctable_water(short i,short j); void shy_change_circle_terrain(location center,short radius,unsigned char terrain_type,short probability); void change_circle_terrain(location center,short radius,unsigned char terrain_type,short probability); -void change_rect_terrain(Rect r,unsigned char terrain_type,short probability,Boolean hollow); +void change_rect_terrain(rectangle r,unsigned char terrain_type,short probability,Boolean hollow); void swap_val(unsigned char *val,short a,short b); void change_val_4 (unsigned char *val,short a,short b,short c,short d); void change_val (unsigned char *val,short a,short b); diff --git a/osx/Scenario Editor/scen.fileio.cpp b/osx/Scenario Editor/scen.fileio.cpp index e2586615..84c08c34 100644 --- a/osx/Scenario Editor/scen.fileio.cpp +++ b/osx/Scenario Editor/scen.fileio.cpp @@ -39,7 +39,7 @@ long start_dir,data_dir; FSSpec temp_file_to_load; Str63 last_load_file = "\pBlades of Exile Scenario"; - +std::string progDir; Boolean cur_scen_is_mac = TRUE; ResFileRefNum mainRef, graphicsRef, soundRef; @@ -102,7 +102,23 @@ void init_directories() printf("Error! File Blades of Exile Sounds not found.\n"); ExitToShell(); } - + + CFStringRef progURL = CFURLCopyFileSystemPath(CFBundleCopyBundleURL(mainBundle), kCFURLPOSIXPathStyle); + const char* tmp = CFStringGetCStringPtr(progURL, kCFStringEncodingASCII);//kCFStringEncodingUTF8); + if(tmp == NULL){ + bool success = CFStringGetCString(progURL, cPath, sizeof(cPath), kCFStringEncodingUTF8); + if(success) { + progDir = cPath; + std::cout << cPath << "\n\n" << progDir << "\n\n"; + } else { + std::cout << "Couldn't retrieve application path.\n"; + exit(1); + } + }else progDir = tmp; + //progDir = cPath; + size_t last_slash = progDir.find_last_of('/'); + progDir.erase(last_slash); + std::cout<= temp_vers.num_towns) { - give_error("Oops ... the selected scenario doesn't have enough towns. The town you selected doesn't exist inside this scenario.","",0); - DisposePtr(buffer); FSClose(file_id); - return; - } - - len = (long) sizeof(legacy::scenario_data_type); - if ((error = FSRead(file_id, &len, buffer)) != 0){ - FSClose(file_id); oops_error(43); return; - } - temp_scenario = (legacy::scenario_data_type *) buffer; - - if (temp_scenario->town_size[which_town] != scenario.town_size[cur_town]) { - give_error("Oops ... the town in the selected scenario and the current town are different sizes. Import failed.","",0); - DisposePtr(buffer); FSClose(file_id); - return; - } - - -// // Now check password -// if (import_check_p(0) == FALSE) { -// import_user_given_password = enter_password(); -// if (import_check_p(import_user_given_password) == FALSE) { -// fancy_choice_dialog(868,0); -// if (overall_mode != 61) { -// import_user_given_password = enter_password(); -// if (import_check_p(import_user_given_password) == FALSE) -// ExitToShell(); + printf("Town import currently disabled.\n"); +// short i,j,k,l,file_id; +// Boolean file_ok = FALSE; +// OSErr error; +// long len,len_to_jump = 0,store; +// Size buf_len = 100000; +// char *buffer = NULL; +// short import_user_given_password; +// legacy::big_tr_type t_d; +// legacy::ave_tr_type ave_t; +// legacy::tiny_tr_type tiny_t; +// legacy::talking_record_type talking; +// legacy::scenario_data_type *temp_scenario; +// +// if ((error = FSpOpenDF(&temp_file_to_load,1,&file_id)) != 0) { +// oops_error(42); return; +// } +// +// buffer = new char[100000]; +// if (buffer == NULL) { +// oops_error(41); +// return; +// } +// scenario_header_flags temp_vers; +// len = (long) sizeof(scenario_header_flags); +// if ((error = FSRead(file_id, &len, &temp_vers)) != 0){ +// FSClose(file_id); oops_error(43); return; +// } +// +// if ((temp_vers.flag1 == 10) && (temp_vers.flag2 == 20) && +// (temp_vers.flag3 == 30) && (temp_vers.flag4 == 40)) { +// file_ok = TRUE; +// } +// if (file_ok == FALSE) { +// FSClose(file_id); give_error("This is not a legitimate Blades of Exile scenario.","",0); return; +// DisposePtr(buffer); FSClose(file_id); give_error("This is not a legitimate Blades of Exile scenario. If it is a scenario, note that it needs to have been saved by the Macintosh scenario editor.","",0); return; +// } +// if (which_town >= temp_vers.num_towns) { +// give_error("Oops ... the selected scenario doesn't have enough towns. The town you selected doesn't exist inside this scenario.","",0); +// DisposePtr(buffer); FSClose(file_id); +// return; +// } +// +// len = (long) sizeof(legacy::scenario_data_type); +// if ((error = FSRead(file_id, &len, buffer)) != 0){ +// FSClose(file_id); oops_error(43); return; +// } +// temp_scenario = (legacy::scenario_data_type *) buffer; +// +// if (temp_scenario->town_size[which_town] != scenario.town_size[cur_town]) { +// give_error("Oops ... the town in the selected scenario and the current town are different sizes. Import failed.","",0); +// DisposePtr(buffer); FSClose(file_id); +// return; +// } +// +// +//// // Now check password +//// if (import_check_p(0) == FALSE) { +//// import_user_given_password = enter_password(); +//// if (import_check_p(import_user_given_password) == FALSE) { +//// fancy_choice_dialog(868,0); +//// if (overall_mode != 61) { +//// import_user_given_password = enter_password(); +//// if (import_check_p(import_user_given_password) == FALSE) +//// ExitToShell(); +//// } +//// else return; +//// } +//// } +// +// len_to_jump = sizeof(legacy::scenario_data_type); +// len_to_jump += sizeof(scen_item_data_type); +// for (i = 0; i < 300; i++) +// len_to_jump += (long) temp_scenario->scen_str_len[i]; +// store = 0; +// for (i = 0; i < 100; i++) +// for (j = 0; j < 2; j++) +// store += (long) (temp_scenario->out_data_size[i][j]); +// for (i = 0; i < which_town; i++) +// for (j = 0; j < 5; j++) +// store += (long) (temp_scenario->town_data_size[i][j]); +// len_to_jump += store; +// error = SetFPos (file_id, 1, len_to_jump); +// if (error != 0) {FSClose(file_id);oops_error(44);} +// +// len = sizeof(legacy::town_record_type); +// error = FSRead(file_id, &len , (char *) &town); +// if (error != 0) {FSClose(file_id);oops_error(45);} +// +// switch (temp_scenario->town_size[which_town]) { +// case 0: +// len = sizeof(legacy::big_tr_type); +// FSRead(file_id, &len, (char *) &t_d); +// break; +// +// case 1: +// len = sizeof(legacy::ave_tr_type); +// FSRead(file_id, &len, (char *) &ave_t); +// for (i = 0; i < 48; i++) +// for (j = 0; j < 48; j++) { +// town->terrain(i,j) = ave_t.terrain[i][j]; +// town->lighting(i / 8,j) = ave_t.lighting[i / 8][j]; +// } +// for (i = 0; i < 16; i++) { +// town->room_rect(i) = ave_t.room_rect[i]; +// } +// for (i = 0; i < 40; i++) { +// //town->creatures(i) = ave_t.creatures[i]; +// } +// for (i = 40; i < 60; i++) { +// town->creatures(i).number = 0; +// } +// break; +// +// case 2: +// len = sizeof(legacy::tiny_tr_type); +// FSRead(file_id,&len , (char *) &tiny_t); +// for (i = 0; i < 32; i++) +// for (j = 0; j < 32; j++) { +// town->terrain(i,j) = tiny_t.terrain[i][j]; +// town->lighting(i / 8,j) = tiny_t.lighting[i / 8][j]; +// } +// for (i = 0; i < 16; i++) { +// town->room_rect(i) = tiny_t.room_rect[i]; // } -// else return; -// } +// for (i = 0; i < 30; i++) { +// //town->creatures(i) = tiny_t.creatures[i]; +// } +// for (i = 30; i < 60; i++) { +// town->creatures(i).number = 0; +// } +// break; // } - - len_to_jump = sizeof(legacy::scenario_data_type); - len_to_jump += sizeof(scen_item_data_type); - for (i = 0; i < 300; i++) - len_to_jump += (long) temp_scenario->scen_str_len[i]; - store = 0; - for (i = 0; i < 100; i++) - for (j = 0; j < 2; j++) - store += (long) (temp_scenario->out_data_size[i][j]); - for (i = 0; i < which_town; i++) - for (j = 0; j < 5; j++) - store += (long) (temp_scenario->town_data_size[i][j]); - len_to_jump += store; - error = SetFPos (file_id, 1, len_to_jump); - if (error != 0) {FSClose(file_id);oops_error(44);} - - len = sizeof(legacy::town_record_type); - error = FSRead(file_id, &len , (char *) &town); - if (error != 0) {FSClose(file_id);oops_error(45);} - - switch (temp_scenario->town_size[which_town]) { - case 0: - len = sizeof(legacy::big_tr_type); - FSRead(file_id, &len, (char *) &t_d); - break; - - case 1: - len = sizeof(legacy::ave_tr_type); - FSRead(file_id, &len, (char *) &ave_t); - for (i = 0; i < 48; i++) - for (j = 0; j < 48; j++) { - town->terrain(i,j) = ave_t.terrain[i][j]; - town->lighting(i / 8,j) = ave_t.lighting[i / 8][j]; - } - for (i = 0; i < 16; i++) { - town->room_rect(i) = ave_t.room_rect[i]; - } - for (i = 0; i < 40; i++) { - //town->creatures(i) = ave_t.creatures[i]; - } - for (i = 40; i < 60; i++) { - town->creatures(i).number = 0; - } - break; - - case 2: - len = sizeof(legacy::tiny_tr_type); - FSRead(file_id,&len , (char *) &tiny_t); - for (i = 0; i < 32; i++) - for (j = 0; j < 32; j++) { - town->terrain(i,j) = tiny_t.terrain[i][j]; - town->lighting(i / 8,j) = tiny_t.lighting[i / 8][j]; - } - for (i = 0; i < 16; i++) { - town->room_rect(i) = tiny_t.room_rect[i]; - } - for (i = 0; i < 30; i++) { - //town->creatures(i) = tiny_t.creatures[i]; - } - for (i = 30; i < 60; i++) { - town->creatures(i).number = 0; - } - break; - } - - for (i = 0; i < 140; i++) { - len = (long) (town->strlens[i]); - FSRead(file_id, &len, (char *) &(town->town_strs(i))); - town->town_strs(i)[len] = 0; - } - - len = sizeof(legacy::talking_record_type); - error = FSRead(file_id, &len , (char *) &talking); - if (error != 0) {FSClose(file_id);oops_error(46);} - - for (i = 0; i < 170; i++) { - len = (long) (talking.strlens[i]); - FSRead(file_id, &len, (char *) &(town->talking.talk_strs[i])); - town->talking.talk_strs[i][len] = 0; - } - - town->talking = talking; - error = FSClose(file_id); - if (error != 0) {FSClose(file_id);oops_error(47);} - DisposePtr(buffer); +// +// for (i = 0; i < 140; i++) { +// len = (long) (town->strlens[i]); +// FSRead(file_id, &len, (char *) &(town->town_strs(i))); +// town->town_strs(i)[len] = 0; +// } +// +// len = sizeof(legacy::talking_record_type); +// error = FSRead(file_id, &len , (char *) &talking); +// if (error != 0) {FSClose(file_id);oops_error(46);} +// +// for (i = 0; i < 170; i++) { +// len = (long) (talking.strlens[i]); +// FSRead(file_id, &len, (char *) &(town->talking.talk_strs[i])); +// town->talking.talk_strs[i][len] = 0; +// } +// +// town->talking = talking; +// error = FSClose(file_id); +// if (error != 0) {FSClose(file_id);oops_error(47);} +// DisposePtr(buffer); } // When this is called, the current town is the town to make town 0. diff --git a/osx/Scenario Editor/scen.main.cpp b/osx/Scenario Editor/scen.main.cpp index e9b34742..6e3a719f 100644 --- a/osx/Scenario Editor/scen.main.cpp +++ b/osx/Scenario Editor/scen.main.cpp @@ -16,6 +16,7 @@ #include "mathutil.h" #include "fileio.h" +cUniverse univ; // not needed; just to silence the compiler /* Globals */ Rect windRect, Drag_Rect; @@ -690,6 +691,7 @@ void Mouse_Pressed() void close_program() { restore_depth(); + if(town != NULL) delete town; } void ding() diff --git a/osx/boe.actions.cpp b/osx/boe.actions.cpp index 88cd9c3e..8d5c1b8e 100644 --- a/osx/boe.actions.cpp +++ b/osx/boe.actions.cpp @@ -553,7 +553,7 @@ Boolean handle_action(EventRecord event) case 5: if (overall_mode == MODE_OUTDOORS) { - save_party(0); + save_party(univ.file); need_redraw = TRUE; current_switch = 6; break; @@ -1395,9 +1395,11 @@ Boolean handle_action(EventRecord event) draw_startup(0); menu_activate(1); strcpy((char*)univ.party.scen_name,".exs"); // should be harmless... - if (FCD(901,0) == 2) - save_party(1); + if (FCD(901,0) == 2){ + FSSpec* file = nav_put_party(); + save_party(*file); } + } else if (party_toast() == TRUE) { for (i = 0; i < 6; i++) if (ADVEN[i].main_status == 5) { @@ -2044,7 +2046,11 @@ void do_save(short mode) print_buf(); return; } - save_party(mode); + FSSpec file; + if(mode == 1) file = *nav_put_party(); + else file = univ.file; + save_party(file); + pause(6); SetPort(GetWindowPort(mainPtr)); initiate_redraw(); @@ -2454,8 +2460,9 @@ void start_new_game() } ADVEN[i].max_sp += ADVEN[i].skills[9] * 3 + ADVEN[i].skills[10] * 3; ADVEN[i].cur_sp = ADVEN[i].max_sp; - } - save_party(1); + } + FSSpec* file = nav_put_party(); + save_party(*file); party_in_memory = TRUE; } diff --git a/osx/boe.combat.cpp b/osx/boe.combat.cpp index 19161916..e0ef3f05 100644 --- a/osx/boe.combat.cpp +++ b/osx/boe.combat.cpp @@ -20,6 +20,7 @@ #include "boe.graphutil.h" #include "boe.main.h" #include "mathutil.h" +#include "dlgutil.h" //extern party_record_type party; //extern pc_record_type ADVEN[6]; @@ -49,7 +50,7 @@ extern location spell_targets[8]; extern Boolean web,crate,barrel,fire_barrier,force_barrier,quickfire,force_wall,fire_wall,antimagic,scloud,ice_wall,blade_wall; extern Boolean sleep_field,in_scen_debug; extern Boolean fast_bang; -extern unsigned char misc_i[64][64],sfx[64][64]; +//extern unsigned char misc_i[64][64],sfx[64][64]; extern short store_current_pc; extern short refer_mage[62],refer_priest[62]; extern location monster_targs[T_M]; @@ -307,8 +308,8 @@ void start_outdoor_combat(cOutdoors::cCreature encounter,unsigned char in_which_ for (i = 0; i < 48; i++) for (j = 0; j < 48; j++) { univ.town.explored[i][j] = 0; - misc_i[i][j] = 0; - sfx[i][j] = 0; + univ.out.misc_i[i][j] = 0; + univ.out.sfx[i][j] = 0; } univ.town.town->in_town_rect = town_rect; diff --git a/osx/boe.consts.h b/osx/boe.consts.h index df24fb99..fe657226 100644 --- a/osx/boe.consts.h +++ b/osx/boe.consts.h @@ -42,7 +42,7 @@ #define SDF_PARTY_FLIGHT 305][1 #define SDF_PARTY_DETECT_LIFE 305][2 #define SDF_PARTY_FIREWALK 305][3 -#define SDF_SKIP_STARTUP 305][4 +#define SDF_SKIP_STARTUP 305][4 // preferably deprecated #define SDF_LESS_SOUND 305][5 #define SDF_NO_TARGET_LINE 305][6 #define SDF_HOSTILES_PRESENT 305][9 diff --git a/osx/boe.dlgutil.cpp b/osx/boe.dlgutil.cpp index 6e83bb58..8b0bffa1 100644 --- a/osx/boe.dlgutil.cpp +++ b/osx/boe.dlgutil.cpp @@ -87,7 +87,7 @@ Rect dummy_rect = {0,0,0,0}; //hold_responses store_resp[83]; short strnum1,strnum2,oldstrnum1,oldstrnum2; short store_talk_face_pic;//,cur_town_talk_loaded = -1; -std::vector scen_header_strs; +extern std::vector scen_header_strs; // Shopping vars @@ -196,7 +196,8 @@ void end_shop_mode() stat_screen_mode = 0; put_item_screen(stat_window,0); put_pc_screen(); - refresh_screen(0); + //refresh_screen(0); + redraw_screen(); } void handle_shop_event(Point p) diff --git a/osx/boe.fileio.cpp b/osx/boe.fileio.cpp index cc6c43dd..eebaf77b 100644 --- a/osx/boe.fileio.cpp +++ b/osx/boe.fileio.cpp @@ -1,6 +1,6 @@ #include -#include +#include //#include "item.h" @@ -22,6 +22,7 @@ #include "mathutil.h" #include "dlgutil.h" #include "fileio.h" +#include "porting.h" // only needed for one little flip_short call, though... #include #include @@ -91,7 +92,7 @@ short specials_res_id,data_dump_file_id; Str255 start_name; short start_volume,data_volume; long start_dir,data_dir/*,scen_dir*/; -string progPath; +string progDir; //outdoor_record_type dummy_out;//// //town_record_type dummy_town; @@ -163,8 +164,21 @@ void init_directories() // scen_dir = myCPB.dirInfo.ioDrDirID; CFStringRef progURL = CFURLCopyFileSystemPath(CFBundleCopyBundleURL(mainBundle), kCFURLPOSIXPathStyle); - CFStringGetCString(progURL, cPath, 768, kCFStringEncodingUTF8); - progPath = cPath; + const char* tmp = CFStringGetCStringPtr(progURL, kCFStringEncodingASCII);//kCFStringEncodingUTF8); + if(tmp == NULL){ + bool success = CFStringGetCString(progURL, cPath, sizeof(cPath), kCFStringEncodingUTF8); + if(success) { + progDir = cPath; + std::cout << cPath << "\n\n" << progDir << "\n\n"; + } else { + std::cout << "Couldn't retrieve application path.\n"; + exit(1); + } + }else progDir = tmp; + //progDir = cPath; + size_t last_slash = progDir.find_last_of('/'); + progDir.erase(last_slash); + std::cout< town_size[town_type] - 1) || (where_draw.y < 0) || (where_draw.y > town_size[town_type] - 1)) ; - else if (sfx[where_draw.x][where_draw.y] != 0) { + else if (univ.out.sfx[where_draw.x][where_draw.y] != 0) { for (i = 0; i < 8; i++) { flag = s_pow(2,i); - if (sfx[where_draw.x][where_draw.y] & flag) + if (univ.out.sfx[where_draw.x][where_draw.y] & flag) if (spot_seen[q][r] > 0) { loc.x = q; loc.y = r; source_rect = orig_rect; @@ -620,7 +620,7 @@ void draw_one_field(unsigned char flag,short source_x,short source_y) || (where_draw.y < 0) || (where_draw.y > town_size[town_type] - 1)) ; else { - if (misc_i[where_draw.x][where_draw.y] & flag) + if (univ.out.misc_i[where_draw.x][where_draw.y] & flag) if (spot_seen[q][r] > 0) { loc.x = q; loc.y = r; source_rect = orig_rect; diff --git a/osx/boe.infodlg.cpp b/osx/boe.infodlg.cpp index c159ef13..38a58185 100644 --- a/osx/boe.infodlg.cpp +++ b/osx/boe.infodlg.cpp @@ -69,7 +69,7 @@ short store_str2a; short store_str2b; short store_which_string_dlog; short store_page_on,store_num_i; -short store_str_label_1,store_str_label_2,store_str_label_1b,store_str_label_2b; +extern short store_str_label_1,store_str_label_2,store_str_label_1b,store_str_label_2b; // Misc dialog vars short store_display_mode,store_displayed_item,position,cur_entry,num_entries,store_help_mode; diff --git a/osx/boe.items.cpp b/osx/boe.items.cpp index 383eb566..c4a7a3d9 100644 --- a/osx/boe.items.cpp +++ b/osx/boe.items.cpp @@ -23,6 +23,7 @@ #include "boe.main.h" #include "graphtool.h" #include "mathutil.h" +#include "dlgutil.h" extern short stat_window,overall_mode,current_cursor,which_combat_type,current_pc; //extern party_record_type party; @@ -1080,11 +1081,11 @@ short display_item(location from_loc,short pc_num,short mode, Boolean check_cont } -void fancy_choice_dialog_event_filter (short item_hit) -{ - toast_dialog(); - dialog_answer = item_hit; -} +//void fancy_choice_dialog_event_filter (short item_hit) +//{ +// toast_dialog(); +// dialog_answer = item_hit; +//} short custom_choice_dialog(Str255 strs[6],short pic_num,short buttons[3]) //// { @@ -1103,9 +1104,10 @@ short custom_choice_dialog(Str255 strs[6],short pic_num,short buttons[3]) //// //if (parent < 2) { SetPort(GetWindowPort(mainPtr)); BeginUpdate(mainPtr); - if (in_startup_mode == FALSE) - refresh_screen(0); - else draw_startup(0); +// if (in_startup_mode == FALSE) +// refresh_screen(0); +// else draw_startup(0); + redraw_screen(); EndUpdate(mainPtr); // } i = dialog_answer; @@ -1115,40 +1117,40 @@ short custom_choice_dialog(Str255 strs[6],short pic_num,short buttons[3]) //// } -short fancy_choice_dialog(short which_dlog,short parent) -// ignore parent in Mac version -{ - short item_hit,i,store_dialog_answer,err; - - store_dialog_answer = dialog_answer; - make_cursor_sword(); - - err = cd_create_dialog_parent_num(which_dlog,parent); - if(err != 0) - printf("Error %i while creating dialog %i.\n",err,which_dlog); - - if (which_dlog == 1062) { - //i = get_ran(1,0,12); - //get_str(temp_str,11,10 + i); - //csit(1062,10,(char *) temp_str); - } - - item_hit = cd_run_dialog(); - cd_kill_dialog(which_dlog,0); - - if (parent < 2) { - SetPort(GetWindowPort(mainPtr)); - BeginUpdate(mainPtr); - if (in_startup_mode == FALSE) - refresh_screen(0); - else draw_startup(0); - EndUpdate(mainPtr); - } - i = dialog_answer; - dialog_answer = store_dialog_answer; - - return i; -} +//short fancy_choice_dialog(short which_dlog,short parent) +//// ignore parent in Mac version +//{ +// short item_hit,i,store_dialog_answer,err; +// +// store_dialog_answer = dialog_answer; +// make_cursor_sword(); +// +// err = cd_create_dialog_parent_num(which_dlog,parent); +// if(err != 0) +// printf("Error %i while creating dialog %i.\n",err,which_dlog); +// +// if (which_dlog == 1062) { +// //i = get_ran(1,0,12); +// //get_str(temp_str,11,10 + i); +// //csit(1062,10,(char *) temp_str); +// } +// +// item_hit = cd_run_dialog(); +// cd_kill_dialog(which_dlog,0); +// +// if (parent < 2) { +// SetPort(GetWindowPort(mainPtr)); +// BeginUpdate(mainPtr); +// if (in_startup_mode == FALSE) +// refresh_screen(0); +// else draw_startup(0); +// EndUpdate(mainPtr); +// } +// i = dialog_answer; +// dialog_answer = store_dialog_answer; +// +// return i; +//} void select_pc_event_filter (short item_hit) { @@ -1188,7 +1190,8 @@ short char_select_pc(short active_only,short free_inv_only,char *title) BeginUpdate(mainPtr); if (in_startup_mode == FALSE) - refresh_screen(0); + //refresh_screen(0); + redraw_screen(); else draw_startup(0); EndUpdate(mainPtr); @@ -1615,8 +1618,8 @@ void get_text_response(short dlg,Str255 str,short parent_num) if ((str[i] > 64) && (str[i] < 91)) str[i] = str[i] + 32; //ASB((char *) str); - final_process_dialog(dlg); - //cd_kill_dialog(dlg,0); + //final_process_dialog(dlg); + cd_kill_dialog(dlg,0); } diff --git a/osx/boe.items.h b/osx/boe.items.h index 4734867f..540b0542 100644 --- a/osx/boe.items.h +++ b/osx/boe.items.h @@ -34,9 +34,9 @@ short get_prot_level(short pc_num,short abil); void make_town_hostile(); void display_item_event_filter (short item_hit); short display_item(location from_loc,short pc_num,short mode, Boolean check_container); -void fancy_choice_dialog_event_filter (short item_hit); +//void fancy_choice_dialog_event_filter (short item_hit); short custom_choice_dialog(Str255 strs[6],short pic_num,short buttons[3]) ; -short fancy_choice_dialog(short which_dlog,short parent); +//short fancy_choice_dialog(short which_dlog,short parent); void select_pc_event_filter (short item_hit); short char_select_pc(short active_only,short free_inv_only,char *title); short select_pc(short active_only,short free_inv_only); diff --git a/osx/boe.locutils.cpp b/osx/boe.locutils.cpp index ae3e664f..a7207955 100644 --- a/osx/boe.locutils.cpp +++ b/osx/boe.locutils.cpp @@ -46,16 +46,16 @@ void set_terrain_blocked() terrain_blocked[i] = scenario.ter_types[i].blockage; } -short dist(location p1,location p2) -{ - return s_sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)); -} - -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); -} +//short dist(location p1,location p2) +//{ +// return s_sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)); +//} +// +//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); +//} Boolean adjacent(location p1,location p2) { diff --git a/osx/boe.locutils.h b/osx/boe.locutils.h index c4cb10d4..2a19d2b6 100644 --- a/osx/boe.locutils.h +++ b/osx/boe.locutils.h @@ -1,7 +1,7 @@ void set_terrain_blocked(); -short dist(location p1,location p2); -short ex_sqrt(short val); -short vdist(location p1,location p2) ; +//short dist(location p1,location p2); +//short ex_sqrt(short val); +//short vdist(location p1,location p2) ; Boolean adjacent(location p1,location p2); Boolean point_onscreen(location center,location check); short set_direction (location old_pt, location new_pt); diff --git a/osx/boe.main.cpp b/osx/boe.main.cpp index eb89a176..941366d1 100644 --- a/osx/boe.main.cpp +++ b/osx/boe.main.cpp @@ -48,10 +48,10 @@ Rect sbar_rect = {283,546,421,562}; Rect shop_sbar_rect = {67,258,357,274}; Rect item_sbar_rect = {146,546,253,562}; Boolean bgm_on = FALSE,bgm_init = FALSE; -short dialog_answer; +//short dialog_answer; Point store_anim_ul; cScenario scenario; -extern cUniverse univ; +cUniverse univ; //piles_of_stuff_dumping_type *data_store; //talking_record_type talking; @@ -491,7 +491,8 @@ void Handle_Update() redraw_screen(); // 1st update never combat } - else refresh_screen(0); + else //refresh_screen(0); + redraw_screen(); } } @@ -618,7 +619,7 @@ void Mouse_Pressed() if (choice == 3) break; if (choice == 1) - save_party(0); + save_party(univ.file); } All_Done = TRUE; } @@ -707,6 +708,8 @@ void close_program() { restore_depth(); //end_music(); + if(univ.town.town != NULL) delete univ.town.town; + if(univ.town.cur_talk != NULL) delete univ.town.cur_talk; } void handle_menu_choice(long choice) @@ -785,8 +788,10 @@ void handle_file_menu(int item_hit) do_save(0); break; case 3: - if (in_startup_mode == TRUE) - save_party(1); + if (in_startup_mode == TRUE){ + FSSpec* file = nav_put_party(); + save_party(*file); + } else do_save(1); break; case 4: @@ -824,7 +829,7 @@ void handle_file_menu(int item_hit) if (choice == 3) break; if (choice == 1) - save_party(0); + save_party(univ.file); } All_Done = TRUE; break; @@ -1241,7 +1246,7 @@ pascal OSErr handle_quit(AppleEvent *theAppleEvent,AppleEvent *reply,long handle if (choice == 3) return userCanceledErr; if (choice == 1) - save_party(0); + save_party(univ.file); } else { choice = FCD(1067,0); diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index a5663509..456ac845 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -1,4 +1,4 @@ -#include +#include //#include "item.h" @@ -112,7 +112,7 @@ extern short stat_window,overall_mode,current_pc,town_size[3],town_type; //extern current_town_type univ.town; //extern big_tr_type t_d; //extern unsigned char out[96][96],out_e[96][96]; -extern std::string progPath; +extern std::string progDir; extern location pc_pos[6],center; extern WindowPtr mainPtr; extern Boolean in_startup_mode,spell_forced,save_maps,suppress_stat_screen,boom_anim_active; @@ -431,7 +431,7 @@ void init_party_scen_data() // When the party is placed into a scen from the startinbg screen, this is called to put the game into game // mode and load in the scen and init the party info // party record already contains scen name -void put_party_in_scen(Str255 scen_name) +void put_party_in_scen(string scen_name) { short i,j; Str255 strs[6] = {"","","","","",""}; @@ -475,7 +475,10 @@ void put_party_in_scen(Str255 scen_name) FSRef file_ref; FSSpec file_spec; std::string path; - path = progPath + "Blades of Exile Scenarios/" + univ.party.scen_name; + //std::cout << progDir; + path = progDir + "/Blades of Exile Scenarios/"; + path += scen_name; + std::cout<<"Searching for scenario at:\n"< scen_headers; extern Boolean unreg_party_in_scen_not_check; extern std::vector scen_names;; -extern cUniverse univ; //void start_game(); @@ -39,7 +38,7 @@ Rect startup_button[6]; Boolean handle_startup_press(Point the_point) { - + std::string scen_name; short i,scen; the_point.h -= ul.h; @@ -80,13 +79,13 @@ Boolean handle_startup_press(Point the_point) break; switch (scen) { - case 0: sprintf(univ.party.scen_name,"valleydy.exs"); break; + case 0: scen_name = "valleydy.exs"; break; // if not reg, rub out - case 1: sprintf(univ.party.scen_name,"stealth.exs"); break; - case 2: sprintf(univ.party.scen_name,"zakhazi.exs"); break; + case 1: scen_name = "stealth.exs"; break; + case 2: scen_name = "zakhazi.exs"; break; //case 3: sprintf(univ.party.scen_name,"busywork.exs"); break; } - put_party_in_scen(); + put_party_in_scen(scen_name); break; case STARTBTN_CUSTOM: // custom @@ -102,8 +101,8 @@ Boolean handle_startup_press(Point the_point) FCD(912,0); break; } - sprintf(univ.party.scen_name,"%s",scen_names[scen].c_str()); - put_party_in_scen(); + scen_name = scen_names[scen]; + put_party_in_scen(scen_name); break; case 5: diff --git a/osx/location.cpp b/osx/location.cpp index decc93b1..67d04d1c 100644 --- a/osx/location.cpp +++ b/osx/location.cpp @@ -23,6 +23,12 @@ short dist(location p1,location p2){ return s_sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)); } +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); +} + location::location() : x(0), y(0) {} location::location(char a,char b) : x(a), y(b) {} diff --git a/osx/location.h b/osx/location.h index 844684e6..53431910 100644 --- a/osx/location.h +++ b/osx/location.h @@ -36,6 +36,7 @@ bool operator != (location p1,location p2); bool operator == (rectangle r1, rectangle r2); bool operator != (rectangle r1, rectangle r2); short dist(location p1,location p2); +short vdist(location p1,location p2); location loc(char a, char b); location loc(); diff --git a/osx/misc/dlgutil.cpp b/osx/misc/dlgutil.cpp index 707689d2..035990a7 100644 --- a/osx/misc/dlgutil.cpp +++ b/osx/misc/dlgutil.cpp @@ -193,13 +193,15 @@ short cd_create_custom_dialog(WindowPtr parent, Str255 strs[6],short pic_num,sho return 0; } -void oops_error(short error){ +void oops_error(short error, short code){ Str255 error_str; SysBeep(50); SysBeep(50); SysBeep(50); sprintf((char *) error_str,"Giving the scenario editor more memory might also help. Be sure to back your scenario up often. Error number: %d.",error); + if(code != 0) + sprintf((char*) error_str,"%s Result code: %i.",error_str,code); give_error("The program encountered an error while loading/saving/creating the scenario. To prevent future problems, the program will now terminate. Trying again may solve the problem.",(char *) error_str,0); ExitToShell(); } diff --git a/osx/misc/dlgutil.h b/osx/misc/dlgutil.h index 31aecd12..a6c85d29 100644 --- a/osx/misc/dlgutil.h +++ b/osx/misc/dlgutil.h @@ -9,7 +9,7 @@ #define FCD fancy_choice_dialog short cd_create_custom_dialog(WindowPtr parent, Str255 strs[6],short pic_num,short btns[3]); -void oops_error(short error); +void oops_error(short error,short code = 0); void give_error(char *text1, char *text2,short parent_num); void display_strings(char *text1, char *text2,short str_label_1,short str_label_2,short str_label_1b, short str_label_2b, diff --git a/osx/misc/fileio.cpp b/osx/misc/fileio.cpp index bf54a2b3..1f9ffbcd 100644 --- a/osx/misc/fileio.cpp +++ b/osx/misc/fileio.cpp @@ -9,7 +9,7 @@ #include #include //#include "scen.global.h" -#include +#include #include "classes.h" //#include "scen.fileio.h" //#include "scen.keydlgs.h" @@ -28,7 +28,7 @@ extern cUniverse univ; //extern unsigned char borders[4][50]; //extern cOutdoors current_terrain; //extern cTown* town; -extern std::string progPath; +extern std::string progDir; //extern short overall_mode; NavDialogRef dlg_get_scen,dlg_get_game,dlg_put_scen,dlg_put_game; @@ -153,10 +153,10 @@ bool load_scenario(FSSpec file_to_load){ OSErr error; long len; // FSSpec file_to_load; - legacy::scenario_data_type *temp_scenario; - legacy::scen_item_data_type *item_data; - - if ((error = FSpOpenDF(&file_to_load,1,&file_id)) != 0) { + legacy::scenario_data_type *temp_scenario = new legacy::scenario_data_type; + legacy::scen_item_data_type *item_data = new legacy::scen_item_data_type; + error = FSpOpenDF(&file_to_load,1,&file_id); + if (error != 0) { oops_error(28); SysBeep(2); return false; @@ -175,7 +175,7 @@ bool load_scenario(FSSpec file_to_load){ cur_scen_is_mac = true; file_ok = TRUE; } - if ((scenario.format.flag1 == 20) && (scenario.format.flag2 == 40) && + else if ((scenario.format.flag1 == 20) && (scenario.format.flag2 == 40) && (scenario.format.flag3 == 60) && (scenario.format.flag4 == 80)) { SysBeep(20); cur_scen_is_mac = FALSE; @@ -189,15 +189,16 @@ bool load_scenario(FSSpec file_to_load){ len = (long) sizeof(legacy::scenario_data_type); temp_scenario = new legacy::scenario_data_type; - - if ((error = FSRead(file_id, &len, (char *) temp_scenario)) != 0){ + error = FSRead(file_id, &len, (char *) temp_scenario); + if (error != 0){ FSClose(file_id); oops_error(29); return false; } port_scenario(temp_scenario); len = sizeof(legacy::scen_item_data_type); // item data - if ((error = FSRead(file_id, &len, (char *) item_data)) != 0){ + error = FSRead(file_id, &len, (char *) item_data); + if (error != 0){ FSClose(file_id); oops_error(30); return false; @@ -245,6 +246,7 @@ bool load_scenario(FSSpec file_to_load){ scenario.ter_types[23].fly_over = FALSE; delete temp_scenario; + delete item_data; //store_file_reply = file_to_load; // overall_mode = 60; @@ -334,7 +336,7 @@ bool load_town(short which_town, cTown*& the_town){ the_town->append(t_d); break; - case 1: + case 1: len = sizeof(legacy::ave_tr_type); FSRead(file_id, &len, (char *) &ave_t); port_ave_t(&ave_t); @@ -343,7 +345,7 @@ bool load_town(short which_town, cTown*& the_town){ the_town->append(ave_t); break; - case 2: + case 2: len = sizeof(legacy::tiny_tr_type); FSRead(file_id,&len , (char *) &tiny_t); port_tiny_t(&tiny_t); @@ -473,7 +475,7 @@ bool load_town(short which_town, cSpeech& the_talk){ return true; } -bool load_town(short which_town, short which_str, void* p){ +bool load_town_str(short which_town, short which_str, char* str){ short i,j,k,file_id; long len,len_to_jump = 0,store; OSErr error; @@ -523,15 +525,9 @@ bool load_town(short which_town, short which_str, void* p){ } error = SetFPos (file_id, 3, len); - char* str = (char*) p; - cTown* t = (cTown*) p; for (i = 0; i < 140; i++) { - len = (long) (t->strlens[i]); - if(which_str < 0){ - FSRead(file_id, &len, (char *) &(t->town_strs(i))); - t->town_strs(i)[len] = 0; - } - else if(i == which_str){ + len = (long) (univ.town.town->strlens[i]); + if(i == which_str){ FSRead(file_id, &len, (char *) str); str[len] = 0; } @@ -548,6 +544,72 @@ bool load_town(short which_town, short which_str, void* p){ return true; } +bool load_town_str(short which_town, cTown*& t){ + short i,j,k,file_id; + long len,len_to_jump = 0,store; + OSErr error; + legacy::town_record_type store_town; + legacy::talking_record_type store_talk; + legacy::big_tr_type t_d; + legacy::ave_tr_type ave_t; + legacy::tiny_tr_type tiny_t; + + // if (overall_mode == 61) + // return; + + len_to_jump = get_town_offset(which_town); + + if ((error = FSpOpenDF(&scenario.scen_file,1,&file_id)) != 0) { + oops_error(34); + return false; + } + + error = SetFPos (file_id, 1, len_to_jump); + if (error != 0) { + FSClose(file_id); + oops_error(35); + return false; + } + + len = sizeof(legacy::town_record_type); + + error = FSRead(file_id, &len , (char *) &store_town); + port_town(&store_town); + if (error != 0) { + FSClose(file_id); + oops_error(36); + return false; + } + + switch (scenario.town_size[which_town]) { + case 0: + len = sizeof(legacy::big_tr_type); + break; + case 1: + len = sizeof(legacy::ave_tr_type); + break; + case 2: + len = sizeof(legacy::tiny_tr_type); + break; + } + error = SetFPos (file_id, 3, len); + + for (i = 0; i < 140; i++) { + len = (long) (t->strlens[i]); + FSRead(file_id, &len, (char *) &(t->town_strs(i))); + t->town_strs(i)[len] = 0; + } + + // town_type = scenario.town_size[which_town]; + error = FSClose(file_id); + if (error != 0) { + FSClose(file_id); + oops_error(38); + } + + return true; +} + long get_outdoors_offset(location& which_out){ int i,j,out_sec_num; long len_to_jump,store; @@ -609,7 +671,7 @@ bool load_outdoors(location which_out,cOutdoors& the_out){ port_out(&store_out); the_out = store_out; - for (i = 0; i < 120; i++) { + for (i = 0; i < 108; i++) { len = (long) (the_out.strlens[i]); FSRead(file_id, &len, (char *) &(the_out.out_strs(i))); the_out.out_strs(i)[len] = 0; @@ -679,7 +741,7 @@ bool load_outdoors(location which_out, short mode, unsigned char borders[4][50]) return true; } -bool load_outdoors(location which_out, short which_str, char* str){ +bool load_outdoor_str(location which_out, short which_str, char* str){ short i,j,k,file_id; long len,len_to_jump,store; short out_sec_num; @@ -808,15 +870,15 @@ bool load_party(FSSpec file_to_load){ legacy::stored_outdoor_maps_type o_maps; unsigned char misc_i[64][64], sfx[64][64]; - short flags[3][2] = { + static const short flags[3][2] = { {5790,1342}, // slot 0 ... 5790 - out, 1342 - town {100,200}, // slot 1 ... 100 - in scenario, 200 - not in {3422,5567} // slot 2 ... 3422 - no maps, 5567 - maps }; // but if the first flag is 0x0B0E, we have a new-format save // the three flags still follow that. - - if ((error = FSpOpenDF(&file_to_load,1,&file_id)) != 0) { + error = FSpOpenDF(&file_to_load,1,&file_id); + if (error != 0) { FCD(1064,0); SysBeep(2); return false; @@ -831,7 +893,8 @@ bool load_party(FSSpec file_to_load){ // add_string_to_buf((char *) debug); for (i = 0; i < 3; i++) { - if ((error = FSRead(file_id, &len, (char *) &flag)) != 0) { + error = FSRead(file_id, &len, (char *) &flag); + if (error != 0) { FSClose(file_id); FCD(1064,0); return false; @@ -886,7 +949,8 @@ bool load_party(FSSpec file_to_load){ store_len = (long) sizeof(legacy::pc_record_type); for (i = 0; i < 6; i++) { len = store_len; - if ((error = FSRead(file_id, &len, (char *) &store_pc[i])) != 0){ + error = FSRead(file_id, &len, (char *) &store_pc[i]); + if (error != 0){ FSClose(file_id); SysBeep(2); FCD(1064,0); @@ -994,15 +1058,6 @@ bool load_party(FSSpec file_to_load){ return false; } - FSRef file_ref; - FSSpec file_spec; - std::string path; - path = progPath + "Blades of Exile Scenarios/" + univ.party.scen_name; - FSPathMakeRef((UInt8*) path.c_str(), &file_ref, NULL); - FSGetCatalogInfo(&file_ref, kFSCatInfoNone, NULL, NULL, &file_spec, NULL); - if (!load_scenario(file_spec)) - return false; - univ.party = store_party; univ.town.append(store_setup); for(i = 0; i < 6; i++) @@ -1020,11 +1075,25 @@ bool load_party(FSSpec file_to_load){ univ.out.append(o_maps); univ.out.append(sfx, misc_i); } + if(in_scen){ + FSRef file_ref; + FSSpec file_spec; + std::string path; + path = progDir + "/Blades of Exile Scenarios/" + univ.party.scen_name; + std::cout<