New GTA2 Script Compiler

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

New GTA2 Script Compiler

Post by B-$hep »

Hi.

I want you to show the new GTA2 Script Compiler that me and T.M working on currently.
Im very thankful to you T.M for your invaluable help and support and sources.

It is very simple atm but it compiles, checks for errors, etc and generates valid .scr file.

I have attached the 7zip, it has pretty good ReadMe.txt included.
Please read it, before asking or using.

Please test it, try to find bugs etc...
Any feedback on this is welcome.


Very short text, but it's 5:30 AM here, and i must go to sleep now.
See ya guys.
Last edited by B-$hep on 21 Dec 2015, 13:56, edited 3 times in total.
Always wear safety glasses while programming.
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: New GTA2 Script Compiler Preview v0.1

Post by Sektor »

Suggestions:

The green comments on grey background are very hard to read. MisIde2 should remember window state. It doesn't detect all syntax errors.

Dream:

One day in the far future we will have an open source compiler that supports everything the official compiler supports only without the bugs or limitations.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler Preview v0.1

Post by B-$hep »

Thanks for reply. I know, the IDE is limited, because it was not meant to be full replacement atm.
The MisPad ide is better for it. Current IDE was just to show the thing.

Yes, compiler will open source, i use parts from T.M scr decompiler, but currently it's pointless to release it, because it's updated too often. I don't have time to update the source here, after each modification. After some specific achievement, i could upload it and then again after some major update, upload latest version.
Always wear safety glasses while programming.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: New GTA2 Script Compiler Preview v0.1

Post by T.M. »

Maybe you should mention in the first post, that i am also working on this thing with you? Or am i? I think i helped you a lot in the PM's we went through, plus i gave lots of ideas and wrote bunch of c++ code for you and fixed some bugs... wrote the scr document for (mainly) you, etc. Anyways, i will help on this once i get your sources, probably fix some stuff again.

Btw, before you do anything bigger, may i look at the code to see if its good to go for larger set of commands, so you/we dont have to waste hours to rewrite 5000 lines of code laterwards. Just PM it to me if you dont want to show it to everyone yet.
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: New GTA2 Script Compiler Preview v0.1

Post by elypter »

this is really a great project. i'm looking forward to see more.
... maybe even new script commands ... vike? ;)
yur sa'nok ngeyä
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler Preview v0.1

Post by B-$hep »

T.M. wrote:...
Yes i know my friend. I apologize, but as i said, i was very very tired when i uploaded this stuff.
I was awake whole night and i wasn't even thinking clearly. I forgot to mention many things, not only you but about compiler also. But anyway, i will create a source pack for you and will send PM soon.

I fixed my mistake.

Elypter or anybody, who downloaded the 7zip pack here:

1) Did you tried to compile the script?
2) Did you executed it with GTA2?
3) Did it work for you? I mean IDE and GTA2MISS.exe?
4) Any errors (error messages anywhere)?


I forgot to mention that this script was designed for ste.gmp map, that ships with GTA2.
It has a parking lot near church, and the cars and bus supposed to be there and parked.


I use GTA2 Power Manager to quickly test maps and script. It makes it very easy and quick. I love it.
Just make sure to check "Skip Frontend"
Image
Always wear safety glasses while programming.
User avatar
Vike the Hube
Hitman
Hitman
Posts: 145
Joined: 28 Feb 2010, 22:34
GH nick: vike

Re: New GTA2 Script Compiler Preview v0.1

Post by Vike the Hube »

elypter wrote:this is really a great project. i'm looking forward to see more.
... maybe even new script commands ... vike? ;)
I endorse this message. ;)
User avatar
Sektor
Boss
Boss
Posts: 1423
Joined: 04 Mar 2008, 06:51
GH nick: Sektor
Location: GTAMP.com
Contact:

Re: New GTA2 Script Compiler Preview v0.1

Post by Sektor »

Ishani's Power Manager won't work with Vike's GTA2 Manager/patch but you can get the same debug tab in any GTA2 Manager just by importing a registry key or running GH.
User avatar
Vike the Hube
Hitman
Hitman
Posts: 145
Joined: 28 Feb 2010, 22:34
GH nick: vike

Re: New GTA2 Script Compiler Preview v0.1

Post by Vike the Hube »

Also B-Shep you could use some source control software like subversion or git. Host it on google code and use something like TortoiseSVN to do your commits. But whatever works for you of course :D I'd rather you work on it than get too bogged down in admin.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler Preview v0.1

