www.ClassicTW.com
http://classictw.com/

Decompiled Sysop Scripts
http://classictw.com/viewtopic.php?f=15&t=35462
Page 1 of 1

Author:  Shadow [ Wed Feb 06, 2019 11:58 pm ]
Post subject:  Decompiled Sysop Scripts

Since we're past Christmas now, Happy Valentine's Day!

I haven't actually tested these yet, but pretty sure they'll work just fine. If there are any problems, let me know.

This pack includes So_MakeAnsi for both v1 and v2.

Edit: Added the random planet maker script as well.

Attachments:
SO_Random_Planet_Maker.ts [75.23 KiB]
Downloaded 624 times
Sysop.zip [506.83 KiB]
Downloaded 636 times

Author:  Vid Kid [ Thu Feb 07, 2019 8:30 am ]
Post subject:  Re: Decompiled Sysop Scripts

Shadow wrote:
Since we're past Christmas now, Happy Valentine's Day!

I haven't actually tested these yet, but pretty sure they'll work just fine. If there are any problems, let me know.

This pack includes So_MakeAnsi for both v1 and v2.

Edit: Added the random planet maker script as well.


Thank you for honoring me with your first tests of your decompiler on my scripts
I have downloaded them and will let you know if it did a good enough job.
I look forward to the possibility of its release.

You have saved me the time to test it against something I have source for
to see how it does .. now I can let everyone know how close you came to nailing it.

I hope its real close , this is something that has been wanted by many players whom dislike compiled scripts.
Plus it will save a lot of time for authors , now YOU can fix their scripts .. hahaha

Good job , now let me go look into the ones you posted..

Vid

Author:  Vid Kid [ Thu Feb 07, 2019 8:54 am ]
Post subject:  Re: Decompiled Sysop Scripts

Ok , looked through the 0_login script .. for those whom have my .cts
Same version that you can have as .ts here ...

Please try the .ts one out and let me know if it works the same.
I have found (in the first few hundred lines)
a couple waiton commands made into settexttriggers
and a bunch of killtriggers with " around them (may cause errors)
as well as if statements changed IF ($var = "1") to IF ($Var = 1)
which WILL be problematic at the end results.

I will continue on reading/comparing original to this decompile.
I cant wait to get to the includes to see that also.

I did notice that any comments were removed and most word placements were
removed.. making reading a bit harder for me , but aesthetically ok in script running.

So far good job .. hope the .ts runs right.
I'll be back to post more in a bit .. for those following.

Vid

Author:  Vid Kid [ Thu Feb 07, 2019 9:24 am ]
Post subject:  Re: Decompiled Sysop Scripts

Aside from the before mention things I found , the includes contain many of the same problems but may still work .. someone please test .. I dont want to
chance it since I would have to rename mine and further confuse myself in
debugging.

Looks good for the most part , and thank you for sharing my scripts .. this one script that I spent many years in perfecting for all types of servers and mods
will help many people learn many advanced ways to overcome obstacles
a server can throw at you.

I'm sure there are many parts that can be added to mombot to get its login script up to par.
But the 0_login has the ability to launch your BOT script if you fill out the
Globals.cfg correctly.

Anyways , I'm done ranting and fact finding on this .. as a whole .. Good job Shadow
Your decompiler seems to work , at least to get inside the script to rip parts
and bypass security for the most part.

I look forward to your release so we all can use it.
And not just on my scripts .. lol j/k

Vid

Author:  Shadow [ Thu Feb 07, 2019 10:17 am ]
Post subject:  Re: Decompiled Sysop Scripts

Vid Kid wrote:
Ok , looked through the 0_login script .. for those whom have my .cts
Same version that you can have as .ts here ...

Please try the .ts one out and let me know if it works the same.
I have found (in the first few hundred lines)
a couple waiton commands made into settexttriggers
and a bunch of killtriggers with " around them (may cause errors)
as well as if statements changed IF ($var = "1") to IF ($Var = 1)
which WILL be problematic at the end results.

I will continue on reading/comparing original to this decompile.
I cant wait to get to the includes to see that also.

I did notice that any comments were removed and most word placements were
removed.. making reading a bit harder for me , but aesthetically ok in script running.

So far good job .. hope the .ts runs right.
I'll be back to post more in a bit .. for those following.

Vid


Hi Vid,

A couple of points here.

None of this is documented, so everything I did was based on reading the released twx source code and reverse engineering it. There were many bugs in my earlier iterations of this based on unexpected behavior by the compiler. I have fixed most of them.

