Use size_t for number of input events

This commit is contained in:
Robert Müller 2023-04-21 18:34:28 +02:00
parent 2b7f054590
commit ecc49a699f
7 changed files with 13 additions and 13 deletions

View file

@ -33,7 +33,7 @@ protected:
}; };
// quick access to events // quick access to events
int m_NumEvents; size_t m_NumEvents;
IInput::CEvent m_aInputEvents[INPUT_BUFFER_SIZE]; IInput::CEvent m_aInputEvents[INPUT_BUFFER_SIZE];
int64_t m_LastUpdate; int64_t m_LastUpdate;
float m_UpdateTime; float m_UpdateTime;
@ -54,15 +54,15 @@ public:
}; };
// events // events
int NumEvents() const { return m_NumEvents; } size_t NumEvents() const { return m_NumEvents; }
virtual bool IsEventValid(const CEvent &Event) const = 0; virtual bool IsEventValid(const CEvent &Event) const = 0;
const CEvent &GetEvent(int Index) const const CEvent &GetEvent(size_t Index) const
{ {
dbg_assert(Index >= 0 && Index < m_NumEvents, "Index invalid"); dbg_assert(Index < m_NumEvents, "Index invalid");
return m_aInputEvents[Index]; return m_aInputEvents[Index];
} }
CEvent *GetEventsRaw() { return m_aInputEvents; } CEvent *GetEventsRaw() { return m_aInputEvents; }
int *GetEventCountRaw() { return &m_NumEvents; } size_t *GetEventCountRaw() { return &m_NumEvents; }
/** /**
* @return Rolling average of the time in seconds between * @return Rolling average of the time in seconds between

View file

@ -58,7 +58,7 @@ float CMenus::ms_ButtonHeight = 25.0f;
float CMenus::ms_ListheaderHeight = 17.0f; float CMenus::ms_ListheaderHeight = 17.0f;
IInput::CEvent CMenus::m_aInputEvents[MAX_INPUTEVENTS]; IInput::CEvent CMenus::m_aInputEvents[MAX_INPUTEVENTS];
int CMenus::m_NumInputEvents; size_t CMenus::m_NumInputEvents;
CMenus::CMenus() CMenus::CMenus()
{ {

View file

@ -340,7 +340,7 @@ protected:
MAX_INPUTEVENTS = 32 MAX_INPUTEVENTS = 32
}; };
static IInput::CEvent m_aInputEvents[MAX_INPUTEVENTS]; static IInput::CEvent m_aInputEvents[MAX_INPUTEVENTS];
static int m_NumInputEvents; static size_t m_NumInputEvents;
// some settings // some settings
static float ms_ButtonHeight; static float ms_ButtonHeight;

View file

@ -392,7 +392,7 @@ void CGameClient::OnUpdate()
} }
// handle key presses // handle key presses
for(int i = 0; i < Input()->NumEvents(); i++) for(size_t i = 0; i < Input()->NumEvents(); i++)
{ {
const IInput::CEvent &Event = Input()->GetEvent(i); const IInput::CEvent &Event = Input()->GetEvent(i);
if(!Input()->IsEventValid(Event)) if(!Input()->IsEventValid(Event))

View file

@ -101,7 +101,7 @@ void CUI::Init(IKernel *pKernel)
CUIElementBase::Init(this); CUIElementBase::Init(this);
} }
void CUI::InitInputs(IInput::CEvent *pInputEventsArray, int *pInputEventCount) void CUI::InitInputs(IInput::CEvent *pInputEventsArray, size_t *pInputEventCount)
{ {
m_pInputEventsArray = pInputEventsArray; m_pInputEventsArray = pInputEventsArray;
m_pInputEventCount = pInputEventCount; m_pInputEventCount = pInputEventCount;
@ -812,7 +812,7 @@ bool CUI::DoEditBox(const void *pID, const CUIRect *pRect, char *pStr, unsigned
ReturnValue = true; ReturnValue = true;
} }
for(int i = 0; i < *m_pInputEventCount; i++) for(size_t i = 0; i < *m_pInputEventCount; i++)
{ {
int LastCursor = m_CurCursor; int LastCursor = m_CurCursor;
int Len, NumChars; int Len, NumChars;

View file

@ -243,7 +243,7 @@ private:
bool m_MouseSlow = false; bool m_MouseSlow = false;
IInput::CEvent *m_pInputEventsArray; IInput::CEvent *m_pInputEventsArray;
int *m_pInputEventCount; size_t *m_pInputEventCount;
unsigned m_HotkeysPressed = 0; unsigned m_HotkeysPressed = 0;
bool m_MouseIsPress = false; bool m_MouseIsPress = false;
@ -297,7 +297,7 @@ public:
static float ms_FontmodHeight; static float ms_FontmodHeight;
void Init(IKernel *pKernel); void Init(IKernel *pKernel);
void InitInputs(IInput::CEvent *pInputEventsArray, int *pInputEventCount); void InitInputs(IInput::CEvent *pInputEventsArray, size_t *pInputEventCount);
IClient *Client() const { return m_pClient; } IClient *Client() const { return m_pClient; }
IGraphics *Graphics() const { return m_pGraphics; } IGraphics *Graphics() const { return m_pGraphics; }
IInput *Input() const { return m_pInput; } IInput *Input() const { return m_pInput; }

View file

@ -6855,7 +6855,7 @@ void CEditor::OnUpdate()
Reset(); Reset();
} }
for(int i = 0; i < Input()->NumEvents(); i++) for(size_t i = 0; i < Input()->NumEvents(); i++)
UI()->OnInput(Input()->GetEvent(i)); UI()->OnInput(Input()->GetEvent(i));
// handle cursor movement // handle cursor movement