Post by B-$hep »

Just want you to know that i still work on this thing. It's going very nicely.
I take it with small steps. And i want this thing to be binary compatible with original scr files except of course the junk data at the end of the .scr files. Everything else must be exactly same.
Otherwise it will crash even without that, GTA2 .scripting is unstable enough.
So far i have pretty much worked on "interesting" things like, cars, players, generators things.

So for ex script like this compiles and works fine and is 99% match with miss2 binaries, except junk data, because it's not needed:
[MIS]/* VENERIC ISLE
created by Jozodezokokotar
ICQ: 319-945-345
DECLARE PLAYERS & VARIABLES */
PLAYER_PED PLAYER_1 = ( 115.0 , 128.5 , 3.0 ) 0 180
PLAYER_PED PLAYER_2 = ( 115.0 , 113.5 , 3.0 ) 2 0
PLAYER_PED PLAYER_3 = ( 122.0 , 121.0 , 3.0 ) 4 270
PLAYER_PED PLAYER_4 = ( 108.0 , 121.0 , 3.0 ) 3 90
PLAYER_PED PLAYER_5 = ( 124.6 , 110.5 , 4.0 ) 13 90
PLAYER_PED PLAYER_6 = ( 104.0 , 132.0 , 4.0 ) 12 315

CHAR_DATA pl1_helfer
CHAR_DATA pl2_helfer
CHAR_DATA pl3_helfer
CHAR_DATA pl4_helfer
CHAR_DATA pl5_helfer
CHAR_DATA pl6_helfer

DECLARE_POLICELEVEL ( 1 )
DECLARE_FINISH_SCORE ( 0 )
DECLARE_TOTAL_MISSIONS ( 0 )
DECLARE_TOTAL_SECRETS ( 0 )

// DECLARE CARS
PARKED_CAR_DATA swatvan1 = ( 116.9 , 131.8 , 3.0 ) -1 315 SWATVAN
PARKED_CAR_DATA miara = ( 115.2 , 131.6 , 3.0 ) 9 45 MIURA
PARKED_CAR_DATA meteor = ( 114.1 , 131.6 , 3.0 ) 10 45 STRATOSB
PARKED_CAR_DATA michelli = ( 112.8 , 131.6 , 3.0 ) 34 45 T2000GT
PARKED_CAR_DATA swatvan2 = ( 117.1 , 110.1 , 3.0 ) -1 225 SWATVAN
PARKED_CAR_DATA stinger = ( 115.2 , 110.3 , 3.0 ) 30 135 STINGRAY
PARKED_CAR_DATA wellard = ( 114.1 , 110.3 , 3.0 ) 13 135 ALLARD
PARKED_CAR_DATA atype = ( 112.8 , 110.3 , 3.0 ) 34 135 RTYPE
PARKED_CAR_DATA furore = ( 122.6 , 122.6 , 3.0 ) 33 135 ZCX5
PARKED_CAR_DATA ztype = ( 107.4 , 119.4 , 3.0 ) 11 315 VTYPE
PARKED_CAR_DATA rumbler = ( 106.0 , 123.5 , 3.0 ) 21 260 WBTWIN
PARKED_CAR_DATA jeffry = ( 124.5 , 119.2 , 3.0 ) 5 45 JEFFREY
PARKED_CAR_DATA garbaget = ( 90.8 , 121.5 , 3.0 ) 29 45 GTRUCK
PARKED_CAR_DATA apc = ( 86.0 , 119.0 , 3.0 ) -1 170 APC
PARKED_CAR_DATA blackvan = ( 120.5 , 141.7 , 3.0 ) 2 315 VAN
PARKED_CAR_DATA karmabus = ( 123.1 , 98.0 , 3.0 ) -1 225 KRSNABUS
PARKED_CAR_DATA copcar1 = ( 107.5 , 139.4 , 3.0 ) -1 180 COPCAR
PARKED_CAR_DATA copcar2 = ( 122.5 , 102.6 , 3.0 ) -1 0 COPCAR
PARKED_CAR_DATA parked_trailer1 = ( 124.1 , 142.0 , 3.0 ) 16 315 truktrns
PARKED_CAR_DATA parked_trailer2 = ( 91.0 , 118.0 , 3.0 ) 21 45 truktrns
PARKED_CAR_DATA parked_trailer3 = ( 137.9 , 117.0 , 3.0 ) 29 45 truktrns
PARKED_CAR_DATA truckcabsx = ( 125.5 , 95.6 , 3.0 ) 32 315 TRUKCAB2
PARKED_CAR_DATA armyjeep = ( 118.0 , 142.0 , 3.0 ) -1 0 GUNJEEP
PARKED_CAR_DATA oiljeep = ( 135.8 , 116.8 , 3.0 ) -1 45 JEEP
PARKED_CAR_DATA fbicar = ( 90.5 , 119.5 , 3.0 ) -1 45 EDSELFBI
PARKED_CAR_DATA firetruck1 = ( 108.5 , 139.7 , 3.0 ) -1 180 FIRETRUK
PARKED_CAR_DATA firetruck2 = ( 121.5 , 102.3 , 3.0 ) -1 0 FIRETRUK
PARKED_CAR_DATA dummy1 = ( 105.0 , 106.5 , 3.0 ) -1 45 JEEP
PARKED_CAR_DATA dummy2 = ( 96.8 , 120.9 , 3.0 ) -1 90 SWATVAN
PARKED_CAR_DATA dummy3 = ( 133.0 , 121.0 , 3.0 ) -1 270 APC
PARKED_CAR_DATA car_pl1 = ( 112.2 , 129.2 , 3.0 ) 31 135 GT24640
PARKED_CAR_DATA car_pl2 = ( 118.6 , 113.6 , 3.0 ) 28 315 GT24640
PARKED_CAR_DATA car_pl3 = ( 124.6 , 120.5 , 3.0 ) 20 90 GT24640
PARKED_CAR_DATA car_pl4 = ( 105.4 , 120.5 , 3.0 ) 35 270 GT24640
PARKED_CAR_DATA car_pl5 = ( 127.5 , 111.5 , 3.0 ) 27 45 GT24640
PARKED_CAR_DATA car_pl6 = ( 104.8 , 134.5 , 3.0 ) 34 80 GT24640

