1 /*
2  * OpenBOR - http://www.chronocrash.com
3  * -----------------------------------------------------------------------
4  * All rights reserved. See LICENSE in OpenBOR root for license details.
5  *
6  * Copyright (c) 2004 - 2017 OpenBOR Team
7  */
8 
9 #ifndef SCRIPT_COMMON_H
10 #define SCRIPT_COMMON_H
11 
12 #include "openbor.h"
13 
14 #define _is_not_a_known_subproperty_of_  "'%s' is not a known subproperty of '%s'.\n"
15 #define _is_not_supported_by_ "'%s' is not supported by '%s'.\n"
16 
17 // Define macro for string mapping.
18 //
19 // 1. Is property argument a string?
20 //      a. True
21 //          1. Populate 'propname' with string.
22 //          2. Use searchlist function to populate
23 //          'prop' with integer constant matching
24 //          position in propstring list. So if a
25 //          propname matches the second item in
26 //          propstring list, then searchlist will
27 //          return 1.
28 //
29 //          c. Is prop a 0+ integer?
30 //              1. True
31 //                  a. Use prop to populate varlist->lval.
32 //                  We now have a property integer we can
33 //                  compare to enumerated property constant
34 //                  list and take action as needed by property
35 //                  access functions.
36 //
37 //              2. False
38 //                  a. Send a failed message to the log.
39 //                  User most likely made a typo error
40 //                  and tried to access a property that
41 //                  does not exist.
42 //                  b. Return 0.
43 //
44 //      b. False.
45 //          1. Do nothing and allow function to continue.
46 #define MAPSTRINGS(VAR, LIST, MAXINDEX, FAILMSG, args...) \
47 {\
48     int proplist_cursor; \
49     if(VAR->vt == VT_STR) { \
50         propname = (char*)StrCache_Get(VAR->strVal); \
51         prop = searchList(LIST, propname, MAXINDEX); \
52         if(prop >= 0) { \
53             ScriptVariant_ChangeType(VAR, VT_INTEGER); \
54             VAR->lVal = prop; \
55         } else { \
56             \
57             printf(FAILMSG, propname, ##args);  \
58             printf("\n Available properties:\n"); \
59             \
60             for(proplist_cursor = 0; LIST[proplist_cursor] != NULL; proplist_cursor++){ \
61                printf("\n\t%s", LIST[proplist_cursor]); \
62             } \
63             \
64             printf("\n\n"); \
65             return 0; \
66         }\
67     }\
68 }
69 
70 extern int			  PLAYER_MIN_Z;
71 extern int			  PLAYER_MAX_Z;
72 extern int			  BGHEIGHT;
73 extern int            MAX_WALL_HEIGHT;
74 extern int			  SAMPLE_GO;
75 extern int			  SAMPLE_BEAT;
76 extern int			  SAMPLE_BLOCK;
77 extern int			  SAMPLE_INDIRECT;
78 extern int			  SAMPLE_GET;
79 extern int			  SAMPLE_GET2;
80 extern int			  SAMPLE_FALL;
81 extern int			  SAMPLE_JUMP;
82 extern int			  SAMPLE_PUNCH;
83 extern int			  SAMPLE_1UP;
84 extern int			  SAMPLE_TIMEOVER;
85 extern int			  SAMPLE_BEEP;
86 extern int			  SAMPLE_BEEP2;
87 extern int			  SAMPLE_BIKE;
88 extern int            current_palette;
89 extern s_player       player[4];
90 extern s_level        *level;
91 extern s_filestream   *filestreams;
92 extern int			  numfilestreams;
93 extern entity         *self;
94 extern int            *animspecials;
95 extern int            *animattacks;
96 extern int            *animfollows;
97 extern int            *animpains;
98 extern int            *animfalls;
99 extern int            *animrises;
100 extern int            *animriseattacks;
101 extern int            *animdies;
102 extern int            *animidles;
103 extern int            *animwalks;
104 extern int            *animbackwalks;
105 extern int            *animups;
106 extern int            *animdowns;
107 extern int            *animbackpains;
108 extern int            *animbackfalls;
109 extern int            *animbackdies;
110 extern int            *animbackrises;
111 extern int            *animbackriseattacks;
112 extern int            *animblkpains;
113 extern int            *animbackblkpains;
114 
115 extern int            noshare;
116 extern int            credits;
117 extern char           musicname[128];
118 extern float          musicfade[2];
119 extern int            musicloop;
120 extern u32            musicoffset;
121 extern int            models_cached;
122 extern int endgame;
123 extern int useSave;
124 extern int useSet;
125 
126 
127 extern s_sprite_list *sprite_list;
128 extern s_sprite_map *sprite_map;
129 
130 extern unsigned char *blendings[MAX_BLENDINGS];
131 extern int            current_palette;
132 extern s_collision_attack emptyattack;
133 
134 #endif // SCRIPT_COMMON_H
135 
136