diff --git a/Strategic/Map Screen Interface Map Inventory.cpp b/Strategic/Map Screen Interface Map Inventory.cpp index 623fb043a..41922b4d6 100644 --- a/Strategic/Map Screen Interface Map Inventory.cpp +++ b/Strategic/Map Screen Interface Map Inventory.cpp @@ -1498,18 +1498,83 @@ void BeginInventoryPoolPtr( OBJECTTYPE *pInventorySlot ) fMapPanelDirty = TRUE; gpItemPointer = &gItemPointer; - if ( _KeyDown ( CTRL ))//Delete Item + if ( _KeyDown ( CTRL ))//MM: Pass item to selected merc. Delete if none selected. { - gpItemPointer = NULL; - fMapInventoryItem = FALSE; + SOLDIERTYPE *pSoldier = &Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ]; + bool placedObject = false; - if ( _KeyDown ( 89 )) //Lalien: delete all items of this type on Ctrl+Y + if(pSoldier->exists() == true) { - DeleteItemsOfType( gItemPointer.usItem ); - ScreenMsg( FONT_MCOLOR_LTRED, MSG_INTERFACE, New113Message[MSG113_DELETE_ALL] ); + if(pSoldier->flags.uiStatusFlags & SOLDIER_VEHICLE) + { + for(int x = 0; xinv[x].exists() == true) + { + if(pSoldier->inv[x].usItem == gpItemPointer->usItem) + { + pSoldier->inv[x].AddObjectsToStack(*gpItemPointer, gpItemPointer->ubNumberOfObjects, pSoldier, x); + placedObject = true; + break; + } + } + else + { + gpItemPointer->MoveThisObjectTo(pSoldier->inv[x], gpItemPointer->ubNumberOfObjects, pSoldier, x); + placedObject = true; + break; + } + } + } + else + { + if (AutoPlaceObject(pSoldier,gpItemPointer,FALSE)) //doesn't work for vehicles :p + placedObject = true; + } + + if (placedObject) + { + fShowInventoryFlag = true; + fTeamPanelDirty = TRUE; + fInterfacePanelDirty = DIRTYLEVEL2; + fMapInventoryItem = FALSE; + gpItemPointer = NULL; + } + else // can't seem to get the code to just leave the item alone after it's been clicked on, so just pick it up... + { + gpItemPointerSoldier = NULL; + + // now set the cursor + guiExternVo = GetInterfaceGraphicForItem( &(Item[ gpItemPointer->usItem ]) ); + gusExternVoSubIndex = g_bUsePngItemImages ? 0 : Item[ gpItemPointer->usItem ].ubGraphicNum; + + fMapInventoryItem = TRUE; + MSYS_ChangeRegionCursor( &gMPanelRegion , EXTERN_CURSOR ); + SetCurrentCursorFromDatabase( EXTERN_CURSOR ); + + if ( fShowInventoryFlag && bSelectedInfoChar >= 0 ) + { + ReevaluateItemHatches( MercPtrs[ gCharactersList[ bSelectedInfoChar ].usSolID ], FALSE ); + fTeamPanelDirty = TRUE; + } + } } - else { - ScreenMsg( FONT_MCOLOR_LTRED, MSG_INTERFACE, New113Message[MSG113_DELETED] ); + else + { + gpItemPointer = NULL; + fMapInventoryItem = FALSE; + + if ( _KeyDown ( 89 )) //Lalien: delete all items of this type on Ctrl+Y + { + DeleteItemsOfType( gItemPointer.usItem ); + ScreenMsg( FONT_MCOLOR_LTRED, MSG_INTERFACE, New113Message[MSG113_DELETE_ALL] ); + } + else { + ScreenMsg( FONT_MCOLOR_LTRED, MSG_INTERFACE, New113Message[MSG113_DELETED] ); + } } if ( fShowMapInventoryPool ) HandleButtonStatesWhileMapInventoryActive(); diff --git a/Tactical/Faces.cpp b/Tactical/Faces.cpp index 5cc14c650..77e298035 100644 --- a/Tactical/Faces.cpp +++ b/Tactical/Faces.cpp @@ -1835,64 +1835,35 @@ void HandleRenderFaceAdjustments( FACETYPE *pFace, BOOLEAN fDisplayBuffer, BOOLE uiFaceItemOne=MercPtrs[ pFace->ubSoldierID ]->inv[HEAD1POS].usItem; uiFaceItemTwo=MercPtrs[ pFace->ubSoldierID ]->inv[HEAD2POS].usItem; + //MM: fixing the hardcoded craziness here... // check first face slot if ( uiFaceItemOne != NONE ) { - switch( uiFaceItemOne ) - { - // gas mask - case GASMASK: - uiFaceItemOne = 1; - break; - // NV goggles - case 211: - case 246: - case 1024: - case 1025: - uiFaceItemOne = 2; - break; - // sun goggles - case 212: - uiFaceItemOne = 3; - break; - // extended ear - case 210: - uiFaceItemOne = 4; - break; - default: - uiFaceItemOne = 0; - break; - } + if ( Item[uiFaceItemOne].gasmask ) + uiFaceItemOne = 1; + else if ( Item[uiFaceItemOne].nightvisionrangebonus > 0 ) + uiFaceItemOne = 2; + else if ( Item[uiFaceItemOne].dayvisionrangebonus > 0 || Item[uiFaceItemOne].brightlightvisionrangebonus > 0 ) + uiFaceItemOne = 3; + else if ( Item[uiFaceItemOne].hearingrangebonus > 0 ) + uiFaceItemOne = 4; + else + uiFaceItemOne = 0; } // check second face slot if ( uiFaceItemTwo != NONE ) { - switch( uiFaceItemTwo ) - { - // gas mask - case GASMASK: - uiFaceItemTwo = 21; - break; - // NV goggles - case 211: - case 246: - case 1024: - case 1025: - uiFaceItemTwo = 42; - break; - // sun goggles - case 212: - uiFaceItemTwo = 63; - break; - // extended ear - case 210: - uiFaceItemTwo = 84; - break; - default: - uiFaceItemTwo = 0; - break; - } + if ( Item[uiFaceItemTwo].gasmask ) + uiFaceItemTwo = 21; + else if ( Item[uiFaceItemTwo].nightvisionrangebonus > 0 ) + uiFaceItemTwo = 42; + else if ( Item[uiFaceItemTwo].dayvisionrangebonus > 0 || Item[uiFaceItemTwo].brightlightvisionrangebonus > 0 ) + uiFaceItemTwo = 63; + else if ( Item[uiFaceItemTwo].hearingrangebonus > 0 ) + uiFaceItemTwo = 84; + else + uiFaceItemTwo = 0; } // Now select the correct icon. This uses a matrix from uiFaceOneItem and uiFaceTwoItem (simple addition) diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index e9c35d954..ee43e70b3 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -2589,6 +2589,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) INT32 worldItem; UINT8 magType; bool mergeSuccessful, ammoPresent; + int loopCount = 0; OBJECTTYPE newCrate; ammoPresent = true; @@ -2597,7 +2598,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) else magType = AMMO_BOX; - while (ammoPresent) + while (ammoPresent && loopCount <= 10) { //look through all sector items for ammo. for(unsigned int wItem = 0; wItem < guiNumWorldItems; wItem++) @@ -2685,11 +2686,13 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) } } } - else // MM: no crate item, so we must be missing a crate item from the xmls. Set ammoPresent to false to avoid infinitely looping. - ammoPresent = false; } } + // if we added to / created a box/crate, then we're fine to reset this + if ( mergeSuccessful ) + loopCount = 0; + //MM: loop through ammo multiple times, as boxes and crates may take a few passes to fill ammoPresent = false; for(unsigned int wItem = 0; wItem < guiNumWorldItems; wItem++) @@ -2700,6 +2703,7 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) if(Magazine[Item[worldItem].ubClassIndex].ubMagType == magType) continue; + loopCount++; ammoPresent = true; break; } diff --git a/TacticalAI/AIMain.cpp b/TacticalAI/AIMain.cpp index 64ec12dd8..f93c28b6b 100644 --- a/TacticalAI/AIMain.cpp +++ b/TacticalAI/AIMain.cpp @@ -2084,6 +2084,7 @@ INT8 ExecuteAction(SOLDIERTYPE *pSoldier) INT32 iRetCode; //NumMessage("ExecuteAction - Guy#",pSoldier->ubID); + // in most cases, merc will change location, or may cause damage to opponents, // so a new cover check will be necessary. Exceptions handled individually. SkipCoverCheck = FALSE; diff --git a/TileEngine/worlddef.h b/TileEngine/worlddef.h index 444b68b97..3c89c57c5 100644 --- a/TileEngine/worlddef.h +++ b/TileEngine/worlddef.h @@ -279,10 +279,10 @@ extern MAP_ELEMENT *gpWorldLevelData; // World Movement Costs //UINT8 gubWorldMovementCosts[ WORLD_MAX ][MAXDIR][2]; -//ddd для убыстрения поиска освещенных участков в патхаи. +//ddd Tables to track tactical value of grid tiles extern BOOLEAN gubWorldTileInLight[ MAX_ALLOWED_WORLD_MAX ]; -extern BOOLEAN gubIsCorpseThere[ MAX_ALLOWED_WORLD_MAX ]; //надо бы учитывать крыша\земля ;) -extern INT32 gubMerkCanSeeThisTile[ MAX_ALLOWED_WORLD_MAX ]; //положение драника не учитываем, крыша\земля тож? +extern BOOLEAN gubIsCorpseThere[ MAX_ALLOWED_WORLD_MAX ]; //Tracks position of corpses for AI avoidance +extern INT32 gubMerkCanSeeThisTile[ MAX_ALLOWED_WORLD_MAX ]; //Tracks visibility my mercs //ddd extern UINT8 (*gubWorldMovementCosts)[MAXDIR][2];//dnl ch43 260909