Make NotificationManager::Send take a const reference to notification (#836)

* Make NotificationManager::Send take a const reference to notification

* Fix virtual func
This commit is contained in:
Christian Semmler
2024-04-22 08:11:38 -04:00
committed by GitHub
parent 0e0d6890ad
commit f1688be263
22 changed files with 50 additions and 180 deletions

View File

@@ -96,17 +96,10 @@ void MxCompositePresenter::EndAction()
MxPresenter::EndAction();
if (action && action->GetOrigin()) {
#ifdef COMPAT_MODE
{
MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE);
NotificationManager()->Send(action->GetOrigin(), &param);
}
#else
NotificationManager()->Send(
action->GetOrigin(),
&MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
);
#endif
}
}
@@ -209,7 +202,7 @@ void MxCompositePresenter::VTable0x5c(MxNotificationParam& p_param)
}
}
NotificationManager()->Send(this, &p_param);
NotificationManager()->Send(this, p_param);
}
}

View File

@@ -154,17 +154,10 @@ void MxMediaPresenter::EndAction()
}
if (action && action->GetOrigin()) {
#ifdef COMPAT_MODE
{
MxEndActionNotificationParam param(c_notificationEndAction, this, action, FALSE);
NotificationManager()->Send(action->GetOrigin(), &param);
}
#else
NotificationManager()->Send(
action->GetOrigin(),
&MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
MxEndActionNotificationParam(c_notificationEndAction, this, action, FALSE)
);
#endif
}
}
}

View File

@@ -58,16 +58,9 @@ void MxPresenter::EndAction()
AUTOLOCK(m_criticalSection);
if (!this->m_compositePresenter) {
#ifdef COMPAT_MODE
{
MxEndActionNotificationParam param(c_notificationEndAction, NULL, this->m_action, TRUE);
MxOmni::GetInstance()->NotifyCurrentEntity(&param);
}
#else
MxOmni::GetInstance()->NotifyCurrentEntity(
&MxEndActionNotificationParam(c_notificationEndAction, NULL, this->m_action, TRUE)
MxEndActionNotificationParam(c_notificationEndAction, NULL, this->m_action, TRUE)
);
#endif
}
this->m_action = NULL;
@@ -115,15 +108,7 @@ void MxPresenter::SendToCompositePresenter(MxOmni* p_omni)
if (m_compositePresenter) {
AUTOLOCK(m_criticalSection);
#ifdef COMPAT_MODE
{
MxNotificationParam param(c_notificationPresenter, this);
NotificationManager()->Send(m_compositePresenter, &param);
}
#else
NotificationManager()->Send(m_compositePresenter, &MxNotificationParam(c_notificationPresenter, this));
#endif
NotificationManager()->Send(m_compositePresenter, MxNotificationParam(c_notificationPresenter, this));
m_action->SetOrigin(p_omni ? p_omni : MxOmni::GetInstance());
m_compositePresenter = NULL;
}

View File

