Fix special spots not being properly cleared from the previous town

(And get rid of the old forwarder functions for the field bitfields.)
This commit is contained in:
2014-12-16 18:18:58 -05:00
parent bfafc42d46
commit 6866bf70c5
6 changed files with 23 additions and 53 deletions

View File

@@ -184,10 +184,6 @@ void init_town(){ // formerly part of load_town
univ.town.fields[i][j] = 0;
//univ.out.sfx[i][j] = 0;
}
for(i = 0; i < 50; i++)
if(univ.town->special_locs[i].x < 100){
univ.town.set_special(univ.town->special_locs[i].x,univ.town->special_locs[i].y,true);
}
for(i = 0; i < univ.town->preset_fields.size(); i++) {
switch(univ.town->preset_fields[i].type){
case 1: // currently unused

View File

@@ -736,11 +736,13 @@ bool combat_move_monster(short which,location destination) {
// Looks at all spaces within 2, looking for a spot which is clear of nastiness and beings
// returns {0,0} if none found
// THIS MAKES NO ADJUSTMENTS FOR BIG MONSTERS!!!
// TODO: THIS MAKES NO ADJUSTMENTS FOR BIG MONSTERS!!!
//mode; // 0 - normal 1 - prefer adjacent space
location find_clear_spot(location from_where,short mode) {
location loc,store_loc;
short num_tries = 0,r1;
// Here 254 indicates the low byte of the town fields, minus explored spaces (which is lowest bit).
unsigned long blocking_fields = OBJECT_CRATE | OBJECT_BARREL | OBJECT_BLOCK | FIELD_QUICKFIRE | 254;
while(num_tries < 75) {
num_tries++;
@@ -753,8 +755,7 @@ location find_clear_spot(location from_where,short mode) {
&& can_see_light(from_where,loc,combat_obscurity) == 0
&& (!(is_combat()) || (pc_there(loc) == 6))
&& (!(is_town()) || (loc != univ.town.p_loc))
&& (!(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
&& (!(univ.town.fields[loc.x][loc.y] & blocking_fields))) {
if((mode == 0) || ((mode == 1) && (adjacent(from_where,loc))))
return loc;
else store_loc = loc;

View File

@@ -277,10 +277,11 @@ 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.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];
// except that pushable things restore to orig locs
temp = univ.party.setup[i][j][k] << 8;
temp &= OBJECT_CRATE | OBJECT_BARREL | OBJECT_BLOCK;
univ.town.fields[j][k] &= ~(OBJECT_CRATE | OBJECT_BARREL | OBJECT_BLOCK);
univ.town.fields[j][k] |= temp;
}
}
@@ -570,14 +571,14 @@ location end_town_mode(short switching_level,location destination) { // returns
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.party.setup[i][j][k] = univ.town.misc_i(j,k);
univ.party.setup[i][j][k] = (univ.town.fields[j][k] & 0xff00) >> 8;
data_saved = true;
}
if(!data_saved) {
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.party.setup[univ.party.at_which_save_slot][j][k] = univ.town.misc_i(j,k);
univ.party.setup[univ.party.at_which_save_slot][j][k] = (univ.town.fields[j][k] & 0xff00) >> 8;
univ.party.at_which_save_slot = (univ.party.at_which_save_slot == 3) ? 0 : univ.party.at_which_save_slot + 1;
}
@@ -1199,7 +1200,6 @@ void erase_specials() {
// case 212: univ.town->terrain(where.x,where.y) = 36; break;
// }
univ.town.set_spot(where.x,where.y,false);
univ.town.set_special(where.x,where.y,false);
}
}

View File

@@ -801,14 +801,16 @@ enum eFieldType {
WALL_ICE = 5,
WALL_BLADES = 6,
CLOUD_SLEEP = 7,
// Begin fields saved in town setup
OBJECT_BLOCK = 8,
SPECIAL_SPACE = 9, // Don't allow monsters or combat PC placement
SPECIAL_SPOT = 9, // Space contains a white special spot
FIELD_WEB = 10,
OBJECT_CRATE = 11,
OBJECT_BARREL = 12,
BARRIER_FIRE = 13,
BARRIER_FORCE = 14,
FIELD_QUICKFIRE = 15,
// End fields saved in town setup
SFX_SMALL_BLOOD = 16,
SFX_MEDIUM_BLOOD = 17,
SFX_LARGE_BLOOD = 18,
@@ -818,7 +820,6 @@ enum eFieldType {
SFX_BONES = 22,
SFX_RUBBLE = 23,
BARRIER_CAGE = 24,
SPECIAL_SPOT = 25,
// From here on are special values that don't index anything.
// Thus, they start at 32.
FIELD_DISPEL = 32, // Dispel field

View File

@@ -96,8 +96,8 @@ void cCurTown::append(unsigned char(& old_sfx)[64][64], unsigned char(& old_misc
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;
fields[i][j] = tmp_sfx;
fields[i][j] = tmp_misc_i;
}
}
@@ -191,12 +191,15 @@ bool cCurTown::is_block(char x, char y) const{ // currently unused
}
bool cCurTown::is_spot(char x, char y) const{
return special_spot[x][y];
return fields[x][y] & SPECIAL_SPOT;
}
bool cCurTown::is_special(char x, char y) const{
if(x > record->max_dim() || y > record->max_dim()) return false;
return fields[x][y] & SPECIAL_SPACE;
for(int i = 0; i < 50; i++)
if(x == record->special_locs[i].x && y == record->special_locs[i].y)
return true;
return false;
}
bool cCurTown::is_web(char x, char y) const{
@@ -412,14 +415,8 @@ bool cCurTown::set_block(char x, char y, bool b){ // currently unused
bool cCurTown::set_spot(char x, char y, bool b){
if(x > record->max_dim() || y > record->max_dim()) return false;
special_spot[x][y] = b;
return true;
}
bool cCurTown::set_special(char x, char y, bool b){
if(x > record->max_dim() || y > record->max_dim()) return false;
if(b) fields[x][y] |= SPECIAL_SPACE;
else fields[x][y] &= ~SPECIAL_SPACE;
if(b) fields[x][y] |= SPECIAL_SPOT;
else fields[x][y] &= ~SPECIAL_SPOT;
return true;
}
@@ -721,21 +718,6 @@ bool cCurTown::set_force_cage(char x, char y, bool b){
// }else trim[x][y] &= ~bit;
//}
unsigned char cCurTown::explored(char x,char y) const{
if(x > record->max_dim() || y > record->max_dim()) return 0;
return fields[x][y] & 0x000000FF;
}
unsigned char cCurTown::misc_i(char x, char y) const{
if(x > record->max_dim() || y > record->max_dim()) return 0;
return (fields[x][y] & 0x0000FF00) >> 8;
}
unsigned char cCurTown::sfx(char x, char y) const{
if(x > record->max_dim() || y > record->max_dim()) return 0;
return (fields[x][y] & 0x00FF0000) >> 16;
}
// TODO: This seems to be wrong; impassable implies "blocks movement", which two other blockages also do
bool cCurTown::is_impassable(short i,short j) {
ter_num_t ter;

View File

@@ -50,18 +50,12 @@ public:
//ter_num_t template_terrain[64][64];
unsigned long fields[64][64];
bool special_spot[64][64];
// unsigned char trim[64][64]; // transient
void append(legacy::current_town_type& old,short which_size);
void append(legacy::town_item_list& old);
void append(unsigned char(& old_sfx)[64][64], unsigned char(& old_misc_i)[64][64]);
void append(legacy::big_tr_type& old);
__declspec(deprecated) unsigned char explored(char x,char y) const;
__declspec(deprecated) unsigned char misc_i(char x, char y) const;
__declspec(deprecated) unsigned char sfx(char x, char y) const;
cTown* operator -> ();
cCurTown();
bool loaded() const;
@@ -108,7 +102,6 @@ public:
bool set_sleep_cloud(char x, char y, bool b);
bool set_block(char x, char y, bool b); // currently unused
bool set_spot(char x, char y, bool b);
bool set_special(char x, char y, bool b);
bool set_web(char x, char y, bool b);
bool set_crate(char x, char y, bool b);
bool set_barrel(char x, char y, bool b);
@@ -139,9 +132,6 @@ public:
unsigned char out_e[96][96];
cOutdoors outdoors[2][2];
//unsigned char sfx[64][64];
//unsigned char misc_i[64][64];
void append(legacy::out_info_type& old);
ter_num_t(& operator [] (size_t i))[96];