gametechmods

Robot Arena => Modifications => Topic started by: apanx on September 29, 2016, 10:18:31 AM

Title: plus.isDebugMode()
Post by: apanx on September 29, 2016, 10:18:31 AM
So, when is it true?
Title: Re: plus.isDebugMode()
Post by: Trovaner on October 02, 2016, 02:20:04 PM
I'm pretty sure it is always false. The devs probably have a boolean in the EXE that they manually set during development. You may be able to enable it using sergepatcher. I usually just create my own boolean for turning on the debug code.
Title: Re: plus.isDebugMode()
Post by: Badger on October 02, 2016, 03:36:53 PM
well there goes trov's quarterly post.
Title: Re: plus.isDebugMode()
Post by: Serge on October 06, 2016, 09:15:49 PM
So, when is it true?

Never. It will always return None.

Code: [Select]
.text:004BC585                 push    offset aIsdebugmode ; "isDebugMode"
.text:004BC58A                 push    offset py_isDebugMode
.text:004BC58F                 mov     ecx, esi
.text:004BC591                 call    sub_4BDF80

[...]

.text:004B9BF0 py_isDebugMode  proc near               ; CODE XREF: sub_57C000+9Cp
.text:004B9BF0                                         ; DATA XREF: sub_4BBA00+B8Ao ...
.text:004B9BF0                 xor     al, al
.text:004B9BF2                 retn
.text:004B9BF2 py_isDebugMode  endp
Title: Re: plus.isDebugMode()
Post by: apanx on October 10, 2016, 01:43:53 PM
Thanks Serge

Patched it statically to
Code: [Select]
.text:004B9BF0                 or     al, alNow it returns true

Big meh, just crashes the game when trying to play. I suppose it needs extra coding from debug-build to work properly.
https://gametechmods.com/forums/index.php?action=downloads;sa=view;down=288

OffTopic: Also patched in 16-point chassis limit removal statically based on offsets in SergePatcher, can put it up on GTM for you.
Title: Re: plus.isDebugMode()
Post by: Serge on October 11, 2016, 02:26:40 PM
Thanks Serge

Patched it statically to
Code: [Select]
.text:004B9BF0                 or     al, alNow it returns true

Big meh, just crashes the game when trying to play. I suppose it needs extra coding from debug-build to work properly.
https://gametechmods.com/forums/index.php?action=downloads;sa=view;down=288

OffTopic: Also patched in 16-point chassis limit removal statically based on offsets in SergePatcher, can put it up on GTM for you.

The reason it doesn't work is because this function returns a PyObject *, so it should return the global Py_True or another truthy object. Returning a C NULL for None only works because of the way the C API parses a NULL that way. Everything else (including an 0x00000001-FF) will get parsed as a PyObject*, so in the case of an invalid pointer (like 0x1) will crash on dereferencing.