Fixes (by The_Bob):

- Fixed index out of bounds in get items assignment check
- Fixed attachment popup not allowing more than one of the same attachment
- Improved timer control sanity check code
- Added timer adjustment for variable CPU frequency
- Added shortcut: ctrl+left-click on attachment to remove and drop it in sector inventory

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8400 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
silversurfer
2017-04-14 08:34:20 +00:00
parent fef0722178
commit d7f91064f0
4 changed files with 71 additions and 33 deletions
+9 -9
View File
@@ -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
+3 -3
View File
@@ -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);
+51 -15
View File
@@ -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<PopupAttachmentInfo*> 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<void,UINT16>(&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<bool,UINT16, OBJECTTYPE*, POPUP_OPTION*>(&popupCallbackItemInSector,usAttachment, pObject, o) );
o->setAvail(new popupCallbackFunction<bool, PopupAttachmentInfo*>(&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
+8 -6
View File
@@ -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);
}