// DECLARE WEAPONS
GENERATOR machine_gun1 = ( 113.0 , 126.0 , 3.0 ) 0 COLLECT_01 200 800 10
GENERATOR machine_gun2 = ( 117.0 , 116.0 , 3.0 ) 0 COLLECT_01 200 800 10
GENERATOR machine_gun3 = ( 134.5 , 126.6 , 4.0 ) 0 COLLECT_01 600 800 15
GENERATOR machine_gun4 = ( 121.0 , 127.0 , 4.0 ) 0 COLLECT_01 200 800 10
GENERATOR machine_gun5 = ( 104.0 , 111.2 , 4.0 ) 0 COLLECT_01 200 800 10
GENERATOR silenced_machine1 = ( 120.0 , 123.0 , 3.0 ) 0 COLLECT_09 200 800 10
GENERATOR silenced_machine2 = ( 110.0 , 119.0 , 3.0 ) 0 COLLECT_09 200 800 10
GENERATOR silenced_machine3 = ( 104.6 , 133.6 , 4.0 ) 0 COLLECT_09 600 800 15
GENERATOR silenced_machine4 = ( 119.5 , 102.5 , 3.0 ) 0 COLLECT_09 600 800 15
GENERATOR silenced_machine5 = ( 95.5 , 115.4 , 4.0 ) 0 COLLECT_09 600 800 15
GENERATOR shotgun1 = ( 117.0 , 126.0 , 3.0 ) 0 COLLECT_06 200 800 16
GENERATOR shotgun2 = ( 120.0 , 119.0 , 3.0 ) 0 COLLECT_06 200 800 16
GENERATOR shotgun3 = ( 113.0 , 116.0 , 3.0 ) 0 COLLECT_06 200 800 16
GENERATOR shotgun4 = ( 110.0 , 123.0 , 3.0 ) 0 COLLECT_06 200 800 16
GENERATOR dual_pistol1 = ( 126.0 , 132.4 , 4.0 ) 0 COLLECT_10 200 800 32
GENERATOR dual_pistol2 = ( 126.0 , 109.0 , 4.0 ) 0 COLLECT_10 200 800 32
GENERATOR dual_pistol3 = ( 104.0 , 109.8 , 4.0 ) 0 COLLECT_10 200 800 32
GENERATOR dual_pistol4 = ( 109.0 , 127.0 , 4.0 ) 0 COLLECT_10 200 800 32
GENERATOR flamethrower = ( 109.5 , 111.5 , 5.0 ) 0 COLLECT_08 1200 3600 5
GENERATOR electro_gun = ( 120.5 , 130.5 , 5.0 ) 0 COLLECT_03 1200 3600 5
GENERATOR rocket_launcher1 = ( 124.5 , 115.5 , 5.0 ) 0 COLLECT_02 1200 3600 2
GENERATOR rocket_launcher2 = ( 105.5 , 126.5 , 5.0 ) 0 COLLECT_02 1200 3600 2
GENERATOR rocket_launcher3 = ( 120.6 , 92.5 , 3.0 ) 0 COLLECT_02 1200 3600 2
GENERATOR invisibility = ( 115.0 , 121.0 , 3.0 ) 0 COLLECT_39 9800 9900
GENERATOR pistol1 = ( 102.4 , 131.4 , 4.0 ) 0 COLLECT_00 200 800 99
GENERATOR pistol2 = ( 126.0 , 111.0 , 4.0 ) 0 COLLECT_00 200 800 99
GENERATOR molotov1 = ( 102.5 , 116.5 , 4.0 ) 0 COLLECT_04 600 800 6
GENERATOR molotov2 = ( 134.4 , 123.6 , 3.0 ) 0 COLLECT_04 600 800 6
GENERATOR molotov3 = ( 104.0 , 139.0 , 3.0 ) 0 COLLECT_04 600 800 6
GENERATOR grenade1 = ( 117.5 , 102.5 , 3.0 ) 0 COLLECT_05 600 800 8
GENERATOR grenade2 = ( 126.8 , 122.2 , 3.0 ) 0 COLLECT_05 600 800 8
GENERATOR grenade3 = ( 95.5 , 118.5 , 3.0 ) 0 COLLECT_05 600 800 8
GENERATOR armour1 = ( 104.0 , 110.5 , 4.0 ) 0 COLLECT_31 600 1200
GENERATOR armour2 = ( 126.0 , 131.6 , 4.0 ) 0 COLLECT_31 600 1200
GENERATOR health1 = ( 120.5 , 111.5 , 5.0 ) 0 COLLECT_30 600 1200
GENERATOR health2 = ( 109.5 , 130.5 , 5.0 ) 0 COLLECT_30 600 1200
GENERATOR double_damage = ( 126.0 , 110.0 , 4.0 ) 0 COLLECT_35 6400 7200
GENERATOR double_fire_rate = ( 102.4 , 133.6 , 4.0 ) 0 COLLECT_36 6400 7200
GENERATOR cop_bribe = ( 100.0 , 106.0 , 3.0 ) 0 COLLECT_33 600 800
GENERATOR gang_powerup = ( 130.0 , 136.0 , 3.0 ) 0 COLLECT_40 3800 4200
GENERATOR electrofingers = ( 100.0 , 136.0 , 3.0 ) 0 COLLECT_37 600 1200
GENERATOR car_oil = ( 105.5 , 115.5 , 5.0 ) 0 COLLECT_16 3800 4200 5
GENERATOR car_bomb = ( 130.0 , 106.0 , 3.0 ) 0 COLLECT_15 3800 4200
GENERATOR instant_bomb = ( 124.5 , 126.5 , 5.0 ) 0 COLLECT_23 3800 4200

