Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/Helpers/TimeAttackData.h
338 views
1
#ifndef OBJ_TIMEATTACKDATA_H
2
#define OBJ_TIMEATTACKDATA_H
3
4
#include "Game.h"
5
6
typedef enum {
7
CHAR_SONIC_AND_TAILS,
8
CHAR_SONIC,
9
CHAR_TAILS,
10
CHAR_KNUX,
11
#if MANIA_USE_PLUS
12
CHAR_MIGHTY,
13
CHAR_RAY,
14
#endif
15
} CharacterIDs;
16
17
typedef enum {
18
ACT_1,
19
ACT_2,
20
ACT_3,
21
ACT_NONE,
22
} ActIDs;
23
24
// Using a seperate TimeAttackRAM struct
25
// Normally (and officially) the ObjectGameProgress struct was used here
26
// but due to v5U updating the entity (and thus the TimeAttackRAM "spec")
27
// ObjectGameProgress is no longer easily compatible across versions
28
// so I gave it dummy data and will be using this struct to interact with TimeAttackRAM
29
// this one was also broken with plus since medals[] were aligned by 1 byte
30
// so when "filter" was added, all medals were offset by 1 without this fix
31
typedef struct {
32
uint8 padding[0x56]; // aka sizeof(Entity) for pre-plus
33
uint16 records[3][12][2][3];
34
} TimeAttackRAM;
35
36
// Object Class
37
struct ObjectTimeAttackData {
38
#if !MANIA_USE_PLUS
39
RSDK_OBJECT
40
#endif
41
bool32 loaded;
42
uint8 zoneID;
43
uint8 act;
44
uint8 characterID;
45
bool32 encore;
46
int32 uuid;
47
int32 rowID;
48
int32 personalRank;
49
int32 leaderboardRank;
50
bool32 isMigratingData;
51
Entity *loadEntityPtr;
52
void (*loadCallback)(bool32 success);
53
Entity *saveEntityPtr;
54
void (*saveCallback)(bool32 success);
55
};
56
57
#if !MANIA_USE_PLUS
58
// Entity Class
59
struct EntityTimeAttackData {
60
RSDK_ENTITY
61
// padding to match whatever it would be normally
62
// not required, but its for safety :)
63
uint8 padding[sizeof(TimeAttackRAM) - sizeof(Entity)];
64
};
65
#endif
66
67
// Object Entity
68
extern ObjectTimeAttackData *TimeAttackData;
69
70
// Standard Entity Events
71
void TimeAttackData_Update(void);
72
void TimeAttackData_LateUpdate(void);
73
void TimeAttackData_StaticUpdate(void);
74
void TimeAttackData_Draw(void);
75
void TimeAttackData_Create(void *data);
76
void TimeAttackData_StageLoad(void);
77
#if GAME_INCLUDE_EDITOR
78
void TimeAttackData_EditorDraw(void);
79
void TimeAttackData_EditorLoad(void);
80
#endif
81
void TimeAttackData_Serialize(void);
82
83
// Extra Entity Functions
84
#if MANIA_USE_PLUS
85
void TimeAttackData_TrackActClear(StatInfo *stat, uint8 zone, uint8 act, uint8 charID, int32 time, int32 rings, int32 score);
86
void TimeAttackData_TrackTAClear(StatInfo *stat, uint8 zone, uint8 actID, uint8 charID, int32 gameMode, int32 time);
87
void TimeAttackData_TrackEnemyDefeat(StatInfo *stat, uint8 zoneID, uint8 actID, uint8 charID, bool32 encore, int32 x, int32 y);
88
#endif
89
90
TimeAttackRAM *TimeAttackData_GetTimeAttackRAM(void);
91
void TimeAttackData_Clear(void);
92
int32 TimeAttackData_GetManiaListPos(int32 zoneID, int32 act, int32 characterID);
93
#if MANIA_USE_PLUS
94
int32 TimeAttackData_GetEncoreListPos(int32 zoneID, int32 act, int32 characterID);
95
#endif
96
uint32 TimeAttackData_GetPackedTime(int32 minutes, int32 seconds, int32 milliseconds);
97
void TimeAttackData_GetUnpackedTime(int32 time, int32 *minutes, int32 *seconds, int32 *milliseconds);
98
uint16 *TimeAttackData_GetRecordedTime(uint8 zoneID, uint8 act, uint8 characterID, uint8 rank);
99
100
#if MANIA_USE_PLUS
101
void TimeAttackData_CreateDB(void);
102
uint16 TimeAttackData_LoadDB(void (*callback)(bool32 success));
103
void TimeAttackData_SaveDB(void (*callback)(bool32 success));
104
void TimeAttackData_LoadDBCallback(int32 status);
105
void TimeAttackData_SaveDBCallback(int32 status);
106
void TimeAttackData_MigrateLegacySaves(void);
107
int32 TimeAttackData_AddDBRow(uint8 zoneID, uint8 act, uint8 characterID, uint8 encore, int32 score);
108
int32 TimeAttackData_AddRecord(uint8 zoneID, uint8 act, uint8 characterID, bool32 encore, int32 score, void (*callback)(bool32 success));
109
int32 TimeAttackData_GetScore(uint8 zoneID, uint8 act, uint8 characterID, bool32 encore, int32 rank);
110
int32 TimeAttackData_GetReplayID(uint8 zoneID, uint8 act, uint8 characterID, bool32 encore, int32 rank);
111
void TimeAttackData_ConfigureTableView(uint8 zoneID, uint8 act, uint8 characterID, bool32 encore);
112
113
void TimeAttackData_Leaderboard_GetRank(bool32 success, int32 rank);
114
void TimeAttackData_AddLeaderboardEntry(uint8 zoneID, uint8 act, uint8 characterID, bool32 isEncore, int32 score);
115
LeaderboardID *TimeAttackData_GetLeaderboardInfo(uint8 zoneID, uint8 act, uint8 characterID, bool32 isEncore);
116
#else
117
void TimeAttackData_AddRecord(uint8 zoneID, uint8 act, uint8 characterID, uint8 rank, uint16 score);
118
#endif
119
120
#endif //! OBJ_TIMEATTACKDATA_H
121
122