Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash - Ham_Item_GetWeaponPtr #754

Open
DarthMan opened this issue Sep 5, 2019 · 8 comments
Open

Crash - Ham_Item_GetWeaponPtr #754

DarthMan opened this issue Sep 5, 2019 · 8 comments

Comments

@DarthMan
Copy link

DarthMan commented Sep 5, 2019

Hello. I have not tested in other Half-Life One engine based games, but on the internet computer game Team Fortress Classic the HAM forward Ham_Item_GetWeaponPtr crashes the server whenever being used on a valid entity edict. So if I do something like if(ExecuteHam(Ham_Item_GetWeaponPtr, iEnt) != FM_NULLENT) where iEnt is a valid entity edict that exists on the map I am getting a nice crash with no errors on Windows, but segmentation fault on Linux. The forward is supposed to return minus one if the given entity is not a weapon, the correct entity identifier otherwise.

@Arkshine
Copy link
Member

Can you please provide a simple test plugin and how to reproduce the crash?

Also, please try again, and before, update to the latest AMXX version, whatever 1.9 or master.
Do the same for the game as well. Just to make sure.

@DarthMan
Copy link
Author

DarthMan commented Oct 17, 2019

Sure, I'll make a test example. But my guess is that it crashes simply because it's checking if an entity that's actually not an item is a weapon. So more like if being called on classes such as info_target it would crash, whereas with classes such as item_ it will return -1 and weapon_ the weapon entity id.

@DarthMan
Copy link
Author

DarthMan commented Oct 17, 2019

Here I'm attaching a test plug-in. Also, can you update the gamedata files for TFC and the other goldsrc games excluding CS 1.6? It seems that a new memebr was added to CbaseMonster so some pdata offsets are no longer valid.

In this example it is suposed to check if the player is a weapon, but, rather than crashing, still return -1 even if it's not part of CBasePlayerItem/Weapon. But it crashes instead. Test it on TFC. I am using latest AMXX v1.10 dev build.

#include <hamsandwich>

public plugin_init()
{
    register_clcmd("say /weapontest", "OnWeaponTest");
}

public OnWeaponTest(const iID)
{
    client_print(iID, print_chat, "Is the player a weapon ? Answer: %d", ExecuteHam(Ham_Item_GetWeaponPtr, iID));
}

@DarthMan
Copy link
Author

Also, take a look here: ValveSoftware/halflife#2458

m_flLastYawTime or whatever is the new member that was added.

@Arkshine
Copy link
Member

Please keep content related only to the actual issue. I've already created one in #765.

@DarthMan

This comment has been minimized.

@DarthMan
Copy link
Author

Have you tested the attached plug-in? Does it crash the server? My intention was to use it on my EntMod when searching for entities to tell if an entity is a weapon, then get it's owner, if ti equals the player, skip it. That's because I sue a special technique for the ent to grab entities with solidity <= SOLID_TRIGGER. So that's what I was tyring to use the function for. I was hoping that it would return -1, but it crashed the server.

@Arkshine
Copy link
Member

Arkshine commented Oct 29, 2019

I can reproduce the crash under windows. Basically, the function from the game returns 0x0000001. The value is not null but is not a valid pointer. That's why, it passes the check and crash at some point. Not sure why though.

@WPMGPRoSToTeMa any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants