diff --git a/osx/Scenario Editor/scen.actions.cpp b/osx/Scenario Editor/scen.actions.cpp index aa391522..e1272329 100644 --- a/osx/Scenario Editor/scen.actions.cpp +++ b/osx/Scenario Editor/scen.actions.cpp @@ -177,18 +177,20 @@ bool handle_action(Point the_point,EventRecord event) { break; case 4: // edit - FSSpec* file_to_load = nav_get_scenario(); - if (load_scenario(*file_to_load)) { - if(load_town(scenario.last_town_edited,town)) - cur_town = scenario.last_town_edited; - if(load_outdoors(scenario.last_out_edited,current_terrain)){ - cur_out = scenario.last_out_edited; - augment_terrain(cur_out); + try{ + FSSpec file_to_load = nav_get_scenario(); + if (load_scenario(file_to_load)) { + if(load_town(scenario.last_town_edited,town)) + cur_town = scenario.last_town_edited; + if(load_outdoors(scenario.last_out_edited,current_terrain)){ + cur_out = scenario.last_out_edited; + augment_terrain(cur_out); + } + overall_mode = MODE_MAIN_SCREEN; + set_up_main_screen(); + update_item_menu(); } - overall_mode = MODE_MAIN_SCREEN; - set_up_main_screen(); - update_item_menu(); - } + } catch(no_file_chosen){} break; } } diff --git a/osx/Scenario Editor/scen.main.cpp b/osx/Scenario Editor/scen.main.cpp index a35d2770..eaae3717 100644 --- a/osx/Scenario Editor/scen.main.cpp +++ b/osx/Scenario Editor/scen.main.cpp @@ -372,19 +372,21 @@ void handle_file_menu(int item_hit) { switch (item_hit) { case 1: // open - FSSpec* file_to_load = nav_get_scenario(); - if (load_scenario(*file_to_load)) { - if(load_town(scenario.last_town_edited,town)) - cur_town = scenario.last_town_edited; - if(load_outdoors(scenario.last_out_edited,current_terrain)){ - cur_out = scenario.last_out_edited; - augment_terrain(cur_out); + try{ + FSSpec file_to_load = nav_get_scenario(); + if (load_scenario(file_to_load)) { + if(load_town(scenario.last_town_edited,town)) + cur_town = scenario.last_town_edited; + if(load_outdoors(scenario.last_out_edited,current_terrain)){ + cur_out = scenario.last_out_edited; + augment_terrain(cur_out); + } + overall_mode = MODE_MAIN_SCREEN; + change_made = false; + update_item_menu(); + set_up_main_screen(); } - overall_mode = MODE_MAIN_SCREEN; - change_made = false; - update_item_menu(); - set_up_main_screen(); - } + } catch(no_file_chosen){} break; case 2: // save modify_lists(); diff --git a/osx/boe.actions.cpp b/osx/boe.actions.cpp index a43d3e02..7b19ab74 100644 --- a/osx/boe.actions.cpp +++ b/osx/boe.actions.cpp @@ -1398,8 +1398,10 @@ bool handle_action(EventRecord event) menu_activate(1); univ.party.scen_name = ".exs"; // should be harmless... if (FCD(901,0) == 2){ - FSSpec* file = nav_put_party(); - save_party(*file); + try{ + FSSpec file = nav_put_party(); + save_party(file); + } catch(no_file_chosen){} } } else if (party_toast() == true) { @@ -1995,8 +1997,10 @@ void menu_activate( short type) void do_load() { - FSSpecPtr file_to_load = nav_get_party(); - if(file_to_load != NULL) load_party(*file_to_load); + try{ + FSSpec file_to_load = nav_get_party(); + load_party(file_to_load); + } catch(no_file_chosen){} if (in_startup_mode == false) post_load(); menu_activate(1); @@ -2049,9 +2053,11 @@ void do_save(short mode) return; } FSSpec file; - if(mode == 1) file = *nav_put_party(); - else file = univ.file; - save_party(file); + try{ + if(mode == 1) file = nav_put_party(); + else file = univ.file; + save_party(file); + } catch(no_file_chosen){} pause(6); SetPort(GetWindowPort(mainPtr)); @@ -2396,8 +2402,10 @@ void handle_death() } if (choice == 1) { in_startup_mode = false; - FSSpecPtr file_to_load = nav_get_party(); - if(file_to_load != NULL) load_party(*file_to_load); + try{ + FSSpec file_to_load = nav_get_party(); + load_party(file_to_load); + } catch(no_file_chosen){} if (party_toast() == false) { if (in_startup_mode == false) post_load(); @@ -2465,9 +2473,11 @@ 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; } - FSSpec* file = nav_put_party(); - save_party(*file); - party_in_memory = true; + try{ + FSSpec file = nav_put_party(); + save_party(file); + party_in_memory = true; + } catch(no_file_chosen){} } diff --git a/osx/boe.combat.cpp b/osx/boe.combat.cpp index 40af8a88..f5624069 100644 --- a/osx/boe.combat.cpp +++ b/osx/boe.combat.cpp @@ -1994,7 +1994,7 @@ void do_monster_turn() // missile range && (dist(cur_monst->m_loc,targ_space) <= abil_range[cur_monst->m_d.spec_skill])) { print_monst_name(cur_monst->number); - monst_fire_missile(i,cur_monst->m_d.skill,cur_monst->m_d.status[1], + monst_fire_missile(i/*,cur_monst->m_d.skill*/,cur_monst->m_d.status[1], cur_monst->m_d.spec_skill,cur_monst->m_loc,target); // Vapors don't count as action @@ -2541,7 +2541,7 @@ void monster_attack_monster(short who_att,short attackee) } -void monst_fire_missile(short m_num,short skill,short bless,short level,location source,short target) +void monst_fire_missile(short m_num,short bless,short level,location source,short target) //short target; // 100 + - monster is target { cPopulation::cCreature *m_target; @@ -2997,7 +2997,7 @@ bool monst_cast_mage(cPopulation::cCreature *caster,short targ)//// break; case 10: // summon beast r1 = get_summon_monster(1); - if (r1 < 0) + if (r1 == 0) break; x = get_ran(3,1,4); //Delay(12,&dummy); // gives sound time to end @@ -3022,19 +3022,19 @@ bool monst_cast_mage(cPopulation::cCreature *caster,short targ)//// play_sound(25); if (spell == 13) { r1 = get_summon_monster(1); - if (r1 < 0) + if (r1 == 0) break; j = get_ran(2,1,3) + 1; } if (spell == 20) { r1 = get_summon_monster(2); - if (r1 < 0) + if (r1 == 0) break; j = get_ran(2,1,2) + 1; } if (spell == 26) { r1 = get_summon_monster(3); - if (r1 < 0) + if (r1 == 0) break; j = get_ran(1,2,3); } diff --git a/osx/boe.combat.h b/osx/boe.combat.h index 46c37824..20bb8835 100644 --- a/osx/boe.combat.h +++ b/osx/boe.combat.h @@ -15,7 +15,7 @@ void combat_run_monst(); void do_monster_turn(); void monster_attack_pc(short who_att,short target); void monster_attack_monster(short who_att,short attackee); -void monst_fire_missile(short m_num,short skill,short bless,short level,location source,short target); +void monst_fire_missile(short m_num,short bless,short level,location source,short target); bool monst_breathe(cPopulation::cCreature *caster,location targ_space,short dam_type); bool monst_cast_mage(cPopulation::cCreature *caster,short targ); bool monst_cast_priest(cPopulation::cCreature *caster,short targ); diff --git a/osx/boe.main.cpp b/osx/boe.main.cpp index aa9eb923..8df8ecb5 100644 --- a/osx/boe.main.cpp +++ b/osx/boe.main.cpp @@ -792,8 +792,10 @@ void handle_file_menu(int item_hit) break; case 3: if (in_startup_mode == true){ - FSSpec* file = nav_put_party(); - save_party(*file); + try{ + FSSpec file = nav_put_party(); + save_party(file); + } catch(no_file_chosen){} } else do_save(1); break; diff --git a/osx/boe.monster.cpp b/osx/boe.monster.cpp index a3ef7931..c14da5b2 100644 --- a/osx/boe.monster.cpp +++ b/osx/boe.monster.cpp @@ -1466,7 +1466,7 @@ short get_encumberance(short pc_num) return store; } -short get_summon_monster(short summon_class) +unsigned short get_summon_monster(short summon_class) { short i,j; @@ -1477,5 +1477,5 @@ short get_summon_monster(short summon_class) } } ASB(" Summon failed."); - return -1; + return 0; } diff --git a/osx/boe.monster.h b/osx/boe.monster.h index 650350b7..4ed2ff2e 100644 --- a/osx/boe.monster.h +++ b/osx/boe.monster.h @@ -49,4 +49,4 @@ short place_monster(unsigned char which,location where); bool summon_monster(unsigned char which,location where,short duration,short given_attitude); void activate_monsters(short code,short attitude); short get_encumberance(short pc_num); -short get_summon_monster(short summon_class); +unsigned short get_summon_monster(short summon_class); diff --git a/osx/boe.specials.cpp b/osx/boe.specials.cpp index 9690376e..766fd345 100644 --- a/osx/boe.specials.cpp +++ b/osx/boe.specials.cpp @@ -144,7 +144,7 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short // returns true if can enter this space // sets forced to true if definitely can enter { - unsigned char ter; + unsigned short ter; short r1,i,choice,door_pc,ter_special,ter_flag1,ter_flag2,pic_type = 0,ter_pic = 0; eDamageType dam_type = DAMAGE_WEAPON; bool can_enter = true; diff --git a/osx/boe.startup.cpp b/osx/boe.startup.cpp index 3991c620..eeee46ee 100644 --- a/osx/boe.startup.cpp +++ b/osx/boe.startup.cpp @@ -118,13 +118,16 @@ bool handle_startup_press(Point the_point) void startup_load()//// { - FSSpec* file_to_load = nav_get_party(); - if(file_to_load == NULL) return; - if(load_party(*file_to_load)){ - party_in_memory = true; - update_pc_graphics(); - in_startup_mode = univ.party.scen_name.length(); - } + try{ + FSSpec file_to_load = nav_get_party(); + if(load_party(file_to_load)){ + party_in_memory = true; + update_pc_graphics(); + if(univ.party.scen_name.length() > 0) + in_startup_mode = false; + else in_startup_mode = true; + } + } catch(no_file_chosen){} if (!in_startup_mode) { //end_anim(); end_startup(); diff --git a/osx/misc/fileio.cpp b/osx/misc/fileio.cpp index bd68c7f2..5ce51699 100644 --- a/osx/misc/fileio.cpp +++ b/osx/misc/fileio.cpp @@ -95,40 +95,43 @@ void init_fileio(){ NULL }; err = NavCreatePutFileDialog (&opts, 'BlEd', 'BETM', NULL, NULL, &dlg_put_scen); - err = NavCreatePutFileDialog (&opts, 'blx!', 'beSV', NULL, NULL, &dlg_put_game); err = NavCreateGetFileDialog (&opts, NULL, NULL, NULL, scen_file_filter, NULL, &dlg_get_scen); - err = NavCreateGetFileDialog (&opts, NULL, NULL, NULL, party_file_filter, NULL, &dlg_get_game); + NavDialogCreationOptions opts2 = opts; + opts2.clientName = CFSTR("com.spidweb.bladesofexile"); + opts2.windowTitle = CFSTR("Blades of Exile"); + err = NavCreatePutFileDialog (&opts2, 'blx!', 'beSV', NULL, NULL, &dlg_put_game); + err = NavCreateGetFileDialog (&opts2, NULL, NULL, NULL, party_file_filter, NULL, &dlg_get_game); } -FSSpecPtr nav_get_scenario(){ +FSSpec nav_get_scenario() throw(no_file_chosen) { NavReplyRecord s_reply; AEKeyword keyword; DescType descType; Size actualSize; - FSSpecPtr file_to_load; + FSSpec file_to_load; NavGetFile(NULL,&s_reply,NULL,NULL,NULL,NULL,NULL,NULL); if (s_reply.validRecord == false) - return NULL; - AEGetNthPtr(&s_reply.selection,1,typeFSS,&keyword,&descType,file_to_load,sizeof(FSSpec),&actualSize); + throw no_file_chosen(); + AEGetNthPtr(&s_reply.selection,1,typeFSS,&keyword,&descType,&file_to_load,sizeof(FSSpec),&actualSize); return file_to_load; } -FSSpecPtr nav_put_scenario(){ +FSSpec nav_put_scenario() throw(no_file_chosen) { NavReplyRecord s_reply; AEKeyword keyword; DescType descType; Size actualSize; - FSSpecPtr file_to_load; + FSSpec file_to_load; return file_to_load; } -FSSpecPtr nav_get_party(){ +FSSpec nav_get_party() throw(no_file_chosen) { NavReplyRecord reply; NavTypeList type_list; // To be able to have more than one type, this wouldn't do. - FSSpecPtr file_to_load; + FSSpec file_to_load; type_list.componentSignature = kNavGenericSignature; type_list.osTypeCount = 1; @@ -139,22 +142,25 @@ FSSpecPtr nav_get_party(){ NavChooseFile(NULL,&reply,NULL,NULL,NULL,NULL,&type_list_p,NULL); if (!reply.validRecord) - return NULL; + throw no_file_chosen(); AEKeyword keyword; DescType descType; Size actualSize; - AEGetNthPtr(&reply.selection,1,typeFSS,&keyword,&descType,file_to_load,sizeof(FSSpec),&actualSize); + AEGetNthPtr(&reply.selection,1,typeFSS,&keyword,&descType,&file_to_load,sizeof(FSSpec),&actualSize); + + NavDisposeReply(&reply); return file_to_load; } -FSSpecPtr nav_put_party(){ + +FSSpec nav_put_party() throw(no_file_chosen) { NavReplyRecord s_reply; AEKeyword keyword; DescType descType; Size actualSize; - FSSpecPtr file_to_load; + FSSpec file_to_load; return file_to_load; } diff --git a/osx/misc/fileio.h b/osx/misc/fileio.h index 6c3294a5..3e646ece 100644 --- a/osx/misc/fileio.h +++ b/osx/misc/fileio.h @@ -8,10 +8,12 @@ void init_fileio(); +struct no_file_chosen {}; // an exception class + Boolean scen_file_filter(AEDesc* item, void* info, void * dummy, NavFilterModes filterMode); Boolean party_file_filter(AEDesc* item, void* info, void * dummy, NavFilterModes filterMode); -FSSpecPtr nav_get_scenario(); -FSSpecPtr nav_put_scenario(); +FSSpec nav_get_scenario() throw(no_file_chosen); +FSSpec nav_put_scenario() throw(no_file_chosen); bool load_scenario(FSSpec file_to_load); bool load_town(short which_town, cTown*& the_town); bool load_town(short which_town, cSpeech& the_talk); @@ -22,7 +24,7 @@ bool load_outdoors(location which_out, short mode, unsigned char borders[4][50]) bool load_outdoor_str(location which_out, short which_str, char* str); void load_spec_graphics(); -FSSpecPtr nav_get_party(); -FSSpecPtr nav_put_party(); +FSSpec nav_get_party() throw(no_file_chosen); +FSSpec nav_put_party() throw(no_file_chosen); bool load_party(FSSpec file_to_load); void save_party(FSSpec dest_file); diff --git a/osx/party.cpp b/osx/party.cpp index 07627cfe..60bb9f0c 100644 --- a/osx/party.cpp +++ b/osx/party.cpp @@ -30,12 +30,18 @@ cParty& cParty::operator = (legacy::party_record_type& old){ p_loc.y = old.p_loc.y; loc_in_sec.x = old.loc_in_sec.x; loc_in_sec.y = old.loc_in_sec.y; + party_event_timers.reserve(30); for(i = 0; i < 30; i++){ boats[i] = old.boats[i]; horses[i] = old.horses[i]; - party_event_timers[i].time = old.party_event_timers[i]; - party_event_timers[i].global_or_town = old.global_or_town[i]; - party_event_timers[i].node_to_call = old.node_to_call[i]; + cTimer t; + t.time = old.party_event_timers[i]; + t.global_or_town = old.global_or_town[i]; + t.node_to_call = old.node_to_call[i]; + party_event_timers.push_back(t); +// party_event_timers[i].time = old.party_event_timers[i]; +// party_event_timers[i].global_or_town = old.global_or_town[i]; +// party_event_timers[i].node_to_call = old.node_to_call[i]; } for(i = 0; i < 4; i++){ creature_save[i] = old.creature_save[i]; @@ -50,17 +56,31 @@ cParty& cParty::operator = (legacy::party_record_type& old){ } for(i = 0; i < 256; i++) m_seen[i] = old.m_seen[i]; + journal.reserve(50); for(i = 0; i < 50; i++){ - journal[i].str_num = old.journal_str[i]; - journal[i].day = old.journal_day[i]; + cJournal j; + j.str_num = old.journal_str[i]; + j.day = old.journal_day[i]; + journal.push_back(j); +// journal[i].str_num = old.journal_str[i]; +// journal[i].day = old.journal_day[i]; spec_items[i] = old.spec_items[i]; } + special_notes.reserve(140); for(i = 0; i < 140; i++){ - special_notes[i].str_num = old.special_notes_str[i][0]; - special_notes[i].where = old.special_notes_str[i][1]; + cEncNote n; + n.str_num = old.special_notes_str[i][0]; + n.where = old.special_notes_str[i][1]; + special_notes.push_back(n); +// special_notes[i].str_num = old.special_notes_str[i][0]; +// special_notes[i].where = old.special_notes_str[i][1]; } + talk_save.reserve(120); for(i = 0; i < 120; i++){ - talk_save[i] = old.talk_save[i]; + cConvers t; + t = old.talk_save[i]; + talk_save.push_back(t); +// talk_save[i] = old.talk_save[i]; help_received[i] = old.help_received[i]; } direction = old.direction; diff --git a/osx/universe.cpp b/osx/universe.cpp index b901041c..bc3d0a36 100644 --- a/osx/universe.cpp +++ b/osx/universe.cpp @@ -115,107 +115,133 @@ void cCurTown::unload(){ } bool cCurTown::is_explored(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 1L; } bool cCurTown::is_force_wall(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 2L; } bool cCurTown::is_fire_wall(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 4L; } bool cCurTown::is_antimagic(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 8L; } bool cCurTown::is_scloud(char x, char y) const{ // stinking cloud + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 16L; } bool cCurTown::is_ice_wall(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 32L; } bool cCurTown::is_blade_wall(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 64L; } bool cCurTown::is_sleep_cloud(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 128L; } bool cCurTown::is_block(char x, char y) const{ // currently unused + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 256L; } bool cCurTown::is_special(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 512L; } bool cCurTown::is_web(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 1024L; } bool cCurTown::is_crate(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 2048L; } bool cCurTown::is_barrel(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 4096L; } bool cCurTown::is_fire_barr(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 8192L; } bool cCurTown::is_force_barr(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 16384L; } bool cCurTown::is_quickfire(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 32768L; } bool cCurTown::is_sm_blood(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 65536L; } bool cCurTown::is_med_blood(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 131072L; } bool cCurTown::is_lg_blood(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 262144L; } bool cCurTown::is_sm_slime(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 524288L; } bool cCurTown::is_lg_slime(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 1048576L; } bool cCurTown::is_ash(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 2097152L; } bool cCurTown::is_bones(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 4194304L; } bool cCurTown::is_rubble(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return false; return fields[x][y] & 8388608L; } -void cCurTown::set_explored(char x, char y, bool b){ +bool cCurTown::set_explored(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b) fields[x][y] |= 1L; else fields[x][y] &= ~1L; } bool cCurTown::set_force_wall(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on space, there's no room for field. if(is_antimagic(x,y) || is_blade_wall(x,y) || is_quickfire(x,y)) return false; @@ -230,6 +256,7 @@ bool cCurTown::set_force_wall(char x, char y, bool b){ } bool cCurTown::set_fire_wall(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on space, there's no room for field. if(is_antimagic(x,y) || is_blade_wall(x,y) || is_quickfire(x,y) || is_ice_wall(x,y)) return false; @@ -246,6 +273,7 @@ bool cCurTown::set_fire_wall(char x, char y, bool b){ } bool cCurTown::set_antimagic(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on space, there's no room for a field. if(is_quickfire(x,y) || is_force_wall(x,y) || is_fire_wall(x,y)) return false; @@ -263,6 +291,7 @@ bool cCurTown::set_antimagic(char x, char y, bool b){ } bool cCurTown::set_scloud(char x, char y, bool b){ // stinking cloud + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on space, there's no room for cloud. if(is_force_wall(x,y) || is_fire_wall(x,y) || is_ice_wall(x,y) || is_blade_wall(x,y)) return false; @@ -277,6 +306,7 @@ bool cCurTown::set_scloud(char x, char y, bool b){ // stinking cloud } bool cCurTown::set_ice_wall(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on space, ther's no room for a field. if(is_force_wall(x,y) || is_blade_wall(x,y) || is_antimagic(x,y)) return false; @@ -293,6 +323,7 @@ bool cCurTown::set_ice_wall(char x, char y, bool b){ } bool cCurTown::set_blade_wall(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // if certain things are on space, there's no room for a field. if(is_fire_barr(x,y) || is_force_barr(x,y) || is_quickfire(x,y) || is_antimagic(x,y)) return false; @@ -305,6 +336,7 @@ bool cCurTown::set_blade_wall(char x, char y, bool b){ } bool cCurTown::set_sleep_cloud(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // if certain things are on space, there's no room for cloud. if(is_fire_barr(x,y) || is_force_barr(x,y) || is_quickfire(x,y) || is_antimagic(x,y)) return false; @@ -316,17 +348,20 @@ bool cCurTown::set_sleep_cloud(char x, char y, bool b){ return true; } -void cCurTown::set_block(char x, char y, bool b){ // currently unused +bool cCurTown::set_block(char x, char y, bool b){ // currently unused + if(x > record->max_dim() || y > record->max_dim()) return false; if(b) fields[x][y] |= 256L; else fields[x][y] &= ~256L; } -void cCurTown::set_special(char x, char y, bool b){ +bool cCurTown::set_special(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b) fields[x][y] |= 512L; else fields[x][y] &= ~512L; } bool cCurTown::set_web(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on the space, there's no room for web. if(is_fire_barr(x,y) || is_force_barr(x,y) || is_quickfire(x,y)) return false; @@ -341,6 +376,7 @@ bool cCurTown::set_web(char x, char y, bool b){ } bool cCurTown::set_crate(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on the space, there's no room for a crate. if(is_fire_barr(x,y) || is_force_barr(x,y) || is_quickfire(x,y) || is_barrel(x,y)) return false; @@ -351,6 +387,7 @@ bool cCurTown::set_crate(char x, char y, bool b){ } bool cCurTown::set_barrel(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on the space, there's no room for a crate. if(is_fire_barr(x,y) || is_force_barr(x,y) || is_quickfire(x,y) || is_crate(x,y)) return false; @@ -361,6 +398,7 @@ bool cCurTown::set_barrel(char x, char y, bool b){ } bool cCurTown::set_fire_barr(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on the space, there's no room for a barrier. if(is_barrel(x,y) || is_force_barr(x,y) || is_quickfire(x,y) || is_crate(x,y)) return false; @@ -382,6 +420,7 @@ bool cCurTown::set_fire_barr(char x, char y, bool b){ } bool cCurTown::set_force_barr(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on the space, there's no room for a barrier. if(is_fire_barr(x,y) || is_barrel(x,y) || is_quickfire(x,y) || is_crate(x,y)) return false; @@ -403,6 +442,7 @@ bool cCurTown::set_force_barr(char x, char y, bool b){ } bool cCurTown::set_quickfire(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ // If certain things are on space, there's no room for quickfire. if (is_antimagic(x,y) && get_ran(1,0,1) == 0) return false; @@ -426,10 +466,11 @@ bool cCurTown::set_quickfire(char x, char y, bool b){ return true; } -void cCurTown::set_sm_blood(char x, char y, bool b){ +bool cCurTown::set_sm_blood(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ if(is_med_blood(x,y) || is_lg_blood(x,y)) - return; + return false; fields[x][y] |= 65536L; set_sm_slime(x,y,false); set_lg_slime(x,y,false); @@ -440,11 +481,13 @@ void cCurTown::set_sm_blood(char x, char y, bool b){ else fields[x][y] &= ~65536L; } -void cCurTown::set_med_blood(char x, char y, bool b){ +bool cCurTown::set_med_blood(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ - if(is_sm_blood(x,y) || is_lg_blood(x,y)) - return; + if(is_lg_blood(x,y)) + return false; fields[x][y] |= 131072L; + set_sm_blood(x,y,false); set_sm_slime(x,y,false); set_lg_slime(x,y,false); set_ash(x,y,false); @@ -454,11 +497,12 @@ void cCurTown::set_med_blood(char x, char y, bool b){ else fields[x][y] &= ~131072L; } -void cCurTown::set_lg_blood(char x, char y, bool b){ +bool cCurTown::set_lg_blood(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ - if(is_sm_blood(x,y) || is_med_blood(x,y)) - return; fields[x][y] |= 262144L; + set_sm_blood(x,y,false); + set_med_blood(x,y,false); set_sm_slime(x,y,false); set_lg_slime(x,y,false); set_ash(x,y,false); @@ -468,10 +512,10 @@ void cCurTown::set_lg_blood(char x, char y, bool b){ else fields[x][y] &= ~262144L; } -void cCurTown::set_sm_slime(char x, char y, bool b){ +bool cCurTown::set_sm_slime(char x, char y, bool b){ if(b){ - if(is_lg_blood(x,y)) - return; + if(is_lg_slime(x,y)) + return false; fields[x][y] |= 524288L; set_sm_blood(x,y,false); set_med_blood(x,y,false); @@ -483,14 +527,14 @@ void cCurTown::set_sm_slime(char x, char y, bool b){ else fields[x][y] &= ~524288L; } -void cCurTown::set_lg_slime(char x, char y, bool b){ +bool cCurTown::set_lg_slime(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ - if(is_sm_blood(x,y)) - return; fields[x][y] |= 1048576L; set_sm_blood(x,y,false); set_med_blood(x,y,false); set_lg_blood(x,y,false); + set_sm_slime(x,y,false); set_ash(x,y,false); set_bones(x,y,false); set_rubble(x,y,false); @@ -498,7 +542,8 @@ void cCurTown::set_lg_slime(char x, char y, bool b){ else fields[x][y] &= ~1048576L; } -void cCurTown::set_ash(char x, char y, bool b){ +bool cCurTown::set_ash(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ fields[x][y] |= 2097152L; set_sm_blood(x,y,false); @@ -512,7 +557,8 @@ void cCurTown::set_ash(char x, char y, bool b){ else fields[x][y] &= ~2097152L; } -void cCurTown::set_bones(char x, char y, bool b){ +bool cCurTown::set_bones(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ fields[x][y] |= 4194304L; set_sm_blood(x,y,false); @@ -526,7 +572,8 @@ void cCurTown::set_bones(char x, char y, bool b){ else fields[x][y] &= ~4194304L; } -void cCurTown::set_rubble(char x, char y, bool b){ +bool cCurTown::set_rubble(char x, char y, bool b){ + if(x > record->max_dim() || y > record->max_dim()) return false; if(b){ fields[x][y] |= 8388608L; set_sm_blood(x,y,false); @@ -541,13 +588,16 @@ void cCurTown::set_rubble(char x, char y, bool b){ } unsigned char cCurTown::explored(char x,char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return 0; return fields[x][y] & 0x000000FF; } unsigned char cCurTown::misc_i(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return 0; return (fields[x][y] & 0x0000FF00) >> 8; } unsigned char cCurTown::sfx(char x, char y) const{ + if(x > record->max_dim() || y > record->max_dim()) return 0; return (fields[x][y] & 0x00FF0000) >> 16; } diff --git a/osx/universe.h b/osx/universe.h index 9e31b8ea..07343eb1 100644 --- a/osx/universe.h +++ b/osx/universe.h @@ -71,7 +71,7 @@ public: bool is_ash(char x, char y) const; bool is_bones(char x, char y) const; bool is_rubble(char x, char y) const; - void set_explored(char x, char y, bool b); + bool set_explored(char x, char y, bool b); bool set_force_wall(char x, char y, bool b); bool set_fire_wall(char x, char y, bool b); bool set_antimagic(char x, char y, bool b); @@ -79,22 +79,22 @@ public: bool set_ice_wall(char x, char y, bool b); bool set_blade_wall(char x, char y, bool b); bool set_sleep_cloud(char x, char y, bool b); - void set_block(char x, char y, bool b); // currently unused - void set_special(char x, char y, bool b); + bool set_block(char x, char y, bool b); // currently unused + bool set_special(char x, char y, bool b); bool set_web(char x, char y, bool b); bool set_crate(char x, char y, bool b); bool set_barrel(char x, char y, bool b); bool set_fire_barr(char x, char y, bool b); bool set_force_barr(char x, char y, bool b); bool set_quickfire(char x, char y, bool b); - void set_sm_blood(char x, char y, bool b); - void set_med_blood(char x, char y, bool b); - void set_lg_blood(char x, char y, bool b); - void set_sm_slime(char x, char y, bool b); - void set_lg_slime(char x, char y, bool b); - void set_ash(char x, char y, bool b); - void set_bones(char x, char y, bool b); - void set_rubble(char x, char y, bool b); + bool set_sm_blood(char x, char y, bool b); + bool set_med_blood(char x, char y, bool b); + bool set_lg_blood(char x, char y, bool b); + bool set_sm_slime(char x, char y, bool b); + bool set_lg_slime(char x, char y, bool b); + bool set_ash(char x, char y, bool b); + bool set_bones(char x, char y, bool b); + bool set_rubble(char x, char y, bool b); }; class cCurOut {