foxygit / doom Log in
commit 8cdc173252c479b8a7448da9ccd48f32eeb0c427
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Wed Sep 17 19:56:12 2008 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Wed Sep 17 19:56:12 2008 +0000

    Remove definitions from heretic/doomdef.h that are in common code.
    Replace "shareware" variable with gamemode, as in doom code. Merge angle
    definitions into common code.

    Subversion-branch: /branches/raven-branch
    Subversion-revision: 1240
---
 src/doom/f_finale.c    |   1 +
 src/doom/g_game.c      |   2 -
 src/heretic/am_map.c   |   5 ++-
 src/heretic/ct_chat.c  |   1 +
 src/heretic/d_main.c   |  19 ++++++---
 src/heretic/d_net.c    |   1 +
 src/heretic/doomdef.h  | 102 +++++++------------------------------------------
 src/heretic/f_finale.c |   2 +-
 src/heretic/g_game.c   |   1 +
 src/heretic/m_misc.c   |   2 +-
 src/heretic/mn_menu.c  |   5 ++-
 src/heretic/p_enemy.c  |   8 ++--
 src/heretic/p_mobj.c   |   8 ++--
 src/heretic/p_pspr.c   |   6 +--
 src/heretic/p_switch.c |   2 +-
 src/heretic/p_user.c   |   2 +-
 src/heretic/r_draw.c   |   4 +-
 src/heretic/r_local.h  |   1 -
 src/heretic/r_main.c   |  13 -------
 src/heretic/r_things.c |   2 +-
 src/heretic/sb_bar.c   |   8 ++--
 src/tables.h           |  11 ++++--
 22 files changed, 68 insertions(+), 138 deletions(-)

diff --git a/src/doom/f_finale.c b/src/doom/f_finale.c
index 1a3a85ca..e4d35ca4 100644
--- a/src/doom/f_finale.c
+++ b/src/doom/f_finale.c
@@ -38,6 +38,7 @@
 #include "s_sound.h"

 // Data.
+#include "d_main.h"
 #include "dstrings.h"
 #include "sounds.h"

diff --git a/src/doom/g_game.c b/src/doom/g_game.c
index d819af8d..99be6592 100644
--- a/src/doom/g_game.c
+++ b/src/doom/g_game.c
@@ -82,8 +82,6 @@

 #define SAVEGAMESIZE	0x2c000

-
-
 boolean	G_CheckDemoStatus (void);
 void	G_ReadDemoTiccmd (ticcmd_t* cmd);
 void	G_WriteDemoTiccmd (ticcmd_t* cmd);
diff --git a/src/heretic/am_map.c b/src/heretic/am_map.c
index 9fcc2714..90807644 100644
--- a/src/heretic/am_map.c
+++ b/src/heretic/am_map.c
@@ -23,11 +23,14 @@

 // AM_map.c

+#include <stdio.h>
+
 #include "doomdef.h"
 #include "p_local.h"
 #include "am_map.h"
 #include "am_data.h"
-#include <stdio.h>
+
+#include "doomkeys.h"

 vertex_t KeyPoints[NUMKEYS];

diff --git a/src/heretic/ct_chat.c b/src/heretic/ct_chat.c
index d83325b4..16635ba2 100644
--- a/src/heretic/ct_chat.c
+++ b/src/heretic/ct_chat.c
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <ctype.h>
 #include "doomdef.h"
+#include "doomkeys.h"
 #include "p_local.h"
 #include "s_sound.h"

diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c
index 283bd50d..e274044c 100644
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -35,7 +35,8 @@
 #include "p_local.h"
 #include "s_sound.h"

-boolean shareware = false;      // true if only episode 1 present
+GameMission_t gamemission = heretic;
+GameMode_t gamemode = indetermined;
 boolean ExtendedWAD = false;    // true if episodes 4 and 5 present

 boolean nomonsters;             // checkparm of -nomonsters
