u16 tileweight( unsigned short tilenum ) { USTRUCT_TILE tile; tile.weight = 1; readtile( tilenum, &tile ); return tile.weight; }
char tileheight(unsigned short tilenum) { u8 height; u32 flags; if (tilenum <= config.max_tile_id) { height = tiledata[tilenum].height; flags = tiledata[tilenum].flags; } else { USTRUCT_TILE tile; height = 0; flags = 0; readtile(tilenum, &tile); height = tile.height; flags = tile.flags; } if (flags & USTRUCT_TILE::FLAG_HALF_HEIGHT) return (height/2); else return height; }
u32 tile_uoflags( unsigned short tilenum ) { if (tilenum <= config.max_tile_id ) { return tiledata[ tilenum ].flags; } else { USTRUCT_TILE tile; tile.flags = 0; readtile(tilenum, &tile); return tile.flags; } }
unsigned char tilelayer( unsigned short tilenum ) { if (tilenum <= config.max_tile_id ) { return tiledata[ tilenum ].layer; } else { USTRUCT_TILE tile; tile.layer = 0; readtile(tilenum, &tile); return tile.layer; } }
static void read_tiledata() { tiledata = new TileData[config.max_tile_id+1]; for( u16 graphic = 0; graphic <= config.max_tile_id; ++graphic ) { USTRUCT_TILE objinfo; memset( &objinfo, 0, sizeof objinfo ); readtile( graphic, &objinfo ); tiledata[ graphic ].height = objinfo.height; tiledata[ graphic ].layer = objinfo.layer; tiledata[ graphic ].flags = objinfo.flags; } }
void read_objinfo( u16 graphic, USTRUCT_TILE& objinfo ) { readtile( graphic, &objinfo ); }
void write_multi( FILE* multis_cfg, unsigned id, FILE* multi_mul, unsigned int offset, unsigned int length ) { USTRUCT_MULTI_ELEMENT elem; unsigned int count; if ( cfg_use_new_hsa_format ) count = length / sizeof( USTRUCT_MULTI_ELEMENT_HSA ); else count = length / sizeof elem; std::string type, mytype; if ( BoatTypes.count( id ) ) type = "Boat"; else if ( HouseTypes.count( id ) ) type = "House"; else if ( StairTypes.count( id ) ) type = "Stairs"; else { ERROR_PRINT << "Type 0x" << fmt::hexu( id ) << " not found in uoconvert.cfg, assuming \"House\" type.\n"; type = "House"; } mytype = type; fprintf( multis_cfg, "%s 0x%x\n", type.c_str(), id ); fprintf( multis_cfg, "{\n" ); if (fseek(multi_mul, offset, SEEK_SET) != 0) { throw std::runtime_error("write_multi(): fseek() failed"); } bool first = true; while ( count-- ) { if (fread(&elem, sizeof elem, 1, multi_mul) != 1) { throw std::runtime_error("write_multi(): fread() failed"); } if (cfg_use_new_hsa_format) { if (fseek(multi_mul, 4, SEEK_CUR) != 0) throw std::runtime_error("write_multi(): fseek() failed"); } if ( elem.graphic == GRAPHIC_NODRAW ) continue; if ( elem.flags ) type = "static"; else type = "dynamic"; // boats typically have as their first element the "mast", but flagged as dynamic. if ( mytype == "Boat" ) { if ( first && elem.graphic != 1 ) type = "static"; } std::string comment; if ( cfg_use_new_hsa_format ) { USTRUCT_TILE_HSA tile; readtile( elem.graphic, &tile ); comment.assign( tile.name, sizeof( tile.name ) ); } else { USTRUCT_TILE tile; readtile( elem.graphic, &tile ); comment.assign( tile.name, sizeof( tile.name ) ); } fprintf( multis_cfg, " %-7s 0x%04x %4d %4d %4d // %s\n", type.c_str(), elem.graphic, elem.x, elem.y, elem.z, comment.c_str() ); first = false; } fprintf( multis_cfg, "}\n" ); fprintf( multis_cfg, "\n" ); }