git-svn-id: https://svn.eduke32.com/eduke32@1201 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2009-01-05 14:43:12 +00:00
parent 0614f0b64c
commit 68ab9ebeaa
16 changed files with 135 additions and 106 deletions

View file

@ -594,25 +594,26 @@ extern int mapversion; // if loadboard() fails with -2 return, try loadoldboard(
int loadoldboard(char *filename, char fromwhere, int *daposx, int *daposy, int *daposz, short *daang, short *dacursectnum);
// Hash functions
struct HASH_item // size is 12/24 bits.
typedef struct _hashitem // size is 12/24 bits.
{
char *string;
int key;
struct HASH_item *next;
};
struct _hashitem *next;
} HASH_item;
struct HASH_table
typedef struct
{
int size;
struct HASH_item **items;
};
HASH_item **items;
} HASH_table;
void HASH_init(struct HASH_table *t);
void HASH_free(struct HASH_table *t);
int HASH_findcase(struct HASH_table *t, const char *s);
int HASH_find(struct HASH_table *t, const char *s);
void HASH_replace(struct HASH_table *t, const char *s, int key);
void HASH_add(struct HASH_table *t, const char *s, int key);
void HASH_init(HASH_table *t);
void HASH_free(HASH_table *t);
int HASH_findcase(HASH_table *t, const char *s);
int HASH_find(HASH_table *t, const char *s);
void HASH_replace(HASH_table *t, const char *s, int key);
void HASH_add(HASH_table *t, const char *s, int key);
#ifdef _MSC_VER
#pragma pack()

View file

