resonance 1.0.1
Loading...
Searching...
No Matches
Rnd::Manager Class Reference

Registry of every loaded renderer object, and of every class a .rnd file may instantiate. More...

#include <manager.h>

Public Member Functions

 Manager ()
 Construct an empty registry.
 ~Manager ()
 Destroy the registry.
bool Contains (const Object *pObject)
 Report whether an object is registered, by identity rather than by name.
void Init ()
 Register the profile timers and the loadable renderer classes.
void RegisterClass (const HxStr &name, ClassFactory pfnCreate)
 Pair a type name with the factory that builds it.
Object * Create (const HxStr &className, const HxStr &objectName)
 Build one instance of a registered class.
Object * ResolveAndLinkObject (Object *pSource, const HxStr &prefix, unsigned nFlags, int bRecurse, int bLink)
 Clone an object under a prefixed name, optionally with its descendants and its parents.
void RemapLegacyClassName (HxStr &name)
 Rewrite a type name that a file older than version 3 wrote.
void Read (Stream &stream)
 Read a .rnd file's object table from stream.
void Write (Stream &stream)
 Write the object table to stream.
void LoadFile (const HxStr &path)
 Open a .rnd file by path and read it.
void SaveFile (const HxStr &path)
 Write the object table to a .rnd file by path.
Object * Find (const HxStr &name)
 Resolve a loaded object by name.
void DumpText (Dbg &sink)
 Write the registry and every object in it to sink.
void DeleteLoadedObjects ()
 Destroy every registered object that a file created.

Public Attributes

std::map< HxStr, Object * > mObjects
std::list< Object * > mLoaded
std::list< Object * > mMergeObjects

Detailed Description

Registry of every loaded renderer object, and of every class a .rnd file may instantiate.

The class emits no RTTI descriptor, so it declares no virtual. Its title is settled all the same, because the destructor at 0x00520348 passes the literal "Rnd::Manager" at 0x00826e98 to OperatorDeleteOverride() as the tag for its own storage. Every other tag the renderer frees under is a class name the RTTI also includes, "Rnd::Button", "Rnd::Font", "Rnd::Mat", "Rnd::Mesh", "Rnd::Movie", and eleven more, so the vocabulary is the class-name vocabulary and this entry belongs to it. No embedded __FILE__ corroborates it, because the whole image holds exactly one source path, C:/FREQ/src/rndartt/abitmap.h.

The object is 0x20 bytes, four members of 0x0c, 0x04, 0x04, and 0x0c. The highest store the constructor makes is the comparator byte of mClasses at +0x1c, and the four-member layout is what fills the rest.

The destructor destroys the members in reverse declaration order, mClasses, mMergeObjects, mLoaded, and then mObjects, before the tagged free. That order is the evidence for the member order declared below.

0x0051fe58 is library code rather than source. It is mClasses.find(), which Read() calls twice and Create() calls once.

Every Rnd::Object registers itself in mObjects on construction and erases that entry on destruction, so Find() resolves any live object by name.

These are the twenty-two classes Init() registers, with the factory for each. The first column is the type name as it appears in a .rnd file.

Name Factory Name Factory
Arena 0x005bba98 Mat 0x004dbc80
Blur 0x004c34e0 MatAnim 0x004dcb00
Button 0x00534678 Mesh 0x00492f50
Cam 0x004b23e0 MeshAnim 0x00493a00
Environ 0x00519278 Movie 0x005d20b8
Font 0x004cefe0 MultiMesh 0x004ebb58
Generator 0x0045e300 ParticleSys 0x0052b6d8
Light 0x00544828 ParticleSysAnim 0x0052c180
LightAnim 0x005452d0 String 0x004bf440
Text 0x004cf770 Tex 0x004e7770
TransAnim 0x004fbf70 Tunnel 0x00476468

Rnd::View is absent from the table, and Read() is the reason. Read() resolves each file entry by object name through mObjects before it consults the registry, and it compares the class name of an object it already has against the literal "View" at 0x00827268. A scene root is therefore recognised rather than built by name, which is also why the factory at 0x004e2088 has no reference anywhere in the image.

The format version this build writes is 6, and Read() accepts 6 and below.

Constructor & Destructor Documentation

◆ Manager()

Rnd::Manager::Manager ( )

Construct an empty registry.

The body default-constructs the four members and nothing else.

Ghidra address:
NTSC-U/C: 0x005200c0
Ghidra address:
PAL: 0x00560618

◆ ~Manager()

Rnd::Manager::~Manager ( )

Destroy the registry.

The members are destroyed in reverse declaration order. The deleting variant then frees the storage under the tag "Rnd::Manager".

Ghidra address:
NTSC-U/C: 0x00520348
Ghidra address:
PAL: 0x005608a0

Member Function Documentation

◆ Contains()

bool Rnd::Manager::Contains ( const Object * pObject)

Report whether an object is registered, by identity rather than by name.

Walks mObjects in key order and compares each value with pObject. No call site survives in the shipped program, and the name is inferred.

