AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Call_Void_ItemInfo (https://forums.alliedmods.net/showthread.php?t=299769)

PartialCloning 07-25-2017 08:57

Call_Void_ItemInfo
 
Is Call_Void_ItemInfo called when using RegisterHam(Ham_Item_GetItemInfo, "weapon_" "Function")?

Code:
cell Call_Void_ItemInfo(AMX *amx, cell *params) {     SETUP(1);     void *ptr=reinterpret_cast<void *>(*MF_GetAmxAddr(amx, params[3]));     if (ptr==0)     {         MF_LogError(amx, AMX_ERR_NATIVE, "Null ItemInfo handle!");         return 0;     } #if defined(_WIN32)     reinterpret_cast<void (__fastcall *)(void*, int, void *)>(__func)(pv, 0, ptr); #elif defined(__linux__) || defined(__APPLE__)     reinterpret_cast<void (*)(void *, void *)>(__func)(pv, ptr); #endif     return 1; }

Ham_Item_GetItemInfo "breaks" any weapon it's hooked for on linux. I'm trying to find out why it does that.

I have read that it's not actually legal to mix reinterpret_cast<> with pointers to void. If Call_Void_ItemInfo is called by RegisterHam, could the bug be caused by the reinterpret_cast? It works on windows OS, but not on linux.

Arkshine 07-25-2017 09:00

Re: Call_Void_ItemInfo
 
No, it's used with ExecuteHam.

What you're looking for is "void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo)" in hook_callback.cpp, but the handler looks okay.

PartialCloning 07-25-2017 12:21

Re: Call_Void_ItemInfo
 
All the other void variables (void *other or void *cb1 ..etc) use:
Code:
P_CBASE(__PARAM, __INDEX)   __vec->append(new Data(RET_CBASE, (void *) & (__PARAM), reinterpret_cast<int *>(& (__INDEX))));

Where as iteminfo (void *iteminfo) uses:
Code:
P_ITEMINFO(__PARAM)         __vec->append(new Data(RET_ITEMINFO, (void *) & (__PARAM)));

Does P_ITEMINFO not need a reinterpret_cast?


All times are GMT -4. The time now is 22:44.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.