hlmod / Shop-Core

Documentation
https://hlmod.github.io/Shop-Core/module/create/
GNU General Public License v3.0
28 stars 26 forks source link

Bug. Push invalid Handle on native Shop_KvCopySubKeysItemCustomInfo() #120

Closed IL0co closed 2 years ago

IL0co commented 2 years ago

Bug problem:

[SM] Plugin [Shop] Core reloaded successfully.
sm plugins reload shop;sm plugins load shop;
L 03/29/2022 - 19:00:40: [SM] Exception reported: Invalid key value handle 0 (error 4)
L 03/29/2022 - 19:00:40: [SM] Blaming: shop.smx
L 03/29/2022 - 19:00:40: [SM] Call stack trace:
L 03/29/2022 - 19:00:40: [SM]   [0] KeyValues.GetNum
L 03/29/2022 - 19:00:40: [SM]   [1] Line 779, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/item_manager.sp::ItemManager_KvCopySubKeysItemCustomInfo
L 03/29/2022 - 19:00:40: [SM]   [3] Shop_KvCopySubKeysItemCustomInfo
L 03/29/2022 - 19:00:40: [SM]   [4] Line 29, d:\scripting\shop_bug.sp::CallBack_OnItemRegistered
L 03/29/2022 - 19:00:40: [SM]   [6] Call_Finish
L 03/29/2022 - 19:00:40: [SM]   [7] Line 717, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/item_manager.sp::ItemManager_OnItemRegistered
L 03/29/2022 - 19:00:40: [SM]   [9] Database.Query
L 03/29/2022 - 19:00:40: [SM]   [10] Line 533, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/db.sp::DB_TQuery
L 03/29/2022 - 19:00:40: [SM]   [11] Line 2048, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop.sp::TQuery
L 03/29/2022 - 19:00:40: [SM]   [12] Line 599, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/item_manager.sp::ItemManager_EndItem
L 03/29/2022 - 19:00:40: [SM]   [14] Shop_EndItem
L 03/29/2022 - 19:00:40: [SM]   [15] Line 22, d:\scripting\shop_bug.sp::Shop_Started
L 03/29/2022 - 19:00:40: [SM]   [17] Call_Finish
L 03/29/2022 - 19:00:40: [SM]   [18] Line 324, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/forwards.sp::Forward_NotifyShopLoaded
L 03/29/2022 - 19:00:40: [SM]   [19] Line 390, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop.sp::OnReadyToStart
L 03/29/2022 - 19:00:40: [SM]   [20] Line 495, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/db.sp::DB_OnPlayersTableLoad
L 03/29/2022 - 19:00:40: [SM]   [22] Database.Query
L 03/29/2022 - 19:00:40: [SM]   [23] Line 533, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/db.sp::DB_TQuery
L 03/29/2022 - 19:00:40: [SM]   [24] Line 461, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/db.sp::DB_CreateTables
L 03/29/2022 - 19:00:40: [SM]   [25] Line 338, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/db.sp::DB_CheckTable
L 03/29/2022 - 19:00:40: [SM]   [27] Database.Query
L 03/29/2022 - 19:00:40: [SM]   [28] Line 533, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/db.sp::DB_TQuery
L 03/29/2022 - 19:00:40: [SM]   [29] Line 283, d:\@me\mygithub\Shop-Core\addons\sourcemod\scripting\shop/db.sp::DB_Connect
[Shop] Trying to connect!
[SM] Plugin [Shop] Core reloaded successfully.
Bug Launcher Plugin ```cpp #include #pragma newdecls required public void OnPluginEnd() { Shop_UnregisterMe(); } public void OnPluginStart() { if(Shop_IsStarted()) { Shop_Started(); } } public void Shop_Started() { CategoryId category = Shop_RegisterCategory("test_bug", "Test bug", ""); if(Shop_StartItem(category, "test_item")) { Shop_SetInfo("Test item", "", 500, 400, Item_Finite); Shop_SetCallbacks(CallBack_OnItemRegistered, CallBack_OnItemUse); Shop_EndItem(); } } public void CallBack_OnItemRegistered(CategoryId category_id, const char[] category, const char[] item, ItemId item_id) { KeyValues kv; Shop_KvCopySubKeysItemCustomInfo(item_id, kv); } public ShopAction CallBack_OnItemUse(int client, CategoryId category_id, const char[] category, ItemId item_id, const char[] item) { } ```
IL0co commented 2 years ago

@R1KO I have a question why get this? https://github.com/FD-Forks/Shop-Core/blob/8410e6a88a52f2dd5bb5fc46c756f18518d243c1/addons/sourcemod/scripting/shop/item_manager.sp#L778

R1KO commented 2 years ago

@R1KO I have a question why get this?

https://github.com/FD-Forks/Shop-Core/blob/8410e6a88a52f2dd5bb5fc46c756f18518d243c1/addons/sourcemod/scripting/shop/item_manager.sp#L778

i think it checks that the handle is really kv