Parameters
pObjectThe object to look for.
Returns
True when some entry holds pObject.
Ghidra address:
NTSC-U/C: 0x005199d8
Ghidra address:
PAL: 0x00559d88

◆ Init()

void Rnd::Manager::Init ( )

Register the profile timers and the loadable renderer classes.

The six timers "callback", "anim", "updateworldxfm", "draw", "swap", and "frame" become records 14 through 19 of the 0x14-byte timer table addressed by *(0x00720378), each name assigned to the HxStr at record + 0x08. The twenty-two class registrations listed above follow, each passing a static HxStr that a static initialiser built from a literal.

Ghidra address:
NTSC-U/C: 0x00519bb8
Ghidra address:
PAL: 0x00559f88

◆ RegisterClass()

void Rnd::Manager::RegisterClass ( const HxStr & name,
ClassFactory pfnCreate )

Pair a type name with the factory that builds it.

A name already registered has its factory overwritten.

Parameters
nameThe type name a .rnd file writes.
pfnCreateThe factory for that name.
Ghidra address:
NTSC-U/C: 0x00519a98
Ghidra address:
PAL: 0x00559e48

◆ Create()

Object * Rnd::Manager::Create ( const HxStr & className,
const HxStr & objectName )

Build one instance of a registered class.

An unregistered type name reports "Class %s is unregistered" and yields null.

Parameters
classNameThe type name a .rnd file wrote.
objectNameThe object name for the new instance.
Returns
The new object, or null when the type name is unregistered.
Ghidra address:
NTSC-U/C: 0x005205b0
Ghidra address:
PAL: 0x00560b08

◆ ResolveAndLinkObject()

Object * Rnd::Manager::ResolveAndLinkObject ( Object * pSource,
const HxStr & prefix,
unsigned nFlags,
int bRecurse,
int bLink )

Clone an object under a prefixed name, optionally with its descendants and its parents.

The clone is created from the source's class, named with prefix followed by the source's name, and copied from the source with nFlags. mLoaded is then left holding the clone alone. With bRecurse set, every animation, collision, draw, and transform descendant of the source is cloned the same way, without recursing further, every clone's references to a source object are redirected to that object's clone, and mLoaded is left holding the source's clone followed by every descendant's. With bLink set, the clone joins each of the source's parents in the relation the parent has with the source. ScrollingList clones its rows through it.

Parameters
pSourceThe object to clone.
prefixThe prefix for the clone's name and every descendant clone's.
nFlagsThe copy flags.
bRecurseNon-zero to clone the descendants.
bLinkNon-zero to attach the clone to the source's parents.
Returns
The clone, or null when the source's class cannot be created.
Ghidra address:
NTSC-U/C: 0x0051a428
Ghidra address:
PAL: 0x0055a820

◆ RemapLegacyClassName()

void Rnd::Manager::RemapLegacyClassName ( HxStr & name)

Rewrite a type name that a file older than version 3 wrote.

Seven names were rewritten across four format revisions, and each rewrite applies only to a file below the revision that introduced it. The version comes from g_nRndManagerFileVersion rather than from an argument.

Below version Old name New name
3 AnimObject Animatable
3 DrawObject Drawable
3 CollideObject Collideable
3 TransObject Transformable
4 DrawRect Sprite
5 TexMovie Movie
6 MeshGenerator Generator

The four mix-in rewrites are mutually exclusive, because the first that matches skips the other three. The last three are each tested on their own, so a file below version 4 runs all four gates in turn.

Two of the old type names do not identify a class in the shipped registry. The registry has no DrawRect, and TexMovie is the earlier type name of Rnd::Movie. That earlier type name is what makes a movie the texture-streaming class it is.

Parameters
nameThe type name to rewrite in place.
Ghidra address:
NTSC-U/C: 0x0051be08
Ghidra address:
PAL: 0x0055c2c8

◆ Read()

void Rnd::Manager::Read ( Stream & stream)

Read a .rnd file's object table from stream.

The first word is the file version, which lands in g_nRndManagerFileVersion for every class reached during the load to consult. A version of 7 or above reports "Can't load new Manager" and abandons the load. The second word is the object count, and mLoaded and mMergeObjects are emptied before the entries are read.

Each entry is a class name and an object name, both NUL-terminated, followed from file version 1 by one flag byte. RemapLegacyClassName() rewrites the class name. Every eighth entry calls g_pfnLongOperationDrawProc, counted in g_nRndManagerLoadFrameCounter.

An existing object of the incoming name is reused. Otherwise Create() builds one and it is appended to mLoaded. A class name absent from the registry reports "Failed to create object %s of class %s", runs the abort handler, and skips the entry.

A reused object with mInternal set is rejected. Otherwise it is accepted when its class name matches the incoming one, or when its class name is "View" and the incoming one is "Animatable", "Transformable", "Drawable", or "Collideable". A rejection reports "Can't merge object %s" and abandons the load. An accepted object whose mMerge is set is appended to mMergeObjects.

