diff --git a/generated/meson.build b/generated/meson.build index fe3a619518..bee670c564 100644 --- a/generated/meson.build +++ b/generated/meson.build @@ -117,7 +117,7 @@ metang_generators = { 'tutor_locations': {'type': 'enum', 'tag': 'TutorLocation'}, 'vars_flags': {'type': 'enum', 'tag': 'VarFlag'}, 'versions': {'type': 'enum', 'tag': 'Version'}, - 'villa_furnitures': {'type': 'enum', 'tag': 'VillaFurniture'}, + 'villa_furniture_type': {'type': 'enum', 'tag': 'VillaFurnitureType'}, 'mart_specialties_id': {'type': 'enum', 'tag': 'MartSpecialtiesID'}, 'mart_decor_id': {'type': 'enum', 'tag': 'MartDecorID'}, 'mart_seal_id': {'type': 'enum', 'tag': 'MartSealID'}, diff --git a/generated/villa_furnitures.txt b/generated/villa_furniture_type.txt similarity index 100% rename from generated/villa_furnitures.txt rename to generated/villa_furniture_type.txt diff --git a/include/map_object.h b/include/map_object.h index be977f6982..c36982d89b 100644 --- a/include/map_object.h +++ b/include/map_object.h @@ -25,7 +25,8 @@ #include "narc.h" #include "sys_task_manager.h" -#define MAP_OBJECT_COORD_TO_FX32(coord) ((coord << 4) * FX32_ONE) + (MAP_OBJECT_TILE_SIZE >> 1) +#define MAP_OBJECT_COORD_CENTER_TO_FX32(coord) ((coord << 4) * FX32_ONE) + (MAP_OBJECT_TILE_SIZE >> 1) +#define MAP_OBJECT_COORD_EDGE_TO_FX32(coord) ((coord << 4) * FX32_ONE) typedef struct MapObjectSave { u32 status; diff --git a/include/overlay005/ov5_021F8370.h b/include/overlay005/ov5_021F8370.h deleted file mode 100644 index 84026e6def..0000000000 --- a/include/overlay005/ov5_021F8370.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef POKEPLATINUM_OV5_021F8370_H -#define POKEPLATINUM_OV5_021F8370_H - -#include "field/field_system_decl.h" - -void Villa_DynamicMapFeaturesInit(FieldSystem *fieldSystem); -void Villa_DynamicMapFeaturesFree(FieldSystem *fieldSystem); -BOOL Villa_DynamicMapFeaturesCheckCollision(FieldSystem *fieldSystem, const int tileX, const int tileZ, const fx32 height, BOOL *isColliding); -BOOL ov5_021F8410(FieldSystem *fieldSystem, const int param1, const int param2, const int param3); - -#endif // POKEPLATINUM_OV5_021F8370_H diff --git a/include/overlay005/villa_furniture.h b/include/overlay005/villa_furniture.h new file mode 100644 index 0000000000..130ab81ee2 --- /dev/null +++ b/include/overlay005/villa_furniture.h @@ -0,0 +1,15 @@ +#ifndef POKEPLATINUM_VILLA_FURNITURE_H +#define POKEPLATINUM_VILLA_FURNITURE_H + +#include "field/field_system_decl.h" + +typedef struct VillaPersistedData { + int dummy; +} VillaPersistedData; + +void Villa_DynamicMapFeaturesInit(FieldSystem *fieldSystem); +void Villa_DynamicMapFeaturesFree(FieldSystem *fieldSystem); +BOOL Villa_DynamicMapFeaturesCheckCollision(FieldSystem *fieldSystem, const int tileX, const int tileZ, const fx32 height, BOOL *isColliding); +BOOL FieldSystem_TrySetVillaFurnitureScript(FieldSystem *fieldSystem, const int param1, const int param2, const int direction); + +#endif // POKEPLATINUM_VILLA_FURNITURE_H diff --git a/include/struct_defs/struct_02071C34.h b/include/struct_defs/struct_02071C34.h deleted file mode 100644 index e5961d7064..0000000000 --- a/include/struct_defs/struct_02071C34.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_02071C34_H -#define POKEPLATINUM_STRUCT_02071C34_H - -typedef struct { - int unk_00; -} UnkStruct_02071C34; - -#endif // POKEPLATINUM_STRUCT_02071C34_H diff --git a/include/system_flags.h b/include/system_flags.h index 1a067f4c34..9078df83a5 100644 --- a/include/system_flags.h +++ b/include/system_flags.h @@ -6,7 +6,7 @@ #include "generated/giratina_shadow_animations.h" #include "generated/map_headers.h" #include "generated/pokemon_contest_types.h" -#include "generated/villa_furnitures.h" +#include "generated/villa_furniture_type.h" #include "vars_flags.h" @@ -67,7 +67,7 @@ BOOL SystemFlag_HandleForceBikingInGate(VarsFlags *varsFlags, enum HandleFlagOp BOOL SystemFlag_HandleJournalAcquired(VarsFlags *varsFlags, enum HandleFlagOp op); BOOL SystemFlag_HandleFirstArrivalToZone(VarsFlags *varsFlags, enum HandleFlagOp op, u32 firstArrival); void SystemFlag_SetConnectedToWiFi(VarsFlags *varsFlags); -BOOL SystemFlag_HandleOwnsVillaFurniture(VarsFlags *varsFlags, enum HandleFlagOp op, enum VillaFurniture furniture); +BOOL SystemFlag_HandleOwnsVillaFurniture(VarsFlags *varsFlags, enum HandleFlagOp op, enum VillaFurnitureType furniture); void SystemFlag_ClearVillaVisitorInside(VarsFlags *varsFlags); void SystemFlag_ClearVillaVisitorOutside(VarsFlags *varsFlags); BOOL SystemFlag_HandleGiratinaAnimation(VarsFlags *varsFlags, enum HandleFlagOp op, enum GiratinaShadowAnimation anim); diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index ebe4ef0023..acd593e31a 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -552,7 +552,7 @@ Overlay overlay5 Object main.nef.p/src_overlay005_ov5_021F61BC.c.o Object main.nef.p/src_overlay005_ov5_021F6454.c.o Object main.nef.p/src_overlay005_scrcmd_move_tutor.c.o - Object main.nef.p/src_overlay005_ov5_021F8370.c.o + Object main.nef.p/src_overlay005_villa_furniture.c.o Object main.nef.p/src_overlay005_dist_world_surf_mount_renderer.c.o } diff --git a/res/field/props/model_sets/prop_model_set_047.json b/res/field/props/model_sets/prop_model_set_047.json index dc53c059a2..77956a3fda 100644 --- a/res/field/props/model_sets/prop_model_set_047.json +++ b/res/field/props/model_sets/prop_model_set_047.json @@ -1,25 +1,25 @@ { "mapPropModels": [ "prop_model_078_nsbmd", - "prop_model_559_nsbmd", - "prop_model_560_nsbmd", - "prop_model_561_nsbmd", - "prop_model_562_nsbmd", - "prop_model_563_nsbmd", - "prop_model_564_nsbmd", - "prop_model_565_nsbmd", - "prop_model_566_nsbmd", - "prop_model_567_nsbmd", - "prop_model_568_nsbmd", - "prop_model_569_nsbmd", - "prop_model_570_nsbmd", - "prop_model_571_nsbmd", - "prop_model_572_nsbmd", - "prop_model_573_nsbmd", - "prop_model_574_nsbmd", - "prop_model_575_nsbmd", - "prop_model_576_nsbmd", - "prop_model_577_nsbmd", - "prop_model_578_nsbmd" + "villa_furniture_table_nsbmd", + "villa_furniture_big_sofa_nsbmd", + "villa_furniture_small_sofa_nsbmd", + "villa_furniture_bed_nsbmd", + "villa_furniture_night_table_nsbmd", + "villa_furniture_tv_nsbmd", + "villa_furniture_audio_system_nsbmd", + "villa_furniture_bookshelf_nsbmd", + "villa_furniture_rack_nsbmd", + "villa_furniture_houseplant_nsbmd", + "villa_furniture_pc_desk_nsbmd", + "villa_furniture_music_box_nsbmd", + "villa_furniture_pokemon_bust_nsbmd", + "villa_furniture_pokemon_bust_silver_nsbmd", + "villa_furniture_piano_nsbmd", + "villa_furniture_guest_set_nsbmd", + "villa_furniture_wall_clock_nsbmd", + "villa_furniture_masterpiece_nsbmd", + "villa_furniture_tea_set_nsbmd", + "villa_furniture_chandelier_nsbmd" ] } diff --git a/res/field/props/models/map_prop_models.order b/res/field/props/models/map_prop_models.order index a28eba6a5e..aef950328d 100644 --- a/res/field/props/models/map_prop_models.order +++ b/res/field/props/models/map_prop_models.order @@ -557,26 +557,26 @@ prop_model_555.nsbmd prop_model_556.nsbmd prop_model_557.nsbmd prop_model_558.nsbmd -prop_model_559.nsbmd -prop_model_560.nsbmd -prop_model_561.nsbmd -prop_model_562.nsbmd -prop_model_563.nsbmd -prop_model_564.nsbmd -prop_model_565.nsbmd -prop_model_566.nsbmd -prop_model_567.nsbmd -prop_model_568.nsbmd -prop_model_569.nsbmd -prop_model_570.nsbmd -prop_model_571.nsbmd -prop_model_572.nsbmd -prop_model_573.nsbmd -prop_model_574.nsbmd -prop_model_575.nsbmd -prop_model_576.nsbmd -prop_model_577.nsbmd -prop_model_578.nsbmd +villa_furniture_table.nsbmd +villa_furniture_big_sofa.nsbmd +villa_furniture_small_sofa.nsbmd +villa_furniture_bed.nsbmd +villa_furniture_night_table.nsbmd +villa_furniture_tv.nsbmd +villa_furniture_audio_system.nsbmd +villa_furniture_bookshelf.nsbmd +villa_furniture_rack.nsbmd +villa_furniture_houseplant.nsbmd +villa_furniture_pc_desk.nsbmd +villa_furniture_music_box.nsbmd +villa_furniture_pokemon_bust.nsbmd +villa_furniture_pokemon_bust_silver.nsbmd +villa_furniture_piano.nsbmd +villa_furniture_guest_set.nsbmd +villa_furniture_wall_clock.nsbmd +villa_furniture_masterpiece.nsbmd +villa_furniture_tea_set.nsbmd +villa_furniture_chandelier.nsbmd prop_model_579.nsbmd prop_model_580.nsbmd prop_model_581.nsbmd diff --git a/res/field/props/models/meson.build b/res/field/props/models/meson.build index e77a5e2a3d..502f539ef9 100644 --- a/res/field/props/models/meson.build +++ b/res/field/props/models/meson.build @@ -558,26 +558,26 @@ map_prop_model_files = copy_gen.process(files( 'prop_model_556.nsbmd', 'prop_model_557.nsbmd', 'prop_model_558.nsbmd', - 'prop_model_559.nsbmd', - 'prop_model_560.nsbmd', - 'prop_model_561.nsbmd', - 'prop_model_562.nsbmd', - 'prop_model_563.nsbmd', - 'prop_model_564.nsbmd', - 'prop_model_565.nsbmd', - 'prop_model_566.nsbmd', - 'prop_model_567.nsbmd', - 'prop_model_568.nsbmd', - 'prop_model_569.nsbmd', - 'prop_model_570.nsbmd', - 'prop_model_571.nsbmd', - 'prop_model_572.nsbmd', - 'prop_model_573.nsbmd', - 'prop_model_574.nsbmd', - 'prop_model_575.nsbmd', - 'prop_model_576.nsbmd', - 'prop_model_577.nsbmd', - 'prop_model_578.nsbmd', + 'villa_furniture_table.nsbmd', + 'villa_furniture_big_sofa.nsbmd', + 'villa_furniture_small_sofa.nsbmd', + 'villa_furniture_bed.nsbmd', + 'villa_furniture_night_table.nsbmd', + 'villa_furniture_tv.nsbmd', + 'villa_furniture_audio_system.nsbmd', + 'villa_furniture_bookshelf.nsbmd', + 'villa_furniture_rack.nsbmd', + 'villa_furniture_houseplant.nsbmd', + 'villa_furniture_pc_desk.nsbmd', + 'villa_furniture_music_box.nsbmd', + 'villa_furniture_pokemon_bust.nsbmd', + 'villa_furniture_pokemon_bust_silver.nsbmd', + 'villa_furniture_piano.nsbmd', + 'villa_furniture_guest_set.nsbmd', + 'villa_furniture_wall_clock.nsbmd', + 'villa_furniture_masterpiece.nsbmd', + 'villa_furniture_tea_set.nsbmd', + 'villa_furniture_chandelier.nsbmd', 'prop_model_579.nsbmd', 'prop_model_580.nsbmd', 'prop_model_581.nsbmd', diff --git a/res/field/props/models/prop_model_565.nsbmd b/res/field/props/models/villa_furniture_audio_system.nsbmd similarity index 100% rename from res/field/props/models/prop_model_565.nsbmd rename to res/field/props/models/villa_furniture_audio_system.nsbmd diff --git a/res/field/props/models/prop_model_562.nsbmd b/res/field/props/models/villa_furniture_bed.nsbmd similarity index 100% rename from res/field/props/models/prop_model_562.nsbmd rename to res/field/props/models/villa_furniture_bed.nsbmd diff --git a/res/field/props/models/prop_model_560.nsbmd b/res/field/props/models/villa_furniture_big_sofa.nsbmd similarity index 100% rename from res/field/props/models/prop_model_560.nsbmd rename to res/field/props/models/villa_furniture_big_sofa.nsbmd diff --git a/res/field/props/models/prop_model_566.nsbmd b/res/field/props/models/villa_furniture_bookshelf.nsbmd similarity index 100% rename from res/field/props/models/prop_model_566.nsbmd rename to res/field/props/models/villa_furniture_bookshelf.nsbmd diff --git a/res/field/props/models/prop_model_578.nsbmd b/res/field/props/models/villa_furniture_chandelier.nsbmd similarity index 100% rename from res/field/props/models/prop_model_578.nsbmd rename to res/field/props/models/villa_furniture_chandelier.nsbmd diff --git a/res/field/props/models/prop_model_574.nsbmd b/res/field/props/models/villa_furniture_guest_set.nsbmd similarity index 100% rename from res/field/props/models/prop_model_574.nsbmd rename to res/field/props/models/villa_furniture_guest_set.nsbmd diff --git a/res/field/props/models/prop_model_568.nsbmd b/res/field/props/models/villa_furniture_houseplant.nsbmd similarity index 100% rename from res/field/props/models/prop_model_568.nsbmd rename to res/field/props/models/villa_furniture_houseplant.nsbmd diff --git a/res/field/props/models/prop_model_576.nsbmd b/res/field/props/models/villa_furniture_masterpiece.nsbmd similarity index 100% rename from res/field/props/models/prop_model_576.nsbmd rename to res/field/props/models/villa_furniture_masterpiece.nsbmd diff --git a/res/field/props/models/prop_model_570.nsbmd b/res/field/props/models/villa_furniture_music_box.nsbmd similarity index 100% rename from res/field/props/models/prop_model_570.nsbmd rename to res/field/props/models/villa_furniture_music_box.nsbmd diff --git a/res/field/props/models/prop_model_563.nsbmd b/res/field/props/models/villa_furniture_night_table.nsbmd similarity index 100% rename from res/field/props/models/prop_model_563.nsbmd rename to res/field/props/models/villa_furniture_night_table.nsbmd diff --git a/res/field/props/models/prop_model_569.nsbmd b/res/field/props/models/villa_furniture_pc_desk.nsbmd similarity index 100% rename from res/field/props/models/prop_model_569.nsbmd rename to res/field/props/models/villa_furniture_pc_desk.nsbmd diff --git a/res/field/props/models/prop_model_573.nsbmd b/res/field/props/models/villa_furniture_piano.nsbmd similarity index 100% rename from res/field/props/models/prop_model_573.nsbmd rename to res/field/props/models/villa_furniture_piano.nsbmd diff --git a/res/field/props/models/prop_model_571.nsbmd b/res/field/props/models/villa_furniture_pokemon_bust.nsbmd similarity index 100% rename from res/field/props/models/prop_model_571.nsbmd rename to res/field/props/models/villa_furniture_pokemon_bust.nsbmd diff --git a/res/field/props/models/prop_model_572.nsbmd b/res/field/props/models/villa_furniture_pokemon_bust_silver.nsbmd similarity index 100% rename from res/field/props/models/prop_model_572.nsbmd rename to res/field/props/models/villa_furniture_pokemon_bust_silver.nsbmd diff --git a/res/field/props/models/prop_model_567.nsbmd b/res/field/props/models/villa_furniture_rack.nsbmd similarity index 100% rename from res/field/props/models/prop_model_567.nsbmd rename to res/field/props/models/villa_furniture_rack.nsbmd diff --git a/res/field/props/models/prop_model_561.nsbmd b/res/field/props/models/villa_furniture_small_sofa.nsbmd similarity index 100% rename from res/field/props/models/prop_model_561.nsbmd rename to res/field/props/models/villa_furniture_small_sofa.nsbmd diff --git a/res/field/props/models/prop_model_559.nsbmd b/res/field/props/models/villa_furniture_table.nsbmd similarity index 100% rename from res/field/props/models/prop_model_559.nsbmd rename to res/field/props/models/villa_furniture_table.nsbmd diff --git a/res/field/props/models/prop_model_577.nsbmd b/res/field/props/models/villa_furniture_tea_set.nsbmd similarity index 100% rename from res/field/props/models/prop_model_577.nsbmd rename to res/field/props/models/villa_furniture_tea_set.nsbmd diff --git a/res/field/props/models/prop_model_564.nsbmd b/res/field/props/models/villa_furniture_tv.nsbmd similarity index 100% rename from res/field/props/models/prop_model_564.nsbmd rename to res/field/props/models/villa_furniture_tv.nsbmd diff --git a/res/field/props/models/prop_model_575.nsbmd b/res/field/props/models/villa_furniture_wall_clock.nsbmd similarity index 100% rename from res/field/props/models/prop_model_575.nsbmd rename to res/field/props/models/villa_furniture_wall_clock.nsbmd diff --git a/res/field/scripts/scripts_villa.s b/res/field/scripts/scripts_villa.s index 6278017355..775ab1d220 100644 --- a/res/field/scripts/scripts_villa.s +++ b/res/field/scripts/scripts_villa.s @@ -22,26 +22,26 @@ ScriptEntry _0B5C ScriptEntry _0BBC ScriptEntry _0C24 - ScriptEntry _0C88 - ScriptEntry _0C99 - ScriptEntry _0CAA - ScriptEntry _0CBB - ScriptEntry _0CCC - ScriptEntry _0CDD - ScriptEntry _0CEE - ScriptEntry _0D03 - ScriptEntry _0D14 - ScriptEntry _0D30 - ScriptEntry _0D41 - ScriptEntry _0D55 - ScriptEntry _0DD1 - ScriptEntry _0DE2 - ScriptEntry _0DF3 - ScriptEntry _0E08 - ScriptEntry _0E19 - ScriptEntry _0E2A - ScriptEntry _0E3B - ScriptEntry _0E4C + ScriptEntry Villa_Furniture_Table + ScriptEntry Villa_Furniture_BigSofa + ScriptEntry Villa_Furniture_SmallSofa + ScriptEntry Villa_Furniture_Bed + ScriptEntry Villa_Furniture_NightTable + ScriptEntry Villa_Furniture_TVDummy + ScriptEntry Villa_Furniture_AudioSystem + ScriptEntry Villa_Furniture_Bookshelf + ScriptEntry Villa_Furniture_Rack + ScriptEntry Villa_Furniture_Houseplant + ScriptEntry Villa_Furniture_PCDesk + ScriptEntry Villa_Furniture_MusicBox + ScriptEntry Villa_Furniture_PokemonBust + ScriptEntry Villa_Furniture_PokemonBustSilver + ScriptEntry Villa_Furniture_Piano + ScriptEntry Villa_Furniture_GuestSet + ScriptEntry Villa_Furniture_WallClock + ScriptEntry Villa_Furniture_Masterpiece + ScriptEntry Villa_Furniture_TeaSet + ScriptEntry Villa_Furniture_Chandelier ScriptEntry _0E65 ScriptEntry _0EB4 ScriptEntry _15F3 @@ -184,23 +184,23 @@ _029C: End _02F3: - Message 15 + Message pl_msg_00000602_00015 Return _02F8: - Message 16 + Message pl_msg_00000602_00016 Return _02FD: - Message 17 + Message pl_msg_00000602_00017 Return _0302: - Message 18 + Message pl_msg_00000602_00018 Return _0307: - Message 19 + Message pl_msg_00000602_00019 Return _030C: @@ -247,43 +247,43 @@ _03E0: Return _0400: - Message 20 + Message pl_msg_00000602_00020 Return _0405: - Message 25 + Message pl_msg_00000602_00025 Return _040A: - Message 21 + Message pl_msg_00000602_00021 Return _040F: - Message 26 + Message pl_msg_00000602_00026 Return _0414: - Message 22 + Message pl_msg_00000602_00022 Return _0419: - Message 27 + Message pl_msg_00000602_00027 Return _041E: - Message 23 + Message pl_msg_00000602_00023 Return _0423: - Message 28 + Message pl_msg_00000602_00028 Return _0428: - Message 24 + Message pl_msg_00000602_00024 Return _042D: - Message 29 + Message pl_msg_00000602_00029 Return _0432: @@ -299,23 +299,23 @@ _0432: End _0483: - Message 30 + Message pl_msg_00000602_00030 Return _0488: - Message 31 + Message pl_msg_00000602_00031 Return _048D: - Message 32 + Message pl_msg_00000602_00032 Return _0492: - Message 33 + Message pl_msg_00000602_00033 Return _0497: - Message 34 + Message pl_msg_00000602_00034 Return _049C: @@ -333,23 +333,23 @@ _049C: End _04F3: - Message 35 + Message pl_msg_00000602_00035 Return _04F8: - Message 36 + Message pl_msg_00000602_00036 Return _04FD: - Message 37 + Message pl_msg_00000602_00037 Return _0502: - Message 38 + Message pl_msg_00000602_00038 Return _0507: - Message 39 + Message pl_msg_00000602_00039 Return _050C: @@ -365,23 +365,23 @@ _050C: End _055D: - Message 40 + Message pl_msg_00000602_00040 Return _0562: - Message 41 + Message pl_msg_00000602_00041 Return _0567: - Message 42 + Message pl_msg_00000602_00042 Return _056C: - Message 43 + Message pl_msg_00000602_00043 Return _0571: - Message 44 + Message pl_msg_00000602_00044 Return _0576: @@ -397,23 +397,23 @@ _0576: End _05C7: - Message 45 + Message pl_msg_00000602_00045 Return _05CC: - Message 46 + Message pl_msg_00000602_00046 Return _05D1: - Message 47 + Message pl_msg_00000602_00047 Return _05D6: - Message 48 + Message pl_msg_00000602_00048 Return _05DB: - Message 49 + Message pl_msg_00000602_00049 Return _05E0: @@ -429,23 +429,23 @@ _05E0: End _0631: - Message 50 + Message pl_msg_00000602_00050 Return _0636: - Message 51 + Message pl_msg_00000602_00051 Return _063B: - Message 52 + Message pl_msg_00000602_00052 Return _0640: - Message 53 + Message pl_msg_00000602_00053 Return _0645: - Message 54 + Message pl_msg_00000602_00054 Return _064A: @@ -463,23 +463,23 @@ _064A: End _06AB: - Message 55 + Message pl_msg_00000602_00055 Return _06B0: - Message 56 + Message pl_msg_00000602_00056 Return _06B5: - Message 57 + Message pl_msg_00000602_00057 Return _06BA: - Message 58 + Message pl_msg_00000602_00058 Return _06BF: - Message 59 + Message pl_msg_00000602_00059 Return _06C4: @@ -496,24 +496,24 @@ _06C4: _0715: BufferRivalName 0 - Message 60 + Message pl_msg_00000602_00060 Return _071D: - Message 61 + Message pl_msg_00000602_00061 Return _0722: BufferRivalName 0 - Message 62 + Message pl_msg_00000602_00062 Return _072A: - Message 63 + Message pl_msg_00000602_00063 Return _072F: - Message 64 + Message pl_msg_00000602_00064 Return _0734: @@ -529,23 +529,23 @@ _0734: End _0785: - Message 65 + Message pl_msg_00000602_00065 Return _078A: - Message 66 + Message pl_msg_00000602_00066 Return _078F: - Message 67 + Message pl_msg_00000602_00067 Return _0794: - Message 68 + Message pl_msg_00000602_00068 Return _0799: - Message 69 + Message pl_msg_00000602_00069 Return _079E: @@ -562,23 +562,23 @@ _079E: End _07FC: - Message 70 + Message pl_msg_00000602_00070 Return _0801: - Message 71 + Message pl_msg_00000602_00071 Return _0806: - Message 72 + Message pl_msg_00000602_00072 Return _080B: - Message 73 + Message pl_msg_00000602_00073 Return _0810: - Message 74 + Message pl_msg_00000602_00074 Return _0815: @@ -595,23 +595,23 @@ _0815: End _0873: - Message 75 + Message pl_msg_00000602_00075 Return _0878: - Message 76 + Message pl_msg_00000602_00076 Return _087D: - Message 77 + Message pl_msg_00000602_00077 Return _0882: - Message 78 + Message pl_msg_00000602_00078 Return _0887: - Message 79 + Message pl_msg_00000602_00079 Return _088C: @@ -627,33 +627,33 @@ _088C: _08DB: FacePlayer - Message 86 + Message pl_msg_00000602_00086 Return _08E2: FacePlayer - Message 88 + Message pl_msg_00000602_00088 Return _08E9: ApplyMovement 11, _0930 ApplyMovement 13, _093C WaitMovement - Message 89 + Message pl_msg_00000602_00089 Return _0900: ApplyMovement 11, _0930 ApplyMovement 13, _093C WaitMovement - Message 90 + Message pl_msg_00000602_00090 Return _0917: ApplyMovement 11, _0930 ApplyMovement 13, _093C WaitMovement - Message 91 + Message pl_msg_00000602_00091 Return .balign 4, 0 @@ -680,23 +680,23 @@ _0944: End _0995: - Message 80 + Message pl_msg_00000602_00080 Return _099A: - Message 81 + Message pl_msg_00000602_00081 Return _099F: - Message 82 + Message pl_msg_00000602_00082 Return _09A4: - Message 83 + Message pl_msg_00000602_00083 Return _09A9: - Message 84 + Message pl_msg_00000602_00084 Return _09AE: @@ -712,33 +712,33 @@ _09AE: _09FD: FacePlayer - Message 85 + Message pl_msg_00000602_00085 Return _0A04: FacePlayer - Message 87 + Message pl_msg_00000602_00087 Return _0A0B: ApplyMovement 11, _0930 ApplyMovement 13, _093C WaitMovement - Message 89 + Message pl_msg_00000602_00089 Return _0A22: ApplyMovement 11, _0930 ApplyMovement 13, _093C WaitMovement - Message 90 + Message pl_msg_00000602_00090 Return _0A39: ApplyMovement 11, _0930 ApplyMovement 13, _093C WaitMovement - Message 91 + Message pl_msg_00000602_00091 Return _0A50: @@ -757,24 +757,24 @@ _0A50: End _0AB4: - Message 92 + Message pl_msg_00000602_00092 Return _0AB9: - Message 93 + Message pl_msg_00000602_00093 Return _0ABE: - Message 94 + Message pl_msg_00000602_00094 Return _0AC3: - Message 95 + Message pl_msg_00000602_00095 Return _0AC8: GoToIfUnset FLAG_VILLA_FURNITURE_TEA_SET, _0AB4 - Message 96 + Message pl_msg_00000602_00096 Return .balign 4, 0 @@ -915,94 +915,94 @@ _0C78: WalkOnSpotNormalWest EndMovement -_0C88: +Villa_Furniture_Table: PlaySE SEQ_SE_CONFIRM LockAll - Message 99 - GoTo _0E5D + Message Villa_Text_Table + GoTo Villa_Furniture_End End -_0C99: +Villa_Furniture_BigSofa: PlaySE SEQ_SE_CONFIRM LockAll - Message 100 - GoTo _0E5D + Message Villa_Text_BigSofa + GoTo Villa_Furniture_End End -_0CAA: +Villa_Furniture_SmallSofa: PlaySE SEQ_SE_CONFIRM LockAll - Message 101 - GoTo _0E5D + Message Villa_Text_SmallSofa + GoTo Villa_Furniture_End End -_0CBB: +Villa_Furniture_Bed: PlaySE SEQ_SE_CONFIRM LockAll - Message 102 - GoTo _0E5D + Message Villa_Text_Bed + GoTo Villa_Furniture_End End -_0CCC: +Villa_Furniture_NightTable: PlaySE SEQ_SE_CONFIRM LockAll - Message 103 - GoTo _0E5D + Message Villa_Text_NightTable + GoTo Villa_Furniture_End End -_0CDD: +Villa_Furniture_TVDummy: PlaySE SEQ_SE_CONFIRM LockAll - Message 104 - GoTo _0E5D + Message Villa_Text_TV + GoTo Villa_Furniture_End End -_0CEE: +Villa_Furniture_AudioSystem: PlaySE SEQ_SE_CONFIRM LockAll PlayMusic SEQ_PL_AUDIO - Message 105 - GoTo _0E5D + Message Villa_Text_AudioSystem + GoTo Villa_Furniture_End End -_0D03: +Villa_Furniture_Bookshelf: PlaySE SEQ_SE_CONFIRM LockAll - Message 106 - GoTo _0E5D + Message Villa_Text_Bookshelf + GoTo Villa_Furniture_End End -_0D14: +Villa_Furniture_Rack: PlaySE SEQ_SE_CONFIRM LockAll GoToIfSet FLAG_VILLA_FURNITURE_MUSIC_BOX, _0D63 - Message 107 - GoTo _0E5D + Message Villa_Text_Rack + GoTo Villa_Furniture_End End -_0D30: +Villa_Furniture_Houseplant: PlaySE SEQ_SE_CONFIRM LockAll - Message 108 - GoTo _0E5D + Message Villa_Text_Houseplant + GoTo Villa_Furniture_End End -_0D41: +Villa_Furniture_PCDesk: PlaySE SEQ_SE_CONFIRM LockAll BufferPlayerName 0 - Message 109 - GoTo _0E5D + Message Villa_Text_PCDesk + GoTo Villa_Furniture_End End -_0D55: +Villa_Furniture_MusicBox: PlaySE SEQ_SE_CONFIRM LockAll GoTo _0D63 End _0D63: - Message 110 + Message Villa_Text_MusicBox GoTo _0D6E End @@ -1032,67 +1032,67 @@ _0DC2: End Villa_Unused: - Message 118 + Message Villa_Text_Chandelier Return -_0DD1: +Villa_Furniture_PokemonBust: PlaySE SEQ_SE_CONFIRM LockAll - Message 111 - GoTo _0E5D + Message Villa_Text_PokemonBust + GoTo Villa_Furniture_End End -_0DE2: +Villa_Furniture_PokemonBustSilver: PlaySE SEQ_SE_CONFIRM LockAll - Message 112 - GoTo _0E5D + Message Villa_Text_PokemonBustSilver + GoTo Villa_Furniture_End End -_0DF3: +Villa_Furniture_Piano: PlaySE SEQ_SE_CONFIRM LockAll PlayMusic SEQ_PL_PIANO - Message 113 - GoTo _0E5D + Message Villa_Text_Piano + GoTo Villa_Furniture_End End -_0E08: +Villa_Furniture_GuestSet: PlaySE SEQ_SE_CONFIRM LockAll - Message 114 - GoTo _0E5D + Message Villa_Text_GuestSet + GoTo Villa_Furniture_End End -_0E19: +Villa_Furniture_WallClock: PlaySE SEQ_SE_CONFIRM LockAll - Message 115 - GoTo _0E5D + Message Villa_Text_WallClock + GoTo Villa_Furniture_End End -_0E2A: +Villa_Furniture_Masterpiece: PlaySE SEQ_SE_CONFIRM LockAll - Message 116 - GoTo _0E5D + Message Villa_Text_Masterpiece + GoTo Villa_Furniture_End End -_0E3B: +Villa_Furniture_TeaSet: PlaySE SEQ_SE_CONFIRM LockAll - Message 117 - GoTo _0E5D + Message Villa_Text_TeaSet + GoTo Villa_Furniture_End End -_0E4C: +Villa_Furniture_Chandelier: PlaySE SEQ_SE_CONFIRM LockAll - Message 118 - GoTo _0E5D + Message Villa_Text_Chandelier + GoTo Villa_Furniture_End End -_0E5D: +Villa_Furniture_End: WaitButton CloseMessage ReleaseAll @@ -1329,12 +1329,12 @@ _12BF: End _12FC: - Message 10 + Message pl_msg_00000602_00010 GoTo _1312 End _1307: - Message 11 + Message pl_msg_00000602_00011 GoTo _1312 End @@ -1359,7 +1359,7 @@ _1332: SetVar VAR_RESORT_VILLA_VISITOR, 2 BufferRivalName 0 BufferPlayerName 1 - Message 12 + Message pl_msg_00000602_00012 CloseMessage Return @@ -1384,7 +1384,7 @@ _1390: SetVar VAR_RESORT_VILLA_VISITOR, 5 BufferRivalName 0 BufferPlayerName 1 - Message 13 + Message pl_msg_00000602_00013 CloseMessage Return @@ -1410,7 +1410,7 @@ _13EE: SetFlag FLAG_VILLA_VISITOR_OUTSIDE BufferRivalName 0 BufferPlayerName 1 - Message 14 + Message pl_msg_00000602_00014 CloseMessage Return diff --git a/res/text/villa.json b/res/text/villa.json index 37f64399aa..538683a53f 100644 --- a/res/text/villa.json +++ b/res/text/villa.json @@ -1025,134 +1025,134 @@ "garbage": 25 }, { - "id": "pl_msg_00000602_00099", + "id": "Villa_Text_Table", "en_US": [ "The table’s subtle curves accentuate\n", "its distinctive presence." ] }, { - "id": "pl_msg_00000602_00100", + "id": "Villa_Text_BigSofa", "en_US": [ "A big sofa with a wonderful sense\n", "of presence." ] }, { - "id": "pl_msg_00000602_00101", + "id": "Villa_Text_SmallSofa", "en_US": [ "A smaller sofa with a wonderful sense\n", "of presence." ] }, { - "id": "pl_msg_00000602_00102", + "id": "Villa_Text_Bed", "en_US": [ "A canopied bed for deep, relaxing\n", "sleep." ] }, { - "id": "pl_msg_00000602_00103", + "id": "Villa_Text_NightTable", "en_US": "A small night table for the bedside." }, { - "id": "pl_msg_00000602_00104", + "id": "Villa_Text_TV", "en_US": "A TV featuring the latest technology." }, { - "id": "pl_msg_00000602_00105", + "id": "Villa_Text_AudioSystem", "en_US": [ "An audio system that maximally draws\n", "out the charms of music." ] }, { - "id": "pl_msg_00000602_00106", + "id": "Villa_Text_Bookshelf", "en_US": [ "The shelves are lined with books left\n", "by Prof. Rowan." ] }, { - "id": "pl_msg_00000602_00107", + "id": "Villa_Text_Rack", "en_US": [ "An attractive rack that looks good with\n", "or without things on it." ] }, { - "id": "pl_msg_00000602_00108", + "id": "Villa_Text_Houseplant", "en_US": [ "All houseplants give off the fragrance\n", "of life." ] }, { - "id": "pl_msg_00000602_00109", + "id": "Villa_Text_PCDesk", "en_US": [ "A thin-bodied PC made for the design\n", "conscious." ] }, { - "id": "pl_msg_00000602_00110", + "id": "Villa_Text_MusicBox", "en_US": [ "A handmade music box with a soothing\n", "melody." ] }, { - "id": "pl_msg_00000602_00111", + "id": "Villa_Text_PokemonBust", "en_US": [ "An almost lifelike Pokémon statue.\n", "It would be nice to have a pair." ] }, { - "id": "pl_msg_00000602_00112", + "id": "Villa_Text_PokemonBustSilver", "en_US": [ "An almost lifelike Pokémon statue.\n", "It would be nice to have a pair." ] }, { - "id": "pl_msg_00000602_00113", + "id": "Villa_Text_Piano", "en_US": [ "Even playing a simple scale will tell you\n", "this is a special piano." ] }, { - "id": "pl_msg_00000602_00114", + "id": "Villa_Text_GuestSet", "en_US": [ "A guest set that exemplifies the\n", "meaning of comfort." ] }, { - "id": "pl_msg_00000602_00115", + "id": "Villa_Text_WallClock", "en_US": [ "A clock that teaches the beauty of\n", "precisely marking time." ] }, { - "id": "pl_msg_00000602_00116", + "id": "Villa_Text_Masterpiece", "en_US": [ "A breathtaking masterpiece that no\n", "words can ever do justice." ] }, { - "id": "pl_msg_00000602_00117", + "id": "Villa_Text_TeaSet", "en_US": [ "An exquisitely designed tea set for\n", "luxuriantly elegant times." ] }, { - "id": "pl_msg_00000602_00118", + "id": "Villa_Text_Chandelier", "en_US": [ "Light makes the glass gleam, and the\n", "glass dazzlingly reflects the light." diff --git a/src/dynamic_map_features.c b/src/dynamic_map_features.c index 3da79f66e6..d335ff8ca7 100644 --- a/src/dynamic_map_features.c +++ b/src/dynamic_map_features.c @@ -7,7 +7,7 @@ #include "generated/map_headers.h" #include "field/field_system.h" -#include "overlay005/ov5_021F8370.h" +#include "overlay005/villa_furniture.h" #include "overlay006/great_marsh_tram.h" #include "overlay008/ov8_02249960.h" #include "overlay009/ov9_02249960.h" diff --git a/src/map_object_move.c b/src/map_object_move.c index ff2b3a365f..e679037c1e 100644 --- a/src/map_object_move.c +++ b/src/map_object_move.c @@ -987,8 +987,8 @@ void VecFx32_StepDirection(int dir, VecFx32 *vec, fx32 val) void VecFx32_SetPosFromMapCoords(int x, int z, VecFx32 *outVec) { - outVec->x = MAP_OBJECT_COORD_TO_FX32(x); - outVec->z = MAP_OBJECT_COORD_TO_FX32(z); + outVec->x = MAP_OBJECT_COORD_CENTER_TO_FX32(x); + outVec->z = MAP_OBJECT_COORD_CENTER_TO_FX32(z); } void sub_02064464(MapObject *mapObj) diff --git a/src/meson.build b/src/meson.build index 6206d9e151..7226e622e6 100644 --- a/src/meson.build +++ b/src/meson.build @@ -443,7 +443,7 @@ pokeplatinum_c = files( 'overlay005/ov5_021F61BC.c', 'overlay005/ov5_021F6454.c', 'overlay005/scrcmd_move_tutor.c', - 'overlay005/ov5_021F8370.c', + 'overlay005/villa_furniture.c', 'overlay005/dist_world_surf_mount_renderer.c', 'overlay005/ov5_021FAF40.c', 'overlay005/field_effect_renderer.c', diff --git a/src/overlay005/field_control.c b/src/overlay005/field_control.c index 7f324637b5..08f479e6d0 100644 --- a/src/overlay005/field_control.c +++ b/src/overlay005/field_control.c @@ -20,7 +20,7 @@ #include "overlay005/ov5_021E1154.h" #include "overlay005/ov5_021EA714.h" #include "overlay005/ov5_021EF4BC.h" -#include "overlay005/ov5_021F8370.h" +#include "overlay005/villa_furniture.h" #include "overlay005/vs_seeker.h" #include "overlay006/repel_step_update.h" #include "overlay006/wild_encounters.h" @@ -310,7 +310,7 @@ BOOL FieldInput_Process(const FieldInput *input, FieldSystem *fieldSystem) Field_Step(fieldSystem, &playerX, &playerZ); - if (ov5_021F8410(fieldSystem, playerX, playerZ, playerDir) == TRUE) { + if (FieldSystem_TrySetVillaFurnitureScript(fieldSystem, playerX, playerZ, playerDir) == TRUE) { return TRUE; } } diff --git a/src/overlay005/ov5_021F8370.c b/src/overlay005/ov5_021F8370.c deleted file mode 100644 index 54d6425819..0000000000 --- a/src/overlay005/ov5_021F8370.c +++ /dev/null @@ -1,487 +0,0 @@ -#include "overlay005/ov5_021F8370.h" - -#include -#include - -#include "constants/field/dynamic_map_features.h" - -#include "struct_defs/struct_02071C34.h" - -#include "field/field_system.h" -#include "field/field_system_sub2_t.h" -#include "overlay005/map_prop.h" - -#include "field_system.h" -#include "heap.h" -#include "persisted_map_features.h" -#include "savedata_misc.h" -#include "script_manager.h" -#include "system_flags.h" -#include "vars_flags.h" - -typedef struct UnkStruct_ov5_021F8480_t UnkStruct_ov5_021F8480; - -typedef struct { - s16 unk_00; - s16 unk_02; - s16 unk_04; - s16 unk_06; -} UnkStruct_ov5_021F83D4; - -typedef struct { - u16 furniture; - u16 unk_02; - VecFx32 unk_04; - UnkStruct_ov5_021F83D4 unk_10; -} UnkStruct_ov5_0220192C; - -typedef struct { - u32 unk_00; -} UnkStruct_ov5_022018DC; - -typedef struct { - u16 unk_00; - u16 unk_02; - u32 unk_04; - MapProp *unk_08; -} UnkStruct_ov5_021F8480_sub1; - -struct UnkStruct_ov5_021F8480_t { - FieldSystem *fieldSystem; - UnkStruct_02071C34 *unk_04; - UnkStruct_ov5_021F8480_sub1 unk_08[23]; -}; - -static void ov5_021F8480(UnkStruct_ov5_021F8480 *param0, const enum VillaFurniture furniture); -static BOOL FieldSystem_OwnsVillaFurniture(FieldSystem *fieldSystem, enum VillaFurniture furniture); -static BOOL ov5_021F851C(int param0, int param1, const UnkStruct_ov5_0220192C *param2, FieldSystem *fieldSystem); - -static const UnkStruct_ov5_0220192C Unk_ov5_0220192C[23]; -static const u32 Unk_ov5_0220188C[20]; -static const UnkStruct_ov5_022018DC Unk_ov5_022018DC[20]; - -void Villa_DynamicMapFeaturesInit(FieldSystem *fieldSystem) -{ - int v0; - PersistedMapFeatures *v1 = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); - UnkStruct_02071C34 *v2 = PersistedMapFeatures_GetBuffer(v1, DYNAMIC_MAP_FEATURES_VILLA); - UnkStruct_ov5_021F8480 *v3 = Heap_Alloc(HEAP_ID_FIELD1, sizeof(UnkStruct_ov5_021F8480)); - - memset(v3, 0, sizeof(UnkStruct_ov5_021F8480)); - - v3->fieldSystem = fieldSystem; - v3->unk_04 = v2; - - fieldSystem->unk_04->dynamicMapFeaturesData = v3; - - { - for (int i = 0; i < VILLA_FURNITURE_MAX; i++) { - if (FieldSystem_OwnsVillaFurniture(fieldSystem, i) == TRUE) { - ov5_021F8480(v3, i); - } - } - } -} - -void Villa_DynamicMapFeaturesFree(FieldSystem *fieldSystem) -{ - UnkStruct_ov5_021F8480 *v0 = fieldSystem->unk_04->dynamicMapFeaturesData; - - Heap_Free(v0); - fieldSystem->unk_04->dynamicMapFeaturesData = NULL; -} - -BOOL Villa_DynamicMapFeaturesCheckCollision(FieldSystem *fieldSystem, const int tileX, const int tileZ, const fx32 height, BOOL *isColliding) -{ - int v0; - const UnkStruct_ov5_021F83D4 *v1; - const UnkStruct_ov5_0220192C *v2 = Unk_ov5_0220192C; - - for (v0 = 0; v0 < 23; v0++, v2++) { - if (ov5_021F851C(tileX, tileZ, v2, fieldSystem) == 1) { - *isColliding = 1; - return 1; - } - } - - *isColliding = 0; - return 0; -} - -BOOL ov5_021F8410(FieldSystem *fieldSystem, const int param1, const int param2, const int param3) -{ - PersistedMapFeatures *v0 = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); - - if (PersistedMapFeatures_GetID(v0) == DYNAMIC_MAP_FEATURES_VILLA) { - int v1; - const UnkStruct_ov5_021F83D4 *v2; - const UnkStruct_ov5_0220192C *v3 = Unk_ov5_0220192C; - - for (v1 = 0; v1 < 23; v1++, v3++) { - if (ov5_021F851C(param1, param2, v3, fieldSystem) == 1) { - const UnkStruct_ov5_022018DC *v4 = &Unk_ov5_022018DC[v3->furniture]; - - if (v4->unk_00 == 10100) { - if (param3 != 0) { - continue; - } - } - - ScriptManager_Set(fieldSystem, v4->unk_00, NULL); - return 1; - } - } - } - - return 0; -} - -static void ov5_021F8480(UnkStruct_ov5_021F8480 *param0, const enum VillaFurniture furniture) -{ - int v0, v1; - UnkStruct_ov5_021F8480_sub1 *v2; - VecFx32 v3 = { 0, 0, 0 }; - int v4 = Unk_ov5_0220188C[furniture]; - const UnkStruct_ov5_0220192C *v5 = Unk_ov5_0220192C; - FieldSystem *fieldSystem = param0->fieldSystem; - - for (v0 = 0; v0 < 23; v0++, v5++) { - if (v5->furniture == furniture) { - v1 = 0; - v2 = param0->unk_08; - - do { - if (v2->unk_00 == 0) { - v2->unk_00 = 1; - v2->unk_04 = v4; - v2->unk_02 = MapPropManager_LoadOne(fieldSystem->mapPropManager, fieldSystem->areaDataManager, v4, &v5->unk_04, &v3, fieldSystem->mapPropAnimMan); - v2->unk_08 = MapPropManager_FindLoadedPropByModelID(fieldSystem->mapPropManager, v4); - break; - } - - v1++; - v2++; - } while (v1 < 23); - } - } -} - -static BOOL FieldSystem_OwnsVillaFurniture(FieldSystem *fieldSystem, enum VillaFurniture furniture) -{ - return SystemFlag_HandleOwnsVillaFurniture(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, furniture); -} - -static BOOL ov5_021F851C(int param0, int param1, const UnkStruct_ov5_0220192C *param2, FieldSystem *fieldSystem) -{ - const UnkStruct_ov5_021F83D4 *v0 = ¶m2->unk_10; - - if ((param2->unk_02 == 1) && (FieldSystem_OwnsVillaFurniture(fieldSystem, param2->furniture) == TRUE)) { - if ((param1 >= v0->unk_02) && (param1 <= v0->unk_06) && (param0 >= v0->unk_00) && (param0 <= v0->unk_04)) { - return 1; - } - } - - return 0; -} - -static const UnkStruct_ov5_0220192C Unk_ov5_0220192C[23] = { - { - 0x0, - 0x1, - { (((0xc << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), ((0x7 << 4) * FX32_ONE) }, - { - 0xB, - 0x5, - 0xD, - 0x8, - }, - }, - { - 0x1, - 0x1, - { ((0xf << 4) * FX32_ONE), ((0 << 4) * FX32_ONE), ((0x7 << 4) * FX32_ONE) }, - { - 0xE, - 0x5, - 0xf, - 0x8, - }, - }, - { - 0x2, - 0x1, - { (((0xd << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0xa << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0xB, - 0x9, - 0xD, - 0xA, - }, - }, - { - 0x3, - 0x1, - { (((0x12 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), ((0x8 << 4) * FX32_ONE) }, - { - 0x12, - 0x6, - 0x14, - 0x9, - }, - }, - { - 0x4, - 0x1, - { (((0x14 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x7 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x11, - 0x6, - 0x11, - 0x7, - }, - }, - { - 0x5, - 0x1, - { ((0xc << 4) * FX32_ONE), ((0 << 4) * FX32_ONE), (((0x3 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0xB, - 0x3, - 0xC, - 0x3, - }, - }, - { - 0x6, - 0x1, - { (((0xe << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x3 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0xD, - 0x3, - 0xf, - 0x3, - }, - }, - { - 0x7, - 0x1, - { ((0x11 << 4) * FX32_ONE), ((0 << 4) * FX32_ONE), (((0x3 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x10, - 0x3, - 0x11, - 0x3, - }, - }, - { - 0x8, - 0x1, - { ((0x13 << 4) * FX32_ONE), ((0 << 4) * FX32_ONE), (((0x3 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x12, - 0x3, - 0x13, - 0x3, - }, - }, - { - 0x9, - 0x1, - { (((0x1 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x3 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x1, - 0x3, - 0x1, - 0x3, - }, - }, - { - 0x9, - 0x1, - { (((0x14 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x3 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x14, - 0x3, - 0x14, - 0x3, - }, - }, - { - 0x9, - 0x1, - { (((0x1 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0xb << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x1, - 0xB, - 0x1, - 0xB, - }, - }, - { - 0x9, - 0x1, - { (((0x14 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0xb << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x14, - 0xB, - 0x14, - 0xB, - }, - }, - { - 0xA, - 0x1, - { ((0x2 << 4) * FX32_ONE), ((0 << 4) * FX32_ONE), (((0x8 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x1, - 0x7, - 0x2, - 0x9, - }, - }, - { - 0xB, - 0x0, - { (((0x12 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x3 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x0, - 0x0, - 0x0, - 0x0, - }, - }, - { - 0xC, - 0x1, - { (((0x2 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x3 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x2, - 0x3, - 0x2, - 0x3, - }, - }, - { - 0xD, - 0x1, - { (((0x6 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x3 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x6, - 0x3, - 0x6, - 0x3, - }, - }, - { - 0xE, - 0x1, - { (((0x2 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x5 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x1, - 0x4, - 0x2, - 0x6, - }, - }, - { - 0xF, - 0x1, - { ((0x6 << 4) * FX32_ONE), ((0 << 4) * FX32_ONE), ((0xa << 4) * FX32_ONE) }, - { - 0x4, - 0x9, - 0x7, - 0xA, - }, - }, - { - 0x10, - 0x0, - { (((0xb << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x1 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x0, - 0x0, - 0x0, - 0x0, - }, - }, - { - 0x11, - 0x0, - { (((0x8 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x1 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x0, - 0x0, - 0x0, - 0x0, - }, - }, - { - 0x12, - 0x0, - { (((0x6 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0xa << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x0, - 0x0, - 0x0, - 0x0, - }, - }, - { - 0x13, - 0x0, - { (((0x7 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)), ((0 << 4) * FX32_ONE), (((0x6 << 4) * FX32_ONE) + ((16 * FX32_ONE) >> 1)) }, - { - 0x0, - 0x0, - 0x0, - 0x0, - }, - }, -}; - -static const u32 Unk_ov5_0220188C[20] = { - 0x22F, - 0x230, - 0x231, - 0x232, - 0x233, - 0x234, - 0x235, - 0x236, - 0x237, - 0x238, - 0x239, - 0x23A, - 0x23B, - 0x23C, - 0x23D, - 0x23E, - 0x23F, - 0x240, - 0x241, - 0x242 -}; - -static const UnkStruct_ov5_022018DC Unk_ov5_022018DC[20] = { - { 0x15 }, - { 0x16 }, - { 0x17 }, - { 0x18 }, - { 0x19 }, - { 0x2774 }, - { 0x1B }, - { 0x1C }, - { 0x1D }, - { 0x1E }, - { 0x1F }, - { 0x20 }, - { 0x21 }, - { 0x22 }, - { 0x23 }, - { 0x24 }, - { 0x25 }, - { 0x26 }, - { 0x27 }, - { 0x28 } -}; diff --git a/src/overlay005/surf_mount_renderer.c b/src/overlay005/surf_mount_renderer.c index 3af3d1d61e..b500efd75f 100644 --- a/src/overlay005/surf_mount_renderer.c +++ b/src/overlay005/surf_mount_renderer.c @@ -98,8 +98,8 @@ OverworldAnimManager *SurfMountRenderer_HandleSurfBegin(MapObject *surfMountMapO if (!reuseMapObjPos) { FieldSystem *fieldSystem = MapObject_FieldSystem(surfMountMapObj); - mapObjPos.x = MAP_OBJECT_COORD_TO_FX32(tileX); - mapObjPos.z = MAP_OBJECT_COORD_TO_FX32(tileZ); + mapObjPos.x = MAP_OBJECT_COORD_CENTER_TO_FX32(tileX); + mapObjPos.z = MAP_OBJECT_COORD_CENTER_TO_FX32(tileZ); MapObject_RecalculatePositionHeight(fieldSystem, &mapObjPos); } else { VecFx32 spritePosOffset = { MAP_OBJECT_BASE_POS_OFFSET_X, MAP_OBJECT_BASE_POS_OFFSET_Y, MAP_OBJECT_BASE_POS_OFFSET_Z }; diff --git a/src/overlay005/villa_furniture.c b/src/overlay005/villa_furniture.c new file mode 100644 index 0000000000..8db0051458 --- /dev/null +++ b/src/overlay005/villa_furniture.c @@ -0,0 +1,542 @@ +#include "overlay005/villa_furniture.h" + +#include +#include + +#include "constants/field/dynamic_map_features.h" + +#include "field/field_system.h" +#include "field/field_system_sub2_t.h" +#include "overlay005/map_prop.h" + +#include "field_system.h" +#include "heap.h" +#include "map_object.h" +#include "persisted_map_features.h" +#include "savedata_misc.h" +#include "script_manager.h" +#include "system_flags.h" +#include "vars_flags.h" + +#include "res/field/props/models/prop_models.naix" + +#define FURNITURE_SLOTS 23 +#define COLLISION_BOUNDS_NONE { 0, 0, 0, 0 } + +typedef struct FurnitureCollisionBoundingBox { + s16 left; + s16 top; + s16 right; + s16 bottom; +} FurnitureCollisionBoundingBox; + +typedef struct VillaFurniture { + u16 furnitureType; + u16 isCollisionEnabled; + VecFx32 position; + FurnitureCollisionBoundingBox collisionBounds; +} VillaFurniture; + +typedef struct VillaFurnitureProp { + u16 isLoaded; + u16 propIdx; + u32 modelID; + MapProp *mapProp; +} VillaFurnitureProp; + +typedef struct VillaDynamicMapData { + FieldSystem *fieldSystem; + VillaPersistedData *persistedData; + VillaFurnitureProp furnitureProps[FURNITURE_SLOTS]; +} VillaDynamicMapData; + +static void LoadFurniturePropModel(VillaDynamicMapData *villaDynamicData, const enum VillaFurnitureType furnitureType); +static BOOL FieldSystem_OwnsVillaFurniture(FieldSystem *fieldSystem, enum VillaFurnitureType furnitureType); +static BOOL CheckFurnitureCollision(int tileX, int tileZ, const VillaFurniture *furniture, FieldSystem *fieldSystem); + +static const VillaFurniture sVillaFurnitures[FURNITURE_SLOTS]; +static const u32 sVillaFurnitureModelIDs[VILLA_FURNITURE_MAX]; +static const u32 sVillaFurnitureScriptIDs[VILLA_FURNITURE_MAX]; + +void Villa_DynamicMapFeaturesInit(FieldSystem *fieldSystem) +{ + PersistedMapFeatures *persistedDatas = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); + VillaPersistedData *villaPersistedData = PersistedMapFeatures_GetBuffer(persistedDatas, DYNAMIC_MAP_FEATURES_VILLA); + VillaDynamicMapData *villaDynamicData = Heap_Alloc(HEAP_ID_FIELD1, sizeof(VillaDynamicMapData)); + + memset(villaDynamicData, 0, sizeof(VillaDynamicMapData)); + + villaDynamicData->fieldSystem = fieldSystem; + villaDynamicData->persistedData = villaPersistedData; + + fieldSystem->unk_04->dynamicMapFeaturesData = villaDynamicData; + + for (int i = 0; i < VILLA_FURNITURE_MAX; i++) { + if (FieldSystem_OwnsVillaFurniture(fieldSystem, i) == TRUE) { + LoadFurniturePropModel(villaDynamicData, i); + } + } +} + +void Villa_DynamicMapFeaturesFree(FieldSystem *fieldSystem) +{ + VillaDynamicMapData *villaDynamicData = fieldSystem->unk_04->dynamicMapFeaturesData; + + Heap_Free(villaDynamicData); + fieldSystem->unk_04->dynamicMapFeaturesData = NULL; +} + +BOOL Villa_DynamicMapFeaturesCheckCollision(FieldSystem *fieldSystem, const int tileX, const int tileZ, const fx32 height, BOOL *isColliding) +{ + int i; + const VillaFurniture *furniture = sVillaFurnitures; + + for (i = 0; i < FURNITURE_SLOTS; i++, furniture++) { + if (CheckFurnitureCollision(tileX, tileZ, furniture, fieldSystem) == TRUE) { + *isColliding = TRUE; + return TRUE; + } + } + + *isColliding = FALSE; + return FALSE; +} + +BOOL FieldSystem_TrySetVillaFurnitureScript(FieldSystem *fieldSystem, const int tileX, const int tileZ, const int direction) +{ + PersistedMapFeatures *persistedDatas = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); + + if (PersistedMapFeatures_GetID(persistedDatas) == DYNAMIC_MAP_FEATURES_VILLA) { + int i; + const VillaFurniture *furniture = sVillaFurnitures; + + for (i = 0; i < FURNITURE_SLOTS; i++, furniture++) { + if (CheckFurnitureCollision(tileX, tileZ, furniture, fieldSystem) == TRUE) { + u32 furnitureScript = sVillaFurnitureScriptIDs[furniture->furnitureType]; + + if (furnitureScript == SCRIPT_ID_OFFSET_TV_BROADCAST && direction != DIR_NORTH) { + continue; + } + + ScriptManager_Set(fieldSystem, furnitureScript, NULL); + return TRUE; + } + } + } + + return FALSE; +} + +static void LoadFurniturePropModel(VillaDynamicMapData *villaDynamicData, const enum VillaFurnitureType furnitureType) +{ + VillaFurnitureProp *furnitureProp; + VecFx32 rotation = { 0, 0, 0 }; + int modelID = sVillaFurnitureModelIDs[furnitureType]; + const VillaFurniture *furniture = sVillaFurnitures; + FieldSystem *fieldSystem = villaDynamicData->fieldSystem; + + for (int i = 0; i < FURNITURE_SLOTS; i++, furniture++) { + if (furniture->furnitureType == furnitureType) { + + furnitureProp = villaDynamicData->furnitureProps; + for (int j = 0; j < FURNITURE_SLOTS; j++) { + if (!furnitureProp->isLoaded) { + furnitureProp->isLoaded = TRUE; + furnitureProp->modelID = modelID; + furnitureProp->propIdx = MapPropManager_LoadOne(fieldSystem->mapPropManager, fieldSystem->areaDataManager, modelID, &furniture->position, &rotation, fieldSystem->mapPropAnimMan); + furnitureProp->mapProp = MapPropManager_FindLoadedPropByModelID(fieldSystem->mapPropManager, modelID); + break; + } + furnitureProp++; + } + } + } +} + +static BOOL FieldSystem_OwnsVillaFurniture(FieldSystem *fieldSystem, enum VillaFurnitureType furnitureType) +{ + return SystemFlag_HandleOwnsVillaFurniture(SaveData_GetVarsFlags(fieldSystem->saveData), HANDLE_FLAG_CHECK, furnitureType); +} + +static BOOL CheckFurnitureCollision(int tileX, int tileZ, const VillaFurniture *furniture, FieldSystem *fieldSystem) +{ + const FurnitureCollisionBoundingBox *collisionBounds = &furniture->collisionBounds; + + if (furniture->isCollisionEnabled == TRUE && FieldSystem_OwnsVillaFurniture(fieldSystem, furniture->furnitureType) == TRUE) { + if (tileZ >= collisionBounds->top && tileZ <= collisionBounds->bottom && tileX >= collisionBounds->left && tileX <= collisionBounds->right) { + return TRUE; + } + } + + return FALSE; +} + +static const VillaFurniture sVillaFurnitures[FURNITURE_SLOTS] = { + { + .furnitureType = VILLA_FURNITURE_TABLE, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(12), + .y = 0, + .z = MAP_OBJECT_COORD_EDGE_TO_FX32(7), + }, + .collisionBounds = { + .left = 11, + .top = 5, + .right = 13, + .bottom = 8, + }, + }, + { + .furnitureType = VILLA_FURNITURE_BIG_SOFA, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_EDGE_TO_FX32(15), + .y = 0, + .z = MAP_OBJECT_COORD_EDGE_TO_FX32(7), + }, + .collisionBounds = { + .left = 14, + .top = 5, + .right = 15, + .bottom = 8, + }, + }, + { + .furnitureType = VILLA_FURNITURE_SMALL_SOFA, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(13), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(10), + }, + .collisionBounds = { + .left = 11, + .top = 9, + .right = 13, + .bottom = 10, + }, + }, + { + .furnitureType = VILLA_FURNITURE_BED, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(18), + .y = 0, + .z = MAP_OBJECT_COORD_EDGE_TO_FX32(8), + }, + .collisionBounds = { + .left = 18, + .top = 6, + .right = 20, + .bottom = 9, + }, + }, + { + .furnitureType = VILLA_FURNITURE_NIGHT_TABLE, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(20), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(7), + }, + .collisionBounds = { + .left = 17, + .top = 6, + .right = 17, + .bottom = 7, + }, + }, + { + .furnitureType = VILLA_FURNITURE_TV, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_EDGE_TO_FX32(12), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(3), + }, + .collisionBounds = { + .left = 11, + .top = 3, + .right = 12, + .bottom = 3, + }, + }, + { + .furnitureType = VILLA_FURNITURE_AUDIO_SYSTEM, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(14), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(3), + }, + .collisionBounds = { + .left = 13, + .top = 3, + .right = 15, + .bottom = 3, + }, + }, + { + .furnitureType = VILLA_FURNITURE_BOOKSHELF, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_EDGE_TO_FX32(17), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(3), + }, + .collisionBounds = { + .left = 16, + .top = 3, + .right = 17, + .bottom = 3, + }, + }, + { + .furnitureType = VILLA_FURNITURE_RACK, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_EDGE_TO_FX32(19), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(3), + }, + .collisionBounds = { + .left = 18, + .top = 3, + .right = 19, + .bottom = 3, + }, + }, + { + .furnitureType = VILLA_FURNITURE_HOUSEPLANT, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(1), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(3), + }, + .collisionBounds = { + .left = 1, + .top = 3, + .right = 1, + .bottom = 3, + }, + }, + { + .furnitureType = VILLA_FURNITURE_HOUSEPLANT, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(20), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(3), + }, + .collisionBounds = { + .left = 20, + .top = 3, + .right = 20, + .bottom = 3, + }, + }, + { + .furnitureType = VILLA_FURNITURE_HOUSEPLANT, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(1), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(11), + }, + .collisionBounds = { + .left = 1, + .top = 11, + .right = 1, + .bottom = 11, + }, + }, + { + .furnitureType = VILLA_FURNITURE_HOUSEPLANT, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(20), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(11), + }, + .collisionBounds = { + .left = 20, + .top = 11, + .right = 20, + .bottom = 11, + }, + }, + { + .furnitureType = VILLA_FURNITURE_PC_DESK, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_EDGE_TO_FX32(2), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(8), + }, + .collisionBounds = { + .left = 1, + .top = 7, + .right = 2, + .bottom = 9, + }, + }, + { + .furnitureType = VILLA_FURNITURE_MUSIC_BOX, + .isCollisionEnabled = FALSE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(18), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(3), + }, + .collisionBounds = COLLISION_BOUNDS_NONE, + }, + { + .furnitureType = VILLA_FURNITURE_POKEMON_BUST, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(2), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(3), + }, + .collisionBounds = { + .left = 2, + .top = 3, + .right = 2, + .bottom = 3, + }, + }, + { + .furnitureType = VILLA_FURNITURE_POKEMON_BUST_SILVER, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(6), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(3), + }, + .collisionBounds = { + .left = 6, + .top = 3, + .right = 6, + .bottom = 3, + }, + }, + { + .furnitureType = VILLA_FURNITURE_PIANO, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(2), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(5), + }, + .collisionBounds = { + .left = 1, + .top = 4, + .right = 2, + .bottom = 6, + }, + }, + { + .furnitureType = VILLA_FURNITURE_GUEST_SET, + .isCollisionEnabled = TRUE, + .position = { + .x = MAP_OBJECT_COORD_EDGE_TO_FX32(6), + .y = 0, + .z = MAP_OBJECT_COORD_EDGE_TO_FX32(10), + }, + .collisionBounds = { + .left = 4, + .top = 9, + .right = 7, + .bottom = 10, + }, + }, + { + .furnitureType = VILLA_FURNITURE_WALL_CLOCK, + .isCollisionEnabled = FALSE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(11), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(1), + }, + .collisionBounds = COLLISION_BOUNDS_NONE, + }, + { + .furnitureType = VILLA_FURNITURE_MASTERPIECE, + .isCollisionEnabled = FALSE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(8), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(1), + }, + .collisionBounds = COLLISION_BOUNDS_NONE, + }, + { + .furnitureType = VILLA_FURNITURE_TEA_SET, + .isCollisionEnabled = FALSE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(6), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(10), + }, + .collisionBounds = COLLISION_BOUNDS_NONE, + }, + { + .furnitureType = VILLA_FURNITURE_CHANDELIER, + .isCollisionEnabled = FALSE, + .position = { + .x = MAP_OBJECT_COORD_CENTER_TO_FX32(7), + .y = 0, + .z = MAP_OBJECT_COORD_CENTER_TO_FX32(6), + }, + .collisionBounds = COLLISION_BOUNDS_NONE, + }, +}; + +static const u32 sVillaFurnitureModelIDs[VILLA_FURNITURE_MAX] = { + [VILLA_FURNITURE_TABLE] = villa_furniture_table_nsbmd, + [VILLA_FURNITURE_BIG_SOFA] = villa_furniture_big_sofa_nsbmd, + [VILLA_FURNITURE_SMALL_SOFA] = villa_furniture_small_sofa_nsbmd, + [VILLA_FURNITURE_BED] = villa_furniture_bed_nsbmd, + [VILLA_FURNITURE_NIGHT_TABLE] = villa_furniture_night_table_nsbmd, + [VILLA_FURNITURE_TV] = villa_furniture_tv_nsbmd, + [VILLA_FURNITURE_AUDIO_SYSTEM] = villa_furniture_audio_system_nsbmd, + [VILLA_FURNITURE_BOOKSHELF] = villa_furniture_bookshelf_nsbmd, + [VILLA_FURNITURE_RACK] = villa_furniture_rack_nsbmd, + [VILLA_FURNITURE_HOUSEPLANT] = villa_furniture_houseplant_nsbmd, + [VILLA_FURNITURE_PC_DESK] = villa_furniture_pc_desk_nsbmd, + [VILLA_FURNITURE_MUSIC_BOX] = villa_furniture_music_box_nsbmd, + [VILLA_FURNITURE_POKEMON_BUST] = villa_furniture_pokemon_bust_nsbmd, + [VILLA_FURNITURE_POKEMON_BUST_SILVER] = villa_furniture_pokemon_bust_silver_nsbmd, + [VILLA_FURNITURE_PIANO] = villa_furniture_piano_nsbmd, + [VILLA_FURNITURE_GUEST_SET] = villa_furniture_guest_set_nsbmd, + [VILLA_FURNITURE_WALL_CLOCK] = villa_furniture_wall_clock_nsbmd, + [VILLA_FURNITURE_MASTERPIECE] = villa_furniture_masterpiece_nsbmd, + [VILLA_FURNITURE_TEA_SET] = villa_furniture_tea_set_nsbmd, + [VILLA_FURNITURE_CHANDELIER] = villa_furniture_chandelier_nsbmd, +}; + +// TODO: generate script IDs and replace magic numbers with generated script IDs +static const u32 sVillaFurnitureScriptIDs[VILLA_FURNITURE_MAX] = { + [VILLA_FURNITURE_TABLE] = 0x15, + [VILLA_FURNITURE_BIG_SOFA] = 0x16, + [VILLA_FURNITURE_SMALL_SOFA] = 0x17, + [VILLA_FURNITURE_BED] = 0x18, + [VILLA_FURNITURE_NIGHT_TABLE] = 0x19, + [VILLA_FURNITURE_TV] = SCRIPT_ID_OFFSET_TV_BROADCAST, + [VILLA_FURNITURE_AUDIO_SYSTEM] = 0x1B, + [VILLA_FURNITURE_BOOKSHELF] = 0x1C, + [VILLA_FURNITURE_RACK] = 0x1D, + [VILLA_FURNITURE_HOUSEPLANT] = 0x1E, + [VILLA_FURNITURE_PC_DESK] = 0x1F, + [VILLA_FURNITURE_MUSIC_BOX] = 0x20, + [VILLA_FURNITURE_POKEMON_BUST] = 0x21, + [VILLA_FURNITURE_POKEMON_BUST_SILVER] = 0x22, + [VILLA_FURNITURE_PIANO] = 0x23, + [VILLA_FURNITURE_GUEST_SET] = 0x24, + [VILLA_FURNITURE_WALL_CLOCK] = 0x25, + [VILLA_FURNITURE_MASTERPIECE] = 0x26, + [VILLA_FURNITURE_TEA_SET] = 0x27, + [VILLA_FURNITURE_CHANDELIER] = 0x28 +}; diff --git a/src/overlay008/ov8_02249960.c b/src/overlay008/ov8_02249960.c index 0a7c48399a..91b0c7479a 100644 --- a/src/overlay008/ov8_02249960.c +++ b/src/overlay008/ov8_02249960.c @@ -2232,14 +2232,14 @@ static const u32 sEternaGymClockModelIds[2] = { static const VecFx32 sEternaGymClockHandsCenter[2] = { { - MAP_OBJECT_COORD_TO_FX32(ETERNA_CLOCK_CENTER_X), + MAP_OBJECT_COORD_CENTER_TO_FX32(ETERNA_CLOCK_CENTER_X), FX32_ONE * 12, - MAP_OBJECT_COORD_TO_FX32(ETERNA_CLOCK_CENTER_Z), + MAP_OBJECT_COORD_CENTER_TO_FX32(ETERNA_CLOCK_CENTER_Z), }, { - MAP_OBJECT_COORD_TO_FX32(ETERNA_CLOCK_CENTER_X), + MAP_OBJECT_COORD_CENTER_TO_FX32(ETERNA_CLOCK_CENTER_X), FX32_ONE * 13, - MAP_OBJECT_COORD_TO_FX32(ETERNA_CLOCK_CENTER_Z), + MAP_OBJECT_COORD_CENTER_TO_FX32(ETERNA_CLOCK_CENTER_Z), } }; diff --git a/src/overlay009/ov9_02249960.c b/src/overlay009/ov9_02249960.c index 58dbfd2242..af2aef334a 100644 --- a/src/overlay009/ov9_02249960.c +++ b/src/overlay009/ov9_02249960.c @@ -3717,7 +3717,7 @@ static BOOL DistWorldPlatformProp_AnimInit(OverworldAnimManager *animMan, void * } VecFx32_SetPosFromMapCoords(ghostPropTemplate->tileX, ghostPropTemplate->tileZ, &platformProp->initialPos); - platformProp->initialPos.y = MAP_OBJECT_COORD_TO_FX32(ghostPropTemplate->tileY); + platformProp->initialPos.y = MAP_OBJECT_COORD_CENTER_TO_FX32(ghostPropTemplate->tileY); const VecFx32 *initialPosOffset = &sPropInitialPosOffsetByKind[ghostPropTemplate->propKind]; platformProp->initialPos.x += initialPosOffset->x; @@ -3884,7 +3884,7 @@ static BOOL DistWorldObstacleProp_AnimInit(OverworldAnimManager *animMan, void * } VecFx32_SetPosFromMapCoords(ghostPropTemplate->tileX, ghostPropTemplate->tileZ, &obstacleProp->pos); - obstacleProp->pos.y = MAP_OBJECT_COORD_TO_FX32(ghostPropTemplate->tileY); + obstacleProp->pos.y = MAP_OBJECT_COORD_CENTER_TO_FX32(ghostPropTemplate->tileY); const VecFx32 *initialPosOffset = &sPropInitialPosOffsetByKind[ghostPropTemplate->propKind]; obstacleProp->pos.x += initialPosOffset->x; @@ -6323,7 +6323,7 @@ static int DistWorldMovingPlatformProp_AnimInit(OverworldAnimManager *animMan, v } VecFx32_SetPosFromMapCoords(userData->tileX, userData->tileZ, &movingPlatformProp->pos); - movingPlatformProp->pos.y = MAP_OBJECT_COORD_TO_FX32(userData->tileY); + movingPlatformProp->pos.y = MAP_OBJECT_COORD_CENTER_TO_FX32(userData->tileY); const VecFx32 *initialPosOffset = &sPropInitialPosOffsetByKind[userData->propKind]; movingPlatformProp->pos.x += initialPosOffset->x; @@ -7209,7 +7209,7 @@ static BOOL DistWorldSimpleProp_AnimInit(OverworldAnimManager *animMan, void *co } VecFx32_SetPosFromMapCoords(simplePropTemplate->tileX, simplePropTemplate->tileZ, &simpleProp->pos); - simpleProp->pos.y = MAP_OBJECT_COORD_TO_FX32(simplePropTemplate->tileY); + simpleProp->pos.y = MAP_OBJECT_COORD_CENTER_TO_FX32(simplePropTemplate->tileY); const VecFx32 *initialPosOffset = &sPropInitialPosOffsetByKind[simplePropTemplate->propKind]; simpleProp->pos.x += initialPosOffset->x; diff --git a/src/persisted_map_features_init.c b/src/persisted_map_features_init.c index 3736f4888a..f368017f5d 100644 --- a/src/persisted_map_features_init.c +++ b/src/persisted_map_features_init.c @@ -10,10 +10,10 @@ #include "struct_defs/struct_02071B6C.h" #include "struct_defs/struct_02071BF8.h" #include "struct_defs/struct_02071C18.h" -#include "struct_defs/struct_02071C34.h" #include "field/field_system.h" #include "field/field_system_sub2_t.h" +#include "overlay005/villa_furniture.h" #include "overlay006/great_marsh_tram.h" #include "overlay008/ov8_02249960.h" #include "overlay009/ov9_02249960.h" @@ -137,8 +137,8 @@ void PersistedMapFeatures_InitForVilla(FieldSystem *fieldSystem) PersistedMapFeatures *persistedMapFeatures = MiscSaveBlock_GetPersistedMapFeatures(FieldSystem_GetSaveData(fieldSystem)); PersistedMapFeatures_InitWithID(persistedMapFeatures, DYNAMIC_MAP_FEATURES_VILLA); - UnkStruct_02071C34 *data = PersistedMapFeatures_GetBuffer(persistedMapFeatures, DYNAMIC_MAP_FEATURES_VILLA); - memset(data, 0, sizeof(UnkStruct_02071C34)); + VillaPersistedData *data = PersistedMapFeatures_GetBuffer(persistedMapFeatures, DYNAMIC_MAP_FEATURES_VILLA); + memset(data, 0, sizeof(VillaPersistedData)); } void PersistedMapFeatures_InitForDistortionWorld(FieldSystem *fieldSystem) diff --git a/src/system_flags.c b/src/system_flags.c index f8f217aabc..6c86468343 100644 --- a/src/system_flags.c +++ b/src/system_flags.c @@ -490,7 +490,7 @@ void SystemFlag_SetConnectedToWiFi(VarsFlags *varsFlags) SetFlag(varsFlags, FLAG_CONNECTED_TO_WIFI); } -BOOL SystemFlag_HandleOwnsVillaFurniture(VarsFlags *varsFlags, enum HandleFlagOp op, enum VillaFurniture furniture) +BOOL SystemFlag_HandleOwnsVillaFurniture(VarsFlags *varsFlags, enum HandleFlagOp op, enum VillaFurnitureType furniture) { GF_ASSERT(furniture < VILLA_FURNITURE_MAX); return HandleFlag(varsFlags, op, FLAG_VILLA_FURNITURE_START + furniture);