sannybuilder/dev

typed variable declaration should not stomp on timer variables

x87 opened this issue · 2 comments

x87 commented

#32
Skip TIMERA and TIMERB when allocating the next index It happens e.g. when using a lot of custom variables in a mission code.

x87 commented

Managing variable buffer overflow (too many local vars).

Precondition:

  • If this is GTA 3 or GTA VC
    • limit number of available indexes to 16 (from 0@ to 15@)
    • 16@ and 17@ are reserved for timers.
  • if this is SA
    • if this is a regular script
      • limit number of available indexes to 32 (from 0@ to 31@)
      • 32@ and 33@ are reserved for timers.
    • if this is a mission script
      • limit number of available indexes to 990 (from 34@ to 1023@)
      • 32@ and 33@ are reserved for timers.
  • if this is SA Mobile
    • if this is a regular script
      • limit number of available indexes to 40 (from 0@ to 39@)
      • 40@ and 41@ are reserved for timers.
    • if this is a mission script
      • limit number of available indexes to 982 (from 42@ to 1023@)
      • 40@ and 41@ are reserved for timers.
  • If this is LCS or VCS
    • limit number of available indexes to 96 (from 0@ to 95@)
    • -1@ and -2@ are reserved for timers.

Validation rule:

  • if Ranges check is ON
    • and next requested index overruns the buffer (see ranges above)
    • OR the array size is larger than the number of remaining indexes
      • throw an error
x87 commented

this validation will be annoying without #145 . however current behavior is even worse, as new declared variables go beyond the limit without any warning (35@, 36@, etc)