@@ -378,7 +379,7 @@ void D_DoAdvanceDemo(void)
         case 5:
             pagetic = 200;
             gamestate = GS_DEMOSCREEN;
-            if (shareware)
+            if (gamemode == shareware)
             {
                 pagename = "ORDER";
             }
@@ -919,11 +920,17 @@ void D_DoomMain(void)

     if (W_CheckNumForName("E2M1") == -1)
     {                           // Can't find episode 2 maps, must be the shareware WAD
-        shareware = true;
+        gamemode = shareware;
     }
-    else if (W_CheckNumForName("EXTENDED") != -1)
-    {                           // Found extended lump, must be the extended WAD
-        ExtendedWAD = true;
+    else
+    {
+        gamemode = registered;
+
+        // Is this the extended WAD?
+        if (W_CheckNumForName("EXTENDED") != -1)
+        {
+            ExtendedWAD = true;
+        }
     }

 #ifdef __WATCOMC__
diff --git a/src/heretic/d_net.c b/src/heretic/d_net.c
index 50cd7b63..bd94746a 100644
--- a/src/heretic/d_net.c
+++ b/src/heretic/d_net.c
@@ -25,6 +25,7 @@
 // This version has the fixed ticdup code

 #include "doomdef.h"
+#include "doomkeys.h"

 #define NCMD_EXIT               0x80000000
 #define NCMD_RETRANSMIT 0x40000000
diff --git a/src/heretic/doomdef.h b/src/heretic/doomdef.h
index 969448c6..bdf78a19 100644
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -53,46 +53,18 @@
 // WAD file access
 #include "w_wad.h"

-extern byte *destview, *destscreen;     // PC direct to screen pointers
+// fixed_t
+#include "m_fixed.h"

-//
-// most key data are simple ascii (uppercased)
-//
-#define	KEY_RIGHTARROW		0xae
-#define	KEY_LEFTARROW		0xac
-#define	KEY_UPARROW			0xad
-#define	KEY_DOWNARROW		0xaf
-#define	KEY_ESCAPE			27
-#define	KEY_ENTER			13
-#define	KEY_F1				(0x80+0x3b)
-#define	KEY_F2				(0x80+0x3c)
-#define	KEY_F3				(0x80+0x3d)
-#define	KEY_F4				(0x80+0x3e)
-#define	KEY_F5				(0x80+0x3f)
-#define	KEY_F6				(0x80+0x40)
-#define	KEY_F7				(0x80+0x41)
-#define	KEY_F8				(0x80+0x42)
-#define	KEY_F9				(0x80+0x43)
-#define	KEY_F10				(0x80+0x44)
-#define	KEY_F11				(0x80+0x57)
-#define	KEY_F12				(0x80+0x58)
-
-#define	KEY_BACKSPACE		127
-#define	KEY_PAUSE			0xff
-
-#define KEY_EQUALS			0x3d
-#define KEY_MINUS			0x2d
-
-#define	KEY_RSHIFT			(0x80+0x36)
-#define	KEY_RCTRL			(0x80+0x1d)
-#define	KEY_RALT			(0x80+0x38)
-
-#define	KEY_LALT			KEY_RALT
-
-
-#define	FINEANGLES			8192
-#define	FINEMASK			(FINEANGLES-1)
-#define	ANGLETOFINESHIFT	19      // 0x100000000 to 0x2000
+// angle_t
+#include "tables.h"
+
+// events
+#include "d_event.h"
+
+#include "d_mode.h"
+
+extern byte *destview, *destscreen;     // PC direct to screen pointers

 #define	SAVEGAMENAME "hticsav"
 #define SAVEGAMENAMECD "c:\\heretic.cd\\hticsav"
@@ -110,48 +82,6 @@ extern byte *destview, *destscreen;     // PC direct to screen pointers
 #define TICRATE		35      // number of tics / second
 #define TICSPERSEC	35

-#define	FRACBITS		16
-#define	FRACUNIT		(1<<FRACBITS)
-typedef int fixed_t;
-
-#define ANGLE_1		0x01000000
-#define ANGLE_45	0x20000000
-#define ANGLE_90	0x40000000
-#define ANGLE_180	0x80000000
-#define ANGLE_MAX	0xffffffff
-
-#define	ANG45	0x20000000
-#define	ANG90	0x40000000
-#define	ANG180	0x80000000
-#define	ANG270	0xc0000000
-
-typedef unsigned angle_t;
-
-typedef enum
-{
-    sk_baby,
-    sk_easy,
-    sk_medium,
-    sk_hard,
-    sk_nightmare
-} skill_t;
-
-typedef enum
-{
-    ev_keydown,
-    ev_keyup,
-    ev_mouse,
-    ev_joystick
-} evtype_t;
-
-typedef struct
-{
-    evtype_t type;
-    int data1;                  // keys / mouse/joystick buttons
-    int data2;                  // mouse/joystick x move
-    int data3;                  // mouse/joystick y move
-} event_t;
-
 typedef struct
 {
     char forwardmove;           // *2048 for move
@@ -633,14 +563,13 @@ extern event_t events[MAXEVENTS];
 extern int eventhead;
 extern int eventtail;

-extern fixed_t finesine[5 * FINEANGLES / 4];
-extern fixed_t *finecosine;
-
 extern gameaction_t gameaction;

 extern boolean paused;

-extern boolean shareware;       // true if main WAD is the shareware version
+extern GameMode_t gamemode;
+extern GameMission_t gamemission;
+
 extern boolean ExtendedWAD;     // true if main WAD is the extended version

 extern boolean nomonsters;      // checkparm of -nomonsters
@@ -792,9 +721,6 @@ void D_DoomLoop(void);
 // calls all ?_Responder, ?_Ticker, and ?_Drawer functions
 // calls I_GetTime, I_StartFrame, and I_StartTic

-void D_PostEvent(event_t * ev);
-// called by IO functions when input is detected
-
 void NetUpdate(void);
 // create any new ticcmds and broadcast to other players

diff --git a/src/heretic/f_finale.c b/src/heretic/f_finale.c
index b723f731..10d11d7e 100644
--- a/src/heretic/f_finale.c
+++ b/src/heretic/f_finale.c
@@ -408,7 +408,7 @@ void F_Drawer(void)
         switch (gameepisode)
         {
             case 1:
-                if (shareware)
+                if (gamemode == shareware)
                 {
                     V_DrawRawScreen(W_CacheLumpName("ORDER", PU_CACHE));
                 }
diff --git a/src/heretic/g_game.c b/src/heretic/g_game.c
index daaa8d74..602afbf0 100644
--- a/src/heretic/g_game.c
+++ b/src/heretic/g_game.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "doomdef.h"
+#include "doomkeys.h"
 #include "p_local.h"
 #include "s_sound.h"

diff --git a/src/heretic/m_misc.c b/src/heretic/m_misc.c
index dd39ec1e..4d9f6b5d 100644
--- a/src/heretic/m_misc.c
+++ b/src/heretic/m_misc.c
@@ -52,7 +52,7 @@ boolean M_ValidEpisodeMap(int episode, int map)
     {
         return false;
     }
-    if (shareware)
+    if (gamemode == shareware)
     {                           // Shareware version checks
         if (episode != 1)
         {
diff --git a/src/heretic/mn_menu.c b/src/heretic/mn_menu.c
index 8d828daa..6423ebdf 100644
--- a/src/heretic/mn_menu.c
+++ b/src/heretic/mn_menu.c
@@ -25,6 +25,7 @@

 #include <ctype.h>
 #include "doomdef.h"
+#include "doomkeys.h"
 #include "p_local.h"
 #include "r_local.h"
 #include "s_sound.h"
@@ -882,7 +883,7 @@ static boolean SCSaveGame(int option)

 static boolean SCEpisode(int option)
 {
-    if (shareware && option > 1)
+    if (gamemode == shareware && option > 1)
     {
         P_SetMessage(&players[consoleplayer],
                      "ONLY AVAILABLE IN THE REGISTERED VERSION", true);
@@ -1045,7 +1046,7 @@ boolean MN_Responder(event_t * event)
     key = event->data1;
     if (InfoType)
     {
-        if (shareware)
+        if (gamemode == shareware)
         {
             InfoType = (InfoType + 1) % 5;
         }
diff --git a/src/heretic/p_enemy.c b/src/heretic/p_enemy.c
index 714ce724..c33f7834 100644
--- a/src/heretic/p_enemy.c
+++ b/src/heretic/p_enemy.c
@@ -1241,7 +1241,7 @@ void A_MummyAttack2(mobj_t * actor)

 void A_MummyFX1Seek(mobj_t * actor)
 {
-    P_SeekerMissile(actor, ANGLE_1 * 10, ANGLE_1 * 20);
+    P_SeekerMissile(actor, ANG1 * 10, ANG1 * 20);
 }

 //----------------------------------------------------------------------------
@@ -1322,8 +1322,8 @@ void A_Srcr1Attack(mobj_t * actor)
         {
             momz = mo->momz;
             angle = mo->angle;
-            P_SpawnMissileAngle(actor, MT_SRCRFX1, angle - ANGLE_1 * 3, momz);
-            P_SpawnMissileAngle(actor, MT_SRCRFX1, angle + ANGLE_1 * 3, momz);
+            P_SpawnMissileAngle(actor, MT_SRCRFX1, angle - ANG1 * 3, momz);
+            P_SpawnMissileAngle(actor, MT_SRCRFX1, angle + ANG1 * 3, momz);
         }
         if (actor->health < actor->info->spawnhealth / 3)
         {                       // Maybe attack again
@@ -1888,7 +1888,7 @@ void A_WhirlwindSeek(mobj_t * actor)
     {
         return;
     }
-    P_SeekerMissile(actor, ANGLE_1 * 10, ANGLE_1 * 30);
+    P_SeekerMissile(actor, ANG1 * 10, ANG1 * 30);
 }

 //----------------------------------------------------------------------------
diff --git a/src/heretic/p_mobj.c b/src/heretic/p_mobj.c
index 839e9744..15a39773 100644
--- a/src/heretic/p_mobj.c
+++ b/src/heretic/p_mobj.c
@@ -180,7 +180,7 @@ int P_FaceMobj(mobj_t * source, mobj_t * target, angle_t * delta)
     if (angle2 > angle1)
     {
         diff = angle2 - angle1;
-        if (diff > ANGLE_180)
+        if (diff > ANG180)
         {
             *delta = ANGLE_MAX - diff;
             return (0);
@@ -194,7 +194,7 @@ int P_FaceMobj(mobj_t * source, mobj_t * target, angle_t * delta)
     else
     {
         diff = angle1 - angle2;
-        if (diff > ANGLE_180)
+        if (diff > ANG180)
         {
             *delta = ANGLE_MAX - diff;
             return (1);
@@ -1129,13 +1129,13 @@ void P_SpawnMapThing(mapthing_t * mthing)
         case MT_ARTISUPERHEAL:
         case MT_ARTITELEPORT:
         case MT_ITEMSHIELD2:
-            if (shareware)
+            if (gamemode == shareware)
             {                   // Don't place on map in shareware version
                 return;
             }
             break;
         case MT_WMACE:
-            if (!shareware)
+            if (gamemode != shareware)
             {                   // Put in the mace spot list
                 P_AddMaceSpot(mthing);
                 return;
diff --git a/src/heretic/p_pspr.c b/src/heretic/p_pspr.c
index 79976b5c..7ded5b26 100644
--- a/src/heretic/p_pspr.c
+++ b/src/heretic/p_pspr.c
@@ -1298,7 +1298,7 @@ void A_DeathBallImpact(mobj_t * ball)
                     newAngle = true;
                     break;
                 }
-                angle += ANGLE_45 / 2;
+                angle += ANG45 / 2;
             }
         }
         if (newAngle)
@@ -1463,7 +1463,7 @@ void A_FireSkullRodPL2(player_t * player, pspdef_t * psp)

 void A_SkullRodPL2Seek(mobj_t * actor)
 {
-    P_SeekerMissile(actor, ANGLE_1 * 10, ANGLE_1 * 30);
+    P_SeekerMissile(actor, ANG1 * 10, ANG1 * 30);
 }

 //----------------------------------------------------------------------------
@@ -1632,7 +1632,7 @@ void A_PhoenixPuff(mobj_t * actor)
     mobj_t *puff;
     angle_t angle;

-    P_SeekerMissile(actor, ANGLE_1 * 5, ANGLE_1 * 10);
+    P_SeekerMissile(actor, ANG1 * 5, ANG1 * 10);
     puff = P_SpawnMobj(actor->x, actor->y, actor->z, MT_PHOENIXPUFF);
     angle = actor->angle + ANG90;
     angle >>= ANGLETOFINESHIFT;
diff --git a/src/heretic/p_switch.c b/src/heretic/p_switch.c
index 29b057e7..7c4f8c02 100644
--- a/src/heretic/p_switch.c
+++ b/src/heretic/p_switch.c
@@ -111,7 +111,7 @@ void P_InitSwitchList(void)
     int episode;

     episode = 1;
-    if (!shareware)
+    if (gamemode != shareware)
         episode = 2;

     for (index = 0, i = 0; i < MAXSWITCHES; i++)
diff --git a/src/heretic/p_user.c b/src/heretic/p_user.c
index 67ae00d7..3c880b88 100644
--- a/src/heretic/p_user.c
+++ b/src/heretic/p_user.c
@@ -620,7 +620,7 @@ void P_PlayerThink(player_t * player)
         if (player->weaponowned[newweapon]
             && newweapon != player->readyweapon)
         {
-            if (WeaponInShareware[newweapon] || !shareware)
+            if (WeaponInShareware[newweapon] || gamemode != shareware)
             {
                 player->pendingweapon = newweapon;
             }
diff --git a/src/heretic/r_draw.c b/src/heretic/r_draw.c
index f955b127..aac9e88d 100644
--- a/src/heretic/r_draw.c
+++ b/src/heretic/r_draw.c
@@ -425,7 +425,7 @@ void R_DrawViewBorder(void)
     if (scaledviewwidth == SCREENWIDTH)
         return;

-    if (shareware)
+    if (gamemode == shareware)
     {
         src = W_CacheLumpName("FLOOR04", PU_CACHE);
     }
@@ -489,7 +489,7 @@ void R_DrawTopBorder(void)
     if (scaledviewwidth == SCREENWIDTH)
         return;

-    if (shareware)
+    if (gamemode == shareware)
     {
         src = W_CacheLumpName("FLOOR04", PU_CACHE);
     }
diff --git a/src/heretic/r_local.h b/src/heretic/r_local.h
index 38945bad..fa0efacd 100644
--- a/src/heretic/r_local.h
+++ b/src/heretic/r_local.h
@@ -269,7 +269,6 @@ extern angle_t clipangle;

 extern int viewangletox[FINEANGLES / 2];
 extern angle_t xtoviewangle[SCREENWIDTH + 1];
-extern fixed_t finetangent[FINEANGLES / 2];

 extern fixed_t rw_distance;
 extern angle_t rw_normalangle;
diff --git a/src/heretic/r_main.c b/src/heretic/r_main.c
index 7628e595..7137615a 100644
--- a/src/heretic/r_main.c
+++ b/src/heretic/r_main.c
@@ -70,14 +70,6 @@ int viewangletox[FINEANGLES / 2];
 // that maps back to x ranges from clipangle to -clipangle
 angle_t xtoviewangle[SCREENWIDTH + 1];

-// the finetangentgent[angle+FINEANGLES/4] table holds the fixed_t tangent
-// values for view angles, ranging from INT_MIN to 0 to INT_MAX.
-// fixed_t              finetangent[FINEANGLES/2];
-
-// fixed_t              finesine[5*FINEANGLES/4];
-fixed_t *finecosine = &finesine[FINEANGLES / 4];
-
-
 lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
 lighttable_t *scalelightfixed[MAXLIGHTSCALE];
 lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
@@ -222,11 +214,6 @@ int R_PointOnSegSide(fixed_t x, fixed_t y, seg_t * line)
 #define	SLOPEBITS	11
 #define	DBITS		(FRACBITS-SLOPEBITS)

-
-extern int tantoangle[SLOPERANGE + 1];  // get from tables.c
-
-// int  tantoangle[SLOPERANGE+1];
-
 int SlopeDiv(unsigned num, unsigned den)
 {
     unsigned ans;
diff --git a/src/heretic/r_things.c b/src/heretic/r_things.c
index de51504b..1c7f1889 100644
--- a/src/heretic/r_things.c
+++ b/src/heretic/r_things.c
@@ -203,7 +203,7 @@ void R_InitSpriteDefs(char **namelist)
         {
             //continue;
             sprites[i].numframes = 0;
-            if (shareware)
+            if (gamemode == shareware)
                 continue;
             I_Error("R_InitSprites: No lumps found for sprite %s",
                     namelist[i]);
diff --git a/src/heretic/sb_bar.c b/src/heretic/sb_bar.c
index 6414bb8f..3b6434b3 100644
--- a/src/heretic/sb_bar.c
+++ b/src/heretic/sb_bar.c
@@ -1275,7 +1275,7 @@ static void CheatWeaponsFunc(player_t * player, Cheat_t * cheat)
     {
         player->weaponowned[i] = true;
     }
-    if (shareware)
+    if (gamemode == shareware)
     {
         player->weaponowned[wp_skullrod] = false;
         player->weaponowned[wp_phoenixrod] = false;
@@ -1377,7 +1377,8 @@ static void CheatArtifact3Func(player_t * player, Cheat_t * cheat)
     {                           // All artifacts
         for (i = arti_none + 1; i < NUMARTIFACTS; i++)
         {
-            if (shareware && (i == arti_superhealth || i == arti_teleport))
+            if (gamemode == shareware
+             && (i == arti_superhealth || i == arti_teleport))
             {
                 continue;
             }
@@ -1391,7 +1392,8 @@ static void CheatArtifact3Func(player_t * player, Cheat_t * cheat)
     else if (type > arti_none && type < NUMARTIFACTS
              && count > 0 && count < 10)
     {
-        if (shareware && (type == arti_superhealth || type == arti_teleport))
+        if (gamemode == shareware
+         && (type == arti_superhealth || type == arti_teleport))
         {
             P_SetMessage(player, TXT_CHEATARTIFACTSFAIL, false);
             return;
diff --git a/src/tables.h b/src/tables.h
index baf785ca..cc211c24 100644
--- a/src/tables.h
+++ b/src/tables.h
@@ -63,10 +63,13 @@ extern const fixed_t *finecosine;
 extern const fixed_t finetangent[FINEANGLES/2];

 // Binary Angle Measument, BAM.
-#define ANG45			0x20000000
-#define ANG90			0x40000000
-#define ANG180		0x80000000
-#define ANG270		0xc0000000
+
+#define ANG1            0x01000000
+#define ANG45           0x20000000
+#define ANG90           0x40000000
+#define ANG180          0x80000000
+#define ANG270          0xc0000000
+#define ANG_MAX         0xffffffff


 #define SLOPERANGE		2048