Quantcast

Jump to content

» «
Photo

[REL] Sanny Builder

648 replies to this topic
Silent
  • Silent

    Altering R* Vision™ since 2008

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#631

Posted 01 October 2015 - 07:54 PM

@up
Disable IF range checks, or whatever this option is enabled. Needless to say, I agree this particular case could use whitelisting from this check.
  • Craig Kostelecky likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#632

Posted 02 October 2015 - 02:31 AM

If I disable the Condition Check option I get the message "Enable "Conditions check" option to use this feature." on the first 00D6: if or statement.


goodidea82
  • goodidea82

    SA Modder

  • Members
  • Joined: 13 Jun 2013
  • Germany

#633

Posted 07 October 2015 - 05:29 PM

Would it be possible for you to update Sanny Builder with a new datatype for global variables indices? The idea is discussed here. There is currently the limit of approximately 65536 / 4 = 16384 global variables, which is due to the __int16 datatype. Fastman92 said he would be able to break this limit, but his would only make sense if Sanny Builder would support a new datatype. Projects such as SAxVCxLC and GTA Underground would have exciting possibilities if this limit was broken.

 

Btw. I have generated code to stress-test Sanny Builder. Sanny Builder throws and application error if the script becomes too big (adding about 100.000 LOC):

Access violation at address 8B407D3C. Read of address 8B407D3C.

It would be also important to fix this issue.


Seemann
  • Seemann

    Ruhe

  • GTA Mods Staff
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"
    Contribution Award [Mods]
    Helpfulness Awards [Mods]

#634

Posted 07 October 2015 - 07:49 PM Edited by Seemann, 07 October 2015 - 07:49 PM.

Well, first thing: did you ever try to optimize the code a litte bit? Why so many global variables? Ok, I guess you are trying to combine scms from III, VC, SA. Most of the global variables are only used within one mission, use you can re-use them. San Andreas allows 1024 local variables that fit every single mission in III/VC even the biggest ones.

Yes, it's a dangerous and complicate way. Let's look at another one: arrays. They are not limited in any way.
 
0@ = 100000
&0(0@,1i) = 1
this works essentially same as $25000 = 1
and both the compiler and game allow that right now. You only need to reserve some space in the beginning of your scm file. How? Just and a giant list of '00's within the hex..end and the variables will be stored there.
 
...
DEFINE UNKNOWN_EMPTY_SEGMENT 0

DEFINE UNKNOWN_THREADS_MEMORY 574

//-------------MAIN---------------
:my_vars
hex 
00 00 
00 00
00 00
...
00 00
// one row per variable
end
...
0@ = @my_vars
0@ /= 4
0@ += 1 // var index in the buffer
&0(0@,1i) = 1
Still complicated? Then you need to wait when both game limit and the compiler will be updated. Not sure how soon it will happen but I've got your request.

fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • None
  • Contribution Award [Mods]

#635

Posted 07 October 2015 - 07:56 PM

Well, first thing: did you ever try to optimize the code a litte bit? Why so many global variables? Ok, I guess you are trying to combine scms from III, VC, SA. Most of the global variables are only used within one mission, use you can re-use them. San Andreas allows 1024 local variables that fit every single mission in III/VC even the biggest ones.

Yes, it's a dangerous and complicate way. Let's look at another one: arrays. They are not limited in any way.
 

0@ = 100000
&0(0@,1i) = 1
this works essentially same as $25000 = 1
and both the compiler and game allow that right now. You only need to reserve some space in the beginning of your scm file. How? Just and a giant list of '00's within the hex..end and the variables will be stored there.
 
...
DEFINE UNKNOWN_EMPTY_SEGMENT 0

DEFINE UNKNOWN_THREADS_MEMORY 574

//-------------MAIN---------------
:my_vars
hex 
00 00 
00 00
00 00
...
00 00
// one row per variable
end
...
0@ = @my_vars
0@ /= 4
0@ += 1 // var index in the buffer
&0(0@,1i) = 1
Still complicated? Then you need to wait when both game limit and the compiler will be updated. Not sure how soon it will happen but I've got your request.

I can hack add a new data type to game very quickly within one day in FLA.

Similarly adding a new data type to Sanny Builder should be very easy, it's just a matter of different data type to be used if needed (global variable offset over 65556).

goodidea82
  • goodidea82

    SA Modder

  • Members
  • Joined: 13 Jun 2013
  • Germany

#636

