Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Anything to do with GTA1/GTA2 modding (tools, scripts and more).
User avatar
B-$hep
Immortal
Posts: 543
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: Estonia - Finland

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Post by B-$hep »

Does your decompiler decompiles WHILE_EXEC ENDWHILE commands?

Do you know what these means: S_PLUS_S, S_MINUS_I, i know they are operators but whats the I and S?
Integer and String?

I did my own small mini decompiler few months ago, just very small, yesterday i was in a mood to decompile WHILE_EXEC ENDWHILE commands but its not complete because of these S_MINUS_I etc things. But it was alot easier to write new one from scratch than integrate something into C++ code of yours. I did it in Delphi. It decompiles simple WHILE_EXEC ENDWHILE loops. Also "++" and "--" for correct variables.

I added other commands as needed for my small test scripts. I only focused atm on loops and IF_ENDIFs.
By writing my own code i know how all works and how i could make different things.

Again, i repeat: im focused on loops and IF_ENDIFs. Nothing fancy, so its small and clean. For very specific tasks only.

Must finish that before trying IF_ENDIF. Especially nested things.

WHILE_EXEC could be also nested?

I must understand whats the difference between the S and I

Edit!
For ex. my simple script:

Code: Select all

PLAYER_PED player = (49.5, 46.5, 1.0) 25 0


COUNTER loop = 321

LEVELSTART 
WHILE_EXEC ( loop< 5621 )
do_nowt
endwhile

LEVELEND
It used ID: 86 which is "S_LESS_I"
"loop" is string in his own way, but what difference it makes to miss2?
Its just variable.

I dont get it.

TM or anybody, do you have a complete list what kind of types and operators can be used to compare/add/ divide different things? Are they all documented correctly in dma docs?
Always wear safety glasses while programming.

User avatar
Sektor
Boss
Boss
Posts: 1387
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Post by Sektor »

S might be Signed Integer.

User avatar
B-$hep
Immortal
Posts: 543
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: Estonia - Finland

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Post by B-$hep »

That makes sense. Thanks.
Always wear safety glasses while programming.

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Post by T.M. »

Sektor wrote:S might be Signed Integer.
Not in this case.

Sint32 = Signed Integer (32 bits)
B-$hep wrote: It used ID: 86 which is "S_LESS_I"
"loop" is string in his own way, but what difference it makes to miss2?
Its just variable.

I dont get it.
Read the source dude... its all there. Just look at the functions... it cant be that hard.

S_EQUAL_I = String Equal Integer (= checks if variable value equals integer)
B-$hep wrote:TM or anybody, do you have a complete list what kind of types and operators can be used to compare/add/ divide different things? Are they all documented correctly in dma docs?
The complete list is in the source code of Epic GTA2 Script Decompiler.

DMA docs, dont trust them at all. I Went through them all, and corrected billions of incorrect information. The correct information is encoded into the sources, once again.

