From 2cd3521e3f8f00b95d6cf8b460ec8337b2c79a82 Mon Sep 17 00:00:00 2001 From: SpaceViking Date: Fri, 15 Jun 2007 03:05:04 +0000 Subject: [PATCH] Update inventory arrays to be vectors. Add class for inventory. Change some structs that use inventories to classes to provide constructors, destructors, etc. Note that with this update all file operations should still be compatible with previous files. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@973 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- TileEngine/Buildings.cpp | 4 +++- TileEngine/Exit Grids.cpp | 4 +++- TileEngine/Map Edgepoints.cpp | 12 +++++++++--- TileEngine/worlddef.cpp | 7 +++++-- TileEngine/worlddef.h | 9 +++++---- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/TileEngine/Buildings.cpp b/TileEngine/Buildings.cpp index 0c32b62b..62b7cb92 100644 --- a/TileEngine/Buildings.cpp +++ b/TileEngine/Buildings.cpp @@ -59,8 +59,10 @@ BUILDING * GenerateBuilding( INT16 sDesiredSpot ) return( NULL ); } + // WDS - Clean up inventory handling // set up fake soldier for location testing - memset( &FakeSoldier, 0, sizeof( SOLDIERTYPE ) ); +// memset( &FakeSoldier, 0, SIZEOF_SOLDIERTYPE ); + FakeSoldier.initialize(); FakeSoldier.sGridNo = sDesiredSpot; FakeSoldier.bLevel = 1; FakeSoldier.bTeam = 1; diff --git a/TileEngine/Exit Grids.cpp b/TileEngine/Exit Grids.cpp index 5913b450..992150b9 100644 --- a/TileEngine/Exit Grids.cpp +++ b/TileEngine/Exit Grids.cpp @@ -256,9 +256,11 @@ UINT16 FindGridNoFromSweetSpotCloseToExitGrid( SOLDIERTYPE *pSoldier, INT16 sSwe gubNPCAPBudget = 0; gubNPCDistLimit = ubRadius; + // WDS - Clean up inventory handling //create dummy soldier, and use the pathing to determine which nearby slots are //reachable. - memset( &soldier, 0, sizeof( SOLDIERTYPE ) ); +// memset( &soldier, 0, SIZEOF_SOLDIERTYPE ); + soldier.initialize(); soldier.bLevel = 0; soldier.bTeam = 1; soldier.sGridNo = pSoldier->sGridNo; diff --git a/TileEngine/Map Edgepoints.cpp b/TileEngine/Map Edgepoints.cpp index ebc1cb3f..a685d9db 100644 --- a/TileEngine/Map Edgepoints.cpp +++ b/TileEngine/Map Edgepoints.cpp @@ -123,7 +123,9 @@ void ValidateEdgepoints() UINT16 usValidEdgepoints; SOLDIERTYPE Soldier; - memset( &Soldier, 0, sizeof( SOLDIERTYPE ) ); + // WDS - Clean up inventory handling +// memset( &Soldier, 0, SIZEOF_SOLDIERTYPE ); + Soldier.initialize(); Soldier.bTeam = 1; //north @@ -435,7 +437,9 @@ void ClassifyEdgepoints() SOLDIERTYPE Soldier; INT16 sGridNo = -1; - memset( &Soldier, 0, sizeof( SOLDIERTYPE ) ); + // WDS - Clean up inventory handling +// memset( &Soldier, 0, SIZEOF_SOLDIERTYPE ); + Soldier.initialize(); Soldier.bTeam = 1; //north @@ -1636,7 +1640,9 @@ UINT8 CalcMapEdgepointClassInsertionCode( INT16 sGridNo ) INT16 sClosestSpot2 = NOWHERE, sClosestDist2 = 0x7FFF; BOOLEAN fPrimaryValid = FALSE, fSecondaryValid = FALSE; - memset( &Soldier, 0, sizeof( SOLDIERTYPE ) ); + // WDS - Clean up inventory handling +// memset( &Soldier, 0, SIZEOF_SOLDIERTYPE ); + Soldier.initialize(); Soldier.bTeam = 1; Soldier.sGridNo = sGridNo; diff --git a/TileEngine/worlddef.cpp b/TileEngine/worlddef.cpp index 3df050ad..d9026c75 100644 --- a/TileEngine/worlddef.cpp +++ b/TileEngine/worlddef.cpp @@ -1695,8 +1695,9 @@ BOOLEAN SaveWorld( const STR8 puiFilename ) // Write tileset ID FileWrite( hfile, &giCurrentTilesetID, sizeof( INT32 ), &uiBytesWritten ); + // WDS - Clean up inventory handling // Write SOLDIER CONTROL SIZE - uiSoldierSize = sizeof( SOLDIERTYPE ); + uiSoldierSize = SIZEOF_SOLDIERTYPE_POD; //SIZEOF_SOLDIERTYPE; FileWrite( hfile, &uiSoldierSize, sizeof( INT32 ), &uiBytesWritten ); @@ -2477,7 +2478,9 @@ BOOLEAN EvaluateWorld( STR8 pSector, UINT8 ubLevel ) } if( basic.fDetailedPlacement ) { //skip static priority placement - LOADDATA( &priority, pBuffer, sizeof( SOLDIERCREATE_STRUCT ) ); + // WDS - Clean up inventory handling + LOADDATA( &priority, pBuffer, SIZEOF_SOLDIERCREATE_STRUCT_POD); //SIZEOF_SOLDIERCREATE_STRUCT ); + priority.CopyOldDataToNew(); if( priority.ubProfile != NO_PROFILE ) pTeam->ubProfile++; else diff --git a/TileEngine/worlddef.h b/TileEngine/worlddef.h index dba229c5..19bd32f9 100644 --- a/TileEngine/worlddef.h +++ b/TileEngine/worlddef.h @@ -104,9 +104,10 @@ #define ANY_SMOKE_EFFECT ( MAPELEMENT_EXT_CREATUREGAS | MAPELEMENT_EXT_SMOKE | MAPELEMENT_EXT_TEARGAS | MAPELEMENT_EXT_MUSTARDGAS | MAPELEMENT_EXT_BURNABLEGAS ) -typedef struct TAG_level_node +// WDS - Clean up inventory handling +struct LEVELNODE { - struct TAG_level_node *pNext; + struct LEVELNODE *pNext; UINT32 uiFlags; // flags struct UINT8 ubSumLights; // LIGHTING INFO @@ -114,7 +115,7 @@ typedef struct TAG_level_node union { - struct TAG_level_node *pPrevNode; // FOR LAND, GOING BACKWARDS POINTER + struct LEVELNODE *pPrevNode; // FOR LAND, GOING BACKWARDS POINTER STRUCTURE *pStructureData; // STRUCTURE DATA INT32 iPhysicsObjectID; // ID FOR PHYSICS ITEM INT32 uiAPCost; // FOR AP DISPLAY @@ -173,7 +174,7 @@ typedef struct TAG_level_node UINT8 ubNaturalShadeLevel; // LIGHTING INFO UINT8 ubFakeShadeLevel; // LIGHTING INFO -} LEVELNODE; +}; // LEVELNODE; #define LAND_START_INDEX 1