From 74bd6ca4b3d1212f221f0e100966e1957b20c42d Mon Sep 17 00:00:00 2001 From: inshy Date: Sun, 1 Mar 2009 18:22:56 +0000 Subject: [PATCH] Fix from Heinz: 1) Fixed error creating new soldiers in DoReinforcementAsPendingEnemy 2) Fixed some bugs in Shopkeeper interface. 3) Fixed CTD when pressing Alt-Y not in cheat mode 4) Save/load screen shouldn't appear during quickload git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2612 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- SaveLoadGame.cpp | 1 + Strategic/Queen Command.cpp | 23 +++++++- Strategic/Queen Command.h | 2 + Strategic/Reinforcement.cpp | 21 +++---- Tactical/Interface Items.cpp | 2 +- Tactical/Interface Panels.cpp | 3 +- Tactical/ShopKeeper Interface.cpp | 94 ++++++++++++++++++++++--------- Tactical/Turn Based Input.cpp | 19 ++++--- 8 files changed, 113 insertions(+), 52 deletions(-) diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index b2531f76..ce23d6bc 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -4280,6 +4280,7 @@ BOOLEAN LoadSavedGame( int ubSavedGameID ) OutputDebugString( "Resetting attack busy due to load game.\n"); #endif gTacticalStatus.ubAttackBusyCount = 0; + gfPendingEnemies = CheckPendingEnemies(); } // ATE: if we are within this window where skyridder was foobared, fix! diff --git a/Strategic/Queen Command.cpp b/Strategic/Queen Command.cpp index edfdc4c1..805ba6dc 100644 --- a/Strategic/Queen Command.cpp +++ b/Strategic/Queen Command.cpp @@ -1600,7 +1600,7 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub { ubNumElites--; ubTotalSoldiers--; - pSoldier = TacticalCreateEliteEnemy(); + Assert(pSoldier = TacticalCreateEliteEnemy()); if( pGroup ) { pSoldier->ubGroupID = pGroup->ubGroupID; @@ -1623,7 +1623,7 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub { ubNumTroops--; ubTotalSoldiers--; - pSoldier = TacticalCreateArmyTroop(); + Assert(pSoldier = TacticalCreateArmyTroop()); if( pGroup ) { pSoldier->ubGroupID = pGroup->ubGroupID; @@ -1646,7 +1646,7 @@ void AddEnemiesToBattle( GROUP *pGroup, UINT8 ubStrategicInsertionCode, UINT8 ub { ubNumAdmins--; ubTotalSoldiers--; - pSoldier = TacticalCreateAdministrator(); + Assert(pSoldier = TacticalCreateAdministrator()); if( pGroup ) { pSoldier->ubGroupID = pGroup->ubGroupID; @@ -2184,4 +2184,21 @@ BOOLEAN OnlyHostileCivsInSector() return TRUE; } +BOOLEAN CheckPendingEnemies() +{ + if( gbWorldSectorZ ) return FALSE; + SECTORINFO *pSector = &SectorInfo[ SECTOR( gWorldSectorX, gWorldSectorY ) ]; + if( (pSector->ubNumElites + pSector->ubNumTroops + pSector->ubNumAdmins) > ( pSector->ubElitesInBattle + pSector->ubTroopsInBattle + pSector->ubAdminsInBattle) ) + return TRUE; + for (GROUP *pGroup = gpGroupList; pGroup; pGroup = pGroup->next) + { + if( !pGroup->fPlayer + && !pGroup->fVehicle + && pGroup->ubSectorX == gWorldSectorX + && pGroup->ubSectorY == gWorldSectorY + && pGroup->ubGroupSize > pGroup->pEnemyGroup->ubElitesInBattle + pGroup->pEnemyGroup->ubTroopsInBattle + pGroup->pEnemyGroup->ubAdminsInBattle) + return TRUE; + } + return FALSE; +} diff --git a/Strategic/Queen Command.h b/Strategic/Queen Command.h index 7ec22102..77114271 100644 --- a/Strategic/Queen Command.h +++ b/Strategic/Queen Command.h @@ -56,4 +56,6 @@ BOOLEAN OnlyHostileCivsInSector(); extern INT16 gsInterrogationGridNo[3]; +BOOLEAN CheckPendingEnemies(); + #endif \ No newline at end of file diff --git a/Strategic/Reinforcement.cpp b/Strategic/Reinforcement.cpp index 328ec3df..64a9a975 100644 --- a/Strategic/Reinforcement.cpp +++ b/Strategic/Reinforcement.cpp @@ -247,7 +247,7 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY ) GROUP *pGroup; //ENEMYGROUP *pEnemyGroup; SECTORINFO *pThisSector, *pSector; - + if( !gGameExternalOptions.gfAllowReinforcements ) return 255; @@ -274,7 +274,7 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY ) } } - while( ubDirNumber > 0) + while( ubDirNumber > 0 ) { ubIndex = Random(ubDirNumber); @@ -286,26 +286,22 @@ UINT8 DoReinforcementAsPendingEnemy( INT16 sMapX, INT16 sMapY ) { (pThisSector->ubNumElites)++; (pSector->ubNumElites)--; + (pThisSector->ubElitesInBattle)++; + AddEnemiesToBattle( NULL, (UINT8)pusMoveDir[ ubIndex ][ 2 ], 0, 0, 1, FALSE ); }else if( pSector->ubNumTroops ) { (pThisSector->ubNumTroops)++; (pSector->ubNumTroops)--; + (pThisSector->ubTroopsInBattle)++; + AddEnemiesToBattle( NULL, (UINT8)pusMoveDir[ ubIndex ][ 2 ], 0, 1, 0, FALSE ); }else if( pSector->ubNumAdmins ) { (pThisSector->ubNumAdmins)++; (pSector->ubNumAdmins)--; + (pThisSector->ubAdminsInBattle)++; + AddEnemiesToBattle( NULL, (UINT8)pusMoveDir[ ubIndex ][ 2 ], 1, 0, 0, FALSE ); } - AddEnemiesToBattle( NULL, (UINT8)pusMoveDir[ ubIndex ][ 2 ], - pThisSector->ubNumAdmins - pThisSector->ubAdminsInBattle, - pThisSector->ubNumTroops - pThisSector->ubTroopsInBattle, - pThisSector->ubNumElites - pThisSector->ubElitesInBattle, - FALSE ); - - pThisSector->ubAdminsInBattle = pThisSector->ubNumAdmins; - pThisSector->ubTroopsInBattle = pThisSector->ubNumTroops; - pThisSector->ubElitesInBattle = pThisSector->ubNumElites; - return (UINT8)pusMoveDir[ ubIndex ][ 2 ]; } else @@ -458,3 +454,4 @@ void AddPossiblePendingMilitiaToBattle() } } } + diff --git a/Tactical/Interface Items.cpp b/Tactical/Interface Items.cpp index f61c3119..3f3574b5 100644 --- a/Tactical/Interface Items.cpp +++ b/Tactical/Interface Items.cpp @@ -2828,7 +2828,7 @@ void InitItemDescriptionBoxStartCoords( BOOLEAN fIsEnhanced ) { ITEMDESC_START_X = 259; ITEMDESC_START_Y = (1 + INV_INTERFACE_START_Y); - ITEMDESC_HEIGHT = 195; + ITEMDESC_HEIGHT = guiCurrentItemDescriptionScreen == SHOPKEEPER_SCREEN ? 133 : 195; ITEMDESC_WIDTH = 320; // OIV only } else // ODB/OIV diff --git a/Tactical/Interface Panels.cpp b/Tactical/Interface Panels.cpp index 31531ab4..de223113 100644 --- a/Tactical/Interface Panels.cpp +++ b/Tactical/Interface Panels.cpp @@ -3011,7 +3011,8 @@ void SMInvClickCamoCallback( MOUSE_REGION * pRegion, INT32 iReason ) else { // Send message - ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ CANNOT_DO_INV_STUFF_STR ] ); + //Heinz: 23.02.09 BUGFIX: Don't send message when SKI is on + if( !( guiTacticalInterfaceFlags & INTERFACE_SHOPKEEP_INTERFACE ) ) ScreenMsg( FONT_MCOLOR_LTYELLOW, MSG_UI_FEEDBACK, TacticalStr[ CANNOT_DO_INV_STUFF_STR ] ); } } } diff --git a/Tactical/ShopKeeper Interface.cpp b/Tactical/ShopKeeper Interface.cpp index 84544f4d..88f797ba 100644 --- a/Tactical/ShopKeeper Interface.cpp +++ b/Tactical/ShopKeeper Interface.cpp @@ -403,7 +403,6 @@ extern BOOLEAN BltVSurfaceUsingDD( HVSURFACE hDestVSurface, HVSURFACE hSrcVSurf extern UINT8 gubLastSpecialItemAddedAtElement; - //Enums for the various Atm modes enum { @@ -790,12 +789,18 @@ UINT32 ShopKeeperScreenHandle() // render buttons marked dirty //ATM: DisableSMPpanelButtonsWhenInShopKeeperInterface( FALSE ); + //Heinz: 22.02.09 BUGFIX: buttons should not render upon shopkeeper's message + if( gfIsTheShopKeeperTalking && !gfInItemDescBox ) + { + ButtonList[ guiSKI_TransactionButton ]->uiFlags |= BUTTON_FORCE_UNDIRTY; + ButtonList[ guiSKI_DoneButton ]->uiFlags |= BUTTON_FORCE_UNDIRTY; + } RenderButtons( ); - + RenderItemDescriptionBox( ); // render help SaveBackgroundRects( ); RenderButtonsFastHelp( ); - + ExecuteBaseDirtyRectQueue(); EndFrameBufferRender(); @@ -912,8 +917,12 @@ BOOLEAN EnterShopKeeperInterface() // Create a video surface to blt corner of the tactical screen that still shines through vs_desc.fCreateFlags = VSURFACE_CREATE_DEFAULT | VSURFACE_SYSTEM_MEM_USAGE; - vs_desc.usWidth = SKI_TACTICAL_BACKGROUND_START_WIDTH; - vs_desc.usHeight = SKI_TACTICAL_BACKGROUND_START_HEIGHT; + //Heinz: 22.02.09 BUGFIX: best way - to update whole tactical screen around SKI + //vs_desc.usWidth = SKI_TACTICAL_BACKGROUND_START_WIDTH; + //vs_desc.usHeight = SKI_TACTICAL_BACKGROUND_START_HEIGHT; + vs_desc.usWidth = SCREEN_WIDTH; + vs_desc.usHeight = SCREEN_HEIGHT; + vs_desc.ubBitDepth = 16; if( !AddVideoSurface( &vs_desc, &guiCornerWhereTacticalIsStillSeenImage) ) { @@ -923,8 +932,10 @@ BOOLEAN EnterShopKeeperInterface() return( FALSE ); } - - + + //Heinz: 22.02.09 shadowing of tactical screen for further using as a background + ShadowVideoSurfaceRect( guiCornerWhereTacticalIsStillSeenImage, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); + //Clear out all the save background rects EmptyBackgroundRects( ); @@ -1361,8 +1372,9 @@ void HandleShopKeeperInterface() //make sure the buttons dont render // ButtonList[ guiSKI_InvPageUpButton ]->uiFlags |= BUTTON_FORCE_UNDIRTY; // ButtonList[ guiSKI_InvPageDownButton ]->uiFlags |= BUTTON_FORCE_UNDIRTY; - ButtonList[ guiSKI_TransactionButton ]->uiFlags |= BUTTON_FORCE_UNDIRTY; - ButtonList[ guiSKI_DoneButton ]->uiFlags |= BUTTON_FORCE_UNDIRTY; + //Heinz: 22.02.09 BUGFIX: buttons should render for items in inventory with EDB + //ButtonList[ guiSKI_TransactionButton ]->uiFlags |= BUTTON_FORCE_UNDIRTY; + //ButtonList[ guiSKI_DoneButton ]->uiFlags |= BUTTON_FORCE_UNDIRTY; // make sure the shop keeper doesn't start talking ( reset the timing variable ) @@ -1450,8 +1462,9 @@ void HandleShopKeeperInterface() //if the merc is talking and there is an item currently being highlighted // ( this gets rid of the item burning through the dealers text box ) if( gfIsTheShopKeeperTalking ) - if( gpHighLightedItemObject != NULL || gubSkiDirtyLevel != SKI_DIRTY_LEVEL0 ) - RenderMercPopUpBoxFromIndex( giPopUpBoxId, gusPositionOfSubTitlesX, SKI_POSITION_SUBTITLES_Y, FRAME_BUFFER); + //Heinz: 23.02.09 BUGFIX: if shopkeeper is talking we should render popup in all cases + //if( gpHighLightedItemObject != NULL || gubSkiDirtyLevel != SKI_DIRTY_LEVEL0 ) + RenderMercPopUpBoxFromIndex( giPopUpBoxId, gusPositionOfSubTitlesX, SKI_POSITION_SUBTITLES_Y, FRAME_BUFFER); //if we are to display the drop item to ground text @@ -1515,8 +1528,9 @@ BOOLEAN RenderShopKeeperInterface() InsertDollarSignInToString( zMoney ); DrawTextToScreen( zMoney, SKI_PLAYERS_CURRENT_BALANCE_X, SKI_PLAYERS_CURRENT_BALANCE_OFFSET_TO_VALUE, SKI_PLAYERS_CURRENT_BALANCE_WIDTH, FONT10ARIAL, SKI_ITEM_PRICE_COLOR, FONT_MCOLOR_BLACK, TRUE, CENTER_JUSTIFIED ); - BlitBufferToBuffer( guiRENDERBUFFER, guiSAVEBUFFER, 0, 0, SKI_TACTICAL_BACKGROUND_START_X, SKI_TACTICAL_BACKGROUND_START_HEIGHT ); - + //Heinz: 22.02.09 BUGFIX: best way - to update whole tactical screen around SKI + //BlitBufferToBuffer( guiRENDERBUFFER, guiSAVEBUFFER, 0, 0, SKI_TACTICAL_BACKGROUND_START_X, SKI_TACTICAL_BACKGROUND_START_HEIGHT ); + BlitBufferToBuffer( guiRENDERBUFFER, guiSAVEBUFFER, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); //At this point the background is pure, copy it to the save buffer if( gfRenderScreenOnNextLoop ) { @@ -1524,12 +1538,17 @@ BOOLEAN RenderShopKeeperInterface() GetVideoSurface( &hDestVSurface, guiCornerWhereTacticalIsStillSeenImage ); GetVideoSurface( &hSrcVSurface, guiSAVEBUFFER ); - SrcRect.iLeft = SKI_TACTICAL_BACKGROUND_START_X; - SrcRect.iTop = SKI_TACTICAL_BACKGROUND_START_Y; - SrcRect.iRight = SKI_TACTICAL_BACKGROUND_START_X + SKI_TACTICAL_BACKGROUND_START_WIDTH; - SrcRect.iBottom = SKI_TACTICAL_BACKGROUND_START_Y + SKI_TACTICAL_BACKGROUND_START_HEIGHT; - - BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, SKI_TACTICAL_BACKGROUND_START_X, SKI_TACTICAL_BACKGROUND_START_Y, (RECT*)&SrcRect ); + //Heinz: 22.02.09 BUGFIX: best way - to update whole tactical screen around SKI + //SrcRect.iLeft = SKI_TACTICAL_BACKGROUND_START_X; + //SrcRect.iTop = SKI_TACTICAL_BACKGROUND_START_Y; + //SrcRect.iRight = SKI_TACTICAL_BACKGROUND_START_X + SKI_TACTICAL_BACKGROUND_START_WIDTH; + //SrcRect.iBottom = SKI_TACTICAL_BACKGROUND_START_Y + SKI_TACTICAL_BACKGROUND_START_HEIGHT; + //BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, SKI_TACTICAL_BACKGROUND_START_X, SKI_TACTICAL_BACKGROUND_START_Y, (RECT*)&SrcRect ); + SrcRect.iLeft = 0; + SrcRect.iTop = 0; + SrcRect.iRight = SCREEN_WIDTH; + SrcRect.iBottom = SCREEN_HEIGHT; + BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, 0, 0, (RECT*)&SrcRect ); gfRenderScreenOnNextLoop = FALSE; } @@ -1574,14 +1593,37 @@ void RestoreTacticalBackGround() GetVideoSurface( &hDestVSurface, guiRENDERBUFFER ); GetVideoSurface( &hSrcVSurface, guiCornerWhereTacticalIsStillSeenImage ); + //Heinz: 22.02.09 BUGFIX: best way - to update whole tactical screen around SKI + //SrcRect.iLeft = SKI_TACTICAL_BACKGROUND_START_X; //0; + //SrcRect.iTop = SKI_TACTICAL_BACKGROUND_START_Y; //0; + //SrcRect.iRight = SKI_TACTICAL_BACKGROUND_START_WIDTH; //SKI_TACTICAL_BACKGROUND_START_WIDTH; + //SrcRect.iBottom = SKI_TACTICAL_BACKGROUND_START_HEIGHT; //SKI_TACTICAL_BACKGROUND_START_HEIGHT; + + //BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, SKI_TACTICAL_BACKGROUND_START_X, SKI_TACTICAL_BACKGROUND_START_Y, (RECT*)&SrcRect ); // Top - SrcRect.iLeft = SKI_TACTICAL_BACKGROUND_START_X; //0; - SrcRect.iTop = SKI_TACTICAL_BACKGROUND_START_Y; //0; - SrcRect.iRight = SKI_TACTICAL_BACKGROUND_START_WIDTH; //SKI_TACTICAL_BACKGROUND_START_WIDTH; - SrcRect.iBottom = SKI_TACTICAL_BACKGROUND_START_HEIGHT; //SKI_TACTICAL_BACKGROUND_START_HEIGHT; - - BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, SKI_TACTICAL_BACKGROUND_START_X, SKI_TACTICAL_BACKGROUND_START_Y, (RECT*)&SrcRect ); - + SrcRect.iLeft = 0; + SrcRect.iTop = 0; + SrcRect.iRight = SCREEN_WIDTH; + SrcRect.iBottom = SCREEN_Y_OFFSET; + BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, SrcRect.iLeft, SrcRect.iTop, (RECT*)&SrcRect ); + // Bottom + SrcRect.iLeft = 0; + SrcRect.iTop = SCREEN_Y_OFFSET + SKI_INTERFACE_HEIGHT; + SrcRect.iRight = SCREEN_WIDTH; + SrcRect.iBottom = SCREEN_HEIGHT - INV_INTERFACE_HEIGHT; + BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, SrcRect.iLeft, SrcRect.iTop, (RECT*)&SrcRect ); + // Left + SrcRect.iLeft = 0; + SrcRect.iTop = SCREEN_Y_OFFSET; + SrcRect.iRight = SCREEN_X_OFFSET; + SrcRect.iBottom = SCREEN_Y_OFFSET + SKI_INTERFACE_HEIGHT; + BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, SrcRect.iLeft, SrcRect.iTop, (RECT*)&SrcRect ); + // Right + SrcRect.iLeft = SCREEN_X_OFFSET + SKI_INTERFACE_WIDTH; + SrcRect.iTop = SCREEN_Y_OFFSET; + SrcRect.iRight = SCREEN_WIDTH; + SrcRect.iBottom = SCREEN_Y_OFFSET + SKI_INTERFACE_HEIGHT; + BltVSurfaceUsingDD( hDestVSurface, hSrcVSurface, VO_BLT_SRCTRANSPARENCY, SrcRect.iLeft, SrcRect.iTop, (RECT*)&SrcRect ); // WANNE: I think it is not used. //InvalidateRegion( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT ); } diff --git a/Tactical/Turn Based Input.cpp b/Tactical/Turn Based Input.cpp index 3e8ef2e1..85a8f467 100644 --- a/Tactical/Turn Based Input.cpp +++ b/Tactical/Turn Based Input.cpp @@ -1542,7 +1542,8 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) gfCameDirectlyFromGame = TRUE; guiPreviousOptionScreen = GAME_SCREEN; - LeaveTacticalScreen( SAVE_LOAD_SCREEN ); + //Heinz: 28.02.09 BUGFIX: player doesn't need to see save/load screen + //LeaveTacticalScreen( SAVE_LOAD_SCREEN ); DoQuickLoad(); } } @@ -3834,15 +3835,15 @@ void GetKeyboardInput( UINT32 *puiNewEvent ) // Recruit! RecruitEPC( MARIA ); + + //Heinz: 28.02.09 BUGFIX: giving G41 to Maria only in cheat mode + // Create object and set + CreateItem( (UINT16) G41, 100, &Object ); + + pSoldier = FindSoldierByProfileID( MARIA, FALSE ); + + AutoPlaceObject( pSoldier, &Object, FALSE ); } - - // Create object and set - CreateItem( (UINT16) G41, 100, &Object ); - - pSoldier = FindSoldierByProfileID( MARIA, FALSE ); - - AutoPlaceObject( pSoldier, &Object, FALSE ); - } else {