1#include <game/mapitems.h>
2
3bool IsValidGameTile(int Index)
4{
5 return (
6 Index == TILE_AIR ||
7 (Index >= TILE_SOLID && Index <= TILE_THROUGH) ||
8 Index == TILE_FREEZE ||
9 (Index >= TILE_UNFREEZE && Index <= TILE_DUNFREEZE) ||
10 (Index >= TILE_LFREEZE && Index <= TILE_LUNFREEZE) ||
11 (Index >= TILE_WALLJUMP && Index <= TILE_SOLO_DISABLE) ||
12 (Index >= TILE_REFILL_JUMPS && Index <= TILE_STOPA) ||
13 (Index >= TILE_CP && Index <= TILE_THROUGH_DIR) ||
14 (Index >= TILE_OLDLASER && Index <= TILE_UNLOCK_TEAM) ||
15 (Index >= TILE_NPC_DISABLE && Index <= TILE_NPH_DISABLE) ||
16 (Index >= TILE_TELE_GUN_ENABLE && Index <= TILE_TELE_GUN_DISABLE) ||
17 (Index >= TILE_TELE_GRENADE_ENABLE && Index <= TILE_TELE_GRENADE_DISABLE) ||
18 (Index >= TILE_TELE_LASER_ENABLE && Index <= TILE_TELE_LASER_DISABLE) ||
19 (Index >= TILE_NPC_ENABLE && Index <= TILE_NPH_ENABLE) ||
20 (Index >= TILE_ENTITIES_OFF_1 && Index <= TILE_ENTITIES_OFF_2) ||
21 IsValidEntity(Index));
22}
23
24bool IsValidFrontTile(int Index)
25{
26 return (
27 Index == TILE_AIR ||
28 Index == TILE_DEATH ||
29 (Index >= TILE_NOLASER && Index <= TILE_THROUGH) ||
30 Index == TILE_FREEZE ||
31 (Index >= TILE_UNFREEZE && Index <= TILE_DUNFREEZE) ||
32 (Index >= TILE_LFREEZE && Index <= TILE_LUNFREEZE) ||
33 (Index >= TILE_WALLJUMP && Index <= TILE_SOLO_DISABLE) ||
34 (Index >= TILE_REFILL_JUMPS && Index <= TILE_STOPA) ||
35 (Index >= TILE_CP && Index <= TILE_THROUGH_DIR) ||
36 (Index >= TILE_OLDLASER && Index <= TILE_UNLOCK_TEAM) ||
37 (Index >= TILE_NPC_DISABLE && Index <= TILE_NPH_DISABLE) ||
38 (Index >= TILE_TELE_GUN_ENABLE && Index <= TILE_ALLOW_BLUE_TELE_GUN) ||
39 (Index >= TILE_TELE_GRENADE_ENABLE && Index <= TILE_TELE_GRENADE_DISABLE) ||
40 (Index >= TILE_TELE_LASER_ENABLE && Index <= TILE_TELE_LASER_DISABLE) ||
41 (Index >= TILE_NPC_ENABLE && Index <= TILE_NPH_ENABLE) ||
42 (Index >= TILE_ENTITIES_OFF_1 && Index <= TILE_ENTITIES_OFF_2) ||
43 IsValidEntity(Index));
44}
45
46bool IsValidTeleTile(int Index)
47{
48 return (
49 Index == TILE_TELEINEVIL ||
50 Index == TILE_TELEINWEAPON ||
51 Index == TILE_TELEINHOOK ||
52 Index == TILE_TELEIN ||
53 Index == TILE_TELEOUT ||
54 Index == TILE_TELECHECK ||
55 Index == TILE_TELECHECKOUT ||
56 Index == TILE_TELECHECKIN ||
57 Index == TILE_TELECHECKINEVIL);
58}
59
60bool IsTeleTileCheckpoint(int Index)
61{
62 return Index == TILE_TELECHECK || Index == TILE_TELECHECKOUT;
63}
64
65bool IsTeleTileNumberUsed(int Index, bool Checkpoint)
66{
67 if(Checkpoint)
68 return IsTeleTileCheckpoint(Index);
69 return !IsTeleTileCheckpoint(Index) && Index != TILE_TELECHECKIN &&
70 Index != TILE_TELECHECKINEVIL;
71}
72
73bool IsTeleTileNumberUsedAny(int Index)
74{
75 return Index != TILE_TELECHECKIN &&
76 Index != TILE_TELECHECKINEVIL;
77}
78
79bool IsValidSpeedupTile(int Index)
80{
81 return Index == TILE_BOOST;
82}
83
84bool IsValidSwitchTile(int Index)
85{
86 return (
87 Index == TILE_JUMP ||
88 Index == TILE_FREEZE ||
89 Index == TILE_DFREEZE ||
90 Index == TILE_DUNFREEZE ||
91 Index == TILE_LFREEZE ||
92 Index == TILE_LUNFREEZE ||
93 Index == TILE_HIT_ENABLE ||
94 Index == TILE_HIT_DISABLE ||
95 (Index >= TILE_SWITCHTIMEDOPEN && Index <= TILE_SWITCHCLOSE) ||
96 Index == TILE_ADD_TIME ||
97 Index == TILE_SUBTRACT_TIME ||
98 Index == TILE_ALLOW_TELE_GUN ||
99 Index == TILE_ALLOW_BLUE_TELE_GUN ||
100 (IsValidEntity(Index) && Index >= ENTITY_OFFSET + ENTITY_ARMOR_1));
101}
102
103bool IsSwitchTileFlagsUsed(int Index)
104{
105 return Index != TILE_FREEZE &&
106 Index != TILE_DFREEZE &&
107 Index != TILE_DUNFREEZE;
108}
109
110bool IsSwitchTileNumberUsed(int Index)
111{
112 return Index != TILE_JUMP &&
113 Index != TILE_HIT_ENABLE &&
114 Index != TILE_HIT_DISABLE &&
115 Index != TILE_ALLOW_TELE_GUN &&
116 Index != TILE_ALLOW_BLUE_TELE_GUN;
117}
118
119bool IsSwitchTileDelayUsed(int Index)
120{
121 return Index != TILE_DFREEZE &&
122 Index != TILE_DUNFREEZE;
123}
124
125bool IsValidTuneTile(int Index)
126{
127 return Index == TILE_TUNE;
128}
129
130bool IsValidEntity(int Index)
131{
132 Index -= ENTITY_OFFSET;
133 return (
134 (Index >= ENTITY_SPAWN && Index <= ENTITY_LASER_O_FAST) ||
135 (Index >= ENTITY_PLASMAE && Index <= ENTITY_ARMOR_LASER) ||
136 (Index >= ENTITY_DRAGGER_WEAK && Index <= ENTITY_DRAGGER_STRONG_NW) ||
137 Index == ENTITY_DOOR);
138}
139
140bool IsRotatableTile(int Index)
141{
142 return (
143 Index == TILE_STOP ||
144 Index == TILE_STOPS ||
145 Index == TILE_CP ||
146 Index == TILE_CP_F ||
147 Index == TILE_THROUGH_DIR ||
148 Index == TILE_ENTITIES_OFF_1 ||
149 Index == TILE_ENTITIES_OFF_2 ||
150 Index - ENTITY_OFFSET == ENTITY_CRAZY_SHOTGUN_EX ||
151 Index - ENTITY_OFFSET == ENTITY_CRAZY_SHOTGUN);
152}
153
154bool IsCreditsTile(int TileIndex)
155{
156 return (
157 (TILE_CREDITS_1 == TileIndex) ||
158 (TILE_CREDITS_2 == TileIndex) ||
159 (TILE_CREDITS_3 == TileIndex) ||
160 (TILE_CREDITS_4 == TileIndex) ||
161 (TILE_CREDITS_5 == TileIndex) ||
162 (TILE_CREDITS_6 == TileIndex) ||
163 (TILE_CREDITS_7 == TileIndex) ||
164 (TILE_CREDITS_8 == TileIndex));
165}
166
167int PackColor(CColor Color)
168{
169 int Res = 0;
170 Res |= Color.r << 24;
171 Res |= Color.g << 16;
172 Res |= Color.b << 8;
173 Res |= Color.a;
174 return Res;
175}
176