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

This commit is contained in:
terminx 2008-12-13 07:23:13 +00:00
parent 8ec01d5ea2
commit ac36ad3943
13 changed files with 1047 additions and 1087 deletions

View file

@ -63,18 +63,18 @@ extern int cachefilehandle;
extern FILE *cacheindexptr; extern FILE *cacheindexptr;
extern struct HASH_table cacheH; extern struct HASH_table cacheH;
struct cache_entry struct cacheitem_t
{ {
char name[BMAX_PATH]; char name[BMAX_PATH];
int offset; int offset;
int len; int len;
struct cache_entry *next; struct cacheitem_t *next;
}; };
typedef struct cache_entry texcacheindex; typedef struct cacheitem_t texcacheindex;
extern texcacheindex firstcacheindex; extern texcacheindex firstcacheindex;
extern texcacheindex *datextures; extern texcacheindex *curcacheindex;
extern texcacheindex *cacheptrs[MAXTILES<<2]; extern texcacheindex *cacheptrs[MAXTILES<<2];
extern int numcacheentries; extern int numcacheentries;

View file

@ -207,7 +207,7 @@ void initmultiplayers(int argc, char **argv)
if (!argc) if (!argc)
{ {
initprintf("mmulti_unstable: No configuration file specified!\n"); // initprintf("mmulti_unstable: No configuration file specified!\n");
numplayers = 1; myconnectindex = 0; numplayers = 1; myconnectindex = 0;
connecthead = 0; connectpoint2[0] = -1; connecthead = 0; connectpoint2[0] = -1;
return; return;

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 int cachefilehandle = -1; // texture cache file handle
FILE *cacheindexptr = NULL; FILE *cacheindexptr = NULL;
struct HASH_table cacheH = { MAXTILES<<3, NULL }; struct HASH_table cacheH = { MAXTILES<<2, NULL };
char TEXCACHEFILE[BMAX_PATH] = "textures"; char TEXCACHEFILE[BMAX_PATH] = "textures";
@ -347,7 +347,7 @@ int mdtims, omdtims;
float alphahackarray[MAXTILES]; float alphahackarray[MAXTILES];
texcacheindex firstcacheindex; texcacheindex firstcacheindex;
texcacheindex *datextures = NULL; texcacheindex *curcacheindex = NULL;
texcacheindex *cacheptrs[MAXTILES<<2]; texcacheindex *cacheptrs[MAXTILES<<2];
int numcacheentries = 0; int numcacheentries = 0;
@ -708,11 +708,11 @@ void polymost_glreset()
{ {
texcacheindex *index; texcacheindex *index;
datextures = firstcacheindex.next; curcacheindex = firstcacheindex.next;
while (datextures) while (curcacheindex)
{ {
index = datextures; index = curcacheindex;
datextures = datextures->next; curcacheindex = curcacheindex->next;
Bfree(index); Bfree(index);
} }
firstcacheindex.next = NULL; firstcacheindex.next = NULL;
@ -891,7 +891,7 @@ void polymost_glinit()
cacheindexptr = NULL; cacheindexptr = NULL;
} }
datextures = &firstcacheindex; curcacheindex = &firstcacheindex;
numcacheentries = 0; numcacheentries = 0;
Bmemset(&firstcacheindex, 0, sizeof(texcacheindex)); Bmemset(&firstcacheindex, 0, sizeof(texcacheindex));
Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs)); Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs));
@ -912,7 +912,7 @@ void polymost_glinit()
if (!ftell(cacheindexptr)) if (!ftell(cacheindexptr))
{ {
rewind(cacheindexptr); rewind(cacheindexptr);
fprintf(cacheindexptr,"// automatically generated by EDuke32, DO NOT MODIFY!\n"); Bfprintf(cacheindexptr,"// automatically generated by EDuke32, DO NOT MODIFY!\n");
} }
else rewind(cacheindexptr); else rewind(cacheindexptr);
@ -927,14 +927,14 @@ void polymost_glinit()
i = 0; i = 0;
datextures = &firstcacheindex; curcacheindex = &firstcacheindex;
while (datextures->next) while (curcacheindex->next)
{ {
i += datextures->len; i += curcacheindex->len;
datextures = datextures->next; curcacheindex = curcacheindex->next;
} }
datextures = &firstcacheindex; curcacheindex = &firstcacheindex;
initprintf("Cache contains %d bytes of garbage data\n",Blseek(cachefilehandle, 0, BSEEK_END)-i); initprintf("Cache contains %d bytes of garbage data\n",Blseek(cachefilehandle, 0, BSEEK_END)-i);
Blseek(cachefilehandle, 0, BSEEK_SET); Blseek(cachefilehandle, 0, BSEEK_SET);
} }
@ -955,16 +955,16 @@ void invalidatecache(void)
{ {
texcacheindex *index; texcacheindex *index;
datextures = firstcacheindex.next; curcacheindex = firstcacheindex.next;
while (datextures) while (curcacheindex)
{ {
index = datextures; index = curcacheindex;
datextures = datextures->next; curcacheindex = curcacheindex->next;
Bfree(index); Bfree(index);
} }
} }
datextures = &firstcacheindex; curcacheindex = &firstcacheindex;
numcacheentries = 0; numcacheentries = 0;
Bmemset(&firstcacheindex, 0, sizeof(texcacheindex)); Bmemset(&firstcacheindex, 0, sizeof(texcacheindex));
Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs)); Bmemset(&cacheptrs[0], 0, sizeof(cacheptrs));
@ -981,7 +981,7 @@ void invalidatecache(void)
return; return;
} }
fprintf(cacheindexptr,"// automatically generated by EDuke32, DO NOT MODIFY!\n"); Bfprintf(cacheindexptr,"// automatically generated by EDuke32, DO NOT MODIFY!\n");
cachefilehandle = Bopen(TEXCACHEFILE,BO_BINARY|BO_TRUNC|BO_APPEND|BO_RDWR,BS_IREAD|BS_IWRITE); cachefilehandle = Bopen(TEXCACHEFILE,BO_BINARY|BO_TRUNC|BO_APPEND|BO_RDWR,BS_IREAD|BS_IWRITE);
@ -1377,23 +1377,23 @@ static int LoadCacheOffsets(void)
if (scriptfile_getnumber(script, &fsize)) break; // size if (scriptfile_getnumber(script, &fsize)) break; // size
i = HASH_find(&cacheH,fname); i = HASH_find(&cacheH,fname);
if (i != -1) if (i > -1)
{ {
// update an existing entry // update an existing entry
texcacheindex *cacheindex = cacheptrs[i]; texcacheindex *t = cacheptrs[i];
cacheindex->offset = foffset; t->offset = foffset;
cacheindex->len = fsize; t->len = fsize;
// initprintf("got a match for %s offset %d\n",cachefn,offset); // initprintf("got a match for %s offset %d\n",cachefn,offset);
} }
else else
{ {
strncpy(datextures->name, fname, BMAX_PATH); strncpy(curcacheindex->name, fname, BMAX_PATH);
datextures->offset = foffset; curcacheindex->offset = foffset;
datextures->len = fsize; curcacheindex->len = fsize;
datextures->next = Bcalloc(1, sizeof(texcacheindex)); curcacheindex->next = Bcalloc(1, sizeof(texcacheindex));
HASH_replace(&cacheH, Bstrdup(fname), numcacheentries); HASH_replace(&cacheH, Bstrdup(fname), numcacheentries);
cacheptrs[numcacheentries++] = datextures; cacheptrs[numcacheentries++] = curcacheindex;
datextures = datextures->next; curcacheindex = curcacheindex->next;
} }
} }
@ -1441,15 +1441,16 @@ int trytexcache(char *fn, int len, int dameth, char effect, texcacheheader *head
int i; int i;
i = HASH_find(&cacheH,cachefn); i = HASH_find(&cacheH,cachefn);
if (i != -1) if (i > -1)
{ {
texcacheindex *cacheindex = cacheptrs[i]; texcacheindex *t = cacheptrs[i];
len = cacheindex->len; len = t->len;
offset = cacheindex->offset; offset = t->offset;
// initprintf("got a match for %s offset %d\n",cachefn,offset); // initprintf("got a match for %s offset %d\n",cachefn,offset);
} }
if (len == 0) return -1; // didn't find it if (i < 0) return -1; // didn't find it
if (Blseek(cachefilehandle, offset, BSEEK_SET) == -1) if (Blseek(cachefilehandle, offset, BSEEK_SET) == -1)
{ {
OSD_Printf("Cache seek error: %s\n",strerror(errno)); OSD_Printf("Cache seek error: %s\n",strerror(errno));
@ -1611,30 +1612,30 @@ void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *hea
{ {
int i = HASH_find(&cacheH,cachefn); int i = HASH_find(&cacheH,cachefn);
if (i != -1) if (i > -1)
{ {
// update an existing entry // update an existing entry
texcacheindex *cacheindex = cacheptrs[i]; texcacheindex *t = cacheptrs[i];
cacheindex->offset = offset; t->offset = offset;
cacheindex->len = Blseek(cachefilehandle, 0, BSEEK_CUR) - cacheindex->offset; t->len = Blseek(cachefilehandle, 0, BSEEK_CUR) - t->offset;
// initprintf("got a match for %s offset %d\n",cachefn,offset); // initprintf("got a match for %s offset %d\n",cachefn,offset);
if (cacheindexptr) if (cacheindexptr)
fprintf(cacheindexptr, "%s %d %d\n", cacheindex->name, cacheindex->offset, cacheindex->len); Bfprintf(cacheindexptr, "%s %d %d\n", t->name, t->offset, t->len);
} }
else else
{ {
Bstrcpy(datextures->name, cachefn); Bstrcpy(curcacheindex->name, cachefn);
datextures->offset = offset; curcacheindex->offset = offset;
datextures->len = Blseek(cachefilehandle, 0, BSEEK_CUR) - datextures->offset; curcacheindex->len = Blseek(cachefilehandle, 0, BSEEK_CUR) - curcacheindex->offset;
datextures->next = (texcacheindex *)Bcalloc(1,sizeof(texcacheindex)); curcacheindex->next = (texcacheindex *)Bcalloc(1, sizeof(texcacheindex));
if (cacheindexptr) if (cacheindexptr)
fprintf(cacheindexptr, "%s %d %d\n", datextures->name, datextures->offset, datextures->len); Bfprintf(cacheindexptr, "%s %d %d\n", curcacheindex->name, curcacheindex->offset, curcacheindex->len);
HASH_replace(&cacheH, Bstrdup(cachefn), numcacheentries); HASH_add(&cacheH, Bstrdup(cachefn), numcacheentries);
cacheptrs[numcacheentries++] = datextures; cacheptrs[numcacheentries++] = curcacheindex;
datextures = datextures->next; curcacheindex = curcacheindex->next;
} }
} }
@ -1642,8 +1643,9 @@ void writexcache(char *fn, int len, int dameth, char effect, texcacheheader *hea
failure: failure:
initprintf("failure!\n"); initprintf("failure!\n");
datextures->offset = 0; curcacheindex->offset = 0;
Bmemset(datextures->name,0,sizeof(datextures->name)); Bmemset(curcacheindex->name,0,sizeof(curcacheindex->name));
success: success:
// if (fil>=0) Bclose(fil); // if (fil>=0) Bclose(fil);
if (midbuf) free(midbuf); if (midbuf) free(midbuf);

View file

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

View file

@ -193,8 +193,8 @@ extern inline int gametext_z(int small, int starttile, int x,int y,const char *t
extern void G_DrawTXDigiNumZ(int starttile, int x,int y,int n,int s,int pal,int cs,int x1, int y1, int x2, int y2, int z); extern void G_DrawTXDigiNumZ(int starttile, int x,int y,int n,int s,int pal,int cs,int x1, int y1, int x2, int y2, int z);
extern void G_DrawTileSmall(int x,int y,int tilenum,int shade,int orientation); extern void G_DrawTileSmall(int x,int y,int tilenum,int shade,int orientation);
extern void G_DrawTilePalSmall(int x,int y,int tilenum,int shade,int orientation,int p); extern void G_DrawTilePalSmall(int x,int y,int tilenum,int shade,int orientation,int p);
extern void Gv_ResetVarsToDefault(void); extern void Gv_ResetVars(void);
extern void A_ResetGameVars(int iActor); extern void A_ResetVars(int iActor);
extern int minitext_(int x,int y,const char *t,int s,int p,int sb); extern int minitext_(int x,int y,const char *t,int s,int p,int sb);
@ -225,8 +225,8 @@ extern int Gv_GetVar(int id, int iActor, int iPlayer);
extern void Gv_SetVar(int id, int lValue, int iActor, int iPlayer); extern void Gv_SetVar(int id, int lValue, int iActor, int iPlayer);
// extern void SetGameArrayID(int id,int index, int lValue); // extern void SetGameArrayID(int id,int index, int lValue);
extern int Gv_SetupVar(const char *pszLabel, int lValue, unsigned int dwFlags); extern int Gv_NewVar(const char *pszLabel, int lValue, unsigned int dwFlags);
extern int Gv_AddArray(const char *pszLabel, int asize); extern int Gv_NewArray(const char *pszLabel, int asize);
extern void C_ReportError(int iError); extern void C_ReportError(int iError);
extern void onvideomodechange(int newmode); extern void onvideomodechange(int newmode);

View file

@ -2172,7 +2172,7 @@ static void G_DrawStatusBar(int snum)
if (p->inven_icon) if (p->inven_icon)
rotatesprite(sbarx(69),sbary(200-30),sbarsc(65536L),0,INVENTORYBOX,0,21,10+16,0,0,xdim-1,ydim-1); rotatesprite(sbarx(69),sbary(200-30),sbarsc(65536L),0,INVENTORYBOX,0,21,10+16,0,0,xdim-1,ydim-1);
if (sprite[p->i].pal == 1 && p->last_extra < 2) if (sprite[p->i].pal == 1 && p->last_extra < 2) // frozen
G_DrawDigiNum(20,200-17,1,-16,10+16); G_DrawDigiNum(20,200-17,1,-16,10+16);
else G_DrawDigiNum(20,200-17,p->last_extra,-16,10+16); else G_DrawDigiNum(20,200-17,p->last_extra,-16,10+16);
@ -2557,7 +2557,7 @@ static void G_DrawStatusBar(int snum)
#define COLOR_WHITE 31 #define COLOR_WHITE 31
#define LOW_FPS 30 #define LOW_FPS 30
static void G_PrintFrameRate(void) static void G_PrintFPS(void)
{ {
// adapted from ZDoom because I like it better than what we had // adapted from ZDoom because I like it better than what we had
// applicable ZDoom code available under GPL from csDoom // applicable ZDoom code available under GPL from csDoom
@ -3873,7 +3873,7 @@ void G_DisplayRest(int smoothratio)
} }
#endif #endif
G_PrintFrameRate(); G_PrintFPS();
// JBF 20040124: display level stats in screen corner // JBF 20040124: display level stats in screen corner
if ((ud.overhead_on != 2 && ud.levelstats) && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0) if ((ud.overhead_on != 2 && ud.levelstats) && (g_player[myconnectindex].ps->gm&MODE_MENU) == 0)
@ -4740,7 +4740,7 @@ int A_InsertSprite(int whatsect,int s_x,int s_y,int s_z,int s_pn,int s_s,int s_x
changespritestat(i,5); changespritestat(i,5);
} }
*/ */
A_ResetGameVars(i); A_ResetVars(i);
ActorExtra[i].flags = 0; ActorExtra[i].flags = 0;
if (apScriptGameEvent[EVENT_EGS]) if (apScriptGameEvent[EVENT_EGS])
@ -9032,17 +9032,25 @@ static int getfilenames(const char *path, char kind[])
return(0); return(0);
} }
static void DoAutoload(const char *fn) static char *autoloadmasks[] = { "*.grp", "*.zip", "*.pk3" };
#define NUMAUTOLOADMASKS 3
static void G_DoAutoload(const char *fn)
{ {
int i;
for (i=0;i<NUMAUTOLOADMASKS;i++)
{
Bsprintf(tempbuf,"autoload/%s",fn); Bsprintf(tempbuf,"autoload/%s",fn);
getfilenames(tempbuf,"*.grp"); getfilenames(tempbuf,autoloadmasks[i]);
while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",fn,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } while (findfiles)
Bsprintf(tempbuf,"autoload/%s",fn); {
getfilenames(tempbuf,"*.zip"); Bsprintf(tempbuf,"autoload/%s/%s",fn,findfiles->name);
while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",fn,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } initprintf("Using group file '%s'.\n",tempbuf);
Bsprintf(tempbuf,"autoload/%s",fn); initgroupfile(tempbuf);
getfilenames(tempbuf,"*.pk3"); findfiles = findfiles->next;
while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",fn,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } }
}
} }
static char *makename(char *destname, char *OGGname, char *origname) static char *makename(char *destname, char *OGGname, char *origname)
@ -9052,7 +9060,7 @@ static char *makename(char *destname, char *OGGname, char *origname)
if (destname) if (destname)
Bfree(destname); Bfree(destname);
destname=Bcalloc(Bstrlen(OGGname)+Bstrlen(origname)+1,sizeof(char)); destname = Bcalloc(Bstrlen(OGGname) + Bstrlen(origname) + 1, sizeof(char));
if (!destname) if (!destname)
return NULL; return NULL;
@ -9164,7 +9172,7 @@ static int parsedefinitions_game(scriptfile *script, const int preload)
{ {
initprintf("Using group file '%s'.\n",fn); initprintf("Using group file '%s'.\n",fn);
if (!g_noAutoLoad) if (!g_noAutoLoad)
DoAutoload(fn); G_DoAutoload(fn);
} }
} }
@ -9892,7 +9900,7 @@ static void G_CheckCommandLine(int argc, const char **argv)
CommandMap = (char *)argv[i++]; CommandMap = (char *)argv[i++];
continue; continue;
} }
if (!Bstrcasecmp(k,".grp") || !Bstrcasecmp(k,".zip")) if (!Bstrcasecmp(k,".grp") || !Bstrcasecmp(k,".zip") || !Bstrcasecmp(k,".pk3"))
{ {
G_AddGroup(argv[i++]); G_AddGroup(argv[i++]);
continue; continue;
@ -10104,73 +10112,54 @@ static void loadtmb(void)
} }
void freehash(); void freehash();
static void CON_FreeMem(void) static void G_FreeCONMem(void)
{ {
int i; int i;
extern char *bitptr; extern char *bitptr;
for (i=(MAXLEVELS*(MAXVOLUMES+1))-1;i>=0;i--) // +1 volume for "intro", "briefing" music for (i=(MAXLEVELS*(MAXVOLUMES+1))-1;i>=0;i--) // +1 volume for "intro", "briefing" music
{ {
if (MapInfo[i].name != NULL) if (MapInfo[i].name != NULL) Bfree(MapInfo[i].name);
Bfree(MapInfo[i].name); if (MapInfo[i].filename != NULL) Bfree(MapInfo[i].filename);
if (MapInfo[i].filename != NULL) if (MapInfo[i].musicfn != NULL) Bfree(MapInfo[i].musicfn);
Bfree(MapInfo[i].filename); if (MapInfo[i].musicfn1 != NULL) Bfree(MapInfo[i].musicfn1);
if (MapInfo[i].musicfn != NULL) if (MapInfo[i].savedstate != NULL) G_FreeMapState(i);
Bfree(MapInfo[i].musicfn);
if (MapInfo[i].musicfn1 != NULL)
Bfree(MapInfo[i].musicfn1);
if (MapInfo[i].savedstate != NULL)
G_FreeMapState(i);
} }
for (i=MAXQUOTES-1;i>=0;i--) for (i=MAXQUOTES-1;i>=0;i--)
{ {
if (ScriptQuotes[i] != NULL) if (ScriptQuotes[i] != NULL) Bfree(ScriptQuotes[i]);
Bfree(ScriptQuotes[i]); if (ScriptQuoteRedefinitions[i] != NULL) Bfree(ScriptQuoteRedefinitions[i]);
if (ScriptQuoteRedefinitions[i] != NULL)
Bfree(ScriptQuoteRedefinitions[i]);
} }
for (i=g_gameVarCount-1;i>=0;i--) for (i=g_gameVarCount-1;i>=0;i--)
{ {
if (aGameVars[i].szLabel != NULL) if (aGameVars[i].szLabel != NULL) Bfree(aGameVars[i].szLabel);
Bfree(aGameVars[i].szLabel); if (aGameVars[i].plValues != NULL) Bfree(aGameVars[i].plValues);
if (aGameVars[i].plValues != NULL)
Bfree(aGameVars[i].plValues);
} }
for (i=g_gameArrayCount-1;i>=0;i--) for (i=g_gameArrayCount-1;i>=0;i--)
{ {
if (aGameArrays[i].szLabel != NULL) if (aGameArrays[i].szLabel != NULL) Bfree(aGameArrays[i].szLabel);
Bfree(aGameArrays[i].szLabel); if (aGameArrays[i].plValues != NULL) Bfree(aGameArrays[i].plValues);
if (aGameArrays[i].plValues != NULL)
Bfree(aGameArrays[i].plValues);
} }
for (i=MAXPLAYERS-1;i>=0;i--) for (i=MAXPLAYERS-1;i>=0;i--)
{ {
if (g_player[i].ps != NULL) if (g_player[i].ps != NULL) Bfree(g_player[i].ps);
Bfree(g_player[i].ps); if (g_player[i].sync != NULL) Bfree(g_player[i].sync);
if (g_player[i].sync != NULL)
Bfree(g_player[i].sync);
} }
for (i=MAXSOUNDS-1;i>=0;i--) for (i=MAXSOUNDS-1;i>=0;i--)
{ {
if (g_sounds[i].filename != NULL) if (g_sounds[i].filename != NULL) Bfree(g_sounds[i].filename);
Bfree(g_sounds[i].filename); if (g_sounds[i].filename1 != NULL) Bfree(g_sounds[i].filename1);
if (g_sounds[i].filename1 != NULL)
Bfree(g_sounds[i].filename1);
} }
if (label != NULL) if (label != NULL) Bfree(label);
Bfree(label); if (labelcode != NULL) Bfree(labelcode);
if (labelcode != NULL) if (script != NULL) Bfree(script);
Bfree(labelcode); if (bitptr != NULL) Bfree(bitptr);
if (script != NULL)
Bfree(script);
if (bitptr != NULL)
Bfree(bitptr);
freehash(); freehash();
HASH_free(&gamefuncH); HASH_free(&gamefuncH);
@ -10192,7 +10181,7 @@ void G_Shutdown(void)
CONTROL_Shutdown(); CONTROL_Shutdown();
CONFIG_WriteSetup(); CONFIG_WriteSetup();
KB_Shutdown(); KB_Shutdown();
CON_FreeMem(); G_FreeCONMem();
uninitengine(); uninitengine();
} }
@ -10340,7 +10329,7 @@ static void G_Startup(void)
{ {
wm_msgbox("Build Engine Initialization Error", wm_msgbox("Build Engine Initialization Error",
"There was a problem initializing the Build engine: %s", engineerrstr); "There was a problem initializing the Build engine: %s", engineerrstr);
CON_FreeMem(); G_FreeCONMem();
exit(1); exit(1);
} }
@ -10412,7 +10401,6 @@ static void G_Startup(void)
g_player[i].playerreadyflag = 0; g_player[i].playerreadyflag = 0;
#ifndef RANCID_NETWORKING #ifndef RANCID_NETWORKING
// enet regression
if (CommandNet) if (CommandNet)
{ {
setup_rancid_net(CommandNet); setup_rancid_net(CommandNet);
@ -10721,19 +10709,6 @@ void G_UpdatePlayerFromMenu(void)
} }
} }
#if 0
void writestring(int a1,int a2,int a3,short a4,int vx,int vy,int vz)
{
FILE *fp;
fp = (FILE *)fopen("debug.txt","rt+");
fprintf(fp,"%d %d %d %d %d %d %d\n",a1,a2,a3,a4,vx,vy,vz);
fclose(fp);
}
#endif
#if 0 #if 0
char testcd(char *fn, int testsiz); char testcd(char *fn, int testsiz);
@ -11043,21 +11018,21 @@ void app_main(int argc,const char **argv)
FreeGroups(); FreeGroups();
if (WW2GI || NAM)
{
// overwrite the default GRP and CON so that if the user chooses
// something different, they get what they asked for
if (WW2GI) if (WW2GI)
{ {
// overwrite the default GRP and CON so that if the user chooses
// something different, they get what they asked for
Bsprintf(defaultduke3dgrp,"ww2gi.grp"); Bsprintf(defaultduke3dgrp,"ww2gi.grp");
Bsprintf(defaultconfilename, "ww2gi.con"); Bsprintf(defaultconfilename, "ww2gi.con");
Bsprintf(GametypeNames[0],"GRUNTMATCH (SPAWN)");
Bsprintf(GametypeNames[2],"GRUNTMATCH (NO SPAWN)");
} }
else if (NAM) else
{ {
// overwrite the default GRP and CON so that if the user chooses
// something different, they get what they asked for
Bsprintf(defaultduke3dgrp,"nam.grp"); Bsprintf(defaultduke3dgrp,"nam.grp");
Bsprintf(defaultconfilename, "nam.con"); Bsprintf(defaultconfilename, "nam.con");
}
Bsprintf(GametypeNames[0],"GRUNTMATCH (SPAWN)"); Bsprintf(GametypeNames[0],"GRUNTMATCH (SPAWN)");
Bsprintf(GametypeNames[2],"GRUNTMATCH (NO SPAWN)"); Bsprintf(GametypeNames[2],"GRUNTMATCH (NO SPAWN)");
} }
@ -11076,34 +11051,46 @@ void app_main(int argc,const char **argv)
i = initgroupfile(duke3dgrp); i = initgroupfile(duke3dgrp);
if (i == -1) if (i == -1)
initprintf("Warning: could not find group file '%s'.\n",duke3dgrp); initprintf("Warning: could not find group file '%s'!\n",duke3dgrp);
else else
initprintf("Using group file '%s' as main group file.\n", duke3dgrp); initprintf("Using group file '%s' as main group file.\n", duke3dgrp);
if (!g_noAutoLoad) if (!g_noAutoLoad)
{ {
getfilenames("autoload","*.grp"); int ii;
while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; }
getfilenames("autoload","*.zip"); for (ii=0;ii<NUMAUTOLOADMASKS;ii++)
while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } {
getfilenames("autoload","*.pk3"); getfilenames("autoload",autoloadmasks[ii]);
while (findfiles) { Bsprintf(tempbuf,"autoload/%s",findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } while (findfiles)
{
Bsprintf(tempbuf,"autoload/%s",findfiles->name);
initprintf("Using group file '%s'.\n",tempbuf);
initgroupfile(tempbuf);
findfiles = findfiles->next;
}
}
if (i != -1) if (i != -1)
DoAutoload(duke3dgrp); G_DoAutoload(duke3dgrp);
} }
if (mod_dir[0] != '/') if (mod_dir[0] != '/')
{
int ii;
for (ii=0;ii<NUMAUTOLOADMASKS;ii++)
{ {
Bsprintf(tempbuf,"%s/",mod_dir); Bsprintf(tempbuf,"%s/",mod_dir);
getfilenames(tempbuf,"*.grp"); getfilenames(tempbuf,autoloadmasks[ii]);
while (findfiles) { Bsprintf(tempbuf,"%s/%s",mod_dir,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } while (findfiles)
Bsprintf(tempbuf,"%s/",mod_dir); {
getfilenames(tempbuf,"*.zip"); Bsprintf(tempbuf,"%s/%s",mod_dir,findfiles->name);
while (findfiles) { Bsprintf(tempbuf,"%s/%s",mod_dir,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } initprintf("Using group file '%s'.\n",tempbuf);
Bsprintf(tempbuf,"%s/",mod_dir); initgroupfile(tempbuf);
getfilenames(tempbuf,"*.pk3"); findfiles = findfiles->next;
while (findfiles) { Bsprintf(tempbuf,"%s/%s",mod_dir,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } }
}
} }
loaddefinitions_game(duke3ddef, TRUE); loaddefinitions_game(duke3ddef, TRUE);
@ -11122,7 +11109,7 @@ void app_main(int argc,const char **argv)
g_groupFileHandle = j; g_groupFileHandle = j;
initprintf("Using group file '%s'.\n",CommandGrps->str); initprintf("Using group file '%s'.\n",CommandGrps->str);
if (!g_noAutoLoad) if (!g_noAutoLoad)
DoAutoload(CommandGrps->str); G_DoAutoload(CommandGrps->str);
} }
free(CommandGrps->str); free(CommandGrps->str);

View file

@ -2084,7 +2084,7 @@ static int C_ParseCommand(void)
*(g_scriptPtr-1)^=GAMEVAR_PERPLAYER; *(g_scriptPtr-1)^=GAMEVAR_PERPLAYER;
C_ReportError(WARNING_BADGAMEVAR); C_ReportError(WARNING_BADGAMEVAR);
} }
Gv_SetupVar(label+(g_numLabels<<6),*(g_scriptPtr-2), Gv_NewVar(label+(g_numLabels<<6),*(g_scriptPtr-2),
(*(g_scriptPtr-1)) (*(g_scriptPtr-1))
// can't define default or secret // can't define default or secret
& (~(GAMEVAR_DEFAULT | GAMEVAR_SECRET)) & (~(GAMEVAR_DEFAULT | GAMEVAR_SECRET))
@ -2123,7 +2123,7 @@ static int C_ParseCommand(void)
} }
C_GetNextValue(LABEL_DEFINE); C_GetNextValue(LABEL_DEFINE);
Gv_AddArray(label+(g_numLabels<<6),*(g_scriptPtr-1)); Gv_NewArray(label+(g_numLabels<<6),*(g_scriptPtr-1));
g_scriptPtr -= 2; // no need to save in script... g_scriptPtr -= 2; // no need to save in script...
return 0; return 0;

