shithub: choc

Download patch

ref: 8cdc173252c479b8a7448da9ccd48f32eeb0c427
parent: 3dc8f945820e08c698d4aed66f4f7bf4a9eb9401
author: Simon Howard <fraggle@gmail.com>
date: Wed Sep 17 15:56:12 EDT 2008

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

--- 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"
 
--- 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); 
--- 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];
 
--- 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"
 
--- 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 @@
         case 5:
             pagetic = 200;
             gamestate = GS_DEMOSCREEN;
-            if (shareware)
+            if (gamemode == shareware)
             {
                 pagename = "ORDER";
             }
@@ -919,11 +920,17 @@
 
     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__
--- 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
--- a/src/heretic/doomdef.h
+++ b/src/heretic/doomdef.h
@@ -53,47 +53,19 @@
 // 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)
+// angle_t 
+#include "tables.h"
 
-#define	KEY_BACKSPACE		127
-#define	KEY_PAUSE			0xff
+// events
+#include "d_event.h"
 
-#define KEY_EQUALS			0x3d
-#define KEY_MINUS			0x2d
+#include "d_mode.h"
 
-#define	KEY_RSHIFT			(0x80+0x36)
-#define	KEY_RCTRL			(0x80+0x1d)
-#define	KEY_RALT			(0x80+0x38)
+extern byte *destview, *destscreen;     // PC direct to screen pointers
 
-#define	KEY_LALT			KEY_RALT
-
-
-#define	FINEANGLES			8192
-#define	FINEMASK			(FINEANGLES-1)
-#define	ANGLETOFINESHIFT	19      // 0x100000000 to 0x2000
-
 #define	SAVEGAMENAME "hticsav"
 #define SAVEGAMENAMECD "c:\\heretic.cd\\hticsav"
 
@@ -110,50 +82,8 @@
 #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
     char sidemove;              // *2048 for move
     short angleturn;            // <<16 for angle delta
@@ -633,14 +563,13 @@
 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
@@ -791,9 +720,6 @@
 // manages timing and IO
 // 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
--- a/src/heretic/f_finale.c
+++ b/src/heretic/f_finale.c
@@ -408,7 +408,7 @@
         switch (gameepisode)
         {
             case 1:
-                if (shareware)
+                if (gamemode == shareware)
                 {
                     V_DrawRawScreen(W_CacheLumpName("ORDER", PU_CACHE));
                 }
--- 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"
 
--- a/src/heretic/m_misc.c
+++ b/src/heretic/m_misc.c
@@ -52,7 +52,7 @@
     {
         return false;
     }
-    if (shareware)
+    if (gamemode == shareware)
     {                           // Shareware version checks
         if (episode != 1)
         {
--- 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 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 @@
     key = event->data1;
     if (InfoType)
     {
-        if (shareware)
+        if (gamemode == shareware)
         {
             InfoType = (InfoType + 1) % 5;
         }
--- a/src/heretic/p_enemy.c
+++ b/src/heretic/p_enemy.c
@@ -1241,7 +1241,7 @@
 
 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 @@
         {
             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 @@
     {
         return;
     }
-    P_SeekerMissile(actor, ANGLE_1 * 10, ANGLE_1 * 30);
+    P_SeekerMissile(actor, ANG1 * 10, ANG1 * 30);
 }
 
 //----------------------------------------------------------------------------
--- a/src/heretic/p_mobj.c
+++ b/src/heretic/p_mobj.c
@@ -180,7 +180,7 @@
     if (angle2 > angle1)
     {
         diff = angle2 - angle1;
-        if (diff > ANGLE_180)
+        if (diff > ANG180)
         {
             *delta = ANGLE_MAX - diff;
             return (0);
@@ -194,7 +194,7 @@
     else
     {
         diff = angle1 - angle2;
-        if (diff > ANGLE_180)
+        if (diff > ANG180)
         {
             *delta = ANGLE_MAX - diff;
             return (1);
@@ -1129,13 +1129,13 @@
         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;
--- a/src/heretic/p_pspr.c
+++ b/src/heretic/p_pspr.c
@@ -1298,7 +1298,7 @@
                     newAngle = true;
                     break;
                 }
-                angle += ANGLE_45 / 2;
+                angle += ANG45 / 2;
             }
         }
         if (newAngle)
@@ -1463,7 +1463,7 @@
 
 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 @@
     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;
--- a/src/heretic/p_switch.c
+++ b/src/heretic/p_switch.c
@@ -111,7 +111,7 @@
     int episode;
 
     episode = 1;
-    if (!shareware)
+    if (gamemode != shareware)
         episode = 2;
 
     for (index = 0, i = 0; i < MAXSWITCHES; i++)
--- a/src/heretic/p_user.c
+++ b/src/heretic/p_user.c
@@ -620,7 +620,7 @@
         if (player->weaponowned[newweapon]
             && newweapon != player->readyweapon)
         {
-            if (WeaponInShareware[newweapon] || !shareware)
+            if (WeaponInShareware[newweapon] || gamemode != shareware)
             {
                 player->pendingweapon = newweapon;
             }
--- a/src/heretic/r_draw.c
+++ b/src/heretic/r_draw.c
@@ -425,7 +425,7 @@
     if (scaledviewwidth == SCREENWIDTH)
         return;
 
-    if (shareware)
+    if (gamemode == shareware)
     {
         src = W_CacheLumpName("FLOOR04", PU_CACHE);
     }
@@ -489,7 +489,7 @@
     if (scaledviewwidth == SCREENWIDTH)
         return;
 
-    if (shareware)
+    if (gamemode == shareware)
     {
         src = W_CacheLumpName("FLOOR04", PU_CACHE);
     }
--- a/src/heretic/r_local.h
+++ b/src/heretic/r_local.h
@@ -269,7 +269,6 @@
 
 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;
--- a/src/heretic/r_main.c
+++ b/src/heretic/r_main.c
@@ -70,14 +70,6 @@
 // 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];
@@ -221,11 +213,6 @@
 #define	SLOPERANGE	2048
 #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)
 {
--- a/src/heretic/r_things.c
+++ b/src/heretic/r_things.c
@@ -203,7 +203,7 @@
         {
             //continue;
             sprites[i].numframes = 0;
-            if (shareware)
+            if (gamemode == shareware)
                 continue;
             I_Error("R_InitSprites: No lumps found for sprite %s",
                     namelist[i]);
--- a/src/heretic/sb_bar.c
+++ b/src/heretic/sb_bar.c
@@ -1275,7 +1275,7 @@
     {
         player->weaponowned[i] = true;
     }
-    if (shareware)
+    if (gamemode == shareware)
     {
         player->weaponowned[wp_skullrod] = false;
         player->weaponowned[wp_phoenixrod] = false;
@@ -1377,7 +1377,8 @@
     {                           // 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 @@
     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;
--- a/src/tables.h
+++ b/src/tables.h
@@ -63,10 +63,13 @@
 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