mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
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:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user