1 #ifndef __WORLD_ITEMS
2 #define __WORLD_ITEMS
3
4 #include "Debug.h"
5 #include "Item_Types.h"
6
7 #include <vector>
8
9
10 #define WORLD_ITEM_DONTRENDER 0x0001
11 #define WOLRD_ITEM_FIND_SWEETSPOT_FROM_GRIDNO 0x0002
12 #define WORLD_ITEM_ARMED_BOMB 0x0040
13 #define WORLD_ITEM_SCIFI_ONLY 0x0080
14 #define WORLD_ITEM_REALISTIC_ONLY 0x0100
15 #define WORLD_ITEM_REACHABLE 0x0200
16 #define WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT 0x0400
17
18 struct WORLDITEM
19 {
20 BOOLEAN fExists;
21 INT16 sGridNo;
22 UINT8 ubLevel;
23 OBJECTTYPE o;
24 UINT16 usFlags;
25 INT8 bRenderZHeightAboveLevel;
26
27 INT8 bVisible;
28
29 //This is the chance associated with an item or a trap not-existing in the world. The reason why
30 //this is reversed (10 meaning item has 90% chance of appearing, is because the order that the map
31 //is saved, we don't know if the version is older or not until after the items are loaded and added.
32 //Because this value is zero in the saved maps, we can't change it to 100, hence the reversal method.
33 //This check is only performed the first time a map is loaded. Later, it is entirely skipped.
34 UINT8 ubNonExistChance;
35 };
36
37
38 // items in currently loaded sector
39 extern std::vector<WORLDITEM> gWorldItems;
40
GetWorldItem(size_t const idx)41 static inline WORLDITEM& GetWorldItem(size_t const idx)
42 {
43 Assert(idx < gWorldItems.size());
44 return gWorldItems[idx];
45 }
46
47 #define BASE_FOR_EACH_WORLD_ITEM(type, iter) \
48 for (type& iter : gWorldItems) \
49 if (!iter.fExists) continue; else
50 #define FOR_EACH_WORLD_ITEM( iter) BASE_FOR_EACH_WORLD_ITEM( WORLDITEM, iter)
51 #define CFOR_EACH_WORLD_ITEM(iter) BASE_FOR_EACH_WORLD_ITEM(const WORLDITEM, iter)
52
53 INT32 AddItemToWorld(INT16 sGridNo, const OBJECTTYPE* pObject, UINT8 ubLevel, UINT16 usFlags, INT8 bRenderZHeightAboveLevel, INT8 bVisible);
54 void RemoveItemFromWorld( INT32 iItemIndex );
55 INT32 FindWorldItem( UINT16 usItem );
56
57 void LoadWorldItemsFromMap(HWFILE);
58
59 void SaveWorldItemsToMap( HWFILE fp );
60
61 void TrashWorldItems(void);
62
63 struct WORLDBOMB
64 {
65 BOOLEAN fExists;
66 INT32 iItemIndex;
67 };
68
69 extern std::vector<WORLDBOMB> gWorldBombs;
70
71 #define BASE_FOR_EACH_WORLD_BOMB(type, iter) \
72 for (type& iter : gWorldBombs) \
73 if (!iter.fExists) continue; else
74 #define FOR_EACH_WORLD_BOMB( iter) BASE_FOR_EACH_WORLD_BOMB( WORLDBOMB, iter)
75 #define CFOR_EACH_WORLD_BOMB(iter) BASE_FOR_EACH_WORLD_BOMB(const WORLDBOMB, iter)
76
77 extern void FindPanicBombsAndTriggers( void );
78 extern INT32 FindWorldItemForBombInGridNo( INT16 sGridNo, INT8 bLevel);
79
80 void RefreshWorldItemsIntoItemPools(const std::vector<WORLDITEM>& items);
81
82 #endif
83