@@ -42,7 +42,7 @@ MxEntity* MxOmni::AddToWorld(const char*, MxS32, MxPresenter*)
}
// FUNCTION: LEGO1 0x100aefc0
void MxOmni::NotifyCurrentEntity(MxNotificationParam* p_param)
void MxOmni::NotifyCurrentEntity(const MxNotificationParam& p_param)
{
}
@@ -269,28 +269,14 @@ MxResult MxOmni::CreatePresenter(MxStreamController* p_controller, MxDSAction& p
if (object->StartAction(p_controller, &p_action) == SUCCESS) {
if (sender) {
#ifdef COMPAT_MODE
{
MxType4NotificationParam param(this, &p_action, object);
NotificationManager()->Send(sender, &param);
}
#else
NotificationManager()->Send(sender, &MxType4NotificationParam(this, &p_action, object));
#endif
NotificationManager()->Send(sender, MxType4NotificationParam(this, &p_action, object));
}
if (p_action.GetUnknown84()) {
#ifdef COMPAT_MODE
{
MxStartActionNotificationParam param(c_notificationStartAction, object, &p_action, FALSE);
NotificationManager()->Send(p_action.GetUnknown84(), &param);
}
#else
NotificationManager()->Send(
p_action.GetUnknown84(),
&MxStartActionNotificationParam(c_notificationStartAction, object, &p_action, FALSE)
MxStartActionNotificationParam(c_notificationStartAction, object, &p_action, FALSE)
);
#endif
}
result = SUCCESS;
}

View File

@@ -4,7 +4,7 @@ DECOMP_SIZE_ASSERT(MxActionNotificationParam, 0x14)
DECOMP_SIZE_ASSERT(MxEndActionNotificationParam, 0x14)
// FUNCTION: LEGO1 0x100b0300
MxNotificationParam* MxStartActionNotificationParam::Clone()
MxNotificationParam* MxStartActionNotificationParam::Clone() const
{
return new MxStartActionNotificationParam(
c_notificationStartAction,
@@ -15,7 +15,7 @@ MxNotificationParam* MxStartActionNotificationParam::Clone()
}
// FUNCTION: LEGO1 0x100b04f0
MxNotificationParam* MxType4NotificationParam::Clone()
MxNotificationParam* MxType4NotificationParam::Clone() const
{
return new MxType4NotificationParam(this->m_sender, this->m_action, this->m_unk0x14);
}

View File

@@ -12,10 +12,10 @@ DECOMP_SIZE_ASSERT(MxNotification, 0x08);
DECOMP_SIZE_ASSERT(MxNotificationManager, 0x40);
// FUNCTION: LEGO1 0x100ac220
MxNotification::MxNotification(MxCore* p_target, MxNotificationParam* p_param)
MxNotification::MxNotification(MxCore* p_target, const MxNotificationParam& p_param)
{
m_target = p_target;
m_param = p_param->Clone();
m_param = p_param.Clone();
}
// FUNCTION: LEGO1 0x100ac240
@@ -61,25 +61,23 @@ MxResult MxNotificationManager::Create(MxU32 p_frequencyMS, MxBool p_createThrea
}
// FUNCTION: LEGO1 0x100ac6c0
MxResult MxNotificationManager::Send(MxCore* p_listener, MxNotificationParam* p_param)
MxResult MxNotificationManager::Send(MxCore* p_listener, const MxNotificationParam& p_param)
{
AUTOLOCK(m_lock);
if (m_active == FALSE) {
if (!m_active) {
return FAILURE;
}
else {
MxIdList::iterator it = find(m_listenerIds.begin(), m_listenerIds.end(), p_listener->GetId());
if (it == m_listenerIds.end()) {
return FAILURE;
}
else {
MxNotification* notif = new MxNotification(p_listener, p_param);
if (notif != NULL) {
m_queue->push_back(notif);
return SUCCESS;
}
}
MxIdList::iterator it = find(m_listenerIds.begin(), m_listenerIds.end(), p_listener->GetId());
if (it == m_listenerIds.end()) {
return FAILURE;
}
MxNotification* notif = new MxNotification(p_listener, p_param);
if (notif != NULL) {
m_queue->push_back(notif);
return SUCCESS;
}
return FAILURE;

View File

@@ -334,16 +334,9 @@ MxResult MxDiskStreamController::VTable0x24(MxDSAction* p_action)
AUTOLOCK(m_criticalSection);
if (m_unk0x54.Find(p_action, FALSE) == NULL) {
if (VTable0x30(p_action) == SUCCESS) {
#ifdef COMPAT_MODE
{
MxEndActionNotificationParam param(c_notificationEndAction, NULL, p_action, TRUE);
MxOmni::GetInstance()->NotifyCurrentEntity(&param);
}
#else
MxOmni::GetInstance()->NotifyCurrentEntity(
&MxEndActionNotificationParam(c_notificationEndAction, NULL, p_action, TRUE)
MxEndActionNotificationParam(c_notificationEndAction, NULL, p_action, TRUE)
);
#endif
}
}

View File

@@ -81,14 +81,7 @@ MxLong MxStreamer::Close(const char* p_name)
delete c;
}
else {
#ifdef COMPAT_MODE
{
MxStreamerNotification notification(c_notificationStreamer, NULL, c);
NotificationManager()->Send(this, &notification);
}
#else
NotificationManager()->Send(this, &MxStreamerNotification(c_notificationStreamer, NULL, c));
#endif
NotificationManager()->Send(this, MxStreamerNotification(c_notificationStreamer, NULL, c));
}
return SUCCESS;
@@ -99,7 +92,7 @@ MxLong MxStreamer::Close(const char* p_name)
}
// FUNCTION: LEGO1 0x100b9700
MxNotificationParam* MxStreamerNotification::Clone()
MxNotificationParam* MxStreamerNotification::Clone() const
{
return new MxStreamerNotification(m_type, m_sender, m_controller);
}
@@ -204,14 +197,7 @@ MxLong MxStreamer::Notify(MxParam& p_param)
delete c;
}
else {
#ifdef COMPAT_MODE
{
MxStreamerNotification notification(c_notificationStreamer, NULL, c);
NotificationManager()->Send(this, &notification);
}
#else
NotificationManager()->Send(this, &MxStreamerNotification(c_notificationStreamer, NULL, c));
#endif
NotificationManager()->Send(this, MxStreamerNotification(c_notificationStreamer, NULL, c));
}
}