Raised This Month: $51 Target: $400
 12% 

Call_Void_ItemInfo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PartialCloning
Senior Member
Join Date: Dec 2015
Old 07-25-2017 , 08:57   Call_Void_ItemInfo
Reply With Quote #1

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.
PartialCloning is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-25-2017 , 09:00   Re: Call_Void_ItemInfo
Reply With Quote #2

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.
__________________

Last edited by Arkshine; 07-25-2017 at 09:05.
Arkshine is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 07-25-2017 , 12:21   Re: Call_Void_ItemInfo
Reply With Quote #3

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?
PartialCloning is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:32.


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