mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-15 04:00:53 +00:00
- SW script parser cleanup
This commit is contained in:
parent
a3dfa58662
commit
4fef66c78a
8 changed files with 47 additions and 408 deletions
|
@ -926,12 +926,6 @@ void bfirst_search_try(T *const list, uint8_t *const bitmap, T *const eltnumptr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if RAND_MAX == 32767
|
|
||||||
static FORCE_INLINE uint16_t system_15bit_rand(void) { return (uint16_t)rand(); }
|
|
||||||
#else // RAND_MAX > 32767, assumed to be of the form 2^k - 1
|
|
||||||
static FORCE_INLINE uint16_t system_15bit_rand(void) { return ((uint16_t)rand())&0x7fff; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Copy min(strlen(src)+1, n) characters into dst, always terminate with a NUL.
|
// Copy min(strlen(src)+1, n) characters into dst, always terminate with a NUL.
|
||||||
static FORCE_INLINE char *Bstrncpyz(char *dst, const char *src, bsize_t n)
|
static FORCE_INLINE char *Bstrncpyz(char *dst, const char *src, bsize_t n)
|
||||||
{
|
{
|
||||||
|
@ -940,47 +934,9 @@ static FORCE_INLINE char *Bstrncpyz(char *dst, const char *src, bsize_t n)
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append extension when <outbuf> contains no dot.
|
|
||||||
// <ext> can be like ".mhk" or like "_crash.map", no need to start with a dot.
|
|
||||||
// The ugly name is deliberate: we should be checking the sizes of all buffers!
|
|
||||||
static inline void append_ext_UNSAFE(char *outbuf, const char *ext)
|
|
||||||
{
|
|
||||||
char *p = Bstrrchr(outbuf,'.');
|
|
||||||
|
|
||||||
if (!p)
|
|
||||||
Bstrcat(outbuf, ext);
|
|
||||||
else
|
|
||||||
Bstrcpy(p, ext);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////// Paths //////////
|
|
||||||
|
|
||||||
////////// String manipulation //////////
|
|
||||||
|
|
||||||
inline char* Bstrtolower(char* str)
|
|
||||||
{
|
|
||||||
if (str) for (int i = 0; str[i]; i++) str[i] = tolower(str[i]);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////// Miscellaneous //////////
|
|
||||||
|
|
||||||
int Bgetpagesize(void);
|
|
||||||
uint32_t Bgetsysmemsize(void);
|
|
||||||
|
|
||||||
////////// PANICKING ALLOCATION WRAPPERS //////////
|
////////// PANICKING ALLOCATION WRAPPERS //////////
|
||||||
|
|
||||||
#ifdef DEBUGGINGAIDS
|
|
||||||
extern void xalloc_set_location(int32_t line, const char *file, const char *func);
|
|
||||||
#endif
|
|
||||||
void set_memerr_handler(void (*handlerfunc)(int32_t, const char *, const char *));
|
|
||||||
void *handle_memerr(void *);
|
|
||||||
|
|
||||||
|
|
||||||
// This is for allowing the compiler's heap checker to do its job. When wrapped it only points to the wrapper for a memory leak, not to the real location where the allocation takes place.
|
|
||||||
#define Xstrdup(s) (strdup(s))
|
#define Xstrdup(s) (strdup(s))
|
||||||
#define Xmalloc(size) (M_Malloc(size))
|
#define Xmalloc(size) (M_Malloc(size))
|
||||||
#define Xcalloc(nmemb, size) (M_Calloc(nmemb, size))
|
#define Xcalloc(nmemb, size) (M_Calloc(nmemb, size))
|
||||||
|
@ -992,12 +948,6 @@ void *handle_memerr(void *);
|
||||||
|
|
||||||
////////// Inlined external libraries //////////
|
////////// Inlined external libraries //////////
|
||||||
|
|
||||||
#ifndef LIBDIVIDE_BODY
|
|
||||||
# define LIBDIVIDE_HEADER_ONLY
|
|
||||||
#endif
|
|
||||||
#define LIBDIVIDE_C_HEADERS
|
|
||||||
#define LIBDIVIDE_NONAMESPACE
|
|
||||||
#define LIBDIVIDE_NOINLINE
|
|
||||||
#include "fix16.h"
|
#include "fix16.h"
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
using ClockTicks = int;
|
using ClockTicks = int;
|
||||||
|
|
|
@ -366,169 +366,6 @@ int krand1(void)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
SWBOOL
|
|
||||||
ValidPtr(void *ptr)
|
|
||||||
{
|
|
||||||
MEM_HDRp mhp;
|
|
||||||
uint8_t* check;
|
|
||||||
|
|
||||||
ASSERT(ptr != NULL);
|
|
||||||
|
|
||||||
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
|
||||||
|
|
||||||
if (mhp->size == 0 || mhp->checksum == 0)
|
|
||||||
{
|
|
||||||
printf("ValidPtr(): Size or Checksum == 0!\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
check = (uint8_t*) & mhp->size;
|
|
||||||
|
|
||||||
if (mhp->checksum == check[0] + check[1] + check[2] + check[3])
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
printf("ValidPtr(): Checksum bad!\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PtrCheckSum(void *ptr, unsigned int *stored, unsigned int *actual)
|
|
||||||
{
|
|
||||||
MEM_HDRp mhp;
|
|
||||||
uint8_t* check;
|
|
||||||
|
|
||||||
ASSERT(ptr != NULL);
|
|
||||||
|
|
||||||
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
|
||||||
|
|
||||||
check = (uint8_t*) & mhp->size;
|
|
||||||
|
|
||||||
*stored = mhp->checksum;
|
|
||||||
*actual = check[0] + check[1] + check[2] + check[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
AllocMem(int size)
|
|
||||||
{
|
|
||||||
uint8_t* bp;
|
|
||||||
MEM_HDRp mhp;
|
|
||||||
uint8_t* check;
|
|
||||||
|
|
||||||
ASSERT(size != 0);
|
|
||||||
|
|
||||||
bp = (uint8_t*) malloc(size + sizeof(MEM_HDR));
|
|
||||||
|
|
||||||
// Used for debugging, we can remove this at ship time
|
|
||||||
if (bp == NULL)
|
|
||||||
{
|
|
||||||
I_FatalError("Memory could NOT be allocated in AllocMem: size = %d\n",size);
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(bp != NULL);
|
|
||||||
|
|
||||||
mhp = (MEM_HDRp) bp;
|
|
||||||
|
|
||||||
mhp->size = size;
|
|
||||||
check = (uint8_t*) & mhp->size;
|
|
||||||
mhp->checksum = check[0] + check[1] + check[2] + check[3];
|
|
||||||
|
|
||||||
bp += sizeof(MEM_HDR);
|
|
||||||
|
|
||||||
return bp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *
|
|
||||||
ReAllocMem(void *ptr, int size)
|
|
||||||
{
|
|
||||||
if (ptr == nullptr)
|
|
||||||
return AllocMem(size);
|
|
||||||
|
|
||||||
if (size == 0)
|
|
||||||
{
|
|
||||||
FreeMem(ptr);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t* bp;
|
|
||||||
MEM_HDRp mhp;
|
|
||||||
uint8_t* check;
|
|
||||||
|
|
||||||
ASSERT(ValidPtr(ptr));
|
|
||||||
|
|
||||||
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
|
||||||
|
|
||||||
bp = (uint8_t*) realloc(mhp, size + sizeof(MEM_HDR));
|
|
||||||
|
|
||||||
ASSERT(bp != NULL);
|
|
||||||
|
|
||||||
mhp = (MEM_HDRp) bp;
|
|
||||||
|
|
||||||
mhp->size = size;
|
|
||||||
check = (uint8_t*) & mhp->size;
|
|
||||||
mhp->checksum = check[0] + check[1] + check[2] + check[3];
|
|
||||||
|
|
||||||
bp += sizeof(MEM_HDR);
|
|
||||||
|
|
||||||
ASSERT(ValidPtr(bp));
|
|
||||||
|
|
||||||
return bp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void *
|
|
||||||
CallocMem(int size, int num)
|
|
||||||
{
|
|
||||||
uint8_t* bp;
|
|
||||||
MEM_HDRp mhp;
|
|
||||||
uint8_t* check;
|
|
||||||
int num_bytes;
|
|
||||||
|
|
||||||
ASSERT(size != 0 && num != 0);
|
|
||||||
|
|
||||||
num_bytes = (size * num) + sizeof(MEM_HDR);
|
|
||||||
bp = (uint8_t*) calloc(num_bytes, 1);
|
|
||||||
|
|
||||||
// Used for debugging, we can remove this at ship time
|
|
||||||
if (bp == NULL)
|
|
||||||
{
|
|
||||||
I_FatalError("Memory could NOT be allocated in CallocMem: size = %d, num = %d\n",size,num);
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT(bp != NULL);
|
|
||||||
|
|
||||||
mhp = (MEM_HDRp) bp;
|
|
||||||
|
|
||||||
mhp->size = size;
|
|
||||||
check = (uint8_t*) & mhp->size;
|
|
||||||
mhp->checksum = check[0] + check[1] + check[2] + check[3];
|
|
||||||
|
|
||||||
bp += sizeof(MEM_HDR);
|
|
||||||
|
|
||||||
return bp;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
FreeMem(void *ptr)
|
|
||||||
{
|
|
||||||
if (ptr == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
MEM_HDRp mhp;
|
|
||||||
uint8_t* check;
|
|
||||||
|
|
||||||
ASSERT(ValidPtr(ptr));
|
|
||||||
|
|
||||||
mhp = (MEM_HDRp)(((uint8_t*) ptr) - sizeof(MEM_HDR));
|
|
||||||
check = (uint8_t*)&mhp->size;
|
|
||||||
|
|
||||||
memset(mhp, 0xCC, mhp->size + sizeof(MEM_HDR));
|
|
||||||
|
|
||||||
free(mhp);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int PointOnLine(int x, int y, int x1, int y1, int x2, int y2)
|
int PointOnLine(int x, int y, int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
// the closer to 0 the closer to the line the point is
|
// the closer to 0 the closer to the line the point is
|
||||||
|
|
|
@ -1858,19 +1858,8 @@ typedef struct
|
||||||
unsigned int size, checksum;
|
unsigned int size, checksum;
|
||||||
} MEM_HDR,*MEM_HDRp;
|
} MEM_HDR,*MEM_HDRp;
|
||||||
|
|
||||||
#if !DEBUG
|
# define CallocMem(size, num) M_Calloc(size, num)
|
||||||
# define ValidPtr(ptr) ((SWBOOL)(TRUE))
|
# define FreeMem(ptr) M_Free(ptr)
|
||||||
# define AllocMem(size) Xmalloc(size)
|
|
||||||
# define CallocMem(size, num) Xcalloc(size, num)
|
|
||||||
# define ReAllocMem(ptr, size) Xrealloc(ptr, size)
|
|
||||||
# define FreeMem(ptr) Xfree(ptr)
|
|
||||||
#else
|
|
||||||
SWBOOL ValidPtr(void *ptr);
|
|
||||||
void *AllocMem(int size);
|
|
||||||
void *CallocMem(int size, int num);
|
|
||||||
void *ReAllocMem(void *ptr, int size);
|
|
||||||
void FreeMem(void *ptr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -1125,7 +1125,6 @@ void
|
||||||
InsertOrgTile(OrgTileP tp, OrgTileListP thelist)
|
InsertOrgTile(OrgTileP tp, OrgTileListP thelist)
|
||||||
{
|
{
|
||||||
ASSERT(tp);
|
ASSERT(tp);
|
||||||
ASSERT(ValidPtr(tp));
|
|
||||||
|
|
||||||
// if list is empty, insert at front
|
// if list is empty, insert at front
|
||||||
if (EMPTY(thelist))
|
if (EMPTY(thelist))
|
||||||
|
@ -1159,7 +1158,6 @@ void
|
||||||
KillOrgTile(OrgTileP tp)
|
KillOrgTile(OrgTileP tp)
|
||||||
{
|
{
|
||||||
ASSERT(tp);
|
ASSERT(tp);
|
||||||
ASSERT(ValidPtr(tp));
|
|
||||||
|
|
||||||
REMOVE(tp);
|
REMOVE(tp);
|
||||||
|
|
||||||
|
|
|
@ -7128,7 +7128,6 @@ InsertPanelSprite(PLAYERp pp, PANEL_SPRITEp psp)
|
||||||
PANEL_SPRITEp cur, nxt;
|
PANEL_SPRITEp cur, nxt;
|
||||||
|
|
||||||
ASSERT(psp);
|
ASSERT(psp);
|
||||||
ASSERT(ValidPtr(psp));
|
|
||||||
|
|
||||||
// if list is empty, insert at front
|
// if list is empty, insert at front
|
||||||
if (EMPTY(&pp->PanelSpriteList))
|
if (EMPTY(&pp->PanelSpriteList))
|
||||||
|
@ -7218,7 +7217,6 @@ void
|
||||||
pKillSprite(PANEL_SPRITEp psp)
|
pKillSprite(PANEL_SPRITEp psp)
|
||||||
{
|
{
|
||||||
PRODUCTION_ASSERT(psp);
|
PRODUCTION_ASSERT(psp);
|
||||||
ASSERT(ValidPtr(psp));
|
|
||||||
|
|
||||||
REMOVE(psp);
|
REMOVE(psp);
|
||||||
|
|
||||||
|
@ -7320,7 +7318,6 @@ pDisplaySprites(PLAYERp pp)
|
||||||
set.clear();
|
set.clear();
|
||||||
TRAVERSE(&pp->PanelSpriteList, psp, next)
|
TRAVERSE(&pp->PanelSpriteList, psp, next)
|
||||||
{
|
{
|
||||||
ASSERT(ValidPtr(psp));
|
|
||||||
ang = psp->rotate_ang;
|
ang = psp->rotate_ang;
|
||||||
shade = 0;
|
shade = 0;
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
@ -7646,8 +7643,6 @@ void pFlushPerms(PLAYERp pp)
|
||||||
|
|
||||||
TRAVERSE(&pp->PanelSpriteList, psp, next)
|
TRAVERSE(&pp->PanelSpriteList, psp, next)
|
||||||
{
|
{
|
||||||
ASSERT(ValidPtr(psp));
|
|
||||||
|
|
||||||
// force kill before showing again
|
// force kill before showing again
|
||||||
if (TEST(psp->flags, PANF_KILL_AFTER_SHOW))
|
if (TEST(psp->flags, PANF_KILL_AFTER_SHOW))
|
||||||
{
|
{
|
||||||
|
@ -7667,8 +7662,6 @@ pSpriteControl(PLAYERp pp)
|
||||||
// somewhere else other than by themselves
|
// somewhere else other than by themselves
|
||||||
// RULE: Sprites can only kill themselves
|
// RULE: Sprites can only kill themselves
|
||||||
PRODUCTION_ASSERT(psp);
|
PRODUCTION_ASSERT(psp);
|
||||||
ASSERT(ValidPtr(psp));
|
|
||||||
// ASSERT((uint32_t) psp->Next != 0xCCCCCCCC);
|
|
||||||
|
|
||||||
if (psp->State)
|
if (psp->State)
|
||||||
pStateControl(psp);
|
pStateControl(psp);
|
||||||
|
@ -7686,7 +7679,6 @@ void
|
||||||
pSetState(PANEL_SPRITEp psp, PANEL_STATEp panel_state)
|
pSetState(PANEL_SPRITEp psp, PANEL_STATEp panel_state)
|
||||||
{
|
{
|
||||||
PRODUCTION_ASSERT(psp);
|
PRODUCTION_ASSERT(psp);
|
||||||
ASSERT(ValidPtr(psp));
|
|
||||||
psp->tics = 0;
|
psp->tics = 0;
|
||||||
psp->State = panel_state;
|
psp->State = panel_state;
|
||||||
psp->picndx = panel_state ? panel_state->picndx : 0;
|
psp->picndx = panel_state ? panel_state->picndx : 0;
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
/*
|
|
||||||
Copyright (C) 1997, 2005 - 3D Realms Entertainment
|
|
||||||
|
|
||||||
This file is part of Shadow Warrior version 1.2
|
|
||||||
|
|
||||||
Shadow Warrior is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU General Public License
|
|
||||||
as published by the Free Software Foundation; either version 2
|
|
||||||
of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
See the GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
|
|
||||||
Original Source: 1997 - Frank Maddin and Jim Norwood
|
|
||||||
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|
||||||
*/
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// scriplib.h
|
|
||||||
BEGIN_SW_NS
|
|
||||||
|
|
||||||
#define MAXTOKEN 255
|
|
||||||
|
|
||||||
extern char token[MAXTOKEN];
|
|
||||||
extern char *scriptbuffer,*script_p,*scriptend_p;
|
|
||||||
extern int grabbed;
|
|
||||||
extern int scriptline;
|
|
||||||
extern SWBOOL endofscript;
|
|
||||||
|
|
||||||
|
|
||||||
SWBOOL LoadScriptFile(const char *filename);
|
|
||||||
void GetToken(SWBOOL crossline);
|
|
||||||
void UnGetToken(void);
|
|
||||||
SWBOOL TokenAvailable(void);
|
|
||||||
|
|
||||||
void DefaultExtension(char *path, char *extension);
|
|
||||||
void DefaultPath(char *path, char *basepath);
|
|
||||||
void StripFilename(char *path);
|
|
||||||
void ExtractFileBase(char *path, char *dest);
|
|
||||||
|
|
||||||
int ParseNum(char *str);
|
|
||||||
|
|
||||||
END_SW_NS
|
|
|
@ -34,7 +34,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
||||||
#include "panel.h"
|
#include "panel.h"
|
||||||
#include "game.h"
|
#include "game.h"
|
||||||
|
|
||||||
#include "parse.h"
|
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
#include "jsector.h"
|
#include "jsector.h"
|
||||||
#include "parent.h"
|
#include "parent.h"
|
||||||
|
@ -45,10 +44,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
||||||
|
|
||||||
BEGIN_SW_NS
|
BEGIN_SW_NS
|
||||||
|
|
||||||
#define PATHSEPERATOR '\\'
|
|
||||||
|
|
||||||
//#define COMPUTE_TOTALS 1
|
|
||||||
|
|
||||||
ParentalStruct aVoxelArray[MAXTILES];
|
ParentalStruct aVoxelArray[MAXTILES];
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,13 +54,14 @@ ParentalStruct aVoxelArray[MAXTILES];
|
||||||
|
|
||||||
=============================================================================
|
=============================================================================
|
||||||
*/
|
*/
|
||||||
|
#define MAXTOKEN 255
|
||||||
|
|
||||||
char token[MAXTOKEN];
|
static char* script_p, * scriptend_p;
|
||||||
char *scriptbuffer,*script_p,*scriptend_p;
|
static char token[MAXTOKEN];
|
||||||
int grabbed;
|
static int grabbed;
|
||||||
int scriptline;
|
static int scriptline;
|
||||||
SWBOOL endofscript;
|
static SWBOOL endofscript;
|
||||||
SWBOOL tokenready; // only TRUE if UnGetToken was just called
|
static SWBOOL tokenready; // only TRUE if UnGetToken was just called
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==============
|
==============
|
||||||
|
@ -75,60 +71,26 @@ SWBOOL tokenready; // only TRUE if UnGetToken was just ca
|
||||||
==============
|
==============
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SWBOOL LoadScriptFile(const char *filename)
|
TArray<uint8_t> LoadScriptFile(const char *filename)
|
||||||
{
|
{
|
||||||
size_t size, readsize;
|
|
||||||
FileReader fp;
|
FileReader fp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!(fp = fileSystem.OpenFileReader(filename)).isOpen())
|
if (!(fp = fileSystem.OpenFileReader(filename)).isOpen())
|
||||||
{
|
{
|
||||||
// If there's no script file, forget it.
|
// If there's no script file, forget it.
|
||||||
return FALSE;
|
return TArray<uint8_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
size = fp.GetLength();
|
auto scriptbuffer = fp.Read();
|
||||||
|
|
||||||
scriptbuffer = (char *)AllocMem(size+1);
|
if (scriptbuffer.Size() != 0)
|
||||||
|
{
|
||||||
ASSERT(scriptbuffer != NULL);
|
scriptbuffer.Push(0);
|
||||||
|
scriptline = 1;
|
||||||
readsize = fp.Read(scriptbuffer, size);
|
endofscript = FALSE;
|
||||||
|
tokenready = FALSE;
|
||||||
ASSERT(readsize == size);
|
}
|
||||||
|
return scriptbuffer;
|
||||||
scriptbuffer[readsize] = '\0';
|
|
||||||
|
|
||||||
script_p = scriptbuffer;
|
|
||||||
scriptend_p = script_p + size;
|
|
||||||
scriptline = 1;
|
|
||||||
endofscript = FALSE;
|
|
||||||
tokenready = FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
=
|
|
||||||
= UnGetToken
|
|
||||||
=
|
|
||||||
= Signals that the current token was not used, and should be reported
|
|
||||||
= for the next GetToken. Note that
|
|
||||||
|
|
||||||
GetToken (TRUE);
|
|
||||||
UnGetToken ();
|
|
||||||
GetToken (FALSE);
|
|
||||||
|
|
||||||
= could cross a line boundary.
|
|
||||||
=
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
|
|
||||||
void UnGetToken(void)
|
|
||||||
{
|
|
||||||
tokenready = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -182,15 +144,15 @@ skipspace:
|
||||||
if (script_p >= scriptend_p)
|
if (script_p >= scriptend_p)
|
||||||
{
|
{
|
||||||
if (!crossline)
|
if (!crossline)
|
||||||
Printf("Error: Line %i is incomplete\n",scriptline);
|
Printf("Error: Line %i is incomplete\n", scriptline);
|
||||||
endofscript = TRUE;
|
endofscript = TRUE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*script_p == '#') // # is comment field
|
if (*script_p == '#') // # is comment field
|
||||||
{
|
{
|
||||||
if (!crossline)
|
if (!crossline)
|
||||||
Printf("Error: Line %i is incomplete\n",scriptline);
|
Printf("Error: Line %i is incomplete\n", scriptline);
|
||||||
while (*script_p++ != '\n')
|
while (*script_p++ != '\n')
|
||||||
if (script_p >= scriptend_p)
|
if (script_p >= scriptend_p)
|
||||||
{
|
{
|
||||||
|
@ -200,9 +162,9 @@ skipspace:
|
||||||
goto skipspace;
|
goto skipspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// copy token
|
// copy token
|
||||||
//
|
//
|
||||||
token_p = token;
|
token_p = token;
|
||||||
|
|
||||||
while (*script_p > 32 && *script_p != '#')
|
while (*script_p > 32 && *script_p != '#')
|
||||||
|
@ -211,47 +173,13 @@ skipspace:
|
||||||
if (script_p == scriptend_p)
|
if (script_p == scriptend_p)
|
||||||
break;
|
break;
|
||||||
ASSERT(token_p != &token[MAXTOKEN]);
|
ASSERT(token_p != &token[MAXTOKEN]);
|
||||||
// Printf("Error: Token too large on line %i\n",scriptline);
|
// Printf("Error: Token too large on line %i\n",scriptline);
|
||||||
}
|
}
|
||||||
|
|
||||||
*token_p = 0;
|
*token_p = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
==============
|
|
||||||
=
|
|
||||||
= TokenAvailable
|
|
||||||
=
|
|
||||||
= Returns true if there is another token on the line
|
|
||||||
=
|
|
||||||
==============
|
|
||||||
*/
|
|
||||||
|
|
||||||
SWBOOL TokenAvailable(void)
|
|
||||||
{
|
|
||||||
char *search_p;
|
|
||||||
|
|
||||||
search_p = script_p;
|
|
||||||
|
|
||||||
if (search_p >= scriptend_p)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
while (*search_p <= 32)
|
|
||||||
{
|
|
||||||
if (*search_p == '\n')
|
|
||||||
return FALSE;
|
|
||||||
search_p++;
|
|
||||||
if (search_p == scriptend_p)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*search_p == '#')
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Load all the voxel files using swvoxfil.txt script file
|
// Load all the voxel files using swvoxfil.txt script file
|
||||||
|
@ -263,19 +191,15 @@ SWBOOL TokenAvailable(void)
|
||||||
// 1804 1 shotgun.kvx
|
// 1804 1 shotgun.kvx
|
||||||
// etc....
|
// etc....
|
||||||
|
|
||||||
void LoadKVXFromScript(const char *filename)
|
void LoadKVXFromScript(const char* filename)
|
||||||
{
|
{
|
||||||
int lNumber=0,lTile=0; // lNumber is the voxel no. and lTile is the editart tile being
|
int lNumber = 0, lTile = 0; // lNumber is the voxel no. and lTile is the editart tile being
|
||||||
// replaced.
|
// replaced.
|
||||||
char *sName; // KVS file being loaded in.
|
|
||||||
|
|
||||||
int grabbed=0; // Number of lines parsed
|
int grabbed = 0; // Number of lines parsed
|
||||||
|
|
||||||
sName = (char *)AllocMem(256); // Up to 256 bytes for path
|
|
||||||
ASSERT(sName != NULL);
|
|
||||||
|
|
||||||
// zero out the array memory with -1's for pics not being voxelized
|
// zero out the array memory with -1's for pics not being voxelized
|
||||||
memset(&aVoxelArray[0],-1,sizeof(struct TILE_INFO_TYPE)*MAXTILES);
|
memset(&aVoxelArray[0], -1, sizeof(struct TILE_INFO_TYPE) * MAXTILES);
|
||||||
for (grabbed = 0; grabbed < MAXTILES; grabbed++)
|
for (grabbed = 0; grabbed < MAXTILES; grabbed++)
|
||||||
{
|
{
|
||||||
aVoxelArray[grabbed].Voxel = -1;
|
aVoxelArray[grabbed].Voxel = -1;
|
||||||
|
@ -285,8 +209,13 @@ void LoadKVXFromScript(const char *filename)
|
||||||
grabbed = 0;
|
grabbed = 0;
|
||||||
|
|
||||||
// Load the file
|
// Load the file
|
||||||
if (!LoadScriptFile(filename))
|
auto buffer = LoadScriptFile(filename);
|
||||||
ASSERT(TRUE==FALSE);
|
if (!buffer.Size())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
script_p = (char*)buffer.Data();
|
||||||
|
scriptend_p = (char*)&buffer.Last();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -301,10 +230,9 @@ void LoadKVXFromScript(const char *filename)
|
||||||
lNumber = atol(token);
|
lNumber = atol(token);
|
||||||
|
|
||||||
GetToken(FALSE);
|
GetToken(FALSE);
|
||||||
strcpy(sName,token); // Copy the whole token as a file name and path
|
|
||||||
|
|
||||||
// Load the voxel file into memory
|
// Load the voxel file into memory
|
||||||
if (!qloadkvx(lNumber,sName))
|
if (!qloadkvx(lNumber,token))
|
||||||
{
|
{
|
||||||
// Store the sprite and voxel numbers for later use
|
// Store the sprite and voxel numbers for later use
|
||||||
aVoxelArray[lTile].Voxel = lNumber; // Voxel num
|
aVoxelArray[lTile].Voxel = lNumber; // Voxel num
|
||||||
|
@ -319,8 +247,6 @@ void LoadKVXFromScript(const char *filename)
|
||||||
}
|
}
|
||||||
while (script_p < scriptend_p);
|
while (script_p < scriptend_p);
|
||||||
|
|
||||||
FreeMem(scriptbuffer);
|
|
||||||
FreeMem(sName);
|
|
||||||
script_p = NULL;
|
script_p = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,16 +260,17 @@ void LoadPLockFromScript(const char *filename)
|
||||||
{
|
{
|
||||||
int lNumber=0,lTile=0; // lNumber is the voxel no. and lTile is the editart tile being
|
int lNumber=0,lTile=0; // lNumber is the voxel no. and lTile is the editart tile being
|
||||||
// replaced.
|
// replaced.
|
||||||
char *sName; // KVS file being loaded in.
|
|
||||||
|
|
||||||
int grabbed=0; // Number of lines parsed
|
int grabbed=0; // Number of lines parsed
|
||||||
|
|
||||||
sName = (char *)AllocMem(256); // Up to 256 bytes for path
|
|
||||||
ASSERT(sName != NULL);
|
|
||||||
|
|
||||||
// Load the file
|
// Load the file
|
||||||
if (!LoadScriptFile(filename))
|
auto buffer = LoadScriptFile(filename);
|
||||||
ASSERT(TRUE==FALSE);
|
if (!buffer.Size())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
script_p = (char*)buffer.Data();
|
||||||
|
scriptend_p = (char*)&buffer.Last();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -366,8 +293,6 @@ void LoadPLockFromScript(const char *filename)
|
||||||
}
|
}
|
||||||
while (script_p < scriptend_p);
|
while (script_p < scriptend_p);
|
||||||
|
|
||||||
FreeMem(scriptbuffer);
|
|
||||||
FreeMem(sName);
|
|
||||||
script_p = NULL;
|
script_p = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6711,7 +6711,6 @@ StateControl(int16_t SpriteNum)
|
||||||
if (u)
|
if (u)
|
||||||
{
|
{
|
||||||
ASSERT(u->State);
|
ASSERT(u->State);
|
||||||
ASSERT(ValidPtr(u));
|
|
||||||
// Set picnum to the correct pic
|
// Set picnum to the correct pic
|
||||||
if (TEST(u->State->Tics, SF_WALL_STATE))
|
if (TEST(u->State->Tics, SF_WALL_STATE))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue