1. Removed hardcoding of face items in the code for the face icons / graphics

2. Fixed potential infinite loop bug if no ammo crate or box is present and (ctrl+)shift+a is pressed.
3. Changed Ctrl click on mapscreen from Delete to auto-place item in selected merc or vehicle inventory.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5179 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
MaddMugsy
2012-04-10 20:41:04 +00:00
parent 74c6e3c56c
commit ab3412e5ed
5 changed files with 105 additions and 64 deletions
@@ -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; x<NUM_INV_SLOTS-1; x++)
{
if(vehicleInv[x] == FALSE)
continue;
if(pSoldier->inv[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();
+21 -50
View File
@@ -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)
+7 -3
View File
@@ -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;
}
+1
View File
@@ -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;
+3 -3
View File
@@ -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