mirror of
https://github.com/isledecomp/isle.git
synced 2025-10-23 08:24:16 +00:00
Score class cleanup (#855)
* Cleanup/fixes * Improve Paint match * Improve Score::FillArea * Fix naming * Fix value
This commit is contained in:

committed by
GitHub

parent
180a1e6360
commit
19d39394be
@@ -605,6 +605,7 @@ MxLong LegoNavController::Notify(MxParam& p_param)
|
||||
break;
|
||||
case VK_ESCAPE: {
|
||||
LegoWorld* currentWorld = CurrentWorld();
|
||||
|
||||
if (currentWorld) {
|
||||
InfocenterState* infocenterState = (InfocenterState*) GameState()->GetState("InfocenterState");
|
||||
if (infocenterState && infocenterState->GetUnknown0x74() != 8 && currentWorld->VTable0x64()) {
|
||||
|
@@ -12,11 +12,11 @@ AmbulanceMissionState::AmbulanceMissionState()
|
||||
m_unk0x16 = 0;
|
||||
m_unk0x0c = 0;
|
||||
m_unk0x18 = 0;
|
||||
m_color1 = 0;
|
||||
m_color2 = 0;
|
||||
m_color3 = 0;
|
||||
m_color4 = 0;
|
||||
m_color5 = 0;
|
||||
m_score1 = 0;
|
||||
m_score2 = 0;
|
||||
m_score3 = 0;
|
||||
m_score4 = 0;
|
||||
m_score5 = 0;
|
||||
}
|
||||
|
||||
// STUB: LEGO1 0x10037440
|
||||
|
@@ -25,6 +25,7 @@ RaceStateEntry* RaceState::GetState(MxU8 p_id)
|
||||
if (i >= 5) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (m_state[i].m_id == p_id) {
|
||||
return m_state + i;
|
||||
}
|
||||
|
@@ -13,11 +13,11 @@ TowTrackMissionState::TowTrackMissionState()
|
||||
m_unk0x0c = 0;
|
||||
m_unk0x1a = 0;
|
||||
m_unk0x10 = 0;
|
||||
m_unk0x1c = 0;
|
||||
m_color1 = 0;
|
||||
m_color2 = 0;
|
||||
m_color3 = 0;
|
||||
m_color4 = 0;
|
||||
m_score1 = 0;
|
||||
m_score2 = 0;
|
||||
m_score3 = 0;
|
||||
m_score4 = 0;
|
||||
m_score5 = 0;
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x1004dde0
|
||||
@@ -31,11 +31,11 @@ MxResult TowTrackMissionState::Serialize(LegoFile* p_legoFile)
|
||||
p_legoFile->Read(&m_unk0x16, sizeof(m_unk0x16));
|
||||
p_legoFile->Read(&m_unk0x18, sizeof(m_unk0x18));
|
||||
p_legoFile->Read(&m_unk0x1a, sizeof(m_unk0x1a));
|
||||
p_legoFile->Read(&m_unk0x1c, sizeof(m_unk0x1c));
|
||||
p_legoFile->Read(&m_color1, sizeof(m_color1));
|
||||
p_legoFile->Read(&m_color2, sizeof(m_color2));
|
||||
p_legoFile->Read(&m_color3, sizeof(m_color3));
|
||||
p_legoFile->Read(&m_color4, sizeof(m_color4));
|
||||
p_legoFile->Read(&m_score1, sizeof(m_score1));
|
||||
p_legoFile->Read(&m_score2, sizeof(m_score2));
|
||||
p_legoFile->Read(&m_score3, sizeof(m_score3));
|
||||
p_legoFile->Read(&m_score4, sizeof(m_score4));
|
||||
p_legoFile->Read(&m_score5, sizeof(m_score5));
|
||||
}
|
||||
else if (p_legoFile->IsWriteMode()) {
|
||||
MxU16 write = m_unk0x12;
|
||||
@@ -53,19 +53,19 @@ MxResult TowTrackMissionState::Serialize(LegoFile* p_legoFile)
|
||||
write = m_unk0x1a;
|
||||
p_legoFile->Write(&write, sizeof(m_unk0x12));
|
||||
|
||||
write = m_unk0x1c;
|
||||
write = m_score1;
|
||||
p_legoFile->Write(&write, sizeof(m_unk0x12));
|
||||
|
||||
write = m_color1;
|
||||
write = m_score2;
|
||||
p_legoFile->Write(&write, sizeof(m_unk0x12));
|
||||
|
||||
write = m_color2;
|
||||
write = m_score3;
|
||||
p_legoFile->Write(&write, sizeof(m_unk0x12));
|
||||
|
||||
write = m_color3;
|
||||
write = m_score4;
|
||||
p_legoFile->Write(&write, sizeof(m_unk0x12));
|
||||
|
||||
write = m_color4;
|
||||
write = m_score5;
|
||||
p_legoFile->Write(&write, sizeof(m_unk0x12));
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,9 @@
|
||||
#include "score.h"
|
||||
|
||||
#include "ambulancemissionstate.h"
|
||||
#include "carracestate.h"
|
||||
#include "infoscor_actions.h"
|
||||
#include "jetskiracestate.h"
|
||||
#include "jukebox.h"
|
||||
#include "jukebox_actions.h"
|
||||
#include "legocontrolmanager.h"
|
||||
@@ -39,6 +41,7 @@ Score::~Score()
|
||||
if (InputManager()->GetWorld() == this) {
|
||||
InputManager()->ClearWorld();
|
||||
}
|
||||
|
||||
InputManager()->UnRegister(this);
|
||||
ControlManager()->Unregister(this);
|
||||
NotificationManager()->Unregister(this);
|
||||
@@ -54,9 +57,9 @@ MxResult Score::Create(MxDSAction& p_dsAction)
|
||||
ControlManager()->Register(this);
|
||||
InputManager()->Register(this);
|
||||
SetIsWorldActive(FALSE);
|
||||
LegoGameState* gs = GameState();
|
||||
ScoreState* state = (ScoreState*) gs->GetState("ScoreState");
|
||||
m_state = state ? state : (ScoreState*) gs->CreateState("ScoreState");
|
||||
LegoGameState* gameState = GameState();
|
||||
ScoreState* state = (ScoreState*) gameState->GetState("ScoreState");
|
||||
m_state = state ? state : (ScoreState*) gameState->CreateState("ScoreState");
|
||||
GameState()->SetCurrentArea(LegoGameState::e_infoscor);
|
||||
GameState()->StopArea(LegoGameState::e_previousArea);
|
||||
}
|
||||
@@ -69,7 +72,7 @@ void Score::DeleteScript()
|
||||
{
|
||||
if (m_state->GetTutorialFlag()) {
|
||||
MxDSAction action;
|
||||
action.SetObjectId(0x1f5);
|
||||
action.SetObjectId(InfoscorScript::c_iicc31in_PlayWav);
|
||||
action.SetAtomId(*g_infoscorScript);
|
||||
action.SetUnknown24(-2);
|
||||
DeleteObject(action);
|
||||
@@ -82,18 +85,19 @@ MxLong Score::Notify(MxParam& p_param)
|
||||
{
|
||||
MxLong ret = 0;
|
||||
LegoWorld::Notify(p_param);
|
||||
|
||||
if (m_worldStarted) {
|
||||
switch (((MxNotificationParam&) p_param).GetNotification()) {
|
||||
case c_notificationStartAction:
|
||||
ret = 1;
|
||||
Paint();
|
||||
ret = 1;
|
||||
break;
|
||||
case c_notificationEndAction:
|
||||
ret = FUN_10001510((MxEndActionNotificationParam&) p_param);
|
||||
break;
|
||||
case c_notificationKeyPress:
|
||||
if (((LegoEventNotificationParam&) p_param).GetKey() == 0x20) {
|
||||
DeleteScript(); // Shutting down
|
||||
if (((LegoEventNotificationParam&) p_param).GetKey() == VK_SPACE) {
|
||||
DeleteScript();
|
||||
}
|
||||
ret = 1;
|
||||
break;
|
||||
@@ -101,16 +105,15 @@ MxLong Score::Notify(MxParam& p_param)
|
||||
ret = FUN_100016d0((LegoControlManagerEvent&) p_param);
|
||||
break;
|
||||
case c_notificationTransitioned:
|
||||
DeleteObjects(g_infoscorScript, 7, 9);
|
||||
DeleteObjects(g_infoscorScript, InfoscorScript::c_LegoBox1_Flc, InfoscorScript::c_LegoBox3_Flc);
|
||||
if (m_destLocation) {
|
||||
GameState()->SwitchArea(m_destLocation);
|
||||
}
|
||||
ret = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -120,15 +123,15 @@ MxLong Score::FUN_10001510(MxEndActionNotificationParam& p_param)
|
||||
MxDSAction* action = p_param.GetAction();
|
||||
|
||||
if (m_atom == action->GetAtomId()) {
|
||||
MxU32 id = action->GetObjectId();
|
||||
switch (action->GetObjectId()) {
|
||||
case 10:
|
||||
case InfoscorScript::c_GoTo_HistBook:
|
||||
m_destLocation = LegoGameState::e_histbook;
|
||||
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 0x32, 0, 0);
|
||||
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
|
||||
break;
|
||||
case 0x1f5:
|
||||
case InfoscorScript::c_iicc31in_PlayWav:
|
||||
PlayMusic(JukeboxScript::c_InformationCenter_Music);
|
||||
m_state->SetTutorialFlag(FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,14 +144,14 @@ void Score::ReadyWorld()
|
||||
LegoWorld::ReadyWorld();
|
||||
|
||||
MxDSAction action;
|
||||
action.SetObjectId(0x1f4);
|
||||
action.SetObjectId(InfoscorScript::c_nin001pr_RunAnim);
|
||||
action.SetAtomId(m_atom);
|
||||
action.SetUnknown84(this);
|
||||
Start(&action);
|
||||
|
||||
if (m_state->GetTutorialFlag()) {
|
||||
MxDSAction action2;
|
||||
action.SetObjectId(0x1f5);
|
||||
MxDSAction action;
|
||||
action.SetObjectId(InfoscorScript::c_iicc31in_PlayWav);
|
||||
action.SetAtomId(*g_infoscorScript);
|
||||
Start(&action);
|
||||
}
|
||||
@@ -162,51 +165,49 @@ void Score::ReadyWorld()
|
||||
// FUNCTION: LEGO1 0x100016d0
|
||||
MxLong Score::FUN_100016d0(LegoControlManagerEvent& p_param)
|
||||
{
|
||||
MxS16 l = p_param.GetUnknown0x28();
|
||||
MxS16 unk0x28 = p_param.GetUnknown0x28();
|
||||
|
||||
if (l == 1 || p_param.GetClickedObjectId() == 4) {
|
||||
if (unk0x28 == 1 || p_param.GetClickedObjectId() == InfoscorScript::c_LegoBox_Ctl) {
|
||||
switch (p_param.GetClickedObjectId()) {
|
||||
case InfoscorScript::c_LeftArrow_Ctl:
|
||||
m_destLocation = LegoGameState::e_infomain;
|
||||
DeleteScript();
|
||||
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 0x32, 0, 0);
|
||||
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
|
||||
break;
|
||||
case InfoscorScript::c_RightArrow_Ctl:
|
||||
m_destLocation = LegoGameState::e_infodoor;
|
||||
DeleteScript();
|
||||
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 0x32, 0, 0);
|
||||
TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE);
|
||||
break;
|
||||
case InfoscorScript::c_Book_Ctl: {
|
||||
LegoInputManager* im = InputManager();
|
||||
im->SetUnknown88(TRUE);
|
||||
im->SetUnknown336(FALSE);
|
||||
InputManager()->DisableInputProcessing();
|
||||
DeleteScript();
|
||||
|
||||
MxDSAction action;
|
||||
action.SetObjectId(10);
|
||||
action.SetObjectId(InfoscorScript::c_GoTo_HistBook);
|
||||
action.SetAtomId(*g_infoscorScript);
|
||||
Start(&action);
|
||||
break;
|
||||
}
|
||||
case InfoscorScript::c_LegoBox_Ctl: {
|
||||
switch (l) {
|
||||
switch (unk0x28) {
|
||||
case 1: {
|
||||
MxDSAction action;
|
||||
action.SetObjectId(7);
|
||||
action.SetObjectId(InfoscorScript::c_LegoBox1_Flc);
|
||||
action.SetAtomId(*g_infoscorScript);
|
||||
Start(&action);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
MxDSAction action;
|
||||
action.SetObjectId(8);
|
||||
action.SetObjectId(InfoscorScript::c_LegoBox2_Flc);
|
||||
action.SetAtomId(*g_infoscorScript);
|
||||
Start(&action);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
MxDSAction action;
|
||||
action.SetObjectId(9);
|
||||
action.SetObjectId(InfoscorScript::c_LegoBox3_Flc);
|
||||
action.SetAtomId(*g_infoscorScript);
|
||||
Start(&action);
|
||||
break;
|
||||
@@ -235,97 +236,74 @@ void Score::Enable(MxBool p_enable)
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x100019d0
|
||||
// FUNCTION: BETA10 0x100f47d8
|
||||
void Score::Paint()
|
||||
{
|
||||
LegoTextureInfo* gd = TextureContainer()->Get("bigcube.gif");
|
||||
LegoTextureInfo* cube = TextureContainer()->Get("bigcube.gif");
|
||||
|
||||
if (gd) {
|
||||
RaceState* l78 = (RaceState*) GameState()->GetState("JetskiRaceState");
|
||||
RaceState* l70 = (RaceState*) GameState()->GetState("CarRaceState");
|
||||
TowTrackMissionState* lesi = (TowTrackMissionState*) GameState()->GetState("TowTrackMissionState");
|
||||
PizzaMissionState* l74 = (PizzaMissionState*) GameState()->GetState("PizzaMissionState");
|
||||
AmbulanceMissionState* lebp = (AmbulanceMissionState*) GameState()->GetState("AmbulanceMissionState");
|
||||
if (cube != NULL) {
|
||||
JetskiRaceState* jetskiRaceState = (JetskiRaceState*) GameState()->GetState("JetskiRaceState");
|
||||
CarRaceState* carRaceState = (CarRaceState*) GameState()->GetState("CarRaceState");
|
||||
TowTrackMissionState* towTrackMissionState =
|
||||
(TowTrackMissionState*) GameState()->GetState("TowTrackMissionState");
|
||||
PizzaMissionState* pizzaMissionState = (PizzaMissionState*) GameState()->GetState("PizzaMissionState");
|
||||
AmbulanceMissionState* ambulanceMissionState =
|
||||
(AmbulanceMissionState*) GameState()->GetState("AmbulanceMissionState");
|
||||
|
||||
DDSURFACEDESC desc;
|
||||
memset(&desc, 0, sizeof(desc));
|
||||
desc.dwSize = sizeof(desc);
|
||||
if (gd->m_surface->Lock(NULL, &desc, 0, NULL) == DD_OK) {
|
||||
|
||||
if (cube->m_surface->Lock(NULL, &desc, 0, NULL) == DD_OK) {
|
||||
if (desc.lPitch != desc.dwWidth) {
|
||||
gd->m_surface->Unlock(desc.lpSurface);
|
||||
cube->m_surface->Unlock(desc.lpSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
for (MxU8 id = 1; id <= 5; id++) {
|
||||
m_surface = (MxU8*) desc.lpSurface;
|
||||
MxU16 color = 0;
|
||||
if (l70) {
|
||||
color = l70->GetColor(id);
|
||||
}
|
||||
MxU32 row = id - 1;
|
||||
FillArea(0, row, color);
|
||||
color = 0;
|
||||
if (l78) {
|
||||
color = l78->GetColor(id);
|
||||
}
|
||||
FillArea(1, row, color);
|
||||
color = 0;
|
||||
if (l74) {
|
||||
color = l74->GetColor(id);
|
||||
}
|
||||
FillArea(2, row, color);
|
||||
color = 0;
|
||||
if (lesi) {
|
||||
color = lesi->GetColor(id);
|
||||
}
|
||||
FillArea(3, row, color);
|
||||
color = 0;
|
||||
if (lebp) {
|
||||
color = lebp->GetColor(id);
|
||||
}
|
||||
FillArea(4, row, color);
|
||||
m_surface = (MxU8*) desc.lpSurface;
|
||||
|
||||
for (MxU8 actor = 1; actor <= 5; actor++) {
|
||||
MxU16 score;
|
||||
|
||||
score = carRaceState ? carRaceState->GetState(actor)->GetScore() : 0;
|
||||
FillArea(0, actor - 1, score);
|
||||
|
||||
score = jetskiRaceState ? jetskiRaceState->GetState(actor)->GetScore() : 0;
|
||||
FillArea(1, actor - 1, score);
|
||||
|
||||
score = pizzaMissionState ? pizzaMissionState->GetScore(actor) : 0;
|
||||
FillArea(2, actor - 1, score);
|
||||
|
||||
score = towTrackMissionState ? towTrackMissionState->GetScore(actor) : 0;
|
||||
FillArea(3, actor - 1, score);
|
||||
|
||||
score = ambulanceMissionState ? ambulanceMissionState->GetScore(actor) : 0;
|
||||
FillArea(4, actor - 1, score);
|
||||
}
|
||||
|
||||
gd->m_surface->Unlock(desc.lpSurface);
|
||||
gd->m_texture->Changed(TRUE, FALSE);
|
||||
cube->m_surface->Unlock(desc.lpSurface);
|
||||
cube->m_texture->Changed(TRUE, FALSE);
|
||||
m_surface = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FUNCTION: LEGO1 0x10001d20
|
||||
void Score::FillArea(MxU32 p_x, MxU32 p_y, MxS16 p_color)
|
||||
// FUNCTION: BETA10 0x100f4a52
|
||||
void Score::FillArea(MxU32 i_activity, MxU32 i_actor, MxS16 score)
|
||||
{
|
||||
MxU32 data[24];
|
||||
data[9] = 0x2b00;
|
||||
data[10] = 0x5700;
|
||||
data[11] = 0x8000;
|
||||
data[19] = 0x2a;
|
||||
data[12] = 0xab00;
|
||||
data[13] = 0xd600;
|
||||
data[20] = 0x27;
|
||||
data[21] = 0x29;
|
||||
data[22] = 0x29;
|
||||
data[23] = 0x2a;
|
||||
data[4] = 0x2f;
|
||||
data[5] = 0x56;
|
||||
data[6] = 0x81;
|
||||
data[15] = 0x29;
|
||||
data[16] = 0x27;
|
||||
data[7] = 0xaa;
|
||||
data[8] = 0xd4;
|
||||
data[14] = 0x25;
|
||||
data[0] = 0x11;
|
||||
data[17] = 0x28;
|
||||
data[18] = 0x28;
|
||||
data[1] = 0x0f;
|
||||
MxU32 size = data[p_x + 14];
|
||||
MxU8* ptr = data[p_x + 4] + data[p_y + 9] + m_surface;
|
||||
MxS32 count = data[p_y + 19];
|
||||
data[2] = 0x08;
|
||||
data[3] = 0x05;
|
||||
MxU32 value = data[p_color];
|
||||
for (; count > 0; count--) {
|
||||
memset(ptr++, value, size);
|
||||
MxS32 local3c[] = {0x2b00, 0x5700, 0x8000, 0xab00, 0xd600};
|
||||
MxS32 local14[] = {0x2a, 0x27, 0x29, 0x29, 0x2a};
|
||||
MxS32 local50[] = {0x2f, 0x56, 0x81, 0xaa, 0xd4};
|
||||
MxS32 local28[] = {0x25, 0x29, 0x27, 0x28, 0x28};
|
||||
MxS32 local60[] = {0x11, 0x0f, 0x08, 0x05};
|
||||
|
||||
MxU8* ptr = m_surface + local3c[i_actor] + local50[i_activity];
|
||||
MxS32 val = local60[score];
|
||||
MxS32 size = local28[i_activity];
|
||||
|
||||
for (MxS32 i = 0; i < local14[i_actor]; i++) {
|
||||
memset(ptr, val, size);
|
||||
ptr += 0x100;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user