Added Common Attachment Framework

-- Known issue -- the BR gun tooltips will double up if an item is using both the old attachment method and the new CAF

& Working files

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5234 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
MaddMugsy
2012-04-28 10:17:59 +00:00
parent 11cc056601
commit dafc7d8bec
10 changed files with 258 additions and 47 deletions
+35 -6
View File
@@ -2521,16 +2521,19 @@ void CreateMouseRegionForBigImage( UINT16 usPosY, UINT8 ubCount, INT16 *pItemNum
// HEADROCK HAM 3: Generate list of possible attachments to a gun (Guns only!) // HEADROCK HAM 3: Generate list of possible attachments to a gun (Guns only!)
if (gGameExternalOptions.fBobbyRayTooltipsShowAttachments) if (gGameExternalOptions.fBobbyRayTooltipsShowAttachments)
{ {
// Check entire attachment list
UINT16 iLoop = 0; UINT16 iLoop = 0;
// Check entire attachment list
while( 1 ) while( 1 )
{ {
// Is the weapon we're checking the same as the one we're tooltipping? //Madd: Common Attachment Framework
if (Attachment[iLoop][1] == Item[pItemNumbers[ i ]].uiIndex) //TODO: Note that the items in this list will be duplicated if they are present in both the CAF and the old attachment method
//need to refactor this to work more like the NAS attachment slots method
usAttachment = 0;
if ( IsAttachmentPointAvailable(Item[pItemNumbers[ i ]].uiIndex, iLoop) )
{ {
usAttachment = Attachment[iLoop][0]; usAttachment = iLoop;
// If the attachment is not hidden // If the attachment is not hidden
if (!Item[ usAttachment ].hiddenaddon && !Item[ usAttachment ].hiddenattachment) if (usAttachment > 0 && !Item[ usAttachment ].hiddenaddon && !Item[ usAttachment ].hiddenattachment)
{ {
if (wcslen( attachStr3 ) + wcslen(Item[usAttachment].szItemName) > 3800) if (wcslen( attachStr3 ) + wcslen(Item[usAttachment].szItemName) > 3800)
{ {
@@ -2546,8 +2549,34 @@ void CreateMouseRegionForBigImage( UINT16 usPosY, UINT8 ubCount, INT16 *pItemNum
} }
} }
} }
// Is the weapon we're checking the same as the one we're tooltipping?
usAttachment = 0;
if (Attachment[iLoop][1] == Item[pItemNumbers[ i ]].uiIndex)
{
usAttachment = Attachment[iLoop][0];
}
// If the attachment is not hidden
if (usAttachment > 0 && !Item[ usAttachment ].hiddenaddon && !Item[ usAttachment ].hiddenattachment)
{
if (wcslen( attachStr3 ) + wcslen(Item[usAttachment].szItemName) > 3800)
{
// End list early to avoid stack overflow
wcscat( attachStr3, L"\n..." );
break;
}
else
{// Add the attachment's name to the list.
fAttachmentsFound = TRUE;
swprintf( attachStr2, L"\n%s", Item[ usAttachment ].szItemName );
wcscat( attachStr3, attachStr2);
}
}
iLoop++; iLoop++;
if (Attachment[iLoop][0] == 0) if (Attachment[iLoop][0] == 0 && Item[iLoop].usItemClass == 0)
{ {
// Reached end of list // Reached end of list
break; break;
+1 -1
View File
@@ -36,7 +36,7 @@ typedef unsigned int UINT32;
typedef signed __int64 INT64; // WANNE - BMP: Used for Big Maps typedef signed __int64 INT64; // WANNE - BMP: Used for Big Maps
typedef signed int INT32; typedef signed int INT32;
typedef unsigned __int64 UINT64; typedef unsigned __int64 UINT64;
typedef unsigned long long UINT128; //typedef unsigned long long UINT128; //Madd: Doing away with this redundant type
#else #else
typedef unsigned int UINT32; typedef unsigned int UINT32;
typedef int INT32; typedef int INT32;
+1 -1
View File
@@ -287,7 +287,7 @@ void HandleEndTurnDrugAdjustments( SOLDIERTYPE *pSoldier )
// The drug rate is 0 now too // The drug rate is 0 now too
pSoldier->drugs.bDrugEffectRate[ cnt ] = 0; pSoldier->drugs.bDrugEffectRate[ cnt ] = 0;
// morla downer only if side effect exists and this effect is allowed for a drug // morale downer only if side effect exists and this effect is allowed for a drug
if ( Drug[cnt].ubDrugSideEffect > 0 && Drug[cnt].ubMoralBacklash > 0 ) if ( Drug[cnt].ubDrugSideEffect > 0 && Drug[cnt].ubMoralBacklash > 0 )
{ {
// Once for each 'level' of crash.... // Once for each 'level' of crash....
+37 -1
View File
@@ -5147,6 +5147,7 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
UINT16 usAttachment; UINT16 usAttachment;
std::vector<UINT16> attachList, parseList; std::vector<UINT16> attachList, parseList;
std::vector<UINT16> usAttachmentSlotIndexVector = GetItemSlots(pObject); std::vector<UINT16> usAttachmentSlotIndexVector = GetItemSlots(pObject);
UINT64 point = GetAvailableAttachmentPoint(pObject, 0); //Madd: Common Attachment Framework
//start by deleting the currently defined regions if they exist //start by deleting the currently defined regions if they exist
//BOB : also, clean up the popup boxes (in case they're still around) //BOB : also, clean up the popup boxes (in case they're still around)
@@ -5209,6 +5210,28 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
//Print all attachments that fit on this item. //Print all attachments that fit on this item.
for(UINT16 usLoop = 0; usLoop < MAXATTACHMENTS; usLoop++) for(UINT16 usLoop = 0; usLoop < MAXATTACHMENTS; usLoop++)
{ //We no longer find valid attachments from AttachmentSlots.xml so we need to work a bit harder to get our list { //We no longer find valid attachments from AttachmentSlots.xml so we need to work a bit harder to get our list
usAttachment = 0;
//Madd: Common Attachment Framework
if (Item[usLoop].nasAttachmentClass & AttachmentSlots[usLoopSlotID].nasAttachmentClass && IsAttachmentPointAvailable(point, usLoop, TRUE))
{
usAttachment = usLoop;
if( !Item[usAttachment].hiddenaddon && !Item[usAttachment].hiddenattachment && ItemIsLegal(usAttachment))
{
bool exists = false;
for (UINT32 i = 0; i < attachList.size(); i++)
{
if ( attachList[i] == usAttachment )
{
exists = true;
break;
}
}
if (!exists)
attachList.push_back(usAttachment);
}
}
usAttachment = 0; usAttachment = 0;
if(Attachment[usLoop][1] == pObject->usItem && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Attachment[usLoop][0]].nasAttachmentClass) if(Attachment[usLoop][1] == pObject->usItem && AttachmentSlots[usLoopSlotID].nasAttachmentClass & Item[Attachment[usLoop][0]].nasAttachmentClass)
{ //search primary item attachments.xml { //search primary item attachments.xml
@@ -5232,12 +5255,25 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex)
} }
} }
} }
if(Attachment[usLoop][0] == 0 && Launchable[usLoop][0] == 0) if(Attachment[usLoop][0] == 0 && Launchable[usLoop][0] == 0 && Item[usLoop].usItemClass == 0)
break; break;
if( usAttachment > 0 && !Item[usAttachment].hiddenaddon && !Item[usAttachment].hiddenattachment && ItemIsLegal(usAttachment)) if( usAttachment > 0 && !Item[usAttachment].hiddenaddon && !Item[usAttachment].hiddenattachment && ItemIsLegal(usAttachment))
{
bool exists = false;
for (UINT32 i = 0; i < attachList.size(); i++)
{
if ( attachList[i] == usAttachment )
{
exists = true;
break;
}
}
if (!exists)
attachList.push_back(usAttachment); attachList.push_back(usAttachment);
} }
}
if(attachList.size()>0){ if(attachList.size()>0){
parseList = attachList; parseList = attachList;
+8 -4
View File
@@ -767,8 +767,12 @@ extern OBJECTTYPE gTempObject;
typedef struct typedef struct
{ {
UINT32 usItemClass; UINT32 usItemClass;
UINT32 nasAttachmentClass; //CHRISL: Identify the class of attachment UINT64 nasAttachmentClass; //CHRISL: Identify the class of attachment
UINT32 nasLayoutClass; UINT64 nasLayoutClass;
//Madd: Common Attachment Framework: attach items based on matching connection points rather than using the old long attachmentinfo method
UINT64 ulAvailableAttachmentPoint;
UINT64 ulAttachmentPoint;
UINT8 ubAttachToPointAPCost; // cost to attach to any matching point
UINT16 ubClassIndex; UINT16 ubClassIndex;
UINT8 ubCursor; UINT8 ubCursor;
INT8 bSoundType; INT8 bSoundType;
@@ -1469,8 +1473,8 @@ typedef struct
{ {
UINT16 uiSlotIndex; UINT16 uiSlotIndex;
CHAR16 szSlotName[200]; CHAR16 szSlotName[200];
UINT32 nasAttachmentClass; UINT64 nasAttachmentClass;
UINT128 nasLayoutClass; UINT64 nasLayoutClass;
UINT16 usDescPanelPosX; UINT16 usDescPanelPosX;
UINT16 usDescPanelPosY; UINT16 usDescPanelPosY;
BOOLEAN fMultiShot; BOOLEAN fMultiShot;
+97 -16
View File
@@ -2086,6 +2086,13 @@ BOOLEAN ValidAttachment( UINT16 usAttachment, UINT16 usItem, UINT8 * pubAPCost )
*pubAPCost = (UINT8)APBPConstants[AP_RELOAD_GUN]; //default value *pubAPCost = (UINT8)APBPConstants[AP_RELOAD_GUN]; //default value
} }
//Madd: Common Attachment Framework
if ( IsAttachmentPointAvailable(usItem, usAttachment))
{
if (pubAPCost)
*pubAPCost = Item[usAttachment].ubAttachToPointAPCost;
return TRUE;
}
// look for the section of the array pertaining to this attachment... // look for the section of the array pertaining to this attachment...
while( 1 ) while( 1 )
{ {
@@ -2142,6 +2149,12 @@ BOOLEAN ValidAttachment( UINT16 usAttachment, OBJECTTYPE * pObj, UINT8 * pubAPCo
if(usAttachmentSlotIndexVector.empty()) if(usAttachmentSlotIndexVector.empty())
return FALSE; return FALSE;
//Madd: Common Attachment Framework
foundValidAttachment = IsAttachmentPointAvailable(pObj, subObject, usAttachment);
if (foundValidAttachment && pubAPCost )
*pubAPCost = Item[usAttachment].ubAttachToPointAPCost;
else
{
//Check if the attachment is valid with the main item //Check if the attachment is valid with the main item
foundValidAttachment = (ValidAttachment(usAttachment, pObj->usItem, pubAPCost) || ValidLaunchable(usAttachment, pObj->usItem)); foundValidAttachment = (ValidAttachment(usAttachment, pObj->usItem, pubAPCost) || ValidLaunchable(usAttachment, pObj->usItem));
@@ -2151,7 +2164,7 @@ BOOLEAN ValidAttachment( UINT16 usAttachment, OBJECTTYPE * pObj, UINT8 * pubAPCo
if(iter->exists()) if(iter->exists())
foundValidAttachment = (ValidAttachment(usAttachment, iter->usItem, pubAPCost) || ValidLaunchable(usAttachment, iter->usItem)); foundValidAttachment = (ValidAttachment(usAttachment, iter->usItem, pubAPCost) || ValidLaunchable(usAttachment, iter->usItem));
} }
}
return ( foundValidAttachment ); return ( foundValidAttachment );
} }
else else
@@ -2571,6 +2584,10 @@ BOOLEAN TwoHandedItem( UINT16 usItem )
BOOLEAN ValidLaunchable( UINT16 usLaunchable, UINT16 usItem ) BOOLEAN ValidLaunchable( UINT16 usLaunchable, UINT16 usItem )
{ {
INT32 iLoop = 0; INT32 iLoop = 0;
//Madd: Common Attachment Framework
if ( IsAttachmentPointAvailable(usItem, usLaunchable) )
return TRUE;
//DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("ValidLaunchable: launchable=%d, item=%d",usLaunchable,usItem)); //DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("ValidLaunchable: launchable=%d, item=%d",usLaunchable,usItem));
// look for the section of the array pertaining to this launchable item... // look for the section of the array pertaining to this launchable item...
while( 1 ) while( 1 )
@@ -2611,7 +2628,8 @@ BOOLEAN ValidItemLaunchable( OBJECTTYPE * pObj, UINT16 usAttachment )
if (pObj->exists() == false) { if (pObj->exists() == false) {
return FALSE; return FALSE;
} }
if ( !ValidLaunchable( usAttachment, pObj->usItem ) ) //Madd: Common Attachment Framework
if ( !ValidLaunchable( usAttachment, pObj->usItem ) && !IsAttachmentPointAvailable(pObj, 0, usAttachment) )
{ {
return( FALSE ); return( FALSE );
} }
@@ -4993,33 +5011,51 @@ BOOLEAN OBJECTTYPE::AttachObjectNAS( SOLDIERTYPE * pSoldier, OBJECTTYPE * pAttac
} }
if ( pSoldier != NULL ) if ( pSoldier != NULL )
ApplyEquipmentBonuses(pSoldier); ApplyEquipmentBonuses(pSoldier);
return( TRUE ); return( TRUE );
} }
return( FALSE ); return( FALSE );
} }
//CHRISL: Use this function to sort through Attachments.xml and Launchables.xml //CHRISL: Use this function to sort through Attachments.xml and Launchables.xml
UINT32 SetAttachmentSlotsFlag(OBJECTTYPE* pObj){ UINT64 SetAttachmentSlotsFlag(OBJECTTYPE* pObj){
UINT32 uiSlotFlag = 0; UINT64 uiSlotFlag = 0;
UINT32 uiLoop = 0; UINT32 uiLoop = 0;
UINT32 fItem; UINT32 fItem;
if(pObj->exists()==false) if(pObj->exists()==false)
return 0; return 0;
//Madd: Common Attachment Framework
UINT64 point = GetAvailableAttachmentPoint(pObj, 0);
while(1) while(1)
{ {
fItem = 0; fItem = 0;
if (Attachment[uiLoop][1] == pObj->usItem){ //Madd: Common Attachment Framework
fItem = Attachment[uiLoop][0]; if (IsAttachmentPointAvailable(point, uiLoop, TRUE))
} {
if (Launchable[uiLoop][1] == pObj->usItem ){ fItem = uiLoop;
fItem = Launchable[uiLoop][0]; if(fItem && ItemIsLegal(fItem, TRUE)) // We've found a valid attachment. Set the nasAttachmentSlots flag appropriately
}
if(fItem && ItemIsLegal(fItem, TRUE)){ // We've found a valid attachment. Set the nasAttachmentSlots flag appropriately
uiSlotFlag |= Item[fItem].nasAttachmentClass; uiSlotFlag |= Item[fItem].nasAttachmentClass;
} }
if (Attachment[uiLoop][1] == pObj->usItem){
fItem = Attachment[uiLoop][0];
if(fItem && ItemIsLegal(fItem, TRUE))
uiSlotFlag |= Item[fItem].nasAttachmentClass;
}
if (Launchable[uiLoop][1] == pObj->usItem ){
fItem = Launchable[uiLoop][0];
if(fItem && ItemIsLegal(fItem, TRUE))
uiSlotFlag |= Item[fItem].nasAttachmentClass;
}
uiLoop++; uiLoop++;
if (Attachment[uiLoop][0] == 0 && Launchable[uiLoop][0] == 0){ if (Attachment[uiLoop][0] == 0 && Launchable[uiLoop][0] == 0 && Item[uiLoop].usItemClass == 0 ){
// No more attachments to search // No more attachments to search
break; break;
} }
@@ -5035,8 +5071,8 @@ std::vector<UINT16> GetItemSlots(OBJECTTYPE* pObj, UINT8 subObject, BOOLEAN fAtt
std::vector<UINT16> tempSlots; std::vector<UINT16> tempSlots;
UINT8 numSlots = 0; UINT8 numSlots = 0;
UINT16 magSize = 0; UINT16 magSize = 0;
UINT32 fItemSlots = 0; UINT64 fItemSlots = 0; //MM: Bumped the NAS UINT32s to UINT64s
UINT128 fItemLayout = 0; UINT64 fItemLayout = 0;
if(UsingNewAttachmentSystem()==false || !pObj->exists()) if(UsingNewAttachmentSystem()==false || !pObj->exists())
return tempItemSlots; return tempItemSlots;
@@ -5050,8 +5086,8 @@ std::vector<UINT16> GetItemSlots(OBJECTTYPE* pObj, UINT8 subObject, BOOLEAN fAtt
//Next, let's figure out which slots the item gives us access to //Next, let's figure out which slots the item gives us access to
if(fItemSlots){ //We don't need to do anything if the item gets no slots if(fItemSlots){ //We don't need to do anything if the item gets no slots
for(UINT8 sClass = 0; sClass < 32; sClass++){ //go through each attachment class and find the slots the item should have for(UINT8 sClass = 0; sClass < 64; sClass++){ //go through each attachment class and find the slots the item should have
UINT32 uiClass = (UINT32)pow((double)2, (int)sClass); UINT64 uiClass = (UINT64)pow((double)2, (int)sClass);
UINT32 slotSize = tempItemSlots.size(); UINT32 slotSize = tempItemSlots.size();
if(fItemSlots & uiClass){ //don't bother with this slot if it's not a valid class if(fItemSlots & uiClass){ //don't bother with this slot if it's not a valid class
for(UINT32 sCount = 1; sCount < MAXITEMS+1; sCount++){ for(UINT32 sCount = 1; sCount < MAXITEMS+1; sCount++){
@@ -13459,3 +13495,48 @@ BOOLEAN OBJECTTYPE::TransformObject( SOLDIERTYPE * pSoldier, UINT8 ubStatusIndex
// Signal a successful transformation. // Signal a successful transformation.
return TRUE; return TRUE;
} }
//Madd: Common Attachment Framework - check if a given point is acceptable
bool IsAttachmentPointAvailable( OBJECTTYPE * pObject, UINT8 subObject, UINT32 attachmentID )
{
if (Item[pObject->usItem].ulAvailableAttachmentPoint > 0 && (Item[attachmentID].attachment || Item[attachmentID].usItemClass & IC_GRENADE || Item[attachmentID].usItemClass & IC_BOMB)&& Item[attachmentID].ulAttachmentPoint & GetAvailableAttachmentPoint(pObject, subObject))
return true;
else
return false;
}
//Madd: Common Attachment Framework - if we already know the point
bool IsAttachmentPointAvailable( UINT64 point, UINT32 attachmentID, BOOLEAN onlyCheckAttachments )
{
if (point > 0 && (!onlyCheckAttachments || (Item[attachmentID].attachment || Item[attachmentID].usItemClass & IC_GRENADE || Item[attachmentID].usItemClass & IC_BOMB)) && Item[attachmentID].ulAttachmentPoint & point)
return true;
else
return false;
}
//Madd: Common Attachment Framework, doesn't look at attachments
bool IsAttachmentPointAvailable( UINT32 itemID, UINT32 attachmentID )
{
if (Item[itemID].ulAvailableAttachmentPoint > 0 && (Item[attachmentID].attachment || Item[attachmentID].usItemClass & IC_GRENADE || Item[attachmentID].usItemClass & IC_BOMB) && Item[attachmentID].ulAttachmentPoint & Item[itemID].ulAvailableAttachmentPoint)
return true;
else
return false;
}
//Madd: Common Attachment Framework, get point value from object + attachments
UINT64 GetAvailableAttachmentPoint (OBJECTTYPE * pObject, UINT8 subObject)
{
UINT64 point = 0;
if (pObject)
{
point = Item[pObject->usItem].ulAvailableAttachmentPoint;
for (attachmentList::iterator iter = (*pObject)[subObject]->attachments.begin(); iter != (*pObject)[subObject]->attachments.end(); ++iter)
{
if(iter->exists() && Item[iter->usItem].ulAvailableAttachmentPoint > 0 )
point |= Item[iter->usItem].ulAvailableAttachmentPoint;
}
}
return point;
}
+6
View File
@@ -452,6 +452,12 @@ void GetScopeLists( OBJECTTYPE * pObj, std::map<INT8, OBJECTTYPE*>& arScopeMap
BOOLEAN IsAttachmentClass( UINT16 usItem, UINT32 aFlag ); BOOLEAN IsAttachmentClass( UINT16 usItem, UINT32 aFlag );
BOOLEAN HasAttachmentOfClass( OBJECTTYPE * pObj, UINT32 aFlag ); BOOLEAN HasAttachmentOfClass( OBJECTTYPE * pObj, UINT32 aFlag );
//Madd: Common Attachment Framework
bool IsAttachmentPointAvailable( OBJECTTYPE * pObject, UINT8 subObject, UINT32 attachmentID );
bool IsAttachmentPointAvailable( UINT32 itemID, UINT32 attachmentID );
bool IsAttachmentPointAvailable( UINT64 point, UINT32 attachmentID, BOOLEAN onlyCheckAttachments );
UINT64 GetAvailableAttachmentPoint ( OBJECTTYPE * pObject, UINT8 subObject );
#endif #endif
+2 -2
View File
@@ -122,12 +122,12 @@ attachmentslotEndElementHandle(void *userData, const XML_Char *name)
else if(strcmp(name, "nasAttachmentClass") == 0) else if(strcmp(name, "nasAttachmentClass") == 0)
{ {
pData->curElement = ELEMENT; pData->curElement = ELEMENT;
pData->curAttachmentSlot.nasAttachmentClass = (UINT32) atol(pData->szCharData); pData->curAttachmentSlot.nasAttachmentClass = (UINT64) atof(pData->szCharData);
} }
else if(strcmp(name, "nasLayoutClass") == 0) else if(strcmp(name, "nasLayoutClass") == 0)
{ {
pData->curElement = ELEMENT; pData->curElement = ELEMENT;
pData->curAttachmentSlot.nasLayoutClass = (UINT128) atol(pData->szCharData); pData->curAttachmentSlot.nasLayoutClass = (UINT64) atof(pData->szCharData);
} }
else if(strcmp(name, "usDescPanelPosX") == 0) else if(strcmp(name, "usDescPanelPosX") == 0)
{ {
+37
View File
@@ -1903,7 +1903,25 @@ void CalculateLaunchItemBasicParams( SOLDIERTYPE *pSoldier, OBJECTTYPE *pItem, I
// Are we armed, and are we throwing a LAUNCHABLE? // Are we armed, and are we throwing a LAUNCHABLE?
//MM: Again, this only works if the launchers are all the same
//usLauncher = GetLauncherFromLaunchable( pItem->usItem );
//MM: Replacement:
OBJECTTYPE *pObj = NULL;
usLauncher = 0;
pObj = pSoldier->GetUsedWeapon( &pSoldier->inv[pSoldier->ubAttackingHand] );
if ( pObj != NULL )
{
if (Item[pObj->usItem].usItemClass == IC_LAUNCHER)
usLauncher = pObj->usItem;
else if (Item[pObj->usItem].usItemClass == IC_GUN)
{
usLauncher = GetAttachedGrenadeLauncher(pObj);
}
}
if ( usLauncher == 0) // fail back to the original
usLauncher = GetLauncherFromLaunchable( pItem->usItem ); usLauncher = GetLauncherFromLaunchable( pItem->usItem );
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("physics.cpp line 1741")); DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("physics.cpp line 1741"));
if ( fArmed && ( Item[usLauncher].mortar || Item[pItem->usItem].mortar ) ) if ( fArmed && ( Item[usLauncher].mortar || Item[pItem->usItem].mortar ) )
{ {
@@ -2304,7 +2322,26 @@ void CalculateLaunchItemParamsForThrow( SOLDIERTYPE *pSoldier, INT32 sGridNo, UI
sStartZ = GET_SOLDIER_THROW_HEIGHT( pSoldier->pathing.bLevel ); sStartZ = GET_SOLDIER_THROW_HEIGHT( pSoldier->pathing.bLevel );
//MM: Again, this only works if the launchers are all the same
//usLauncher = GetLauncherFromLaunchable( pItem->usItem );
//MM: Replacement:
OBJECTTYPE *pObj = NULL;
usLauncher = 0;
pObj = pSoldier->GetUsedWeapon( &pSoldier->inv[pSoldier->ubAttackingHand] );
if ( pObj != NULL )
{
if (Item[pObj->usItem].usItemClass == IC_LAUNCHER)
usLauncher = pObj->usItem;
else if (Item[pObj->usItem].usItemClass == IC_GUN)
{
usLauncher = GetAttachedGrenadeLauncher(pObj);
}
}
if ( usLauncher == 0) // fail back to the original
usLauncher = GetLauncherFromLaunchable( pItem->usItem ); usLauncher = GetLauncherFromLaunchable( pItem->usItem );
DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("physics.cpp line 2103")); DebugMsg(TOPIC_JA2,DBG_LEVEL_3,String("physics.cpp line 2103"));
if ( fArmed && Item[usLauncher].mortar ) if ( fArmed && Item[usLauncher].mortar )
+20 -2
View File
@@ -124,6 +124,9 @@ itemStartElementHandle(void *userData, const XML_Char *name, const XML_Char **at
strcmp(name, "usItemClass") == 0 || strcmp(name, "usItemClass") == 0 ||
strcmp(name, "nasAttachmentClass") == 0 || strcmp(name, "nasAttachmentClass") == 0 ||
strcmp(name, "nasLayoutClass") == 0 || strcmp(name, "nasLayoutClass") == 0 ||
strcmp(name, "AvailableAttachmentPoint") == 0 ||
strcmp(name, "AttachmentPoint") == 0 ||
strcmp(name, "AttachToPointAPCost") == 0 ||
strcmp(name, "ubClassIndex") == 0 || strcmp(name, "ubClassIndex") == 0 ||
strcmp(name, "ubCursor") == 0 || strcmp(name, "ubCursor") == 0 ||
strcmp(name, "bSoundType") == 0 || strcmp(name, "bSoundType") == 0 ||
@@ -528,12 +531,27 @@ itemEndElementHandle(void *userData, const XML_Char *name)
else if(strcmp(name, "nasAttachmentClass") == 0) else if(strcmp(name, "nasAttachmentClass") == 0)
{ {
pData->curElement = ELEMENT; pData->curElement = ELEMENT;
pData->curItem.nasAttachmentClass = (UINT32) atol(pData->szCharData); pData->curItem.nasAttachmentClass = (UINT64) atof(pData->szCharData);
} }
else if(strcmp(name, "nasLayoutClass") == 0) else if(strcmp(name, "nasLayoutClass") == 0)
{ {
pData->curElement = ELEMENT; pData->curElement = ELEMENT;
pData->curItem.nasLayoutClass = (UINT32) atol(pData->szCharData); pData->curItem.nasLayoutClass = (UINT64) atof(pData->szCharData);
}
else if(strcmp(name, "AvailableAttachmentPoint") == 0)
{
pData->curElement = ELEMENT;
pData->curItem.ulAvailableAttachmentPoint = (UINT64) atof(pData->szCharData);
}
else if(strcmp(name, "AttachmentPoint") == 0)
{
pData->curElement = ELEMENT;
pData->curItem.ulAttachmentPoint = (UINT64) atof(pData->szCharData);
}
else if(strcmp(name, "AttachToPointAPCost") == 0)
{
pData->curElement = ELEMENT;
pData->curItem.ubAttachToPointAPCost = (UINT8) atol(pData->szCharData);
} }
else if(strcmp(name, "ubClassIndex") == 0) else if(strcmp(name, "ubClassIndex") == 0)
{ {