Skip to content

Commit

Permalink
Update for new ApiVersion 2022-03-21
Browse files Browse the repository at this point in the history
You can still use the old ApiVersion 2013-04-16 by setting it inside the

base.py in settings folder by adding the following line:

`DEDICATED = {
	'default': {
		'HOST': '127.0.0.1',
		'PORT': '5008',
		'USER': 'SuperAdmin',
		'PASSWORD': 'SuperAdmin',
		'APIVERSION': '2013-04-16', #2013-04-16 Old APIVERSION for MP. #2022-03-21 New APIVERSION for TM2020
	}
}`
  • Loading branch information
w1lla committed Jun 1, 2022
1 parent a85e1cf commit 78baec5
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions pyplanet/core/gbx/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class GbxRemote:
MAX_REQUEST_SIZE = 2000000 # 2MB
MAX_RESPONSE_SIZE = 4000000 # 4MB

def __init__(self, host, port, event_pool=None, user=None, password=None, api_version='2013-04-16', instance=None):
def __init__(self, host, port, event_pool=None, user=None, password=None, api_version=None, instance=None):
"""
Initiate the GbxRemote client.
Expand Down Expand Up @@ -78,7 +78,7 @@ def create_from_settings(cls, instance, conf):
"""
return cls(
instance=instance,
host=conf['HOST'], port=conf['PORT'], user=conf['USER'], password=conf['PASSWORD']
host=conf['HOST'], port=conf['PORT'], user=conf['USER'], password=conf['PASSWORD'], api_version=conf['APIVERSION']
)

def get_next_handler(self):
Expand Down Expand Up @@ -149,8 +149,24 @@ async def connect(self):
exit(50)

# Check for scripted mode.
mode = await self.execute('GetGameMode')
settings = await self.execute('GetModeScriptSettings')
if self.dedicated_build == '2022-05-04_19_08' and self.api_version == '2022-03-21':
getCurrentGameInfos = await self.execute('GetCurrentGameInfo')
mode = getCurrentGameInfos['GameMode']
settings = await self.execute('GetModeScriptSettings')
if mode == 0:
if 'S_UseScriptCallbacks' in settings:
settings['S_UseScriptCallbacks'] = True
if 'S_UseLegacyCallback' in settings:
settings['S_UseLegacyCallback'] = False
if 'S_UseLegacyXmlRpcCallbacks' in settings:
settings['S_UseLegacyXmlRpcCallbacks'] = False
await asyncio.gather(
self.execute('SetModeScriptSettings', settings),
self.execute('TriggerModeScriptEventArray', 'XmlRpc.EnableCallbacks', ['true']),
)
else:
mode = await self.execute('GetGameMode')
settings = await self.execute('GetModeScriptSettings')
if mode == 0:
if 'S_UseScriptCallbacks' in settings:
settings['S_UseScriptCallbacks'] = True
Expand All @@ -160,7 +176,7 @@ async def connect(self):
settings['S_UseLegacyXmlRpcCallbacks'] = False
await asyncio.gather(
self.execute('SetModeScriptSettings', settings),
self.execute('TriggerModeScriptEventArray', 'XmlRpc.EnableCallbacks', ['true'])
self.execute('TriggerModeScriptEventArray', 'XmlRpc.EnableCallbacks', ['true']),
)

logger.debug('Dedicated authenticated, API version set and callbacks enabled!')
Expand Down

0 comments on commit 78baec5

Please sign in to comment.