resonance 1.0.1
Loading...
Searching...
No Matches
RndAsyncLoader Class Reference

Request to load one renderer file in the background. More...

#include <asyncloader.h>

Public Member Functions

 RndAsyncLoader ()
 Prepare an empty request with no directory or file.
 RndAsyncLoader (const HxStr &directory, const HxStr &file, int nZone)
 Prepare a load request.
 ~RndAsyncLoader ()
 Release the request and any partially loaded data.
void Enqueue ()
 Add this request to the load queue.
void Cancel ()
 Abandon this request.
void Restart (const HxStr &directory, const HxStr &file)
 Abandon this request and point it at another file.
void Unload ()
 Abandon this request and release everything it has loaded, leaving it ready to start again.
int Poll (float *pfProgress)
 Test whether this request has finished and report how far it has advanced.

Static Public Member Functions

static void * operator new (size_t nSize)
 Allocate a request under the tag RndAsyncLoader.
static void operator delete (void *pBlock)
 Release a request under the tag RndAsyncLoader.
static void PollAsyncLoads ()
 Advance every queued load request.

Public Attributes

std::list< Rnd::Object * > mObjects
 The objects the request has produced so far.
std::list< Rnd::Drawable * > mDrawables
 Drawables the container load produced.
int mPending
 Starts set and reports no progress while it stays set.

Detailed Description

Request to load one renderer file in the background.

The class is not polymorphic and has no RTTI, so its title is inferred. A request is constructed with the directory and file to load, then enqueued. Callers advance the queue with PollAsyncLoads() and test the individual request with Poll() until it reports completion.

The object is 0x2c bytes. The constructor builds three std::list members at +0x00, +0x04, and +0x08, each of which takes a 0x10-byte sentinel; that bounds their element at 8 bytes or less, so all three are lists of pointers rather than of records. The list at +0x00 stores the objects the request has produced so far, which is what Poll() counts and what RndAsyncLoader::HarvestLoadedObjects() fills. Everything from +0x0c on is declared below. The three flag titles are inferred from their initial values and from the order Poll() tests them in.

Constructor & Destructor Documentation

◆ RndAsyncLoader() [1/2]

RndAsyncLoader::RndAsyncLoader ( )

Prepare an empty request with no directory or file.

The request starts pending, with its file not read and its textures not finished, and with no zone. The image lists no caller for the out-of-line body.

Ghidra address:
NTSC-U/C: 0x003f7e50
Ghidra address:
PAL: 0x00430688

◆ RndAsyncLoader() [2/2]

RndAsyncLoader::RndAsyncLoader ( const HxStr & directory,
const HxStr & file,
int nZone )

Prepare a load request.

Parameters
directoryThe directory to load from.
fileThe file to load.
nZoneThe zone PollAsyncLoads() selects while it reads the objects, or kNoZone.
Ghidra address:
NTSC-U/C: 0x003f7c00
Ghidra address:
PAL: 0x00430428

◆ ~RndAsyncLoader()

RndAsyncLoader::~RndAsyncLoader ( )

Release the request and any partially loaded data.

Ghidra address:
NTSC-U/C: 0x003f8178
Ghidra address:
PAL: 0x004309b8

Member Function Documentation

◆ Enqueue()

void RndAsyncLoader::Enqueue ( )

Add this request to the load queue.

A request already in either queue logs an internal error with its directory and file and is not added again. The first request resolves g_nRndLoaderZone from the zone "rndfile". The request is then marked not pending, not read, and not finished, and appended to gPendingRndFiles.

Ghidra address:
NTSC-U/C: 0x003f8308
Ghidra address:
PAL: 0x00430b68

◆ Cancel()

void RndAsyncLoader::Cancel ( )

Abandon this request.

A request whose file has been read is not affected. Otherwise its read is cancelled and its entry removed from gInProgressRndFiles, and it is removed from gPendingRndFiles.

Ghidra address:
NTSC-U/C: 0x003f8030
Ghidra address:
PAL: 0x00430870

◆ Restart()

