Fix: sometimes items moved by the MOVEITEM assignment are left unreachable

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8100 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-03-09 20:18:35 +00:00
parent 908923e813
commit 1689f1b571
9 changed files with 37 additions and 7 deletions
+13 -6
View File
@@ -7139,9 +7139,9 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
std::map<UINT8, std::pair<UINT8, UINT8> > sectormercmap; // this map uses the sectors we take stuff from as keys and the number of mercs as elements
// we need a gridno to which we drop stuff
INT32 sDropOffGridNo = gMapInformation.sCenterGridNo;
if ( !GridNoOnVisibleWorldTile( sDropOffGridNo ) )
sDropOffGridNo = RandomGridNo();
INT32 sDropOffGridNo = NOWHERE;
if ( (gWorldSectorX == sMapX) && (gWorldSectorY == sMapY) && (gbWorldSectorZ == bZ) )
sDropOffGridNo = gMapInformation.sCenterGridNo;
SOLDIERTYPE *pSoldier = NULL;
UINT32 uiCnt = 0;
@@ -7176,7 +7176,7 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
sectormercmap[targetsector] = pair;
}
if ( pSoldier->sGridNo != NOWHERE )
if ( TileIsOutOfBounds(sDropOffGridNo) && !TileIsOutOfBounds( pSoldier->sGridNo ) )
sDropOffGridNo = pSoldier->sGridNo;
}
}
@@ -7185,10 +7185,17 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
// no mercs that move stuff here, exit
if ( sectormercmap.empty() )
return;
CHAR16 wSectorName[ 64 ];
GetShortSectorString( sMapX, sMapY, wSectorName );
// if we don't have a valid spot to drop gear at, don't do so - better than having tons of items unreachable
if ( TileIsOutOfBounds( sDropOffGridNo ) )
{
ScreenMsg( FONT_MCOLOR_RED, MSG_INTERFACE, pMapErrorString[50], wSectorName );
return;
}
std::vector<WORLDITEM> pWorldItem_Target;//dnl ch75 271013
// now loop over all sectors from which we take stuff, and move the equipment
@@ -7336,7 +7343,7 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
CHAR16 wSectorName_Target[ 64 ];
GetShortSectorString( targetX, targetY, wSectorName_Target );
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"%d items moved from %s to %s", moveditems, wSectorName_Target, wSectorName );
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pMapErrorString[51], moveditems, wSectorName_Target, wSectorName );
// if we didn't move any item, no need to save a changed inventory etc.
if ( !moveditems )