ref: e1de7bdf07eeb410f734b2de212885bf7de6699e
parent: 4354eb4c578d4536614333615b2edd1c51d71d88
author: levesqu8 <levesqu8@msu.edu>
date: Sun Oct 15 17:27:45 EDT 2017
Save/Load is functional with ZomROTT
--- a/rott/rt_actor.c
+++ b/rott/rt_actor.c
@@ -3634,13 +3634,11 @@
}
extern Queue enemiesToRes;
-extern unsigned int freeSlot;
-//extern STACK s;
+
void AddEnemyToResurrectList(objtype * ob)
{
ob->resurrectAtTime = DetermineTimeUntilEnemyIsResurrected(ob->obclass);
SetReverseDeathState(ob);
- //freeSlot = pop();
enqueue(&enemiesToRes, ob);
}
@@ -3719,10 +3717,10 @@
if (currTime >= actor->resurrectAtTime)
{
- //dequeue(&enemiesToRes, actor);
SD_PlaySoundRTP(SD_PLAYERSPAWNSND, actor->x, actor->y);
SpawnDuringGameWithState (actor->obclass,actor->tilex,actor->tiley,actor->dir, 1, actor->state);
dequeue(&enemiesToRes, actor);
+ gamestate.killcount--;
}
}
@@ -3776,14 +3774,36 @@
void SaveResurrectList(byte ** buffer, int *size)
{
/*
- byte*tptr;
+ //objtype * arrayOfStuff = calloc(sizeof(objtype), enemiesToRes.sizeOfQueue);
- *size = sizeof(enemiesToRes);
+ //memset(arrayOfStuff, 0, enemiesToRes.sizeOfQueue);
+
+ int x;
+
+ node * thingToSave = enemiesToRes.head;
+
+ for (x = 0; x < enemiesToRes.sizeOfQueue; x++)
+ {
+ //objtype * copyOfObject = malloc(sizeof(objtype));
+
+ //objtype * ob = (objtype *) thingToSave->data;
+
+ //memcpy(copyOfObject, ob, sizeof(objtype));
+
+ //arrayOfStuff[x] = *copyOfObject;
+ //thingToSave = thingToSave->next;
+ }
+
+
+
+ byte* tptr;
+
+ *size = sizeof(arrayOfStuff);
*buffer = (byte*)SafeMalloc(*size);
tptr = *buffer;
- memcpy(tptr, enemiesToRes, sizeof(enemiesToRes));
- tptr += sizeof(enemiesToRes);
+ memcpy(tptr, arrayOfStuff, sizeof(*arrayOfStuff));
+ tptr += sizeof(arrayOfStuff);
*/
}
--- a/rott/rt_game.c
+++ b/rott/rt_game.c
@@ -4900,6 +4900,7 @@
extern boolean enableZomROTT;
extern boolean allowBlitzMoreMissileWeps;
extern boolean enableAmmoPickups;
+extern Queue enemiesToRes;
boolean SaveTheGame (int num, gamestorage_t * game)
{
@@ -5174,9 +5175,20 @@
//ZomROTT Stuff
if(enableZomROTT)
{
- SaveResurrectList(&altbuffer, &size);
- StoreBuffer(savehandle,altbuffer,size);
- SafeFree(altbuffer);
+ size = sizeof(int);
+ SafeWrite(savehandle, &enemiesToRes.sizeOfQueue, size);
+
+ int x = 0;
+ node * thingToSave = enemiesToRes.head;
+ size = sizeof(objtype);
+ for (x = 0; x < enemiesToRes.sizeOfQueue; x++)
+ {
+ SafeWrite(savehandle, (objtype *) thingToSave->data, size);
+ thingToSave = thingToSave->next;
+ }
+ //SaveResurrectList(&altbuffer, &size);
+ //StoreBuffer(savehandle,altbuffer,size);
+ //SafeFree(altbuffer);
}
close (savehandle);
@@ -5239,7 +5251,6 @@
//******************************************************************************
-extern objtype* enemiesToRes;
extern unsigned int freeSlot;
boolean LoadTheGame (int num, gamestorage_t * game)
@@ -5566,23 +5577,34 @@
bufptr += size;
- //ZomROTT Stuff
+ //ZomROTT Stuff (rebuild the queue))
if(enableZomROTT)
{
-/*
- enemiesToRes = calloc(sizeof(objtype), gamestate.killtotal);
- memset(enemiesToRes, 0, sizeof(*enemiesToRes));
- size = sizeof(enemiesToRes);
- memcpy(enemiesToRes, bufptr, size);
- bufptr += size;
+ queueInit(&enemiesToRes, sizeof(objtype));
- objtype * findFreeSlotPtr;
- //find index of free
- for (findFreeSlotPtr = &enemiesToRes[0]; findFreeSlotPtr != 0; findFreeSlotPtr++)
+ int origQueueSize = 0;
+
+ size = sizeof(int);
+
+ memcpy(&origQueueSize, bufptr, size);
+ bufptr+=size;
+
+ size = sizeof(objtype);
+
+ int x = 0;
+
+ while(x < origQueueSize)
{
- freeSlot++;
+ objtype * item = (objtype *) malloc(sizeof(objtype));
+
+ memcpy(item, bufptr, size);
+
+ enqueue(&enemiesToRes, item);
+
+ bufptr+=size;
+
+ x++;
}
-*/
}
// Set the viewsize
--- a/rott/rt_main.c
+++ b/rott/rt_main.c
@@ -1857,7 +1857,6 @@
extern boolean enableZomROTT;
-extern int numOfNonGibbedEnemies;
void UpdateGameObjects ( void )
{
int j;