Page 1 of 1
GetDataTableProxyFn?
Posted: Tue May 22, 2018 5:58 pm
by quartata
I was trying to get the proxy function for a datatable (tf_gamerules_data in this case):
Syntax: Select all
gamerules_proxy = entities.entity.BaseEntity.find("tf_gamerules")
gamerules = None
for prop in gamerules_proxy.server_class.table:
if prop.name == "tf_gamerules_data":
gamerules = prop.proxy_function(None, None, None, None, 0)
break
However, I was greeted with this:
Code: Select all
TypeError: tf_gamerules_data is a DataTable.
I dug through the code and found it came from here:
https://github.com/Source-Python-Dev-Te ... s.cpp#L139, which just calls GetProxyFn directly (so the assertion did the right thing, that wouldn’t have worked). What I could not find was a wrapper for GetDataTableProxyFn, which is what I need. Is there one?
Thanks.
Re: GetDataTableProxyFn?
Posted: Tue May 22, 2018 7:41 pm
by Ayuto
Re: GetDataTableProxyFn?
Posted: Tue May 22, 2018 7:57 pm
by quartata
Oh that was quick. Thanks!
Re: GetDataTableProxyFn?
Posted: Tue May 22, 2018 9:24 pm
by quartata
I don't think this quite works yet:
Code: Select all
TypeError: No to_python (by-value) converter found for C++ type: boost::function<void* (SendProp const*, void const*, void const*, CSendProxyRecipients*, int)>
I thought at first this was because I invoked it wrong, but it happens when accessing data_table_proxy_function.
Re: GetDataTableProxyFn?
Posted: Tue May 22, 2018 10:00 pm
by Ayuto
Re: GetDataTableProxyFn?
Posted: Wed May 23, 2018 12:36 am
by quartata
Heh, build failed with a template error. Fun stuff :P
Code: Select all
error C2027: use of undefined type 'boost::python::detail::specify_a_return_value_policy_to_wrap_functions_returning<T>'
Re: GetDataTableProxyFn?
Posted: Wed May 23, 2018 5:48 am
by Ayuto
Sorry, now it's working:
https://github.com/Source-Python-Dev-Te ... 89460d4eaaSyntax: Select all
from entities.entity import BaseEntity
gamerules_proxy = BaseEntity.find("cs_gamerules")
gamerules = None
for prop in gamerules_proxy.server_class.table:
if prop.name == "cs_gamerules_data":
gamerules = prop.data_table_proxy_function(None, None, None, None, 0)
break
gamerules.type_info.dump()
Code: Select all
CCSGameRules
-CTeamplayRules
--CMultiplayRules
---CGameRules
----CAutoGameSystemPerFrame
-----CBaseGameSystemPerFrame
------IGameSystemPerFrame
-------IGameSystem
Re: GetDataTableProxyFn?
Posted: Wed May 23, 2018 1:34 pm
by quartata
Awesome, thanks! (Incidentally it's cool to see that you can get the real g_pGameRules from the proxy like that in CS too. So much easier than scanning for CreateGameRulesObject and getting the pointer from there like I've seen people doing)
Re: GetDataTableProxyFn?
Posted: Wed May 23, 2018 6:19 pm
by Ayuto
Thank you too! I didn't know about that way before.

Re: GetDataTableProxyFn?
Posted: Thu May 24, 2018 2:49 am
by quartata
I can't really take credit for it, I found it in a very old AlliedModders thread and wanted to try it:
https://forums.alliedmods.net/showpost.php?p=858244&postcount=6This is the relevant SendProxy:
https://github.com/NicknineTheEagle/TF2-Base/blob/master/src/game/shared/tf/tf_gamerules.cpp#L192 The SDK and HL2DM gamerules have one just like it too. I'm not *entirely* sure why it's OK with pRecipients being null but hey whatever. (As far as I can tell that class is just an int anyways :P)