LEVELSTART
// WEAPONS RESPAWN pt.2
SWITCH_GENERATOR ( flamethrower , ON )
SWITCH_GENERATOR ( electro_gun , ON )
SWITCH_GENERATOR ( rocket_launcher1 , ON )
SWITCH_GENERATOR ( rocket_launcher2 , ON )
SWITCH_GENERATOR ( rocket_launcher3 , ON )
SWITCH_GENERATOR ( invisibility , ON )
SWITCH_GENERATOR ( molotov1 , ON )
SWITCH_GENERATOR ( molotov2 , ON )
SWITCH_GENERATOR ( molotov3 , ON )
SWITCH_GENERATOR ( grenade1 , ON )
SWITCH_GENERATOR ( grenade2 , ON )
SWITCH_GENERATOR ( grenade3 , ON )
SWITCH_GENERATOR ( armour1 , ON )
SWITCH_GENERATOR ( armour2 , ON )
SWITCH_GENERATOR ( health1 , ON )
SWITCH_GENERATOR ( health2 , ON )
SWITCH_GENERATOR ( cop_bribe , ON )
SWITCH_GENERATOR ( gang_powerup , ON )
SWITCH_GENERATOR ( electrofingers , ON )
SWITCH_GENERATOR ( car_oil , ON )
SWITCH_GENERATOR ( car_bomb , ON )
SWITCH_GENERATOR ( instant_bomb , ON )
LEVELEND
[/mis]