[mis]
// math functions: (note: S_MINUS_I wont compile!)
TWO_PARAMS_LAYOUT(S_PLUS_I, sprintf_str("%s + %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT(I_PLUS_S, sprintf_str("%d + %s", data.sintvar1, getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT(I_MINUS_S, sprintf_str("%d - %s", data.sintvar1, getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT(S_PLUS_S, sprintf_str("%s + %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT(S_MINUS_S, sprintf_str("%s - %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT(DECREMENT, sprintf_str("--%s", getname(data.var1).c_str()));
TWO_PARAMS_LAYOUT(INCREMENT, sprintf_str("++%s", getname(data.var1).c_str()));

FOUR_PARAMS_LAYOUT(S_IS_S_MINUS_I, sprintf_str("SET %s = (%s - %d)", getname(data.var1).c_str(), getname(data.var2).c_str(), data.sintvar3));
FOUR_PARAMS_LAYOUT(S_IS_S_PLUS_I, sprintf_str("SET %s = (%s + %d)", getname(data.var1).c_str(), getname(data.var2).c_str(), data.sintvar3));
FOUR_PARAMS_LAYOUT(S_IS_S_DIV_I, sprintf_str("SET %s = (%s / %d)", getname(data.var1).c_str(), getname(data.var2).c_str(), data.sintvar3));
FOUR_PARAMS_LAYOUT(S_IS_S_MULT_I, sprintf_str("SET %s = (%s * %d)", getname(data.var1).c_str(), getname(data.var2).c_str(), data.sintvar3));
FOUR_PARAMS_LAYOUT(S_IS_S_MOD_I, sprintf_str("SET %s = (%s MOD %d)", getname(data.var1).c_str(), getname(data.var2).c_str(), data.sintvar3));
FOUR_PARAMS_LAYOUT(S_IS_S_MINUS_S, sprintf_str("SET %s = (%s - %s)", getname(data.var1).c_str(), getname(data.var2).c_str(), getname(data.var3).c_str()));
FOUR_PARAMS_LAYOUT(S_IS_S_PLUS_S, sprintf_str("SET %s = (%s + %s)", getname(data.var1).c_str(), getname(data.var2).c_str(), getname(data.var3).c_str()));
FOUR_PARAMS_LAYOUT(S_IS_S_DIV_S, sprintf_str("SET %s = (%s / %s)", getname(data.var1).c_str(), getname(data.var2).c_str(), getname(data.var3).c_str()));
FOUR_PARAMS_LAYOUT(S_IS_S_MULT_S, sprintf_str("SET %s = (%s * %s)", getname(data.var1).c_str(), getname(data.var2).c_str(), getname(data.var3).c_str()));
FOUR_PARAMS_LAYOUT(S_IS_S_MOD_S, sprintf_str("SET %s = (%s MOD %s)", getname(data.var1).c_str(), getname(data.var2).c_str(), getname(data.var3).c_str()));

// boolean comparison functions with max 2 params:
TWO_PARAMS_LAYOUT_BOOL(S_EQUAL_I, sprintf_str("%s = %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT_BOOL(S_GEQUAL_I, sprintf_str("%s >= %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT_BOOL(S_GREATER_I, sprintf_str("%s > %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT_BOOL(S_LESS_I, sprintf_str("%s < %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT_BOOL(S_LEQUAL_I, sprintf_str("%s <= %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT_BOOL(S_EQUAL_S, sprintf_str("%s = %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT_BOOL(S_GEQUAL_S, sprintf_str("%s >= %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT_BOOL(S_GREATER_S, sprintf_str("%s > %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT_BOOL(S_LESS_S, sprintf_str("%s < %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT_BOOL(S_LEQUAL_S, sprintf_str("%s <= %s", getname(data.var1).c_str(), getname(data.var2).c_str()));[/mis]

How hard it really is, to figure out that %s means string and %d means integer? Note that "sintvar" means signed integer variable. Check sources for more information.

User avatar
Sektor
Boss
Boss
Posts: 1387
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Post by Sektor »

I tried compiling this in VS2013. I needed to add #include <functional> to get it to compile.

When I tried to use it in Epic Map Editor, I got "Error: File not found or cannot be read". Does the map editor use a different version of the decompiler or did VS2013 break something?

I mostly just want to enable SCR_debug_all_lines.

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Post by T.M. »

Sektor wrote:I tried compiling this in VS2013. I needed to add #include <functional> to get it to compile.

When I tried to use it in Epic Map Editor, I got "Error: File not found or cannot be read". Does the map editor use a different version of the decompiler or did VS2013 break something?

I mostly just want to enable SCR_debug_all_lines.
I think there is some problem with the way you compiled the DLL. Looking at my sources comments, my issue was:
// Note: To be able to use this as a DLL, you must set both projects to use the
// same setting: "Multi-threaded DLL (/MD)" or it will crash!

User avatar
Sektor
Boss
Boss
Posts: 1387
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Post by Sektor »

It was already set to that. It’s not crashing, it’s returning an error code when trying to read the SCR. Probably some IO works different on VS2013.

User avatar
T.M.
Immortal
Posts: 957
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Post by T.M. »

Sektor wrote:It was already set to that. It’s not crashing, it’s returning an error code when trying to read the SCR. Probably some IO works different on VS2013.
Ah i see. The file pointer is returning NULL. Seems like your SCR file does not have sufficient rights for reading, or your compiled DLL does not have those rights.

Post Reply