From 2562c5dcef2be83a8012ad00f1ed229475c06a26 Mon Sep 17 00:00:00 2001 From: Maxime Vincent Date: Mon, 16 May 2016 23:27:09 +0200 Subject: [PATCH] Game now proceeds to the main game loop --- frosted-doom/compat/values.h | 1 - frosted-doom/d_main.c | 11 +++++++---- frosted-doom/p_spec.c | 5 +++-- frosted-doom/r_data.c | 37 ++++++++++++++++++++++++++++++------ frosted-doom/stubs.c | 15 ++++++++++----- frosted-doom/w_wad.c | 14 +++++++++++--- 6 files changed, 62 insertions(+), 21 deletions(-) diff --git a/frosted-doom/compat/values.h b/frosted-doom/compat/values.h index 5ae2ead..389b9d2 100644 --- a/frosted-doom/compat/values.h +++ b/frosted-doom/compat/values.h @@ -51,7 +51,6 @@ #include #define MAXDOUBLE DBL_MAX -#define MAXFLOAT FLT_MAX #define MINDOUBLE DBL_MIN #define MINFLOAT FLT_MIN #define DMINEXP DBL_MIN_EXP diff --git a/frosted-doom/d_main.c b/frosted-doom/d_main.c index 0d52762..c8c7a2b 100644 --- a/frosted-doom/d_main.c +++ b/frosted-doom/d_main.c @@ -577,7 +577,8 @@ void IdentifyVersion (void) char *doomwaddir; doomwaddir = getenv("DOOMWADDIR"); if (!doomwaddir) - doomwaddir = "."; + doomwaddir = "/mnt"; + //XXX doomwaddir = "."; // Commercial. doom2wad = malloc(strlen(doomwaddir)+1+9+1); @@ -593,7 +594,8 @@ void IdentifyVersion (void) // Shareware. 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. // Insufficient malloc, caused spurious realloc errors. @@ -608,7 +610,8 @@ void IdentifyVersion (void) doom2fwad = malloc(strlen(doomwaddir)+1+10+1); sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir); - home = getenv("HOME"); + //home = getenv("HOME"); + home = "/mnt"; if (!home) I_Error("Please set $HOME to your home directory"); sprintf(basedefault, "%s/.doomrc", home); @@ -802,7 +805,7 @@ void D_DoomMain (void) IdentifyVersion (); - setbuf (stdout, NULL); + //XXX setbuf (stdout, NULL); modifiedgame = false; nomonsters = M_CheckParm ("-nomonsters"); diff --git a/frosted-doom/p_spec.c b/frosted-doom/p_spec.c index f048afb..78452c8 100644 --- a/frosted-doom/p_spec.c +++ b/frosted-doom/p_spec.c @@ -128,7 +128,7 @@ animdef_t animdefs[] = {true, "WFALL4", "WFALL1", 8}, {true, "DBRAIN4", "DBRAIN1", 8}, - {-1} + {false, "\0", "\0", 0} }; anim_t anims[MAXANIMS]; @@ -152,7 +152,8 @@ void P_InitPicAnims (void) // Init animation 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) { diff --git a/frosted-doom/r_data.c b/frosted-doom/r_data.c index acabd53..54e6ec5 100644 --- a/frosted-doom/r_data.c +++ b/frosted-doom/r_data.c @@ -319,7 +319,10 @@ void R_GenerateLookup (int texnum) // that are covered by more than one patch. // Fill in the lump / offset, so columns // 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); patch = texture->patches; @@ -370,7 +373,9 @@ void R_GenerateLookup (int texnum) texturecompositesize[texnum] += texture->height; } - } + } + + free(patchcount); } @@ -448,7 +453,10 @@ void R_InitTextures (void) names = W_CacheLumpName ("PNAMES", PU_STATIC); nummappatches = LONG ( *((int *)names) ); 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 ; inext) @@ -842,6 +865,8 @@ void R_PrecacheLevel (void) } } } + + free(numsprites); } diff --git a/frosted-doom/stubs.c b/frosted-doom/stubs.c index dc1a32e..77a5358 100644 --- a/frosted-doom/stubs.c +++ b/frosted-doom/stubs.c @@ -10,8 +10,13 @@ in_addr_t inet_addr(const char *cp) } // XXX FIXME -int usleep(useconds_t us) -{ - return 0; -} - +//int usleep(useconds_t us) +//{ +// return 0; +//} +// +// +//struct hostent *gethostbyname(const char *name) +//{ +// return NULL; +//} diff --git a/frosted-doom/w_wad.c b/frosted-doom/w_wad.c index de6b2b1..636e4fb 100644 --- a/frosted-doom/w_wad.c +++ b/frosted-doom/w_wad.c @@ -196,7 +196,8 @@ void W_AddFile (char *filename) header.numlumps = LONG(header.numlumps); header.infotableofs = LONG(header.infotableofs); length = header.numlumps*sizeof(filelump_t); - fileinfo = alloca (length); + //XXX fileinfo = alloca (length); + fileinfo = malloc (length); lseek (handle, header.infotableofs, SEEK_SET); read (handle, fileinfo, length); numlumps += header.numlumps; @@ -220,6 +221,9 @@ void W_AddFile (char *filename) lump_p->size = LONG(fileinfo->size); strncpy (lump_p->name, fileinfo->name, 8); } + + //XXX: Alloca replacement + free(fileinfo); if (reloadname) close (handle); @@ -253,7 +257,10 @@ void W_Reload (void) lumpcount = LONG(header.numlumps); header.infotableofs = LONG(header.infotableofs); length = lumpcount*sizeof(filelump_t); - fileinfo = alloca (length); + //XXX fileinfo = alloca (length); + fileinfo = malloc (length); + if (!fileinfo) + return; lseek (handle, header.infotableofs, SEEK_SET); read (handle, fileinfo, length); @@ -270,7 +277,8 @@ void W_Reload (void) lump_p->position = LONG(fileinfo->filepos); lump_p->size = LONG(fileinfo->size); } - + + free(fileinfo); close (handle); }