I really want to try out IF..THEN & WHILE's soon.
It would be very exciting.


REQUEST
If anybody here has bunch of scripts (.mis files) on your hard drive, any script, it doesn't matter short or big, please make a pack with them and upload to somewhere.
I need example .mis files as much as possible. To test different kinds of syntax and commands.
It would help alot.

So far i got bunch of them from Elypter packs, but i want more.
Currently 263 .mis files in my C:\Scripts folder.
I need more
Always wear safety glasses while programming.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: New GTA2 Script Compiler Preview v0.1

Post by T.M. »

B-$hep wrote:Currently 263 .mis files in my C:\Scripts folder.
I need more
I dont think you need more files. Just time and some logical thinking how to use the IF/WHILE stuff. There are not many tricks to use them, except the tricks to avoid compiler bugs in current compiler. For example ELSE command doesnt work at all, or was it just in nested IF's? Dunno anymore.

You could use my stuff i used to build my decompiler:
decompiler_mis_tests.7z
(14.93 KiB) Downloaded 1265 times
Not sure if there is every command, i think i overwrote some files while testing in huge rush the commands.

Note: not all those files are playable, they were used to test how the compiler compiles them, if it compiles them at all. For example there are some negative coordinate values i think. But thats still useful since you have to add error checking for every parameter. You need to check which ranges each parameter allows to be executed in GTA2 without crash, and then allow that in the compiler. Some of the parameters i used have -1 values, which is not always treated as negative; the compiler probably converts it to unsigned integer in some cases. I think there was some conversion in the CHANGE_BLOCK commands etc... hard to remember. It will be a lot of testing though.

When are you gonna release the source? C++?
(i dont think you will finish it by yourself, nor do i think i have time for that either, but who knows, and there are other people willing to help too, i think).

Here are some things to consider, maybe helps thinking how to do the IF's:
http://gtamp.com/forum/viewtopic.php?p=5039#p5039 (i dont mean you have to change the syntax!)
http://gtamp.com/forum/viewtopic.php?p=5123#p5123
http://gtamp.com/forum/viewtopic.php?p=6384#p6384

Some documentation made by me:
http://epicgta2.omnitude.net/scrdoc/scr_strings.html
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler Preview v0.1

Post by B-$hep »

Hi T.M.
Thanks for the scripts.
Yes, i have looked into if-then's some time ago, just to see how they are done / used etc.
Just small sneak peak to this thing.

About finishing the compiler i want to tell you one thing.
It will be like with decompiler, i slowly worked on it, it was fun and then you came and basically finished the job with "1 day". But i asked you to not to code it and finish it. Even you said you don't have time. But you did it. OK what's done that's done. Im not mad or anything. I know there are better coders, like you. I wanted to try to finish the if-thens, while in your decompiler, but the source is not easy to understand. If i figure them out then i can only give you the stuff i figured out and you must add this to decompiler by yourself.

And i think same will be with compiler. You will make it in 1-2 days maybe and that's it.
But im bored atm and it's interesting to code and fun to run GTA2 to see if it crashes or something or doing a binary compare on .scr files after compile, etc.

If you will finish it withing few days, i don't have anything to do again.
Don't understand me wrong, im not mad at you because of this nor i will be, but im just telling you how it will go.

And im still very very thankful to your help and sources you gave out.
Of course i will give out the source fully, but i don't know when.

Im just afraid i will be out of job again.

EDIT:
You really should use more #ifdef #endif in your headers to avoid multiple declarations errors.
Or just #pragma once
It's very good practice. I got a bunch of errors from VC++ and wondered why. And then i discovered that you don't have these commands at the beginning of the header files.
I added and errors went away.
I know that scr decompiler dll compiles but when using stuff in other projects you (users) will have problems.
Always wear safety glasses while programming.
Jones
Psycho
Psycho
Posts: 51
Joined: 08 Aug 2012, 21:25

Re: New GTA2 Script Compiler Preview v0.1

Post by Jones »