View file

@ -88,9 +88,7 @@ void X_OnEvent(int iEventID, int iActor, int iPlayer, int lDist)
g_sp = &sprite[g_i]; g_sp = &sprite[g_i];
g_t = &ActorExtra[g_i].temp_data[0]; g_t = &ActorExtra[g_i].temp_data[0];
insptr = (apScriptGameEvent[iEventID]); insptr = apScriptGameEvent[iEventID];
//Bsprintf(g_szBuf,"Executing event for %d at %lX",iEventID, insptr);
//AddLog(g_szBuf);
g_killitFlag = 0; g_killitFlag = 0;
@ -757,7 +755,7 @@ static int X_DoExecute(void)
case CON_IFCANSEE: case CON_IFCANSEE:
{ {
spritetype *s; spritetype *s = &sprite[g_player[g_p].ps->i];
// select sprite for monster to target // select sprite for monster to target
// if holoduke is on, let them target holoduke first. // if holoduke is on, let them target holoduke first.
@ -775,7 +773,6 @@ static int X_DoExecute(void)
s = &sprite[g_player[g_p].ps->i]; s = &sprite[g_player[g_p].ps->i];
} }
} }
else s = &sprite[g_player[g_p].ps->i]; // holoduke not on. look for player
// can they see player, (or player's holoduke) // can they see player, (or player's holoduke)
j = cansee(g_sp->x,g_sp->y,g_sp->z-(krand()&((47<<8))),g_sp->sectnum, j = cansee(g_sp->x,g_sp->y,g_sp->z-(krand()&((47<<8))),g_sp->sectnum,
@ -841,16 +838,15 @@ static int X_DoExecute(void)
if (g_t[5]) g_t[1] = *(((intptr_t *)g_t[5])+1); // move if (g_t[5]) g_t[1] = *(((intptr_t *)g_t[5])+1); // move
g_sp->hitag = *(((intptr_t *)g_t[5])+2); // move flags g_sp->hitag = *(((intptr_t *)g_t[5])+2); // move flags
g_t[0] = g_t[2] = g_t[3] = 0; // count, actioncount... g_t[3] = ??? g_t[0] = g_t[2] = g_t[3] = 0; // count, actioncount... g_t[3] = ???
if (A_CheckEnemySprite(g_sp) && g_sp->extra <= 0) // hack // if (A_CheckEnemySprite(g_sp) && g_sp->extra <= 0) // hack
break; // break;
if (g_sp->hitag&random_angle) if (g_sp->hitag&random_angle)
g_sp->ang = krand()&2047; g_sp->ang = krand()&2047;
break; break;
case CON_ACTION: case CON_ACTION:
insptr++; insptr++;
g_t[2] = 0; g_t[2] = g_t[3] = 0;
g_t[3] = 0;
g_t[4] = *insptr++; g_t[4] = *insptr++;
break; break;
@ -974,19 +970,18 @@ static int X_DoExecute(void)
case CON_SHOOT: case CON_SHOOT:
insptr++; insptr++;
A_Shoot(g_i,(short)*insptr++); A_Shoot(g_i,*insptr++);
break; break;
case CON_SOUNDONCE: case CON_SOUNDONCE:
insptr++; insptr++;
if ((*insptr<0 || *insptr>=MAXSOUNDS) && g_scriptSanityChecks) if ((*insptr<0 || *insptr>=MAXSOUNDS) && g_scriptSanityChecks)
{ {
OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr); OSD_Printf(CON_ERROR "Invalid sound %d\n",g_errorLineNum,keyw[g_tw],*insptr++);
insptr++;break; break;
} }
if (!A_CheckSoundPlaying(g_i,*insptr)) if (!A_CheckSoundPlaying(g_i,*insptr++))
A_PlaySound((short) *insptr,g_i); A_PlaySound(*(insptr-1),g_i);
insptr++;
break; break;
case CON_IFSOUND: case CON_IFSOUND:
@ -1050,7 +1045,7 @@ static int X_DoExecute(void)
else if (G_CheckForSpaceFloor(g_sp->sectnum)) else if (G_CheckForSpaceFloor(g_sp->sectnum))
j = 0; j = 0;
if (!ActorExtra[g_i].cgg-- || (sector[g_sp->sectnum].floorstat&2)) if (--ActorExtra[g_i].cgg == 0 || (sector[g_sp->sectnum].floorstat&2))
{ {
A_GetZLimits(g_i); A_GetZLimits(g_i);
ActorExtra[g_i].cgg = 3; ActorExtra[g_i].cgg = 3;
@ -1058,9 +1053,7 @@ static int X_DoExecute(void)
if (g_sp->z < (ActorExtra[g_i].floorz-FOURSLEIGHT)) if (g_sp->z < (ActorExtra[g_i].floorz-FOURSLEIGHT))
{ {
g_sp->z += g_sp->zvel += j; g_sp->z += g_sp->zvel = min(6144, g_sp->zvel+j);
if (g_sp->zvel > 6144) g_sp->zvel = 6144;
if (g_sp->z > (ActorExtra[g_i].floorz - FOURSLEIGHT)) if (g_sp->z > (ActorExtra[g_i].floorz - FOURSLEIGHT))
g_sp->z = (ActorExtra[g_i].floorz - FOURSLEIGHT); g_sp->z = (ActorExtra[g_i].floorz - FOURSLEIGHT);
@ -1441,18 +1434,10 @@ static int X_DoExecute(void)
} }
case CON_HEADSPRITESTAT: case CON_HEADSPRITESTAT:
case CON_PREVSPRITESTAT:
case CON_NEXTSPRITESTAT:
case CON_HEADSPRITESECT:
case CON_PREVSPRITESECT:
case CON_NEXTSPRITESECT:
insptr++; insptr++;
{ {
int i=*insptr++; int i=*insptr++;
j=Gv_GetVar(*insptr++, g_i, g_p); j=Gv_GetVar(*insptr++, g_i, g_p);
switch (tw)
{
case CON_HEADSPRITESTAT:
if ((j < 0 || j > MAXSTATUS) && g_scriptSanityChecks) if ((j < 0 || j > MAXSTATUS) && g_scriptSanityChecks)
{ {
OSD_Printf(CON_ERROR "invalid status list %d\n",g_errorLineNum,keyw[g_tw],j); OSD_Printf(CON_ERROR "invalid status list %d\n",g_errorLineNum,keyw[g_tw],j);
@ -1460,7 +1445,13 @@ static int X_DoExecute(void)
} }
Gv_SetVar(i,headspritestat[j],g_i,g_p); Gv_SetVar(i,headspritestat[j],g_i,g_p);
break; break;
}
case CON_PREVSPRITESTAT: case CON_PREVSPRITESTAT:
insptr++;
{
int i=*insptr++;
j=Gv_GetVar(*insptr++, g_i, g_p);
if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks) if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks)
{ {
OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j);
@ -1468,7 +1459,13 @@ static int X_DoExecute(void)
} }
Gv_SetVar(i,prevspritestat[j],g_i,g_p); Gv_SetVar(i,prevspritestat[j],g_i,g_p);
break; break;
}
case CON_NEXTSPRITESTAT: case CON_NEXTSPRITESTAT:
insptr++;
{
int i=*insptr++;
j=Gv_GetVar(*insptr++, g_i, g_p);
if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks) if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks)
{ {
OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j);
@ -1476,7 +1473,13 @@ static int X_DoExecute(void)
} }
Gv_SetVar(i,nextspritestat[j],g_i,g_p); Gv_SetVar(i,nextspritestat[j],g_i,g_p);
break; break;
}
case CON_HEADSPRITESECT: case CON_HEADSPRITESECT:
insptr++;
{
int i=*insptr++;
j=Gv_GetVar(*insptr++, g_i, g_p);
if ((j < 0 || j > numsectors) && g_scriptSanityChecks) if ((j < 0 || j > numsectors) && g_scriptSanityChecks)
{ {
OSD_Printf(CON_ERROR "invalid sector %d\n",g_errorLineNum,keyw[g_tw],j); OSD_Printf(CON_ERROR "invalid sector %d\n",g_errorLineNum,keyw[g_tw],j);
@ -1484,7 +1487,13 @@ static int X_DoExecute(void)
} }
Gv_SetVar(i,headspritesect[j],g_i,g_p); Gv_SetVar(i,headspritesect[j],g_i,g_p);
break; break;
}
case CON_PREVSPRITESECT: case CON_PREVSPRITESECT:
insptr++;
{
int i=*insptr++;
j=Gv_GetVar(*insptr++, g_i, g_p);
if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks) if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks)
{ {
OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j);
@ -1492,7 +1501,13 @@ static int X_DoExecute(void)
} }
Gv_SetVar(i,prevspritesect[j],g_i,g_p); Gv_SetVar(i,prevspritesect[j],g_i,g_p);
break; break;
}
case CON_NEXTSPRITESECT: case CON_NEXTSPRITESECT:
insptr++;
{
int i=*insptr++;
j=Gv_GetVar(*insptr++, g_i, g_p);
if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks) if ((j < 0 || j >= MAXSPRITES) && g_scriptSanityChecks)
{ {
OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j); OSD_Printf(CON_ERROR "invalid sprite ID %d\n",g_errorLineNum,keyw[g_tw],j);
@ -1501,8 +1516,6 @@ static int X_DoExecute(void)
Gv_SetVar(i,nextspritesect[j],g_i,g_p); Gv_SetVar(i,nextspritesect[j],g_i,g_p);
break; break;
} }
break;
}
case CON_GETKEYNAME: case CON_GETKEYNAME:
insptr++; insptr++;
@ -3421,13 +3434,16 @@ static int X_DoExecute(void)
// syntax [gs]etactor[<var>].x <VAR> // syntax [gs]etactor[<var>].x <VAR>
// <varid> <xxxid> <varid> // <varid> <xxxid> <varid>
int lVar1=*insptr++, lLabelID=*insptr++, lParm2 = 0, lVar2; int lVar1=*insptr++, lLabelID=*insptr++, lParm2 = 0;
if (ActorLabels[lLabelID].flags & LABEL_HASPARM2) if (ActorLabels[lLabelID].flags & LABEL_HASPARM2)
lParm2=Gv_GetVar(*insptr++, g_i, g_p); lParm2=Gv_GetVar(*insptr++, g_i, g_p);
lVar2=*insptr++;
{
int lVar2=*insptr++;
X_AccessSprite(tw==CON_SETACTOR, lVar1, lLabelID, lVar2, lParm2); X_AccessSprite(tw==CON_SETACTOR, lVar1, lLabelID, lVar2, lParm2);
}
break; break;
} }
@ -3548,13 +3564,13 @@ static int X_DoExecute(void)
case CON_RANDVAR: case CON_RANDVAR:
insptr++; insptr++;
Gv_SetVar(*insptr, mulscale(krand(), *(insptr+1)+1, 16), g_i, g_p); Gv_SetVar(*insptr, mulscale16(krand(), *(insptr+1)+1), g_i, g_p);
insptr += 2; insptr += 2;
break; break;
case CON_DISPLAYRANDVAR: case CON_DISPLAYRANDVAR:
insptr++; insptr++;
Gv_SetVar(*insptr, mulscale(rand(), *(insptr+1)+1, 15), g_i, g_p); Gv_SetVar(*insptr, mulscale15(rand(), *(insptr+1)+1), g_i, g_p);
insptr += 2; insptr += 2;
break; break;

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

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

