
The end of locked scripts
So, I am ready to announce that I have successfully built a .CTS decompiler (in C#, using the published Delphi code as a guide) that works on all versions of TWX from 2.03final to 2.05 (and the new 2.06 from Micro).
There are some kinks that I am working out around properly de-compiling and reassembling language structures (IF, WHILE, and the like) but it is 75% accurate to the original code and the parts that aren't are easily readable and fixed.
I will be releasing this to the community at some point soon, once the kinks are worked out and it's tested.
Why? Because this is a game that is dying in many ways, with only a handful of serious players left, and it's far past time that anything that could be useful to the community is released openly. I know of people using locked scripts from a decade ago because someone gave it to them, and it's a good script, and they wish they could edit it but they can't.
Also, because it was a fun and interesting project. Though I will not be upset if I never have to look at Delphi again.
I am sure this will result in some condemnation but hey, as a friend of mine recently pointed out, enough people already think i'm a supervillain that I can't make that any worse.
And now, for your enjoyment, some code from the start of EPHaggle that checks the date (which I used to block this part of the code - my decompiler also gives me all the commands, parameters, and labels and breaks them out in addition to the bytecode). This is direct output from the current version of the decompiler.
Code:
SETVAR $EOHHYP FALSE
SETVAR $LPHRPH FALSE
SYSTEMSCRIPT
SETVAR $VERSION 2018
MERGETEXT EP's Perfect Haggle, v. $VERSION $$1
SETVAR $SIGLINE $$1
:INCLUDESTART
GETWORD CURRENTLINE $YN 1
ISNOTEQUAL $$1 $YN Command
BRANCH $$1 ::1
ECHO "Script must be started from the Command prompt, HALTING."
HALT
::1
::2
SEND "ct"
SETTEXTLINETRIGGER AM :DATE AM
SETTEXTLINETRIGGER PM :DATE PM
PAUSE
:DATE
KILLTRIGGER AM
KILLTRIGGER PM
GETWORD CURRENTLINE $YEAR1 6
GETTIME $YEAR2 yyyy
GETSECTORPARAMETER 81 INVALID $ISINVALID
SEND "q"
SETTEXTTRIGGER WAITON1 :WAITON1 Command [TL=
PAUSE
:WAITON1
ISEQUAL $$1 $ISINVALID 1
BRANCH $$1 ::3
ECHO ANSI_12 "Contact ElderProphet via email, " ANSI_14 ElderProphet@comcast.net
HALT
GOTO ::4
::3
ISNOTEQUAL $$2 $YEAR1 2030
ISNOTEQUAL $$5 $YEAR1 2046
SETVAR $$1 $$2
AND $$1 $$5
BRANCH $$1 ::5
SETSECTORPARAMETER 81 INVALID 1
ECHO ANSI_12 "Contact ElderProphet via email," ANSI_14 ElderProphet@comcast.net
HALT
GOTO ::4
::5
ISNOTEQUAL $$1 $YEAR2 2018
BRANCH $$1 ::6
SETSECTORPARAMETER 81 INVALID 1
HALT
::6
::4
The parts that need to be fully restored for the code to compile should be pretty obvious.
Oh, and the fun parts (well some of it; I want to clean it up before I post it all):
Code:
SETPRECISION 0
SETVAR FUEL 25.5
SETVAR ORGANICS 50.5
SETVAR EQUIPMENT 90.5
SETVAR FUEL 0.25
SETVAR ORGANICS 0.5
SETVAR EQUIPMENT 0.9
SETVAR FUEL 40
SETVAR FUEL 90
SETVAR ORGANICS 30
SETVAR ORGANICS 75
SETVAR EQUIPMENT 20
SETVAR EQUIPMENT 65
ISEQUAL $$1 $PLANETSHIP PLANET
BRANCH $$1 ::77
SETVAR $PORPHT 0
SETVAR $ROLLHH 0
SETVAR $PLRYHH 0
SETARRAY $HHDYOR 0
SETVAR $EDDHPO 0
SETVAR $PELHOH 0
SETVAR $HLRHRT 0
GOTO ::78
::77
SETVAR $PORPHT -0.003
SETVAR $ROLLHH -0.003
SETVAR $PLRYHH 0.003
ISEQUAL $$1 $WEEKDAY Mon
BRANCH $$1 ::79
SETVAR $EDDHPO 0
SETVAR $PELHOH 5
GOTO ::80
::79
ISEQUAL $$1 $WEEKDAY Tue
BRANCH $$1 ::81
SETVAR $EDDHPO 7
SETVAR $PELHOH 7
GOTO ::80
::81
ISEQUAL $$1 $WEEKDAY Wed
BRANCH $$1 ::82
SETVAR $EDDHPO 10
SETVAR $PELHOH 15
GOTO ::80
::82
ISEQUAL $$1 $WEEKDAY Thu
BRANCH $$1 ::83
SETVAR $EDDHPO 9
SETVAR $PELHOH 9
GOTO ::80
::83
ISEQUAL $$1 $WEEKDAY Fri
BRANCH $$1 ::84
SETVAR $EDDHPO 11
SETVAR $PELHOH 12
GOTO ::80
::84
ISEQUAL $$1 $WEEKDAY Sat
BRANCH $$1 ::85
SETVAR $EDDHPO 11
SETVAR $PELHOH 18
GOTO ::80
::85
ISEQUAL $$1 $WEEKDAY Sun
BRANCH $$1 ::86
SETVAR $EDDHPO 10
SETVAR $PELHOH 12
GOTO ::80