void update_map_collide(SlabKind slbkind, MapSubtlCoord stl_x, MapSubtlCoord stl_y) { struct Map *mapblk; mapblk = get_map_block_at(stl_x, stl_y); struct Column *colmn; colmn = get_map_column(mapblk); if (column_invalid(colmn)) { ERRORLOG("Invalid column at (%d,%d)",(int)stl_x,(int)stl_y); } unsigned long smask; smask = colmn->solidmask; MapSubtlCoord stl_z; for (stl_z=0; stl_z < map_subtiles_z; stl_z++) { if ((smask & 0x01) == 0) break; smask >>= 1; } struct SlabAttr *slbattr; slbattr = get_slab_kind_attrs(slbkind); unsigned long nflags; if (slbattr->field_2 < stl_z) { nflags = slbattr->block_flags; } else { nflags = slbattr->noblck_flags; } mapblk->flags &= (SlbAtFlg_Unk80|SlbAtFlg_Unk04); mapblk->flags |= nflags; }
/** * Returns amount of filled subtiles at bottom of column at given map block. * @param mapblk The map block for which column height should be returned. */ long get_map_floor_filled_subtiles(const struct Map *mapblk) { const struct Column *col; col = get_map_column(mapblk); if (column_invalid(col)) return 0; return (col->bitfields & 0xF0) >> 4; }
/** * Returns amount of filled subtiles at top of column at given map block. * @param mapblk The map block for which column height should be returned. */ long get_map_ceiling_filled_subtiles(const struct Map *mapblk) { const struct Column *col; col = get_map_column(mapblk); if (column_invalid(col)) return 0; return (col->bitfields & 0x0E) >> 1; }
/** * Sets amount of filled subtiles at top of a column at given map block. * @param mapblk The map block for which filled height should be set. * @param n Amount of subtiles. */ void set_map_ceiling_filled_subtiles(struct Map *mapblk, MapSubtlCoord n) { struct Column *col; col = get_map_column(mapblk); if (column_invalid(col)) return; col->bitfields &= ~0x0E; col->bitfields |= (n<<1) & 0x0E; }
long get_map_ceiling_height(const struct Map *mapblk) { const struct Column *colmn; long i,cubes_height; colmn = get_map_column(mapblk); i = get_column_ceiling_filled_subtiles(colmn); if (i > 0) { cubes_height = 8 - i; } else { cubes_height = get_mapblk_filled_subtiles(mapblk); } return cubes_height << 8; }
/** * Returns height of a floor, in map coordinates. * @param mapblk The map block for which floor height should be returned. */ long get_map_floor_height(const struct Map *mapblk) { const struct Column *colmn; long i,cubes_height; colmn = get_map_column(mapblk); i = get_column_floor_filled_subtiles(colmn); if (i > 0) { cubes_height = i; } else { cubes_height = 0; } return cubes_height << 8; }
long get_top_cube_at_pos(long stl_num) { struct Column *col; struct Map *mapblk; unsigned long top_pos; long tcube; mapblk = get_map_block_at_pos(stl_num); col = get_map_column(mapblk); top_pos = get_column_floor_filled_subtiles(col); if (top_pos > 0) tcube = col->cubes[top_pos-1]; else tcube = game.field_14BB65[col->baseblock]; return tcube; }