I'm also interested in writing the compiler or at least have a glance how you have done it B-$hep, please release it as source ;) I don't know how you can circumvent your problem of attractive problems which been solved by others, but aren't there enough for everyone? I don't think someone here can write a fully fledged compiler without bugs and new features alone, even if someone can, not in the same time as more people could do. We still have no full map editor alternative and Vike is surely happy if someone get into GTA 2 reverse engineering. In my opinion it also wouldn't be fatal if we have two different compilers, you can still exchange ideas and your findings :)
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler Preview v0.1

Post by B-$hep »

99% (ok almost i think) of compiling is done for me. I have to just tell "him" (the engine) what to expect as input.
Rest of the parsing is done by him. I just take the values / variables from commands and process that.
I know how difficult is to write complete parser for any language, specially the recursive descent parsers. Fortunately there are good engines to simplify this alot. And im using one of them. It's the best out there.


If we talk about Vike, i don't know how he is so good at fixing stuff in GTA2 and adding features.
Sometimes i think he got the sources of GTA2 :D
Always wear safety glasses while programming.
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: New GTA2 Script Compiler Preview v0.1

Post by T.M. »

B-$hep wrote:About finishing the compiler i want to tell you one thing.
It will be like with decompiler, i slowly worked on it, it was fun and then you came and basically finished the job with "1 day". But i asked you to not to code it and finish it. Even you said you don't have time. But you did it.
Yeah. If you shared the code on the first place, i probably wouldnt have finished it myself. You know, when you tell a kid "no", he wants it even more. ;-)

Currently i really dont have any time, so no worries.
B-$hep wrote:I wanted to try to finish the if-thens, while in your decompiler, but the source is not easy to understand.
You probably have to rewrite some parts of the code anyways. It doesnt get linear anymore when the If's and While's are added. Currently it just outputs each command for each line. if/whiles need more trickier formatting and parsing logic.

Basically the decompiler just reads one command at a time, parses the values for each parameter, executes some custom functions for some of them (to keep track of stuff), and then outputs the line. I have added a lot of comments there, so it should be possible to understand the logic. If you read it all and still dont understand, i can explain more.
B-$hep wrote:If i figure them out then i can only give you the stuff i figured out and you must add this to decompiler by yourself.
Its best if you just make own decompiler from scratch, and then just parse the if/whiles, and forget about the CREATE_CAR etc other commands (you can just ignore them, or replace them with a simple DO_NOWT command. Though, that is trickier to add in the IF's like IF(delay(5)) or something. But in my decompiler source code you can find all those commands which are "boolean" so they return a bool value, which means they are used in if-structures. You can find them with these keywords in the scr_functions.h: TWO_PARAMS_LAYOUT_BOOL, FOUR_PARAMS_LAYOUT_BOOL, CUSTOM_STRUCT_LAYOUT_BOOL, ZERO_PARAMS_LAYOUT_BOOL.
B-$hep wrote:And i think same will be with compiler. You will make it in 1-2 days maybe and that's it.
I wont. I have other stuff to be busy with. Honestly.
B-$hep wrote:You really should use more #ifdef #endif in your headers to avoid multiple declarations errors.
Or just #pragma once
It's very good practice. I got a bunch of errors from VC++ and wondered why. And then i discovered that you don't have these commands at the beginning of the header files.
I added and errors went away.
I know that scr decompiler dll compiles but when using stuff in other projects you (users) will have problems.
Yeah the code is shitty, didnt really think how to make it "good", just wanted to make it easy as possible. Didnt really care either, since i knew nobody will use it anyways.

Here is something i figured from the IF's before:
[cpp]struct SCR_IF_JUMP {
SCR_CMD_FORMAT(
Uint16 logical_operator; // seems to be 0 for AND command and 1 for OR command.
Uint16 else_jump; // where will it jump if check was false.
);
};
string read_IF_JUMP(FPStruct &params){
get_data(SCR_IF_JUMP, data);
if(params.header->return_value == 0 && data.logical_operator == 0){ // not sure about this.
return sprintf_str("ENDIF %s", hexdump(params,0).c_str());
}else{
return sprintf_str("%s", hexdump(params,1).c_str());
}
}[/cpp]
(taken from scr_functions.h end of file)
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler Preview v0.1

Post by B-$hep »

Ok thank you so far. Im at work , so cant write much. Will come back later
Always wear safety glasses while programming.
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler Preview v0.1

Post by B-$hep »

Last night i messed with some commands, specially the CAR_DATA command.
And noticed that miss2 either forgot to initialize some of the stuff to 0 or it does something more.

Also T.M, if you are reading this...

Code: Select all

struct SCR_CAR_DATA_DEC {
	SCR_CMD_FORMAT(
		Uint16 varname;
What's the purpose of "varname". Is it even used?
Currently i init this to 0 and GTA2 still works fine.


Also the trailer model thingy, you said in sources that 0xFFFE is mini_car.
miss2 puts a 0x0000 instead of it.
In my compiler i write 0xFFFE if trailer is mini_car. GTA2 shows mini version of car although i don't know the purpose of it, i can't enter the car and control it. Probably for remote only.

There are some things that miss2 does differently, to be exact, it saves some "odd" looking stuff / values that i don't understand. And because of these values some bytes are different in compiled .scr. I mean odd stuff for CAR_DATA specifically.

If you see some missing "h" letters in my posts, im sorry, my keyboard is dying here.
Always wear safety glasses while programming.
User avatar
elypter
Immortal
Posts: 1120
Joined: 26 Dec 2009, 23:53
GH nick: elypter

Re: New GTA2 Script Compiler Preview v0.1

Post by elypter »

yes, minicars are only for remote.

btw, clean your keyboard :P (there might be dirt between the different layers of foils)
yur sa'nok ngeyä
User avatar
T.M.
Immortal
Posts: 960
Joined: 29 Jan 2010, 15:00
Location: F21B3EED

Re: New GTA2 Script Compiler Preview v0.1

Post by T.M. »

B-$hep wrote:Last night i messed with some commands, specially the CAR_DATA command.
And noticed that miss2 either forgot to initialize some of the stuff to 0 or it does something more.

Also T.M, if you are reading this...

Code: Select all

struct SCR_CAR_DATA_DEC {
	SCR_CMD_FORMAT(
		Uint16 varname;
What's the purpose of "varname". Is it even used?
Currently i init this to 0 and GTA2 still works fine.
Its used in the CREATE_CAR command (read under the first function that uses that struct), it uses the exact same struct. For CAR_DATA command it is not used at all. You can set it to zero indeed. Varname purpose is to store the variable identifier, aka pointer, so we can refer to it later in the code.

Only variables you need to ignore completely are those named "unk1", "unk2" etc.. or "unknown" etc...

B-$hep wrote:Also the trailer model thingy, you said in sources that 0xFFFE is mini_car.
miss2 puts a 0x0000 instead of it.
Yes. miss2 is crazy. dont trust it... there are lots of bugs in it with those commands! for some commands MINI_CAR doesnt even work! but if you add 0xFFFE manually in the SCR file, then it works in gta2!
B-$hep wrote:In my compiler i write 0xFFFE if trailer is mini_car. GTA2 shows mini version of car although i don't know the purpose of it, i can't enter the car and control it. Probably for remote only.
Not sure what happened there, but there are lots of bugs indeed. I cant remember what was the logic anymore.........
Did you read this?

Code: Select all

		if(data.trailer_id == 0xFFFE){ // note: compiler doesnt make MINI_CAR in car declarations!
			optional = " MINI_CAR";
		}else if(data.trailer_id != 0xFFFF){ // note: compiler doesnt make trailer in 2d car declarations!
			optional = string(" ")+enum_cstr(CARS,data.trailer_id);
		}
Just make the compiler so it makes code that works in GTA2. dont check your stuff with miss2, its buggy as hell.
B-$hep wrote:There are some things that miss2 does differently, to be exact, it saves some "odd" looking stuff / values that i don't understand. And because of these values some bytes are different in compiled .scr. I mean odd stuff for CAR_DATA specifically.

If you see some missing "h" letters in my posts, im sorry, my keyboard is dying here.
Those odd things are uninitialized bytes, just random trash, ignore them.

Perhaps its best if you create own struct for each of the commands.... currently im sharing same struct for multiple commands. Dunno really what is the easiest way. You need to think that yourself, i cant remember much from this, been year or two since i made it?
User avatar
B-$hep
Immortal
Posts: 568
Joined: 24 Apr 2009, 21:43
GH nick: B-Shep
Location: EU

Re: New GTA2 Script Compiler Preview v0.1

Post by B-$hep »

Ok.
I added lots of commands and they are binary compatible with miss2 and gta2 runs very fine.
Only few structs have strange values. But anyways, Gta2 is happy and things are going very well.

I also have redesigned Scriptpad ide. New compiler will use it.
Always wear safety glasses while programming.
Post Reply