diff --git a/GameVersion.cpp b/GameVersion.cpp index 0f064d5b4..a2abb30cc 100644 --- a/GameVersion.cpp +++ b/GameVersion.cpp @@ -15,9 +15,9 @@ #ifdef JA2EDITOR #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8399 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Unfinished Business - Map Editor v1.13.8400 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8399 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Map Editor v1.13.8400 (Development Build)" }; #endif // ------------------------------ @@ -27,11 +27,11 @@ //DEBUG BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8399 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: Unfinished Business - v1.13.8400 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8399 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: JA2 Demo - v1.13.8400 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8399 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Debug: v1.13.8400 (Development Build)" }; #endif #elif defined CRIPPLED_VERSION @@ -46,16 +46,16 @@ //RELEASE BUILD VERSION #ifdef JA2UB - CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8399 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release Unfinished Business - v1.13.8400 (Development Build)" }; #elif defined (JA113DEMO) - CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8399 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release JA2 Demo - v1.13.8400 (Development Build)" }; #else - CHAR16 zVersionLabel[256] = { L"Release v1.13.8399 (Development Build)" }; + CHAR16 zVersionLabel[256] = { L"Release v1.13.8400 (Development Build)" }; #endif #endif -CHAR8 czVersionNumber[16] = { "Build 17.04.12" }; //YY.MM.DD +CHAR8 czVersionNumber[16] = { "Build 17.04.14" }; //YY.MM.DD CHAR16 zTrackingNumber[16] = { L"Z" }; // SAVE_GAME_VERSION is defined in header, change it there diff --git a/Strategic/Assignments.cpp b/Strategic/Assignments.cpp index 4288c16de..2dbf365ac 100644 --- a/Strategic/Assignments.cpp +++ b/Strategic/Assignments.cpp @@ -17178,12 +17178,12 @@ void ReEvaluateEveryonesNothingToDo() case MOVE_EQUIPMENT: { // which sector do we want to move stuff to? - INT16 targetX = SECTORX( pSoldier->usItemMoveSectorID ); - INT16 targetY = SECTORY( pSoldier->usItemMoveSectorID ); + INT16 targetX = SECTORX( pSoldier->usItemMoveSectorID )-1; + INT16 targetY = SECTORY( pSoldier->usItemMoveSectorID )-1; if (numberOfMovableItemsCache[targetX][targetY] == INT_MAX) { - numberOfMovableItemsCache[targetX][targetY] = GetNumberOfMovableItems(targetX, targetY, 0); + numberOfMovableItemsCache[targetX][targetY] = GetNumberOfMovableItems(targetX+1, targetY+1, 0); } fNothingToDo = (numberOfMovableItemsCache[targetX][targetY] == 0); diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index d26f0e389..dc748d4e5 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -599,6 +599,25 @@ INT16 getStatusOfLeastDamagedItemInStack( OBJECTTYPE * stack ); // BOB : globals for telling attachment popups _where_ should the attachment go UINT8 gubPopupStatusIndex; UINT32 guiPopupItemPos; + +// BOB : common class for attachment popup callbacks. +class PopupAttachmentInfo { +public: + INT16 usAttachment; // attachment being attached + + OBJECTTYPE * pObj; // object it is being attached to + UINT8 subObject; // in case we're in an object stack + INT16 slotCount; // the attachment slot that's being attached to + + POPUP_OPTION * o; // option that's doing the attaching + POPUP * p; // the popup that's tied to the attachment slot + + PopupAttachmentInfo() {}; + PopupAttachmentInfo(INT16 usAttachment, OBJECTTYPE * pObj, UINT8 subObject, INT16 slotCount, POPUP_OPTION * o, POPUP * p) : + usAttachment(usAttachment), pObj(pObj), subObject(subObject), slotCount(slotCount), o(o), p(p) {} +}; +std::vector gPopupAttachmentInfos; + void popupCallbackItem(INT16 itemId){ OBJECTTYPE* bestStack; @@ -677,20 +696,20 @@ void popupCallbackItem(INT16 itemId){ } } -bool popupCallbackItemInSector(INT16 usAttachment, OBJECTTYPE * pObj, POPUP_OPTION * o){ +bool popupCallbackItemInSector(PopupAttachmentInfo * pai) { for (UINT16 i = 0; i < pInventoryPoolList.size(); i++) { - if (pInventoryPoolList[i].object.usItem == usAttachment) { - if (ValidItemAttachmentSlot(pObj, usAttachment, true, false, 0, -1, true, NULL, GetItemSlots(pObj))) { + if (pInventoryPoolList[i].object.usItem == pai->usAttachment) { + if (ValidItemAttachmentSlot(pai->pObj, pai->usAttachment, true, false, pai->subObject, pai->slotCount, false, NULL, GetItemSlots(pai->pObj))) { return true; } else { - o->color_shade = COLOR_RED; + pai->o->color_shade = COLOR_RED; return false; } } } - //return ValidAttachment(itemId, pObj); - o->color_shade = COLOR_DKGREY; + + pai->o->color_shade = COLOR_DKGREY; return false; } @@ -5664,10 +5683,15 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex) if( gItemDescAttachmentPopupsInitialized && gItemDescAttachmentPopups[cnt] != NULL ){ delete(gItemDescAttachmentPopups[cnt]); } - gItemDescAttachmentPopups[cnt] = NULL; + gItemDescAttachmentPopups[cnt] = NULL; } gItemDescAttachmentPopupsInitialized = TRUE; + for (auto iter = gPopupAttachmentInfos.begin(); iter != gPopupAttachmentInfos.end(); iter++) { + delete (*iter); + } + gPopupAttachmentInfos.clear(); + //now, create new regions for (slotCount = 0; ; ++slotCount ) { @@ -5876,8 +5900,11 @@ void UpdateAttachmentTooltips(OBJECTTYPE *pObject, UINT8 ubStatusIndex) { // add the current attachment to the popup assigned to this attachment slot POPUP_OPTION * o = new POPUP_OPTION( &std::wstring( Item[ usAttachment ].szItemName ), new popupCallbackFunction(&popupCallbackItem,usAttachment)); + + gPopupAttachmentInfos.push_back(new PopupAttachmentInfo(usAttachment, pObject, ubStatusIndex, slotCount, o, gItemDescAttachmentPopups[slotCount])); + // set an availiability callback to gray out any compatible attachments not found in this sector - o->setAvail( new popupCallbackFunction3(&popupCallbackItemInSector,usAttachment, pObject, o) ); + o->setAvail(new popupCallbackFunction(&popupCallbackItemInSector, (gPopupAttachmentInfos.back()))); if (loop == 11 && attachList.size() > 11){ // if there's too much stuff to list, we create a subpopup for the rest gItemDescAttachmentPopups[slotCount]->addSubMenuOption( &std::wstring(L"More...") ); @@ -6420,14 +6447,23 @@ void ItemDescAttachmentsCallback( MOUSE_REGION * pRegion, INT32 iReason ) if( guiCurrentItemDescriptionScreen == MAP_SCREEN ) { - // Set mouse - guiExternVo = GetInterfaceGraphicForItem( &(Item[ gpItemPointer->usItem ]) ); - gusExternVoSubIndex = g_bUsePngItemImages ? 0 : Item[ gpItemPointer->usItem ].ubGraphicNum; + //Autoplace to map sector inventory + if (_KeyDown(CTRL)) + { + AutoPlaceObjectToWorld(gpItemPointerSoldier, gpItemPointer); + gpItemPointer = NULL; + } + else { + // Set mouse + guiExternVo = GetInterfaceGraphicForItem(&(Item[gpItemPointer->usItem])); + gusExternVoSubIndex = g_bUsePngItemImages ? 0 : Item[gpItemPointer->usItem].ubGraphicNum; + + MSYS_ChangeRegionCursor(&gMPanelRegion, EXTERN_CURSOR); + MSYS_SetCurrentCursor(EXTERN_CURSOR); + fMapInventoryItem = TRUE; + fTeamPanelDirty = TRUE; + } - MSYS_ChangeRegionCursor( &gMPanelRegion , EXTERN_CURSOR ); - MSYS_SetCurrentCursor( EXTERN_CURSOR ); - fMapInventoryItem=TRUE; - fTeamPanelDirty=TRUE; } //if we are currently in the shopkeeper interface diff --git a/Utils/Timer Control.cpp b/Utils/Timer Control.cpp index 972ec790c..56228a4c6 100644 --- a/Utils/Timer Control.cpp +++ b/Utils/Timer Control.cpp @@ -286,15 +286,17 @@ static inline bool TimerSanityCheck() { UINT32 GetNextCounterDoneTime(void) { QueryPerformanceCounter(&gliPerfCount); - - if (TimerSanityCheck() == false) { - // timer has gone off the rails, try to reset and hope for the best. - gliPerfCountNext.QuadPart = gliPerfCount.QuadPart + 25; - } - gliTimestampDiff = gliPerfCountNext.QuadPart - gliPerfCount.QuadPart; gliWaitTime = (gliTimestampDiff * FREQUENCY_CONST) / gliPerfFreq.QuadPart; + // if the wait time is too long/short, re-evaluate the timer and try waiting 125ms + if (gliWaitTime > 15 * FREQUENCY_CONST) { + gliWaitTime = 125; // in mili-seconds + + QueryPerformanceFrequency(&gliPerfFreq); + gliPerfCountNext.QuadPart = gliPerfCount.QuadPart + ((125 * gliPerfFreq.QuadPart) / 1000000); + } + return (UINT32)((gliWaitTime > 0) ? gliWaitTime : 0); }