@ -61,7 +61,7 @@ extern GLuint peelprogram[2];
extern int cachefilehandle;
extern FILE *cacheindexptr;
extern struct HASH_table cacheH;
extern HASH_table cacheH;
struct cacheitem_t
{

View file

@ -1621,19 +1621,16 @@ void overheadeditor(void)
int ii = xyaspect;
i = yxaspect;
Bmemset(show2dsector, 255, sizeof(show2dsector));
setview(0, 0, xdim-1, ydim16-1);
yxaspect = xyaspect = 65536;
j = ydim;
ydim -= scale((MAXYDIM/6), ydim, MAXYDIM);
if (graphicsmode == 2)
totalclocklock = totalclock;
drawmapview(posx, posy, zoom, 1536);
drawmapview(posx, posy, zoom, 1536);
yxaspect = i;
ydim = j;
xyaspect = ii;

View file

@ -12129,15 +12129,15 @@ void setpolymost2dview(void)
#endif
}
void HASH_init(struct HASH_table *t)
void HASH_init(HASH_table *t)
{
HASH_free(t);
t->items=Bcalloc(1, t->size * sizeof(struct HASH_item));
t->items=Bcalloc(1, t->size * sizeof(HASH_item));
}
void HASH_free(struct HASH_table *t)
void HASH_free(HASH_table *t)
{
struct HASH_item *cur, *tmp;
HASH_item *cur, *tmp;
int i;
int num;
@ -12192,9 +12192,9 @@ inline unsigned int HASH_getcode(const char *s)
}
#endif
void HASH_add(struct HASH_table *t, const char *s, int key)
void HASH_add(HASH_table *t, const char *s, int key)
{
struct HASH_item *cur, *prev=NULL;
HASH_item *cur, *prev=NULL;
int code;
if (!s)
@ -12209,7 +12209,7 @@ void HASH_add(struct HASH_table *t, const char *s, int key)
if (!cur)
{
cur=Bcalloc(1,sizeof(struct HASH_item));
cur=Bcalloc(1,sizeof(HASH_item));
cur->string=Bstrdup(s);
cur->key=key;
cur->next=NULL;
@ -12226,16 +12226,16 @@ void HASH_add(struct HASH_table *t, const char *s, int key)
}
while (cur);
cur=Bcalloc(1,sizeof(struct HASH_item));
cur=Bcalloc(1,sizeof(HASH_item));
cur->string=Bstrdup(s);
cur->key=key;
cur->next=NULL;
prev->next=cur;
}
void HASH_replace(struct HASH_table *t, const char *s, int key)
void HASH_replace(HASH_table *t, const char *s, int key)
{
struct HASH_item *cur, *prev=NULL;
HASH_item *cur, *prev=NULL;
int code;
if (t->items==NULL)
@ -12248,7 +12248,7 @@ void HASH_replace(struct HASH_table *t, const char *s, int key)
if (!cur)
{
cur=Bcalloc(1,sizeof(struct HASH_item));
cur=Bcalloc(1,sizeof(HASH_item));
cur->string=Bstrdup(s);
cur->key=key;
cur->next=NULL;
@ -12268,16 +12268,16 @@ void HASH_replace(struct HASH_table *t, const char *s, int key)
}
while (cur);
cur=Bcalloc(1,sizeof(struct HASH_item));
cur=Bcalloc(1,sizeof(HASH_item));
cur->string=Bstrdup(s);
cur->key=key;
cur->next=NULL;
prev->next=cur;
}
int HASH_find(struct HASH_table *t, const char *s)
int HASH_find(HASH_table *t, const char *s)
{
struct HASH_item *cur;
HASH_item *cur;
if (t->items==NULL)
{
@ -12294,9 +12294,9 @@ int HASH_find(struct HASH_table *t, const char *s)
return -1;
}
int HASH_findcase(struct HASH_table *t, const char *s)
int HASH_findcase(HASH_table *t, const char *s)
{
struct HASH_item *cur;
HASH_item *cur;
if (t->items==NULL)
{

View file

@ -105,7 +105,7 @@ static int osdcursorpal=0; */
static symbol_t *osdsymbptrs[MAXSYMBOLS];
static int osdnumsymbols = 0;
static struct HASH_table osdsymbolsH = { MAXSYMBOLS<<1, NULL };
static HASH_table osdsymbolsH = { MAXSYMBOLS<<1, NULL };
// application callbacks
static void (*drawosdchar)(int, int, char, int, int) = _internal_drawosdchar;

View file

@ -339,7 +339,7 @@ void drawline2d(float x0, float y0, float x1, float y1, char col)
int cachefilehandle = -1; // texture cache file handle
FILE *cacheindexptr = NULL;
struct HASH_table cacheH = { 1024, NULL };
HASH_table cacheH = { 1024, NULL };
char TEXCACHEFILE[BMAX_PATH] = "textures";

View file

@ -44,7 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <shellapi.h>
#endif
#define BUILDDATE " 20090101"
#define BUILDDATE " 20090104"
#define VERSION " 1.2.0devel"
static int floor_over_floor;

View file

@ -51,7 +51,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
===================
*/
struct HASH_table gamefuncH = { NUMGAMEFUNCTIONS<<1, NULL };
HASH_table gamefuncH = { NUMGAMEFUNCTIONS<<1, NULL };
int32 CONFIG_FunctionNameToNum(char * func)
{

View file

@ -1053,10 +1053,10 @@ extern char *mousenames[];
extern char *duke3dgrp, *duke3dgrpstring;
extern char mod_dir[BMAX_PATH];
extern struct HASH_table gamevarH;
extern struct HASH_table arrayH;
extern struct HASH_table keywH;
extern struct HASH_table gamefuncH;
extern HASH_table gamevarH;
extern HASH_table arrayH;
extern HASH_table keywH;
extern HASH_table gamefuncH;
enum DukePacket_t
{

View file

@ -10136,8 +10136,9 @@ static void loadtmb(void)
kclose(fil);
}
void freehash();
static void G_FreeCONMem(void)
extern void C_FreeHashes();
static void G_FreeMemory(void)
{
int i;
extern char *bitptr;
@ -10157,19 +10158,6 @@ static void G_FreeCONMem(void)
if (ScriptQuoteRedefinitions[i] != NULL) Bfree(ScriptQuoteRedefinitions[i]);
}
for (i=g_gameVarCount-1;i>=0;i--)
{
if (aGameVars[i].szLabel != NULL) Bfree(aGameVars[i].szLabel);
if (aGameVars[i].dwFlags & (GAMEVAR_USER_MASK) && aGameVars[i].val.plValues != NULL)
Bfree(aGameVars[i].val.plValues);
}
for (i=g_gameArrayCount-1;i>=0;i--)
{
if (aGameArrays[i].szLabel != NULL) Bfree(aGameArrays[i].szLabel);
if (aGameArrays[i].plValues != NULL) Bfree(aGameArrays[i].plValues);
}
for (i=MAXPLAYERS-1;i>=0;i--)
{
if (g_player[i].ps != NULL) Bfree(g_player[i].ps);
@ -10187,7 +10175,9 @@ static void G_FreeCONMem(void)
if (script != NULL) Bfree(script);
if (bitptr != NULL) Bfree(bitptr);
freehash();
// if (MusicPtr != NULL) Bfree(MusicPtr);
// C_FreeHashes();
HASH_free(&gamefuncH);
}
@ -10207,7 +10197,7 @@ void G_Shutdown(void)
CONTROL_Shutdown();
CONFIG_WriteSetup();
KB_Shutdown();
G_FreeCONMem();
G_FreeMemory();
uninitengine();
}
@ -10361,7 +10351,7 @@ static void G_Startup(void)
{
wm_msgbox("Build Engine Initialization Error",
"There was a problem initializing the Build engine: %s", engineerrstr);
G_FreeCONMem();
G_FreeMemory();
exit(1);
}

View file

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int g_scriptVersion = 13; // 13 = 1.3D-style CON files, 14 = 1.4/1.5 style CON files
char g_szScriptFileName[BMAX_PATH] = "(none)"; // file we're currently compiling
static char g_szCurrentBlockName[MAXVARLABEL] = "(none)", g_szLastBlockName[MAXVARLABEL] = "NULL";
static char g_szCurrentBlockName[256] = "(none)", g_szLastBlockName[256] = "NULL";
int g_totalLines,g_lineNumber;
static int g_checkingIfElse,g_processingState;
@ -935,25 +935,25 @@ const memberlabel_t InputLabels[]=
char *bitptr; // pointer to bitmap of which bytecode positions contain pointers
#define BITPTR_POINTER 1
struct HASH_table gamevarH = { MAXGAMEVARS>>1, NULL };
struct HASH_table arrayH = { MAXGAMEARRAYS>>1, NULL };
struct HASH_table labelH = { 11264>>1, NULL };
struct HASH_table keywH = { CON_END>>1, NULL };
HASH_table gamevarH = { MAXGAMEVARS>>1, NULL };
HASH_table arrayH = { MAXGAMEARRAYS>>1, NULL };
HASH_table labelH = { 11264>>1, NULL };
HASH_table keywH = { CON_END>>1, NULL };
struct HASH_table sectorH = { SECTOR_END>>1, NULL };
struct HASH_table wallH = { WALL_END>>1, NULL };
struct HASH_table userdefH = { USERDEFS_END>>1, NULL };
HASH_table sectorH = { SECTOR_END>>1, NULL };
HASH_table wallH = { WALL_END>>1, NULL };
HASH_table userdefH = { USERDEFS_END>>1, NULL };
struct HASH_table projectileH = { PROJ_END>>1, NULL };
struct HASH_table playerH = { PLAYER_END>>1, NULL };
struct HASH_table inputH = { INPUT_END>>1, NULL };
struct HASH_table actorH = { ACTOR_END>>1, NULL };
struct HASH_table tspriteH = { ACTOR_END>>1, NULL };
HASH_table projectileH = { PROJ_END>>1, NULL };
HASH_table playerH = { PLAYER_END>>1, NULL };
HASH_table inputH = { INPUT_END>>1, NULL };
HASH_table actorH = { ACTOR_END>>1, NULL };
HASH_table tspriteH = { ACTOR_END>>1, NULL };
void inithashnames();
void freehashnames();
void inithash()
void C_InitHashes()
{
int i;
@ -993,13 +993,14 @@ void inithash()
HASH_add(&tspriteH,TsprLabels[i].name,i);
}
void freehash()
void C_FreeHashes(void)
{
HASH_free(&gamevarH);
HASH_free(&arrayH);
HASH_free(&labelH);
}
#define IFELSE_MAGIC 31337
static int g_ifElseAborted;
static int C_IncreaseScriptSize(int size)
@ -1413,7 +1414,7 @@ static inline int isaltok(char c)
return (isalnum(c) || c == '{' || c == '}' || c == '/' || c == '*' || c == '-' || c == '_' || c == '.');
}
static inline int GetLabelNameid(const memberlabel_t *pLabel, struct HASH_table *tH, const char *psz)
static inline int GetLabelNameid(const memberlabel_t *pLabel, HASH_table *tH, const char *psz)
{
// find the label psz in the table pLabel.
// returns the ID for the label, or -1
@ -1426,7 +1427,7 @@ static inline int GetLabelNameid(const memberlabel_t *pLabel, struct HASH_table
return l;
}
static inline int C_GetLabelNameOffset(struct HASH_table *tH, const char *psz)
static inline int C_GetLabelNameOffset(HASH_table *tH, const char *psz)
{
// find the label psz in the table pLabel.
// returns the offset in the array for the label, or -1
@ -1511,7 +1512,7 @@ static int C_GetNextKeyword(void) //Returns its code #
if (i>=0)
{
if (i == CON_LEFTBRACE || i == CON_RIGHTBRACE || i == CON_NULLOP)
*g_scriptPtr = i + (31337<<12);
*g_scriptPtr = i + (IFELSE_MAGIC<<12);
else *g_scriptPtr = i + (g_lineNumber<<12);
bitptr[(g_scriptPtr-script)>>3] &= ~(1<<((g_scriptPtr-script)&7));
textptr += l;
@ -1802,23 +1803,24 @@ static int C_GetNextValue(int type)
static int C_CheckEmptyBranch(int tw, intptr_t lastScriptPtr)
{
if (Bstrncmp(keyw[tw],"if",2) && tw != CON_ELSE)
if (Bstrncmp(keyw[tw], "if", 2) && tw != CON_ELSE)
{
g_ifElseAborted = 0;
return 0;
}
if ((*(g_scriptPtr) & 0xFFF) != CON_NULLOP || *(g_scriptPtr)>>12 != 31337)
if ((*(g_scriptPtr) & 0xFFF) != CON_NULLOP || *(g_scriptPtr)>>12 != IFELSE_MAGIC)
g_ifElseAborted = 0;
if (g_ifElseAborted)
{
// C_ReportError(-1);
C_ReportError(-1);
g_numCompilerWarnings++;
g_scriptPtr = lastScriptPtr + &script[0];
initprintf("%s:%d: removing empty '%s' branch\n",g_szScriptFileName,g_lineNumber,
initprintf("%s:%d: warning: empty `%s' branch\n",g_szScriptFileName,g_lineNumber,
keyw[*(g_scriptPtr) & 0xFFF]);
if (g_ifElseAborted)
*(g_scriptPtr) = (CON_NULLOP + (31337<<12));
*(g_scriptPtr) = (CON_NULLOP + (IFELSE_MAGIC<<12));
return 1;
}
return 0;
@ -2960,10 +2962,7 @@ static int C_ParseCommand(void)
C_ParseCommand();
if (C_CheckEmptyBranch(tw, lastScriptPtr))
{
// g_scriptPtr;
return 0;
}
tempscrptr = (intptr_t *)script+offset;
*tempscrptr = (intptr_t) g_scriptPtr;
@ -2972,9 +2971,24 @@ static int C_ParseCommand(void)
else
{
g_scriptPtr--;
g_numCompilerErrors++;
tempscrptr = g_scriptPtr;
g_numCompilerWarnings++;
C_ReportError(-1);
initprintf("%s:%d: error: found `else' with no `if'.\n",g_szScriptFileName,g_lineNumber);
initprintf("%s:%d: warning: found `else' with no `if'.\n",g_szScriptFileName,g_lineNumber);
if (C_GetKeyword() == CON_LEFTBRACE)
{
C_GetNextKeyword();
g_numBraces++;
do
done = C_ParseCommand();
while (done == 0);
}
else C_ParseCommand();
g_scriptPtr = tempscrptr;
}
return 0;
@ -4059,7 +4073,13 @@ static int C_ParseCommand(void)
*tempscrptr = (intptr_t) g_scriptPtr;
bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7));
if (tw != CON_WHILEVARVARN) g_checkingIfElse++;
if (tw != CON_WHILEVARVARN)
{
j = C_GetKeyword();
if (j == CON_ELSE || j == CON_LEFTBRACE)
g_checkingIfElse++;
}
return 0;
}
@ -4108,7 +4128,14 @@ static int C_ParseCommand(void)
*tempscrptr = (intptr_t) g_scriptPtr;
bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7));
if (tw != CON_WHILEVARN) g_checkingIfElse++;
if (tw != CON_WHILEVARN)
{
j = C_GetKeyword();
if (j == CON_ELSE || j == CON_LEFTBRACE)
g_checkingIfElse++;
}
return 0;
}
case CON_ADDLOGVAR:
@ -4645,7 +4672,11 @@ repeatcase:
*tempscrptr = (intptr_t) g_scriptPtr;
bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7));
g_checkingIfElse++;
j = C_GetKeyword();
if (j == CON_ELSE || j == CON_LEFTBRACE)
g_checkingIfElse++;
return 0;
}
@ -4688,7 +4719,11 @@ repeatcase:
*tempscrptr = (intptr_t) g_scriptPtr;
bitptr[(tempscrptr-script)>>3] |= (BITPTR_POINTER<<((tempscrptr-script)&7));
g_checkingIfElse++;
j = C_GetKeyword();
if (j == CON_ELSE || j == CON_LEFTBRACE)
g_checkingIfElse++;
return 0;
}
@ -4725,17 +4760,22 @@ repeatcase:
case CON_RIGHTBRACE:
g_numBraces--;
if ((*(g_scriptPtr-2)>>12) == (31337) &&
if ((*(g_scriptPtr-2)>>12) == (IFELSE_MAGIC) &&
((*(g_scriptPtr-2) & 0xFFF) == CON_LEFTBRACE)) // rewrite "{ }" into "nullop"
{
// initprintf("%s:%d: rewriting empty braces '{ }' as 'nullop' from right\n",g_szScriptFileName,g_lineNumber);
*(g_scriptPtr-2) = CON_NULLOP + (31337<<12);
*(g_scriptPtr-2) = CON_NULLOP + (IFELSE_MAGIC<<12);
g_scriptPtr -= 2;
if (C_GetKeyword() != CON_ELSE && (*(g_scriptPtr-2)&0xFFF) != CON_ELSE)
g_ifElseAborted = 1;
else g_ifElseAborted = 0;
j = C_GetKeyword();
if (g_checkingIfElse && j != CON_ELSE)
g_checkingIfElse--;
return 1;
}
@ -4750,6 +4790,9 @@ repeatcase:
initprintf("%s:%d: error: found more `}' than `{'.\n",g_szScriptFileName,g_lineNumber);
g_numCompilerErrors++;
}
if (g_checkingIfElse && j != CON_ELSE)
g_checkingIfElse--;
return 1;
case CON_BETANAME:
@ -5370,7 +5413,8 @@ repeatcase:
if (C_GetKeyword() != CON_ELSE)
{
C_ReportError(-1);
initprintf("%s:%d: removing 'nullop' found without 'else'\n",g_szScriptFileName,g_lineNumber);
g_numCompilerWarnings++;
initprintf("%s:%d: warning: `nullop' found without `else'\n",g_szScriptFileName,g_lineNumber);
g_scriptPtr--;
g_ifElseAborted = 1;
}
@ -5694,7 +5738,7 @@ void C_Compile(const char *filenam)
clearbuf(apScriptGameEvent,MAXGAMEEVENTS,0L);
inithash();
C_InitHashes();
Gv_Init();
C_InitProjectiles();

