Fix: dragging a structure repaired it and removed all decals

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9120 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2021-06-28 14:52:12 +00:00
parent 587b7e2874
commit 6f24fb89fd
4 changed files with 41 additions and 5 deletions
+26 -1
View File
@@ -7884,7 +7884,7 @@ BOOLEAN CanRemoveFortification( INT32 sGridNo, INT8 sLevel, UINT32 usStructureco
return FALSE;
}
BOOLEAN IsDragStructurePresent( INT32 sGridNo, INT8 sLevel, UINT32& arusTileType, UINT16& arusStructureNumber )
BOOLEAN IsDragStructurePresent( INT32 sGridNo, INT8 sLevel, UINT32& arusTileType, UINT16& arusStructureNumber, UINT8& arusHitpoints, UINT8& arusDecalFlags )
{
// needs to be a valid location
if ( TileIsOutOfBounds( sGridNo ) )
@@ -7902,6 +7902,8 @@ BOOLEAN IsDragStructurePresent( INT32 sGridNo, INT8 sLevel, UINT32& arusTileType
if ( GetTileType( pNode->usIndex, &arusTileType ) )
{
arusStructureNumber = pStruct->pDBStructureRef->pDBStructure->usStructureNumber;
arusHitpoints = pStruct->ubHitPoints;
arusDecalFlags = pStruct->ubDecalFlag;
// if tileset is from the current tileset, check that
for ( int i = 0; i < STRUCTURE_MOVEPOSSIBLE_MAX; ++i )
@@ -8027,6 +8029,29 @@ BOOLEAN RemoveStructDrag( INT32 sGridNo, INT8 sLevel, UINT32 uiTileType )
return FALSE;
}
void CorrectDragStructData( INT32 sGridNo, INT8 sLevel, UINT8 ausHitpoints, UINT8 ausDecalFlags )
{
// needs to be a valid location
if ( TileIsOutOfBounds( sGridNo ) )
return;
STRUCTURE* pStruct = GetTallestStructureOnGridnoDrag( sGridNo, sLevel );
if ( pStruct != NULL )
{
pStruct->ubHitPoints = ausHitpoints;
pStruct->ubDecalFlag = ausDecalFlags;
if ( pStruct->ubHitPoints < pStruct->pDBStructureRef->pDBStructure->ubHitPoints
|| pStruct->ubDecalFlag & STRUCTURE_DECALFLAG_BLOOD )
{
gpWorldLevelData[sGridNo].uiFlags & MAPELEMENT_STRUCTURE_DAMAGED;
//SetRenderFlags( RENDER_FLAG_FULL );
}
}
}
BOOLEAN RemoveFortification( INT32 sGridNo, INT8 sLevel, UINT32 usStructureconstructindex )
{
// needs to be a valid location
+2 -1
View File
@@ -290,9 +290,10 @@ BOOLEAN BuildFortification( INT32 sGridNo, INT8 sLevel, UINT8 usIndex, UINT32 us
BOOLEAN CanRemoveFortification( INT32 sGridNo, INT8 sLevel, UINT32 usStructureconstructindex );
BOOLEAN RemoveFortification( INT32 sGridNo, INT8 sLevel, UINT32 usStructureconstructindex );
BOOLEAN IsDragStructurePresent( INT32 sGridNo, INT8 sLevel, UINT32& arusTileType, UINT16& arusStructureNumber );
BOOLEAN IsDragStructurePresent( INT32 sGridNo, INT8 sLevel, UINT32& arusTileType, UINT16& arusStructureNumber, UINT8& arusHitpoints, UINT8& arusDecalFlags );
void GetDragStructureXmlEntry( UINT32 ausTileType, UINT16 ausStructureNumber, int& arXmlVectorEntry );
BOOLEAN RemoveStructDrag( INT32 sGridNo, INT8 sLevel, UINT32 uiTileType );
void CorrectDragStructData( INT32 sGridNo, INT8 sLevel, UINT8 ausHitpoints, UINT8 ausDecalFlags );
BOOLEAN BuildStructDrag( INT32 sGridNo, INT8 sLevel, UINT32 uiTileType, UINT8 usIndex, UINT16 usSoldierID );
void UpdateFortificationPossibleAmount();
+3 -1
View File
@@ -853,8 +853,10 @@ DragSelection::Setup( UINT32 aVal )
UINT32 tiletype;
UINT16 structurenumber;
UINT8 hitpoints;
UINT8 decalflag;
if ( pSoldier->CanDragStructure( sTempGridNo )
&& IsDragStructurePresent( sTempGridNo, pSoldier->pathing.bLevel, tiletype, structurenumber ) )
&& IsDragStructurePresent( sTempGridNo, pSoldier->pathing.bLevel, tiletype, structurenumber, hitpoints, decalflag ) )
{
int xmlentry;
GetDragStructureXmlEntry( tiletype, structurenumber, xmlentry );
+10 -2
View File
@@ -11864,11 +11864,17 @@ void SOLDIERTYPE::MoveMerc( FLOAT dMovementChange, FLOAT dAngle, BOOLEAN fCheckR
bool success = false;
UINT32 arusTileType;
UINT16 arusStructureNumber;
if ( IsDragStructurePresent( this->sDragGridNo, this->pathing.bLevel, arusTileType, arusStructureNumber ) )
UINT8 hitpoints;
UINT8 decalflag;
if ( IsDragStructurePresent( this->sDragGridNo, this->pathing.bLevel, arusTileType, arusStructureNumber, hitpoints, decalflag ) )
{
// add
if ( BuildStructDrag( sOldGridNo, gsInterfaceLevel, arusTileType, arusStructureNumber, this->ubID ) )
{
// as structures might be damaged/have decals, make sure to keep the old values
CorrectDragStructData( sOldGridNo, (INT8)gsInterfaceLevel, hitpoints, decalflag );
// remove
RemoveStructDrag( this->sDragGridNo, (INT8)gsInterfaceLevel, arusTileType );
@@ -20698,7 +20704,9 @@ BOOLEAN SOLDIERTYPE::CanDragStructure( INT32 sGridNo )
UINT32 tiletype;
UINT16 structurenumber;
if ( !IsDragStructurePresent( sGridNo, this->pathing.bLevel, tiletype, structurenumber ) )
UINT8 hitpoints;
UINT8 decalflag;
if ( !IsDragStructurePresent( sGridNo, this->pathing.bLevel, tiletype, structurenumber, hitpoints, decalflag ) )
return FALSE;
// Now we need to check if there is not a wall between the two middle tiles