When you compile a .CTS to .TS, it is actually compiling it into bytecode - meaning that it breaks down the statements (setvar, send, etc) and turns them into individual bytes that refer to what each statement does. It then has a structure where the bytes following reference each of the parameters (variables, constants, etc) used by the command, and it separately adds all the text strings, encrypted, to the end of the file, along with the labels (unencrypted).

The compiler throws away all comments, so the .CTS doesn't contain any of the comments in the original code. Those are impossible to reproduce.

When you actually load a .TS into TWX, it compiles it exactly as it would if you ran TWXC on it, and then executes the compiled code. So the only difference in performance between loading a .CTS or a .TS is that the startup time to load the script is slightly slower with a .TS (because it has to compile it to run it).

Anyway, back to what's changed/missing. The compiler converts all if/then/else and while statements to "BRANCH" statements. These are in the twx documentation describing what they do as a compiler internal statement (but can actually be used in scripts directly). So, an if statement like:

if ($1 = foo)
setvar $1 bar
end

Turns into:

BRANCH :22 $1 = foo
setvar $1 bar
:22

If/then/else are more complicated:

if ($1 = foo)
setvar $1 bar
else if ($1 = bar)
setvar $1 foo
else if ($1 = bob)
setvar $1 foo
end

Becomes:

BRANCH :23 $1 = foo
setvar $1 bar
goto :22
:23
BRANCH :24 $1 = bar
setvar $1 foo
goto :22
:24
BRANCH :22 $1 = bob
setvar $1 foo
:22

While statements are similarly changed into BRANCH and GOTO. This is reflected in the output of my decompiler. I may go back and clean it up, but it's difficult work, and the code generated runs just fine.

re waiton - the compiler converts this directly:

waiton "foo"

to:

settexttrigger WAITON1 :28 "foo"
:WAITON1

Meaning, if you put a "waiton" in your code, it is automatically converted to a trigger by the compiler. So it's no difference from using a trigger.

Waitfor is different - it is a separate function and ignores all other triggers. Waiton can be interrupted by other triggers because it's a trigger itself.

I suspect waitfor is faster, based on how the compiler handles it.

More on this later - I plan to document all of this for anyone who wants to work on this in the future.

I am happy to discuss with you sometime if you'd like.

I would love for you to look at the other scripts and provide any feedback you have so I can make the decompiler better. It's over 2000 lines of c# code already. I do plan to release it once I am sure I have dealt with all the edge cases.

Author:  tex. [ Tue Mar 12, 2019 2:46 pm ]
Post subject:  Re: Decompiled Sysop Scripts

Just going to slide in the conversation here.

How do I compile a .ts file that I have.....I see the file TWXC and thought that was it but it doesn't work. I know it compiles it when it runs, but how do I save that .CTS file??

Author:  Vid Kid [ Wed Apr 17, 2019 10:34 am ]
Post subject:  Re: Decompiled Sysop Scripts

tex. wrote:
Just going to slide in the conversation here.

How do I compile a .ts file that I have.....I see the file TWXC and thought that was it but it doesn't work. I know it compiles it when it runs, but how do I save that .CTS file??


The quickest way is to drag & drop your .ts to the TWXC.exe icon.

Or copy the TWXC.exe to your scripts directory and work there.

This one is a bit harder and requires some editing.
Attachment:
File comment: Written by Archy
for ALL to use.

compile.zip [1.27 KiB]
Downloaded 617 times

Now rename it to compile.CMD
Put it in your scripts directory with a copy of the TWXC.EXE
and edit 2 lines :
set TW_TWXCPATH=c:\unzipped\TWX_204_RC\scripts <-- this one.
is my twx/scripts location - change to reflect your location.

echo # Vid Compiled: %DATE% - %TIME%>>%TW_FILENAME%%TW_FILEEXT% <--- this is two.
change Vid if you like to whatever you like (its added at end of compile).

After you do all this and SAVE , make a shortcut for your desktop to
launch this CMD anytime your ready to past script name and compile.

Archy made many CMD files for doing quick jobs for US tradewars players
and OPs.

Vid

Author:  Kaus [ Mon Apr 22, 2019 6:43 pm ]
Post subject:  Re: Decompiled Sysop Scripts

Why would you not just capture outbound commands via the proxy already established. I would think that "reversing" those commands would be easier with some variance due to waitfors which would be somewhat obvious given the timing of the scripts.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/