wavelength 1.0.0
Loading...
Searching...
No Matches
RndManager Class Reference

Registry of every live renderer object, of every class a .rnd file may instantiate, and of the texture files being read. More...

#include <rndmanager.h>

Classes

class  ResourceLoader
 Read of one resource file into memory, shared by every reference to the file. More...

Public Types

enum  TextureState { kTextureLoading = 0 , kTextureLoaded = 1 , kTextureUnknown = 2 }
 Results of IsTextureLoaded(). More...
typedef RndObject *(* ClassFactory) (const char *pszName)
 Builds one instance of a registered class.

Public Member Functions

 RndManager ()
 Construct an empty registry.
 ~RndManager ()
 Destroy the registry.
void Init ()
 Register the factory of every class a .rnd file may instantiate.
void PollLoaders (float fBudgetMs)
 Advance the queued loaders until a time budget is spent.
void RemoveLoader (RndLoader *pLoader)
 Remove a loader from the queue.
RndObject * Find (const char *pszName)
 Resolve a live object by name.
std::unique_ptr< RndLoader > AddLoader (const char *pszFile, int nFlags, RndLoader::Callback *pCallback, BinStream *pStream)
 Create a loader for a .rnd file and queue it.
void LoadFile (const char *pszFile)
 Load a .rnd file before the call returns.
void SaveFile (const char *pszFile)
 Write the objects to a .rnd file.
RndObject * Create (const char *pszClass, const char *pszName)
 Create an instance of a registered class.
void Clone (RndObject *pSource, const char *pszPrefix, std::list< RndObject * > *pClones, int nFlags, int bRecurse, int bLink)
 Clone an object under a prefixed name, optionally with its descendants and its parents.
void SortObjects (std::list< RndObject * > &objects)
 Order a list of objects for writing, the textures first and sorted by file, followed by the animations, the materials, the fonts, the texts, the meshes, the blurs, and the rest.
void Write (BinStream &stream)
 Write every object that is not internal as a .rnd file.
const char * ResourcePath (const char *pszFile)
 Report the file to read for a resource.
bool AcquireTexture (const FilePath &path)
 Take a reference on a texture file, starting to read it on the first reference.
void GetResource (const FilePath &path, void **ppData, int *pnSize)
 Wait for a resource file and hand out its data, dropping one reference.
int IsTextureLoaded (const FilePath &path)
 Report whether a texture file finished reading.
void DeleteLoadedObjects ()
 Delete every object a file created, leaving the internal objects.
void ReleaseTexture (const FilePath &path)
 Release the read of a texture file whatever its references.
void ClearResources ()
 Release every resource read.
const std::map< const char *, RndObject *, StrLess > & GetObjects () const
void SetObject (const char *pszName, RndObject *pObject)
 Register an object under a name, replacing any object registered under it.
void RemoveObject (const char *pszName)
 Remove the registration of a name.
void SetClassFactory (const char *pszClass, ClassFactory factory)
 Register the factory that Create() calls for a class.

Static Public Member Functions

static RndObject * NewTunnel (const char *pszName)
 Create a view in place of a tunnel, the factory registered for the class Tunnel.
static const char * ResourceTag (const char *pszFile)
 Report the tag a resource file's buffer is billed to, from the file's extension.

Static Public Attributes

static int sRev
 The format version Write() writes and the newest a loader accepts.

Detailed Description

Registry of every live renderer object, of every class a .rnd file may instantiate, and of the texture files being read.

The class has no virtual and no RTTI. Its name is the tag it bills its loaders' storage to, and the RTTI of its nested ResourceLoader records it as the enclosing class.

Member Typedef Documentation

◆ ClassFactory

typedef RndObject *(* RndManager::ClassFactory) (const char *pszName)

Builds one instance of a registered class.

Parameters
pszNameThe object name for the new instance.
Returns
The new object.

Member Enumeration Documentation

◆ TextureState

Results of IsTextureLoaded().

Enumerator
kTextureLoading 

The file is still being read.

kTextureLoaded 

The file is in memory.

kTextureUnknown 

No reference on the file exists.

Constructor & Destructor Documentation

◆ RndManager()

RndManager::RndManager ( )

Construct an empty registry.

Ghidra address:
NTSC-U/C: 0x0038f578
Ghidra address:
PAL: 0x003fdc80

◆ ~RndManager()

RndManager::~RndManager ( )

Destroy the registry.

Ghidra address:
NTSC-U/C: 0x0038f748
Ghidra address:
PAL: 0x003fde50

Member Function Documentation

◆ Init()

void RndManager::Init ( )

Register the factory of every class a .rnd file may instantiate.

The class Tunnel is registered with NewTunnel(). The current camera is cleared.

Ghidra address:
NTSC-U/C: 0x00236800
Ghidra address:
PAL: 0x0023f380

◆ PollLoaders()

void RndManager::PollLoaders ( float fBudgetMs)

Advance the queued loaders until a time budget is spent.

The front loader is advanced, and it leaves the queue once it has loaded. The budget is measured on the system clock.

Parameters
fBudgetMsThe time the loads may take, in milliseconds.
Ghidra address:
NTSC-U/C: 0x00237bc0
Ghidra address:
PAL: 0x00240740

◆ RemoveLoader()

void RndManager::RemoveLoader ( RndLoader * pLoader)

Remove a loader from the queue.

The name is inferred.

Parameters
pLoaderThe loader.
Ghidra address:
NTSC-U/C: 0x00237d60
Ghidra address:
PAL: 0x002408e0

◆ Find()

RndObject * RndManager::Find ( const char * pszName)

Resolve a live object by name.

Parameters
pszNameThe object name.
Returns
The object, or null when no object has the name.
Ghidra address:
NTSC-U/C: 0x00237e00
Ghidra address:
PAL: 0x00240980

◆ AddLoader()

std::unique_ptr< RndLoader > RndManager::AddLoader ( const char * pszFile,
int nFlags,
RndLoader::Callback * pCallback,
BinStream * pStream )

Create a loader for a .rnd file and queue it.

A synchronous load first finishes the loads already queued.

Parameters
pszFileThe file.
nFlagsThe RndLoader::Flags of the load.
pCallbackThe callback the loader consults for each object, or null.
pStreamThe stream to read instead of the file, or null.
Returns
The loader, which the caller owns. It leaves the queue when destroyed.
Ghidra address:
NTSC-U/C: 0x00238e98
Ghidra address:
PAL: 0x00241a18

◆ LoadFile()

void RndManager::LoadFile ( const char * pszFile)

Load a .rnd file before the call returns.

The loader is deleted once it finishes, and the objects remain.

Parameters
pszFileThe file.
Ghidra address:
NTSC-U/C: 0x00238fb0
Ghidra address:
PAL: 0x00241b30

◆ SaveFile()

void RndManager::SaveFile ( const char * pszFile)

Write the objects to a .rnd file.

A file that does not open reports "Could not open file: %s" and nothing is written. Otherwise the directory of the file becomes the root that relative paths resolve against.

Parameters
pszFileThe file.
Ghidra address:
NTSC-U/C: 0x00238fe8
Ghidra address:
PAL: 0x00241b68

◆ Create()

RndObject * RndManager::Create ( const char * pszClass,
const char * pszName )

Create an instance of a registered class.

An unregistered class, or a name already in use, yields null.

Parameters
pszClassThe class name a .rnd file writes.
pszNameThe object name for the new instance.
Returns
The new object, or null.
Ghidra address:
NTSC-U/C: 0x002397f8
Ghidra address:
PAL: 0x00242378

◆ Clone()

void RndManager::Clone ( RndObject * pSource,
const char * pszPrefix,
std::list< RndObject * > * pClones,
int nFlags,
int bRecurse,
int bLink )

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

The descendants are cloned without their descendants, and every clone then has each reference to an original replaced with the clone of that original. The pairing assumes that pClones started empty. A linked clone is attached to each parent of the source.

Parameters
pSourceThe object to clone.
pszPrefixThe prefix for the name of every clone.
pClonesReceives the clone first, followed by the clones of the descendants.
nFlagsThe copy flags.
bRecurseNon-zero to clone the descendants.
bLinkNon-zero to attach the clone to the parents of the source.
Ghidra address:
NTSC-U/C: 0x002382b0
Ghidra address:
PAL: 0x00240e30

◆ SortObjects()

void RndManager::SortObjects ( std::list< RndObject * > & objects)

Order a list of objects for writing, the textures first and sorted by file, followed by the animations, the materials, the fonts, the texts, the meshes, the blurs, and the rest.

The name is inferred.

Parameters
objectsThe list to order.
Ghidra address:
NTSC-U/C: 0x00238958
Ghidra address:
PAL: 0x002414d8

◆ Write()

