mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 00:40:56 +00:00
Merge commit '3061e3860cd212893e7d08a09223d4e9ad78b204' into Dear_ImGui
This commit is contained in:
commit
fd4680c347
62 changed files with 548 additions and 1268 deletions
|
@ -28,7 +28,6 @@
|
||||||
#include "multivoc.h"
|
#include "multivoc.h"
|
||||||
#include "mutex.h"
|
#include "mutex.h"
|
||||||
#include "sdl_inc.h"
|
#include "sdl_inc.h"
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
SDLErr_Warning = -2,
|
SDLErr_Warning = -2,
|
||||||
|
|
|
@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "mmulti.h"
|
#include "mmulti.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "renderlayer.h"
|
#include "renderlayer.h"
|
||||||
#include "vfs.h"
|
|
||||||
#include "fx_man.h"
|
#include "fx_man.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "common_game.h"
|
#include "common_game.h"
|
||||||
|
|
|
@ -1278,374 +1278,11 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dbSaveMap(const char *pPath, int nX, int nY, int nZ, short nAngle, short nSector)
|
|
||||||
{
|
|
||||||
char sMapExt[BMAX_PATH];
|
|
||||||
int16_t tpskyoff[256];
|
|
||||||
int nSpriteNum;
|
|
||||||
psky_t *pSky = tileSetupSky(0);
|
|
||||||
gSkyCount = 1<<pSky->lognumtiles;
|
|
||||||
gMapRev++;
|
|
||||||
nSpriteNum = 0;
|
|
||||||
strcpy(sMapExt, pPath);
|
|
||||||
ChangeExtension(sMapExt, ".MAP");
|
|
||||||
int nSize = sizeof(MAPSIGNATURE)+sizeof(MAPHEADER);
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
nSize += sizeof(MAPHEADER2);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < gSkyCount; i++)
|
|
||||||
tpskyoff[i] = pSky->tileofs[i];
|
|
||||||
nSize += gSkyCount*sizeof(tpskyoff[0]);
|
|
||||||
nSize += sizeof(sectortype)*numsectors;
|
|
||||||
for (int i = 0; i < numsectors; i++)
|
|
||||||
{
|
|
||||||
if (sector[i].extra > 0)
|
|
||||||
{
|
|
||||||
nSize += nXSectorSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nSize += sizeof(walltype)*numwalls;
|
|
||||||
for (int i = 0; i < numwalls; i++)
|
|
||||||
{
|
|
||||||
if (wall[i].extra > 0)
|
|
||||||
{
|
|
||||||
nSize += nXWallSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < kMaxSprites; i++)
|
|
||||||
{
|
|
||||||
if (sprite[i].statnum < kMaxStatus)
|
|
||||||
{
|
|
||||||
nSpriteNum++;
|
|
||||||
if (sprite[i].extra > 0)
|
|
||||||
{
|
|
||||||
nSize += nXSpriteSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nSize += sizeof(spritetype)*nSpriteNum;
|
|
||||||
nSize += 4;
|
|
||||||
char *pData = (char*)Xmalloc(nSize);
|
|
||||||
IOBuffer IOBuffer1 = IOBuffer(nSize, pData);
|
|
||||||
MAPSIGNATURE header;
|
|
||||||
memcpy(&header, "BLM\x1a", 4);
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
header.version = 0x700;
|
|
||||||
byte_1A76C7 = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
header.version = 0x603;
|
|
||||||
byte_1A76C7 = 0;
|
|
||||||
}
|
|
||||||
IOBuffer1.Write(&header, sizeof(header));
|
|
||||||
MAPHEADER mapheader;
|
|
||||||
mapheader.at0 = B_LITTLE32(nX);
|
|
||||||
mapheader.at4 = B_LITTLE32(nY);
|
|
||||||
mapheader.at8 = B_LITTLE32(nZ);
|
|
||||||
mapheader.atc = B_LITTLE16(nAngle);
|
|
||||||
mapheader.ate = B_LITTLE16(nSector);
|
|
||||||
mapheader.at10 = B_LITTLE16(pSky->lognumtiles);
|
|
||||||
mapheader.at12 = B_LITTLE32(gVisibility);
|
|
||||||
if (byte_1A76C6)
|
|
||||||
{
|
|
||||||
gSongId = 0x7474614d;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gSongId = 0;
|
|
||||||
}
|
|
||||||
mapheader.at16 = B_LITTLE32(gSongId);
|
|
||||||
mapheader.at1a = parallaxtype;
|
|
||||||
mapheader.at1b = gMapRev;
|
|
||||||
mapheader.at1f = B_LITTLE16(numsectors);
|
|
||||||
mapheader.at21 = B_LITTLE16(numwalls);
|
|
||||||
mapheader.at23 = B_LITTLE16(nSpriteNum);
|
|
||||||
if (byte_1A76C7)
|
|
||||||
{
|
|
||||||
dbCrypt((char*)&mapheader, sizeof(MAPHEADER), 'ttaM');
|
|
||||||
}
|
|
||||||
IOBuffer1.Write(&mapheader, sizeof(MAPHEADER));
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
byte_19AE44.at48 = nXSectorSize;
|
|
||||||
byte_19AE44.at44 = nXWallSize;
|
|
||||||
byte_19AE44.at40 = nXSpriteSize;
|
|
||||||
dbCrypt((char*)&byte_19AE44, sizeof(MAPHEADER2), numwalls);
|
|
||||||
IOBuffer1.Write(&byte_19AE44, sizeof(MAPHEADER2));
|
|
||||||
dbCrypt((char*)&byte_19AE44, sizeof(MAPHEADER2), numwalls);
|
|
||||||
}
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
dbCrypt((char*)tpskyoff, gSkyCount*sizeof(tpskyoff[0]), gSkyCount*sizeof(tpskyoff[0]));
|
|
||||||
}
|
|
||||||
IOBuffer1.Write(tpskyoff, gSkyCount*sizeof(tpskyoff[0]));
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
dbCrypt((char*)tpskyoff, gSkyCount*sizeof(tpskyoff[0]), gSkyCount*sizeof(tpskyoff[0]));
|
|
||||||
}
|
|
||||||
for (int i = 0; i < numsectors; i++)
|
|
||||||
{
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
dbCrypt((char*)§or[i], sizeof(sectortype), gMapRev*sizeof(sectortype));
|
|
||||||
}
|
|
||||||
IOBuffer1.Write(§or[i], sizeof(sectortype));
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
dbCrypt((char*)§or[i], sizeof(sectortype), gMapRev*sizeof(sectortype));
|
|
||||||
}
|
|
||||||
if (sector[i].extra > 0)
|
|
||||||
{
|
|
||||||
char pBuffer[nXSectorSize];
|
|
||||||
BitWriter bitWriter(pBuffer, nXSectorSize);
|
|
||||||
XSECTOR* pXSector = &xsector[sector[i].extra];
|
|
||||||
bitWriter.write(pXSector->reference, 14);
|
|
||||||
bitWriter.write(pXSector->state, 1);
|
|
||||||
bitWriter.write(pXSector->busy, 17);
|
|
||||||
bitWriter.write(pXSector->data, 16);
|
|
||||||
bitWriter.write(pXSector->txID, 10);
|
|
||||||
bitWriter.write(pXSector->busyWaveA, 3);
|
|
||||||
bitWriter.write(pXSector->busyWaveB, 3);
|
|
||||||
bitWriter.write(pXSector->rxID, 10);
|
|
||||||
bitWriter.write(pXSector->command, 8);
|
|
||||||
bitWriter.write(pXSector->triggerOn, 1);
|
|
||||||
bitWriter.write(pXSector->triggerOff, 1);
|
|
||||||
bitWriter.write(pXSector->busyTimeA, 12);
|
|
||||||
bitWriter.write(pXSector->waitTimeA, 12);
|
|
||||||
bitWriter.write(pXSector->restState, 1);
|
|
||||||
bitWriter.write(pXSector->interruptable, 1);
|
|
||||||
bitWriter.write(pXSector->amplitude, 8);
|
|
||||||
bitWriter.write(pXSector->freq, 8);
|
|
||||||
bitWriter.write(pXSector->reTriggerA, 1);
|
|
||||||
bitWriter.write(pXSector->reTriggerB, 1);
|
|
||||||
bitWriter.write(pXSector->phase, 8);
|
|
||||||
bitWriter.write(pXSector->wave, 4);
|
|
||||||
bitWriter.write(pXSector->shadeAlways, 1);
|
|
||||||
bitWriter.write(pXSector->shadeFloor, 1);
|
|
||||||
bitWriter.write(pXSector->shadeCeiling, 1);
|
|
||||||
bitWriter.write(pXSector->shadeWalls, 1);
|
|
||||||
bitWriter.write(pXSector->shade, 8);
|
|
||||||
bitWriter.write(pXSector->panAlways, 1);
|
|
||||||
bitWriter.write(pXSector->panFloor, 1);
|
|
||||||
bitWriter.write(pXSector->panCeiling, 1);
|
|
||||||
bitWriter.write(pXSector->Drag, 1);
|
|
||||||
bitWriter.write(pXSector->Underwater, 1);
|
|
||||||
bitWriter.write(pXSector->Depth, 3);
|
|
||||||
bitWriter.write(pXSector->panVel, 8);
|
|
||||||
bitWriter.write(pXSector->panAngle, 11);
|
|
||||||
bitWriter.write(pXSector->unused1, 1);
|
|
||||||
bitWriter.write(pXSector->decoupled, 1);
|
|
||||||
bitWriter.write(pXSector->triggerOnce, 1);
|
|
||||||
bitWriter.write(pXSector->isTriggered, 1);
|
|
||||||
bitWriter.write(pXSector->Key, 3);
|
|
||||||
bitWriter.write(pXSector->Push, 1);
|
|
||||||
bitWriter.write(pXSector->Vector, 1);
|
|
||||||
bitWriter.write(pXSector->Reserved, 1);
|
|
||||||
bitWriter.write(pXSector->Enter, 1);
|
|
||||||
bitWriter.write(pXSector->Exit, 1);
|
|
||||||
bitWriter.write(pXSector->Wallpush, 1);
|
|
||||||
bitWriter.write(pXSector->color, 1);
|
|
||||||
bitWriter.write(pXSector->unused2, 1);
|
|
||||||
bitWriter.write(pXSector->busyTimeB, 12);
|
|
||||||
bitWriter.write(pXSector->waitTimeB, 12);
|
|
||||||
bitWriter.write(pXSector->stopOn, 1);
|
|
||||||
bitWriter.write(pXSector->stopOff, 1);
|
|
||||||
bitWriter.write(pXSector->ceilpal, 4);
|
|
||||||
bitWriter.write(pXSector->offCeilZ, 32);
|
|
||||||
bitWriter.write(pXSector->onCeilZ, 32);
|
|
||||||
bitWriter.write(pXSector->offFloorZ, 32);
|
|
||||||
bitWriter.write(pXSector->onFloorZ, 32);
|
|
||||||
bitWriter.write(pXSector->marker0, 16);
|
|
||||||
bitWriter.write(pXSector->marker1, 16);
|
|
||||||
bitWriter.write(pXSector->Crush, 1);
|
|
||||||
bitWriter.write(pXSector->ceilXPanFrac, 8);
|
|
||||||
bitWriter.write(pXSector->ceilYPanFrac, 8);
|
|
||||||
bitWriter.write(pXSector->floorXPanFrac, 8);
|
|
||||||
bitWriter.write(pXSector->damageType, 3);
|
|
||||||
bitWriter.write(pXSector->floorpal, 4);
|
|
||||||
bitWriter.write(pXSector->floorYPanFrac, 8);
|
|
||||||
bitWriter.write(pXSector->locked, 1);
|
|
||||||
bitWriter.write(pXSector->windVel, 10);
|
|
||||||
bitWriter.write(pXSector->windAng, 11);
|
|
||||||
bitWriter.write(pXSector->windAlways, 1);
|
|
||||||
bitWriter.write(pXSector->dudeLockout, 1);
|
|
||||||
bitWriter.write(pXSector->bobTheta, 11);
|
|
||||||
bitWriter.write(pXSector->bobZRange, 5);
|
|
||||||
bitWriter.write(pXSector->bobSpeed, 12);
|
|
||||||
bitWriter.write(pXSector->bobAlways, 1);
|
|
||||||
bitWriter.write(pXSector->bobFloor, 1);
|
|
||||||
bitWriter.write(pXSector->bobCeiling, 1);
|
|
||||||
bitWriter.write(pXSector->bobRotate, 1);
|
|
||||||
IOBuffer1.Write(pBuffer, nXSectorSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < numwalls; i++)
|
|
||||||
{
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
dbCrypt((char*)&wall[i], sizeof(walltype), gMapRev*sizeof(sectortype) | 0x7474614d);
|
|
||||||
}
|
|
||||||
IOBuffer1.Write(&wall[i], sizeof(walltype));
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
dbCrypt((char*)&wall[i], sizeof(walltype), gMapRev*sizeof(sectortype) | 0x7474614d);
|
|
||||||
}
|
|
||||||
if (wall[i].extra > 0)
|
|
||||||
{
|
|
||||||
char pBuffer[nXWallSize];
|
|
||||||
BitWriter bitWriter(pBuffer, nXWallSize);
|
|
||||||
XWALL* pXWall = &xwall[wall[i].extra];
|
|
||||||
bitWriter.write(pXWall->reference, 14);
|
|
||||||
bitWriter.write(pXWall->state, 1);
|
|
||||||
bitWriter.write(pXWall->busy, 17);
|
|
||||||
bitWriter.write(pXWall->data, 16);
|
|
||||||
bitWriter.write(pXWall->txID, 10);
|
|
||||||
bitWriter.write(pXWall->unused1, 6);
|
|
||||||
bitWriter.write(pXWall->rxID, 10);
|
|
||||||
bitWriter.write(pXWall->command, 8);
|
|
||||||
bitWriter.write(pXWall->triggerOn, 1);
|
|
||||||
bitWriter.write(pXWall->triggerOff, 1);
|
|
||||||
bitWriter.write(pXWall->busyTime, 12);
|
|
||||||
bitWriter.write(pXWall->waitTime, 12);
|
|
||||||
bitWriter.write(pXWall->restState, 1);
|
|
||||||
bitWriter.write(pXWall->interruptable, 1);
|
|
||||||
bitWriter.write(pXWall->panAlways, 1);
|
|
||||||
bitWriter.write(pXWall->panXVel, 8);
|
|
||||||
bitWriter.write(pXWall->panYVel, 8);
|
|
||||||
bitWriter.write(pXWall->decoupled, 1);
|
|
||||||
bitWriter.write(pXWall->triggerOnce, 1);
|
|
||||||
bitWriter.write(pXWall->isTriggered, 1);
|
|
||||||
bitWriter.write(pXWall->key, 3);
|
|
||||||
bitWriter.write(pXWall->triggerPush, 1);
|
|
||||||
bitWriter.write(pXWall->triggerVector, 1);
|
|
||||||
bitWriter.write(pXWall->triggerTouch, 1);
|
|
||||||
bitWriter.write(pXWall->unused2, 2);
|
|
||||||
bitWriter.write(pXWall->xpanFrac, 8);
|
|
||||||
bitWriter.write(pXWall->ypanFrac, 8);
|
|
||||||
bitWriter.write(pXWall->locked, 1);
|
|
||||||
bitWriter.write(pXWall->dudeLockout, 1);
|
|
||||||
bitWriter.write(pXWall->unused3, 4);
|
|
||||||
bitWriter.write(pXWall->unused4, 32);
|
|
||||||
IOBuffer1.Write(pBuffer, nXWallSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int i = 0; i < kMaxSprites; i++)
|
|
||||||
{
|
|
||||||
if (sprite[i].statnum < kMaxStatus)
|
|
||||||
{
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
dbCrypt((char*)&sprite[i], sizeof(spritetype), gMapRev*sizeof(spritetype) | 'ttaM');
|
|
||||||
}
|
|
||||||
IOBuffer1.Write(&sprite[i], sizeof(spritetype));
|
|
||||||
if (byte_1A76C8)
|
|
||||||
{
|
|
||||||
dbCrypt((char*)&sprite[i], sizeof(spritetype), gMapRev*sizeof(spritetype) | 'ttaM');
|
|
||||||
}
|
|
||||||
if (sprite[i].extra > 0)
|
|
||||||
{
|
|
||||||
char pBuffer[nXSpriteSize];
|
|
||||||
BitWriter bitWriter(pBuffer, nXSpriteSize);
|
|
||||||
XSPRITE* pXSprite = &xsprite[sprite[i].extra];
|
|
||||||
bitWriter.write(pXSprite->reference, 14);
|
|
||||||
bitWriter.write(pXSprite->state, 1);
|
|
||||||
bitWriter.write(pXSprite->busy, 17);
|
|
||||||
bitWriter.write(pXSprite->txID, 10);
|
|
||||||
bitWriter.write(pXSprite->rxID, 10);
|
|
||||||
bitWriter.write(pXSprite->command, 8);
|
|
||||||
bitWriter.write(pXSprite->triggerOn, 1);
|
|
||||||
bitWriter.write(pXSprite->triggerOff, 1);
|
|
||||||
bitWriter.write(pXSprite->wave, 2);
|
|
||||||
bitWriter.write(pXSprite->busyTime, 12);
|
|
||||||
bitWriter.write(pXSprite->waitTime, 12);
|
|
||||||
bitWriter.write(pXSprite->restState, 1);
|
|
||||||
bitWriter.write(pXSprite->Interrutable, 1);
|
|
||||||
bitWriter.write(pXSprite->unused1, 2);
|
|
||||||
bitWriter.write(pXSprite->respawnPending, 2);
|
|
||||||
bitWriter.write(pXSprite->unused2, 1);
|
|
||||||
bitWriter.write(pXSprite->lT, 1);
|
|
||||||
bitWriter.write(pXSprite->dropMsg, 8);
|
|
||||||
bitWriter.write(pXSprite->Decoupled, 1);
|
|
||||||
bitWriter.write(pXSprite->triggerOnce, 1);
|
|
||||||
bitWriter.write(pXSprite->isTriggered, 1);
|
|
||||||
bitWriter.write(pXSprite->key, 3);
|
|
||||||
bitWriter.write(pXSprite->Push, 1);
|
|
||||||
bitWriter.write(pXSprite->Vector, 1);
|
|
||||||
bitWriter.write(pXSprite->Impact, 1);
|
|
||||||
bitWriter.write(pXSprite->Pickup, 1);
|
|
||||||
bitWriter.write(pXSprite->Touch, 1);
|
|
||||||
bitWriter.write(pXSprite->Sight, 1);
|
|
||||||
bitWriter.write(pXSprite->Proximity, 1);
|
|
||||||
bitWriter.write(pXSprite->unused3, 2);
|
|
||||||
bitWriter.write(pXSprite->lSkill, 5);
|
|
||||||
bitWriter.write(pXSprite->lS, 1);
|
|
||||||
bitWriter.write(pXSprite->lB, 1);
|
|
||||||
bitWriter.write(pXSprite->lC, 1);
|
|
||||||
bitWriter.write(pXSprite->DudeLockout, 1);
|
|
||||||
bitWriter.write(pXSprite->data1, 16);
|
|
||||||
bitWriter.write(pXSprite->data2, 16);
|
|
||||||
bitWriter.write(pXSprite->data3, 16);
|
|
||||||
bitWriter.write(pXSprite->goalAng, 11);
|
|
||||||
bitWriter.write(pXSprite->dodgeDir, 2);
|
|
||||||
bitWriter.write(pXSprite->locked, 1);
|
|
||||||
bitWriter.write(pXSprite->medium, 2);
|
|
||||||
bitWriter.write(pXSprite->respawn, 2);
|
|
||||||
bitWriter.write(pXSprite->data4, 16);
|
|
||||||
bitWriter.write(pXSprite->unused4, 6);
|
|
||||||
bitWriter.write(pXSprite->lockMsg, 8);
|
|
||||||
bitWriter.write(pXSprite->health, 12);
|
|
||||||
bitWriter.write(pXSprite->dudeDeaf, 1);
|
|
||||||
bitWriter.write(pXSprite->dudeAmbush, 1);
|
|
||||||
bitWriter.write(pXSprite->dudeGuard, 1);
|
|
||||||
bitWriter.write(pXSprite->dudeFlag4, 1);
|
|
||||||
bitWriter.write(pXSprite->target, 16);
|
|
||||||
bitWriter.write(pXSprite->targetX, 32);
|
|
||||||
bitWriter.write(pXSprite->targetY, 32);
|
|
||||||
bitWriter.write(pXSprite->targetZ, 32);
|
|
||||||
bitWriter.write(pXSprite->burnTime, 16);
|
|
||||||
bitWriter.write(pXSprite->burnSource, 16);
|
|
||||||
bitWriter.write(pXSprite->height, 16);
|
|
||||||
bitWriter.write(pXSprite->stateTimer, 16);
|
|
||||||
IOBuffer1.Write(pBuffer, nXSpriteSize);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unsigned int nCRC = Bcrc32(pData, nSize-4, 0);
|
|
||||||
IOBuffer1.Write(&nCRC, 4);
|
|
||||||
int nHandle = Bopen(sMapExt, BO_BINARY|BO_TRUNC|BO_CREAT|BO_WRONLY, BS_IREAD|BS_IWRITE);
|
|
||||||
if (nHandle == -1)
|
|
||||||
{
|
|
||||||
initprintf("Couldn't open \"%s\" for writing: %s\n", sMapExt, strerror(errno));
|
|
||||||
Bfree(pData);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (Bwrite(nHandle, pData, nSize) != nSize)
|
|
||||||
{
|
|
||||||
initprintf("Couldn't write to \"%s\": %s\n", sMapExt, strerror(errno));
|
|
||||||
Bclose(nHandle);
|
|
||||||
Bfree(pData);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
Bclose(nHandle);
|
|
||||||
Bfree(pData);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang, int16_t* dacursectnum)
|
int32_t qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang, int16_t* dacursectnum)
|
||||||
{
|
{
|
||||||
// NUKE-TODO: implement flags, see mapedit.cpp
|
// NUKE-TODO: implement flags, see mapedit.cpp
|
||||||
return dbLoadMap(filename, &dapos->x, &dapos->y, &dapos->z, (short*)daang, (short*)dacursectnum, NULL);
|
return dbLoadMap(filename, &dapos->x, &dapos->y, &dapos->z, (short*)daang, (short*)dacursectnum, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t qsaveboard(const char* filename, const vec3_t* dapos, int16_t daang, int16_t dacursectnum)
|
|
||||||
{
|
|
||||||
// NUKE-TODO: see mapedit.cpp
|
|
||||||
byte_1A76C6 = byte_1A76C8 = byte_1A76C7 = 1;
|
|
||||||
return dbSaveMap(filename, dapos->x, dapos->y, dapos->z, daang, dacursectnum);
|
|
||||||
}
|
|
||||||
|
|
||||||
END_BLD_NS
|
END_BLD_NS
|
||||||
|
|
|
@ -84,7 +84,6 @@ int32_t qdeletesprite(int16_t nSprite);
|
||||||
int32_t qchangespritesect(int16_t nSprite, int16_t nSector);
|
int32_t qchangespritesect(int16_t nSprite, int16_t nSector);
|
||||||
int32_t qchangespritestat(int16_t nSprite, int16_t nStatus);
|
int32_t qchangespritestat(int16_t nSprite, int16_t nStatus);
|
||||||
int32_t qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang, int16_t* dacursectnum);
|
int32_t qloadboard(const char* filename, char flags, vec3_t* dapos, int16_t* daang, int16_t* dacursectnum);
|
||||||
int32_t qsaveboard(const char* filename, const vec3_t* dapos, int16_t daang, int16_t dacursectnum);
|
|
||||||
|
|
||||||
void HookReplaceFunctions(void)
|
void HookReplaceFunctions(void)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +97,6 @@ void HookReplaceFunctions(void)
|
||||||
changespritestat_replace = qchangespritestat;
|
changespritestat_replace = qchangespritestat;
|
||||||
loadvoxel_replace = qloadvoxel;
|
loadvoxel_replace = qloadvoxel;
|
||||||
loadboard_replace = qloadboard;
|
loadboard_replace = qloadboard;
|
||||||
saveboard_replace = qsaveboard;
|
|
||||||
playing_blood = true;
|
playing_blood = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@ typedef struct
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
#ifndef ANIMVPX_STANDALONE
|
#ifndef ANIMVPX_STANDALONE
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
extern const char *animvpx_read_ivf_header_errmsg[7];
|
extern const char *animvpx_read_ivf_header_errmsg[7];
|
||||||
int32_t animvpx_read_ivf_header(FileReader & inhandle, animvpx_ivf_header_t *hdr);
|
int32_t animvpx_read_ivf_header(FileReader & inhandle, animvpx_ivf_header_t *hdr);
|
||||||
|
|
|
@ -27,7 +27,6 @@ static_assert('\xff' == 255, "Char must be unsigned!");
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "pragmas.h"
|
#include "pragmas.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
#include "cache1d.h"
|
#include "cache1d.h"
|
||||||
#include "textures.h"
|
#include "textures.h"
|
||||||
#include "c_cvars.h"
|
#include "c_cvars.h"
|
||||||
|
@ -1020,8 +1019,8 @@ int videoCaptureScreen();
|
||||||
|
|
||||||
struct OutputFileCounter {
|
struct OutputFileCounter {
|
||||||
uint16_t count = 0;
|
uint16_t count = 0;
|
||||||
buildvfs_FILE opennextfile(char *, char *);
|
FileWriter *opennextfile(char *, char *);
|
||||||
buildvfs_FILE opennextfile_withext(char *, const char *);
|
FileWriter *opennextfile_withext(char *, const char *);
|
||||||
};
|
};
|
||||||
|
|
||||||
// PLAG: line utility functions
|
// PLAG: line utility functions
|
||||||
|
@ -1270,7 +1269,6 @@ extern int32_t(*changespritesect_replace)(int16_t spritenum, int16_t newsectnum)
|
||||||
extern int32_t(*changespritestat_replace)(int16_t spritenum, int16_t newstatnum);
|
extern int32_t(*changespritestat_replace)(int16_t spritenum, int16_t newstatnum);
|
||||||
extern void(*loadvoxel_replace)(int32_t voxel);
|
extern void(*loadvoxel_replace)(int32_t voxel);
|
||||||
extern int32_t(*loadboard_replace)(const char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
|
extern int32_t(*loadboard_replace)(const char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
|
||||||
extern int32_t(*saveboard_replace)(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum);
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
extern void(*PolymostProcessVoxels_Callback)(void);
|
extern void(*PolymostProcessVoxels_Callback)(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,12 +12,8 @@
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "files.h"
|
#include "files.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
void cacheAllocateBlock(intptr_t *newhandle, int32_t newbytes, uint8_t *newlockptr);
|
void cacheAllocateBlock(intptr_t *newhandle, int32_t newbytes, uint8_t *newlockptr);
|
||||||
|
|
||||||
using buildvfs_kfd = int32_t;
|
|
||||||
|
|
||||||
extern int32_t pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode)
|
extern int32_t pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode)
|
||||||
|
|
||||||
#include "filesystem/filesystem.h"
|
#include "filesystem/filesystem.h"
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#define EDUKE32_COMMON_H_
|
#define EDUKE32_COMMON_H_
|
||||||
|
|
||||||
#include "cache1d.h"
|
#include "cache1d.h"
|
||||||
#include "vfs.h"
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "pragmas.h" // klabs
|
#include "pragmas.h" // klabs
|
||||||
#include "scriptfile.h"
|
#include "scriptfile.h"
|
||||||
|
|
|
@ -438,8 +438,7 @@ defined __x86_64__ || defined __amd64__ || defined _M_X64 || defined _M_IA64 ||
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# if defined _M_AMD64 || defined _M_ARM64 || defined _M_X64 || defined _WIN64
|
# if defined _M_AMD64 || defined _M_ARM64 || defined _M_X64 || defined _WIN64
|
||||||
// should be int64_t, if not for a suspected VS compiler bug
|
typedef int64_t ssize_t;
|
||||||
typedef int32_t ssize_t;
|
|
||||||
# else
|
# else
|
||||||
typedef int32_t ssize_t;
|
typedef int32_t ssize_t;
|
||||||
# endif
|
# endif
|
||||||
|
@ -479,31 +478,7 @@ typedef FILE BFILE;
|
||||||
#define Bcalloc calloc
|
#define Bcalloc calloc
|
||||||
#define Brealloc realloc
|
#define Brealloc realloc
|
||||||
#define Bfree free
|
#define Bfree free
|
||||||
#define Bopen open
|
|
||||||
#define Bclose close
|
|
||||||
#define Bwrite write
|
|
||||||
#define Bread read
|
|
||||||
#define Blseek lseek
|
|
||||||
#define Bstat stat
|
|
||||||
#define Bfstat fstat
|
|
||||||
#define Bfileno fileno
|
|
||||||
#define Bferror ferror
|
|
||||||
#define Bfopen fopen
|
|
||||||
#define Bfclose fclose
|
|
||||||
#define Bfflush fflush
|
|
||||||
#define Bfeof feof
|
|
||||||
#define Bfgetc fgetc
|
|
||||||
#define Brewind rewind
|
|
||||||
#define Bfgets fgets
|
|
||||||
#define Bfputc fputc
|
|
||||||
#define Bfputs fputs
|
|
||||||
#define Bfread fread
|
|
||||||
#define Bfwrite fwrite
|
|
||||||
#define Bfprintf fprintf
|
|
||||||
#define Bfscanf fscanf
|
|
||||||
#define Bfseek fseek
|
|
||||||
#define Bftell ftell
|
|
||||||
#define Bputs puts
|
|
||||||
#define Bstrcpy strcpy
|
#define Bstrcpy strcpy
|
||||||
#define Bstrncpy strncpy
|
#define Bstrncpy strncpy
|
||||||
#define Bstrcmp strcmp
|
#define Bstrcmp strcmp
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#define palette_h_
|
#define palette_h_
|
||||||
|
|
||||||
#include "cache1d.h"
|
#include "cache1d.h"
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
#define MAXBASEPALS 256
|
#define MAXBASEPALS 256
|
||||||
#define MAXPALOOKUPS 256
|
#define MAXPALOOKUPS 256
|
||||||
|
|
|
@ -1,94 +1 @@
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifndef vfs_h_
|
|
||||||
#define vfs_h_
|
|
||||||
|
|
||||||
#include "compat.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#ifdef _WIN32
|
|
||||||
# include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using buildvfs_FILE = FILE *;
|
|
||||||
#define buildvfs_EOF EOF
|
|
||||||
#define buildvfs_fread(p, s, n, fp) fread((p), (s), (n), (fp))
|
|
||||||
#define buildvfs_fwrite(p, s, n, fp) fwrite((p), (s), (n), (fp))
|
|
||||||
#define buildvfs_fopen_read(fn) fopen((fn), "rb")
|
|
||||||
#define buildvfs_fopen_write(fn) fopen((fn), "wb")
|
|
||||||
#define buildvfs_fopen_write_text(fn) fopen((fn), "w")
|
|
||||||
#define buildvfs_fopen_append(fn) fopen((fn), "ab")
|
|
||||||
#define buildvfs_fgetc(fp) fgetc(fp)
|
|
||||||
#define buildvfs_fputc(c, fp) fputc((c), (fp))
|
|
||||||
#define buildvfs_fgets(str, size, fp) fgets((str), (size), (fp))
|
|
||||||
#define buildvfs_fclose(fp) fclose(fp)
|
|
||||||
#define buildvfs_feof(fp) feof(fp)
|
|
||||||
#define buildvfs_ftell(fp) ftell(fp)
|
|
||||||
#define buildvfs_fseek_abs(fp, o) fseek((fp), (o), SEEK_SET)
|
|
||||||
#define buildvfs_fseek_rel(fp, o) fseek((fp), (o), SEEK_CUR)
|
|
||||||
#define buildvfs_rewind(fp) rewind(fp)
|
|
||||||
|
|
||||||
static inline int64_t buildvfs_length(int fd)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
return filelength(fd);
|
|
||||||
#else
|
|
||||||
struct stat st;
|
|
||||||
return fstat(fd, &st) < 0 ? -1 : st.st_size;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#define buildvfs_getcwd(buf, size) getcwd((buf), (size))
|
|
||||||
|
|
||||||
using buildvfs_fd = int;
|
|
||||||
#define buildvfs_fd_invalid (-1)
|
|
||||||
#define buildvfs_read(fd, p, s) read((fd), (p), (s))
|
|
||||||
#define buildvfs_write(fd, p, s) write((fd), (p), (s))
|
|
||||||
#define buildvfs_open_read(fn) open((fn), O_RDONLY)
|
|
||||||
#define buildvfs_open_write(fn) open((fn), O_BINARY|O_TRUNC|O_CREAT|O_WRONLY, S_IREAD|S_IWRITE)
|
|
||||||
// #define buildvfs_open_append(fn) todo(fn)
|
|
||||||
#define buildvfs_close(fd) close(fd)
|
|
||||||
|
|
||||||
static inline int64_t buildvfs_flength(FILE * f)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
return filelength(_fileno(f));
|
|
||||||
#else
|
|
||||||
return buildvfs_length(fileno(f));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#define buildvfs_exists(fn) (access((fn), 0) == 0)
|
|
||||||
static inline int buildvfs_isdir(char const *path)
|
|
||||||
{
|
|
||||||
struct Bstat st;
|
|
||||||
return (Bstat(path, &st) ? 0 : (st.st_mode & S_IFDIR) == S_IFDIR);
|
|
||||||
}
|
|
||||||
#define buildvfs_unlink(path) unlink(path)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MAYBE_FCLOSE_AND_NULL(fileptr) do { \
|
|
||||||
if (fileptr) { buildvfs_fclose(fileptr); fileptr = buildvfs_FILE{}; } \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
static inline void buildvfs_fputstrptr(buildvfs_FILE fp, char const * str)
|
|
||||||
{
|
|
||||||
buildvfs_fwrite(str, 1, strlen(str), fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void buildvfs_fputs(char const * str, buildvfs_FILE fp)
|
|
||||||
{
|
|
||||||
buildvfs_fwrite(str, 1, strlen(str), fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <size_t N>
|
|
||||||
static inline void buildvfs_fputstr(buildvfs_FILE fp, char const (&str)[N])
|
|
||||||
{
|
|
||||||
buildvfs_fwrite(&str, 1, N-1, fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // vfs_h_
|
|
||||||
|
|
|
@ -17,9 +17,6 @@
|
||||||
#include "pragmas.h"
|
#include "pragmas.h"
|
||||||
#include "baselayer.h"
|
#include "baselayer.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t toupperlookup[256] =
|
uint8_t toupperlookup[256] =
|
||||||
{
|
{
|
||||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
|
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
#include "../../glbackend/glbackend.h"
|
#include "../../glbackend/glbackend.h"
|
||||||
|
|
||||||
// def/clipmap handling
|
// def/clipmap handling
|
||||||
|
@ -293,16 +292,15 @@ static char* KeyValues_FindKeyValue(char **vdfbuf, char * const vdfbufend, const
|
||||||
|
|
||||||
void Paths_ParseSteamKeyValuesForPaths(const char *vdf, SteamPathParseFunc func)
|
void Paths_ParseSteamKeyValuesForPaths(const char *vdf, SteamPathParseFunc func)
|
||||||
{
|
{
|
||||||
buildvfs_fd fd = buildvfs_open_read(vdf);
|
FileReader fr = fopenFileReader(vdf, 0);
|
||||||
int32_t size = buildvfs_length(fd);
|
auto size = fr.GetLength();
|
||||||
char *vdfbufstart, *vdfbuf, *vdfbufend;
|
char *vdfbuf, *vdfbufend;
|
||||||
|
|
||||||
if (size <= 0)
|
if (size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vdfbufstart = vdfbuf = (char*)Xmalloc(size);
|
auto vdfbuffer = fr.ReadPadded(1);
|
||||||
size = (int32_t)buildvfs_read(fd, vdfbuf, size);
|
vdfbuf = (char*)vdfbuffer.Data();
|
||||||
buildvfs_close(fd);
|
|
||||||
vdfbufend = vdfbuf + size;
|
vdfbufend = vdfbuf + size;
|
||||||
|
|
||||||
if (KeyValues_FindParentKey(&vdfbuf, vdfbufend, "LibraryFolders"))
|
if (KeyValues_FindParentKey(&vdfbuf, vdfbufend, "LibraryFolders"))
|
||||||
|
@ -312,6 +310,4 @@ void Paths_ParseSteamKeyValuesForPaths(const char *vdf, SteamPathParseFunc func)
|
||||||
while ((result = KeyValues_FindKeyValue(&vdfbuf, vdfbufend, NULL)) != NULL)
|
while ((result = KeyValues_FindKeyValue(&vdfbuf, vdfbufend, NULL)) != NULL)
|
||||||
func(result);
|
func(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Xfree(vdfbufstart);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,6 @@
|
||||||
|
|
||||||
#include "baselayer.h"
|
#include "baselayer.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
////////// PANICKING ALLOCATION FUNCTIONS //////////
|
////////// PANICKING ALLOCATION FUNCTIONS //////////
|
||||||
|
|
||||||
static void (*g_MemErrHandler)(int32_t line, const char *file, const char *func);
|
static void (*g_MemErrHandler)(int32_t line, const char *file, const char *func);
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
# include "hightile.h"
|
# include "hightile.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
enum scripttoken_t
|
enum scripttoken_t
|
||||||
{
|
{
|
||||||
T_INCLUDE = 0,
|
T_INCLUDE = 0,
|
||||||
|
|
|
@ -34,9 +34,6 @@
|
||||||
#include "../../glbackend/glbackend.h"
|
#include "../../glbackend/glbackend.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
// Compilation switches for optional/extended engine features
|
// Compilation switches for optional/extended engine features
|
||||||
|
|
||||||
|
@ -10020,208 +10017,6 @@ static int32_t get_mapversion(void)
|
||||||
return 7;
|
return 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// saveboard
|
|
||||||
//
|
|
||||||
int32_t(*saveboard_replace)(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum) = NULL;
|
|
||||||
int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum)
|
|
||||||
{
|
|
||||||
if (saveboard_replace)
|
|
||||||
return saveboard_replace(filename, dapos, daang, dacursectnum);
|
|
||||||
|
|
||||||
int16_t numsprites, ts;
|
|
||||||
int32_t i, j, tl;
|
|
||||||
|
|
||||||
// First, some checking.
|
|
||||||
for (j=0; j<MAXSPRITES; j++)
|
|
||||||
{
|
|
||||||
if ((unsigned)sprite[j].statnum > MAXSTATUS)
|
|
||||||
{
|
|
||||||
initprintf("Map error: sprite #%d(%d,%d) with an illegal statnum(%d)\n",
|
|
||||||
j,TrackerCast(sprite[j].x),TrackerCast(sprite[j].y),TrackerCast(sprite[j].statnum));
|
|
||||||
changespritestat(j,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((unsigned)sprite[j].sectnum > MAXSECTORS)
|
|
||||||
{
|
|
||||||
initprintf("Map error: sprite #%d(%d,%d) with an illegal sectnum(%d)\n",
|
|
||||||
j,TrackerCast(sprite[j].x),TrackerCast(sprite[j].y),TrackerCast(sprite[j].sectnum));
|
|
||||||
changespritesect(j,0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Count the number of sprites.
|
|
||||||
numsprites = 0;
|
|
||||||
for (j=0; j<MAXSPRITES; j++)
|
|
||||||
{
|
|
||||||
if (sprite[j].statnum != MAXSTATUS)
|
|
||||||
numsprites++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check consistency of sprite-in-the-world predicate (.statnum != MAXSTATUS)
|
|
||||||
// and the engine-reported number of sprites 'Numsprites'.
|
|
||||||
Bassert(numsprites == Numsprites);
|
|
||||||
|
|
||||||
// Determine the map version.
|
|
||||||
mapversion = get_mapversion();
|
|
||||||
|
|
||||||
#ifdef NEW_MAP_FORMAT
|
|
||||||
if (mapversion == 10)
|
|
||||||
{
|
|
||||||
initprintf("Saving of TROR maps not yet accessible in the Lunatic preview build\n");
|
|
||||||
return -1;
|
|
||||||
// return saveboard_maptext(filename, dapos, daang, dacursectnum);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
buildvfs_fd fil = buildvfs_open_write(filename);
|
|
||||||
|
|
||||||
if (fil == buildvfs_fd_invalid)
|
|
||||||
{
|
|
||||||
initprintf("Couldn't open \"%s\" for writing: %s\n", filename, strerror(errno));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
tl = B_LITTLE32(mapversion); buildvfs_write(fil,&tl,4);
|
|
||||||
|
|
||||||
tl = B_LITTLE32(dapos->x); buildvfs_write(fil,&tl,4);
|
|
||||||
tl = B_LITTLE32(dapos->y); buildvfs_write(fil,&tl,4);
|
|
||||||
tl = B_LITTLE32(dapos->z); buildvfs_write(fil,&tl,4);
|
|
||||||
ts = B_LITTLE16(daang); buildvfs_write(fil,&ts,2);
|
|
||||||
ts = B_LITTLE16(dacursectnum); buildvfs_write(fil,&ts,2);
|
|
||||||
|
|
||||||
ts = B_LITTLE16(numsectors); buildvfs_write(fil,&ts,2);
|
|
||||||
|
|
||||||
while (1) // if, really
|
|
||||||
{
|
|
||||||
usectortypev7 *const tsect = (usectortypev7 *)Xmalloc(sizeof(usectortypev7) * numsectors);
|
|
||||||
uwalltypev7 *twall;
|
|
||||||
|
|
||||||
#ifdef NEW_MAP_FORMAT
|
|
||||||
for (i=0; i<numsectors; i++)
|
|
||||||
copy_v7_from_vx_sector(&tsect[i], §or[i]);
|
|
||||||
#else
|
|
||||||
Bmemcpy(tsect, sector, sizeof(sectortypev7)*numsectors);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i=0; i<numsectors; i++)
|
|
||||||
{
|
|
||||||
usectortypev7 *const sec = &tsect[i];
|
|
||||||
|
|
||||||
sec->wallptr = B_LITTLE16(sec->wallptr);
|
|
||||||
sec->wallnum = B_LITTLE16(sec->wallnum);
|
|
||||||
sec->ceilingz = B_LITTLE32(sec->ceilingz);
|
|
||||||
sec->floorz = B_LITTLE32(sec->floorz);
|
|
||||||
sec->ceilingstat = B_LITTLE16(sec->ceilingstat);
|
|
||||||
sec->floorstat = B_LITTLE16(sec->floorstat);
|
|
||||||
sec->ceilingpicnum = B_LITTLE16(sec->ceilingpicnum);
|
|
||||||
sec->ceilingheinum = B_LITTLE16(sec->ceilingheinum);
|
|
||||||
sec->floorpicnum = B_LITTLE16(sec->floorpicnum);
|
|
||||||
sec->floorheinum = B_LITTLE16(sec->floorheinum);
|
|
||||||
sec->lotag = B_LITTLE16(sec->lotag);
|
|
||||||
sec->hitag = B_LITTLE16(sec->hitag);
|
|
||||||
sec->extra = B_LITTLE16(sec->extra);
|
|
||||||
#ifdef YAX_ENABLE__COMPAT
|
|
||||||
if (editstatus == 0)
|
|
||||||
{
|
|
||||||
// if in-game, pack game-time bunchnum data back into structs
|
|
||||||
int32_t cf, bn;
|
|
||||||
|
|
||||||
for (cf=0; cf<2; cf++)
|
|
||||||
if ((bn=yax_getbunch(i, cf)) >= 0)
|
|
||||||
YAX_PTRBUNCHNUM(tsect, i, cf) = bn;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
buildvfs_write(fil, tsect, sizeof(sectortypev7)*numsectors);
|
|
||||||
Xfree(tsect);
|
|
||||||
|
|
||||||
ts = B_LITTLE16(numwalls);
|
|
||||||
buildvfs_write(fil,&ts,2);
|
|
||||||
|
|
||||||
twall = (uwalltypev7 *)Xmalloc(sizeof(uwalltypev7) * numwalls);
|
|
||||||
|
|
||||||
#ifdef NEW_MAP_FORMAT
|
|
||||||
for (i=0; i<numwalls; i++)
|
|
||||||
copy_v7_from_vx_wall(&twall[i], &wall[i]);
|
|
||||||
#else
|
|
||||||
Bmemcpy(twall, wall, sizeof(walltypev7)*numwalls);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i=0; i<numwalls; i++)
|
|
||||||
{
|
|
||||||
uwalltypev7 *const wal = &twall[i];
|
|
||||||
|
|
||||||
wal->x = B_LITTLE32(wal->x);
|
|
||||||
wal->y = B_LITTLE32(wal->y);
|
|
||||||
wal->point2 = B_LITTLE16(wal->point2);
|
|
||||||
wal->nextwall = B_LITTLE16(wal->nextwall);
|
|
||||||
wal->nextsector = B_LITTLE16(wal->nextsector);
|
|
||||||
wal->cstat = B_LITTLE16(wal->cstat);
|
|
||||||
wal->picnum = B_LITTLE16(wal->picnum);
|
|
||||||
wal->overpicnum = B_LITTLE16(wal->overpicnum);
|
|
||||||
#ifdef YAX_ENABLE__COMPAT
|
|
||||||
if (editstatus == 0)
|
|
||||||
{
|
|
||||||
// if in-game, pack game-time yax-nextwall data back into structs
|
|
||||||
int16_t ynw;
|
|
||||||
if ((ynw=yax_getnextwall(i, YAX_CEILING))>=0)
|
|
||||||
YAX_PTRNEXTWALL(twall,i,YAX_CEILING) = ynw;
|
|
||||||
if ((ynw=yax_getnextwall(i, YAX_FLOOR))>=0)
|
|
||||||
YAX_PTRNEXTWALL(twall,i,YAX_FLOOR) = ynw;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
wal->lotag = B_LITTLE16(wal->lotag);
|
|
||||||
wal->hitag = B_LITTLE16(wal->hitag);
|
|
||||||
wal->extra = B_LITTLE16(wal->extra);
|
|
||||||
}
|
|
||||||
|
|
||||||
buildvfs_write(fil, twall, sizeof(walltypev7)*numwalls);
|
|
||||||
Xfree(twall);
|
|
||||||
|
|
||||||
ts = B_LITTLE16(numsprites); buildvfs_write(fil,&ts,2);
|
|
||||||
|
|
||||||
if (numsprites > 0)
|
|
||||||
{
|
|
||||||
auto const tspri = (uspritetype *)Xmalloc(sizeof(spritetype) * numsprites);
|
|
||||||
auto spri = tspri;
|
|
||||||
|
|
||||||
for (j=0; j<MAXSPRITES; j++)
|
|
||||||
{
|
|
||||||
if (sprite[j].statnum != MAXSTATUS)
|
|
||||||
{
|
|
||||||
Bmemcpy(spri, &sprite[j], sizeof(spritetype));
|
|
||||||
spri->x = B_LITTLE32(spri->x);
|
|
||||||
spri->y = B_LITTLE32(spri->y);
|
|
||||||
spri->z = B_LITTLE32(spri->z);
|
|
||||||
spri->cstat = B_LITTLE16(spri->cstat);
|
|
||||||
spri->picnum = B_LITTLE16(spri->picnum);
|
|
||||||
spri->sectnum = B_LITTLE16(spri->sectnum);
|
|
||||||
spri->statnum = B_LITTLE16(spri->statnum);
|
|
||||||
spri->ang = B_LITTLE16(spri->ang);
|
|
||||||
spri->owner = B_LITTLE16(spri->owner);
|
|
||||||
spri->xvel = B_LITTLE16(spri->xvel);
|
|
||||||
spri->yvel = B_LITTLE16(spri->yvel);
|
|
||||||
spri->zvel = B_LITTLE16(spri->zvel);
|
|
||||||
spri->lotag = B_LITTLE16(spri->lotag);
|
|
||||||
spri->hitag = B_LITTLE16(spri->hitag);
|
|
||||||
spri->extra = B_LITTLE16(spri->extra);
|
|
||||||
spri++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buildvfs_write(fil, tspri, sizeof(spritetype)*numsprites);
|
|
||||||
Xfree(tspri);
|
|
||||||
}
|
|
||||||
|
|
||||||
buildvfs_close(fil);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
buildvfs_close(fil);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define YSAVES ((xdim*MAXSPRITES)>>7)
|
#define YSAVES ((xdim*MAXSPRITES)>>7)
|
||||||
|
|
||||||
|
@ -11669,75 +11464,6 @@ void rotatepoint(vec2_t const pivot, vec2_t p, int16_t const daang, vec2_t * con
|
||||||
p2->y = dmulscale14(p.y, dacos, p.x, dasin) + pivot.y;
|
p2->y = dmulscale14(p.y, dacos, p.x, dasin) + pivot.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if KRANDDEBUG
|
|
||||||
# include <execinfo.h>
|
|
||||||
# define KRD_MAXCALLS 262144
|
|
||||||
# define KRD_DEPTH 8
|
|
||||||
static int32_t krd_numcalls=0;
|
|
||||||
static void *krd_fromwhere[KRD_MAXCALLS][KRD_DEPTH];
|
|
||||||
static int32_t krd_enabled=0;
|
|
||||||
|
|
||||||
void krd_enable(int which) // 0: disable, 1: rec, 2: play
|
|
||||||
{
|
|
||||||
krd_enabled = which;
|
|
||||||
|
|
||||||
if (which)
|
|
||||||
Bmemset(krd_fromwhere, 0, sizeof(krd_fromwhere));
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t krd_print(const char *filename)
|
|
||||||
{
|
|
||||||
buildvfs_FILE fp;
|
|
||||||
int32_t i, j;
|
|
||||||
|
|
||||||
if (!krd_enabled) return 1;
|
|
||||||
krd_enabled = 0;
|
|
||||||
|
|
||||||
fp = buildvfs_fopen_write(filename);
|
|
||||||
if (!fp) { OSD_Printf("krd_print (2): fopen"); return 1; }
|
|
||||||
|
|
||||||
for (i=0; i<krd_numcalls; i++)
|
|
||||||
{
|
|
||||||
for (j=1;; j++) // skip self entry
|
|
||||||
{
|
|
||||||
if (j>=KRD_DEPTH || krd_fromwhere[i][j]==NULL)
|
|
||||||
{
|
|
||||||
fprintf(fp, "\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
fprintf(fp, " [%p]", krd_fromwhere[i][j]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
krd_numcalls = 0;
|
|
||||||
|
|
||||||
buildvfs_fclose(fp);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif // KRANDDEBUG
|
|
||||||
|
|
||||||
#if KRANDDEBUG || defined LUNATIC
|
|
||||||
//
|
|
||||||
// krand
|
|
||||||
//
|
|
||||||
int32_t krand(void)
|
|
||||||
{
|
|
||||||
// randomseed = (randomseed*27584621)+1;
|
|
||||||
randomseed = (randomseed * 1664525ul) + 221297ul;
|
|
||||||
#ifdef KRANDDEBUG
|
|
||||||
if (krd_enabled)
|
|
||||||
if (krd_numcalls < KRD_MAXCALLS)
|
|
||||||
{
|
|
||||||
backtrace(krd_fromwhere[krd_numcalls], KRD_DEPTH);
|
|
||||||
krd_numcalls++;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return ((uint32_t)randomseed)>>16;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int32_t setaspect_new_use_dimen = 0;
|
int32_t setaspect_new_use_dimen = 0;
|
||||||
|
|
||||||
void videoSetCorrectedAspect()
|
void videoSetCorrectedAspect()
|
||||||
|
|
|
@ -17,8 +17,6 @@
|
||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
#include "../../glbackend/glbackend.h"
|
#include "../../glbackend/glbackend.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
static int32_t curextra=MAXTILES;
|
static int32_t curextra=MAXTILES;
|
||||||
|
|
||||||
#define MIN_CACHETIME_PRINT 10
|
#define MIN_CACHETIME_PRINT 10
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "../../glbackend/glbackend.h"
|
#include "../../glbackend/glbackend.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
uint8_t *basepaltable[MAXBASEPALS] = { palette };
|
uint8_t *basepaltable[MAXBASEPALS] = { palette };
|
||||||
uint8_t basepalreset=1;
|
uint8_t basepalreset=1;
|
||||||
uint8_t curbasepal;
|
uint8_t curbasepal;
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include "gamecontrol.h"
|
#include "gamecontrol.h"
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
#include "../../glbackend/glbackend.h"
|
#include "../../glbackend/glbackend.h"
|
||||||
|
|
||||||
EXTERN_CVAR(Float, png_gamma)
|
EXTERN_CVAR(Float, png_gamma)
|
||||||
|
@ -17,7 +16,7 @@ EXTERN_CVAR(Float, png_gamma)
|
||||||
// screencapture
|
// screencapture
|
||||||
//
|
//
|
||||||
|
|
||||||
buildvfs_FILE OutputFileCounter::opennextfile(char *fn, char *zeros)
|
FileWriter *OutputFileCounter::opennextfile(char *fn, char *zeros)
|
||||||
{
|
{
|
||||||
do // JBF 2004022: So we don't overwrite existing screenshots
|
do // JBF 2004022: So we don't overwrite existing screenshots
|
||||||
{
|
{
|
||||||
|
@ -27,25 +26,18 @@ buildvfs_FILE OutputFileCounter::opennextfile(char *fn, char *zeros)
|
||||||
zeros[1] = ((count/100)%10)+'0';
|
zeros[1] = ((count/100)%10)+'0';
|
||||||
zeros[2] = ((count/10)%10)+'0';
|
zeros[2] = ((count/10)%10)+'0';
|
||||||
zeros[3] = (count%10)+'0';
|
zeros[3] = (count%10)+'0';
|
||||||
#ifdef USE_PHYSFS
|
if (!FileExists(fn)) break;
|
||||||
buildvfs_FILE file;
|
|
||||||
if ((file = buildvfs_fopen_read(fn)) == nullptr) break;
|
|
||||||
buildvfs_fclose(file);
|
|
||||||
#else
|
|
||||||
struct Bstat st;
|
|
||||||
if (Bstat(fn, &st) == -1) break;
|
|
||||||
#endif
|
|
||||||
count++;
|
count++;
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
return buildvfs_fopen_write(fn);
|
return FileWriter::Open(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildvfs_FILE OutputFileCounter::opennextfile_withext(char *fn, const char *ext)
|
FileWriter *OutputFileCounter::opennextfile_withext(char *fn, const char *ext)
|
||||||
{
|
{
|
||||||
char *dot = strrchr(fn, '.');
|
char *dot = strrchr(fn, '.');
|
||||||
strcpy(dot+1, ext);
|
strcpy(dot+1, ext);
|
||||||
return opennextfile(fn, dot-4);
|
return opennextfile(fn, dot-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static OutputFileCounter capturecounter;
|
static OutputFileCounter capturecounter;
|
||||||
|
@ -111,20 +103,18 @@ int videoCaptureScreen()
|
||||||
else autoname << currentGame;
|
else autoname << currentGame;
|
||||||
autoname << "_0000";
|
autoname << "_0000";
|
||||||
char* fn = autoname.LockBuffer();
|
char* fn = autoname.LockBuffer();
|
||||||
buildvfs_FILE fp = capturecounter.opennextfile_withext(fn, "png");
|
FileWriter *fil = capturecounter.opennextfile_withext(fn, "png");
|
||||||
autoname.UnlockBuffer();
|
autoname.UnlockBuffer();
|
||||||
|
|
||||||
if (fp == nullptr)
|
if (fil == nullptr)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
FileWriter writer(fp);
|
|
||||||
|
|
||||||
uint8_t * const imgBuf = (uint8_t *) Xmalloc(xdim * ydim * (HICOLOR ? 3 : 1));
|
uint8_t * const imgBuf = (uint8_t *) Xmalloc(xdim * ydim * (HICOLOR ? 3 : 1));
|
||||||
|
|
||||||
videoBeginDrawing(); //{{{
|
videoBeginDrawing(); //{{{
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
|
||||||
if (HICOLOR)
|
if (HICOLOR)
|
||||||
{
|
{
|
||||||
getScreen(imgBuf);
|
getScreen(imgBuf);
|
||||||
|
@ -135,15 +125,14 @@ int videoCaptureScreen()
|
||||||
|
|
||||||
for (int i = 0, numRows = ydim >> 1; i < numRows; ++i)
|
for (int i = 0, numRows = ydim >> 1; i < numRows; ++i)
|
||||||
{
|
{
|
||||||
Bmemcpy(rowBuf, imgBuf + i * bytesPerLine, bytesPerLine);
|
memcpy(rowBuf, imgBuf + i * bytesPerLine, bytesPerLine);
|
||||||
Bmemcpy(imgBuf + i * bytesPerLine, imgBuf + (ydim - i - 1) * bytesPerLine, bytesPerLine);
|
memcpy(imgBuf + i * bytesPerLine, imgBuf + (ydim - i - 1) * bytesPerLine, bytesPerLine);
|
||||||
Bmemcpy(imgBuf + (ydim - i - 1) * bytesPerLine, rowBuf, bytesPerLine);
|
memcpy(imgBuf + (ydim - i - 1) * bytesPerLine, rowBuf, bytesPerLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
Xfree(rowBuf);
|
Xfree(rowBuf);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
for (bssize_t i = 0; i < 256; ++i)
|
for (bssize_t i = 0; i < 256; ++i)
|
||||||
{
|
{
|
||||||
|
@ -158,7 +147,8 @@ int videoCaptureScreen()
|
||||||
|
|
||||||
videoEndDrawing(); //}}}
|
videoEndDrawing(); //}}}
|
||||||
|
|
||||||
WritePNGfile(&writer, imgBuf, Palette, HICOLOR ? SS_RGB : SS_PAL, xdim, ydim, HICOLOR? xdim*3 : xdim, png_gamma);
|
WritePNGfile(fil, imgBuf, Palette, HICOLOR ? SS_RGB : SS_PAL, xdim, ydim, HICOLOR? xdim*3 : xdim, png_gamma);
|
||||||
|
delete fil;
|
||||||
Xfree(imgBuf);
|
Xfree(imgBuf);
|
||||||
Printf("Saved screenshot to %s\n", fn);
|
Printf("Saved screenshot to %s\n", fn);
|
||||||
capturecounter.count++;
|
capturecounter.count++;
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "cache1d.h"
|
#include "cache1d.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define ISWS(x) ((x == ' ') || (x == '\t') || (x == '\r') || (x == '\n'))
|
#define ISWS(x) ((x == ' ') || (x == '\t') || (x == '\r') || (x == '\n'))
|
||||||
static inline void skipoverws(scriptfile *sf) { if ((sf->textptr < sf->eof) && (!sf->textptr[0])) sf->textptr++; }
|
static inline void skipoverws(scriptfile *sf) { if ((sf->textptr < sf->eof) && (!sf->textptr[0])) sf->textptr++; }
|
||||||
|
|
|
@ -59,8 +59,6 @@
|
||||||
# include "win32/winbits.h"
|
# include "win32/winbits.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
CVAR(Int, r_displayindex, 0, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
CVAR(Int, r_displayindex, 0, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
||||||
CVAR(Int, r_borderless, 2, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
CVAR(Int, r_borderless, 2, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
||||||
CVAR(Int, maxrefreshfreq, 0, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
CVAR(Int, maxrefreshfreq, 0, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
||||||
|
|
|
@ -12,9 +12,6 @@
|
||||||
#include "engine_priv.h"
|
#include "engine_priv.h"
|
||||||
#include "cache1d.h"
|
#include "cache1d.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// copytilepiece
|
// copytilepiece
|
||||||
//
|
//
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "../../glbackend/glbackend.h"
|
#include "../../glbackend/glbackend.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
|
|
||||||
//For loading/conversion only
|
//For loading/conversion only
|
||||||
static vec3_t voxsiz;
|
static vec3_t voxsiz;
|
||||||
|
|
|
@ -68,7 +68,7 @@ static bool UncompressZipLump(char *Cache, FileReader &Reader, int Method, int L
|
||||||
case METHOD_LZMA:
|
case METHOD_LZMA:
|
||||||
{
|
{
|
||||||
FileReader frz;
|
FileReader frz;
|
||||||
if (frz.OpenDecompressor(Reader, LumpSize, Method, false, [](const char* err) { I_Error("%s", err); }))
|
if (frz.OpenDecompressor(Reader, LumpSize, Method, false, nullptr))
|
||||||
{
|
{
|
||||||
frz.Read(Cache, LumpSize);
|
frz.Read(Cache, LumpSize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,9 +157,9 @@ void D_AddWildFile (TArray<FString> &wadfiles, const char *value)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const char *wadfile = BaseFileSearch (value, ".wad", false);
|
FString wadfile = BaseFileSearch (value, ".wad", false);
|
||||||
|
|
||||||
if (wadfile != NULL)
|
if (wadfile.Len() != 0)
|
||||||
{
|
{
|
||||||
D_AddFile (wadfiles, wadfile);
|
D_AddFile (wadfiles, wadfile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1123,12 +1123,11 @@ const char* G_ConFile(void)
|
||||||
bool AddINIFile(const char* pzFile, bool bForce = false)
|
bool AddINIFile(const char* pzFile, bool bForce = false)
|
||||||
{
|
{
|
||||||
char* pzFN;
|
char* pzFN;
|
||||||
struct Bstat st;
|
|
||||||
static INICHAIN* pINIIter = NULL;
|
static INICHAIN* pINIIter = NULL;
|
||||||
if (!bForce)
|
if (!bForce)
|
||||||
{
|
{
|
||||||
if (findfrompath(pzFile, &pzFN)) return false; // failed to resolve the filename
|
if (findfrompath(pzFile, &pzFN)) return false; // failed to resolve the filename
|
||||||
if (Bstat(pzFN, &st))
|
if (!FileExists(pzFN))
|
||||||
{
|
{
|
||||||
Bfree(pzFN);
|
Bfree(pzFN);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1185,4 +1184,4 @@ void ScanINIFiles(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -56,8 +56,11 @@ enum
|
||||||
METHOD_PPMD = 98,
|
METHOD_PPMD = 98,
|
||||||
METHOD_LZSS = 1337, // not used in Zips - this is for Console Doom compression
|
METHOD_LZSS = 1337, // not used in Zips - this is for Console Doom compression
|
||||||
METHOD_ZLIB = 1338, // Zlib stream with header, used by compressed nodes.
|
METHOD_ZLIB = 1338, // Zlib stream with header, used by compressed nodes.
|
||||||
|
METHOD_TRANSFEROWNER = 0x8000,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FileReader;
|
||||||
|
|
||||||
class FileReaderInterface
|
class FileReaderInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -71,22 +74,6 @@ public:
|
||||||
long GetLength () const { return Length; }
|
long GetLength () const { return Length; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class DecompressorBase : public FileReaderInterface
|
|
||||||
{
|
|
||||||
std::function<void(const char*)> ErrorCallback = nullptr;
|
|
||||||
public:
|
|
||||||
// These do not work but need to be defined to satisfy the FileReaderInterface.
|
|
||||||
// They will just error out when called.
|
|
||||||
long Tell() const override;
|
|
||||||
long Seek(long offset, int origin) override;
|
|
||||||
char *Gets(char *strbuf, int len) override;
|
|
||||||
void DecompressionError(const char* error, ...) const;
|
|
||||||
void SetErrorCallback(const std::function<void(const char*)>& cb)
|
|
||||||
{
|
|
||||||
ErrorCallback = cb;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class MemoryReader : public FileReaderInterface
|
class MemoryReader : public FileReaderInterface
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
@ -301,6 +288,28 @@ public:
|
||||||
friend class FWadCollection;
|
friend class FWadCollection;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DecompressorBase : public FileReaderInterface
|
||||||
|
{
|
||||||
|
std::function<void(const char*)> ErrorCallback = nullptr;
|
||||||
|
public:
|
||||||
|
// These do not work but need to be defined to satisfy the FileReaderInterface.
|
||||||
|
// They will just error out when called.
|
||||||
|
long Tell() const override;
|
||||||
|
long Seek(long offset, int origin) override;
|
||||||
|
char* Gets(char* strbuf, int len) override;
|
||||||
|
void DecompressionError(const char* error, ...) const;
|
||||||
|
void SetErrorCallback(const std::function<void(const char*)>& cb)
|
||||||
|
{
|
||||||
|
ErrorCallback = cb;
|
||||||
|
}
|
||||||
|
void SetOwnsReader();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
FileReader* File = nullptr;
|
||||||
|
FileReader OwnedFile;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -316,7 +325,7 @@ public:
|
||||||
}
|
}
|
||||||
virtual ~FileWriter()
|
virtual ~FileWriter()
|
||||||
{
|
{
|
||||||
if (File != NULL) fclose(File);
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
static FileWriter *Open(const char *filename);
|
static FileWriter *Open(const char *filename);
|
||||||
|
@ -325,6 +334,11 @@ public:
|
||||||
virtual long Tell();
|
virtual long Tell();
|
||||||
virtual long Seek(long offset, int mode);
|
virtual long Seek(long offset, int mode);
|
||||||
size_t Printf(const char *fmt, ...) GCCPRINTF(2,3);
|
size_t Printf(const char *fmt, ...) GCCPRINTF(2,3);
|
||||||
|
virtual void Close()
|
||||||
|
{
|
||||||
|
if (File != NULL) fclose(File);
|
||||||
|
File = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -343,6 +357,26 @@ public:
|
||||||
BufferWriter() {}
|
BufferWriter() {}
|
||||||
virtual size_t Write(const void *buffer, size_t len) override;
|
virtual size_t Write(const void *buffer, size_t len) override;
|
||||||
TArray<unsigned char> *GetBuffer() { return &mBuffer; }
|
TArray<unsigned char> *GetBuffer() { return &mBuffer; }
|
||||||
|
TArray<unsigned char>&& TakeBuffer() { return std::move(mBuffer); }
|
||||||
|
};
|
||||||
|
|
||||||
|
class CompressedFileWriter : public FileWriter
|
||||||
|
{
|
||||||
|
FileWriter *target;
|
||||||
|
struct z_stream_s *zipstream;
|
||||||
|
uint8_t outbuf[1024];
|
||||||
|
size_t compressedSize;
|
||||||
|
bool ownsWriter;
|
||||||
|
|
||||||
|
size_t WriteBlock(const void *buffer, size_t bytes);
|
||||||
|
|
||||||
|
public:
|
||||||
|
CompressedFileWriter(FileWriter *wr, bool transfer = false);
|
||||||
|
CompressedFileWriter(FILE *wr);
|
||||||
|
~CompressedFileWriter() { Close(); }
|
||||||
|
virtual size_t Write(const void *buffer, size_t len) override;
|
||||||
|
virtual void Close() override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -63,7 +63,7 @@ void DecompressorBase::DecompressionError(const char *error, ...) const
|
||||||
va_end(argptr);
|
va_end(argptr);
|
||||||
|
|
||||||
if (ErrorCallback != nullptr) ErrorCallback(errortext);
|
if (ErrorCallback != nullptr) ErrorCallback(errortext);
|
||||||
else std::terminate();
|
else throw std::runtime_error(errortext);
|
||||||
}
|
}
|
||||||
|
|
||||||
long DecompressorBase::Tell () const
|
long DecompressorBase::Tell () const
|
||||||
|
@ -82,6 +82,12 @@ char *DecompressorBase::Gets(char *strbuf, int len)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DecompressorBase::SetOwnsReader()
|
||||||
|
{
|
||||||
|
OwnedFile = std::move(*File);
|
||||||
|
File = &OwnedFile;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// M_ZlibError
|
// M_ZlibError
|
||||||
//
|
//
|
||||||
|
@ -125,17 +131,17 @@ class DecompressorZ : public DecompressorBase
|
||||||
{
|
{
|
||||||
enum { BUFF_SIZE = 4096 };
|
enum { BUFF_SIZE = 4096 };
|
||||||
|
|
||||||
FileReader &File;
|
|
||||||
bool SawEOF;
|
bool SawEOF;
|
||||||
z_stream Stream;
|
z_stream Stream;
|
||||||
uint8_t InBuff[BUFF_SIZE];
|
uint8_t InBuff[BUFF_SIZE];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DecompressorZ (FileReader &file, bool zip, const std::function<void(const char*)>& cb)
|
DecompressorZ (FileReader *file, bool zip, const std::function<void(const char*)>& cb)
|
||||||
: File(file), SawEOF(false)
|
: SawEOF(false)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
File = file;
|
||||||
SetErrorCallback(cb);
|
SetErrorCallback(cb);
|
||||||
FillBuffer ();
|
FillBuffer ();
|
||||||
|
|
||||||
|
@ -187,7 +193,7 @@ public:
|
||||||
|
|
||||||
void FillBuffer ()
|
void FillBuffer ()
|
||||||
{
|
{
|
||||||
auto numread = File.Read (InBuff, BUFF_SIZE);
|
auto numread = File->Read (InBuff, BUFF_SIZE);
|
||||||
|
|
||||||
if (numread < BUFF_SIZE)
|
if (numread < BUFF_SIZE)
|
||||||
{
|
{
|
||||||
|
@ -216,17 +222,17 @@ class DecompressorBZ2 : public DecompressorBase
|
||||||
{
|
{
|
||||||
enum { BUFF_SIZE = 4096 };
|
enum { BUFF_SIZE = 4096 };
|
||||||
|
|
||||||
FileReader &File;
|
|
||||||
bool SawEOF;
|
bool SawEOF;
|
||||||
bz_stream Stream;
|
bz_stream Stream;
|
||||||
uint8_t InBuff[BUFF_SIZE];
|
uint8_t InBuff[BUFF_SIZE];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DecompressorBZ2 (FileReader &file, const std::function<void(const char*)>& cb)
|
DecompressorBZ2 (FileReader *file, const std::function<void(const char*)>& cb)
|
||||||
: File(file), SawEOF(false)
|
: SawEOF(false)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
File = file;
|
||||||
SetErrorCallback(cb);
|
SetErrorCallback(cb);
|
||||||
stupidGlobal = this;
|
stupidGlobal = this;
|
||||||
FillBuffer ();
|
FillBuffer ();
|
||||||
|
@ -281,7 +287,7 @@ public:
|
||||||
|
|
||||||
void FillBuffer ()
|
void FillBuffer ()
|
||||||
{
|
{
|
||||||
auto numread = File.Read(InBuff, BUFF_SIZE);
|
auto numread = File->Read(InBuff, BUFF_SIZE);
|
||||||
|
|
||||||
if (numread < BUFF_SIZE)
|
if (numread < BUFF_SIZE)
|
||||||
{
|
{
|
||||||
|
@ -325,7 +331,6 @@ class DecompressorLZMA : public DecompressorBase
|
||||||
{
|
{
|
||||||
enum { BUFF_SIZE = 4096 };
|
enum { BUFF_SIZE = 4096 };
|
||||||
|
|
||||||
FileReader &File;
|
|
||||||
bool SawEOF;
|
bool SawEOF;
|
||||||
CLzmaDec Stream;
|
CLzmaDec Stream;
|
||||||
size_t Size;
|
size_t Size;
|
||||||
|
@ -335,18 +340,19 @@ class DecompressorLZMA : public DecompressorBase
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DecompressorLZMA (FileReader &file, size_t uncompressed_size, const std::function<void(const char*)>& cb)
|
DecompressorLZMA (FileReader *file, size_t uncompressed_size, const std::function<void(const char*)>& cb)
|
||||||
: File(file), SawEOF(false)
|
: SawEOF(false)
|
||||||
{
|
{
|
||||||
uint8_t header[4 + LZMA_PROPS_SIZE];
|
uint8_t header[4 + LZMA_PROPS_SIZE];
|
||||||
int err;
|
int err;
|
||||||
|
File = file;
|
||||||
SetErrorCallback(cb);
|
SetErrorCallback(cb);
|
||||||
|
|
||||||
Size = uncompressed_size;
|
Size = uncompressed_size;
|
||||||
OutProcessed = 0;
|
OutProcessed = 0;
|
||||||
|
|
||||||
// Read zip LZMA properties header
|
// Read zip LZMA properties header
|
||||||
if (File.Read(header, sizeof(header)) < (long)sizeof(header))
|
if (File->Read(header, sizeof(header)) < (long)sizeof(header))
|
||||||
{
|
{
|
||||||
DecompressionError("DecompressorLZMA: File too short\n");
|
DecompressionError("DecompressorLZMA: File too short\n");
|
||||||
}
|
}
|
||||||
|
@ -423,7 +429,7 @@ public:
|
||||||
|
|
||||||
void FillBuffer ()
|
void FillBuffer ()
|
||||||
{
|
{
|
||||||
auto numread = File.Read(InBuff, BUFF_SIZE);
|
auto numread = File->Read(InBuff, BUFF_SIZE);
|
||||||
|
|
||||||
if (numread < BUFF_SIZE)
|
if (numread < BUFF_SIZE)
|
||||||
{
|
{
|
||||||
|
@ -445,7 +451,6 @@ class DecompressorLZSS : public DecompressorBase
|
||||||
{
|
{
|
||||||
enum { BUFF_SIZE = 4096, WINDOW_SIZE = 4096, INTERNAL_BUFFER_SIZE = 128 };
|
enum { BUFF_SIZE = 4096, WINDOW_SIZE = 4096, INTERNAL_BUFFER_SIZE = 128 };
|
||||||
|
|
||||||
FileReader &File;
|
|
||||||
bool SawEOF;
|
bool SawEOF;
|
||||||
uint8_t InBuff[BUFF_SIZE];
|
uint8_t InBuff[BUFF_SIZE];
|
||||||
|
|
||||||
|
@ -476,7 +481,7 @@ class DecompressorLZSS : public DecompressorBase
|
||||||
if(Stream.AvailIn)
|
if(Stream.AvailIn)
|
||||||
memmove(InBuff, Stream.In, Stream.AvailIn);
|
memmove(InBuff, Stream.In, Stream.AvailIn);
|
||||||
|
|
||||||
auto numread = File.Read(InBuff+Stream.AvailIn, BUFF_SIZE-Stream.AvailIn);
|
auto numread = File->Read(InBuff+Stream.AvailIn, BUFF_SIZE-Stream.AvailIn);
|
||||||
|
|
||||||
if (numread < BUFF_SIZE)
|
if (numread < BUFF_SIZE)
|
||||||
{
|
{
|
||||||
|
@ -563,8 +568,9 @@ class DecompressorLZSS : public DecompressorBase
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DecompressorLZSS(FileReader &file, const std::function<void(const char*)>& cb) : File(file), SawEOF(false)
|
DecompressorLZSS(FileReader *file, const std::function<void(const char*)>& cb) : SawEOF(false)
|
||||||
{
|
{
|
||||||
|
File = file;
|
||||||
SetErrorCallback(cb);
|
SetErrorCallback(cb);
|
||||||
Stream.State = STREAM_EMPTY;
|
Stream.State = STREAM_EMPTY;
|
||||||
Stream.WindowData = Stream.InternalBuffer = Stream.Window+WINDOW_SIZE;
|
Stream.WindowData = Stream.InternalBuffer = Stream.Window+WINDOW_SIZE;
|
||||||
|
@ -629,29 +635,35 @@ public:
|
||||||
bool FileReader::OpenDecompressor(FileReader &parent, Size length, int method, bool seekable, const std::function<void(const char*)>& cb)
|
bool FileReader::OpenDecompressor(FileReader &parent, Size length, int method, bool seekable, const std::function<void(const char*)>& cb)
|
||||||
{
|
{
|
||||||
DecompressorBase *dec = nullptr;
|
DecompressorBase *dec = nullptr;
|
||||||
switch (method)
|
FileReader *p = &parent;
|
||||||
|
switch (method & ~METHOD_TRANSFEROWNER)
|
||||||
{
|
{
|
||||||
case METHOD_DEFLATE:
|
case METHOD_DEFLATE:
|
||||||
case METHOD_ZLIB:
|
case METHOD_ZLIB:
|
||||||
dec = new DecompressorZ(parent, method == METHOD_DEFLATE, cb);
|
dec = new DecompressorZ(p, method == METHOD_DEFLATE, cb);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case METHOD_BZIP2:
|
case METHOD_BZIP2:
|
||||||
dec = new DecompressorBZ2(parent, cb);
|
dec = new DecompressorBZ2(p, cb);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case METHOD_LZMA:
|
case METHOD_LZMA:
|
||||||
dec = new DecompressorLZMA(parent, length, cb);
|
dec = new DecompressorLZMA(p, length, cb);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case METHOD_LZSS:
|
case METHOD_LZSS:
|
||||||
dec = new DecompressorLZSS(parent, cb);
|
dec = new DecompressorLZSS(p, cb);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// todo: METHOD_IMPLODE, METHOD_SHRINK
|
// todo: METHOD_IMPLODE, METHOD_SHRINK
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (method & METHOD_TRANSFEROWNER)
|
||||||
|
{
|
||||||
|
dec->SetOwnsReader();
|
||||||
|
}
|
||||||
|
|
||||||
dec->Length = (long)length;
|
dec->Length = (long)length;
|
||||||
if (!seekable)
|
if (!seekable)
|
||||||
{
|
{
|
||||||
|
@ -666,3 +678,117 @@ bool FileReader::OpenDecompressor(FileReader &parent, Size length, int method, b
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
CompressedFileWriter::CompressedFileWriter(FileWriter *targ, bool transfer)
|
||||||
|
{
|
||||||
|
target = targ;
|
||||||
|
zipstream = new z_stream;
|
||||||
|
|
||||||
|
compressedSize = 0;
|
||||||
|
zipstream->next_in = Z_NULL;
|
||||||
|
zipstream->avail_in = 0;
|
||||||
|
zipstream->zalloc = Z_NULL;
|
||||||
|
zipstream->zfree = Z_NULL;
|
||||||
|
int err = deflateInit2 (zipstream, Z_BEST_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY);
|
||||||
|
if (err != Z_OK)
|
||||||
|
{
|
||||||
|
delete zipstream;
|
||||||
|
zipstream = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
zipstream->next_out = outbuf;
|
||||||
|
zipstream->avail_out = sizeof(outbuf);
|
||||||
|
ownsWriter = transfer;
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
CompressedFileWriter::CompressedFileWriter(FILE *targ)
|
||||||
|
: CompressedFileWriter(new FileWriter(targ), true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
size_t CompressedFileWriter::Write(const void *buffer, size_t bytes)
|
||||||
|
{
|
||||||
|
size_t wrote = 0;
|
||||||
|
size_t towrite = bytes;
|
||||||
|
|
||||||
|
zipstream->next_in = (Bytef *)buffer;
|
||||||
|
while (towrite > 0)
|
||||||
|
{
|
||||||
|
auto chunk = std::min(towrite, (size_t)0x40000000);
|
||||||
|
zipstream->avail_in = chunk;
|
||||||
|
buffer = ((char*)buffer) + chunk;
|
||||||
|
towrite -= chunk;
|
||||||
|
|
||||||
|
while (zipstream->avail_in != 0)
|
||||||
|
{
|
||||||
|
if (zipstream->avail_out == 0)
|
||||||
|
{
|
||||||
|
zipstream->next_out = outbuf;
|
||||||
|
zipstream->avail_out = 1024;
|
||||||
|
wrote += 1024;
|
||||||
|
target->Write(outbuf, 1024);
|
||||||
|
}
|
||||||
|
deflate (zipstream, Z_NO_FLUSH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
compressedSize += wrote;
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
void CompressedFileWriter::Close()
|
||||||
|
{
|
||||||
|
if (!zipstream) return;
|
||||||
|
// Flush the zlib stream buffer.
|
||||||
|
|
||||||
|
for (bool done = false;;)
|
||||||
|
{
|
||||||
|
auto len = sizeof(outbuf) - zipstream->avail_out;
|
||||||
|
if (len != 0)
|
||||||
|
{
|
||||||
|
compressedSize += len;
|
||||||
|
|
||||||
|
target->Write(outbuf, len);
|
||||||
|
zipstream->next_out = outbuf;
|
||||||
|
zipstream->avail_out = sizeof(outbuf);
|
||||||
|
}
|
||||||
|
if (done)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
auto err = deflate (zipstream, Z_FINISH);
|
||||||
|
done = zipstream->avail_out != 0 || err == Z_STREAM_END;
|
||||||
|
if (err != Z_STREAM_END && err != Z_OK)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deflateEnd (zipstream);
|
||||||
|
delete zipstream;
|
||||||
|
zipstream = nullptr;
|
||||||
|
}
|
||||||
|
|
|
@ -36,8 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
# include "animvpx.h"
|
# include "animvpx.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,6 @@
|
||||||
#include "rts.h"
|
#include "rts.h"
|
||||||
#include "gamecontrol.h"
|
#include "gamecontrol.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "common_game.h"
|
#include "common_game.h"
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
#include "collections.h"
|
#include "collections.h"
|
||||||
#include "gamecontrol.h"
|
#include "gamecontrol.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "renderlayer.h"
|
#include "renderlayer.h"
|
||||||
#include "cmdline.h"
|
#include "cmdline.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
#if defined RENDERTYPESDL && defined SDL_TARGET && SDL_TARGET > 1
|
#if defined RENDERTYPESDL && defined SDL_TARGET && SDL_TARGET > 1
|
||||||
# include "sdl_inc.h"
|
# include "sdl_inc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,14 +31,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "i_specialpaths.h"
|
#include "i_specialpaths.h"
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
char g_firstDemoFile[BMAX_PATH];
|
char g_firstDemoFile[BMAX_PATH];
|
||||||
|
|
||||||
buildvfs_FILE g_demo_filePtr{}; // write
|
FileWriter *g_demo_filePtr{}; // write
|
||||||
FileReader g_demo_recFilePtr; // read
|
FileReader g_demo_recFilePtr; // read
|
||||||
|
|
||||||
int32_t g_demo_cnt;
|
int32_t g_demo_cnt;
|
||||||
|
@ -65,7 +63,6 @@ static void Demo_RestoreModes(int32_t menu)
|
||||||
g_player[myconnectindex].ps->gm |= MODE_DEMO;
|
g_player[myconnectindex].ps->gm |= MODE_DEMO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is utterly gross. Global configuration should not be manipulated like this.
|
|
||||||
void Demo_PrepareWarp(void)
|
void Demo_PrepareWarp(void)
|
||||||
{
|
{
|
||||||
if (!g_demo_paused)
|
if (!g_demo_paused)
|
||||||
|
@ -163,23 +160,24 @@ void G_OpenDemoWrite(void)
|
||||||
|
|
||||||
demonum++;
|
demonum++;
|
||||||
|
|
||||||
g_demo_filePtr = buildvfs_fopen_read(demofn);
|
g_demo_filePtr = FileWriter::Open(demofn);
|
||||||
if (g_demo_filePtr == NULL)
|
if (g_demo_filePtr == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
delete g_demo_filePtr;
|
||||||
}
|
}
|
||||||
while (1);
|
while (1);
|
||||||
|
|
||||||
g_demo_filePtr = buildvfs_fopen_write(demofn);
|
g_demo_filePtr = FileWriter::Open(demofn);
|
||||||
if (g_demo_filePtr == NULL)
|
if (g_demo_filePtr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
i=sv_saveandmakesnapshot(g_demo_filePtr, nullptr, -1, demorec_diffs_cvar, demorec_diffcompress_cvar,
|
i=sv_saveandmakesnapshot(*g_demo_filePtr, nullptr, -1, demorec_diffs_cvar, demorec_diffcompress_cvar,
|
||||||
(demorec_seeds_cvar<<1));
|
(demorec_seeds_cvar<<1));
|
||||||
if (i)
|
if (i)
|
||||||
{
|
{
|
||||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
delete g_demo_filePtr;
|
||||||
|
g_demo_filePtr = nullptr;
|
||||||
error_wopen_demo:
|
error_wopen_demo:
|
||||||
Bstrcpy(apStrings[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE CONSOLE FOR DETAILS.");
|
Bstrcpy(apStrings[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE CONSOLE FOR DETAILS.");
|
||||||
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
|
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
|
||||||
|
@ -232,13 +230,13 @@ static void Demo_WriteSync()
|
||||||
{
|
{
|
||||||
int16_t tmpreccnt;
|
int16_t tmpreccnt;
|
||||||
|
|
||||||
buildvfs_fwrite("sYnC", 4, 1, g_demo_filePtr);
|
g_demo_filePtr->Write("sYnC", 4);
|
||||||
tmpreccnt = (int16_t)ud.reccnt;
|
tmpreccnt = (int16_t)ud.reccnt;
|
||||||
buildvfs_fwrite(&tmpreccnt, sizeof(int16_t), 1, g_demo_filePtr);
|
g_demo_filePtr->Write(&tmpreccnt, sizeof(int16_t));
|
||||||
if (demorec_seeds)
|
if (demorec_seeds)
|
||||||
buildvfs_fwrite(g_demo_seedbuf, 1, ud.reccnt, g_demo_filePtr);
|
g_demo_filePtr->Write(g_demo_seedbuf, ud.reccnt);
|
||||||
|
|
||||||
buildvfs_fwrite(recsync, sizeof(input_t), ud.reccnt, g_demo_filePtr);
|
g_demo_filePtr->Write(recsync, sizeof(input_t)* ud.reccnt);
|
||||||
|
|
||||||
ud.reccnt = 0;
|
ud.reccnt = 0;
|
||||||
}
|
}
|
||||||
|
@ -275,16 +273,14 @@ void G_CloseDemoWrite(void)
|
||||||
if (ud.reccnt > 0)
|
if (ud.reccnt > 0)
|
||||||
Demo_WriteSync();
|
Demo_WriteSync();
|
||||||
|
|
||||||
buildvfs_fwrite("EnD!", 4, 1, g_demo_filePtr);
|
g_demo_filePtr->Write("EnD!", 4);
|
||||||
|
|
||||||
// lastly, we need to write the number of written recsyncs to the demo file
|
// lastly, we need to write the number of written recsyncs to the demo file
|
||||||
if (buildvfs_fseek_abs(g_demo_filePtr, offsetof(savehead_t, reccnt)))
|
g_demo_filePtr->Write(&g_demo_cnt, sizeof(g_demo_cnt));
|
||||||
perror("G_CloseDemoWrite: final fseek");
|
|
||||||
else
|
|
||||||
buildvfs_fwrite(&g_demo_cnt, sizeof(g_demo_cnt), 1, g_demo_filePtr);
|
|
||||||
|
|
||||||
ud.recstat = ud.m_recstat = 0;
|
ud.recstat = ud.m_recstat = 0;
|
||||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
delete g_demo_filePtr;
|
||||||
|
g_demo_filePtr = nullptr;
|
||||||
|
|
||||||
sv_freemem();
|
sv_freemem();
|
||||||
|
|
||||||
|
@ -416,7 +412,8 @@ static void Demo_FinishProfile(void)
|
||||||
dn, gms, (gms*1000.0)/nt);
|
dn, gms, (gms*1000.0)/nt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nf > 0) {
|
if (nf > 0)
|
||||||
|
{
|
||||||
OSD_Printf("== demo %d: %d frames (%d frames/gametic)\n", dn, nf, g_demo_profile-1);
|
OSD_Printf("== demo %d: %d frames (%d frames/gametic)\n", dn, nf, g_demo_profile-1);
|
||||||
OSD_Printf("== demo %d drawrooms times: %.03f s (%.03f ms/frame)\n",
|
OSD_Printf("== demo %d drawrooms times: %.03f s (%.03f ms/frame)\n",
|
||||||
dn, dms1/1000.0, dms1/nf);
|
dn, dms1/1000.0, dms1/nf);
|
||||||
|
|
|
@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#define demo_h_
|
#define demo_h_
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "vfs.h"
|
|
||||||
#include "cache1d.h"
|
#include "cache1d.h"
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
@ -32,7 +31,7 @@ BEGIN_DUKE_NS
|
||||||
#define DEMOFN_FMT "edemo%03d.edm"
|
#define DEMOFN_FMT "edemo%03d.edm"
|
||||||
#define MAXDEMOS 1000
|
#define MAXDEMOS 1000
|
||||||
|
|
||||||
extern buildvfs_FILE g_demo_filePtr;
|
extern FileWriter * g_demo_filePtr;
|
||||||
extern char g_firstDemoFile[BMAX_PATH];
|
extern char g_firstDemoFile[BMAX_PATH];
|
||||||
|
|
||||||
extern int32_t g_demo_cnt;
|
extern int32_t g_demo_cnt;
|
||||||
|
|
|
@ -46,8 +46,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "m_argv.h"
|
#include "m_argv.h"
|
||||||
#include "filesystem/filesystem.h"
|
#include "filesystem/filesystem.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
// Uncomment to prevent anything except mirrors from drawing. It is sensible to
|
// Uncomment to prevent anything except mirrors from drawing. It is sensible to
|
||||||
// also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h.
|
// also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h.
|
||||||
//#define DEBUG_MIRRORS_ONLY
|
//#define DEBUG_MIRRORS_ONLY
|
||||||
|
@ -261,8 +259,11 @@ void G_GameExit(const char *msg)
|
||||||
|
|
||||||
if (ud.recstat == 1)
|
if (ud.recstat == 1)
|
||||||
G_CloseDemoWrite();
|
G_CloseDemoWrite();
|
||||||
else if (ud.recstat == 2)
|
else if (ud.recstat == 2)
|
||||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
{
|
||||||
|
delete g_demo_filePtr;
|
||||||
|
g_demo_filePtr = nullptr;
|
||||||
|
}
|
||||||
// JBF: fixes crash on demo playback
|
// JBF: fixes crash on demo playback
|
||||||
// PK: modified from original
|
// PK: modified from original
|
||||||
|
|
||||||
|
@ -293,9 +294,6 @@ void G_GameExit(const char *msg)
|
||||||
I_Error("%s", msg);
|
I_Error("%s", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bfflush(NULL);
|
|
||||||
|
|
||||||
throw ExitEvent(0);
|
throw ExitEvent(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1165,10 +1163,8 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
|
||||||
|
|
||||||
void G_DumpDebugInfo(void)
|
void G_DumpDebugInfo(void)
|
||||||
{
|
{
|
||||||
#if !defined LUNATIC
|
|
||||||
static char const s_WEAPON[] = "WEAPON";
|
static char const s_WEAPON[] = "WEAPON";
|
||||||
int32_t i,j,x;
|
int32_t i,j,x;
|
||||||
// buildvfs_FILE fp = buildvfs_fopen_write("condebug.log");
|
|
||||||
|
|
||||||
VM_ScriptInfo(insptr, 64);
|
VM_ScriptInfo(insptr, 64);
|
||||||
buildprint("\nCurrent gamevar values:\n");
|
buildprint("\nCurrent gamevar values:\n");
|
||||||
|
@ -1232,17 +1228,12 @@ void G_DumpDebugInfo(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Gv_DumpValues();
|
Gv_DumpValues();
|
||||||
// buildvfs_fclose(fp);
|
|
||||||
#endif
|
|
||||||
saveboard("debug.map", &g_player[myconnectindex].ps->pos, fix16_to_int(g_player[myconnectindex].ps->q16ang),
|
|
||||||
g_player[myconnectindex].ps->cursectnum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if <set_movflag_uncond> is true, set the moveflag unconditionally,
|
// if <set_movflag_uncond> is true, set the moveflag unconditionally,
|
||||||
// else only if it equals 0.
|
// else only if it equals 0.
|
||||||
static int32_t G_InitActor(int32_t i, int32_t tilenum, int32_t set_movflag_uncond)
|
static int32_t G_InitActor(int32_t i, int32_t tilenum, int32_t set_movflag_uncond)
|
||||||
{
|
{
|
||||||
#if !defined LUNATIC
|
|
||||||
if (g_tile[tilenum].execPtr)
|
if (g_tile[tilenum].execPtr)
|
||||||
{
|
{
|
||||||
SH(i) = *(g_tile[tilenum].execPtr);
|
SH(i) = *(g_tile[tilenum].execPtr);
|
||||||
|
@ -1254,26 +1245,6 @@ static int32_t G_InitActor(int32_t i, int32_t tilenum, int32_t set_movflag_uncon
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (El_HaveActor(tilenum))
|
|
||||||
{
|
|
||||||
// ^^^ C-CON takes precedence for now.
|
|
||||||
const el_actor_t *a = &g_elActors[tilenum];
|
|
||||||
auto movflagsptr = &AC_MOVFLAGS(&sprite[i], &actor[i]);
|
|
||||||
|
|
||||||
SH(i) = a->strength;
|
|
||||||
AC_ACTION_ID(actor[i].t_data) = a->act.id;
|
|
||||||
AC_MOVE_ID(actor[i].t_data) = a->mov.id;
|
|
||||||
Bmemcpy(&actor[i].ac, &a->act.ac, sizeof(struct action));
|
|
||||||
Bmemcpy(&actor[i].mv, &a->mov.mv, sizeof(struct move));
|
|
||||||
|
|
||||||
if (set_movflag_uncond || *movflagsptr == 0)
|
|
||||||
*movflagsptr = a->movflags;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5709,7 +5680,6 @@ void G_Shutdown(void)
|
||||||
CONTROL_Shutdown();
|
CONTROL_Shutdown();
|
||||||
engineUnInit();
|
engineUnInit();
|
||||||
G_Cleanup();
|
G_Cleanup();
|
||||||
Bfflush(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -5992,8 +5962,6 @@ static void G_Startup(void)
|
||||||
G_LoadLookups();
|
G_LoadLookups();
|
||||||
|
|
||||||
screenpeek = myconnectindex;
|
screenpeek = myconnectindex;
|
||||||
|
|
||||||
Bfflush(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void P_SetupMiscInputSettings(void)
|
static void P_SetupMiscInputSettings(void)
|
||||||
|
|
|
@ -37,8 +37,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
#include "m_argv.h"
|
#include "m_argv.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
#define LINE_NUMBER (g_lineNumber << 12)
|
#define LINE_NUMBER (g_lineNumber << 12)
|
||||||
|
|
|
@ -38,8 +38,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
#include "debugbreak.h"
|
#include "debugbreak.h"
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
|
@ -27,8 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "savegame.h"
|
#include "savegame.h"
|
||||||
#include "gamecvars.h"
|
#include "gamecvars.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
#define gamevars_c_
|
#define gamevars_c_
|
||||||
|
@ -236,34 +234,34 @@ corrupt:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that this entire function is totally architecture dependent and needs to be fixed (which won't be easy...)
|
// Note that this entire function is totally architecture dependent and needs to be fixed (which won't be easy...)
|
||||||
void Gv_WriteSave(buildvfs_FILE fil)
|
void Gv_WriteSave(FileWriter &fil)
|
||||||
{
|
{
|
||||||
// AddLog("Saving Game Vars to File");
|
// AddLog("Saving Game Vars to File");
|
||||||
buildvfs_fwrite("BEG: EDuke32", 12, 1, fil);
|
fil.Write("BEG: EDuke32", 12);
|
||||||
|
|
||||||
buildvfs_fwrite(&g_gameVarCount,sizeof(g_gameVarCount),1,fil);
|
fil.Write(&g_gameVarCount,sizeof(g_gameVarCount));
|
||||||
|
|
||||||
for (bssize_t i = 0; i < g_gameVarCount; i++)
|
for (bssize_t i = 0; i < g_gameVarCount; i++)
|
||||||
{
|
{
|
||||||
buildvfs_fwrite(&(aGameVars[i]), sizeof(gamevar_t), 1, fil);
|
fil.Write(&(aGameVars[i]), sizeof(gamevar_t));
|
||||||
buildvfs_fwrite(aGameVars[i].szLabel, sizeof(uint8_t) * MAXVARLABEL, 1, fil);
|
fil.Write(aGameVars[i].szLabel, sizeof(uint8_t) * MAXVARLABEL);
|
||||||
|
|
||||||
if (aGameVars[i].flags & GAMEVAR_PERPLAYER)
|
if (aGameVars[i].flags & GAMEVAR_PERPLAYER)
|
||||||
buildvfs_fwrite(aGameVars[i].pValues, sizeof(intptr_t) * MAXPLAYERS, 1, fil);
|
fil.Write(aGameVars[i].pValues, sizeof(intptr_t) * MAXPLAYERS);
|
||||||
else if (aGameVars[i].flags & GAMEVAR_PERACTOR)
|
else if (aGameVars[i].flags & GAMEVAR_PERACTOR)
|
||||||
buildvfs_fwrite(aGameVars[i].pValues, sizeof(intptr_t) * MAXSPRITES, 1, fil);
|
fil.Write(aGameVars[i].pValues, sizeof(intptr_t) * MAXSPRITES);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildvfs_fwrite(&g_gameArrayCount,sizeof(g_gameArrayCount),1,fil);
|
fil.Write(&g_gameArrayCount,sizeof(g_gameArrayCount));
|
||||||
|
|
||||||
for (bssize_t i = 0; i < g_gameArrayCount; i++)
|
for (bssize_t i = 0; i < g_gameArrayCount; i++)
|
||||||
{
|
{
|
||||||
// write for .size and .dwFlags (the rest are pointers):
|
// write for .size and .dwFlags (the rest are pointers):
|
||||||
buildvfs_fwrite(&aGameArrays[i], sizeof(gamearray_t), 1, fil);
|
fil.Write(&aGameArrays[i], sizeof(gamearray_t));
|
||||||
buildvfs_fwrite(aGameArrays[i].szLabel, sizeof(uint8_t) * MAXARRAYLABEL, 1, fil);
|
fil.Write(aGameArrays[i].szLabel, sizeof(uint8_t) * MAXARRAYLABEL);
|
||||||
|
|
||||||
if ((aGameArrays[i].flags & GAMEARRAY_SYSTEM) != GAMEARRAY_SYSTEM)
|
if ((aGameArrays[i].flags & GAMEARRAY_SYSTEM) != GAMEARRAY_SYSTEM)
|
||||||
buildvfs_fwrite(aGameArrays[i].pValues, Gv_GetArrayAllocSize(i), 1, fil);
|
fil.Write(aGameArrays[i].pValues, Gv_GetArrayAllocSize(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t savedstate[MAXVOLUMES * MAXLEVELS];
|
uint8_t savedstate[MAXVOLUMES * MAXLEVELS];
|
||||||
|
@ -273,7 +271,7 @@ void Gv_WriteSave(buildvfs_FILE fil)
|
||||||
if (g_mapInfo[i].savedstate != NULL)
|
if (g_mapInfo[i].savedstate != NULL)
|
||||||
savedstate[i] = 1;
|
savedstate[i] = 1;
|
||||||
|
|
||||||
buildvfs_fwrite(savedstate, sizeof(savedstate), 1, fil);
|
fil.Write(savedstate, sizeof(savedstate));
|
||||||
|
|
||||||
for (bssize_t i = 0; i < (MAXVOLUMES * MAXLEVELS); i++)
|
for (bssize_t i = 0; i < (MAXVOLUMES * MAXLEVELS); i++)
|
||||||
{
|
{
|
||||||
|
@ -281,27 +279,27 @@ void Gv_WriteSave(buildvfs_FILE fil)
|
||||||
|
|
||||||
mapstate_t &sv = *g_mapInfo[i].savedstate;
|
mapstate_t &sv = *g_mapInfo[i].savedstate;
|
||||||
|
|
||||||
buildvfs_fwrite(g_mapInfo[i].savedstate, sizeof(mapstate_t), 1, fil);
|
fil.Write(g_mapInfo[i].savedstate, sizeof(mapstate_t));
|
||||||
|
|
||||||
for (bssize_t j = 0; j < g_gameVarCount; j++)
|
for (bssize_t j = 0; j < g_gameVarCount; j++)
|
||||||
{
|
{
|
||||||
if (aGameVars[j].flags & GAMEVAR_NORESET) continue;
|
if (aGameVars[j].flags & GAMEVAR_NORESET) continue;
|
||||||
if (aGameVars[j].flags & GAMEVAR_PERPLAYER)
|
if (aGameVars[j].flags & GAMEVAR_PERPLAYER)
|
||||||
buildvfs_fwrite(sv.vars[j], sizeof(intptr_t) * MAXPLAYERS, 1, fil);
|
fil.Write(sv.vars[j], sizeof(intptr_t) * MAXPLAYERS);
|
||||||
else if (aGameVars[j].flags & GAMEVAR_PERACTOR)
|
else if (aGameVars[j].flags & GAMEVAR_PERACTOR)
|
||||||
buildvfs_fwrite(sv.vars[j], sizeof(intptr_t) * MAXSPRITES, 1, fil);
|
fil.Write(sv.vars[j], sizeof(intptr_t) * MAXSPRITES);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildvfs_fwrite(sv.arraysiz, sizeof(sv.arraysiz), 1, fil);
|
fil.Write(sv.arraysiz, sizeof(sv.arraysiz));
|
||||||
|
|
||||||
for (bssize_t j = 0; j < g_gameArrayCount; j++)
|
for (bssize_t j = 0; j < g_gameArrayCount; j++)
|
||||||
if (aGameArrays[j].flags & GAMEARRAY_RESTORE)
|
if (aGameArrays[j].flags & GAMEARRAY_RESTORE)
|
||||||
{
|
{
|
||||||
buildvfs_fwrite(sv.arrays[j], Gv_GetArrayAllocSizeForCount(j, sv.arraysiz[j]), 1, fil);
|
fil.Write(sv.arrays[j], Gv_GetArrayAllocSizeForCount(j, sv.arraysiz[j]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buildvfs_fwrite("EOF: EDuke32", 12, 1, fil);
|
fil.Write("EOF: EDuke32", 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gv_DumpValues(void)
|
void Gv_DumpValues(void)
|
||||||
|
|
|
@ -26,8 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "fix16.hpp"
|
#include "fix16.hpp"
|
||||||
#include "gamedef.h"
|
#include "gamedef.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
|
||||||
|
@ -159,7 +157,7 @@ void Gv_InitWeaponPointers(void);
|
||||||
void Gv_RefreshPointers(void);
|
void Gv_RefreshPointers(void);
|
||||||
void Gv_ResetVars(void);
|
void Gv_ResetVars(void);
|
||||||
int Gv_ReadSave(FileReader &kFile);
|
int Gv_ReadSave(FileReader &kFile);
|
||||||
void Gv_WriteSave(buildvfs_FILE fil);
|
void Gv_WriteSave(FileWriter &fil);
|
||||||
void Gv_Clear(void);
|
void Gv_Clear(void);
|
||||||
#else
|
#else
|
||||||
extern int32_t g_noResetVars;
|
extern int32_t g_noResetVars;
|
||||||
|
|
|
@ -41,8 +41,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "enet.h"
|
#include "enet.h"
|
||||||
#include "m_crc32.h"
|
#include "m_crc32.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
// Data needed even if netcode is disabled
|
// Data needed even if netcode is disabled
|
||||||
|
|
|
@ -32,8 +32,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "savegame.h"
|
#include "savegame.h"
|
||||||
#include "sbar.h"
|
#include "sbar.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5729,15 +5729,15 @@ int portableBackupSave(const char * path, const char * name, int volume, int lev
|
||||||
|
|
||||||
char * encoded = sjson_stringify(ctx, root, " ");
|
char * encoded = sjson_stringify(ctx, root, " ");
|
||||||
|
|
||||||
buildvfs_FILE fil = buildvfs_fopen_write(fn);
|
FileWriter *fil = FileWriter::Open(fn);
|
||||||
if (!fil)
|
if (!fil)
|
||||||
{
|
{
|
||||||
sjson_destroy_context(ctx);
|
sjson_destroy_context(ctx);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildvfs_fwrite(encoded, strlen(encoded), 1, fil);
|
fil->Write(encoded, strlen(encoded));
|
||||||
buildvfs_fclose(fil);
|
delete fil;
|
||||||
|
|
||||||
sjson_free_string(ctx, encoded);
|
sjson_free_string(ctx, encoded);
|
||||||
sjson_destroy_context(ctx);
|
sjson_destroy_context(ctx);
|
||||||
|
|
|
@ -28,9 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "duke3d.h"
|
#include "duke3d.h"
|
||||||
#include "menus.h"
|
#include "menus.h"
|
||||||
#include "savegame.h"
|
#include "savegame.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
static uint8_t precachehightile[2][(MAXTILES+7)>>3];
|
static uint8_t precachehightile[2][(MAXTILES+7)>>3];
|
||||||
|
|
|
@ -31,8 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "gamecontrol.h"
|
#include "gamecontrol.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
|
||||||
|
@ -152,14 +150,36 @@ uint16_t g_nummenusaves;
|
||||||
static menusave_t * g_internalsaves;
|
static menusave_t * g_internalsaves;
|
||||||
static uint16_t g_numinternalsaves;
|
static uint16_t g_numinternalsaves;
|
||||||
|
|
||||||
|
static FileReader OpenSavegame(const char *fn)
|
||||||
|
{
|
||||||
|
auto file = fopenFileReader(fn, 0);
|
||||||
|
if (!file.isOpen())
|
||||||
|
return file;
|
||||||
|
|
||||||
|
char buffer[13];
|
||||||
|
file.Read(buffer, 13);
|
||||||
|
if (memcmp(buffer, "DEMOLITION_ED", 13))
|
||||||
|
return FileReader();
|
||||||
|
|
||||||
|
FileReader fr;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fr.OpenDecompressor(file, file.GetLength()-13, METHOD_DEFLATE, false, nullptr);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error & err)
|
||||||
|
{
|
||||||
|
Printf("%s: %s\n", fn, err.what());
|
||||||
|
}
|
||||||
|
return fr;
|
||||||
|
}
|
||||||
|
|
||||||
static void ReadSaveGameHeaders_CACHE1D(TArray<FString> &saves)
|
static void ReadSaveGameHeaders_CACHE1D(TArray<FString> &saves)
|
||||||
{
|
{
|
||||||
savehead_t h;
|
savehead_t h;
|
||||||
|
|
||||||
for (auto &save : saves)
|
for (FString &save : saves)
|
||||||
{
|
{
|
||||||
char const * fn = save;
|
auto fil = OpenSavegame(save);
|
||||||
auto fil = fopenFileReader(fn, 0);
|
|
||||||
if (!fil.isOpen())
|
if (!fil.isOpen())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -176,7 +196,7 @@ static void ReadSaveGameHeaders_CACHE1D(TArray<FString> &saves)
|
||||||
{
|
{
|
||||||
if (FURY)
|
if (FURY)
|
||||||
{
|
{
|
||||||
FStringf extfn("%s.ext", fn);
|
FStringf extfn("%s.ext", save.GetChars());
|
||||||
auto extfil = fopenFileReader(extfn, 0);
|
auto extfil = fopenFileReader(extfn, 0);
|
||||||
if (extfil.isOpen())
|
if (extfil.isOpen())
|
||||||
{
|
{
|
||||||
|
@ -191,7 +211,7 @@ static void ReadSaveGameHeaders_CACHE1D(TArray<FString> &saves)
|
||||||
|
|
||||||
msv.isAutoSave = h.isAutoSave();
|
msv.isAutoSave = h.isAutoSave();
|
||||||
|
|
||||||
strncpy(msv.brief.path, fn, ARRAY_SIZE(msv.brief.path));
|
strncpy(msv.brief.path, save.GetChars(), ARRAY_SIZE(msv.brief.path));
|
||||||
++g_numinternalsaves;
|
++g_numinternalsaves;
|
||||||
|
|
||||||
if (k >= 0 && h.savename[0] != '\0')
|
if (k >= 0 && h.savename[0] != '\0')
|
||||||
|
@ -206,7 +226,7 @@ static void ReadSaveGameHeaders_CACHE1D(TArray<FString> &saves)
|
||||||
|
|
||||||
static void ReadSaveGameHeaders_Internal(void)
|
static void ReadSaveGameHeaders_Internal(void)
|
||||||
{
|
{
|
||||||
FString pattern = M_GetSavegamesPath() + "*.esv";
|
FString pattern = M_GetSavegamesPath() + "*.bsv";
|
||||||
TArray<FString> saves;
|
TArray<FString> saves;
|
||||||
D_AddWildFile(saves, pattern);
|
D_AddWildFile(saves, pattern);
|
||||||
// potentially overallocating but programmatically simple
|
// potentially overallocating but programmatically simple
|
||||||
|
@ -293,7 +313,7 @@ void ReadSaveGameHeaders(void)
|
||||||
|
|
||||||
int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
||||||
{
|
{
|
||||||
auto fil = fopenFileReader(fn, 0);
|
auto fil = OpenSavegame(fn);
|
||||||
if (!fil.isOpen())
|
if (!fil.isOpen())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -342,7 +362,7 @@ int32_t G_LoadPlayer(savebrief_t & sv)
|
||||||
int level = -1;
|
int level = -1;
|
||||||
int skill = -1;
|
int skill = -1;
|
||||||
|
|
||||||
auto fil = fopenFileReader(sv.path, 0);
|
auto fil = OpenSavegame(sv.path);
|
||||||
|
|
||||||
if (fil.isOpen())
|
if (fil.isOpen())
|
||||||
{
|
{
|
||||||
|
@ -569,7 +589,7 @@ int32_t G_LoadPlayer(savebrief_t & sv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fil = fopenFileReader(sv.path, 0);
|
auto fil = OpenSavegame(sv.path);
|
||||||
|
|
||||||
if (!fil.isOpen())
|
if (!fil.isOpen())
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -695,9 +715,9 @@ void G_DeleteSave(savebrief_t const & sv)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildvfs_unlink(temp);
|
remove(temp);
|
||||||
Bstrcat(temp, ".ext");
|
Bstrcat(temp, ".ext");
|
||||||
buildvfs_unlink(temp);
|
remove(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void G_DeleteOldSaves(void)
|
void G_DeleteOldSaves(void)
|
||||||
|
@ -738,92 +758,77 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
|
||||||
Net_WaitForServer();
|
Net_WaitForServer();
|
||||||
ready2send = 0;
|
ready2send = 0;
|
||||||
|
|
||||||
char fn[BMAX_PATH];
|
FString fn;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
buildvfs_FILE fil;
|
FileWriter *fil;
|
||||||
|
|
||||||
if (sv.isValid())
|
if (sv.isValid())
|
||||||
{
|
{
|
||||||
if (snprintf(fn, sizeof(fn), "%s%s", M_GetSavegamesPath().GetChars(), sv.path))
|
fn.Format("%s%s", M_GetSavegamesPath().GetChars(), sv.path);
|
||||||
{
|
fil = FileWriter::Open(fn);
|
||||||
OSD_Printf("G_SavePlayer: file name \"%s\" too long\n", sv.path);
|
}
|
||||||
goto saveproblem;
|
else
|
||||||
}
|
{
|
||||||
fil = buildvfs_fopen_write(fn);
|
static char const SaveName[] = "save0000.bsv";
|
||||||
}
|
fn.Format("%s%s", M_GetSavegamesPath().GetChars(), SaveName);
|
||||||
else
|
|
||||||
{
|
|
||||||
static char const SaveName[] = "save0000.esv";
|
|
||||||
int const len = snprintf(fn, ARRAY_SIZE(fn), "%s%s", M_GetSavegamesPath().GetChars(), SaveName);
|
|
||||||
if (len >= ARRAY_SSIZE(fn)-1)
|
|
||||||
{
|
|
||||||
OSD_Printf("G_SavePlayer: could not form automatic save path\n");
|
|
||||||
goto saveproblem;
|
|
||||||
}
|
|
||||||
char * zeros = fn + (len-8);
|
|
||||||
fil = savecounter.opennextfile(fn, zeros);
|
|
||||||
savecounter.count++;
|
|
||||||
// don't copy the mod dir into sv.path
|
|
||||||
Bstrcpy(sv.path, fn + (len-(ARRAY_SIZE(SaveName)-1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fil)
|
auto fnp = fn.LockBuffer();
|
||||||
{
|
char* zeros = fnp + (fn.Len() - 8);
|
||||||
OSD_Printf("G_SavePlayer: failed opening \"%s\" for writing: %s\n",
|
fil = savecounter.opennextfile(fnp, zeros);
|
||||||
fn, strerror(errno));
|
fn.UnlockBuffer();
|
||||||
goto saveproblem;
|
savecounter.count++;
|
||||||
}
|
// don't copy the mod dir into sv.path
|
||||||
|
Bstrcpy(sv.path, fn + (fn.Len() - (ARRAY_SIZE(SaveName) - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
sv.isExt = 0;
|
if (!fil)
|
||||||
|
{
|
||||||
|
OSD_Printf("G_SavePlayer: failed opening \"%s\" for writing: %s\n",
|
||||||
|
fn.GetChars(), strerror(errno));
|
||||||
|
ready2send = 1;
|
||||||
|
Net_WaitForServer();
|
||||||
|
|
||||||
// temporary hack
|
G_RestoreTimers();
|
||||||
ud.user_map = G_HaveUserMap();
|
ototalclock = totalclock;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fil->Write("DEMOLITION_ED", 13);
|
||||||
|
CompressedFileWriter fw(fil, true);
|
||||||
|
|
||||||
#ifdef POLYMER
|
sv.isExt = 0;
|
||||||
if (videoGetRenderMode() == REND_POLYMER)
|
|
||||||
polymer_resetlights();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
VM_OnEvent(EVENT_SAVEGAME, g_player[myconnectindex].ps->i, myconnectindex);
|
// temporary hack
|
||||||
|
ud.user_map = G_HaveUserMap();
|
||||||
|
|
||||||
portableBackupSave(sv.path, sv.name, ud.last_stateless_volume, ud.last_stateless_level);
|
VM_OnEvent(EVENT_SAVEGAME, g_player[myconnectindex].ps->i, myconnectindex);
|
||||||
|
|
||||||
// SAVE!
|
portableBackupSave(sv.path, sv.name, ud.last_stateless_volume, ud.last_stateless_level);
|
||||||
sv_saveandmakesnapshot(fil, sv.name, 0, 0, 0, 0, isAutoSave);
|
|
||||||
|
|
||||||
buildvfs_fclose(fil);
|
// SAVE!
|
||||||
|
sv_saveandmakesnapshot(fw, sv.name, 0, 0, 0, 0, isAutoSave);
|
||||||
|
|
||||||
if (!g_netServer && ud.multimode < 2)
|
fw.Close();
|
||||||
{
|
|
||||||
OSD_Printf("Saved: %s\n", fn);
|
|
||||||
#ifdef LUNATIC
|
|
||||||
if (!g_savedOK)
|
|
||||||
Bstrcpy(apStrings[QUOTE_RESERVED4], "^10Failed Saving Game");
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
Bstrcpy(apStrings[QUOTE_RESERVED4], "Game Saved");
|
|
||||||
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
|
|
||||||
}
|
|
||||||
|
|
||||||
ready2send = 1;
|
if (!g_netServer && ud.multimode < 2)
|
||||||
Net_WaitForServer();
|
{
|
||||||
|
OSD_Printf("Saved: %s\n", fn.GetChars());
|
||||||
|
strcpy(apStrings[QUOTE_RESERVED4], "Game Saved");
|
||||||
|
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
|
||||||
|
}
|
||||||
|
|
||||||
G_RestoreTimers();
|
ready2send = 1;
|
||||||
ototalclock = totalclock;
|
Net_WaitForServer();
|
||||||
|
|
||||||
VM_OnEvent(EVENT_POSTSAVEGAME, g_player[myconnectindex].ps->i, myconnectindex);
|
G_RestoreTimers();
|
||||||
|
ototalclock = totalclock;
|
||||||
|
|
||||||
return 0;
|
VM_OnEvent(EVENT_POSTSAVEGAME, g_player[myconnectindex].ps->i, myconnectindex);
|
||||||
|
|
||||||
saveproblem:
|
return 0;
|
||||||
ready2send = 1;
|
}
|
||||||
Net_WaitForServer();
|
|
||||||
|
|
||||||
G_RestoreTimers();
|
|
||||||
ototalclock = totalclock;
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t G_LoadPlayerMaybeMulti(savebrief_t & sv)
|
int32_t G_LoadPlayerMaybeMulti(savebrief_t & sv)
|
||||||
|
@ -917,7 +922,7 @@ static inline void ds_get(const dataspec_t *spec, void **ptr, int32_t *cnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// write state to file and/or to dump
|
// write state to file and/or to dump
|
||||||
static uint8_t *writespecdata(const dataspec_t *spec, buildvfs_FILE fil, uint8_t *dump)
|
static uint8_t *writespecdata(const dataspec_t *spec, FileWriter *fil, uint8_t *dump)
|
||||||
{
|
{
|
||||||
for (; spec->flags != DS_END; spec++)
|
for (; spec->flags != DS_END; spec++)
|
||||||
{
|
{
|
||||||
|
@ -932,7 +937,7 @@ static uint8_t *writespecdata(const dataspec_t *spec, buildvfs_FILE fil, uint8_t
|
||||||
continue;
|
continue;
|
||||||
else if (spec->flags & DS_STRING)
|
else if (spec->flags & DS_STRING)
|
||||||
{
|
{
|
||||||
buildvfs_fwrite(spec->ptr, Bstrlen((const char *)spec->ptr), 1, fil); // not null-terminated!
|
fil->Write(spec->ptr, Bstrlen((const char *)spec->ptr)); // not null-terminated!
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,7 +957,7 @@ static uint8_t *writespecdata(const dataspec_t *spec, buildvfs_FILE fil, uint8_t
|
||||||
|
|
||||||
if (fil)
|
if (fil)
|
||||||
{
|
{
|
||||||
buildvfs_fwrite(ptr, spec->size, cnt, fil);
|
fil->Write(ptr, spec->size * cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dump && (spec->flags & (DS_NOCHK|DS_CMP)) == 0)
|
if (dump && (spec->flags & (DS_NOCHK|DS_CMP)) == 0)
|
||||||
|
@ -1019,7 +1024,7 @@ static int32_t readspecdata(const dataspec_t *spec, FileReader *fil, uint8_t **d
|
||||||
if (!ptr || !cnt)
|
if (!ptr || !cnt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fil != nullptr)
|
if (fil != nullptr && fil->isOpen())
|
||||||
{
|
{
|
||||||
auto const mem = (dump && (spec->flags & DS_NOCHK) == 0) ? dump : (uint8_t *)ptr;
|
auto const mem = (dump && (spec->flags & DS_NOCHK) == 0) ? dump : (uint8_t *)ptr;
|
||||||
int const siz = cnt * spec->size;
|
int const siz = cnt * spec->size;
|
||||||
|
@ -1393,11 +1398,6 @@ static const dataspec_t svgm_udnetw[] =
|
||||||
{ 0, connectpoint2, sizeof(connectpoint2), 1 },
|
{ 0, connectpoint2, sizeof(connectpoint2), 1 },
|
||||||
{ 0, &randomseed, sizeof(randomseed), 1 },
|
{ 0, &randomseed, sizeof(randomseed), 1 },
|
||||||
{ 0, &g_globalRandom, sizeof(g_globalRandom), 1 },
|
{ 0, &g_globalRandom, sizeof(g_globalRandom), 1 },
|
||||||
#ifdef LUNATIC
|
|
||||||
// Save game tic count for Lunatic because it is exposed to userland. See
|
|
||||||
// test/helixspawner.lua for an example.
|
|
||||||
{ 0, &g_moveThingsCount, sizeof(g_moveThingsCount), 1 },
|
|
||||||
#endif
|
|
||||||
// { 0, &lockclock_dummy, sizeof(lockclock), 1 },
|
// { 0, &lockclock_dummy, sizeof(lockclock), 1 },
|
||||||
{ DS_END, 0, 0, 0 }
|
{ DS_END, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
@ -1522,10 +1522,8 @@ static const dataspec_t svgm_anmisc[] =
|
||||||
{ DS_END, 0, 0, 0 }
|
{ DS_END, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined LUNATIC
|
|
||||||
static dataspec_gv_t *svgm_vars=NULL;
|
static dataspec_gv_t *svgm_vars=NULL;
|
||||||
#endif
|
static uint8_t *dosaveplayer2(FileWriter &fil, uint8_t *mem);
|
||||||
static uint8_t *dosaveplayer2(buildvfs_FILE fil, uint8_t *mem);
|
|
||||||
static int32_t doloadplayer2(FileReader &fil, uint8_t **memptr);
|
static int32_t doloadplayer2(FileReader &fil, uint8_t **memptr);
|
||||||
static void postloadplayer(int32_t savegamep);
|
static void postloadplayer(int32_t savegamep);
|
||||||
|
|
||||||
|
@ -1629,7 +1627,7 @@ static void SV_AllocSnap(int32_t allocinit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// make snapshot only if spot < 0 (demo)
|
// make snapshot only if spot < 0 (demo)
|
||||||
int32_t sv_saveandmakesnapshot(buildvfs_FILE fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave)
|
int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave)
|
||||||
{
|
{
|
||||||
savehead_t h;
|
savehead_t h;
|
||||||
|
|
||||||
|
@ -1699,24 +1697,24 @@ int32_t sv_saveandmakesnapshot(buildvfs_FILE fil, char const *name, int8_t spot,
|
||||||
|
|
||||||
|
|
||||||
// write header
|
// write header
|
||||||
buildvfs_fwrite(&h, sizeof(savehead_t), 1, fil);
|
fil.Write(&h, sizeof(savehead_t));
|
||||||
|
|
||||||
// for savegames, the file offset after the screenshot goes here;
|
// for savegames, the file offset after the screenshot goes here;
|
||||||
// for demos, we keep it 0 to signify that we didn't save one
|
// for demos, we keep it 0 to signify that we didn't save one
|
||||||
buildvfs_fwrite("\0\0\0\0", 4, 1, fil);
|
|
||||||
if (spot >= 0 && tileData(TILE_SAVESHOT))
|
if (spot >= 0 && tileData(TILE_SAVESHOT))
|
||||||
{
|
{
|
||||||
int32_t ofs;
|
|
||||||
|
int v = 64000;
|
||||||
|
fil.Write(&v, 4);
|
||||||
// write the screenshot compressed
|
// write the screenshot compressed
|
||||||
buildvfs_fwrite(tileData(TILE_SAVESHOT), 320, 200, fil);
|
fil.Write(tileData(TILE_SAVESHOT), 320*200);
|
||||||
|
|
||||||
// write the current file offset right after the header
|
|
||||||
ofs = buildvfs_ftell(fil);
|
|
||||||
buildvfs_fseek_abs(fil, sizeof(savehead_t));
|
|
||||||
buildvfs_fwrite(&ofs, 4, 1, fil);
|
|
||||||
buildvfs_fseek_abs(fil, ofs);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int v = 0;
|
||||||
|
fil.Write(&v, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (spot >= 0)
|
if (spot >= 0)
|
||||||
|
@ -1829,7 +1827,7 @@ int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h)
|
||||||
}
|
}
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
if (fil.Seek(i, FileReader::SeekSet) != i)
|
if (fil.Seek(i, FileReader::SeekCur) < 0)
|
||||||
{
|
{
|
||||||
OSD_Printf("sv_snapshot: failed skipping over the screenshot.\n");
|
OSD_Printf("sv_snapshot: failed skipping over the screenshot.\n");
|
||||||
return 8;
|
return 8;
|
||||||
|
@ -1883,7 +1881,7 @@ int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t sv_writediff(buildvfs_FILE fil)
|
uint32_t sv_writediff(FileWriter *fil)
|
||||||
{
|
{
|
||||||
uint8_t *p = svsnapshot;
|
uint8_t *p = svsnapshot;
|
||||||
uint8_t *d = svdiff;
|
uint8_t *d = svdiff;
|
||||||
|
@ -1901,10 +1899,10 @@ uint32_t sv_writediff(buildvfs_FILE fil)
|
||||||
|
|
||||||
uint32_t const diffsiz = d - svdiff;
|
uint32_t const diffsiz = d - svdiff;
|
||||||
|
|
||||||
buildvfs_fwrite("dIfF",4,1,fil);
|
fil->Write("dIfF",4);
|
||||||
buildvfs_fwrite(&diffsiz, sizeof(diffsiz), 1, fil);
|
fil->Write(&diffsiz, sizeof(diffsiz));
|
||||||
|
|
||||||
buildvfs_fwrite(svdiff, 1, diffsiz, fil);
|
fil->Write(svdiff, diffsiz);
|
||||||
|
|
||||||
return diffsiz;
|
return diffsiz;
|
||||||
}
|
}
|
||||||
|
@ -2168,19 +2166,19 @@ static void sv_restload()
|
||||||
LUNATIC_CB const char *(*El_SerializeGamevars)(int32_t *slenptr, int32_t levelnum);
|
LUNATIC_CB const char *(*El_SerializeGamevars)(int32_t *slenptr, int32_t levelnum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t *dosaveplayer2(buildvfs_FILE fil, uint8_t *mem)
|
static uint8_t *dosaveplayer2(FileWriter &fil, uint8_t *mem)
|
||||||
{
|
{
|
||||||
#ifdef DEBUGGINGAIDS
|
#ifdef DEBUGGINGAIDS
|
||||||
uint8_t *tmem = mem;
|
uint8_t *tmem = mem;
|
||||||
int32_t t=timerGetTicks();
|
int32_t t=timerGetTicks();
|
||||||
#endif
|
#endif
|
||||||
mem=writespecdata(svgm_udnetw, fil, mem); // user settings, players & net
|
mem=writespecdata(svgm_udnetw, &fil, mem); // user settings, players & net
|
||||||
PRINTSIZE("ud");
|
PRINTSIZE("ud");
|
||||||
mem=writespecdata(svgm_secwsp, fil, mem); // sector, wall, sprite
|
mem=writespecdata(svgm_secwsp, &fil, mem); // sector, wall, sprite
|
||||||
PRINTSIZE("sws");
|
PRINTSIZE("sws");
|
||||||
mem=writespecdata(svgm_script, fil, mem); // script
|
mem=writespecdata(svgm_script, &fil, mem); // script
|
||||||
PRINTSIZE("script");
|
PRINTSIZE("script");
|
||||||
mem=writespecdata(svgm_anmisc, fil, mem); // animates, quotes & misc.
|
mem=writespecdata(svgm_anmisc, &fil, mem); // animates, quotes & misc.
|
||||||
PRINTSIZE("animisc");
|
PRINTSIZE("animisc");
|
||||||
|
|
||||||
#if !defined LUNATIC
|
#if !defined LUNATIC
|
||||||
|
@ -2204,13 +2202,6 @@ static int32_t doloadplayer2(FileReader &fil, uint8_t **memptr)
|
||||||
PRINTSIZE("ud");
|
PRINTSIZE("ud");
|
||||||
if (readspecdata(svgm_secwsp, &fil, &mem)) return -4;
|
if (readspecdata(svgm_secwsp, &fil, &mem)) return -4;
|
||||||
PRINTSIZE("sws");
|
PRINTSIZE("sws");
|
||||||
#ifdef LUNATIC
|
|
||||||
{
|
|
||||||
int32_t ret = El_ReadSaveCode(fil);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (readspecdata(svgm_script, &fil, &mem)) return -5;
|
if (readspecdata(svgm_script, &fil, &mem)) return -5;
|
||||||
PRINTSIZE("script");
|
PRINTSIZE("script");
|
||||||
if (readspecdata(svgm_anmisc, &fil, &mem)) return -6;
|
if (readspecdata(svgm_anmisc, &fil, &mem)) return -6;
|
||||||
|
|
|
@ -25,8 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,10 +119,10 @@ extern uint16_t g_nummenusaves;
|
||||||
|
|
||||||
int32_t sv_updatestate(int32_t frominit);
|
int32_t sv_updatestate(int32_t frominit);
|
||||||
int32_t sv_readdiff(FileReader& fil);
|
int32_t sv_readdiff(FileReader& fil);
|
||||||
uint32_t sv_writediff(buildvfs_FILE fil);
|
uint32_t sv_writediff(FileWriter *fil);
|
||||||
int32_t sv_loadheader(FileReader &fil, int32_t spot, savehead_t *h);
|
int32_t sv_loadheader(FileReader &fil, int32_t spot, savehead_t *h);
|
||||||
int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h);
|
int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h);
|
||||||
int32_t sv_saveandmakesnapshot(buildvfs_FILE fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave = false);
|
int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave = false);
|
||||||
void sv_freemem();
|
void sv_freemem();
|
||||||
void G_DeleteSave(savebrief_t const & sv);
|
void G_DeleteSave(savebrief_t const & sv);
|
||||||
void G_DeleteOldSaves(void);
|
void G_DeleteOldSaves(void);
|
||||||
|
|
|
@ -30,8 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "openaudio.h"
|
#include "openaudio.h"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
BEGIN_DUKE_NS
|
BEGIN_DUKE_NS
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#define _SmackerFileStream_h_
|
#define _SmackerFileStream_h_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "vfs.h"
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "files.h"
|
#include "files.h"
|
||||||
|
|
|
@ -30,15 +30,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
#include "screens.h"
|
#include "screens.h"
|
||||||
#include "i_specialpaths.h"
|
#include "i_specialpaths.h"
|
||||||
|
|
||||||
#include "vfs.h"
|
|
||||||
|
|
||||||
|
|
||||||
BEGIN_RR_NS
|
BEGIN_RR_NS
|
||||||
|
|
||||||
char g_firstDemoFile[BMAX_PATH];
|
char g_firstDemoFile[BMAX_PATH];
|
||||||
|
|
||||||
buildvfs_FILE g_demo_filePtr{}; // write
|
FileWriter *g_demo_filePtr{}; // write
|
||||||
FileReader g_demo_recFilePtr;
|
FileReader g_demo_recFilePtr; // read
|
||||||
|
|
||||||
int32_t g_demo_cnt;
|
int32_t g_demo_cnt;
|
||||||
int32_t g_demo_goalCnt=0;
|
int32_t g_demo_goalCnt=0;
|
||||||
|
@ -156,7 +153,7 @@ void G_OpenDemoWrite(void)
|
||||||
if (demonum == MAXDEMOS)
|
if (demonum == MAXDEMOS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (snprintf(demofn, sizeof(demofn), "%s" DEMOFN_FMT, M_GetSavegamesPath().GetChars(), demonum))
|
if (snprintf(demofn, sizeof(demofn), "%s" DEMOFN_FMT, M_GetDemoPath().GetChars(), demonum))
|
||||||
{
|
{
|
||||||
initprintf("Couldn't start demo writing: INTERNAL ERROR: file name too long\n");
|
initprintf("Couldn't start demo writing: INTERNAL ERROR: file name too long\n");
|
||||||
goto error_wopen_demo;
|
goto error_wopen_demo;
|
||||||
|
@ -164,25 +161,26 @@ void G_OpenDemoWrite(void)
|
||||||
|
|
||||||
demonum++;
|
demonum++;
|
||||||
|
|
||||||
g_demo_filePtr = buildvfs_fopen_read(demofn);
|
g_demo_filePtr = FileWriter::Open(demofn);
|
||||||
if (g_demo_filePtr == NULL)
|
if (g_demo_filePtr == NULL)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
delete g_demo_filePtr;
|
||||||
}
|
}
|
||||||
while (1);
|
while (1);
|
||||||
|
|
||||||
g_demo_filePtr = buildvfs_fopen_write(demofn);
|
g_demo_filePtr = FileWriter::Open(demofn);
|
||||||
if (g_demo_filePtr == NULL)
|
if (g_demo_filePtr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
i=sv_saveandmakesnapshot(g_demo_filePtr, nullptr, -1, demorec_diffs_cvar, demorec_diffcompress_cvar,
|
i=sv_saveandmakesnapshot(*g_demo_filePtr, nullptr, -1, demorec_diffs_cvar, demorec_diffcompress_cvar,
|
||||||
(demorec_seeds_cvar<<1));
|
(demorec_seeds_cvar<<1));
|
||||||
if (i)
|
if (i)
|
||||||
{
|
{
|
||||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
delete g_demo_filePtr;
|
||||||
|
g_demo_filePtr = nullptr;
|
||||||
error_wopen_demo:
|
error_wopen_demo:
|
||||||
Bstrcpy(apStrings[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS.");
|
Bstrcpy(apStrings[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE CONSOLE FOR DETAILS.");
|
||||||
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
|
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
|
||||||
ud.recstat = ud.m_recstat = 0;
|
ud.recstat = ud.m_recstat = 0;
|
||||||
return;
|
return;
|
||||||
|
@ -233,13 +231,13 @@ static void Demo_WriteSync()
|
||||||
{
|
{
|
||||||
int16_t tmpreccnt;
|
int16_t tmpreccnt;
|
||||||
|
|
||||||
buildvfs_fwrite("sYnC", 4, 1, g_demo_filePtr);
|
g_demo_filePtr->Write("sYnC", 4);
|
||||||
tmpreccnt = (int16_t)ud.reccnt;
|
tmpreccnt = (int16_t)ud.reccnt;
|
||||||
buildvfs_fwrite(&tmpreccnt, sizeof(int16_t), 1, g_demo_filePtr);
|
g_demo_filePtr->Write(&tmpreccnt, sizeof(int16_t));
|
||||||
if (demorec_seeds)
|
if (demorec_seeds)
|
||||||
buildvfs_fwrite(g_demo_seedbuf, 1, ud.reccnt, g_demo_filePtr);
|
g_demo_filePtr->Write(g_demo_seedbuf, ud.reccnt);
|
||||||
|
|
||||||
buildvfs_fwrite(recsync, sizeof(input_t), ud.reccnt, g_demo_filePtr);
|
g_demo_filePtr->Write(recsync, sizeof(input_t)* ud.reccnt);
|
||||||
|
|
||||||
ud.reccnt = 0;
|
ud.reccnt = 0;
|
||||||
}
|
}
|
||||||
|
@ -276,16 +274,14 @@ void G_CloseDemoWrite(void)
|
||||||
if (ud.reccnt > 0)
|
if (ud.reccnt > 0)
|
||||||
Demo_WriteSync();
|
Demo_WriteSync();
|
||||||
|
|
||||||
buildvfs_fwrite("EnD!", 4, 1, g_demo_filePtr);
|
g_demo_filePtr->Write("EnD!", 4);
|
||||||
|
|
||||||
// lastly, we need to write the number of written recsyncs to the demo file
|
// lastly, we need to write the number of written recsyncs to the demo file
|
||||||
if (buildvfs_fseek_abs(g_demo_filePtr, offsetof(savehead_t, reccnt)))
|
g_demo_filePtr->Write(&g_demo_cnt, sizeof(g_demo_cnt));
|
||||||
perror("G_CloseDemoWrite: final fseek");
|
|
||||||
else
|
|
||||||
buildvfs_fwrite(&g_demo_cnt, sizeof(g_demo_cnt), 1, g_demo_filePtr);
|
|
||||||
|
|
||||||
ud.recstat = ud.m_recstat = 0;
|
ud.recstat = ud.m_recstat = 0;
|
||||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
delete g_demo_filePtr;
|
||||||
|
g_demo_filePtr = nullptr;
|
||||||
|
|
||||||
sv_freemem();
|
sv_freemem();
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ BEGIN_RR_NS
|
||||||
#define LDEMOFN_FMT "demo%d.dmo"
|
#define LDEMOFN_FMT "demo%d.dmo"
|
||||||
#define MAXDEMOS 1000
|
#define MAXDEMOS 1000
|
||||||
|
|
||||||
extern FILE *g_demo_filePtr;
|
extern FileWriter * g_demo_filePtr;
|
||||||
extern char g_firstDemoFile[BMAX_PATH];
|
extern char g_firstDemoFile[BMAX_PATH];
|
||||||
|
|
||||||
extern int32_t g_demo_cnt;
|
extern int32_t g_demo_cnt;
|
||||||
|
|
|
@ -361,8 +361,11 @@ void G_GameExit(const char *msg)
|
||||||
|
|
||||||
if (ud.recstat == 1)
|
if (ud.recstat == 1)
|
||||||
G_CloseDemoWrite();
|
G_CloseDemoWrite();
|
||||||
else if (ud.recstat == 2)
|
else if (ud.recstat == 2)
|
||||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
{
|
||||||
|
delete g_demo_filePtr;
|
||||||
|
g_demo_filePtr = nullptr;
|
||||||
|
}
|
||||||
// JBF: fixes crash on demo playback
|
// JBF: fixes crash on demo playback
|
||||||
// PK: modified from original
|
// PK: modified from original
|
||||||
|
|
||||||
|
@ -391,9 +394,6 @@ void G_GameExit(const char *msg)
|
||||||
I_Error(msg);
|
I_Error(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bfflush(NULL);
|
|
||||||
|
|
||||||
throw ExitEvent(0);
|
throw ExitEvent(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1570,9 +1570,6 @@ void G_DumpDebugInfo(void)
|
||||||
j = nextspritestat[j];
|
j = nextspritestat[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// fclose(fp);
|
|
||||||
saveboard("debug.map", &g_player[myconnectindex].ps->pos, fix16_to_int(g_player[myconnectindex].ps->q16ang),
|
|
||||||
g_player[myconnectindex].ps->cursectnum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if <set_movflag_uncond> is true, set the moveflag unconditionally,
|
// if <set_movflag_uncond> is true, set the moveflag unconditionally,
|
||||||
|
@ -7076,7 +7073,6 @@ void G_Shutdown(void)
|
||||||
G_SetFog(0);
|
G_SetFog(0);
|
||||||
engineUnInit();
|
engineUnInit();
|
||||||
G_Cleanup();
|
G_Cleanup();
|
||||||
Bfflush(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7390,8 +7386,6 @@ static void G_Startup(void)
|
||||||
G_LoadLookups();
|
G_LoadLookups();
|
||||||
|
|
||||||
screenpeek = myconnectindex;
|
screenpeek = myconnectindex;
|
||||||
|
|
||||||
Bfflush(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void P_SetupMiscInputSettings(void)
|
static void P_SetupMiscInputSettings(void)
|
||||||
|
|
|
@ -147,14 +147,37 @@ uint16_t g_nummenusaves;
|
||||||
static menusave_t * g_internalsaves;
|
static menusave_t * g_internalsaves;
|
||||||
static uint16_t g_numinternalsaves;
|
static uint16_t g_numinternalsaves;
|
||||||
|
|
||||||
|
static FileReader OpenSavegame(const char *fn)
|
||||||
|
{
|
||||||
|
auto file = fopenFileReader(fn, 0);
|
||||||
|
if (!file.isOpen())
|
||||||
|
return file;
|
||||||
|
|
||||||
|
char buffer[13];
|
||||||
|
file.Read(buffer, 13);
|
||||||
|
if (memcmp(buffer, "DEMOLITION_RN", 13))
|
||||||
|
return FileReader();
|
||||||
|
|
||||||
|
FileReader fr;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fr.OpenDecompressor(file, file.GetLength()-13, METHOD_DEFLATE|METHOD_TRANSFEROWNER, false, nullptr);
|
||||||
|
}
|
||||||
|
catch(std::runtime_error & err)
|
||||||
|
{
|
||||||
|
Printf("%s: %s\n", fn, err.what());
|
||||||
|
}
|
||||||
|
return fr;
|
||||||
|
}
|
||||||
|
|
||||||
static void ReadSaveGameHeaders_CACHE1D(TArray<FString>& saves)
|
static void ReadSaveGameHeaders_CACHE1D(TArray<FString>& saves)
|
||||||
{
|
{
|
||||||
savehead_t h;
|
savehead_t h;
|
||||||
|
|
||||||
for (auto& save : saves)
|
for (FString& save : saves)
|
||||||
{
|
{
|
||||||
char const* fn = save;
|
char const* fn = save;
|
||||||
auto fil = fopenFileReader(fn, 0);
|
auto fil = OpenSavegame(fn);
|
||||||
if (!fil.isOpen())
|
if (!fil.isOpen())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -186,7 +209,7 @@ static void ReadSaveGameHeaders_CACHE1D(TArray<FString>& saves)
|
||||||
|
|
||||||
static void ReadSaveGameHeaders_Internal(void)
|
static void ReadSaveGameHeaders_Internal(void)
|
||||||
{
|
{
|
||||||
FString pattern = M_GetSavegamesPath() + "*.esv";
|
FString pattern = M_GetSavegamesPath() + "*.bsv";
|
||||||
TArray<FString> saves;
|
TArray<FString> saves;
|
||||||
D_AddWildFile(saves, pattern);
|
D_AddWildFile(saves, pattern);
|
||||||
|
|
||||||
|
@ -274,7 +297,7 @@ void ReadSaveGameHeaders(void)
|
||||||
|
|
||||||
int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
||||||
{
|
{
|
||||||
auto fil = fopenFileReader(fn, 0);
|
auto fil = OpenSavegame(fn);
|
||||||
if (!fil.isOpen())
|
if (!fil.isOpen())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -316,7 +339,7 @@ static int different_user_map;
|
||||||
// XXX: keyboard input 'blocked' after load fail? (at least ESC?)
|
// XXX: keyboard input 'blocked' after load fail? (at least ESC?)
|
||||||
int32_t G_LoadPlayer(savebrief_t & sv)
|
int32_t G_LoadPlayer(savebrief_t & sv)
|
||||||
{
|
{
|
||||||
auto fil = fopenFileReader(sv.path, 0);
|
auto fil = OpenSavegame(sv.path);
|
||||||
|
|
||||||
if (!fil.isOpen())
|
if (!fil.isOpen())
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -480,78 +503,70 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
|
||||||
Net_WaitForEverybody();
|
Net_WaitForEverybody();
|
||||||
ready2send = 0;
|
ready2send = 0;
|
||||||
|
|
||||||
char temp[BMAX_PATH];
|
FString fn;
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
FILE *fil;
|
FileWriter *fil;
|
||||||
|
|
||||||
if (sv.isValid())
|
if (sv.isValid())
|
||||||
{
|
{
|
||||||
if (snprintf(temp, sizeof(temp), "%s%s", M_GetSavegamesPath().GetChars(), sv.path))
|
fn.Format("%s%s", M_GetSavegamesPath().GetChars(), sv.path);
|
||||||
{
|
fil = FileWriter::Open(fn);
|
||||||
OSD_Printf("G_SavePlayer: file name \"%s\" too long\n", sv.path);
|
}
|
||||||
goto saveproblem;
|
else
|
||||||
}
|
{
|
||||||
fil = fopen(temp, "wb");
|
static char const SaveName[] = "save0000.bsv";
|
||||||
}
|
fn.Format("%s%s", M_GetSavegamesPath().GetChars(), SaveName);
|
||||||
else
|
|
||||||
{
|
|
||||||
static char const SaveName[] = "save0000.esv";
|
|
||||||
int const len = snprintf(temp, ARRAY_SIZE(temp), "%s%s", M_GetSavegamesPath().GetChars(), SaveName);
|
|
||||||
if (len >= ARRAY_SSIZE(temp)-1)
|
|
||||||
{
|
|
||||||
OSD_Printf("G_SavePlayer: could not form automatic save path\n");
|
|
||||||
goto saveproblem;
|
|
||||||
}
|
|
||||||
char * zeros = temp + (len-8);
|
|
||||||
fil = savecounter.opennextfile(temp, zeros);
|
|
||||||
savecounter.count++;
|
|
||||||
// don't copy the mod dir into sv.path
|
|
||||||
Bstrcpy(sv.path, temp + (len-(ARRAY_SIZE(SaveName)-1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!fil)
|
auto fnp = fn.LockBuffer();
|
||||||
{
|
char* zeros = fnp + (fn.Len() - 8);
|
||||||
OSD_Printf("G_SavePlayer: failed opening \"%s\" for writing: %s\n",
|
fil = savecounter.opennextfile(fnp, zeros);
|
||||||
temp, strerror(errno));
|
fn.UnlockBuffer();
|
||||||
goto saveproblem;
|
savecounter.count++;
|
||||||
}
|
// don't copy the mod dir into sv.path
|
||||||
|
Bstrcpy(sv.path, fn + (fn.Len() - (ARRAY_SIZE(SaveName) - 1)));
|
||||||
|
}
|
||||||
|
|
||||||
// temporary hack
|
if (!fil)
|
||||||
ud.user_map = G_HaveUserMap();
|
{
|
||||||
|
OSD_Printf("G_SavePlayer: failed opening \"%s\" for writing: %s\n",
|
||||||
|
fn.GetChars(), strerror(errno));
|
||||||
|
ready2send = 1;
|
||||||
|
Net_WaitForEverybody();
|
||||||
|
|
||||||
#ifdef POLYMER
|
G_RestoreTimers();
|
||||||
if (videoGetRenderMode() == REND_POLYMER)
|
ototalclock = totalclock;
|
||||||
polymer_resetlights();
|
return -1;
|
||||||
#endif
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fil->Write("DEMOLITION_RN", 13);
|
||||||
|
CompressedFileWriter fw(fil, true);
|
||||||
|
|
||||||
// SAVE!
|
// temporary hack
|
||||||
sv_saveandmakesnapshot(fil, sv.name, 0, 0, 0, 0, isAutoSave);
|
ud.user_map = G_HaveUserMap();
|
||||||
|
|
||||||
fclose(fil);
|
|
||||||
|
|
||||||
if (!g_netServer && ud.multimode < 2)
|
// SAVE!
|
||||||
{
|
sv_saveandmakesnapshot(fw, sv.name, 0, 0, 0, 0, isAutoSave);
|
||||||
Bstrcpy(apStrings[QUOTE_RESERVED4], "Game Saved");
|
|
||||||
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
|
|
||||||
}
|
|
||||||
|
|
||||||
ready2send = 1;
|
fw.Close();
|
||||||
Net_WaitForEverybody();
|
|
||||||
|
|
||||||
G_RestoreTimers();
|
if (!g_netServer && ud.multimode < 2)
|
||||||
ototalclock = totalclock;
|
{
|
||||||
|
OSD_Printf("Saved: %s\n", fn.GetChars());
|
||||||
return 0;
|
Bstrcpy(apStrings[QUOTE_RESERVED4], "Game Saved");
|
||||||
|
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
|
||||||
saveproblem:
|
}
|
||||||
ready2send = 1;
|
|
||||||
Net_WaitForEverybody();
|
ready2send = 1;
|
||||||
|
Net_WaitForEverybody();
|
||||||
G_RestoreTimers();
|
|
||||||
ototalclock = totalclock;
|
G_RestoreTimers();
|
||||||
|
ototalclock = totalclock;
|
||||||
return -1;
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t G_LoadPlayerMaybeMulti(savebrief_t & sv)
|
int32_t G_LoadPlayerMaybeMulti(savebrief_t & sv)
|
||||||
|
@ -637,7 +652,7 @@ static inline void ds_get(const dataspec_t *spec, void **ptr, int32_t *cnt)
|
||||||
}
|
}
|
||||||
|
|
||||||
// write state to file and/or to dump
|
// write state to file and/or to dump
|
||||||
static uint8_t *writespecdata(const dataspec_t *spec, FILE *fil, uint8_t *dump)
|
static uint8_t *writespecdata(const dataspec_t *spec, FileWriter *fil, uint8_t *dump)
|
||||||
{
|
{
|
||||||
for (; spec->flags != DS_END; spec++)
|
for (; spec->flags != DS_END; spec++)
|
||||||
{
|
{
|
||||||
|
@ -652,7 +667,7 @@ static uint8_t *writespecdata(const dataspec_t *spec, FILE *fil, uint8_t *dump)
|
||||||
continue;
|
continue;
|
||||||
else if (spec->flags & DS_STRING)
|
else if (spec->flags & DS_STRING)
|
||||||
{
|
{
|
||||||
fwrite(spec->ptr, Bstrlen((const char *)spec->ptr), 1, fil); // not null-terminated!
|
fil->Write(spec->ptr, Bstrlen((const char *)spec->ptr)); // not null-terminated!
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -672,7 +687,7 @@ static uint8_t *writespecdata(const dataspec_t *spec, FILE *fil, uint8_t *dump)
|
||||||
|
|
||||||
if (fil)
|
if (fil)
|
||||||
{
|
{
|
||||||
fwrite(ptr, spec->size, cnt, fil);
|
fil->Write(ptr, spec->size * cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dump && (spec->flags & (DS_NOCHK|DS_CMP)) == 0)
|
if (dump && (spec->flags & (DS_NOCHK|DS_CMP)) == 0)
|
||||||
|
@ -739,7 +754,7 @@ static int32_t readspecdata(const dataspec_t *spec, FileReader *fil, uint8_t **d
|
||||||
if (!ptr || !cnt)
|
if (!ptr || !cnt)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fil->isOpen())
|
if (fil != nullptr && fil->isOpen())
|
||||||
{
|
{
|
||||||
auto const mem = (dump && (spec->flags & DS_NOCHK) == 0) ? dump : (uint8_t *)ptr;
|
auto const mem = (dump && (spec->flags & DS_NOCHK) == 0) ? dump : (uint8_t *)ptr;
|
||||||
int const siz = cnt * spec->size;
|
int const siz = cnt * spec->size;
|
||||||
|
@ -1267,7 +1282,7 @@ static const dataspec_t svgm_anmisc[] =
|
||||||
{ DS_END, 0, 0, 0 }
|
{ DS_END, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static uint8_t *dosaveplayer2(FILE *fil, uint8_t *mem);
|
static uint8_t *dosaveplayer2(FileWriter *fil, uint8_t *mem);
|
||||||
static int32_t doloadplayer2(FileReader &fil, uint8_t **memptr);
|
static int32_t doloadplayer2(FileReader &fil, uint8_t **memptr);
|
||||||
static void postloadplayer(int32_t savegamep);
|
static void postloadplayer(int32_t savegamep);
|
||||||
|
|
||||||
|
@ -1299,7 +1314,7 @@ static void SV_AllocSnap(int32_t allocinit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// make snapshot only if spot < 0 (demo)
|
// make snapshot only if spot < 0 (demo)
|
||||||
int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave)
|
int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave)
|
||||||
{
|
{
|
||||||
savehead_t h;
|
savehead_t h;
|
||||||
|
|
||||||
|
@ -1347,10 +1362,6 @@ int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t
|
||||||
{
|
{
|
||||||
// savegame
|
// savegame
|
||||||
Bstrncpyz(h.savename, name, sizeof(h.savename));
|
Bstrncpyz(h.savename, name, sizeof(h.savename));
|
||||||
#ifdef __ANDROID__
|
|
||||||
Bstrncpyz(h.volname, g_volumeNames[ud.volume_number], sizeof(h.volname));
|
|
||||||
Bstrncpyz(h.skillname, g_skillNames[ud.player_skill], sizeof(h.skillname));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1367,40 +1378,37 @@ int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t
|
||||||
|
|
||||||
|
|
||||||
// write header
|
// write header
|
||||||
fwrite(&h, sizeof(savehead_t), 1, fil);
|
fil.Write(&h, sizeof(savehead_t));
|
||||||
|
|
||||||
// for savegames, the file offset after the screenshot goes here;
|
// for savegames, the file offset after the screenshot goes here;
|
||||||
// for demos, we keep it 0 to signify that we didn't save one
|
// for demos, we keep it 0 to signify that we didn't save one
|
||||||
fwrite("\0\0\0\0", 4, 1, fil);
|
|
||||||
if (spot >= 0 && tileData(TILE_SAVESHOT))
|
if (spot >= 0 && tileData(TILE_SAVESHOT))
|
||||||
{
|
{
|
||||||
int32_t ofs;
|
|
||||||
|
int v = 64000;
|
||||||
|
fil.Write(&v, 4);
|
||||||
// write the screenshot compressed
|
// write the screenshot compressed
|
||||||
fwrite(tileData(TILE_SAVESHOT), 320, 200, fil);
|
fil.Write(tileData(TILE_SAVESHOT), 320*200);
|
||||||
|
|
||||||
// write the current file offset right after the header
|
|
||||||
ofs = ftell(fil);
|
|
||||||
fseek(fil, sizeof(savehead_t), SEEK_SET);
|
|
||||||
fwrite(&ofs, 4, 1, fil);
|
|
||||||
fseek(fil, ofs, SEEK_SET);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int v = 0;
|
||||||
|
fil.Write(&v, 4);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUGGINGAIDS
|
|
||||||
OSD_Printf("sv_saveandmakesnapshot: snapshot size: %d bytes.\n", svsnapsiz);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (spot >= 0)
|
if (spot >= 0)
|
||||||
{
|
{
|
||||||
// savegame
|
// savegame
|
||||||
dosaveplayer2(fil, NULL);
|
dosaveplayer2(&fil, NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// demo
|
// demo
|
||||||
SV_AllocSnap(0);
|
SV_AllocSnap(0);
|
||||||
|
|
||||||
uint8_t * const p = dosaveplayer2(fil, svsnapshot);
|
uint8_t * const p = dosaveplayer2(&fil, svsnapshot);
|
||||||
|
|
||||||
if (p != svsnapshot+svsnapsiz)
|
if (p != svsnapshot+svsnapsiz)
|
||||||
{
|
{
|
||||||
|
@ -1441,7 +1449,7 @@ int32_t sv_loadheader(FileReader &fil, int32_t spot, savehead_t *h)
|
||||||
#ifndef DEBUGGINGAIDS
|
#ifndef DEBUGGINGAIDS
|
||||||
if (havedemo)
|
if (havedemo)
|
||||||
#endif
|
#endif
|
||||||
OSD_Printf("Incompatible file version. Expected %d.%d.%d.%d.%0x, found %d.%d.%d.%d.%0x\n", SV_MAJOR_VER, SV_MINOR_VER, BYTEVERSION,
|
OSD_Printf("Incompatible savegame. Expected version %d.%d.%d.%d.%0x, found %d.%d.%d.%d.%0x\n", SV_MAJOR_VER, SV_MINOR_VER, BYTEVERSION,
|
||||||
ud.userbytever, g_scriptcrc, h->majorver, h->minorver, h->bytever, h->userbytever, h->scriptcrc);
|
ud.userbytever, g_scriptcrc, h->majorver, h->minorver, h->bytever, h->userbytever, h->scriptcrc);
|
||||||
|
|
||||||
if (h->majorver == SV_MAJOR_VER && h->minorver == SV_MINOR_VER)
|
if (h->majorver == SV_MAJOR_VER && h->minorver == SV_MINOR_VER)
|
||||||
|
@ -1500,8 +1508,8 @@ int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h)
|
||||||
}
|
}
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
{
|
{
|
||||||
if (fil.Seek(i, FileReader::SeekSet) != i)
|
if (fil.Seek(i, FileReader::SeekCur) < 0)
|
||||||
{
|
{
|
||||||
OSD_Printf("sv_snapshot: failed skipping over the screenshot.\n");
|
OSD_Printf("sv_snapshot: failed skipping over the screenshot.\n");
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
@ -1554,7 +1562,7 @@ int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t sv_writediff(FILE *fil)
|
uint32_t sv_writediff(FileWriter *fil)
|
||||||
{
|
{
|
||||||
uint8_t *p = svsnapshot;
|
uint8_t *p = svsnapshot;
|
||||||
uint8_t *d = svdiff;
|
uint8_t *d = svdiff;
|
||||||
|
@ -1569,10 +1577,10 @@ uint32_t sv_writediff(FILE *fil)
|
||||||
|
|
||||||
uint32_t const diffsiz = d - svdiff;
|
uint32_t const diffsiz = d - svdiff;
|
||||||
|
|
||||||
fwrite("dIfF",4,1,fil);
|
fil->Write("dIfF",4);
|
||||||
fwrite(&diffsiz, sizeof(diffsiz), 1, fil);
|
fil->Write(&diffsiz, sizeof(diffsiz));
|
||||||
|
|
||||||
fwrite(svdiff, 1, diffsiz, fil);
|
fil->Write(svdiff, diffsiz);
|
||||||
|
|
||||||
return diffsiz;
|
return diffsiz;
|
||||||
}
|
}
|
||||||
|
@ -1746,7 +1754,7 @@ static void sv_restload()
|
||||||
# define PRINTSIZE(name) do { } while (0)
|
# define PRINTSIZE(name) do { } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static uint8_t *dosaveplayer2(FILE *fil, uint8_t *mem)
|
static uint8_t *dosaveplayer2(FileWriter *fil, uint8_t *mem)
|
||||||
{
|
{
|
||||||
#ifdef DEBUGGINGAIDS
|
#ifdef DEBUGGINGAIDS
|
||||||
uint8_t *tmem = mem;
|
uint8_t *tmem = mem;
|
||||||
|
|
|
@ -111,11 +111,11 @@ extern menusave_t * g_menusaves;
|
||||||
extern uint16_t g_nummenusaves;
|
extern uint16_t g_nummenusaves;
|
||||||
|
|
||||||
int32_t sv_updatestate(int32_t frominit);
|
int32_t sv_updatestate(int32_t frominit);
|
||||||
int32_t sv_readdiff(FileReader &fil);
|
int32_t sv_readdiff(FileReader& fil);
|
||||||
uint32_t sv_writediff(FILE *fil);
|
uint32_t sv_writediff(FileWriter *fil);
|
||||||
int32_t sv_loadheader(FileReader& fil, int32_t spot, savehead_t* h);
|
int32_t sv_loadheader(FileReader &fil, int32_t spot, savehead_t *h);
|
||||||
int32_t sv_loadsnapshot(FileReader& fil, int32_t spot, savehead_t* h);
|
int32_t sv_loadsnapshot(FileReader &fil, int32_t spot, savehead_t *h);
|
||||||
int32_t sv_saveandmakesnapshot(FILE *fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave = false);
|
int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, int8_t recdiffsp, int8_t diffcompress, int8_t synccompress, bool isAutoSave = false);
|
||||||
void sv_freemem();
|
void sv_freemem();
|
||||||
void G_DeleteSave(savebrief_t const & sv);
|
void G_DeleteSave(savebrief_t const & sv);
|
||||||
void G_DeleteOldSaves(void);
|
void G_DeleteOldSaves(void);
|
||||||
|
|
|
@ -597,7 +597,7 @@ int AutoBreakWall(WALLp wallp, int hit_x, int hit_y, int hit_z, short ang, short
|
||||||
// Check to see if it should break with current weapon type
|
// Check to see if it should break with current weapon type
|
||||||
if (!CheckBreakToughness(break_info, type)) return FALSE;
|
if (!CheckBreakToughness(break_info, type)) return FALSE;
|
||||||
|
|
||||||
if (hit_x != MAXLONG)
|
if (hit_x != INT32_MAX)
|
||||||
{
|
{
|
||||||
vec3_t hit_pos = { hit_x, hit_y, hit_z };
|
vec3_t hit_pos = { hit_x, hit_y, hit_z };
|
||||||
// need correct location for spawning shrap
|
// need correct location for spawning shrap
|
||||||
|
@ -811,7 +811,7 @@ int WallBreakPosition(short hit_wall, short *sectnum, int *x, int *y, int *z, sh
|
||||||
updatesectorz(*x,*y,*z,sectnum);
|
updatesectorz(*x,*y,*z,sectnum);
|
||||||
if (*sectnum < 0)
|
if (*sectnum < 0)
|
||||||
{
|
{
|
||||||
*x = MAXLONG; // don't spawn shrap, just change wall
|
*x = INT32_MAX; // don't spawn shrap, just change wall
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -830,7 +830,7 @@ SWBOOL HitBreakWall(WALLp wp, int hit_x, int hit_y, int hit_z, short ang, short
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (hit_x == MAXLONG)
|
//if (hit_x == INT32_MAX)
|
||||||
{
|
{
|
||||||
short sectnum;
|
short sectnum;
|
||||||
WallBreakPosition(wp - wall, §num, &hit_x, &hit_y, &hit_z, &ang);
|
WallBreakPosition(wp - wall, §num, &hit_x, &hit_y, &hit_z, &ang);
|
||||||
|
|
|
@ -250,8 +250,6 @@ void EveryCheatToggle(PLAYERp pp, char *cheat_string)
|
||||||
|
|
||||||
void SaveCheat(PLAYERp pp, char *UNUSED(cheat_string))
|
void SaveCheat(PLAYERp pp, char *UNUSED(cheat_string))
|
||||||
{
|
{
|
||||||
saveboard("swsave.map", (vec3_t *)pp,
|
|
||||||
pp->pang, pp->cursectnum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeorgeFunc(PLAYERp pp, char *UNUSED(cheat_string))
|
void GeorgeFunc(PLAYERp pp, char *UNUSED(cheat_string))
|
||||||
|
@ -426,7 +424,7 @@ void CheatInput(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure string is lower cased
|
// make sure string is lower cased
|
||||||
strlwr(CheatInputString);
|
Bstrlwr(CheatInputString);
|
||||||
|
|
||||||
// check for at least one single match
|
// check for at least one single match
|
||||||
for (i = 0; i < SIZ(ci); i++)
|
for (i = 0; i < SIZ(ci); i++)
|
||||||
|
|
|
@ -2269,7 +2269,7 @@ extern SWBOOL NightVision;
|
||||||
int _PlayerSound(const char *file, int line, int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp);
|
int _PlayerSound(const char *file, int line, int num, int *x, int *y, int *z, Voc3D_Flags flags, PLAYERp pp);
|
||||||
#define PlayerSound(num, x, y, z, flags, pp) _PlayerSound(__FILE__, __LINE__, (num), (x), (y), (z), (flags), (pp))
|
#define PlayerSound(num, x, y, z, flags, pp) _PlayerSound(__FILE__, __LINE__, (num), (x), (y), (z), (flags), (pp))
|
||||||
|
|
||||||
#define MAXSO (MAXLONG)
|
#define MAXSO (INT32_MAX)
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
|
|
@ -4424,7 +4424,7 @@ SetupMenu(void)
|
||||||
void MNU_DoMenu(CTLType type, PLAYERp pp)
|
void MNU_DoMenu(CTLType type, PLAYERp pp)
|
||||||
{
|
{
|
||||||
SWBOOL resetitem;
|
SWBOOL resetitem;
|
||||||
UCHAR key;
|
unsigned char key;
|
||||||
int zero = 0;
|
int zero = 0;
|
||||||
static int handle2 = 0;
|
static int handle2 = 0;
|
||||||
static int limitmove=0;
|
static int limitmove=0;
|
||||||
|
|
|
@ -47,7 +47,7 @@ DoSectorObjectSetScale(short match)
|
||||||
|
|
||||||
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
||||||
{
|
{
|
||||||
if (sop->xmid == MAXLONG)
|
if (sop->xmid == INT32_MAX)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sop->match_event == match)
|
if (sop->match_event == match)
|
||||||
|
@ -122,7 +122,7 @@ DoSOevent(short match, short state)
|
||||||
|
|
||||||
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
||||||
{
|
{
|
||||||
if (sop->xmid == MAXLONG)
|
if (sop->xmid == INT32_MAX)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sop->match_event == match)
|
if (sop->match_event == match)
|
||||||
|
|
|
@ -99,7 +99,7 @@ SWBOOL LoadScriptFile(const char *filename)
|
||||||
|
|
||||||
|
|
||||||
// Convert filebuffer to all upper case
|
// Convert filebuffer to all upper case
|
||||||
//strupr(scriptbuffer);
|
//Bstrupr(scriptbuffer);
|
||||||
|
|
||||||
script_p = scriptbuffer;
|
script_p = scriptbuffer;
|
||||||
scriptend_p = script_p + size;
|
scriptend_p = script_p + size;
|
||||||
|
|
|
@ -496,7 +496,7 @@ SectorSetup(void)
|
||||||
SectorObject[ndx].Animator = NULL;
|
SectorObject[ndx].Animator = NULL;
|
||||||
SectorObject[ndx].controller = NULL;
|
SectorObject[ndx].controller = NULL;
|
||||||
SectorObject[ndx].sp_child = NULL;
|
SectorObject[ndx].sp_child = NULL;
|
||||||
SectorObject[ndx].xmid = MAXLONG;
|
SectorObject[ndx].xmid = INT32_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(SineWaveFloor, -1, sizeof(SineWaveFloor));
|
memset(SineWaveFloor, -1, sizeof(SineWaveFloor));
|
||||||
|
@ -1451,7 +1451,7 @@ DoSectorObjectKillMatch(short match)
|
||||||
|
|
||||||
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
||||||
{
|
{
|
||||||
if (sop->xmid == MAXLONG)
|
if (sop->xmid == INT32_MAX)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (sop->match_event == match)
|
if (sop->match_event == match)
|
||||||
|
@ -3419,7 +3419,7 @@ DoSector(void)
|
||||||
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (sop->xmid == MAXLONG /*|| sop->xmid == MAXSO*/)
|
if (sop->xmid == INT32_MAX /*|| sop->xmid == MAXSO*/)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ SOSync(void)
|
||||||
|
|
||||||
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
||||||
{
|
{
|
||||||
// if (sop->xmid == MAXLONG)
|
// if (sop->xmid == INT32_MAX)
|
||||||
// continue;
|
// continue;
|
||||||
|
|
||||||
updatecrc(crc, (sop->xmid) & 255);
|
updatecrc(crc, (sop->xmid) & 255);
|
||||||
|
|
|
@ -1428,7 +1428,7 @@ PostSetupSectorObject(void)
|
||||||
|
|
||||||
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
||||||
{
|
{
|
||||||
if (sop->xmid == MAXLONG)
|
if (sop->xmid == INT32_MAX)
|
||||||
continue;
|
continue;
|
||||||
FindMainSector(sop);
|
FindMainSector(sop);
|
||||||
}
|
}
|
||||||
|
@ -1442,7 +1442,7 @@ PlayerOnObject(short sectnum_match)
|
||||||
SECTOR_OBJECTp sop;
|
SECTOR_OBJECTp sop;
|
||||||
|
|
||||||
// place each sector object on the track
|
// place each sector object on the track
|
||||||
//for (i = 0; (SectorObject[i].xmid != MAXLONG) && (i < MAX_SECTOR_OBJECTS); i++)
|
//for (i = 0; (SectorObject[i].xmid != INT32_MAX) && (i < MAX_SECTOR_OBJECTS); i++)
|
||||||
for (i = 0; (i < MAX_SECTOR_OBJECTS); i++)
|
for (i = 0; (i < MAX_SECTOR_OBJECTS); i++)
|
||||||
{
|
{
|
||||||
sop = &SectorObject[i];
|
sop = &SectorObject[i];
|
||||||
|
@ -1477,7 +1477,7 @@ PlaceSectorObjectsOnTracks(void)
|
||||||
TRACK_POINTp tpoint = NULL;
|
TRACK_POINTp tpoint = NULL;
|
||||||
short spnum, next_spnum;
|
short spnum, next_spnum;
|
||||||
|
|
||||||
if (sop->xmid == MAXLONG)
|
if (sop->xmid == INT32_MAX)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1693,14 +1693,14 @@ MovePoints(SECTOR_OBJECTp sop, short delta_ang, int nx, int ny)
|
||||||
short i, nexti, rot_ang;
|
short i, nexti, rot_ang;
|
||||||
SWBOOL PlayerMove = TRUE;
|
SWBOOL PlayerMove = TRUE;
|
||||||
|
|
||||||
if (sop->xmid >= (int)MAXSO)
|
if (sop->xmid >= MAXSO)
|
||||||
PlayerMove = FALSE;
|
PlayerMove = FALSE;
|
||||||
|
|
||||||
// move along little midpoint
|
// move along little midpoint
|
||||||
sop->xmid += BOUND_4PIX(nx);
|
sop->xmid += BOUND_4PIX(nx);
|
||||||
sop->ymid += BOUND_4PIX(ny);
|
sop->ymid += BOUND_4PIX(ny);
|
||||||
|
|
||||||
if (sop->xmid >= (int)MAXSO)
|
if (sop->xmid >= MAXSO)
|
||||||
PlayerMove = FALSE;
|
PlayerMove = FALSE;
|
||||||
|
|
||||||
// move child sprite along also
|
// move child sprite along also
|
||||||
|
@ -1882,7 +1882,7 @@ PlayerPart:
|
||||||
|
|
||||||
// Does not necessarily move with the sector so must accout for
|
// Does not necessarily move with the sector so must accout for
|
||||||
// moving across sectors
|
// moving across sectors
|
||||||
if (sop->xmid < (int)MAXSO) // special case for operating SO's
|
if (sop->xmid < MAXSO) // special case for operating SO's
|
||||||
setspritez(sop->sp_num[i], (vec3_t *)sp);
|
setspritez(sop->sp_num[i], (vec3_t *)sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1902,7 +1902,7 @@ PlayerPart:
|
||||||
// update here AFTER sectors/player has been manipulated
|
// update here AFTER sectors/player has been manipulated
|
||||||
// prevents you from falling into map HOLEs created by moving
|
// prevents you from falling into map HOLEs created by moving
|
||||||
// Sectors and sprites around.
|
// Sectors and sprites around.
|
||||||
//if (sop->xmid < (int)MAXSO)
|
//if (sop->xmid < MAXSO)
|
||||||
COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum);
|
COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum);
|
||||||
|
|
||||||
// in case you are in a whirlpool
|
// in case you are in a whirlpool
|
||||||
|
@ -2077,7 +2077,7 @@ DetectSectorObject(SECTORp sectph)
|
||||||
// move all points to nx,ny
|
// move all points to nx,ny
|
||||||
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
||||||
{
|
{
|
||||||
if (sop->xmid == MAXLONG /*|| sop->xmid == MAXSO*/)
|
if (sop->xmid == INT32_MAX /*|| sop->xmid == MAXSO*/)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
||||||
|
@ -2105,7 +2105,7 @@ DetectSectorObjectByWall(WALLp wph)
|
||||||
// move all points to nx,ny
|
// move all points to nx,ny
|
||||||
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
for (sop = SectorObject; sop < &SectorObject[MAX_SECTOR_OBJECTS]; sop++)
|
||||||
{
|
{
|
||||||
if (sop->xmid == MAXLONG /*|| sop->xmid == MAXSO*/)
|
if (sop->xmid == INT32_MAX /*|| sop->xmid == MAXSO*/)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
for (sectp = sop->sectp, j = 0; *sectp; sectp++, j++)
|
||||||
|
|
|
@ -7762,10 +7762,10 @@ void TraverseBreakableWalls(short start_sect, int x, int y, int z, short ang, in
|
||||||
|
|
||||||
if (WallBreakPosition(j, §num, &hit_x, &hit_y, &hit_z, &wall_ang))
|
if (WallBreakPosition(j, §num, &hit_x, &hit_y, &hit_z, &wall_ang))
|
||||||
{
|
{
|
||||||
if (hit_x != MAXLONG && sectnum >= 0 && FAFcansee(x, y, z, start_sect, hit_x, hit_y, hit_z, sectnum))
|
if (hit_x != INT32_MAX && sectnum >= 0 && FAFcansee(x, y, z, start_sect, hit_x, hit_y, hit_z, sectnum))
|
||||||
{
|
{
|
||||||
//HitBreakWall(&wall[j], x, y, z, ang, 0);
|
//HitBreakWall(&wall[j], x, y, z, ang, 0);
|
||||||
HitBreakWall(&wall[j], MAXLONG, MAXLONG, MAXLONG, ang, 0);
|
HitBreakWall(&wall[j], INT32_MAX, INT32_MAX, INT32_MAX, ang, 0);
|
||||||
|
|
||||||
break_count++;
|
break_count++;
|
||||||
if (break_count > 4)
|
if (break_count > 4)
|
||||||
|
|
Loading…
Reference in a new issue