Address review feedback

* Dialogue control.cpp
* vsurface.cpp
* Event pump.cpp
This commit is contained in:
Asdow
2023-10-10 19:53:19 +03:00
parent f00214d00d
commit d6a3a27b58
3 changed files with 57 additions and 75 deletions
+13 -14
View File
@@ -1795,13 +1795,13 @@ BOOLEAN GetVSurfaceRegion( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION
{
Assert( hVSurface != NULL );
if (usIndex < hVSurface->RegionList.size())
if (usIndex >= hVSurface->RegionList.size())
{
*aRegion = hVSurface->RegionList[usIndex];
return( TRUE );
return( FALSE );
}
return( FALSE );
*aRegion = hVSurface->RegionList[usIndex];
return( TRUE );
}
BOOLEAN GetVSurfaceRect( HVSURFACE hVSurface, RECT *pRect)
@@ -1823,13 +1823,13 @@ BOOLEAN ReplaceVSurfaceRegion( HVSURFACE hVSurface , UINT16 usIndex, VSURFACE_RE
Assert( hVSurface != NULL );
if (usIndex < hVSurface->RegionList.size())
if (usIndex >= hVSurface->RegionList.size())
{
hVSurface->RegionList[usIndex] = *aRegion;
return( TRUE );
return( FALSE );
}
return( FALSE );
hVSurface->RegionList[usIndex] = *aRegion;
return( TRUE );
}
BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_REGION *pNewRegion )
@@ -1837,15 +1837,14 @@ BOOLEAN AddVSurfaceRegionAtIndex( HVSURFACE hVSurface, UINT16 usIndex, VSURFACE_
Assert( hVSurface != NULL );
Assert( pNewRegion != NULL );
// Add new region to list
if (usIndex < hVSurface->RegionList.size())
if (usIndex >= hVSurface->RegionList.size())
{
auto pos = hVSurface->RegionList.begin() + usIndex;
hVSurface->RegionList.insert(pos, *pNewRegion);
return(TRUE);
return(FALSE);
}
return(FALSE);
auto pos = hVSurface->RegionList.begin() + usIndex;
hVSurface->RegionList.insert(pos, *pNewRegion);
return(TRUE);
}
// *******************************************************************
+7 -13
View File
@@ -361,7 +361,7 @@ void EmptyDialogueQueue( )
}
inline BOOLEAN DialogueQueueIsEmpty( )
BOOLEAN DialogueQueueIsEmpty( )
{
return( ghDialogueQ.empty() );
}
@@ -1798,8 +1798,7 @@ void AdditionalTacticalCharacterDialogue_AllInSectorRadiusCall( UINT8 ausIgnoreP
BOOLEAN CharacterDialogueWithSpecialEvent( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 iFaceIndex, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed, UINT32 uiFlag, UINT32 uiData1, UINT32 uiData2 )
{
DIALOGUE_Q_STRUCT QItem;
memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT));
DIALOGUE_Q_STRUCT QItem{};
QItem.ubCharacterNum = ubCharacterNum;
QItem.usQuoteNum = usQuoteNum;
QItem.iFaceIndex = iFaceIndex;
@@ -1833,8 +1832,7 @@ BOOLEAN CharacterDialogueWithSpecialEvent( UINT8 ubCharacterNum, UINT16 usQuoteN
BOOLEAN CharacterDialogueWithSpecialEventEx( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 iFaceIndex, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed, UINT32 uiFlag, UINT32 uiData1, UINT32 uiData2, UINT32 uiData3 )
{
DIALOGUE_Q_STRUCT QItem;
memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT));
DIALOGUE_Q_STRUCT QItem{};
QItem.ubCharacterNum = ubCharacterNum;
QItem.usQuoteNum = usQuoteNum;
QItem.iFaceIndex = iFaceIndex;
@@ -1863,8 +1861,7 @@ BOOLEAN CharacterDialogueWithSpecialEventEx( UINT8 ubCharacterNum, UINT16 usQuot
BOOLEAN CharacterDialogue( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32 iFaceIndex, UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed )
{
DIALOGUE_Q_STRUCT QItem;
memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT));
DIALOGUE_Q_STRUCT QItem{};
QItem.ubCharacterNum = ubCharacterNum;
QItem.usQuoteNum = usQuoteNum;
QItem.iFaceIndex = iFaceIndex;
@@ -1914,8 +1911,7 @@ BOOLEAN SnitchCharacterDialogue( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32
UINT32 uiSpecialEventData3, UINT32 uiSpecialEventData4,
UINT8 bUIHandlerID, BOOLEAN fFromSoldier, BOOLEAN fDelayed )
{
DIALOGUE_Q_STRUCT QItem;
memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT));
DIALOGUE_Q_STRUCT QItem{};
QItem.ubCharacterNum = ubCharacterNum;
QItem.usQuoteNum = usQuoteNum;
QItem.uiSpecialEventFlag = uiSpecialEventFlag;
@@ -1946,8 +1942,7 @@ BOOLEAN SnitchCharacterDialogue( UINT8 ubCharacterNum, UINT16 usQuoteNum, INT32
BOOLEAN SpecialCharacterDialogueEvent( UINT32 uiSpecialEventFlag, UINT32 uiSpecialEventData1, UINT32 uiSpecialEventData2, UINT32 uiSpecialEventData3, INT32 iFaceIndex, UINT8 bUIHandlerID )
{
DIALOGUE_Q_STRUCT QItem;
memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT));
DIALOGUE_Q_STRUCT QItem{};
QItem.uiSpecialEventFlag = uiSpecialEventFlag;
QItem.uiSpecialEventData = uiSpecialEventData1;
QItem.uiSpecialEventData2 = uiSpecialEventData2;
@@ -1972,8 +1967,7 @@ BOOLEAN SpecialCharacterDialogueEvent( UINT32 uiSpecialEventFlag, UINT32 uiSpeci
BOOLEAN SpecialCharacterDialogueEventWithExtraParam( UINT32 uiSpecialEventFlag, UINT32 uiSpecialEventData1, UINT32 uiSpecialEventData2, UINT32 uiSpecialEventData3, UINT32 uiSpecialEventData4, INT32 iFaceIndex, UINT8 bUIHandlerID )
{
DIALOGUE_Q_STRUCT QItem;
memset(&QItem, 0, sizeof(DIALOGUE_Q_STRUCT));
DIALOGUE_Q_STRUCT QItem{};
QItem.uiSpecialEventFlag = uiSpecialEventFlag;
QItem.uiSpecialEventData = uiSpecialEventData1;
QItem.uiSpecialEventData2 = uiSpecialEventData2;
+37 -48
View File
@@ -11,8 +11,8 @@
#include "Animation Control.h"
#include "opplist.h"
#include "Tactical Save.h"
#include<vector>
#include<queue>
#include <vector>
#include <queue>
#ifdef NETWORKED
#include "Networking.h"
@@ -595,7 +595,7 @@ UINT8 gubEncryptionArray4[ BASE_NUMBER_OF_ROTATION_ARRAYS * 3 ][ NEW_ROTATION_AR
},
};
typedef struct
struct EVENT
{
TIMER TimeStamp;
UINT32 uiFlags;
@@ -604,7 +604,25 @@ typedef struct
UINT32 uiDataSize;
BYTE* pData;
} EVENT;
EVENT(UINT16 delay, UINT32 event, UINT32 dataSize, BYTE* eventData) :
TimeStamp(GetJA2Clock()),
uiFlags(0),
usDelay(delay),
uiEvent(event),
uiDataSize(dataSize),
pData{ eventData }
{
}
EVENT() :
TimeStamp(GetJA2Clock()),
uiFlags(0),
usDelay(0),
uiEvent(0),
uiDataSize(0),
pData{ nullptr }
{}
};
#define PRIMARY_EVENT_QUEUE 0
#define SECONDARY_EVENT_QUEUE 1
@@ -653,43 +671,15 @@ BOOLEAN AddEvent(UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSi
switch (ubQueueID)
{
case PRIMARY_EVENT_QUEUE:
//hEventQueue.push(*pEvent);
hEventQueue.emplace(
EVENT{
GetJA2Clock(),
0,
usDelay,
uiEvent,
uiDataSize,
pData
}
);
hEventQueue.emplace(usDelay, uiEvent, uiDataSize, pData);
break;
case SECONDARY_EVENT_QUEUE:
hDelayEventQueue.emplace_back(
EVENT{
GetJA2Clock(),
0,
usDelay,
uiEvent,
uiDataSize,
pData
}
);
hDelayEventQueue.emplace_back(usDelay, uiEvent, uiDataSize, pData);
break;
case DEMAND_EVENT_QUEUE:
hDemandEventQueue.emplace(
EVENT{
GetJA2Clock(),
0,
usDelay,
uiEvent,
uiDataSize,
pData
}
);
hDemandEventQueue.emplace(usDelay, uiEvent, uiDataSize, pData);
break;
default:
@@ -703,18 +693,18 @@ BOOLEAN AddEvent(UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT32 uiDataSi
static BOOLEAN RemoveEventFromSecondaryEventQueue(EVENT* ppEvent, UINT32 uiIndex)
{
if (uiIndex < hDelayEventQueue.size())
if (uiIndex >= hDelayEventQueue.size())
{
*ppEvent = hDelayEventQueue[uiIndex];
hDelayEventQueue.erase(hDelayEventQueue.begin() + uiIndex);
return(TRUE);
return(FALSE);
}
return(FALSE);
*ppEvent = hDelayEventQueue[uiIndex];
hDelayEventQueue.erase(hDelayEventQueue.begin() + uiIndex);
return(TRUE);
}
BOOLEAN PopEvent(EVENT* ppEvent, UINT8 ubQueueID)
static BOOLEAN PopEvent(EVENT* ppEvent, UINT8 ubQueueID)
{
// Get an event from queue, if one exists
//
@@ -756,11 +746,10 @@ BOOLEAN PopEvent(EVENT* ppEvent, UINT8 ubQueueID)
}
BOOLEAN FreeEvent(EVENT* pEvent)
static BOOLEAN FreeEventData(EVENT* pEvent)
{
CHECKF(pEvent != NULL);
// Delete event
MemFree(pEvent->pData);
//MemFree(pEvent);
@@ -792,7 +781,7 @@ UINT32 EventQueueSize(UINT8 ubQueueID)
}
BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT8 ubQueueID )
static BOOLEAN AddGameEventToQueue( UINT32 uiEvent, UINT16 usDelay, PTR pEventData, UINT8 ubQueueID )
{
UINT32 uiDataSize;
@@ -990,7 +979,7 @@ BOOLEAN DequeAllGameEvents( BOOLEAN fExecute )
}
// Delete event
FreeEvent( &pEvent );
FreeEventData( &pEvent );
};
@@ -1021,7 +1010,7 @@ BOOLEAN DequeAllGameEvents( BOOLEAN fExecute )
if (pEventRef.uiFlags & EVENT_EXPIRED)
{
RemoveEventFromSecondaryEventQueue(&pEventRef, i);
FreeEvent(&pEventRef);
FreeEventData(&pEventRef);
}
}
@@ -1057,7 +1046,7 @@ BOOLEAN DequeueAllDemandGameEvents( BOOLEAN fExecute )
}
// Delete event
FreeEvent( &pEvent );
FreeEventData( &pEvent );
};
@@ -1397,7 +1386,7 @@ BOOLEAN ClearEventQueue( void )
{
return( FALSE );
}
FreeEvent(&pEvent);
FreeEventData(&pEvent);
}
return( TRUE );