mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
Fixed bug with merc swap feature which was introduced with Waldo the mechanic. Faces were swapped incorrectly.
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6797 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -6668,37 +6668,43 @@ void SwapMercPortraits ( SOLDIERTYPE *pSoldier, INT8 bDirection )
|
|||||||
|
|
||||||
UINT8 ubSourceMerc = (UINT8)gusSelectedSoldier;
|
UINT8 ubSourceMerc = (UINT8)gusSelectedSoldier;
|
||||||
UINT8 ubTargetMerc;
|
UINT8 ubTargetMerc;
|
||||||
|
INT32 iSourceFace;
|
||||||
|
INT32 iTargetFace;
|
||||||
UINT8 ubGroupID = pSoldier->ubGroupID;
|
UINT8 ubGroupID = pSoldier->ubGroupID;
|
||||||
INT8 bOldPosition = GetTeamSlotFromPlayerID ( MercPtrs[ ubSourceMerc ]->ubID );
|
INT8 bOldPosition = GetTeamSlotFromPlayerID ( MercPtrs[ ubSourceMerc ]->ubID );
|
||||||
INT8 bNewPosition = bOldPosition + bDirection;
|
INT8 bNewPosition = bOldPosition + bDirection;
|
||||||
SOLDIERTYPE TempMercPtr = *MercPtrs[ ubSourceMerc ];
|
SOLDIERTYPE TempMercPtr = *MercPtrs[ ubSourceMerc ];
|
||||||
FACETYPE TempFace = gFacesData[ ubSourceMerc +1 ];
|
|
||||||
|
|
||||||
// check if new position is occupied by another merc? we won't replace an empty slot
|
// check if new position is occupied by another merc? we won't replace an empty slot
|
||||||
if ( gTeamPanel[ bNewPosition ].fOccupied && gTeamPanel[ bNewPosition ].ubID != NOBODY )
|
if ( gTeamPanel[ bNewPosition ].fOccupied && gTeamPanel[ bNewPosition ].ubID != NOBODY )
|
||||||
{
|
{
|
||||||
ubTargetMerc = gTeamPanel[ bNewPosition ].ubID;
|
ubTargetMerc = gTeamPanel[ bNewPosition ].ubID;
|
||||||
|
|
||||||
|
// store face indexes
|
||||||
|
iSourceFace = MercPtrs[ ubSourceMerc ]->iFaceIndex;
|
||||||
|
iTargetFace = MercPtrs[ ubTargetMerc ]->iFaceIndex;
|
||||||
|
FACETYPE TempFace = gFacesData[ iSourceFace ];
|
||||||
|
|
||||||
// swap the data
|
// swap the data
|
||||||
*MercPtrs[ ubSourceMerc ] = *MercPtrs[ ubTargetMerc ];
|
*MercPtrs[ ubSourceMerc ] = *MercPtrs[ ubTargetMerc ];
|
||||||
*MercPtrs[ ubTargetMerc ] = TempMercPtr;
|
*MercPtrs[ ubTargetMerc ] = TempMercPtr;
|
||||||
// also swap face data, otherwise face gear, opp count etc won't update
|
// also swap face data, otherwise face gear, opp count etc won't update
|
||||||
gFacesData[ ubSourceMerc +1 ] = gFacesData[ ubTargetMerc +1 ];
|
gFacesData[ iSourceFace ] = gFacesData[ iTargetFace ];
|
||||||
gFacesData[ ubTargetMerc +1 ] = TempFace;
|
gFacesData[ iTargetFace ] = TempFace;
|
||||||
|
|
||||||
// update IDs in the data so they match array index again
|
// update IDs in the data so they match array index again
|
||||||
MercPtrs[ ubSourceMerc ]->ubID = ubSourceMerc;
|
MercPtrs[ ubSourceMerc ]->ubID = ubSourceMerc;
|
||||||
MercPtrs[ ubTargetMerc ]->ubID = ubTargetMerc;
|
MercPtrs[ ubTargetMerc ]->ubID = ubTargetMerc;
|
||||||
gFacesData[ ubSourceMerc +1 ].iID = ubSourceMerc +1;
|
gFacesData[ iSourceFace ].iID = iSourceFace;
|
||||||
gFacesData[ ubTargetMerc +1 ].iID = ubTargetMerc +1;
|
gFacesData[ iTargetFace ].iID = iTargetFace;
|
||||||
|
|
||||||
// update soldier ID so they match array index again
|
// update soldier ID so they match merc index again
|
||||||
gFacesData[ ubSourceMerc +1 ].ubSoldierID = ubSourceMerc;
|
gFacesData[ iSourceFace ].ubSoldierID = ubSourceMerc;
|
||||||
gFacesData[ ubTargetMerc +1 ].ubSoldierID = ubTargetMerc;
|
gFacesData[ iTargetFace ].ubSoldierID = ubTargetMerc;
|
||||||
|
|
||||||
// update face index in merc data
|
// update face index in merc data
|
||||||
MercPtrs[ ubSourceMerc ]->iFaceIndex = ubSourceMerc +1;
|
MercPtrs[ ubSourceMerc ]->iFaceIndex = iSourceFace;
|
||||||
MercPtrs[ ubTargetMerc ]->iFaceIndex = ubTargetMerc +1;
|
MercPtrs[ ubTargetMerc ]->iFaceIndex = iTargetFace;
|
||||||
|
|
||||||
// update group info
|
// update group info
|
||||||
RemovePlayerFromGroup( ubGroupID, MercPtrs[ ubSourceMerc ] );
|
RemovePlayerFromGroup( ubGroupID, MercPtrs[ ubSourceMerc ] );
|
||||||
|
|||||||
Reference in New Issue
Block a user