void unfill_reinforced_corners(PlayerNumber keep_plyr_idx, MapSlabCoord base_slb_x, MapSlabCoord base_slb_y) { //_DK_unfill_reinforced_corners(plyr_idx, base_slb_x, base_slb_y); return; int i; for (i = 0; i < SMALL_AROUND_SLAB_LENGTH; i++) { MapSlabCoord slb_x, slb_y; slb_x = base_slb_x + small_around[i].delta_x; slb_y = base_slb_y + small_around[i].delta_y; struct SlabMap *slb; slb = get_slabmap_block(slb_x, slb_y); struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); if ((slbattr->category == SlbAtCtg_FortifiedWall) && (slabmap_owner(slb) != keep_plyr_idx)) { int num_owned_around; num_owned_around = count_owned_ground_around(slabmap_owner(slb), slb_x, slb_y); if (num_owned_around < 2) { SlabKind slbkind; slbkind = alter_rock_style(SlbT_EARTH, slb_x, slb_y, game.neutral_player_num); place_slab_type_on_map(slbkind, slab_subtile_center(slb_x), slab_subtile_center(slb_y), game.neutral_player_num, 0); do_slab_efficiency_alteration(slb_x, slb_y); } } } }
/** * Removes reinforces walls from tiles around given slab, except given owner. * @param keep_plyr_idx The owning player whose walls are not to be affected. * @param slb_x Central slab for the unprettying effect, X coord. * @param slb_y Central slab for the unprettying effect, Y coord. */ void do_unprettying(PlayerNumber keep_plyr_idx, MapSlabCoord slb_x, MapSlabCoord slb_y) { long n; for (n=0; n < SMALL_AROUND_SLAB_LENGTH; n++) { long sslb_x,sslb_y; struct SlabMap *slb; sslb_x = slb_x + (long)small_around[n].delta_x; sslb_y = slb_y + (long)small_around[n].delta_y; slb = get_slabmap_block(sslb_x, sslb_y); struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); if ((slbattr->category == SlbAtCtg_FortifiedWall) && (slabmap_owner(slb) != keep_plyr_idx)) { if (!slab_by_players_land(slabmap_owner(slb), sslb_x, sslb_y)) { SlabKind newslab; newslab = choose_rock_type(keep_plyr_idx, sslb_x, sslb_y); place_slab_type_on_map(newslab, slab_subtile_center(sslb_x), slab_subtile_center(sslb_y), game.neutral_player_num, 0); unfill_reinforced_corners(keep_plyr_idx, sslb_x, sslb_y); do_slab_efficiency_alteration(sslb_x, sslb_y); } } } }
TbBool can_place_trap_on(PlayerNumber plyr_idx, MapSubtlCoord stl_x, MapSubtlCoord stl_y) { MapSlabCoord slb_x, slb_y; slb_x = subtile_slab_fast(stl_x); slb_y = subtile_slab_fast(stl_y); struct SlabMap *slb; slb = get_slabmap_block(slb_x, slb_y); struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); if (!subtile_revealed(stl_x, stl_y, plyr_idx)) { return false; } if (((slbattr->block_flags & (SlbAtFlg_Filled|SlbAtFlg_Digable|SlbAtFlg_Valuable)) != 0)) { return false; } if (slab_kind_is_liquid(slb->kind)) { return false; } if ((slabmap_owner(slb) == plyr_idx) && (slb->kind == SlbT_CLAIMED)) { if (!slab_has_trap_on(slb_x, slb_y) && !subtile_has_door_thing_on(stl_x, stl_y)) { return true; } } return false; }
/** * Counts amount of tiles owned by given player around given slab. * @param plyr_idx Owning player to be checked. * @param slb_x Target slab to check around, X coord. * @param slb_y Target slab to check around, Y coord. * @return Amount 0-4 of owned slabs, or just 4 if there is any owned ground or room slab. */ int count_owned_ground_around(PlayerNumber plyr_idx, MapSlabCoord slb_x, MapSlabCoord slb_y) { int i, num_owned; num_owned = 0; for (i=0; i < SMALL_AROUND_SLAB_LENGTH; i++) { MapSlabCoord sslb_x, sslb_y; sslb_x = slb_x + small_around[i].delta_x; sslb_y = slb_y + small_around[i].delta_y; struct SlabMap *slb; slb = get_slabmap_block(sslb_x, sslb_y); if (slabmap_owner(slb) == plyr_idx) { struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); if ((slbattr->category == SlbAtCtg_FortifiedGround) || (slbattr->category == SlbAtCtg_RoomInterior)) { num_owned = 4; break; } else { num_owned++; } } } return num_owned; }
SlabKind find_core_slab_type(MapSlabCoord slb_x, MapSlabCoord slb_y) { struct SlabMap *slb; slb = get_slabmap_block(slb_x, slb_y); struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); SlabKind corekind; switch (slbattr->category) { case SlbAtCtg_FriableDirt: corekind = SlbT_EARTH; break; case SlbAtCtg_FortifiedWall: corekind = SlbT_WALLDRAPE; break; case SlbAtCtg_Obstacle: // originally, 99 was returned by this case, without further conditions if ((slbattr->block_flags & SlbAtFlg_IsRoom) != 0) corekind = SlbT_BRIDGE; else corekind = SlbT_DOORWOOD1; break; default: corekind = slb->kind; break; } return corekind; }
TbBool slab_is_safe_land(PlayerNumber plyr_idx, MapSlabCoord slb_x, MapSlabCoord slb_y) { struct SlabMap *slb; struct SlabAttr *slbattr; int slb_owner; slb = get_slabmap_block(slb_x, slb_y); slbattr = get_slab_attrs(slb); slb_owner = slabmap_owner(slb); if ((slb_owner == plyr_idx) || (slb_owner == game.neutral_player_num)) { return slbattr->is_safe_land; } return false; }
int floor_height_for_volume_box(PlayerNumber plyr_idx, MapSlabCoord slb_x, MapSlabCoord slb_y) { struct SlabMap *slb; slb = get_slabmap_block(slb_x, slb_y); struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); if (!subtile_revealed(slab_subtile_center(slb_x), slab_subtile_center(slb_y), plyr_idx) || ((slbattr->block_flags & (SlbAtFlg_Filled|SlbAtFlg_Digable|SlbAtFlg_Valuable)) != 0)) { return temp_cluedo_mode < 1u ? 5 : 2; } if (slab_kind_is_liquid(slb->kind)) { return 0; } return 1; }
/** * Scans map for gold veins, and fills up gold_lookup array with veins found. */ void check_map_for_gold(void) { MapSlabCoord slb_x,slb_y; struct SlabMap *slb; SlabCodedCoords slb_num; unsigned char *treasure_map; unsigned short *vein_list; long gold_next_idx; long i; SYNCDBG(8,"Starting"); //_DK_check_map_for_gold(); for (i=0; i < GOLD_LOOKUP_COUNT; i++) { LbMemorySet(&game.gold_lookup[i], 0, sizeof(struct GoldLookup)); } // Make a map with treasure areas marked treasure_map = (unsigned char *)scratch; vein_list = (unsigned short *)&scratch[map_tiles_x*map_tiles_y]; for (slb_y = 0; slb_y < map_tiles_y; slb_y++) { for (slb_x = 0; slb_x < map_tiles_x; slb_x++) { slb_num = get_slab_number(slb_x, slb_y); slb = get_slabmap_direct(slb_num); treasure_map[slb_num] = 0; const struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); // Mark areas which are not valuable if ((slbattr->block_flags & (SlbAtFlg_Valuable)) == 0) { treasure_map[slb_num] |= 0x01; } } } // Add treasures to lookup as gold veins gold_next_idx = 0; for (slb_y = 0; slb_y < map_tiles_y; slb_y++) { for (slb_x = 0; slb_x < map_tiles_x; slb_x++) { slb_num = get_slab_number(slb_x, slb_y); if ( ((treasure_map[slb_num] & 0x01) == 0) && ((treasure_map[slb_num] & 0x02) == 0) ) { check_treasure_map(treasure_map, vein_list, &gold_next_idx, slb_x, slb_y); } } } SYNCDBG(8,"Found %ld possible digging locations",gold_next_idx); }
void do_slab_efficiency_alteration(MapSlabCoord slb_x, MapSlabCoord slb_y) { long n; for (n=0; n < SMALL_AROUND_SLAB_LENGTH; n++) { MapSlabCoord sslb_x, sslb_y; sslb_x = slb_x + small_around[n].delta_x; sslb_y = slb_y + small_around[n].delta_y; struct SlabMap *slb; struct SlabAttr *slbattr; slb = get_slabmap_block(sslb_x, sslb_y); if (slabmap_block_invalid(slb)) { continue; } slbattr = get_slab_attrs(slb); if (slbattr->category == SlbAtCtg_RoomInterior) { struct Room *room; room = slab_room_get(sslb_x, sslb_y); set_room_efficiency(room); set_room_capacity(room, true); } } }
void update_horizonal_explored_flags_for_power_sight(struct PlayerInfo *player, struct Coord3d *soe_pos) { struct Dungeon *dungeon; long stl_x,stl_y; long soe_x,soe_y; long boundstl_y; long slb_x,slb_y; long delta; long i; dungeon = get_players_dungeon(player); stl_x = (long)soe_pos->x.stl.num - MAX_SOE_RADIUS; for (soe_x=0; soe_x < 2*MAX_SOE_RADIUS; soe_x++,stl_x++) { if ( (stl_x >= 0) && (stl_x <= 255) ) { stl_y = (long)soe_pos->y.stl.num - MAX_SOE_RADIUS; for (soe_y=0; soe_y <= MAX_SOE_RADIUS; soe_y++,stl_y++) { if (dungeon->soe_explored_flags[soe_y][soe_x]) { soe_y++; // Find max value for delta delta = 0; for (i=1; soe_y < 2*MAX_SOE_RADIUS; soe_y++,i++) { if (dungeon->soe_explored_flags[soe_y][soe_x]) delta = i; } boundstl_y = stl_y + delta; if (boundstl_y < 0) { boundstl_y = 0; } else if (boundstl_y > map_subtiles_y-1) { boundstl_y = map_subtiles_y-1; } if (stl_y < 0) { stl_y = 0; } else if (stl_y > map_subtiles_y-1) { stl_y = map_subtiles_y-1; } if (stl_y <= boundstl_y) { delta = boundstl_y - stl_y + 1; slb_x = subtile_slab_fast(stl_x); for (i=0; i < delta; i++) { struct Map *mapblk; slb_y = subtile_slab_fast(stl_y+i); mapblk = get_map_block_at(stl_x, stl_y+i); reveal_map_block(mapblk, player->id_number); struct SlabMap *slb; struct SlabAttr *slbattr; slb = get_slabmap_block(slb_x, slb_y); slbattr = get_slab_attrs(slb); if ( !slbattr->is_unknflg14 ) mapblk->flags &= ~(MapFlg_Unkn80|MapFlg_Unkn04); } stl_y += delta; } } } } } }
void make_safe(struct PlayerInfo *player) { //_DK_make_safe(player); unsigned char *areamap; areamap = (unsigned char *)scratch; MapSlabCoord slb_x, slb_y; // Prepare the array to remember which slabs were already taken care of for (slb_y=0; slb_y < map_tiles_y; slb_y++) { for (slb_x=0; slb_x < map_tiles_x; slb_x++) { SlabCodedCoords slb_num; struct SlabMap *slb; slb_num = get_slab_number(slb_x, slb_y); slb = get_slabmap_direct(slb_num); struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); if ((slbattr->block_flags & (SlbAtFlg_Filled|SlbAtFlg_Digable|SlbAtFlg_Valuable)) != 0) areamap[slb_num] = 0x01; else areamap[slb_num] = 0x00; } } { const struct Coord3d *center_pos; center_pos = dungeon_get_essential_pos(player->id_number); slb_x = subtile_slab_fast(center_pos->x.stl.num); slb_y = subtile_slab_fast(center_pos->y.stl.num); SlabCodedCoords slb_num; slb_num = get_slab_number(slb_x, slb_y); areamap[slb_num] |= 0x02; } unsigned int list_cur, list_len; PlayerNumber plyr_idx; plyr_idx = player->id_number; SlabCodedCoords *slblist; slblist = (SlabCodedCoords *)(scratch + map_tiles_x*map_tiles_y); list_len = 0; list_cur = 0; while (list_cur <= list_len) { SlabCodedCoords slb_num; if (slb_x > 0) { slb_num = get_slab_number(slb_x-1, slb_y); if ((areamap[slb_num] & 0x01) != 0) { areamap[slb_num] |= 0x02; struct SlabMap *slb; slb = get_slabmap_direct(slb_num); struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); if ((slbattr->category == SlbAtCtg_FriableDirt) && slab_by_players_land(plyr_idx, slb_x-1, slb_y)) { unsigned char pretty_type; pretty_type = choose_pretty_type(plyr_idx, slb_x-1, slb_y); place_slab_type_on_map(pretty_type, slab_subtile(slb_x-1,0), slab_subtile(slb_y,0), plyr_idx, 1); do_slab_efficiency_alteration(slb_x-1, slb_y); fill_in_reinforced_corners(plyr_idx, slb_x-1, slb_y); } } else if ((areamap[slb_num] & 0x02) == 0) { areamap[slb_num] |= 0x02; slblist[list_len] = slb_num; list_len++; } } if (slb_x < map_tiles_x-1) { slb_num = get_slab_number(slb_x+1, slb_y); if ((areamap[slb_num] & 0x01) != 0) { areamap[slb_num] |= 0x02; struct SlabMap *slb; slb = get_slabmap_direct(slb_num); struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); if ((slbattr->category == SlbAtCtg_FriableDirt) && slab_by_players_land(plyr_idx, slb_x+1, slb_y)) { unsigned char pretty_type; pretty_type = choose_pretty_type(plyr_idx, slb_x+1, slb_y); place_slab_type_on_map(pretty_type, slab_subtile(slb_x+1,0), slab_subtile(slb_y,0), plyr_idx, 1u); do_slab_efficiency_alteration(slb_x+1, slb_y); fill_in_reinforced_corners(plyr_idx, slb_x+1, slb_y); } } else if ((areamap[slb_num] & 0x02) == 0) { areamap[slb_num] |= 0x02; slblist[list_len] = slb_num; list_len++; } } if (slb_y > 0) { slb_num = get_slab_number(slb_x, slb_y-1); if ((areamap[slb_num] & 0x01) != 0) { areamap[slb_num] |= 0x02; struct SlabMap *slb; slb = get_slabmap_direct(slb_num); struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); if ((slbattr->category == SlbAtCtg_FriableDirt) && slab_by_players_land(plyr_idx, slb_x, slb_y-1)) { unsigned char pretty_type; pretty_type = choose_pretty_type(plyr_idx, slb_x, slb_y-1); place_slab_type_on_map(pretty_type, slab_subtile(slb_x,0), slab_subtile(slb_y-1,0), plyr_idx, 1u); do_slab_efficiency_alteration(slb_x, slb_y-1); fill_in_reinforced_corners(plyr_idx, slb_x, slb_y-1); } } else if ((areamap[slb_num] & 0x02) == 0) { areamap[slb_num] |= 0x02; slblist[list_len] = slb_num; list_len++; } } if (slb_y < map_tiles_y-1) { slb_num = get_slab_number(slb_x, slb_y+1); if ((areamap[slb_num] & 0x01) != 0) { areamap[slb_num] |= 0x02; struct SlabMap *slb; slb = get_slabmap_direct(slb_num); struct SlabAttr *slbattr; slbattr = get_slab_attrs(slb); if ((slbattr->category == SlbAtCtg_FriableDirt) && slab_by_players_land(plyr_idx, slb_x, slb_y+1)) { unsigned char pretty_type; pretty_type = choose_pretty_type(plyr_idx, slb_x, slb_y+1); place_slab_type_on_map(pretty_type, slab_subtile(slb_x,0), slab_subtile(slb_y+1,0), plyr_idx, 1u); do_slab_efficiency_alteration(slb_x, slb_y+1); fill_in_reinforced_corners(plyr_idx, slb_x, slb_y+1); } } else if ((areamap[slb_num] & 0x02) == 0) { areamap[slb_num] |= 0x02; slblist[list_len] = slb_num; list_len++; } } slb_x = slb_num_decode_x(slblist[list_cur]); slb_y = slb_num_decode_y(slblist[list_cur]); list_cur++; } pannel_map_update(0, 0, map_subtiles_x+1, map_subtiles_y+1); }