void RndManager::Write ( BinStream & stream)

Write every object that is not internal as a .rnd file.

The file is the version, the class and the name of each object, the files of the textures and the movies, and the record of each object, each record followed by an end marker.

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

◆ NewTunnel()

RndObject * RndManager::NewTunnel ( const char * pszName)
static

Create a view in place of a tunnel, the factory registered for the class Tunnel.

A notice reports the substitution. The name is inferred.

Parameters
pszNameThe object name.
Returns
The view, or null when the name is taken.
Ghidra address:
NTSC-U/C: 0x002367b8
Ghidra address:
PAL: 0x0023f338

◆ ResourceTag()

const char * RndManager::ResourceTag ( const char * pszFile)
static

Report the tag a resource file's buffer is billed to, from the file's extension.

The name is inferred.

Parameters
pszFileThe file.
Returns
"Resource_bmp", "Resource_ipu", or "Resource_other".
Ghidra address:
NTSC-U/C: 0x00239900
Ghidra address:
PAL: 0x00242480

◆ ResourcePath()

const char * RndManager::ResourcePath ( const char * pszFile)

Report the file to read for a resource.

A bitmap is converted to the renderer's texture format and cached. The name is inferred.

Parameters
pszFileThe resource file.
Returns
The file to read, or null when the bitmap cannot be converted.
Ghidra address:
NTSC-U/C: 0x00239970
Ghidra address:
PAL: 0x002424f0

◆ AcquireTexture()

bool RndManager::AcquireTexture ( const FilePath & path)

Take a reference on a texture file, starting to read it on the first reference.

An empty path, or a renderer without textures, is ignored. The name is inferred.

Parameters
pathThe file.
Returns
Whether the file is referenced, false when it could not be opened.
Ghidra address:
NTSC-U/C: 0x00239c90
Ghidra address:
PAL: 0x00242810

◆ GetResource()

void RndManager::GetResource ( const FilePath & path,
void ** ppData,
int * pnSize )

Wait for a resource file and hand out its data, dropping one reference.

A file without a reference is read first. The read is released with its last reference. The name is inferred.

Parameters
pathThe file.
ppDataReceives the data, or null when the file cannot be read.
pnSizeReceives the size of the data in bytes.
Ghidra address:
NTSC-U/C: 0x00239e98
Ghidra address:
PAL: 0x00242a18

◆ IsTextureLoaded()

int RndManager::IsTextureLoaded ( const FilePath & path)

Report whether a texture file finished reading.

The name is inferred.

Parameters
pathThe file.
Returns
A TextureState.
Ghidra address:
NTSC-U/C: 0x0023a080
Ghidra address:
PAL: 0x00242c00

◆ DeleteLoadedObjects()

void RndManager::DeleteLoadedObjects ( )

Delete every object a file created, leaving the internal objects.

The resource reads are released as well.

Ghidra address:
NTSC-U/C: 0x0023a420
Ghidra address:
PAL: 0x00242fa0

◆ ReleaseTexture()

void RndManager::ReleaseTexture ( const FilePath & path)

Release the read of a texture file whatever its references.

The name is inferred.

Parameters
pathThe file.
Ghidra address:
NTSC-U/C: 0x0023a4e0
Ghidra address:
PAL: 0x00243060

◆ ClearResources()

void RndManager::ClearResources ( )

Release every resource read.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x0023a5f0
Ghidra address:
PAL: 0x00243170

◆ GetObjects()

const std::map< const char *, RndObject *, StrLess > & RndManager::GetObjects ( ) const
inline
Returns
The live objects by name.

◆ SetObject()

void RndManager::SetObject ( const char * pszName,
RndObject * pObject )
inline

Register an object under a name, replacing any object registered under it.

Parameters
pszNameThe name, which must outlive the registration.
pObjectThe object.

◆ RemoveObject()

void RndManager::RemoveObject ( const char * pszName)
inline

Remove the registration of a name.

Parameters
pszNameThe name.

◆ SetClassFactory()

void RndManager::SetClassFactory ( const char * pszClass,
ClassFactory factory )
inline

Register the factory that Create() calls for a class.

Parameters
pszClassThe class name a .rnd file writes.
factoryThe factory.

Member Data Documentation

◆ sRev

int RndManager::sRev
static

The format version Write() writes and the newest a loader accepts.

Ghidra address:
NTSC-U/C: 0x003b0a00
Ghidra address:
PAL: 0x0042f898

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