summaryrefslogtreecommitdiff
path: root/src/doom
diff options
context:
space:
mode:
Diffstat (limited to 'src/doom')
-rw-r--r--src/doom/d_main.c4
-rw-r--r--src/doom/d_net.h2
-rw-r--r--src/doom/deh_defs.h2
-rw-r--r--src/doom/deh_main.c4
-rw-r--r--src/doom/deh_ptr.c2
-rw-r--r--src/doom/p_doors.c37
-rw-r--r--src/doom/p_map.c3
-rw-r--r--src/doom/p_spec.c150
8 files changed, 182 insertions, 22 deletions
diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index 9fa9ae3b..4e7812cc 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -901,7 +901,7 @@ static struct
{ NULL, NULL, 0},
};
-// Initialise the game version
+// Initialize the game version
static void InitGameVersion(void)
{
@@ -1701,7 +1701,7 @@ void D_DoomMain (void)
I_InitJoystick();
#ifdef FEATURE_MULTIPLAYER
- printf ("NET_Init: Initialise network subsystem.\n");
+ printf ("NET_Init: Init network subsystem.\n");
NET_Init ();
#endif
diff --git a/src/doom/d_net.h b/src/doom/d_net.h
index 6d162d20..f801d216 100644
--- a/src/doom/d_net.h
+++ b/src/doom/d_net.h
@@ -42,7 +42,7 @@ void D_QuitNetGame (void);
//? how many ticks to run?
void TryRunTics (void);
-// Called at start of game loop to initialise timers
+// Called at start of game loop to initialize timers
void D_StartGameLoop(void);
extern boolean drone;
diff --git a/src/doom/deh_defs.h b/src/doom/deh_defs.h
index a6650544..e7b76182 100644
--- a/src/doom/deh_defs.h
+++ b/src/doom/deh_defs.h
@@ -41,7 +41,7 @@ struct deh_section_s
{
char *name;
- // Called on startup to initialise code
+ // Called on startup to initialize code
deh_section_init_t init;
diff --git a/src/doom/deh_main.c b/src/doom/deh_main.c
index 59e63ea3..63cae460 100644
--- a/src/doom/deh_main.c
+++ b/src/doom/deh_main.c
@@ -110,7 +110,7 @@ void DEH_Checksum(md5_digest_t digest)
// Called on startup to call the Init functions
-static void InitialiseSections(void)
+static void InitializeSections(void)
{
unsigned int i;
@@ -385,7 +385,7 @@ void DEH_Init(void)
char *filename;
int p;
- InitialiseSections();
+ InitializeSections();
//!
// @category mod
diff --git a/src/doom/deh_ptr.c b/src/doom/deh_ptr.c
index 87daf7d8..d757a178 100644
--- a/src/doom/deh_ptr.c
+++ b/src/doom/deh_ptr.c
@@ -56,7 +56,7 @@ static void DEH_PointerInit(void)
{
int i;
- // Initialise list of dehacked pointers
+ // Initialize list of dehacked pointers
for (i=0; i<NUMSTATES; ++i)
codeptrs[i] = states[i].action;
diff --git a/src/doom/p_doors.c b/src/doom/p_doors.c
index b681a8d0..89b65328 100644
--- a/src/doom/p_doors.c
+++ b/src/doom/p_doors.c
@@ -420,8 +420,41 @@ EV_VerticalDoor
{
if (!thing->player)
return; // JDC: bad guys never close doors
-
- door->direction = -1; // start going down immediately
+
+ // When is a door not a door?
+ // In Vanilla, door->direction is set, even though
+ // "specialdata" might not actually point at a door.
+
+ if (door->thinker.function.acp1 == (actionf_p1) T_VerticalDoor)
+ {
+ door->direction = -1; // start going down immediately
+ }
+ else if (door->thinker.function.acp1 == (actionf_p1) T_PlatRaise)
+ {
+ // Erm, this is a plat, not a door.
+ // This notably causes a problem in ep1-0500.lmp where
+ // a plat and a door are cross-referenced; the door
+ // doesn't open on 64-bit.
+ // The direction field in vldoor_t corresponds to the wait
+ // field in plat_t. Let's set that to -1 instead.
+
+ plat_t *plat;
+
+ plat = (plat_t *) door;
+ plat->wait = -1;
+ }
+ else
+ {
+ // This isn't a door OR a plat. Now we're in trouble.
+
+ fprintf(stderr, "EV_VerticalDoor: Tried to close "
+ "something that wasn't a door.\n");
+
+ // Try closing it anyway. At least it will work on 32-bit
+ // machines.
+
+ door->direction = -1;
+ }
}
return;
}
diff --git a/src/doom/p_map.c b/src/doom/p_map.c
index 9198d59e..3f88aabc 100644
--- a/src/doom/p_map.c
+++ b/src/doom/p_map.c
@@ -36,6 +36,7 @@
#include "doomdef.h"
#include "m_argv.h"
+#include "m_misc.h"
#include "p_local.h"
#include "s_sound.h"
@@ -1412,7 +1413,7 @@ static void SpechitOverrun(line_t *ld)
if (p > 0)
{
- baseaddr = atoi(myargv[p+1]);
+ M_StrToInt(myargv[p+1], (int *) &baseaddr);
}
else
{
diff --git a/src/doom/p_spec.c b/src/doom/p_spec.c
index 27042b5d..37beb850 100644
--- a/src/doom/p_spec.c
+++ b/src/doom/p_spec.c
@@ -38,6 +38,7 @@
#include "i_system.h"
#include "z_zone.h"
#include "m_argv.h"
+#include "m_misc.h"
#include "m_random.h"
#include "w_wad.h"
@@ -1169,10 +1170,94 @@ void P_UpdateSpecials (void)
memset(&buttonlist[i],0,sizeof(button_t));
}
}
-
}
+//
+// Donut overrun emulation
+//
+// Derived from the code from PrBoom+. Thanks go to Andrey Budko (entryway)
+// as usual :-)
+//
+
+#define DONUT_FLOORHEIGHT_DEFAULT 0x00000000
+#define DONUT_FLOORPIC_DEFAULT 0x16
+
+static void DonutOverrun(fixed_t *s3_floorheight, short *s3_floorpic,
+ line_t *line, sector_t *pillar_sector)
+{
+ static int first = 1;
+ static int tmp_s3_floorheight;
+ static int tmp_s3_floorpic;
+
+ extern int numflats;
+
+ if (first)
+ {
+ int p;
+
+ // This is the first time we have had an overrun.
+ first = 0;
+
+ // Default values
+ tmp_s3_floorheight = DONUT_FLOORHEIGHT_DEFAULT;
+ tmp_s3_floorpic = DONUT_FLOORPIC_DEFAULT;
+
+ //!
+ // @category compat
+ // @arg <x> <y>
+ //
+ // Use the specified magic values when emulating behavior caused
+ // by memory overruns from improperly constructed donuts.
+ // In Vanilla Doom this can differ depending on the operating
+ // system. The default (if this option is not specified) is to
+ // emulate the behavior when running under Windows 98.
+
+ p = M_CheckParm("-donut");
+
+ if (p > 0 && p < myargc - 2)
+ {
+ // Dump of needed memory: (fixed_t)0000:0000 and (short)0000:0008
+ //
+ // C:\>debug
+ // -d 0:0
+ //
+ // DOS 6.22:
+ // 0000:0000 (57 92 19 00) F4 06 70 00-(16 00)
+ // DOS 7.1:
+ // 0000:0000 (9E 0F C9 00) 65 04 70 00-(16 00)
+ // Win98:
+ // 0000:0000 (00 00 00 00) 65 04 70 00-(16 00)
+ // DOSBox under XP:
+ // 0000:0000 (00 00 00 F1) ?? ?? ?? 00-(07 00)
+
+ M_StrToInt(myargv[p + 1], &tmp_s3_floorheight);
+ M_StrToInt(myargv[p + 2], &tmp_s3_floorpic);
+
+ if (tmp_s3_floorpic >= numflats)
+ {
+ fprintf(stderr,
+ "DonutOverrun: The second parameter for \"-donut\" "
+ "switch should be greater than 0 and less than number "
+ "of flats (%d). Using default value (%d) instead. \n",
+ numflats, DONUT_FLOORPIC_DEFAULT);
+ tmp_s3_floorpic = DONUT_FLOORPIC_DEFAULT;
+ }
+ }
+ }
+
+ /*
+ fprintf(stderr,
+ "Linedef: %d; Sector: %d; "
+ "New floor height: %d; New floor pic: %d\n",
+ line->iLineID, pillar_sector->iSectorID,
+ tmp_s3_floorheight >> 16, tmp_s3_floorpic);
+ */
+
+ *s3_floorheight = (fixed_t) tmp_s3_floorheight;
+ *s3_floorpic = (short) tmp_s3_floorpic;
+}
+
//
// Special Stuff that can not be categorized
@@ -1186,26 +1271,67 @@ int EV_DoDonut(line_t* line)
int rtn;
int i;
floormove_t* floor;
-
+ fixed_t s3_floorheight;
+ short s3_floorpic;
+
secnum = -1;
rtn = 0;
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
{
s1 = &sectors[secnum];
-
+
// ALREADY MOVING? IF SO, KEEP GOING...
if (s1->specialdata)
continue;
-
+
rtn = 1;
s2 = getNextSector(s1->lines[0],s1);
- for (i = 0;i < s2->linecount;i++)
+
+ // Vanilla Doom does not check if the linedef is one sided. The
+ // game does not crash, but reads invalid memory and causes the
+ // sector floor to move "down" to some unknown height.
+ // DOSbox prints a warning about an invalid memory access.
+ //
+ // I'm not sure exactly what invalid memory is being read. This
+ // isn't something that should be done, anyway.
+ // Just print a warning and return.
+
+ if (s2 == NULL)
+ {
+ fprintf(stderr,
+ "EV_DoDonut: linedef had no second sidedef! "
+ "Unexpected behavior may occur in Vanilla Doom. \n");
+ break;
+ }
+
+ for (i = 0; i < s2->linecount; i++)
{
- if ((!s2->lines[i]->flags & ML_TWOSIDED) ||
- (s2->lines[i]->backsector == s1))
- continue;
s3 = s2->lines[i]->backsector;
-
+
+ if (s3 == s1)
+ continue;
+
+ if (s3 == NULL)
+ {
+ // e6y
+ // s3 is NULL, so
+ // s3->floorheight is an int at 0000:0000
+ // s3->floorpic is a short at 0000:0008
+ // Trying to emulate
+
+ fprintf(stderr,
+ "EV_DoDonut: WARNING: emulating buffer overrun due to "
+ "NULL back sector. "
+ "Unexpected behavior may occur in Vanilla Doom.\n");
+
+ DonutOverrun(&s3_floorheight, &s3_floorpic, line, s1);
+ }
+ else
+ {
+ s3_floorheight = s3->floorheight;
+ s3_floorpic = s3->floorpic;
+ }
+
// Spawn rising slime
floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);
P_AddThinker (&floor->thinker);
@@ -1216,9 +1342,9 @@ int EV_DoDonut(line_t* line)
floor->direction = 1;
floor->sector = s2;
floor->speed = FLOORSPEED / 2;
- floor->texture = s3->floorpic;
+ floor->texture = s3_floorpic;
floor->newspecial = 0;
- floor->floordestheight = s3->floorheight;
+ floor->floordestheight = s3_floorheight;
// Spawn lowering donut-hole
floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0);
@@ -1230,7 +1356,7 @@ int EV_DoDonut(line_t* line)
floor->direction = -1;
floor->sector = s1;
floor->speed = FLOORSPEED / 2;
- floor->floordestheight = s3->floorheight;
+ floor->floordestheight = s3_floorheight;
break;
}
}