mirror of
https://github.com/1dot13/source.git
synced 2026-08-19 14:20:30 +02:00
Added: Ctrl+Shift+E now fill LBE items in sector with other items and places them in vehicles first.
Added: Right-Click on remove attachments button on sector inventory screen will not empty LBE items in sector Changed: SLAY_STAYS_FOREVER disables Slay's hourly chance to leave when unattended Added: SLAY_HOURLY_CHANCE_TO_LEAVE setting to Ja2_Options.ini Fixed: a bunch of array index out of bounds bugs Fixed: a bunch of typos in if contitions Fixed: BuildListFile() function loading items from index 1 instead 0 Added translation: Polish text for some map inventory screen items Added translation: English texts for new functionality for other language files Cleaned up some old TODOs git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8404 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -4833,7 +4833,7 @@ BOOLEAN CleanObject( SOLDIERTYPE * pSoldier, SOLDIERTYPE * pOwner, OBJECTTYPE *
|
||||
BOOLEAN bFullyCleaned = FALSE;
|
||||
|
||||
// no gun? We shouldn't be here...
|
||||
if ( !Item[pObj->usItem].usItemClass & IC_GUN )
|
||||
if ( !(Item[pObj->usItem].usItemClass & IC_GUN) )
|
||||
Assert(0);
|
||||
|
||||
ubItemsInPocket = pObj->ubNumberOfObjects;
|
||||
@@ -5033,7 +5033,7 @@ void HandleRepairBySoldier( SOLDIERTYPE *pSoldier )
|
||||
// we spent some time cleaning so adjust repair points accordingly
|
||||
if ( ubRepairPtsLeft > 0 && ubInitialCleaningPts > ubCleaningPtsLeft )
|
||||
{
|
||||
ubRepairPtsLeft = UINT8()(ubRepairPtsLeft * ubCleaningPtsLeft / ubInitialCleaningPts);
|
||||
ubRepairPtsLeft = (UINT8)(ubRepairPtsLeft * ubCleaningPtsLeft / ubInitialCleaningPts);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -811,6 +811,8 @@ void HourlyStealUpdate()
|
||||
#else
|
||||
void HourlyCheckIfSlayAloneSoHeCanLeave()
|
||||
{
|
||||
if (gGameExternalOptions.fEnableSlayForever || gGameExternalOptions.ubHourlyChanceSlayWillLeave < 1) return;
|
||||
|
||||
SOLDIERTYPE *pSoldier;
|
||||
pSoldier = FindSoldierByProfileID( SLAY, TRUE );
|
||||
if( !pSoldier )
|
||||
@@ -827,7 +829,7 @@ void HourlyCheckIfSlayAloneSoHeCanLeave()
|
||||
}
|
||||
if( PlayerMercsInSector( (UINT8)pSoldier->sSectorX, (UINT8)pSoldier->sSectorY, pSoldier->bSectorZ ) == 1 )
|
||||
{
|
||||
if( Chance( 15 ) )
|
||||
if( Chance( gGameExternalOptions.ubHourlyChanceSlayWillLeave ) )
|
||||
{
|
||||
pSoldier->ubLeaveHistoryCode = HISTORY_SLAY_MYSTERIOUSLY_LEFT;
|
||||
TacticalCharacterDialogueWithSpecialEvent( pSoldier, 0, DIALOGUE_SPECIAL_EVENT_CONTRACT_ENDING_NO_ASK_EQUIP, 0, 0 );
|
||||
|
||||
@@ -2925,7 +2925,7 @@ SOLDIERTYPE * FindSoldierByProfileID2( UINT8 ubProfileID, BOOLEAN fPlayerMercsOn
|
||||
|
||||
BOOLEAN FindSoldier( SOLDIERTYPE **ppSoldier, UINT16 usSoldierIndex, BOOLEAN fPlayerMercsOnly)
|
||||
{
|
||||
SOLDIERTYPE Menptr[ TOTAL_SOLDIERS ];
|
||||
//SOLDIERTYPE Menptr[ TOTAL_SOLDIERS ];
|
||||
|
||||
*ppSoldier = NULL;
|
||||
|
||||
@@ -12009,11 +12009,15 @@ static int l_SetStartMission(lua_State *L)
|
||||
|
||||
if ( idMission != -1 )
|
||||
{
|
||||
if ( gBriefingRoomData[idMission].CheckMission != MISSIONSTART || gBriefingRoomData[idMission].CheckMission != MISSIONEND || gBriefingRoomData[idMission].CheckMission == MISSIONNOSTARTED )
|
||||
{
|
||||
gBriefingRoomData[idMission].CheckMission = MISSIONSTART; //set start mission
|
||||
gBriefingRoomData[idMission].Hidden = TRUE; // set next mission
|
||||
}
|
||||
if (
|
||||
(gBriefingRoomData[idMission].CheckMission != MISSIONSTART)
|
||||
|| (gBriefingRoomData[idMission].CheckMission != MISSIONEND)
|
||||
|| (gBriefingRoomData[idMission].CheckMission == MISSIONNOSTARTED)
|
||||
)
|
||||
{
|
||||
gBriefingRoomData[idMission].CheckMission = MISSIONSTART; //set start mission
|
||||
gBriefingRoomData[idMission].Hidden = TRUE; // set next mission
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -337,6 +337,7 @@ void AnimateZoomInventory ( UINT16 iLocationInPool, UINT16 iCounter, INT32 iStar
|
||||
// the currently-opened sector inventory ammo.
|
||||
void SortSectorInventoryAmmo(bool useBoxes);
|
||||
void SortSectorInventoryEjectAmmo();
|
||||
void SortSectorInventoryEmptyLBE(); // Bob: added option to empty LBE items in sector
|
||||
void SortSectorInventorySeparateAttachments();
|
||||
void SortSectorInventoryStackAndMerge(bool ammoOnly);
|
||||
// HEADROCK HAM 5: A quick function to rebuilt the Seen and Unseen item pools without saving the inventory.
|
||||
@@ -2244,15 +2245,22 @@ void BuildStashForSelectedSector( INT16 sMapX, INT16 sMapY, INT16 sMapZ )
|
||||
{
|
||||
uiTotalNumberOfItems = guiNumWorldItems;
|
||||
uiNumOfSlots = (uiTotalNumberOfItems / MAP_INVENTORY_POOL_SLOT_COUNT + 1) * MAP_INVENTORY_POOL_SLOT_COUNT;
|
||||
if(pInventoryPoolList.size() < uiNumOfSlots)
|
||||
|
||||
if (pInventoryPoolList.size() < uiNumOfSlots) {
|
||||
pInventoryPoolList.resize(uiNumOfSlots);
|
||||
if(pUnSeenItems.size() < uiNumOfSlots)
|
||||
}
|
||||
|
||||
if (pUnSeenItems.size() < uiNumOfSlots) {
|
||||
pUnSeenItems.resize(uiNumOfSlots);
|
||||
}
|
||||
|
||||
uiNumberOfSeenItems = 0;
|
||||
uiNumberOfUnSeenItems = 0;
|
||||
|
||||
pwi = &gWorldItems.front();
|
||||
pipl = &pInventoryPoolList.front();
|
||||
pusi = &pUnSeenItems.front();
|
||||
|
||||
for(i=0; i<uiTotalNumberOfItems; i++, pwi++)
|
||||
{
|
||||
if(IsMapScreenWorldItemVisibleInMapInventory(pwi))
|
||||
@@ -2814,13 +2822,21 @@ void MapInventoryPoolStackAndMergeBtn( GUI_BUTTON *btn, INT32 reason )
|
||||
// HEADROCK HAM 5: Sort attachments button callback
|
||||
void MapInventoryPoolSortAttachmentsBtn( GUI_BUTTON *btn, INT32 reason )
|
||||
{
|
||||
if (reason & MSYS_CALLBACK_REASON_LBUTTON_DWN)
|
||||
if (reason & MSYS_CALLBACK_REASON_LBUTTON_DWN || reason & MSYS_CALLBACK_REASON_RBUTTON_DWN)
|
||||
{
|
||||
if (!(btn->uiFlags & (BUTTON_CLICKED_ON)))
|
||||
{
|
||||
btn->uiFlags |= (BUTTON_CLICKED_ON);
|
||||
}
|
||||
}
|
||||
if (reason & MSYS_CALLBACK_REASON_RBUTTON_UP)
|
||||
{
|
||||
if (btn->uiFlags & (BUTTON_CLICKED_ON))
|
||||
{
|
||||
SortSectorInventoryEmptyLBE();
|
||||
btn->uiFlags &= ~(BUTTON_CLICKED_ON);
|
||||
}
|
||||
}
|
||||
if (reason & MSYS_CALLBACK_REASON_LBUTTON_UP)
|
||||
{
|
||||
if (btn->uiFlags & (BUTTON_CLICKED_ON))
|
||||
@@ -2829,6 +2845,7 @@ void MapInventoryPoolSortAttachmentsBtn( GUI_BUTTON *btn, INT32 reason )
|
||||
btn->uiFlags &=~ (BUTTON_CLICKED_ON);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// HEADROCK HAM 5: Eject Ammo button callback
|
||||
@@ -4002,21 +4019,27 @@ BOOLEAN SortInventoryPoolQ(void)
|
||||
BOOLEAN SwitchToInventoryPoolQ(UINT8 newidx)//dnl ch75 021113
|
||||
{
|
||||
UINT8 curidx = gInventoryPoolIndex & 0x0F;
|
||||
if(curidx >= INVPOOLLISTNUM)
|
||||
return(FALSE);
|
||||
|
||||
newidx &= 0x0F;
|
||||
|
||||
if(curidx == newidx)
|
||||
return(FALSE);
|
||||
|
||||
MapInventoryFilterSet(IC_MAPFILTER_ALL);
|
||||
#if 0
|
||||
pInventoryPoolListQ[curidx] = pInventoryPoolList;
|
||||
#else
|
||||
|
||||
UINT32 uiNumOfSlots = (iLastInventoryPoolPage + 1) * MAP_INVENTORY_POOL_SLOT_COUNT;
|
||||
|
||||
if(pInventoryPoolListQ[curidx].size() != uiNumOfSlots)
|
||||
pInventoryPoolListQ[curidx].resize(uiNumOfSlots);
|
||||
|
||||
WORLDITEM *pwiQ1 = &pInventoryPoolListQ[curidx].front();
|
||||
WORLDITEM *pwiQ2 = &pInventoryPoolListQ[curidx].back();
|
||||
WORLDITEM *pwi1 = &pInventoryPoolList.front();
|
||||
WORLDITEM *pwi2 = &pInventoryPoolList.back();
|
||||
int cnt = 0;
|
||||
|
||||
while(pwi1 <= pwi2)
|
||||
{
|
||||
if(pwi1->fExists)
|
||||
@@ -4027,22 +4050,23 @@ BOOLEAN SwitchToInventoryPoolQ(UINT8 newidx)//dnl ch75 021113
|
||||
pwi1++;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
while(pwiQ1 <= pwiQ2)
|
||||
{
|
||||
pwiQ1->fExists = FALSE;
|
||||
pwiQ1->object.ubNumberOfObjects = 0;
|
||||
pwiQ1++;
|
||||
}
|
||||
#endif
|
||||
|
||||
iCurrentInventoryPoolPageQ[curidx] = iCurrentInventoryPoolPage;
|
||||
iLastInventoryPoolPageQ[curidx] = iLastInventoryPoolPage;
|
||||
|
||||
if(pInventoryPoolListQ[newidx].empty() == true)
|
||||
pInventoryPoolListQ[newidx].resize(MAP_INVENTORY_POOL_SLOT_COUNT);
|
||||
#if 0
|
||||
pInventoryPoolList = pInventoryPoolListQ[newidx];
|
||||
#else
|
||||
|
||||
if(pInventoryPoolList.size() < pInventoryPoolListQ[newidx].size())
|
||||
pInventoryPoolList.resize(pInventoryPoolListQ[newidx].size());
|
||||
|
||||
pwiQ1 = &pInventoryPoolListQ[newidx].front();
|
||||
pwiQ2 = &pInventoryPoolListQ[newidx].back();
|
||||
pwi1 = &pInventoryPoolList.front();
|
||||
@@ -4064,11 +4088,12 @@ BOOLEAN SwitchToInventoryPoolQ(UINT8 newidx)//dnl ch75 021113
|
||||
pwi1->object.ubNumberOfObjects = 0;
|
||||
pwi1++;
|
||||
}
|
||||
#endif
|
||||
|
||||
iCurrentInventoryPoolPage = iCurrentInventoryPoolPageQ[newidx];
|
||||
iLastInventoryPoolPage = iLastInventoryPoolPageQ[newidx];
|
||||
gInventoryPoolIndex = newidx | 0x30;
|
||||
fMapPanelDirty = TRUE;
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
@@ -5011,23 +5036,98 @@ void SortSectorInventoryEjectAmmo()
|
||||
fMapPanelDirty=TRUE;
|
||||
}
|
||||
|
||||
void SortSectorInventoryEmptyLBE() {
|
||||
// current item
|
||||
WORLDITEM * pInventoryItem = NULL;
|
||||
|
||||
SOLDIERTYPE * pSoldier = &(Menptr[gCharactersList[bSelectedInfoChar].usSolID]);
|
||||
|
||||
for (UINT32 uiLoop = 0; uiLoop < pInventoryPoolList.size(); uiLoop++) //for all items in sector
|
||||
{
|
||||
pInventoryItem = &(pInventoryPoolList[uiLoop]);
|
||||
|
||||
if (pInventoryItem->bVisible == TRUE && // Visible
|
||||
pInventoryItem->object.exists() == true && // Exists
|
||||
pInventoryItem->usFlags & WORLD_ITEM_REACHABLE && // Reachable
|
||||
!(pInventoryItem->usFlags & WORLD_ITEM_ARMED_BOMB)) // Not booby-trapped!
|
||||
{
|
||||
// Iterate through stacks
|
||||
for (int x = 0; x < pInventoryItem->object.ubNumberOfObjects; ++x)
|
||||
{
|
||||
UINT8 size = 0, cnt = 0, uiLoopCnt = 0;
|
||||
// Bob: empty LBE items in sector inventory
|
||||
if (pInventoryItem->object.IsActiveLBE(x)) {
|
||||
LBENODE * lbePtr = pInventoryItem->object.GetLBEPointer(x);
|
||||
INVTYPE & LBEType = Item[pInventoryItem->object.usItem];
|
||||
|
||||
if (lbePtr != NULL) {
|
||||
int dropCnt = 0;
|
||||
|
||||
for (auto lbeInvIter = lbePtr->inv.begin(); lbeInvIter != lbePtr->inv.end(); lbeInvIter++) {
|
||||
OBJECTTYPE * LBEStack = lbeInvIter._Ptr;
|
||||
dropCnt += LBEStack->ubNumberOfObjects;
|
||||
|
||||
AutoPlaceObjectToWorld(pSoldier, LBEStack, true);
|
||||
if (LBEStack != NULL)
|
||||
{
|
||||
DeleteObj(lbeInvIter._Ptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (dropCnt > 0) {
|
||||
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, gzMapInventorySortingMessage[5], dropCnt, LBEType.szItemName);
|
||||
}
|
||||
else {
|
||||
ScreenMsg(FONT_MCOLOR_LTRED, MSG_INTERFACE, gzMapInventorySortingMessage[6], LBEType.szItemName);
|
||||
}
|
||||
|
||||
if (DestroyLBEIfEmpty(&(pInventoryItem->object), x)) {
|
||||
ScreenMsg(FONT_MCOLOR_LTGREEN, MSG_INTERFACE, gzMapInventorySortingMessage[7], LBEType.szItemName);
|
||||
}
|
||||
else {
|
||||
ScreenMsg(FONT_MCOLOR_LTRED, MSG_INTERFACE, gzMapInventorySortingMessage[8], LBEType.szItemName);
|
||||
}
|
||||
}
|
||||
else { // can't get LBE pointer, something is wrong
|
||||
ScreenMsg(FONT_MCOLOR_LTRED, MSG_INTERFACE, gzMapInventorySortingMessage[9], LBEType.szItemName);
|
||||
}
|
||||
} // IsActiveLBE
|
||||
} // Iterate through stacks
|
||||
} // pInventoryPoolList loop
|
||||
}
|
||||
|
||||
// "FINISHED"
|
||||
CHAR16 pStr[500];
|
||||
swprintf(pStr, gzMapInventorySortingMessage[4], 'A' + sSelMapY - 1, sSelMapX);
|
||||
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pStr);
|
||||
|
||||
// Dirty!
|
||||
fMapPanelDirty = TRUE;
|
||||
}
|
||||
|
||||
void SortSectorInventorySeparateAttachments()
|
||||
{
|
||||
|
||||
// attachment ref and pointer
|
||||
OBJECTTYPE gTempObject;
|
||||
|
||||
SOLDIERTYPE * pSoldier = &(Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ]);
|
||||
OBJECTTYPE * gpTempObject = NULL;
|
||||
|
||||
for ( UINT32 uiLoop = 0; uiLoop < pInventoryPoolList.size(); uiLoop++ ) //for all items in sector
|
||||
// current item
|
||||
WORLDITEM * pInventoryItem = NULL;
|
||||
|
||||
|
||||
SOLDIERTYPE * pSoldier = &(Menptr[gCharactersList[bSelectedInfoChar].usSolID]);
|
||||
|
||||
for (UINT32 uiLoop = 0; uiLoop < pInventoryPoolList.size(); uiLoop++) //for all items in sector
|
||||
{
|
||||
if ( pInventoryPoolList[uiLoop].bVisible == TRUE && // Visible
|
||||
pInventoryPoolList[uiLoop].object.exists() == true && // Exists
|
||||
pInventoryPoolList[uiLoop].usFlags & WORLD_ITEM_REACHABLE && // Reachable
|
||||
!(pInventoryPoolList[uiLoop].usFlags & WORLD_ITEM_ARMED_BOMB) ) // Not booby-trapped!
|
||||
{
|
||||
pInventoryItem = &(pInventoryPoolList[uiLoop]);
|
||||
|
||||
if (pInventoryItem->bVisible == TRUE && // Visible
|
||||
pInventoryItem->object.exists() == true && // Exists
|
||||
pInventoryItem->usFlags & WORLD_ITEM_REACHABLE && // Reachable
|
||||
!(pInventoryItem->usFlags & WORLD_ITEM_ARMED_BOMB)) // Not booby-trapped!
|
||||
{
|
||||
// Iterate through stacks
|
||||
for (int x = 0; x < pInventoryPoolList[uiLoop].object.ubNumberOfObjects; ++x)
|
||||
for (int x = 0; x < pInventoryItem->object.ubNumberOfObjects; ++x)
|
||||
{
|
||||
UINT8 size = 0, cnt = 0, uiLoopCnt = 0;
|
||||
|
||||
@@ -5035,17 +5135,28 @@ void SortSectorInventorySeparateAttachments()
|
||||
// launchers before detaching the launchers (and their grenade slots) themselves.
|
||||
// Since the size of the attachmentList remains constant under NAS but decrements by one
|
||||
// under OAS, recheck the list size every iteration in order to calculate an rindex.
|
||||
while((size = pInventoryPoolList[uiLoop].object[x]->attachments.size()) != cnt)
|
||||
while ((size = pInventoryItem->object[x]->attachments.size()) != cnt)
|
||||
{
|
||||
gTempObject = *(pInventoryPoolList[uiLoop].object[x]->GetAttachmentAtIndex(size - 1 - cnt));
|
||||
OBJECTTYPE * pNewObj = new OBJECTTYPE();
|
||||
gpTempObject = pInventoryItem->object[x]->GetAttachmentAtIndex(size - 1 - cnt);
|
||||
|
||||
//WarmSteel - This actually still works with NAS, be it by accident
|
||||
if (pInventoryPoolList[uiLoop].object.RemoveAttachment(&gTempObject,0,x))
|
||||
if (gpTempObject != NULL && pInventoryItem->object.RemoveAttachment(gpTempObject, pNewObj, x))
|
||||
{
|
||||
AutoPlaceObjectToWorld( pSoldier, &gTempObject, true );
|
||||
if (&gTempObject != NULL)
|
||||
// Bob: sanity check! I think RemoveAttachment shouldn't be used like it was here.
|
||||
if (gpTempObject->usItem > 0 && (gpTempObject->ubNumberOfObjects != 1 || gpTempObject->usItem > MAXITEMS || gpTempObject->ubMission != 0)) {
|
||||
gpTempObject = pNewObj;
|
||||
}
|
||||
|
||||
// Bob: not sure why was this a ref instead of a pointer,
|
||||
// I'll leave it here so it gets cleaned up when going out of scope
|
||||
// since DeleteObj() doesn't free all the memory
|
||||
gTempObject = *gpTempObject;
|
||||
|
||||
AutoPlaceObjectToWorld(pSoldier, gpTempObject, true);
|
||||
if (gpTempObject != NULL)
|
||||
{
|
||||
DeleteObj( &gTempObject );
|
||||
DeleteObj(gpTempObject);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -5053,24 +5164,25 @@ void SortSectorInventorySeparateAttachments()
|
||||
cnt++;
|
||||
}
|
||||
|
||||
uiLoopCnt ++;
|
||||
uiLoopCnt++;
|
||||
|
||||
// Failsafe
|
||||
if(uiLoopCnt > 100)
|
||||
if (uiLoopCnt > 100)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // Iterate through stacks
|
||||
} // pInventoryPoolList loop
|
||||
}
|
||||
|
||||
// "FINISHED"
|
||||
CHAR16 pStr[500];
|
||||
swprintf( pStr, gzMapInventorySortingMessage[ 1 ], 'A' + sSelMapY - 1, sSelMapX );
|
||||
ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pStr );
|
||||
swprintf(pStr, gzMapInventorySortingMessage[1], 'A' + sSelMapY - 1, sSelMapX);
|
||||
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, pStr);
|
||||
|
||||
// Dirty!
|
||||
fMapPanelDirty=TRUE;
|
||||
fMapPanelDirty = TRUE;
|
||||
}
|
||||
|
||||
// HEADROCK HAM 5: This function sorts all inventory items into stacks. It is similar to a hotkey-driven
|
||||
|
||||
+172
-28
@@ -1035,6 +1035,14 @@ void ChangeCharacterListSortMethod( INT32 iValue );
|
||||
|
||||
void MapscreenMarkButtonsDirty();
|
||||
|
||||
// Bob: functions for packing vehicles with filled LBE items
|
||||
void moveSectorInventoryToVehicle(SOLDIERTYPE *pSoldier);
|
||||
void fillCurrentSectorLBEItems(SOLDIERTYPE *pSoldier);
|
||||
void fillLBEWithSectorItems(OBJECTTYPE * LBEObject);
|
||||
void moveCurrentSectorItemsToVehicle(SOLDIERTYPE *pSoldier);
|
||||
bool placeItemInVehicle(SOLDIERTYPE *pSoldier, WORLDITEM &worldItem);
|
||||
bool placeItemInVehicle(SOLDIERTYPE *pSoldier, OBJECTTYPE &item);
|
||||
|
||||
extern BOOLEAN CanRedistributeMilitiaInSector( INT16 sClickedSectorX, INT16 sClickedSectorY, INT8 bClickedTownId );
|
||||
|
||||
extern INT32 GetNumberOfMercsInUpdateList( void );
|
||||
@@ -7671,34 +7679,7 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
|
||||
{
|
||||
if (gGameExternalOptions.fVehicleInventory)
|
||||
{
|
||||
for (unsigned int i = 0; i < pInventoryPoolList.size(); i++)
|
||||
{
|
||||
if (pInventoryPoolList[i].fExists == TRUE && (pInventoryPoolList[i].usFlags & WORLD_ITEM_REACHABLE))
|
||||
{
|
||||
for (int x = 0; x < NUM_INV_SLOTS; x++)
|
||||
{
|
||||
if (vehicleInv[x] == FALSE)
|
||||
continue;
|
||||
if (pSoldier->inv[x].exists() == true)
|
||||
{
|
||||
if (pSoldier->inv[x].usItem != pInventoryPoolList[i].object.usItem)
|
||||
continue;
|
||||
else
|
||||
pInventoryPoolList[i].object.AddObjectsToStack(pSoldier->inv[x], -1, pSoldier, x);
|
||||
}
|
||||
else
|
||||
pInventoryPoolList[i].object.MoveThisObjectTo(pSoldier->inv[x], -1, pSoldier, x);
|
||||
if (pInventoryPoolList[i].object.ubNumberOfObjects < 0)
|
||||
{
|
||||
//RemoveItemFromWorld(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fTeamPanelDirty = TRUE;
|
||||
fMapPanelDirty = TRUE;
|
||||
fInterfacePanelDirty = DIRTYLEVEL2;
|
||||
}
|
||||
moveSectorInventoryToVehicle(pSoldier);
|
||||
}
|
||||
}
|
||||
// Flugente: also allow mercs to qickly pick up items this way (but not EPCs)
|
||||
@@ -16973,3 +16954,166 @@ void RetreatBandageCallback( UINT8 ubResult )
|
||||
{
|
||||
HandleRetreatBandaging( );
|
||||
}
|
||||
|
||||
// Bob: moved here to expand what CHRISL did
|
||||
// try to move all items in sector into the vehicle inventory. Try to use LBE items in sector to store as much stuff as possible
|
||||
void moveSectorInventoryToVehicle(SOLDIERTYPE *pSoldier) {
|
||||
|
||||
fillCurrentSectorLBEItems(pSoldier); // puts LBE items in vehicle
|
||||
// ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"---------------------------------------------");
|
||||
// ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Moving remaining sector items into the car...");
|
||||
moveCurrentSectorItemsToVehicle(pSoldier); // puts remaining items in vehicle
|
||||
|
||||
fTeamPanelDirty = TRUE;
|
||||
fMapPanelDirty = TRUE;
|
||||
fInterfacePanelDirty = DIRTYLEVEL2;
|
||||
}
|
||||
|
||||
// fills all empty LBE items in currebt sector with other sector items then tries to place all LBE items in the vehicle (pSoldier)
|
||||
void fillCurrentSectorLBEItems(SOLDIERTYPE *pSoldier) {
|
||||
std::vector<OBJECTTYPE*> LBEObjects; // list of LBE objects found in sector
|
||||
|
||||
// build a list of LBE objects in sector. Stacks are split into separate items.
|
||||
for (unsigned int i = 0; i < pInventoryPoolList.size(); i++)
|
||||
{
|
||||
WORLDITEM & stack = pInventoryPoolList[i];
|
||||
OBJECTTYPE & stackContents = pInventoryPoolList[i].object;
|
||||
INVTYPE & stackContentType = Item[stackContents.usItem];
|
||||
|
||||
if ( stack.fExists == TRUE
|
||||
&& stack.usFlags & WORLD_ITEM_REACHABLE
|
||||
&& stackContentType.usItemClass == IC_LBEGEAR
|
||||
) {
|
||||
for (int j = 0; j< stackContents.ubNumberOfObjects; j++) {
|
||||
OBJECTTYPE * LBEObject = new OBJECTTYPE();
|
||||
|
||||
stackContents.MoveThisObjectTo(*LBEObject, 1);
|
||||
LBEObjects.push_back(LBEObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fill the LBE items in the list with items from current sector then try to put them in the vehicle
|
||||
for (std::vector<OBJECTTYPE*>::iterator LBEItemIter = LBEObjects.begin(); LBEItemIter != LBEObjects.end(); LBEItemIter++) {
|
||||
OBJECTTYPE* LBEItem = *LBEItemIter;
|
||||
INVTYPE LBEItemType = Item[LBEItem->usItem];
|
||||
LBETYPE LBEType = LoadBearingEquipment[LBEItemType.ubClassIndex];
|
||||
|
||||
//ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"===================================");
|
||||
//ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Filling: %s", LBEItemType.szItemName);
|
||||
|
||||
if ( LBEItem->IsActiveLBE(0) == FALSE ) {
|
||||
// init LBE data
|
||||
CreateLBE(LBEItem, pSoldier->ubID, LBEType.lbePocketIndex.size());
|
||||
// stuff it full of sector items
|
||||
fillLBEWithSectorItems(LBEItem);
|
||||
}
|
||||
|
||||
// try to put the LBE item in the vehicle, if we fail then drop it.
|
||||
if (placeItemInVehicle(pSoldier, *LBEItem) == false) {
|
||||
// ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Dropped %s on the ground", LBEItemType.szItemName);
|
||||
AutoPlaceObjectToWorld(pSoldier, LBEItem);
|
||||
} else {
|
||||
// ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Moved %s into the car", LBEItemType.szItemName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// fills LBEObject with items from currently loaded sector. Assumes that LBEObject contains only one item
|
||||
void fillLBEWithSectorItems(OBJECTTYPE * LBEObject) {
|
||||
LBENODE* pLBE = LBEObject->GetLBEPointer(0);
|
||||
|
||||
INVTYPE LBEItemType = Item[LBEObject->usItem];
|
||||
LBETYPE LBEType = LoadBearingEquipment[LBEItemType.ubClassIndex];
|
||||
|
||||
int movedItemsTotal = 0;
|
||||
|
||||
for (int i = 0; i < LBEType.lbePocketIndex.size(); i++) {
|
||||
INT16 lbePocket = LBEType.lbePocketIndex[i];
|
||||
if (lbePocket == 0) continue;
|
||||
|
||||
POCKETTYPE lbePocketType = LBEPocketType[lbePocket];
|
||||
|
||||
for (auto itemIterator = pInventoryPoolList.begin(); itemIterator != pInventoryPoolList.end(); itemIterator++) {
|
||||
WORLDITEM * sectorItemStack = &(*itemIterator);
|
||||
OBJECTTYPE * sectorItemObject = &(itemIterator->object);
|
||||
INVTYPE sectorItemType = Item[sectorItemObject->usItem];
|
||||
|
||||
if (sectorItemStack->fExists && sectorItemStack->usFlags & WORLD_ITEM_REACHABLE && sectorItemType.usItemClass != IC_LBEGEAR && sectorItemObject->usItem > 0) {
|
||||
int pocketCapacity = lbePocketType.ItemCapacityPerSize[sectorItemType.ItemSize];
|
||||
|
||||
if (pocketCapacity > 0) {
|
||||
OBJECTTYPE * pocketItemObject = new OBJECTTYPE();
|
||||
|
||||
int movedItems = (sectorItemObject->ubNumberOfObjects > pocketCapacity) ? pocketCapacity : sectorItemObject->ubNumberOfObjects;
|
||||
|
||||
int remainingItems = sectorItemObject->MoveThisObjectTo(*pocketItemObject, movedItems);
|
||||
|
||||
//ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Moved %s * %i (%i remaining) into %s (%s)", sectorItemType.szItemName, movedItems, remainingItems, LBEItemType.szItemName, lbePocketType.pName);
|
||||
|
||||
pLBE->inv[i] = (*pocketItemObject);
|
||||
|
||||
movedItemsTotal += movedItems;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (movedItemsTotal == 0) {
|
||||
DestroyLBE(LBEObject);
|
||||
}
|
||||
}
|
||||
|
||||
void moveCurrentSectorItemsToVehicle(SOLDIERTYPE *pSoldier) {
|
||||
for (unsigned int i = 0; i < pInventoryPoolList.size(); i++)
|
||||
{
|
||||
if (pInventoryPoolList[i].fExists == TRUE && (pInventoryPoolList[i].usFlags & WORLD_ITEM_REACHABLE))
|
||||
{
|
||||
placeItemInVehicle(pSoldier, pInventoryPoolList[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool placeItemInVehicle(SOLDIERTYPE *pSoldier, WORLDITEM &worldItem) {
|
||||
return placeItemInVehicle(pSoldier, worldItem.object);
|
||||
}
|
||||
|
||||
bool placeItemInVehicle(SOLDIERTYPE *pSoldier, OBJECTTYPE &item) {
|
||||
if (item.usItem < 1) return false;
|
||||
|
||||
INVTYPE sectorItemType = Item[item.usItem];
|
||||
|
||||
for (int x = 0; x < NUM_INV_SLOTS && item.ubNumberOfObjects > 0; x++)
|
||||
{
|
||||
if (vehicleInv[x] == FALSE)
|
||||
continue;
|
||||
|
||||
if (pSoldier->inv[x].exists() == true)
|
||||
{
|
||||
if (pSoldier->inv[x].usItem != item.usItem)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
//ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Stacking %s * %i in car slot %i", sectorItemType.szItemName, item.ubNumberOfObjects, x);
|
||||
pSoldier->inv[x].AddObjectsToStack(item, -1, pSoldier, x);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"Placing %s * %i in car slot %i", sectorItemType.szItemName, item.ubNumberOfObjects, x);
|
||||
int result = item.MoveThisObjectTo(pSoldier->inv[x], -1, pSoldier, x);
|
||||
}
|
||||
|
||||
if (item.ubNumberOfObjects < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (item.ubNumberOfObjects == 0);
|
||||
}
|
||||
|
||||
@@ -676,7 +676,7 @@ samsiteEndElementHandle( void *userData, const XML_Char *name )
|
||||
pData->curElement = SAMSITE_ELEMENT_SAM;
|
||||
|
||||
pData->curSamInfo.samOrientation = (INT8)atol( pData->szCharData );
|
||||
if ( pData->curSamInfo.samOrientation != 3 || pData->curSamInfo.samOrientation != 4 )
|
||||
if ( pData->curSamInfo.samOrientation != 3 && pData->curSamInfo.samOrientation != 4 )
|
||||
{
|
||||
pData->curSamInfo.samOrientation = 3;
|
||||
}
|
||||
@@ -2045,7 +2045,7 @@ void GetMapFileName( INT16 sMapX, INT16 sMapY, INT8 bSectorZ, STR8 bString, BOOL
|
||||
// Debug str
|
||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Map does not exist for %s, using default.", bTestString ) );
|
||||
// Set to a string we know!
|
||||
sprintf( bString, "H10.DAT", pVertStrings[sMapY], pHortStrings[sMapX] );
|
||||
sprintf( bString, "H10.DAT");
|
||||
ScreenMsg( FONT_YELLOW, MSG_DEBUG, L"Using PLACEHOLDER map!" );
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user