mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
- got rid of some editor-only code and the entire buildvfs header
Nearly all file write access now uses the FileWriter class, which is UTF-8-safe on all platforms - unlike stdio.
This commit is contained in:
parent
4fc56203c2
commit
9aa275f996
47 changed files with 37 additions and 922 deletions
|
@ -28,7 +28,6 @@
|
|||
#include "multivoc.h"
|
||||
#include "mutex.h"
|
||||
#include "sdl_inc.h"
|
||||
#include "vfs.h"
|
||||
|
||||
enum {
|
||||
SDLErr_Warning = -2,
|
||||
|
|
|
@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "mmulti.h"
|
||||
#include "compat.h"
|
||||
#include "renderlayer.h"
|
||||
#include "vfs.h"
|
||||
#include "fx_man.h"
|
||||
#include "common.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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
// NUKE-TODO: implement flags, see mapedit.cpp
|
||||
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
|
||||
|
|
|
@ -84,7 +84,6 @@ int32_t qdeletesprite(int16_t nSprite);
|
|||
int32_t qchangespritesect(int16_t nSprite, int16_t nSector);
|
||||
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 qsaveboard(const char* filename, const vec3_t* dapos, int16_t daang, int16_t dacursectnum);
|
||||
|
||||
void HookReplaceFunctions(void)
|
||||
{
|
||||
|
@ -98,7 +97,6 @@ void HookReplaceFunctions(void)
|
|||
changespritestat_replace = qchangespritestat;
|
||||
loadvoxel_replace = qloadvoxel;
|
||||
loadboard_replace = qloadboard;
|
||||
saveboard_replace = qsaveboard;
|
||||
playing_blood = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ typedef struct
|
|||
#pragma pack(pop)
|
||||
|
||||
#ifndef ANIMVPX_STANDALONE
|
||||
#include "vfs.h"
|
||||
|
||||
extern const char *animvpx_read_ivf_header_errmsg[7];
|
||||
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 "pragmas.h"
|
||||
|
||||
#include "vfs.h"
|
||||
#include "cache1d.h"
|
||||
#include "textures.h"
|
||||
#include "c_cvars.h"
|
||||
|
@ -1020,8 +1019,8 @@ int videoCaptureScreen();
|
|||
|
||||
struct OutputFileCounter {
|
||||
uint16_t count = 0;
|
||||
buildvfs_FILE opennextfile(char *, char *);
|
||||
buildvfs_FILE opennextfile_withext(char *, const char *);
|
||||
FileWriter *opennextfile(char *, char *);
|
||||
FileWriter *opennextfile_withext(char *, const char *);
|
||||
};
|
||||
|
||||
// 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 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(*saveboard_replace)(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum);
|
||||
#ifdef USE_OPENGL
|
||||
extern void(*PolymostProcessVoxels_Callback)(void);
|
||||
#endif
|
||||
|
|
|
@ -12,12 +12,8 @@
|
|||
#include "compat.h"
|
||||
#include "files.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
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)
|
||||
|
||||
#include "filesystem/filesystem.h"
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#define EDUKE32_COMMON_H_
|
||||
|
||||
#include "cache1d.h"
|
||||
#include "vfs.h"
|
||||
#include "compat.h"
|
||||
#include "pragmas.h" // klabs
|
||||
#include "scriptfile.h"
|
||||
|
|
|
@ -438,8 +438,7 @@ defined __x86_64__ || defined __amd64__ || defined _M_X64 || defined _M_IA64 ||
|
|||
|
||||
#ifdef _MSC_VER
|
||||
# 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 int32_t ssize_t;
|
||||
typedef int64_t ssize_t;
|
||||
# else
|
||||
typedef int32_t ssize_t;
|
||||
# endif
|
||||
|
@ -479,31 +478,7 @@ typedef FILE BFILE;
|
|||
#define Bcalloc calloc
|
||||
#define Brealloc realloc
|
||||
#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 Bstrncpy strncpy
|
||||
#define Bstrcmp strcmp
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#define palette_h_
|
||||
|
||||
#include "cache1d.h"
|
||||
#include "vfs.h"
|
||||
|
||||
#define MAXBASEPALS 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 "baselayer.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
||||
uint8_t toupperlookup[256] =
|
||||
{
|
||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
#include "vfs.h"
|
||||
#include "../../glbackend/glbackend.h"
|
||||
|
||||
// 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)
|
||||
{
|
||||
buildvfs_fd fd = buildvfs_open_read(vdf);
|
||||
int32_t size = buildvfs_length(fd);
|
||||
char *vdfbufstart, *vdfbuf, *vdfbufend;
|
||||
FileReader fr = fopenFileReader(vdf, 0);
|
||||
auto size = fr.GetLength();
|
||||
char *vdfbuf, *vdfbufend;
|
||||
|
||||
if (size <= 0)
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
vdfbufstart = vdfbuf = (char*)Xmalloc(size);
|
||||
size = (int32_t)buildvfs_read(fd, vdfbuf, size);
|
||||
buildvfs_close(fd);
|
||||
auto vdfbuffer = fr.ReadPadded(1);
|
||||
vdfbuf = (char*)vdfbuffer.Data();
|
||||
vdfbufend = vdfbuf + size;
|
||||
|
||||
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)
|
||||
func(result);
|
||||
}
|
||||
|
||||
Xfree(vdfbufstart);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
|
||||
#include "baselayer.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
////////// PANICKING ALLOCATION FUNCTIONS //////////
|
||||
|
||||
static void (*g_MemErrHandler)(int32_t line, const char *file, const char *func);
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
# include "hightile.h"
|
||||
#endif
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
enum scripttoken_t
|
||||
{
|
||||
T_INCLUDE = 0,
|
||||
|
|
|
@ -33,9 +33,6 @@
|
|||
#include "../../glbackend/glbackend.h"
|
||||
#endif
|
||||
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
//////////
|
||||
// Compilation switches for optional/extended engine features
|
||||
|
||||
|
@ -10019,208 +10016,6 @@ static int32_t get_mapversion(void)
|
|||
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)
|
||||
|
||||
|
@ -11659,75 +11454,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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#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;
|
||||
|
||||
void videoSetCorrectedAspect()
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
#include "bitmap.h"
|
||||
#include "../../glbackend/glbackend.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
static int32_t curextra=MAXTILES;
|
||||
|
||||
#define MIN_CACHETIME_PRINT 10
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include "common.h"
|
||||
#include "../../glbackend/glbackend.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
uint8_t *basepaltable[MAXBASEPALS] = { palette };
|
||||
uint8_t basepalreset=1;
|
||||
uint8_t curbasepal;
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "gamecontrol.h"
|
||||
#include "printf.h"
|
||||
|
||||
#include "vfs.h"
|
||||
#include "../../glbackend/glbackend.h"
|
||||
|
||||
EXTERN_CVAR(Float, png_gamma)
|
||||
|
@ -17,7 +16,7 @@ EXTERN_CVAR(Float, png_gamma)
|
|||
// 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
|
||||
{
|
||||
|
@ -27,21 +26,14 @@ buildvfs_FILE OutputFileCounter::opennextfile(char *fn, char *zeros)
|
|||
zeros[1] = ((count/100)%10)+'0';
|
||||
zeros[2] = ((count/10)%10)+'0';
|
||||
zeros[3] = (count%10)+'0';
|
||||
#ifdef USE_PHYSFS
|
||||
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
|
||||
if (!FileExists(fn)) break;
|
||||
count++;
|
||||
} 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, '.');
|
||||
strcpy(dot+1, ext);
|
||||
|
@ -111,20 +103,18 @@ int videoCaptureScreen()
|
|||
else autoname << currentGame;
|
||||
autoname << "_0000";
|
||||
char* fn = autoname.LockBuffer();
|
||||
buildvfs_FILE fp = capturecounter.opennextfile_withext(fn, "png");
|
||||
FileWriter *fil = capturecounter.opennextfile_withext(fn, "png");
|
||||
autoname.UnlockBuffer();
|
||||
|
||||
if (fp == nullptr)
|
||||
if (fil == nullptr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
FileWriter writer(fp);
|
||||
|
||||
uint8_t * const imgBuf = (uint8_t *) Xmalloc(xdim * ydim * (HICOLOR ? 3 : 1));
|
||||
|
||||
videoBeginDrawing(); //{{{
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
if (HICOLOR)
|
||||
{
|
||||
getScreen(imgBuf);
|
||||
|
@ -135,15 +125,14 @@ int videoCaptureScreen()
|
|||
|
||||
for (int i = 0, numRows = ydim >> 1; i < numRows; ++i)
|
||||
{
|
||||
Bmemcpy(rowBuf, imgBuf + i * bytesPerLine, bytesPerLine);
|
||||
Bmemcpy(imgBuf + i * bytesPerLine, imgBuf + (ydim - i - 1) * bytesPerLine, bytesPerLine);
|
||||
Bmemcpy(imgBuf + (ydim - i - 1) * bytesPerLine, rowBuf, bytesPerLine);
|
||||
memcpy(rowBuf, imgBuf + i * bytesPerLine, bytesPerLine);
|
||||
memcpy(imgBuf + i * bytesPerLine, imgBuf + (ydim - i - 1) * bytesPerLine, bytesPerLine);
|
||||
memcpy(imgBuf + (ydim - i - 1) * bytesPerLine, rowBuf, bytesPerLine);
|
||||
}
|
||||
|
||||
Xfree(rowBuf);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
for (bssize_t i = 0; i < 256; ++i)
|
||||
{
|
||||
|
@ -158,7 +147,8 @@ int videoCaptureScreen()
|
|||
|
||||
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);
|
||||
Printf("Saved screenshot to %s\n", fn);
|
||||
capturecounter.count++;
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
#include "compat.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
||||
#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++; }
|
||||
|
|
|
@ -54,8 +54,6 @@
|
|||
# include "win32/winbits.h"
|
||||
#endif
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
CVAR(Int, r_displayindex, 0, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
||||
CVAR(Int, r_borderless, 2, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
||||
CVAR(Int, maxrefreshfreq, 0, CVAR_ARCHIVE | CVAR_VIDEOCONFIG)
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
#include "engine_priv.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
||||
//
|
||||
// copytilepiece
|
||||
//
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
#include "palette.h"
|
||||
#include "../../glbackend/glbackend.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
||||
//For loading/conversion only
|
||||
static vec3_t voxsiz;
|
||||
|
|
|
@ -1123,12 +1123,11 @@ const char* G_ConFile(void)
|
|||
bool AddINIFile(const char* pzFile, bool bForce = false)
|
||||
{
|
||||
char* pzFN;
|
||||
struct Bstat st;
|
||||
static INICHAIN* pINIIter = NULL;
|
||||
if (!bForce)
|
||||
{
|
||||
if (findfrompath(pzFile, &pzFN)) return false; // failed to resolve the filename
|
||||
if (Bstat(pzFN, &st))
|
||||
if (!FileExists(pzFN))
|
||||
{
|
||||
Bfree(pzFN);
|
||||
return false;
|
||||
|
|
|
@ -36,8 +36,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
# include "animvpx.h"
|
||||
#endif
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
#include "rts.h"
|
||||
#include "gamecontrol.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
||||
#include "common.h"
|
||||
#include "common_game.h"
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
#include "collections.h"
|
||||
#include "gamecontrol.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
||||
|
|
|
@ -27,8 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "renderlayer.h"
|
||||
#include "cmdline.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
#if defined RENDERTYPESDL && defined SDL_TARGET && SDL_TARGET > 1
|
||||
# include "sdl_inc.h"
|
||||
#endif
|
||||
|
|
|
@ -31,8 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "i_specialpaths.h"
|
||||
#include "printf.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#define demo_h_
|
||||
|
||||
#include "compat.h"
|
||||
#include "vfs.h"
|
||||
#include "cache1d.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
|
|
@ -46,8 +46,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "m_argv.h"
|
||||
#include "filesystem/filesystem.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
// Uncomment to prevent anything except mirrors from drawing. It is sensible to
|
||||
// also uncomment ENGINE_CLEAR_SCREEN in build/src/engine_priv.h.
|
||||
//#define DEBUG_MIRRORS_ONLY
|
||||
|
@ -296,9 +294,6 @@ void G_GameExit(const char *msg)
|
|||
I_Error("%s", msg);
|
||||
}
|
||||
}
|
||||
|
||||
Bfflush(NULL);
|
||||
|
||||
throw ExitEvent(0);
|
||||
}
|
||||
|
||||
|
@ -1168,10 +1163,8 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
|
|||
|
||||
void G_DumpDebugInfo(void)
|
||||
{
|
||||
#if !defined LUNATIC
|
||||
static char const s_WEAPON[] = "WEAPON";
|
||||
int32_t i,j,x;
|
||||
// buildvfs_FILE fp = buildvfs_fopen_write("condebug.log");
|
||||
|
||||
VM_ScriptInfo(insptr, 64);
|
||||
buildprint("\nCurrent gamevar values:\n");
|
||||
|
@ -1235,17 +1228,12 @@ void G_DumpDebugInfo(void)
|
|||
}
|
||||
}
|
||||
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,
|
||||
// else only if it equals 0.
|
||||
static int32_t G_InitActor(int32_t i, int32_t tilenum, int32_t set_movflag_uncond)
|
||||
{
|
||||
#if !defined LUNATIC
|
||||
if (g_tile[tilenum].execPtr)
|
||||
{
|
||||
SH(i) = *(g_tile[tilenum].execPtr);
|
||||
|
@ -1257,26 +1245,6 @@ static int32_t G_InitActor(int32_t i, int32_t tilenum, int32_t set_movflag_uncon
|
|||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -5712,7 +5680,6 @@ void G_Shutdown(void)
|
|||
CONTROL_Shutdown();
|
||||
engineUnInit();
|
||||
G_Cleanup();
|
||||
Bfflush(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -5995,8 +5962,6 @@ static void G_Startup(void)
|
|||
G_LoadLookups();
|
||||
|
||||
screenpeek = myconnectindex;
|
||||
|
||||
Bfflush(NULL);
|
||||
}
|
||||
|
||||
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 "m_argv.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
#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 "version.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
#include "debugbreak.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
|
|
@ -27,8 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "savegame.h"
|
||||
#include "gamecvars.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
#define gamevars_c_
|
||||
|
|
|
@ -26,8 +26,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "fix16.hpp"
|
||||
#include "gamedef.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
||||
|
|
|
@ -41,8 +41,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "enet.h"
|
||||
#include "m_crc32.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
// 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 "sbar.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
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, " ");
|
||||
|
||||
buildvfs_FILE fil = buildvfs_fopen_write(fn);
|
||||
FileWriter *fil = FileWriter::Open(fn);
|
||||
if (!fil)
|
||||
{
|
||||
sjson_destroy_context(ctx);
|
||||
return 1;
|
||||
}
|
||||
|
||||
buildvfs_fwrite(encoded, strlen(encoded), 1, fil);
|
||||
buildvfs_fclose(fil);
|
||||
fil->Write(encoded, strlen(encoded));
|
||||
delete fil;
|
||||
|
||||
sjson_free_string(ctx, encoded);
|
||||
sjson_destroy_context(ctx);
|
||||
|
|
|
@ -28,9 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "duke3d.h"
|
||||
#include "menus.h"
|
||||
#include "savegame.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
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 "version.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
||||
|
@ -717,9 +715,9 @@ void G_DeleteSave(savebrief_t const & sv)
|
|||
return;
|
||||
}
|
||||
|
||||
buildvfs_unlink(temp);
|
||||
remove(temp);
|
||||
Bstrcat(temp, ".ext");
|
||||
buildvfs_unlink(temp);
|
||||
remove(temp);
|
||||
}
|
||||
|
||||
void G_DeleteOldSaves(void)
|
||||
|
@ -763,12 +761,12 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
|
|||
FString fn;
|
||||
|
||||
errno = 0;
|
||||
buildvfs_FILE fil;
|
||||
FileWriter *fil;
|
||||
|
||||
if (sv.isValid())
|
||||
{
|
||||
fn.Format("%s%s", M_GetSavegamesPath().GetChars(), sv.path);
|
||||
fil = fopen(fn, "wb");
|
||||
fil = FileWriter::Open(fn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -797,8 +795,8 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
|
|||
}
|
||||
else
|
||||
{
|
||||
fwrite("DEMOLITION_ED", 13, 1, fil);
|
||||
CompressedFileWriter fw(fil);
|
||||
fil->Write("DEMOLITION_ED", 13);
|
||||
CompressedFileWriter fw(fil, true);
|
||||
|
||||
sv.isExt = 0;
|
||||
|
||||
|
|
|
@ -25,8 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
#include "game.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "openaudio.h"
|
||||
#include <atomic>
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
BEGIN_DUKE_NS
|
||||
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#define _SmackerFileStream_h_
|
||||
|
||||
#include <string>
|
||||
#include "vfs.h"
|
||||
#include "compat.h"
|
||||
#include <stdint.h>
|
||||
#include "files.h"
|
||||
|
|
|
@ -30,9 +30,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "screens.h"
|
||||
#include "i_specialpaths.h"
|
||||
|
||||
#include "vfs.h"
|
||||
|
||||
|
||||
BEGIN_RR_NS
|
||||
|
||||
char g_firstDemoFile[BMAX_PATH];
|
||||
|
|
|
@ -394,9 +394,6 @@ void G_GameExit(const char *msg)
|
|||
I_Error(msg);
|
||||
}
|
||||
}
|
||||
|
||||
Bfflush(NULL);
|
||||
|
||||
throw ExitEvent(0);
|
||||
}
|
||||
|
||||
|
@ -1573,9 +1570,6 @@ void G_DumpDebugInfo(void)
|
|||
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,
|
||||
|
@ -7079,7 +7073,6 @@ void G_Shutdown(void)
|
|||
G_SetFog(0);
|
||||
engineUnInit();
|
||||
G_Cleanup();
|
||||
Bfflush(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -7393,8 +7386,6 @@ static void G_Startup(void)
|
|||
G_LoadLookups();
|
||||
|
||||
screenpeek = myconnectindex;
|
||||
|
||||
Bfflush(NULL);
|
||||
}
|
||||
|
||||
static void P_SetupMiscInputSettings(void)
|
||||
|
|
|
@ -506,12 +506,12 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
|
|||
FString fn;
|
||||
|
||||
errno = 0;
|
||||
buildvfs_FILE fil;
|
||||
FileWriter *fil;
|
||||
|
||||
if (sv.isValid())
|
||||
{
|
||||
fn.Format("%s%s", M_GetSavegamesPath().GetChars(), sv.path);
|
||||
fil = fopen(fn, "wb");
|
||||
fil = FileWriter::Open(fn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -540,8 +540,8 @@ int32_t G_SavePlayer(savebrief_t & sv, bool isAutoSave)
|
|||
}
|
||||
else
|
||||
{
|
||||
fwrite("DEMOLITION_RN", 13, 1, fil);
|
||||
CompressedFileWriter fw(fil);
|
||||
fil->Write("DEMOLITION_RN", 13);
|
||||
CompressedFileWriter fw(fil, true);
|
||||
|
||||
// temporary hack
|
||||
ud.user_map = G_HaveUserMap();
|
||||
|
|
|
@ -250,8 +250,6 @@ void EveryCheatToggle(PLAYERp pp, char *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))
|
||||
|
|
Loading…
Reference in a new issue