· 9 years ago · Nov 25, 2016, 09:46 AM
1//v0.67
2// 16-JUNE-2016
3
4//////////////////////////////////////////////
5/// System Limitations, Minimums, Maximums ///
6//////////////////////////////////////////////
7
8 Maximum numeric literal: 214747.9999
9
10Ints, Floats, Arrays
11
12 Maximum float: -214747.9999 to 214747.9999
13 Maximum int -214747 to 214747
14 Maximum array size (number of indices): 214747
15
16 * This further includes arrays with a type of npc, leweapon, eweapon, item, and itemdata.
17 Maximum value in an array index: Same as float, or int; based on type declaration.
18 Maximum size of string index: 214747
19 Maximum string length: 214747
20 Maximum simultaneous arrays in operation: 4095
21
22Counters, Tiles, Combos, Strings
23
24 Maximum Tiles: 65519
25 Maximum Combos: 65279
26 Maximum Counter Value: 0 to 32767
27 Maximum strings in string editor: ( 65519 )
28
29 Largest tile ID (ZQ Editors): 32767 ?
30
31 The largest value that can be referenced in the ZQ item, enemy, and other editors.
32
33 --> I seem to remember a problem calling high values.
34
35Pointers and Objects
36
37 Maximum number of item pointers (on-screen items) at any one time: 255
38 Maximum number of lweapon pointers (on-screen lweapons) at any one time: 255
39 Maximum number of eweapon pointers (on-screen eweapons) at any one time: 255
40 Maximum number of npc pointers (on-screen NPCs) at any one time: 255
41 Maximum number of ffc (on-screen FFCs) pointers at any one time: 32
42 Array Pointers (maximum number of arrays in operation): 4095
43
44 Maximum total (cumulative) number of 'object' pointers at any one time: 1020
45 * 255 each, npc, lweapon, eweapon, item + 32 (ffcs)
46
47 --> ZC separates pointers by class. All pointers are stored in vectors, with pointer IDs ranging from 1 to 255.
48
49 Maximum Z Height of a Screen Object (npc, weapon, item) or Link: 32767. Values above this wrap to -32767, which is reset to 0 every frame.
50
51Compiler
52
53 Maximum constants (any scope): Unlimited. (Constants are converted to their true value at compilation, and are not preserved by name.)
54 Maximum global variables: 255*
55 Maximum global functions: 4,294,967,295 (2^32-1).
56 Note that this is limited by the filesystem, as each function requires its ASCII size in bytes,
57 and is stored in the quest file. Many filesystems have a file size limit, that restricts it.
58 At the smallest function size, max functions would use ~40GB of space.
59 It is further restricted by the maximum buffer size at between 18MB and 22MB.
60
61Script Drawing
62
63 Maximum number of drawing commands per frame: 1000
64 Maximum distance (x,y) for drawing, including off-screen areas (and bitmaps): -214747.9999 to 214747.9999 (X and Y)
65 Maximum Z Height for 3D Drawing: 214747.9999
66
67 --> Negative Z Height is effectively '0'.
68
69Stack Operation
70
71 Maximum number of concurrent stacks: ?
72 --> Essentially, the maximum number of concurrent scripts; except that item scripts share one stack.
73
74 Maximum variables in operation at any given time: 255* (gd1-gd255)
75 Maximum variables per script: 255*
76 Maximum function calls per script ( 127* )
77 *Note: 255 variables will compile, but fail to run. A safe maximum is closer to 245, to allow instructions and function calls on the stack
78 *Note: Both variables, and function calls share registers (global variables are gd registers), and thus cumulatively count against their combined caps (within a register type). See: ZASM_Registers
79 --> How are these tabulated at compilation, and is there a strict ratio ( function call:variable ) ?
80 --> Script-scope variables use gd registers. Thus, you need to retain free registers for scripts to run.
81
82 Maximum script buffer size: ~18MB, including code imported with the 'import' directive.
83 --> Maximum line count is also limited, but it is restricted by being a signed int.
84 --> Thus, max line-count is somewhere around 2,147,483,647 lines, however,
85 this is still restricted by the 18MB buffer size.
86
87 Maximum number of instructions: 2^32-1 * Max Scripts
88 Maximum instructions per script: 4,294,967,295 (2^31 - 1)
89 Maximum instructions per frame: Effectively unlimited, save by instructions per script.
90
91 Maximum number of scripts ?
92 Max ffc scripts at compilation ?
93 Max Item scripts at compilation ?
94 Max global scripts at compilation ?
95 --> I know this is unlikely to ever be reached.
96
97 Maximum function calls per script: Limited by maximum instructions, and available gd registers.
98 Maximum local functions per script: ? Effectively unlimited, and tied to maximum functions (see above).
99
100Maximum Values (Binary, Hex) for Use as Flags
101
102 The largest literal that you can use as a flag, binary, is: 110100011010111101
103 ( dec. 214717, hex 0x346BD )
104
105 The largest true binary value (all ones) is 11111111111111111
106 ( dec. 131071, hex 0x1FFFF )
107
108 While these are certainly possible, the largest absolutely useful value, that maximises all places in
109 both binary, and hex, and thus is the true flag maximum is: 65535 (decimal).
110 This becomes 1111111111111111b, or 0XFFFF, which means that you may use each place to its full potential,
111 at all times.
112
113 Thus, the maximum useful flags are a width of 16-bit, and are represented below.
114
115 Max Flag
116
117 Binary Hexadecimal Decimal
118 1111111111111111b 0XFFFF 65535
119
120
121//! A list of all known system limitations.
122
123################################
124## COMPILER ERROR DEFINITIONS ##
125################################
126These errors are generated by the parser, during compilation.
127
128Error codes are broken down by type:
129P** Preprocessing errors.
130S** Symbol table errors.
131T** Type-checking errors.
132G** Code Generation Errors
133** Array Errors ---We need to change these to A**
134
135Errors of each class are given unique numerical identifiers, ranging from 00 to 41, such as P01, or G33.
136The letter code will give you an indication of the type of error, and the full code will give you specific details.
137
138In ZQuest v2.50.2 and later, the compiler will report name of the script that generated (where possible).
139This applies only to errors caused by scripts, and not errors at a 'global' level, such as global functions.
140Thus, if you are using 2.50.2, or later, an error without a script name is likely to be caused at global scope.
141
142#####################
143## Specific Errors ##
144## Preprocessing ##
145#####################
146
147P00: Can't open or parse input file!
148
149Your script file contains illegal characters, or is not plain ASCII Text.
150
151Otherwise, it is possible that the compiler is unable to write to the disk, that the disk is out of space.
152
153Last, your file may be bad, such as a file in the qrong encoding format (not ASCII text).
154
155P01: Failure to parse imported file foo.
156
157Generally means that you are trying to call a file via the import directive that does not exist; or that
158you have a typo in the filename, or path.
159
160
161P02: Recursion limit of x hit while preprocessing.
162
163Caused by attempting to import a file recursively. For example:
164
165If you declare: import "script.z" ... and ... the file 'script.z' has the line: ' import "script.z" ' inside it.
166
167This error should no longer exist! Recursive imports should resolve as duplicate finction/variable/script declarations.
168
169Error P03: You may only place import statements at file scope.
170
171Import directives ( import "file.z" ) may only be declared at a global scope, not within
172a function, statement, or script.
173
174P35: There is already a constant with name 'foo' defined.
175You attempted to define the same constant more than once.
176The identifier (declared name) of all constants MUST be UNIQUE.
177
178
179#####################
180## Specific Errors ##
181## Symbol Table ##
182#####################
183
184S04: Function 'foo' was already declared with that type signature.
185
186You attempted to declare a function with the same parameters twice, int he same scope.
187This can occur when using different types, if the compiler cannot resolve a difference between the signatures.
188
189To fix this, remove one function,or change its signature (the arguments inside the parens) so that each is unique or;
190If you declare a functiona t a global scope, and the same at a local scope, remove one of the two.
191
192Note that return type is NOT enough to distinguish otherwise identical function declarations and that 'int' and 'float'
193types are the same type internally, so int/float is identical insofar as the signature is concerned.
194
195If two function type signatures are identical except that one has a parameter of type float where the other has the
196same parameter of type int, you will have a conflict.
197
198There are two additional subtle situations where you might get a conflict:
199
2001. A function declared at file scope might conflict with a function that's implicitly added to file scope
201by the preprocessor because of an import statement.
2022. A function might conflict with one already reserved by the ZScript standard library (std.zh).
203
204S05: Function parameter 'foo' cannot have void type.
205
206You cannot set a parameter (argument of a function) as a void type. e.g.:
207int foo(void var){ return var+1; }
208
209This is illegal, and the param 'var' muct be changed to a legal type.
210
211S06: Duplicate script with name 'foo' already exists.
212
213Script names must be wholly unique. For example, if there's already an ffc script named 'my_script' you cannot
214declare an item script with the name 'my_script'.
215
216S07: Variable 'foo' can't have type void.
217
218Variables at any scope may not have a void type. Only functions may have this type.
219
220S08: There is already a variable with name 'foo' defined in this scope.
221
222Variable identifiers must be unique at any given scope. Thus, this is illegal:
223
224ffc script my_ffc(){
225 void run(int x){
226 int v = 1;
227 int w = 10;
228 int x = 0.5;
229 int y = 13;
230 int z = v+w+x+y;
231 Trace(z);
232 }
233}
234
235As the variable 'x' is declared in the params of the run() function, it cannot be declared inside the function with
236the same identifier (name).
237
238
239S09: Variable 'foo' is undeclared.
240
241You attempted to reference a variable identifier (namme) that has not been declared.
242Usually this is due to a typo:
243
244int var;
245if ( val > 0 ) Link->X += var;
246
247Here, 'val' will return this error, as it was not declared.
248
249A variable with the give name could not be found in the current or any enclosing scope. Keep in mind the following subtleties:
2501. To access a different script's global variables, or to access a global variable from within a function delcared at file scope,
251you must use the dot operator: scriptname.varname.
2522. To access the data members of the ffc or item associated with a script, you must use the this pointer: this->varname.
2533. ZScript uses C++-style for loop scoping rules, so variables declared in the header part of the for loop cannot be
254accessed outside the loop:
255
256Code:
257
258for(int i=0; i<5;i++);
259i = 2; //NOT legal
260
261S10: Function 'foo' is undeclared.
262
263You attempted to call a function that was not declared. This is usually due to either a typo in your code, or failing
264to import a mandatory header. Check that you are importing 'std.zh' as well, as failing to do this will result in a slew
265of this error type.
266
267S11: Script 'foo' must implement void run().
268
269Every script must implement run() function call. The signature may be empty, or contain arguments.
270Zelda Classic uses all the code inside the run() function when executing the script, so a script without
271this function would do nothing, and will return an error.
272
273S12: Script 'foo's' run() must have return type void.
274
275Is this error even implemented? The run() function is automatic, and never declared by type, unless the user tries to declare
276a separate run(params) function with a different type.
277
278S26: Pointer types (ffc, etc) cannot be declared as global variables.
279
280/* It is illegal to declare a global variable (that is, a variable in script scope) or any type other than int, float, and bool.
281Why? Recall that global variables are permanent; they persist from frame to frame, screen to screen.
282Pointer types, on the other hand, reference ffcs or items that are transitory; they become stale after a single WAITFRAME,
283so it makes no sense to try to store them for the long term.
284*/
285
286This explanation may no longer be true, as pointers may no longer be dereferenced by Waitframe(),
287and global pointers may also be implemented in a future version.
288
289
290S30: Script foo may have only one run method.
291
292You may not call a run() function more than once per script.
293Your run method may have any type signature, but because of this flexibility, the compiler cannot
294determine which run script it the "real" entry point of the script if multiple run methods are declared.
295
296S32: Script foo is of illegal type.
297
298The only legal script tokens are: global, ffc, and item. You cannot declare other types (such as itemdata script).
299
300S38: Script-scope global variable declaration syntax is deprecated; put declarations at file scope instead.
301You cannot declare a global variable in a global script, outside the run function.
302
303Example:
304
305global script active{
306 int x;
307 void run(){
308 x = 16;
309 }
310}
311
312This is ILLEGAL. The declaration of variable 'x' must either be at a global scope, or at the scope of the
313run function. Do this, instead:
314
315int x;
316global script active{
317 void run(){
318 x = 16;
319 }
320}
321
322This creates a global variable at the file scope.
323
324S39: Array 'foo' can't have type void.
325Arrays may be types of int, float, bool, ffc, item, itemdata, npc, lweapon, or eweapon; but arrays
326with a void type are illegal.
327
328S40: Pointer types (ffc, etc) cannot be declared as global arrays.
329As of 2.50.2, global array declarations may only have the following types:
330int, float, bool
331Any other type is illegal.
332
333S41: There is already an array with name 'foo' defined in this scope.
334As with variables, and functions, arrays must have unique identifiers within the same scope.
335
336###################
337## LEXING ERRORS ##
338###################
339L24: Too many global variables.
340
341The assembly language to which ZScript is compiled has a built-in maximum of 256 global variables. ZScript can't do anything if you exceed this limit.
342
343#####################
344## Specific Errors ##
345## Type Checking ##
346#####################
347
348T13: Script 'foo' has id that's not an integer.
349
350/* I do not know what can cause this error, or if it ever occurs. */
351
352T14: Script 'foo's' id must be between 0 and 255.
353
354Occurs if you try to load more than 256 scripts of any given type at any given time.
355/* The maximum number of concurrent scripts (of any given type?) is 256. */
356
357T15: Script 'foo's' id is already in use.
358You attempted to laod two scripts into the same slot.
359/* I do not know if this is EVER possible. */
360
361T16: Cast from foo to bar.
362
363The only "safe" implicit casts are from int to float and vice-versa (since they are the same type),
364and from int (or float) to bool (0 becomes false, anything else true).
365The results of any other kind of cast are unspecified.
366
367/*
368Is this error still in effect? Casting from npc to itemdata, or others, usually results in a different error code.
369Further, Cannot cast from wtf to int, is a thing.
370*/
371
372Explicit casts are unimplemented and unnecessary.
373
374T17: Cannot cast from foo to bar.
375
376You attempted to typecast illegally, such as tyring to typecast from bool to float.
377
378T18: Operand is void.
379Occurs if you try to use a void type value in an operation.
380/* I do not know if this is EVER possible. */
381
382T19: Constant division by zero.
383
384While constant-folding, the compiler has detected a division by zero
385
386 Example:
387 const int MY_CONSTANT = 0;
388 ffc script foo{
389 void run(){
390 int x = 6;
391 Link->Jump = x / MY_CONSTANT;
392 }
393 }
394
395Correct the value of your constant. Perhaps you meant to use a variable?
396
397Note that only division by a CONSTANT zero can be detected at compile time.
398The following code, for instance, compiles with no errors but will generate script errors during execution.
399
400 Example:
401
402 int x = 0;
403 int y;
404 y = 1/x;
405
406
407
408
409T20: Truncation of constant x.
410
411Constants can only be specified to four places of decimal precision, withing the legal range of values.
412Any extra digits are simply ignored by the compiler, which then issues this warning.
413
414Any values greater than MAX_CONSTANT, or less then MIN_CONSTANT will result in this error.
415
416## Applies to variables, but does not throw an error:
417Both floats and ints can only be specified to four places of decimal precision.
418Any extra digits are simply ignored by the compiler, which then issues this warning.
419
420Any values greater than MAX_VARIABLE, or less then MIN_VARIABLE will result in this error.
421
422########
423
424T21: Could not match type signature 'foo'.
425
426When calling a function, you used the wrong number, or types, of parameters.
427The compiler can determine no way of casting the parameters of a function call so that they
428match the type signature of a declared function.
429
430For instance, in the following snippet
431Code:
432
433int x = Sin(true);
434
435since true cannot be cast to a float, this function call cannot be matched to the library function Sin, triggering this error.
436
437
438T22: Two or more functions match type signature 'foo'.
439
440If there is ambiguity as to which function declaration a function call should matched to,
441the compiler will attempt to determine the "best fit."
442These measures are however occasionally still not enough. Consider for instance the following snippet:
443Code:
444
445void foo(int x, bool y) {}
446void foo(bool x, int y) {}
447foo(1,1);
448
449matching either of the two foo declarations requires one cast, so no match can be made.
450In contrast, the following code has no error:
451Code:
452
453void foo(int x, bool y) {}
454void foo(bool x, bool y) {}
455foo(1,1);
456
457(The first foo function is matched.)
458
459It is best to design functions so that noambiguity is possible, by addign extra params, to change the signature or by using
460different identifiers (function names) when using more params is not desirable.
461
462T23: This function must return a value.
463
464All return statements must be followed by an expression if the enclosing function returns a value.
465Note that the compiler does NOT attempt to verify that all executions paths of a function with non-void
466return type actually returns a value; if you fail to return a value, the return value is undefined.
467For instace, the following is a legal (though incorrect) ZScript program:
468
469int foo() {}
470
471/* I don't believe anythign ever returns this error.
472I've seen functions with int/float/bool types, and no returns compile, without errors.
473Perhaps we should fix this, and issue a warning during compilation? */
474
475T25: Constant bitshift by noninteger amount; truncating to nearest integer.
476
477The bitshift operators (<< and >>) require that their second parameters be whole integers.
478
479T27: Left of the arrow (->) operator must be a pointer type (ffc, etc).
480
481It makes no sense to write "x->foo" if x is of type int.
482You may only use the dereference (->) operator on pointer types.
483
484T28: That pointer type does not have a function 'foo'.
485
486You tried to use the dereference operator (->) to call a function that does not exist for the pointer type being dereferenced.
487Check the list of member variables and functions and verify you have not mistyped the function you are trying to call.
488
489This generally occurs when calling internal functions, using the incorrect class, or namespace, such as:
490
491Game->Rectangle() instead of Screen->Rectangle()
492
493The extra std.zh component 'shortcuts.zh' assists in preventing this error type.
494
495
496T29: That pointer type does not have a variable 'foo'.
497
498You tried to use the dereference operator (->) to call a member variable that does not exist for the pointer type being dereferenced.
499Check the list of member variables and verify you have not mistyped the variable you are trying to call.
500
501This generally occurs when calling internal variables, using the incorrect class, or namespace, such as:
502
503Link->D[] instead of Screen->D[]
504
505/* The extra std.zh component 'shortcuts.zh' assists in preventing this error type.
506Probaby not, as this requires silly amounts of functions to handle variables with identical identifiers.
507C'est la vie. perhaps we'll do it, but I really am not fond of the idea. */
508
509As above, but the member variable you tried to access does not exist.
510
511Error T31: The index of 'foo' must be an integer.
512
513/* This has been deprecated, so who cares? */
514
515
516T36: Cannot change the value of constant variable 'foo'.
517
518You cannot assign a CONSTANT to another value.
519
520T37: Global variables can only be initialized to constants or globals declared in the same script.
521You cannot (directly) simultaneously declare, and initialise a global value using the value of a variable at
522the scope of another script, or function.
523
524Example:
525int x = script.a;
526ffc script foo{
527 int a = 6;
528 void run(){
529 for ( int q = 9; q < Rand(15); q++ ) a++;
530 }
531}
532
533This is ILLEGAL. You cannot initialise the value of the global variable 'x' using the local value
534of 'a' in the ffc script 'foo'.
535
536/* I believe this is deprecated, as I do not believe that script level declarations remain legal */
537
538T45 (old version, T38): Arrays can only be initialized to numerical values
539You attempted to declare an array using a floating point value (e.g. 10.5), constant or equation,
540rather than a numeric literal.
541
542
543 Consider that you want to declare an array with an explicit size of '40':
544 These are ILLEGAL:
545 int my_arr[26+14];
546 const int CONSTANT = 30;
547 int my_arr[CONSTANT];
548 int my_arr[CONSTANT/2+20]
549
550 YOu must declare an arrray with a numeric literal:
551 int my_array[40];
552 This is the only legal way to declare the size of an array as of 2.50.2.
553
554
555#####################
556## Specific Errors ##
557## @Generation ##
558#####################
559
560
561G33: Break must lie inside of an enclosing for or while loop.
562
563The 'break' keyword aborts the loop (in a for, while, or do statement) in which it is called.
564You must be in a loop to break out of one, so calling 'break' outside of a loop is illegal.
565
566
567G34: Continue must lie inside of an enclosing for or while loop.
568
569The 'continue' keyword halts a loop, and repeats the loop from its head (in a for, while, or do statement) in which it is called.
570You must be in a loop to continue one, so calling 'continue' outside of a loop is illegal.
571
572As the above error, but with the continue keyword. Continue aborts the current iteration of the loop and skips to the next iteration.
573
574
575##################
576## Array Errors ##
577##################
578
579Error A42 (old, Error O1): Array is too small. ( Converting to A42 in 2.50.3 )
580You attempted to declare an array, with a set of values, where the number of values in the set
581exceeds an explicit array size declaration:
582
583int foo[4]={1,2,3,4,5};
584The declared size is '4', but you tried to initialise it with five elements.
585
586/* THis doesn't seem right, as this seems to be covered by Err 02. Check the source to see what causes this. */
587
588Error O2: Array initializer larger than specified dimensions. ( Converting to A43 in 2.50.3)
589You attempted to initialise an array, with a set of values, where the number of values in the set
590exceeds an explicit array size declaration:
591
592int foo[4]={1,2,3,4,5};
593The declared size is '4', but you tried to initialise it with five elements.
594
595Error O3: String array initializer larger than specified dimensions, space must be allocated for NULL terminator.
596( Convering to A44 in 2.50.3 )
597YOu attempted to seclare a QUOTEDSTRING of an explicit size, but you didn;t add space
598for the NULL terminator; or you used more chars than you allocated:
599
600int my_string[17]="This is a string.";
601 THis allocates only enough indices for the chars, but not for the NULL terminator.
602 The array size here needs to be 18.
603int my_string[12]="THis is a string.";
604 You tried to initialise a QUOTEDSTRING that is longer than the array size.
605 The minimum array size for this is '18'.
606
607 It is generally best either to declare strings with an implicit size (set by the initialiser):
608 int my_string[]="This is a string";
609 This reads the nuber of chars, adds one to the count (for NULL), and sizes the array to 18.
610 ...or...
611 Declare the string with an arbitrarily large size:
612 int my_string[256]="This is a string";
613 This reserves 256 chars. Only 18 are used, and the rest of the indices
614 are initialised as '0' (NULL). YOu may later populate the unused space, if desired.
615
616
617#################
618## Misc Errors ##
619#################
620
621FATAL FATAL ERROR I0: bad internal error code
622A fallback error if no other type matches the problem.
623
624/* I have no idea what causes this. Be afraid, very afraid. */
625
626/* OTHER ERRORS
627Document any further error codes here.
628We need to convert the array errors from raw numeric, to A** codes.
629*/
630
631########################
632## OPERATIONAL ERRORS ##
633###################################################################################################
634## These errors occur only during the operation of script execution (i.e. when running a script, ##
635## in Zelda Classic while playing a quest). ##
636## --------------------------------------------------------------------------------------------- ##
637## In ZC versions 2.50.2, and later, operational script errors will return the ID of the script ##
638## from which they were generated. ##
639###################################################################################################
640
641//! These errors will be reported to allegro.log (or the ZConsole) when scripts run.
642
643
644
645////////////////////
646/// Stack Errors ///
647////////////////////
648
649 "Stack over or underflow, stack pointer = %ld\n"
650
651* !? How should I describe this, and give examples?
652
653 "Invalid ZASM command %ld reached\n"
654
655Stack instruction countber reached, or exceeded. The stack counter is an unsigned int, so it's maximum value is 65536.
656You have isused more instructiosn this frame than the instructon counter can ahndle. Look through your code for
657something that may be doing this.
658
659////////////////////
660/// Array Errors ///
661////////////////////
662
663 "Invalid value (%i) passed to '%s'\n"
664 "Invalid index (%ld) to local array of size %ld\n"
665
666You attempted to reference an array index that is either too small, or too large.
667Check the size of your array, and try again.
668Perhaps you have a for loop, or other loop that is parsing the array, and trying to read beyond its index ranges.
669
670
671 "Invalid pointer (%i) passed to array (don't change the values of your array pointers)\n"
672
673Array pointers values in operation are 1 through 4095, ( and 4096 to 8164? as declared global pointers ?).
674An array may not have a pointer of '0', nor may you reference an array for which a pointer does not exist.
675Often, this error is caused by attempting to reference an array that you created, without updating the saved game slot
676as the old save does not have the array allocated, but the script is attempting to reference its global ID.
677
678 "Script tried to deallocate memory at invalid address %ld\n"
679 "Script tried to deallocate memory that was not allocated at address %ld\n"
680
681/* Script attempted to change the value of an array index // that does not exist // due to the inability to declare an array
682because too many registers are in use?
683
684
685 "You were trying to reference an out-of-bounds array index for a screen's D[] array (%ld); valid indices are from 0 to 7.\n"
686You attempted to read, or write to a Screen->D[register] that was less than 1, or greater than 10.
687Check for loops, and vriables that read/write to Screen->D for any that can fall outside the legal range.
688
689 "Array initialized to invalid size of %d\n"
690You attempted to init array to a size less than 1, or a size greater than 214747, or;
691You attempted to init array with a constant, a variable, a formula, or with a floating point value.
692Arrays may ONLY be initialised with numeric literals (integers only) between 1 and 214747.
693
694 "%d local arrays already in use, no more can be allocated\n", MAX_ZCARRAY_SIZE-1);
695The maximum number of arrays in operation at one time is 4095.
696
697"Invalid pointer value of %ld passed to global allocate\n"
698 !
699
700/////////////////////////////
701/// Object Pointer Errors ///
702/////////////////////////////
703
704 "Invalid NPC with UID %ld passed to %s\nNPCs on screen have UIDs "
705 "Invalid item with UID %ld passed to %s\nItems on screen have UIDs "
706 "Invalid lweapon with UID %ld passed to %s\nLWeapons on screen have UIDs "
707 "Invalid eweapon with UID %ld passed to %s\nEWeapons on screen have UIDs "
708
709 "Script attempted to reference a nonexistent NPC!\n"
710 "You were trying to reference the %s of an NPC with UID = %ld; NPC on screen are UIDs "
711
712 "Script attempted to reference a nonexistent item!\n"
713 "You were trying to reference an item with UID = %ld; Items on screen are UIDs: "
714
715 "Script attempted to reference a nonexistent LWeapon!\n"
716 "You were trying to reference the %s of an LWeapon with UID = %ld; LWeapons on screen are UIDs "
717
718 "Script attempted to reference a nonexistent EWeapon!\n"
719 "You were trying to reference the %s of an EWeapon with UID = %ld; EWeapons on screen are UIDs "
720
721You attempted to reference a game object that has a maximum legal range of 1 to 255.
722It is possible that you tried to read outside that range, or that the pointer that you were loading is not valid.
723Check NumItems(), NumLWeapons(), NumEWeapons(0, and NumNPCs() before referencing them; and verify that the object ->IsValid()
724Check for loops that may attempt ro reference items outside of the range that actually exist.
725Look for any for loops that access these objects, that start, or end at zero.
726
727The best way to ensure this does not occur, is to make a for loop as follows:
728
729 for ( int q = 1; q < Screen->NumLWeapons; q++ )
730
731 //or//
732
733 for ( int q = Screen->NumLWeapons(); q > 0; q-- )
734
735...replacing NumLWeapons() withthe appropriate type that you are attempting to load.
736
737You may be attempting to refrence a pointer that has fallen out of scope.
738You may be attempting to reference a pointer that is no longer valid, or has been removed.
739Check ( pinter->IsValid() ) by itself, to ensure this does not occur:
740
741 if ( pointer->IsValid ) {
742 if ( pointer->ID == LW_FIRE ) //Do things.
743 }
744
745This helps to prevent loading invalid pointers.
746
747////////////////////////////////
748/// Maths and Logical Errors ///
749////////////////////////////////
750
751"Script attempted to divide %ld by zero!\n"
752"Script attempted to modulo %ld by zero!\n"
753
754"Script attempted to pass %ld into ArcSin!\n"
755"Script attempted to pass %ld into ArcCos!\n"
756"Script tried to calculate log of 0\n"
757"Script tried to calculate log of %f\n"
758"Script tried to calculate ln of 0\n"
759"Script tried to calculate ln of %f\n"
760"Script attempted to calculate 0 to the power 0!\n"
761"Script attempted to calculate square root of %ld!\n"
762
763Look for scripts that pass a variable into these functions, or use a variable in a mathematical operation, that
764may be zero at any point, and correct it to ensure that it is never zero, or that it is never illegal for the type of
765mathematical operation you wish to perform.
766
767Chweck for any hardcoded values, or constants that are in use with these functions that may be illegal, or irrational.
768
769////////////////////////////////
770/// System Limitation Errors ///
771////////////////////////////////
772
773"Couldn't create lweapon %ld, screen lweapon limit reached\n"
774"Couldn't create eweapon %ld, screen eweapon limit reached\n"
775"Couldn't create item \"%s\", screen item limit reached\n"
776"Couldn't create NPC \"%s\", screen NPC limit reached\n"
777
778You may create a maximum of 255 of any one object type on the screen at any one time.
779Look for anything that is generating extra pointers, and add a statement such as:
780 if ( Screen->NumNPCs() < 255 )
781
782 "Max draw primitive limit reached\n"
783The maximum number of drawing function calls, per frame, is 1,000.
784
785/////////////////////
786/// String Errors ///
787/////////////////////
788
789 "Array supplied to 'Game->GetDMapMusicFilename' not large enough\n"
790 "Array supplied to 'Game->GetSaveName' not large enough\n"
791 "String supplied to 'Game->GetSaveName' too large\n"
792 "Array supplied to 'Game->GetMessage' not large enough\n"
793 "Array supplied to 'Game->GetDMapName' not large enough\n"
794 "Array supplied to 'Game->GetDMapTitle' not large enough\n"
795 "Array supplied to 'Game->GetDMapIntro' not large enough\n"
796 "Array supplied to 'itemdata->GetName' not large enough\n"
797 "Array supplied to 'npc->GetName' not large enough\n"
798
799The buffer for these actions must be equal to the size of the text to load into it, plus one, for NULL.
800
801If you wish to load a game name, with Game->LoadSaveName(), and the name on the file select is FOO, you must
802supply a buffer with a size of [4] to hold it. (Three chars in the name, plus one for NULL.)
803
804////////////////////
805/// Misc. Errors ///
806////////////////////
807
808 "Waitdraw can only be used in the active global script\n"
809You attempted to call Waitdrw() in an ffc script, or an item script; or in your global OnContinue,
810global OnExit, or ~Init scripts.
811You may only use the Waitdraw() function from a global active script.
812
813 "No other scripts are currently supported\n"
814? You should never see this. May indicate that you have attempted to load more scripts than ZC can handle.
815
816
817 "Invalid value (%i) passed to '%s'\n"
818!? WHat should we put here?
819
820 "Global scripts currently have no A registers\n"
821This error can only occur if you are coding ZASM, and attempt to utilise an Address register with a global script.
822
823////////////////////////
824/// Script Reporting ///
825////////////////////////
826
827 //Events that will be recorded if Quest Rule 'Log Game Events to Allegro.log' is enabled:
828
829"Script created lweapon %ld with UID = %ld\n"
830"Script created eweapon %ld with UID = %ld\n"
831"Script created item \"%s\" with UID = %ld\n"
832"Script created NPC \"%s\" with UID = %ld\n"
833
834When any new game object is generated by script, and reporting is enabled, the lweapon, and the name of the
835script that generated it, will be reported to allegro.log.