void RndAsyncLoader::Restart ( const HxStr & directory,
const HxStr & file )

Abandon this request and point it at another file.

Runs Cancel(), replaces the directory and the file, and marks the request pending, not read, and not finished. Unlike Unload() it releases nothing that was already loaded. The image lists no caller, and the title is inferred.

Parameters
directoryThe directory to load from.
fileThe file to load.
Ghidra address:
NTSC-U/C: 0x003fc708
Ghidra address:
PAL: 0x00435108

◆ Unload()

void RndAsyncLoader::Unload ( )

Abandon this request and release everything it has loaded, leaving it ready to start again.

Runs Cancel(), then, unless the request is still pending, deletes every object in mLoadedObjects through its destructor, clears the three lists, and marks the request pending, not read, and not finished. The destructor runs it first, and Renderer::UnloadCommon() runs it before each delete as well. The title is inferred.

Ghidra address:
NTSC-U/C: 0x003f8240
Ghidra address:
PAL: 0x00430aa0

◆ operator new()

void * RndAsyncLoader::operator new ( size_t nSize)
inlinestatic

Allocate a request under the tag RndAsyncLoader.

Every new-expression open-codes the call.

Parameters
nSizeThe object size the compiler supplies.
Returns
The block.

◆ operator delete()

void RndAsyncLoader::operator delete ( void * pBlock)
inlinestatic

Release a request under the tag RndAsyncLoader.

The deleting branch of the destructor open-codes the call.

Parameters
pBlockThe block.

◆ Poll()

int RndAsyncLoader::Poll ( float * pfProgress)

Test whether this request has finished and report how far it has advanced.

The fraction is the proportion of the textures in mObjects whose mip levels have all arrived, each polled once through Rnd::Tex::PollAsyncMips(). A request still pending, or one whose file has not been read, reports 0. A request already marked finished reports 1, and one whose textures are all loaded is marked finished.

Parameters
pfProgressReceives a fraction between 0 and 1.
Returns
Non-zero once the request is complete.
Ghidra address:
NTSC-U/C: 0x003f8fc0
Ghidra address:
PAL: 0x00431908

◆ PollAsyncLoads()

void RndAsyncLoader::PollAsyncLoads ( )
static

Advance every queued load request.

Runs with g_nRndLoaderZone selected and restores the previous zone on return. The zone is reset when requests are waiting and no read is in flight. Each waiting request then has gen/<file>.gz under its directory read into a block of that zone and moves to gInProgressRndFiles, until a file does not fit. A file of length 0 raises "RndAsyncLoader::Poll(): couldn't find: %s".

The reads are then collected in issue order. The first one still in flight stops the collection. A failed read logs "ERROR reading RND file async: %s:%s!!" and is dropped. A finished read selects the request's zone, loads the objects through Rnd::TheManager, marks the file read, and ends the collection. Only one file is loaded per call.

Ghidra address:
NTSC-U/C: 0x003f8930
Ghidra address:
PAL: 0x00431190

Member Data Documentation

◆ mObjects

std::list<Rnd::Object *> RndAsyncLoader::mObjects

The objects the request has produced so far.

+0x00

Poll() counts it and RndAsyncLoader::HarvestLoadedObjects() fills it. Public because MetFreqMakerAssetManager::GetLoadedObjects() and MetFreqMakerAssetManager::PollLoad() copy it directly, and the image has no accessor.

◆ mDrawables

std::list<Rnd::Drawable *> RndAsyncLoader::mDrawables

Drawables the container load produced.

MetScreen::SetShowing() copies the list and shows or hides every entry, which is what fixes the element as a drawable rather than a bare object. Public because that read comes from outside the hierarchy and the image has no accessor to route it through. A friend declaration fits the image equally well. The member is declared between mObjects and the private list after it so that the recovered order, and therefore the recovered layout, is preserved. +0x04

◆ mPending

int RndAsyncLoader::mPending

Starts set and reports no progress while it stays set.

+0x1c

Public because MetRenderer's loader routines at 0x00371270 and 0x00371438 read it directly before Enqueue(), and the image has no accessor for it.


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