View file

@ -341,7 +341,6 @@ int A_Shoot(int i,int atwith)
if (ProjectileData[atwith].offset == 0) ProjectileData[atwith].offset = 1; if (ProjectileData[atwith].offset == 0) ProjectileData[atwith].offset = 1;
// writestring(sx,sy,sz,sect,sintable[(sa+512)&2047],sintable[sa&2047],zvel<<6);
if (ProjectileData[atwith].workslike & PROJECTILE_BLOOD || ProjectileData[atwith].workslike & PROJECTILE_KNEE) if (ProjectileData[atwith].workslike & PROJECTILE_BLOOD || ProjectileData[atwith].workslike & PROJECTILE_KNEE)
{ {
@ -1013,7 +1012,6 @@ DOSKIPBULLETHOLE:
} }
} }
// writestring(sx,sy,sz,sect,sintable[(sa+512)&2047],sintable[sa&2047],zvel<<6);
if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9]; if (ActorExtra[i].temp_data[9]) zvel = ActorExtra[i].temp_data[9];
hitscan(sx,sy,sz,sect, hitscan(sx,sy,sz,sect,
sintable[(sa+512)&2047], sintable[(sa+512)&2047],

View file

@ -371,8 +371,8 @@ static void G_DoLoadScreen(char *statustext, int percent)
if (statustext) gametext(160,180,statustext,0,2+8+16); if (statustext) gametext(160,180,statustext,0,2+8+16);
j = usehightile; j = usehightile;
usehightile = 0; usehightile = 0;
rotatesprite(33<<16,140<<16,65536,0,LASERLINE,0,0,2+8+16,0,0,scale(xdim-1,percent,100),ydim-1); rotatesprite(33<<16,144<<16,65536,0,LASERLINE,0,0,2+8+16,0,0,scale(xdim-1,percent,100),ydim-1);
rotatesprite(153<<16,140<<16,65536,0,LASERLINE,0,0,2+8+16,0,0,scale(xdim-1,percent,100),ydim-1); rotatesprite(153<<16,144<<16,65536,0,LASERLINE,0,0,2+8+16,0,0,scale(xdim-1,percent,100),ydim-1);
usehightile = j; usehightile = j;
X_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1); X_OnEvent(EVENT_DISPLAYLOADINGSCREEN, g_player[screenpeek].ps->i, screenpeek, -1);
nextpage(); nextpage();
@ -505,7 +505,7 @@ void G_CacheMapData(void)
} }
if (totalclock - tc > TICRATE/4) if (totalclock - tc > TICRATE/4)
{ {
sprintf(tempbuf,"%d resources remaining\n",g_precacheCount-pc); sprintf(tempbuf,"%d resources remaining\n",g_precacheCount-pc+1);
G_DoLoadScreen(tempbuf, min(100,100*pc/g_precacheCount)); G_DoLoadScreen(tempbuf, min(100,100*pc/g_precacheCount));
tc = totalclock; tc = totalclock;
} }
@ -930,7 +930,7 @@ static void prelevel(char g)
while (i >= 0) while (i >= 0)
{ {
nexti = nextspritestat[i]; nexti = nextspritestat[i];
A_ResetGameVars(i); A_ResetVars(i);
A_LoadActor(i); A_LoadActor(i);
X_OnEvent(EVENT_LOADACTOR, i, -1, -1); X_OnEvent(EVENT_LOADACTOR, i, -1, -1);
if (sprite[i].lotag == -1 && (sprite[i].cstat&16)) if (sprite[i].lotag == -1 && (sprite[i].cstat&16))
@ -1253,7 +1253,7 @@ void G_NewGame(int vn,int ln,int sk)
p->gm = 0; p->gm = 0;
//AddLog("Newgame"); //AddLog("Newgame");
Gv_ResetVarsToDefault(); Gv_ResetVars();
Gv_InitWeaponPointers(); Gv_InitWeaponPointers();