Files
wii-ipl/include/system/iplCdbManager.h
coah a824e02a30 fix: restore 43U DOL hash on main (#213)
* fix: restore MSL extab flags and force-active stripped symbols

* fix: limit ChannelTitle novtable header changes to IPL_CHANNEL_TITLE_NOVTABLE

PR #182 made gui::EventHandler novtable and rewrote HermiteIntp for every
unit, which dropped __vt__Q23gui12EventHandler from linked scene units and
moved EventHandler::onEvent. Restore the pre-#182 definitions unless the
macro is defined.

* fix: restore u16 addrType in cdb::Manager::createNewRecord

The original symbol takes u16 (mangled UsUs); the enum parameter made
createNewRecord 4 bytes longer. Match the caller in iplNwc24Manager with a
u16 local assigned through if/else.

* fix: emit TVRC loop handlers after TVRCSendStartAsync

The original object places both alarm handlers at the end of .text.

* fix: construct scene::Date::mscMaxDate with utility::Date

The MaxDate wrapper emitted a weak MaxDate ctor that the original does
not have, shifting .text by 0x10 after iplDate. Go back to a plain
utility::Date followed by the 0x10-byte padding array.

* fix: define textinput PaneComponent dtor after PaneManager dtor

Matches the original object's function order, which also pulls the weak
GUIComponent dtor into place.

* fix: define EGG audio Arg and SoundHeapMgr ctors out of line

Emits IAudioMgr::Arg::Arg first and SoundHeapMgr's weak dtor ahead of its
ctor, matching the original eggAudioMgr function order.

* fix: define WaveFile dtors in AudioWavePlayer after the ctor

The original emits WavePacket's weak dtor first, then the WaveFileAiff and
WaveFileWav dtors. Declaring the dtors after getBit keeps the vtables in
AudioWaveUtility.

* fix: restore fork-point iplCSMtx string pooling

Moving "MTX34" into a static const array put it in .sdata2 and left the
pooled .sdata copy to be dead-stripped, shifting both sections.

* fix: share tiGUIManager's named 0.0f constant

drawLine_ and PaneComponent::contain now load lbl_81694EE8, as in the
original, instead of emitting their own 0.0f ahead of it in .sdata2.

* fix: force-active unreferenced iplDate and WDScan data

MWLD dead-strips scene::padding (the 0x10 bytes after Date::mscMaxDate)
and the unreferenced WDScan .sdata2 bytes lbl_81695063/lbl_81695067,
which shifted .bss and .sdata2.

* fix: unlink eggAudioExpMgr

MWCC emits the @52 calc thunk ahead of the @52 dtor thunk, but the
original has them the other way round, which swaps two vtable entries.
Link the original object until the order is matched.

* fix: shrink Calendar .data padding now that EventHandler has a vtable

With gui::EventHandler no longer novtable, its 0x18-byte vtable fills most
of the gap after __vt__Q33ipl5scene8Calendar; keep one 4-byte pad.
2026-09-27 23:26:31 -05:00

133 lines
4.7 KiB
C++

#ifndef IPL_CDB_MANAGER_H
#define IPL_CDB_MANAGER_H
#include <revolution/cdb.h>
#include <revolution/nwc24.h>
#include <revolution/os.h>
#include "system/RIPL_BoardRecord.h"
#include "system/iplSDVFWorker.h"
#include "iplMath.h"
#include "utility/iplLock.h"
#include <egg/core.h>
namespace ipl {
namespace cdb {
class Manager {
public:
static const int UNKNOWN_VALUE;
Manager(EGG::Heap* heap);
void closeDatabase();
BOOL createNewRecord(const char* recordName, const char* recordFileType, const OSCalendarTime* dateTime, u32* gameCode, u16* makerCode,
const math::VEC2& recordPos, u32 recordFlags, const NWC24FriendAddr& addr, u16 addrType, u16 noReplyFlag,
const wchar_t* titleText, const wchar_t* bodyText, const void* faceData, const void** attachData, u32* attachSize,
RBRAttachmentType* attachType);
u8* makeBuffer(const math::VEC2& recordPos, u32 recordFlags, const NWC24FriendAddr& addr, u16 addrType, u16 noReplyFlag,
const wchar_t* titleText, const wchar_t* bodyText, const void* faceData, const void** attachData, u32* attachSize,
RBRAttachmentType* attachType, u32* bufferSize);
BOOL writeRecord(CDBRecord* record, const math::VEC2& recordPos, u32 recordFlags, const NWC24FriendAddr& addr, u16 addrType,
u16 noReplyFlag, const wchar_t* titleText, const wchar_t* bodyText, const void* faceData, const void** attachData,
u32* attachSize, RBRAttachmentType* attachType);
BOOL createAtOnce(CDBRecord* record, const char* recordName, const char* recordFileType, u32* gameCode, u16* makerCode,
const OSCalendarTime* dateTime, u8* buffer, u32 bufferSize);
BOOL deleteRecord(CDBRecordKey* recordKey);
BOOL isValidHeader(const RBRHeader* header);
BOOL isValidType(const char* text);
BOOL isTxtValidType(const char* text);
u32 calcCRC(const RBRHeader* header);
BOOL isOverFlow() const;
BOOL isUnderFlow() const;
BOOL findByKey(CDBRecord* record, CDBRecordKey* recordKey);
BOOL search(const CDBDate& begin, const CDBDate& end, CDBSearchDirection searchDirection, CDBRecordLocation recordLocation, int unk2,
CDBSearchRecordCB searchRecordCB, void* searchRecordWork);
BOOL getDataSize(CDBRecord* record, u32* recordDataSize);
BOOL getCDBId(CDBRecord* record, CDBId* recordCDBId);
BOOL open(CDBRecord* record);
BOOL read(CDBRecord* record, void* buffer, u32 readSize);
BOOL write(CDBRecord* record, void* buffer, u32 writeSize);
BOOL seek(CDBRecord* record, s32 offset, CDBSeek seekOrigin);
BOOL close(CDBRecord* record);
BOOL remove(CDBRecord* record);
void startSDProc();
void terminateSDProc();
BOOL mountSD();
BOOL unmountSD();
void unused() { utility::autoMutexLock lock(mMutex); }
void unused2() { utility::autoMutexLock lock(mMutex); }
void mountSD_safe() {
if (!mbSDMounted) {
mountSD();
}
}
void unmountSD_safe() {
if (mbSDMounted) {
unmountSD();
}
}
bool isSDMounted() { return mbSDMounted; }
BOOL backupToSD(CDBRecord* record);
BOOL cleanUpEmptyDirectories(CDBRecordLocation recordLocation);
CDBErr getCDBResult() { return mCDBResult; }
void getFreeSize(u32* freeSize = NULL);
SDVFWorker* getSDWorker() { return &mSDVFWorker; }
private:
BOOL error_handling(CDBErr err, int line);
int mCDBFreeSize; // 0x00
CDBErr mCDBResult; // 0x04
CDBDatabase mDatabase; // 0x08
bool mbSDMounted; // 0x14
SDVFWorker mSDVFWorker; // 0x18
u8* mpSDVFWork; // 0x1C
OSMutex mMutex; // 0x20
u8 unk_0x38;
u8 unk_0x39;
};
class auto_closer {
public:
auto_closer(Manager* mgr, CDBRecord* record) : mpCDBMgr(mgr), mpRecord(record) {}
~auto_closer() { mpCDBMgr->close(mpRecord); }
private:
Manager* mpCDBMgr; // 0x00
CDBRecord* mpRecord; // 0x04
};
} // namespace cdb
} // namespace ipl
#endif // IPL_CDB_MANAGER_H