View file

@ -4195,14 +4195,9 @@ static int X_DoExecute(void)
break;
default:
/* OSD_Printf("fatal error: default processing: previous five values: %d, %d, %d, %d, %d, "
"current opcode: %d, next five values: %d, %d, %d, %d, %d\ncurrent actor: %d (%d)\n",
*(insptr-5),*(insptr-4),*(insptr-3),*(insptr-2),*(insptr-1),*insptr,*(insptr+1),
*(insptr+2),*(insptr+3),*(insptr+4),*(insptr+5),g_i,g_sp->picnum);
OSD_Printf("g_errorLineNum: %d, g_tw: %d\n",g_errorLineNum,g_tw);*/
X_ScriptInfo();
G_GameExit("An error has occurred in the EDuke32 CON executor.\n\n"
G_GameExit("An error has occurred in the EDuke32 virtual machine.\n\n"
"If you are an end user, please e-mail the file eduke32.log\n"
"along with links to any mods you're using to terminx@gmail.com.\n\n"
"If you are a mod developer, please attach all of your CON files\n"

View file

@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//-------------------------------------------------------------------------
#include "duke3d.h"
const char *s_buildDate = "20090101";
const char *s_buildDate = "20090104";
char *MusicPtr = NULL;
int g_musicSize;

View file

@ -35,7 +35,7 @@ struct dynitem
short vstat;
short val;
};
struct HASH_table dynnamesH = {512, NULL};
HASH_table dynnamesH = {512, NULL};
struct dynitem list[]=
{

View file

@ -4483,7 +4483,7 @@ void P_ProcessInput(int snum)
}
}
else if (p->walking_snd_toggle > 0)
p->walking_snd_toggle --;
p->walking_snd_toggle--;
if (p->jetpack_on == 0 && p->steroids_amount > 0 && p->steroids_amount < 400)
doubvel <<= 1;

View file

@ -207,8 +207,10 @@ void _playmusic(const char *fn)
l = kfilelength(fp);
MUSIC_StopSong();
if (!MusicPtr) MusicPtr=Bcalloc(1,l * sizeof(char));
else MusicPtr=Brealloc(MusicPtr,l * sizeof(char));
if (!MusicPtr) MusicPtr = Bcalloc(1, l);
else MusicPtr = Brealloc(MusicPtr, l);
g_musicSize=l;
kread(fp, (unsigned char *)MusicPtr, l);