mirror of
https://github.com/isledecomp/isle.git
synced 2024-11-26 09:38:14 -05:00
494a556f8e
* Adjustments to "decomp" language * Fix a comment * Fix accidental clang-formatting * Fix order * Fix order * Remove junk * Fix OFFSET * Adjustments based on new suggestions * Annotate globals * Globals in ISLE * More globals * Merge from parser2 branch * Allow prepending space for exact marker match * To eliminate noise, require the 0x prefix on offset for marker match * fix test from previous * Count tab stops for indented functions to reduce MISSED_END_OF_FUNCTION noise * FUNCTION to SYNTHETIC where needed * Missed marker conversion on SetAtomId * pylint cleanup, remove unused code * Fix unexpected function end, add more unit tests * Be more strict about synthetic name syntax * Revert "Missed marker conversion on SetAtomId" This reverts commitd87d665127
. * Revert "FUNCTION to SYNTHETIC where needed" This reverts commit8c815418d2
. * Implicit lookup by name for functions * Fix VTABLE SYNTHETIC and other decomp markers * Get vtable class name * Vtable marker should identify struct * No colon for SIZE comment * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update README.md * Update CONTRIBUTING.md * Update README.md * Update CONTRIBUTING.md * Fix destructor/annotation * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --------- Co-authored-by: disinvite <disinvite@users.noreply.github.com>
113 lines
2.7 KiB
C++
113 lines
2.7 KiB
C++
#include "mxticklemanager.h"
|
|
|
|
#include "decomp.h"
|
|
#include "mxomni.h"
|
|
#include "mxtimer.h"
|
|
#include "mxtypes.h"
|
|
|
|
#define TICKLE_MANAGER_FLAG_DESTROY 0x1
|
|
|
|
DECOMP_SIZE_ASSERT(MxTickleClient, 0x10);
|
|
DECOMP_SIZE_ASSERT(MxTickleManager, 0x14);
|
|
|
|
// FUNCTION: LEGO1 0x100bdd10
|
|
MxTickleClient::MxTickleClient(MxCore* p_client, MxTime p_interval)
|
|
{
|
|
m_flags = 0;
|
|
m_client = p_client;
|
|
m_interval = p_interval;
|
|
m_lastUpdateTime = -m_interval;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100bdd30
|
|
MxTickleManager::~MxTickleManager()
|
|
{
|
|
while (m_clients.size() != 0) {
|
|
MxTickleClient* client = m_clients.front();
|
|
m_clients.pop_front();
|
|
delete client;
|
|
}
|
|
}
|
|
|
|
// TODO: Match.
|
|
// FUNCTION: LEGO1 0x100bdde0
|
|
MxResult MxTickleManager::Tickle()
|
|
{
|
|
MxTime time = Timer()->GetTime();
|
|
|
|
MxTickleClientPtrList::iterator it = m_clients.begin();
|
|
|
|
while (it != m_clients.end()) {
|
|
MxTickleClient* client = *it;
|
|
if ((client->GetFlags() & TICKLE_MANAGER_FLAG_DESTROY) == 0) {
|
|
if (client->GetLastUpdateTime() >= time)
|
|
client->SetLastUpdateTime(-client->GetTickleInterval());
|
|
|
|
if ((client->GetTickleInterval() + client->GetLastUpdateTime()) < time) {
|
|
client->GetClient()->Tickle();
|
|
client->SetLastUpdateTime(time);
|
|
}
|
|
|
|
it++;
|
|
}
|
|
else {
|
|
m_clients.erase(it++);
|
|
delete client;
|
|
}
|
|
}
|
|
|
|
return SUCCESS;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100bde80
|
|
void MxTickleManager::RegisterClient(MxCore* p_client, MxTime p_interval)
|
|
{
|
|
MxTime interval = GetClientTickleInterval(p_client);
|
|
if (interval == TICKLE_MANAGER_NOT_FOUND) {
|
|
MxTickleClient* client = new MxTickleClient(p_client, p_interval);
|
|
if (client != NULL)
|
|
m_clients.push_back(client);
|
|
}
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100bdf60
|
|
void MxTickleManager::UnregisterClient(MxCore* p_client)
|
|
{
|
|
MxTickleClientPtrList::iterator it = m_clients.begin();
|
|
while (it != m_clients.end()) {
|
|
MxTickleClient* client = *it;
|
|
if (client->GetClient() == p_client) {
|
|
client->SetFlags(client->GetFlags() | TICKLE_MANAGER_FLAG_DESTROY);
|
|
return;
|
|
}
|
|
|
|
it++;
|
|
}
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100bdfa0
|
|
void MxTickleManager::SetClientTickleInterval(MxCore* p_client, MxTime p_interval)
|
|
{
|
|
for (MxTickleClientPtrList::iterator it = m_clients.begin(); it != m_clients.end(); it++) {
|
|
MxTickleClient* client = *it;
|
|
if ((client->GetClient() == p_client) && ((client->GetFlags() & TICKLE_MANAGER_FLAG_DESTROY) == 0)) {
|
|
client->SetTickleInterval(p_interval);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100be000
|
|
MxTime MxTickleManager::GetClientTickleInterval(MxCore* p_client)
|
|
{
|
|
MxTickleClientPtrList::iterator it = m_clients.begin();
|
|
while (it != m_clients.end()) {
|
|
MxTickleClient* client = *it;
|
|
if ((client->GetClient() == p_client) && ((client->GetFlags() & TICKLE_MANAGER_FLAG_DESTROY) == 0))
|
|
return client->GetTickleInterval();
|
|
|
|
it++;
|
|
}
|
|
|
|
return TICKLE_MANAGER_NOT_FOUND;
|
|
}
|