Skip to content

Sendprop string fixes #1372

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

Merged
merged 2 commits into from
Oct 23, 2020
Merged

Sendprop string fixes #1372

merged 2 commits into from
Oct 23, 2020

Conversation

psychonic
Copy link
Member

@psychonic psychonic commented Oct 23, 2020

Stumbled across this on the forum, https://forums.alliedmods.net/showthread.php?t=327642.

I don't know what I'm doing wrong here but when I dump the netprops it says that "m_szCrosshairCodes" is a string but when I try to get it through sourcemod it doesn't work.

char szCrosshair[64];
    
GetEntPropString(GetPlayerResourceEntity(), Prop_Send, "m_szCrosshairCodes", szCrosshair, sizeof(szCrosshair), client);

PrintToServer("Crosshair Code: %s", szCrosshair); 

This is the error that happens:

L 10/01/2020 - 18:28:23: [SM] Exception reported: SendProp m_szCrosshairCodes is not a string (6 != 4)
L 10/01/2020 - 18:28:23: [SM] Blaming: bot_stuff.smx
L 10/01/2020 - 18:28:23: [SM] Call stack trace:
L 10/01/2020 - 18:28:23: [SM]   [0] GetEntPropString
L 10/01/2020 - 18:28:23: [SM]   [1] Line 6317, bot_stuff.sp::OnPlayerRunCmd

Reading SendProp strings (char *, not string_t) broke at some point, due to us not deref-ing enough. Support for string prop arrays was also missing because of not using our macros that handle that. Both fixed. Tested on CS:GO getting/setting m_szCrosshairCodes on the player resource entity, and m_szLastPlaceName on a player entity.

Copy link
Member

@asherkin asherkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@psychonic psychonic merged commit 18d93ff into master Oct 23, 2020
@Headline Headline deleted the sendprop-string-fixes branch October 27, 2020 22:23
asherkin added a commit that referenced this pull request Jul 17, 2021
When a netprop is an array the name resolves to the outer DataTable
array, which we then need to recurse into to find the actual prop.

For string_t props we need their sendprop info to call the proxy
function to get their real storage address, but when accessing an array
we were trying to read the prop off the outer DataTable prop, rather
than the real string_t prop. Fix this by using the pProp variable that
FIND_PROP_SEND helpfully provides for us.

Tested by writing/reading the `m_szCrosshairCodes` array, which got
changed to a string_t prop sometime since #1372.

Fixes #1484
asherkin added a commit that referenced this pull request Jul 18, 2021
When a netprop is an array the name resolves to the outer DataTable
array, which we then need to recurse into to find the actual prop.

For string_t props we need their sendprop info to call the proxy
function to get their real storage address, but when accessing an array
we were trying to read the prop off the outer DataTable prop, rather
than the real string_t prop. Fix this by using the pProp variable that
FIND_PROP_SEND helpfully provides for us.

Tested by writing/reading the `m_szCrosshairCodes` array, which got
changed to a string_t prop sometime since #1372.

Fixes #1484
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

Successfully merging this pull request may close these issues.

2 participants