Each object is recorded with its mMerge as the table pass found it. An object whose mMerge was set then takes the entry's flag byte, and one whose mMerge was clear is not changed.

A second pass visits the recorded objects in table order and calls g_pfnLongOperationDrawProc before each. An object recorded with mMerge set runs Load() on its record, and the record of one recorded with mMerge clear is skipped. From file version 2 each record ends with the marker 0xdeaddead, and after each record, loaded or skipped, the pass reads forward through the next marker. A file below version 2 has no marker. The pass skips such a record by building a throwaway object of the same class under the name "__temp__", loading the record into it, and destroying it.

Parameters
streamThe stream to read from.
Ghidra address:
NTSC-U/C: 0x0051b450
Ghidra address:
PAL: 0x0055b888

◆ Write()

void Rnd::Manager::Write ( Stream & stream)

Write the object table to stream.

Walks mObjects in key order and collects every object whose mInternal is clear, so an object the renderer created is never written back. The collected list is then partitioned four times, each call moving one class to the front, in the order Font, Mat, Tex, TransAnim; the emitted order therefore starts TransAnim, Tex, Mat, Font and continues with everything else.

The header is the version word 6, which is the highest Read() accepts, followed by the object count. Each entry is then the object's class name and its own name, each written with its terminator, and one byte of its merge flag. A second pass then has every object Save() its record and follows each record with the marker 0xdeaddead.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x0051aff8
Ghidra address:
PAL: 0x0055b430

◆ LoadFile()

void Rnd::Manager::LoadFile ( const HxStr & path)

Open a .rnd file by path and read it.

A path that fails to open reports "Could not open file: %s", empties the two lists at +0x0c and +0x10, and returns. The stream is a Rnd::FileStream built on the stack.

Parameters
pathThe file to read.
Ghidra address:
NTSC-U/C: 0x00520648
Ghidra address:
PAL: 0x00560ba0

◆ SaveFile()

void Rnd::Manager::SaveFile ( const HxStr & path)

Write the object table to a .rnd file by path.

A path that fails to open for writing reports "Could not open file: %s" and writes nothing. The stream is a Rnd::FileStream built on the stack. The script command that saves a scene is the one caller. The name is inferred from LoadFile().

Parameters
pathThe file to write.
Ghidra address:
NTSC-U/C: 0x005204e8
Ghidra address:
PAL: 0x00560a40

◆ Find()

Object * Rnd::Manager::Find ( const HxStr & name)

Resolve a loaded object by name.

Parameters
nameThe object name as written in the .rnd file.
Returns
The object, or null when no object has that name.
Ghidra address:
NTSC-U/C: 0x00520498
Ghidra address:
PAL: 0x005609f0

◆ DumpText()

void Rnd::Manager::DumpText ( Dbg & sink)

Write the registry and every object in it to sink.

The class registry comes first, as its entry count and then one line per entry. The objects follow, each writing its own description. A dump level below 2 stops after the objects a file created, and a level of 2 or above adds a second section for the objects the renderer created itself.

No call site survives in the shipped program, so the routine is a debugging entry point rather than dead analysis.

Parameters
sinkThe diagnostic sink to write to.
Ghidra address:
NTSC-U/C: 0x0051ad98
Ghidra address:
PAL: 0x0055b1d0

◆ DeleteLoadedObjects()

void Rnd::Manager::DeleteLoadedObjects ( )

Destroy every registered object that a file created.

Scans mObjects from the first key for an object whose mInternal is clear, destroys it, and starts the scan again, until only the objects the renderer created itself remain. Restarting is what makes the scan correct, because destroying an Rnd::Object erases its own entry from mObjects and invalidates the position the scan held.

The title is inferred from the behaviour. No call site survives, and the predicate is the inverse of the one the address was first recorded under.

Ghidra address:
NTSC-U/C: 0x0051bf70
Ghidra address:
PAL: 0x0055c430

Member Data Documentation

◆ mObjects

std::map<HxStr, Object *> Rnd::Manager::mObjects

Name to object. Public because Rnd::Object drives this tree directly from outside the class at three sites, an inlined lower_bound plus insert in its constructor and in SetName() and an inlined erase in its destructor, and the image exposes no accessor that hands the tree out. +0x00

◆ mLoaded

std::list<Object *> Rnd::Manager::mLoaded

Objects the last file load produced. Public because RndAsyncLoader::HarvestLoadedObjects() at 0x003f8460 copies it wholesale into its own request list and then classifies each entry, and the image exposes no accessor. That routine is the only reader of mLoaded and mMergeObjects outside this class. Read() and LoadFile() empty it before a load. +0x0c

◆ mMergeObjects

std::list<Object *> Rnd::Manager::mMergeObjects

Objects whose mMerge is set, appended by Read() as it resolves the object table. Public because RndAsyncLoader::HarvestLoadedObjects() classifies each entry after mLoaded, and the image exposes no accessor. +0x10


The documentation for this class was generated from the following file: