GTAMP.com

Grand Theft Auto Multiplayer
It is currently Mon Nov 19, 2018 1:20 pm

All times are UTC




Post new topic Reply to topic  [ 148 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Author Message
 Post subject: Re: SCR decompiler
PostPosted: Sat Oct 29, 2011 5:32 pm 
Offline
Boss
User avatar

Joined: Tue Mar 04, 2008 6:51 am
Posts: 1342
Location: GTAMP.com
I split this topic from the original. It would be better if TM attaches files to the first post since they can get lost on the other pages.


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Sat Oct 29, 2011 5:54 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Pyro wrote:
While it correctly shows the door placement, all the checks it needs on how to open the door were all set to 0.0. Fortunately I knew how to correct it and now all the doors in ste are working correctly. Just for reference, here's my code with the updated info of what it should have looked like:
NOOOooooo.... :D you did it wrong... if you set the target width/height to zero it means the trigger will be autogenerated on front of the door! my editor shows it correctly. god damn use it! :D (docs say ALL must be, but ive tested and only w/h must be set to zero!).

Pyro wrote:
As you can see, I re-named the doors more appropriately ...
That gives me an idea... maybe the variable names should be padded with zeroes? then its much easier to replace their names since if you try to replace "obj1" it will also replace "obj11" etc. on the other hand, it makes it really fugly: "obj001", well, maybe i could add an option.

Pyro wrote:
Also, I noticed a lot of floating points have two decimal places after them (like 127.50). While the game doesn't have a problem with this, but wondering if this is done from the decompiler or the actual person who coded it all those years ago? Just trivial really but I've always used one decimal place myself.
floats arent stored with dots and numbers in any binary files, not even in SCR ;D so instead, its calculated which allows you to have at least 6 decimal precision rougly said (in SCR floats its calculated with: x/16384). I am displaying floats with 2 decimal precision because that is the highest you can use (more precise than that are impractical for anything). and i have really no way of knowing the original precision, unlike from .mis files. sure i could strip off the zeroes from end of the float values, but then it might look dumb if you actually use 2 decimal precision (like the golden-lap map does for the wall objects); some values would be 2 decimals and some 1, in same line of code! then it would look all crazy and unclean :(

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Sat Oct 29, 2011 6:12 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Sektor, thanks, i still think there should be one thread though, but its hard to have such since only one person can edit the first post. But i guess B-$hep wants to do it alone then... Im just a bit confused of his raging here about stealing his project when he himself said "It's very boring work" -- i did him a favor by doing all that dirty boring work for him... So whats the problem, B-$hep?

I still havent figured out the IF/WHILE things... its still open for anyone to join here, even for you B-$hep! Figure out how to build up the original IF structure, or something that will work equally well with same size of script (if nothing else is possible), and you will get FAME AND RESPECT [respect] 8-)

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Sat Oct 29, 2011 6:44 pm 
Offline
User avatar

Joined: Wed Mar 17, 2010 4:07 am
Posts: 414
Location: Wales, UK
T.M. wrote:
NOOOooooo.... :D you did it wrong... if you set the target width/height to zero it means the trigger will be autogenerated on front of the door! my editor shows it correctly. god damn use it! :D (docs say ALL must be, but ive tested and only w/h must be set to zero!).


Ha, you were right - it does indeed work with second set being all 0.0 :shock: I've been so used to putting manual coordinates in for doors (and even bil.mis has coordinates!) since forever. Only noticed in the documentation right now it does say you can put 0.0 for the trigger to do it automatically :oops: Oh well, live and learn, eh? So I wasn't wrong, both are correct ways of doing it :P

T.M. wrote:
That gives me an idea... maybe the variable names should be padded with zeroes? then its much easier to replace their names since if you try to replace "obj1" it will also replace "obj11" etc. on the other hand, it makes it really fugly: "obj001", well, maybe i could add an option.


Do you mean change variables like "auto1, auto2... auto9, auto10" into "auto01, auto02... auto09, auto10" (extra 0 before the number if less than 10)? If so, I do it this way myself so I have plenty of choice from 00 all the way to 99 and never needed anything past 100 yet. I think adding two 0's (e.g. auto001) might be a bit overkill, but that's my opinion only.

T.M. wrote:
...stuff about floating points with decimal places...


Alrighty, its no problem really. I just personally like having it as one decimal place in floats and it's easy/quick enough to change anyway. 8-)

PS - it seems the ste.scr I have currently doesn't have the Redneck crane fix in it (using Vikes newest/latest gta2.exe - thought it was supposed to come with the fix?). Still, since I'm making a "ste-new.mis" I fixed it in this one. Just a 'simple' case of moving the crane powerup generator up one block (from 4.5,83.5,3.0 to 4.5,82.5,3.0).

_________________


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Sat Oct 29, 2011 7:04 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Pyro wrote:
Do you mean change variables like "auto1, auto2... auto9, auto10" into "auto01, auto02... auto09, auto10" (extra 0 before the number if less than 10)? If so, I do it this way myself so I have plenty of choice from 00 all the way to 99 and never needed anything past 100 yet. I think adding two 0's (e.g. auto001) might be a bit overkill, but that's my opinion only.
Yes, actually i thought of calculating the maximum amount of the objects (or other types of stuff) and thus getting how many preceding zeroes there should be. Since i already read the SCR file TWICE because of how functions are saved, this shouldnt add much more complexity into it.

Pyro wrote:
PS - it seems the ste.scr I have currently doesn't have the Redneck crane fix in it (using Vikes newest/latest gta2.exe - thought it was supposed to come with the fix?). Still, since I'm making a "ste-new.mis" I fixed it in this one. Just a 'simple' case of moving the crane powerup generator up one block (from 4.5,83.5,3.0 to 4.5,82.5,3.0).
As i said before, im not entirely sure which file this crane fix should be in, this .mis file i generated is from the single player missions (as far as i understand). maybe the fix is in the multiplayer version? multiplayer map showed them fine i think.

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Sat Oct 29, 2011 7:26 pm 
Offline
User avatar

Joined: Wed Mar 17, 2010 4:07 am
Posts: 414
Location: Wales, UK
The crane fix should be in the main "ste.scr" file itself. Not sure what part was fixed, but my method in my mis file is to move the powerup generator by 1 block. Hope this helps.

_________________


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Sat Oct 29, 2011 8:01 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Crap... i dont think i can make the padded variable names, i would have to decompile it twice... while atm i dont really do it twice, i just read subroutine declarations twice. and it gets tricky when i have "shop1" etc for objects as well... i could do this though, but then there would be the same logic twice in different parts of code, and if i change the reader functions a little, i would have to update the other piece of code as well.. and eh.. i dont think its that important anyways, since i think its easiest to replace those variables when you just choose "whole word only" option :D

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Sun Oct 30, 2011 8:44 am 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:03 pm
Posts: 905
All this talk about compiling, decompiling and hacking makes me wanna start programming again, txt2gta2 still needs some updating, but it's so long ago I worked on it. :-)

Anyway, continue decompiling!

_________________
"Mmmm, your eyes are so beautiful."


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Sun Oct 30, 2011 8:06 pm 
Offline
User avatar

Joined: Fri Apr 24, 2009 9:43 pm
Posts: 515
Location: Estonia
T.M. wrote:
Figure out how to build up the original IF structure, or something that will work equally well with same size of script


What do you mean by that?

"with same size of script"?

I probably missed some posts (this topic is getting big).

_________________
Always wear safety glasses while programming.


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Sun Oct 30, 2011 10:48 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Yeah, same size of script, so its still possible to decompile and compile any script without increasing its script size. for example you could use GOSUB command with simple IF commands, i think. but thats rather crappy way of doing it...

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Wed Nov 02, 2011 8:58 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Damn, i really want to make my own compiler now: the current compiler is REALLY slow! i made the simplest and longest possible script, but its still compiling it as slow as the biggest known map script i have. I just added 5690 DO_NOWT commands + LEVELSTART/LEVELEND (maximum size of script), and you know how long it took? 5 seconds! crazy! what is it doing all that time? i have no idea... it shouldnt take that long.

While i was figuring out the missions, i noticed the mission scripts have 8 byte header:
Code:
3C16 3C16 0030 0000

- the first 2 values is the amount of pointers the base script has (including the useless first zero pointer). both have same value for some weird reason.
- after that comes the size of the mission script commands data.
- then there is just null value which i dont completely understand whats its purpose, i assume its just padding.
- then starts the mission script pointers (max 1536).

conclusions after testing a while:
- maximum base script size = 45544 bytes
- maximum mission script size = 65536-base_script_size, EXCEPT: there is max 1536 pointers! i tried to add max+1 pointers and the last pointer simply didnt appear in the file at all, but the script did get larger! so its possible to make too large mission script and not get notified by compiler that its not going to work in gta2. i also noticed it seems the actual maximum for mission script commands data size = 56260, compiler refused to compile after that size reached. what is weird is mission scripts allow more script data than base scripts! but since they cant have enough pointers that size can never be reached though.

gotta do some more testing:
- checking if all my mission files i have has the same logic in the .scr file first 8 bytes.

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Thu Nov 03, 2011 9:46 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
I noticed that you cant declare trains, gangs, zones or use .mis script names inside the mission scripts .mis code. Reason: .scr files usually store those strings in the end of file, but for missions those arent stored, not even in the base script file, but whats weird that the compiler doesnt say anything is wrong, and it even writes the SCR code for those commands! it even includes a pointer for the strings, which point to nowhere! so this might be a reason why some of your mission scripts havent been working sometimes.

I also noticed the second variable in the 8 byte header in mission scripts is just garbage! it is totally random in every mission file, i happened to be lucky (as usually) and i had the same value there as the first variable had.

I've been working on decompiling the missions now. I decided to make the decompiler as a DLL file: easier to update and work on it from any program. the DLL has one function which takes parameters: base_script, base_script_output, array of mission_scripts, array of mission_scripts_output. You can also edit the prefixes for variable names with global strings like "VARNAME_PLAYER", just change it and the PLAYER_PED variables will have different prefix the next time you call decompile_scr() function. although, i think i shouldnt use globals like that... maybe a function is better for changing those values, or not. i would need two parameters: type and the string to change to... uh. i think variables are just fine! oh and it will also return integer value of error code, zero = success.

I made my editor use that DLL now, and when you load a map without a .mis file, it will automatically decompile the SCR and put it into "data/decompiled/" folder. its pretty nice to be able to see inside any map script! now if i just could decompile the if-structures :roll:

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Thu Nov 03, 2011 10:01 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 1100
wow, again very nice progress

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Thu Nov 03, 2011 11:45 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Oh yeah, just finished it, works perfectly! Im gladly surprised it worked at the first compile (was coding for long time without the ability to test it, and made tons of changes in the code!). It even allows you to refer in the base script subroutines or variables (which should be possible in gta2 missions too, at least the compiler writes references to those).

Here is some missions decompiled:
http://pastebin.com/ZNypyagZ
http://pastebin.com/S75KkTgc
http://pastebin.com/7JkUAJ6f

Edit: added to pastebin and changed script and added "debug info", using decimal values instead of hex now! and it displays the data for all boolean commands, so you can figure those if-jumps/else's etc they have stored data in there, note: the data part doesnt have the 3 variable header, cmd.this and cmd.next is inside the braces: (this -> next)

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Tue Nov 08, 2011 1:45 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
I tried to increase the maximum script size manually: i wrote few more commands in the file with hex editor. What happened? IT WORKED!

So, the compiler is limiting the max script size on its own! GTA2 still can read scripts with size 65k, we just need to find out how to remove this limitation from the compiler! The compiler starts crying after your script exceeds 45544 bytes (havent been able to test it with byte precision since i have no way of adding only 1 more byte in the script, all commands size in SCR file is 4 bytes blocks, so this number is in 4 bytes precision then!).

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Tue Nov 08, 2011 3:48 pm 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
I was playing around and made this:
Image
Code:
auto1 = CREATE_CAR (100.5, 215.5, 255.0) 1 0 COPCAR TRAIN END
the train will appear after you go inside the copcar. too bad it will crash if:
- it hits some car, it will blow up any car it hits, and blowing up for some reason crashes.
- you or any ped tries to get inside the train.
- you shoot it with flamer or etc, or you blow it up, or shoot it enough to make smoke.
- you press CTRL to release the trailer.

I also found out that MINI_CAR cant be created with CAR_DATA declarations, because the compiler is buggy! i edited the .scr file with hex editor again and set the MINI_CAR value there, and it worked! damn crappy compiler, makes me want to do it myself already!

also fixed some bugs in the decompiler, for example the mini_car, i had ignored it for some reason.

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Tue Nov 08, 2011 5:32 pm 
Offline
User avatar

Joined: Sat Dec 26, 2009 11:53 pm
Posts: 1100
awesome

_________________
yur sa'nok ngeyä


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Tue Nov 08, 2011 11:41 pm 
Offline
Hitman
User avatar

Joined: Sun Feb 28, 2010 10:34 pm
Posts: 144
T.M. wrote:
I tried to increase the maximum script size manually: i wrote few more commands in the file with hex editor. What happened? IT WORKED!

So, the compiler is limiting the max script size on its own! GTA2 still can read scripts with size 65k, we just need to find out how to remove this limitation from the compiler! The compiler starts crying after your script exceeds 45544 bytes (havent been able to test it with byte precision since i have no way of adding only 1 more byte in the script, all commands size in SCR file is 4 bytes blocks, so this number is in 4 bytes precision then!).


So, it should be limited to 65k because of the two byte pointers; but it's limited to ~45544 bytes by the compiler? And you want me to... coax it into not doing that? ;)


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Wed Nov 09, 2011 12:41 am 
Offline
User avatar

Joined: Fri Jan 29, 2010 3:00 pm
Posts: 953
Location: F21B3EED
Vike the Hube wrote:
So, it should be limited to 65k because of the two byte pointers; but it's limited to ~45544 bytes by the compiler? And you want me to... coax it into not doing that? ;)

Yes, but you dont have to if you dont want, just thought it would be interesting to you... i tried to look a little bit in the compiler binary files but i couldnt even find those error message strings! damn i suck at hacking. :oops:

_________________
My GTA2 related projects:


Top
 Profile  
 
 Post subject: Re: SCR decompiler
PostPosted: Wed Nov 09, 2011 4:06 am 
Offline
User avatar

Joined: Wed Mar 17, 2010 4:07 am
Posts: 414
Location: Wales, UK
Cool stuff.

Did you modify the SCR by hex in any way to make the trailer (well, train in your case) attach to car? Always thought adding trailers to cars normally (via MIS) was bugged and didn't work even using proper cars like a Truck Cab (both versions) and any trailer.

Also noticed that the code for TRAIN actually gives the passenger carriage rather than the powered train itself :P

_________________


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 148 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group