From 9e5c4898af92b7a5fac0d52052fb251cce578302 Mon Sep 17 00:00:00 2001 From: Mr-Auto Date: Sat, 2 Sep 2023 19:30:36 +0200 Subject: [PATCH 1/7] some unknown layer stuff --- src/game_api/layer.hpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/game_api/layer.hpp b/src/game_api/layer.hpp index ddd0aee0f..b5d0feb92 100644 --- a/src/game_api/layer.hpp +++ b/src/game_api/layer.hpp @@ -117,6 +117,15 @@ struct EntityList } }; +struct EntityRegions +{ + EntityList** entity_lists; + // pointers to entities from entities_by_region array + + uint8_t size; + uint8_t cap; // seam to be locked at 4 +}; + struct Layer { bool is_back_layer; @@ -125,14 +134,17 @@ struct Layer EntityList all_entities; // char + fx + mons + item + logical + mount + activefloor + BG (excluding BG_SHOP, BG_LEVEL_*) EntityList unknown_entities1; - size_t unknown1; - // key is the mask - std::map entities_by_mask; + EntityRegions* unknown1; // players in motion? + + std::map entities_by_mask; // key is the mask - EntityList entities_by_unknown[647]; // could be more, not sure what for, each holds like 1 entity for split second - char stuff0[0xB778]; // unknown, maybe more of the array above? + // 4x4 block areas (overlaping one block plus the edge ones extending to infinity?), each probably contains diffrent mask entities + EntityList entities_by_region1[31][21]; + EntityList entities_by_region2[31][21]; // Active floors ? + EntityList entities_by_region3[31][21]; + EntityList entities_by_region4[31][21]; - std::map unknown_map; // some movable and liquids and something else maybe?, key is uid + std::map entity_regions; // key is uid, all entities except FX, FLOOR, DECORATION, BG, SHADOW and LOGICAL Entity* grid_entities[g_level_max_y][g_level_max_x]; EntityList entities_overlaping_grid[g_level_max_y][g_level_max_x]; // static entities (like midbg, decorations) that overlap this grid position @@ -142,7 +154,7 @@ struct Layer EntityList unknown_entities3; // debris, explosions, laserbeams etc. ? EntityList unknown_entities4; // explosions, laserbeams, BG_LEVEL_*_SOOT ? only for short time while there are spawned? std::vector unknown_vector; // add_to_layer uses this - size_t unknown6; // MysteryLayerPointer1 in plugin + std::list* unknown6; // triggered by floor entity destruction? needs more testing // List of items that were destroyed and are waiting to have the dtor called // and then be returned to the entity pool EntityList expired_entities; From d5e4dfeb38884453d6d8444eb5954e7f50519ef2 Mon Sep 17 00:00:00 2001 From: Mr-Auto Date: Sat, 2 Sep 2023 20:42:33 +0200 Subject: [PATCH 2/7] some map/set stuff --- src/game_api/entities_fx.hpp | 4 +++- src/game_api/entities_monsters.hpp | 2 +- src/game_api/layer.hpp | 2 +- src/game_api/movable.hpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/game_api/entities_fx.hpp b/src/game_api/entities_fx.hpp index 5c9db1258..8f629b1f0 100644 --- a/src/game_api/entities_fx.hpp +++ b/src/game_api/entities_fx.hpp @@ -216,7 +216,9 @@ class FxSpringtrapRing : public Movable class FxWitchdoctorHint : public Movable { public: - std::set unknown; // uid of the witchdoctor, why the map/set? + /// There can be only one Hint above the player, so it has list of witchdoctors + /// in case there are more then one attacking you the same time + std::set witchdoctor; }; class FxNecromancerANKH : public Movable diff --git a/src/game_api/entities_monsters.hpp b/src/game_api/entities_monsters.hpp index e03e58784..30887780b 100644 --- a/src/game_api/entities_monsters.hpp +++ b/src/game_api/entities_monsters.hpp @@ -243,7 +243,7 @@ class Yang : public RoomOwner { public: /// Table of uid's of the turkeys, goes only up to 3, is nil when yang is angry - std::set turkeys_in_den; // probably a Map, but the second value is just 1 or 0, not really useful + std::set turkeys_in_den; uint8_t unknown4; uint8_t unknown5; /// I'm looking for turkeys, wanna help? diff --git a/src/game_api/layer.hpp b/src/game_api/layer.hpp index b5d0feb92..3df5cff14 100644 --- a/src/game_api/layer.hpp +++ b/src/game_api/layer.hpp @@ -154,7 +154,7 @@ struct Layer EntityList unknown_entities3; // debris, explosions, laserbeams etc. ? EntityList unknown_entities4; // explosions, laserbeams, BG_LEVEL_*_SOOT ? only for short time while there are spawned? std::vector unknown_vector; // add_to_layer uses this - std::list* unknown6; // triggered by floor entity destruction? needs more testing + std::set* unknown6; // triggered by floor entity destruction? needs more testing // List of items that were destroyed and are waiting to have the dtor called // and then be returned to the entity pool EntityList expired_entities; diff --git a/src/game_api/movable.hpp b/src/game_api/movable.hpp index ae8a70d24..c76079213 100644 --- a/src/game_api/movable.hpp +++ b/src/game_api/movable.hpp @@ -16,7 +16,7 @@ class Movable : public Entity custom_map behaviors_map; custom_set behaviors; MovableBehavior* current_behavior; - int64_t ic8; + int64_t ic8; // some AI stuff for cutscenes union { /// {movex, movey} From b4137d541120da6910ae43df74fdf1b962929b35 Mon Sep 17 00:00:00 2001 From: Mr-Auto Date: Sat, 2 Sep 2023 20:46:26 +0200 Subject: [PATCH 3/7] . --- src/game_api/layer.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game_api/layer.hpp b/src/game_api/layer.hpp index 3df5cff14..5b474b0e9 100644 --- a/src/game_api/layer.hpp +++ b/src/game_api/layer.hpp @@ -123,7 +123,7 @@ struct EntityRegions // pointers to entities from entities_by_region array uint8_t size; - uint8_t cap; // seam to be locked at 4 + uint8_t cap; }; struct Layer @@ -138,7 +138,7 @@ struct Layer std::map entities_by_mask; // key is the mask - // 4x4 block areas (overlaping one block plus the edge ones extending to infinity?), each probably contains diffrent mask entities + // 4x4 block areas (the edge ones extend to infinity?), each probably contains diffrent mask entities EntityList entities_by_region1[31][21]; EntityList entities_by_region2[31][21]; // Active floors ? EntityList entities_by_region3[31][21]; @@ -154,7 +154,7 @@ struct Layer EntityList unknown_entities3; // debris, explosions, laserbeams etc. ? EntityList unknown_entities4; // explosions, laserbeams, BG_LEVEL_*_SOOT ? only for short time while there are spawned? std::vector unknown_vector; // add_to_layer uses this - std::set* unknown6; // triggered by floor entity destruction? needs more testing + std::set* unknown6; // triggered by floor entity destruction? needs more testing // List of items that were destroyed and are waiting to have the dtor called // and then be returned to the entity pool EntityList expired_entities; From 6e83d9804dd32229a84b9d1a9d9194db43535eac Mon Sep 17 00:00:00 2001 From: Mr-Auto Date: Thu, 7 Sep 2023 16:39:41 +0200 Subject: [PATCH 4/7] improve `add_item_to_shop` to use the actual map.insert and add other map's in the game --- src/game_api/layer.hpp | 1 + src/game_api/rpc.cpp | 18 ++---------------- src/game_api/search.cpp | 9 --------- src/game_api/state_structs.hpp | 23 ++++++++++++----------- 4 files changed, 15 insertions(+), 36 deletions(-) diff --git a/src/game_api/layer.hpp b/src/game_api/layer.hpp index 5b474b0e9..8def12e0c 100644 --- a/src/game_api/layer.hpp +++ b/src/game_api/layer.hpp @@ -5,6 +5,7 @@ #include // for less #include // for map #include // for operator new +#include // #include // for find, pair #include // for allocator, vector diff --git a/src/game_api/rpc.cpp b/src/game_api/rpc.cpp index eefce27ec..3755cdca9 100644 --- a/src/game_api/rpc.cpp +++ b/src/game_api/rpc.cpp @@ -1674,13 +1674,6 @@ void move_grid_entity(int32_t uid, float x, float y, LAYER layer) void add_item_to_shop(int32_t item_uid, int32_t shop_owner_uid) { - struct dummy // dummy struct - { - std::set::iterator __omg; - int __wow; - }; - using AddRestrictedItemFun = size_t(std::set*, dummy, ShopRestrictedItem); - Movable* item = get_entity_ptr(item_uid)->as(); Entity* owner = get_entity_ptr(shop_owner_uid); if (item && owner && item->is_movable()) @@ -1698,21 +1691,14 @@ void add_item_to_shop(int32_t item_uid, int32_t shop_owner_uid) { if (owner->type->id == it) // TODO: check what happens if it's not room owner/shopkeeper { - static auto add_to_items_set = (AddRestrictedItemFun*)get_address("add_shopitem"); auto state = State::get(); item->flags = setflag(item->flags, 23); // shop item item->flags = setflag(item->flags, 20); // Enable button prompt (flag is problably: show dialogs and other fx) state.layer_local(item->layer)->spawn_entity_over(to_id("ENT_TYPE_FX_SALEICON"), item, 0, 0); state.layer_local(item->layer)->spawn_entity_over(to_id("ENT_TYPE_FX_SALEDIALOG_CONTAINER"), item, 0, 0.5); - // This function actually only takes iterator and value as argument, but for some reason they need to be passed thru stack - // This is probably some standard `insert` function, but the items is a strange one, i would guess it's a map (item uid as a key and array/struct as a value) - // but standard function, no matter if i set it to map or set, also adds something at the end of a bucket (key hash?), so it's either very similar container or some special setup for set/map - const auto bucket = add_to_items_set(&state.ptr()->shops.items, {state.ptr()->shops.items.end(), 0}, {item_uid, 0, 0}); - - auto the_struct = (ShopRestrictedItem*)(bucket + 0x1C); // 0x1C - is just the internal map/set stuff - the_struct->owner_uid = shop_owner_uid; - the_struct->owner_type = owner->type->id; + ItemOwnerDetails iod{shop_owner_uid, owner->type->id}; + state.ptr()->shops.items.insert({item->uid, iod}); return; } } diff --git a/src/game_api/search.cpp b/src/game_api/search.cpp index 17d40c853..863dbc131 100644 --- a/src/game_api/search.cpp +++ b/src/game_api/search.cpp @@ -1727,15 +1727,6 @@ std::unordered_map g_address_rules{ .find_after_inst("\x41\x0F\xB6\x87\x17\x01\x00\x00\x83\xF8"sv) .at_exe(), }, - { - // Set write bp on State->shops->restricted_item_count, this structure is quite common so i chosen pattern before the call - "add_shopitem"sv, - PatternCommandBuffer{} - .find_after_inst("\x4C\x8D\x84\x24\xD0\x00\x00\x00\xE8"sv) - .offset(-0x1) - .decode_call() - .at_exe(), - }, { // Find a string "Basic systems initialized", right after it's usage (found via XREFS) // stuff gets emplaced to a map, it is this map diff --git a/src/game_api/state_structs.hpp b/src/game_api/state_structs.hpp index 64992cad1..70d9020a6 100644 --- a/src/game_api/state_structs.hpp +++ b/src/game_api/state_structs.hpp @@ -1,11 +1,12 @@ #pragma once #include "aliases.hpp" +#include "containers/custom_map.hpp" #include "containers/custom_vector.hpp" #include "render_api.hpp" #include #include -#include +#include class Entity; @@ -834,13 +835,13 @@ struct LiquidPhysics LiquidTileSpawnData stagnant_lava_tile_spawn_data; }; }; - std::list* floors; // pointer to map/list that contains all floor uids that the liquid interact with - std::list* push_blocks; // pointer to map/list that contains all activefloor uids that the liquid interact with - custom_vector impostor_lakes; // - uint32_t total_liquid_spawned; // Total number of spawned liquid entities, all types. - uint32_t unknown8; // padding probably - uint8_t* unknown9; // array byte* ? game allocates 0x2F9E8 bytes for it, (0x2F9E8 / g_level_max_x * g_level_max_y = 18) which is weird, but i still think it's position based index, maybe it's 16 and accounts for more rows (grater level height) - // always allocates after the LiquidPhysics + std::map, size_t*>* floors; // key is a grid position, the struct seams to be the same as in push_blocks + std::map* push_blocks; // key is uid, not sure about the struct it points to (it's also possible that the value is 2 pointers) + custom_vector impostor_lakes; // + uint32_t total_liquid_spawned; // Total number of spawned liquid entities, all types. + uint32_t unknown8; // padding probably + uint8_t* unknown9; // array byte* ? game allocates 0x2F9E8 bytes for it, (0x2F9E8 / g_level_max_x * g_level_max_y = 18) which is weird, but i still think it's position based index, maybe it's 16 and accounts for more rows (grater level height) + // always allocates after the LiquidPhysics uint32_t total_liquid_spawned2; // Same as total_liquid_spawned? bool unknown12; @@ -965,9 +966,8 @@ struct Dialogue uint32_t unknown18; }; -struct ShopRestrictedItem +struct ItemOwnerDetails { - int32_t item_uid; int32_t owner_uid; ENT_TYPE owner_type; }; @@ -984,7 +984,8 @@ struct ShopOwnerDetails struct ShopsInfo { - std::set items; // could also be a map + // key is the uid of an item + custom_map items; std::vector shop_owners; }; From 0d49a84492622c1bf9a3bc0ce12b39055f0973cc Mon Sep 17 00:00:00 2001 From: Mr-Auto Date: Thu, 7 Sep 2023 17:02:20 +0200 Subject: [PATCH 5/7] Rename shops to room owners, as it contains more than just a the shop stuff --- src/game_api/rpc.cpp | 2 +- src/game_api/state.hpp | 2 +- src/game_api/state_structs.hpp | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/game_api/rpc.cpp b/src/game_api/rpc.cpp index 3755cdca9..e687d743b 100644 --- a/src/game_api/rpc.cpp +++ b/src/game_api/rpc.cpp @@ -1698,7 +1698,7 @@ void add_item_to_shop(int32_t item_uid, int32_t shop_owner_uid) state.layer_local(item->layer)->spawn_entity_over(to_id("ENT_TYPE_FX_SALEDIALOG_CONTAINER"), item, 0, 0.5); ItemOwnerDetails iod{shop_owner_uid, owner->type->id}; - state.ptr()->shops.items.insert({item->uid, iod}); + state.ptr()->room_owners.owned_items.insert({item->uid, iod}); return; } } diff --git a/src/game_api/state.hpp b/src/game_api/state.hpp index 5c464c4db..45cfc44cf 100644 --- a/src/game_api/state.hpp +++ b/src/game_api/state.hpp @@ -260,7 +260,7 @@ struct StateMemory uint8_t unknown31a; // padding probably uint8_t unknown31b; uint8_t unknown31c; - ShopsInfo shops; + RoomOwnersInfo room_owners; /// Number of frames since the game was launched uint32_t time_startup; uint32_t special_visibility_flags; diff --git a/src/game_api/state_structs.hpp b/src/game_api/state_structs.hpp index 70d9020a6..0ce77fde0 100644 --- a/src/game_api/state_structs.hpp +++ b/src/game_api/state_structs.hpp @@ -982,11 +982,11 @@ struct ShopOwnerDetails uint32_t shop_owner_uid; }; -struct ShopsInfo +struct RoomOwnersInfo { // key is the uid of an item - custom_map items; - std::vector shop_owners; + custom_map owned_items; + std::vector room_owners; }; struct MultiLineTextRendering From f3aa6141d3a3b0d220a3b9a18b3aa7716678e82a Mon Sep 17 00:00:00 2001 From: Mr-Auto <36127424+Mr-Auto@users.noreply.github.com> Date: Fri, 8 Sep 2023 20:02:57 +0200 Subject: [PATCH 6/7] expose room owners stuff from state --- docs/game_data/spel2.lua | 14 ++++++++++ docs/src/includes/_types.md | 29 +++++++++++++++++++++ src/game_api/script/usertypes/state_lua.cpp | 10 +++++++ src/game_api/state.hpp | 1 + src/game_api/state_structs.hpp | 8 +++--- 5 files changed, 58 insertions(+), 4 deletions(-) diff --git a/docs/game_data/spel2.lua b/docs/game_data/spel2.lua index bf911e699..7891fc7c2 100644 --- a/docs/game_data/spel2.lua +++ b/docs/game_data/spel2.lua @@ -1923,6 +1923,7 @@ do ---@field logic LogicList @Level logic like dice game and cutscenes ---@field liquid LiquidPhysics ---@field next_entity_uid integer @Next entity spawned will have this uid + ---@field room_owners RoomOwnersInfo @Holds info about owned rooms and items (shops, challenge rooms, vault etc.) ---@class LightParams ---@field red number @@ -2023,6 +2024,19 @@ do ---@field won_prizes_count integer ---@field balance integer +---@class RoomOwnersInfo + ---@field owned_items custom_map @key/index is the uid of an item + ---@field owned_rooms RoomwOwnerDetails[] + +---@class ItemOwnerDetails + ---@field owner_type ENT_TYPE + ---@field owner_uid integer + +---@class RoomwOwnerDetails + ---@field layer integer + ---@field room_index integer + ---@field owner_uid integer + ---@class BackgroundMusic ---@field game_startup BackgroundSound ---@field main_backgroundtrack BackgroundSound diff --git a/docs/src/includes/_types.md b/docs/src/includes/_types.md index 88aaf6b91..4992540ab 100644 --- a/docs/src/includes/_types.md +++ b/docs/src/includes/_types.md @@ -686,6 +686,15 @@ int | [health](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=health) int | [bombs](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=bombs) | int | [ropes](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=ropes) | +### ItemOwnerDetails + +Used in [RoomOwnersInfo](#RoomOwnersInfo) + +Type | Name | Description +---- | ---- | ----------- +[ENT_TYPE](#ENT_TYPE) | [owner_type](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owner_type) | +int | [owner_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owner_uid) | + ### Letter @@ -798,6 +807,25 @@ nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/ov [CallbackId](#Aliases) | [set_pre_render(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_render) | Hooks before the virtual function.
The callback signature is `bool render(RenderInfo self, float float, VanillaRenderContext vanilla_render_context)` [CallbackId](#Aliases) | [set_post_render(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_render) | Hooks after the virtual function.
The callback signature is `nil render(RenderInfo self, float float, VanillaRenderContext vanilla_render_context)` +### RoomOwnersInfo + +Used in [StateMemory](#StateMemory) + +Type | Name | Description +---- | ---- | ----------- +custom_map<int, [ItemOwnerDetails](#ItemOwnerDetails)> | [owned_items](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owned_items) | key/index is the uid of an item +array<[RoomwOwnerDetails](#RoomwOwnerDetails)> | [owned_rooms](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owned_rooms) | + +### RoomwOwnerDetails + +Used in [RoomOwnersInfo](#RoomOwnersInfo) + +Type | Name | Description +---- | ---- | ----------- +int | [layer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=layer) | +int | [room_index](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=room_index) | +int | [owner_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owner_uid) | + ### ShortTileCodeDef Used in [get_short_tile_code](#get_short_tile_code), [get_short_tile_code_definition](#get_short_tile_code_definition) and [PostRoomGenerationContext](#PostRoomGenerationContext) @@ -2628,6 +2656,7 @@ array<int, 9> | [journal_progress_theme_slots](https://github.com/spelunky [LogicList](#LogicList) | [logic](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=logic) | Level logic like dice game and cutscenes [LiquidPhysics](#LiquidPhysics) | [liquid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=liquid) | int | [next_entity_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=next_entity_uid) | Next entity spawned will have this uid +[RoomOwnersInfo](#RoomOwnersInfo) | [room_owners](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=room_owners) | Holds info about owned rooms and items (shops, challenge rooms, vault etc.) ## Texture types diff --git a/src/game_api/script/usertypes/state_lua.cpp b/src/game_api/script/usertypes/state_lua.cpp index b2cc8de25..f6f1fbedc 100644 --- a/src/game_api/script/usertypes/state_lua.cpp +++ b/src/game_api/script/usertypes/state_lua.cpp @@ -401,6 +401,7 @@ void register_usertypes(sol::state& lua) statememory_type["logic"] = &StateMemory::logic; statememory_type["liquid"] = &StateMemory::liquid_physics; statememory_type["next_entity_uid"] = &StateMemory::next_entity_uid; + statememory_type["room_owners"] = &StateMemory::room_owners; lua.create_named_table("QUEST_FLAG", "RESET", 1, "DARK_LEVEL_SPAWNED", 2, "VAULT_SPAWNED", 3, "SPAWN_OUTPOST", 4, "SHOP_SPAWNED", 5, "SHORTCUT_USED", 6, "SEEDED", 7, "DAILY", 8, "CAVEMAN_SHOPPIE_AGGROED", 9, "WADDLER_AGGROED", 10, "SHOP_BOUGHT_OUT", 11, "EGGPLANT_CROWN_PICKED_UP", 12, "UDJAT_EYE_SPAWNED", 17, "BLACK_MARKET_SPAWNED", 18, "DRILL_SPAWNED", 19, "MOON_CHALLENGE_SPAWNED", 25, "STAR_CHALLENGE_SPAWNED", 26, "SUN_CHALLENGE_SPAWNED", 27); @@ -554,6 +555,15 @@ void register_usertypes(sol::state& lua) logicdiceshop_type["won_prizes_count"] = &LogicDiceShop::won_prizes_count; logicdiceshop_type["balance"] = &LogicDiceShop::balance; + /// Used in StateMemory + lua.new_usertype("RoomOwnersInfo", "owned_items", &RoomOwnersInfo::owned_items, "owned_rooms", &RoomOwnersInfo::owned_rooms); + + /// Used in RoomOwnersInfo + lua.new_usertype("ItemOwnerDetails", "owner_type", &ItemOwnerDetails::owner_type, "owner_uid", &ItemOwnerDetails::owner_uid); + + /// Used in RoomOwnersInfo + lua.new_usertype("RoomwOwnerDetails", "layer", &RoomwOwnerDetails::layer, "room_index", &RoomwOwnerDetails::room_index, "owner_uid", &RoomwOwnerDetails::owner_uid); + lua.create_named_table("CAUSE_OF_DEATH", "DEATH", 0, "ENTITY", 1, "LONG_FALL", 2, "STILL_FALLING", 3, "MISSED", 4, "POISONED", 5); lua["toast_visible"] = []() -> bool diff --git a/src/game_api/state.hpp b/src/game_api/state.hpp index 4d1a34166..a0c24245b 100644 --- a/src/game_api/state.hpp +++ b/src/game_api/state.hpp @@ -265,6 +265,7 @@ struct StateMemory uint8_t unknown31a; // padding probably uint8_t unknown31b; uint8_t unknown31c; + /// Holds info about owned rooms and items (shops, challenge rooms, vault etc.) RoomOwnersInfo room_owners; /// Number of frames since the game was launched uint32_t time_startup; diff --git a/src/game_api/state_structs.hpp b/src/game_api/state_structs.hpp index 1380cf052..523b141c5 100644 --- a/src/game_api/state_structs.hpp +++ b/src/game_api/state_structs.hpp @@ -978,21 +978,21 @@ struct ItemOwnerDetails ENT_TYPE owner_type; }; -struct ShopOwnerDetails +struct RoomwOwnerDetails { uint8_t layer; uint8_t padding1; uint8_t padding2; uint8_t padding3; uint32_t room_index; - uint32_t shop_owner_uid; + int32_t owner_uid; }; struct RoomOwnersInfo { - // key is the uid of an item + /// key/index is the uid of an item custom_map owned_items; - std::vector room_owners; + std::vector owned_rooms; }; struct MultiLineTextRendering From 34c67567b60571e9d2ec815be202726903ee9544 Mon Sep 17 00:00:00 2001 From: Mr-Auto <36127424+Mr-Auto@users.noreply.github.com> Date: Wed, 27 Sep 2023 20:58:54 +0200 Subject: [PATCH 7/7] fix typo --- docs/game_data/spel2.lua | 4 ++-- docs/src/includes/_types.md | 18 +++++++++--------- src/game_api/script/usertypes/state_lua.cpp | 2 +- src/game_api/state_structs.hpp | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/game_data/spel2.lua b/docs/game_data/spel2.lua index 75f67da45..0b2d17dbf 100644 --- a/docs/game_data/spel2.lua +++ b/docs/game_data/spel2.lua @@ -2062,13 +2062,13 @@ do ---@class RoomOwnersInfo ---@field owned_items custom_map @key/index is the uid of an item - ---@field owned_rooms RoomwOwnerDetails[] + ---@field owned_rooms RoomOwnerDetails[] ---@class ItemOwnerDetails ---@field owner_type ENT_TYPE ---@field owner_uid integer ----@class RoomwOwnerDetails +---@class RoomOwnerDetails ---@field layer integer ---@field room_index integer ---@field owner_uid integer diff --git a/docs/src/includes/_types.md b/docs/src/includes/_types.md index 0a6c2d6a7..d724bef56 100644 --- a/docs/src/includes/_types.md +++ b/docs/src/includes/_types.md @@ -808,24 +808,24 @@ nil | [clear_virtual(CallbackId callback_id)](https://github.com/spelunky-fyi/ov [CallbackId](#Aliases) | [set_pre_render(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_pre_render) | Hooks before the virtual function.
The callback signature is `bool render(RenderInfo self, float float, VanillaRenderContext vanilla_render_context)` [CallbackId](#Aliases) | [set_post_render(function fun)](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=set_post_render) | Hooks after the virtual function.
The callback signature is `nil render(RenderInfo self, float float, VanillaRenderContext vanilla_render_context)` -### RoomOwnersInfo +### RoomOwnerDetails -Used in [StateMemory](#StateMemory) +Used in [RoomOwnersInfo](#RoomOwnersInfo) Type | Name | Description ---- | ---- | ----------- -custom_map<int, [ItemOwnerDetails](#ItemOwnerDetails)> | [owned_items](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owned_items) | key/index is the uid of an item -array<[RoomwOwnerDetails](#RoomwOwnerDetails)> | [owned_rooms](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owned_rooms) | +int | [layer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=layer) | +int | [room_index](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=room_index) | +int | [owner_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owner_uid) | -### RoomwOwnerDetails +### RoomOwnersInfo -Used in [RoomOwnersInfo](#RoomOwnersInfo) +Used in [StateMemory](#StateMemory) Type | Name | Description ---- | ---- | ----------- -int | [layer](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=layer) | -int | [room_index](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=room_index) | -int | [owner_uid](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owner_uid) | +custom_map<int, [ItemOwnerDetails](#ItemOwnerDetails)> | [owned_items](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owned_items) | key/index is the uid of an item +array<[RoomOwnerDetails](#RoomOwnerDetails)> | [owned_rooms](https://github.com/spelunky-fyi/overlunky/search?l=Lua&q=owned_rooms) | ### ShortTileCodeDef diff --git a/src/game_api/script/usertypes/state_lua.cpp b/src/game_api/script/usertypes/state_lua.cpp index f6f1fbedc..eec0989a4 100644 --- a/src/game_api/script/usertypes/state_lua.cpp +++ b/src/game_api/script/usertypes/state_lua.cpp @@ -562,7 +562,7 @@ void register_usertypes(sol::state& lua) lua.new_usertype("ItemOwnerDetails", "owner_type", &ItemOwnerDetails::owner_type, "owner_uid", &ItemOwnerDetails::owner_uid); /// Used in RoomOwnersInfo - lua.new_usertype("RoomwOwnerDetails", "layer", &RoomwOwnerDetails::layer, "room_index", &RoomwOwnerDetails::room_index, "owner_uid", &RoomwOwnerDetails::owner_uid); + lua.new_usertype("RoomOwnerDetails", "layer", &RoomOwnerDetails::layer, "room_index", &RoomOwnerDetails::room_index, "owner_uid", &RoomOwnerDetails::owner_uid); lua.create_named_table("CAUSE_OF_DEATH", "DEATH", 0, "ENTITY", 1, "LONG_FALL", 2, "STILL_FALLING", 3, "MISSED", 4, "POISONED", 5); diff --git a/src/game_api/state_structs.hpp b/src/game_api/state_structs.hpp index 93cf367ca..559448b64 100644 --- a/src/game_api/state_structs.hpp +++ b/src/game_api/state_structs.hpp @@ -979,7 +979,7 @@ struct ItemOwnerDetails ENT_TYPE owner_type; }; -struct RoomwOwnerDetails +struct RoomOwnerDetails { uint8_t layer; uint8_t padding1; @@ -993,7 +993,7 @@ struct RoomOwnersInfo { /// key/index is the uid of an item custom_map owned_items; - std::vector owned_rooms; + std::vector owned_rooms; }; struct MultiLineTextRendering