Isle
Loading...
Searching...
No Matches
score.cpp
Go to the documentation of this file.
1#include "score.h"
2
3#include "ambulance.h"
4#include "carrace.h"
5#include "infoscor_actions.h"
6#include "jetski.h"
7#include "jetskirace.h"
8#include "jukebox.h"
9#include "jukebox_actions.h"
10#include "legocontrolmanager.h"
11#include "legogamestate.h"
12#include "legoinputmanager.h"
13#include "legomain.h"
14#include "misc.h"
15#include "misc/legocontainer.h"
17#include "mxmisc.h"
19#include "mxnotificationparam.h"
20#include "mxtransitionmanager.h"
21#include "pizza.h"
22#include "scripts.h"
23#include "towtrack.h"
24
27
28// FUNCTION: LEGO1 0x10001000
30{
31 m_destLocation = LegoGameState::e_undefined;
33}
34
35// FUNCTION: LEGO1 0x10001200
37{
38 if (InputManager()->GetWorld() == this) {
40 }
41
42 InputManager()->UnRegister(this);
45}
46
47// FUNCTION: LEGO1 0x100012a0
49{
50 MxResult result = LegoWorld::Create(p_dsAction);
51
52 if (result == SUCCESS) {
53 InputManager()->SetWorld(this);
54 ControlManager()->Register(this);
55 InputManager()->Register(this);
57 LegoGameState* gameState = GameState();
58 ScoreState* state = (ScoreState*) gameState->GetState("ScoreState");
59 m_state = state ? state : (ScoreState*) gameState->CreateState("ScoreState");
62 }
63
64 return result;
65}
66
67// FUNCTION: LEGO1 0x10001340
69{
70 if (m_state->GetTutorialFlag()) {
71 MxDSAction action;
74 action.SetUnknown24(-2);
75 DeleteObject(action);
77 }
78}
79
80// FUNCTION: LEGO1 0x10001410
81// FUNCTION: BETA10 0x100f4398
83{
84 MxLong ret = 0;
85 MxNotificationParam& param = (MxNotificationParam&) p_param;
86
87 LegoWorld::Notify(p_param);
88
89 if (m_worldStarted) {
90 switch (param.GetNotification()) {
92 Paint();
93 ret = 1;
94 break;
97 break;
99 if (((LegoEventNotificationParam&) p_param).GetKey() == VK_SPACE) {
100 DeleteScript();
101 }
102 ret = 1;
103 break;
106 break;
109 if (m_destLocation) {
111 }
112 ret = 1;
113 break;
114 }
115 }
116
117 return ret;
118}
119
120// FUNCTION: LEGO1 0x10001510
122{
123 MxDSAction* action = p_param.GetAction();
124
125 if (m_atomId == action->GetAtomId()) {
126 switch (action->GetObjectId()) {
130 break;
134 break;
135 }
136 }
137
138 return 1;
139}
140
141// FUNCTION: LEGO1 0x10001580
143{
145
146 MxDSAction action;
148 action.SetAtomId(m_atomId);
149 action.SetUnknown84(this);
150 Start(&action);
151
152 if (m_state->GetTutorialFlag()) {
153 MxDSAction action;
156 Start(&action);
157 }
158 else {
160 }
161
163}
164
165// FUNCTION: LEGO1 0x100016d0
167{
168 MxS16 unk0x28 = p_param.m_unk0x28;
169
170 if (unk0x28 == 1 || p_param.m_clickedObjectId == InfoscorScript::c_LegoBox_Ctl) {
171 switch (p_param.m_clickedObjectId) {
174 DeleteScript();
176 break;
179 DeleteScript();
181 break;
184 DeleteScript();
185
186 MxDSAction action;
189 Start(&action);
190 break;
191 }
193 switch (unk0x28) {
194 case 1: {
195 MxDSAction action;
198 Start(&action);
199 break;
200 }
201 case 2: {
202 MxDSAction action;
205 Start(&action);
206 break;
207 }
208 case 3: {
209 MxDSAction action;
212 Start(&action);
213 break;
214 }
215 }
216 break;
217 }
218 }
219 }
220
221 return 1;
222}
223
224// FUNCTION: LEGO1 0x10001980
225void Score::Enable(MxBool p_enable)
226{
227 LegoWorld::Enable(p_enable);
228
229 if (p_enable) {
230 InputManager()->SetWorld(this);
232 }
233 else if (InputManager()->GetWorld() == this) {
235 }
236}
237
238// FUNCTION: LEGO1 0x100019d0
239// FUNCTION: BETA10 0x100f47d8
241{
242 LegoTextureInfo* cube = TextureContainer()->Get("bigcube.gif");
243
244 if (cube != NULL) {
245 JetskiRaceState* jetskiRaceState = (JetskiRaceState*) GameState()->GetState("JetskiRaceState");
246 CarRaceState* carRaceState = (CarRaceState*) GameState()->GetState("CarRaceState");
247 TowTrackMissionState* towTrackMissionState =
248 (TowTrackMissionState*) GameState()->GetState("TowTrackMissionState");
249 PizzaMissionState* pizzaMissionState = (PizzaMissionState*) GameState()->GetState("PizzaMissionState");
250 AmbulanceMissionState* ambulanceMissionState =
251 (AmbulanceMissionState*) GameState()->GetState("AmbulanceMissionState");
252
253 DDSURFACEDESC desc;
254 memset(&desc, 0, sizeof(desc));
255 desc.dwSize = sizeof(desc);
256
257 HRESULT result = cube->m_surface->Lock(NULL, &desc, DDLOCK_SURFACEMEMORYPTR, NULL);
258 if (result == DD_OK) {
259 if (desc.lPitch != desc.dwWidth) {
260 cube->m_surface->Unlock(desc.lpSurface);
261 return;
262 }
263
264 m_surface = (MxU8*) desc.lpSurface;
265
266 for (MxU8 actor = 1; actor <= 5; actor++) {
267 MxS16 score;
268
269 score = carRaceState ? carRaceState->GetState(actor)->GetHighScore() : 0;
270 FillArea(0, actor - 1, score);
271
272 score = jetskiRaceState ? jetskiRaceState->GetState(actor)->GetHighScore() : 0;
273 FillArea(1, actor - 1, score);
274
275 score = pizzaMissionState ? pizzaMissionState->GetHighScore(actor) : 0;
276 FillArea(2, actor - 1, score);
277
278 score = towTrackMissionState ? towTrackMissionState->GetHighScore(actor) : 0;
279 FillArea(3, actor - 1, score);
280
281 score = ambulanceMissionState ? ambulanceMissionState->GetHighScore(actor) : 0;
282 FillArea(4, actor - 1, score);
283 }
284
285 cube->m_surface->Unlock(desc.lpSurface);
286 cube->m_texture->Changed(TRUE, FALSE);
287 m_surface = NULL;
288 }
289 }
290}
291
292// FUNCTION: LEGO1 0x10001d20
293// FUNCTION: BETA10 0x100f4a52
294void Score::FillArea(MxS32 i_activity, MxS32 i_actor, MxS16 score)
295{
296 MxS32 local3c[] = {0x2b00, 0x5700, 0x8000, 0xab00, 0xd600};
297 MxS32 local14[] = {0x2a, 0x27, 0x29, 0x29, 0x2a};
298 MxS32 local50[] = {0x2f, 0x56, 0x81, 0xaa, 0xd4};
299 MxS32 local28[] = {0x25, 0x29, 0x27, 0x28, 0x28};
300 MxS32 colors[] = {0x11, 0x0f, 0x08, 0x05};
301
302 assert(i_activity >= 0 && i_activity < 5);
303 assert(i_actor >= 0 && i_actor < 5);
304 assert(score >= 0 && score < 4);
305
306 MxU8* ptr = m_surface + local3c[i_actor] + local50[i_activity];
307 MxS32 color = colors[score];
308 MxS32 size = local28[i_activity];
309
310 for (MxS32 i = 0; i < local14[i_actor]; i++) {
311 memset(ptr, color, size);
312 ptr += 0x100;
313 }
314}
315
316// FUNCTION: LEGO1 0x10001e40
318{
319 DeleteScript();
321 return TRUE;
322}
Holds state and scoring information for the Ambulance mission.
Definition: ambulance.h:12
MxS16 GetHighScore(MxU8 p_actorId)
[AI] Retrieves the highest score achieved by a specified actor.
The state object used for the car race mini-game.
Definition: carrace.h:16
[AI] Per-race state data and logic holder for JetskiRace, used for tracking player and AI standings,...
Definition: jetskirace.h:107
T * Get(const char *p_name)
Retrieve the element mapped to the given name, or nullptr if missing.
Definition: legocontainer.h:92
[AI] Notification parameter for the LegoControlManager, used to propagate information about control e...
MxS32 m_clickedObjectId
[AI] Object ID of the clicked control/presenter (or -1 if not set). [AI]
MxS16 m_unk0x28
[AI] Undetermined; settable via SetUnknown0x28. [AI]
void Register(MxCore *p_listener)
[AI] Adds a listener to be notified of control events.
void Unregister(MxCore *p_listener)
[AI] Removes a listener so it no longer receives control events.
Notification parameter class for LEGO event notifications such as mouse events and modifier keys.
Comprehensive persistent game state manager: handles save/load, player selection, area switching,...
Definition: legogamestate.h:78
void SwitchArea(Area p_area)
Switches the whole game state into a new area/world; manages transitions/scene loads.
Area m_currentArea
Area/world the player is presently in. [AI].
LegoState * CreateState(const char *p_stateName)
Creates an instance of given state, registers it, and returns pointer.
void StopArea(Area p_area)
Calls cleanup logic for the specified area (removes actors, VMs, closes handles, etc....
LegoState * GetState(const char *p_stateName)
Find an existing state (LegoState-derived) object by its registered script/class name.
@ e_infomain
Information Center, main screen. [AI].
Definition: legogamestate.h:96
@ e_previousArea
Alias: go to previous area. [AI].
Definition: legogamestate.h:94
@ e_histbook
History book (scoreboard). [AI].
@ e_infoscor
Info Center hi-score area. [AI].
@ e_undefined
Undefined or unset area. [AI].
Definition: legogamestate.h:93
@ e_infodoor
Info Center door/title view. [AI].
Definition: legogamestate.h:97
void UnRegister(MxCore *)
[AI] Unregister a previously registered recipient so it will no longer receive input notifications.
void ClearWorld()
[AI] Remove any world assignment (used to clear targeting/scene changes). [AI]
void SetWorld(LegoWorld *p_world)
[AI] Assigns the current world to receive mouse/click/pick notifications.
void Register(MxCore *)
[AI] Register a core object as a recipient for keyboard events; safe for concurrent multi-threading.
void DisableInputProcessing()
[AI] Block most input processing, allowing only button-down and space events (UI modal input blocking...
@ c_clearScreen
[AI] When set, clears the display surface. [AI]
Definition: legomain.h:49
@ c_disable3d
[AI] When set, disables 3D rendering. [AI]
Definition: legomain.h:48
@ c_disableInput
[AI] When set, disables input processing. [AI]
Definition: legomain.h:47
[AI] Contains DirectDraw and Direct3DRM handles and metadata for a texture used in the LEGO Island re...
LPDIRECTDRAWSURFACE m_surface
[AI] DirectDraw surface holding the 8-bit indexed image for the texture.
LPDIRECT3DRMTEXTURE2 m_texture
[AI] Direct3DRM texture object used by retained-mode rendering.
virtual void ReadyWorld()
Called when the world is ready to be used—typically for custom scene setup after startup.
Definition: legoworld.cpp:874
virtual void Enable(MxBool p_enable)
Enables or disables (pauses) the world and its main components.
Definition: legoworld.cpp:684
MxBool m_worldStarted
Indicates if the world has successfully started and is considered active.
Definition: legoworld.h:388
MxLong Notify(MxParam &p_param) override
Notification callback responding to registered events such as EndAction and NewPresenter.
Definition: legoworld.cpp:212
MxResult Create(MxDSAction &p_dsAction) override
Initializes the world using an action, creating entity and sound lists, and camera controller.
Definition: legoworld.cpp:58
MxDSAction * GetAction()
[AI] Direct access to the underlying action.
[AI] Represents an action deserialized from SI chunks, holding key animation or script parameters suc...
Definition: mxdsaction.h:17
void SetUnknown84(MxCore *p_unk0x84)
[AI] Sets the auxiliary core pointer for this action.
Definition: mxdsaction.h:254
const MxAtomId & GetAtomId()
[AI] Returns a const-reference to the object's atom identifier.
Definition: mxdsobject.h:133
virtual void SetAtomId(MxAtomId p_atomId)
[AI] Sets the atom id for this object instance, used for indexing or lookup.
Definition: mxdsobject.h:118
void SetUnknown24(MxS16 p_unk0x24)
[AI] Sets the unknown field at 0x24 (possibly version/state).
Definition: mxdsobject.h:151
void SetObjectId(MxU32 p_objectId)
[AI] Sets the object id (for serialization or lookup).
Definition: mxdsobject.h:147
MxU32 GetObjectId()
[AI] Returns the object id numeric value.
Definition: mxdsobject.h:130
[AI] Notification parameter marking the end of an action, specialization of MxActionNotificationParam...
MxAtomId m_atomId
The AtomId associated with this entity, used for resource and script identification.
Definition: mxentity.h:124
void Unregister(MxCore *p_listener)
[AI] Removes a previously registered listener and flushes any pending notifications for it.
void Register(MxCore *p_listener)
[AI] Registers a listener object to receive notifications.
[AI] Parameter object representing a single notification or event, carrying an identifier and sender ...
NotificationId GetNotification() const
[AI] Retrieves the current notification type of this parameter.
[AI] MxParam serves as a polymorphic base class for parameter passing in event and notification syste...
Definition: mxparam.h:7
MxResult StartTransition(TransitionType p_animationType, MxS32 p_speed, MxBool p_doCopy, MxBool p_playMusicInAnim)
[AI] Begins a new transition animation of type p_animationType at the specified speed,...
@ e_mosaic
[AI] Complex mosaic block-out effect.
Pizza mission state for the pizza delivery minigame and related characters.
Definition: pizza.h:21
MxS16 GetHighScore(MxU8 p_actorId)
Retrieves the historical best (high) score for a given actor's pizza mission.
Definition: pizza.h:220
Entry * GetState(MxU8 p_id)
[AI] Fetches a race state entry matching the given entry ID, or NULL if not found in the array.
Definition: legorace.cpp:151
[AI] State object used to track the status of the Score/High Score area, particularly whether the edu...
Definition: score.h:15
MxBool GetTutorialFlag()
[AI] Get whether the high score cube tutorial should be played.
Definition: score.h:49
void SetTutorialFlag(MxBool p_playCubeTutorial)
[AI] Set whether the high score cube tutorial should be played.
Definition: score.h:53
[AI] Implements the InfoScore/High Score game world/area, including score table display and handling ...
Definition: score.h:66
MxLong FUN_100016d0(LegoControlManagerNotificationParam &p_param)
[AI] Handles user input/control interaction (button/cube click) in the InfoScore area,...
Definition: score.cpp:166
ScoreState * m_state
[AI] Pointer to the current ScoreState for this world's area/session.
Definition: score.h:140
void FillArea(MxS32 i_activity, MxS32 i_actor, MxS16 score)
[AI] Helper for painting – fills the correct high score colored area for an activity/actor pair on th...
Definition: score.cpp:294
MxLong FUN_10001510(MxEndActionNotificationParam &p_param)
[AI] Handles notification of a completed action (like an InfoScore script finishing).
Definition: score.cpp:121
void DeleteScript()
[AI] Cancels the tutorial script playback if still running and disables further tutorials for this se...
Definition: score.cpp:68
void ReadyWorld() override
[AI] Called when the world is ready to be started (usually upon area entry); triggers the correct ani...
Definition: score.cpp:142
MxLong Notify(MxParam &p_param) override
[AI] Handles incoming notifications, including control and action completion, and manages state trans...
Definition: score.cpp:82
~Score() override
[AI] Destructor unregisters Score from managers and performs cleanup.
Definition: score.cpp:36
MxResult Create(MxDSAction &p_dsAction) override
[AI] Creates and initializes the Score world with the specified DS action.
Definition: score.cpp:48
MxU8 * m_surface
[AI] Raw surface data pointer for direct pixel manipulation (locked during Paint(); NULL otherwise)....
Definition: score.h:143
MxBool Escape() override
[AI] Called when the player is attempting to “escape” (exit) the InfoScore area; deletes script actio...
Definition: score.cpp:317
LegoGameState::Area m_destLocation
[AI] Area/room to switch to after leaving Score (set when the user clicks navigation arrows/books/etc...
Definition: score.h:137
void Enable(MxBool p_enable) override
[AI] Called to enable or disable this world, hooking up input as needed.
Definition: score.cpp:225
void Paint()
[AI] Paints the current score cube with the high scores for each activity and actor.
Definition: score.cpp:240
[AI] State class for the TowTrack mini-game, storing scores by character and handling their serializa...
Definition: towtrack.h:17
MxS16 GetHighScore(MxU8 p_actorId)
[AI] Retrieves the highscore for a given actor in the Tow Track mini-game.
#define TRUE
Definition: d3drmdef.h:28
#define FALSE
Definition: d3drmdef.h:27
#define DD_OK
Definition: ddraw.h:3166
long HRESULT
Definition: ddraw.h:115
#define DDLOCK_SURFACEMEMORYPTR
Definition: ddraw.h:2909
#define DECOMP_SIZE_ASSERT(T, S)
Definition: decomp.h:19
#define NULL
[AI] Null pointer value (C/C++ semantics).
Definition: legotypes.h:26
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30
LegoGameState * GameState()
[AI] Accessor for the game's central game state controller. [AI]
Definition: misc.cpp:61
void DeleteObjects(MxAtomId *p_id, MxS32 p_first, MxS32 p_last)
[AI] Batch deletes objects, given by atom id, and within the entity id range [p_first,...
Definition: misc.cpp:237
MxTransitionManager * TransitionManager()
[AI] Accessor for the MxTransitionManager, handling level transitions, fades, and world changes....
Definition: misc.cpp:208
LegoControlManager * ControlManager()
[AI] Accessor for the control manager through the input manager; manages higher-level user/game contr...
Definition: misc.cpp:53
void FUN_10015820(MxBool p_disable, MxU16 p_flags)
[AI] Utility for enabling or disabling functionality in LegoOmni based on certain flags.
Definition: misc.cpp:143
void PlayMusic(JukeboxScript::Script p_objectId)
[AI] Starts music playback by scripting the background audio manager to play the music piece referenc...
Definition: misc.cpp:216
LegoTextureContainer * TextureContainer()
[AI] Accessor for the texture container used for global texture management. [AI]
Definition: misc.cpp:130
void SetIsWorldActive(MxBool p_isWorldActive)
[AI] Toggles whether the world should be considered active (enables/disables camera/user control etc)...
Definition: misc.cpp:228
LegoInputManager * InputManager()
[AI] Accessor for the input manager, which handles keyboard, mouse, and controller input....
Definition: misc.cpp:45
MxResult Start(MxDSAction *p_dsAction)
[AI] Schedules and initiates execution of a script action.
Definition: mxmisc.cpp:97
void DeleteObject(MxDSAction &p_dsAction)
[AI] Deletes the specified action object, removing it from the global action list.
Definition: mxmisc.cpp:105
MxNotificationManager * NotificationManager()
[AI] Returns the notification manager for system-wide state/update notifications.
Definition: mxmisc.cpp:17
@ c_notificationControl
[AI] UI control event [AI]
@ c_notificationStartAction
[AI] Indicates the start of an action [AI]
@ c_notificationKeyPress
[AI] Keyboard key press detected [AI]
@ c_notificationTransitioned
[AI] Object has transitioned states or locations [AI]
@ c_notificationEndAction
[AI] Indicates the end of an action [AI]
MxU8 MxBool
[AI]
Definition: mxtypes.h:124
MxLong MxResult
[AI]
Definition: mxtypes.h:106
int MxLong
[AI]
Definition: mxtypes.h:83
signed short MxS16
[AI]
Definition: mxtypes.h:26
unsigned char MxU8
[AI]
Definition: mxtypes.h:8
signed int MxS32
[AI]
Definition: mxtypes.h:38
@ c_InformationCenter_Music
[AI] Background music for the information center.
[AI] Contains global script AtomId pointers and utility functions for managing script AtomIds in LEGO...
MxAtomId * g_infoscorScript
[AI] Script AtomId for the Info Center scoring/stat script.
Definition: scripts.cpp:45
MxS16 GetHighScore()
[AI] Retrieves the race entry's current high score.
Definition: legorace.h:57
LPVOID lpSurface
Definition: ddraw.h:1152
LONG lPitch
Definition: ddraw.h:1140
DWORD dwSize
Definition: ddraw.h:1134
DWORD dwWidth
Definition: ddraw.h:1137