GetDataTableProxyFn?

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
quartata
Member
Posts: 77
Joined: Wed Jun 22, 2016 11:49 pm

GetDataTableProxyFn?

Postby quartata » Tue May 22, 2018 5:58 pm

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.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: GetDataTableProxyFn?

Postby Ayuto » Tue May 22, 2018 7:41 pm

The next version will contain GetDataTableProxyFn:
https://github.com/Source-Python-Dev-Te ... e50ab23a1d
User avatar
quartata
Member
Posts: 77
Joined: Wed Jun 22, 2016 11:49 pm

Re: GetDataTableProxyFn?

Postby quartata » Tue May 22, 2018 7:57 pm

Oh that was quick. Thanks!
User avatar
quartata
Member
Posts: 77
Joined: Wed Jun 22, 2016 11:49 pm

Re: GetDataTableProxyFn?

Postby quartata » Tue May 22, 2018 9:24 pm

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.
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: GetDataTableProxyFn?

Postby Ayuto » Tue May 22, 2018 10:00 pm

User avatar
quartata
Member
Posts: 77
Joined: Wed Jun 22, 2016 11:49 pm

Re: GetDataTableProxyFn?

Postby quartata » Wed May 23, 2018 12:36 am

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>'
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: GetDataTableProxyFn?

Postby Ayuto » Wed May 23, 2018 5:48 am

Sorry, now it's working:
https://github.com/Source-Python-Dev-Te ... 89460d4eaa

Syntax: 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
User avatar
quartata
Member
Posts: 77
Joined: Wed Jun 22, 2016 11:49 pm

Re: GetDataTableProxyFn?

Postby quartata » Wed May 23, 2018 1:34 pm

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)
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: GetDataTableProxyFn?

Postby Ayuto » Wed May 23, 2018 6:19 pm

Thank you too! I didn't know about that way before. :smile:
User avatar
quartata
Member
Posts: 77
Joined: Wed Jun 22, 2016 11:49 pm

Re: GetDataTableProxyFn?

Postby quartata » Thu May 24, 2018 2:49 am

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=6

This 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)

Return to “Plugin Development Support”

Who is online

Users browsing this forum: Bing [Bot] and 25 guests