Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    2. GTANet 20th Anniversary

    1. GTA Online

      1. The Cayo Perico Heist
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

      1. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

      1. Court House
    3. Suggestions

[DOC] Reconstructing the III .sc language


NTAuthority

Recommended Posts

This topic will hopefully contain some implementation details about the GTA3 .sc language.

 

START_NEW_SCRIPT, VC AMMU.sc and the division

 

As you might know, the .sc scripting language has a file structure where every script is separated into its own source code file. For instance, VC could have been something like this:

 

main.sc

ammu.sc

interio.sc

[...]

 

Also, anybody who has ever poked around the Ammu-Nation/hardware store sections in the VC main.scm in Sanny would have seen a structure somewhat like this:

 

 

[... in MAIN ...]create_thread @AMMU[...]:AMMU[... variable initalizations ...]create_thread @AMMU1create_thread @AMMU2create_thread @AMMU3create_thread @HARD1create_thread @HARD2create_thread @HARD3end_thread:AMMU1thread 'AMMU1'[... blah ...]gosub @HARD3_20120[...]:HARD3_20120[...]

 

 

The cross-script calls, combined with the fact that .sc scripts are usually found in their own files, which shouldn't be able to call to other script files makes me think of this documentation for START_NEW_SCRIPT (IV name, III one could differ):

 

START_NEW_SCRIPT {label/file name}

Starts a new script thread. If a label is used, the label will be relative to this script file. If a script file is used, the script will start from the beginning of the other script file.

 

With this syntax in mind, think about how the original code could have looked like:

 

 

-> main.scSTART_NEW_SCRIPT ammu.sc-> ammu.sc[... VAR_INT/VAR_FLOAT definitions ...]SCRIPT_NAME ammu[... variable stuff ...]START_NEW_SCRIPT ammu1START_NEW_SCRIPT ammu2START_NEW_SCRIPT ammu3START_NEW_SCRIPT hard1START_NEW_SCRIPT hard2START_NEW_SCRIPT hard3TERMINATE_THIS_SCRIPTammu1:SCRIPT_NAME ammu1[...]GOSUB CreateWeaponDealer[...][other scripts]hard3:[...]CreateWeaponDealer:[...]

 

 

Obviously, Sanny Builder's decompiler, and any other decompiler would not know about this separation, and since these occur after hard3, the decompiler expects it to belong to HARD3. Other examples, though this one has only two threads, of which only one is running, is interio.sc, which starts a thread named 'sh*t'. Really, would you expect a file called 'sh*t.sc'? tounge.gif

 

String variables in SA and their ambiguity

As should be known, SA added string variables to GTA. The only .sc examples we've seen are from VC, which literally use strings as any identifier:

 

 

PRINT_NOW LOADCAR 100 1

 

 

This could, unless the .sc compiler has a list of all possible string values, cause ambiguity when something other than string literals is used when variables are in play. For instance, in SA, if you'd have a string variable named 'carname', you could have a typo like this:

 

 

PRINT_NOW carnam 1000 1

 

 

This would not resolve to the 'carname' variable's value, but to a string literal named 'carnam'. It's like, when using Sanny, replacing [email protected] with 'CARNAM'! Unless the .sc language is really this badly designed, such an error would have no consequences at all.

 

It could be that SA fixed this by requiring string literals to be prefixed with quotation marks, so that the example from main.sc would actually be this:

 

 

PRINT_NOW "LOADCAR" 100 1

 

 

One thing that seems to hint in favor of this issue is that VC/III had string values just without any parameter type, but SA uses an parameter type for these values. However, this might also be because more different types of string values exist, and not reflect any change in the language.

 

Another thing in favor of this is that the opcode 05B6's parameter, without parameter type, oftenly contains spaces.

 

However, hinting against this are two other things. The first argument being the values used for opcode 0662 in the regular SA main.scm:

 

 

0662: NOP "CHEAT_PLAYER1_NOT_HUMAN"

 

 

None of these values ever contain spaces, which goes in with the .sc rule that an identifier can never contain spaces.

 

The other reason against this is that the modification of all the existing code which used string literals would be so much work that it was decided to simply use this 'bad language design' for backwards compatibility.

 

As for the 'community .sc' specification, I'm in favor of just using what we can see from main.sc, that literals do not contain spaces, but with one additional rule: if there's a space in it, wrap it in quotation marks. smile.gif

  • Like 2
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.