mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 01:07:22 +00:00
M4: Cleanup of dead machine code, deleting of dead machines between scenes
This commit is contained in:
parent
a6929c4882
commit
41d87f2178
@ -213,6 +213,8 @@ void Sections::m4EndScene() {
|
||||
|
||||
conv_unload(conv_get_handle());
|
||||
|
||||
ws_KillDeadMachines();
|
||||
|
||||
//-------------------- DUMP ASSETS AND MINI-ENGINES ------------------
|
||||
// Note machines should always be cleared before anything else
|
||||
ClearWSAssets(_WS_ASSET_MACH, 0, 255);
|
||||
|
@ -682,7 +682,7 @@ void ws_RefreshWoodscriptBuffer(Buffer *cleanBackground, int16 *depth_table,
|
||||
static void cancelAllEngineReqs(machine *m) {
|
||||
globalMsgReq *myGMsg, *tempGMsg;
|
||||
|
||||
if (m->machID == 0xdeaddead) {
|
||||
if (m->machID == DEAD_MACHINE_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -715,7 +715,7 @@ static void cancelAllEngineReqs(machine *m) {
|
||||
|
||||
|
||||
static void shutdownMachine(machine *m) {
|
||||
if (m->machID == 0xdeaddead) {
|
||||
if (m->machID == DEAD_MACHINE_ID) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -737,7 +737,7 @@ static void shutdownMachine(machine *m) {
|
||||
// Clear any existing walk path
|
||||
DisposePath(m->walkPath);
|
||||
|
||||
m->machID = 0xdeaddead;
|
||||
m->machID = DEAD_MACHINE_ID;
|
||||
|
||||
if (m->machName) {
|
||||
m->machName[0] = '\0';
|
||||
@ -750,7 +750,7 @@ static machine *getValidNext(machine *currMachine) {
|
||||
machine *iterMachine = currMachine;
|
||||
if (iterMachine) {
|
||||
while ((iterMachine = iterMachine->next) != nullptr) {
|
||||
if (iterMachine->machID != 0xdeaddead) {
|
||||
if (iterMachine->machID != DEAD_MACHINE_ID) {
|
||||
return iterMachine;
|
||||
}
|
||||
}
|
||||
@ -824,7 +824,7 @@ int32 ws_KillMachines() {
|
||||
// get any next Machine here, not validNext
|
||||
_GWS(firstMachine) = _GWS(firstMachine)->next;
|
||||
|
||||
if (myMachine->machID != 0xdeaddead) {
|
||||
if (myMachine->machID != DEAD_MACHINE_ID) {
|
||||
cancelAllEngineReqs(myMachine);
|
||||
shutdownMachine(myMachine);
|
||||
}
|
||||
@ -845,6 +845,23 @@ int32 ws_KillMachines() {
|
||||
return myBytes;
|
||||
}
|
||||
|
||||
void ws_KillDeadMachines() {
|
||||
machine *myMachine;
|
||||
machine **priorNext = &_GWS(firstMachine);
|
||||
|
||||
// Deallocate all machines that are dead
|
||||
while ((myMachine = *priorNext) != nullptr) {
|
||||
if (myMachine->machID == DEAD_MACHINE_ID) {
|
||||
// Shutdown the dead machine, and unlink it from the machine chain
|
||||
*priorNext = myMachine->next;
|
||||
mem_free(myMachine);
|
||||
|
||||
} else {
|
||||
// Valid machine, skip over
|
||||
priorNext = &myMachine->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is the proc designed to evaluate the instructions of the state machine
|
||||
|
||||
@ -981,7 +998,7 @@ machine *TriggerMachineByHash(int32 myHash, Anim8 *parentAnim8, int32 dataHash,
|
||||
|
||||
// Initialize the identification fields
|
||||
_GWS(machineIDCount)++;
|
||||
if (_GWS(machineIDCount) == 0xdeaddead) {
|
||||
if (_GWS(machineIDCount) == DEAD_MACHINE_ID) {
|
||||
_GWS(machineIDCount)++;
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,8 @@
|
||||
|
||||
namespace M4 {
|
||||
|
||||
#define DEAD_MACHINE_ID 0xdeaddead
|
||||
|
||||
enum {
|
||||
NOSEPICK = 0,
|
||||
STARTWALK = 1,
|
||||
@ -193,6 +195,7 @@ void terminateMachinesByHash(uint32 machHash);
|
||||
void terminateMachineAndNull(machine *&m);
|
||||
bool verifyMachineExists(machine *m);
|
||||
int32 ws_KillMachines();
|
||||
void ws_KillDeadMachines();
|
||||
void ws_StepWhile(machine *m, int32 pcOffset, int32 pcCount);
|
||||
void IntoTheState(machine *m);
|
||||
machine *TriggerMachineByHash(int32 myHash, Anim8 *parentAnim8, int32 dataHash, int32 dataRow, MessageCB CintrMsg, bool debug, const char *machName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user