Posted 08 October 2015 - 09:26 PM Edited by goodidea82, 08 October 2015 - 09:41 PM.

Thanks for the quick response. I need to pack for holiday so here is a quick reply.

 

Indeed it's about extending SA's scm with the full scms from VC, LC, and why not VCS and LCS. I'm trying to figure out what would be the easiest and safest way to do that (I'm not making a commitment :-) ). A proof of concept for one of the scms would have to be done first. Then further scms could be added the same way. The basic ideas are the following:

- Automatically transform all global variables to new global variables, so that the global variables of SA, VC, LC etc do not overlap. Also, automatically rename labels, and stuff I didn't think about yet.

- Automatically replace all cleo opcodes that depend on game-specific properties/behavior with new opcodes which will be provided as a cleo plugin. These new opcodes will be wrappers that call the original opcodes and apply game-specific transformations to parameters and to return values, e.g.: transform coordinates, map IDs to new IDs, map strings to new strings, map various other values. Theses mapping will not be hard-coded. The cleo plugin will read these mappings from ini-files, so they can be configured for different targets (e.g. SAxVCxLC). The nice thing about this is that in the beginning default mappings can be used that do not require the entire game infrastructure. For example, in the beginning all car model IDs in the VC-scm can be mapped to one car ID that exists in SA. Later the details can be worked out.

- Cutscene opcodes will be provided in a separate cleo plugin allowing different implementations. E.g. one plugin may allow playback of recorded videos, and perhaps someday a plugin will be created that plays real cutscenes.

 

 

The problem with the 1000 local variables is that this would require understanding the code. If a global variable is shared between missions, or mission and main, and we separate them, then this will be a bug and it will be too difficult to find it. As you pointed out, it's a dangerous and complicate way, and therefore not an option.

 

The arrays could be an option if you think it is easy to automatically transform the code and replace global variables with arrays. I don't know if they behave like global variables under all aspects, e.g. when a game is saved. Let us know if you still recommend this approach more than extending the the global variable space. You say that $25000 = 1 should work. Isn't 25000 the address of the global variable? Shouldn't this give an __int16 overflow and map to a variable in the 2^16/4 space? I have done several tests (starting from here) and the conclusion so far is that it does not work.

  • fastman92 likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#637

Posted 10 October 2015 - 11:47 AM Edited by OrionSR, 10 October 2015 - 07:02 PM.

I found another odd issue with recompiling [codes taken from an] original main.scm [and recompiled into cleo] scripts for San Andreas. The random model car generators in Angel Pine will be missing without a few changes as the decompile/recompile process is changing -1 into 1239, and invalid vehicle model. The #INFO Cargens either don't get created or don't get saved. For now I'm just using search (#INFO) and replace (-1).

 

Update: Problem was using #INFO model in cleo script, not main.scm.

// These don't work
014B: create_car_generator -2151.303 -2440.136 29.822 angle 324.7583 model #INFO color -1 -1 force_spawn 0 alarm 0 doorlock 0 delay 0 10000 store_to $5277 
014B: create_car_generator -2147.038 -2443.752 29.822 angle 324.7583 model #INFO color -1 -1 force_spawn 0 alarm 0 doorlock 0 delay 0 10000 store_to $5278 
014B: create_car_generator -2140.979 -2448.733 29.822 angle 144.7583 model #INFO color -1 -1 force_spawn 0 alarm 0 doorlock 0 delay 0 10000 store_to $5279 

I need to specify the -1 value for random vehicles explicitly.

// Random models in Angel Pine: -1
014B: create_car_generator -2151.303 -2440.136 29.822 angle 324.7583 model -1 color -1 -1 force_spawn 0 alarm 0 doorlock 0 delay 0 10000 store_to $5277 
014B: create_car_generator -2147.038 -2443.752 29.822 angle 324.7583 model -1 color -1 -1 force_spawn 0 alarm 0 doorlock 0 delay 0 10000 store_to $5278 
014B: create_car_generator -2140.979 -2448.733 29.822 angle 144.7583 model -1 color -1 -1 force_spawn 0 alarm 0 doorlock 0 delay 0 10000 store_to $5279 

I believe this is the process for the Info pickups, but I haven't examined the code in hex.

// Originally pickup model is:
0213: create_pickup -1 type 3 at 2027.77 -1420.52 16.49 store_to $669 // reference
0213: create_pickup -1 type 3 at 1180.85 -1325.57 13.08 store_to $670 
0213: create_pickup -1 type 3 at 1550.68 -1675.49 15.01 store_to $671 
0213: create_pickup -1 type 3 at 2431.17 -1668.75 13.04 store_to $124 
// Decompiled text is:
0213: create_pickup #INFO type 3 at 2027.77 -1420.52 16.49 store_to $PICKUP_INFO_HOSPITAL 
0213: create_pickup #INFO type 3 at 1180.85 -1325.57 13.08 store_to $PICKUP_INFO_HOSPITAL_2 
0213: create_pickup #INFO type 3 at 1550.68 -1675.49 15.01 store_to $PICKUP_INFO_POLICE 
0213: create_pickup #INFO type 3 at 2431.17 -1668.75 13.04 store_to $PICKUP_INFO_CONVERSATION 
// Compiled as model id of info icon. (untested for pickup)
0213: create_pickup 1239 type 3 at 2027.77 -1420.52 16.49 store_to $PICKUP_INFO_HOSPITAL 
0213: create_pickup 1239 type 3 at 1180.85 -1325.57 13.08 store_to $PICKUP_INFO_HOSPITAL_2 
0213: create_pickup 1239 type 3 at 1550.68 -1675.49 15.01 store_to $PICKUP_INFO_POLICE 
0213: create_pickup 1239 type 3 at 2431.17 -1668.75 13.04 store_to $PICKUP_INFO_CONVERSATION 

The other instance of #INFO in an original SA main.scm shouldn't matter as the field is reported to be unused, and new Sanny gets it right away.

// 073E's model field is reported as unused
073E: get_car_in_sphere -1577.942 52.6333 16.3281 radius 4.0 model #INFO handle_as $TEMPVAR_ACTOR_CAR // Sanny v3.0.4,  SASCM.INI 14.6.2013
073E: get_random_car_in_sphere_no_save -1577.942 52.6333 16.3281 radius 4.0 model -1 store_to $TEMPVAR_ACTOR_CAR // Sanny v3.2.2, SASCM.ini 24.2.2014, SA SCR 

Seemann
  • Seemann

    Ruhe

  • GTA Mods Staff
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"
    Contribution Award [Mods]
    Helpfulness Awards [Mods]

#638

Posted 10 October 2015 - 03:31 PM Edited by Seemann, 10 October 2015 - 03:32 PM.

When Sanny's compiler finds a model name (#INFO) it acts in the following way:

1. Searches the name in the list of models defined in the default.ide (default.dat => default.ide, peds.ide, vehicles.ide for SA). It found, the model name is converted to the id.

2.1 If not found, and this is an headerless file (a DEBUG option SKIP_SCM_HEADER is on, or the $E, $CLEO directives used), it tries to find the model by scanning all the ide files like with the Ctrl+Alt+H feature. If not found, the compiler throws an exception.

2.2 If the current file has a header (no explicit directives are set), it tries to find the model in the DEFINE OBJECT list. If not found, it adds it there, otherwise it uses an index of the object in that list (-1 for #INFO).

Based on that, I would assume that you're compiling a headerless file and the compiler replaces #INFO with it's actual id (1239), not trying to add into the DEFINE OBJECT list, which is the common way for a main.scm. Checkout the conditions I described (a DEBUG option SKIP_SCM_HEADER is on, or the $E, $CLEO directives used), maybe something is valid for you.
  • AnotherGamer likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#639

Posted 10 October 2015 - 06:58 PM

Oh... yeah. Gotcha. My mistake. The errors and test above was using codes pulled from a decompiled main and pasted into a cleo script.  Based on your description I assume that #INFO would have recompiled to -1 for both pickups and vehicles if used in an actual main.scm. I don't see a point in running an actual test as long as observations are matching expectations. I'll just learn to manage my info models properly when using cleo.


Seemann
  • Seemann

    Ruhe

  • GTA Mods Staff
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"
    Contribution Award [Mods]
    Helpfulness Awards [Mods]

#640

Posted 11 October 2015 - 11:54 AM

Interesting observation anyway. Some opcodes don't use negative indices for the model parameter, only allow -1 and positive values, such as 014B. A decompiler should not replace -1 with #INFO there.

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#641

Posted 11 October 2015 - 09:42 PM

My thought was that a model ID of -1 would decompile as something like #DEFAULT, and always recompile back into -1, but I'm not sure how this would effect the larger picture. It seems odd that if I want to use the info icon model for an object in my custom main script I (probably) need to specific the model number.

 

Other observations:

 

Sanny is compiling #INFO in main.scm files to -1 as described.

Pickups codes with a -1 model create pickups with the info icon ID of 1239.

Pickups are not terribly picky about which model is assigned.

 

I doubt a cargen code would create a generator of this type but, the cargens use the negative values of car model IDs to flag a recently spawned random model.


Silent
  • Silent

    Altering R* Vision™ since 2008

  • GTA Mods Staff
  • Joined: 01 Feb 2010
  • Poland
  • Contribution Award [Mods]
    Best Script/Plugin 2014 [SilentPatch]
    Most Respected 2014
    Most Helpful [Mods] 2014
    Most Helpful [GTA] 2013
    Most Helpful [Mods] 2013
    Most Talented [Modding] 2013
    Best Map 2013 [ViceCityStories PC Edition]
    Best Vehicle 2013 [III Aircraft]
    Most Helpful [Mods] 2012
    Modder of the Year 2012

#642

Posted 11 October 2015 - 11:34 PM

It's nothing but a coincidence - #INFO is the first referenced model in the SCM, hence it got assigned to -1.

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#643

Posted 12 October 2015 - 05:09 AM Edited by OrionSR, 12 October 2015 - 05:28 AM.

Okay, okay. I finally followed the logic string through define objects. It seems my best options are to 1) get a time machine and talk Rockstar into defining #RANDOM as -1 to make decompiling easier, or 2) manage my vehicle models properly in cleo scripts. When I get the time machine working is there anything else I should mention?

 

I just noticed that I can use #HEALTH and #BRIBE in my cleo scripts. I got used to using the model numbers and didn't notice the change. Is this why I didn't notice a problem with #INFO in my cleo script before?


Seemann
  • Seemann

    Ruhe

  • GTA Mods Staff
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"
    Contribution Award [Mods]
    Helpfulness Awards [Mods]

#644

Posted 12 October 2015 - 06:34 PM

That's my fault. I should distinguish model parameters for object opcodes (such as pickups) and actors/cars. Objects can use negative indices (-1 for #INFO, -2 for #KEYCARD, etc) (do they use actual ids in the original main.scm?), and actors and peds can only use positive ids and -1 for the 'any model value' in some cases (i.e. 014b). But I used the only data type for all them in the INI.

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#645

Posted 12 October 2015 - 08:02 PM Edited by OrionSR, 12 October 2015 - 11:30 PM.

(do they use actual ids in the original main.scm?)

It doesn't look like it. I went searching for the info icon codes in the main.scm and I'm pretty sure the create pickup command says -1 but the define object line somehow translates that into the proper model ID when it's used to create pickups. I'm expecting all of the defined objects in main to compile to their defined values. Except for #INFO, this has the benefit of decompiling -146 from main into #HEALTH in Sanny which now compiles to 1240 for cleo. So, everything is awesome.

 

Oh, you were specific about objects. Um... Should I see what I can find for create objects ID codes?

 

Added:

0107: $2706 = create_object #AD_FLATDOOR at 1833.36 -1995.45 12.5

This line was decompiled from -3 in SCM and compiles to 3061 in cleo.


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#646

Posted 16 October 2015 - 01:00 AM Edited by OrionSR, 16 October 2015 - 06:12 PM.

Bug: Missing Splash Screen and Help-About with Multi-Monitor System

 

I tried logging into the bug tracker but must have messed up the sign up process, anyway...

 

Description: With 2 monitors side by side the splash screen and Help-About screens are displayed centered, so the window is split between monitors. With 3 monitors side by side by side both windows are missing, which leaves Sanny going boing boing boing until Enter is pressed to clear the About dialog box and no way to check the version without shutting down a monitor or two.

 

Workaround: Disable a monitor or two long enough to check Sanny's version.

 

Bug 0000033: Models are not loaded for LCS/VCS - Extract the IDE files from disk and alter custom.dat to load the files? I could bump this up on my edit mode project list. I think I have what is needed on hand. Can custom.dat read .dat files for a list of IDE references? Probably not; I'm just looking for ways to make IDE loading from the edit mode folder as easy as it is when the files are found in the game directory. Never mind, not so easy after all.

DAT DATA\DEFAULT.DAT
DAT DATA\GTA3.DAT

Suggestion: Extend Mode for Text Selection. I've been searching Sanny's help files and can't seem to find what I'm looking for.

 

"Extend Mode" is enabled with F8 as documented for MS Word, but I'm more familiar with the old Ctrl-K style block commands used in Wordstar. Basically, I want a way to select large blocks of text, a whole mission usually, without having to click and drag or shift-click the entire selection. Extend mode allows me to set an anchor at the cursor location that will select all text from there to wherever else is selected. So I could use bookmarks, goto, search or manual scrolling with mouse clicks or cursor controls to select whatever text I want.


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#647

Posted 19 October 2015 - 12:28 AM Edited by OrionSR, 22 October 2015 - 02:56 AM.

Can you provide more information on how Sanny's Edit Modes work?

<game shortcut="Test" title="SAPC Test" mode="sa_mobile" type="">

What are the differences between the various "mode" settings? So far I've got:

"sa" mode won't read custom.dat

"sa_mobile" mode won't Copy + Paste

"sa_mobile" mode looks for american.gxt in the edit mode folder.

 

What would be required to make a ps2 or vc_mobile "mode"? Is there a way to change how a "mode" behaves?

<data>@sb:\data\sapctest\support\</data>

What files would be expected to be found in the support\ folder? (Both data\ and files\ folder names have a standard game use.) So far I've got:

opcodes.txt

GamePath=C:\GTA San Andreas

What files are referenced from this path? It looks like:

data\default.dat

data\gta.dat

relative paths for all IDE files defined in those two files

 

For Copy + Paste:

data\script\main.scm

data\script\script.img

cleo\

 

What is the purpose of these edit mode files?

sa_mobile: 130.bin, 137.bin

sa and sa_mobile: debug.bin


Seemann
  • Seemann

    Ruhe

  • GTA Mods Staff
  • Joined: 03 Sep 2004
  • Russia
  • Best Tool 2013 "Sanny Builder"
    Contribution Award [Mods]
    Helpfulness Awards [Mods]

#648

Posted 01 November 2015 - 02:05 PM

Well, that's a tough question. An edit mode is a set of rules telling Sanny how to de-/compile scripts and read the needed files. It's very hardcoded feature and you can't make your own mode. I made them to best fit the different games. The mobile mode is made based on an assumption that the game is not available on the user PC, so the game files must be read from the Sanny's folder instead, and also the game cannot be started with the F8 feature.

In the sa_mobile mode the compiler differently treats some opcodes: 0A66, 0A67, 0A6E, which are used for the debug purposes. .bin files contain a plain dump from the scm file for these opcodes data. debug.bin is an array of 128-bytes raw data used by 05B6 (sa) or 0A66 (sa_m), 130.bin and 137.bin are arrays of 130-bytes and 137-bytes raw data respectively used by 0A67 and 0A68 in the sa mobile version. The compiler just copies data from this file into an output scm file. These files are only made once and not expected to be edited.

The data path is used differently. It's mainly used for non-PC games to allow Sanny to read the game data. It's valid for english.gxt for lcs, vcs, american.gxt for sa_mobile, .bin files, models.ide for VCS.

goodidea82
  • goodidea82

    SA Modder

  • Members
  • Joined: 13 Jun 2013
  • Germany

#649

Posted 07 November 2015 - 08:20 AM Edited by goodidea82, 07 November 2015 - 08:21 AM.

SannyBuilder crashes when compiling a big file.

 

I have extended main.scm from gta SA with approximately 104.000 LOC of automatically generated code. SB is capable of compiling the code with the following statistics: MAIN size is 778423; Largest mission: 68439; largest script 35122.

 

When I increase the size of the code, approximately 120.000 LOC, then I get the following crash:

 

"Sanny Builder 3 - application error: Access violation at address 00405474 in module 'sanny.exe'. Read of address 010002F4."

 

The code tests the array-approach that you have suggested in this post. You can download the code and the python script that generated the SCM code here:

http://www.file-uplo...aytest.zip.html

 

The code is structured as follows:

main.txt
  ...
  {$Include hexfile.txt}
  ...
  {$INCLUDE MyThreads.txt}
  ...
  {$INCLUDE MyMainPart.txt}
      ...
      {$INCLUDE writeReadTest0.txt}
  ...

In the python script you can control the size of the generated code with the variable varnum (for number of variables) at the beginning of the script. When set to 8000 the files compiles, when set to 9000, then SB crashes.

 

This problem is independent from which approach is used to solve the problem with the number of global variables. We need SB to be able to compile any size of code.

  • PlatinumSerb likes this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users