Game now proceeds to the main game loop

This commit is contained in:
Maxime Vincent 2016-05-16 23:27:09 +02:00
parent 6ab1ad1ed2
commit 2562c5dcef
6 changed files with 62 additions and 21 deletions

View File

@ -51,7 +51,6 @@
#include <float.h> #include <float.h>
#define MAXDOUBLE DBL_MAX #define MAXDOUBLE DBL_MAX
#define MAXFLOAT FLT_MAX
#define MINDOUBLE DBL_MIN #define MINDOUBLE DBL_MIN
#define MINFLOAT FLT_MIN #define MINFLOAT FLT_MIN
#define DMINEXP DBL_MIN_EXP #define DMINEXP DBL_MIN_EXP

View File

@ -577,7 +577,8 @@ void IdentifyVersion (void)
char *doomwaddir; char *doomwaddir;
doomwaddir = getenv("DOOMWADDIR"); doomwaddir = getenv("DOOMWADDIR");
if (!doomwaddir) if (!doomwaddir)
doomwaddir = "."; doomwaddir = "/mnt";
//XXX doomwaddir = ".";
// Commercial. // Commercial.
doom2wad = malloc(strlen(doomwaddir)+1+9+1); doom2wad = malloc(strlen(doomwaddir)+1+9+1);
@ -593,7 +594,8 @@ void IdentifyVersion (void)
// Shareware. // Shareware.
doom1wad = malloc(strlen(doomwaddir)+1+9+1); doom1wad = malloc(strlen(doomwaddir)+1+9+1);
sprintf(doom1wad, "%s/doom1.wad", doomwaddir); //XXX sprintf(doom1wad, "%s/doom1.wad", doomwaddir);
sprintf(doom1wad, "%s/DOOM1.WAD", doomwaddir);
// Bug, dear Shawn. // Bug, dear Shawn.
// Insufficient malloc, caused spurious realloc errors. // Insufficient malloc, caused spurious realloc errors.
@ -608,7 +610,8 @@ void IdentifyVersion (void)
doom2fwad = malloc(strlen(doomwaddir)+1+10+1); doom2fwad = malloc(strlen(doomwaddir)+1+10+1);
sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir); sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir);
home = getenv("HOME"); //home = getenv("HOME");
home = "/mnt";
if (!home) if (!home)
I_Error("Please set $HOME to your home directory"); I_Error("Please set $HOME to your home directory");
sprintf(basedefault, "%s/.doomrc", home); sprintf(basedefault, "%s/.doomrc", home);
@ -802,7 +805,7 @@ void D_DoomMain (void)
IdentifyVersion (); IdentifyVersion ();
setbuf (stdout, NULL); //XXX setbuf (stdout, NULL);
modifiedgame = false; modifiedgame = false;
nomonsters = M_CheckParm ("-nomonsters"); nomonsters = M_CheckParm ("-nomonsters");

View File

@ -128,7 +128,7 @@ animdef_t animdefs[] =
{true, "WFALL4", "WFALL1", 8}, {true, "WFALL4", "WFALL1", 8},
{true, "DBRAIN4", "DBRAIN1", 8}, {true, "DBRAIN4", "DBRAIN1", 8},
{-1} {false, "\0", "\0", 0}
}; };
anim_t anims[MAXANIMS]; anim_t anims[MAXANIMS];
@ -152,7 +152,8 @@ void P_InitPicAnims (void)
// Init animation // Init animation
lastanim = anims; lastanim = anims;
for (i=0 ; animdefs[i].istexture != -1 ; i++) //for (i=0 ; animdefs[i].istexture != -1 ; i++)
for (i=0 ; animdefs[i].startname[0] != NULL ; i++)
{ {
if (animdefs[i].istexture) if (animdefs[i].istexture)
{ {

View File

@ -319,7 +319,10 @@ void R_GenerateLookup (int texnum)
// that are covered by more than one patch. // that are covered by more than one patch.
// Fill in the lump / offset, so columns // Fill in the lump / offset, so columns
// with only a single patch are all done. // with only a single patch are all done.
patchcount = (byte *)alloca (texture->width); //XXX patchcount = (byte *)alloca (texture->width);
patchcount = (byte *)malloc (texture->width);
if (!patchcount)
return;
memset (patchcount, 0, texture->width); memset (patchcount, 0, texture->width);
patch = texture->patches; patch = texture->patches;
@ -371,6 +374,8 @@ void R_GenerateLookup (int texnum)
texturecompositesize[texnum] += texture->height; texturecompositesize[texnum] += texture->height;
} }
} }
free(patchcount);
} }
@ -448,7 +453,10 @@ void R_InitTextures (void)
names = W_CacheLumpName ("PNAMES", PU_STATIC); names = W_CacheLumpName ("PNAMES", PU_STATIC);
nummappatches = LONG ( *((int *)names) ); nummappatches = LONG ( *((int *)names) );
name_p = names+4; name_p = names+4;
patchlookup = alloca (nummappatches*sizeof(*patchlookup)); //XXX patchlookup = alloca (nummappatches*sizeof(*patchlookup));
patchlookup = malloc (nummappatches*sizeof(*patchlookup));
if (!patchlookup)
return;
for (i=0 ; i<nummappatches ; i++) for (i=0 ; i<nummappatches ; i++)
{ {
@ -571,6 +579,8 @@ void R_InitTextures (void)
for (i=0 ; i<numtextures ; i++) for (i=0 ; i<numtextures ; i++)
texturetranslation[i] = i; texturetranslation[i] = i;
free(patchlookup);
} }
@ -759,7 +769,10 @@ void R_PrecacheLevel (void)
return; return;
// Precache flats. // Precache flats.
flatpresent = alloca(numflats); //XXX flatpresent = alloca(numflats);
flatpresent = malloc(numflats);
if (!flatpresent)
return;
memset (flatpresent,0,numflats); memset (flatpresent,0,numflats);
for (i=0 ; i<numsectors ; i++) for (i=0 ; i<numsectors ; i++)
@ -780,8 +793,13 @@ void R_PrecacheLevel (void)
} }
} }
free(flatpresent);
// Precache textures. // Precache textures.
texturepresent = alloca(numtextures); //XXX texturepresent = alloca(numtextures);
texturepresent = malloc(numtextures);
if (!texturepresent)
return;
memset (texturepresent,0, numtextures); memset (texturepresent,0, numtextures);
for (i=0 ; i<numsides ; i++) for (i=0 ; i<numsides ; i++)
@ -815,8 +833,13 @@ void R_PrecacheLevel (void)
} }
} }
free(texturepresent);
// Precache sprites. // Precache sprites.
spritepresent = alloca(numsprites); //XXX spritepresent = alloca(numsprites);
spritepresent = malloc(numsprites);
if (!numsprites)
return;
memset (spritepresent,0, numsprites); memset (spritepresent,0, numsprites);
for (th = thinkercap.next ; th != &thinkercap ; th=th->next) for (th = thinkercap.next ; th != &thinkercap ; th=th->next)
@ -842,6 +865,8 @@ void R_PrecacheLevel (void)
} }
} }
} }
free(numsprites);
} }

View File

@ -10,8 +10,13 @@ in_addr_t inet_addr(const char *cp)
} }
// XXX FIXME // XXX FIXME
int usleep(useconds_t us) //int usleep(useconds_t us)
{ //{
return 0; // return 0;
} //}
//
//
//struct hostent *gethostbyname(const char *name)
//{
// return NULL;
//}

View File

@ -196,7 +196,8 @@ void W_AddFile (char *filename)
header.numlumps = LONG(header.numlumps); header.numlumps = LONG(header.numlumps);
header.infotableofs = LONG(header.infotableofs); header.infotableofs = LONG(header.infotableofs);
length = header.numlumps*sizeof(filelump_t); length = header.numlumps*sizeof(filelump_t);
fileinfo = alloca (length); //XXX fileinfo = alloca (length);
fileinfo = malloc (length);
lseek (handle, header.infotableofs, SEEK_SET); lseek (handle, header.infotableofs, SEEK_SET);
read (handle, fileinfo, length); read (handle, fileinfo, length);
numlumps += header.numlumps; numlumps += header.numlumps;
@ -221,6 +222,9 @@ void W_AddFile (char *filename)
strncpy (lump_p->name, fileinfo->name, 8); strncpy (lump_p->name, fileinfo->name, 8);
} }
//XXX: Alloca replacement
free(fileinfo);
if (reloadname) if (reloadname)
close (handle); close (handle);
} }
@ -253,7 +257,10 @@ void W_Reload (void)
lumpcount = LONG(header.numlumps); lumpcount = LONG(header.numlumps);
header.infotableofs = LONG(header.infotableofs); header.infotableofs = LONG(header.infotableofs);
length = lumpcount*sizeof(filelump_t); length = lumpcount*sizeof(filelump_t);
fileinfo = alloca (length); //XXX fileinfo = alloca (length);
fileinfo = malloc (length);
if (!fileinfo)
return;
lseek (handle, header.infotableofs, SEEK_SET); lseek (handle, header.infotableofs, SEEK_SET);
read (handle, fileinfo, length); read (handle, fileinfo, length);
@ -271,6 +278,7 @@ void W_Reload (void)
lump_p->size = LONG(fileinfo->size); lump_p->size = LONG(fileinfo->size);
} }
free(fileinfo);
close (handle); close (handle);
} }