Debian Codegraph @

src/cdogs/map_object.c

raw symbols SCIP
1 /*
2 C-Dogs SDL
3 A port of the legendary (and fun) action/arcade cdogs.
4 Copyright (C) 1995 Ronny Wester
5 Copyright (C) 2003 Jeremy Chin
6 Copyright (C) 2003-2007 Lucas Martin-King
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 This file incorporates work covered by the following copyright and
23 permission notice:
24
25 Copyright (c) 2014, 2016-2017, 2019, 2021, 2024-2025 Cong Xu
26 All rights reserved.
27
28 Redistribution and use in source and binary forms, with or without
29 modification, are permitted provided that the following conditions are met:
30
31 Redistributions of source code must retain the above copyright notice, this
32 list of conditions and the following disclaimer.
33 Redistributions in binary form must reproduce the above copyright notice,
34 this list of conditions and the following disclaimer in the documentation
35 and/or other materials provided with the distribution.
36
37 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
38 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
41 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
44 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
45 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
47 POSSIBILITY OF SUCH DAMAGE.
48 */
49 #include "map_object.h"
50
51 #include "json_utils.h"
52 #include "log.h"
53 #include "map.h"
54 #include "net_util.h"
55 #include "objs.h"
56 #include "pics.h"
57
58 MapObjects gMapObjects;
59
60 const char *PlacementFlagStr(const int i)
61 {
62 switch (i)
63 {
64 T2S(PLACEMENT_OUTSIDE, "Outside");
65 T2S(PLACEMENT_INSIDE, "Inside");
66 T2S(PLACEMENT_NO_WALLS, "NoWalls");
67 T2S(PLACEMENT_ONE_WALL, "OneWall");
68 T2S(PLACEMENT_ONE_OR_MORE_WALLS, "OneOrMoreWalls");
69 T2S(PLACEMENT_FREE_IN_FRONT, "FreeInFront");
70 T2S(PLACEMENT_ON_WALL, "OnWall");
71 default:
72 return "";
73 }
74 }
75 static PlacementFlags StrPlacementFlag(const char *s)
76 {
77 S2T(PLACEMENT_OUTSIDE, "Outside");
78 S2T(PLACEMENT_INSIDE, "Inside");
79 S2T(PLACEMENT_NO_WALLS, "NoWalls");
80 S2T(PLACEMENT_ONE_WALL, "OneWall");
81 S2T(PLACEMENT_ONE_OR_MORE_WALLS, "OneOrMoreWalls");
82 S2T(PLACEMENT_FREE_IN_FRONT, "FreeInFront");
83 S2T(PLACEMENT_ON_WALL, "OnWall");
84 return PLACEMENT_NONE;
85 }
86
87 static MapObjectType StrMapObjectType(const char *s)
88 {
89 S2T(MAP_OBJECT_TYPE_NORMAL, "Normal");
90 S2T(MAP_OBJECT_TYPE_PICKUP_SPAWNER, "PickupSpawner");
91 S2T(MAP_OBJECT_TYPE_ACTOR_SPAWNER, "ActorSpawner");
92 CASSERT(false, "unknown map object name");
93 return MAP_OBJECT_TYPE_NORMAL;
94 }
95
96 MapObject *StrMapObject(const char *s)
97 {
98 if (s == NULL || strlen(s) == 0)
99 {
100 return NULL;
101 }
102 CA_FOREACH(MapObject, c, gMapObjects.CustomClasses)
103 if (strcmp(s, c->Name) == 0)
104 {
105 return c;
106 }
107 CA_FOREACH_END()
108 CA_FOREACH(MapObject, c, gMapObjects.Classes)
109 if (strcmp(s, c->Name) == 0)
110 {
111 return c;
112 }
113 CA_FOREACH_END()
114 return NULL;
115 }
116 MapObject *IntMapObject(const int m)
117 {
118 // Note: do not edit; legacy integer mapping
119 static const char *oldMapObjects[] = {
120 "barrel_blue",
121 "box",
122 "box2",
123 "cabinet",
124 "plant",
125 "bench",
126 "chair",
127 "column",
128 "barrel_skull",
129 "barrel_wood",
130 "box_gray",
131 "box_green",
132 "statue_ogre",
133 "table_wood_candle",
134 "table_wood",
135 "tree_dead",
136 "bookshelf",
137 "box_wood",
138 "table_clothed",
139 "table_steel",
140 "tree_autumn",
141 "tree",
142 "box_metal_green",
143 "safe",
144 "box_red",
145 "table_lab",
146 "terminal",
147 "barrel",
148 "rocket",
149 "egg",
150 "bloodstain",
151 "wall_skull",
152 "bone_blood",
153 "bulletmarks",
154 "skull",
155 "blood0",
156 "scratch",
157 "wall_stuff",
158 "wall_goo",
159 "goo"};
160 if (m < 0 || m > (int)(sizeof oldMapObjects / sizeof oldMapObjects[0]))
161 {
162 LOG(LM_MAIN, LL_ERROR, "cannot find map object %d", m);
163 return NULL;
164 }
165 return StrMapObject(oldMapObjects[m]);
166 }
167 MapObject *IndexMapObject(const int i)
168 {
169 CASSERT(
170 i >= 0 && i < (int)gMapObjects.Classes.size +
171 (int)gMapObjects.CustomClasses.size,
172 "Map object index out of bounds");
173 if (i < (int)gMapObjects.Classes.size)
174 {
175 return CArrayGet(&gMapObjects.Classes, i);
176 }
177 return CArrayGet(&gMapObjects.CustomClasses, i - gMapObjects.Classes.size);
178 }
179 int DestructibleMapObjectIndex(const MapObject *mo)
180 {
181 if (mo == NULL)
182 {
183 return 0;
184 }
185 CA_FOREACH(const char *, name, gMapObjects.Destructibles)
186 const MapObject *d = StrMapObject(*name);
187 if (d == mo)
188 {
189 return _ca_index;
190 }
191 CA_FOREACH_END()
192 CASSERT(false, "cannot find destructible map object");
193 return -1;
194 }
195 const MapObject *GetRandomBloodPool(void)
196 {
197 const int idx = rand() % (int)gMapObjects.Bloods.size;
198 const char **name = CArrayGet(&gMapObjects.Bloods, idx);
199 return StrMapObject(*name);
200 }
201 int MapObjectGetFlags(const MapObject *mo)
202 {
203 int flags = 0;
204 if (mo->DrawBelow)
205 {
206 flags |= THING_DRAW_BELOW;
207 }
208 if (mo->DrawAbove)
209 {
210 flags |= THING_DRAW_ABOVE;
211 }
212 if (mo->Health > 0)
213 {
214 flags |= THING_IMPASSABLE;
215 flags |= THING_CAN_BE_SHOT;
216 }
217 return flags;
218 }
219
220 #define VERSION 4
221
222 void MapObjectsInit(
223 MapObjects *classes, const char *filename, const AmmoClasses *ammo,
224 const WeaponClasses *guns)
225 {
226 CArrayInit(&classes->Classes, sizeof(MapObject));
227 CArrayInit(&classes->CustomClasses, sizeof(MapObject));
228 CArrayInit(&classes->Destructibles, sizeof(char *));
229 CArrayInit(&classes->Bloods, sizeof(char *));
230
231 char buf[CDOGS_PATH_MAX];
232 GetDataFilePath(buf, filename);
233 FILE *f = fopen(buf, "r");
234 json_t *root = NULL;
235 if (f == NULL)
236 {
237 LOG(LM_MAIN, LL_ERROR, "Error: cannot load map objects file %s", buf);
238 goto bail;
239 }
240 enum json_error e = json_stream_parse(f, &root);
241 if (e != JSON_OK)
242 {
243 LOG(LM_MAIN, LL_ERROR, "Error parsing map objects file %s", buf);
244 goto bail;
245 }
246 MapObjectsLoadJSON(&classes->Classes, root);
247
248 // Load initial ammo/weapon spawners
249 MapObjectsLoadAmmoAndGunSpawners(classes, ammo, guns, false);
250
251 bail:
252 if (f != NULL)
253 {
254 fclose(f);
255 }
256 json_free_value(&root);
257 }
258 static bool TryLoadMapObject(MapObject *m, json_t *node, const int version);
259 static void ReloadDestructibles(MapObjects *mo);
260 void MapObjectsLoadJSON(CArray *classes, json_t *root)
261 {
262 int version;
263 LoadInt(&version, root, "Version");
264 if (version > VERSION || version <= 0)
265 {
266 CASSERT(false, "cannot read map objects file version");
267 return;
268 }
269
270 json_t *pickupsNode = json_find_first_label(root, "MapObjects")->child;
271 for (json_t *child = pickupsNode->child; child; child = child->next)
272 {
273 MapObject m;
274 if (TryLoadMapObject(&m, child, version))
275 {
276 CArrayPushBack(classes, &m);
277 }
278 }
279
280 ReloadDestructibles(&gMapObjects);
281 // Load blood objects
282 CArrayClear(&gMapObjects.Bloods);
283 for (int i = 0;; i++)
284 {
285 char buf[CDOGS_FILENAME_MAX];
286 sprintf(buf, "blood%d", i);
287 if (StrMapObject(buf) == NULL)
288 {
289 break;
290 }
291 char *tmp;
292 CSTRDUP(tmp, buf);
293 CArrayPushBack(&gMapObjects.Bloods, &tmp);
294 }
295 }
296 static bool TryLoadMapObject(MapObject *m, json_t *node, const int version)
297 {
298 char *tmp = NULL;
299 memset(m, 0, sizeof *m);
300
301 m->Name = GetString(node, "Name");
302
303 // Pic
304 json_t *normalNode = json_find_first_label(node, "Pic");
305 if (normalNode != NULL && normalNode->child != NULL)
306 {
307 if (version < 2)
308 {
309 CPicLoadNormal(&m->Pic, normalNode->child);
310 }
311 else
312 {
313 CPicLoadJSON(&m->Pic, normalNode->child);
314 }
315 // Pic required for map object
316 if (!CPicIsLoaded(&m->Pic))
317 {
318 LOG(LM_MAIN, LL_ERROR, "pic not found for map object(%s)",
319 m->Name);
320 goto bail;
321 }
322 }
323 if (CPicIsLoaded(&m->Pic))
324 {
325 // Default offset: centered X, align bottom of tile and sprite
326 const struct vec2i size = CPicGetSize(&m->Pic);
327 m->Offset = svec2i(-size.x / 2, TILE_HEIGHT / 2 - size.y);
328 LoadVec2i(&m->Offset, node, "Offset");
329 }
330
331 // Wreck
332 m->Wreck.Sound = StrSound("bang");
333 if (version < 4)
334 {
335 if (version < 3)
336 {
337 // Assume old wreck pic is wreck
338 json_t *wreckNode = json_find_first_label(node, "WreckPic");
339 if (wreckNode != NULL && wreckNode->child != NULL)
340 {
341 if (version < 2)
342 {
343 LoadStr(&m->Wreck.MO, node, "WreckPic");
344 }
345 else
346 {
347 LoadStr(&m->Wreck.MO, wreckNode, "Pic");
348 }
349 }
350 }
351 else
352 {
353 LoadStr(&m->Wreck.MO, node, "Wreck");
354 }
355 }
356 else
357 {
358 json_t *wreckNode = json_find_first_label(node, "Wreck");
359 if (wreckNode != NULL && wreckNode->child != NULL)
360 {
361 LoadStr(&m->Wreck.MO, wreckNode->child, "MapObject");
362 tmp = NULL;
363 LoadStr(&tmp, wreckNode->child, "Sound");
364 if (tmp != NULL)
365 {
366 m->Wreck.Sound = StrSound(tmp);
367 CFREE(tmp);
368 }
369 LoadStr(&m->Wreck.Bullet, wreckNode->child, "Bullet");
370 }
371 }
372 if (m->Wreck.Bullet == NULL)
373 {
374 CSTRDUP(m->Wreck.Bullet, "fireball_wreck");
375 }
376
377 // Default tile size
378 m->Size = TILE_SIZE;
379 LoadVec2i(&m->Size, node, "Size");
380 LoadVec2(&m->PosOffset, node, "PosOffset");
381 LoadInt(&m->Health, node, "Health");
382 LoadBulletGuns(&m->DestroyGuns, node, "DestroyGuns");
383
384 // Flags
385 json_t *flagsNode = json_find_first_label(node, "Flags");
386 if (flagsNode != NULL && flagsNode->child != NULL)
387 {
388 for (json_t *flagNode = flagsNode->child->child; flagNode;
389 flagNode = flagNode->next)
390 {
391 m->Flags |= 1 << StrPlacementFlag(flagNode->text);
392 }
393 }
394
395 LoadBool(&m->DrawBelow, node, "DrawBelow");
396 LoadBool(&m->DrawAbove, node, "DrawAbove");
397
398 LoadStr(&m->FootstepSound, node, "FootstepSound");
399 LoadColor(&m->FootprintMask, node, "FootprintMask");
400
401 // Special types
402 JSON_UTILS_LOAD_ENUM(m->Type, node, "Type", StrMapObjectType);
403 switch (m->Type)
404 {
405 case MAP_OBJECT_TYPE_NORMAL:
406 // Do nothing
407 break;
408 case MAP_OBJECT_TYPE_PICKUP_SPAWNER: {
409 tmp = GetString(node, "Pickup");
410 m->u.PickupClass = StrPickupClass(tmp);
411 CFREE(tmp);
412 }
413 break;
414 case MAP_OBJECT_TYPE_ACTOR_SPAWNER:
415 LoadInt(&m->u.Character.CharId, node, "CharId");
416 LoadInt(&m->u.Character.Counter, node, "Counter");
417 break;
418 default:
419 CASSERT(false, "unknown error");
420 break;
421 }
422
423 // DestroySpawn - pickups to spawn on destruction
424 json_t *destroySpawnNode = json_find_first_label(node, "DestroySpawn");
425 if (destroySpawnNode != NULL && destroySpawnNode->child != NULL)
426 {
427 CArrayInit(&m->DestroySpawn, sizeof(MapObjectDestroySpawn));
428 for (json_t *dsNode = destroySpawnNode->child->child; dsNode;
429 dsNode = dsNode->next)
430 {
431 MapObjectDestroySpawn mods;
432 memset(&mods, 0, sizeof mods);
433 JSON_UTILS_LOAD_ENUM(mods.Type, dsNode, "Type", StrPickupType);
434 LoadDouble(&mods.SpawnChance, dsNode, "SpawnChance");
435 CArrayPushBack(&m->DestroySpawn, &mods);
436 }
437 }
438
439 // Initialise to negative so zero health map objects don't smoke
440 m->DamageSmoke.HealthThreshold = -1;
441 json_t *dSmokeNode = json_find_first_label(node, "DamageSmoke");
442 if (dSmokeNode != NULL && dSmokeNode->child != NULL)
443 {
444 LoadStr(&m->DamageSmoke.ParticleClass, dSmokeNode->child, "Particle");
445 if (m->DamageSmoke.ParticleClass == NULL)
446 {
447 CSTRDUP(m->DamageSmoke.ParticleClass, "smoke_big");
448 }
449 LoadFloat(
450 &m->DamageSmoke.HealthThreshold, dSmokeNode->child,
451 "HealthThreshold");
452 LoadFloat(&m->DamageSmoke.Z, dSmokeNode->child, "Z");
453 m->DamageSmoke.Ticks = 20;
454 LoadInt(&m->DamageSmoke.Ticks, dSmokeNode->child, "Ticks");
455 }
456
457 return true;
458
459 bail:
460 return false;
461 }
462 static void AddDestructibles(MapObjects *mo, const CArray *classes);
463 static void ReloadDestructibles(MapObjects *mo)
464 {
465 CA_FOREACH(char *, s, mo->Destructibles)
466 CFREE(*s);
467 CA_FOREACH_END()
468 CArrayClear(&mo->Destructibles);
469 AddDestructibles(mo, &mo->Classes);
470 AddDestructibles(mo, &mo->CustomClasses);
471 }
472 static void AddDestructibles(MapObjects *m, const CArray *classes)
473 {
474 for (int i = 0; i < (int)classes->size; i++)
475 {
476 const MapObject *mo = CArrayGet(classes, i);
477 if (mo->Health > 0)
478 {
479 char *s;
480 CSTRDUP(s, mo->Name);
481 CArrayPushBack(&m->Destructibles, &s);
482 }
483 }
484 }
485
486 static void LoadAmmoSpawners(CArray *classes, const CArray *ammo);
487 static void LoadGunSpawners(CArray *classes, const CArray *guns);
488 void MapObjectsLoadAmmoAndGunSpawners(
489 MapObjects *classes, const AmmoClasses *ammo, const WeaponClasses *guns,
490 const bool isCustom)
491 {
492 if (isCustom)
493 {
494 LoadAmmoSpawners(&classes->CustomClasses, &ammo->CustomAmmo);
495 LoadGunSpawners(&classes->CustomClasses, &guns->CustomGuns);
496 }
497 else
498 {
499 // Load built-in classes
500 LoadAmmoSpawners(&classes->Classes, &ammo->Ammo);
501 LoadGunSpawners(&classes->Classes, &guns->Guns);
502 }
503 }
504
505 static void SetupSpawner(
506 MapObject *m, const char *spawnerName, const char *pickupClassName);
507
508 static void LoadAmmoSpawners(CArray *classes, const CArray *ammo)
509 {
510 for (int i = 0; i < (int)ammo->size; i++)
511 {
512 const Ammo *a = CArrayGet(ammo, i);
513 MapObject m;
514 char spawnerName[256];
515 char pickupClassName[256];
516 sprintf(spawnerName, "%s ammo spawner", a->Name);
517 sprintf(pickupClassName, "ammo_%s", a->Name);
518 SetupSpawner(&m, spawnerName, pickupClassName);
519 CArrayPushBack(classes, &m);
520 }
521 }
522 static void LoadGunSpawners(CArray *classes, const CArray *guns)
523 {
524 for (int i = 0; i < (int)guns->size; i++)
525 {
526 const WeaponClass *wc = CArrayGet(guns, i);
527 if (!wc->IsRealGun)
528 {
529 continue;
530 }
531 MapObject m;
532 char spawnerName[256];
533 char pickupClassName[256];
534 sprintf(spawnerName, "%s spawner", wc->name);
535 sprintf(pickupClassName, "gun_%s", wc->name);
536 SetupSpawner(&m, spawnerName, pickupClassName);
537 CArrayPushBack(classes, &m);
538 }
539 }
540
541 static void SetupSpawner(
542 MapObject *m, const char *spawnerName, const char *pickupClassName)
543 {
544 memset(m, 0, sizeof *m);
545 CSTRDUP(m->Name, spawnerName);
546 m->Pic.Type = PICTYPE_ANIMATED;
547 m->Pic.u.Animated.Sprites =
548 &PicManagerGetSprites(&gPicManager, "spawn_pad")->pics;
549 m->Pic.u.Animated.TicksPerFrame = 8;
550 m->Pic.Mask = colorWhite;
551 const struct vec2i size = CPicGetSize(&m->Pic);
552 m->Offset = svec2i(-size.x / 2, TILE_HEIGHT / 2 - size.y);
553 m->Size = TILE_SIZE;
554 m->Health = 0;
555 m->DrawBelow = true;
556 m->Type = MAP_OBJECT_TYPE_PICKUP_SPAWNER;
557 m->u.PickupClass = StrPickupClass(pickupClassName);
558 }
559
560 void MapObjectsClear(CArray *classes)
561 {
562 for (int i = 0; i < (int)classes->size; i++)
563 {
564 MapObject *c = CArrayGet(classes, i);
565 CFREE(c->Name);
566 CFREE(c->Wreck.MO);
567 CFREE(c->Wreck.Bullet);
568 CFREE(c->FootstepSound);
569 CFREE(c->DamageSmoke.ParticleClass);
570 CArrayTerminate(&c->DestroyGuns);
571 CArrayTerminate(&c->DestroySpawn);
572 }
573 CArrayClear(classes);
574 }
575 void MapObjectsTerminate(MapObjects *classes)
576 {
577 MapObjectsClear(&classes->Classes);
578 CArrayTerminate(&classes->Classes);
579 MapObjectsClear(&classes->CustomClasses);
580 CArrayTerminate(&classes->CustomClasses);
581 CA_FOREACH(char *, s, classes->Destructibles)
582 CFREE(*s);
583 CA_FOREACH_END()
584 CArrayTerminate(&classes->Destructibles);
585 CA_FOREACH(char *, s, classes->Bloods)
586 CFREE(*s);
587 CA_FOREACH_END()
588 CArrayTerminate(&classes->Bloods);
589 }
590
591 int MapObjectsCount(const MapObjects *classes)
592 {
593 return (int)classes->Classes.size + (int)classes->CustomClasses.size;
594 }
595
596 const Pic *MapObjectGetPic(const MapObject *mo, struct vec2i *offset)
597 {
598 *offset = mo->Offset;
599 return CPicGetPic(&mo->Pic, 0);
600 }
601
602 bool MapObjectIsTileOK(
603 const MapObject *mo, const Tile *tile, const Tile *tileAbove)
604 {
605 if (tile == NULL)
606 {
607 return false;
608 }
609 if (mo->DrawAbove)
610 {
611 // Check there are no draw above objects
612 CA_FOREACH(const ThingId, tid, tile->things)
613 if (tid->Kind == KIND_OBJECT &&
614 ((TObject *)CArrayGet(&gObjs, tid->Id))->Class->DrawAbove)
615 return false;
616 CA_FOREACH_END()
617 }
618 else if (mo->DrawBelow)
619 {
620 // Check there are no draw below objects
621 CA_FOREACH(const ThingId, tid, tile->things)
622 if (tid->Kind == KIND_OBJECT &&
623 ((TObject *)CArrayGet(&gObjs, tid->Id))->Class->DrawBelow)
624 return false;
625 CA_FOREACH_END()
626 }
627 else
628 {
629 if (!TileCanWalk(tile))
630 {
631 return false;
632 }
633 // Check if tile has no things on it, excluding particles and pickups
634 // and non-draw-above/below objects
635 CA_FOREACH(const ThingId, tid, tile->things)
636 if (tid->Kind == KIND_OBJECT)
637 {
638 const TObject *obj = CArrayGet(&gObjs, tid->Id);
639 if (!obj->Class->DrawAbove && !obj->Class->DrawBelow)
640 {
641 return false;
642 }
643 }
644 else if (tid->Kind != KIND_PARTICLE && tid->Kind != KIND_PICKUP)
645 return false;
646 CA_FOREACH_END()
647 }
648 if (MapObjectIsOnWall(mo) &&
649 (tileAbove == NULL || tileAbove->Class->Type != TILE_CLASS_WALL))
650 {
651 return false;
652 }
653 return true;
654 }
655 struct vec2 MapObjectGetPlacementPos(
656 const MapObject *mo, const struct vec2i tilePos)
657 {
658 struct vec2 pos = Vec2CenterOfTile(tilePos);
659 pos = svec2_add(pos, mo->PosOffset);
660 // For on-wall objects, set their position to the top of the tile
661 // This guarantees that they are drawn last
662 if (MapObjectIsOnWall(mo))
663 {
664 pos.y -= TILE_HEIGHT / 2 + 1;
665 }
666 return pos;
667 }
668 bool MapObjectIsOnWall(const MapObject *mo)
669 {
670 return mo->Flags & (1 << PLACEMENT_ON_WALL);
671 }