mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
'Improve Gear'-function now also merges magazines and fills up ammo stacks
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8221 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -5100,6 +5100,36 @@ void UpdateGear()
|
||||
|
||||
if ( pObj != NULL ) // ... if pointer is not obviously useless ...
|
||||
{
|
||||
// before replacing it, merge ammo in stacks, the not-full mag being the visible one
|
||||
// by doing this we won't have so many used magazines lying around
|
||||
if ( (Item[pObj->usItem].usItemClass & IC_AMMO) && pObj->ubNumberOfObjects > 1 )
|
||||
{
|
||||
UINT32 ammocount = 0;
|
||||
for ( INT16 i = 0; i < pObj->ubNumberOfObjects; ++i )
|
||||
ammocount += (*pObj)[i]->data.ubShotsLeft;
|
||||
|
||||
UINT16 usMagIndex = Item[pObj->usItem].ubClassIndex;
|
||||
UINT16 magsize = Magazine[usMagIndex].ubMagSize;
|
||||
|
||||
if ( magsize )
|
||||
{
|
||||
UINT8 fullmags = ammocount / magsize;
|
||||
|
||||
UINT16 leftover = ammocount - fullmags * magsize;
|
||||
|
||||
UINT8 totalmags = fullmags + (leftover > 0 ? 1 : 0);
|
||||
|
||||
if ( totalmags < pObj->ubNumberOfObjects )
|
||||
pObj->RemoveObjectsFromStack( pObj->ubNumberOfObjects - totalmags );
|
||||
|
||||
for ( INT16 i = 0; i < totalmags; ++i )
|
||||
(*pObj)[i]->data.ubShotsLeft = magsize;
|
||||
|
||||
if ( leftover > 0 )
|
||||
(*pObj)[0]->data.ubShotsLeft = leftover;
|
||||
}
|
||||
}
|
||||
|
||||
for ( INT16 i = 0; i < pObj->ubNumberOfObjects; ++i ) // ... there might be multiple items here (item stack), so for each one ...
|
||||
{
|
||||
// we could improve our gear by changing this object with another one
|
||||
@@ -5169,6 +5199,54 @@ void UpdateGear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if this is an ammo stack that could use more mags, try to fill it up
|
||||
if ( (Item[pObj->usItem].usItemClass & IC_AMMO) )
|
||||
{
|
||||
UINT8 ubSlotLimit = ItemSlotLimit( pObj, bLoop, pSoldier, FALSE );
|
||||
UINT16 usMagIndex = Item[pObj->usItem].ubClassIndex;
|
||||
UINT16 magsize = Magazine[usMagIndex].ubMagSize;
|
||||
|
||||
if ( magsize )
|
||||
{
|
||||
while ( pObj->ubNumberOfObjects < ubSlotLimit )
|
||||
{
|
||||
int add = ubSlotLimit - pObj->ubNumberOfObjects;
|
||||
|
||||
UINT8 index = 0;
|
||||
OBJECTTYPE* pObj_Better = GetBetterSectorObject( pObj->usItem, 0, index );
|
||||
|
||||
if ( pObj_Better )
|
||||
{
|
||||
pObj->AddObjectsToStack( *pObj_Better, add );
|
||||
|
||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, TacticalStr[IMPROVEGEARPICKUPMAG_STR], pSoldier->GetName( ), Item[pObj->usItem].szItemName );
|
||||
|
||||
// re-merge the magazines again, in case we picked up not full magazines
|
||||
UINT32 ammocount = 0;
|
||||
for ( INT16 i = 0; i < pObj->ubNumberOfObjects; ++i )
|
||||
ammocount += (*pObj)[i]->data.ubShotsLeft;
|
||||
|
||||
UINT8 fullmags = ammocount / magsize;
|
||||
|
||||
UINT16 leftover = ammocount - fullmags * magsize;
|
||||
|
||||
UINT8 totalmags = fullmags + (leftover > 0 ? 1 : 0);
|
||||
|
||||
if ( totalmags < pObj->ubNumberOfObjects )
|
||||
pObj->RemoveObjectsFromStack( pObj->ubNumberOfObjects - totalmags );
|
||||
|
||||
for ( INT16 i = 0; i < totalmags; ++i )
|
||||
(*pObj)[i]->data.ubShotsLeft = magsize;
|
||||
|
||||
if ( leftover > 0 )
|
||||
(*pObj)[0]->data.ubShotsLeft = leftover;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1131,6 +1131,7 @@ enum
|
||||
|
||||
IMPROVEGEARBUTTON_STR,
|
||||
IMPROVEGEARDESCRIBE_STR,
|
||||
IMPROVEGEARPICKUPMAG_STR,
|
||||
|
||||
TEXT_NUM_TACTICAL_STR
|
||||
};
|
||||
|
||||
@@ -4002,6 +4002,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
|
||||
|
||||
L"改进装备", //L"Improve gear",
|
||||
L"%s 改变 %s 对高级版本", //L"%s changed %s for superior version",
|
||||
L"%s picked up %s", // TODO.Translate
|
||||
};
|
||||
|
||||
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
|
||||
|
||||
@@ -4001,6 +4001,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
|
||||
|
||||
L"Improve gear",
|
||||
L"%s changed %s for superior version",
|
||||
L"%s picked up %s", // TODO.Translate
|
||||
};
|
||||
|
||||
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
|
||||
|
||||
@@ -3999,6 +3999,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
|
||||
|
||||
L"Improve gear",
|
||||
L"%s changed %s for superior version",
|
||||
L"%s picked up %s",
|
||||
};
|
||||
|
||||
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
|
||||
|
||||
@@ -4005,6 +4005,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
|
||||
|
||||
L"Improve gear",
|
||||
L"%s changed %s for superior version",
|
||||
L"%s picked up %s", // TODO.Translate
|
||||
};
|
||||
|
||||
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
|
||||
|
||||
@@ -4007,6 +4007,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
|
||||
|
||||
L"Improve gear",
|
||||
L"%s changed %s for superior version",
|
||||
L"%s picked up %s", // TODO.Translate
|
||||
};
|
||||
|
||||
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
|
||||
|
||||
@@ -3995,6 +3995,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
|
||||
|
||||
L"Improve gear",
|
||||
L"%s changed %s for superior version",
|
||||
L"%s picked up %s", // TODO.Translate
|
||||
};
|
||||
|
||||
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
|
||||
|
||||
@@ -4006,6 +4006,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
|
||||
|
||||
L"Improve gear",
|
||||
L"%s changed %s for superior version",
|
||||
L"%s picked up %s", // TODO.Translate
|
||||
};
|
||||
|
||||
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
|
||||
|
||||
@@ -3999,6 +3999,7 @@ CHAR16 TacticalStr[][ MED_STRING_LENGTH ] =
|
||||
|
||||
L"Improve gear",
|
||||
L"%s changed %s for superior version",
|
||||
L"%s picked up %s", // TODO.Translate
|
||||
};
|
||||
|
||||
//Varying helptext explains (for the "Go to Sector/Map" checkbox) what will happen given different circumstances in the "exiting sector" interface.
|
||||
|
||||
Reference in New Issue
Block a user