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
TF2 run_command hook gives bad pointer as second argument when the player in question is a bot #140
Comments
What gets printed to the console when you execute the following? stack[1].type_info.dump() |
Segfault. Here's the debug.log: http://pastebin.com/pn9eY8re |
I'll try to see if I can reproduce this on DoD:S a little later. |
Well, the debug.log still mentions from entities.hooks import EntityCondition, EntityPreHook
@EntityPreHook(EntityCondition.is_player, "run_command")
def hook(stack):
stack[1].type_info.dump() |
This was all I had:
|
The log says something different: |
I've done it three times now (each time I've removed the pycache, guaranteed that no other plugins were loaded, etc.) and that's what the stacktrace looks like. Maybe |
No, it doesn't call it. In the log file there is also this line:
Did you notice the |
I added a print statement before the |
Then please upload the new debug.log. It's impossible to get this output with the snippet I gave you. |
CRASH: Thu Jul 14 11:15:12 PDT 2016 → That debug.log is about 2 hours old. Delete the file, and try again. |
That 2 hour old log was the first log I got when I ran the snippet plugin. All the other logs I got had identical stacktraces, but for some reason when I deleted the |
L'In20Cible and I came to the conclusion that the passed pointer doesn't has RTTI data. This snippet will work around that issue. ucmd_size = memory.get_size(UserCmd)
@EntityPreHook(EntityCondition.is_player, "run_command")
def hook(stack):
ucmd = UserCmd()
ucmd_ptr = memory.get_object_pointer(ucmd)
orig_ucmd_ptr = stack[1]
orig_ucmd_ptr.copy(ucmd_ptr, ucmd_size)
# You have now read-only access to the user command. Writing any attribute
# has no effect as it doesn't modify the original user command.
print(ucmd.buttons)
# If you want to modify the user command, you need to copy back your work
ucmd_ptr.copy(orig_ucmd_ptr, ucmd_size) |
Does this workaround work for you, @quartata? |
Yes, it works fine. Thanks. |
Thanks for confirming! I guess we can close this issue now, since it is not directly related to Source.Python. |
Original thread: http://forums.sourcepython.com/viewtopic.php?f=20&t=1257
Title says it all. Not certain what pointer is getting passed, but it's not pointing to an instance of
CUserCmd
nor to an instance ofCBotCmd
. To reproduce, make a new plugin with this code:and add a bot with
sv_cheats 1; bot
. Currently only been reproduced on TF2 with Linux, other games/platforms may be affected. NextBots (added withtf_bot_add
) do not seem to have any problems.The text was updated successfully, but these errors were encountered: