diff --git a/osx/boe.actions.cpp b/osx/boe.actions.cpp index 3c181496..c3e3a065 100644 --- a/osx/boe.actions.cpp +++ b/osx/boe.actions.cpp @@ -186,12 +186,12 @@ void init_screen_locs() //// for (i = 0; i < 200; i++) for (j = 0; j < 8; j++) for (k = 0; k < 64; k++)//// - univ.town.maps[i][j][k] = 0; + univ.town_maps[i][j][k] = 0; for (i = 0; i < 100; i++) for (k = 0; k < 6; k++) for (l = 0; l < 48; l++) - univ.out.maps[i][k][l] = 0; + univ.out_maps[i][k][l] = 0; for (i = 0; i < 7; i++) { bottom_buttons[i].top = 383; diff --git a/osx/boe.combat.cpp b/osx/boe.combat.cpp index 4c11be8f..1f0a73fc 100644 --- a/osx/boe.combat.cpp +++ b/osx/boe.combat.cpp @@ -307,9 +307,9 @@ void start_outdoor_combat(cOutdoors::cCreature encounter,unsigned char in_which_ // the combat to take place in for (i = 0; i < 48; i++) for (j = 0; j < 48; j++) { - univ.town.explored[i][j] = 0; - univ.out.misc_i[i][j] = 0; - univ.out.sfx[i][j] = 0; + univ.town.fields[i][j] = 0; + //univ.out.misc_i[i][j] = 0; + //univ.out.sfx[i][j] = 0; } univ.town->in_town_rect = town_rect; @@ -835,7 +835,7 @@ void place_target(location target) add_string_to_buf(" Target space obstructed. "); return; } - if (is_antimagic(target.x,target.y)) { + if (univ.town.is_antimagic(target.x,target.y)) { add_string_to_buf(" Target in antimagic field."); return; } @@ -953,7 +953,7 @@ void do_combat_cast(location target)//// add_string_to_buf(" Target out of range."); else if ((get_obscurity(target.x,target.y) == 5) && (spell_being_cast != 41)) add_string_to_buf(" Target space obstructed. "); - else if (is_antimagic(target.x,target.y)) + else if (univ.town.is_antimagic(target.x,target.y)) add_string_to_buf(" Target in antimagic field."); else { if (ap_taken == false) { @@ -1003,8 +1003,8 @@ void do_combat_cast(location target)//// play_sound(68); r1 = get_ran(3,2,7); hit_space(target,r1,DAMAGE_FIRE,true,true); - make_fire_barrier(target.x,target.y); - if (is_fire_barrier(target.x,target.y)) + univ.town.set_fire_barr(target.x,target.y,true); + if (univ.town.is_fire_barr(target.x,target.y)) add_string_to_buf(" You create the barrier. "); else add_string_to_buf(" Failed."); break; @@ -1012,8 +1012,8 @@ void do_combat_cast(location target)//// play_sound(68); r1 = get_ran(7,2,7); hit_space(target,r1,DAMAGE_FIRE,true,true); - make_force_barrier(target.x,target.y); - if (is_force_barrier(target.x,target.y)) + univ.town.set_force_barr(target.x,target.y,true); + if (univ.town.is_force_barr(target.x,target.y)) add_string_to_buf(" You create the barrier. "); else add_string_to_buf(" Failed."); break; @@ -2857,7 +2857,7 @@ bool monst_cast_mage(cPopulation::cCreature *caster,short targ)//// {18,26,19,27}}; - if (is_antimagic(caster->m_loc.x,caster->m_loc.y)) { + if (univ.town.is_antimagic(caster->m_loc.x,caster->m_loc.y)) { return false; } // is target dead? @@ -2908,17 +2908,17 @@ bool monst_cast_mage(cPopulation::cCreature *caster,short targ)//// } if (targ >= 100) vict_loc = univ.town.monst.dudes[targ - 100].m_loc; - if ((targ == 6) && (is_antimagic(target.x,target.y))) + if ((targ == 6) && (univ.town.is_antimagic(target.x,target.y))) return false; // check antimagic if (is_combat()) - if ((targ < 6) && (is_antimagic(pc_pos[targ].x,pc_pos[targ].y))) + if ((targ < 6) && (univ.town.is_antimagic(pc_pos[targ].x,pc_pos[targ].y))) return false; if (is_town()) - if ((targ < 6) && (is_antimagic(univ.town.p_loc.x,univ.town.p_loc.y))) + if ((targ < 6) && (univ.town.is_antimagic(univ.town.p_loc.x,univ.town.p_loc.y))) return false; - if ((targ >= 100) && (is_antimagic(univ.town.monst.dudes[targ - 100].m_loc.x, + if ((targ >= 100) && (univ.town.is_antimagic(univ.town.monst.dudes[targ - 100].m_loc.x, univ.town.monst.dudes[targ - 100].m_loc.y))) return false; @@ -3179,7 +3179,7 @@ bool monst_cast_priest(cPopulation::cCreature *caster,short targ) return false; if ((targ >= 100) && (univ.town.monst.dudes[targ - 100].active == 0)) return false; - if (is_antimagic(caster->m_loc.x,caster->m_loc.y)) { + if (univ.town.is_antimagic(caster->m_loc.x,caster->m_loc.y)) { return false; } level = max(1,caster->m_d.cl - caster->m_d.status[9]) - 1; @@ -3215,11 +3215,11 @@ bool monst_cast_priest(cPopulation::cCreature *caster,short targ) vict_loc = (is_town()) ? univ.town.p_loc : pc_pos[targ]; if (targ >= 100) vict_loc = univ.town.monst.dudes[targ - 100].m_loc; - if ((targ == 6) && (is_antimagic(target.x,target.y))) + if ((targ == 6) && (univ.town.is_antimagic(target.x,target.y))) return false; - if ((targ < 6) && (is_antimagic(pc_pos[targ].x,pc_pos[targ].y))) + if ((targ < 6) && (univ.town.is_antimagic(pc_pos[targ].x,pc_pos[targ].y))) return false; - if ((targ >= 100) && (is_antimagic(univ.town.monst.dudes[targ - 100].m_loc.x, + if ((targ >= 100) && (univ.town.is_antimagic(univ.town.monst.dudes[targ - 100].m_loc.x, univ.town.monst.dudes[targ - 100].m_loc.y))) return false; @@ -3592,8 +3592,8 @@ void place_spell_pattern(effect_pat_type pat,location center,short type,bool pre effect = pat.pattern[i - center.x + 4][j - center.y + 4]; switch (effect) { case 1: web_space(i,j); break; - case 2: make_fire_barrier(i,j); break; - case 3: make_force_barrier(i,j); break; + case 2: univ.town.set_fire_barr(i,j,true); break; + case 3: univ.town.set_force_barr(i,j,true); break; case 4: make_force_wall(i,j); break; case 5: make_fire_wall(i,j); break; @@ -3832,7 +3832,7 @@ void hit_space(location target,short dam,eDamageType type,short report,short hit hit_all -= 10; } - if ((is_antimagic(target.x,target.y)) && ((type == 1) || (type == 3) || (type == 5))) { + if ((univ.town.is_antimagic(target.x,target.y)) && ((type == 1) || (type == 3) || (type == 5))) { return; } @@ -4045,7 +4045,7 @@ bool combat_cast_mage_spell() cPopulation::cCreature *which_m; cMonster get_monst; - if (is_antimagic(pc_pos[current_pc].x,pc_pos[current_pc].y)) { + if (univ.town.is_antimagic(pc_pos[current_pc].x,pc_pos[current_pc].y)) { add_string_to_buf(" Not in antimagic field."); return false; } @@ -4256,7 +4256,7 @@ bool combat_cast_priest_spell() {4,8,8,8,8,8,8,8,4}, {0,4,4,4,4,4,4,4,0}}}; - if (is_antimagic(pc_pos[current_pc].x,pc_pos[current_pc].y)) { + if (univ.town.is_antimagic(pc_pos[current_pc].x,pc_pos[current_pc].y)) { add_string_to_buf(" Not in antimagic field."); return false; } @@ -4513,11 +4513,11 @@ void process_fields() r = univ.town->in_town_rect; for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) - qf[i][j] = (is_quickfire(i,j)) ? 2 : 0; + qf[i][j] = (univ.town.is_quickfire(i,j)) ? 2 : 0; for (k = 0; k < ((is_combat()) ? 4 : 1); k++) { for (i = r.left + 1; i < r.right ; i++) for (j = r.top + 1; j < r.bottom ; j++) - if (is_quickfire(i,j) > 0) { + if (univ.town.is_quickfire(i,j) > 0) { r1 = get_ran(1,1,8); if (r1 != 1) { qf[i - 1][j] = 1; @@ -4544,13 +4544,13 @@ void process_fields() force_wall = false; for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) - if (is_force_wall(i,j)) { + if (univ.town.is_force_wall(i,j)) { r1 = get_ran(3,1,6); loc.x = i; loc.y = j; hit_pcs_in_space(loc,r1,DAMAGE_MAGIC,1,1); r1 = get_ran(1,1,6); if (r1 == 2) - take_force_wall(i,j); + univ.town.set_force_wall(i,j,false); else { force_wall = true; } @@ -4560,13 +4560,13 @@ void process_fields() fire_wall = false; for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) - if (is_fire_wall(i,j)) { + if (univ.town.is_fire_wall(i,j)) { loc.x = i; loc.y = j; r1 = get_ran(2,1,6) + 1; hit_pcs_in_space(loc,r1,DAMAGE_FIRE,1,1); r1 = get_ran(1,1,4); if (r1 == 2) - take_fire_wall(i,j); + univ.town.set_fire_wall(i,j,false); else { fire_wall = true; } @@ -4576,10 +4576,10 @@ void process_fields() antimagic = false; for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) - if (is_antimagic(i,j)) { + if (univ.town.is_antimagic(i,j)) { r1 = get_ran(1,1,8); if (r1 == 2) - take_antimagic(i,j); + univ.town.set_antimagic(i,j,false); else antimagic = true; } } @@ -4587,10 +4587,10 @@ void process_fields() scloud = false; for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) - if (is_scloud(i,j)) { + if (univ.town.is_scloud(i,j)) { r1 = get_ran(1,1,4); if (r1 == 2) - take_scloud(i,j); + univ.town.set_scloud(i,j,false); else { scloud_space(i,j); scloud = true; @@ -4601,10 +4601,10 @@ void process_fields() sleep_field = false; for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) - if (is_sleep_cloud(i,j)) { + if (univ.town.is_sleep_cloud(i,j)) { r1 = get_ran(1,1,4); if (r1 == 2) - take_sleep_cloud(i,j); + univ.town.set_sleep_cloud(i,j,false); else { sleep_cloud_space(i,j); sleep_field = true; @@ -4615,13 +4615,13 @@ void process_fields() ice_wall = false; for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) - if (is_ice_wall(i,j)) { + if (univ.town.is_ice_wall(i,j)) { loc.x = i; loc.y = j; r1 = get_ran(3,1,6); hit_pcs_in_space(loc,r1,DAMAGE_COLD,1,1); r1 = get_ran(1,1,6); if (r1 == 1) - take_ice_wall(i,j); + univ.town.set_ice_wall(i,j,false); else { ice_wall = true; } @@ -4631,13 +4631,13 @@ void process_fields() blade_wall = false; for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) - if (is_blade_wall(i,j)) { + if (univ.town.is_blade_wall(i,j)) { loc.x = i; loc.y = j; r1 = get_ran(6,1,8); hit_pcs_in_space(loc,r1,DAMAGE_WEAPON,1,1); r1 = get_ran(1,1,5); if (r1 == 1) - take_blade_wall(i,j); + univ.town.set_blade_wall(i,j,false); else { blade_wall = true; } @@ -4651,7 +4651,7 @@ void process_fields() if (quickfire) { for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) - if (is_quickfire(i,j)) { + if (univ.town.is_quickfire(i,j)) { loc.x = i; loc.y = j; r1 = get_ran(2,1,8); hit_pcs_in_space(loc,r1,DAMAGE_FIRE,1,1); diff --git a/osx/boe.fields.cpp b/osx/boe.fields.cpp index bbf64cb2..8f661294 100644 --- a/osx/boe.fields.cpp +++ b/osx/boe.fields.cpp @@ -26,23 +26,26 @@ bool is_explored(short i,short j) { if (is_out()) return (univ.out.out_e[i][j] != 0) ? true : false; - if (univ.town.explored[i][j] & 1) { - return true; - } - else return false; + else return univ.town.is_explored(i,j); +// if (univ.town.explored[i][j] & 1) { +// return true; +// } +// else return false; } void make_explored(short i,short j) { if (is_out()) univ.out.out_e[i][j] = 1; - univ.town.explored[i][j] = univ.town.explored[i][j] | 1; +// univ.town.explored[i][j] = univ.town.explored[i][j] | 1; + else univ.town.set_explored(i,j,true); } void take_explored(short i,short j) { if (is_out()) univ.out.out_e[i][j] = 0; - univ.town.explored[i][j] = univ.town.explored[i][j] & 254; +// univ.town.explored[i][j] = univ.town.explored[i][j] & 254; + else univ.town.set_explored(i,j,false); } bool is_out() @@ -66,334 +69,367 @@ bool is_combat() -bool special(short i,short j) -/**/{ - if (((univ.out.misc_i[i][j]) & 2) != 0) - return true; - else return false; -} -void flip_special(short i,short j) -/**/{ - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] ^ (char) (2); -} -void make_special(short i,short j) -/**/{ - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | (char) (2); -} -void take_special(short i,short j) -/**/{ - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 253; -} +//bool special(short i,short j) +///**/{ +// if (((univ.out.misc_i[i][j]) & 2) != 0) +// return true; +// else return false; +//} +//void flip_special(short i,short j) +///**/{ +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] ^ (char) (2); +//} +//void make_special(short i,short j) +///**/{ +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | (char) (2); +//} +//void take_special(short i,short j) +///**/{ +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 253; +//} -bool is_web(short i,short j) -/**/{ - return (univ.out.misc_i[i][j] & 4) ? true : false; -} +//bool is_web(short i,short j) +///**/{ +// return (univ.out.misc_i[i][j] & 4) ? true : false; +//} void make_web(short i,short j) /**/{ if (spot_impassable(i,j) == true) return; - if ((univ.out.misc_i[i][j] & 224) || (univ.town.explored[i][j] & 238)) - return; - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 4; - web = true; -} -void take_web(short i,short j) -/**/{ - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 251; -} - -bool is_crate(short i,short j) -/**/{ - return (univ.out.misc_i[i][j] & 8) ? true : false; -} -void make_crate(short i,short j) -/**/{ -// if (univ.out.misc_i[i][j] & 240) +// if ((univ.out.misc_i[i][j] & 224) || (univ.town.explored[i][j] & 238)) // return; - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 8; - crate = true; -} -void take_crate(short i,short j) -/**/{ - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 247; +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 4; + web = univ.town.set_web(i,j,true); +// web = true; } +//void take_web(short i,short j) +///**/{ +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 251; +//} -bool is_barrel(short i,short j) -/**/{ - return (univ.out.misc_i[i][j] & 16) ? true : false; -} -void make_barrel(short i,short j) -/**/{ -// if (univ.out.misc_i[i][j] & 234) +//bool is_crate(short i,short j) +///**/{ +// return (univ.out.misc_i[i][j] & 8) ? true : false; +//} +//void make_crate(short i,short j) +///**/{ +//// if (univ.out.misc_i[i][j] & 240) +//// return; +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 8; +// crate = true; +//} +//void take_crate(short i,short j) +///**/{ +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 247; +//} + +//bool is_barrel(short i,short j) +///**/{ +// return (univ.out.misc_i[i][j] & 16) ? true : false; +//} +//void make_barrel(short i,short j) +///**/{ +//// if (univ.out.misc_i[i][j] & 234) +//// return; +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 16; +// barrel = true; +//} +//void take_barrel(short i,short j) +///**/{ +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 239; +//} + +//bool is_fire_barrier(short i,short j) +///**/{ +// return (univ.out.misc_i[i][j] & 32) ? true : false; +//} +//void make_fire_barrier(short i,short j) +///**/{ +// if ((is_antimagic(i,j)) && (get_ran(1,0,3) < 3)) // return; - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 16; - barrel = true; -} -void take_barrel(short i,short j) -/**/{ - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 239; -} +// if (univ.out.misc_i[i][j] & 248) +// return; +// take_web(i,j); +// univ.town.explored[i][j] = univ.town.explored[i][j] & 1; +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 32; +// fire_barrier = true; +//} +//void take_fire_barrier(short i,short j) +///**/{ +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 223; +//} -bool is_fire_barrier(short i,short j) -/**/{ - return (univ.out.misc_i[i][j] & 32) ? true : false; -} -void make_fire_barrier(short i,short j) -/**/{ - if ((is_antimagic(i,j)) && (get_ran(1,0,3) < 3)) - return; - if (univ.out.misc_i[i][j] & 248) - return; - take_web(i,j); - univ.town.explored[i][j] = univ.town.explored[i][j] & 1; - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 32; - fire_barrier = true; -} -void take_fire_barrier(short i,short j) -/**/{ - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 223; -} +//bool is_force_barrier(short i,short j) +///**/{ +// return (univ.out.misc_i[i][j] & 64) ? true : false; +//} +//void make_force_barrier(short i,short j) +///**/{ +// if ((is_antimagic(i,j)) && (get_ran(1,0,2) < 2)) +// return; +// if (univ.out.misc_i[i][j] & 248) +// return; +// take_web(i,j); +// univ.town.explored[i][j] = univ.town.explored[i][j] & 1; +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 64; +// force_barrier = true; +//} +//void take_force_barrier(short i,short j) +///**/{ +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 191; +//} -bool is_force_barrier(short i,short j) -/**/{ - return (univ.out.misc_i[i][j] & 64) ? true : false; -} -void make_force_barrier(short i,short j) -/**/{ - if ((is_antimagic(i,j)) && (get_ran(1,0,2) < 2)) - return; - if (univ.out.misc_i[i][j] & 248) - return; - take_web(i,j); - univ.town.explored[i][j] = univ.town.explored[i][j] & 1; - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 64; - force_barrier = true; -} -void take_force_barrier(short i,short j) -/**/{ - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 191; -} - -bool is_quickfire(short i,short j) -/**/{ - return (univ.out.misc_i[i][j] & 128) ? true : false; -} +//bool is_quickfire(short i,short j) +///**/{ +// return (univ.out.misc_i[i][j] & 128) ? true : false; +//} void make_quickfire(short i,short j) /**/{//// - unsigned char ter; - - if ((is_antimagic(i,j)) && (get_ran(1,0,1) == 0)) - return; - if ((is_force_barrier(i,j)) || (is_fire_barrier(i,j))) - return; + unsigned short ter; +// +// if ((is_antimagic(i,j)) && (get_ran(1,0,1) == 0)) +// return; +// if ((is_force_barrier(i,j)) || (is_fire_barrier(i,j))) +// return; ter = coord_to_ter(i,j); if (scenario.ter_types[ter].blockage == 1) return; if (scenario.ter_types[ter].blockage == 5) return; - univ.town.explored[i][j] = univ.town.explored[i][j] & 1; - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 3; - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 128; - quickfire = true; -} -void take_quickfire(short i,short j) -/**/{ - univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 127; +// univ.town.explored[i][j] = univ.town.explored[i][j] & 1; +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 3; +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] | 128; + quickfire = univ.town.set_quickfire(i,j,true); +// quickfire = true; } +//void take_quickfire(short i,short j) +///**/{ +// univ.out.misc_i[i][j] = univ.out.misc_i[i][j] & 127; +//} -bool is_force_wall(short i,short j) -/**/{ - return (univ.town.explored[i][j] & 2) ? true : false; -} +//bool is_force_wall(short i,short j) +///**/{ +// return (univ.town.explored[i][j] & 2) ? true : false; +//} void make_force_wall(short i,short j) /**/{ if (spot_impassable(i,j) == true) return; - if ((univ.town.explored[i][j] & 74) || (univ.out.misc_i[i][j] & 248)) - return; - take_web(i,j); - take_fire_wall(i,j); - univ.town.explored[i][j] = univ.town.explored[i][j] | 2; - force_wall = true; -} -void take_force_wall(short i,short j) -/**/{ - univ.town.explored[i][j] = univ.town.explored[i][j] & 253; +// if ((univ.town.explored[i][j] & 74) || (univ.out.misc_i[i][j] & 248)) +// return; +// take_web(i,j); +// take_fire_wall(i,j); +// univ.town.explored[i][j] = univ.town.explored[i][j] | 2; + force_wall = univ.town.set_force_wall(i,j,true); +// force_wall = true; } +//void take_force_wall(short i,short j) +///**/{ +// univ.town.explored[i][j] = univ.town.explored[i][j] & 253; +//} -bool is_fire_wall(short i,short j) -/**/{ - return (univ.town.explored[i][j] & 4) ? true : false; -} +//bool is_fire_wall(short i,short j) +///**/{ +// return (univ.town.explored[i][j] & 4) ? true : false; +//} void make_fire_wall(short i,short j) /**/{ if (spot_impassable(i,j) == true) return; - if ((univ.town.explored[i][j] & 248) || (univ.out.misc_i[i][j] & 254)) - return; - take_web(i,j); - univ.town.explored[i][j] = univ.town.explored[i][j] | 4; - fire_wall = true; -} -void take_fire_wall(short i,short j) -/**/{ - univ.town.explored[i][j] = univ.town.explored[i][j] & 251; +// if ((univ.town.explored[i][j] & 248) || (univ.out.misc_i[i][j] & 254)) +// return; +// take_web(i,j); +// univ.town.explored[i][j] = univ.town.explored[i][j] | 4; + fire_wall = univ.town.set_fire_wall(i,j,true); +// fire_wall = true; } +//void take_fire_wall(short i,short j) +///**/{ +// univ.town.explored[i][j] = univ.town.explored[i][j] & 251; +//} -bool is_antimagic(short i,short j) -/**/{ - return (univ.town.explored[i][j] & 8) ? true : false; -} +//bool is_antimagic(short i,short j) +///**/{ +// return (univ.town.explored[i][j] & 8) ? true : false; +//} void make_antimagic(short i,short j) /**/{ if (spot_impassable(i,j) == true) return; - if (univ.out.misc_i[i][j] & 224) - return; - - univ.town.explored[i][j] = univ.town.explored[i][j] & 1; - univ.town.explored[i][j] = univ.town.explored[i][j] | 8; - antimagic = true; -} -void take_antimagic(short i,short j) -/**/{ - univ.town.explored[i][j] = univ.town.explored[i][j] & 247; +// if (univ.out.misc_i[i][j] & 224) +// return; +// +// univ.town.explored[i][j] = univ.town.explored[i][j] & 1; +// univ.town.explored[i][j] = univ.town.explored[i][j] | 8; + antimagic = univ.town.set_antimagic(i,j,true); +// antimagic = true; } +//void take_antimagic(short i,short j) +///**/{ +// univ.town.explored[i][j] = univ.town.explored[i][j] & 247; +//} -bool is_scloud(short i,short j) -/**/{ - return (univ.town.explored[i][j] & 16) ? true : false; -} +//bool is_scloud(short i,short j) +///**/{ +// return (univ.town.explored[i][j] & 16) ? true : false; +//} void make_scloud(short i,short j) /**/{ if (spot_impassable(i,j) == true) return; - - if ((univ.town.explored[i][j] & 238) || (univ.out.misc_i[i][j] & 224)) - return; - univ.town.explored[i][j] = univ.town.explored[i][j] | 16; - scloud = true; -} -void take_scloud(short i,short j) -/**/{ - univ.town.explored[i][j] = univ.town.explored[i][j] & 239; +// +// if ((univ.town.explored[i][j] & 238) || (univ.out.misc_i[i][j] & 224)) +// return; +// univ.town.explored[i][j] = univ.town.explored[i][j] | 16; + scloud = univ.town.set_scloud(i,j,true); +// scloud = true; } +//void take_scloud(short i,short j) +///**/{ +// univ.town.explored[i][j] = univ.town.explored[i][j] & 239; +//} -bool is_ice_wall(short i,short j) -/**/{ - return (univ.town.explored[i][j] & 32) ? true : false; -} +//bool is_ice_wall(short i,short j) +///**/{ +// return (univ.town.explored[i][j] & 32) ? true : false; +//} void make_ice_wall(short i,short j) /**/{ if (spot_impassable(i,j) == true) return; - if ((univ.town.explored[i][j] & 74) || (univ.out.misc_i[i][j] & 252)) - return; - take_fire_wall(i,j); - take_scloud(i,j); - univ.town.explored[i][j] = univ.town.explored[i][j] | 32; - ice_wall = true; -} -void take_ice_wall(short i,short j) -/**/{ - univ.town.explored[i][j] = univ.town.explored[i][j] & 223; +// if ((univ.town.explored[i][j] & 74) || (univ.out.misc_i[i][j] & 252)) +// return; +// take_fire_wall(i,j); +// take_scloud(i,j); +// univ.town.explored[i][j] = univ.town.explored[i][j] | 32; + ice_wall = univ.town.set_ice_wall(i,j,true); +// ice_wall = true; } +//void take_ice_wall(short i,short j) +///**/{ +// univ.town.explored[i][j] = univ.town.explored[i][j] & 223; +//} -bool is_blade_wall(short i,short j) -/**/{ - return (univ.town.explored[i][j] & 64) ? true : false; -} +//bool is_blade_wall(short i,short j) +///**/{ +// return (univ.town.explored[i][j] & 64) ? true : false; +//} void make_blade_wall(short i,short j) /**/{ if (spot_impassable(i,j) == true) return; - if ((univ.town.explored[i][j] & 8) || (univ.out.misc_i[i][j] & 224)) - return; - univ.town.explored[i][j] = univ.town.explored[i][j] & 9; - univ.town.explored[i][j] = univ.town.explored[i][j] | 64; - blade_wall = true; -} -void take_blade_wall(short i,short j) -/**/{ - univ.town.explored[i][j] = univ.town.explored[i][j] & 191; -} -bool is_sleep_cloud(short i,short j) -/**/{ - return (univ.town.explored[i][j] & 128) ? true : false; +// if ((univ.town.explored[i][j] & 8) || (univ.out.misc_i[i][j] & 224)) +// return; +// univ.town.explored[i][j] = univ.town.explored[i][j] & 9; +// univ.town.explored[i][j] = univ.town.explored[i][j] | 64; + blade_wall = univ.town.set_blade_wall(i,j,true); +// blade_wall = true; } +//void take_blade_wall(short i,short j) +///**/{ +// univ.town.explored[i][j] = univ.town.explored[i][j] & 191; +//} +//bool is_sleep_cloud(short i,short j) +///**/{ +// return (univ.town.explored[i][j] & 128) ? true : false; +//} void make_sleep_cloud(short i,short j) /**/{ if (spot_impassable(i,j) == true) return; - if ((univ.town.explored[i][j] & 8) || (univ.out.misc_i[i][j] & 224)) - return; - univ.town.explored[i][j] = univ.town.explored[i][j] & 9; - univ.town.explored[i][j] = univ.town.explored[i][j] | 128; - sleep_field = true; -} -void take_sleep_cloud(short i,short j) -/**/{ - univ.town.explored[i][j] = univ.town.explored[i][j] & 127; +// if ((univ.town.explored[i][j] & 8) || (univ.out.misc_i[i][j] & 224)) +// return; +// univ.town.explored[i][j] = univ.town.explored[i][j] & 9; +// univ.town.explored[i][j] = univ.town.explored[i][j] | 128; + sleep_field = univ.town.set_sleep_cloud(i,j,true); +// sleep_field = true; } +//void take_sleep_cloud(short i,short j) +///**/{ +// univ.town.explored[i][j] = univ.town.explored[i][j] & 127; +//} // START SFX -bool is_small_blood(short i,short j) -{ - return (univ.out.sfx[i][j] & 1) ? true : false; -} -bool is_medium_blood(short i,short j) -{ - return (univ.out.sfx[i][j] & 2) ? true : false; -} -bool is_large_blood(short i,short j) -{ - return (univ.out.sfx[i][j] & 4) ? true : false; -} -bool is_small_slime(short i,short j) -{ - return (univ.out.sfx[i][j] & 8) ? true : false; -} -bool is_big_slime(short i,short j) -{ - return (univ.out.sfx[i][j] & 16) ? true : false; -} -bool is_ash(short i,short j) -{ - return (univ.out.sfx[i][j] & 32) ? true : false; -} -bool is_bones(short i,short j) -{ - return (univ.out.sfx[i][j] & 64) ? true : false; -} -bool is_rubble(short i,short j) -{ - return (univ.out.sfx[i][j] & 128) ? true : false; -} +//bool is_small_blood(short i,short j) +//{ +// return (univ.out.sfx[i][j] & 1) ? true : false; +//} +//bool is_medium_blood(short i,short j) +//{ +// return (univ.out.sfx[i][j] & 2) ? true : false; +//} +//bool is_large_blood(short i,short j) +//{ +// return (univ.out.sfx[i][j] & 4) ? true : false; +//} +//bool is_small_slime(short i,short j) +//{ +// return (univ.out.sfx[i][j] & 8) ? true : false; +//} +//bool is_big_slime(short i,short j) +//{ +// return (univ.out.sfx[i][j] & 16) ? true : false; +//} +//bool is_ash(short i,short j) +//{ +// return (univ.out.sfx[i][j] & 32) ? true : false; +//} +//bool is_bones(short i,short j) +//{ +// return (univ.out.sfx[i][j] & 64) ? true : false; +//} +//bool is_rubble(short i,short j) +//{ +// return (univ.out.sfx[i][j] & 128) ? true : false; +//} void make_sfx(short i,short j, short type) { - unsigned char ter; - + unsigned char ter, cur_sfx, new_sfx; + if (get_obscurity(i,j) > 0) return; ter = coord_to_ter(i,j); if (terrain_blocked[ter] != 0) return; switch (type) { - case 1: case 2: - if (univ.out.sfx[i][j] == 4) - return; - if (univ.out.sfx[i][j] < 4) - type = min(3,type + univ.out.sfx[i][j]); +// case 1: case 2: +// if (univ.out.sfx[i][j] == 4) +// return; +// if (univ.out.sfx[i][j] < 4) +// type = min(3,type + univ.out.sfx[i][j]); +// break; +// case 4: +// if (univ.out.sfx[i][j] == 8) +// type = 5; +// break; + case 1: + univ.town.set_sm_blood(i,j,true); + break; + case 2: + univ.town.set_med_blood(i,j,true); + break; + case 3: + univ.town.set_lg_blood(i,j,true); break; case 4: - if (univ.out.sfx[i][j] == 8) - type = 5; + univ.town.set_sm_slime(i,j,true); break; - } - univ.out.sfx[i][j] = s_pow(2,type - 1); + case 5: + univ.town.set_lg_slime(i,j,true); + break; + case 6: + univ.town.set_ash(i,j,true); + break; + case 7: + univ.town.set_bones(i,j,true); + break; + case 8: + univ.town.set_rubble(i,j,true); + break; + } +// univ.out.sfx[i][j] = s_pow(2,type - 1); } void spread_sfx(short type,short prob) diff --git a/osx/boe.fields.h b/osx/boe.fields.h index 43bc5cc6..bed96ecc 100644 --- a/osx/boe.fields.h +++ b/osx/boe.fields.h @@ -4,58 +4,58 @@ void take_explored(short i,short j); bool is_out(); bool is_town(); bool is_combat(); -bool special(short i,short j); -void flip_special(short i,short j); -void make_special(short i,short j); -void take_special(short i,short j); -bool is_web(short i,short j); +//bool special(short i,short j); +//void flip_special(short i,short j); +//void make_special(short i,short j); +//void take_special(short i,short j); +//bool is_web(short i,short j); void make_web(short i,short j); -void take_web(short i,short j); -bool is_crate(short i,short j); -void make_crate(short i,short j); -void take_crate(short i,short j); -bool is_barrel(short i,short j); -void make_barrel(short i,short j); -void take_barrel(short i,short j); -bool is_fire_barrier(short i,short j); -void make_fire_barrier(short i,short j); -void take_fire_barrier(short i,short j); -bool is_force_barrier(short i,short j); -void make_force_barrier(short i,short j); -void take_force_barrier(short i,short j); -bool is_quickfire(short i,short j); +//void take_web(short i,short j); +//bool is_crate(short i,short j); +//void make_crate(short i,short j); +//void take_crate(short i,short j); +//bool is_barrel(short i,short j); +//void make_barrel(short i,short j); +//void take_barrel(short i,short j); +//bool is_fire_barrier(short i,short j); +//void make_fire_barrier(short i,short j); +//void take_fire_barrier(short i,short j); +//bool is_force_barrier(short i,short j); +//void make_force_barrier(short i,short j); +//void take_force_barrier(short i,short j); +//bool is_quickfire(short i,short j); void make_quickfire(short i,short j); -void take_quickfire(short i,short j); -bool is_force_wall(short i,short j); +//void take_quickfire(short i,short j); +//bool is_force_wall(short i,short j); void make_force_wall(short i,short j); -void take_force_wall(short i,short j); -bool is_fire_wall(short i,short j); +//void take_force_wall(short i,short j); +//bool is_fire_wall(short i,short j); void make_fire_wall(short i,short j); -void take_fire_wall(short i,short j); -bool is_antimagic(short i,short j); +//void take_fire_wall(short i,short j); +//bool is_antimagic(short i,short j); void make_antimagic(short i,short j); -void take_antimagic(short i,short j); -bool is_scloud(short i,short j); +//void take_antimagic(short i,short j); +//bool is_scloud(short i,short j); void make_scloud(short i,short j); -void take_scloud(short i,short j); -bool is_ice_wall(short i,short j); +//void take_scloud(short i,short j); +//bool is_ice_wall(short i,short j); void make_ice_wall(short i,short j); -void take_ice_wall(short i,short j); -bool is_blade_wall(short i,short j); +//void take_ice_wall(short i,short j); +//bool is_blade_wall(short i,short j); void make_blade_wall(short i,short j); -void take_blade_wall(short i,short j); -bool is_sleep_cloud(short i,short j); +//void take_blade_wall(short i,short j); +//bool is_sleep_cloud(short i,short j); void make_sleep_cloud(short i,short j); -void take_sleep_cloud(short i,short j); +//void take_sleep_cloud(short i,short j); -bool is_small_blood(short i,short j); -bool is_medium_blood(short i,short j); -bool is_large_blood(short i,short j); -bool is_small_slime(short i,short j); -bool is_big_slime(short i,short j); -bool is_ash(short i,short j); -bool is_bones(short i,short j); -bool is_rubble(short i,short j); +//bool is_small_blood(short i,short j); +//bool is_medium_blood(short i,short j); +//bool is_large_blood(short i,short j); +//bool is_small_slime(short i,short j); +//bool is_big_slime(short i,short j); +//bool is_ash(short i,short j); +//bool is_bones(short i,short j); +//bool is_rubble(short i,short j); void make_sfx(short i,short j, short type); void spread_sfx(short type,short prob); diff --git a/osx/boe.fileio.cpp b/osx/boe.fileio.cpp index f9bf3a39..cf21de00 100644 --- a/osx/boe.fileio.cpp +++ b/osx/boe.fileio.cpp @@ -237,17 +237,17 @@ void finish_load_party(){ // Set up field booleans for (int j = 0; j < univ.town->max_dim(); j++) for (int k = 0; k < univ.town->max_dim(); k++) { - if (is_web(j,k) == true) + if (univ.town.is_web(j,k) == true) web = true; - if (is_crate(j,k) == true) + if (univ.town.is_crate(j,k) == true) crate = true; - if (is_barrel(j,k) == true) + if (univ.town.is_barrel(j,k) == true) barrel = true; - if (is_fire_barrier(j,k) == true) + if (univ.town.is_fire_barr(j,k) == true) fire_barrier = true; - if (is_force_barrier(j,k) == true) + if (univ.town.is_force_barr(j,k) == true) force_barrier = true; - if (is_quickfire(j,k) == true) + if (univ.town.is_quickfire(j,k) == true) quickfire = true; if ((scenario.ter_types[univ.town->terrain(j,k)].special >= 16) && (scenario.ter_types[univ.town->terrain(j,k)].special <= 19)) @@ -541,22 +541,62 @@ void init_town(){ // formerly part of load_town int i,j; for (i = 0; i < 64; i++) for (j = 0; j < 64; j++) { - univ.out.misc_i[i][j] = 0; - univ.out.sfx[i][j] = 0; + univ.town.fields[i][j] = 0; + //univ.out.sfx[i][j] = 0; } for (i = 0; i < 50; i++) if ((univ.town->spec_id[i] >= 0) && (univ.town->special_locs[i].x < 100)){ - make_special(univ.town->special_locs[i].x,univ.town->special_locs[i].y); + univ.town.set_special(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); } for (i = 0; i < 50; i++) { - if ((univ.town->preset_fields[i].type > 0) && (univ.town->preset_fields[i].type < 9)) - univ.out.misc_i[univ.town->preset_fields[i].loc.x][univ.town->preset_fields[i].loc.y] = - univ.out.misc_i[univ.town->preset_fields[i].loc.x][univ.town->preset_fields[i].loc.y] | - (unsigned char) (s_pow(2,univ.town->preset_fields[i].type - 1)); - if ((univ.town->preset_fields[i].type >= 14) && (univ.town->preset_fields[i].type <= 21)) - univ.out.sfx[univ.town->preset_fields[i].loc.x][univ.town->preset_fields[i].loc.y] = - univ.out.sfx[univ.town->preset_fields[i].loc.x][univ.town->preset_fields[i].loc.y] | - (unsigned char) (s_pow(2,univ.town->preset_fields[i].type - 14)); + switch(univ.town->preset_fields[i].type){ + case 1: // currently unused + univ.town.set_block(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + // case 2 is covered by the preceding loop + case 3: + univ.town.set_web(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 4: + univ.town.set_crate(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 5: + univ.town.set_barrel(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 6: + univ.town.set_fire_barr(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 7: + univ.town.set_force_barr(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 8: + univ.town.set_quickfire(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 14: + univ.town.set_sm_blood(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 15: + univ.town.set_med_blood(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 16: + univ.town.set_lg_blood(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 17: + univ.town.set_sm_slime(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 18: + univ.town.set_lg_slime(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 19: + univ.town.set_ash(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 20: + univ.town.set_bones(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + case 21: + univ.town.set_rubble(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true); + break; + } } // univ.town.cur_talk_loaded = univ.town.town_num; @@ -797,26 +837,26 @@ void save_outdoor_maps() for (i = 0; i < 48; i++) for (j = 0; j < 48; j++) { if (univ.out.out_e[i][j] > 0) - univ.out.maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y)][i / 8][j] = - univ.out.maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y)][i / 8][j] | + univ.out_maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y)][i / 8][j] = + univ.out_maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y)][i / 8][j] | (char) (s_pow(2,i % 8)); if (univ.party.outdoor_corner.x + 1 < scenario.out_width) { if (univ.out.out_e[i + 48][j] > 0) - univ.out.maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y)][i / 8][j] = - univ.out.maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y)][i / 8][j] | + univ.out_maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y)][i / 8][j] = + univ.out_maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y)][i / 8][j] | (char) (s_pow(2,i % 8)); } if (univ.party.outdoor_corner.y + 1 < scenario.out_height) { if (univ.out.out_e[i][j + 48] > 0) - univ.out.maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y + 1)][i / 8][j] = - univ.out.maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y + 1)][i / 8][j] | + univ.out_maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y + 1)][i / 8][j] = + univ.out_maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y + 1)][i / 8][j] | (char) (s_pow(2,i % 8)); } if ((univ.party.outdoor_corner.y + 1 < scenario.out_height) && (univ.party.outdoor_corner.x + 1 < scenario.out_width)) { if (univ.out.out_e[i + 48][j + 48] > 0) - univ.out.maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y + 1)][i / 8][j] = - univ.out.maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y + 1)][i / 8][j] | + univ.out_maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y + 1)][i / 8][j] = + univ.out_maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y + 1)][i / 8][j] | (char) (s_pow(2,i % 8)); } } @@ -830,25 +870,25 @@ void add_outdoor_maps() // This takes the existing outdoor map info and supplem for (i = 0; i < 48; i++) for (j = 0; j < 48; j++) { if ((univ.out.out_e[i][j] == 0) && - ((univ.out.maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y)][i / 8][j] & + ((univ.out_maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y)][i / 8][j] & (char) (s_pow(2,i % 8))) != 0)) univ.out.out_e[i][j] = 1; if (univ.party.outdoor_corner.x + 1 < scenario.out_width) { if ((univ.out.out_e[i + 48][j] == 0) && - ((univ.out.maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y)][i / 8][j] & + ((univ.out_maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y)][i / 8][j] & (char) (s_pow(2,i % 8))) != 0)) univ.out.out_e[i + 48][j] = 1; } if (univ.party.outdoor_corner.y + 1 < scenario.out_height) { if ((univ.out.out_e[i][j + 48] == 0) && - ((univ.out.maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y + 1)][i / 8][j] & + ((univ.out_maps[onm(univ.party.outdoor_corner.x,univ.party.outdoor_corner.y + 1)][i / 8][j] & (char) (s_pow(2,i % 8))) != 0)) univ.out.out_e[i][j + 48] = 1; } if ((univ.party.outdoor_corner.y + 1 < scenario.out_height) && (univ.party.outdoor_corner.x + 1 < scenario.out_width)) { if ((univ.out.out_e[i + 48][j + 48] == 0) && - ((univ.out.maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y + 1)][i / 8][j] & + ((univ.out_maps[onm(univ.party.outdoor_corner.x + 1,univ.party.outdoor_corner.y + 1)][i / 8][j] & (char) (s_pow(2,i % 8))) != 0)) univ.out.out_e[i + 48][j + 48] = 1; } diff --git a/osx/boe.graphutil.cpp b/osx/boe.graphutil.cpp index 826348be..04b54866 100644 --- a/osx/boe.graphutil.cpp +++ b/osx/boe.graphutil.cpp @@ -584,17 +584,20 @@ void draw_sfx() for (q = 0; q < 9; q++) for (r = 0; r < 9; r++) { - where_draw = center;where_draw.x += q - 4;where_draw.y += r - 4; + where_draw = center; + where_draw.x += q - 4; + where_draw.y += r - 4; if ((where_draw.x < 0) || (where_draw.x > univ.town->max_dim() - 1) || (where_draw.y < 0) || (where_draw.y > univ.town->max_dim() - 1)) ; - else if (univ.out.sfx[where_draw.x][where_draw.y] != 0) { + else if (univ.town.sfx(where_draw.x,where_draw.y) != 0) { for (i = 0; i < 8; i++) { flag = s_pow(2,i); - if (univ.out.sfx[where_draw.x][where_draw.y] & flag) + if (univ.town.sfx(where_draw.x,where_draw.y) & flag) if (spot_seen[q][r] > 0) { - loc.x = q; loc.y = r; + loc.x = q; + loc.y = r; source_rect = orig_rect; OffsetRect(&source_rect,28 * i,36 * 3); Draw_Some_Item(fields_gworld,source_rect,terrain_screen_gworld,loc, @@ -621,7 +624,7 @@ void draw_one_field(unsigned char flag,short source_x,short source_y) || (where_draw.y < 0) || (where_draw.y > univ.town->max_dim() - 1)) ; else { - if (univ.out.misc_i[where_draw.x][where_draw.y] & flag) + if (univ.town.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; @@ -652,7 +655,7 @@ void draw_one_spec_item(unsigned char flag,short source_x,short source_y) || (where_draw.y < 0) || (where_draw.y > univ.town->max_dim() - 1)) ; else { - if (univ.town.explored[where_draw.x][where_draw.y] & flag) + if (univ.town.explored(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.locutils.cpp b/osx/boe.locutils.cpp index df36ac04..080d0a13 100644 --- a/osx/boe.locutils.cpp +++ b/osx/boe.locutils.cpp @@ -284,25 +284,25 @@ short get_obscurity(short x,short y) store = get_blockage(what_terrain); if (is_town()) { - if (special(x,y)) + if (univ.town.is_special(x,y)) store++; } if ((is_town()) || (is_combat())) { - if (is_web(x,y)) + if (univ.town.is_web(x,y)) store += 2; - if ((is_fire_barrier(x,y)) || (is_force_barrier(x,y))) + if ((univ.town.is_fire_barr(x,y)) || (univ.town.is_force_barr(x,y))) return 5; - if ((is_crate(x,y)) || (is_barrel(x,y))) + if ((univ.town.is_crate(x,y)) || (univ.town.is_barrel(x,y))) store++; } return store; } -unsigned char coord_to_ter(short x,short y) +unsigned short coord_to_ter(short x,short y) { - char what_terrain; + unsigned short what_terrain; if ((overall_mode == MODE_OUTDOORS) || (overall_mode == MODE_LOOK_OUTDOORS)) what_terrain = univ.out.out[x][y]; @@ -319,7 +319,7 @@ bool is_container(location loc) { unsigned char ter; - if ((is_barrel(loc.x,loc.y)) || (is_crate(loc.x,loc.y))) + if ((univ.town.is_barrel(loc.x,loc.y)) || (univ.town.is_crate(loc.x,loc.y))) return true; ter = coord_to_ter(loc.x,loc.y); if (scenario.ter_types[ter].special == 14) @@ -412,7 +412,7 @@ bool is_blocked(location to_check) return true; // Magic barrier? - if (is_force_barrier(to_check.x,to_check.y)) + if (univ.town.is_force_barr(to_check.x,to_check.y)) return true; return false; diff --git a/osx/boe.locutils.h b/osx/boe.locutils.h index 1034a80a..81b41012 100644 --- a/osx/boe.locutils.h +++ b/osx/boe.locutils.h @@ -14,7 +14,7 @@ short short_can_see(shortloc p1,shortloc p2); bool is_lava(short x,short y); short can_see(location p1,location p2,short mode); short get_obscurity(short x,short y); -unsigned char coord_to_ter(short x,short y); +unsigned short coord_to_ter(short x,short y); bool is_container(location loc); void update_explored(location dest); bool is_blocked(location to_check); diff --git a/osx/boe.monster.cpp b/osx/boe.monster.cpp index a4b445fb..bd19e720 100644 --- a/osx/boe.monster.cpp +++ b/osx/boe.monster.cpp @@ -401,20 +401,20 @@ bool monst_hate_spot(short which_m,location *good_loc) location prospect,loc; loc = univ.town.monst.dudes[which_m].m_loc; - if ((univ.out.misc_i[loc.x][loc.y] & 224) - || (univ.town.explored[loc.x][loc.y] & 64) // hate regular fields - || ((univ.town.explored[loc.x][loc.y] & 32) && (univ.town.monst.dudes[which_m].m_d.radiate_1 != 2) + if (univ.town.is_fire_barr(loc.x,loc.y) || univ.town.is_force_barr(loc.x,loc.y) || univ.town.is_quickfire(loc.x,loc.y) + || univ.town.is_blade_wall(loc.x,loc.y) // hate regular fields + || (univ.town.is_ice_wall(loc.x,loc.y) && (univ.town.monst.dudes[which_m].m_d.radiate_1 != 2) && (univ.town.monst.dudes[which_m].m_d.immunities & 32 == 0)) // hate ice wall? - || ((univ.town.explored[loc.x][loc.y] & 4) && (univ.town.monst.dudes[which_m].m_d.radiate_1 != 1) + || (univ.town.is_fire_wall(loc.x,loc.y) && (univ.town.monst.dudes[which_m].m_d.radiate_1 != 1) && (univ.town.monst.dudes[which_m].m_d.immunities & 8 == 0)) // hate fire wall? - || ((univ.town.explored[loc.x][loc.y] & 16) && (univ.town.monst.dudes[which_m].m_d.radiate_1 != 6) + || (univ.town.is_scloud(loc.x,loc.y) && (univ.town.monst.dudes[which_m].m_d.radiate_1 != 6) && (univ.town.monst.dudes[which_m].m_d.immunities & 3 == 0)) // hate stink cloud? - || ((univ.town.explored[loc.x][loc.y] & 128) && (univ.town.monst.dudes[which_m].m_d.radiate_1 != 5) + || (univ.town.is_sleep_cloud(loc.x,loc.y) && (univ.town.monst.dudes[which_m].m_d.radiate_1 != 5) && (univ.town.monst.dudes[which_m].m_d.immunities & 3 == 0)) // hate sleep cloud? - || ((univ.town.explored[loc.x][loc.y] & 2) && (univ.town.monst.dudes[which_m].m_d.radiate_1 != 3) + || (univ.town.is_force_wall(loc.x,loc.y) && (univ.town.monst.dudes[which_m].m_d.radiate_1 != 3) && (univ.town.monst.dudes[which_m].m_d.immunities & 3 == 0)) // hate shock cloud? || (((univ.town.monst.dudes[which_m].m_d.mu > 0) || (univ.town.monst.dudes[which_m].m_d.cl > 0)) - && (univ.town.explored[loc.x][loc.y] & 8))) // hate antimagic + && univ.town.is_antimagic(loc.x,loc.y))) // hate antimagic { prospect = find_clear_spot(loc,1); if (prospect.x > 0) { @@ -841,8 +841,8 @@ location find_clear_spot(location from_where,short mode) && (can_see(from_where,loc,1) == 0) && (!(is_combat()) || (pc_there(loc) == 6)) && (!(is_town()) || (loc != univ.town.p_loc)) - && (!(univ.out.misc_i[loc.x][loc.y] & 248)) && - (!(univ.town.explored[loc.x][loc.y] & 254))) { + && (!(univ.town.misc_i(loc.x,loc.y) & 248)) && // check for crate, barrel, barrier, quickfire + (!(univ.town.explored(loc.x,loc.y) & 254))) { // check for fields, clouds if ((mode == 0) || ((mode == 1) && (adjacent(from_where,loc) == true))) return loc; else store_loc = loc; @@ -926,44 +926,44 @@ void monst_inflict_fields(short which_monst) if (univ.town.monst.dudes[which_monst].active > 0) { where_check.x = univ.town.monst.dudes[which_monst].m_loc.x + i; where_check.y = univ.town.monst.dudes[which_monst].m_loc.y + j; - if (is_quickfire(where_check.x,where_check.y)) { + if (univ.town.is_quickfire(where_check.x,where_check.y)) { r1 = get_ran(2,1,8); damage_monst(which_monst,7,r1,0,DAMAGE_FIRE,0); break; } - if (is_blade_wall(where_check.x,where_check.y)) { + if (univ.town.is_blade_wall(where_check.x,where_check.y)) { r1 = get_ran(6,1,8); damage_monst(which_monst,7,r1,0,DAMAGE_WEAPON,0); break; } - if (is_force_wall(where_check.x,where_check.y)) { + if (univ.town.is_force_wall(where_check.x,where_check.y)) { r1 = get_ran(3,1,6); damage_monst(which_monst,7,r1,0,DAMAGE_MAGIC,0); break; } - if (is_sleep_cloud(where_check.x,where_check.y)) { + if (univ.town.is_sleep_cloud(where_check.x,where_check.y)) { charm_monst(which_m,0,11,3); break; } - if (is_ice_wall(where_check.x,where_check.y)) { + if (univ.town.is_ice_wall(where_check.x,where_check.y)) { r1 = get_ran(3,1,6); if (univ.town.monst.dudes[which_monst].m_d.spec_skill != 23) damage_monst(which_monst,7,r1,0,DAMAGE_COLD,0); break; } - if (is_scloud(where_check.x,where_check.y)) { + if (univ.town.is_scloud(where_check.x,where_check.y)) { r1 = get_ran(1,2,3); curse_monst(which_m,r1); break; } - if ((is_web(where_check.x,where_check.y)) && (which_m->m_d.m_type != 12)) { + if ((univ.town.is_web(where_check.x,where_check.y)) && (which_m->m_d.m_type != 12)) { monst_spell_note(which_m->number,19); r1 = get_ran(1,2,3); web_monst(which_m,r1); - take_web(where_check.x,where_check.y); + univ.town.set_web(where_check.x,where_check.y,false); break; } - if (is_fire_wall(where_check.x,where_check.y)) { + if (univ.town.is_fire_wall(where_check.x,where_check.y)) { r1 = get_ran(2,1,6); if (univ.town.monst.dudes[which_monst].m_d.spec_skill != 22) damage_monst(which_monst,7,r1,0,DAMAGE_FIRE,0); @@ -975,15 +975,15 @@ void monst_inflict_fields(short which_monst) for (j = 0; j < univ.town.monst.dudes[which_monst].m_d.y_width; j++) { where_check.x = univ.town.monst.dudes[which_monst].m_loc.x + i; where_check.y = univ.town.monst.dudes[which_monst].m_loc.y + j; - if ((is_crate(where_check.x,where_check.y)) || - (is_barrel(where_check.x,where_check.y)) ) + if ((univ.town.is_crate(where_check.x,where_check.y)) || + (univ.town.is_barrel(where_check.x,where_check.y)) ) for (k = 0; k < NUM_TOWN_ITEMS; k++) if ((univ.town.items[k].variety > 0) && (univ.town.items[k].is_contained()) && (univ.town.items[k].item_loc == where_check)) univ.town.items[k].item_properties = univ.town.items[k].item_properties & 247; - take_crate(where_check.x,where_check.y); - take_barrel(where_check.x,where_check.y); - if (is_fire_barrier(where_check.x,where_check.y)) { + univ.town.set_crate(where_check.x,where_check.y,false); + univ.town.set_barrel(where_check.x,where_check.y,false); + if (univ.town.is_fire_barr(where_check.x,where_check.y)) { r1 = get_ran(2,1,10); damage_monst(which_monst,7,r1,0,DAMAGE_FIRE,0); } @@ -1041,37 +1041,37 @@ bool monst_check_special_terrain(location where_check,short mode,short which_mon if (which_m->attitude == 0) guts = guts / 2; - if ((is_antimagic(where_check.x,where_check.y)) && (mage == true)) + if ((univ.town.is_antimagic(where_check.x,where_check.y)) && (mage == true)) return false; - if ((is_fire_wall(where_check.x,where_check.y)) && (which_m->m_d.spec_skill != 22)) { + if ((univ.town.is_fire_wall(where_check.x,where_check.y)) && (which_m->m_d.spec_skill != 22)) { if (guts < 3) return false; } - if (is_force_wall(where_check.x,where_check.y)) { + if (univ.town.is_force_wall(where_check.x,where_check.y)) { if (guts < 4) return false; } - if ((is_ice_wall(where_check.x,where_check.y)) && (which_m->m_d.spec_skill != 23)) { + if ((univ.town.is_ice_wall(where_check.x,where_check.y)) && (which_m->m_d.spec_skill != 23)) { if (guts < 5) return false; } - if (is_sleep_cloud(where_check.x,where_check.y)) { + if (univ.town.is_sleep_cloud(where_check.x,where_check.y)) { if (guts < 8) return false; } - if (is_blade_wall(where_check.x,where_check.y)) { + if (univ.town.is_blade_wall(where_check.x,where_check.y)) { if (guts < 8) return false; } - if (is_quickfire(where_check.x,where_check.y)) { + if (univ.town.is_quickfire(where_check.x,where_check.y)) { if (guts < 8) return false; } - if (is_scloud(where_check.x,where_check.y)) { + if (univ.town.is_scloud(where_check.x,where_check.y)) { if (guts < 4) return false; } - if ((is_web(where_check.x,where_check.y)) && (which_m->m_d.m_type != 12)) { + if ((univ.town.is_web(where_check.x,where_check.y)) && (which_m->m_d.m_type != 12)) { if (guts < 3) return false; } - if (is_fire_barrier(where_check.x,where_check.y)) { + if (univ.town.is_fire_barr(where_check.x,where_check.y)) { if ((which_m->attitude % 2 == 1) && (get_ran(1,1,100) < (which_m->m_d.mu * 10 + which_m->m_d.cl * 4))) { play_sound(60); add_string_to_buf("Monster breaks barrier."); - take_fire_barrier(where_check.x,where_check.y); + univ.town.set_fire_barr(where_check.x,where_check.y,false); } else { if (guts < 6) return false; @@ -1080,37 +1080,37 @@ bool monst_check_special_terrain(location where_check,short mode,short which_mon can_enter = false; } } - if (is_force_barrier(where_check.x,where_check.y)) { /// Not in big towns + if (univ.town.is_force_barr(where_check.x,where_check.y)) { /// Not in big towns if ((which_m->attitude % 2 == 1) && (get_ran(1,1,100) < (which_m->m_d.mu * 10 + which_m->m_d.cl * 4)) - && (univ.town.num >= 20)) { + /*&& (univ.town.num >= 20)*/) { // Checking for a town num > 20 seems utterly pointless play_sound(60); add_string_to_buf("Monster breaks barrier."); - take_force_barrier(where_check.x,where_check.y); + univ.town.set_force_barr(where_check.x,where_check.y,false); } else can_enter = false; } - if (is_crate(where_check.x,where_check.y)) { + if (univ.town.is_crate(where_check.x,where_check.y)) { if (monster_placid(which_monst)) can_enter = false; else { to_loc = push_loc(from_loc,where_check); - take_crate((short) where_check.x,(short) where_check.y); + univ.town.set_crate((short) where_check.x,(short) where_check.y,false); if (to_loc.x > 0) - make_crate((short) to_loc.x,(short) to_loc.y); + univ.town.set_crate((short) to_loc.x,(short) to_loc.y, true); for (i = 0; i < NUM_TOWN_ITEMS; i++) if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where_check) && (univ.town.items[i].is_contained())) univ.town.items[i].item_loc = to_loc; } } - if (is_barrel(where_check.x,where_check.y)) { + if (univ.town.is_barrel(where_check.x,where_check.y)) { if (monster_placid(which_monst)) can_enter = false; else { to_loc = push_loc(from_loc,where_check); - take_barrel((short) where_check.x,(short) where_check.y); + univ.town.set_barrel((short) where_check.x,(short) where_check.y,false); if (to_loc.x > 0) - make_barrel((short) to_loc.x,(short) to_loc.y); + univ.town.set_barrel((short) to_loc.x,(short) to_loc.y,true); for (i = 0; i < NUM_TOWN_ITEMS; i++) if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where_check) && (univ.town.items[i].is_contained())) @@ -1362,8 +1362,8 @@ short place_monster(unsigned char which,location where) add_monst_graphic(which,1); } - take_crate(where.x,where.y); - take_barrel(where.x,where.y); + univ.town.set_crate(where.x,where.y,false); + univ.town.set_barrel(where.x,where.y,false); return i; } @@ -1397,7 +1397,7 @@ bool summon_monster(unsigned char which,location where,short duration,short give if (where.x == 0) return false; } - if ((is_barrel(where.x,where.y)) || (is_crate(where.x,where.y))) + if ((univ.town.is_barrel(where.x,where.y)) || (univ.town.is_crate(where.x,where.y))) return false; loc = where; } @@ -1445,8 +1445,8 @@ void activate_monsters(short code,short attitude) monst_target[i] = 6; add_monst_graphic(univ.town.monst.dudes[i].number,1); - take_crate(univ.town.monst.dudes[i].m_loc.x,univ.town.monst.dudes[i].m_loc.y); - take_barrel(univ.town.monst.dudes[i].m_loc.x,univ.town.monst.dudes[i].m_loc.y); + univ.town.set_crate(univ.town.monst.dudes[i].m_loc.x,univ.town.monst.dudes[i].m_loc.y,false); + univ.town.set_barrel(univ.town.monst.dudes[i].m_loc.x,univ.town.monst.dudes[i].m_loc.y,false); } } diff --git a/osx/boe.party.cpp b/osx/boe.party.cpp index 6f5f9eaf..fcc4769d 100644 --- a/osx/boe.party.cpp +++ b/osx/boe.party.cpp @@ -301,12 +301,12 @@ void init_party(short mode) for (i = 0; i < 200; i++) for (j = 0; j < 8; j++) for (k = 0; k < 64; k++) - univ.town.maps[i][j][k] = 0; + univ.town_maps[i][j][k] = 0; for (i = 0; i < 100; i++) for (k = 0; k < 6; k++) for (l = 0; l < 48; l++) - univ.out.maps[i][k][l] = 0; + univ.out_maps[i][k][l] = 0; // Default is save maps PSD[SDF_NO_MAPS] = 0; @@ -433,12 +433,12 @@ void init_party_scen_data() for (i = 0; i < 200; i++) for (j = 0; j < 8; j++) for (k = 0; k < 64; k++) - univ.town.maps[i][j][k] = 0; + univ.town_maps[i][j][k] = 0; for (i = 0; i < 100; i++) for (k = 0; k < 6; k++) for (l = 0; l < 48; l++) - univ.out.maps[i][k][l] = 0; + univ.out_maps[i][k][l] = 0; } @@ -1324,7 +1324,7 @@ void cast_spell(short type,short situation) { short spell; - if ((is_town()) && (is_antimagic(univ.town.p_loc.x,univ.town.p_loc.y))) { + if ((is_town()) && (univ.town.is_antimagic(univ.town.p_loc.x,univ.town.p_loc.y))) { add_string_to_buf(" Not in antimagic field."); return; } @@ -2036,8 +2036,8 @@ void cast_town_spell(location where) //// add_string_to_buf(" Target space obstructed."); break; } - make_fire_barrier(where.x,where.y); - if (is_fire_barrier(where.x,where.y)) + univ.town.set_fire_barr(where.x,where.y,true); + if (univ.town.is_fire_barr(where.x,where.y)) add_string_to_buf(" You create the barrier. "); else add_string_to_buf(" Failed."); break; @@ -2046,14 +2046,14 @@ void cast_town_spell(location where) //// add_string_to_buf(" Target space obstructed."); break; } - make_force_barrier(where.x,where.y); - if (is_force_barrier(where.x,where.y)) + univ.town.set_force_barr(where.x,where.y,true); + if (univ.town.is_force_barr(where.x,where.y)) add_string_to_buf(" You create the barrier. "); else add_string_to_buf(" Failed."); break; case 60: - make_quickfire(where.x,where.y); - if (is_quickfire(where.x,where.y)) + univ.town.set_quickfire(where.x,where.y,true); + if (univ.town.is_quickfire(where.x,where.y)) add_string_to_buf(" You create quickfire. "); else add_string_to_buf(" Failed."); break; @@ -2096,14 +2096,14 @@ void cast_town_spell(location where) //// break; case 41: - if ((is_fire_barrier(where.x,where.y)) || (is_force_barrier(where.x,where.y))) { + if ((univ.town.is_fire_barr(where.x,where.y)) || (univ.town.is_force_barr(where.x,where.y))) { r1 = get_ran(1,1,100) - 5 * stat_adj(who_cast,2) + 5 * (univ.town.difficulty / 10); - if (is_fire_barrier(where.x,where.y)) + if (univ.town.is_fire_barr(where.x,where.y)) r1 -= 8; if (r1 < (120 - combat_percent[min(19,ADVEN[who_cast].level)])) { add_string_to_buf(" Barrier broken. "); - take_fire_barrier(where.x,where.y); - take_force_barrier(where.x,where.y); + univ.town.set_fire_barr(where.x,where.y,false); + univ.town.set_force_barr(where.x,where.y,false); // Now, show party new things update_explored(univ.town.p_loc); @@ -2219,32 +2219,32 @@ void dispel_fields(short i,short j,short mode) short r1; if (mode == 2) { - take_fire_barrier(i,j); - take_force_barrier(i,j); - take_barrel(i,j); - take_crate(i,j); - take_web(i,j); + univ.town.set_fire_barr(i,j,false); + univ.town.set_force_barr(i,j,false); + univ.town.set_barrel(i,j,false); + univ.town.set_crate(i,j,false); + univ.town.set_web(i,j,false); } if (mode >= 1) mode = -10; - take_fire_wall(i,j); - take_force_wall(i,j); - take_scloud(i,j); + univ.town.set_fire_wall(i,j,false); + univ.town.set_force_wall(i,j,false); + univ.town.set_scloud(i,j,false); r1 = get_ran(1,1,6) + mode; if (r1 <= 1) - take_web(i,j); + univ.town.set_web(i,j,false); r1 = get_ran(1,1,6) + mode; if (r1 < 6) - take_ice_wall(i,j); + univ.town.set_ice_wall(i,j,false); r1 = get_ran(1,1,6) + mode; if (r1 < 5) - take_sleep_cloud(i,j); + univ.town.set_sleep_cloud(i,j,false); r1 = get_ran(1,1,8) + mode; if (r1 <= 1) - take_quickfire(i,j); + univ.town.set_quickfire(i,j,false); r1 = get_ran(1,1,7) + mode; if (r1 < 5) - take_blade_wall(i,j); + univ.town.set_blade_wall(i,j,false); } bool pc_can_cast_spell(short pc_num,short type,short spell_num) diff --git a/osx/boe.specials.cpp b/osx/boe.specials.cpp index 49500cc0..199a7b73 100644 --- a/osx/boe.specials.cpp +++ b/osx/boe.specials.cpp @@ -210,8 +210,8 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short } if (((mode == 1) || ((mode == 2) && (which_combat_type == 1))) - && (special(where_check.x,where_check.y))) { - if (is_force_barrier(where_check.x,where_check.y)) { + && (univ.town.is_special(where_check.x,where_check.y))) { + if (univ.town.is_force_barr(where_check.x,where_check.y)) { add_string_to_buf(" Magic barrier! "); return false; } @@ -240,7 +240,7 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short if ((!is_out()) && (overall_mode < MODE_TALKING)) { check_fields(where_check,mode,which_pc); - if (is_web(where_check.x,where_check.y)) { + if (univ.town.is_web(where_check.x,where_check.y)) { add_string_to_buf(" Webs! "); if (mode < 2) { suppress_stat_screen = true; @@ -252,29 +252,29 @@ bool check_special_terrain(location where_check,short mode,short which_pc,short put_pc_screen(); } else web_pc(current_pc,get_ran(1,2,3)); - take_web(where_check.x,where_check.y); + univ.town.set_web(where_check.x,where_check.y,false); } - if (is_force_barrier(where_check.x,where_check.y)) { + if (univ.town.is_force_barr(where_check.x,where_check.y)) { add_string_to_buf(" Magic barrier! "); can_enter = false; } - if (is_crate(where_check.x,where_check.y)) { + if (univ.town.is_crate(where_check.x,where_check.y)) { add_string_to_buf(" You push the crate."); to_loc = push_loc(from_loc,where_check); - take_crate((short) where_check.x,(short) where_check.y); + univ.town.set_crate((short) where_check.x,(short) where_check.y,false); if (to_loc.x > 0) - make_crate((short) to_loc.x,(short) to_loc.y); + univ.town.set_crate((short) to_loc.x,(short) to_loc.y,true); for (i = 0; i < NUM_TOWN_ITEMS; i++) if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where_check) && (univ.town.items[i].is_contained() == true)) univ.town.items[i].item_loc = to_loc; } - if (is_barrel(where_check.x,where_check.y)) { + if (univ.town.is_barrel(where_check.x,where_check.y)) { add_string_to_buf(" You push the barrel."); to_loc = push_loc(from_loc,where_check); - take_barrel((short) where_check.x,(short) where_check.y); + univ.town.set_barrel((short) where_check.x,(short) where_check.y,false); if (to_loc.x > 0) - make_barrel((short) to_loc.x,(short) to_loc.y); + univ.town.set_barrel((short) to_loc.x,(short) to_loc.y,false); for (i = 0; i < NUM_TOWN_ITEMS; i++) if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where_check) && (univ.town.items[i].is_contained())) @@ -403,7 +403,7 @@ void check_fields(location where_check,short mode,short which_pc) return; if (is_town()) fast_bang = 1; - if (is_fire_wall(where_check.x,where_check.y)) { + if (univ.town.is_fire_wall(where_check.x,where_check.y)) { add_string_to_buf(" Fire wall! "); r1 = get_ran(1,1,6) + 1; // if (mode < 2) @@ -413,7 +413,7 @@ void check_fields(location where_check,short mode,short which_pc) if (overall_mode < MODE_COMBAT) boom_space(univ.party.p_loc,overall_mode,0,r1,5); } - if (is_force_wall(where_check.x,where_check.y)) { + if (univ.town.is_force_wall(where_check.x,where_check.y)) { add_string_to_buf(" Force wall! "); r1 = get_ran(2,1,6); // if (mode < 2) @@ -423,7 +423,7 @@ void check_fields(location where_check,short mode,short which_pc) if (overall_mode < MODE_COMBAT) boom_space(univ.party.p_loc,overall_mode,1,r1,12); } - if (is_ice_wall(where_check.x,where_check.y)) { + if (univ.town.is_ice_wall(where_check.x,where_check.y)) { add_string_to_buf(" Ice wall! "); r1 = get_ran(2,1,6); // if (mode < 2) @@ -433,7 +433,7 @@ void check_fields(location where_check,short mode,short which_pc) if (overall_mode < MODE_COMBAT) boom_space(univ.party.p_loc,overall_mode,4,r1,7); } - if (is_blade_wall(where_check.x,where_check.y)) { + if (univ.town.is_blade_wall(where_check.x,where_check.y)) { add_string_to_buf(" Blade wall! "); r1 = get_ran(4,1,8); // if (mode < 2) @@ -443,7 +443,7 @@ void check_fields(location where_check,short mode,short which_pc) if (overall_mode < MODE_COMBAT) boom_space(univ.party.p_loc,overall_mode,3,r1,2); } - if (is_quickfire(where_check.x,where_check.y)) { + if (univ.town.is_quickfire(where_check.x,where_check.y)) { add_string_to_buf(" Quickfire! "); r1 = get_ran(2,1,8); // if (mode < 2) @@ -453,7 +453,7 @@ void check_fields(location where_check,short mode,short which_pc) if (overall_mode < MODE_COMBAT) boom_space(univ.party.p_loc,overall_mode,0,r1,5); } - if (is_scloud(where_check.x,where_check.y)) { + if (univ.town.is_scloud(where_check.x,where_check.y)) { add_string_to_buf(" Stinking cloud! "); if (mode < 2) { suppress_stat_screen = true; @@ -466,7 +466,7 @@ void check_fields(location where_check,short mode,short which_pc) } else curse_pc(current_pc,get_ran(1,2,3)); } - if (is_sleep_cloud(where_check.x,where_check.y)) { + if (univ.town.is_sleep_cloud(where_check.x,where_check.y)) { add_string_to_buf(" Sleep cloud! "); if (mode < 2) { suppress_stat_screen = true; @@ -478,7 +478,7 @@ void check_fields(location where_check,short mode,short which_pc) } else sleep_pc(current_pc,3,11,0); } - if (is_fire_barrier(where_check.x,where_check.y)) { + if (univ.town.is_fire_barr(where_check.x,where_check.y)) { add_string_to_buf(" Magic barrier! "); r1 = get_ran(2,1,10); if (mode < 2) @@ -923,34 +923,34 @@ bool use_space(location where) add_string_to_buf("Use..."); - if (is_web(where.x,where.y)) { + if (univ.town.is_web(where.x,where.y)) { add_string_to_buf(" You clear the webs."); - take_web(where.x,where.y); + univ.town.set_web(where.x,where.y,false); return true; } - if (is_crate(where.x,where.y)) { + if (univ.town.is_crate(where.x,where.y)) { to_loc = push_loc(from_loc,where); if (from_loc == to_loc) { add_string_to_buf(" Can't push crate."); return false; } add_string_to_buf(" You push the crate."); - take_crate((short) where.x,(short) where.y); - make_crate((short) to_loc.x,(short) to_loc.y); + univ.town.set_crate((short) where.x,(short) where.y,false); + univ.town.set_crate((short) to_loc.x,(short) to_loc.y,true); for (i = 0; i < NUM_TOWN_ITEMS; i++) if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where) && (univ.town.items[i].is_contained())) univ.town.items[i].item_loc = to_loc; } - if (is_barrel(where.x,where.y)) { + if (univ.town.is_barrel(where.x,where.y)) { to_loc = push_loc(from_loc,where); if (from_loc == to_loc) { add_string_to_buf(" Can't push barrel."); return false; } add_string_to_buf(" You push the barrel."); - take_barrel((short) where.x,(short) where.y); - make_barrel((short) to_loc.x,(short) to_loc.y); + univ.town.set_barrel((short) where.x,(short) where.y,false); + univ.town.set_barrel((short) to_loc.x,(short) to_loc.y,true); for (i = 0; i < NUM_TOWN_ITEMS; i++) if ((univ.town.items[i].variety > 0) && (univ.town.items[i].item_loc == where) && (univ.town.items[i].is_contained())) @@ -992,7 +992,7 @@ bool adj_town_look(location where) item_there = true; terrain = univ.town->terrain(where.x,where.y); - if (special(where.x,where.y)) {// && (get_blockage(terrain) > 0)) { + if (univ.town.is_special(where.x,where.y)) {// && (get_blockage(terrain) > 0)) { if (adjacent(univ.town.p_loc,where) == false) add_string_to_buf(" Not close enough to search."); else { @@ -1477,12 +1477,12 @@ void push_things()//// update_explored(l); ter = univ.town->terrain(univ.town.p_loc.x,univ.town.p_loc.y); draw_map(modeless_dialogs[5],5); - if (is_barrel(univ.town.p_loc.x,univ.town.p_loc.y)) { - take_barrel(univ.town.p_loc.x,univ.town.p_loc.y); + if (univ.town.is_barrel(univ.town.p_loc.x,univ.town.p_loc.y)) { + univ.town.set_barrel(univ.town.p_loc.x,univ.town.p_loc.y,false); ASB("You smash the barrel."); } - if (is_crate(univ.town.p_loc.x,univ.town.p_loc.y)) { - take_crate(univ.town.p_loc.x,univ.town.p_loc.y); + if (univ.town.is_crate(univ.town.p_loc.x,univ.town.p_loc.y)) { + univ.town.set_crate(univ.town.p_loc.x,univ.town.p_loc.y,false); ASB("You smash the crate."); } for (k = 0; k < NUM_TOWN_ITEMS; k++) @@ -1511,12 +1511,12 @@ void push_things()//// pc_pos[i] = l; update_explored(l); draw_map(modeless_dialogs[5],5); - if (is_barrel(pc_pos[i].x,pc_pos[i].y)) { - take_barrel(pc_pos[i].x,pc_pos[i].y); + if (univ.town.is_barrel(pc_pos[i].x,pc_pos[i].y)) { + univ.town.set_barrel(pc_pos[i].x,pc_pos[i].y,false); ASB("You smash the barrel."); } - if (is_crate(pc_pos[i].x,pc_pos[i].y)) { - take_crate(pc_pos[i].x,pc_pos[i].y); + if (univ.town.is_crate(pc_pos[i].x,pc_pos[i].y)) { + univ.town.set_crate(pc_pos[i].x,pc_pos[i].y,false); ASB("You smash the crate."); } for (k = 0; k < NUM_TOWN_ITEMS; k++) @@ -2401,13 +2401,13 @@ void ifthen_spec(short which_mode,cSpecial cur_node,short cur_spec_type, case 148: for (j = 0; j < univ.town->max_dim(); j++) for (k = 0; k < univ.town->max_dim(); k++) - if (is_barrel(j,k)) + if (univ.town.is_barrel(j,k)) *next_spec = spec.ex1b; break; case 149: for (j = 0; j < univ.town->max_dim(); j++) for (k = 0; k < univ.town->max_dim(); k++) - if (is_crate(j,k)) + if (univ.town.is_crate(j,k)) *next_spec = spec.ex1b; break; case 150: @@ -2834,11 +2834,11 @@ void rect_spec(short which_mode,cSpecial cur_node,short cur_spec_type, break; case 207: if (get_ran(1,1,100) <= spec.sd1 ) - make_fire_barrier(i,j); + univ.town.set_fire_barr(i,j,true); break; case 208: if (get_ran(1,1,100) <= spec.sd1 ) - make_force_barrier(i,j); + univ.town.set_force_barr(i,j,true); break; case 209: if (spec.sd1 == 0) @@ -2854,9 +2854,9 @@ void rect_spec(short which_mode,cSpecial cur_node,short cur_spec_type, if (spec.sd2 == 0) make_web(i,j); if (spec.sd2 == 1) - make_barrel(i,j); + univ.town.set_barrel(i,j,true); if (spec.sd2 == 2) - make_crate(i,j); + univ.town.set_crate(i,j,true); } break; case 212: diff --git a/osx/boe.text.cpp b/osx/boe.text.cpp index 4fabd15a..99154372 100644 --- a/osx/boe.text.cpp +++ b/osx/boe.text.cpp @@ -896,46 +896,46 @@ short do_look(location space) if (town_horse_there(space) < 30) add_string_to_buf(" Horse "); - if (is_web(space.x,space.y)) + if (univ.town.is_web(space.x,space.y)) add_string_to_buf(" Web "); - if (is_crate(space.x,space.y)) + if (univ.town.is_crate(space.x,space.y)) add_string_to_buf(" Crate "); - if (is_barrel(space.x,space.y)) + if (univ.town.is_barrel(space.x,space.y)) add_string_to_buf(" Barrel "); - if (is_fire_barrier(space.x,space.y)) + if (univ.town.is_fire_barr(space.x,space.y)) add_string_to_buf(" Magic Barrier "); - if (is_force_barrier(space.x,space.y)) + if (univ.town.is_force_barr(space.x,space.y)) add_string_to_buf(" Magic Barrier "); - if (is_quickfire(space.x,space.y)) + if (univ.town.is_quickfire(space.x,space.y)) add_string_to_buf(" Quickfire "); - if (is_fire_wall(space.x,space.y)) + if (univ.town.is_fire_wall(space.x,space.y)) add_string_to_buf(" Wall of Fire "); - if (is_force_wall(space.x,space.y)) + if (univ.town.is_force_wall(space.x,space.y)) add_string_to_buf(" Wall of Force "); - if (is_antimagic(space.x,space.y)) + if (univ.town.is_antimagic(space.x,space.y)) add_string_to_buf(" Antimagic Field "); - if (is_scloud(space.x,space.y)) + if (univ.town.is_scloud(space.x,space.y)) add_string_to_buf(" Stinking Cloud "); - if (is_ice_wall(space.x,space.y)) + if (univ.town.is_ice_wall(space.x,space.y)) add_string_to_buf(" Ice Wall "); - if (is_blade_wall(space.x,space.y)) + if (univ.town.is_blade_wall(space.x,space.y)) add_string_to_buf(" Blade Wall "); - if (is_small_blood(space.x,space.y)) + if (univ.town.is_sm_blood(space.x,space.y)) add_string_to_buf(" Blood stain "); - if (is_medium_blood(space.x,space.y)) + if (univ.town.is_med_blood(space.x,space.y)) add_string_to_buf(" Blood stain "); - if (is_large_blood(space.x,space.y)) + if (univ.town.is_lg_blood(space.x,space.y)) add_string_to_buf(" Blood stain "); - if (is_small_slime(space.x,space.y)) + if (univ.town.is_sm_slime(space.x,space.y)) add_string_to_buf(" Smears of slime "); - if (is_big_slime(space.x,space.y)) + if (univ.town.is_lg_slime(space.x,space.y)) add_string_to_buf(" Smears of slime "); - if (is_ash(space.x,space.y)) + if (univ.town.is_ash(space.x,space.y)) add_string_to_buf(" Ashes "); - if (is_bones(space.x,space.y)) + if (univ.town.is_bones(space.x,space.y)) add_string_to_buf(" Bones "); - if (is_rubble(space.x,space.y)) + if (univ.town.is_rubble(space.x,space.y)) add_string_to_buf(" Rubble "); for (i = 0; i < NUM_TOWN_ITEMS; i++) { diff --git a/osx/boe.town.cpp b/osx/boe.town.cpp index e3c8a995..8b23f550 100644 --- a/osx/boe.town.cpp +++ b/osx/boe.town.cpp @@ -207,9 +207,9 @@ void start_town_mode(short which_town, short entry_dir) // Set up map, using stored map for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) { - univ.town.explored[i][j] = 0; + univ.town.fields[i][j] = 0; //univ.out.sfx[i][j] = 0; - if (univ.town.maps[univ.town.num][i / 8][j] & (char)(s_pow(2,i % 8))) + if (univ.town_maps[univ.town.num][i / 8][j] & (char)(s_pow(2,i % 8))) make_explored(i,j); if (univ.town->terrain(i,j) == 0) @@ -299,9 +299,9 @@ void start_town_mode(short which_town, short entry_dir) for (j = 0; j < univ.town->max_dim(); j++) for (k = 0; k < univ.town->max_dim(); k++) { // now load in saved setup, // except that barrels and crates restore to orig locs - temp = univ.town.setup[i][j][k] & 231; - - univ.out.misc_i[j][k] = (univ.out.misc_i[j][k] & 24) | temp;//setup_save.setup[i][j][k]; + temp = univ.party.setup[i][j][k] & 231; + temp <<= 8; + univ.town.fields[j][k] = (univ.town.fields[j][k] & 24) | temp;//setup_save.setup[i][j][k]; } } @@ -436,19 +436,26 @@ void start_town_mode(short which_town, short entry_dir) for (j = 0; j < univ.town->max_dim(); j++) for (k = 0; k < univ.town->max_dim(); k++) { loc.x = j; loc.y = k; - if (is_door(loc) == true) - univ.out.misc_i[j][k] = univ.out.misc_i[j][k] & 3; - if (is_web(j,k) == true) + if (is_door(loc) == true) { + univ.town.set_web(j,k,false); + univ.town.set_crate(j,k,false); + univ.town.set_barrel(j,k,false); + univ.town.set_fire_barr(j,k,false); + univ.town.set_force_barr(j,k,false); + univ.town.set_quickfire(j,k,false); + //univ.out.misc_i[j][k] = univ.out.misc_i[j][k] & 3; + } + if (univ.town.is_web(j,k) == true) web = true; - if (is_crate(j,k) == true) + if (univ.town.is_crate(j,k) == true) crate = true; - if (is_barrel(j,k) == true) + if (univ.town.is_barrel(j,k) == true) barrel = true; - if (is_fire_barrier(j,k) == true) + if (univ.town.is_fire_barr(j,k) == true) fire_barrier = true; - if (is_force_barrier(j,k) == true) + if (univ.town.is_force_barr(j,k) == true) force_barrier = true; - if (is_quickfire(j,k) == true) + if (univ.town.is_quickfire(j,k) == true) quickfire = true; } @@ -545,7 +552,13 @@ void start_town_mode(short which_town, short entry_dir) // clear entry space, and check exploration - univ.out.misc_i[univ.town.p_loc.x][univ.town.p_loc.y] = univ.out.misc_i[univ.town.p_loc.x][univ.town.p_loc.y] & 3; + univ.town.set_web(univ.town.p_loc.x,univ.town.p_loc.y,false); + univ.town.set_crate(univ.town.p_loc.x,univ.town.p_loc.y,false); + univ.town.set_barrel(univ.town.p_loc.x,univ.town.p_loc.y,false); + univ.town.set_fire_barr(univ.town.p_loc.x,univ.town.p_loc.y,false); + univ.town.set_force_barr(univ.town.p_loc.x,univ.town.p_loc.y,false); + univ.town.set_quickfire(univ.town.p_loc.x,univ.town.p_loc.y,false); + //univ.out.misc_i[univ.town.p_loc.x][univ.town.p_loc.y] = univ.out.misc_i[univ.town.p_loc.x][univ.town.p_loc.y] & 3; update_explored(univ.town.p_loc); // If a PC dead, drop his items @@ -605,14 +618,14 @@ location end_town_mode(short switching_level,location destination) // returns n univ.party.creature_save[i] = univ.town.monst; for (j = 0; j < univ.town->max_dim(); j++) for (k = 0; k < univ.town->max_dim(); k++) - univ.town.setup[i][j][k] = univ.out.misc_i[j][k]; + univ.party.setup[i][j][k] = univ.town.misc_i(j,k); data_saved = true; } if (data_saved == false) { univ.party.creature_save[univ.party.at_which_save_slot] = univ.town.monst; for (j = 0; j < univ.town->max_dim(); j++) for (k = 0; k < univ.town->max_dim(); k++) - univ.town.setup[univ.party.at_which_save_slot][j][k] = univ.out.misc_i[j][k]; + univ.party.setup[univ.party.at_which_save_slot][j][k] = univ.town.misc_i(j,k); univ.party.at_which_save_slot = (univ.party.at_which_save_slot == 3) ? 0 : univ.party.at_which_save_slot + 1; } @@ -642,7 +655,7 @@ location end_town_mode(short switching_level,location destination) // returns n for (i = 0; i < univ.town->max_dim(); i++) for (j = 0; j < univ.town->max_dim(); j++) if (is_explored(i,j) > 0) { - univ.town.maps[univ.town.num][i / 8][j] = univ.town.maps[univ.town.num][i / 8][j] | + univ.town_maps[univ.town.num][i / 8][j] = univ.town_maps[univ.town.num][i / 8][j] | (char) (s_pow(2,i % 8)); } // } @@ -987,9 +1000,9 @@ void create_out_combat_terrain(short type,short num_walls,short spec_code) for (i = 0; i < 48; i++) for (j = 0; j < 48; j++) { - univ.town.explored[i][j] = 0; - univ.out.misc_i[i][j] = 0; - univ.out.sfx[i][j] = 0; + univ.town.fields[i][j] = 0; + //univ.out.misc_i[i][j] = 0; + //univ.out.sfx[i][j] = 0; if ((j <= 8) || (j >= 35) || (i <= 8) || (i >= 35)) univ.town->terrain(i,j) = 90; else univ.town->terrain(i,j) = ter_base[ter_type]; @@ -1265,7 +1278,7 @@ void erase_specials()//// case 211: univ.town->terrain(where.x,where.y) = 2; break; case 212: univ.town->terrain(where.x,where.y) = 36; break; } - take_special(where.x,where.y); + univ.town.set_special(where.x,where.y,false); } } diff --git a/osx/misc/fileio.cpp b/osx/misc/fileio.cpp index c4701b8c..167e1868 100644 --- a/osx/misc/fileio.cpp +++ b/osx/misc/fileio.cpp @@ -1059,7 +1059,7 @@ bool load_party(FSSpec file_to_load){ } univ.party = store_party; - univ.town.append(store_setup); + univ.party.append(store_setup); for(i = 0; i < 6; i++) univ.party.add_pc(store_pc[i]); if(in_scen){ @@ -1071,9 +1071,9 @@ bool load_party(FSSpec file_to_load){ } for(i = 0; i < 3; i++) univ.party.append(stored_items[i],i); - univ.town.append(town_maps); - univ.out.append(o_maps); - univ.out.append(sfx, misc_i); + univ.append(town_maps); + univ.append(o_maps); + univ.town.append(sfx, misc_i); } if(in_scen){ FSRef file_ref; diff --git a/osx/party.cpp b/osx/party.cpp index b85050f8..cef4683b 100644 --- a/osx/party.cpp +++ b/osx/party.cpp @@ -86,6 +86,14 @@ void cParty::append(legacy::stored_items_list_type& old,short which_list){ stored_items[which_list][i] = old.items[i]; } +__attribute__((deprecated)) +void cParty::append(legacy::setup_save_type& old){ + for(int n = 0; n < 4; n++) + for(int i = 0; i < 64; i++) + for(int j = 0; j < 64; j++) + setup[n][i][j] = old.setup[n][i][j]; +} + __attribute__((deprecated)) cParty::cConvers& cParty::cConvers::operator = (legacy::talk_save_type old){ personality = old.personality; diff --git a/osx/party.h b/osx/party.h index cf7ab00e..f0f1653b 100644 --- a/osx/party.h +++ b/osx/party.h @@ -17,6 +17,7 @@ namespace legacy { struct talk_save_type; struct creature_list_type; struct pc_record_type; + struct setup_save_type; }; class cParty { @@ -86,6 +87,7 @@ public: cPlayer adven[6]; + unsigned short setup[4][64][64]; // formerly setup_save_type cItemRec stored_items[3][115]; // formerly stored_items_list_type string graphicsFile; // the name of the png file holding this party's custom item, pc, and summonable monster graphics @@ -96,6 +98,7 @@ public: cParty& operator = (legacy::party_record_type& old); void append(legacy::big_tr_type& old); void append(legacy::stored_items_list_type& old,short which_list); + void append(legacy::setup_save_type& old); void add_pc(legacy::pc_record_type old); void add_pc(cPlayer new_pc); diff --git a/osx/universe.cpp b/osx/universe.cpp index c5c141df..164daf01 100644 --- a/osx/universe.cpp +++ b/osx/universe.cpp @@ -8,14 +8,7 @@ #include "classes.h" #include "oldstructs.h" - -__attribute__((deprecated)) -void cCurTown::append(legacy::setup_save_type& old){ - for(int n = 0; n < 4; n++) - for(int i = 0; i < 64; i++) - for(int j = 0; j < 64; j++) - setup[n][i][j] = old.setup[n][i][j]; -} +#include "mathutil.h" __attribute__((deprecated)) void cCurOut::append(legacy::out_info_type& old){ @@ -43,7 +36,7 @@ void cCurTown::append(legacy::current_town_type& old,short which_size){ *record = old.town; for(int i = 0; i < 64; i++) for(int j = 0; j < 64; j++) - explored[i][j] = old.explored[i][j]; + fields[i][j] = old.explored[i][j]; hostile = old.hostile; monst = old.monst; in_boat = old.in_boat; @@ -79,27 +72,32 @@ void cCurTown::append(legacy::town_item_list& old){ } __attribute__((deprecated)) -void cCurTown::append(legacy::stored_town_maps_type& old){ +void cUniverse::append(legacy::stored_town_maps_type& old){ for(int n = 0; n < 200; n++) for(int i = 0; i < 8; i++) for(int j = 0; j < 64; j++) - maps[n][i][j] = old.town_maps[n][i][j]; + town_maps[n][i][j] = old.town_maps[n][i][j]; } __attribute__((deprecated)) -void cCurOut::append(legacy::stored_outdoor_maps_type& old){ +void cUniverse::append(legacy::stored_outdoor_maps_type& old){ for(int n = 0; n < 100; n++) for(int i = 0; i < 6; i++) for(int j = 0; j < 48; j++) - maps[n][i][j] = old.outdoor_maps[n][i][j]; + out_maps[n][i][j] = old.outdoor_maps[n][i][j]; } __attribute__((deprecated)) -void cCurOut::append(unsigned char(& old_sfx)[64][64], unsigned char(& old_misc_i)[64][64]){ +void cCurTown::append(unsigned char(& old_sfx)[64][64], unsigned char(& old_misc_i)[64][64]){ for(int i = 0; i < 64; i++) for(int j = 0; j < 64; j++){ - sfx[i][j] = old_sfx[i][j]; - misc_i[i][j] = old_misc_i[i][j]; + unsigned long tmp_sfx, tmp_misc_i; + tmp_sfx = old_sfx[i][j]; + tmp_misc_i = old_misc_i[i][j]; + tmp_sfx <<= 16; + tmp_misc_i <<= 8; + fields[i][j] |= tmp_sfx; + fields[i][j] |= tmp_misc_i; } } @@ -116,3 +114,427 @@ void cCurTown::unload(){ record = NULL; } +bool cCurTown::is_explored(char x, char y) const{ + return fields[x][y] & 1L; +} + +bool cCurTown::is_force_wall(char x, char y) const{ + return fields[x][y] & 2L; +} + +bool cCurTown::is_fire_wall(char x, char y) const{ + return fields[x][y] & 4L; +} + +bool cCurTown::is_antimagic(char x, char y) const{ + return fields[x][y] & 8L; +} + +bool cCurTown::is_scloud(char x, char y) const{ // stinking cloud + return fields[x][y] & 16L; +} + +bool cCurTown::is_ice_wall(char x, char y) const{ + return fields[x][y] & 32L; +} + +bool cCurTown::is_blade_wall(char x, char y) const{ + return fields[x][y] & 64L; +} + +bool cCurTown::is_sleep_cloud(char x, char y) const{ + return fields[x][y] & 128L; +} + +bool cCurTown::is_block(char x, char y) const{ // currently unused + return fields[x][y] & 256L; +} + +bool cCurTown::is_special(char x, char y) const{ + return fields[x][y] & 512L; +} + +bool cCurTown::is_web(char x, char y) const{ + return fields[x][y] & 1024L; +} + +bool cCurTown::is_crate(char x, char y) const{ + return fields[x][y] & 2048L; +} + +bool cCurTown::is_barrel(char x, char y) const{ + return fields[x][y] & 4096L; +} + +bool cCurTown::is_fire_barr(char x, char y) const{ + return fields[x][y] & 8192L; +} + +bool cCurTown::is_force_barr(char x, char y) const{ + return fields[x][y] & 16384L; +} + +bool cCurTown::is_quickfire(char x, char y) const{ + return fields[x][y] & 32768L; +} + +bool cCurTown::is_sm_blood(char x, char y) const{ + return fields[x][y] & 65536L; +} + +bool cCurTown::is_med_blood(char x, char y) const{ + return fields[x][y] & 131072L; +} + +bool cCurTown::is_lg_blood(char x, char y) const{ + return fields[x][y] & 262144L; +} + +bool cCurTown::is_sm_slime(char x, char y) const{ + return fields[x][y] & 524288L; +} + +bool cCurTown::is_lg_slime(char x, char y) const{ + return fields[x][y] & 1048576L; +} + +bool cCurTown::is_ash(char x, char y) const{ + return fields[x][y] & 2097152L; +} + +bool cCurTown::is_bones(char x, char y) const{ + return fields[x][y] & 4194304L; +} + +bool cCurTown::is_rubble(char x, char y) const{ + return fields[x][y] & 8388608L; +} + +void cCurTown::set_explored(char x, char y, bool b){ + if(b) fields[x][y] |= 1L; + else fields[x][y] & ~1L; +} + +bool cCurTown::set_force_wall(char x, char y, bool b){ + 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; + if(is_crate(x,y) || is_barrel(x,y) || is_fire_barr(x,y) || is_force_barr(x,y)) + return false; + fields[x][y] |= 2L; + set_web(x,y,false); + set_fire_wall(x,y,false); + } + else fields[x][y] &= ~2L; +} + +bool cCurTown::set_fire_wall(char x, char y, bool b){ + 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; + if(is_crate(x,y) || is_barrel(x,y) || is_fire_barr(x,y) || is_force_barr(x,y)) + return false; + if(is_web(x,y) || is_scloud(x,y) || is_sleep_cloud(x,y)) + return false; + fields[x][y] |= 4L; + set_web(x,y,false); + set_fire_wall(x,y,false); + } + else fields[x][y] &= ~4L; +} + +bool cCurTown::set_antimagic(char x, char y, bool b){ + 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; + fields[x][y] |= 8L; + set_force_wall(x,y,false); + set_fire_wall(x,y,false); + set_antimagic(x,y,false); + set_scloud(x,y,false); + set_ice_wall(x,y,false); + set_blade_wall(x,y,false); + set_sleep_cloud(x,y,false); + } + else fields[x][y] &= ~8L; +} + +bool cCurTown::set_scloud(char x, char y, bool b){ // stinking cloud + 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; + if(is_antimagic(x,y) || is_sleep_cloud(x,y) || is_quickfire(x,y)) + return false; + if(is_fire_barr(x,y) || is_force_barr(x,y)) + return false; + fields[x][y] |= 16L; + } + else fields[x][y] &= ~16L; +} + +bool cCurTown::set_ice_wall(char x, char y, bool b){ + 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; + if(is_web(x,y) || is_crate(x,y) || is_barrel(x,y)) + return false; + if(is_fire_barr(x,y) || is_force_barr(x,y) || is_quickfire(x,y)) + return false; + fields[x][y] |= 32L; + set_fire_wall(x,y,false); + set_scloud(x,y,false); + } + else fields[x][y] &= ~32L; +} + +bool cCurTown::set_blade_wall(char x, char y, bool b){ + 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; + fields[x][y] |= 64L; + set_force_wall(x,y,false); + set_fire_wall(x,y,false); + } + else fields[x][y] &= ~64L; +} + +bool cCurTown::set_sleep_cloud(char x, char y, bool b){ + 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; + fields[x][y] |= 128L; + set_force_wall(x,y,false); + set_fire_wall(x,y,false); + } + else fields[x][y] &= ~128L; +} + +void cCurTown::set_block(char x, char y, bool b){ // currently unused + if(b) fields[x][y] |= 256L; + else fields[x][y] &= ~256L; +} + +void cCurTown::set_special(char x, char y, bool b){ + if(b) fields[x][y] |= 512L; + else fields[x][y] &= ~512L; +} + +bool cCurTown::set_web(char x, char y, bool b){ + 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; + if(is_force_wall(x,y) || is_fire_wall(x,y) || is_antimagic(x, y)) + return false; + if(is_ice_wall(x, y) || is_blade_wall(x,y) || is_sleep_cloud(x,y)) + return false; + fields[x][y] |= 1024L; + } + else fields[x][y] &= ~1024L; +} + +bool cCurTown::set_crate(char x, char y, bool b){ + 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; + fields[x][y] |= 2048L; + } + else fields[x][y] &= ~2048L; +} + +bool cCurTown::set_barrel(char x, char y, bool b){ + 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; + fields[x][y] |= 4096L; + } + else fields[x][y] &= ~4096L; +} + +bool cCurTown::set_fire_barr(char x, char y, bool b){ + 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; + if (is_antimagic(x,y) && get_ran(1,0,3) < 3) + return false; + fields[x][y] |= 8192L; + // Cancel out fields + set_web(x,y,false); + set_force_wall(x,y,false); + set_fire_wall(x,y,false); + set_antimagic(x,y,false); + set_scloud(x,y,false); + set_ice_wall(x,y,false); + set_blade_wall(x,y,false); + set_sleep_cloud(x,y,false); + } + else fields[x][y] &= ~8192L; +} + +bool cCurTown::set_force_barr(char x, char y, bool b){ + 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; + if (is_antimagic(x,y) && get_ran(1,0,2) < 2) + return false; + fields[x][y] |= 16384L; + // Cancel out fields + set_web(x,y,false); + set_force_wall(x,y,false); + set_fire_wall(x,y,false); + set_antimagic(x,y,false); + set_scloud(x,y,false); + set_ice_wall(x,y,false); + set_blade_wall(x,y,false); + set_sleep_cloud(x,y,false); + } + else fields[x][y] &= ~16384L; +} + +bool cCurTown::set_quickfire(char x, char y, bool b){ + 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; + if (is_force_barr(x,y) || is_fire_barr(x,y)) + return false; + fields[x][y] |= 32768L; + set_force_wall(x,y,false); + set_fire_wall(x,y,false); + set_antimagic(x,y,false); + set_scloud(x,y,false); + set_ice_wall(x,y,false); + set_blade_wall(x,y,false); + set_sleep_cloud(x,y,false); + set_web(x,y,false); + set_crate(x,y,false); + set_barrel(x,y,false); + set_force_barr(x,y,false); + set_fire_barr(x,y,false); + } + else fields[x][y] &= ~32768; +} + +void cCurTown::set_sm_blood(char x, char y, bool b){ + if(b){ + if(is_med_blood(x,y) || is_lg_blood(x,y)) + return; + fields[x][y] |= 65536L; + set_sm_slime(x,y,false); + set_lg_slime(x,y,false); + set_ash(x,y,false); + set_bones(x,y,false); + set_rubble(x,y,false); + } + else fields[x][y] &= ~65536L; +} + +void cCurTown::set_med_blood(char x, char y, bool b){ + if(b){ + if(is_sm_blood(x,y) || is_lg_blood(x,y)) + return; + fields[x][y] |= 131072L; + set_sm_slime(x,y,false); + set_lg_slime(x,y,false); + set_ash(x,y,false); + set_bones(x,y,false); + set_rubble(x,y,false); + } + else fields[x][y] &= ~131072L; +} + +void cCurTown::set_lg_blood(char x, char y, bool b){ + if(b){ + if(is_sm_blood(x,y) || is_med_blood(x,y)) + return; + fields[x][y] |= 262144L; + set_sm_slime(x,y,false); + set_lg_slime(x,y,false); + set_ash(x,y,false); + set_bones(x,y,false); + set_rubble(x,y,false); + } + else fields[x][y] &= ~262144L; +} + +void cCurTown::set_sm_slime(char x, char y, bool b){ + if(b){ + if(is_lg_blood(x,y)) + return; + fields[x][y] |= 524288L; + set_sm_blood(x,y,false); + set_med_blood(x,y,false); + set_lg_blood(x,y,false); + set_ash(x,y,false); + set_bones(x,y,false); + set_rubble(x,y,false); + } + else fields[x][y] &= ~524288L; +} + +void cCurTown::set_lg_slime(char x, char y, bool b){ + 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_ash(x,y,false); + set_bones(x,y,false); + set_rubble(x,y,false); + } + else fields[x][y] &= ~1048576L; +} + +void cCurTown::set_ash(char x, char y, bool b){ + if(b){ + fields[x][y] |= 2097152L; + 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_lg_slime(x,y,false); + set_bones(x,y,false); + set_rubble(x,y,false); + } + else fields[x][y] &= ~2097152L; +} + +void cCurTown::set_bones(char x, char y, bool b){ + if(b){ + fields[x][y] |= 4194304L; + 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_lg_slime(x,y,false); + set_ash(x,y,false); + set_rubble(x,y,false); + } + else fields[x][y] &= ~4194304L; +} + +void cCurTown::set_rubble(char x, char y, bool b){ + if(b){ + fields[x][y] |= 8388608L; + 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_lg_slime(x,y,false); + set_ash(x,y,false); + set_bones(x,y,false); + } + else fields[x][y] &= ~8388608L; +} + +unsigned char cCurTown::explored(char x,char y) const{ + return fields[x][y] & 0x000000FF; +} + +unsigned char cCurTown::misc_i(char x, char y) const{ + return (fields[x][y] & 0x0000FF00) >> 8; +} + +unsigned char cCurTown::sfx(char x, char y) const{ + return (fields[x][y] & 0x00FF0000) >> 16; +} diff --git a/osx/universe.h b/osx/universe.h index 412f68d7..06fc3ece 100644 --- a/osx/universe.h +++ b/osx/universe.h @@ -7,7 +7,6 @@ */ namespace legacy { - struct setup_save_type; struct out_info_type; struct current_town_type; struct town_item_list; @@ -22,7 +21,7 @@ public: // formerly current_town_type short num; // 200 if outdoors (my addition) short difficulty; - char explored[64][64]; + //char explored[64][64]; bool hostile; cPopulation monst; bool in_boat; // is this really needed? @@ -30,44 +29,95 @@ public: cSpeech* cur_talk; // my addition short cur_talk_loaded; // my addition - unsigned short setup[4][64][64]; // formerly setup_save_type cItemRec items[115]; // formerly town_item_list type - char maps[200][8][64]; // formerly stored_town_maps_type unsigned short template_terrain[64][64]; + unsigned long fields[64][64]; void append(legacy::current_town_type& old,short which_size); void append(legacy::town_item_list& old); - void append(legacy::setup_save_type& old); - void append(legacy::stored_town_maps_type& old); void append(unsigned char(& old_sfx)[64][64], unsigned char(& old_misc_i)[64][64]); void cCurTown::append(legacy::big_tr_type& old); + unsigned char explored(char x,char y) const; + unsigned char misc_i(char x, char y) const; + unsigned char sfx(char x, char y) const; + cTown* operator -> (); bool loaded() const; void unload(); + + bool is_explored(char x, char y) const; + bool is_force_wall(char x, char y) const; + bool is_fire_wall(char x, char y) const; + bool is_antimagic(char x, char y) const; + bool is_scloud(char x, char y) const; // stinking cloud + bool is_ice_wall(char x, char y) const; + bool is_blade_wall(char x, char y) const; + bool is_sleep_cloud(char x, char y) const; + bool is_block(char x, char y) const; // currently unused + bool is_special(char x, char y) const; + bool is_web(char x, char y) const; + bool is_crate(char x, char y) const; + bool is_barrel(char x, char y) const; + bool is_fire_barr(char x, char y) const; + bool is_force_barr(char x, char y) const; + bool is_quickfire(char x, char y) const; + bool is_sm_blood(char x, char y) const; + bool is_med_blood(char x, char y) const; + bool is_lg_blood(char x, char y) const; + bool is_sm_slime(char x, char y) const; + bool is_lg_slime(char x, char y) const; + 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_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); + bool set_scloud(char x, char y, bool b); // stinking cloud + 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_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); }; class cCurOut { public: char expl[96][96]; // formerly out_info_type - char maps[100][6][48]; // formerly stored_outdoor_maps_type unsigned short out[96][96]; unsigned char out_e[96][96]; cOutdoors outdoors[2][2]; - unsigned char sfx[64][64]; - unsigned char misc_i[64][64]; + //unsigned char sfx[64][64]; + //unsigned char misc_i[64][64]; void append(legacy::out_info_type& old); - void append(legacy::stored_outdoor_maps_type& old); - void append(unsigned char(& old_sfx)[64][64], unsigned char(& old_misc_i)[64][64]); }; class cUniverse{ public: cParty party; cCurTown town; + char town_maps[200][8][64]; // formerly stored_town_maps_type cCurOut out; + char out_maps[100][6][48]; // formerly stored_outdoor_maps_type FSSpec file; + void append(legacy::stored_town_maps_type& old); + void append(legacy::stored_outdoor_maps_type& old); }; \ No newline at end of file