Files
source/Tactical/World Items.h
T
Kriplo b91bc7b209 Brief: //dnl ch75
- More map editor fixes and map inventory pool performance improvement for big maps.
Details:
- Fix not showing expected messagebox on exit (ALT+x) which also throw exception and goes to improper mapeditor exit.
- Fix second annoying sticky message which shouldn't popup during map loading and performing RemoveProhibitedAttachments.
- Fix CTD when delete all enemies or civilians or all of them in map.
- Fix some std exception when reporting for missing optional xml file.
- Fix memory and map corruption in old mapeditors if loaded old map has item with invalid attachment and we try to attach something else.
- As years ago pInventoryPoolList had migrated from WORLDITEM* array to std::vector<WORLDITEM> it was time to do that with gWorldItems too, all necessary functions which need to be adopted to gWorldItems std::vector type are also changed.
- Resize code for gWorldItems is changed hoping will lead into less corruption problems as now could occur in mapeditor and game when code automatically doing attachment changes.
- Change code for handling map inventory which now should be fast enough to support AIMNAS project which will probably deal with thousands of items per map.


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6554 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2013-11-03 16:26:30 +00:00

141 lines
5.2 KiB
C++

#ifndef __WORLD_ITEMS
#define __WORLD_ITEMS
#include "items.h"
#include "FileMan.h"
#define WORLD_ITEM_DONTRENDER 0x0001
#define WOLRD_ITEM_FIND_SWEETSPOT_FROM_GRIDNO 0x0002
#define WORLD_ITEM_ARMED_BOMB 0x0040
#define WORLD_ITEM_SCIFI_ONLY 0x0080
#define WORLD_ITEM_REALISTIC_ONLY 0x0100
#define WORLD_ITEM_REACHABLE 0x0200
#define WORLD_ITEM_GRIDNO_NOT_SET_USE_ENTRY_POINT 0x0400
//Kaiden: This constant is to flag items that an enemy drops when they die.
#define WORLD_ITEM_DROPPED_FROM_ENEMY 0x0800
// Flugente: when equipping militia from inventory, do not consider this item
#define WORLD_ITEM_TABOO_FOR_MILITIA_EQ_ELITE 0x1000
#define WORLD_ITEM_TABOO_FOR_MILITIA_EQ_BLUE 0x2000
#define WORLD_ITEM_TABOO_FOR_MILITIA_EQ_GREEN 0x4000
// Flugente: when moving items via 'move items' assignment, ignore this item
#define WORLD_ITEM_MOVE_ASSIGNMENT_IGNORE 0x8000
#define WORLD_ITEM_TABOO_FOR_MILITIA_EQ_ALL 0x7000
class WORLDITEM;//dnl ch33 120909
class _OLD_WORLDITEM;//dnl ch42 280909
class OLD_WORLDITEM_101
{
public:
OLD_WORLDITEM_101& operator=(WORLDITEM& src);//dnl ch33 120909
BOOLEAN fExists;
INT16 sGridNo;
UINT8 ubLevel;
OLD_OBJECTTYPE_101 oldObject;
UINT16 usFlags;
INT8 bRenderZHeightAboveLevel;
INT8 bVisible;
UINT8 ubNonExistChance;
};
// WANNE - BMP: DONE!
class WORLDITEM
{
public:
WORLDITEM() {initialize();};
WORLDITEM& operator=(OLD_WORLDITEM_101& src);
WORLDITEM& operator=(_OLD_WORLDITEM& src);//dnl ch42 280909
WORLDITEM& operator=(const WORLDITEM& src);
bool operator<(WORLDITEM& compare);
BOOLEAN Save( HWFILE hFile, bool fSavingMap );
BOOLEAN Load( HWFILE hFile );
BOOLEAN Load( HWFILE hFile, float dMajorMapVersion, UINT8 ubMinorMapVersion );
BOOLEAN Load( INT8** hBuffer, float dMajorMapVersion, UINT8 ubMinorMapVersion );
void initialize();
BOOLEAN fExists;
INT32 sGridNo;
UINT8 ubLevel;
UINT16 usFlags;
INT8 bRenderZHeightAboveLevel;
INT8 bVisible;
//This is the chance associated with an item or a trap not-existing in the world. The reason why
//this is reversed (10 meaning item has 90% chance of appearing, is because the order that the map
//is saved, we don't know if the version is older or not until after the items are loaded and added.
//Because this value is zero in the saved maps, we can't change it to 100, hence the reversal method.
//This check is only performed the first time a map is loaded. Later, it is entirely skipped.
UINT8 ubNonExistChance;
INT8 soldierID;
char endOfPod;
OBJECTTYPE object;
};
// WANNE - BMP: DONE!
class _OLD_WORLDITEM
{
public:
BOOLEAN fExists;
INT16 sGridNo;
UINT8 ubLevel;
UINT16 usFlags;
INT8 bRenderZHeightAboveLevel;
INT8 bVisible;
//This is the chance associated with an item or a trap not-existing in the world. The reason why
//this is reversed (10 meaning item has 90% chance of appearing, is because the order that the map
//is saved, we don't know if the version is older or not until after the items are loaded and added.
//Because this value is zero in the saved maps, we can't change it to 100, hence the reversal method.
//This check is only performed the first time a map is loaded. Later, it is entirely skipped.
UINT8 ubNonExistChance;
INT8 soldierID;
char endOfPod;
OBJECTTYPE object;
}; // _OLD_WORLDITEM
#define SIZEOF_WORLDITEM_POD (offsetof(WORLDITEM, endOfPod))
#define _OLD_SIZEOF_WORLDITEM_POD (offsetof(_OLD_WORLDITEM, endOfPod))
extern std::vector<WORLDITEM> gWorldItems;//dnl ch75 261013
extern UINT32 guiNumWorldItems;
INT32 AddItemToWorld( INT32 sGridNo, OBJECTTYPE *pObject, UINT8 ubLevel, UINT16 usFlags, INT8 bRenderZHeightAboveLevel, INT8 bVisible, INT8 soldierID );
void RemoveItemFromWorld( INT32 iItemIndex );
INT32 FindWorldItem( UINT16 usItem );
void LoadWorldItemsFromMap( INT8 **hBuffer, float dMajorMapVersion, int ubMinorMapVersion );
void SaveWorldItemsToMap(HWFILE fp, float dMajorMapVersion, UINT8 ubMinorMapVersion);//dnl ch33 150909
void TrashWorldItems();
typedef struct
{
BOOLEAN fExists;
INT32 iItemIndex;
INT32 iMPWorldItemIndex; // OJW - 20091002 - needed to link correct explosives between clients
UINT8 ubMPTeamIndex;
bool bIsFromRemotePlayer;
} WORLDBOMB;
extern WORLDBOMB * gWorldBombs;
extern UINT32 guiNumWorldBombs;
extern INT32 AddBombToWorld( INT32 iItemIndex );
extern void FindPanicBombsAndTriggers( void );
extern INT32 FindWorldItemForBombInGridNo( INT32 sGridNo, INT8 bLevel);
// Flugente: is there a planted tripwire at this gridno? fKnown = TRUE: only return true if we know of that one already
extern INT32 FindWorldItemForTripwireInGridNo( INT32 sGridNo, INT8 bLevel, BOOLEAN fKnown = TRUE );
void ResizeWorldItems(void);//dnl ch75 271013
void RefreshWorldItemsIntoItemPools( std::vector<WORLDITEM>& pItemList, INT32 iNumberOfItems );//dnl ch75 271013
void CoolDownWorldItems( ); // Flugente: Cool/decay down all items in this sector
#endif