doom

a minimalistic implementation of doom
git clone git://ssnf.xyz/doom
Log | Files | Refs

commit 41ea012cacbf2bb674b8c0b9755df2f180efb72a
parent 2bc8e02677c424f2b8b4a194243008d53c2b3083
Author: ssnf <ssnf@ssnf.xyz>
Date:   Thu, 17 Jun 2021 02:24:18 +0000

delete non-lines

Diffstat:
Msrc/Makefile | 7-------
Msrc/am_map.c | 396-------------------------------------------------------------------------------
Msrc/am_map.h | 42------------------------------------------
Msrc/d_englsh.h | 179-------------------------------------------------------------------------------
Msrc/d_event.h | 72------------------------------------------------------------------------
Msrc/d_french.h | 124-------------------------------------------------------------------------------
Msrc/d_items.c | 56--------------------------------------------------------
Msrc/d_items.h | 35-----------------------------------
Msrc/d_main.c | 361-------------------------------------------------------------------------------
Msrc/d_main.h | 48------------------------------------------------
Msrc/d_net.c | 237-------------------------------------------------------------------------------
Msrc/d_net.h | 101-------------------------------------------------------------------------------
Msrc/d_player.h | 135-------------------------------------------------------------------------------
Msrc/d_textur.h | 41-----------------------------------------
Msrc/d_think.h | 57---------------------------------------------------------
Msrc/d_ticcmd.h | 37-------------------------------------
Msrc/doomdata.h | 129-------------------------------------------------------------------------------
Msrc/doomdef.c | 32--------------------------------
Msrc/doomdef.h | 204-------------------------------------------------------------------------------
Msrc/doomstat.c | 1-
Msrc/doomstat.h | 213-------------------------------------------------------------------------------
Msrc/doomtype.h | 3---
Msrc/dstrings.c | 1-
Msrc/dstrings.h | 53-----------------------------------------------------
Msrc/f_finale.c | 199-------------------------------------------------------------------------------
Msrc/f_finale.h | 44--------------------------------------------
Msrc/f_wipe.c | 83-------------------------------------------------------------------------------
Msrc/f_wipe.h | 42------------------------------------------
Msrc/g_game.c | 476-------------------------------------------------------------------------------
Msrc/g_game.h | 56--------------------------------------------------------
Msrc/hu_lib.c | 100-------------------------------------------------------------------------------
Msrc/hu_lib.h | 117-------------------------------------------------------------------------------
Msrc/hu_stuff.c | 148-------------------------------------------------------------------------------
Msrc/hu_stuff.h | 45---------------------------------------------
Msrc/i_main.c | 30------------------------------
Msrc/i_net.c | 119-------------------------------------------------------------------------------
Msrc/i_net.h | 37-------------------------------------
Msrc/i_sound.c | 515-------------------------------------------------------------------------------
Msrc/i_sound.h | 78------------------------------------------------------------------------------
Msrc/i_system.c | 76----------------------------------------------------------------------------
Msrc/i_system.h | 79-------------------------------------------------------------------------------
Msrc/i_video.c | 291------------------------------------------------------------------------------
Msrc/i_video.h | 47-----------------------------------------------
Msrc/info.c | 175-------------------------------------------------------------------------------
Msrc/info.h | 45---------------------------------------------
Msrc/m_argv.c | 41-----------------------------------------
Msrc/m_argv.h | 36------------------------------------
Msrc/m_bbox.c | 38--------------------------------------
Msrc/m_bbox.h | 37-------------------------------------
Msrc/m_cheat.c | 49-------------------------------------------------
Msrc/m_cheat.h | 39---------------------------------------
Msrc/m_fixed.c | 46----------------------------------------------
Msrc/m_fixed.h | 39---------------------------------------
Msrc/m_menu.c | 547-------------------------------------------------------------------------------
Msrc/m_menu.h | 58----------------------------------------------------------
Msrc/m_misc.c | 179-------------------------------------------------------------------------------
Msrc/m_misc.h | 43-------------------------------------------
Msrc/m_random.c | 38--------------------------------------
Msrc/m_random.h | 40----------------------------------------
Msrc/m_swap.c | 37-------------------------------------
Msrc/m_swap.h | 37-------------------------------------
Msrc/p_ceilng.c | 103-------------------------------------------------------------------------------
Msrc/p_doors.c | 194-------------------------------------------------------------------------------
Msrc/p_enemy.c | 666+------------------------------------------------------------------------------
Msrc/p_floor.c | 122-------------------------------------------------------------------------------
Msrc/p_inter.c | 278-------------------------------------------------------------------------------
Msrc/p_inter.h | 34----------------------------------
Msrc/p_lights.c | 154-------------------------------------------------------------------------------
Msrc/p_local.h | 140-------------------------------------------------------------------------------
Msrc/p_map.c | 572-------------------------------------------------------------------------------
Msrc/p_maputl.c | 311-------------------------------------------------------------------------------
Msrc/p_mobj.c | 357-------------------------------------------------------------------------------
Msrc/p_mobj.h | 215-------------------------------------------------------------------------------
Msrc/p_plats.c | 92-------------------------------------------------------------------------------
Msrc/p_pspr.c | 352-------------------------------------------------------------------------------
Msrc/p_pspr.h | 58----------------------------------------------------------
Msrc/p_saveg.c | 171-------------------------------------------------------------------------------
Msrc/p_saveg.h | 36------------------------------------
Msrc/p_setup.c | 251-------------------------------------------------------------------------------
Msrc/p_setup.h | 35-----------------------------------
Msrc/p_sight.c | 147-------------------------------------------------------------------------------
Msrc/p_spec.c | 517-------------------------------------------------------------------------------
Msrc/p_spec.h | 265-------------------------------------------------------------------------------
Msrc/p_switch.c | 229-------------------------------------------------------------------------------
Msrc/p_telept.c | 63---------------------------------------------------------------
Msrc/p_tick.c | 93-------------------------------------------------------------------------------
Msrc/p_tick.h | 37-------------------------------------
Msrc/p_user.c | 165-------------------------------------------------------------------------------
Msrc/r_bsp.c | 249-------------------------------------------------------------------------------
Msrc/r_bsp.h | 46----------------------------------------------
Msrc/r_data.c | 337-------------------------------------------------------------------------------
Msrc/r_data.h | 45---------------------------------------------
Msrc/r_defs.h | 311-------------------------------------------------------------------------------
Msrc/r_draw.c | 374-------------------------------------------------------------------------------
Msrc/r_draw.h | 72------------------------------------------------------------------------
Msrc/r_local.h | 40----------------------------------------
Msrc/r_main.c | 347-------------------------------------------------------------------------------
Msrc/r_main.h | 96-------------------------------------------------------------------------------
Msrc/r_plane.c | 174-------------------------------------------------------------------------------
Msrc/r_plane.h | 47-----------------------------------------------
Msrc/r_segs.c | 242-------------------------------------------------------------------------------
Msrc/r_segs.h | 33---------------------------------
Msrc/r_sky.c | 47-----------------------------------------------
Msrc/r_sky.h | 37-------------------------------------
Msrc/r_state.h | 86-------------------------------------------------------------------------------
Msrc/r_things.c | 382-------------------------------------------------------------------------------
Msrc/r_things.h | 45---------------------------------------------
Msrc/s_sound.c | 348-------------------------------------------------------------------------------
Msrc/s_sound.h | 77-----------------------------------------------------------------------------
Msrc/sounds.c | 41-----------------------------------------
Msrc/sounds.h | 87-------------------------------------------------------------------------------
Msrc/st_lib.c | 105-------------------------------------------------------------------------------
Msrc/st_lib.h | 133-------------------------------------------------------------------------------
Msrc/st_stuff.c | 539-------------------------------------------------------------------------------
Msrc/st_stuff.h | 61-------------------------------------------------------------
Msrc/tables.c | 58----------------------------------------------------------
Msrc/tables.h | 72------------------------------------------------------------------------
Msrc/v_video.c | 138-------------------------------------------------------------------------------
Msrc/v_video.h | 63---------------------------------------------------------------
Msrc/w_wad.c | 254-------------------------------------------------------------------------------
Msrc/w_wad.h | 53-----------------------------------------------------
Msrc/wi_stuff.c | 618-------------------------------------------------------------------------------
Msrc/wi_stuff.h | 41-----------------------------------------
Msrc/z_zone.c | 211-------------------------------------------------------------------------------
Msrc/z_zone.h | 50--------------------------------------------------
125 files changed, 1 insertion(+), 18285 deletions(-)

diff --git a/src/Makefile b/src/Makefile @@ -2,7 +2,6 @@ CC = c89 CFLAGS = -g -Wall -Wpedantic -D_DEFAULT_SOURCE -Wno-deprecated-declarations LIBS = -lXext -lX11 -lnsl -lm LDFLAGS = ${LIBS} -L/usr/X11R6/lib - SRC = doomstat.c \ dstrings.c \ i_system.c \ @@ -64,17 +63,11 @@ SRC = doomstat.c \ info.c \ lang.c \ sounds.c - - OBJ = ${SRC:.c=.o} - all: doom - clean: rm -f *.o doom - doom: ${OBJ} ${CC} ${CFLAGS} ${LDFLAGS} ${OBJ} -o $@ - %.o: %.c ${CC} ${CFLAGS} -c $< -o $@ diff --git a/src/am_map.c b/src/am_map.c @@ -1,53 +1,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> - - #include "z_zone.h" #include "doomdef.h" #include "st_stuff.h" #include "p_local.h" #include "w_wad.h" - #include "m_cheat.h" #include "i_system.h" - - #include "v_video.h" - - #include "doomstat.h" #include "r_state.h" - - #include "dstrings.h" - #include "am_map.h" - - - #define REDS (256-5*16) #define REDRANGE 16 #define BLUES (256-4*16+8) @@ -62,8 +25,6 @@ #define YELLOWRANGE 1 #define BLACK 0 #define WHITE (256-47) - - #define BACKGROUND BLACK #define YOURCOLORS WHITE #define YOURRANGE 0 @@ -82,10 +43,7 @@ #define GRIDCOLORS (GRAYS + GRAYSRANGE/2) #define GRIDRANGE 0 #define XHAIRCOLORS GRAYS - - #define FB 0 - #define AM_PANDOWNKEY KEY_DOWNARROW #define AM_PANUPKEY KEY_UPARROW #define AM_PANRIGHTKEY KEY_RIGHTARROW @@ -99,63 +57,36 @@ #define AM_GRIDKEY 'g' #define AM_MARKKEY 'm' #define AM_CLEARMARKKEY 'c' - #define AM_NUMMARKPOINTS 10 - - #define INITSCALEMTOF (.2*FRACUNIT) - - #define F_PANINC 4 - - #define M_ZOOMIN ((int) (1.02*FRACUNIT)) - - #define M_ZOOMOUT ((int) (FRACUNIT/1.02)) - - #define FTOM(x) FixedMul(((x)<<16),scale_ftom) #define MTOF(x) (FixedMul((x),scale_mtof)>>16) - #define CXMTOF(x) (f_x + MTOF((x)-m_x)) #define CYMTOF(y) (f_y + (f_h - MTOF((y)-m_y))) - - #define LINE_NEVERSEE ML_DONTDRAW - typedef struct { int x, y; } fpoint_t; - typedef struct { fpoint_t a, b; } fline_t; - typedef struct { fixed_t x,y; } mpoint_t; - typedef struct { mpoint_t a, b; } mline_t; - typedef struct { fixed_t slp, islp; } islope_t; - - - - - - - - #define R ((8*PLAYERRADIUS)/7) mline_t player_arrow[] = { { { -R+R/8, 0 }, { R, 0 } }, @@ -168,7 +99,6 @@ mline_t player_arrow[] = { }; #undef R #define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t)) - #define R ((8*PLAYERRADIUS)/7) mline_t cheat_player_arrow[] = { { { -R+R/8, 0 }, { R, 0 } }, @@ -190,7 +120,6 @@ mline_t cheat_player_arrow[] = { }; #undef R #define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t)) - #define R (FRACUNIT) mline_t triangle_guy[] = { { { -.867*R, -.5*R }, { .867*R, -.5*R } }, @@ -199,7 +128,6 @@ mline_t triangle_guy[] = { }; #undef R #define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t)) - #define R (FRACUNIT) mline_t thintriangle_guy[] = { { { -.5*R, -.7*R }, { R, 0 } }, @@ -208,121 +136,69 @@ mline_t thintriangle_guy[] = { }; #undef R #define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t)) - - - - static int cheating = 0; static int grid = 0; - static int leveljuststarted = 1; - boolean automapactive = false; static int finit_width = SCREENWIDTH; static int finit_height = SCREENHEIGHT - 32; - - static int f_x; static int f_y; - - static int f_w; static int f_h; - static int lightlev; static byte* fb; static int amclock; - static mpoint_t m_paninc; static fixed_t mtof_zoommul; static fixed_t ftom_zoommul; - static fixed_t m_x, m_y; static fixed_t m_x2, m_y2; - - - - static fixed_t m_w; static fixed_t m_h; - - static fixed_t min_x; static fixed_t min_y; static fixed_t max_x; static fixed_t max_y; - static fixed_t max_w; static fixed_t max_h; - - static fixed_t min_w; static fixed_t min_h; - - static fixed_t min_scale_mtof; static fixed_t max_scale_mtof; - - static fixed_t old_m_w, old_m_h; static fixed_t old_m_x, old_m_y; - - static mpoint_t f_oldloc; - - static fixed_t scale_mtof = INITSCALEMTOF; - static fixed_t scale_ftom; - static player_t *plr; - static patch_t *marknums[10]; static mpoint_t markpoints[AM_NUMMARKPOINTS]; static int markpointnum = 0; - static int followplayer = 1; - static unsigned char cheat_amap_seq[] = { 0xb2, 0x26, 0x26, 0x2e, 0xff }; static cheatseq_t cheat_amap = { cheat_amap_seq, 0 }; - static boolean stopped = true; - extern boolean viewactive; - - - - void V_MarkRect ( int x, int y, int width, int height ); - - - - - void AM_getIslope ( mline_t* ml, islope_t* is ) { int dx, dy; - dy = ml->a.y - ml->b.y; dx = ml->b.x - ml->a.x; if (!dy) is->islp = (dx<0?-MAXINT:MAXINT); else is->islp = FixedDiv(dx, dy); if (!dx) is->slp = (dy<0?-MAXINT:MAXINT); else is->slp = FixedDiv(dy, dx); - } - - - - void AM_activateNewScale(void) { m_x += m_w/2; @@ -334,10 +210,6 @@ void AM_activateNewScale(void) m_x2 = m_x + m_w; m_y2 = m_y + m_h; } - - - - void AM_saveScaleAndLoc(void) { old_m_x = m_x; @@ -345,13 +217,8 @@ void AM_saveScaleAndLoc(void) old_m_w = m_w; old_m_h = m_h; } - - - - void AM_restoreScaleAndLoc(void) { - m_w = old_m_w; m_h = old_m_h; if (!followplayer) @@ -364,67 +231,42 @@ void AM_restoreScaleAndLoc(void) } m_x2 = m_x + m_w; m_y2 = m_y + m_h; - - scale_mtof = FixedDiv(f_w<<FRACBITS, m_w); scale_ftom = FixedDiv(FRACUNIT, scale_mtof); } - - - - void AM_addMark(void) { markpoints[markpointnum].x = m_x + m_w/2; markpoints[markpointnum].y = m_y + m_h/2; markpointnum = (markpointnum + 1) % AM_NUMMARKPOINTS; - } - - - - - void AM_findMinMaxBoundaries(void) { int i; fixed_t a; fixed_t b; - min_x = min_y = MAXINT; max_x = max_y = -MAXINT; - for (i=0;i<numvertexes;i++) { if (vertexes[i].x < min_x) min_x = vertexes[i].x; else if (vertexes[i].x > max_x) max_x = vertexes[i].x; - if (vertexes[i].y < min_y) min_y = vertexes[i].y; else if (vertexes[i].y > max_y) max_y = vertexes[i].y; } - max_w = max_x - min_x; max_h = max_y - min_y; - min_w = 2*PLAYERRADIUS; min_h = 2*PLAYERRADIUS; - a = FixedDiv(f_w<<FRACBITS, max_w); b = FixedDiv(f_h<<FRACBITS, max_h); - min_scale_mtof = a < b ? a : b; max_scale_mtof = FixedDiv(f_h<<FRACBITS, 2*PLAYERRADIUS); - } - - - - - void AM_changeWindowLoc(void) { if (m_paninc.x || m_paninc.y) @@ -432,147 +274,94 @@ void AM_changeWindowLoc(void) followplayer = 0; f_oldloc.x = MAXINT; } - m_x += m_paninc.x; m_y += m_paninc.y; - if (m_x + m_w/2 > max_x) m_x = max_x - m_w/2; else if (m_x + m_w/2 < min_x) m_x = min_x - m_w/2; - if (m_y + m_h/2 > max_y) m_y = max_y - m_h/2; else if (m_y + m_h/2 < min_y) m_y = min_y - m_h/2; - m_x2 = m_x + m_w; m_y2 = m_y + m_h; } - - - - - void AM_initVariables(void) { int pnum; static event_t st_notify = { ev_keyup, AM_MSGENTERED }; - automapactive = true; fb = screens[0]; - f_oldloc.x = MAXINT; amclock = 0; lightlev = 0; - m_paninc.x = m_paninc.y = 0; ftom_zoommul = FRACUNIT; mtof_zoommul = FRACUNIT; - m_w = FTOM(f_w); m_h = FTOM(f_h); - - if (!playeringame[pnum = consoleplayer]) for (pnum=0;pnum<MAXPLAYERS;pnum++) if (playeringame[pnum]) break; - plr = &players[pnum]; m_x = plr->mo->x - m_w/2; m_y = plr->mo->y - m_h/2; AM_changeWindowLoc(); - - old_m_x = m_x; old_m_y = m_y; old_m_w = m_w; old_m_h = m_h; - - ST_Responder(&st_notify); - } - - - - void AM_loadPics(void) { int i; char namebuf[9]; - for (i=0;i<10;i++) { sprintf(namebuf, "AMMNUM%d", i); marknums[i] = W_CacheLumpName(namebuf, PU_STATIC); } - } - void AM_unloadPics(void) { int i; - for (i=0;i<10;i++) Z_ChangeTag(marknums[i], PU_CACHE); - } - void AM_clearMarks(void) { int i; - for (i=0;i<AM_NUMMARKPOINTS;i++) markpoints[i].x = -1; markpointnum = 0; } - - - - - void AM_LevelInit(void) { leveljuststarted = 0; - f_x = f_y = 0; f_w = finit_width; f_h = finit_height; - AM_clearMarks(); - AM_findMinMaxBoundaries(); scale_mtof = FixedDiv(min_scale_mtof, (int) (0.7*FRACUNIT)); if (scale_mtof > max_scale_mtof) scale_mtof = min_scale_mtof; scale_ftom = FixedDiv(FRACUNIT, scale_mtof); } - - - - - - - void AM_Stop (void) { static event_t st_notify = { 0, ev_keyup, AM_MSGEXITED }; - AM_unloadPics(); automapactive = false; ST_Responder(&st_notify); stopped = true; } - - - - void AM_Start (void) { static int lastlevel = -1, lastepisode = -1; - if (!stopped) AM_Stop(); stopped = false; if (lastlevel != gamemap || lastepisode != gameepisode) @@ -584,43 +373,27 @@ void AM_Start (void) AM_initVariables(); AM_loadPics(); } - - - - void AM_minOutWindowScale(void) { scale_mtof = min_scale_mtof; scale_ftom = FixedDiv(FRACUNIT, scale_mtof); AM_activateNewScale(); } - - - - void AM_maxOutWindowScale(void) { scale_mtof = max_scale_mtof; scale_ftom = FixedDiv(FRACUNIT, scale_mtof); AM_activateNewScale(); } - - - - - boolean AM_Responder ( event_t* ev ) { - int rc; static int cheatstate=0; static int bigstate=0; static char buffer[20]; - rc = false; - if (!automapactive) { if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY) @@ -630,10 +403,8 @@ AM_Responder rc = true; } } - else if (ev->type == ev_keydown) { - rc = true; switch(ev->data1) { @@ -703,7 +474,6 @@ AM_Responder cheating = (cheating+1) % 3; } } - else if (ev->type == ev_keyup) { rc = false; @@ -728,22 +498,12 @@ AM_Responder break; } } - return rc; - } - - - - - void AM_changeWindowScale(void) { - - scale_mtof = FixedMul(scale_mtof, mtof_zoommul); scale_ftom = FixedDiv(FRACUNIT, scale_mtof); - if (scale_mtof < min_scale_mtof) AM_minOutWindowScale(); else if (scale_mtof > max_scale_mtof) @@ -751,14 +511,8 @@ void AM_changeWindowScale(void) else AM_activateNewScale(); } - - - - - void AM_doFollowPlayer(void) { - if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y) { m_x = FTOM(MTOF(plr->mo->x)) - m_w/2; @@ -767,81 +521,36 @@ void AM_doFollowPlayer(void) m_y2 = m_y + m_h; f_oldloc.x = plr->mo->x; f_oldloc.y = plr->mo->y; - - - - - - } - } - - - - void AM_updateLightLev(void) { static nexttic = 0; - static int litelevels[] = { 0, 4, 7, 10, 12, 14, 15, 15 }; static int litelevelscnt = 0; - - if (amclock>nexttic) { lightlev = litelevels[litelevelscnt++]; if (litelevelscnt == sizeof(litelevels)/sizeof(int)) litelevelscnt = 0; nexttic = amclock + 6 - (amclock % 6); } - } - - - - - void AM_Ticker (void) { - if (!automapactive) return; - amclock++; - if (followplayer) AM_doFollowPlayer(); - - if (ftom_zoommul != FRACUNIT) AM_changeWindowScale(); - - if (m_paninc.x || m_paninc.y) AM_changeWindowLoc(); - - - - } - - - - - void AM_clearFB(int color) { memset(fb, color, f_w*f_h); } - - - - - - - - - boolean AM_clipMline ( mline_t* ml, @@ -854,73 +563,52 @@ AM_clipMline BOTTOM =4, TOP =8 }; - register outcode1 = 0; register outcode2 = 0; register outside; - fpoint_t tmp; int dx; int dy; - - #define DOOUTCODE(oc, mx, my) \ (oc) = 0; \ if ((my) < 0) (oc) |= TOP; \ else if ((my) >= f_h) (oc) |= BOTTOM; \ if ((mx) < 0) (oc) |= LEFT; \ else if ((mx) >= f_w) (oc) |= RIGHT; - - - if (ml->a.y > m_y2) outcode1 = TOP; else if (ml->a.y < m_y) outcode1 = BOTTOM; - if (ml->b.y > m_y2) outcode2 = TOP; else if (ml->b.y < m_y) outcode2 = BOTTOM; - if (outcode1 & outcode2) return false; - if (ml->a.x < m_x) outcode1 |= LEFT; else if (ml->a.x > m_x2) outcode1 |= RIGHT; - if (ml->b.x < m_x) outcode2 |= LEFT; else if (ml->b.x > m_x2) outcode2 |= RIGHT; - if (outcode1 & outcode2) return false; - - fl->a.x = CXMTOF(ml->a.x); fl->a.y = CYMTOF(ml->a.y); fl->b.x = CXMTOF(ml->b.x); fl->b.y = CYMTOF(ml->b.y); - DOOUTCODE(outcode1, fl->a.x, fl->a.y); DOOUTCODE(outcode2, fl->b.x, fl->b.y); - if (outcode1 & outcode2) return false; - while (outcode1 | outcode2) { - - if (outcode1) outside = outcode1; else outside = outcode2; - - if (outside & TOP) { dy = fl->a.y - fl->b.y; @@ -949,7 +637,6 @@ AM_clipMline tmp.y = fl->a.y + (dy*(-fl->a.x))/dx; tmp.x = 0; } - if (outside == outcode1) { fl->a = tmp; @@ -960,19 +647,12 @@ AM_clipMline fl->b = tmp; DOOUTCODE(outcode2, fl->b.x, fl->b.y); } - if (outcode1 & outcode2) return false; } - return true; } #undef DOOUTCODE - - - - - void AM_drawFline ( fline_t* fl, @@ -987,10 +667,7 @@ AM_drawFline register int ax; register int ay; register int d; - static fuck = 0; - - if ( fl->a.x < 0 || fl->a.x >= f_w || fl->a.y < 0 || fl->a.y >= f_h || fl->b.x < 0 || fl->b.x >= f_w @@ -999,20 +676,15 @@ AM_drawFline fprintf(stderr, "fuck %d \r", fuck++); return; } - #define PUTDOT(xx,yy,cc) fb[(yy)*f_w+(xx)]=(cc) - dx = fl->b.x - fl->a.x; ax = 2 * (dx<0 ? -dx : dx); sx = dx<0 ? -1 : 1; - dy = fl->b.y - fl->a.y; ay = 2 * (dy<0 ? -dy : dy); sy = dy<0 ? -1 : 1; - x = fl->a.x; y = fl->a.y; - if (ax > ay) { d = ay - ax/2; @@ -1046,41 +718,25 @@ AM_drawFline } } } - - - - - void AM_drawMline ( mline_t* ml, int color ) { static fline_t fl; - if (AM_clipMline(ml, &fl)) AM_drawFline(&fl, color); } - - - - - - void AM_drawGrid(int color) { fixed_t x, y; fixed_t start, end; mline_t ml; - - start = m_x; if ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)) start += (MAPBLOCKUNITS<<FRACBITS) - ((start-bmaporgx)%(MAPBLOCKUNITS<<FRACBITS)); end = m_x + m_w; - - ml.a.y = m_y; ml.b.y = m_y+m_h; for (x=start; x<end; x+=(MAPBLOCKUNITS<<FRACBITS)) @@ -1089,15 +745,11 @@ void AM_drawGrid(int color) ml.b.x = x; AM_drawMline(&ml, color); } - - start = m_y; if ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)) start += (MAPBLOCKUNITS<<FRACBITS) - ((start-bmaporgy)%(MAPBLOCKUNITS<<FRACBITS)); end = m_y + m_h; - - ml.a.x = m_x; ml.b.x = m_x + m_w; for (y=start; y<end; y+=(MAPBLOCKUNITS<<FRACBITS)) @@ -1106,18 +758,11 @@ void AM_drawGrid(int color) ml.b.y = y; AM_drawMline(&ml, color); } - } - - - - - void AM_drawWalls(void) { int i; static mline_t l; - for (i=0;i<numlines;i++) { l.a.x = lines[i].v1->x; @@ -1162,12 +807,6 @@ void AM_drawWalls(void) } } } - - - - - - void AM_rotate ( fixed_t* x, @@ -1175,18 +814,14 @@ AM_rotate angle_t a ) { fixed_t tmpx; - tmpx = FixedMul(*x,finecosine[a>>ANGLETOFINESHIFT]) - FixedMul(*y,finesine[a>>ANGLETOFINESHIFT]); - *y = FixedMul(*x,finesine[a>>ANGLETOFINESHIFT]) + FixedMul(*y,finecosine[a>>ANGLETOFINESHIFT]); - *x = tmpx; } - void AM_drawLineCharacter ( mline_t* lineguy, @@ -1199,43 +834,33 @@ AM_drawLineCharacter { int i; mline_t l; - for (i=0;i<lineguylines;i++) { l.a.x = lineguy[i].a.x; l.a.y = lineguy[i].a.y; - if (scale) { l.a.x = FixedMul(scale, l.a.x); l.a.y = FixedMul(scale, l.a.y); } - if (angle) AM_rotate(&l.a.x, &l.a.y, angle); - l.a.x += x; l.a.y += y; - l.b.x = lineguy[i].b.x; l.b.y = lineguy[i].b.y; - if (scale) { l.b.x = FixedMul(scale, l.b.x); l.b.y = FixedMul(scale, l.b.y); } - if (angle) AM_rotate(&l.b.x, &l.b.y, angle); - l.b.x += x; l.b.y += y; - AM_drawMline(&l, color); } } - void AM_drawPlayers(void) { int i; @@ -1243,7 +868,6 @@ void AM_drawPlayers(void) static int their_colors[] = { GREENS, GRAYS, BROWNS, REDS }; int their_color = -1; int color; - if (!netgame) { if (cheating) @@ -1256,30 +880,23 @@ void AM_drawPlayers(void) WHITE, plr->mo->x, plr->mo->y); return; } - for (i=0;i<MAXPLAYERS;i++) { their_color++; p = &players[i]; - if ( (deathmatch && !singledemo) && p != plr) continue; - if (!playeringame[i]) continue; - if (p->powers[pw_invisibility]) color = 246; else color = their_colors[their_color]; - AM_drawLineCharacter (player_arrow, NUMPLYRLINES, 0, p->mo->angle, color, p->mo->x, p->mo->y); } - } - void AM_drawThings ( int colors, @@ -1287,7 +904,6 @@ AM_drawThings { int i; mobj_t* t; - for (i=0;i<numsectors;i++) { t = sectors[i].thinglist; @@ -1300,17 +916,13 @@ AM_drawThings } } } - void AM_drawMarks(void) { int i, fx, fy, w, h; - for (i=0;i<AM_NUMMARKPOINTS;i++) { if (markpoints[i].x != -1) { - - w = 5; h = 6; fx = CXMTOF(markpoints[i].x); @@ -1319,19 +931,14 @@ void AM_drawMarks(void) V_DrawPatch(fx, fy, FB, marknums[i]); } } - } - void AM_drawCrosshair(int color) { fb[(f_w*(f_h+1))/2] = color; - } - void AM_Drawer (void) { if (!automapactive) return; - AM_clearFB(BACKGROUND); if (grid) AM_drawGrid(GRIDCOLORS); @@ -1340,9 +947,6 @@ void AM_Drawer (void) if (cheating==2) AM_drawThings(THINGCOLORS, THINGRANGE); AM_drawCrosshair(XHAIRCOLORS); - AM_drawMarks(); - V_MarkRect(f_x, f_y, f_w, f_h); - } diff --git a/src/am_map.h b/src/am_map.h @@ -1,52 +1,10 @@ - - - - - - - - - - - - - - - - - - - - - #ifndef __AMMAP_H__ #define __AMMAP_H__ - - #define AM_MSGHEADER (('a'<<24)+('m'<<16)) #define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8)) #define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8)) - - - boolean AM_Responder (event_t* ev); - - void AM_Ticker (void); - - - void AM_Drawer (void); - - - void AM_Stop (void); - - - #endif - - - - - diff --git a/src/d_englsh.h b/src/d_englsh.h @@ -1,41 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_ENGLSH__ #define __D_ENGLSH__ - - - - - - - - #define D_DEVSTR "Development mode ON.\n" #define D_CDROM "CD-ROM Version: default.cfg from c:\\doomdata\n" - - - - #define PRESSKEY "press a key." #define PRESSYN "press y or n." #define QUITMSG "are you sure you want to\nquit this great game?" @@ -45,26 +11,20 @@ #define SAVEDEAD "you can't save if you aren't playing!\n\n"PRESSKEY #define QSPROMPT "quicksave over your game named\n\n'%s'?\n\n"PRESSYN #define QLPROMPT "do you want to quickload the game named\n\n'%s'?\n\n"PRESSYN - #define NEWGAME \ "you can't start a new game\n"\ "while in a network game.\n\n"PRESSKEY - #define NIGHTMARE \ "are you sure? this skill level\n"\ "isn't even remotely fair.\n\n"PRESSYN - #define SWSTRING \ "this is the shareware version of doom.\n\n"\ "you need to order the entire trilogy.\n\n"PRESSKEY - #define MSGOFF "Messages OFF" #define MSGON "Messages ON" #define NETEND "you can't end a netgame!\n\n"PRESSKEY #define ENDGAME "are you sure you want to end the game?\n\n"PRESSYN - #define DOSY "(press y to quit)" - #define DETAILHI "High detail" #define DETAILLO "Low detail" #define GAMMALVL0 "Gamma correction OFF" @@ -73,10 +33,6 @@ #define GAMMALVL3 "Gamma correction level 3" #define GAMMALVL4 "Gamma correction level 4" #define EMPTYSTRING "empty slot" - - - - #define GOTARMOR "Picked up the armor." #define GOTMEGA "Picked up the MegaArmor!" #define GOTHTHBONUS "Picked up a health bonus." @@ -85,14 +41,12 @@ #define GOTMEDINEED "Picked up a medikit that you REALLY need!" #define GOTMEDIKIT "Picked up a medikit." #define GOTSUPER "Supercharge!" - #define GOTBLUECARD "Picked up a blue keycard." #define GOTYELWCARD "Picked up a yellow keycard." #define GOTREDCARD "Picked up a red keycard." #define GOTBLUESKUL "Picked up a blue skull key." #define GOTYELWSKUL "Picked up a yellow skull key." #define GOTREDSKULL "Picked up a red skull key." - #define GOTINVUL "Invulnerability!" #define GOTBERSERK "Berserk!" #define GOTINVIS "Partial Invisibility" @@ -100,7 +54,6 @@ #define GOTMAP "Computer Area Map" #define GOTVISOR "Light Amplification Visor" #define GOTMSPHERE "MegaSphere!" - #define GOTCLIP "Picked up a clip." #define GOTCLIPBOX "Picked up a box of bullets." #define GOTROCKET "Picked up a rocket." @@ -110,7 +63,6 @@ #define GOTSHELLS "Picked up 4 shotgun shells." #define GOTSHELLBOX "Picked up a box of shotgun shells." #define GOTBACKPACK "Picked up a backpack full of ammo!" - #define GOTBFG9000 "You got the BFG9000! Oh, yes." #define GOTCHAINGUN "You got the chaingun!" #define GOTCHAINSAW "A chainsaw! Find some meat!" @@ -118,27 +70,14 @@ #define GOTPLASMA "You got the plasma gun!" #define GOTSHOTGUN "You got the shotgun!" #define GOTSHOTGUN2 "You got the super shotgun!" - - - - #define PD_BLUEO "You need a blue key to activate this object" #define PD_REDO "You need a red key to activate this object" #define PD_YELLOWO "You need a yellow key to activate this object" #define PD_BLUEK "You need a blue key to open this door" #define PD_REDK "You need a red key to open this door" #define PD_YELLOWK "You need a yellow key to open this door" - - - - #define GGSAVED "game saved." - - - - #define HUSTR_MSGU "[Message unsent]" - #define HUSTR_E1M1 "E1M1: Hangar" #define HUSTR_E1M2 "E1M2: Nuclear Plant" #define HUSTR_E1M3 "E1M3: Toxin Refinery" @@ -148,7 +87,6 @@ #define HUSTR_E1M7 "E1M7: Computer Station" #define HUSTR_E1M8 "E1M8: Phobos Anomaly" #define HUSTR_E1M9 "E1M9: Military Base" - #define HUSTR_E2M1 "E2M1: Deimos Anomaly" #define HUSTR_E2M2 "E2M2: Containment Area" #define HUSTR_E2M3 "E2M3: Refinery" @@ -158,7 +96,6 @@ #define HUSTR_E2M7 "E2M7: Spawning Vats" #define HUSTR_E2M8 "E2M8: Tower of Babel" #define HUSTR_E2M9 "E2M9: Fortress of Mystery" - #define HUSTR_E3M1 "E3M1: Hell Keep" #define HUSTR_E3M2 "E3M2: Slough of Despair" #define HUSTR_E3M3 "E3M3: Pandemonium" @@ -168,7 +105,6 @@ #define HUSTR_E3M7 "E3M7: Limbo" #define HUSTR_E3M8 "E3M8: Dis" #define HUSTR_E3M9 "E3M9: Warrens" - #define HUSTR_E4M1 "E4M1: Hell Beneath" #define HUSTR_E4M2 "E4M2: Perfect Hatred" #define HUSTR_E4M3 "E4M3: Sever The Wicked" @@ -178,7 +114,6 @@ #define HUSTR_E4M7 "E4M7: And Hell Followed" #define HUSTR_E4M8 "E4M8: Unto The Cruel" #define HUSTR_E4M9 "E4M9: Fear" - #define HUSTR_1 "level 1: entryway" #define HUSTR_2 "level 2: underhalls" #define HUSTR_3 "level 3: the gantlet" @@ -190,7 +125,6 @@ #define HUSTR_9 "level 9: the pit" #define HUSTR_10 "level 10: refueling base" #define HUSTR_11 "level 11: 'o' of destruction!" - #define HUSTR_12 "level 12: the factory" #define HUSTR_13 "level 13: downtown" #define HUSTR_14 "level 14: the inmost dens" @@ -200,7 +134,6 @@ #define HUSTR_18 "level 18: the courtyard" #define HUSTR_19 "level 19: the citadel" #define HUSTR_20 "level 20: gotcha!" - #define HUSTR_21 "level 21: nirvana" #define HUSTR_22 "level 22: the catacombs" #define HUSTR_23 "level 23: barrels o' fun" @@ -211,10 +144,8 @@ #define HUSTR_28 "level 28: the spirit world" #define HUSTR_29 "level 29: the living end" #define HUSTR_30 "level 30: icon of sin" - #define HUSTR_31 "level 31: wolfenstein" #define HUSTR_32 "level 32: grosse" - #define PHUSTR_1 "level 1: congo" #define PHUSTR_2 "level 2: well of souls" #define PHUSTR_3 "level 3: aztec" @@ -226,7 +157,6 @@ #define PHUSTR_9 "level 9: abattoire" #define PHUSTR_10 "level 10: onslaught" #define PHUSTR_11 "level 11: hunted" - #define PHUSTR_12 "level 12: speed" #define PHUSTR_13 "level 13: the crypt" #define PHUSTR_14 "level 14: genesis" @@ -236,7 +166,6 @@ #define PHUSTR_18 "level 18: neurosphere" #define PHUSTR_19 "level 19: nme" #define PHUSTR_20 "level 20: the death domain" - #define PHUSTR_21 "level 21: slayer" #define PHUSTR_22 "level 22: impossible mission" #define PHUSTR_23 "level 23: tombstone" @@ -247,10 +176,8 @@ #define PHUSTR_28 "level 28: the sewers" #define PHUSTR_29 "level 29: odyssey of noises" #define PHUSTR_30 "level 30: the gateway of hell" - #define PHUSTR_31 "level 31: cyberden" #define PHUSTR_32 "level 32: go 2 it" - #define THUSTR_1 "level 1: system control" #define THUSTR_2 "level 2: human bbq" #define THUSTR_3 "level 3: power control" @@ -262,7 +189,6 @@ #define THUSTR_9 "level 9: stronghold" #define THUSTR_10 "level 10: redemption" #define THUSTR_11 "level 11: storage facility" - #define THUSTR_12 "level 12: crater" #define THUSTR_13 "level 13: nukage processing" #define THUSTR_14 "level 14: steel works" @@ -272,7 +198,6 @@ #define THUSTR_18 "level 18: mill" #define THUSTR_19 "level 19: shipping/respawning" #define THUSTR_20 "level 20: central processing" - #define THUSTR_21 "level 21: administration center" #define THUSTR_22 "level 22: habitat" #define THUSTR_23 "level 23: lunar mining project" @@ -283,10 +208,8 @@ #define THUSTR_28 "level 28: heck" #define THUSTR_29 "level 29: river styx" #define THUSTR_30 "level 30: last call" - #define THUSTR_31 "level 31: pharaoh" #define THUSTR_32 "level 32: caribbean" - #define HUSTR_CHATMACRO1 "I'm ready to kick butt!" #define HUSTR_CHATMACRO2 "I'm OK." #define HUSTR_CHATMACRO3 "I'm not looking too good!" @@ -297,65 +220,38 @@ #define HUSTR_CHATMACRO8 "I'll take care of it." #define HUSTR_CHATMACRO9 "Yes" #define HUSTR_CHATMACRO0 "No" - #define HUSTR_TALKTOSELF1 "You mumble to yourself" #define HUSTR_TALKTOSELF2 "Who's there?" #define HUSTR_TALKTOSELF3 "You scare yourself" #define HUSTR_TALKTOSELF4 "You start to rave" #define HUSTR_TALKTOSELF5 "You've lost it..." - #define HUSTR_MESSAGESENT "[Message Sent]" - - - - #define HUSTR_PLRGREEN "Green: " #define HUSTR_PLRINDIGO "Indigo: " #define HUSTR_PLRBROWN "Brown: " #define HUSTR_PLRRED "Red: " - #define HUSTR_KEYGREEN 'g' #define HUSTR_KEYINDIGO 'i' #define HUSTR_KEYBROWN 'b' #define HUSTR_KEYRED 'r' - - - - - #define AMSTR_FOLLOWON "Follow Mode ON" #define AMSTR_FOLLOWOFF "Follow Mode OFF" - #define AMSTR_GRIDON "Grid ON" #define AMSTR_GRIDOFF "Grid OFF" - #define AMSTR_MARKEDSPOT "Marked Spot" #define AMSTR_MARKSCLEARED "All Marks Cleared" - - - - - #define STSTR_MUS "Music Change" #define STSTR_NOMUS "IMPOSSIBLE SELECTION" #define STSTR_DQDON "Degreelessness Mode On" #define STSTR_DQDOFF "Degreelessness Mode Off" - #define STSTR_KFAADDED "Very Happy Ammo Added" #define STSTR_FAADDED "Ammo (no keys) Added" - #define STSTR_NCON "No Clipping Mode ON" #define STSTR_NCOFF "No Clipping Mode OFF" - #define STSTR_BEHOLD "inVuln, Str, Inviso, Rad, Allmap, or Lite-amp" #define STSTR_BEHOLDX "Power-up Toggled" - #define STSTR_CHOPPERS "... doesn't suck - GM" #define STSTR_CLEV "Changing Level..." - - - - #define E1TEXT \ "Once you beat the big badasses and\n"\ "clean out the moon base you're supposed\n"\ @@ -372,8 +268,6 @@ "To continue the DOOM experience, play\n"\ "The Shores of Hell and its amazing\n"\ "sequel, Inferno!\n" - - #define E2TEXT \ "You've done it! The hideous cyber-\n"\ "demon lord that ruled the lost Deimos\n"\ @@ -392,8 +286,6 @@ "\n" \ "Now, it's on to the final chapter of\n"\ "DOOM! -- Inferno." - - #define E3TEXT \ "The loathsome spiderdemon that\n"\ "masterminded the invasion of the moon\n"\ @@ -412,8 +304,6 @@ "unleashed. It's good that no Hell-\n"\ "spawn could have come through that\n"\ "door with you ..." - - #define E4TEXT \ "the spider mastermind must have sent forth\n"\ "its legions of hellspawn before your\n"\ @@ -431,10 +321,6 @@ "of demons run amok among our cities.\n"\ "\n"\ "next stop, hell on earth!" - - - - #define C1TEXT \ "YOU HAVE ENTERED DEEPLY INTO THE INFESTED\n" \ "STARPORT. BUT SOMETHING IS WRONG. THE\n" \ @@ -448,9 +334,6 @@ "OF THE STARBASE AND FIND THE CONTROLLING\n" \ "SWITCH WHICH HOLDS EARTH'S POPULATION\n" \ "HOSTAGE." - - - #define C2TEXT \ "YOU HAVE WON! YOUR VICTORY HAS ENABLED\n" \ "HUMANKIND TO EVACUATE EARTH AND ESCAPE\n"\ @@ -469,10 +352,6 @@ "YOUR OWN HOME CITY, NOT FAR FROM THE\n"\ "STARPORT.\" SLOWLY AND PAINFULLY YOU GET\n"\ "UP AND RETURN TO THE FRAY." - - - - #define C3TEXT \ "YOU ARE AT THE CORRUPT HEART OF THE CITY,\n"\ "SURROUNDED BY THE CORPSES OF YOUR ENEMIES.\n"\ @@ -483,10 +362,6 @@ "THERE MUST BE A WAY TO CLOSE IT ON THE\n"\ "OTHER SIDE. WHAT DO YOU CARE IF YOU'VE\n"\ "GOT TO GO THROUGH HELL TO GET TO IT?" - - - - #define C4TEXT \ "THE HORRENDOUS VISAGE OF THE BIGGEST\n"\ "DEMON YOU'VE EVER SEEN CRUMBLES BEFORE\n"\ @@ -503,29 +378,16 @@ "FOREHEAD YOU BEGIN THE LONG TREK BACK\n"\ "HOME. REBUILDING EARTH OUGHT TO BE A\n"\ "LOT MORE FUN THAN RUINING IT WAS.\n" - - - - - #define C5TEXT \ "CONGRATULATIONS, YOU'VE FOUND THE SECRET\n"\ "LEVEL! LOOKS LIKE IT'S BEEN BUILT BY\n"\ "HUMANS, RATHER THAN DEMONS. YOU WONDER\n"\ "WHO THE INMATES OF THIS CORNER OF HELL\n"\ "WILL BE." - - - - #define C6TEXT \ "CONGRATULATIONS, YOU'VE FOUND THE\n"\ "SUPER SECRET LEVEL! YOU'D BETTER\n"\ "BLAZE THROUGH THIS ONE!\n" - - - - #define P1TEXT \ "You gloat over the steaming carcass of the\n"\ "Guardian. With its death, you've wrested\n"\ @@ -539,10 +401,6 @@ "struggles will have been wasted. Keep\n"\ "moving, keep fighting, keep killing.\n"\ "Oh yes, keep living, too." - - - - #define P2TEXT \ "Even the deadly Arch-Vile labyrinth could\n"\ "not stop you, and you've gotten to the\n"\ @@ -550,10 +408,6 @@ "efficiently and permanently deactivated.\n"\ "\n"\ "You're good at that kind of thing." - - - - #define P3TEXT \ "You've bashed and battered your way into\n"\ "the heart of the devil-hive. Time for a\n"\ @@ -565,9 +419,6 @@ "Grinning evilly, you check your gear, and\n"\ "get ready to give the bastard a little Hell\n"\ "of your own making!" - - - #define P4TEXT \ "The Gatekeeper's evil face is splattered\n"\ "all over the place. As its tattered corpse\n"\ @@ -581,23 +432,15 @@ "launcher in your coffin. If you go to Hell\n"\ "when you die, you'll need it for some\n"\ "final cleaning-up ..." - - - #define P5TEXT \ "You've found the second-hardest level we\n"\ "got. Hope you have a saved game a level or\n"\ "two previous. If not, be prepared to die\n"\ "aplenty. For master marines only." - - - #define P6TEXT \ "Betcha wondered just what WAS the hardest\n"\ "level we had ready for ya? Now you know.\n"\ "No one gets out alive." - - #define T1TEXT \ "You've fought your way out of the infested\n"\ "experimental labs. It seems that UAC has\n"\ @@ -611,8 +454,6 @@ "their teeth into you. With luck, the\n"\ "complex still has some warlike ordnance\n"\ "laying around." - - #define T2TEXT \ "You hear the grinding of heavy machinery\n"\ "ahead. You sure hope they're not stamping\n"\ @@ -623,8 +464,6 @@ "maniacs packed into one mad killer.\n"\ "\n"\ "You don't plan to go down easy." - - #define T3TEXT \ "The vista opening ahead looks real damn\n"\ "familiar. Smells familiar, too -- like\n"\ @@ -634,7 +473,6 @@ "brood on it, the madder you get.\n"\ "Hefting your gun, an evil grin trickles\n"\ "onto your face. Time to take some names." - #define T4TEXT \ "Suddenly, all is silent, from one horizon\n"\ "to the other. The agonizing echo of Hell\n"\ @@ -647,16 +485,12 @@ "Something rumbles in the distance.\n"\ "A blue light begins to glow inside the\n"\ "ruined skull of the demon-spitter." - - #define T5TEXT \ "What now? Looks totally different. Kind\n"\ "of like King Tut's condo. Well,\n"\ "whatever's here can't be any worse\n"\ "than usual. Can it? Or maybe it's best\n"\ "to let sleeping gods lie.." - - #define T6TEXT \ "Time for a vacation. You've burst the\n"\ "bowels of hell and by golly you're ready\n"\ @@ -668,12 +502,6 @@ "\n"\ "As you step off the transport, you hear\n"\ "the stomp of a cyberdemon's iron shoe." - - - - - - #define CC_ZOMBIE "ZOMBIEMAN" #define CC_SHOTGUN "SHOTGUN GUY" #define CC_HEAVY "HEAVY WEAPON DUDE" @@ -691,11 +519,4 @@ #define CC_SPIDER "THE SPIDER MASTERMIND" #define CC_CYBER "THE CYBERDEMON" #define CC_HERO "OUR HERO" - - #endif - - - - - diff --git a/src/d_event.h b/src/d_event.h @@ -1,37 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_EVENT__ #define __D_EVENT__ - - #include "doomtype.h" - - - - - - - typedef enum { ev_keydown, @@ -39,8 +8,6 @@ typedef enum ev_mouse, ev_joystick } evtype_t; - - typedef struct { evtype_t type; @@ -48,8 +15,6 @@ typedef struct int data2; int data3; } event_t; - - typedef enum { ga_nothing, @@ -63,60 +28,23 @@ typedef enum ga_worlddone, ga_screenshot } gameaction_t; - - - - - - typedef enum { - BT_ATTACK = 1, - BT_USE = 2, - - BT_SPECIAL = 128, BT_SPECIALMASK = 3, - - - BT_CHANGE = 4, - BT_WEAPONMASK = (8+16+32), BT_WEAPONSHIFT = 3, - - BTS_PAUSE = 1, - BTS_SAVEGAME = 2, - - - BTS_SAVEMASK = (4+8+16), BTS_SAVESHIFT = 2 - } buttoncode_t; - - - - - - - #define MAXEVENTS 64 - extern event_t events[MAXEVENTS]; extern int eventhead; extern int eventtail; - extern gameaction_t gameaction; - - #endif - - - - - diff --git a/src/d_french.h b/src/d_french.h @@ -1,37 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_FRENCH__ #define __D_FRENCH__ - - - - #define D_DEVSTR "MODE DEVELOPPEMENT ON.\n" #define D_CDROM "VERSION CD-ROM: DEFAULT.CFG DANS C:\\DOOMDATA\n" - - - - #define PRESSKEY "APPUYEZ SUR UNE TOUCHE." #define PRESSYN "APPUYEZ SUR Y OU N" #define QUITMSG "VOUS VOULEZ VRAIMENT\nQUITTER CE SUPER JEU?" @@ -54,9 +24,7 @@ #define NETEND "VOUS NE POUVEZ PAS METTRE FIN A UN JEU SUR "\ "RESEAU!\n\n"PRESSKEY #define ENDGAME "VOUS VOULEZ VRAIMENT METTRE FIN AU JEU?\n\n"PRESSYN - #define DOSY "(APPUYEZ SUR Y POUR REVENIR AU OS.)" - #define DETAILHI "GRAPHISMES MAXIMUM " #define DETAILLO "GRAPHISMES MINIMUM " #define GAMMALVL0 "CORRECTION GAMMA OFF" @@ -65,10 +33,6 @@ #define GAMMALVL3 "CORRECTION GAMMA NIVEAU 3" #define GAMMALVL4 "CORRECTION GAMMA NIVEAU 4" #define EMPTYSTRING "EMPLACEMENT VIDE" - - - - #define GOTARMOR "ARMURE RECUPEREE." #define GOTMEGA "MEGA-ARMURE RECUPEREE!" #define GOTHTHBONUS "BONUS DE SANTE RECUPERE." @@ -77,14 +41,12 @@ #define GOTMEDINEED "MEDIKIT RECUPERE. VOUS EN AVEZ VRAIMENT BESOIN!" #define GOTMEDIKIT "MEDIKIT RECUPERE." #define GOTSUPER "SUPERCHARGE!" - #define GOTBLUECARD "CARTE MAGNETIQUE BLEUE RECUPEREE." #define GOTYELWCARD "CARTE MAGNETIQUE JAUNE RECUPEREE." #define GOTREDCARD "CARTE MAGNETIQUE ROUGE RECUPEREE." #define GOTBLUESKUL "CLEF CRANE BLEUE RECUPEREE." #define GOTYELWSKUL "CLEF CRANE JAUNE RECUPEREE." #define GOTREDSKULL "CLEF CRANE ROUGE RECUPEREE." - #define GOTINVUL "INVULNERABILITE!" #define GOTBERSERK "BERSERK!" #define GOTINVIS "INVISIBILITE PARTIELLE " @@ -92,7 +54,6 @@ #define GOTMAP "CARTE INFORMATIQUE " #define GOTVISOR "VISEUR A AMPLIFICATION DE LUMIERE " #define GOTMSPHERE "MEGASPHERE!" - #define GOTCLIP "CHARGEUR RECUPERE." #define GOTCLIPBOX "BOITE DE BALLES RECUPEREE." #define GOTROCKET "ROQUETTE RECUPEREE." @@ -102,7 +63,6 @@ #define GOTSHELLS "4 CARTOUCHES RECUPEREES." #define GOTSHELLBOX "BOITE DE CARTOUCHES RECUPEREE." #define GOTBACKPACK "SAC PLEIN DE MUNITIONS RECUPERE!" - #define GOTBFG9000 "VOUS AVEZ UN BFG9000! OH, OUI!" #define GOTCHAINGUN "VOUS AVEZ LA MITRAILLEUSE!" #define GOTCHAINSAW "UNE TRONCONNEUSE!" @@ -110,27 +70,14 @@ #define GOTPLASMA "VOUS AVEZ UN FUSIL A PLASMA!" #define GOTSHOTGUN "VOUS AVEZ UN FUSIL!" #define GOTSHOTGUN2 "VOUS AVEZ UN SUPER FUSIL!" - - - - #define PD_BLUEO "IL VOUS FAUT UNE CLEF BLEUE" #define PD_REDO "IL VOUS FAUT UNE CLEF ROUGE" #define PD_YELLOWO "IL VOUS FAUT UNE CLEF JAUNE" #define PD_BLUEK PD_BLUEO #define PD_REDK PD_REDO #define PD_YELLOWK PD_YELLOWO - - - - #define GGSAVED "JEU SAUVEGARDE." - - - - #define HUSTR_MSGU "[MESSAGE NON ENVOYE]" - #define HUSTR_E1M1 "E1M1: HANGAR" #define HUSTR_E1M2 "E1M2: USINE NUCLEAIRE " #define HUSTR_E1M3 "E1M3: RAFFINERIE DE TOXINES " @@ -140,7 +87,6 @@ #define HUSTR_E1M7 "E1M7: CENTRE INFORMATIQUE " #define HUSTR_E1M8 "E1M8: ANOMALIE PHOBOS " #define HUSTR_E1M9 "E1M9: BASE MILITAIRE " - #define HUSTR_E2M1 "E2M1: ANOMALIE DEIMOS " #define HUSTR_E2M2 "E2M2: ZONE DE CONFINEMENT " #define HUSTR_E2M3 "E2M3: RAFFINERIE" @@ -150,7 +96,6 @@ #define HUSTR_E2M7 "E2M7: CUVES DE REPRODUCTION " #define HUSTR_E2M8 "E2M8: TOUR DE BABEL " #define HUSTR_E2M9 "E2M9: FORTERESSE DU MYSTERE " - #define HUSTR_E3M1 "E3M1: DONJON DE L'ENFER " #define HUSTR_E3M2 "E3M2: BOURBIER DU DESESPOIR " #define HUSTR_E3M3 "E3M3: PANDEMONIUM" @@ -160,7 +105,6 @@ #define HUSTR_E3M7 "E3M7: LIMBES" #define HUSTR_E3M8 "E3M8: DIS" #define HUSTR_E3M9 "E3M9: CLAPIERS" - #define HUSTR_1 "NIVEAU 1: ENTREE " #define HUSTR_2 "NIVEAU 2: HALLS SOUTERRAINS " #define HUSTR_3 "NIVEAU 3: LE FEU NOURRI " @@ -172,7 +116,6 @@ #define HUSTR_9 "NIVEAU 9: LE PUITS " #define HUSTR_10 "NIVEAU 10: BASE DE RAVITAILLEMENT " #define HUSTR_11 "NIVEAU 11: LE CERCLE DE LA MORT!" - #define HUSTR_12 "NIVEAU 12: L'USINE " #define HUSTR_13 "NIVEAU 13: LE CENTRE VILLE" #define HUSTR_14 "NIVEAU 14: LES ANTRES PROFONDES " @@ -182,7 +125,6 @@ #define HUSTR_18 "NIVEAU 18: LA COUR " #define HUSTR_19 "NIVEAU 19: LA CITADELLE " #define HUSTR_20 "NIVEAU 20: JE T'AI EU!" - #define HUSTR_21 "NIVEAU 21: LE NIRVANA" #define HUSTR_22 "NIVEAU 22: LES CATACOMBES " #define HUSTR_23 "NIVEAU 23: LA GRANDE FETE " @@ -193,11 +135,8 @@ #define HUSTR_28 "NIVEAU 28: LE MONDE DE L'ESPRIT " #define HUSTR_29 "NIVEAU 29: LA LIMITE " #define HUSTR_30 "NIVEAU 30: L'ICONE DU PECHE " - #define HUSTR_31 "NIVEAU 31: WOLFENSTEIN" #define HUSTR_32 "NIVEAU 32: LE MASSACRE" - - #define HUSTR_CHATMACRO1 "JE SUIS PRET A LEUR EN FAIRE BAVER!" #define HUSTR_CHATMACRO2 "JE VAIS BIEN." #define HUSTR_CHATMACRO3 "JE N'AI PAS L'AIR EN FORME!" @@ -208,65 +147,38 @@ #define HUSTR_CHATMACRO8 "JE VAIS M'EN OCCUPER." #define HUSTR_CHATMACRO9 "OUI" #define HUSTR_CHATMACRO0 "NON" - #define HUSTR_TALKTOSELF1 "VOUS PARLEZ TOUT SEUL " #define HUSTR_TALKTOSELF2 "QUI EST LA?" #define HUSTR_TALKTOSELF3 "VOUS VOUS FAITES PEUR " #define HUSTR_TALKTOSELF4 "VOUS COMMENCEZ A DELIRER " #define HUSTR_TALKTOSELF5 "VOUS ETES LARGUE..." - #define HUSTR_MESSAGESENT "[MESSAGE ENVOYE]" - - - - #define HUSTR_PLRGREEN "VERT: " #define HUSTR_PLRINDIGO "INDIGO: " #define HUSTR_PLRBROWN "BRUN: " #define HUSTR_PLRRED "ROUGE: " - #define HUSTR_KEYGREEN 'g' #define HUSTR_KEYINDIGO 'i' #define HUSTR_KEYBROWN 'b' #define HUSTR_KEYRED 'r' - - - - - #define AMSTR_FOLLOWON "MODE POURSUITE ON" #define AMSTR_FOLLOWOFF "MODE POURSUITE OFF" - #define AMSTR_GRIDON "GRILLE ON" #define AMSTR_GRIDOFF "GRILLE OFF" - #define AMSTR_MARKEDSPOT "REPERE MARQUE " #define AMSTR_MARKSCLEARED "REPERES EFFACES " - - - - - #define STSTR_MUS "CHANGEMENT DE MUSIQUE " #define STSTR_NOMUS "IMPOSSIBLE SELECTION" #define STSTR_DQDON "INVULNERABILITE ON " #define STSTR_DQDOFF "INVULNERABILITE OFF" - #define STSTR_KFAADDED "ARMEMENT MAXIMUM! " #define STSTR_FAADDED "ARMES (SAUF CLEFS) AJOUTEES" - #define STSTR_NCON "BARRIERES ON" #define STSTR_NCOFF "BARRIERES OFF" - #define STSTR_BEHOLD " inVuln, Str, Inviso, Rad, Allmap, or Lite-amp" #define STSTR_BEHOLDX "AMELIORATION ACTIVEE" - #define STSTR_CHOPPERS "... DOESN'T SUCK - GM" #define STSTR_CLEV "CHANGEMENT DE NIVEAU..." - - - - #define E1TEXT "APRES AVOIR VAINCU LES GROS MECHANTS\n"\ "ET NETTOYE LA BASE LUNAIRE, VOUS AVEZ\n"\ "GAGNE, NON? PAS VRAI? OU EST DONC VOTRE\n"\ @@ -282,7 +194,6 @@ "POUR VIVRE LA SUITE DE DOOM, JOUEZ\n"\ "A 'AUX PORTES DE L'ENFER' ET A\n"\ "L'EPISODE SUIVANT, 'L'ENFER'!\n" - #define E2TEXT "VOUS AVEZ REUSSI. L'INFAME DEMON\n"\ "QUI CONTROLAIT LA BASE LUNAIRE DE\n"\ "DEIMOS EST MORT, ET VOUS AVEZ\n"\ @@ -300,7 +211,6 @@ "\n" \ "VOICI MAINTENANT LE CHAPITRE FINAL DE\n"\ "DOOM! -- L'ENFER." - #define E3TEXT "LE DEMON ARACHNEEN ET REPUGNANT\n"\ "QUI A DIRIGE L'INVASION DES BASES\n"\ "LUNAIRES ET SEME LA MORT VIENT DE SE\n"\ @@ -318,11 +228,6 @@ "COMBATTU LE DEMON. HEUREUSEMENT,\n"\ "AUCUN GERME DU MAL N'A FRANCHI\n"\ "CETTE PORTE AVEC VOUS..." - - - - - #define C1TEXT "VOUS ETES AU PLUS PROFOND DE L'ASTROPORT\n" \ "INFESTE DE MONSTRES, MAIS QUELQUE CHOSE\n" \ "NE VA PAS. ILS ONT APPORTE LEUR PROPRE\n" \ @@ -335,9 +240,6 @@ "COEUR DE LA BASE HANTEE ET TROUVER \n" \ "L'INTERRUPTEUR DE CONTROLE QUI GARDE LA \n" \ "POPULATION DE LA TERRE EN OTAGE." - - - #define C2TEXT "VOUS AVEZ GAGNE! VOTRE VICTOIRE A PERMIS\n" \ "A L'HUMANITE D'EVACUER LA TERRE ET \n"\ "D'ECHAPPER AU CAUCHEMAR. VOUS ETES \n"\ @@ -355,9 +257,6 @@ "DE VOTRE VILLE NATALE, PRES DE L'ASTROPORT.\n"\ "VOUS VOUS RELEVEZ LENTEMENT ET PENIBLEMENT\n"\ "ET VOUS REPARTEZ POUR LE FRONT." - - - #define C3TEXT "VOUS ETES AU COEUR DE LA CITE CORROMPUE,\n"\ "ENTOURE PAR LES CADAVRES DE VOS ENNEMIS.\n"\ "VOUS NE VOYEZ PAS COMMENT DETRUIRE LA PORTE\n"\ @@ -367,9 +266,6 @@ "IL DOIT Y AVOIR UN MOYEN DE LA FERMER\n"\ "DE L'AUTRE COTE. VOUS ACCEPTEZ DE\n"\ "TRAVERSER L'ENFER POUR LE FAIRE?" - - - #define C4TEXT "LE VISAGE HORRIBLE D'UN DEMON D'UNE\n"\ "TAILLE INCROYABLE S'EFFONDRE DEVANT\n"\ "VOUS LORSQUE VOUS TIREZ UNE SALVE DE\n"\ @@ -385,24 +281,14 @@ "VOTRE FRONT COUVERT DE SUEUR ET REPARTEZ\n"\ "VERS LA TERRE. SA RECONSTRUCTION SERA\n"\ "BEAUCOUP PLUS DROLE QUE SA DESTRUCTION.\n" - - - #define C5TEXT "FELICITATIONS! VOUS AVEZ TROUVE LE\n"\ "NIVEAU SECRET! IL SEMBLE AVOIR ETE\n"\ "CONSTRUIT PAR LES HUMAINS. VOUS VOUS\n"\ "DEMANDEZ QUELS PEUVENT ETRE LES\n"\ "HABITANTS DE CE COIN PERDU DE L'ENFER." - - - #define C6TEXT "FELICITATIONS! VOUS AVEZ DECOUVERT\n"\ "LE NIVEAU SUPER SECRET! VOUS FERIEZ\n"\ "MIEUX DE FONCER DANS CELUI-LA!\n" - - - - #define CC_ZOMBIE "ZOMBIE" #define CC_SHOTGUN "TYPE AU FUSIL" #define CC_HEAVY "MEC SUPER-ARME" @@ -420,14 +306,4 @@ #define CC_SPIDER "L'ARAIGNEE CERVEAU" #define CC_CYBER "LE CYBERDEMON" #define CC_HERO "NOTRE HEROS" - - - #endif - - - - - - - diff --git a/src/d_items.c b/src/d_items.c @@ -1,51 +1,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include "info.h" - #ifdef __GNUG__ #pragma implementation "d_items.h" #endif #include "d_items.h" - - - - - - - - - - - - - - weaponinfo_t weaponinfo[NUMWEAPONS] = { { - am_noammo, S_PUNCHUP, S_PUNCHDOWN, @@ -54,7 +14,6 @@ weaponinfo_t weaponinfo[NUMWEAPONS] = S_NULL }, { - am_clip, S_PISTOLUP, S_PISTOLDOWN, @@ -63,7 +22,6 @@ weaponinfo_t weaponinfo[NUMWEAPONS] = S_PISTOLFLASH }, { - am_shell, S_SGUNUP, S_SGUNDOWN, @@ -72,7 +30,6 @@ weaponinfo_t weaponinfo[NUMWEAPONS] = S_SGUNFLASH1 }, { - am_clip, S_CHAINUP, S_CHAINDOWN, @@ -81,7 +38,6 @@ weaponinfo_t weaponinfo[NUMWEAPONS] = S_CHAINFLASH1 }, { - am_misl, S_MISSILEUP, S_MISSILEDOWN, @@ -90,7 +46,6 @@ weaponinfo_t weaponinfo[NUMWEAPONS] = S_MISSILEFLASH1 }, { - am_cell, S_PLASMAUP, S_PLASMADOWN, @@ -99,7 +54,6 @@ weaponinfo_t weaponinfo[NUMWEAPONS] = S_PLASMAFLASH1 }, { - am_cell, S_BFGUP, S_BFGDOWN, @@ -108,7 +62,6 @@ weaponinfo_t weaponinfo[NUMWEAPONS] = S_BFGFLASH1 }, { - am_noammo, S_SAWUP, S_SAWDOWN, @@ -117,7 +70,6 @@ weaponinfo_t weaponinfo[NUMWEAPONS] = S_NULL }, { - am_shell, S_DSGUNUP, S_DSGUNDOWN, @@ -126,11 +78,3 @@ weaponinfo_t weaponinfo[NUMWEAPONS] = S_DSGUNFLASH1 }, }; - - - - - - - - diff --git a/src/d_items.h b/src/d_items.h @@ -1,36 +1,9 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_ITEMS__ #define __D_ITEMS__ - #include "doomdef.h" - #ifdef __GNUG__ #pragma interface #endif - - - typedef struct { ammotype_t ammo; @@ -39,14 +12,6 @@ typedef struct int readystate; int atkstate; int flashstate; - } weaponinfo_t; - extern weaponinfo_t weaponinfo[NUMWEAPONS]; - #endif - - - - - diff --git a/src/d_main.c b/src/d_main.c @@ -1,35 +1,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - #define BGCOLOR 7 #define FGCOLOR 8 - - #ifdef NORMALUNIX #include <stdio.h> #include <stdlib.h> @@ -38,134 +8,66 @@ #include <sys/stat.h> #include <fcntl.h> #endif - - #include "doomdef.h" #include "doomstat.h" - #include "dstrings.h" #include "sounds.h" - - #include "z_zone.h" #include "w_wad.h" #include "s_sound.h" #include "v_video.h" - #include "f_finale.h" #include "f_wipe.h" - #include "m_argv.h" #include "m_misc.h" #include "m_menu.h" - #include "i_system.h" #include "i_sound.h" #include "i_video.h" - #include "g_game.h" - #include "hu_stuff.h" #include "wi_stuff.h" #include "st_stuff.h" #include "am_map.h" - #include "p_setup.h" #include "r_local.h" - - #include "d_main.h" - - - - - - - - - - void D_DoomLoop (void); - - char* wadfiles[MAXWADFILES]; - - boolean devparm; boolean nomonsters; boolean respawnparm; boolean fastparm; - boolean drone; - boolean singletics = false; - - - - - - - extern boolean inhelpscreens; - skill_t startskill; int startepisode; int startmap; boolean autostart; - FILE* debugfile; - boolean advancedemo; - - - - char wadfile[1024]; char mapdir[1024]; char basedefault[1024]; - - void D_CheckNetGame (void); void D_ProcessEvents (void); void G_BuildTiccmd (ticcmd_t* cmd); void D_DoAdvanceDemo (void); - - - - - - - - event_t events[MAXEVENTS]; int eventhead; int eventtail; - - - - - - void D_PostEvent (event_t* ev) { events[eventhead] = *ev; eventhead = (++eventhead)&(MAXEVENTS-1); } - - - - - - void D_ProcessEvents (void) { event_t* ev; - - if ( ( gamemode == commercial ) && (W_CheckNumForName("map01")<0) ) return; - for ( ; eventtail != eventhead ; eventtail = (++eventtail)&(MAXEVENTS-1) ) { ev = &events[eventtail]; @@ -174,21 +76,10 @@ void D_ProcessEvents (void) G_Responder (ev); } } - - - - - - - - - - gamestate_t wipegamestate = GS_DEMOSCREEN; extern boolean setsizeneeded; extern int showMessages; void R_ExecuteSetViewSize (void); - void D_Display (void) { static boolean viewactivestate = false; @@ -204,21 +95,15 @@ void D_Display (void) boolean done; boolean wipe; boolean redrawsbar; - if (nodrawers) return; - redrawsbar = false; - - if (setsizeneeded) { R_ExecuteSetViewSize (); oldgamestate = -1; borderdrawcount = 3; } - - if (gamestate != wipegamestate) { wipe = true; @@ -226,11 +111,8 @@ void D_Display (void) } else wipe = false; - if (gamestate == GS_LEVEL && gametic) HU_Erase(); - - switch (gamestate) { case GS_LEVEL: @@ -245,42 +127,28 @@ void D_Display (void) ST_Drawer (viewheight == 200, redrawsbar ); fullscreen = viewheight == 200; break; - case GS_INTERMISSION: WI_Drawer (); break; - case GS_FINALE: F_Drawer (); break; - case GS_DEMOSCREEN: D_PageDrawer (); break; } - - I_UpdateNoBlit (); - - if (gamestate == GS_LEVEL && !automapactive && gametic) R_RenderPlayerView (&players[displayplayer]); - if (gamestate == GS_LEVEL && gametic) HU_Drawer (); - - if (gamestate != oldgamestate && gamestate != GS_LEVEL) I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE)); - - if (gamestate == GS_LEVEL && oldgamestate != GS_LEVEL) { viewactivestate = false; R_FillBackScreen (); } - - if (gamestate == GS_LEVEL && !automapactive && scaledviewwidth != 320) { if (menuactive || menuactivestate || !viewactivestate) @@ -290,15 +158,11 @@ void D_Display (void) R_DrawViewBorder (); borderdrawcount--; } - } - menuactivestate = menuactive; viewactivestate = viewactive; inhelpscreensstate = inhelpscreens; oldgamestate = wipegamestate = gamestate; - - if (paused) { if (automapactive) @@ -308,25 +172,15 @@ void D_Display (void) V_DrawPatchDirect(viewwindowx+(scaledviewwidth-68)/2, y,0,W_CacheLumpName ("M_PAUSE", PU_CACHE)); } - - - M_Drawer (); NetUpdate (); - - - if (!wipe) { I_FinishUpdate (); return; } - - wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT); - wipestart = I_GetTime () - 1; - do { do @@ -342,19 +196,11 @@ void D_Display (void) I_FinishUpdate (); } while (!done); } - - - - - - extern boolean demorecording; - void D_DoomLoop (void) { if (demorecording) G_BeginRecording (); - if (M_CheckParm ("-debugfile")) { char filename[20]; @@ -362,15 +208,10 @@ void D_DoomLoop (void) printf ("debug output to: %s\n",filename); debugfile = fopen (filename,"w"); } - I_InitGraphics (); - while (1) { - I_StartFrame (); - - if (singletics) { I_StartTic (); @@ -387,69 +228,32 @@ void D_DoomLoop (void) { TryRunTics (); } - S_UpdateSounds (players[consoleplayer].mo); - - D_Display (); - #ifndef SNDSERV - I_UpdateSound(); #endif - #ifndef SNDINTR - I_SubmitSound(); #endif } } - - - - - - int demosequence; int pagetic; char *pagename; - - - - - - void D_PageTicker (void) { if (--pagetic < 0) D_AdvanceDemo (); } - - - - - - void D_PageDrawer (void) { V_DrawPatch (0,0, 0, W_CacheLumpName(pagename, PU_CACHE)); } - - - - - - void D_AdvanceDemo (void) { advancedemo = true; } - - - - - - void D_DoAdvanceDemo (void) { players[consoleplayer].playerstate = PST_LIVE; @@ -457,12 +261,10 @@ void D_AdvanceDemo (void) usergame = false; paused = false; gameaction = ga_nothing; - if ( gamemode == retail ) demosequence = (demosequence+1)%7; else demosequence = (demosequence+1)%6; - switch (demosequence) { case 0: @@ -499,7 +301,6 @@ void D_AdvanceDemo (void) else { pagetic = 200; - if ( gamemode == retail ) pagename = "CREDIT"; else @@ -509,110 +310,62 @@ void D_AdvanceDemo (void) case 5: G_DeferedPlayDemo ("demo3"); break; - case 6: G_DeferedPlayDemo ("demo4"); break; } } - - - - - - void D_StartTitle (void) { gameaction = ga_nothing; demosequence = -1; D_AdvanceDemo (); } - - - - - char title[128]; - - - - - - void D_AddFile (char *file) { int numwadfiles; char *newfile; - for (numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++) ; - newfile = malloc (strlen(file)+1); strcpy (newfile, file); - wadfiles[numwadfiles] = newfile; } - - - - - - - void IdentifyVersion (void) { - char* doom1wad; char* doomwad; char* doomuwad; char* doom2wad; - char* doom2fwad; char* plutoniawad; char* tntwad; - #ifdef NORMALUNIX char *home; char *doomwaddir; doomwaddir = getenv("DOOMWADDIR"); if (!doomwaddir) doomwaddir = "."; - - doom2wad = malloc(strlen(doomwaddir)+1+9+1); sprintf(doom2wad, "%s/doom2.wad", doomwaddir); - - doomuwad = malloc(strlen(doomwaddir)+1+8+1); sprintf(doomuwad, "%s/doomu.wad", doomwaddir); - - doomwad = malloc(strlen(doomwaddir)+1+8+1); sprintf(doomwad, "%s/doom.wad", doomwaddir); - - doom1wad = malloc(strlen(doomwaddir)+1+9+1); sprintf(doom1wad, "%s/doom1.wad", doomwaddir); - - - plutoniawad = malloc(strlen(doomwaddir)+1+/*9*/12+1); sprintf(plutoniawad, "%s/plutonia.wad", doomwaddir); - tntwad = malloc(strlen(doomwaddir)+1+9+1); sprintf(tntwad, "%s/tnt.wad", doomwaddir); - - - doom2fwad = malloc(strlen(doomwaddir)+1+10+1); sprintf(doom2fwad, "%s/doom2f.wad", doomwaddir); - home = getenv("HOME"); if (!home) I_Error("Please set $HOME to your home directory"); sprintf(basedefault, "%s/.doomrc", home); #endif - if (M_CheckParm ("-shdev")) { gamemode = shareware; @@ -623,7 +376,6 @@ void IdentifyVersion (void) strcpy (basedefault,DEVDATA"default.cfg"); return; } - if (M_CheckParm ("-regdev")) { gamemode = registered; @@ -635,7 +387,6 @@ void IdentifyVersion (void) strcpy (basedefault,DEVDATA"default.cfg"); return; } - if (M_CheckParm ("-comdev")) { gamemode = commercial; @@ -647,82 +398,62 @@ void IdentifyVersion (void) D_AddFile (DEVDATA"tnt.wad"); else*/ D_AddFile (DEVDATA"doom2.wad"); - D_AddFile (DEVMAPS"cdata/texture1.lmp"); D_AddFile (DEVMAPS"cdata/pnames.lmp"); strcpy (basedefault,DEVDATA"default.cfg"); return; } - if ( !access (doom2fwad,R_OK) ) { gamemode = commercial; - - language = french; printf("French version\n"); D_AddFile (doom2fwad); return; } - if ( !access (doom2wad,R_OK) ) { gamemode = commercial; D_AddFile (doom2wad); return; } - if ( !access (plutoniawad, R_OK ) ) { gamemode = commercial; D_AddFile (plutoniawad); return; } - if ( !access ( tntwad, R_OK ) ) { gamemode = commercial; D_AddFile (tntwad); return; } - if ( !access (doomuwad,R_OK) ) { gamemode = retail; D_AddFile (doomuwad); return; } - if ( !access (doomwad,R_OK) ) { gamemode = registered; D_AddFile (doomwad); return; } - if ( !access (doom1wad,R_OK) ) { gamemode = shareware; D_AddFile (doom1wad); return; } - printf("Game mode indeterminate.\n"); gamemode = indetermined; - - - - } - - - - void FindResponseFile (void) { int i; #define MAXARGVS 100 - for (i = 1;i < myargc;i++) if (myargv[i][0] == '@') { @@ -735,8 +466,6 @@ void FindResponseFile (void) char *file; char *moreargs[20]; char *firstargv; - - handle = fopen (&myargv[i][1],"rb"); if (!handle) { @@ -750,16 +479,12 @@ void FindResponseFile (void) file = malloc (size); fread (file,size,1,handle); fclose (handle); - - for (index = 0,k = i+1; k < myargc; k++) moreargs[index++] = myargv[k]; - firstargv = myargv[0]; myargv = malloc(sizeof(char *)*MAXARGVS); memset(myargv,0,sizeof(char *)*MAXARGVS); myargv[0] = firstargv; - infile = file; indexinfile = k = 0; indexinfile++; @@ -774,36 +499,23 @@ void FindResponseFile (void) ((*(infile+k)<= ' ') || (*(infile+k)>'z'))) k++; } while(k < size); - for (k = 0;k < index;k++) myargv[indexinfile++] = moreargs[k]; myargc = indexinfile; - - printf("%d command-line args:\n",myargc); for (k=1;k<myargc;k++) printf("%s\n",myargv[k]); - break; } } - - - - - void D_DoomMain (void) { int p; char file[256]; - FindResponseFile (); - IdentifyVersion (); - setbuf (stdout, NULL); modifiedgame = false; - nomonsters = M_CheckParm ("-nomonsters"); respawnparm = M_CheckParm ("-respawn"); fastparm = M_CheckParm ("-fast"); @@ -812,7 +524,6 @@ void D_DoomMain (void) deathmatch = 2; else if (M_CheckParm ("-deathmatch")) deathmatch = 1; - switch ( gamemode ) { case retail: @@ -867,26 +578,20 @@ void D_DoomMain (void) VERSION/100,VERSION%100); break; } - printf ("%s\n",title); - if (devparm) printf(D_DEVSTR); - if (M_CheckParm("-cdrom")) { printf(D_CDROM); mkdir("c:\\doomdata",0); strcpy (basedefault,"c:/doomdata/default.cfg"); } - - if ( (p=M_CheckParm ("-turbo")) ) { int scale = 200; extern int forwardmove[2]; extern int sidemove[2]; - if (p<myargc-1) scale = atoi (myargv[p+1]); if (scale < 10) @@ -899,18 +604,10 @@ void D_DoomMain (void) sidemove[0] = sidemove[0]*scale/100; sidemove[1] = sidemove[1]*scale/100; } - - - - - - p = M_CheckParm ("-wart"); if (p) { myargv[p][4] = 'p'; - - switch (gamemode ) { case shareware: @@ -921,7 +618,6 @@ void D_DoomMain (void) printf("Warping to Episode %s, Map %s.\n", myargv[p+1],myargv[p+2]); break; - case commercial: default: p = atoi (myargv[p+1]); @@ -933,43 +629,32 @@ void D_DoomMain (void) } D_AddFile (file); } - p = M_CheckParm ("-file"); if (p) { - - modifiedgame = true; while (++p != myargc && myargv[p][0] != '-') D_AddFile (myargv[p]); } - p = M_CheckParm ("-playdemo"); - if (!p) p = M_CheckParm ("-timedemo"); - if (p && p < myargc-1) { sprintf (file,"%s.lmp", myargv[p+1]); D_AddFile (file); printf("Playing demo %s.lmp.\n",myargv[p+1]); } - - startskill = sk_medium; startepisode = 1; startmap = 1; autostart = false; - - p = M_CheckParm ("-skill"); if (p && p < myargc-1) { startskill = myargv[p+1][0]-'1'; autostart = true; } - p = M_CheckParm ("-episode"); if (p && p < myargc-1) { @@ -977,7 +662,6 @@ void D_DoomMain (void) startmap = 1; autostart = true; } - p = M_CheckParm ("-timer"); if (p && p < myargc-1 && deathmatch) { @@ -988,11 +672,9 @@ void D_DoomMain (void) printf("s"); printf(".\n"); } - p = M_CheckParm ("-avg"); if (p && p < myargc-1 && deathmatch) printf("Austin Virtual Gaming: Levels will end after 20 minutes\n"); - p = M_CheckParm ("-warp"); if (p && p < myargc-1) { @@ -1005,26 +687,16 @@ void D_DoomMain (void) } autostart = true; } - - printf ("V_Init: allocate screens.\n"); V_Init (); - printf ("M_LoadDefaults: Load system defaults.\n"); M_LoadDefaults (); - printf ("Z_Init: Init zone memory allocation daemon. \n"); Z_Init (); - printf ("W_Init: Init WADfiles.\n"); W_InitMultipleFiles (wadfiles); - - - if (modifiedgame) { - - char name[23][8]= { "e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9", @@ -1032,20 +704,14 @@ void D_DoomMain (void) "dphoof","bfgga0","heada1","cybra1","spida1d1" }; int i; - if ( gamemode == shareware) I_Error("\nYou cannot -file with the shareware " "version. Register!"); - - - if (gamemode == registered) for (i = 0;i < 23; i++) if (W_CheckNumForName(name[i])<0) I_Error("\nThis is not the registered version."); } - - if (modifiedgame) { /*m*/printf ( @@ -1058,9 +724,6 @@ void D_DoomMain (void) ); getchar (); } - - - switch ( gamemode ) { case shareware: @@ -1081,56 +744,38 @@ void D_DoomMain (void) "===========================================================================\n" ); break; - default: - break; } - printf ("M_Init: Init miscellaneous info.\n"); M_Init (); - printf ("R_Init: Init DOOM refresh daemon - "); R_Init (); - printf ("\nP_Init: Init Playloop state.\n"); P_Init (); - printf ("I_Init: Setting up machine state.\n"); I_Init (); - printf ("D_CheckNetGame: Checking network game status.\n"); D_CheckNetGame (); - printf ("S_Init: Setting up sound.\n"); S_Init (snd_SfxVolume /* *8 */, snd_MusicVolume /* *8*/ ); - printf ("HU_Init: Setting up heads up display.\n"); HU_Init (); - printf ("ST_Init: Init status bar.\n"); ST_Init (); - - p = M_CheckParm ("-statcopy"); if (p && p<myargc-1) { - extern void* statcopy; - statcopy = (void*)atoi(myargv[p+1]); printf ("External statistics registered.\n"); } - - p = M_CheckParm ("-record"); - if (p && p < myargc-1) { G_RecordDemo (myargv[p+1]); autostart = true; } - p = M_CheckParm ("-playdemo"); if (p && p < myargc-1) { @@ -1138,14 +783,12 @@ void D_DoomMain (void) G_DeferedPlayDemo (myargv[p+1]); D_DoomLoop (); } - p = M_CheckParm ("-timedemo"); if (p && p < myargc-1) { G_TimeDemo (myargv[p+1]); D_DoomLoop (); } - p = M_CheckParm ("-loadgame"); if (p && p < myargc-1) { @@ -1155,16 +798,12 @@ void D_DoomMain (void) sprintf(file, SAVEGAMENAME"%c.dsg",myargv[p+1][0]); G_LoadGame (file); } - - if ( gameaction != ga_loadgame ) { if (autostart || netgame) G_InitNew (startskill, startepisode, startmap); else D_StartTitle (); - } - D_DoomLoop (); } diff --git a/src/d_main.h b/src/d_main.h @@ -1,64 +1,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_MAIN__ #define __D_MAIN__ - #include "d_event.h" - #ifdef __GNUG__ #pragma interface #endif - - - #define MAXWADFILES 20 extern char* wadfiles[MAXWADFILES]; - void D_AddFile (char *file); - - - - - - - - - void D_DoomMain (void); - - void D_PostEvent (event_t* ev); - - - - - - void D_PageTicker (void); void D_PageDrawer (void); void D_AdvanceDemo (void); void D_StartTitle (void); - #endif diff --git a/src/d_net.c b/src/d_net.c @@ -1,30 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "m_menu.h" #include "i_system.h" #include "i_video.h" @@ -32,136 +5,82 @@ #include "g_game.h" #include "doomdef.h" #include "doomstat.h" - #define NCMD_EXIT 0x80000000 #define NCMD_RETRANSMIT 0x40000000 #define NCMD_SETUP 0x20000000 #define NCMD_KILL 0x10000000 #define NCMD_CHECKSUM 0x0fffffff - - doomcom_t* doomcom; doomdata_t* netbuffer; - - - - - - - - - - - #define RESENDCOUNT 10 #define PL_DRONE 0x80 - ticcmd_t localcmds[BACKUPTICS]; - ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; int nettics[MAXNETNODES]; boolean nodeingame[MAXNETNODES]; boolean remoteresend[MAXNETNODES]; int resendto[MAXNETNODES]; int resendcount[MAXNETNODES]; - int nodeforplayer[MAXPLAYERS]; - int maketic; int lastnettic; int skiptics; int ticdup; int maxsend; - - void D_ProcessEvents (void); void G_BuildTiccmd (ticcmd_t *cmd); void D_DoAdvanceDemo (void); - boolean reboundpacket; doomdata_t reboundstore; - - - - - - int NetbufferSize (void) { return (int)&(((doomdata_t *)0)->cmds[netbuffer->numtics]); } - - - - unsigned NetbufferChecksum (void) { unsigned c; int i,l; - c = 0x1234567; - - #ifdef NORMALUNIX return 0; #endif - l = (NetbufferSize () - (int)&(((doomdata_t *)0)->retransmitfrom))/4; for (i=0 ; i<l ; i++) c += ((unsigned *)&netbuffer->retransmitfrom)[i] * (i+1); - return c & NCMD_CHECKSUM; } - - - - int ExpandTics (int low) { int delta; - delta = low - (maketic&0xff); - if (delta >= -64 && delta <= 64) return (maketic&~0xff) + low; if (delta > 64) return (maketic&~0xff) - 256 + low; if (delta < -64) return (maketic&~0xff) + 256 + low; - I_Error ("ExpandTics: strange value %i at maketic %i",low,maketic); return 0; } - - - - - - void HSendPacket (int node, int flags ) { netbuffer->checksum = NetbufferChecksum () | flags; - if (!node) { reboundstore = *netbuffer; reboundpacket = true; return; } - if (demoplayback) return; - if (!netgame) I_Error ("Tried to transmit to another node"); - doomcom->command = CMD_SEND; doomcom->remotenode = node; doomcom->datalength = NetbufferSize (); - if (debugfile) { int i; @@ -170,24 +89,15 @@ HSendPacket realretrans = ExpandTics (netbuffer->retransmitfrom); else realretrans = -1; - fprintf (debugfile,"send (%i + %i, R %i) [%i] ", ExpandTics(netbuffer->starttic), netbuffer->numtics, realretrans, doomcom->datalength); - for (i=0 ; i<doomcom->datalength ; i++) fprintf (debugfile,"%i ",((byte *)netbuffer)[i]); - fprintf (debugfile,"\n"); } - I_NetCmd (); } - - - - - boolean HGetPacket (void) { if (reboundpacket) @@ -197,38 +107,30 @@ boolean HGetPacket (void) reboundpacket = false; return true; } - if (!netgame) return false; - if (demoplayback) return false; - doomcom->command = CMD_GET; I_NetCmd (); - if (doomcom->remotenode == -1) return false; - if (doomcom->datalength != NetbufferSize ()) { if (debugfile) fprintf (debugfile,"bad packet length %i\n",doomcom->datalength); return false; } - if (NetbufferChecksum () != (netbuffer->checksum&NCMD_CHECKSUM) ) { if (debugfile) fprintf (debugfile,"bad packet checksum\n"); return false; } - if (debugfile) { int realretrans; int i; - if (netbuffer->checksum & NCMD_SETUP) fprintf (debugfile,"setup packet\n"); else @@ -237,12 +139,10 @@ boolean HGetPacket (void) realretrans = ExpandTics (netbuffer->retransmitfrom); else realretrans = -1; - fprintf (debugfile,"get %i = (%i + %i, R %i)[%i] ", doomcom->remotenode, ExpandTics(netbuffer->starttic), netbuffer->numtics, realretrans, doomcom->datalength); - for (i=0 ; i<doomcom->datalength ; i++) fprintf (debugfile,"%i ",((byte *)netbuffer)[i]); fprintf (debugfile,"\n"); @@ -250,13 +150,7 @@ boolean HGetPacket (void) } return true; } - - - - - char exitmsg[80]; - void GetPackets (void) { int netconsole; @@ -264,21 +158,14 @@ void GetPackets (void) ticcmd_t *src, *dest; int realend; int realstart; - while ( HGetPacket() ) { if (netbuffer->checksum & NCMD_SETUP) continue; - netconsole = netbuffer->player & ~PL_DRONE; netnode = doomcom->remotenode; - - - realstart = ExpandTics (netbuffer->starttic); realend = (realstart+netbuffer->numtics); - - if (netbuffer->checksum & NCMD_EXIT) { if (!nodeingame[netnode]) @@ -292,14 +179,9 @@ void GetPackets (void) G_CheckDemoStatus (); continue; } - - if (netbuffer->checksum & NCMD_KILL) I_Error ("Killed by network driver"); - nodeforplayer[netconsole] = netnode; - - if ( resendcount[netnode] <= 0 && (netbuffer->checksum & NCMD_RETRANSMIT) ) { @@ -310,11 +192,8 @@ void GetPackets (void) } else resendcount[netnode]--; - - if (realend == nettics[netnode]) continue; - if (realend < nettics[netnode]) { if (debugfile) @@ -323,11 +202,8 @@ void GetPackets (void) realstart,netbuffer->numtics); continue; } - - if (realstart > nettics[netnode]) { - if (debugfile) fprintf (debugfile, "missed tics from %i (%i - %i)\n", @@ -335,16 +211,11 @@ void GetPackets (void) remoteresend[netnode] = true; continue; } - - { int start; - remoteresend[netnode] = false; - start = nettics[netnode] - realstart; src = &netbuffer->cmds[start]; - while (nettics[netnode] < realend) { dest = &netcmds[netconsole][nettics[netnode]%BACKUPTICS]; @@ -355,15 +226,7 @@ void GetPackets (void) } } } - - - - - - - int gametime; - void NetUpdate (void) { int nowtime; @@ -371,15 +234,11 @@ void NetUpdate (void) int i,j; int realstart; int gameticdiv; - - nowtime = I_GetTime ()/ticdup; newtics = nowtime - gametime; gametime = nowtime; - if (newtics <= 0) goto listen; - if (skiptics <= newtics) { newtics -= skiptics; @@ -390,11 +249,7 @@ void NetUpdate (void) skiptics -= newtics; newtics = 0; } - - netbuffer->player = consoleplayer; - - gameticdiv = gametic/ticdup; for (i=0 ; i<newtics ; i++) { @@ -402,17 +257,11 @@ void NetUpdate (void) D_ProcessEvents (); if (maketic - gameticdiv >= BACKUPTICS/2-1) break; - - G_BuildTiccmd (&localcmds[maketic%BACKUPTICS]); maketic++; } - - if (singletics) return; - - for (i=0 ; i<doomcom->numnodes ; i++) if (nodeingame[i]) { @@ -420,13 +269,10 @@ void NetUpdate (void) netbuffer->numtics = maketic - realstart; if (netbuffer->numtics > BACKUPTICS) I_Error ("NetUpdate: netbuffer->numtics > BACKUPTICS"); - resendto[i] = maketic - doomcom->extratics; - for (j=0 ; j< netbuffer->numtics ; j++) netbuffer->cmds[j] = localcmds[(realstart+j)%BACKUPTICS]; - if (remoteresend[i]) { netbuffer->retransmitfrom = nettics[i]; @@ -438,26 +284,16 @@ void NetUpdate (void) HSendPacket (i, 0); } } - - listen: GetPackets (); } - - - - - - void CheckAbort (void) { event_t *ev; int stoptic; - stoptic = I_GetTime () + 2; while (I_GetTime() < stoptic) I_StartTic (); - I_StartTic (); for ( ; eventtail != eventhead ; eventtail = (++eventtail)&(MAXEVENTS-1) ) @@ -467,22 +303,14 @@ void CheckAbort (void) I_Error ("Network game synchronization aborted."); } } - - - - - void D_ArbitrateNetStart (void) { int i; boolean gotinfo[MAXNETNODES]; - autostart = true; memset (gotinfo,0,sizeof(gotinfo)); - if (doomcom->consoleplayer) { - printf ("listening for network start info...\n"); while (1) { @@ -505,7 +333,6 @@ void D_ArbitrateNetStart (void) } else { - printf ("sending network start info...\n"); do { @@ -524,7 +351,6 @@ void D_ArbitrateNetStart (void) netbuffer->numtics = 0; HSendPacket (i, NCMD_SETUP); } - #if 1 for(i = 10 ; i && HGetPacket(); --i) { @@ -537,24 +363,16 @@ void D_ArbitrateNetStart (void) gotinfo[netbuffer->player&0x7f] = true; } #endif - for (i=1 ; i<doomcom->numnodes ; i++) if (!gotinfo[i]) break; } while (i < doomcom->numnodes); } } - - - - - extern int viewangleoffset; - void D_CheckNetGame (void) { int i; - for (i=0 ; i<MAXNETNODES ; i++) { nodeingame[i] = false; @@ -562,53 +380,33 @@ void D_CheckNetGame (void) remoteresend[i] = false; resendto[i] = 0; } - - I_InitNetwork (); if (doomcom->id != DOOMCOM_ID) I_Error ("Doomcom buffer invalid!"); - netbuffer = &doomcom->data; consoleplayer = displayplayer = doomcom->consoleplayer; if (netgame) D_ArbitrateNetStart (); - printf ("startskill %i deathmatch: %i startmap: %i startepisode: %i\n", startskill, deathmatch, startmap, startepisode); - - ticdup = doomcom->ticdup; maxsend = BACKUPTICS/(2*ticdup)-1; if (maxsend<1) maxsend = 1; - for (i=0 ; i<doomcom->numplayers ; i++) playeringame[i] = true; for (i=0 ; i<doomcom->numnodes ; i++) nodeingame[i] = true; - printf ("player %i of %i (%i nodes)\n", consoleplayer+1, doomcom->numplayers, doomcom->numnodes); - } - - - - - - - void D_QuitNetGame (void) { int i, j; - if (debugfile) fclose (debugfile); - if (!netgame || !usergame || consoleplayer == -1 || demoplayback) return; - - netbuffer->player = consoleplayer; netbuffer->numtics = 0; for (i=0 ; i<4 ; i++) @@ -619,19 +417,11 @@ void D_QuitNetGame (void) I_WaitVBL (1); } } - - - - - - int frametics[4]; int frameon; int frameskip[4]; int oldnettics; - extern boolean advancedemo; - void TryRunTics (void) { int i; @@ -642,15 +432,10 @@ void TryRunTics (void) int availabletics; int counts; int numplaying; - - entertic = I_GetTime ()/ticdup; realtics = entertic - oldentertics; oldentertics = entertic; - - NetUpdate (); - lowtic = MAXINT; numplaying = 0; for (i=0 ; i<doomcom->numnodes ; i++) @@ -663,75 +448,56 @@ void TryRunTics (void) } } availabletics = lowtic - gametic/ticdup; - - if (realtics < availabletics-1) counts = realtics+1; else if (realtics < availabletics) counts = realtics; else counts = availabletics; - if (counts < 1) counts = 1; - frameon++; - if (debugfile) fprintf (debugfile, "=======real: %i avail: %i game: %i\n", realtics, availabletics,counts); - if (!demoplayback) { - - for (i=0 ; i<MAXPLAYERS ; i++) if (playeringame[i]) break; if (consoleplayer == i) { - } else { if (nettics[0] <= nettics[nodeforplayer[i]]) { gametime--; - } frameskip[frameon&3] = (oldnettics > nettics[nodeforplayer[i]]); oldnettics = nettics[0]; if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3]) { skiptics = 1; - } } } - - while (lowtic < gametic/ticdup + counts) { NetUpdate (); lowtic = MAXINT; - for (i=0 ; i<doomcom->numnodes ; i++) if (nodeingame[i] && nettics[i] < lowtic) lowtic = nettics[i]; - if (lowtic < gametic/ticdup) I_Error ("TryRunTics: lowtic < gametic"); - - if (I_GetTime ()/ticdup - entertic >= 20) { M_Ticker (); return; } } - - while (counts--) { for (i=0 ; i<ticdup ; i++) @@ -743,14 +509,11 @@ void TryRunTics (void) M_Ticker (); G_Ticker (); gametic++; - - if (i != ticdup-1) { ticcmd_t *cmd; int buf; int j; - buf = (gametic/ticdup)%BACKUPTICS; for (j=0 ; j<MAXPLAYERS ; j++) { diff --git a/src/d_net.h b/src/d_net.h @@ -1,149 +1,48 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_NET__ #define __D_NET__ - #include "d_player.h" - - #ifdef __GNUG__ #pragma interface #endif - - - - - - - - - - #define DOOMCOM_ID 0x12345678l - - #define MAXNETNODES 8 - - - #define BACKUPTICS 12 - typedef enum { CMD_SEND = 1, CMD_GET = 2 - } command_t; - - - - - typedef struct { - unsigned checksum; - byte retransmitfrom; - byte starttic; byte player; byte numtics; ticcmd_t cmds[BACKUPTICS]; - } doomdata_t; - - - - typedef struct { - long id; - - short intnum; - - short command; - short remotenode; - - short datalength; - - - short numnodes; - short ticdup; - short extratics; - short deathmatch; - short savegame; short episode; short map; short skill; - - short consoleplayer; short numplayers; - - - - - - - short angleoffset; - short drone; - - doomdata_t data; - } doomcom_t; - - - - void NetUpdate (void); - - - void D_QuitNetGame (void); - - void TryRunTics (void); - - #endif - - - - - - - diff --git a/src/d_player.h b/src/d_player.h @@ -1,219 +1,84 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_PLAYER__ #define __D_PLAYER__ - - - - - - #include "d_items.h" #include "p_pspr.h" - - - #include "p_mobj.h" - - - - #include "d_ticcmd.h" - #ifdef __GNUG__ #pragma interface #endif - - - - - - - typedef enum { - PST_LIVE, - PST_DEAD, - PST_REBORN - } playerstate_t; - - - - - typedef enum { - CF_NOCLIP = 1, - CF_GODMODE = 2, - CF_NOMOMENTUM = 4 - } cheat_t; - - - - - typedef struct player_s { mobj_t* mo; playerstate_t playerstate; ticcmd_t cmd; - - - - fixed_t viewz; - fixed_t viewheight; - fixed_t deltaviewheight; - fixed_t bob; - - - int health; int armorpoints; - int armortype; - - int powers[NUMPOWERS]; boolean cards[NUMCARDS]; boolean backpack; - - int frags[MAXPLAYERS]; weapontype_t readyweapon; - - weapontype_t pendingweapon; - boolean weaponowned[NUMWEAPONS]; int ammo[NUMAMMO]; int maxammo[NUMAMMO]; - - int attackdown; int usedown; - - - int cheats; - - int refire; - - int killcount; int itemcount; int secretcount; - - char* message; - - int damagecount; int bonuscount; - - mobj_t* attacker; - - int extralight; - - - int fixedcolormap; - - - int colormap; - - pspdef_t psprites[NUMPSPRITES]; - - boolean didsecret; - } player_t; - - - - - - typedef struct { boolean in; - - int skills; int sitems; int ssecret; int stime; int frags[4]; int score; - } wbplayerstruct_t; - typedef struct { int epsd; - - boolean didsecret; - - int last; int next; - int maxkills; int maxitems; int maxsecret; int maxfrags; - - int partime; - - int pnum; - wbplayerstruct_t plyr[MAXPLAYERS]; - } wbstartstruct_t; - - #endif - - - - - diff --git a/src/d_textur.h b/src/d_textur.h @@ -1,51 +1,10 @@ - - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_TEXTUR__ #define __D_TEXTUR__ - #include "doomtype.h" - - - - - - - - typedef struct { byte width; byte height; byte data; } pic_t; - - - - #endif - - - - - diff --git a/src/d_think.h b/src/d_think.h @@ -1,79 +1,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_THINK__ #define __D_THINK__ - - #ifdef __GNUG__ #pragma interface #endif - - - - - - - - - typedef void (*actionf_v)(); typedef void (*actionf_p1)( void* ); typedef void (*actionf_p2)( void*, void* ); - typedef union { actionf_p1 acp1; actionf_v acv; actionf_p2 acp2; - } actionf_t; - - - - - - - - typedef actionf_t think_t; - - - typedef struct thinker_s { struct thinker_s* prev; struct thinker_s* next; think_t function; - } thinker_t; - - - #endif - - - - - diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h @@ -1,38 +1,9 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_TICCMD__ #define __D_TICCMD__ - #include "doomtype.h" - #ifdef __GNUG__ #pragma interface #endif - - - - - typedef struct { char forwardmove; @@ -42,12 +13,4 @@ typedef struct byte chatchar; byte buttons; } ticcmd_t; - - - #endif - - - - - diff --git a/src/doomdata.h b/src/doomdata.h @@ -1,45 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - #ifndef __DOOMDATA__ #define __DOOMDATA__ - - #include "doomtype.h" - - #include "doomdef.h" - - - - - - - - - - - enum { ML_LABEL, @@ -54,18 +16,11 @@ enum ML_REJECT, ML_BLOCKMAP }; - - - typedef struct { short x; short y; } mapvertex_t; - - - - typedef struct { short textureoffset; @@ -73,14 +28,8 @@ typedef struct char toptexture[8]; char bottomtexture[8]; char midtexture[8]; - short sector; } mapsidedef_t; - - - - - typedef struct { short v1; @@ -88,56 +37,17 @@ typedef struct short flags; short special; short tag; - short sidenum[2]; } maplinedef_t; - - - - - - - #define ML_BLOCKING 1 - - #define ML_BLOCKMONSTERS 2 - - - #define ML_TWOSIDED 4 - - - - - - - - - - - #define ML_DONTPEGTOP 8 - - #define ML_DONTPEGBOTTOM 16 - - #define ML_SECRET 32 - - #define ML_SOUNDBLOCK 64 - - #define ML_DONTDRAW 128 - - #define ML_MAPPED 256 - - - - - typedef struct { short floorheight; @@ -148,18 +58,11 @@ typedef struct short special; short tag; } mapsector_t; - - typedef struct { short numsegs; - short firstseg; } mapsubsector_t; - - - - typedef struct { short v1; @@ -169,37 +72,16 @@ typedef struct short side; short offset; } mapseg_t; - - - - - - #define NF_SUBSECTOR 0x8000 - typedef struct { - short x; short y; short dx; short dy; - - - short bbox[2][4]; - - - unsigned short children[2]; - } mapnode_t; - - - - - - typedef struct { short x; @@ -208,15 +90,4 @@ typedef struct short type; short options; } mapthing_t; - - - - - #endif - - - - - - diff --git a/src/doomdef.c b/src/doomdef.c @@ -1,36 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #ifdef __GNUG__ #pragma implementation "doomdef.h" #endif #include "doomdef.h" - - - - - - diff --git a/src/doomdef.h b/src/doomdef.h @@ -1,53 +1,16 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __DOOMDEF__ #define __DOOMDEF__ - #include <stdio.h> #include <string.h> - - - - - enum { VERSION = 110 }; - - - - typedef enum { shareware, registered, commercial, - retail, indetermined - } GameMode_t; - - - typedef enum { doom, @@ -55,75 +18,23 @@ typedef enum pack_tnt, pack_plut, none - } GameMission_t; - - - typedef enum { english, french, german, unknown - } Language_t; - - - - #define RANGECHECK - - - - - - - - #define SNDSERV 1 - - - - - - - - - - - - - #define BASE_WIDTH 320 - - - - - #define SCREEN_MUL 1 #define INV_ASPECT_RATIO 0.625 - - - - #define SCREENWIDTH 320 - #define SCREENHEIGHT 200 - - - - - - #define MAXPLAYERS 4 - - #define TICRATE 35 - - - - typedef enum { GS_LEVEL, @@ -131,19 +42,10 @@ typedef enum GS_FINALE, GS_DEMOSCREEN } gamestate_t; - - - - - - #define MTF_EASY 1 #define MTF_NORMAL 2 #define MTF_HARD 4 - - #define MTF_AMBUSH 8 - typedef enum { sk_baby, @@ -152,13 +54,6 @@ typedef enum sk_hard, sk_nightmare } skill_t; - - - - - - - typedef enum { it_bluecard, @@ -167,16 +62,8 @@ typedef enum it_blueskull, it_yellowskull, it_redskull, - NUMCARDS - } card_t; - - - - - - typedef enum { wp_fist, @@ -188,16 +75,9 @@ typedef enum wp_bfg, wp_chainsaw, wp_supershotgun, - NUMWEAPONS, - - wp_nochange - } weapontype_t; - - - typedef enum { am_clip, @@ -206,11 +86,7 @@ typedef enum am_misl, NUMAMMO, am_noammo - } ammotype_t; - - - typedef enum { pw_invulnerability, @@ -220,33 +96,14 @@ typedef enum pw_allmap, pw_infrared, NUMPOWERS - } powertype_t; - - - - - - - - typedef enum { INVULNTICS = (30*TICRATE), INVISTICS = (60*TICRATE), INFRATICS = (120*TICRATE), IRONTICS = (60*TICRATE) - } powerduration_t; - - - - - - - - - #define KEY_RIGHTARROW 0xae #define KEY_LEFTARROW 0xac #define KEY_UPARROW 0xad @@ -266,73 +123,12 @@ typedef enum #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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #endif - - - - - diff --git a/src/doomstat.c b/src/doomstat.c @@ -1,5 +1,4 @@ #include "doomstat.h" - GameMode_t gamemode = indetermined; GameMission_t gamemission = doom; Language_t language = english; diff --git a/src/doomstat.h b/src/doomstat.h @@ -1,296 +1,83 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - #ifndef __D_STATE__ #define __D_STATE__ - - - #include "doomdata.h" #include "d_net.h" - - #include "d_player.h" - - #ifdef __GNUG__ #pragma interface #endif - - - - - - extern boolean nomonsters; extern boolean respawnparm; extern boolean fastparm; - extern boolean devparm; - - - - - - extern GameMode_t gamemode; extern GameMission_t gamemission; - - extern boolean modifiedgame; - - - - extern Language_t language; - - - - - - - extern skill_t startskill; extern int startepisode; extern int startmap; - extern boolean autostart; - - extern skill_t gameskill; extern int gameepisode; extern int gamemap; - - extern boolean respawnmonsters; - - extern boolean netgame; - - - extern boolean deathmatch; - - - - - - - - - - - - extern int snd_SfxVolume; extern int snd_MusicVolume; - - - - - extern int snd_MusicDevice; extern int snd_SfxDevice; - extern int snd_DesiredMusicDevice; extern int snd_DesiredSfxDevice; - - - - - - - - - extern boolean statusbaractive; - extern boolean automapactive; extern boolean menuactive; extern boolean paused; - - extern boolean viewactive; - extern boolean nodrawers; extern boolean noblit; - extern int viewwindowx; extern int viewwindowy; extern int viewheight; extern int viewwidth; extern int scaledviewwidth; - - - - - - - - extern int viewangleoffset; - - extern int consoleplayer; extern int displayplayer; - - - - - - extern int totalkills; extern int totalitems; extern int totalsecret; - - extern int levelstarttic; extern int leveltime; - - - - - - - extern boolean usergame; - - extern boolean demoplayback; extern boolean demorecording; - - extern boolean singledemo; - - - - - extern gamestate_t gamestate; - - - - - - - - - - - - - - extern int gametic; - - - extern player_t players[MAXPLAYERS]; - - extern boolean playeringame[MAXPLAYERS]; - - - #define MAX_DM_STARTS 10 extern mapthing_t deathmatchstarts[MAX_DM_STARTS]; extern mapthing_t* deathmatch_p; - - extern mapthing_t playerstarts[MAXPLAYERS]; - - - extern wbstartstruct_t wminfo; - - - - extern int maxammo[NUMAMMO]; - - - - - - - - - - extern char basedefault[1024]; extern FILE* debugfile; - - extern boolean precache; - - - - extern gamestate_t wipegamestate; - extern int mouseSensitivity; - - extern boolean singletics; - extern int bodyqueslot; - - - - - - extern int skyflatnum; - - - - - - extern doomcom_t* doomcom; - - extern doomdata_t* netbuffer; - - extern ticcmd_t localcmds[BACKUPTICS]; extern int rndindex; - extern int maketic; extern int nettics[MAXNETNODES]; - extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS]; extern int ticdup; - - - #endif - - - - - diff --git a/src/doomtype.h b/src/doomtype.h @@ -1,12 +1,9 @@ #ifndef __DOOMTYPE__ #define __DOOMTYPE__ - #ifndef __BYTEBOOL__ #define __BYTEBOOL__ typedef enum {false, true} boolean; typedef unsigned char byte; #endif - #include <values.h> - #endif diff --git a/src/dstrings.c b/src/dstrings.c @@ -1,5 +1,4 @@ #include "dstrings.h" - char* endmsg[NUM_QUITMESSAGES+1] = { QUITMSG, "please don't leave, there's more\ndemons to toast!", diff --git a/src/dstrings.h b/src/dstrings.h @@ -1,66 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #ifndef __DSTRINGS__ #define __DSTRINGS__ - - - - - - #ifdef FRENCH #include "d_french.h" #else #include "d_englsh.h" #endif - - #define SAVEGAMENAME "doomsav" - - - - - - - #define DEVMAPS "devmaps" #define DEVDATA "devdata" - - - - - #define NUM_QUITMESSAGES 22 - extern char* endmsg[]; - - #endif - - - - - diff --git a/src/f_finale.c b/src/f_finale.c @@ -1,116 +1,59 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include <ctype.h> - - #include "i_system.h" #include "m_swap.h" #include "z_zone.h" #include "v_video.h" #include "w_wad.h" #include "s_sound.h" - - #include "dstrings.h" #include "sounds.h" - #include "doomstat.h" #include "r_state.h" - - - - - - - - int finalestage; - int finalecount; - #define TEXTSPEED 3 #define TEXTWAIT 250 - char* e1text = E1TEXT; char* e2text = E2TEXT; char* e3text = E3TEXT; char* e4text = E4TEXT; - char* c1text = C1TEXT; char* c2text = C2TEXT; char* c3text = C3TEXT; char* c4text = C4TEXT; char* c5text = C5TEXT; char* c6text = C6TEXT; - char* p1text = P1TEXT; char* p2text = P2TEXT; char* p3text = P3TEXT; char* p4text = P4TEXT; char* p5text = P5TEXT; char* p6text = P6TEXT; - char* t1text = T1TEXT; char* t2text = T2TEXT; char* t3text = T3TEXT; char* t4text = T4TEXT; char* t5text = T5TEXT; char* t6text = T6TEXT; - char* finaletext; char* finaleflat; - void F_StartCast (void); void F_CastTicker (void); boolean F_CastResponder (event_t *ev); void F_CastDrawer (void); - - - - void F_StartFinale (void) { gameaction = ga_nothing; gamestate = GS_FINALE; viewactive = false; automapactive = false; - - - - switch ( gamemode ) { - - case shareware: case registered: case retail: { S_ChangeMusic(mus_victor, true); - switch (gameepisode) { case 1: @@ -130,17 +73,13 @@ void F_StartFinale (void) finaletext = e4text; break; default: - break; } break; } - - case commercial: { S_ChangeMusic(mus_read_m, true); - switch (gamemap) { case 6: @@ -168,53 +107,34 @@ void F_StartFinale (void) finaletext = c6text; break; default: - break; } break; } - - - default: S_ChangeMusic(mus_read_m, true); finaleflat = "F_SKY1"; finaletext = c1text; break; } - finalestage = 0; finalecount = 0; - } - - - boolean F_Responder (event_t *event) { if (finalestage == 2) return F_CastResponder (event); - return false; } - - - - - void F_Ticker (void) { int i; - - if ( (gamemode == commercial) && ( finalecount > 50) ) { - for (i=0 ; i<MAXPLAYERS ; i++) if (players[i].cmd.buttons) break; - if (i < MAXPLAYERS) { if (gamemap == 30) @@ -223,19 +143,14 @@ void F_Ticker (void) gameaction = ga_worlddone; } } - - finalecount++; - if (finalestage == 2) { F_CastTicker (); return; } - if ( gamemode == commercial) return; - if (!finalestage && finalecount>strlen (finaletext)*TEXTSPEED + TEXTWAIT) { finalecount = 0; @@ -245,33 +160,20 @@ void F_Ticker (void) S_StartMusic (mus_bunny); } } - - - - - - - #include "hu_stuff.h" extern patch_t *hu_font[HU_FONTSIZE]; - - void F_TextWrite (void) { byte* src; byte* dest; - int x,y,w; int count; char* ch; int c; int cx; int cy; - - src = W_CacheLumpName ( finaleflat , PU_CACHE); dest = screens[0]; - for (y=0 ; y<SCREENHEIGHT ; y++) { for (x=0 ; x<SCREENWIDTH/64 ; x++) @@ -285,14 +187,10 @@ void F_TextWrite (void) dest += (SCREENWIDTH&63); } } - V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); - - cx = 10; cy = 10; ch = finaletext; - count = (finalecount - 10)/TEXTSPEED; if (count < 0) count = 0; @@ -307,34 +205,24 @@ void F_TextWrite (void) cy += 11; continue; } - c = toupper(c) - HU_FONTSTART; if (c < 0 || c> HU_FONTSIZE) { cx += 4; continue; } - w = SHORT (hu_font[c]->width); if (cx+w > SCREENWIDTH) break; V_DrawPatch(cx, cy, 0, hu_font[c]); cx+=w; } - } - - - - - - typedef struct { char *name; mobjtype_t type; } castinfo_t; - castinfo_t castorder[] = { {CC_ZOMBIE, MT_POSSESSED}, {CC_SHOTGUN, MT_SHOTGUY}, @@ -353,10 +241,8 @@ castinfo_t castorder[] = { {CC_SPIDER, MT_SPIDER}, {CC_CYBER, MT_CYBORG}, {CC_HERO, MT_PLAYER}, - {NULL,0} }; - int castnum; int casttics; state_t* caststate; @@ -364,14 +250,7 @@ boolean castdeath; int castframes; int castonmelee; boolean castattacking; - - - - - extern gamestate_t wipegamestate; - - void F_StartCast (void) { wipegamestate = -1; @@ -385,22 +264,14 @@ void F_StartCast (void) castattacking = false; S_ChangeMusic(mus_evil, true); } - - - - - void F_CastTicker (void) { int st; int sfx; - if (--casttics > 0) return; - if (caststate->tics == -1 || caststate->nextstate == S_NULL) { - castnum++; castdeath = false; if (castorder[castnum].name == NULL) @@ -412,14 +283,11 @@ void F_CastTicker (void) } else { - if (caststate == &states[S_PLAY_ATK1]) goto stopattack; st = caststate->nextstate; caststate = &states[st]; castframes++; - - switch (st) { case S_PLAY_ATK1: sfx = sfx_dshtgn; break; @@ -450,14 +318,11 @@ void F_CastTicker (void) case S_PAIN_ATK3: sfx = sfx_sklatk; break; default: sfx = 0; break; } - if (sfx) S_StartSound (NULL, sfx); } - if (castframes == 12) { - castattacking = true; if (castonmelee) caststate=&states[mobjinfo[castorder[castnum].type].meleestate]; @@ -474,7 +339,6 @@ void F_CastTicker (void) &states[mobjinfo[castorder[castnum].type].missilestate]; } } - if (castattacking) { if (castframes == 24 @@ -486,26 +350,16 @@ void F_CastTicker (void) caststate = &states[mobjinfo[castorder[castnum].type].seestate]; } } - casttics = caststate->tics; if (casttics == -1) casttics = 15; } - - - - - - boolean F_CastResponder (event_t* ev) { if (ev->type != ev_keydown) return false; - if (castdeath) return true; - - castdeath = true; caststate = &states[mobjinfo[castorder[castnum].type].deathstate]; casttics = caststate->tics; @@ -513,11 +367,8 @@ boolean F_CastResponder (event_t* ev) castattacking = false; if (mobjinfo[castorder[castnum].type].deathsound) S_StartSound (NULL, mobjinfo[castorder[castnum].type].deathsound); - return true; } - - void F_CastPrint (char* text) { char* ch; @@ -525,11 +376,8 @@ void F_CastPrint (char* text) int cx; int w; int width; - - ch = text; width = 0; - while (ch) { c = *ch++; @@ -541,12 +389,9 @@ void F_CastPrint (char* text) width += 4; continue; } - w = SHORT (hu_font[c]->width); width += w; } - - cx = 160-width/2; ch = text; while (ch) @@ -560,20 +405,12 @@ void F_CastPrint (char* text) cx += 4; continue; } - w = SHORT (hu_font[c]->width); V_DrawPatch(cx, 180, 0, hu_font[c]); cx+=w; } - } - - - - - void V_DrawPatchFlipped (int x, int y, int scrn, patch_t *patch); - void F_CastDrawer (void) { spritedef_t* sprdef; @@ -581,29 +418,18 @@ void F_CastDrawer (void) int lump; boolean flip; patch_t* patch; - - V_DrawPatch (0,0,0, W_CacheLumpName ("BOSSBACK", PU_CACHE)); - F_CastPrint (castorder[castnum].name); - - sprdef = &sprites[caststate->sprite]; sprframe = &sprdef->spriteframes[ caststate->frame & FF_FRAMEMASK]; lump = sprframe->lump[0]; flip = (boolean)sprframe->flip[0]; - patch = W_CacheLumpNum (lump+firstspritelump, PU_CACHE); if (flip) V_DrawPatchFlipped (160,170,0,patch); else V_DrawPatch (160,170,0,patch); } - - - - - void F_DrawPatchCol ( int x, @@ -615,17 +441,13 @@ F_DrawPatchCol byte* dest; byte* desttop; int count; - column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); desttop = screens[0]+x; - - while (column->topdelta != 0xff ) { source = (byte *)column + 3; dest = desttop + column->topdelta*SCREENWIDTH; count = column->length; - while (count--) { *dest = *source++; @@ -634,11 +456,6 @@ F_DrawPatchCol column = (column_t *)( (byte *)column + column->length + 4 ); } } - - - - - void F_BunnyScroll (void) { int scrolled; @@ -648,18 +465,14 @@ void F_BunnyScroll (void) char name[10]; int stage; static int laststage; - p1 = W_CacheLumpName ("PFUB2", PU_LEVEL); p2 = W_CacheLumpName ("PFUB1", PU_LEVEL); - V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); - scrolled = 320 - (finalecount-230)/2; if (scrolled > 320) scrolled = 320; if (scrolled < 0) scrolled = 0; - for ( x=0 ; x<SCREENWIDTH ; x++) { if (x+scrolled < 320) @@ -667,7 +480,6 @@ void F_BunnyScroll (void) else F_DrawPatchCol (x, p2, x+scrolled - 320); } - if (finalecount < 1130) return; if (finalecount < 1180) @@ -677,7 +489,6 @@ void F_BunnyScroll (void) laststage = 0; return; } - stage = (finalecount-1180) / 5; if (stage > 6) stage = 6; @@ -686,15 +497,9 @@ void F_BunnyScroll (void) S_StartSound (NULL, sfx_pistol); laststage = stage; } - sprintf (name,"END%i",stage); V_DrawPatch ((SCREENWIDTH-13*8)/2, (SCREENHEIGHT-8*8)/2,0, W_CacheLumpName (name,PU_CACHE)); } - - - - - void F_Drawer (void) { if (finalestage == 2) @@ -702,7 +507,6 @@ void F_Drawer (void) F_CastDrawer (); return; } - if (!finalestage) F_TextWrite (); else @@ -730,7 +534,4 @@ void F_Drawer (void) break; } } - } - - diff --git a/src/f_finale.h b/src/f_finale.h @@ -1,53 +1,9 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __F_FINALE__ #define __F_FINALE__ - - #include "doomtype.h" #include "d_event.h" - - - - - boolean F_Responder (event_t* ev); - - void F_Ticker (void); - - void F_Drawer (void); - - void F_StartFinale (void); - - - - #endif - - - - - diff --git a/src/f_wipe.c b/src/f_wipe.c @@ -1,51 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "z_zone.h" #include "i_video.h" #include "v_video.h" #include "m_random.h" - #include "doomdef.h" - #include "f_wipe.h" - - - - - - static boolean go = 0; - static byte* wipe_scr_start; static byte* wipe_scr_end; static byte* wipe_scr; - - void wipe_shittyColMajorXform ( short* array, @@ -55,19 +17,13 @@ wipe_shittyColMajorXform int x; int y; short* dest; - dest = (short*) Z_Malloc(width*height*2, PU_STATIC, 0); - for(y=0;y<height;y++) for(x=0;x<width;x++) dest[x*height+y] = array[y*width+x]; - memcpy(array, dest, width*height*2); - Z_Free(dest); - } - int wipe_initColorXForm ( int width, @@ -77,7 +33,6 @@ wipe_initColorXForm memcpy(wipe_scr, wipe_scr_start, width*height); return 0; } - int wipe_doColorXForm ( int width, @@ -88,11 +43,9 @@ wipe_doColorXForm byte* w; byte* e; int newval; - changed = false; w = wipe_scr; e = wipe_scr_end; - while (w!=wipe_scr+width*height) { if (*w != *e) @@ -119,11 +72,8 @@ wipe_doColorXForm w++; e++; } - return !changed; - } - int wipe_exitColorXForm ( int width, @@ -132,10 +82,7 @@ wipe_exitColorXForm { return 0; } - - static int* y; - int wipe_initMelt ( int width, @@ -143,17 +90,9 @@ wipe_initMelt int ticks ) { int i, r; - - memcpy(wipe_scr, wipe_scr_start, width*height); - - - wipe_shittyColMajorXform((short*)wipe_scr_start, width/2, height); wipe_shittyColMajorXform((short*)wipe_scr_end, width/2, height); - - - y = (int *) Z_Malloc(width*sizeof(int), PU_STATIC, 0); y[0] = -(M_Random()%16); for (i=1;i<width;i++) @@ -163,10 +102,8 @@ wipe_initMelt if (y[i] > 0) y[i] = 0; else if (y[i] == -16) y[i] = -15; } - return 0; } - int wipe_doMelt ( int width, @@ -177,13 +114,10 @@ wipe_doMelt int j; int dy; int idx; - short* s; short* d; boolean done = true; - width/=2; - while (ticks--) { for (i=0;i<width;i++) @@ -217,11 +151,8 @@ wipe_doMelt } } } - return done; - } - int wipe_exitMelt ( int width, @@ -231,7 +162,6 @@ wipe_exitMelt Z_Free(y); return 0; } - int wipe_StartScreen ( int x, @@ -243,7 +173,6 @@ wipe_StartScreen I_ReadScreen(wipe_scr_start); return 0; } - int wipe_EndScreen ( int x, @@ -256,7 +185,6 @@ wipe_EndScreen V_DrawBlock(x, y, 0, width, height, wipe_scr_start); return 0; } - int wipe_ScreenWipe ( int wipeno, @@ -272,30 +200,19 @@ wipe_ScreenWipe wipe_initColorXForm, wipe_doColorXForm, wipe_exitColorXForm, wipe_initMelt, wipe_doMelt, wipe_exitMelt }; - void V_MarkRect(int, int, int, int); - - if (!go) { go = 1; - wipe_scr = screens[0]; (*wipes[wipeno*3])(width, height, ticks); } - - V_MarkRect(0, 0, width, height); rc = (*wipes[wipeno*3+1])(width, height, ticks); - - - if (rc) { go = 0; (*wipes[wipeno*3+2])(width, height, ticks); } - return !go; - } diff --git a/src/f_wipe.h b/src/f_wipe.h @@ -1,59 +1,23 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __F_WIPE_H__ #define __F_WIPE_H__ - - - - - enum { - wipe_ColorXForm, - - wipe_Melt, - wipe_NUMWIPES }; - int wipe_StartScreen ( int x, int y, int width, int height ); - - int wipe_EndScreen ( int x, int y, int width, int height ); - - int wipe_ScreenWipe ( int wipeno, @@ -62,10 +26,4 @@ wipe_ScreenWipe int width, int height, int ticks ); - #endif - - - - - diff --git a/src/g_game.c b/src/g_game.c @@ -1,33 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include <string.h> #include <stdlib.h> - #include "doomdef.h" #include "doomstat.h" - #include "z_zone.h" #include "f_finale.h" #include "m_argv.h" @@ -35,53 +9,31 @@ #include "m_menu.h" #include "m_random.h" #include "i_system.h" - #include "p_setup.h" #include "p_saveg.h" #include "p_tick.h" - #include "d_main.h" - #include "wi_stuff.h" #include "hu_stuff.h" #include "st_stuff.h" #include "am_map.h" - - #include "v_video.h" - #include "w_wad.h" - #include "p_local.h" - #include "s_sound.h" - - #include "dstrings.h" #include "sounds.h" - - #include "r_data.h" #include "r_sky.h" - - - #include "g_game.h" - - #define SAVEGAMESIZE 0x2c000 #define SAVESTRINGSIZE 24 - - - boolean G_CheckDemoStatus (void); void G_ReadDemoTiccmd (ticcmd_t* cmd); void G_WriteDemoTiccmd (ticcmd_t* cmd); void G_PlayerReborn (int player); void G_InitNew (skill_t skill, int episode, int map); - void G_DoReborn (int playernum); - void G_DoLoadLevel (void); void G_DoNewGame (void); void G_DoLoadGame (void); @@ -90,38 +42,30 @@ void G_DoCompleted (void); void G_DoVictory (void); void G_DoWorldDone (void); void G_DoSaveGame (void); - - gameaction_t gameaction; gamestate_t gamestate; skill_t gameskill; boolean respawnmonsters; int gameepisode; int gamemap; - boolean paused; boolean sendpause; boolean sendsave; boolean usergame; - boolean timingdemo; boolean nodrawers; boolean noblit; int starttime; - boolean viewactive; - boolean deathmatch; boolean netgame; boolean playeringame[MAXPLAYERS]; player_t players[MAXPLAYERS]; - int consoleplayer; int displayplayer; int gametic; int levelstarttic; int totalkills, totalitems, totalsecret; - char demoname[32]; boolean demorecording; boolean demoplayback; @@ -130,22 +74,12 @@ byte* demobuffer; byte* demo_p; byte* demoend; boolean singledemo; - boolean precache = true; - wbstartstruct_t wminfo; - short consistancy[MAXPLAYERS][BACKUPTICS]; - byte* savebuffer; - - - - - int key_right; int key_left; - int key_up; int key_down; int key_strafeleft; @@ -154,84 +88,50 @@ int key_fire; int key_use; int key_strafe; int key_speed; - int mousebfire; int mousebstrafe; int mousebforward; - int joybfire; int joybstrafe; int joybuse; int joybspeed; - - - #define MAXPLMOVE (forwardmove[1]) - #define TURBOTHRESHOLD 0x32 - fixed_t forwardmove[2] = {0x19, 0x32}; fixed_t sidemove[2] = {0x18, 0x28}; fixed_t angleturn[3] = {640, 1280, 320}; - #define SLOWTURNTICS 6 - #define NUMKEYS 256 - boolean gamekeydown[NUMKEYS]; int turnheld; - boolean mousearray[4]; boolean* mousebuttons = &mousearray[1]; - - int mousex; int mousey; - int dclicktime; int dclickstate; int dclicks; int dclicktime2; int dclickstate2; int dclicks2; - - int joyxmove; int joyymove; boolean joyarray[5]; boolean* joybuttons = &joyarray[1]; - int savegameslot; char savedescription[32]; - - #define BODYQUESIZE 32 - mobj_t* bodyque[BODYQUESIZE]; int bodyqueslot; - void* statcopy; - - - int G_CmdChecksum (ticcmd_t* cmd) { int i; int sum = 0; - for (i=0 ; i< sizeof(*cmd)/4 - 1 ; i++) sum += ((int *)cmd)[i]; - return sum; } - - - - - - - - void G_BuildTiccmd (ticcmd_t* cmd) { int i; @@ -241,24 +141,15 @@ void G_BuildTiccmd (ticcmd_t* cmd) int tspeed; int forward; int side; - ticcmd_t* base; - base = I_BaseTiccmd (); memcpy (cmd,base,sizeof(*cmd)); - cmd->consistancy = consistancy[consoleplayer][maketic%BACKUPTICS]; - - strafe = gamekeydown[key_strafe] || mousebuttons[mousebstrafe] || joybuttons[joybstrafe]; speed = gamekeydown[key_speed] || joybuttons[joybspeed]; - forward = side = 0; - - - if (joyxmove < 0 || joyxmove > 0 || gamekeydown[key_right] @@ -266,30 +157,24 @@ void G_BuildTiccmd (ticcmd_t* cmd) turnheld += ticdup; else turnheld = 0; - if (turnheld < SLOWTURNTICS) tspeed = 2; else tspeed = speed; - - if (strafe) { if (gamekeydown[key_right]) { - side += sidemove[speed]; } if (gamekeydown[key_left]) { - side -= sidemove[speed]; } if (joyxmove > 0) side += sidemove[speed]; if (joyxmove < 0) side -= sidemove[speed]; - } else { @@ -302,15 +187,12 @@ void G_BuildTiccmd (ticcmd_t* cmd) if (joyxmove < 0) cmd->angleturn += angleturn[tspeed]; } - if (gamekeydown[key_up]) { - forward += forwardmove[speed]; } if (gamekeydown[key_down]) { - forward -= forwardmove[speed]; } if (joyymove < 0) @@ -321,22 +203,15 @@ void G_BuildTiccmd (ticcmd_t* cmd) side += sidemove[speed]; if (gamekeydown[key_strafeleft]) side -= sidemove[speed]; - - cmd->chatchar = HU_dequeueChatChar(); - if (gamekeydown[key_fire] || mousebuttons[mousebfire] || joybuttons[joybfire]) cmd->buttons |= BT_ATTACK; - if (gamekeydown[key_use] || joybuttons[joybuse] ) { cmd->buttons |= BT_USE; - dclicks = 0; } - - for (i=0 ; i<NUMWEAPONS-1 ; i++) if (gamekeydown['1'+i]) { @@ -344,12 +219,8 @@ void G_BuildTiccmd (ticcmd_t* cmd) cmd->buttons |= i<<BT_WEAPONSHIFT; break; } - - if (mousebuttons[mousebforward]) forward += forwardmove[speed]; - - if (mousebuttons[mousebforward] != dclickstate && dclicktime > 1 ) { dclickstate = mousebuttons[mousebforward]; @@ -372,8 +243,6 @@ void G_BuildTiccmd (ticcmd_t* cmd) dclickstate = 0; } } - - bstrafe = mousebuttons[mousebstrafe] || joybuttons[joybstrafe]; @@ -399,15 +268,12 @@ void G_BuildTiccmd (ticcmd_t* cmd) dclickstate2 = 0; } } - forward += mousey; if (strafe) side += mousex*2; else cmd->angleturn -= mousex*0x8; - mousex = mousey = 0; - if (forward > MAXPLMOVE) forward = MAXPLMOVE; else if (forward < -MAXPLMOVE) @@ -416,43 +282,24 @@ void G_BuildTiccmd (ticcmd_t* cmd) side = MAXPLMOVE; else if (side < -MAXPLMOVE) side = -MAXPLMOVE; - cmd->forwardmove += forward; cmd->sidemove += side; - - if (sendpause) { sendpause = false; cmd->buttons = BT_SPECIAL | BTS_PAUSE; } - if (sendsave) { sendsave = false; cmd->buttons = BT_SPECIAL | BTS_SAVEGAME | (savegameslot<<BTS_SAVESHIFT); } } - - - - - extern gamestate_t wipegamestate; - void G_DoLoadLevel (void) { int i; - - - - - - skyflatnum = R_FlatNumForName ( SKYFLATNAME ); - - - if ( (gamemode == commercial) || ( gamemode == pack_tnt ) || ( gamemode == pack_plut ) ) @@ -464,28 +311,21 @@ void G_DoLoadLevel (void) if (gamemap < 21) skytexture = R_TextureNumForName ("SKY2"); } - levelstarttic = gametic; - if (wipegamestate == GS_LEVEL) wipegamestate = -1; - gamestate = GS_LEVEL; - for (i=0 ; i<MAXPLAYERS ; i++) { if (playeringame[i] && players[i].playerstate == PST_DEAD) players[i].playerstate = PST_REBORN; memset (players[i].frags,0,sizeof(players[i].frags)); } - P_SetupLevel (gameepisode, gamemap, 0, gameskill); displayplayer = consoleplayer; starttime = I_GetTime (); gameaction = ga_nothing; Z_CheckHeap (); - - memset (gamekeydown, 0, sizeof(gamekeydown)); joyxmove = joyymove = 0; mousex = mousey = 0; @@ -493,19 +333,11 @@ void G_DoLoadLevel (void) memset (mousebuttons, 0, sizeof(mousebuttons)); memset (joybuttons, 0, sizeof(joybuttons)); } - - - - - - boolean G_Responder (event_t* ev) { - if (gamestate == GS_LEVEL && ev->type == ev_keydown && ev->data1 == KEY_F12 && (singledemo || !deathmatch) ) { - do { displayplayer++; @@ -514,8 +346,6 @@ boolean G_Responder (event_t* ev) } while (!playeringame[displayplayer] && displayplayer != consoleplayer); return true; } - - if (gameaction == ga_nothing && !singledemo && (demoplayback || gamestate == GS_DEMOSCREEN) ) @@ -529,7 +359,6 @@ boolean G_Responder (event_t* ev) } return false; } - if (gamestate == GS_LEVEL) { #if 0 @@ -546,13 +375,11 @@ boolean G_Responder (event_t* ev) if (AM_Responder (ev)) return true; } - if (gamestate == GS_FINALE) { if (F_Responder (ev)) return true; } - switch (ev->type) { case ev_keydown: @@ -564,12 +391,10 @@ boolean G_Responder (event_t* ev) if (ev->data1 <NUMKEYS) gamekeydown[ev->data1] = true; return true; - case ev_keyup: if (ev->data1 <NUMKEYS) gamekeydown[ev->data1] = false; return false; - case ev_mouse: mousebuttons[0] = ev->data1 & 1; mousebuttons[1] = ev->data1 & 2; @@ -577,7 +402,6 @@ boolean G_Responder (event_t* ev) mousex = ev->data2*(mouseSensitivity+5)/10; mousey = ev->data3*(mouseSensitivity+5)/10; return true; - case ev_joystick: joybuttons[0] = ev->data1 & 1; joybuttons[1] = ev->data1 & 2; @@ -586,32 +410,19 @@ boolean G_Responder (event_t* ev) joyxmove = ev->data2; joyymove = ev->data3; return true; - default: break; } - return false; } - - - - - - - void G_Ticker (void) { int i; int buf; ticcmd_t* cmd; - - for (i=0 ; i<MAXPLAYERS ; i++) if (playeringame[i] && players[i].playerstate == PST_REBORN) G_DoReborn (i); - - while (gameaction != ga_nothing) { switch (gameaction) @@ -648,25 +459,17 @@ void G_Ticker (void) break; } } - - - buf = (gametic/ticdup)%BACKUPTICS; - for (i=0 ; i<MAXPLAYERS ; i++) { if (playeringame[i]) { cmd = &players[i].cmd; - memcpy (cmd, &netcmds[i][buf], sizeof(ticcmd_t)); - if (demoplayback) G_ReadDemoTiccmd (cmd); if (demorecording) G_WriteDemoTiccmd (cmd); - - if (cmd->forwardmove > TURBOTHRESHOLD && !(gametic&31) && ((gametic>>5)&3) == i ) { @@ -675,7 +478,6 @@ void G_Ticker (void) sprintf (turbomessage, "%s is turbo!",player_names[i]); players[consoleplayer].message = turbomessage; } - if (netgame && !netdemo && !(gametic%ticdup) ) { if (gametic > BACKUPTICS @@ -691,8 +493,6 @@ void G_Ticker (void) } } } - - for (i=0 ; i<MAXPLAYERS ; i++) { if (playeringame[i]) @@ -708,7 +508,6 @@ void G_Ticker (void) else S_ResumeSound (); break; - case BTS_SAVEGAME: if (!savedescription[0]) strcpy (savedescription, "NET GAME"); @@ -720,8 +519,6 @@ void G_Ticker (void) } } } - - switch (gamestate) { case GS_LEVEL: @@ -730,56 +527,27 @@ void G_Ticker (void) AM_Ticker (); HU_Ticker (); break; - case GS_INTERMISSION: WI_Ticker (); break; - case GS_FINALE: F_Ticker (); break; - case GS_DEMOSCREEN: D_PageTicker (); break; } } - - - - - - - - - - - - void G_InitPlayer (int player) { player_t* p; - - p = &players[player]; - - G_PlayerReborn (player); - } - - - - - - - void G_PlayerFinishLevel (int player) { player_t* p; - p = &players[player]; - memset (p->powers, 0, sizeof (p->powers)); memset (p->cards, 0, sizeof (p->cards)); p->mo->flags &= ~MF_SHADOW; @@ -788,13 +556,6 @@ void G_PlayerFinishLevel (int player) p->damagecount = 0; p->bonuscount = 0; } - - - - - - - void G_PlayerReborn (int player) { player_t* p; @@ -803,20 +564,16 @@ void G_PlayerReborn (int player) int killcount; int itemcount; int secretcount; - memcpy (frags,players[player].frags,sizeof(frags)); killcount = players[player].killcount; itemcount = players[player].itemcount; secretcount = players[player].secretcount; - p = &players[player]; memset (p, 0, sizeof(*p)); - memcpy (players[player].frags, frags, sizeof(players[player].frags)); players[player].killcount = killcount; players[player].itemcount = itemcount; players[player].secretcount = secretcount; - p->usedown = p->attackdown = true; p->playerstate = PST_LIVE; p->health = MAXHEALTH; @@ -824,20 +581,10 @@ void G_PlayerReborn (int player) p->weaponowned[wp_fist] = true; p->weaponowned[wp_pistol] = true; p->ammo[am_clip] = 50; - for (i=0 ; i<NUMAMMO ; i++) p->maxammo[i] = maxammo[i]; - } - - - - - - - void P_SpawnPlayer (mapthing_t* mthing); - boolean G_CheckSpot ( int playernum, @@ -849,58 +596,38 @@ G_CheckSpot unsigned an; mobj_t* mo; int i; - if (!players[playernum].mo) { - for (i=0 ; i<playernum ; i++) if (players[i].mo->x == mthing->x << FRACBITS && players[i].mo->y == mthing->y << FRACBITS) return false; return true; } - x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; - if (!P_CheckPosition (players[playernum].mo, x, y) ) return false; - - if (bodyqueslot >= BODYQUESIZE) P_RemoveMobj (bodyque[bodyqueslot%BODYQUESIZE]); bodyque[bodyqueslot%BODYQUESIZE] = players[playernum].mo; bodyqueslot++; - - ss = R_PointInSubsector (x,y); an = ( ANG45 * (mthing->angle/45) ) >> ANGLETOFINESHIFT; - mo = P_SpawnMobj (x+20*finecosine[an], y+20*finesine[an] , ss->sector->floorheight , MT_TFOG); - if (players[consoleplayer].viewz != 1) S_StartSound (mo, sfx_telept); - return true; } - - - - - - - void G_DeathMatchSpawnPlayer (int playernum) { int i,j; int selections; - selections = deathmatch_p - deathmatchstarts; if (selections < 4) I_Error ("Only %i deathmatch spots, 4 required", selections); - for (j=0 ; j<20 ; j++) { i = P_Random() % selections; @@ -911,44 +638,28 @@ void G_DeathMatchSpawnPlayer (int playernum) return; } } - - P_SpawnPlayer (&playerstarts[playernum]); } - - - - void G_DoReborn (int playernum) { int i; - if (!netgame) { - gameaction = ga_loadlevel; } else { - - - players[playernum].mo->player = NULL; - - if (deathmatch) { G_DeathMatchSpawnPlayer (playernum); return; } - if (G_CheckSpot (playernum, &playerstarts[playernum]) ) { P_SpawnPlayer (&playerstarts[playernum]); return; } - - for (i=0 ; i<MAXPLAYERS ; i++) { if (G_CheckSpot (playernum, &playerstarts[i]) ) @@ -958,21 +669,14 @@ void G_DoReborn (int playernum) playerstarts[i].type = i+1; return; } - } P_SpawnPlayer (&playerstarts[playernum]); } } - - void G_ScreenShot (void) { gameaction = ga_screenshot; } - - - - int pars[4][10] = { {0}, @@ -980,8 +684,6 @@ int pars[4][10] = {0,90,90,90,120,90,360,240,30,170}, {0,90,45,90,150,90,90,165,30,135} }; - - int cpars[32] = { 30,90,120,120,90,150,120,120,270,90, @@ -989,24 +691,15 @@ int cpars[32] = 240,150,180,150,150,300,330,420,300,180, 120,30 }; - - - - - boolean secretexit; extern char* pagename; - void G_ExitLevel (void) { secretexit = false; gameaction = ga_completed; } - - void G_SecretExitLevel (void) { - if ( (gamemode == commercial) && (W_CheckNumForName("map31")<0)) secretexit = false; @@ -1014,20 +707,15 @@ void G_SecretExitLevel (void) secretexit = true; gameaction = ga_completed; } - void G_DoCompleted (void) { int i; - gameaction = ga_nothing; - for (i=0 ; i<MAXPLAYERS ; i++) if (playeringame[i]) G_PlayerFinishLevel (i); - if (automapactive) AM_Stop (); - if ( gamemode != commercial) switch(gamemap) { @@ -1039,31 +727,21 @@ void G_DoCompleted (void) players[i].didsecret = true; break; } - - if ( (gamemap == 8) && (gamemode != commercial) ) { - gameaction = ga_victory; return; } - if ( (gamemap == 9) && (gamemode != commercial) ) { - for (i=0 ; i<MAXPLAYERS ; i++) players[i].didsecret = true; } - - - wminfo.didsecret = players[consoleplayer].didsecret; wminfo.epsd = gameepisode -1; wminfo.last = gamemap -1; - - if ( gamemode == commercial) { if (secretexit) @@ -1086,7 +764,6 @@ void G_DoCompleted (void) wminfo.next = 8; else if (gamemap == 9) { - switch (gameepisode) { case 1: @@ -1106,7 +783,6 @@ void G_DoCompleted (void) else wminfo.next = gamemap; } - wminfo.maxkills = totalkills; wminfo.maxitems = totalitems; wminfo.maxsecret = totalsecret; @@ -1116,7 +792,6 @@ void G_DoCompleted (void) else wminfo.partime = 35*pars[gameepisode][gamemap]; wminfo.pnum = consoleplayer; - for (i=0 ; i<MAXPLAYERS ; i++) { wminfo.plyr[i].in = playeringame[i]; @@ -1127,28 +802,18 @@ void G_DoCompleted (void) memcpy (wminfo.plyr[i].frags, players[i].frags , sizeof(wminfo.plyr[i].frags)); } - gamestate = GS_INTERMISSION; viewactive = false; automapactive = false; - if (statcopy) memcpy (statcopy, &wminfo, sizeof(wminfo)); - WI_Start (&wminfo); } - - - - - void G_WorldDone (void) { gameaction = ga_worlddone; - if (secretexit) players[consoleplayer].didsecret = true; - if ( gamemode == commercial ) { switch (gamemap) @@ -1166,7 +831,6 @@ void G_WorldDone (void) } } } - void G_DoWorldDone (void) { gamestate = GS_LEVEL; @@ -1175,86 +839,50 @@ void G_DoWorldDone (void) gameaction = ga_nothing; viewactive = true; } - - - - - - - extern boolean setsizeneeded; void R_ExecuteSetViewSize (void); - char savename[256]; - void G_LoadGame (char* name) { strcpy (savename, name); gameaction = ga_loadgame; } - #define VERSIONSIZE 16 - - void G_DoLoadGame (void) { int length; int i; int a,b,c; char vcheck[VERSIONSIZE]; - gameaction = ga_nothing; - length = M_ReadFile (savename, &savebuffer); save_p = savebuffer + SAVESTRINGSIZE; - - memset (vcheck,0,sizeof(vcheck)); sprintf (vcheck,"version %i",VERSION); if (strcmp (save_p, vcheck)) return; save_p += VERSIONSIZE; - gameskill = *save_p++; gameepisode = *save_p++; gamemap = *save_p++; for (i=0 ; i<MAXPLAYERS ; i++) playeringame[i] = *save_p++; - - G_InitNew (gameskill, gameepisode, gamemap); - - a = *save_p++; b = *save_p++; c = *save_p++; leveltime = (a<<16) + (b<<8) + c; - - P_UnArchivePlayers (); P_UnArchiveWorld (); P_UnArchiveThinkers (); P_UnArchiveSpecials (); - if (*save_p != 0x1d) I_Error ("Bad savegame"); - - Z_Free (savebuffer); - if (setsizeneeded) R_ExecuteSetViewSize (); - - R_FillBackScreen (); } - - - - - - - void G_SaveGame ( int slot, @@ -1264,7 +892,6 @@ G_SaveGame strcpy (savedescription, description); sendsave = true; } - void G_DoSaveGame (void) { char name[100]; @@ -1272,22 +899,18 @@ void G_DoSaveGame (void) char* description; int length; int i; - if (M_CheckParm("-cdrom")) sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",savegameslot); else sprintf (name,SAVEGAMENAME"%d.dsg",savegameslot); description = savedescription; - save_p = savebuffer = screens[1]+0x4000; - memcpy (save_p, description, SAVESTRINGSIZE); save_p += SAVESTRINGSIZE; memset (name2,0,sizeof(name2)); sprintf (name2,"version %i",VERSION); memcpy (save_p, name2, VERSIONSIZE); save_p += VERSIONSIZE; - *save_p++ = gameskill; *save_p++ = gameepisode; *save_p++ = gamemap; @@ -1296,37 +919,23 @@ void G_DoSaveGame (void) *save_p++ = leveltime>>16; *save_p++ = leveltime>>8; *save_p++ = leveltime; - P_ArchivePlayers (); P_ArchiveWorld (); P_ArchiveThinkers (); P_ArchiveSpecials (); - *save_p++ = 0x1d; - length = save_p - savebuffer; if (length > SAVEGAMESIZE) I_Error ("Savegame buffer overrun"); M_WriteFile (name, savebuffer, length); gameaction = ga_nothing; savedescription[0] = 0; - players[consoleplayer].message = GGSAVED; - - R_FillBackScreen (); } - - - - - - - skill_t d_skill; int d_episode; int d_map; - void G_DeferedInitNew ( skill_t skill, @@ -1338,8 +947,6 @@ G_DeferedInitNew d_map = map; gameaction = ga_newgame; } - - void G_DoNewGame (void) { demoplayback = false; @@ -1354,11 +961,7 @@ void G_DoNewGame (void) G_InitNew (d_skill, d_episode, d_map); gameaction = ga_nothing; } - - extern int skytexture; - - void G_InitNew ( skill_t skill, @@ -1366,24 +969,15 @@ G_InitNew int map ) { int i; - if (paused) { paused = false; S_ResumeSound (); } - - if (skill > sk_nightmare) skill = sk_nightmare; - - - - - if (episode < 1) episode = 1; - if ( gamemode == retail ) { if (episode > 4) @@ -1399,23 +993,16 @@ G_InitNew if (episode > 3) episode = 3; } - - - if (map < 1) map = 1; - if ( (map > 9) && ( gamemode != commercial) ) map = 9; - M_ClearRandom (); - if (skill == sk_nightmare || respawnparm ) respawnmonsters = true; else respawnmonsters = false; - if (fastparm || (skill == sk_nightmare && gameskill != sk_nightmare) ) { for (i=S_SARG_RUN1 ; i<=S_SARG_PAIN2 ; i++) @@ -1432,12 +1019,8 @@ G_InitNew mobjinfo[MT_HEADSHOT].speed = 10*FRACUNIT; mobjinfo[MT_TROOPSHOT].speed = 10*FRACUNIT; } - - - for (i=0 ; i<MAXPLAYERS ; i++) players[i].playerstate = PST_REBORN; - usergame = true; paused = false; demoplayback = false; @@ -1446,10 +1029,7 @@ G_InitNew gameepisode = episode; gamemap = map; gameskill = skill; - viewactive = true; - - if ( gamemode == commercial) { skytexture = R_TextureNumForName ("SKY3"); @@ -1475,22 +1055,13 @@ G_InitNew skytexture = R_TextureNumForName ("SKY4"); break; } - G_DoLoadLevel (); } - - - - - #define DEMOMARKER 0x80 - - void G_ReadDemoTiccmd (ticcmd_t* cmd) { if (*demo_p == DEMOMARKER) { - G_CheckDemoStatus (); return; } @@ -1499,8 +1070,6 @@ void G_ReadDemoTiccmd (ticcmd_t* cmd) cmd->angleturn = ((unsigned char)*demo_p++)<<8; cmd->buttons = (unsigned char)*demo_p++; } - - void G_WriteDemoTiccmd (ticcmd_t* cmd) { if (gamekeydown['q']) @@ -1512,24 +1081,15 @@ void G_WriteDemoTiccmd (ticcmd_t* cmd) demo_p -= 4; if (demo_p > demoend - 16) { - G_CheckDemoStatus (); return; } - G_ReadDemoTiccmd (cmd); } - - - - - - void G_RecordDemo (char* name) { int i; int maxsize; - usergame = false; strcpy (demoname, name); strcat (demoname, ".lmp"); @@ -1539,17 +1099,12 @@ void G_RecordDemo (char* name) maxsize = atoi(myargv[i+1])*1024; demobuffer = Z_Malloc (maxsize,PU_STATIC,NULL); demoend = demobuffer + maxsize; - demorecording = true; } - - void G_BeginRecording (void) { int i; - demo_p = demobuffer; - *demo_p++ = VERSION; *demo_p++ = gameskill; *demo_p++ = gameepisode; @@ -1559,29 +1114,19 @@ void G_BeginRecording (void) *demo_p++ = fastparm; *demo_p++ = nomonsters; *demo_p++ = consoleplayer; - for (i=0 ; i<MAXPLAYERS ; i++) *demo_p++ = playeringame[i]; } - - - - - - char* defdemoname; - void G_DeferedPlayDemo (char* name) { defdemoname = name; gameaction = ga_playdemo; } - void G_DoPlayDemo (void) { skill_t skill; int i, episode, map; - gameaction = ga_nothing; demobuffer = demo_p = W_CacheLumpName (defdemoname, PU_STATIC); if ( *demo_p++ != VERSION) @@ -1590,7 +1135,6 @@ void G_DoPlayDemo (void) gameaction = ga_nothing; return; } - skill = *demo_p++; episode = *demo_p++; map = *demo_p++; @@ -1599,7 +1143,6 @@ void G_DoPlayDemo (void) fastparm = *demo_p++; nomonsters = *demo_p++; consoleplayer = *demo_p++; - for (i=0 ; i<MAXPLAYERS ; i++) playeringame[i] = *demo_p++; if (playeringame[1]) @@ -1607,31 +1150,21 @@ void G_DoPlayDemo (void) netgame = true; netdemo = true; } - - precache = false; G_InitNew (skill, episode, map); precache = true; - usergame = false; demoplayback = true; } - - - - void G_TimeDemo (char* name) { nodrawers = M_CheckParm ("-nodraw"); noblit = M_CheckParm ("-noblit"); timingdemo = true; singletics = true; - defdemoname = name; gameaction = ga_playdemo; } - - /* =================== = @@ -1641,23 +1174,19 @@ void G_TimeDemo (char* name) = Returns true if a new demo loop action will take place =================== */ - boolean G_CheckDemoStatus (void) { int endtime; - if (timingdemo) { endtime = I_GetTime (); I_Error ("timed %i gametics in %i realtics",gametic , endtime-starttime); } - if (demoplayback) { if (singledemo) I_Quit (); - Z_ChangeTag (demobuffer, PU_CACHE); demoplayback = false; netdemo = false; @@ -1671,7 +1200,6 @@ boolean G_CheckDemoStatus (void) D_AdvanceDemo (); return true; } - if (demorecording) { *demo_p++ = DEMOMARKER; @@ -1680,9 +1208,5 @@ boolean G_CheckDemoStatus (void) demorecording = false; I_Error ("Demo %s recorded",demoname); } - return false; } - - - diff --git a/src/g_game.h b/src/g_game.h @@ -1,79 +1,23 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __G_GAME__ #define __G_GAME__ - #include "doomdef.h" #include "d_event.h" - - - - - - void G_DeathMatchSpawnPlayer (int playernum); - void G_InitNew (skill_t skill, int episode, int map); - - - - void G_DeferedInitNew (skill_t skill, int episode, int map); - void G_DeferedPlayDemo (char* demo); - - - void G_LoadGame (char* name); - void G_DoLoadGame (void); - - void G_SaveGame (int slot, char* description); - - void G_RecordDemo (char* name); - void G_BeginRecording (void); - void G_PlayDemo (char* name); void G_TimeDemo (char* name); boolean G_CheckDemoStatus (void); - void G_ExitLevel (void); void G_SecretExitLevel (void); - void G_WorldDone (void); - void G_Ticker (void); boolean G_Responder (event_t* ev); - void G_ScreenShot (void); - - #endif - - - - - diff --git a/src/hu_lib.c b/src/hu_lib.c @@ -1,53 +1,21 @@ - - - - - - - - - - - - - - - - - - - - - - - #include <ctype.h> - #include "doomdef.h" - #include "v_video.h" #include "m_swap.h" - #include "hu_lib.h" #include "r_local.h" #include "r_draw.h" - - #define noterased viewwindowx - extern boolean automapactive; - void HUlib_init(void) { } - void HUlib_clearTextLine(hu_textline_t* t) { t->len = 0; t->l[0] = 0; t->needsupdate = true; } - void HUlib_initTextLine ( hu_textline_t* t, @@ -62,13 +30,11 @@ HUlib_initTextLine t->sc = sc; HUlib_clearTextLine(t); } - boolean HUlib_addCharToTextLine ( hu_textline_t* t, char ch ) { - if (t->len == HU_MAXLINELENGTH) return false; else @@ -78,12 +44,9 @@ HUlib_addCharToTextLine t->needsupdate = 4; return true; } - } - boolean HUlib_delCharFromTextLine(hu_textline_t* t) { - if (!t->len) return false; else { @@ -91,21 +54,16 @@ boolean HUlib_delCharFromTextLine(hu_textline_t* t) t->needsupdate = 4; return true; } - } - void HUlib_drawTextLine ( hu_textline_t* l, boolean drawcursor ) { - int i; int w; int x; unsigned char c; - - x = l->x; for (i=0;i<l->len;i++) { @@ -127,28 +85,18 @@ HUlib_drawTextLine break; } } - - if (drawcursor && x + SHORT(l->f['_' - l->sc]->width) <= SCREENWIDTH) { V_DrawPatchDirect(x, l->y, FG, l->f['_' - l->sc]); } } - - - void HUlib_eraseTextLine(hu_textline_t* l) { int lh; int y; int yoffset; static boolean lastautomapactive = true; - - - - - if (!automapactive && viewwindowx && l->needsupdate) { @@ -161,16 +109,12 @@ void HUlib_eraseTextLine(hu_textline_t* l) { R_VideoErase(yoffset, viewwindowx); R_VideoErase(yoffset + viewwindowx + viewwidth, viewwindowx); - } } } - lastautomapactive = automapactive; if (l->needsupdate) l->needsupdate--; - } - void HUlib_initSText ( hu_stext_t* s, @@ -181,9 +125,7 @@ HUlib_initSText int startchar, boolean* on ) { - int i; - s->h = h; s->on = on; s->laston = true; @@ -192,25 +134,16 @@ HUlib_initSText HUlib_initTextLine(&s->l[i], x, y - i*(SHORT(font[0]->height)+1), font, startchar); - } - void HUlib_addLineToSText(hu_stext_t* s) { - int i; - - if (++s->cl == s->h) s->cl = 0; HUlib_clearTextLine(&s->l[s->cl]); - - for (i=0 ; i<s->h ; i++) s->l[i].needsupdate = 4; - } - void HUlib_addMessageToSText ( hu_stext_t* s, @@ -221,39 +154,27 @@ HUlib_addMessageToSText if (prefix) while (*prefix) HUlib_addCharToTextLine(&s->l[s->cl], *(prefix++)); - while (*msg) HUlib_addCharToTextLine(&s->l[s->cl], *(msg++)); } - void HUlib_drawSText(hu_stext_t* s) { int i, idx; hu_textline_t *l; - if (!*s->on) return; - - for (i=0 ; i<s->h ; i++) { idx = s->cl - i; if (idx < 0) idx += s->h; - l = &s->l[idx]; - - HUlib_drawTextLine(l, false); } - } - void HUlib_eraseSText(hu_stext_t* s) { - int i; - for (i=0 ; i<s->h ; i++) { if (s->laston && !*s->on) @@ -261,9 +182,7 @@ void HUlib_eraseSText(hu_stext_t* s) HUlib_eraseTextLine(&s->l[i]); } s->laston = *s->on; - } - void HUlib_initIText ( hu_itext_t* it, @@ -278,28 +197,21 @@ HUlib_initIText it->laston = true; HUlib_initTextLine(&it->l, x, y, font, startchar); } - - - void HUlib_delCharFromIText(hu_itext_t* it) { if (it->l.len != it->lm) HUlib_delCharFromTextLine(&it->l); } - void HUlib_eraseLineFromIText(hu_itext_t* it) { while (it->lm != it->l.len) HUlib_delCharFromTextLine(&it->l); } - - void HUlib_resetIText(hu_itext_t* it) { it->lm = 0; HUlib_clearTextLine(&it->l); } - void HUlib_addPrefixToIText ( hu_itext_t* it, @@ -309,15 +221,11 @@ HUlib_addPrefixToIText HUlib_addCharToTextLine(&it->l, *(str++)); it->lm = it->l.len; } - - - boolean HUlib_keyInIText ( hu_itext_t* it, unsigned char ch ) { - if (ch >= ' ' && ch <= '_') HUlib_addCharToTextLine(&it->l, (char) ch); else @@ -326,22 +234,15 @@ HUlib_keyInIText else if (ch != KEY_ENTER) return false; - return true; - } - void HUlib_drawIText(hu_itext_t* it) { - hu_textline_t *l = &it->l; - if (!*it->on) return; HUlib_drawTextLine(l, true); - } - void HUlib_eraseIText(hu_itext_t* it) { if (it->laston && !*it->on) @@ -349,4 +250,3 @@ void HUlib_eraseIText(hu_itext_t* it) HUlib_eraseTextLine(&it->l); it->laston = *it->on; } - diff --git a/src/hu_lib.h b/src/hu_lib.h @@ -1,131 +1,43 @@ - - - - - - - - - - - - - - - - - - - - #ifndef __HULIB__ #define __HULIB__ - - #include "r_defs.h" - - - - #define BG 1 #define FG 0 - - #define HU_CHARERASE KEY_BACKSPACE - #define HU_MAXLINES 4 #define HU_MAXLINELENGTH 80 - - - - - - - typedef struct { - int x; int y; - patch_t** f; int sc; char l[HU_MAXLINELENGTH+1]; int len; - - int needsupdate; - } hu_textline_t; - - - - - typedef struct { hu_textline_t l[HU_MAXLINES]; int h; int cl; - - boolean* on; boolean laston; - } hu_stext_t; - - - - - typedef struct { hu_textline_t l; - - int lm; - - boolean* on; boolean laston; - } hu_itext_t; - - - - - - - void HUlib_init(void); - - - - - - void HUlib_clearTextLine(hu_textline_t *t); - void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc); - - boolean HUlib_addCharToTextLine(hu_textline_t *t, char ch); - - boolean HUlib_delCharFromTextLine(hu_textline_t *t); - - void HUlib_drawTextLine(hu_textline_t *l, boolean drawcursor); - - void HUlib_eraseTextLine(hu_textline_t *l); - - - - - - - void HUlib_initSText ( hu_stext_t* s, @@ -135,24 +47,14 @@ HUlib_initSText patch_t** font, int startchar, boolean* on ); - - void HUlib_addLineToSText(hu_stext_t* s); - - void HUlib_addMessageToSText ( hu_stext_t* s, char* prefix, char* msg ); - - void HUlib_drawSText(hu_stext_t* s); - - void HUlib_eraseSText(hu_stext_t* s); - - void HUlib_initIText ( hu_itext_t* it, @@ -161,36 +63,17 @@ HUlib_initIText patch_t** font, int startchar, boolean* on ); - - void HUlib_delCharFromIText(hu_itext_t* it); - - void HUlib_eraseLineFromIText(hu_itext_t* it); - - void HUlib_resetIText(hu_itext_t* it); - - void HUlib_addPrefixToIText ( hu_itext_t* it, char* str ); - - boolean HUlib_keyInIText ( hu_itext_t* it, unsigned char ch ); - void HUlib_drawIText(hu_itext_t* it); - - void HUlib_eraseIText(hu_itext_t* it); - #endif - - - - - diff --git a/src/hu_stuff.c b/src/hu_stuff.c @@ -1,49 +1,14 @@ - - - - - - - - - - - - - - - - - - - - - - - #include <ctype.h> - #include "doomdef.h" - #include "z_zone.h" - #include "m_swap.h" - #include "hu_stuff.h" #include "hu_lib.h" #include "w_wad.h" - #include "s_sound.h" - #include "doomstat.h" - - #include "dstrings.h" #include "sounds.h" - - - - #define HU_TITLE (mapnames[(gameepisode-1)*9+gamemap-1]) #define HU_TITLE2 (mapnames2[gamemap-1]) #define HU_TITLEP (mapnamesp[gamemap-1]) @@ -51,15 +16,11 @@ #define HU_TITLEHEIGHT 1 #define HU_TITLEX 0 #define HU_TITLEY (167 - SHORT(hu_font[0]->height)) - #define HU_INPUTTOGGLE 't' #define HU_INPUTX HU_MSGX #define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(SHORT(hu_font[0]->height) +1)) #define HU_INPUTWIDTH 64 #define HU_INPUTHEIGHT 1 - - - char* chat_macros[] = { HUSTR_CHATMACRO0, @@ -73,7 +34,6 @@ char* chat_macros[] = HUSTR_CHATMACRO8, HUSTR_CHATMACRO9 }; - char* player_names[] = { HUSTR_PLRGREEN, @@ -81,8 +41,6 @@ char* player_names[] = HUSTR_PLRBROWN, HUSTR_PLRRED }; - - char chat_char; static player_t* plr; patch_t* hu_font[HU_FONTSIZE]; @@ -92,27 +50,16 @@ static hu_itext_t w_chat; static boolean always_off = false; static char chat_dest[MAXPLAYERS]; static hu_itext_t w_inputbuffer[MAXPLAYERS]; - static boolean message_on; boolean message_dontfuckwithme; static boolean message_nottobefuckedwith; - static hu_stext_t w_message; static int message_counter; - extern int showMessages; extern boolean automapactive; - static boolean headsupactive = false; - - - - - - char* mapnames[] = { - HUSTR_E1M1, HUSTR_E1M2, HUSTR_E1M3, @@ -122,7 +69,6 @@ char* mapnames[] = HUSTR_E1M7, HUSTR_E1M8, HUSTR_E1M9, - HUSTR_E2M1, HUSTR_E2M2, HUSTR_E2M3, @@ -132,7 +78,6 @@ char* mapnames[] = HUSTR_E2M7, HUSTR_E2M8, HUSTR_E2M9, - HUSTR_E3M1, HUSTR_E3M2, HUSTR_E3M3, @@ -142,7 +87,6 @@ char* mapnames[] = HUSTR_E3M7, HUSTR_E3M8, HUSTR_E3M9, - HUSTR_E4M1, HUSTR_E4M2, HUSTR_E4M3, @@ -152,7 +96,6 @@ char* mapnames[] = HUSTR_E4M7, HUSTR_E4M8, HUSTR_E4M9, - "NEWLEVEL", "NEWLEVEL", "NEWLEVEL", @@ -163,7 +106,6 @@ char* mapnames[] = "NEWLEVEL", "NEWLEVEL" }; - char* mapnames2[] = { HUSTR_1, @@ -177,7 +119,6 @@ char* mapnames2[] = HUSTR_9, HUSTR_10, HUSTR_11, - HUSTR_12, HUSTR_13, HUSTR_14, @@ -187,7 +128,6 @@ char* mapnames2[] = HUSTR_18, HUSTR_19, HUSTR_20, - HUSTR_21, HUSTR_22, HUSTR_23, @@ -201,8 +141,6 @@ char* mapnames2[] = HUSTR_31, HUSTR_32 }; - - char* mapnamesp[] = { PHUSTR_1, @@ -216,7 +154,6 @@ char* mapnamesp[] = PHUSTR_9, PHUSTR_10, PHUSTR_11, - PHUSTR_12, PHUSTR_13, PHUSTR_14, @@ -226,7 +163,6 @@ char* mapnamesp[] = PHUSTR_18, PHUSTR_19, PHUSTR_20, - PHUSTR_21, PHUSTR_22, PHUSTR_23, @@ -240,8 +176,6 @@ char* mapnamesp[] = PHUSTR_31, PHUSTR_32 }; - - char *mapnamest[] = { THUSTR_1, @@ -255,7 +189,6 @@ char *mapnamest[] = THUSTR_9, THUSTR_10, THUSTR_11, - THUSTR_12, THUSTR_13, THUSTR_14, @@ -265,7 +198,6 @@ char *mapnamest[] = THUSTR_18, THUSTR_19, THUSTR_20, - THUSTR_21, THUSTR_22, THUSTR_23, @@ -279,10 +211,7 @@ char *mapnamest[] = THUSTR_31, THUSTR_32 }; - - const char* shiftxform; - const char french_shiftxform[] = { 0, @@ -322,12 +251,9 @@ const char french_shiftxform[] = 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', 127 - }; - const char english_shiftxform[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, @@ -366,7 +292,6 @@ const char english_shiftxform[] = 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '{', '|', '}', '~', 127 }; - char frenchKeyMap[128]= { 0, @@ -381,66 +306,49 @@ char frenchKeyMap[128]= '@','Q','B','C','D','E','F','G','H','I','J','K','L',',','N','O', 'P','A','R','S','T','U','V','Z','X','Y','W','^','\\','$','^',127 }; - char ForeignTranslation(unsigned char ch) { return ch < 128 ? frenchKeyMap[ch] : ch; } - void HU_Init(void) { - int i; int j; char buffer[9]; - if (french) shiftxform = french_shiftxform; else shiftxform = english_shiftxform; - - j = HU_FONTSTART; for (i=0;i<HU_FONTSIZE;i++) { sprintf(buffer, "STCFN%.3d", j++); hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC); } - } - void HU_Stop(void) { headsupactive = false; } - void HU_Start(void) { - int i; char* s; - if (headsupactive) HU_Stop(); - plr = &players[consoleplayer]; message_on = false; message_dontfuckwithme = false; message_nottobefuckedwith = false; chat_on = false; - - HUlib_initSText(&w_message, HU_MSGX, HU_MSGY, HU_MSGHEIGHT, hu_font, HU_FONTSTART, &message_on); - - HUlib_initTextLine(&w_title, HU_TITLEX, HU_TITLEY, hu_font, HU_FONTSTART); - switch ( gamemode ) { case shareware: @@ -448,7 +356,6 @@ void HU_Start(void) case retail: s = HU_TITLE; break; - /* FIXME case pack_plut: s = HU_TITLEP; @@ -457,66 +364,45 @@ void HU_Start(void) s = HU_TITLET; break; */ - case commercial: default: s = HU_TITLE2; break; } - while (*s) HUlib_addCharToTextLine(&w_title, *(s++)); - - HUlib_initIText(&w_chat, HU_INPUTX, HU_INPUTY, hu_font, HU_FONTSTART, &chat_on); - - for (i=0 ; i<MAXPLAYERS ; i++) HUlib_initIText(&w_inputbuffer[i], 0, 0, 0, 0, &always_off); - headsupactive = true; - } - void HU_Drawer(void) { - HUlib_drawSText(&w_message); HUlib_drawIText(&w_chat); if (automapactive) HUlib_drawTextLine(&w_title, false); - } - void HU_Erase(void) { - HUlib_eraseSText(&w_message); HUlib_eraseIText(&w_chat); HUlib_eraseTextLine(&w_title); - } - void HU_Ticker(void) { - int i, rc; char c; - - if (message_counter && !--message_counter) { message_on = false; message_nottobefuckedwith = false; } - if (showMessages || message_dontfuckwithme) { - - if ((plr->message && !message_nottobefuckedwith) || (plr->message && message_dontfuckwithme)) { @@ -527,10 +413,7 @@ void HU_Ticker(void) message_nottobefuckedwith = message_dontfuckwithme; message_dontfuckwithme = 0; } - } - - if (netgame) { for (i=0 ; i<MAXPLAYERS; i++) @@ -556,7 +439,6 @@ void HU_Ticker(void) HUlib_addMessageToSText(&w_message, player_names[i], w_inputbuffer[i].l.l); - message_nottobefuckedwith = true; message_on = true; message_counter = HU_MSGTIMEOUT; @@ -572,16 +454,11 @@ void HU_Ticker(void) } } } - } - #define QUEUESIZE 128 - static char chatchars[QUEUESIZE]; static int head = 0; static int tail = 0; - - void HU_queueChatChar(char c) { if (((head + 1) & (QUEUESIZE-1)) == tail) @@ -594,11 +471,9 @@ void HU_queueChatChar(char c) head = (head + 1) & (QUEUESIZE-1); } } - char HU_dequeueChatChar(void) { char c; - if (head != tail) { c = chatchars[tail]; @@ -608,13 +483,10 @@ char HU_dequeueChatChar(void) { c = 0; } - return c; } - boolean HU_Responder(event_t *ev) { - static char lastmessage[HU_MAXLINELENGTH+1]; char* macromessage; boolean eatkey = false; @@ -623,7 +495,6 @@ boolean HU_Responder(event_t *ev) unsigned char c; int i; int numplayers; - static char destination_keys[MAXPLAYERS] = { HUSTR_KEYGREEN, @@ -631,13 +502,10 @@ boolean HU_Responder(event_t *ev) HUSTR_KEYBROWN, HUSTR_KEYRED }; - static int num_nobrainers = 0; - numplayers = 0; for (i=0 ; i<MAXPLAYERS ; i++) numplayers += playeringame[i]; - if (ev->data1 == KEY_RSHIFT) { shiftdown = ev->type == ev_keydown; @@ -648,10 +516,8 @@ boolean HU_Responder(event_t *ev) altdown = ev->type == ev_keydown; return false; } - if (ev->type != ev_keydown) return false; - if (!chat_on) { if (ev->data1 == HU_MSGREFRESH) @@ -700,24 +566,16 @@ boolean HU_Responder(event_t *ev) else { c = ev->data1; - if (altdown) { c = c - '0'; if (c > 9) return false; - macromessage = chat_macros[c]; - - HU_queueChatChar(KEY_ENTER); - - while (*macromessage) HU_queueChatChar(*macromessage++); HU_queueChatChar(KEY_ENTER); - - chat_on = false; strcpy(lastmessage, chat_macros[c]); plr->message = lastmessage; @@ -732,11 +590,7 @@ boolean HU_Responder(event_t *ev) eatkey = HUlib_keyInIText(&w_chat, c); if (eatkey) { - HU_queueChatChar(c); - - - } if (c == KEY_ENTER) { @@ -751,7 +605,5 @@ boolean HU_Responder(event_t *ev) chat_on = false; } } - return eatkey; - } diff --git a/src/hu_stuff.h b/src/hu_stuff.h @@ -1,66 +1,21 @@ - - - - - - - - - - - - - - - - - - - - #ifndef __HU_STUFF_H__ #define __HU_STUFF_H__ - #include "d_event.h" - - - - - #define HU_FONTSTART '!' #define HU_FONTEND '_' - - #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) - #define HU_BROADCAST 5 - #define HU_MSGREFRESH KEY_ENTER #define HU_MSGX 0 #define HU_MSGY 0 #define HU_MSGWIDTH 64 #define HU_MSGHEIGHT 1 - #define HU_MSGTIMEOUT (4*TICRATE) - - - - - void HU_Init(void); void HU_Start(void); - boolean HU_Responder(event_t* ev); - void HU_Ticker(void); void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); - - #endif - - - - - diff --git a/src/i_main.c b/src/i_main.c @@ -1,34 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #include "doomdef.h" - #include "m_argv.h" #include "d_main.h" - int main ( int argc, @@ -36,8 +8,6 @@ main { myargc = argc; myargv = argv; - D_DoomMain (); - return 0; } diff --git a/src/i_net.c b/src/i_net.c @@ -1,30 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - #include <stdlib.h> #include <string.h> #include <stdio.h> - #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> @@ -32,74 +8,41 @@ #include <unistd.h> #include <netdb.h> #include <sys/ioctl.h> - #include "i_system.h" #include "d_event.h" #include "d_net.h" #include "m_argv.h" - #include "doomstat.h" - #ifdef __GNUG__ #pragma implementation "i_net.h" #endif #include "i_net.h" - - - - - - #define ntohl(x) \ ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \ (((unsigned long int)(x) & 0x0000ff00U) << 8) | \ (((unsigned long int)(x) & 0x00ff0000U) >> 8) | \ (((unsigned long int)(x) & 0xff000000U) >> 24))) - #define ntohs(x) \ ((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \ (((unsigned short int)(x) & 0xff00) >> 8))) \ - #define htonl(x) ntohl(x) #define htons(x) ntohs(x) - void NetSend (void); boolean NetListen (void); - - - - - - int DOOMPORT = (IPPORT_USERRESERVED +0x1d ); - int sendsocket; int insocket; - struct sockaddr_in sendaddress[MAXNETNODES]; - void (*netget) (void); void (*netsend) (void); - - - - - int UDPsocket (void) { int s; - - s = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (s<0) I_Error ("can't create socket: %s",strerror(errno)); - return s; } - - - - void BindToLocalPort ( int s, @@ -107,27 +50,18 @@ BindToLocalPort { int v; struct sockaddr_in address; - memset (&address, 0, sizeof(address)); address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; address.sin_port = port; - v = bind (s, (void *)&address, sizeof(address)); if (v == -1) I_Error ("BindToPort: bind: %s", strerror(errno)); } - - - - - void PacketSend (void) { int c; doomdata_t sw; - - sw.checksum = htonl(netbuffer->checksum); sw.player = netbuffer->player; sw.retransmitfrom = netbuffer->retransmitfrom; @@ -142,20 +76,10 @@ void PacketSend (void) sw.cmds[c].chatchar = netbuffer->cmds[c].chatchar; sw.cmds[c].buttons = netbuffer->cmds[c].buttons; } - - c = sendto (sendsocket , &sw, doomcom->datalength ,0,(void *)&sendaddress[doomcom->remotenode] ,sizeof(sendaddress[doomcom->remotenode])); - - - } - - - - - void PacketGet (void) { int i; @@ -163,7 +87,6 @@ void PacketGet (void) struct sockaddr_in fromaddress; int fromlen; doomdata_t sw; - fromlen = sizeof(fromaddress); c = recvfrom (insocket, &sw, sizeof(sw), 0 , (struct sockaddr *)&fromaddress, &fromlen ); @@ -174,36 +97,27 @@ void PacketGet (void) doomcom->remotenode = -1; return; } - { static int first=1; if (first) printf("len=%d:p=[0x%x 0x%x] \n", c, *(int*)&sw, *((int*)&sw+1)); first = 0; } - - for (i=0 ; i<doomcom->numnodes ; i++) if ( fromaddress.sin_addr.s_addr == sendaddress[i].sin_addr.s_addr ) break; - if (i == doomcom->numnodes) { - doomcom->remotenode = -1; return; } - doomcom->remotenode = i; doomcom->datalength = c; - - netbuffer->checksum = ntohl(sw.checksum); netbuffer->player = sw.player; netbuffer->retransmitfrom = sw.retransmitfrom; netbuffer->starttic = sw.starttic; netbuffer->numtics = sw.numtics; - for (c=0 ; c< netbuffer->numtics ; c++) { netbuffer->cmds[c].forwardmove = sw.cmds[c].forwardmove; @@ -214,42 +128,27 @@ void PacketGet (void) netbuffer->cmds[c].buttons = sw.cmds[c].buttons; } } - - - int GetLocalAddress (void) { char hostname[1024]; struct hostent* hostentry; int v; - - v = gethostname (hostname, sizeof(hostname)); if (v == -1) I_Error ("GetLocalAddress : gethostname: errno %d",errno); - hostentry = gethostbyname (hostname); if (!hostentry) I_Error ("GetLocalAddress : gethostbyname: couldn't get local host"); - return *(int *)hostentry->h_addr_list[0]; } - - - - - void I_InitNetwork (void) { boolean trueval = true; int i; int p; struct hostent* hostentry; - doomcom = malloc (sizeof (*doomcom) ); memset (doomcom, 0, sizeof(*doomcom) ); - - i = M_CheckParm ("-dup"); if (i && i< myargc-1) { @@ -261,25 +160,19 @@ void I_InitNetwork (void) } else doomcom-> ticdup = 1; - if (M_CheckParm ("-extratic")) doomcom-> extratics = 1; else doomcom-> extratics = 0; - p = M_CheckParm ("-port"); if (p && p<myargc-1) { DOOMPORT = atoi (myargv[p+1]); printf ("using alternate port %i\n",DOOMPORT); } - - - i = M_CheckParm ("-net"); if (!i) { - netgame = false; doomcom->id = DOOMCOM_ID; doomcom->numplayers = doomcom->numnodes = 1; @@ -287,16 +180,11 @@ void I_InitNetwork (void) doomcom->consoleplayer = 0; return; } - netsend = PacketSend; netget = PacketGet; netgame = true; - - doomcom->consoleplayer = myargv[i+1][0]-'1'; - doomcom->numnodes = 1; - i++; while (++i < myargc && myargv[i][0] != '-') { @@ -317,19 +205,13 @@ void I_InitNetwork (void) } doomcom->numnodes++; } - doomcom->id = DOOMCOM_ID; doomcom->numplayers = doomcom->numnodes; - - insocket = UDPsocket (); BindToLocalPort (insocket,htons(DOOMPORT)); ioctl (insocket, FIONBIO, &trueval); - sendsocket = UDPsocket (); } - - void I_NetCmd (void) { if (doomcom->command == CMD_SEND) @@ -343,4 +225,3 @@ void I_NetCmd (void) else I_Error ("Bad net cmd: %i\n",doomcom->command); } - diff --git a/src/i_net.h b/src/i_net.h @@ -1,45 +1,8 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __I_NET__ #define __I_NET__ - - #ifdef __GNUG__ #pragma interface #endif - - - - - - void I_InitNetwork (void); void I_NetCmd (void); - - #endif - - - - - diff --git a/src/i_sound.c b/src/i_sound.c @@ -1,155 +1,53 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <errno.h> #include <math.h> - #include <sys/time.h> #include <sys/types.h> - #include <fcntl.h> #include <unistd.h> #include <sys/ioctl.h> - - #include <linux/soundcard.h> - - #include <time.h> #include <signal.h> - #include "z_zone.h" - #include "i_system.h" #include "i_sound.h" #include "m_argv.h" #include "m_misc.h" #include "w_wad.h" - #include "doomdef.h" - - #ifdef SNDSERV - FILE* sndserver=0; char* sndserver_filename = "./sndserver "; #elif SNDINTR - - - - #define SOUND_INTERVAL 500 - - int I_SoundSetTimer( int duration_of_tick ); void I_SoundDelTimer( void ); #else - #endif - - - - - static int flag = 0; - - - - - - - - #define SAMPLECOUNT 512 #define NUM_CHANNELS 8 - #define BUFMUL 4 #define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL) - #define SAMPLERATE 11025 #define SAMPLESIZE 2 - - int lengths[NUMSFX]; - - int audio_fd; - - - - - signed short mixbuffer[MIXBUFFERSIZE]; - - - unsigned int channelstep[NUM_CHANNELS]; - unsigned int channelstepremainder[NUM_CHANNELS]; - - - unsigned char* channels[NUM_CHANNELS]; unsigned char* channelsend[NUM_CHANNELS]; - - - - - - - int channelstart[NUM_CHANNELS]; - - - - - int channelhandles[NUM_CHANNELS]; - - - int channelids[NUM_CHANNELS]; - - int steptable[256]; - - int vol_lookup[128*256]; - - int* channelleftvol_lookup[NUM_CHANNELS]; int* channelrightvol_lookup[NUM_CHANNELS]; - - - - - - - void myioctl ( int fd, @@ -157,7 +55,6 @@ myioctl int* arg ) { int rc; - rc = ioctl(fd, command, arg); if (rc < 0) { @@ -166,15 +63,6 @@ myioctl exit(-1); } } - - - - - - - - - void* getsfx ( char* sfxname, @@ -187,73 +75,22 @@ getsfx int paddedsize; char name[20]; int sfxlump; - - - - sprintf(name, "ds%s", sfxname); - - - - - - - - - - - if ( W_CheckNumForName(name) == -1 ) sfxlump = W_GetNumForName("dspistol"); else sfxlump = W_GetNumForName(name); - size = W_LumpLength( sfxlump ); - - - - - - - sfx = (unsigned char*)W_CacheLumpNum( sfxlump, PU_STATIC ); - - - paddedsize = ((size-8 + (SAMPLECOUNT-1)) / SAMPLECOUNT) * SAMPLECOUNT; - - paddedsfx = (unsigned char*)Z_Malloc( paddedsize+8, PU_STATIC, 0 ); - - - - - memcpy( paddedsfx, sfx, size ); for (i=size ; i<paddedsize+8 ; i++) paddedsfx[i] = 128; - - Z_Free( sfx ); - - *len = paddedsize; - - return (void *) (paddedsfx + 8); } - - - - - - - - - - - - int addsfx ( int sfxid, @@ -262,19 +99,13 @@ addsfx int seperation ) { static unsigned short handlenums = 0; - int i; int rc = -1; - int oldest = gametic; int oldestnum = 0; int slot; - int rightvol; int leftvol; - - - if ( sfxid == sfx_sawup || sfxid == sfx_sawidl || sfxid == sfx_sawful @@ -282,23 +113,16 @@ addsfx || sfxid == sfx_stnmov || sfxid == sfx_pistol ) { - for (i=0 ; i<NUM_CHANNELS ; i++) { - if ( (channels[i]) && (channelids[i] == sfxid) ) { - channels[i] = 0; - - break; } } } - - for (i=0; (i<NUM_CHANNELS) && (channels[i]); i++) { if (channelstart[i] < oldest) @@ -307,159 +131,62 @@ addsfx oldest = channelstart[i]; } } - - - - - if (i == NUM_CHANNELS) slot = oldestnum; else slot = i; - - - - channels[slot] = (unsigned char *) S_sfx[sfxid].data; - channelsend[slot] = channels[slot] + lengths[sfxid]; - - if (!handlenums) handlenums = 100; - - - channelhandles[slot] = rc = handlenums++; - - - channelstep[slot] = step; - channelstepremainder[slot] = 0; - channelstart[slot] = gametic; - - - seperation += 1; - - - - leftvol = volume - ((volume*seperation*seperation) >> 16); seperation = seperation - 257; rightvol = volume - ((volume*seperation*seperation) >> 16); - - if (rightvol < 0 || rightvol > 127) I_Error("rightvol out of bounds"); - if (leftvol < 0 || leftvol > 127) I_Error("leftvol out of bounds"); - - - channelleftvol_lookup[slot] = &vol_lookup[leftvol*256]; channelrightvol_lookup[slot] = &vol_lookup[rightvol*256]; - - - channelids[slot] = sfxid; - - return rc; } - - - - - - - - - - - - - - void I_SetChannels() { - - - int i; int j; - int* steptablemid = steptable + 128; - - /*for (i=0; i<NUM_CHANNELS; i++) { channels[i] = 0; }*/ - - - for (i=-128 ; i<128 ; i++) steptablemid[i] = (int)(pow(2.0, (i/64.0))*65536.0); - - - - - for (i=0 ; i<128 ; i++) for (j=0 ; j<256 ; j++) vol_lookup[i*256+j] = (i*(j-128)*256)/127; } - - void I_SetSfxVolume(int volume) { - - - - - snd_SfxVolume = volume; } - - void I_SetMusicVolume(int volume) { - snd_MusicVolume = volume; - - } - - - - - - int I_GetSfxLumpNum(sfxinfo_t* sfx) { char namebuf[9]; sprintf(namebuf, "ds%s", sfx->name); return W_GetNumForName(namebuf); } - - - - - - - - - - - - - int I_StartSound ( int id, @@ -468,202 +195,96 @@ I_StartSound int pitch, int priority ) { - - priority = 0; - #ifdef SNDSERV if (sndserver) { fprintf(sndserver, "p%2.2x%2.2x%2.2x%2.2x\n", id, pitch, vol, sep); fflush(sndserver); } - return id; #else - - - - id = addsfx( id, vol, steptable[pitch], sep ); - - - return id; #endif } - - - void I_StopSound (int handle) { - - - - - - handle = 0; } - - int I_SoundIsPlaying(int handle) { - return gametic < handle; } - - - - - - - - - - - - - - - - - void I_UpdateSound( void ) { #ifdef SNDINTR - static int misses = 0; #endif - - - - register unsigned int sample; register int dl; register int dr; - - signed short* leftout; signed short* rightout; signed short* leftend; - int step; - - int chan; - - - leftout = mixbuffer; rightout = mixbuffer+1; step = 2; - - - leftend = mixbuffer + SAMPLECOUNT*step; - - - - while (leftout != leftend) { - dl = 0; dr = 0; - - - - for ( chan = 0; chan < NUM_CHANNELS; chan++ ) { - if (channels[ chan ]) { - sample = *channels[ chan ]; - - - - dl += channelleftvol_lookup[ chan ][sample]; dr += channelrightvol_lookup[ chan ][sample]; - channelstepremainder[ chan ] += channelstep[ chan ]; - channels[ chan ] += channelstepremainder[ chan ] >> 16; - channelstepremainder[ chan ] &= 65536-1; - - if (channels[ chan ] >= channelsend[ chan ]) channels[ chan ] = 0; } } - - - - - - - if (dl > 0x7fff) *leftout = 0x7fff; else if (dl < -0x8000) *leftout = -0x8000; else *leftout = dl; - - if (dr > 0x7fff) *rightout = 0x7fff; else if (dr < -0x8000) *rightout = -0x8000; else *rightout = dr; - - leftout += step; rightout += step; } - #ifdef SNDINTR - if ( flag ) { misses += flag; flag = 0; } - if ( misses > 10 ) { fprintf( stderr, "I_SoundUpdate: missed 10 buffer writes\n"); misses = 0; } - - flag++; #endif } - - - - - - - - - - void I_SubmitSound(void) { - write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL); } - - - void I_UpdateSoundParams ( int handle, @@ -671,76 +292,44 @@ I_UpdateSoundParams int sep, int pitch) { - - - - - - handle = vol = sep = pitch = 0; } - - - - void I_ShutdownSound(void) { #ifdef SNDSERV if (sndserver) { - fprintf(sndserver, "q\n"); fflush(sndserver); } #else - int done = 0; int i; - - - fprintf( stderr, "I_ShutdownSound: NOT finishing pending sounds\n"); fflush( stderr ); - while ( !done ) { for( i=0 ; i<8 && !channels[i] ; i++); - - - done=1; } #ifdef SNDINTR I_SoundDelTimer(); #endif - - close ( audio_fd ); #endif - - return; } - - - - - - void I_InitSound() { #ifdef SNDSERV char buffer[256]; - if (getenv("DOOMWADDIR")) sprintf(buffer, "%s/%s", getenv("DOOMWADDIR"), sndserver_filename); else sprintf(buffer, "%s", sndserver_filename); - - if ( !access(buffer, X_OK) ) { strcat(buffer, " -quiet"); @@ -749,230 +338,126 @@ I_InitSound() else fprintf(stderr, "Could not start sound server [%s]\n", buffer); #else - int i; - #ifdef SNDINTR fprintf( stderr, "I_SoundSetTimer: %d microsecs\n", SOUND_INTERVAL ); I_SoundSetTimer( SOUND_INTERVAL ); #endif - - fprintf( stderr, "I_InitSound: "); - audio_fd = open("/dev/dsp", O_WRONLY); if (audio_fd<0) fprintf(stderr, "Could not open /dev/dsp\n"); - - i = 11 | (2<<16); myioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &i); myioctl(audio_fd, SNDCTL_DSP_RESET, 0); - i=SAMPLERATE; - myioctl(audio_fd, SNDCTL_DSP_SPEED, &i); - i=1; myioctl(audio_fd, SNDCTL_DSP_STEREO, &i); - myioctl(audio_fd, SNDCTL_DSP_GETFMTS, &i); - if (i&=AFMT_S16_LE) myioctl(audio_fd, SNDCTL_DSP_SETFMT, &i); else fprintf(stderr, "Could not play signed 16 data\n"); - fprintf(stderr, " configured audio device\n" ); - - - fprintf( stderr, "I_InitSound: "); - for (i=1 ; i<NUMSFX ; i++) { - if (!S_sfx[i].link) { - S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] ); } else { - S_sfx[i].data = S_sfx[i].link->data; lengths[i] = lengths[(S_sfx[i].link - S_sfx)/sizeof(sfxinfo_t)]; } } - fprintf( stderr, " pre-cached all sound data\n"); - - for ( i = 0; i< MIXBUFFERSIZE; i++ ) mixbuffer[i] = 0; - - fprintf(stderr, "I_InitSound: sound module ready\n"); - #endif } - - - - - - - - - void I_InitMusic(void) { } void I_ShutdownMusic(void) { } - static int looping=0; static int musicdies=-1; - void I_PlaySong(int handle, int looping) { - handle = looping = 0; musicdies = gametic + TICRATE*30; } - void I_PauseSong (int handle) { - handle = 0; } - void I_ResumeSong (int handle) { - handle = 0; } - void I_StopSong(int handle) { - handle = 0; - looping = 0; musicdies = 0; } - void I_UnRegisterSong(int handle) { - handle = 0; } - int I_RegisterSong(void* data) { - data = NULL; - return 1; } - - int I_QrySongPlaying(int handle) { - handle = 0; return looping || musicdies > gametic; } - - - - - - - - - - - #ifdef sun typedef sigset_t tSigSet; #else typedef int tSigSet; #endif - - - - - - static int /*__itimer_which*/ itimer = ITIMER_REAL; - static int sig = SIGALRM; - - void I_HandleSoundTimer( int ignore ) { - - - - if ( flag ) { - - write(audio_fd, mixbuffer, SAMPLECOUNT*BUFMUL); - - flag = 0; } else return; - - ignore = 0; return; } - - int I_SoundSetTimer( int duration_of_tick ) { - struct itimerval value; struct itimerval ovalue; struct sigaction act; struct sigaction oact; - int res; - - - - - act.sa_handler = I_HandleSoundTimer; #ifndef sun - #endif act.sa_flags = SA_RESTART; - sigaction( sig, &act, &oact ); - value.it_interval.tv_sec = 0; value.it_interval.tv_usec = duration_of_tick; value.it_value.tv_sec = 0; value.it_value.tv_usec = duration_of_tick; - - res = setitimer( itimer, &value, &ovalue ); - - if ( res == -1 ) fprintf( stderr, "I_SoundSetTimer: interrupt n.a.\n"); - return res; } - - - void I_SoundDelTimer() { - if ( I_SoundSetTimer( 0 ) == -1) fprintf( stderr, "I_SoundDelTimer: failed to remove interrupt. Doh!\n"); } diff --git a/src/i_sound.h b/src/i_sound.h @@ -1,65 +1,19 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __I_SOUND__ #define __I_SOUND__ - #include "doomdef.h" - - #ifdef SNDSERV #include <stdio.h> extern FILE* sndserver; extern char* sndserver_filename; #endif - #include "doomstat.h" #include "sounds.h" - - - - void I_InitSound(); - - void I_UpdateSound(void); void I_SubmitSound(void); - - void I_ShutdownSound(void); - - - - - - - void I_SetChannels(); - - int I_GetSfxLumpNum (sfxinfo_t* sfxinfo ); - - - int I_StartSound ( int id, @@ -67,56 +21,24 @@ I_StartSound int sep, int pitch, int priority ); - - - void I_StopSound(int handle); - - - - int I_SoundIsPlaying(int handle); - - - void I_UpdateSoundParams ( int handle, int vol, int sep, int pitch ); - - - - - void I_InitMusic(void); void I_ShutdownMusic(void); - void I_SetMusicVolume(int volume); - void I_PauseSong(int handle); void I_ResumeSong(int handle); - int I_RegisterSong(void *data); - - - - void I_PlaySong ( int handle, int looping ); - void I_StopSong(int handle); - void I_UnRegisterSong(int handle); - - - #endif - - - - - diff --git a/src/i_system.c b/src/i_system.c @@ -1,116 +1,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include <stdlib.h> #include <stdio.h> #include <string.h> - #include <stdarg.h> #include <sys/time.h> #include <unistd.h> - #include "doomdef.h" #include "m_misc.h" #include "i_video.h" #include "i_sound.h" - #include "d_net.h" #include "g_game.h" - #ifdef __GNUG__ #pragma implementation "i_system.h" #endif #include "i_system.h" - - - - int mb_used = 6; - - void I_Tactile ( int on, int off, int total ) { - on = off = total = 0; } - ticcmd_t emptycmd; ticcmd_t* I_BaseTiccmd(void) { return &emptycmd; } - - int I_GetHeapSize (void) { return mb_used*1024*1024; } - byte* I_ZoneBase (int* size) { *size = mb_used*1024*1024; return (byte *) malloc (*size); } - - - - - - - int I_GetTime (void) { struct timeval tp; struct timezone tzp; int newtics; static int basetime=0; - gettimeofday(&tp, &tzp); if (!basetime) basetime = tp.tv_sec; newtics = (tp.tv_sec-basetime)*TICRATE + tp.tv_usec*TICRATE/1000000; return newtics; } - - - - - - void I_Init (void) { I_InitSound(); - } - - - - void I_Quit (void) { D_QuitNetGame (); @@ -120,7 +62,6 @@ void I_Quit (void) I_ShutdownGraphics(); exit(0); } - void I_WaitVBL(int count) { #ifdef SGI @@ -133,49 +74,32 @@ void I_WaitVBL(int count) #endif #endif } - void I_BeginRead(void) { } - void I_EndRead(void) { } - byte* I_AllocLow(int length) { byte* mem; - mem = (byte *)malloc (length); memset (mem,0,length); return mem; } - - - - - extern boolean demorecording; - void I_Error (char *error, ...) { va_list argptr; - - va_start (argptr,error); fprintf (stderr, "Error: "); vfprintf (stderr,error,argptr); fprintf (stderr, "\n"); va_end (argptr); - fflush( stderr ); - - if (demorecording) G_CheckDemoStatus(); - D_QuitNetGame (); I_ShutdownGraphics(); - exit(-1); } diff --git a/src/i_system.h b/src/i_system.h @@ -1,97 +1,18 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __I_SYSTEM__ #define __I_SYSTEM__ - #include "d_ticcmd.h" #include "d_event.h" - #ifdef __GNUG__ #pragma interface #endif - - - void I_Init (void); - - - - byte* I_ZoneBase (int *size); - - - - int I_GetTime (void); - - - - - - - - - - void I_StartFrame (void); - - - - - - - void I_StartTic (void); - - - - - - - - - ticcmd_t* I_BaseTiccmd (void); - - - - void I_Quit (void); - - - - byte* I_AllocLow (int length); - void I_Tactile (int on, int off, int total); - - void I_Error (char *error, ...); - - #endif - - - - - diff --git a/src/i_video.c b/src/i_video.c @@ -1,62 +1,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include <stdlib.h> #include <unistd.h> #include <sys/ipc.h> #include <sys/shm.h> - #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/keysym.h> - #include <X11/extensions/XShm.h> - - #ifdef LINUX int XShmGetEventBase( Display* dpy ); #endif - #include <stdarg.h> #include <sys/time.h> #include <sys/types.h> #include <sys/socket.h> - #include <netinet/in.h> #include <errno.h> #include <signal.h> - #include "doomstat.h" #include "i_system.h" #include "v_video.h" #include "m_argv.h" #include "d_main.h" - #include "doomdef.h" - #define POINTER_WARP_COUNTDOWN 1 - Display* X_display=0; Window X_mainWindow; Colormap X_cmap; @@ -68,35 +34,15 @@ XVisualInfo X_visualinfo; XImage* image; int X_width; int X_height; - - boolean doShm; - XShmSegmentInfo X_shminfo; int X_shmeventtype; - - - - boolean grabMouse; int doPointerWarp = POINTER_WARP_COUNTDOWN; - - - - - static int multiply=1; - - - - - - int xlatekey(void) { - int rc; - switch(rc = XKeycodeToKeysym(X_display, X_event.xkey.keycode, 0)) { case XK_Left: rc = KEY_LEFTARROW; break; @@ -118,35 +64,27 @@ int xlatekey(void) case XK_F10: rc = KEY_F10; break; case XK_F11: rc = KEY_F11; break; case XK_F12: rc = KEY_F12; break; - case XK_BackSpace: case XK_Delete: rc = KEY_BACKSPACE; break; - case XK_Pause: rc = KEY_PAUSE; break; - case XK_KP_Equal: case XK_equal: rc = KEY_EQUALS; break; - case XK_KP_Subtract: case XK_minus: rc = KEY_MINUS; break; - case XK_Shift_L: case XK_Shift_R: rc = KEY_RSHIFT; break; - case XK_Control_L: case XK_Control_R: rc = KEY_RCTRL; break; - case XK_Alt_L: case XK_Meta_L: case XK_Alt_R: case XK_Meta_R: rc = KEY_RALT; break; - default: if (rc >= XK_space && rc <= XK_asciitilde) rc = rc - XK_space + ' '; @@ -154,47 +92,26 @@ int xlatekey(void) rc = rc - 'A' + 'a'; break; } - return rc; - } - void I_ShutdownGraphics(void) { - if (!XShmDetach(X_display, &X_shminfo)) I_Error("XShmDetach() failed in I_ShutdownGraphics()"); - - shmdt(X_shminfo.shmaddr); shmctl(X_shminfo.shmid, IPC_RMID, 0); - - image->data = NULL; } - - - - - - void I_StartFrame (void) { - - } - static int lastmousex = 0; static int lastmousey = 0; boolean mousemoved = false; boolean shmFinished; - void I_GetEvent(void) { - event_t event; - - XNextEvent(X_display, &X_event); switch (X_event.type) { @@ -202,13 +119,11 @@ void I_GetEvent(void) event.type = ev_keydown; event.data1 = xlatekey(); D_PostEvent(&event); - break; case KeyRelease: event.type = ev_keyup; event.data1 = xlatekey(); D_PostEvent(&event); - break; case ButtonPress: event.type = ev_mouse; @@ -221,7 +136,6 @@ void I_GetEvent(void) | (X_event.xbutton.button == Button3 ? 4 : 0); event.data2 = event.data3 = 0; D_PostEvent(&event); - break; case ButtonRelease: event.type = ev_mouse; @@ -229,7 +143,6 @@ void I_GetEvent(void) (X_event.xbutton.state & Button1Mask) | (X_event.xbutton.state & Button2Mask ? 2 : 0) | (X_event.xbutton.state & Button3Mask ? 4 : 0); - event.data1 = event.data1 ^ (X_event.xbutton.button == Button1 ? 1 : 0) @@ -237,7 +150,6 @@ void I_GetEvent(void) ^ (X_event.xbutton.button == Button3 ? 4 : 0); event.data2 = event.data3 = 0; D_PostEvent(&event); - break; case MotionNotify: event.type = ev_mouse; @@ -247,7 +159,6 @@ void I_GetEvent(void) | (X_event.xmotion.state & Button3Mask ? 4 : 0); event.data2 = (X_event.xmotion.x - lastmousex) << 2; event.data3 = (lastmousey - X_event.xmotion.y) << 2; - if (event.data2 || event.data3) { lastmousex = X_event.xmotion.x; @@ -256,7 +167,6 @@ void I_GetEvent(void) X_event.xmotion.y != X_height/2) { D_PostEvent(&event); - mousemoved = false; } else { @@ -264,18 +174,14 @@ void I_GetEvent(void) } } break; - case Expose: case ConfigureNotify: break; - default: if (doShm && X_event.type == X_shmeventtype) shmFinished = true; break; } - } - Cursor createnullcursor ( Display* display, @@ -286,7 +192,6 @@ createnullcursor GC gc; XColor dummycolour; Cursor cursor; - cursormask = XCreatePixmap(display, root, 1, 1, 1/*depth*/); xgc.function = GXclear; gc = XCreateGC(display, cursormask, GCFunction, &xgc); @@ -300,22 +205,12 @@ createnullcursor XFreeGC(display,gc); return cursor; } - - - - void I_StartTic (void) { - if (!X_display) return; - while (XPending(X_display)) I_GetEvent(); - - - - if (grabMouse) { if (!--doPointerWarp) @@ -326,52 +221,30 @@ void I_StartTic (void) 0, 0, 0, 0, X_width/2, X_height/2); - doPointerWarp = POINTER_WARP_COUNTDOWN; } } - mousemoved = false; - } - - - - - void I_UpdateNoBlit (void) { - } - - - - void I_FinishUpdate (void) { - static int lasttic; int tics; int i; - - - if (devparm) { - i = I_GetTime(); tics = i - lasttic; lasttic = i; if (tics > 20) tics = 20; - for (i=0 ; i<tics*2 ; i+=2) screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0xff; for ( ; i<20*2 ; i+=2) screens[0][ (SCREENHEIGHT-1)*SCREENWIDTH + i] = 0x0; - } - - if (multiply == 2) { unsigned int *olineptrs[2]; @@ -380,11 +253,9 @@ void I_FinishUpdate (void) unsigned int twoopixels; unsigned int twomoreopixels; unsigned int fouripixels; - ilineptr = (unsigned int *) (screens[0]); for (i=0 ; i<2 ; i++) olineptrs[i] = (unsigned int *) &image->data[i*X_width]; - y = SCREENHEIGHT; while (y--) { @@ -413,7 +284,6 @@ void I_FinishUpdate (void) olineptrs[0] += X_width/4; olineptrs[1] += X_width/4; } - } else if (multiply == 3) { @@ -422,11 +292,9 @@ void I_FinishUpdate (void) int x, y, i; unsigned int fouropixels[3]; unsigned int fouripixels; - ilineptr = (unsigned int *) (screens[0]); for (i=0 ; i<3 ; i++) olineptrs[i] = (unsigned int *) &image->data[i*X_width]; - y = SCREENHEIGHT; while (y--) { @@ -469,18 +337,14 @@ void I_FinishUpdate (void) olineptrs[1] += 2*X_width/4; olineptrs[2] += 2*X_width/4; } - } else if (multiply == 4) { - void Expand4(unsigned *, double *); Expand4 ((unsigned *)(screens[0]), (double *) (image->data)); } - if (doShm) { - if (!XShmPutImage( X_display, X_mainWindow, X_gc, @@ -490,19 +354,14 @@ void I_FinishUpdate (void) X_width, X_height, True )) I_Error("XShmPutImage() failed\n"); - - shmFinished = false; do { I_GetEvent(); } while (!shmFinished); - } else { - - XPutImage( X_display, X_mainWindow, X_gc, @@ -510,43 +369,25 @@ void I_FinishUpdate (void) 0, 0, 0, 0, X_width, X_height ); - - XSync(X_display, False); - } - } - - - - - void I_ReadScreen (byte* scr) { memcpy (scr, screens[0], SCREENWIDTH*SCREENHEIGHT); } - - - - - static XColor colors[256]; - void UploadNewPalette(Colormap cmap, byte *palette) { - register int i; register int c; static boolean firstcall = true; - #ifdef __cplusplus if (X_visualinfo.c_class == PseudoColor && X_visualinfo.depth == 8) #else if (X_visualinfo.class == PseudoColor && X_visualinfo.depth == 8) #endif { - if (firstcall) { firstcall = false; @@ -556,8 +397,6 @@ void UploadNewPalette(Colormap cmap, byte *palette) colors[i].flags = DoRed|DoGreen|DoBlue; } } - - for (i=0 ; i<256 ; i++) { c = gammatable[usegamma][*palette++]; @@ -567,41 +406,21 @@ void UploadNewPalette(Colormap cmap, byte *palette) c = gammatable[usegamma][*palette++]; colors[i].blue = (c<<8) + c; } - - XStoreColors(X_display, cmap, colors, 256); - } } - - - - void I_SetPalette (byte* palette) { UploadNewPalette(X_cmap, palette); } - - - - - - - - - void grabsharedmemory(int size) { - int key = ('d'<<24) | ('o'<<16) | ('o'<<8) | 'm'; struct shmid_ds shminfo; int minsize = 320*200; int id; int rc; - int pollution=5; - - do { id = shmget((key_t) key, minsize, 0777); @@ -626,15 +445,11 @@ void grabsharedmemory(int size) "Was able to kill my old shared memory\n"); else I_Error("Was NOT able to kill my old shared memory"); - id = shmget((key_t)key, size, IPC_CREAT|0777); if (id==-1) I_Error("Could not get shared memory"); - rc=shmctl(id, IPC_STAT, &shminfo); - break; - } if (size >= shminfo.shm_segsz) { @@ -671,76 +486,52 @@ void grabsharedmemory(int size) break; } } while (--pollution); - if (!pollution) { I_Error("Sorry, system too polluted with stale " "shared memory segments.\n"); } - X_shminfo.shmid = id; - - image->data = X_shminfo.shmaddr = shmat(id, 0, 0); - fprintf(stderr, "shared memory id=%d, addr=0x%x\n", id, (int) (image->data)); } - void I_InitGraphics(void) { - char* displayname; char* d; int n; int pnum; int x=0; int y=0; - - char xsign=' '; char ysign=' '; - int oktodraw; unsigned long attribmask; XSetWindowAttributes attribs; XGCValues xgcvalues; int valuemask; static int firsttime=1; - if (!firsttime) return; firsttime = 0; - signal(SIGINT, (void (*)(int)) I_Quit); - if (M_CheckParm("-2")) multiply = 2; - if (M_CheckParm("-3")) multiply = 3; - if (M_CheckParm("-4")) multiply = 4; - X_width = SCREENWIDTH * multiply; X_height = SCREENHEIGHT * multiply; - - if ( (pnum=M_CheckParm("-disp")) ) displayname = myargv[pnum+1]; else displayname = 0; - - grabMouse = !!M_CheckParm("-grabmouse"); - - if ( (pnum=M_CheckParm("-geom")) ) { - n = sscanf(myargv[pnum+1], "%c%d%c%d", &xsign, &x, &ysign, &y); - if (n==2) x = y = 0; else if (n==6) @@ -753,8 +544,6 @@ void I_InitGraphics(void) else I_Error("bad -geom parameter"); } - - X_display = XOpenDisplay(displayname); if (!X_display) { @@ -763,17 +552,11 @@ void I_InitGraphics(void) else I_Error("Could not open display (DISPLAY=[%s])", getenv("DISPLAY")); } - - X_screen = DefaultScreen(X_display); if (!XMatchVisualInfo(X_display, X_screen, 8, PseudoColor, &X_visualinfo)) I_Error("xdoom currently only supports 256-color PseudoColor screens"); X_visual = X_visualinfo.visual; - - doShm = XShmQueryExtension(X_display); - - if (doShm) { if (!displayname) displayname = (char *) getenv("DISPLAY"); @@ -785,25 +568,16 @@ void I_InitGraphics(void) if (!(!strcasecmp(displayname, "unix") || !*displayname)) doShm = false; } } - fprintf(stderr, "Using MITSHM extension\n"); - - X_cmap = XCreateColormap(X_display, RootWindow(X_display, X_screen), X_visual, AllocAll); - - attribmask = CWEventMask | CWColormap | CWBorderPixel; attribs.event_mask = KeyPressMask | KeyReleaseMask - | ExposureMask; - attribs.colormap = X_cmap; attribs.border_pixel = 0; - - X_mainWindow = XCreateWindow( X_display, RootWindow(X_display, X_screen), x, y, @@ -814,22 +588,15 @@ void I_InitGraphics(void) X_visual, attribmask, &attribs ); - XDefineCursor(X_display, X_mainWindow, createnullcursor( X_display, X_mainWindow ) ); - - valuemask = GCGraphicsExposures; xgcvalues.graphics_exposures = False; X_gc = XCreateGC( X_display, X_mainWindow, valuemask, &xgcvalues ); - - XMapWindow(X_display, X_mainWindow); - - oktodraw = 0; while (!oktodraw) { @@ -840,20 +607,14 @@ void I_InitGraphics(void) oktodraw = 1; } } - - if (grabMouse) XGrabPointer(X_display, X_mainWindow, True, ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, X_mainWindow, None, CurrentTime); - if (doShm) { - X_shmeventtype = XShmGetEventBase(X_display) + ShmCompletion; - - image = XShmCreateImage( X_display, X_visual, 8, @@ -862,34 +623,14 @@ void I_InitGraphics(void) &X_shminfo, X_width, X_height ); - grabsharedmemory(image->bytes_per_line * image->height); - - - - - - - - - - - - - - - - if (!image->data) { perror(""); I_Error("shmat() failed in InitGraphics()"); } - - if (!XShmAttach(X_display, &X_shminfo)) I_Error("XShmAttach() failed in InitGraphics()"); - } else { @@ -902,41 +643,30 @@ void I_InitGraphics(void) X_width, X_height, 8, X_width ); - } - if (multiply == 1) screens[0] = (unsigned char *) (image->data); else screens[0] = (unsigned char *) malloc (SCREENWIDTH * SCREENHEIGHT); - } - - unsigned exptable[256]; - void InitExpand (void) { int i; - for (i=0 ; i<256 ; i++) exptable[i] = i | (i<<8) | (i<<16) | (i<<24); } - double exptable2[256*256]; - void InitExpand2 (void) { int i; int j; - double* exp; union { double d; unsigned u[2]; } pixel; - printf ("building exptable2...\n"); exp = exptable2; for (i=0 ; i<256 ; i++) @@ -950,9 +680,7 @@ void InitExpand2 (void) } printf ("done.\n"); } - int inited; - void Expand4 ( unsigned* lineptr, @@ -964,85 +692,66 @@ Expand4 unsigned fourpixels; unsigned step; double* exp; - exp = exptable2; if (!inited) { inited = 1; InitExpand2 (); } - - step = 3*SCREENWIDTH/2; - y = SCREENHEIGHT-1; do { x = SCREENWIDTH; - do { fourpixels = lineptr[0]; - dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) ); xline[0] = dpixel; xline[160] = dpixel; xline[320] = dpixel; xline[480] = dpixel; - dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) ); xline[1] = dpixel; xline[161] = dpixel; xline[321] = dpixel; xline[481] = dpixel; - fourpixels = lineptr[1]; - dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) ); xline[2] = dpixel; xline[162] = dpixel; xline[322] = dpixel; xline[482] = dpixel; - dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) ); xline[3] = dpixel; xline[163] = dpixel; xline[323] = dpixel; xline[483] = dpixel; - fourpixels = lineptr[2]; - dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) ); xline[4] = dpixel; xline[164] = dpixel; xline[324] = dpixel; xline[484] = dpixel; - dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) ); xline[5] = dpixel; xline[165] = dpixel; xline[325] = dpixel; xline[485] = dpixel; - fourpixels = lineptr[3]; - dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff0000)>>13) ); xline[6] = dpixel; xline[166] = dpixel; xline[326] = dpixel; xline[486] = dpixel; - dpixel = *(double *)( (int)exp + ( (fourpixels&0xffff)<<3 ) ); xline[7] = dpixel; xline[167] = dpixel; xline[327] = dpixel; xline[487] = dpixel; - lineptr+=4; xline+=8; } while (x-=16); xline += step; } while (y--); } - - diff --git a/src/i_video.h b/src/i_video.h @@ -1,63 +1,16 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __I_VIDEO__ #define __I_VIDEO__ - - #include "doomtype.h" - #ifdef __GNUG__ #pragma interface #endif - - - - - void I_InitGraphics (void); - - void I_ShutdownGraphics(void); - - void I_SetPalette (byte* palette); - void I_UpdateNoBlit (void); void I_FinishUpdate (void); - - void I_WaitVBL(int count); - void I_ReadScreen (byte* scr); - void I_BeginRead (void); void I_EndRead (void); - - - #endif - - - - - diff --git a/src/info.c b/src/info.c @@ -1,40 +1,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "sounds.h" #include "m_fixed.h" - #ifdef __GNUG__ #pragma implementation "info.h" #endif #include "info.h" - #include "p_mobj.h" - char *sprnames[NUMSPRITES] = { "TROO","SHTG","PUNG","PISG","PISF","SHTF","SHT2","CHGG","CHGF","MISG", "MISF","SAWG","PLSG","PLSF","BFGG","BFGF","BLUD","PUFF","BAL1","BAL2", @@ -51,9 +21,6 @@ char *sprnames[NUMSPRITES] = { "COL5","TBLU","TGRN","TRED","SMBT","SMGT","SMRT","HDB1","HDB2","HDB3", "HDB4","HDB5","HDB6","POB1","POB2","BRS1","TLMP","TLP2" }; - - - void A_Light0(); void A_WeaponReady(); void A_Lower(); @@ -128,8 +95,6 @@ void A_BrainSpit(); void A_SpawnSound(); void A_SpawnFly(); void A_BrainExplode(); - - state_t states[NUMSTATES] = { {SPR_TROO,0,-1,{NULL},S_NULL,0,0}, {SPR_SHTG,4,0,{A_Light0},S_NULL,0,0}, @@ -1099,10 +1064,7 @@ state_t states[NUMSTATES] = { {SPR_TLP2,32770,4,{NULL},S_TECH2LAMP4,0,0}, {SPR_TLP2,32771,4,{NULL},S_TECH2LAMP,0,0} }; - - mobjinfo_t mobjinfo[NUMMOBJTYPES] = { - { -1, S_PLAY, @@ -1128,7 +1090,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_PICKUP|MF_NOTDMATCH, S_NULL }, - { 3004, S_POSS_STND, @@ -1154,7 +1115,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_POSS_RAISE1 }, - { 9, S_SPOS_STND, @@ -1180,7 +1140,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_SPOS_RAISE1 }, - { 64, S_VILE_STND, @@ -1206,7 +1165,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_NULL }, - { -1, S_FIRE1, @@ -1232,7 +1190,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_NOGRAVITY, S_NULL }, - { 66, S_SKEL_STND, @@ -1258,7 +1215,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_SKEL_RAISE1 }, - { -1, S_TRACER, @@ -1284,7 +1240,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, S_NULL }, - { -1, S_SMOKE1, @@ -1310,7 +1265,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_NOGRAVITY, S_NULL }, - { 67, S_FATT_STND, @@ -1336,7 +1290,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_FATT_RAISE1 }, - { -1, S_FATSHOT1, @@ -1362,7 +1315,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, S_NULL }, - { 65, S_CPOS_STND, @@ -1388,7 +1340,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_CPOS_RAISE1 }, - { 3001, S_TROO_STND, @@ -1414,7 +1365,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_TROO_RAISE1 }, - { 3002, S_SARG_STND, @@ -1440,7 +1390,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_SARG_RAISE1 }, - { 58, S_SARG_STND, @@ -1466,7 +1415,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_SHADOW|MF_COUNTKILL, S_SARG_RAISE1 }, - { 3005, S_HEAD_STND, @@ -1492,7 +1440,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL, S_HEAD_RAISE1 }, - { 3003, S_BOSS_STND, @@ -1518,7 +1465,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_BOSS_RAISE1 }, - { -1, S_BRBALL1, @@ -1544,7 +1490,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, S_NULL }, - { 69, S_BOS2_STND, @@ -1570,7 +1515,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_BOS2_RAISE1 }, - { 3006, S_SKULL_STND, @@ -1596,7 +1540,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY, S_NULL }, - { 7, S_SPID_STND, @@ -1622,7 +1565,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_NULL }, - { 68, S_BSPI_STND, @@ -1648,7 +1590,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_BSPI_RAISE1 }, - { 16, S_CYBER_STND, @@ -1674,7 +1615,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_NULL }, - { 71, S_PAIN_STND, @@ -1700,7 +1640,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL, S_PAIN_RAISE1 }, - { 84, S_SSWV_STND, @@ -1726,7 +1665,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, S_SSWV_RAISE1 }, - { 72, S_KEENSTND, @@ -1752,7 +1690,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY|MF_SHOOTABLE|MF_COUNTKILL, S_NULL }, - { 88, S_BRAIN, @@ -1778,7 +1715,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE, S_NULL }, - { 89, S_BRAINEYE, @@ -1804,7 +1740,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_NOSECTOR, S_NULL }, - { 87, S_NULL, @@ -1830,7 +1765,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_NOSECTOR, S_NULL }, - { -1, S_SPAWN1, @@ -1856,7 +1790,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY|MF_NOCLIP, S_NULL }, - { -1, S_SPAWNFIRE1, @@ -1882,7 +1815,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_NOGRAVITY, S_NULL }, - { 2035, S_BAR1, @@ -1908,7 +1840,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SHOOTABLE|MF_NOBLOOD, S_NULL }, - { -1, S_TBALL1, @@ -1934,7 +1865,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, S_NULL }, - { -1, S_RBALL1, @@ -1960,7 +1890,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, S_NULL }, - { -1, S_ROCKET, @@ -1986,7 +1915,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, S_NULL }, - { -1, S_PLASBALL, @@ -2012,7 +1940,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, S_NULL }, - { -1, S_BFGSHOT, @@ -2038,7 +1965,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, S_NULL }, - { -1, S_ARACH_PLAZ, @@ -2064,7 +1990,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, S_NULL }, - { -1, S_PUFF1, @@ -2090,7 +2015,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_NOGRAVITY, S_NULL }, - { -1, S_BLOOD1, @@ -2116,7 +2040,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP, S_NULL }, - { -1, S_TFOG, @@ -2142,7 +2065,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_NOGRAVITY, S_NULL }, - { -1, S_IFOG, @@ -2168,7 +2090,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_NOGRAVITY, S_NULL }, - { 14, S_NULL, @@ -2194,7 +2115,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_NOSECTOR, S_NULL }, - { -1, S_BFGEXP, @@ -2220,7 +2140,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP|MF_NOGRAVITY, S_NULL }, - { 2018, S_ARM1, @@ -2246,7 +2165,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2019, S_ARM2, @@ -2272,7 +2190,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2014, S_BON1, @@ -2298,7 +2215,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_COUNTITEM, S_NULL }, - { 2015, S_BON2, @@ -2324,7 +2240,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_COUNTITEM, S_NULL }, - { 5, S_BKEY, @@ -2350,7 +2265,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_NOTDMATCH, S_NULL }, - { 13, S_RKEY, @@ -2376,7 +2290,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_NOTDMATCH, S_NULL }, - { 6, S_YKEY, @@ -2402,7 +2315,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_NOTDMATCH, S_NULL }, - { 39, S_YSKULL, @@ -2428,7 +2340,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_NOTDMATCH, S_NULL }, - { 38, S_RSKULL, @@ -2454,7 +2365,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_NOTDMATCH, S_NULL }, - { 40, S_BSKULL, @@ -2480,7 +2390,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_NOTDMATCH, S_NULL }, - { 2011, S_STIM, @@ -2506,7 +2415,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2012, S_MEDI, @@ -2532,7 +2440,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2013, S_SOUL, @@ -2558,7 +2465,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_COUNTITEM, S_NULL }, - { 2022, S_PINV, @@ -2584,7 +2490,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_COUNTITEM, S_NULL }, - { 2023, S_PSTR, @@ -2610,7 +2515,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_COUNTITEM, S_NULL }, - { 2024, S_PINS, @@ -2636,7 +2540,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_COUNTITEM, S_NULL }, - { 2025, S_SUIT, @@ -2662,7 +2565,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2026, S_PMAP, @@ -2688,7 +2590,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_COUNTITEM, S_NULL }, - { 2045, S_PVIS, @@ -2714,7 +2615,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_COUNTITEM, S_NULL }, - { 83, S_MEGA, @@ -2740,7 +2640,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL|MF_COUNTITEM, S_NULL }, - { 2007, S_CLIP, @@ -2766,7 +2665,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2048, S_AMMO, @@ -2792,7 +2690,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2010, S_ROCK, @@ -2818,7 +2715,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2046, S_BROK, @@ -2844,7 +2740,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2047, S_CELL, @@ -2870,7 +2765,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 17, S_CELP, @@ -2896,7 +2790,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2008, S_SHEL, @@ -2922,7 +2815,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2049, S_SBOX, @@ -2948,7 +2840,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 8, S_BPAK, @@ -2974,7 +2865,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2006, S_BFUG, @@ -3000,7 +2890,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2002, S_MGUN, @@ -3026,7 +2915,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2005, S_CSAW, @@ -3052,7 +2940,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2003, S_LAUN, @@ -3078,7 +2965,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2004, S_PLAS, @@ -3104,7 +2990,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 2001, S_SHOT, @@ -3130,7 +3015,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 82, S_SHOT2, @@ -3156,7 +3040,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPECIAL, S_NULL }, - { 85, S_TECHLAMP, @@ -3182,7 +3065,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 86, S_TECH2LAMP, @@ -3208,7 +3090,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 2028, S_COLU, @@ -3234,7 +3115,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 30, S_TALLGRNCOL, @@ -3260,7 +3140,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 31, S_SHRTGRNCOL, @@ -3286,7 +3165,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 32, S_TALLREDCOL, @@ -3312,7 +3190,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 33, S_SHRTREDCOL, @@ -3338,7 +3215,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 37, S_SKULLCOL, @@ -3364,7 +3240,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 36, S_HEARTCOL, @@ -3390,7 +3265,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 41, S_EVILEYE, @@ -3416,7 +3290,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 42, S_FLOATSKULL, @@ -3442,7 +3315,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 43, S_TORCHTREE, @@ -3468,7 +3340,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 44, S_BLUETORCH, @@ -3494,7 +3365,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 45, S_GREENTORCH, @@ -3520,7 +3390,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 46, S_REDTORCH, @@ -3546,7 +3415,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 55, S_BTORCHSHRT, @@ -3572,7 +3440,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 56, S_GTORCHSHRT, @@ -3598,7 +3465,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 57, S_RTORCHSHRT, @@ -3624,7 +3490,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 47, S_STALAGTITE, @@ -3650,7 +3515,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 48, S_TECHPILLAR, @@ -3676,7 +3540,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 34, S_CANDLESTIK, @@ -3702,7 +3565,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 35, S_CANDELABRA, @@ -3728,7 +3590,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 49, S_BLOODYTWITCH, @@ -3754,7 +3615,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 50, S_MEAT2, @@ -3780,7 +3640,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 51, S_MEAT3, @@ -3806,7 +3665,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 52, S_MEAT4, @@ -3832,7 +3690,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 53, S_MEAT5, @@ -3858,7 +3715,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 59, S_MEAT2, @@ -3884,7 +3740,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 60, S_MEAT4, @@ -3910,7 +3765,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 61, S_MEAT3, @@ -3936,7 +3790,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 62, S_MEAT5, @@ -3962,7 +3815,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 63, S_BLOODYTWITCH, @@ -3988,7 +3840,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 22, S_HEAD_DIE6, @@ -4014,7 +3865,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 15, S_PLAY_DIE7, @@ -4040,7 +3890,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 18, S_POSS_DIE5, @@ -4066,7 +3915,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 21, S_SARG_DIE6, @@ -4092,7 +3940,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 23, S_SKULL_DIE6, @@ -4118,7 +3965,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 20, S_TROO_DIE5, @@ -4144,7 +3990,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 19, S_SPOS_DIE5, @@ -4170,7 +4015,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 10, S_PLAY_XDIE9, @@ -4196,7 +4040,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 12, S_PLAY_XDIE9, @@ -4222,7 +4065,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 28, S_HEADSONSTICK, @@ -4248,7 +4090,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 24, S_GIBS, @@ -4274,7 +4115,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { 0, S_NULL }, - { 27, S_HEADONASTICK, @@ -4300,7 +4140,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 29, S_HEADCANDLES, @@ -4326,7 +4165,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 25, S_DEADSTICK, @@ -4352,7 +4190,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 26, S_LIVESTICK, @@ -4378,7 +4215,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 54, S_BIGTREE, @@ -4404,7 +4240,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 70, S_BBAR1, @@ -4430,7 +4265,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID, S_NULL }, - { 73, S_HANGNOGUTS, @@ -4456,7 +4290,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 74, S_HANGBNOBRAIN, @@ -4482,7 +4315,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 75, S_HANGTLOOKDN, @@ -4508,7 +4340,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 76, S_HANGTSKULL, @@ -4534,7 +4365,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 77, S_HANGTLOOKUP, @@ -4560,7 +4390,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 78, S_HANGTNOBRAIN, @@ -4586,7 +4415,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, S_NULL }, - { 79, S_COLONGIBS, @@ -4612,7 +4440,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP, S_NULL }, - { 80, S_SMALLPOOL, @@ -4638,7 +4465,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { MF_NOBLOCKMAP, S_NULL }, - { 81, S_BRAINSTEM, @@ -4665,4 +4491,3 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { S_NULL } }; - diff --git a/src/info.h b/src/info.h @@ -1,32 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - #ifndef __INFO__ #define __INFO__ - - #include "d_think.h" - typedef enum { SPR_TROO, @@ -168,9 +142,7 @@ typedef enum SPR_TLMP, SPR_TLP2, NUMSPRITES - } spritenum_t; - typedef enum { S_NULL, @@ -1142,24 +1114,17 @@ typedef enum S_TECH2LAMP4, NUMSTATES } statenum_t; - - typedef struct { spritenum_t sprite; long frame; long tics; - actionf_t action; statenum_t nextstate; long misc1, misc2; } state_t; - extern state_t states[NUMSTATES]; extern char *sprnames[NUMSPRITES]; - - - typedef enum { MT_PLAYER, MT_POSSESSED, @@ -1299,9 +1264,7 @@ typedef enum { MT_MISC85, MT_MISC86, NUMMOBJTYPES - } mobjtype_t; - typedef struct { int doomednum; @@ -1327,14 +1290,6 @@ typedef struct int activesound; int flags; int raisestate; - } mobjinfo_t; - extern mobjinfo_t mobjinfo[NUMMOBJTYPES]; - #endif - - - - - diff --git a/src/m_argv.c b/src/m_argv.c @@ -1,54 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include <string.h> - int myargc; char** myargv; - - - - - - - - - - int M_CheckParm (char *check) { int i; - for (i = 1;i<myargc;i++) { if ( !strcasecmp(check, myargv[i]) ) return i; } - return 0; } - - - - diff --git a/src/m_argv.h b/src/m_argv.h @@ -1,42 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __M_ARGV__ #define __M_ARGV__ - - - - extern int myargc; extern char** myargv; - - - int M_CheckParm (char* check); - - #endif - - - - - diff --git a/src/m_bbox.c b/src/m_bbox.c @@ -1,45 +1,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - #ifdef __GNUG__ #pragma implementation "m_bbox.h" #endif #include "m_bbox.h" - - - - void M_ClearBox (fixed_t *box) { box[BOXTOP] = box[BOXRIGHT] = MININT; box[BOXBOTTOM] = box[BOXLEFT] = MAXINT; } - void M_AddToBox ( fixed_t* box, @@ -55,8 +22,3 @@ M_AddToBox else if (y>box[BOXTOP]) box[BOXTOP] = y; } - - - - - diff --git a/src/m_bbox.h b/src/m_bbox.h @@ -1,34 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __M_BBOX__ #define __M_BBOX__ - #include <values.h> - #include "m_fixed.h" - - - enum { BOXTOP, @@ -36,20 +9,10 @@ enum BOXLEFT, BOXRIGHT }; - - void M_ClearBox (fixed_t* box); - void M_AddToBox ( fixed_t* box, fixed_t x, fixed_t y ); - - #endif - - - - - diff --git a/src/m_cheat.c b/src/m_cheat.c @@ -1,42 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include "m_cheat.h" - - - - - static int firsttime = 1; static unsigned char cheat_xlate_table[256]; - - - - - - int cht_CheckCheat ( cheatseq_t* cht, @@ -44,23 +8,19 @@ cht_CheckCheat { int i; int rc = 0; - if (firsttime) { firsttime = 0; for (i=0;i<256;i++) cheat_xlate_table[i] = SCRAMBLE(i); } - if (!cht->p) cht->p = cht->sequence; - if (*cht->p == 0) *(cht->p++) = key; else if (cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++; else cht->p = cht->sequence; - if (*cht->p == 1) cht->p++; else if (*cht->p == 0xff) @@ -68,21 +28,16 @@ cht_CheckCheat cht->p = cht->sequence; rc = 1; } - return rc; } - void cht_GetParam ( cheatseq_t* cht, char* buffer ) { - unsigned char *p, c; - p = cht->sequence; while (*(p++) != 1); - do { c = *p; @@ -90,10 +45,6 @@ cht_GetParam *(p++) = 0; } while (c && *p!=0xff ); - if (*p==0xff) *buffer = 0; - } - - diff --git a/src/m_cheat.h b/src/m_cheat.h @@ -1,58 +1,19 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __M_CHEAT__ #define __M_CHEAT__ - - - - - #define SCRAMBLE(a) \ ((((a)&1)<<7) + (((a)&2)<<5) + ((a)&4) + (((a)&8)<<1) \ + (((a)&16)>>1) + ((a)&32) + (((a)&64)>>5) + (((a)&128)>>7)) - typedef struct { unsigned char* sequence; unsigned char* p; - } cheatseq_t; - int cht_CheckCheat ( cheatseq_t* cht, char key ); - - void cht_GetParam ( cheatseq_t* cht, char* buffer ); - - #endif - - - - - diff --git a/src/m_fixed.c b/src/m_fixed.c @@ -1,43 +1,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include "stdlib.h" - #include "doomtype.h" #include "i_system.h" - #ifdef __GNUG__ #pragma implementation "m_fixed.h" #endif #include "m_fixed.h" - - - - - - fixed_t FixedMul ( fixed_t a, @@ -45,13 +12,6 @@ FixedMul { return ((long long) a * (long long) b) >> FRACBITS; } - - - - - - - fixed_t FixedDiv ( fixed_t a, @@ -61,9 +21,6 @@ FixedDiv return (a^b)<0 ? MININT : MAXINT; return FixedDiv2 (a,b); } - - - fixed_t FixedDiv2 ( fixed_t a, @@ -74,11 +31,8 @@ FixedDiv2 c = ((long long)a<<16) / ((long long)b); return (fixed_t) c; #endif - double c; - c = ((double)a) / ((double)b) * FRACUNIT; - if (c >= 2147483648.0 || c < -2147483648.0) I_Error("FixedDiv: divide by zero"); return (fixed_t) c; diff --git a/src/m_fixed.h b/src/m_fixed.h @@ -1,51 +1,12 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __M_FIXED__ #define __M_FIXED__ - - #ifdef __GNUG__ #pragma interface #endif - - - - - #define FRACBITS 16 #define FRACUNIT (1<<FRACBITS) - typedef int fixed_t; - fixed_t FixedMul (fixed_t a, fixed_t b); fixed_t FixedDiv (fixed_t a, fixed_t b); fixed_t FixedDiv2 (fixed_t a, fixed_t b); - - - #endif - - - - - diff --git a/src/m_menu.c b/src/m_menu.c @@ -1,109 +1,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdlib.h> #include <ctype.h> - - #include "doomdef.h" #include "dstrings.h" - #include "d_main.h" - #include "i_system.h" #include "i_video.h" #include "z_zone.h" #include "v_video.h" #include "w_wad.h" - #include "r_local.h" - - #include "hu_stuff.h" - #include "g_game.h" - #include "m_argv.h" #include "m_swap.h" - #include "s_sound.h" - #include "doomstat.h" - - #include "sounds.h" - #include "m_menu.h" - - - extern patch_t* hu_font[HU_FONTSIZE]; extern boolean message_dontfuckwithme; - extern boolean chat_on; - - - - int mouseSensitivity; - - int showMessages; - - - int detailLevel; int screenblocks; - - int screenSize; - - int quickSaveSlot; - - int messageToPrint; - char* messageString; - - int messx; int messy; int messageLastMenuActive; - - boolean messageNeedsInput; - void (*messageRoutine)(int response); - #define SAVESTRINGSIZE 24 - char gammamsg[5][26] = { GAMMALVL0, @@ -112,47 +46,24 @@ char gammamsg[5][26] = GAMMALVL3, GAMMALVL4 }; - - int saveStringEnter; int saveSlot; int saveCharIndex; - char saveOldString[SAVESTRINGSIZE]; - boolean inhelpscreens; boolean menuactive; - #define SKULLXOFF -32 #define LINEHEIGHT 16 - extern boolean sendpause; char savegamestrings[10][SAVESTRINGSIZE]; - char endstring[160]; - - - - - typedef struct { - short status; - char name[10]; - - - - void (*routine)(int choice); - - char alphaKey; } menuitem_t; - - - typedef struct menu_s { short numitems; @@ -163,21 +74,11 @@ typedef struct menu_s short y; short lastOn; } menu_t; - short itemOn; short skullAnimCounter; short whichSkull; - - - char skullName[2][/*8*/9] = {"M_SKULL1","M_SKULL2"}; - - menu_t* currentMenu; - - - - void M_NewGame(int choice); void M_Episode(int choice); void M_ChooseSkill(int choice); @@ -188,7 +89,6 @@ void M_EndGame(int choice); void M_ReadThis(int choice); void M_ReadThis2(int choice); void M_QuitDOOM(int choice); - void M_ChangeMessages(int choice); void M_ChangeSensitivity(int choice); void M_SfxVol(int choice); @@ -197,14 +97,12 @@ void M_ChangeDetail(int choice); void M_SizeDisplay(int choice); void M_StartGame(int choice); void M_Sound(int choice); - void M_FinishReadThis(int choice); void M_LoadSelect(int choice); void M_SaveSelect(int choice); void M_ReadSaveStrings(void); void M_QuickSave(void); void M_QuickLoad(void); - void M_DrawMainMenu(void); void M_DrawReadThis1(void); void M_DrawReadThis2(void); @@ -214,7 +112,6 @@ void M_DrawOptions(void); void M_DrawSound(void); void M_DrawLoad(void); void M_DrawSave(void); - void M_DrawSaveLoadBorder(int x,int y); void M_SetupNextMenu(menu_t *menudef); void M_DrawThermo(int x,int y,int thermWidth,int thermDot); @@ -227,13 +124,6 @@ void M_StartControlPanel(void); void M_StartMessage(char *string,void *routine,boolean input); void M_StopMessage(void); void M_ClearMenus (void); - - - - - - - enum { newgame = 0, @@ -244,18 +134,15 @@ enum quitdoom, main_end } main_e; - menuitem_t MainMenu[]= { {1,"M_NGAME",M_NewGame,'n'}, {1,"M_OPTION",M_Options,'o'}, {1,"M_LOADG",M_LoadGame,'l'}, {1,"M_SAVEG",M_SaveGame,'s'}, - {1,"M_RDTHIS",M_ReadThis,'r'}, {1,"M_QUITG",M_QuitDOOM,'q'} }; - menu_t MainDef = { main_end, @@ -265,11 +152,6 @@ menu_t MainDef = 97,64, 0 }; - - - - - enum { ep1, @@ -278,7 +160,6 @@ enum ep4, ep_end } episodes_e; - menuitem_t EpisodeMenu[]= { {1,"M_EPI1", M_Episode,'k'}, @@ -286,7 +167,6 @@ menuitem_t EpisodeMenu[]= {1,"M_EPI3", M_Episode,'i'}, {1,"M_EPI4", M_Episode,'t'} }; - menu_t EpiDef = { ep_end, @@ -296,10 +176,6 @@ menu_t EpiDef = 48,63, ep1 }; - - - - enum { killthings, @@ -309,7 +185,6 @@ enum nightmare, newg_end } newgame_e; - menuitem_t NewGameMenu[]= { {1,"M_JKILL", M_ChooseSkill, 'i'}, @@ -318,7 +193,6 @@ menuitem_t NewGameMenu[]= {1,"M_ULTRA", M_ChooseSkill, 'u'}, {1,"M_NMARE", M_ChooseSkill, 'n'} }; - menu_t NewDef = { newg_end, @@ -328,12 +202,6 @@ menu_t NewDef = 48,63, hurtme }; - - - - - - enum { endgame, @@ -346,7 +214,6 @@ enum soundvol, opt_end } options_e; - menuitem_t OptionsMenu[]= { {1,"M_ENDGAM", M_EndGame,'e'}, @@ -358,7 +225,6 @@ menuitem_t OptionsMenu[]= {-1,"",0}, {1,"M_SVOL", M_Sound,'s'} }; - menu_t OptionsDef = { opt_end, @@ -368,21 +234,15 @@ menu_t OptionsDef = 60,37, 0 }; - - - - enum { rdthsempty1, read1_end } read_e; - menuitem_t ReadMenu1[] = { {1,"",M_ReadThis2,0} }; - menu_t ReadDef1 = { read1_end, @@ -392,18 +252,15 @@ menu_t ReadDef1 = 280,185, 0 }; - enum { rdthsempty2, read2_end } read_e2; - menuitem_t ReadMenu2[]= { {1,"",M_FinishReadThis,0} }; - menu_t ReadDef2 = { read2_end, @@ -413,10 +270,6 @@ menu_t ReadDef2 = 330,175, 0 }; - - - - enum { sfx_vol, @@ -425,7 +278,6 @@ enum sfx_empty2, sound_end } sound_e; - menuitem_t SoundMenu[]= { {2,"M_SFXVOL",M_SfxVol,'s'}, @@ -433,7 +285,6 @@ menuitem_t SoundMenu[]= {2,"M_MUSVOL",M_MusicVol,'m'}, {-1,"",0} }; - menu_t SoundDef = { sound_end, @@ -443,10 +294,6 @@ menu_t SoundDef = 80,64, 0 }; - - - - enum { load1, @@ -457,7 +304,6 @@ enum load6, load_end } load_e; - menuitem_t LoadMenu[]= { {1,"", M_LoadSelect,'1'}, @@ -467,7 +313,6 @@ menuitem_t LoadMenu[]= {1,"", M_LoadSelect,'5'}, {1,"", M_LoadSelect,'6'} }; - menu_t LoadDef = { load_end, @@ -477,10 +322,6 @@ menu_t LoadDef = 80,54, 0 }; - - - - menuitem_t SaveMenu[]= { {1,"", M_SaveSelect,'1'}, @@ -490,7 +331,6 @@ menuitem_t SaveMenu[]= {1,"", M_SaveSelect,'5'}, {1,"", M_SaveSelect,'6'} }; - menu_t SaveDef = { load_end, @@ -500,26 +340,18 @@ menu_t SaveDef = 80,54, 0 }; - - - - - - void M_ReadSaveStrings(void) { int handle; int count; int i; char name[256]; - for (i = 0;i < load_end;i++) { if (M_CheckParm("-cdrom")) sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",i); else sprintf(name,SAVEGAMENAME"%d.dsg",i); - handle = open (name, O_RDONLY | 0, 0666); if (handle == -1) { @@ -532,15 +364,9 @@ void M_ReadSaveStrings(void) LoadMenu[i].status = 1; } } - - - - - void M_DrawLoad(void) { int i; - V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_LOADG",PU_CACHE)); for (i = 0;i < load_end; i++) { @@ -548,36 +374,20 @@ void M_DrawLoad(void) M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]); } } - - - - - - void M_DrawSaveLoadBorder(int x,int y) { int i; - V_DrawPatchDirect (x-8,y+7,0,W_CacheLumpName("M_LSLEFT",PU_CACHE)); - for (i = 0;i < 24;i++) { V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSCNTR",PU_CACHE)); x += 8; } - V_DrawPatchDirect (x,y+7,0,W_CacheLumpName("M_LSRGHT",PU_CACHE)); } - - - - - - void M_LoadSelect(int choice) { char name[256]; - if (M_CheckParm("-cdrom")) sprintf(name,"c:\\doomdata\\"SAVEGAMENAME"%d.dsg",choice); else @@ -585,10 +395,6 @@ void M_LoadSelect(int choice) G_LoadGame (name); M_ClearMenus (); } - - - - void M_LoadGame (int choice) { if (netgame) @@ -596,64 +402,40 @@ void M_LoadGame (int choice) M_StartMessage(LOADNET,NULL,false); return; } - M_SetupNextMenu(&LoadDef); M_ReadSaveStrings(); } - - - - - void M_DrawSave(void) { int i; - V_DrawPatchDirect (72,28,0,W_CacheLumpName("M_SAVEG",PU_CACHE)); for (i = 0;i < load_end; i++) { M_DrawSaveLoadBorder(LoadDef.x,LoadDef.y+LINEHEIGHT*i); M_WriteText(LoadDef.x,LoadDef.y+LINEHEIGHT*i,savegamestrings[i]); } - if (saveStringEnter) { i = M_StringWidth(savegamestrings[saveSlot]); M_WriteText(LoadDef.x + i,LoadDef.y+LINEHEIGHT*saveSlot,"_"); } } - - - - void M_DoSave(int slot) { G_SaveGame (slot,savegamestrings[slot]); M_ClearMenus (); - - if (quickSaveSlot == -2) quickSaveSlot = slot; } - - - - void M_SaveSelect(int choice) { - saveStringEnter = 1; - saveSlot = choice; strcpy(saveOldString,savegamestrings[choice]); if (!strcmp(savegamestrings[choice],EMPTYSTRING)) savegamestrings[choice][0] = 0; saveCharIndex = strlen(savegamestrings[choice]); } - - - - void M_SaveGame (int choice) { if (!usergame) @@ -661,21 +443,12 @@ void M_SaveGame (int choice) M_StartMessage(SAVEDEAD,NULL,false); return; } - if (gamestate != GS_LEVEL) return; - M_SetupNextMenu(&SaveDef); M_ReadSaveStrings(); } - - - - - - char tempstring[80]; - void M_QuickSaveResponse(int ch) { if (ch == 'y') @@ -684,7 +457,6 @@ void M_QuickSaveResponse(int ch) S_StartSound(NULL,sfx_swtchx); } } - void M_QuickSave(void) { if (!usergame) @@ -692,10 +464,8 @@ void M_QuickSave(void) S_StartSound(NULL,sfx_oof); return; } - if (gamestate != GS_LEVEL) return; - if (quickSaveSlot < 0) { M_StartControlPanel(); @@ -707,12 +477,6 @@ void M_QuickSave(void) sprintf(tempstring,QSPROMPT,savegamestrings[quickSaveSlot]); M_StartMessage(tempstring,M_QuickSaveResponse,true); } - - - - - - void M_QuickLoadResponse(int ch) { if (ch == 'y') @@ -721,8 +485,6 @@ void M_QuickLoadResponse(int ch) S_StartSound(NULL,sfx_swtchx); } } - - void M_QuickLoad(void) { if (netgame) @@ -730,7 +492,6 @@ void M_QuickLoad(void) M_StartMessage(QLOADNET,NULL,false); return; } - if (quickSaveSlot < 0) { M_StartMessage(QSAVESPOT,NULL,false); @@ -739,14 +500,6 @@ void M_QuickLoad(void) sprintf(tempstring,QLPROMPT,savegamestrings[quickSaveSlot]); M_StartMessage(tempstring,M_QuickLoadResponse,true); } - - - - - - - - void M_DrawReadThis1(void) { inhelpscreens = true; @@ -765,12 +518,6 @@ void M_DrawReadThis1(void) } return; } - - - - - - void M_DrawReadThis2(void) { inhelpscreens = true; @@ -778,7 +525,6 @@ void M_DrawReadThis2(void) { case retail: case commercial: - V_DrawPatchDirect (0,0,0,W_CacheLumpName("CREDIT",PU_CACHE)); break; case shareware: @@ -790,27 +536,18 @@ void M_DrawReadThis2(void) } return; } - - - - - void M_DrawSound(void) { V_DrawPatchDirect (60,38,0,W_CacheLumpName("M_SVOL",PU_CACHE)); - M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(sfx_vol+1), 16,snd_SfxVolume); - M_DrawThermo(SoundDef.x,SoundDef.y+LINEHEIGHT*(music_vol+1), 16,snd_MusicVolume); } - void M_Sound(int choice) { M_SetupNextMenu(&SoundDef); } - void M_SfxVol(int choice) { switch(choice) @@ -824,10 +561,8 @@ void M_SfxVol(int choice) snd_SfxVolume++; break; } - S_SetSfxVolume(snd_SfxVolume /* *8 */); } - void M_MusicVol(int choice) { switch(choice) @@ -841,33 +576,17 @@ void M_MusicVol(int choice) snd_MusicVolume++; break; } - S_SetMusicVolume(snd_MusicVolume /* *8 */); } - - - - - - - void M_DrawMainMenu(void) { V_DrawPatchDirect (94,2,0,W_CacheLumpName("M_DOOM",PU_CACHE)); } - - - - - - - void M_DrawNewGame(void) { V_DrawPatchDirect (96,14,0,W_CacheLumpName("M_NEWG",PU_CACHE)); V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_SKILL",PU_CACHE)); } - void M_NewGame(int choice) { if (netgame && !demoplayback) @@ -875,33 +594,23 @@ void M_NewGame(int choice) M_StartMessage(NEWGAME,NULL,false); return; } - if ( gamemode == commercial ) M_SetupNextMenu(&NewDef); else M_SetupNextMenu(&EpiDef); } - - - - - int epi; - void M_DrawEpisode(void) { V_DrawPatchDirect (54,38,0,W_CacheLumpName("M_EPISOD",PU_CACHE)); } - void M_VerifyNightmare(int ch) { if (ch != 'y') return; - G_DeferedInitNew(nightmare,epi+1,1); M_ClearMenus (); } - void M_ChooseSkill(int choice) { if (choice == nightmare) @@ -909,11 +618,9 @@ void M_ChooseSkill(int choice) M_StartMessage(NIGHTMARE,M_VerifyNightmare,true); return; } - G_DeferedInitNew(choice,epi+1,1); M_ClearMenus (); } - void M_Episode(int choice) { if ( (gamemode == shareware) @@ -923,8 +630,6 @@ void M_Episode(int choice) M_SetupNextMenu(&ReadDef1); return; } - - if ( (gamemode == registered) && (choice > 2)) { @@ -932,75 +637,45 @@ void M_Episode(int choice) "M_Episode: 4th episode requires UltimateDOOM\n"); choice = 0; } - epi = choice; M_SetupNextMenu(&NewDef); } - - - - - - char detailNames[2][9] = {"M_GDHIGH","M_GDLOW"}; char msgNames[2][9] = {"M_MSGOFF","M_MSGON"}; - - void M_DrawOptions(void) { V_DrawPatchDirect (108,15,0,W_CacheLumpName("M_OPTTTL",PU_CACHE)); - V_DrawPatchDirect (OptionsDef.x + 175,OptionsDef.y+LINEHEIGHT*detail,0, W_CacheLumpName(detailNames[detailLevel],PU_CACHE)); - V_DrawPatchDirect (OptionsDef.x + 120,OptionsDef.y+LINEHEIGHT*messages,0, W_CacheLumpName(msgNames[showMessages],PU_CACHE)); - M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(mousesens+1), 10,mouseSensitivity); - M_DrawThermo(OptionsDef.x,OptionsDef.y+LINEHEIGHT*(scrnsize+1), 9,screenSize); } - void M_Options(int choice) { M_SetupNextMenu(&OptionsDef); } - - - - - - void M_ChangeMessages(int choice) { - choice = 0; showMessages = 1 - showMessages; - if (!showMessages) players[consoleplayer].message = MSGOFF; else players[consoleplayer].message = MSGON ; - message_dontfuckwithme = true; } - - - - - void M_EndGameResponse(int ch) { if (ch != 'y') return; - currentMenu->lastOn = itemOn; M_ClearMenus (); D_StartTitle (); } - void M_EndGame(int choice) { choice = 0; @@ -1009,46 +684,28 @@ void M_EndGame(int choice) S_StartSound(NULL,sfx_oof); return; } - if (netgame) { M_StartMessage(NETEND,NULL,false); return; } - M_StartMessage(ENDGAME,M_EndGameResponse,true); } - - - - - - - void M_ReadThis(int choice) { choice = 0; M_SetupNextMenu(&ReadDef1); } - void M_ReadThis2(int choice) { choice = 0; M_SetupNextMenu(&ReadDef2); } - void M_FinishReadThis(int choice) { choice = 0; M_SetupNextMenu(&MainDef); } - - - - - - - int quitsounds[8] = { sfx_pldeth, @@ -1060,7 +717,6 @@ int quitsounds[8] = sfx_posit3, sfx_sgtatk }; - int quitsounds2[8] = { sfx_vilact, @@ -1072,9 +728,6 @@ int quitsounds2[8] = sfx_bspact, sfx_sgtatk }; - - - void M_QuitResponse(int ch) { if (ch != 'y') @@ -1089,25 +742,14 @@ void M_QuitResponse(int ch) } I_Quit (); } - - - - void M_QuitDOOM(int choice) { - - if (language != english ) sprintf(endstring,"%s\n\n"DOSY, endmsg[0] ); else sprintf(endstring,"%s\n\n"DOSY, endmsg[ (gametic%(NUM_QUITMESSAGES-2))+1 ]); - M_StartMessage(endstring,M_QuitResponse,true); } - - - - void M_ChangeSensitivity(int choice) { switch(choice) @@ -1122,31 +764,18 @@ void M_ChangeSensitivity(int choice) break; } } - - - - void M_ChangeDetail(int choice) { choice = 0; detailLevel = 1 - detailLevel; - - fprintf( stderr, "M_ChangeDetail: low detail mode n.a.\n"); - return; - /*R_SetViewSize (screenblocks, detailLevel); - if (!detailLevel) players[consoleplayer].message = DETAILHI; else players[consoleplayer].message = DETAILLO;*/ } - - - - void M_SizeDisplay(int choice) { switch(choice) @@ -1166,17 +795,8 @@ void M_SizeDisplay(int choice) } break; } - - R_SetViewSize (screenblocks, detailLevel); } - - - - - - - void M_DrawThermo ( int x, @@ -1186,7 +806,6 @@ M_DrawThermo { int xx; int i; - xx = x; V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERML",PU_CACHE)); xx += 8; @@ -1196,13 +815,9 @@ M_DrawThermo xx += 8; } V_DrawPatchDirect (xx,y,0,W_CacheLumpName("M_THERMR",PU_CACHE)); - V_DrawPatchDirect ((x+8) + thermDot*8,y, 0,W_CacheLumpName("M_THERMO",PU_CACHE)); } - - - void M_DrawEmptyCell ( menu_t* menu, @@ -1211,7 +826,6 @@ M_DrawEmptyCell V_DrawPatchDirect (menu->x - 10, menu->y+item*LINEHEIGHT - 1, 0, W_CacheLumpName("M_CELL1",PU_CACHE)); } - void M_DrawSelCell ( menu_t* menu, @@ -1220,8 +834,6 @@ M_DrawSelCell V_DrawPatchDirect (menu->x - 10, menu->y+item*LINEHEIGHT - 1, 0, W_CacheLumpName("M_CELL2",PU_CACHE)); } - - void M_StartMessage ( char* string, @@ -1236,26 +848,16 @@ M_StartMessage menuactive = true; return; } - - - void M_StopMessage(void) { menuactive = messageLastMenuActive; messageToPrint = 0; } - - - - - - int M_StringWidth(char* string) { int i; int w = 0; int c; - for (i = 0;i < strlen(string);i++) { c = toupper(string[i]) - HU_FONTSTART; @@ -1264,33 +866,19 @@ int M_StringWidth(char* string) else w += SHORT (hu_font[c]->width); } - return w; } - - - - - - int M_StringHeight(char* string) { int i; int h; int height = SHORT(hu_font[0]->height); - h = height; for (i = 0;i < strlen(string);i++) if (string[i] == '\n') h += height; - return h; } - - - - - void M_WriteText ( int x, @@ -1302,12 +890,9 @@ M_WriteText int c; int cx; int cy; - - ch = string; cx = x; cy = y; - while(1) { c = *ch++; @@ -1319,14 +904,12 @@ M_WriteText cy += 12; continue; } - c = toupper(c) - HU_FONTSTART; if (c < 0 || c>= HU_FONTSIZE) { cx += 4; continue; } - w = SHORT (hu_font[c]->width); if (cx+w > SCREENWIDTH) break; @@ -1334,16 +917,6 @@ M_WriteText cx+=w; } } - - - - - - - - - - boolean M_Responder (event_t* ev) { int ch; @@ -1354,9 +927,7 @@ boolean M_Responder (event_t* ev) static int lasty = 0; static int mousex = 0; static int lastx = 0; - ch = -1; - if (ev->type == ev_joystick && joywait < I_GetTime()) { if (ev->data3 == -1) @@ -1369,7 +940,6 @@ boolean M_Responder (event_t* ev) ch = KEY_DOWNARROW; joywait = I_GetTime() + 5; } - if (ev->data2 == -1) { ch = KEY_LEFTARROW; @@ -1380,7 +950,6 @@ boolean M_Responder (event_t* ev) ch = KEY_RIGHTARROW; joywait = I_GetTime() + 2; } - if (ev->data1&1) { ch = KEY_ENTER; @@ -1409,7 +978,6 @@ boolean M_Responder (event_t* ev) mousewait = I_GetTime() + 5; mousey = lasty += 30; } - mousex += ev->data2; if (mousex < lastx-30) { @@ -1423,13 +991,11 @@ boolean M_Responder (event_t* ev) mousewait = I_GetTime() + 5; mousex = lastx += 30; } - if (ev->data1&1) { ch = KEY_ENTER; mousewait = I_GetTime() + 15; } - if (ev->data1&2) { ch = KEY_BACKSPACE; @@ -1442,12 +1008,8 @@ boolean M_Responder (event_t* ev) ch = ev->data1; } } - if (ch == -1) return false; - - - if (saveStringEnter) { switch(ch) @@ -1459,18 +1021,15 @@ boolean M_Responder (event_t* ev) savegamestrings[saveSlot][saveCharIndex] = 0; } break; - case KEY_ESCAPE: saveStringEnter = 0; strcpy(&savegamestrings[saveSlot][0],saveOldString); break; - case KEY_ENTER: saveStringEnter = 0; if (savegamestrings[saveSlot][0]) M_DoSave(saveSlot); break; - default: ch = toupper(ch); if (ch != 32) @@ -1488,32 +1047,24 @@ boolean M_Responder (event_t* ev) } return true; } - - if (messageToPrint) { if (messageNeedsInput == true && !(ch == ' ' || ch == 'n' || ch == 'y' || ch == KEY_ESCAPE)) return false; - menuactive = messageLastMenuActive; messageToPrint = 0; if (messageRoutine) messageRoutine(ch); - menuactive = false; S_StartSound(NULL,sfx_swtchx); return true; } - if (devparm && ch == KEY_F1) { G_ScreenShot (); return true; } - - - if (!menuactive) switch(ch) { @@ -1523,75 +1074,61 @@ boolean M_Responder (event_t* ev) M_SizeDisplay(0); S_StartSound(NULL,sfx_stnmov); return true; - case KEY_EQUALS: if (automapactive || chat_on) return false; M_SizeDisplay(1); S_StartSound(NULL,sfx_stnmov); return true; - case KEY_F1: M_StartControlPanel (); - if ( gamemode == retail ) currentMenu = &ReadDef2; else currentMenu = &ReadDef1; - itemOn = 0; S_StartSound(NULL,sfx_swtchn); return true; - case KEY_F2: M_StartControlPanel(); S_StartSound(NULL,sfx_swtchn); M_SaveGame(0); return true; - case KEY_F3: M_StartControlPanel(); S_StartSound(NULL,sfx_swtchn); M_LoadGame(0); return true; - case KEY_F4: M_StartControlPanel (); currentMenu = &SoundDef; itemOn = sfx_vol; S_StartSound(NULL,sfx_swtchn); return true; - case KEY_F5: M_ChangeDetail(0); S_StartSound(NULL,sfx_swtchn); return true; - case KEY_F6: S_StartSound(NULL,sfx_swtchn); M_QuickSave(); return true; - case KEY_F7: S_StartSound(NULL,sfx_swtchn); M_EndGame(0); return true; - case KEY_F8: M_ChangeMessages(0); S_StartSound(NULL,sfx_swtchn); return true; - case KEY_F9: S_StartSound(NULL,sfx_swtchn); M_QuickLoad(); return true; - case KEY_F10: S_StartSound(NULL,sfx_swtchn); M_QuitDOOM(0); return true; - case KEY_F11: usegamma++; if (usegamma > 4) @@ -1599,11 +1136,7 @@ boolean M_Responder (event_t* ev) players[consoleplayer].message = gammamsg[usegamma]; I_SetPalette (W_CacheLumpName ("PLAYPAL",PU_CACHE)); return true; - } - - - if (!menuactive) { if (ch == KEY_ESCAPE) @@ -1614,9 +1147,6 @@ boolean M_Responder (event_t* ev) } return false; } - - - switch (ch) { case KEY_DOWNARROW: @@ -1628,7 +1158,6 @@ boolean M_Responder (event_t* ev) S_StartSound(NULL,sfx_pstop); } while(currentMenu->menuitems[itemOn].status==-1); return true; - case KEY_UPARROW: do { @@ -1638,7 +1167,6 @@ boolean M_Responder (event_t* ev) S_StartSound(NULL,sfx_pstop); } while(currentMenu->menuitems[itemOn].status==-1); return true; - case KEY_LEFTARROW: if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status == 2) @@ -1647,7 +1175,6 @@ boolean M_Responder (event_t* ev) currentMenu->menuitems[itemOn].routine(0); } return true; - case KEY_RIGHTARROW: if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status == 2) @@ -1656,7 +1183,6 @@ boolean M_Responder (event_t* ev) currentMenu->menuitems[itemOn].routine(1); } return true; - case KEY_ENTER: if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status) @@ -1674,13 +1200,11 @@ boolean M_Responder (event_t* ev) } } return true; - case KEY_ESCAPE: currentMenu->lastOn = itemOn; M_ClearMenus (); S_StartSound(NULL,sfx_swtchx); return true; - case KEY_BACKSPACE: currentMenu->lastOn = itemOn; if (currentMenu->prevMenu) @@ -1690,7 +1214,6 @@ boolean M_Responder (event_t* ev) S_StartSound(NULL,sfx_swtchn); } return true; - default: for (i = itemOn+1;i < currentMenu->numitems;i++) if (currentMenu->menuitems[i].alphaKey == ch) @@ -1707,34 +1230,17 @@ boolean M_Responder (event_t* ev) return true; } break; - } - return false; } - - - - - - void M_StartControlPanel (void) { - if (menuactive) return; - menuactive = 1; currentMenu = &MainDef; itemOn = currentMenu->lastOn; } - - - - - - - void M_Drawer (void) { static short x; @@ -1743,11 +1249,7 @@ void M_Drawer (void) short max; char string[40]; int start; - inhelpscreens = false; - - - if (messageToPrint) { start = 0; @@ -1762,31 +1264,24 @@ void M_Drawer (void) start += i+1; break; } - if (i == strlen(messageString+start)) { strcpy(string,messageString+start); start += i; } - x = 160 - M_StringWidth(string)/2; M_WriteText(x,y,string); y += SHORT(hu_font[0]->height); } return; } - if (!menuactive) return; - if (currentMenu->routine) currentMenu->routine(); - - x = currentMenu->x; y = currentMenu->y; max = currentMenu->numitems; - for (i=0;i<max;i++) { if (currentMenu->menuitems[i].name[0]) @@ -1794,41 +1289,18 @@ void M_Drawer (void) W_CacheLumpName(currentMenu->menuitems[i].name ,PU_CACHE)); y += LINEHEIGHT; } - - - V_DrawPatchDirect(x + SKULLXOFF,currentMenu->y - 5 + itemOn*LINEHEIGHT, 0, W_CacheLumpName(skullName[whichSkull],PU_CACHE)); - } - - - - - void M_ClearMenus (void) { menuactive = 0; - - } - - - - - - - void M_SetupNextMenu(menu_t *menudef) { currentMenu = menudef; itemOn = currentMenu->lastOn; } - - - - - void M_Ticker (void) { if (--skullAnimCounter <= 0) @@ -1837,11 +1309,6 @@ void M_Ticker (void) skullAnimCounter = 8; } } - - - - - void M_Init (void) { currentMenu = &MainDef; @@ -1854,17 +1321,9 @@ void M_Init (void) messageString = NULL; messageLastMenuActive = menuactive; quickSaveSlot = -1; - - - - - switch ( gamemode ) { case commercial: - - - MainMenu[readthis] = MainMenu[quitdoom]; MainDef.numitems--; MainDef.y += 8; @@ -1875,17 +1334,11 @@ void M_Init (void) ReadMenu1[0].routine = M_FinishReadThis; break; case shareware: - - case registered: - EpiDef.numitems--; break; case retail: - default: break; } - } - diff --git a/src/m_menu.h b/src/m_menu.h @@ -1,67 +1,9 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __M_MENU__ #define __M_MENU__ - - - #include "d_event.h" - - - - - - - - - boolean M_Responder (event_t *ev); - - - - void M_Ticker (void); - - - void M_Drawer (void); - - - void M_Init (void); - - - void M_StartControlPanel (void); - - - - - - #endif - - - - - diff --git a/src/m_misc.c b/src/m_misc.c @@ -1,69 +1,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> #include <stdlib.h> #include <unistd.h> - #include <ctype.h> - - #include "doomdef.h" - #include "z_zone.h" - #include "m_swap.h" #include "m_argv.h" - #include "w_wad.h" - #include "i_system.h" #include "i_video.h" #include "v_video.h" - #include "hu_stuff.h" - - #include "doomstat.h" - - #include "dstrings.h" - #include "m_misc.h" - - - - - - extern patch_t* hu_font[HU_FONTSIZE]; - int M_DrawText ( int x, @@ -73,7 +26,6 @@ M_DrawText { int c; int w; - while (*string) { c = toupper(*string) - HU_FONTSTART; @@ -83,7 +35,6 @@ M_DrawText x += 4; continue; } - w = SHORT (hu_font[c]->width); if (x+w > SCREENWIDTH) break; @@ -93,20 +44,11 @@ M_DrawText V_DrawPatch(x, y, 0, hu_font[c]); x+=w; } - return x; } - - - - - - - #ifndef O_BINARY #define O_BINARY 0 #endif - boolean M_WriteFile ( char const* name, @@ -115,25 +57,15 @@ M_WriteFile { int handle; int count; - handle = open ( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); - if (handle == -1) return false; - count = write (handle, source, length); close (handle); - if (count < length) return false; - return true; } - - - - - int M_ReadFile ( char const* name, @@ -142,7 +74,6 @@ M_ReadFile int handle, count, length; struct stat fileinfo; byte *buf; - handle = open (name, O_RDONLY | O_BINARY, 0666); if (handle == -1) I_Error ("Couldn't read file %s", name); @@ -152,74 +83,47 @@ M_ReadFile buf = Z_Malloc (length, PU_STATIC, NULL); count = read (handle, buf, length); close (handle); - if (count < length) I_Error ("Couldn't read file %s", name); - *buffer = buf; return length; } - - - - - int usemouse; int usejoystick; - extern int key_right; extern int key_left; extern int key_up; extern int key_down; - extern int key_strafeleft; extern int key_straferight; - extern int key_fire; extern int key_use; extern int key_strafe; extern int key_speed; - extern int mousebfire; extern int mousebstrafe; extern int mousebforward; - extern int joybfire; extern int joybstrafe; extern int joybuse; extern int joybspeed; - extern int viewwidth; extern int viewheight; - extern int mouseSensitivity; extern int showMessages; - extern int detailLevel; - extern int screenblocks; - extern int showMessages; - - extern int numChannels; - - - #ifdef SNDSERV extern char* sndserver_filename; extern int mb_used; #endif - #ifdef LINUX char* mousetype; char* mousedev; #endif - extern char* chat_macros[]; - - - typedef struct { char* name; @@ -228,15 +132,12 @@ typedef struct int scantranslate; int untranslated; } default_t; - default_t defaults[] = { {"mouse_sensitivity",&mouseSensitivity, 5}, {"sfx_volume",&snd_SfxVolume, 8}, {"music_volume",&snd_MusicVolume, 8}, {"show_messages",&showMessages, 1}, - - #ifdef NORMALUNIX {"key_right",&key_right, KEY_RIGHTARROW}, {"key_left",&key_left, KEY_LEFTARROW}, @@ -244,45 +145,32 @@ default_t defaults[] = {"key_down",&key_down, KEY_DOWNARROW}, {"key_strafeleft",&key_strafeleft, ','}, {"key_straferight",&key_straferight, '.'}, - {"key_fire",&key_fire, KEY_RCTRL}, {"key_use",&key_use, ' '}, {"key_strafe",&key_strafe, KEY_RALT}, {"key_speed",&key_speed, KEY_RSHIFT}, - - #ifdef SNDSERV {"sndserver", (int *) &sndserver_filename, (int) "sndserver"}, {"mb_used", &mb_used, 2}, #endif - #endif - #ifdef LINUX {"mousedev", (int*)&mousedev, (int)"/dev/ttyS0"}, {"mousetype", (int*)&mousetype, (int)"microsoft"}, #endif - {"use_mouse",&usemouse, 1}, {"mouseb_fire",&mousebfire,0}, {"mouseb_strafe",&mousebstrafe,1}, {"mouseb_forward",&mousebforward,2}, - {"use_joystick",&usejoystick, 0}, {"joyb_fire",&joybfire,0}, {"joyb_strafe",&joybstrafe,1}, {"joyb_use",&joybuse,3}, {"joyb_speed",&joybspeed,2}, - {"screenblocks",&screenblocks, 9}, {"detaillevel",&detailLevel, 0}, - {"snd_channels",&numChannels, 3}, - - - {"usegamma",&usegamma, 0}, - {"chatmacro0", (int *) &chat_macros[0], (int) HUSTR_CHATMACRO0 }, {"chatmacro1", (int *) &chat_macros[1], (int) HUSTR_CHATMACRO1 }, {"chatmacro2", (int *) &chat_macros[2], (int) HUSTR_CHATMACRO2 }, @@ -293,26 +181,17 @@ default_t defaults[] = {"chatmacro7", (int *) &chat_macros[7], (int) HUSTR_CHATMACRO7 }, {"chatmacro8", (int *) &chat_macros[8], (int) HUSTR_CHATMACRO8 }, {"chatmacro9", (int *) &chat_macros[9], (int) HUSTR_CHATMACRO9 } - }; - int numdefaults; char* defaultfile; - - - - - void M_SaveDefaults (void) { int i; int v; FILE* f; - f = fopen (defaultfile, "w"); if (!f) return; - for (i=0 ; i<numdefaults ; i++) { if (defaults[i].defaultvalue > -0xfff @@ -325,16 +204,9 @@ void M_SaveDefaults (void) * (char **) (defaults[i].location)); } } - fclose (f); } - - - - - extern byte scantokey[128]; - void M_LoadDefaults (void) { int i; @@ -345,13 +217,9 @@ void M_LoadDefaults (void) char* newstring; int parm; boolean isstring; - - numdefaults = sizeof(defaults)/sizeof(defaults[0]); for (i=0 ; i<numdefaults ; i++) *defaults[i].location = defaults[i].defaultvalue; - - i = M_CheckParm ("-config"); if (i && i<myargc-1) { @@ -360,8 +228,6 @@ void M_LoadDefaults (void) } else defaultfile = basedefault; - - f = fopen (defaultfile, "r"); if (f) { @@ -372,7 +238,6 @@ void M_LoadDefaults (void) { if (strparm[0] == '"') { - isstring = true; len = strlen(strparm); newstring = (char *) malloc(len); @@ -395,47 +260,29 @@ void M_LoadDefaults (void) } } } - fclose (f); } } - - - - - - - typedef struct { char manufacturer; char version; char encoding; char bits_per_pixel; - unsigned short xmin; unsigned short ymin; unsigned short xmax; unsigned short ymax; - unsigned short hres; unsigned short vres; - unsigned char palette[48]; - char reserved; char color_planes; unsigned short bytes_per_line; unsigned short palette_type; - char filler[58]; unsigned char data; } pcx_t; - - - - - void WritePCXfile ( char* filename, @@ -448,9 +295,7 @@ WritePCXfile int length; pcx_t* pcx; byte* pack; - pcx = Z_Malloc (width*height*2+1000, PU_STATIC, NULL); - pcx->manufacturer = 0x0a; pcx->version = 5; pcx->encoding = 1; @@ -466,11 +311,7 @@ WritePCXfile pcx->bytes_per_line = SHORT(width); pcx->palette_type = SHORT(2); memset (pcx->filler,0,sizeof(pcx->filler)); - - - pack = &pcx->data; - for (i=0 ; i<width*height ; i++) { if ( (*data & 0xc0) != 0xc0) @@ -481,36 +322,21 @@ WritePCXfile *pack++ = *data++; } } - - *pack++ = 0x0c; for (i=0 ; i<768 ; i++) *pack++ = *palette++; - - length = pack - (byte *)pcx; M_WriteFile (filename, pcx, length); - Z_Free (pcx); } - - - - - void M_ScreenShot (void) { int i; byte* linear; char lbmname[12]; - - linear = screens[2]; I_ReadScreen (linear); - - strcpy(lbmname,"DOOM00.pcx"); - for (i=0 ; i<=99 ; i++) { lbmname[4] = i/10 + '0'; @@ -520,13 +346,8 @@ void M_ScreenShot (void) } if (i==100) I_Error ("M_ScreenShot: Couldn't create a PCX"); - - WritePCXfile (lbmname, linear, SCREENWIDTH, SCREENHEIGHT, W_CacheLumpName ("PLAYPAL",PU_CACHE)); - players[consoleplayer].message = "screen shot"; } - - diff --git a/src/m_misc.h b/src/m_misc.h @@ -1,65 +1,22 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __M_MISC__ #define __M_MISC__ - - #include "doomtype.h" - - - - - - boolean M_WriteFile ( char const* name, void* source, int length ); - int M_ReadFile ( char const* name, byte** buffer ); - void M_ScreenShot (void); - void M_LoadDefaults (void); - void M_SaveDefaults (void); - - int M_DrawText ( int x, int y, boolean direct, char* string ); - - #endif - - - - - diff --git a/src/m_random.c b/src/m_random.c @@ -1,32 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - unsigned char rndtable[256] = { 0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66 , 74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36 , @@ -48,28 +19,19 @@ unsigned char rndtable[256] = { 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136 , 120, 163, 236, 249 }; - int rndindex = 0; int prndindex = 0; - - int P_Random (void) { prndindex = (prndindex+1)&0xff; return rndtable[prndindex]; } - int M_Random (void) { rndindex = (rndindex+1)&0xff; return rndtable[rndindex]; } - void M_ClearRandom (void) { rndindex = prndindex = 0; } - - - - diff --git a/src/m_random.h b/src/m_random.h @@ -1,47 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __M_RANDOM__ #define __M_RANDOM__ - - #include "doomtype.h" - - - - - int M_Random (void); - - int P_Random (void); - - void M_ClearRandom (void); - - #endif - - - - - diff --git a/src/m_swap.c b/src/m_swap.c @@ -1,45 +1,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #ifdef __GNUG__ #pragma implementation "m_swap.h" #endif #include "m_swap.h" - - - #ifndef __BIG_ENDIAN__ - - unsigned short SwapSHORT(unsigned short x) { - return (x>>8) | (x<<8); } - - unsigned long SwapLONG( unsigned long x) { return @@ -48,8 +15,4 @@ unsigned long SwapLONG( unsigned long x) | ((x<<8) & 0xff0000) | (x<<24); } - - #endif - - diff --git a/src/m_swap.h b/src/m_swap.h @@ -1,36 +1,8 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __M_SWAP__ #define __M_SWAP__ - - #ifdef __GNUG__ #pragma interface #endif - - - - #ifdef __BIG_ENDIAN__ short SwapSHORT(short); long SwapLONG(long); @@ -40,13 +12,4 @@ long SwapLONG(long); #define SHORT(x) (x) #define LONG(x) (x) #endif - - - - #endif - - - - - diff --git a/src/p_ceilng.c b/src/p_ceilng.c @@ -1,68 +1,23 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include "z_zone.h" #include "doomdef.h" #include "p_local.h" - #include "s_sound.h" - - #include "doomstat.h" #include "r_state.h" - - #include "sounds.h" - - - - - - ceiling_t* activeceilings[MAXCEILINGS]; - - - - - - void T_MoveCeiling (ceiling_t* ceiling) { result_e res; - switch(ceiling->direction) { case 0: - break; case 1: - res = T_MovePlane(ceiling->sector, ceiling->speed, ceiling->topheight, false,1,ceiling->direction); - if (!(leveltime&7)) { switch(ceiling->type) @@ -72,11 +27,9 @@ void T_MoveCeiling (ceiling_t* ceiling) default: S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_stnmov); - break; } } - if (res == pastdest) { switch(ceiling->type) @@ -84,7 +37,6 @@ void T_MoveCeiling (ceiling_t* ceiling) case raiseToHighest: P_RemoveActiveCeiling(ceiling); break; - case silentCrushAndRaise: S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_pstop); @@ -92,21 +44,16 @@ void T_MoveCeiling (ceiling_t* ceiling) case crushAndRaise: ceiling->direction = -1; break; - default: break; } - } break; - case -1: - res = T_MovePlane(ceiling->sector, ceiling->speed, ceiling->bottomheight, ceiling->crush,1,ceiling->direction); - if (!(leveltime&7)) { switch(ceiling->type) @@ -117,7 +64,6 @@ void T_MoveCeiling (ceiling_t* ceiling) sfx_stnmov); } } - if (res == pastdest) { switch(ceiling->type) @@ -130,12 +76,10 @@ void T_MoveCeiling (ceiling_t* ceiling) case fastCrushAndRaise: ceiling->direction = 1; break; - case lowerAndCrush: case lowerToFloor: P_RemoveActiveCeiling(ceiling); break; - default: break; } @@ -151,7 +95,6 @@ void T_MoveCeiling (ceiling_t* ceiling) case lowerAndCrush: ceiling->speed = CEILSPEED / 8; break; - default: break; } @@ -160,12 +103,6 @@ void T_MoveCeiling (ceiling_t* ceiling) break; } } - - - - - - int EV_DoCeiling ( line_t* line, @@ -175,11 +112,8 @@ EV_DoCeiling int rtn; sector_t* sec; ceiling_t* ceiling; - secnum = -1; rtn = 0; - - switch(type) { case fastCrushAndRaise: @@ -189,14 +123,11 @@ EV_DoCeiling default: break; } - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; if (sec->specialdata) continue; - - rtn = 1; ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVSPEC, 0); P_AddThinker (&ceiling->thinker); @@ -204,7 +135,6 @@ EV_DoCeiling ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling; ceiling->sector = sec; ceiling->crush = false; - switch(type) { case fastCrushAndRaise: @@ -214,7 +144,6 @@ EV_DoCeiling ceiling->direction = -1; ceiling->speed = CEILSPEED * 2; break; - case silentCrushAndRaise: case crushAndRaise: ceiling->crush = true; @@ -227,29 +156,21 @@ EV_DoCeiling ceiling->direction = -1; ceiling->speed = CEILSPEED; break; - case raiseToHighest: ceiling->topheight = P_FindHighestCeilingSurrounding(sec); ceiling->direction = 1; ceiling->speed = CEILSPEED; break; } - ceiling->tag = sec->tag; ceiling->type = type; P_AddActiveCeiling(ceiling); } return rtn; } - - - - - void P_AddActiveCeiling(ceiling_t* c) { int i; - for (i = 0; i < MAXCEILINGS;i++) { if (activeceilings[i] == NULL) @@ -259,16 +180,9 @@ void P_AddActiveCeiling(ceiling_t* c) } } } - - - - - - void P_RemoveActiveCeiling(ceiling_t* c) { int i; - for (i = 0;i < MAXCEILINGS;i++) { if (activeceilings[i] == c) @@ -280,16 +194,9 @@ void P_RemoveActiveCeiling(ceiling_t* c) } } } - - - - - - void P_ActivateInStasisCeiling(line_t* line) { int i; - for (i = 0;i < MAXCEILINGS;i++) { if (activeceilings[i] @@ -302,18 +209,10 @@ void P_ActivateInStasisCeiling(line_t* line) } } } - - - - - - - int EV_CeilingCrushStop(line_t *line) { int i; int rtn; - rtn = 0; for (i = 0;i < MAXCEILINGS;i++) { @@ -327,7 +226,5 @@ int EV_CeilingCrushStop(line_t *line) rtn = 1; } } - - return rtn; } diff --git a/src/p_doors.c b/src/p_doors.c @@ -1,71 +1,25 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include "z_zone.h" #include "doomdef.h" #include "p_local.h" - #include "s_sound.h" - - - #include "doomstat.h" #include "r_state.h" - - #include "dstrings.h" #include "sounds.h" - #if 0 - - - slidename_t slideFrameNames[MAXSLIDEDOORS] = { {"GDOORF1","GDOORF2","GDOORF3","GDOORF4", "GDOORB1","GDOORB2","GDOORB3","GDOORB4"}, - {"\0","\0","\0","\0"} }; #endif - - - - - - - - - void T_VerticalDoor (vldoor_t* door) { result_e res; - switch(door->direction) { case 0: - if (!--door->topcountdown) { switch(door->type) @@ -75,27 +29,22 @@ void T_VerticalDoor (vldoor_t* door) S_StartSound((mobj_t *)&door->sector->soundorg, sfx_bdcls); break; - case normal: door->direction = -1; S_StartSound((mobj_t *)&door->sector->soundorg, sfx_dorcls); break; - case close30ThenOpen: door->direction = 1; S_StartSound((mobj_t *)&door->sector->soundorg, sfx_doropn); break; - default: break; } } break; - case 2: - if (!--door->topcountdown) { switch(door->type) @@ -106,15 +55,12 @@ void T_VerticalDoor (vldoor_t* door) S_StartSound((mobj_t *)&door->sector->soundorg, sfx_doropn); break; - default: break; } } break; - case -1: - res = T_MovePlane(door->sector, door->speed, door->sector->floorheight, @@ -130,18 +76,15 @@ void T_VerticalDoor (vldoor_t* door) S_StartSound((mobj_t *)&door->sector->soundorg, sfx_bdcls); break; - case normal: case close: door->sector->specialdata = NULL; P_RemoveThinker (&door->thinker); break; - case close30ThenOpen: door->direction = 0; door->topcountdown = 35*30; break; - default: break; } @@ -153,7 +96,6 @@ void T_VerticalDoor (vldoor_t* door) case blazeClose: case close: break; - default: door->direction = 1; S_StartSound((mobj_t *)&door->sector->soundorg, @@ -162,14 +104,11 @@ void T_VerticalDoor (vldoor_t* door) } } break; - case 1: - res = T_MovePlane(door->sector, door->speed, door->topheight, false,1,door->direction); - if (res == pastdest) { switch(door->type) @@ -179,14 +118,12 @@ void T_VerticalDoor (vldoor_t* door) door->direction = 0; door->topcountdown = door->topwait; break; - case close30ThenOpen: case blazeOpen: case open: door->sector->specialdata = NULL; P_RemoveThinker (&door->thinker); break; - default: break; } @@ -194,13 +131,6 @@ void T_VerticalDoor (vldoor_t* door) break; } } - - - - - - - int EV_DoLockedDoor ( line_t* line, @@ -208,12 +138,9 @@ EV_DoLockedDoor mobj_t* thing ) { player_t* p; - p = thing->player; - if (!p) return 0; - switch(line->special) { case 99: @@ -227,7 +154,6 @@ EV_DoLockedDoor return 0; } break; - case 134: case 135: if ( !p ) @@ -239,7 +165,6 @@ EV_DoLockedDoor return 0; } break; - case 136: case 137: if ( !p ) @@ -253,11 +178,8 @@ EV_DoLockedDoor } break; } - return EV_DoDoor(line,type); } - - int EV_DoDoor ( line_t* line, @@ -266,29 +188,22 @@ EV_DoDoor int secnum,rtn; sector_t* sec; vldoor_t* door; - secnum = -1; rtn = 0; - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; if (sec->specialdata) continue; - - - rtn = 1; door = Z_Malloc (sizeof(*door), PU_LEVSPEC, 0); P_AddThinker (&door->thinker); sec->specialdata = door; - door->thinker.function.acp1 = (actionf_p1) T_VerticalDoor; door->sector = sec; door->type = type; door->topwait = VDOORWAIT; door->speed = VDOORSPEED; - switch(type) { case blazeClose: @@ -299,7 +214,6 @@ EV_DoDoor S_StartSound((mobj_t *)&door->sector->soundorg, sfx_bdcls); break; - case close: door->topheight = P_FindLowestCeilingSurrounding(sec); door->topheight -= 4*FRACUNIT; @@ -307,14 +221,12 @@ EV_DoDoor S_StartSound((mobj_t *)&door->sector->soundorg, sfx_dorcls); break; - case close30ThenOpen: door->topheight = sec->ceilingheight; door->direction = -1; S_StartSound((mobj_t *)&door->sector->soundorg, sfx_dorcls); break; - case blazeRaise: case blazeOpen: door->direction = 1; @@ -325,7 +237,6 @@ EV_DoDoor S_StartSound((mobj_t *)&door->sector->soundorg, sfx_bdopn); break; - case normal: case open: door->direction = 1; @@ -335,19 +246,12 @@ EV_DoDoor S_StartSound((mobj_t *)&door->sector->soundorg, sfx_doropn); break; - default: break; } - } return rtn; } - - - - - void EV_VerticalDoor ( line_t* line, @@ -358,19 +262,14 @@ EV_VerticalDoor sector_t* sec; vldoor_t* door; int side; - side = 0; - - player = thing->player; - switch(line->special) { case 26: case 32: if ( !player ) return; - if (!player->cards[it_bluecard] && !player->cards[it_blueskull]) { player->message = PD_BLUEK; @@ -378,12 +277,10 @@ EV_VerticalDoor return; } break; - case 27: case 34: if ( !player ) return; - if (!player->cards[it_yellowcard] && !player->cards[it_yellowskull]) { @@ -392,12 +289,10 @@ EV_VerticalDoor return; } break; - case 28: case 33: if ( !player ) return; - if (!player->cards[it_redcard] && !player->cards[it_redskull]) { player->message = PD_REDK; @@ -406,11 +301,8 @@ EV_VerticalDoor } break; } - - sec = sides[ line->sidenum[side^1]] .sector; secnum = sec-sectors; - if (sec->specialdata) { door = sec->specialdata; @@ -427,33 +319,25 @@ EV_VerticalDoor { if (!thing->player) return; - door->direction = -1; } return; } } - - switch(line->special) { case 117: case 118: S_StartSound((mobj_t *)&sec->soundorg,sfx_bdopn); break; - case 1: case 31: S_StartSound((mobj_t *)&sec->soundorg,sfx_doropn); break; - default: S_StartSound((mobj_t *)&sec->soundorg,sfx_doropn); break; } - - - door = Z_Malloc (sizeof(*door), PU_LEVSPEC, 0); P_AddThinker (&door->thinker); sec->specialdata = door; @@ -462,7 +346,6 @@ EV_VerticalDoor door->direction = 1; door->speed = VDOORSPEED; door->topwait = VDOORWAIT; - switch(line->special) { case 1: @@ -471,7 +354,6 @@ EV_VerticalDoor case 28: door->type = normal; break; - case 31: case 32: case 33: @@ -479,7 +361,6 @@ EV_VerticalDoor door->type = open; line->special = 0; break; - case 117: door->type = blazeRaise; door->speed = VDOORSPEED*4; @@ -490,27 +371,16 @@ EV_VerticalDoor door->speed = VDOORSPEED*4; break; } - - door->topheight = P_FindLowestCeilingSurrounding(sec); door->topheight -= 4*FRACUNIT; } - - - - - void P_SpawnDoorCloseIn30 (sector_t* sec) { vldoor_t* door; - door = Z_Malloc ( sizeof(*door), PU_LEVSPEC, 0); - P_AddThinker (&door->thinker); - sec->specialdata = door; sec->special = 0; - door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor; door->sector = sec; door->direction = 0; @@ -518,24 +388,16 @@ void P_SpawnDoorCloseIn30 (sector_t* sec) door->speed = VDOORSPEED; door->topcountdown = 30 * 35; } - - - - void P_SpawnDoorRaiseIn5Mins ( sector_t* sec, int secnum ) { vldoor_t* door; - door = Z_Malloc ( sizeof(*door), PU_LEVSPEC, 0); - P_AddThinker (&door->thinker); - sec->specialdata = door; sec->special = 0; - door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor; door->sector = sec; door->direction = 2; @@ -546,21 +408,8 @@ P_SpawnDoorRaiseIn5Mins door->topwait = VDOORWAIT; door->topcountdown = 5 * 60 * 35; } - - - - - - #if 0 - - - - - - slideframe_t slideFrames[MAXSLIDEDOORS]; - void P_InitSlidingDoorFrames(void) { int i; @@ -568,58 +417,42 @@ void P_InitSlidingDoorFrames(void) int f2; int f3; int f4; - - if ( gamemode != commercial) return; - for (i = 0;i < MAXSLIDEDOORS; i++) { if (!slideFrameNames[i].frontFrame1[0]) break; - f1 = R_TextureNumForName(slideFrameNames[i].frontFrame1); f2 = R_TextureNumForName(slideFrameNames[i].frontFrame2); f3 = R_TextureNumForName(slideFrameNames[i].frontFrame3); f4 = R_TextureNumForName(slideFrameNames[i].frontFrame4); - slideFrames[i].frontFrames[0] = f1; slideFrames[i].frontFrames[1] = f2; slideFrames[i].frontFrames[2] = f3; slideFrames[i].frontFrames[3] = f4; - f1 = R_TextureNumForName(slideFrameNames[i].backFrame1); f2 = R_TextureNumForName(slideFrameNames[i].backFrame2); f3 = R_TextureNumForName(slideFrameNames[i].backFrame3); f4 = R_TextureNumForName(slideFrameNames[i].backFrame4); - slideFrames[i].backFrames[0] = f1; slideFrames[i].backFrames[1] = f2; slideFrames[i].backFrames[2] = f3; slideFrames[i].backFrames[3] = f4; } } - - - - - - int P_FindSlidingDoorType(line_t* line) { int i; int val; - for (i = 0;i < MAXSLIDEDOORS;i++) { val = sides[line->sidenum[0]].midtexture; if (val == slideFrames[i].frontFrames[0]) return i; } - return -1; } - void T_SlidingDoor (slidedoor_t* door) { switch(door->status) @@ -629,26 +462,21 @@ void T_SlidingDoor (slidedoor_t* door) { if (++door->frame == SNUMFRAMES) { - sides[door->line->sidenum[0]].midtexture = 0; sides[door->line->sidenum[1]].midtexture = 0; door->line->flags &= ML_BLOCKING^0xff; - if (door->type == sdt_openOnly) { door->frontsector->specialdata = NULL; P_RemoveThinker (&door->thinker); break; } - door->timer = SDOORWAIT; door->status = sd_waiting; } else { - door->timer = SWAITTICS; - sides[door->line->sidenum[0]].midtexture = slideFrames[door->whichDoorIndex]. frontFrames[door->frame]; @@ -658,31 +486,24 @@ void T_SlidingDoor (slidedoor_t* door) } } break; - case sd_waiting: - if (!door->timer--) { - if (door->frontsector->thinglist != NULL || door->backsector->thinglist != NULL) { door->timer = SDOORWAIT; break; } - - door->status = sd_closing; door->timer = SWAITTICS; } break; - case sd_closing: if (!door->timer--) { if (--door->frame < 0) { - door->line->flags |= ML_BLOCKING; door->frontsector->specialdata = NULL; P_RemoveThinker (&door->thinker); @@ -690,9 +511,7 @@ void T_SlidingDoor (slidedoor_t* door) } else { - door->timer = SWAITTICS; - sides[door->line->sidenum[0]].midtexture = slideFrames[door->whichDoorIndex]. frontFrames[door->frame]; @@ -704,9 +523,6 @@ void T_SlidingDoor (slidedoor_t* door) break; } } - - - void EV_SlidingDoor ( line_t* line, @@ -714,19 +530,14 @@ EV_SlidingDoor { sector_t* sec; slidedoor_t* door; - - if (gamemode != commercial) return; - - sec = line->frontsector; door = NULL; if (sec->specialdata) { if (!thing->player) return; - door = sec->specialdata; if (door->type == sdt_openAndClose) { @@ -736,21 +547,16 @@ EV_SlidingDoor else return; } - - if (!door) { door = Z_Malloc (sizeof(*door), PU_LEVSPEC, 0); P_AddThinker (&door->thinker); sec->specialdata = door; - door->type = sdt_openAndClose; door->status = sd_opening; door->whichDoorIndex = P_FindSlidingDoorType(line); - if (door->whichDoorIndex < 0) I_Error("EV_SlidingDoor: Can't use texture for sliding door!"); - door->frontsector = sec; door->backsector = line->backsector; door->thinker.function = T_SlidingDoor; diff --git a/src/p_enemy.c b/src/p_enemy.c @@ -1,51 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdlib.h> - #include "m_random.h" #include "i_system.h" - #include "doomdef.h" #include "p_local.h" - #include "s_sound.h" - #include "g_game.h" - - #include "doomstat.h" #include "r_state.h" - - #include "sounds.h" - - - - typedef enum { DI_EAST, @@ -58,48 +20,18 @@ typedef enum DI_SOUTHEAST, DI_NODIR, NUMDIRS - } dirtype_t; - - - - - dirtype_t opposite[] = { DI_WEST, DI_SOUTHWEST, DI_SOUTH, DI_SOUTHEAST, DI_EAST, DI_NORTHEAST, DI_NORTH, DI_NORTHWEST, DI_NODIR }; - dirtype_t diags[] = { DI_NORTHWEST, DI_NORTHEAST, DI_SOUTHWEST, DI_SOUTHEAST }; - - - - - void A_Fall (mobj_t *actor); - - - - - - - - - - - - - - - - - mobj_t* soundtarget; - void P_RecursiveSound ( sector_t* sec, @@ -108,34 +40,26 @@ P_RecursiveSound int i; line_t* check; sector_t* other; - - if (sec->validcount == validcount && sec->soundtraversed <= soundblocks+1) { return; } - sec->validcount = validcount; sec->soundtraversed = soundblocks+1; sec->soundtarget = soundtarget; - for (i=0 ;i<sec->linecount ; i++) { check = sec->lines[i]; if (! (check->flags & ML_TWOSIDED) ) continue; - P_LineOpening (check); - if (openrange <= 0) continue; - if ( sides[ check->sidenum[0] ].sector == sec) other = sides[ check->sidenum[1] ] .sector; else other = sides[ check->sidenum[0] ].sector; - if (check->flags & ML_SOUNDBLOCK) { if (!soundblocks) @@ -145,14 +69,6 @@ P_RecursiveSound P_RecursiveSound (other, soundblocks); } } - - - - - - - - void P_NoiseAlert ( mobj_t* target, @@ -162,160 +78,99 @@ P_NoiseAlert validcount++; P_RecursiveSound (emmiter->subsector->sector, 0); } - - - - - - - boolean P_CheckMeleeRange (mobj_t* actor) { mobj_t* pl; fixed_t dist; - if (!actor->target) return false; - pl = actor->target; dist = P_AproxDistance (pl->x-actor->x, pl->y-actor->y); - if (dist >= MELEERANGE-20*FRACUNIT+pl->info->radius) return false; - if (! P_CheckSight (actor, actor->target) ) return false; - return true; } - - - - boolean P_CheckMissileRange (mobj_t* actor) { fixed_t dist; - if (! P_CheckSight (actor, actor->target) ) return false; - if ( actor->flags & MF_JUSTHIT ) { - - actor->flags &= ~MF_JUSTHIT; return true; } - if (actor->reactiontime) return false; - - dist = P_AproxDistance ( actor->x-actor->target->x, actor->y-actor->target->y) - 64*FRACUNIT; - if (!actor->info->meleestate) dist -= 128*FRACUNIT; - dist >>= 16; - if (actor->type == MT_VILE) { if (dist > 14*64) return false; } - - if (actor->type == MT_UNDEAD) { if (dist < 196) return false; dist >>= 1; } - - if (actor->type == MT_CYBORG || actor->type == MT_SPIDER || actor->type == MT_SKULL) { dist >>= 1; } - if (dist > 200) dist = 200; - if (actor->type == MT_CYBORG && dist > 160) dist = 160; - if (P_Random () < dist) return false; - return true; } - - - - - - - fixed_t xspeed[8] = {FRACUNIT,47000,0,-47000,-FRACUNIT,-47000,0,47000}; fixed_t yspeed[8] = {0,47000,FRACUNIT,47000,0,-47000,-FRACUNIT,-47000}; - #define MAXSPECIALCROSS 8 - extern line_t* spechit[MAXSPECIALCROSS]; extern int numspechit; - boolean P_Move (mobj_t* actor) { fixed_t tryx; fixed_t tryy; - line_t* ld; - - - boolean try_ok; boolean good; - if (actor->movedir == DI_NODIR) return false; - if ((unsigned)actor->movedir >= 8) I_Error ("Weird actor->movedir!"); - tryx = actor->x + actor->info->speed*xspeed[actor->movedir]; tryy = actor->y + actor->info->speed*yspeed[actor->movedir]; - try_ok = P_TryMove (actor, tryx, tryy); - if (!try_ok) { - if (actor->flags & MF_FLOAT && floatok) { - if (actor->z < tmfloorz) actor->z += FLOATSPEED; else actor->z -= FLOATSPEED; - actor->flags |= MF_INFLOAT; return true; } - if (!numspechit) return false; - actor->movedir = DI_NODIR; good = false; while (numspechit--) { ld = spechit[numspechit]; - - - if (P_UseSpecialLine (actor, ld,0)) good = true; } @@ -325,75 +180,45 @@ boolean P_Move (mobj_t* actor) { actor->flags &= ~MF_INFLOAT; } - - if (! (actor->flags & MF_FLOAT) ) actor->z = actor->floorz; return true; } - - - - - - - - - - - - - boolean P_TryWalk (mobj_t* actor) { if (!P_Move (actor)) { return false; } - actor->movecount = P_Random()&15; return true; } - - - - void P_NewChaseDir (mobj_t* actor) { fixed_t deltax; fixed_t deltay; - dirtype_t d[3]; - int tdir; dirtype_t olddir; - dirtype_t turnaround; - if (!actor->target) I_Error ("P_NewChaseDir: called with no target"); - olddir = actor->movedir; turnaround=opposite[olddir]; - deltax = actor->target->x - actor->x; deltay = actor->target->y - actor->y; - if (deltax>10*FRACUNIT) d[1]= DI_EAST; else if (deltax<-10*FRACUNIT) d[1]= DI_WEST; else d[1]=DI_NODIR; - if (deltay<-10*FRACUNIT) d[2]= DI_SOUTH; else if (deltay>10*FRACUNIT) d[2]= DI_NORTH; else d[2]=DI_NODIR; - - if (d[1] != DI_NODIR && d[2] != DI_NODIR) { @@ -401,8 +226,6 @@ void P_NewChaseDir (mobj_t* actor) if (actor->movedir != turnaround && P_TryWalk(actor)) return; } - - if (P_Random() > 200 || abs(deltay)>abs(deltax)) { @@ -410,41 +233,30 @@ void P_NewChaseDir (mobj_t* actor) d[1]=d[2]; d[2]=tdir; } - if (d[1]==turnaround) d[1]=DI_NODIR; if (d[2]==turnaround) d[2]=DI_NODIR; - if (d[1]!=DI_NODIR) { actor->movedir = d[1]; if (P_TryWalk(actor)) { - return; } } - if (d[2]!=DI_NODIR) { actor->movedir =d[2]; - if (P_TryWalk(actor)) return; } - - - if (olddir!=DI_NODIR) { actor->movedir =olddir; - if (P_TryWalk(actor)) return; } - - if (P_Random()&1) { for ( tdir=DI_EAST; @@ -454,7 +266,6 @@ void P_NewChaseDir (mobj_t* actor) if (tdir!=turnaround) { actor->movedir =tdir; - if ( P_TryWalk(actor) ) return; } @@ -469,30 +280,19 @@ void P_NewChaseDir (mobj_t* actor) if (tdir!=turnaround) { actor->movedir =tdir; - if ( P_TryWalk(actor) ) return; } } } - if (turnaround != DI_NODIR) { actor->movedir =turnaround; if ( P_TryWalk(actor) ) return; } - actor->movedir = DI_NODIR; } - - - - - - - - boolean P_LookForPlayers ( mobj_t* actor, @@ -504,32 +304,23 @@ P_LookForPlayers sector_t* sector; angle_t an; fixed_t dist; - sector = actor->subsector->sector; - c = 0; stop = (actor->lastlook-1)&3; - for ( ; ; actor->lastlook = (actor->lastlook+1)&3 ) { if (!playeringame[actor->lastlook]) continue; - if (c++ == 2 || actor->lastlook == stop) { - return false; } - player = &players[actor->lastlook]; - if (player->health <= 0) continue; - if (!P_CheckSight (actor, player->mo)) continue; - if (!allaround) { an = R_PointToAngle2 (actor->x, @@ -537,80 +328,49 @@ P_LookForPlayers player->mo->x, player->mo->y) - actor->angle; - if (an > ANG90 && an < ANG270) { dist = P_AproxDistance (player->mo->x - actor->x, player->mo->y - actor->y); - if (dist > MELEERANGE) continue; } } - actor->target = player->mo; return true; } - return false; } - - - - - - - void A_KeenDie (mobj_t* mo) { thinker_t* th; mobj_t* mo2; line_t junk; - A_Fall (mo); - - - for (th = thinkercap.next ; th != &thinkercap ; th=th->next) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - mo2 = (mobj_t *)th; if (mo2 != mo && mo2->type == mo->type && mo2->health > 0) { - return; } } - junk.tag = 666; EV_DoDoor(&junk,open); } - - - - - - - - - - void A_Look (mobj_t* actor) { mobj_t* targ; - actor->threshold = 0; targ = actor->subsector->sector->soundtarget; - if (targ && (targ->flags & MF_SHOOTABLE) ) { actor->target = targ; - if ( actor->flags & MF_AMBUSH ) { if (P_CheckSight (actor, actor->target)) @@ -619,17 +379,12 @@ void A_Look (mobj_t* actor) else goto seeyou; } - - if (!P_LookForPlayers (actor, false) ) return; - - seeyou: if (actor->info->seesound) { int sound; - switch (actor->info->seesound) { case sfx_posit1: @@ -637,45 +392,29 @@ void A_Look (mobj_t* actor) case sfx_posit3: sound = sfx_posit1+P_Random()%3; break; - case sfx_bgsit1: case sfx_bgsit2: sound = sfx_bgsit1+P_Random()%2; break; - default: sound = actor->info->seesound; break; } - if (actor->type==MT_SPIDER || actor->type == MT_CYBORG) { - S_StartSound (NULL, sound); } else S_StartSound (actor, sound); } - P_SetMobjState (actor, actor->info->seestate); } - - - - - - - void A_Chase (mobj_t* actor) { int delta; - if (actor->reactiontime) actor->reactiontime--; - - - if (actor->threshold) { if (!actor->target @@ -686,31 +425,23 @@ void A_Chase (mobj_t* actor) else actor->threshold--; } - - if (actor->movedir < 8) { actor->angle &= (7<<29); delta = actor->angle - (actor->movedir << 29); - if (delta > 0) actor->angle -= ANG90/2; else if (delta < 0) actor->angle += ANG90/2; } - if (!actor->target || !(actor->target->flags&MF_SHOOTABLE)) { - if (P_LookForPlayers(actor,true)) return; - P_SetMobjState (actor, actor->info->spawnstate); return; } - - if (actor->flags & MF_JUSTATTACKED) { actor->flags &= ~MF_JUSTATTACKED; @@ -718,19 +449,14 @@ void A_Chase (mobj_t* actor) P_NewChaseDir (actor); return; } - - if (actor->info->meleestate && P_CheckMeleeRange (actor)) { if (actor->info->attacksound) S_StartSound (actor, actor->info->attacksound); - P_SetMobjState (actor, actor->info->meleestate); return; } - - if (actor->info->missilestate) { if (gameskill < sk_nightmare @@ -738,18 +464,13 @@ void A_Chase (mobj_t* actor) { goto nomissile; } - if (!P_CheckMissileRange (actor)) goto nomissile; - P_SetMobjState (actor, actor->info->missilestate); actor->flags |= MF_JUSTATTACKED; return; } - - nomissile: - if (netgame && !actor->threshold && !P_CheckSight (actor, actor->target) ) @@ -757,65 +478,44 @@ void A_Chase (mobj_t* actor) if (P_LookForPlayers(actor,true)) return; } - - if (--actor->movecount<0 || !P_Move (actor)) { P_NewChaseDir (actor); } - - if (actor->info->activesound && P_Random () < 3) { S_StartSound (actor, actor->info->activesound); } } - - - - - void A_FaceTarget (mobj_t* actor) { if (!actor->target) return; - actor->flags &= ~MF_AMBUSH; - actor->angle = R_PointToAngle2 (actor->x, actor->y, actor->target->x, actor->target->y); - if (actor->target->flags & MF_SHADOW) actor->angle += (P_Random()-P_Random())<<21; } - - - - - void A_PosAttack (mobj_t* actor) { int angle; int damage; int slope; - if (!actor->target) return; - A_FaceTarget (actor); angle = actor->angle; slope = P_AimLineAttack (actor, angle, MISSILERANGE); - S_StartSound (actor, sfx_pistol); angle += (P_Random()-P_Random())<<20; damage = ((P_Random()%5)+1)*3; P_LineAttack (actor, angle, MISSILERANGE, slope, damage); } - void A_SPosAttack (mobj_t* actor) { int i; @@ -823,15 +523,12 @@ void A_SPosAttack (mobj_t* actor) int bangle; int damage; int slope; - if (!actor->target) return; - S_StartSound (actor, sfx_shotgn); A_FaceTarget (actor); bangle = actor->angle; slope = P_AimLineAttack (actor, bangle, MISSILERANGE); - for (i=0 ; i<3 ; i++) { angle = bangle + ((P_Random()-P_Random())<<20); @@ -839,35 +536,27 @@ void A_SPosAttack (mobj_t* actor) P_LineAttack (actor, angle, MISSILERANGE, slope, damage); } } - void A_CPosAttack (mobj_t* actor) { int angle; int bangle; int damage; int slope; - if (!actor->target) return; - S_StartSound (actor, sfx_shotgn); A_FaceTarget (actor); bangle = actor->angle; slope = P_AimLineAttack (actor, bangle, MISSILERANGE); - angle = bangle + ((P_Random()-P_Random())<<20); damage = ((P_Random()%5)+1)*3; P_LineAttack (actor, angle, MISSILERANGE, slope, damage); } - void A_CPosRefire (mobj_t* actor) { - A_FaceTarget (actor); - if (P_Random () < 40) return; - if (!actor->target || actor->target->health <= 0 || !P_CheckSight (actor, actor->target) ) @@ -875,16 +564,11 @@ void A_CPosRefire (mobj_t* actor) P_SetMobjState (actor, actor->info->seestate); } } - - void A_SpidRefire (mobj_t* actor) { - A_FaceTarget (actor); - if (P_Random () < 10) return; - if (!actor->target || actor->target->health <= 0 || !P_CheckSight (actor, actor->target) ) @@ -892,29 +576,18 @@ void A_SpidRefire (mobj_t* actor) P_SetMobjState (actor, actor->info->seestate); } } - void A_BspiAttack (mobj_t *actor) { if (!actor->target) return; - A_FaceTarget (actor); - - P_SpawnMissile (actor, actor->target, MT_ARACHPLAZ); } - - - - - void A_TroopAttack (mobj_t* actor) { int damage; - if (!actor->target) return; - A_FaceTarget (actor); if (P_CheckMeleeRange (actor)) { @@ -923,20 +596,13 @@ void A_TroopAttack (mobj_t* actor) P_DamageMobj (actor->target, actor, actor, damage); return; } - - - P_SpawnMissile (actor, actor->target, MT_TROOPSHOT); } - - void A_SargAttack (mobj_t* actor) { int damage; - if (!actor->target) return; - A_FaceTarget (actor); if (P_CheckMeleeRange (actor)) { @@ -944,14 +610,11 @@ void A_SargAttack (mobj_t* actor) P_DamageMobj (actor->target, actor, actor, damage); } } - void A_HeadAttack (mobj_t* actor) { int damage; - if (!actor->target) return; - A_FaceTarget (actor); if (P_CheckMeleeRange (actor)) { @@ -959,28 +622,20 @@ void A_HeadAttack (mobj_t* actor) P_DamageMobj (actor->target, actor, actor, damage); return; } - - P_SpawnMissile (actor, actor->target, MT_HEADSHOT); } - void A_CyberAttack (mobj_t* actor) { if (!actor->target) return; - A_FaceTarget (actor); P_SpawnMissile (actor, actor->target, MT_ROCKET); } - - void A_BruisAttack (mobj_t* actor) { int damage; - if (!actor->target) return; - if (P_CheckMeleeRange (actor)) { S_StartSound (actor, sfx_claw); @@ -988,34 +643,22 @@ void A_BruisAttack (mobj_t* actor) P_DamageMobj (actor->target, actor, actor, damage); return; } - - P_SpawnMissile (actor, actor->target, MT_BRUISERSHOT); } - - - - - void A_SkelMissile (mobj_t* actor) { mobj_t* mo; - if (!actor->target) return; - A_FaceTarget (actor); actor->z += 16*FRACUNIT; mo = P_SpawnMissile (actor, actor->target, MT_TRACER); actor->z -= 16*FRACUNIT; - mo->x += mo->momx; mo->y += mo->momy; mo->tracer = actor->target; } - int TRACEANGLE = 0xc000000; - void A_Tracer (mobj_t* actor) { angle_t exact; @@ -1023,34 +666,23 @@ void A_Tracer (mobj_t* actor) fixed_t slope; mobj_t* dest; mobj_t* th; - if (gametic & 3) return; - - P_SpawnPuff (actor->x, actor->y, actor->z); - th = P_SpawnMobj (actor->x-actor->momx, actor->y-actor->momy, actor->z, MT_SMOKE); - th->momz = FRACUNIT; th->tics -= P_Random()&3; if (th->tics < 1) th->tics = 1; - - dest = actor->tracer; - if (!dest || dest->health <= 0) return; - - exact = R_PointToAngle2 (actor->x, actor->y, dest->x, dest->y); - if (exact != actor->angle) { if (exact - actor->angle > 0x80000000) @@ -1066,28 +698,20 @@ void A_Tracer (mobj_t* actor) actor->angle = exact; } } - exact = actor->angle>>ANGLETOFINESHIFT; actor->momx = FixedMul (actor->info->speed, finecosine[exact]); actor->momy = FixedMul (actor->info->speed, finesine[exact]); - - dist = P_AproxDistance (dest->x - actor->x, dest->y - actor->y); - dist = dist / actor->info->speed; - if (dist < 1) dist = 1; slope = (dest->z+40*FRACUNIT - actor->z) / dist; - if (slope < actor->momz) actor->momz -= FRACUNIT/8; else actor->momz += FRACUNIT/8; } - - void A_SkelWhoosh (mobj_t* actor) { if (!actor->target) @@ -1095,16 +719,12 @@ void A_SkelWhoosh (mobj_t* actor) A_FaceTarget (actor); S_StartSound (actor,sfx_skeswg); } - void A_SkelFist (mobj_t* actor) { int damage; - if (!actor->target) return; - A_FaceTarget (actor); - if (P_CheckMeleeRange (actor)) { damage = ((P_Random()%10)+1)*6; @@ -1112,320 +732,202 @@ void A_SkelFist (mobj_t* actor) P_DamageMobj (actor->target, actor, actor, damage); } } - - - - - - - mobj_t* corpsehit; mobj_t* vileobj; fixed_t viletryx; fixed_t viletryy; - boolean PIT_VileCheck (mobj_t* thing) { int maxdist; boolean check; - if (!(thing->flags & MF_CORPSE) ) return true; - if (thing->tics != -1) return true; - if (thing->info->raisestate == S_NULL) return true; - maxdist = thing->info->radius + mobjinfo[MT_VILE].radius; - if ( abs(thing->x - viletryx) > maxdist || abs(thing->y - viletryy) > maxdist ) return true; - corpsehit = thing; corpsehit->momx = corpsehit->momy = 0; corpsehit->height <<= 2; check = P_CheckPosition (corpsehit, corpsehit->x, corpsehit->y); corpsehit->height >>= 2; - if (!check) return true; - return false; } - - - - - - - void A_VileChase (mobj_t* actor) { int xl; int xh; int yl; int yh; - int bx; int by; - mobjinfo_t* info; mobj_t* temp; - if (actor->movedir != DI_NODIR) { - viletryx = actor->x + actor->info->speed*xspeed[actor->movedir]; viletryy = actor->y + actor->info->speed*yspeed[actor->movedir]; - xl = (viletryx - bmaporgx - MAXRADIUS*2)>>MAPBLOCKSHIFT; xh = (viletryx - bmaporgx + MAXRADIUS*2)>>MAPBLOCKSHIFT; yl = (viletryy - bmaporgy - MAXRADIUS*2)>>MAPBLOCKSHIFT; yh = (viletryy - bmaporgy + MAXRADIUS*2)>>MAPBLOCKSHIFT; - vileobj = actor; for (bx=xl ; bx<=xh ; bx++) { for (by=yl ; by<=yh ; by++) { - - - if (!P_BlockThingsIterator(bx,by,PIT_VileCheck)) { - temp = actor->target; actor->target = corpsehit; A_FaceTarget (actor); actor->target = temp; - P_SetMobjState (actor, S_VILE_HEAL1); S_StartSound (corpsehit, sfx_slop); info = corpsehit->info; - P_SetMobjState (corpsehit,info->raisestate); corpsehit->height <<= 2; corpsehit->flags = info->flags; corpsehit->health = info->spawnhealth; corpsehit->target = NULL; - return; } } } } - - A_Chase (actor); } - - - - - void A_VileStart (mobj_t* actor) { S_StartSound (actor, sfx_vilatk); } - - - - - - void A_Fire (mobj_t* actor); - void A_StartFire (mobj_t* actor) { S_StartSound(actor,sfx_flamst); A_Fire(actor); } - void A_FireCrackle (mobj_t* actor) { S_StartSound(actor,sfx_flame); A_Fire(actor); } - void A_Fire (mobj_t* actor) { mobj_t* dest; unsigned an; - dest = actor->tracer; if (!dest) return; - - if (!P_CheckSight (actor->target, dest) ) return; - an = dest->angle >> ANGLETOFINESHIFT; - P_UnsetThingPosition (actor); actor->x = dest->x + FixedMul (24*FRACUNIT, finecosine[an]); actor->y = dest->y + FixedMul (24*FRACUNIT, finesine[an]); actor->z = dest->z; P_SetThingPosition (actor); } - - - - - - - void A_VileTarget (mobj_t* actor) { mobj_t* fog; - if (!actor->target) return; - A_FaceTarget (actor); - fog = P_SpawnMobj (actor->target->x, actor->target->x, actor->target->z, MT_FIRE); - actor->tracer = fog; fog->target = actor; fog->tracer = actor->target; A_Fire (fog); } - - - - - - - void A_VileAttack (mobj_t* actor) { mobj_t* fire; int an; - if (!actor->target) return; - A_FaceTarget (actor); - if (!P_CheckSight (actor, actor->target) ) return; - S_StartSound (actor, sfx_barexp); P_DamageMobj (actor->target, actor, actor, 20); actor->target->momz = 1000*FRACUNIT/actor->target->info->mass; - an = actor->angle >> ANGLETOFINESHIFT; - fire = actor->tracer; - if (!fire) return; - - fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]); fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]); P_RadiusAttack (fire, actor, 70 ); } - - - - - - - - - - #define FATSPREAD (ANG90/8) - void A_FatRaise (mobj_t *actor) { A_FaceTarget (actor); S_StartSound (actor, sfx_manatk); } - - void A_FatAttack1 (mobj_t* actor) { mobj_t* mo; int an; - A_FaceTarget (actor); - actor->angle += FATSPREAD; P_SpawnMissile (actor, actor->target, MT_FATSHOT); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); mo->angle += FATSPREAD; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); mo->momy = FixedMul (mo->info->speed, finesine[an]); } - void A_FatAttack2 (mobj_t* actor) { mobj_t* mo; int an; - A_FaceTarget (actor); - actor->angle -= FATSPREAD; P_SpawnMissile (actor, actor->target, MT_FATSHOT); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); mo->angle -= FATSPREAD*2; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); mo->momy = FixedMul (mo->info->speed, finesine[an]); } - void A_FatAttack3 (mobj_t* actor) { mobj_t* mo; int an; - A_FaceTarget (actor); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); mo->angle -= FATSPREAD/2; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); mo->momy = FixedMul (mo->info->speed, finesine[an]); - mo = P_SpawnMissile (actor, actor->target, MT_FATSHOT); mo->angle += FATSPREAD/2; an = mo->angle >> ANGLETOFINESHIFT; mo->momx = FixedMul (mo->info->speed, finecosine[an]); mo->momy = FixedMul (mo->info->speed, finesine[an]); } - - - - - - #define SKULLSPEED (20*FRACUNIT) - void A_SkullAttack (mobj_t* actor) { mobj_t* dest; angle_t an; int dist; - if (!actor->target) return; - dest = actor->target; actor->flags |= MF_SKULLFLY; - S_StartSound (actor, actor->info->attacksound); A_FaceTarget (actor); an = actor->angle >> ANGLETOFINESHIFT; @@ -1433,17 +935,10 @@ void A_SkullAttack (mobj_t* actor) actor->momy = FixedMul (SKULLSPEED, finesine[an]); dist = P_AproxDistance (dest->x - actor->x, dest->y - actor->y); dist = dist / SKULLSPEED; - if (dist < 1) dist = 1; actor->momz = (dest->z+(dest->height>>1) - actor->z) / dist; } - - - - - - void A_PainShootSkull ( mobj_t* actor, @@ -1452,16 +947,12 @@ A_PainShootSkull fixed_t x; fixed_t y; fixed_t z; - mobj_t* newmobj; angle_t an; int prestep; int count; thinker_t* currentthinker; - - count = 0; - currentthinker = thinkercap.next; while (currentthinker != &thinkercap) { @@ -1470,53 +961,31 @@ A_PainShootSkull count++; currentthinker = currentthinker->next; } - - - if (count > 20) return; - - - an = angle >> ANGLETOFINESHIFT; - prestep = 4*FRACUNIT + 3*(actor->info->radius + mobjinfo[MT_SKULL].radius)/2; - x = actor->x + FixedMul (prestep, finecosine[an]); y = actor->y + FixedMul (prestep, finesine[an]); z = actor->z + 8*FRACUNIT; - newmobj = P_SpawnMobj (x , y, z, MT_SKULL); - - if (!P_TryMove (newmobj, newmobj->x, newmobj->y)) { - P_DamageMobj (newmobj,actor,actor,10000); return; } - newmobj->target = actor->target; A_SkullAttack (newmobj); } - - - - - - void A_PainAttack (mobj_t* actor) { if (!actor->target) return; - A_FaceTarget (actor); A_PainShootSkull (actor, actor->angle); } - - void A_PainDie (mobj_t* actor) { A_Fall (actor); @@ -1524,98 +993,61 @@ void A_PainDie (mobj_t* actor) A_PainShootSkull (actor, actor->angle+ANG180); A_PainShootSkull (actor, actor->angle+ANG270); } - - - - - - void A_Scream (mobj_t* actor) { int sound; - switch (actor->info->deathsound) { case 0: return; - case sfx_podth1: case sfx_podth2: case sfx_podth3: sound = sfx_podth1 + P_Random ()%3; break; - case sfx_bgdth1: case sfx_bgdth2: sound = sfx_bgdth1 + P_Random ()%2; break; - default: sound = actor->info->deathsound; break; } - - if (actor->type==MT_SPIDER || actor->type == MT_CYBORG) { - S_StartSound (NULL, sound); } else S_StartSound (actor, sound); } - - void A_XScream (mobj_t* actor) { S_StartSound (actor, sfx_slop); } - void A_Pain (mobj_t* actor) { if (actor->info->painsound) S_StartSound (actor, actor->info->painsound); } - - - void A_Fall (mobj_t *actor) { - actor->flags &= ~MF_SOLID; - - - -} - - - - - +} void A_Explode (mobj_t* thingy) { P_RadiusAttack ( thingy, thingy->target, 128 ); } - - - - - - - void A_BossDeath (mobj_t* mo) { thinker_t* th; mobj_t* mo2; line_t junk; int i; - if ( gamemode == commercial) { if (gamemap != 7) return; - if ((mo->type != MT_FATSO) && (mo->type != MT_BABY)) return; @@ -1627,28 +1059,21 @@ void A_BossDeath (mobj_t* mo) case 1: if (gamemap != 8) return; - if (mo->type != MT_BRUISER) return; break; - case 2: if (gamemap != 8) return; - if (mo->type != MT_CYBORG) return; break; - case 3: if (gamemap != 8) return; - if (mo->type != MT_SPIDER) return; - break; - case 4: switch(gamemap) { @@ -1656,53 +1081,38 @@ void A_BossDeath (mobj_t* mo) if (mo->type != MT_CYBORG) return; break; - case 8: if (mo->type != MT_SPIDER) return; break; - default: return; break; } break; - default: if (gamemap != 8) return; break; } - } - - - for (i=0 ; i<MAXPLAYERS ; i++) if (playeringame[i] && players[i].health > 0) break; - if (i==MAXPLAYERS) return; - - - for (th = thinkercap.next ; th != &thinkercap ; th=th->next) { if (th->function.acp1 != (actionf_p1)P_MobjThinker) continue; - mo2 = (mobj_t *)th; if (mo2 != mo && mo2->type == mo->type && mo2->health > 0) { - return; } } - - if ( gamemode == commercial) { if (gamemap == 7) @@ -1713,7 +1123,6 @@ void A_BossDeath (mobj_t* mo) EV_DoFloor(&junk,lowerFloorToLowest); return; } - if (mo->type == MT_BABY) { junk.tag = 667; @@ -1731,7 +1140,6 @@ void A_BossDeath (mobj_t* mo) EV_DoFloor (&junk, lowerFloorToLowest); return; break; - case 4: switch(gamemap) { @@ -1740,7 +1148,6 @@ void A_BossDeath (mobj_t* mo) EV_DoDoor (&junk, blazeOpen); return; break; - case 8: junk.tag = 666; EV_DoFloor (&junk, lowerFloorToLowest); @@ -1749,29 +1156,23 @@ void A_BossDeath (mobj_t* mo) } } } - G_ExitLevel (); } - - void A_Hoof (mobj_t* mo) { S_StartSound (mo, sfx_hoof); A_Chase (mo); } - void A_Metal (mobj_t* mo) { S_StartSound (mo, sfx_metal); A_Chase (mo); } - void A_BabyMetal (mobj_t* mo) { S_StartSound (mo, sfx_bspwlk); A_Chase (mo); } - void A_OpenShotgun2 ( player_t* player, @@ -1779,7 +1180,6 @@ A_OpenShotgun2 { S_StartSound (player->mo, sfx_dbopn); } - void A_LoadShotgun2 ( player_t* player, @@ -1787,12 +1187,10 @@ A_LoadShotgun2 { S_StartSound (player->mo, sfx_dbload); } - void A_ReFire ( player_t* player, pspdef_t* psp ); - void A_CloseShotgun2 ( player_t* player, @@ -1801,22 +1199,15 @@ A_CloseShotgun2 S_StartSound (player->mo, sfx_dbcls); A_ReFire(player,psp); } - - - mobj_t* braintargets[32]; int numbraintargets; int braintargeton; - void A_BrainAwake (mobj_t* mo) { thinker_t* thinker; mobj_t* m; - - numbraintargets = 0; braintargeton = 0; - thinker = thinkercap.next; for (thinker = thinkercap.next ; thinker != &thinkercap ; @@ -1824,113 +1215,80 @@ void A_BrainAwake (mobj_t* mo) { if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) continue; - m = (mobj_t *)thinker; - if (m->type == MT_BOSSTARGET ) { braintargets[numbraintargets] = m; numbraintargets++; } } - S_StartSound (NULL,sfx_bossit); } - - void A_BrainPain (mobj_t* mo) { S_StartSound (NULL,sfx_bospn); } - - void A_BrainScream (mobj_t* mo) { int x; int y; int z; mobj_t* th; - for (x=mo->x - 196*FRACUNIT ; x< mo->x + 320*FRACUNIT ; x+= FRACUNIT*8) { y = mo->y - 320*FRACUNIT; z = 128 + P_Random()*2*FRACUNIT; th = P_SpawnMobj (x,y,z, MT_ROCKET); th->momz = P_Random()*512; - P_SetMobjState (th, S_BRAINEXPLODE1); - th->tics -= P_Random()&7; if (th->tics < 1) th->tics = 1; } - S_StartSound (NULL,sfx_bosdth); } - - - void A_BrainExplode (mobj_t* mo) { int x; int y; int z; mobj_t* th; - x = mo->x + (P_Random () - P_Random ())*2048; y = mo->y; z = 128 + P_Random()*2*FRACUNIT; th = P_SpawnMobj (x,y,z, MT_ROCKET); th->momz = P_Random()*512; - P_SetMobjState (th, S_BRAINEXPLODE1); - th->tics -= P_Random()&7; if (th->tics < 1) th->tics = 1; } - - void A_BrainDie (mobj_t* mo) { G_ExitLevel (); } - void A_BrainSpit (mobj_t* mo) { mobj_t* targ; mobj_t* newmobj; - static int easy = 0; - easy ^= 1; if (gameskill <= sk_easy && (!easy)) return; - - targ = braintargets[braintargeton]; braintargeton = (braintargeton+1)%numbraintargets; - - newmobj = P_SpawnMissile (mo, targ, MT_SPAWNSHOT); newmobj->target = targ; newmobj->reactiontime = ((targ->y - mo->y)/newmobj->momy) / newmobj->state->tics; - S_StartSound(NULL, sfx_bospit); } - - - void A_SpawnFly (mobj_t* mo); - - void A_SpawnSound (mobj_t* mo) { S_StartSound (mo,sfx_boscub); A_SpawnFly(mo); } - void A_SpawnFly (mobj_t* mo) { mobj_t* newmobj; @@ -1938,21 +1296,12 @@ void A_SpawnFly (mobj_t* mo) mobj_t* targ; int r; mobjtype_t type; - if (--mo->reactiontime) return; - targ = mo->target; - - fog = P_SpawnMobj (targ->x, targ->y, targ->z, MT_SPAWNFIRE); S_StartSound (fog, sfx_telept); - - r = P_Random (); - - - if ( r<50 ) type = MT_TROOP; else if (r<90) @@ -1975,32 +1324,19 @@ void A_SpawnFly (mobj_t* mo) type = MT_KNIGHT; else type = MT_BRUISER; - newmobj = P_SpawnMobj (targ->x, targ->y, targ->z, type); if (P_LookForPlayers (newmobj, true) ) P_SetMobjState (newmobj, newmobj->info->seestate); - - P_TeleportMove (newmobj, newmobj->x, newmobj->y); - - P_RemoveMobj (mo); } - - - void A_PlayerScream (mobj_t* mo) { - int sound = sfx_pldeth; - if ( (gamemode == commercial) && (mo->health < -50)) { - - sound = sfx_pdiehi; } - S_StartSound (mo, sound); } diff --git a/src/p_floor.c b/src/p_floor.c @@ -1,48 +1,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include "z_zone.h" #include "doomdef.h" #include "p_local.h" - #include "s_sound.h" - - #include "doomstat.h" #include "r_state.h" - #include "sounds.h" - - - - - - - - - result_e T_MovePlane ( sector_t* sector, @@ -54,15 +16,12 @@ T_MovePlane { boolean flag; fixed_t lastpos; - switch(floorOrCeiling) { case 0: - switch(direction) { case -1: - if (sector->floorheight - speed < dest) { lastpos = sector->floorheight; @@ -72,7 +31,6 @@ T_MovePlane { sector->floorheight =lastpos; P_ChangeSector(sector,crush); - } return pastdest; } @@ -89,9 +47,7 @@ T_MovePlane } } break; - case 1: - if (sector->floorheight + speed > dest) { lastpos = sector->floorheight; @@ -101,13 +57,11 @@ T_MovePlane { sector->floorheight = lastpos; P_ChangeSector(sector,crush); - } return pastdest; } else { - lastpos = sector->floorheight; sector->floorheight += speed; flag = P_ChangeSector(sector,crush); @@ -123,34 +77,27 @@ T_MovePlane break; } break; - case 1: - switch(direction) { case -1: - if (sector->ceilingheight - speed < dest) { lastpos = sector->ceilingheight; sector->ceilingheight = dest; flag = P_ChangeSector(sector,crush); - if (flag == true) { sector->ceilingheight = lastpos; P_ChangeSector(sector,crush); - } return pastdest; } else { - lastpos = sector->ceilingheight; sector->ceilingheight -= speed; flag = P_ChangeSector(sector,crush); - if (flag == true) { if (crush == true) @@ -161,9 +108,7 @@ T_MovePlane } } break; - case 1: - if (sector->ceilingheight + speed > dest) { lastpos = sector->ceilingheight; @@ -173,7 +118,6 @@ T_MovePlane { sector->ceilingheight = lastpos; P_ChangeSector(sector,crush); - } return pastdest; } @@ -182,7 +126,6 @@ T_MovePlane lastpos = sector->ceilingheight; sector->ceilingheight += speed; flag = P_ChangeSector(sector,crush); - #if 0 if (flag == true) { @@ -195,32 +138,22 @@ T_MovePlane break; } break; - } return ok; } - - - - - void T_MoveFloor(floormove_t* floor) { result_e res; - res = T_MovePlane(floor->sector, floor->speed, floor->floordestheight, floor->crush,0,floor->direction); - if (!(leveltime&7)) S_StartSound((mobj_t *)&floor->sector->soundorg, sfx_stnmov); - if (res == pastdest) { floor->sector->specialdata = NULL; - if (floor->direction == 1) { switch(floor->type) @@ -244,16 +177,10 @@ void T_MoveFloor(floormove_t* floor) } } P_RemoveThinker(&floor->thinker); - S_StartSound((mobj_t *)&floor->sector->soundorg, sfx_pstop); } - } - - - - int EV_DoFloor ( line_t* line, @@ -264,18 +191,13 @@ EV_DoFloor int i; sector_t* sec; floormove_t* floor; - secnum = -1; rtn = 0; while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; - - if (sec->specialdata) continue; - - rtn = 1; floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); P_AddThinker (&floor->thinker); @@ -283,7 +205,6 @@ EV_DoFloor floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor; floor->type = floortype; floor->crush = false; - switch(floortype) { case lowerFloor: @@ -293,7 +214,6 @@ EV_DoFloor floor->floordestheight = P_FindHighestFloorSurrounding(sec); break; - case lowerFloorToLowest: floor->direction = -1; floor->sector = sec; @@ -301,7 +221,6 @@ EV_DoFloor floor->floordestheight = P_FindLowestFloorSurrounding(sec); break; - case turboLower: floor->direction = -1; floor->sector = sec; @@ -311,7 +230,6 @@ EV_DoFloor if (floor->floordestheight != sec->floorheight) floor->floordestheight += 8*FRACUNIT; break; - case raiseFloorCrush: floor->crush = true; case raiseFloor: @@ -325,7 +243,6 @@ EV_DoFloor floor->floordestheight -= (8*FRACUNIT)* (floortype == raiseFloorCrush); break; - case raiseFloorTurbo: floor->direction = 1; floor->sector = sec; @@ -333,7 +250,6 @@ EV_DoFloor floor->floordestheight = P_FindNextHighestFloor(sec,sec->floorheight); break; - case raiseFloorToNearest: floor->direction = 1; floor->sector = sec; @@ -341,7 +257,6 @@ EV_DoFloor floor->floordestheight = P_FindNextHighestFloor(sec,sec->floorheight); break; - case raiseFloor24: floor->direction = 1; floor->sector = sec; @@ -356,7 +271,6 @@ EV_DoFloor floor->floordestheight = floor->sector->floorheight + 512 * FRACUNIT; break; - case raiseFloor24AndChange: floor->direction = 1; floor->sector = sec; @@ -366,12 +280,10 @@ EV_DoFloor sec->floorpic = line->frontsector->floorpic; sec->special = line->frontsector->special; break; - case raiseToTexture: { int minsize = MAXINT; side_t* side; - floor->direction = 1; floor->sector = sec; floor->speed = FLOORSPEED; @@ -397,7 +309,6 @@ EV_DoFloor floor->sector->floorheight + minsize; } break; - case lowerAndChange: floor->direction = -1; floor->sector = sec; @@ -405,7 +316,6 @@ EV_DoFloor floor->floordestheight = P_FindLowestFloorSurrounding(sec); floor->texture = sec->floorpic; - for (i = 0; i < sec->linecount; i++) { if ( twoSided(secnum, i) ) @@ -413,7 +323,6 @@ EV_DoFloor if (getSide(secnum,i,0)->sector-sectors == secnum) { sec = getSector(secnum,i,1); - if (sec->floorheight == floor->floordestheight) { floor->texture = sec->floorpic; @@ -424,7 +333,6 @@ EV_DoFloor else { sec = getSector(secnum,i,0); - if (sec->floorheight == floor->floordestheight) { floor->texture = sec->floorpic; @@ -440,13 +348,6 @@ EV_DoFloor } return rtn; } - - - - - - - int EV_BuildStairs ( line_t* line, @@ -459,26 +360,18 @@ EV_BuildStairs int texture; int ok; int rtn; - sector_t* sec; sector_t* tsec; - floormove_t* floor; - fixed_t stairsize; fixed_t speed; - secnum = -1; rtn = 0; while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; - - if (sec->specialdata) continue; - - rtn = 1; floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); P_AddThinker (&floor->thinker); @@ -500,12 +393,7 @@ EV_BuildStairs floor->speed = speed; height = sec->floorheight + stairsize; floor->floordestheight = height; - texture = sec->floorpic; - - - - do { ok = 0; @@ -513,30 +401,21 @@ EV_BuildStairs { if ( !((sec->lines[i])->flags & ML_TWOSIDED) ) continue; - tsec = (sec->lines[i])->frontsector; newsecnum = tsec-sectors; - if (secnum != newsecnum) continue; - tsec = (sec->lines[i])->backsector; newsecnum = tsec - sectors; - if (tsec->floorpic != texture) continue; - height += stairsize; - if (tsec->specialdata) continue; - sec = tsec; secnum = newsecnum; floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); - P_AddThinker (&floor->thinker); - sec->specialdata = floor; floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor; floor->direction = 1; @@ -550,4 +429,3 @@ EV_BuildStairs } return rtn; } - diff --git a/src/p_inter.c b/src/p_inter.c @@ -1,73 +1,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "doomdef.h" #include "dstrings.h" #include "sounds.h" - #include "doomstat.h" - #include "m_random.h" #include "i_system.h" - #include "am_map.h" - #include "p_local.h" - #include "s_sound.h" - #ifdef __GNUG__ #pragma implementation "p_inter.h" #endif #include "p_inter.h" - - #define BONUSADD 6 - - - - - - int maxammo[NUMAMMO] = {200, 50, 300, 50}; int clipammo[NUMAMMO] = {10, 4, 20, 1}; - - - - - - - - - - - - - boolean P_GiveAmmo ( player_t* player, @@ -75,45 +21,27 @@ P_GiveAmmo int num ) { int oldammo; - if (ammo == am_noammo) return false; - if (ammo < 0 || ammo > NUMAMMO) I_Error ("P_GiveAmmo: bad type %i", ammo); - if ( player->ammo[ammo] == player->maxammo[ammo] ) return false; - if (num) num *= clipammo[ammo]; else num = clipammo[ammo]/2; - if (gameskill == sk_baby || gameskill == sk_nightmare) { - - num <<= 1; } - - oldammo = player->ammo[ammo]; player->ammo[ammo] += num; - if (player->ammo[ammo] > player->maxammo[ammo]) player->ammo[ammo] = player->maxammo[ammo]; - - - - if (oldammo) return true; - - - - switch (ammo) { case am_clip: @@ -125,7 +53,6 @@ P_GiveAmmo player->pendingweapon = wp_pistol; } break; - case am_shell: if (player->readyweapon == wp_fist || player->readyweapon == wp_pistol) @@ -134,7 +61,6 @@ P_GiveAmmo player->pendingweapon = wp_shotgun; } break; - case am_cell: if (player->readyweapon == wp_fist || player->readyweapon == wp_pistol) @@ -143,7 +69,6 @@ P_GiveAmmo player->pendingweapon = wp_plasma; } break; - case am_misl: if (player->readyweapon == wp_fist) { @@ -153,15 +78,8 @@ P_GiveAmmo default: break; } - return true; } - - - - - - boolean P_GiveWeapon ( player_t* player, @@ -170,33 +88,25 @@ P_GiveWeapon { boolean gaveammo; boolean gaveweapon; - if (netgame && (deathmatch!=2) && !dropped ) { - if (player->weaponowned[weapon]) return false; - player->bonuscount += BONUSADD; player->weaponowned[weapon] = true; - if (deathmatch) P_GiveAmmo (player, weaponinfo[weapon].ammo, 5); else P_GiveAmmo (player, weaponinfo[weapon].ammo, 2); player->pendingweapon = weapon; - if (player == &players[consoleplayer]) S_StartSound (NULL, sfx_wpnup); return false; } - if (weaponinfo[weapon].ammo != am_noammo) { - - if (dropped) gaveammo = P_GiveAmmo (player, weaponinfo[weapon].ammo, 1); else @@ -204,7 +114,6 @@ P_GiveWeapon } else gaveammo = false; - if (player->weaponowned[weapon]) gaveweapon = false; else @@ -213,16 +122,8 @@ P_GiveWeapon player->weaponowned[weapon] = true; player->pendingweapon = weapon; } - return (gaveweapon || gaveammo); } - - - - - - - boolean P_GiveBody ( player_t* player, @@ -230,44 +131,25 @@ P_GiveBody { if (player->health >= MAXHEALTH) return false; - player->health += num; if (player->health > MAXHEALTH) player->health = MAXHEALTH; player->mo->health = player->health; - return true; } - - - - - - - - boolean P_GiveArmor ( player_t* player, int armortype ) { int hits; - hits = armortype*100; if (player->armorpoints >= hits) return false; - player->armortype = armortype; player->armorpoints = hits; - return true; } - - - - - - void P_GiveCard ( player_t* player, @@ -275,15 +157,9 @@ P_GiveCard { if (player->cards[card]) return; - player->bonuscount = BONUSADD; player->cards[card] = 1; } - - - - - boolean P_GivePower ( player_t* player, @@ -294,45 +170,33 @@ P_GivePower player->powers[power] = INVULNTICS; return true; } - if (power == pw_invisibility) { player->powers[power] = INVISTICS; player->mo->flags |= MF_SHADOW; return true; } - if (power == pw_infrared) { player->powers[power] = INFRATICS; return true; } - if (power == pw_ironfeet) { player->powers[power] = IRONTICS; return true; } - if (power == pw_strength) { P_GiveBody (player, 100); player->powers[power] = 1; return true; } - if (player->powers[power]) return false; - player->powers[power] = 1; return true; } - - - - - - void P_TouchSpecialThing ( mobj_t* special, @@ -342,42 +206,28 @@ P_TouchSpecialThing int i; fixed_t delta; int sound; - delta = special->z - toucher->z; - if (delta > toucher->height || delta < -8*FRACUNIT) { - return; } - - sound = sfx_itemup; player = toucher->player; - - - if (toucher->health <= 0) return; - - switch (special->sprite) { - case SPR_ARM1: if (!P_GiveArmor (player, 1)) return; player->message = GOTARMOR; break; - case SPR_ARM2: if (!P_GiveArmor (player, 2)) return; player->message = GOTMEGA; break; - - case SPR_BON1: player->health++; if (player->health > 200) @@ -385,7 +235,6 @@ P_TouchSpecialThing player->mo->health = player->health; player->message = GOTHTHBONUS; break; - case SPR_BON2: player->armorpoints++; if (player->armorpoints > 200) @@ -394,7 +243,6 @@ P_TouchSpecialThing player->armortype = 1; player->message = GOTARMBONUS; break; - case SPR_SOUL: player->health += 100; if (player->health > 200) @@ -403,7 +251,6 @@ P_TouchSpecialThing player->message = GOTSUPER; sound = sfx_getpow; break; - case SPR_MEGA: if (gamemode != commercial) return; @@ -413,9 +260,6 @@ P_TouchSpecialThing player->message = GOTMSPHERE; sound = sfx_getpow; break; - - - case SPR_BKEY: if (!player->cards[it_bluecard]) player->message = GOTBLUECARD; @@ -423,7 +267,6 @@ P_TouchSpecialThing if (!netgame) break; return; - case SPR_YKEY: if (!player->cards[it_yellowcard]) player->message = GOTYELWCARD; @@ -431,7 +274,6 @@ P_TouchSpecialThing if (!netgame) break; return; - case SPR_RKEY: if (!player->cards[it_redcard]) player->message = GOTREDCARD; @@ -439,7 +281,6 @@ P_TouchSpecialThing if (!netgame) break; return; - case SPR_BSKU: if (!player->cards[it_blueskull]) player->message = GOTBLUESKUL; @@ -447,7 +288,6 @@ P_TouchSpecialThing if (!netgame) break; return; - case SPR_YSKU: if (!player->cards[it_yellowskull]) player->message = GOTYELWSKUL; @@ -455,7 +295,6 @@ P_TouchSpecialThing if (!netgame) break; return; - case SPR_RSKU: if (!player->cards[it_redskull]) player->message = GOTREDSKULL; @@ -463,33 +302,25 @@ P_TouchSpecialThing if (!netgame) break; return; - - case SPR_STIM: if (!P_GiveBody (player, 10)) return; player->message = GOTSTIM; break; - case SPR_MEDI: if (!P_GiveBody (player, 25)) return; - if (player->health < 25) player->message = GOTMEDINEED; else player->message = GOTMEDIKIT; break; - - - case SPR_PINV: if (!P_GivePower (player, pw_invulnerability)) return; player->message = GOTINVUL; sound = sfx_getpow; break; - case SPR_PSTR: if (!P_GivePower (player, pw_strength)) return; @@ -498,36 +329,30 @@ P_TouchSpecialThing player->pendingweapon = wp_fist; sound = sfx_getpow; break; - case SPR_PINS: if (!P_GivePower (player, pw_invisibility)) return; player->message = GOTINVIS; sound = sfx_getpow; break; - case SPR_SUIT: if (!P_GivePower (player, pw_ironfeet)) return; player->message = GOTSUIT; sound = sfx_getpow; break; - case SPR_PMAP: if (!P_GivePower (player, pw_allmap)) return; player->message = GOTMAP; sound = sfx_getpow; break; - case SPR_PVIS: if (!P_GivePower (player, pw_infrared)) return; player->message = GOTVISOR; sound = sfx_getpow; break; - - case SPR_CLIP: if (special->flags & MF_DROPPED) { @@ -541,49 +366,41 @@ P_TouchSpecialThing } player->message = GOTCLIP; break; - case SPR_AMMO: if (!P_GiveAmmo (player, am_clip,5)) return; player->message = GOTCLIPBOX; break; - case SPR_ROCK: if (!P_GiveAmmo (player, am_misl,1)) return; player->message = GOTROCKET; break; - case SPR_BROK: if (!P_GiveAmmo (player, am_misl,5)) return; player->message = GOTROCKBOX; break; - case SPR_CELL: if (!P_GiveAmmo (player, am_cell,1)) return; player->message = GOTCELL; break; - case SPR_CELP: if (!P_GiveAmmo (player, am_cell,5)) return; player->message = GOTCELLBOX; break; - case SPR_SHEL: if (!P_GiveAmmo (player, am_shell,1)) return; player->message = GOTSHELLS; break; - case SPR_SBOX: if (!P_GiveAmmo (player, am_shell,5)) return; player->message = GOTSHELLBOX; break; - case SPR_BPAK: if (!player->backpack) { @@ -595,61 +412,51 @@ P_TouchSpecialThing P_GiveAmmo (player, i, 1); player->message = GOTBACKPACK; break; - - case SPR_BFUG: if (!P_GiveWeapon (player, wp_bfg, false) ) return; player->message = GOTBFG9000; sound = sfx_wpnup; break; - case SPR_MGUN: if (!P_GiveWeapon (player, wp_chaingun, special->flags&MF_DROPPED) ) return; player->message = GOTCHAINGUN; sound = sfx_wpnup; break; - case SPR_CSAW: if (!P_GiveWeapon (player, wp_chainsaw, false) ) return; player->message = GOTCHAINSAW; sound = sfx_wpnup; break; - case SPR_LAUN: if (!P_GiveWeapon (player, wp_missile, false) ) return; player->message = GOTLAUNCHER; sound = sfx_wpnup; break; - case SPR_PLAS: if (!P_GiveWeapon (player, wp_plasma, false) ) return; player->message = GOTPLASMA; sound = sfx_wpnup; break; - case SPR_SHOT: if (!P_GiveWeapon (player, wp_shotgun, special->flags&MF_DROPPED ) ) return; player->message = GOTSHOTGUN; sound = sfx_wpnup; break; - case SPR_SGN2: if (!P_GiveWeapon (player, wp_supershotgun, special->flags&MF_DROPPED ) ) return; player->message = GOTSHOTGUN2; sound = sfx_wpnup; break; - default: I_Error ("P_SpecialThing: Unknown gettable thing"); } - if (special->flags & MF_COUNTITEM) player->itemcount++; P_RemoveMobj (special); @@ -657,11 +464,6 @@ P_TouchSpecialThing if (player == &players[consoleplayer]) S_StartSound (NULL, sound); } - - - - - void P_KillMobj ( mobj_t* source, @@ -669,51 +471,35 @@ P_KillMobj { mobjtype_t item; mobj_t* mo; - target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY); - if (target->type != MT_SKULL) target->flags &= ~MF_NOGRAVITY; - target->flags |= MF_CORPSE|MF_DROPOFF; target->height >>= 2; - if (source && source->player) { - if (target->flags & MF_COUNTKILL) source->player->killcount++; - if (target->player) source->player->frags[target->player-players]++; } else if (!netgame && (target->flags & MF_COUNTKILL) ) { - - players[0].killcount++; } - if (target->player) { - if (!source) target->player->frags[target->player-players]++; - target->flags &= ~MF_SOLID; target->player->playerstate = PST_DEAD; P_DropWeapon (target->player); - if (target->player == &players[consoleplayer] && automapactive) { - - AM_Stop (); } - } - if (target->health < -target->info->spawnhealth && target->info->xdeathstate) { @@ -722,53 +508,26 @@ P_KillMobj else P_SetMobjState (target, target->info->deathstate); target->tics -= P_Random()&3; - if (target->tics < 1) target->tics = 1; - - - - - - - switch (target->type) { case MT_WOLFSS: case MT_POSSESSED: item = MT_CLIP; break; - case MT_SHOTGUY: item = MT_SHOTGUN; break; - case MT_CHAINGUY: item = MT_CHAINGUN; break; - default: return; } - mo = P_SpawnMobj (target->x,target->y,ONFLOORZ, item); mo->flags |= MF_DROPPED; } - - - - - - - - - - - - - - - void P_DamageMobj ( mobj_t* target, @@ -781,26 +540,17 @@ P_DamageMobj player_t* player; fixed_t thrust; int temp; - if ( !(target->flags & MF_SHOOTABLE) ) return; - if (target->health <= 0) return; - if ( target->flags & MF_SKULLFLY ) { target->momx = target->momy = target->momz = 0; } - player = target->player; if (player && gameskill == sk_baby) damage >>= 1; - - - - - if (inflictor && !(target->flags & MF_NOCLIP) && (!source @@ -811,10 +561,7 @@ P_DamageMobj inflictor->y, target->x, target->y); - thrust = damage*(FRACUNIT>>3)*100/target->info->mass; - - if ( damage < 40 && damage > target->health && target->z - inflictor->z > 64*FRACUNIT @@ -823,42 +570,31 @@ P_DamageMobj ang += ANG180; thrust *= 4; } - ang >>= ANGLETOFINESHIFT; target->momx += FixedMul (thrust, finecosine[ang]); target->momy += FixedMul (thrust, finesine[ang]); } - - if (player) { - if (target->subsector->sector->special == 11 && damage >= target->health) { damage = target->health - 1; } - - - - if ( damage < 1000 && ( (player->cheats&CF_GODMODE) || player->powers[pw_invulnerability] ) ) { return; } - if (player->armortype) { if (player->armortype == 1) saved = damage/3; else saved = damage/2; - if (player->armorpoints <= saved) { - saved = player->armorpoints; player->armortype = 0; } @@ -868,49 +604,35 @@ P_DamageMobj player->health -= damage; if (player->health < 0) player->health = 0; - player->attacker = source; player->damagecount += damage; - if (player->damagecount > 100) player->damagecount = 100; - temp = damage < 100 ? damage : 100; - if (player == &players[consoleplayer]) I_Tactile (40,10,40+temp*2); } - - target->health -= damage; if (target->health <= 0) { P_KillMobj (source, target); return; } - if ( (P_Random () < target->info->painchance) && !(target->flags&MF_SKULLFLY) ) { target->flags |= MF_JUSTHIT; - P_SetMobjState (target, target->info->painstate); } - target->reactiontime = 0; - if ( (!target->threshold || target->type == MT_VILE) && source && source != target && source->type != MT_VILE) { - - target->target = source; target->threshold = BASETHRESHOLD; if (target->state == &states[target->info->spawnstate] && target->info->seestate != S_NULL) P_SetMobjState (target, target->info->seestate); } - } - diff --git a/src/p_inter.h b/src/p_inter.h @@ -1,41 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __P_INTER__ #define __P_INTER__ - - #ifdef __GNUG__ #pragma interface #endif - - boolean P_GivePower(player_t*, int); - - - #endif - - - - - diff --git a/src/p_lights.c b/src/p_lights.c @@ -1,103 +1,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #include "z_zone.h" #include "m_random.h" - #include "doomdef.h" #include "p_local.h" - - - #include "r_state.h" - - - - - - - - void T_FireFlicker (fireflicker_t* flick) { int amount; - if (--flick->count) return; - amount = (P_Random()&3)*16; - if (flick->sector->lightlevel - amount < flick->minlight) flick->sector->lightlevel = flick->minlight; else flick->sector->lightlevel = flick->maxlight - amount; - flick->count = 4; } - - - - - - void P_SpawnFireFlicker (sector_t* sector) { fireflicker_t* flick; - - - sector->special = 0; - flick = Z_Malloc ( sizeof(*flick), PU_LEVSPEC, 0); - P_AddThinker (&flick->thinker); - flick->thinker.function.acp1 = (actionf_p1) T_FireFlicker; flick->sector = sector; flick->maxlight = sector->lightlevel; flick->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel)+16; flick->count = 4; } - - - - - - - - - - - - void T_LightFlash (lightflash_t* flash) { if (--flash->count) return; - if (flash->sector->lightlevel == flash->maxlight) { flash-> sector->lightlevel = flash->minlight; @@ -108,53 +41,25 @@ void T_LightFlash (lightflash_t* flash) flash-> sector->lightlevel = flash->maxlight; flash->count = (P_Random()&flash->maxtime)+1; } - } - - - - - - - - - void P_SpawnLightFlash (sector_t* sector) { lightflash_t* flash; - - sector->special = 0; - flash = Z_Malloc ( sizeof(*flash), PU_LEVSPEC, 0); - P_AddThinker (&flash->thinker); - flash->thinker.function.acp1 = (actionf_p1) T_LightFlash; flash->sector = sector; flash->maxlight = sector->lightlevel; - flash->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel); flash->maxtime = 64; flash->mintime = 7; flash->count = (P_Random()&flash->maxtime)+1; } - - - - - - - - - - - void T_StrobeFlash (strobe_t* flash) { if (--flash->count) return; - if (flash->sector->lightlevel == flash->minlight) { flash-> sector->lightlevel = flash->maxlight; @@ -165,16 +70,7 @@ void T_StrobeFlash (strobe_t* flash) flash-> sector->lightlevel = flash->minlight; flash->count =flash->darktime; } - } - - - - - - - - void P_SpawnStrobeFlash ( sector_t* sector, @@ -182,55 +78,35 @@ P_SpawnStrobeFlash int inSync ) { strobe_t* flash; - flash = Z_Malloc ( sizeof(*flash), PU_LEVSPEC, 0); - P_AddThinker (&flash->thinker); - flash->sector = sector; flash->darktime = fastOrSlow; flash->brighttime = STROBEBRIGHT; flash->thinker.function.acp1 = (actionf_p1) T_StrobeFlash; flash->maxlight = sector->lightlevel; flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel); - if (flash->minlight == flash->maxlight) flash->minlight = 0; - - sector->special = 0; - if (!inSync) flash->count = (P_Random()&7)+1; else flash->count = 1; } - - - - - void EV_StartLightStrobing(line_t* line) { int secnum; sector_t* sec; - secnum = -1; while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; if (sec->specialdata) continue; - P_SpawnStrobeFlash (sec,SLOWDARK, 0); } } - - - - - - void EV_TurnTagLightsOff(line_t* line) { int i; @@ -239,9 +115,7 @@ void EV_TurnTagLightsOff(line_t* line) sector_t* sector; sector_t* tsec; line_t* templine; - sector = sectors; - for (j = 0;j < numsectors; j++, sector++) { if (sector->tag == line->tag) @@ -260,11 +134,6 @@ void EV_TurnTagLightsOff(line_t* line) } } } - - - - - void EV_LightTurnOn ( line_t* line, @@ -275,26 +144,19 @@ EV_LightTurnOn sector_t* sector; sector_t* temp; line_t* templine; - sector = sectors; - for (i=0;i<numsectors;i++, sector++) { if (sector->tag == line->tag) { - - - if (!bright) { for (j = 0;j < sector->linecount; j++) { templine = sector->lines[j]; temp = getNextSector(templine,sector); - if (!temp) continue; - if (temp->lightlevel > bright) bright = temp->lightlevel; } @@ -303,18 +165,11 @@ EV_LightTurnOn } } } - - - - - - void T_Glow(glow_t* g) { switch(g->direction) { case -1: - g->sector->lightlevel -= GLOWSPEED; if (g->sector->lightlevel <= g->minlight) { @@ -322,9 +177,7 @@ void T_Glow(glow_t* g) g->direction = 1; } break; - case 1: - g->sector->lightlevel += GLOWSPEED; if (g->sector->lightlevel >= g->maxlight) { @@ -334,22 +187,15 @@ void T_Glow(glow_t* g) break; } } - - void P_SpawnGlowingLight(sector_t* sector) { glow_t* g; - g = Z_Malloc( sizeof(*g), PU_LEVSPEC, 0); - P_AddThinker(&g->thinker); - g->sector = sector; g->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel); g->maxlight = sector->lightlevel; g->thinker.function.acp1 = (actionf_p1) T_Glow; g->direction = -1; - sector->special = 0; } - diff --git a/src/p_local.h b/src/p_local.h @@ -1,146 +1,61 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __P_LOCAL__ #define __P_LOCAL__ - #ifndef __R_LOCAL__ #include "r_local.h" #endif - #define FLOATSPEED (FRACUNIT*4) - - #define MAXHEALTH 100 #define VIEWHEIGHT (41*FRACUNIT) - - - #define MAPBLOCKUNITS 128 #define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT) #define MAPBLOCKSHIFT (FRACBITS+7) #define MAPBMASK (MAPBLOCKSIZE-1) #define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS) - - - #define PLAYERRADIUS 16*FRACUNIT - - - - #define MAXRADIUS 32*FRACUNIT - #define GRAVITY FRACUNIT #define MAXMOVE (30*FRACUNIT) - #define USERANGE (64*FRACUNIT) #define MELEERANGE (64*FRACUNIT) #define MISSILERANGE (32*64*FRACUNIT) - - #define BASETHRESHOLD 100 - - - - - - - - extern thinker_t thinkercap; - - void P_InitThinkers (void); void P_AddThinker (thinker_t* thinker); void P_RemoveThinker (thinker_t* thinker); - - - - - void P_SetupPsprites (player_t* curplayer); void P_MovePsprites (player_t* curplayer); void P_DropWeapon (player_t* player); - - - - - void P_PlayerThink (player_t* player); - - - - - #define ONFLOORZ MININT #define ONCEILINGZ MAXINT - - #define ITEMQUESIZE 128 - extern mapthing_t itemrespawnque[ITEMQUESIZE]; extern int itemrespawntime[ITEMQUESIZE]; extern int iquehead; extern int iquetail; - - void P_RespawnSpecials (void); - mobj_t* P_SpawnMobj ( fixed_t x, fixed_t y, fixed_t z, mobjtype_t type ); - void P_RemoveMobj (mobj_t* th); boolean P_SetMobjState (mobj_t* mobj, statenum_t state); void P_MobjThinker (mobj_t* mobj); - void P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z); void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage); mobj_t* P_SpawnMissile (mobj_t* source, mobj_t* dest, mobjtype_t type); void P_SpawnPlayerMissile (mobj_t* source, mobjtype_t type); - - - - - void P_NoiseAlert (mobj_t* target, mobj_t* emmiter); - - - - - typedef struct { fixed_t x; fixed_t y; fixed_t dx; fixed_t dy; - } divline_t; - typedef struct { fixed_t frac; @@ -150,37 +65,27 @@ typedef struct line_t* line; } d; } intercept_t; - #define MAXINTERCEPTS 128 - extern intercept_t intercepts[MAXINTERCEPTS]; extern intercept_t* intercept_p; - typedef boolean (*traverser_t) (intercept_t *in); - fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); int P_PointOnLineSide (fixed_t x, fixed_t y, line_t* line); int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t* line); void P_MakeDivline (line_t* li, divline_t* dl); fixed_t P_InterceptVector (divline_t* v2, divline_t* v1); int P_BoxOnLineSide (fixed_t* tmbox, line_t* ld); - extern fixed_t opentop; extern fixed_t openbottom; extern fixed_t openrange; extern fixed_t lowfloor; - void P_LineOpening (line_t* linedef); - boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t*) ); boolean P_BlockThingsIterator (int x, int y, boolean(*func)(mobj_t*) ); - #define PT_ADDLINES 1 #define PT_ADDTHINGS 2 #define PT_EARLYOUT 4 - extern divline_t trace; - boolean P_PathTraverse ( fixed_t x1, @@ -189,41 +94,25 @@ P_PathTraverse fixed_t y2, int flags, boolean (*trav) (intercept_t *)); - void P_UnsetThingPosition (mobj_t* thing); void P_SetThingPosition (mobj_t* thing); - - - - - - - - extern boolean floatok; extern fixed_t tmfloorz; extern fixed_t tmceilingz; - - extern line_t* ceilingline; - boolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y); boolean P_TryMove (mobj_t* thing, fixed_t x, fixed_t y); boolean P_TeleportMove (mobj_t* thing, fixed_t x, fixed_t y); void P_SlideMove (mobj_t* mo); boolean P_CheckSight (mobj_t* t1, mobj_t* t2); void P_UseLines (player_t* player); - boolean P_ChangeSector (sector_t* sector, boolean crunch); - extern mobj_t* linetarget; - fixed_t P_AimLineAttack ( mobj_t* t1, angle_t angle, fixed_t distance ); - void P_LineAttack ( mobj_t* t1, @@ -231,18 +120,11 @@ P_LineAttack fixed_t distance, fixed_t slope, int damage ); - void P_RadiusAttack ( mobj_t* spot, mobj_t* source, int damage ); - - - - - - extern byte* rejectmatrix; extern short* blockmaplump; extern short* blockmap; @@ -251,39 +133,17 @@ extern int bmapheight; extern fixed_t bmaporgx; extern fixed_t bmaporgy; extern mobj_t** blocklinks; - - - - - - extern int maxammo[NUMAMMO]; extern int clipammo[NUMAMMO]; - void P_TouchSpecialThing ( mobj_t* special, mobj_t* toucher ); - void P_DamageMobj ( mobj_t* target, mobj_t* inflictor, mobj_t* source, int damage ); - - - - - #include "p_spec.h" - - #endif - - - - - - - diff --git a/src/p_map.c b/src/p_map.c @@ -1,114 +1,44 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdlib.h> - #include "m_bbox.h" #include "m_random.h" #include "i_system.h" - #include "doomdef.h" #include "p_local.h" - #include "s_sound.h" - - #include "doomstat.h" #include "r_state.h" - #include "sounds.h" - - fixed_t tmbbox[4]; mobj_t* tmthing; int tmflags; fixed_t tmx; fixed_t tmy; - - - - boolean floatok; - fixed_t tmfloorz; fixed_t tmceilingz; fixed_t tmdropoffz; - - - line_t* ceilingline; - - - #define MAXSPECIALCROSS 8 - line_t* spechit[MAXSPECIALCROSS]; int numspechit; - - - - - - - - - - boolean PIT_StompThing (mobj_t* thing) { fixed_t blockdist; - if (!(thing->flags & MF_SHOOTABLE) ) return true; - blockdist = thing->radius + tmthing->radius; - if ( abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist ) { - return true; } - - if (thing == tmthing) return true; - - if ( !tmthing->player && gamemap != 30) return false; - P_DamageMobj (thing, tmthing, tmthing, 10000); - return true; } - - - - - boolean P_TeleportMove ( mobj_t* thing, @@ -121,69 +51,37 @@ P_TeleportMove int yh; int bx; int by; - subsector_t* newsubsec; - - tmthing = thing; tmflags = thing->flags; - tmx = x; tmy = y; - tmbbox[BOXTOP] = y + tmthing->radius; tmbbox[BOXBOTTOM] = y - tmthing->radius; tmbbox[BOXRIGHT] = x + tmthing->radius; tmbbox[BOXLEFT] = x - tmthing->radius; - newsubsec = R_PointInSubsector (x,y); ceilingline = NULL; - - - - - tmfloorz = tmdropoffz = newsubsec->sector->floorheight; tmceilingz = newsubsec->sector->ceilingheight; - validcount++; numspechit = 0; - - xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT; xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT; yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; - for (bx=xl ; bx<=xh ; bx++) for (by=yl ; by<=yh ; by++) if (!P_BlockThingsIterator(bx,by,PIT_StompThing)) return false; - - - P_UnsetThingPosition (thing); - thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; thing->x = x; thing->y = y; - P_SetThingPosition (thing); - return true; } - - - - - - - - - - - boolean PIT_CheckLine (line_t* ld) { if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] @@ -191,184 +89,95 @@ boolean PIT_CheckLine (line_t* ld) || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP] ) return true; - if (P_BoxOnLineSide (tmbbox, ld) != -1) return true; - - - - - - - - - - - - if (!ld->backsector) return false; - if (!(tmthing->flags & MF_MISSILE) ) { if ( ld->flags & ML_BLOCKING ) return false; - if ( !tmthing->player && ld->flags & ML_BLOCKMONSTERS ) return false; } - - P_LineOpening (ld); - - if (opentop < tmceilingz) { tmceilingz = opentop; ceilingline = ld; } - if (openbottom > tmfloorz) tmfloorz = openbottom; - if (lowfloor < tmdropoffz) tmdropoffz = lowfloor; - - if (ld->special) { spechit[numspechit] = ld; numspechit++; } - return true; } - - - - boolean PIT_CheckThing (mobj_t* thing) { fixed_t blockdist; boolean solid; int damage; - if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_SHOOTABLE) )) return true; - blockdist = thing->radius + tmthing->radius; - if ( abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist ) { - return true; } - - if (thing == tmthing) return true; - - if (tmthing->flags & MF_SKULLFLY) { damage = ((P_Random()%8)+1)*tmthing->info->damage; - P_DamageMobj (thing, tmthing, tmthing, damage); - tmthing->flags &= ~MF_SKULLFLY; tmthing->momx = tmthing->momy = tmthing->momz = 0; - P_SetMobjState (tmthing, tmthing->info->spawnstate); - return false; } - - - if (tmthing->flags & MF_MISSILE) { - if (tmthing->z > thing->z + thing->height) return true; if (tmthing->z+tmthing->height < thing->z) return true; - if (tmthing->target && ( tmthing->target->type == thing->type || (tmthing->target->type == MT_KNIGHT && thing->type == MT_BRUISER)|| (tmthing->target->type == MT_BRUISER && thing->type == MT_KNIGHT) ) ) { - if (thing == tmthing->target) return true; - if (thing->type != MT_PLAYER) { - - return false; } } - if (! (thing->flags & MF_SHOOTABLE) ) { - return !(thing->flags & MF_SOLID); } - - damage = ((P_Random()%8)+1)*tmthing->info->damage; P_DamageMobj (thing, tmthing, tmthing->target, damage); - - return false; } - - if (thing->flags & MF_SPECIAL) { solid = thing->flags&MF_SOLID; if (tmflags&MF_PICKUP) { - P_TouchSpecialThing (thing, tmthing); } return !solid; } - return !(thing->flags & MF_SOLID); } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - boolean P_CheckPosition ( mobj_t* thing, @@ -382,69 +191,40 @@ P_CheckPosition int bx; int by; subsector_t* newsubsec; - tmthing = thing; tmflags = thing->flags; - tmx = x; tmy = y; - tmbbox[BOXTOP] = y + tmthing->radius; tmbbox[BOXBOTTOM] = y - tmthing->radius; tmbbox[BOXRIGHT] = x + tmthing->radius; tmbbox[BOXLEFT] = x - tmthing->radius; - newsubsec = R_PointInSubsector (x,y); ceilingline = NULL; - - - - - tmfloorz = tmdropoffz = newsubsec->sector->floorheight; tmceilingz = newsubsec->sector->ceilingheight; - validcount++; numspechit = 0; - if ( tmflags & MF_NOCLIP ) return true; - - - - - - xl = (tmbbox[BOXLEFT] - bmaporgx - MAXRADIUS)>>MAPBLOCKSHIFT; xh = (tmbbox[BOXRIGHT] - bmaporgx + MAXRADIUS)>>MAPBLOCKSHIFT; yl = (tmbbox[BOXBOTTOM] - bmaporgy - MAXRADIUS)>>MAPBLOCKSHIFT; yh = (tmbbox[BOXTOP] - bmaporgy + MAXRADIUS)>>MAPBLOCKSHIFT; - for (bx=xl ; bx<=xh ; bx++) for (by=yl ; by<=yh ; by++) if (!P_BlockThingsIterator(bx,by,PIT_CheckThing)) return false; - - xl = (tmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; xh = (tmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; yl = (tmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; yh = (tmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; - for (bx=xl ; bx<=xh ; bx++) for (by=yl ; by<=yh ; by++) if (!P_BlockLinesIterator (bx,by,PIT_CheckLine)) return false; - return true; } - - - - - - - boolean P_TryMove ( mobj_t* thing, @@ -456,50 +236,36 @@ P_TryMove int side; int oldside; line_t* ld; - floatok = false; if (!P_CheckPosition (thing, x, y)) return false; - if ( !(thing->flags & MF_NOCLIP) ) { if (tmceilingz - tmfloorz < thing->height) return false; - floatok = true; - if ( !(thing->flags&MF_TELEPORT) &&tmceilingz - thing->z < thing->height) return false; - if ( !(thing->flags&MF_TELEPORT) && tmfloorz - thing->z > 24*FRACUNIT ) return false; - if ( !(thing->flags&(MF_DROPOFF|MF_FLOAT)) && tmfloorz - tmdropoffz > 24*FRACUNIT ) return false; } - - - P_UnsetThingPosition (thing); - oldx = thing->x; oldy = thing->y; thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; thing->x = x; thing->y = y; - P_SetThingPosition (thing); - - if (! (thing->flags&(MF_TELEPORT|MF_NOCLIP)) ) { while (numspechit--) { - ld = spechit[numspechit]; side = P_PointOnLineSide (thing->x, thing->y, ld); oldside = P_PointOnLineSide (oldx, oldy, ld); @@ -510,163 +276,90 @@ P_TryMove } } } - return true; } - - - - - - - - - - - - boolean P_ThingHeightClip (mobj_t* thing) { boolean onfloor; - onfloor = (thing->z == thing->floorz); - P_CheckPosition (thing, thing->x, thing->y); - - thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; - if (onfloor) { - thing->z = thing->floorz; } else { - if (thing->z+thing->height > thing->ceilingz) thing->z = thing->ceilingz - thing->height; } - if (thing->ceilingz - thing->floorz < thing->height) return false; - return true; } - - - - - - - fixed_t bestslidefrac; fixed_t secondslidefrac; - line_t* bestslideline; line_t* secondslideline; - mobj_t* slidemo; - fixed_t tmxmove; fixed_t tmymove; - - - - - - - - void P_HitSlideLine (line_t* ld) { int side; - angle_t lineangle; angle_t moveangle; angle_t deltaangle; - fixed_t movelen; fixed_t newlen; - - if (ld->slopetype == ST_HORIZONTAL) { tmymove = 0; return; } - if (ld->slopetype == ST_VERTICAL) { tmxmove = 0; return; } - side = P_PointOnLineSide (slidemo->x, slidemo->y, ld); - lineangle = R_PointToAngle2 (0,0, ld->dx, ld->dy); - if (side == 1) lineangle += ANG180; - moveangle = R_PointToAngle2 (0,0, tmxmove, tmymove); deltaangle = moveangle-lineangle; - if (deltaangle > ANG180) deltaangle += ANG180; - - lineangle >>= ANGLETOFINESHIFT; deltaangle >>= ANGLETOFINESHIFT; - movelen = P_AproxDistance (tmxmove, tmymove); newlen = FixedMul (movelen, finecosine[deltaangle]); - tmxmove = FixedMul (newlen, finecosine[lineangle]); tmymove = FixedMul (newlen, finesine[lineangle]); } - - - - - boolean PTR_SlideTraverse (intercept_t* in) { line_t* li; - if (!in->isaline) I_Error ("PTR_SlideTraverse: not a line?"); - li = in->d.line; - if ( ! (li->flags & ML_TWOSIDED) ) { if (P_PointOnLineSide (slidemo->x, slidemo->y, li)) { - return true; } goto isblocking; } - - P_LineOpening (li); - if (openrange < slidemo->height) goto isblocking; - if (opentop - slidemo->z < slidemo->height) goto isblocking; - if (openbottom - slidemo->z > 24*FRACUNIT ) goto isblocking; - - return true; - - - isblocking: if (in->frac < bestslidefrac) { @@ -675,21 +368,8 @@ boolean PTR_SlideTraverse (intercept_t* in) bestslidefrac = in->frac; bestslideline = li; } - return false; } - - - - - - - - - - - - void P_SlideMove (mobj_t* mo) { fixed_t leadx; @@ -699,16 +379,11 @@ void P_SlideMove (mobj_t* mo) fixed_t newx; fixed_t newy; int hitcount; - slidemo = mo; hitcount = 0; - retry: if (++hitcount == 3) goto stairstep; - - - if (mo->momx > 0) { leadx = mo->x + mo->radius; @@ -719,7 +394,6 @@ void P_SlideMove (mobj_t* mo) leadx = mo->x - mo->radius; trailx = mo->x + mo->radius; } - if (mo->momy > 0) { leady = mo->y + mo->radius; @@ -730,86 +404,51 @@ void P_SlideMove (mobj_t* mo) leady = mo->y - mo->radius; traily = mo->y + mo->radius; } - bestslidefrac = FRACUNIT+1; - P_PathTraverse ( leadx, leady, leadx+mo->momx, leady+mo->momy, PT_ADDLINES, PTR_SlideTraverse ); P_PathTraverse ( trailx, leady, trailx+mo->momx, leady+mo->momy, PT_ADDLINES, PTR_SlideTraverse ); P_PathTraverse ( leadx, traily, leadx+mo->momx, traily+mo->momy, PT_ADDLINES, PTR_SlideTraverse ); - - if (bestslidefrac == FRACUNIT+1) { - stairstep: if (!P_TryMove (mo, mo->x, mo->y + mo->momy)) P_TryMove (mo, mo->x + mo->momx, mo->y); return; } - - bestslidefrac -= 0x800; if (bestslidefrac > 0) { newx = FixedMul (mo->momx, bestslidefrac); newy = FixedMul (mo->momy, bestslidefrac); - if (!P_TryMove (mo, mo->x+newx, mo->y+newy)) goto stairstep; } - - - bestslidefrac = FRACUNIT-(bestslidefrac+0x800); - if (bestslidefrac > FRACUNIT) bestslidefrac = FRACUNIT; - if (bestslidefrac <= 0) return; - tmxmove = FixedMul (mo->momx, bestslidefrac); tmymove = FixedMul (mo->momy, bestslidefrac); - P_HitSlideLine (bestslideline); - mo->momx = tmxmove; mo->momy = tmymove; - if (!P_TryMove (mo, mo->x+tmxmove, mo->y+tmymove)) { goto retry; } } - - - - - mobj_t* linetarget; mobj_t* shootthing; - - - fixed_t shootz; - int la_damage; fixed_t attackrange; - fixed_t aimslope; - - extern fixed_t topslope; extern fixed_t bottomslope; - - - - - - boolean PTR_AimTraverse (intercept_t* in) { @@ -819,204 +458,124 @@ PTR_AimTraverse (intercept_t* in) fixed_t thingtopslope; fixed_t thingbottomslope; fixed_t dist; - if (in->isaline) { li = in->d.line; - if ( !(li->flags & ML_TWOSIDED) ) return false; - - - - P_LineOpening (li); - if (openbottom >= opentop) return false; - dist = FixedMul (attackrange, in->frac); - if (li->frontsector->floorheight != li->backsector->floorheight) { slope = FixedDiv (openbottom - shootz , dist); if (slope > bottomslope) bottomslope = slope; } - if (li->frontsector->ceilingheight != li->backsector->ceilingheight) { slope = FixedDiv (opentop - shootz , dist); if (slope < topslope) topslope = slope; } - if (topslope <= bottomslope) return false; - return true; } - - th = in->d.thing; if (th == shootthing) return true; - if (!(th->flags&MF_SHOOTABLE)) return true; - - dist = FixedMul (attackrange, in->frac); thingtopslope = FixedDiv (th->z+th->height - shootz , dist); - if (thingtopslope < bottomslope) return true; - thingbottomslope = FixedDiv (th->z - shootz, dist); - if (thingbottomslope > topslope) return true; - - if (thingtopslope > topslope) thingtopslope = topslope; - if (thingbottomslope < bottomslope) thingbottomslope = bottomslope; - aimslope = (thingtopslope+thingbottomslope)/2; linetarget = th; - return false; } - - - - - boolean PTR_ShootTraverse (intercept_t* in) { fixed_t x; fixed_t y; fixed_t z; fixed_t frac; - line_t* li; - mobj_t* th; - fixed_t slope; fixed_t dist; fixed_t thingtopslope; fixed_t thingbottomslope; - if (in->isaline) { li = in->d.line; - if (li->special) P_ShootSpecialLine (shootthing, li); - if ( !(li->flags & ML_TWOSIDED) ) goto hitline; - - P_LineOpening (li); - dist = FixedMul (attackrange, in->frac); - if (li->frontsector->floorheight != li->backsector->floorheight) { slope = FixedDiv (openbottom - shootz , dist); if (slope > aimslope) goto hitline; } - if (li->frontsector->ceilingheight != li->backsector->ceilingheight) { slope = FixedDiv (opentop - shootz , dist); if (slope < aimslope) goto hitline; } - - return true; - - - hitline: - frac = in->frac - FixedDiv (4*FRACUNIT,attackrange); x = trace.x + FixedMul (trace.dx, frac); y = trace.y + FixedMul (trace.dy, frac); z = shootz + FixedMul (aimslope, FixedMul(frac, attackrange)); - if (li->frontsector->ceilingpic == skyflatnum) { - if (z > li->frontsector->ceilingheight) return false; - - if (li->backsector && li->backsector->ceilingpic == skyflatnum) return false; } - - P_SpawnPuff (x,y,z); - - return false; } - - th = in->d.thing; if (th == shootthing) return true; - if (!(th->flags&MF_SHOOTABLE)) return true; - - dist = FixedMul (attackrange, in->frac); thingtopslope = FixedDiv (th->z+th->height - shootz , dist); - if (thingtopslope < aimslope) return true; - thingbottomslope = FixedDiv (th->z - shootz, dist); - if (thingbottomslope > aimslope) return true; - - - - frac = in->frac - FixedDiv (10*FRACUNIT,attackrange); - x = trace.x + FixedMul (trace.dx, frac); y = trace.y + FixedMul (trace.dy, frac); z = shootz + FixedMul (aimslope, FixedMul(frac, attackrange)); - - - if (in->d.thing->flags & MF_NOBLOOD) P_SpawnPuff (x,y,z); else P_SpawnBlood (x,y,z, la_damage); - if (la_damage) P_DamageMobj (th, shootthing, shootthing, la_damage); - - return false; - } - - - - - fixed_t P_AimLineAttack ( mobj_t* t1, @@ -1025,38 +584,23 @@ P_AimLineAttack { fixed_t x2; fixed_t y2; - angle >>= ANGLETOFINESHIFT; shootthing = t1; - x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; y2 = t1->y + (distance>>FRACBITS)*finesine[angle]; shootz = t1->z + (t1->height>>1) + 8*FRACUNIT; - - topslope = 100*FRACUNIT/160; bottomslope = -100*FRACUNIT/160; - attackrange = distance; linetarget = NULL; - P_PathTraverse ( t1->x, t1->y, x2, y2, PT_ADDLINES|PT_ADDTHINGS, PTR_AimTraverse ); - if (linetarget) return aimslope; - return 0; } - - - - - - - void P_LineAttack ( mobj_t* t1, @@ -1067,7 +611,6 @@ P_LineAttack { fixed_t x2; fixed_t y2; - angle >>= ANGLETOFINESHIFT; shootthing = t1; la_damage = damage; @@ -1076,55 +619,31 @@ P_LineAttack shootz = t1->z + (t1->height>>1) + 8*FRACUNIT; attackrange = distance; aimslope = slope; - P_PathTraverse ( t1->x, t1->y, x2, y2, PT_ADDLINES|PT_ADDTHINGS, PTR_ShootTraverse ); } - - - - - - mobj_t* usething; - boolean PTR_UseTraverse (intercept_t* in) { int side; - if (!in->d.line->special) { P_LineOpening (in->d.line); if (openrange <= 0) { S_StartSound (usething, sfx_noway); - - return false; } - return true ; } - side = 0; if (P_PointOnLineSide (usething->x, usething->y, in->d.line) == 1) side = 1; - - - P_UseSpecialLine (usething, in->d.line, side); - - return false; } - - - - - - void P_UseLines (player_t* player) { int angle; @@ -1132,74 +651,41 @@ void P_UseLines (player_t* player) fixed_t y1; fixed_t x2; fixed_t y2; - usething = player->mo; - angle = player->mo->angle >> ANGLETOFINESHIFT; - x1 = player->mo->x; y1 = player->mo->y; x2 = x1 + (USERANGE>>FRACBITS)*finecosine[angle]; y2 = y1 + (USERANGE>>FRACBITS)*finesine[angle]; - P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse ); } - - - - - mobj_t* bombsource; mobj_t* bombspot; int bombdamage; - - - - - - - boolean PIT_RadiusAttack (mobj_t* thing) { fixed_t dx; fixed_t dy; fixed_t dist; - if (!(thing->flags & MF_SHOOTABLE) ) return true; - - - if (thing->type == MT_CYBORG || thing->type == MT_SPIDER) return true; - dx = abs(thing->x - bombspot->x); dy = abs(thing->y - bombspot->y); - dist = dx>dy ? dx : dy; dist = (dist - thing->radius) >> FRACBITS; - if (dist < 0) dist = 0; - if (dist >= bombdamage) return true; - if ( P_CheckSight (thing, bombspot) ) { - P_DamageMobj (thing, bombspot, bombsource, bombdamage - dist); } - return true; } - - - - - - void P_RadiusAttack ( mobj_t* spot, @@ -1208,14 +694,11 @@ P_RadiusAttack { int x; int y; - int xl; int xh; int yl; int yh; - fixed_t dist; - dist = (damage+MAXRADIUS)<<FRACBITS; yh = (spot->y + dist - bmaporgy)>>MAPBLOCKSHIFT; yl = (spot->y - dist - bmaporgy)>>MAPBLOCKSHIFT; @@ -1224,97 +707,48 @@ P_RadiusAttack bombspot = spot; bombsource = source; bombdamage = damage; - for (y=yl ; y<=yh ; y++) for (x=xl ; x<=xh ; x++) P_BlockThingsIterator (x, y, PIT_RadiusAttack ); } - - - - - - - - - - - - - - - - boolean crushchange; boolean nofit; - - - - - boolean PIT_ChangeSector (mobj_t* thing) { mobj_t* mo; - if (P_ThingHeightClip (thing)) { - return true; } - - - if (thing->health <= 0) { P_SetMobjState (thing, S_GIBS); - thing->flags &= ~MF_SOLID; thing->height = 0; thing->radius = 0; - - return true; } - - if (thing->flags & MF_DROPPED) { P_RemoveMobj (thing); - - return true; } - if (! (thing->flags & MF_SHOOTABLE) ) { - return true; } - nofit = true; - if (crushchange && !(leveltime&3) ) { P_DamageMobj(thing,NULL,NULL,10); - - mo = P_SpawnMobj (thing->x, thing->y, thing->z + thing->height/2, MT_BLOOD); - mo->momx = (P_Random() - P_Random ())<<12; mo->momy = (P_Random() - P_Random ())<<12; } - - return true; } - - - - - - boolean P_ChangeSector ( sector_t* sector, @@ -1322,16 +756,10 @@ P_ChangeSector { int x; int y; - nofit = false; crushchange = crunch; - - for (x=sector->blockbox[BOXLEFT] ; x<= sector->blockbox[BOXRIGHT] ; x++) for (y=sector->blockbox[BOXBOTTOM];y<= sector->blockbox[BOXTOP] ; y++) P_BlockThingsIterator (x, y, PIT_ChangeSector); - - return nofit; } - diff --git a/src/p_maputl.c b/src/p_maputl.c @@ -1,48 +1,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdlib.h> - - #include "m_bbox.h" - #include "doomdef.h" #include "p_local.h" - - - #include "r_state.h" - - - - - - fixed_t P_AproxDistance ( fixed_t dx, @@ -54,12 +14,6 @@ P_AproxDistance return dx+dy-(dx>>1); return dx+dy-(dy>>1); } - - - - - - int P_PointOnLineSide ( fixed_t x, @@ -70,40 +24,26 @@ P_PointOnLineSide fixed_t dy; fixed_t left; fixed_t right; - if (!line->dx) { if (x <= line->v1->x) return line->dy > 0; - return line->dy < 0; } if (!line->dy) { if (y <= line->v1->y) return line->dx < 0; - return line->dx > 0; } - dx = (x - line->v1->x); dy = (y - line->v1->y); - left = FixedMul ( line->dy>>FRACBITS , dx ); right = FixedMul ( dy , line->dx>>FRACBITS ); - if (right < left) return 0; return 1; } - - - - - - - - int P_BoxOnLineSide ( fixed_t* tmbox, @@ -111,7 +51,6 @@ P_BoxOnLineSide { int p1; int p2; - switch (ld->slopetype) { case ST_HORIZONTAL: @@ -123,7 +62,6 @@ P_BoxOnLineSide p2 ^= 1; } break; - case ST_VERTICAL: p1 = tmbox[BOXRIGHT] < ld->v1->x; p2 = tmbox[BOXLEFT] < ld->v1->x; @@ -133,28 +71,19 @@ P_BoxOnLineSide p2 ^= 1; } break; - case ST_POSITIVE: p1 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXTOP], ld); p2 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXBOTTOM], ld); break; - case ST_NEGATIVE: p1 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXTOP], ld); p2 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXBOTTOM], ld); break; } - if (p1 == p2) return p1; return -1; } - - - - - - int P_PointOnDivlineSide ( fixed_t x, @@ -165,46 +94,32 @@ P_PointOnDivlineSide fixed_t dy; fixed_t left; fixed_t right; - if (!line->dx) { if (x <= line->x) return line->dy > 0; - return line->dy < 0; } if (!line->dy) { if (y <= line->y) return line->dx < 0; - return line->dx > 0; } - dx = (x - line->x); dy = (y - line->y); - - if ( (line->dy ^ line->dx ^ dx ^ dy)&0x80000000 ) { if ( (line->dy ^ dx) & 0x80000000 ) return 1; return 0; } - left = FixedMul ( line->dy>>8, dx>>8 ); right = FixedMul ( dy>>8 , line->dx>>8 ); - if (right < left) return 0; return 1; } - - - - - - void P_MakeDivline ( line_t* li, @@ -215,16 +130,6 @@ P_MakeDivline dl->dx = li->dx; dl->dy = li->dy; } - - - - - - - - - - fixed_t P_InterceptVector ( divline_t* v2, @@ -234,19 +139,13 @@ P_InterceptVector fixed_t frac; fixed_t num; fixed_t den; - den = FixedMul (v1->dy>>8,v2->dx) - FixedMul(v1->dx>>8,v2->dy); - if (den == 0) return 0; - - num = FixedMul ( (v1->x - v2->x)>>8 ,v1->dy ) +FixedMul ( (v2->y - v1->y)>>8, v1->dx ); - frac = FixedDiv (num , den); - return frac; #else float frac; @@ -260,7 +159,6 @@ P_InterceptVector float v2y; float v2dx; float v2dy; - v1x = (float)v1->x/FRACUNIT; v1y = (float)v1->y/FRACUNIT; v1dx = (float)v1->dx/FRACUNIT; @@ -269,52 +167,33 @@ P_InterceptVector v2y = (float)v2->y/FRACUNIT; v2dx = (float)v2->dx/FRACUNIT; v2dy = (float)v2->dy/FRACUNIT; - den = v1dy*v2dx - v1dx*v2dy; - if (den == 0) return 0; - num = (v1x - v2x)*v1dy + (v2y - v1y)*v1dx; frac = num / den; - return frac*FRACUNIT; #endif } - - - - - - - - fixed_t opentop; fixed_t openbottom; fixed_t openrange; fixed_t lowfloor; - - void P_LineOpening (line_t* linedef) { sector_t* front; sector_t* back; - if (linedef->sidenum[1] == -1) { - openrange = 0; return; } - front = linedef->frontsector; back = linedef->backsector; - if (front->ceilingheight < back->ceilingheight) opentop = front->ceilingheight; else opentop = back->ceilingheight; - if (front->floorheight > back->floorheight) { openbottom = front->floorheight; @@ -325,55 +204,31 @@ void P_LineOpening (line_t* linedef) openbottom = back->floorheight; lowfloor = front->floorheight; } - openrange = opentop - openbottom; } - - - - - - - - - - - - - - void P_UnsetThingPosition (mobj_t* thing) { int blockx; int blocky; - if ( ! (thing->flags & MF_NOSECTOR) ) { - - if (thing->snext) thing->snext->sprev = thing->sprev; - if (thing->sprev) thing->sprev->snext = thing->snext; else thing->subsector->sector->thinglist = thing->snext; } - if ( ! (thing->flags & MF_NOBLOCKMAP) ) { - - if (thing->bnext) thing->bnext->bprev = thing->bprev; - if (thing->bprev) thing->bprev->bnext = thing->bnext; else { blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT; blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT; - if (blockx>=0 && blockx < bmapwidth && blocky>=0 && blocky <bmapheight) { @@ -382,14 +237,6 @@ void P_UnsetThingPosition (mobj_t* thing) } } } - - - - - - - - void P_SetThingPosition (mobj_t* thing) { @@ -398,34 +245,21 @@ P_SetThingPosition (mobj_t* thing) int blockx; int blocky; mobj_t** link; - - - ss = R_PointInSubsector (thing->x,thing->y); thing->subsector = ss; - if ( ! (thing->flags & MF_NOSECTOR) ) { - sec = ss->sector; - thing->sprev = NULL; thing->snext = sec->thinglist; - if (sec->thinglist) sec->thinglist->sprev = thing; - sec->thinglist = thing; } - - - if ( ! (thing->flags & MF_NOBLOCKMAP) ) { - blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT; blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT; - if (blockx>=0 && blockx < bmapwidth && blocky>=0 @@ -436,36 +270,14 @@ P_SetThingPosition (mobj_t* thing) thing->bnext = *link; if (*link) (*link)->bprev = thing; - *link = thing; } else { - thing->bnext = thing->bprev = NULL; } } } - - - - - - - - - - - - - - - - - - - - boolean P_BlockLinesIterator ( int x, @@ -475,7 +287,6 @@ P_BlockLinesIterator int offset; short* list; line_t* ld; - if (x<0 || y<0 || x>=bmapwidth @@ -483,30 +294,19 @@ P_BlockLinesIterator { return true; } - offset = y*bmapwidth+x; - offset = *(blockmap+offset); - for ( list = blockmaplump+offset ; *list != -1 ; list++) { ld = &lines[*list]; - if (ld->validcount == validcount) continue; - ld->validcount = validcount; - if ( !func(ld) ) return false; } return true; } - - - - - boolean P_BlockThingsIterator ( int x, @@ -514,7 +314,6 @@ P_BlockThingsIterator boolean(*func)(mobj_t*) ) { mobj_t* mobj; - if ( x<0 || y<0 || x>=bmapwidth @@ -522,8 +321,6 @@ P_BlockThingsIterator { return true; } - - for (mobj = blocklinks[y*bmapwidth+x] ; mobj ; mobj = mobj->bnext) @@ -533,29 +330,11 @@ P_BlockThingsIterator } return true; } - - - - - - intercept_t intercepts[MAXINTERCEPTS]; intercept_t* intercept_p; - divline_t trace; boolean earlyout; int ptflags; - - - - - - - - - - - boolean PIT_AddLineIntercepts (line_t* ld) { @@ -563,8 +342,6 @@ PIT_AddLineIntercepts (line_t* ld) int s2; fixed_t frac; divline_t dl; - - if ( trace.dx > FRACUNIT*16 || trace.dy > FRACUNIT*16 || trace.dx < -FRACUNIT*16 @@ -578,63 +355,40 @@ PIT_AddLineIntercepts (line_t* ld) s1 = P_PointOnLineSide (trace.x, trace.y, ld); s2 = P_PointOnLineSide (trace.x+trace.dx, trace.y+trace.dy, ld); } - if (s1 == s2) return true; - - P_MakeDivline (ld, &dl); frac = P_InterceptVector (&trace, &dl); - if (frac < 0) return true; - - if (earlyout && frac < FRACUNIT && !ld->backsector) { return false; } - - intercept_p->frac = frac; intercept_p->isaline = true; intercept_p->d.line = ld; intercept_p++; - return true; } - - - - - - boolean PIT_AddThingIntercepts (mobj_t* thing) { fixed_t x1; fixed_t y1; fixed_t x2; fixed_t y2; - int s1; int s2; - boolean tracepositive; - divline_t dl; - fixed_t frac; - tracepositive = (trace.dx ^ trace.dy)>0; - - if (tracepositive) { x1 = thing->x - thing->radius; y1 = thing->y + thing->radius; - x2 = thing->x + thing->radius; y2 = thing->y - thing->radius; } @@ -642,41 +396,26 @@ boolean PIT_AddThingIntercepts (mobj_t* thing) { x1 = thing->x - thing->radius; y1 = thing->y - thing->radius; - x2 = thing->x + thing->radius; y2 = thing->y + thing->radius; } - s1 = P_PointOnDivlineSide (x1, y1, &trace); s2 = P_PointOnDivlineSide (x2, y2, &trace); - if (s1 == s2) return true; - dl.x = x1; dl.y = y1; dl.dx = x2-x1; dl.dy = y2-y1; - frac = P_InterceptVector (&trace, &dl); - if (frac < 0) return true; - intercept_p->frac = frac; intercept_p->isaline = false; intercept_p->d.thing = thing; intercept_p++; - return true; } - - - - - - - boolean P_TraverseIntercepts ( traverser_t func, @@ -686,11 +425,8 @@ P_TraverseIntercepts fixed_t dist; intercept_t* scan; intercept_t* in; - count = intercept_p - intercepts; - in = 0; - while (count--) { dist = MAXINT; @@ -702,13 +438,10 @@ P_TraverseIntercepts in = scan; } } - if (dist > maxfrac) return true; - #if 0 { - in = scan = intercepts; for ( scan = intercepts ; scan<intercept_p ; scan++) if (scan->frac > maxfrac) @@ -717,26 +450,12 @@ P_TraverseIntercepts return false; } #endif - if ( !func (in) ) return false; - in->frac = MAXINT; } - return true; } - - - - - - - - - - - boolean P_PathTraverse ( fixed_t x1, @@ -750,49 +469,35 @@ P_PathTraverse fixed_t yt1; fixed_t xt2; fixed_t yt2; - fixed_t xstep; fixed_t ystep; - fixed_t partial; - fixed_t xintercept; fixed_t yintercept; - int mapx; int mapy; - int mapxstep; int mapystep; - int count; - earlyout = flags & PT_EARLYOUT; - validcount++; intercept_p = intercepts; - if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0) x1 += FRACUNIT; - if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0) y1 += FRACUNIT; - trace.x = x1; trace.y = y1; trace.dx = x2 - x1; trace.dy = y2 - y1; - x1 -= bmaporgx; y1 -= bmaporgy; xt1 = x1>>MAPBLOCKSHIFT; yt1 = y1>>MAPBLOCKSHIFT; - x2 -= bmaporgx; y2 -= bmaporgy; xt2 = x2>>MAPBLOCKSHIFT; yt2 = y2>>MAPBLOCKSHIFT; - if (xt2 > xt1) { mapxstep = 1; @@ -811,10 +516,7 @@ P_PathTraverse partial = FRACUNIT; ystep = 256*FRACUNIT; } - yintercept = (y1>>MAPBTOFRAC) + FixedMul (partial, ystep); - - if (yt2 > yt1) { mapystep = 1; @@ -834,13 +536,8 @@ P_PathTraverse xstep = 256*FRACUNIT; } xintercept = (x1>>MAPBTOFRAC) + FixedMul (partial, xstep); - - - - mapx = xt1; mapy = yt1; - for (count = 0 ; count < 64 ; count++) { if (flags & PT_ADDLINES) @@ -848,19 +545,16 @@ P_PathTraverse if (!P_BlockLinesIterator (mapx, mapy,PIT_AddLineIntercepts)) return false; } - if (flags & PT_ADDTHINGS) { if (!P_BlockThingsIterator (mapx, mapy,PIT_AddThingIntercepts)) return false; } - if (mapx == xt2 && mapy == yt2) { break; } - if ( (yintercept >> FRACBITS) == mapy) { yintercept += ystep; @@ -871,11 +565,6 @@ P_PathTraverse xintercept += xstep; mapy += mapystep; } - } - return P_TraverseIntercepts ( trav, FRACUNIT ); } - - - diff --git a/src/p_mobj.c b/src/p_mobj.c @@ -1,60 +1,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include "i_system.h" #include "z_zone.h" #include "m_random.h" - #include "doomdef.h" #include "p_local.h" #include "sounds.h" - #include "st_stuff.h" #include "hu_stuff.h" - #include "s_sound.h" - #include "doomstat.h" - - void G_PlayerReborn (int player); void P_SpawnMapThing (mapthing_t* mthing); - - - - - - int test; - boolean P_SetMobjState ( mobj_t* mobj, statenum_t state ) { state_t* st; - do { if (state == S_NULL) @@ -63,52 +25,30 @@ P_SetMobjState P_RemoveMobj (mobj); return false; } - st = &states[state]; mobj->state = st; mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - - - if (st->action.acp1) st->action.acp1(mobj); - state = st->nextstate; } while (!mobj->tics); - return true; } - - - - - void P_ExplodeMissile (mobj_t* mo) { mo->momx = mo->momy = mo->momz = 0; - P_SetMobjState (mo, mobjinfo[mo->type].deathstate); - mo->tics -= P_Random()&3; - if (mo->tics < 1) mo->tics = 1; - mo->flags &= ~MF_MISSILE; - if (mo->info->deathsound) S_StartSound (mo, mo->info->deathsound); } - - - - - #define STOPSPEED 0x1000 #define FRICTION 0xe800 - void P_XYMovement (mobj_t* mo) { fixed_t ptryx; @@ -116,35 +56,27 @@ void P_XYMovement (mobj_t* mo) player_t* player; fixed_t xmove; fixed_t ymove; - if (!mo->momx && !mo->momy) { if (mo->flags & MF_SKULLFLY) { - mo->flags &= ~MF_SKULLFLY; mo->momx = mo->momy = mo->momz = 0; - P_SetMobjState (mo, mo->info->spawnstate); } return; } - player = mo->player; - if (mo->momx > MAXMOVE) mo->momx = MAXMOVE; else if (mo->momx < -MAXMOVE) mo->momx = -MAXMOVE; - if (mo->momy > MAXMOVE) mo->momy = MAXMOVE; else if (mo->momy < -MAXMOVE) mo->momy = -MAXMOVE; - xmove = mo->momx; ymove = mo->momy; - do { if (xmove > MAXMOVE/2 || ymove > MAXMOVE/2) @@ -160,24 +92,18 @@ void P_XYMovement (mobj_t* mo) ptryy = mo->y + ymove; xmove = ymove = 0; } - if (!P_TryMove (mo, ptryx, ptryy)) { - if (mo->player) { P_SlideMove (mo); } else if (mo->flags & MF_MISSILE) { - if (ceilingline && ceilingline->backsector && ceilingline->backsector->ceilingpic == skyflatnum) { - - - P_RemoveMobj (mo); return; } @@ -187,25 +113,17 @@ void P_XYMovement (mobj_t* mo) mo->momx = mo->momy = 0; } } while (xmove || ymove); - - if (player && player->cheats & CF_NOMOMENTUM) { - mo->momx = mo->momy = 0; return; } - if (mo->flags & (MF_MISSILE | MF_SKULLFLY) ) return; - if (mo->z > mo->floorz) return; - if (mo->flags & MF_CORPSE) { - - if (mo->momx > FRACUNIT/4 || mo->momx < -FRACUNIT/4 || mo->momy > FRACUNIT/4 @@ -215,7 +133,6 @@ void P_XYMovement (mobj_t* mo) return; } } - if (mo->momx > -STOPSPEED && mo->momx < STOPSPEED && mo->momy > -STOPSPEED @@ -224,10 +141,8 @@ void P_XYMovement (mobj_t* mo) || (player->cmd.forwardmove== 0 && player->cmd.sidemove == 0 ) ) ) { - if ( player&&(unsigned)((player->mo->state - states)- S_PLAY_RUN1) < 4) P_SetMobjState (player->mo, S_PLAY); - mo->momx = 0; mo->momy = 0; } @@ -237,77 +152,49 @@ void P_XYMovement (mobj_t* mo) mo->momy = FixedMul (mo->momy, FRICTION); } } - - - - void P_ZMovement (mobj_t* mo) { fixed_t dist; fixed_t delta; - - if (mo->player && mo->z < mo->floorz) { mo->player->viewheight -= mo->floorz-mo->z; - mo->player->deltaviewheight = (VIEWHEIGHT - mo->player->viewheight)>>3; } - - mo->z += mo->momz; - if ( mo->flags & MF_FLOAT && mo->target) { - if ( !(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT) ) { dist = P_AproxDistance (mo->x - mo->target->x, mo->y - mo->target->y); - delta =(mo->target->z + (mo->height>>1)) - mo->z; - if (delta<0 && dist < -(delta*3) ) mo->z -= FLOATSPEED; else if (delta>0 && dist < (delta*3) ) mo->z += FLOATSPEED; } - } - - if (mo->z <= mo->floorz) { - - - - - if (mo->flags & MF_SKULLFLY) { - mo->momz = -mo->momz; } - if (mo->momz < 0) { if (mo->player && mo->momz < -GRAVITY*8) { - - - - mo->player->deltaviewheight = mo->momz>>3; S_StartSound (mo, sfx_oof); } mo->momz = 0; } mo->z = mo->floorz; - if ( (mo->flags & MF_MISSILE) && !(mo->flags & MF_NOCLIP) ) { @@ -322,21 +209,17 @@ void P_ZMovement (mobj_t* mo) else mo->momz -= GRAVITY; } - if (mo->z + mo->height > mo->ceilingz) { - if (mo->momz > 0) mo->momz = 0; { mo->z = mo->ceilingz - mo->height; } - if (mo->flags & MF_SKULLFLY) { mo->momz = -mo->momz; } - if ( (mo->flags & MF_MISSILE) && !(mo->flags & MF_NOCLIP) ) { @@ -345,12 +228,6 @@ void P_ZMovement (mobj_t* mo) } } } - - - - - - void P_NightmareRespawn (mobj_t* mobj) { @@ -360,66 +237,37 @@ P_NightmareRespawn (mobj_t* mobj) subsector_t* ss; mobj_t* mo; mapthing_t* mthing; - x = mobj->spawnpoint.x << FRACBITS; y = mobj->spawnpoint.y << FRACBITS; - - if (!P_CheckPosition (mobj, x, y) ) return; - - - mo = P_SpawnMobj (mobj->x, mobj->y, mobj->subsector->sector->floorheight , MT_TFOG); - S_StartSound (mo, sfx_telept); - - ss = R_PointInSubsector (x,y); - mo = P_SpawnMobj (x, y, ss->sector->floorheight , MT_TFOG); - S_StartSound (mo, sfx_telept); - - mthing = &mobj->spawnpoint; - - if (mobj->info->flags & MF_SPAWNCEILING) z = ONCEILINGZ; else z = ONFLOORZ; - - mo = P_SpawnMobj (x,y,z, mobj->type); mo->spawnpoint = mobj->spawnpoint; mo->angle = ANG45 * (mthing->angle/45); - if (mthing->options & MTF_AMBUSH) mo->flags |= MF_AMBUSH; - mo->reactiontime = 18; - - P_RemoveMobj (mobj); } - - - - - void P_MobjThinker (mobj_t* mobj) { - if (mobj->momx || mobj->momy || (mobj->flags&MF_SKULLFLY) ) { P_XYMovement (mobj); - - if (mobj->thinker.function.acv == (actionf_v) (-1)) return; } @@ -427,53 +275,32 @@ void P_MobjThinker (mobj_t* mobj) || mobj->momz ) { P_ZMovement (mobj); - - if (mobj->thinker.function.acv == (actionf_v) (-1)) return; } - - - - if (mobj->tics != -1) { mobj->tics--; - - if (!mobj->tics) if (!P_SetMobjState (mobj, mobj->state->nextstate) ) return; } else { - if (! (mobj->flags & MF_COUNTKILL) ) return; - if (!respawnmonsters) return; - mobj->movecount++; - if (mobj->movecount < 12*35) return; - if ( leveltime&31 ) return; - if (P_Random () > 4) return; - P_NightmareRespawn (mobj); } - } - - - - - mobj_t* P_SpawnMobj ( fixed_t x, @@ -484,11 +311,9 @@ P_SpawnMobj mobj_t* mobj; state_t* st; mobjinfo_t* info; - mobj = Z_Malloc (sizeof(*mobj), PU_LEVEL, NULL); memset (mobj, 0, sizeof (*mobj)); info = &mobjinfo[type]; - mobj->type = type; mobj->info = info; mobj->x = x; @@ -497,50 +322,31 @@ P_SpawnMobj mobj->height = info->height; mobj->flags = info->flags; mobj->health = info->spawnhealth; - if (gameskill != sk_nightmare) mobj->reactiontime = info->reactiontime; - mobj->lastlook = P_Random () % MAXPLAYERS; - - st = &states[info->spawnstate]; - mobj->state = st; mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - - P_SetThingPosition (mobj); - mobj->floorz = mobj->subsector->sector->floorheight; mobj->ceilingz = mobj->subsector->sector->ceilingheight; - if (z == ONFLOORZ) mobj->z = mobj->floorz; else if (z == ONCEILINGZ) mobj->z = mobj->ceilingz - mobj->info->height; else mobj->z = z; - mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; - P_AddThinker (&mobj->thinker); - return mobj; } - - - - - mapthing_t itemrespawnque[ITEMQUESIZE]; int itemrespawntime[ITEMQUESIZE]; int iquehead; int iquetail; - - void P_RemoveMobj (mobj_t* mobj) { if ((mobj->flags & MF_SPECIAL) @@ -551,125 +357,70 @@ void P_RemoveMobj (mobj_t* mobj) itemrespawnque[iquehead] = mobj->spawnpoint; itemrespawntime[iquehead] = leveltime; iquehead = (iquehead+1)&(ITEMQUESIZE-1); - - if (iquehead == iquetail) iquetail = (iquetail+1)&(ITEMQUESIZE-1); } - - P_UnsetThingPosition (mobj); - - S_StopSound (mobj); - - P_RemoveThinker ((thinker_t*)mobj); } - - - - - - - void P_RespawnSpecials (void) { fixed_t x; fixed_t y; fixed_t z; - subsector_t* ss; mobj_t* mo; mapthing_t* mthing; - int i; - - if (deathmatch != 2) return; - - if (iquehead == iquetail) return; - - if (leveltime - itemrespawntime[iquetail] < 30*35) return; - mthing = &itemrespawnque[iquetail]; - x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; - - ss = R_PointInSubsector (x,y); mo = P_SpawnMobj (x, y, ss->sector->floorheight , MT_IFOG); S_StartSound (mo, sfx_itmbk); - - for (i=0 ; i< NUMMOBJTYPES ; i++) { if (mthing->type == mobjinfo[i].doomednum) break; } - - if (mobjinfo[i].flags & MF_SPAWNCEILING) z = ONCEILINGZ; else z = ONFLOORZ; - mo = P_SpawnMobj (x,y,z, i); mo->spawnpoint = *mthing; mo->angle = ANG45 * (mthing->angle/45); - - iquetail = (iquetail+1)&(ITEMQUESIZE-1); } - - - - - - - - - - void P_SpawnPlayer (mapthing_t* mthing) { player_t* p; fixed_t x; fixed_t y; fixed_t z; - mobj_t* mobj; - int i; - - if (!playeringame[mthing->type-1]) return; - p = &players[mthing->type-1]; - if (p->playerstate == PST_REBORN) G_PlayerReborn (mthing->type-1); - x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; z = ONFLOORZ; mobj = P_SpawnMobj (x,y,z, MT_PLAYER); - - if (mthing->type > 1) mobj->flags |= (mthing->type-1)<<MF_TRANSSHIFT; - mobj->angle = ANG45 * (mthing->angle/45); mobj->player = p; mobj->health = p->health; - p->mo = mobj; p->playerstate = PST_LIVE; p->refire = 0; @@ -679,30 +430,16 @@ void P_SpawnPlayer (mapthing_t* mthing) p->extralight = 0; p->fixedcolormap = 0; p->viewheight = VIEWHEIGHT; - - P_SetupPsprites (p); - - if (deathmatch) for (i=0 ; i<NUMCARDS ; i++) p->cards[i] = true; - if (mthing->type-1 == consoleplayer) { - ST_Start (); - HU_Start (); } } - - - - - - - void P_SpawnMapThing (mapthing_t* mthing) { int i; @@ -711,8 +448,6 @@ void P_SpawnMapThing (mapthing_t* mthing) fixed_t x; fixed_t y; fixed_t z; - - if (mthing->type == 11) { if (deathmatch_p < &deathmatchstarts[10]) @@ -722,90 +457,57 @@ void P_SpawnMapThing (mapthing_t* mthing) } return; } - - if (mthing->type <= 4) { - playerstarts[mthing->type-1] = *mthing; if (!deathmatch) P_SpawnPlayer (mthing); - return; } - - if (!netgame && (mthing->options & 16) ) return; - if (gameskill == sk_baby) bit = 1; else if (gameskill == sk_nightmare) bit = 4; else bit = 1<<(gameskill-1); - if (!(mthing->options & bit) ) return; - - for (i=0 ; i< NUMMOBJTYPES ; i++) if (mthing->type == mobjinfo[i].doomednum) break; - if (i==NUMMOBJTYPES) I_Error ("P_SpawnMapThing: Unknown type %i at (%i, %i)", mthing->type, mthing->x, mthing->y); - - if (deathmatch && mobjinfo[i].flags & MF_NOTDMATCH) return; - - if (nomonsters && ( i == MT_SKULL || (mobjinfo[i].flags & MF_COUNTKILL)) ) { return; } - - x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; - if (mobjinfo[i].flags & MF_SPAWNCEILING) z = ONCEILINGZ; else z = ONFLOORZ; - mobj = P_SpawnMobj (x,y,z, i); mobj->spawnpoint = *mthing; - if (mobj->tics > 0) mobj->tics = 1 + (P_Random () % mobj->tics); if (mobj->flags & MF_COUNTKILL) totalkills++; if (mobj->flags & MF_COUNTITEM) totalitems++; - mobj->angle = ANG45 * (mthing->angle/45); if (mthing->options & MTF_AMBUSH) mobj->flags |= MF_AMBUSH; } - - - - - - - - - - - extern fixed_t attackrange; - void P_SpawnPuff ( fixed_t x, @@ -813,26 +515,15 @@ P_SpawnPuff fixed_t z ) { mobj_t* th; - z += ((P_Random()-P_Random())<<10); - th = P_SpawnMobj (x,y,z, MT_PUFF); th->momz = FRACUNIT; th->tics -= P_Random()&3; - if (th->tics < 1) th->tics = 1; - - if (attackrange == MELEERANGE) P_SetMobjState (th, S_PUFF3); } - - - - - - void P_SpawnBlood ( fixed_t x, @@ -841,48 +532,28 @@ P_SpawnBlood int damage ) { mobj_t* th; - z += ((P_Random()-P_Random())<<10); th = P_SpawnMobj (x,y,z, MT_BLOOD); th->momz = FRACUNIT*2; th->tics -= P_Random()&3; - if (th->tics < 1) th->tics = 1; - if (damage <= 12 && damage >= 9) P_SetMobjState (th,S_BLOOD2); else if (damage < 9) P_SetMobjState (th,S_BLOOD3); } - - - - - - - - void P_CheckMissileSpawn (mobj_t* th) { th->tics -= P_Random()&3; if (th->tics < 1) th->tics = 1; - - - th->x += (th->momx>>1); th->y += (th->momy>>1); th->z += (th->momz>>1); - if (!P_TryMove (th, th->x, th->y)) P_ExplodeMissile (th); } - - - - - mobj_t* P_SpawnMissile ( mobj_t* source, @@ -892,43 +563,27 @@ P_SpawnMissile mobj_t* th; angle_t an; int dist; - th = P_SpawnMobj (source->x, source->y, source->z + 4*8*FRACUNIT, type); - if (th->info->seesound) S_StartSound (th, th->info->seesound); - th->target = source; an = R_PointToAngle2 (source->x, source->y, dest->x, dest->y); - - if (dest->flags & MF_SHADOW) an += (P_Random()-P_Random())<<20; - th->angle = an; an >>= ANGLETOFINESHIFT; th->momx = FixedMul (th->info->speed, finecosine[an]); th->momy = FixedMul (th->info->speed, finesine[an]); - dist = P_AproxDistance (dest->x - source->x, dest->y - source->y); dist = dist / th->info->speed; - if (dist < 1) dist = 1; - th->momz = (dest->z - source->z) / dist; P_CheckMissileSpawn (th); - return th; } - - - - - - void P_SpawnPlayerMissile ( mobj_t* source, @@ -936,43 +591,33 @@ P_SpawnPlayerMissile { mobj_t* th; angle_t an; - fixed_t x; fixed_t y; fixed_t z; fixed_t slope; - - an = source->angle; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); - if (!linetarget) { an += 1<<26; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); - if (!linetarget) { an -= 2<<26; slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); } - if (!linetarget) { an = source->angle; slope = 0; } } - x = source->x; y = source->y; z = source->z + 4*8*FRACUNIT; - th = P_SpawnMobj (x,y,z, type); - if (th->info->seesound) S_StartSound (th, th->info->seesound); - th->target = source; th->angle = an; th->momx = FixedMul( th->info->speed, @@ -980,7 +625,5 @@ P_SpawnPlayerMissile th->momy = FixedMul( th->info->speed, finesine[an>>ANGLETOFINESHIFT]); th->momz = FixedMul( th->info->speed, slope); - P_CheckMissileSpawn (th); } - diff --git a/src/p_mobj.h b/src/p_mobj.h @@ -1,295 +1,80 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __P_MOBJ__ #define __P_MOBJ__ - - #include "tables.h" #include "m_fixed.h" - - #include "d_think.h" - - - #include "doomdata.h" - - - - #include "info.h" - - - #ifdef __GNUG__ #pragma interface #endif - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - typedef enum { - MF_SPECIAL = 1, - MF_SOLID = 2, - MF_SHOOTABLE = 4, - MF_NOSECTOR = 8, - MF_NOBLOCKMAP = 16, - - MF_AMBUSH = 32, - MF_JUSTHIT = 64, - MF_JUSTATTACKED = 128, - - MF_SPAWNCEILING = 256, - - - MF_NOGRAVITY = 512, - - - MF_DROPOFF = 0x400, - MF_PICKUP = 0x800, - MF_NOCLIP = 0x1000, - MF_SLIDE = 0x2000, - - MF_FLOAT = 0x4000, - - MF_TELEPORT = 0x8000, - - MF_MISSILE = 0x10000, - - MF_DROPPED = 0x20000, - - MF_SHADOW = 0x40000, - - MF_NOBLOOD = 0x80000, - - MF_CORPSE = 0x100000, - - MF_INFLOAT = 0x200000, - - - - MF_COUNTKILL = 0x400000, - - - MF_COUNTITEM = 0x800000, - - - MF_SKULLFLY = 0x1000000, - - - MF_NOTDMATCH = 0x2000000, - - - - - MF_TRANSLATION = 0xc000000, - MF_TRANSSHIFT = 26 - } mobjflag_t; - - - typedef struct mobj_s { - thinker_t thinker; - - fixed_t x; fixed_t y; fixed_t z; - - struct mobj_s* snext; struct mobj_s* sprev; - - angle_t angle; spritenum_t sprite; int frame; - - - struct mobj_s* bnext; struct mobj_s* bprev; - struct subsector_s* subsector; - - fixed_t floorz; fixed_t ceilingz; - - fixed_t radius; fixed_t height; - - fixed_t momx; fixed_t momy; fixed_t momz; - - int validcount; - mobjtype_t type; mobjinfo_t* info; - int tics; state_t* state; int flags; int health; - - int movedir; int movecount; - - - struct mobj_s* target; - - - int reactiontime; - - - int threshold; - - - struct player_s* player; - - int lastlook; - - mapthing_t spawnpoint; - - struct mobj_s* tracer; - } mobj_t; - - - #endif - - - - - diff --git a/src/p_plats.c b/src/p_plats.c @@ -1,56 +1,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include "i_system.h" #include "z_zone.h" #include "m_random.h" - #include "doomdef.h" #include "p_local.h" - #include "s_sound.h" - - #include "doomstat.h" #include "r_state.h" - - #include "sounds.h" - - plat_t* activeplats[MAXPLATS]; - - - - - - void T_PlatRaise(plat_t* plat) { result_e res; - switch(plat->status) { case up: @@ -58,7 +18,6 @@ void T_PlatRaise(plat_t* plat) plat->speed, plat->high, plat->crush,0,1); - if (plat->type == raiseAndChange || plat->type == raiseToNearestAndChange) { @@ -66,8 +25,6 @@ void T_PlatRaise(plat_t* plat) S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_stnmov); } - - if (res == crushed && (!plat->crush)) { plat->count = plat->wait; @@ -83,29 +40,24 @@ void T_PlatRaise(plat_t* plat) plat->status = waiting; S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_pstop); - switch(plat->type) { case blazeDWUS: case downWaitUpStay: P_RemoveActivePlat(plat); break; - case raiseAndChange: case raiseToNearestAndChange: P_RemoveActivePlat(plat); break; - default: break; } } } break; - case down: res = T_MovePlane(plat->sector,plat->speed,plat->low,false,0,-1); - if (res == pastdest) { plat->count = plat->wait; @@ -113,7 +65,6 @@ void T_PlatRaise(plat_t* plat) S_StartSound((mobj_t *)&plat->sector->soundorg,sfx_pstop); } break; - case waiting: if (!--plat->count) { @@ -127,12 +78,6 @@ void T_PlatRaise(plat_t* plat) break; } } - - - - - - int EV_DoPlat ( line_t* line, @@ -143,41 +88,30 @@ EV_DoPlat int secnum; int rtn; sector_t* sec; - secnum = -1; rtn = 0; - - - switch(type) { case perpetualRaise: P_ActivateInStasis(line->tag); break; - default: break; } - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { sec = &sectors[secnum]; - if (sec->specialdata) continue; - - rtn = 1; plat = Z_Malloc( sizeof(*plat), PU_LEVSPEC, 0); P_AddThinker(&plat->thinker); - plat->type = type; plat->sector = sec; plat->sector->specialdata = plat; plat->thinker.function.acp1 = (actionf_p1) T_PlatRaise; plat->crush = false; plat->tag = line->tag; - switch(type) { case raiseToNearestAndChange: @@ -186,63 +120,47 @@ EV_DoPlat plat->high = P_FindNextHighestFloor(sec,sec->floorheight); plat->wait = 0; plat->status = up; - sec->special = 0; - S_StartSound((mobj_t *)&sec->soundorg,sfx_stnmov); break; - case raiseAndChange: plat->speed = PLATSPEED/2; sec->floorpic = sides[line->sidenum[0]].sector->floorpic; plat->high = sec->floorheight + amount*FRACUNIT; plat->wait = 0; plat->status = up; - S_StartSound((mobj_t *)&sec->soundorg,sfx_stnmov); break; - case downWaitUpStay: plat->speed = PLATSPEED * 4; plat->low = P_FindLowestFloorSurrounding(sec); - if (plat->low > sec->floorheight) plat->low = sec->floorheight; - plat->high = sec->floorheight; plat->wait = 35*PLATWAIT; plat->status = down; S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); break; - case blazeDWUS: plat->speed = PLATSPEED * 8; plat->low = P_FindLowestFloorSurrounding(sec); - if (plat->low > sec->floorheight) plat->low = sec->floorheight; - plat->high = sec->floorheight; plat->wait = 35*PLATWAIT; plat->status = down; S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); break; - case perpetualRaise: plat->speed = PLATSPEED; plat->low = P_FindLowestFloorSurrounding(sec); - if (plat->low > sec->floorheight) plat->low = sec->floorheight; - plat->high = P_FindHighestFloorSurrounding(sec); - if (plat->high < sec->floorheight) plat->high = sec->floorheight; - plat->wait = 35*PLATWAIT; plat->status = P_Random()&1; - S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart); break; } @@ -250,13 +168,9 @@ EV_DoPlat } return rtn; } - - - void P_ActivateInStasis(int tag) { int i; - for (i = 0;i < MAXPLATS;i++) if (activeplats[i] && (activeplats[i])->tag == tag @@ -267,11 +181,9 @@ void P_ActivateInStasis(int tag) = (actionf_p1) T_PlatRaise; } } - void EV_StopPlat(line_t* line) { int j; - for (j = 0;j < MAXPLATS;j++) if (activeplats[j] && ((activeplats[j])->status != in_stasis) @@ -282,11 +194,9 @@ void EV_StopPlat(line_t* line) (activeplats[j])->thinker.function.acv = (actionf_v)NULL; } } - void P_AddActivePlat(plat_t* plat) { int i; - for (i = 0;i < MAXPLATS;i++) if (activeplats[i] == NULL) { @@ -295,7 +205,6 @@ void P_AddActivePlat(plat_t* plat) } I_Error ("P_AddActivePlat: no more plats!"); } - void P_RemoveActivePlat(plat_t* plat) { int i; @@ -305,7 +214,6 @@ void P_RemoveActivePlat(plat_t* plat) (activeplats[i])->sector->specialdata = NULL; P_RemoveThinker(&(activeplats[i])->thinker); activeplats[i] = NULL; - return; } I_Error ("P_RemoveActivePlat: can't find plat!"); diff --git a/src/p_pspr.c b/src/p_pspr.c @@ -1,58 +1,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include "doomdef.h" #include "d_event.h" - - #include "m_random.h" #include "p_local.h" #include "s_sound.h" - - #include "doomstat.h" - - #include "sounds.h" - #include "p_pspr.h" - #define LOWERSPEED FRACUNIT*6 #define RAISESPEED FRACUNIT*6 - #define WEAPONBOTTOM 128*FRACUNIT #define WEAPONTOP 32*FRACUNIT - - - #define BFGCELLS 40 - - - - - void P_SetPsprite ( player_t* player, @@ -61,123 +19,68 @@ P_SetPsprite { pspdef_t* psp; state_t* state; - psp = &player->psprites[position]; - do { if (!stnum) { - psp->state = NULL; break; } - state = &states[stnum]; psp->state = state; psp->tics = state->tics; - if (state->misc1) { - psp->sx = state->misc1 << FRACBITS; psp->sy = state->misc2 << FRACBITS; } - - - if (state->action.acp2) { state->action.acp2(player, psp); if (!psp->state) break; } - stnum = psp->state->nextstate; - } while (!psp->tics); - } - - - - - - fixed_t swingx; fixed_t swingy; - void P_CalcSwing (player_t* player) { fixed_t swing; int angle; - - - - - swing = player->bob; - angle = (FINEANGLES/70*leveltime)&FINEMASK; swingx = FixedMul ( swing, finesine[angle]); - angle = (FINEANGLES/70*leveltime+FINEANGLES/2)&FINEMASK; swingy = -FixedMul ( swingx, finesine[angle]); } - - - - - - - - - void P_BringUpWeapon (player_t* player) { statenum_t newstate; - if (player->pendingweapon == wp_nochange) player->pendingweapon = player->readyweapon; - if (player->pendingweapon == wp_chainsaw) S_StartSound (player->mo, sfx_sawup); - newstate = weaponinfo[player->pendingweapon].upstate; - player->pendingweapon = wp_nochange; player->psprites[ps_weapon].sy = WEAPONBOTTOM; - P_SetPsprite (player, ps_weapon, newstate); } - - - - - - boolean P_CheckAmmo (player_t* player) { ammotype_t ammo; int count; - ammo = weaponinfo[player->readyweapon].ammo; - - if (player->readyweapon == wp_bfg) count = BFGCELLS; else if (player->readyweapon == wp_supershotgun) count = 2; else count = 1; - - - if (ammo == am_noammo || player->ammo[ammo] >= count) return true; - - - do { if (player->weaponowned[wp_plasma] @@ -223,59 +126,30 @@ boolean P_CheckAmmo (player_t* player) } else { - player->pendingweapon = wp_fist; } - } while (player->pendingweapon == wp_nochange); - - P_SetPsprite (player, ps_weapon, weaponinfo[player->readyweapon].downstate); - return false; } - - - - - void P_FireWeapon (player_t* player) { statenum_t newstate; - if (!P_CheckAmmo (player)) return; - P_SetMobjState (player->mo, S_PLAY_ATK1); newstate = weaponinfo[player->readyweapon].atkstate; P_SetPsprite (player, ps_weapon, newstate); P_NoiseAlert (player->mo, player->mo); } - - - - - - - void P_DropWeapon (player_t* player) { P_SetPsprite (player, ps_weapon, weaponinfo[player->readyweapon].downstate); } - - - - - - - - - - void A_WeaponReady ( player_t* player, @@ -283,33 +157,22 @@ A_WeaponReady { statenum_t newstate; int angle; - - if (player->mo->state == &states[S_PLAY_ATK1] || player->mo->state == &states[S_PLAY_ATK2] ) { P_SetMobjState (player->mo, S_PLAY); } - if (player->readyweapon == wp_chainsaw && psp->state == &states[S_SAW]) { S_StartSound (player->mo, sfx_sawidl); } - - - if (player->pendingweapon != wp_nochange || !player->health) { - - newstate = weaponinfo[player->readyweapon].downstate; P_SetPsprite (player, ps_weapon, newstate); return; } - - - if (player->cmd.buttons & BT_ATTACK) { if ( !player->attackdown @@ -323,28 +186,15 @@ A_WeaponReady } else player->attackdown = false; - - angle = (128*leveltime)&FINEMASK; psp->sx = FRACUNIT + FixedMul (player->bob, finecosine[angle]); angle &= FINEANGLES/2-1; psp->sy = WEAPONTOP + FixedMul (player->bob, finesine[angle]); } - - - - - - - - void A_ReFire ( player_t* player, pspdef_t* psp ) { - - - if ( (player->cmd.buttons & BT_ATTACK) && player->pendingweapon == wp_nochange && player->health) @@ -358,8 +208,6 @@ void A_ReFire P_CheckAmmo (player); } } - - void A_CheckReload ( player_t* player, @@ -371,78 +219,40 @@ A_CheckReload P_SetPsprite (player, ps_weapon, S_DSNR1); #endif } - - - - - - - - void A_Lower ( player_t* player, pspdef_t* psp ) { psp->sy += LOWERSPEED; - - if (psp->sy < WEAPONBOTTOM ) return; - - if (player->playerstate == PST_DEAD) { psp->sy = WEAPONBOTTOM; - - return; } - - - if (!player->health) { - P_SetPsprite (player, ps_weapon, S_NULL); return; } - player->readyweapon = player->pendingweapon; - P_BringUpWeapon (player); } - - - - - void A_Raise ( player_t* player, pspdef_t* psp ) { statenum_t newstate; - psp->sy -= RAISESPEED; - if (psp->sy > WEAPONTOP ) return; - psp->sy = WEAPONTOP; - - - newstate = weaponinfo[player->readyweapon].readystate; - P_SetPsprite (player, ps_weapon, newstate); } - - - - - - void A_GunFlash ( player_t* player, @@ -451,17 +261,6 @@ A_GunFlash P_SetMobjState (player->mo, S_PLAY_ATK2); P_SetPsprite (player,ps_flash,weaponinfo[player->readyweapon].flashstate); } - - - - - - - - - - - void A_Punch ( player_t* player, @@ -470,18 +269,13 @@ A_Punch angle_t angle; int damage; int slope; - damage = (P_Random ()%10+1)<<1; - if (player->powers[pw_strength]) damage *= 10; - angle = player->mo->angle; angle += (P_Random()-P_Random())<<18; slope = P_AimLineAttack (player->mo, angle, MELEERANGE); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage); - - if (linetarget) { S_StartSound (player->mo, sfx_punch); @@ -491,11 +285,6 @@ A_Punch linetarget->y); } } - - - - - void A_Saw ( player_t* player, @@ -504,23 +293,17 @@ A_Saw angle_t angle; int damage; int slope; - damage = 2*(P_Random ()%10+1); angle = player->mo->angle; angle += (P_Random()-P_Random())<<18; - - slope = P_AimLineAttack (player->mo, angle, MELEERANGE+1); P_LineAttack (player->mo, angle, MELEERANGE+1, slope, damage); - if (!linetarget) { S_StartSound (player->mo, sfx_sawful); return; } S_StartSound (player->mo, sfx_sawhit); - - angle = R_PointToAngle2 (player->mo->x, player->mo->y, linetarget->x, linetarget->y); if (angle - player->mo->angle > ANG180) @@ -539,12 +322,6 @@ A_Saw } player->mo->flags |= MF_JUSTATTACKED; } - - - - - - void A_FireMissile ( player_t* player, @@ -553,11 +330,6 @@ A_FireMissile player->ammo[weaponinfo[player->readyweapon].ammo]--; P_SpawnPlayerMissile (player->mo, MT_ROCKET); } - - - - - void A_FireBFG ( player_t* player, @@ -566,44 +338,23 @@ A_FireBFG player->ammo[weaponinfo[player->readyweapon].ammo] -= BFGCELLS; P_SpawnPlayerMissile (player->mo, MT_BFG); } - - - - - - void A_FirePlasma ( player_t* player, pspdef_t* psp ) { player->ammo[weaponinfo[player->readyweapon].ammo]--; - P_SetPsprite (player, ps_flash, weaponinfo[player->readyweapon].flashstate+(P_Random ()&1) ); - P_SpawnPlayerMissile (player->mo, MT_PLASMA); } - - - - - - - - fixed_t bulletslope; - - void P_BulletSlope (mobj_t* mo) { angle_t an; - - an = mo->angle; bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT); - if (!linetarget) { an += 1<<26; @@ -615,11 +366,6 @@ void P_BulletSlope (mobj_t* mo) } } } - - - - - void P_GunShot ( mobj_t* mo, @@ -627,69 +373,42 @@ P_GunShot { angle_t angle; int damage; - damage = 5*(P_Random ()%3+1); angle = mo->angle; - if (!accurate) angle += (P_Random()-P_Random())<<18; - P_LineAttack (mo, angle, MISSILERANGE, bulletslope, damage); } - - - - - void A_FirePistol ( player_t* player, pspdef_t* psp ) { S_StartSound (player->mo, sfx_pistol); - P_SetMobjState (player->mo, S_PLAY_ATK2); player->ammo[weaponinfo[player->readyweapon].ammo]--; - P_SetPsprite (player, ps_flash, weaponinfo[player->readyweapon].flashstate); - P_BulletSlope (player->mo); P_GunShot (player->mo, !player->refire); } - - - - - void A_FireShotgun ( player_t* player, pspdef_t* psp ) { int i; - S_StartSound (player->mo, sfx_shotgn); P_SetMobjState (player->mo, S_PLAY_ATK2); - player->ammo[weaponinfo[player->readyweapon].ammo]--; - P_SetPsprite (player, ps_flash, weaponinfo[player->readyweapon].flashstate); - P_BulletSlope (player->mo); - for (i=0 ; i<7 ; i++) P_GunShot (player->mo, false); } - - - - - - void A_FireShotgun2 ( player_t* player, @@ -698,19 +417,13 @@ A_FireShotgun2 int i; angle_t angle; int damage; - - S_StartSound (player->mo, sfx_dshtgn); P_SetMobjState (player->mo, S_PLAY_ATK2); - player->ammo[weaponinfo[player->readyweapon].ammo]-=2; - P_SetPsprite (player, ps_flash, weaponinfo[player->readyweapon].flashstate); - P_BulletSlope (player->mo); - for (i=0 ; i<20 ; i++) { damage = 5*(P_Random ()%3+1); @@ -722,96 +435,58 @@ A_FireShotgun2 bulletslope + ((P_Random()-P_Random())<<5), damage); } } - - - - - void A_FireCGun ( player_t* player, pspdef_t* psp ) { S_StartSound (player->mo, sfx_pistol); - if (!player->ammo[weaponinfo[player->readyweapon].ammo]) return; - P_SetMobjState (player->mo, S_PLAY_ATK2); player->ammo[weaponinfo[player->readyweapon].ammo]--; - P_SetPsprite (player, ps_flash, weaponinfo[player->readyweapon].flashstate + psp->state - &states[S_CHAIN1] ); - P_BulletSlope (player->mo); - P_GunShot (player->mo, !player->refire); } - - - - - - void A_Light0 (player_t *player, pspdef_t *psp) { player->extralight = 0; } - void A_Light1 (player_t *player, pspdef_t *psp) { player->extralight = 1; } - void A_Light2 (player_t *player, pspdef_t *psp) { player->extralight = 2; } - - - - - - void A_BFGSpray (mobj_t* mo) { int i; int j; int damage; angle_t an; - - for (i=0 ; i<40 ; i++) { an = mo->angle - ANG90/2 + ANG90/40*i; - - - P_AimLineAttack (mo->target, an, 16*64*FRACUNIT); - if (!linetarget) continue; - P_SpawnMobj (linetarget->x, linetarget->y, linetarget->z + (linetarget->height>>2), MT_EXTRABFG); - damage = 0; for (j=0;j<15;j++) damage += (P_Random()&7) + 1; - P_DamageMobj (linetarget, mo->target,mo->target, damage); } } - - - - - void A_BFGsound ( player_t* player, @@ -819,48 +494,24 @@ A_BFGsound { S_StartSound (player->mo, sfx_bfg); } - - - - - - - void P_SetupPsprites (player_t* player) { int i; - - for (i=0 ; i<NUMPSPRITES ; i++) player->psprites[i].state = NULL; - - player->pendingweapon = player->readyweapon; P_BringUpWeapon (player); } - - - - - - - - void P_MovePsprites (player_t* player) { int i; pspdef_t* psp; state_t* state; - psp = &player->psprites[0]; for (i=0 ; i<NUMPSPRITES ; i++, psp++) { - if ( (state = psp->state) ) { - - - if (psp->tics != -1) { psp->tics--; @@ -869,9 +520,6 @@ void P_MovePsprites (player_t* player) } } } - player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx; player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy; } - - diff --git a/src/p_pspr.h b/src/p_pspr.h @@ -1,82 +1,24 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __P_PSPR__ #define __P_PSPR__ - - - #include "m_fixed.h" #include "tables.h" - - - - - - - - - #include "info.h" - #ifdef __GNUG__ #pragma interface #endif - - - - - - #define FF_FULLBRIGHT 0x8000 #define FF_FRAMEMASK 0x7fff - - - - - - - - typedef enum { ps_weapon, ps_flash, NUMPSPRITES - } psprnum_t; - typedef struct { state_t* state; int tics; fixed_t sx; fixed_t sy; - } pspdef_t; - #endif - - - - - diff --git a/src/p_saveg.c b/src/p_saveg.c @@ -1,60 +1,20 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include "i_system.h" #include "z_zone.h" #include "p_local.h" - - #include "doomstat.h" #include "r_state.h" - byte* save_p; - - - - #define PADSAVEP() save_p += (4 - ((int) save_p & 3)) & 3 - - - - - - void P_ArchivePlayers (void) { int i; int j; player_t* dest; - for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; - PADSAVEP(); - dest = (player_t *)save_p; memcpy (dest,&players[i],sizeof(player_t)); save_p += sizeof(player_t); @@ -68,32 +28,20 @@ void P_ArchivePlayers (void) } } } - - - - - - void P_UnArchivePlayers (void) { int i; int j; - for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; - PADSAVEP(); - memcpy (&players[i],save_p, sizeof(player_t)); save_p += sizeof(player_t); - - players[i].mo = NULL; players[i].message = NULL; players[i].attacker = NULL; - for (j=0 ; j<NUMPSPRITES ; j++) { if (players[i]. psprites[j].state) @@ -104,11 +52,6 @@ void P_UnArchivePlayers (void) } } } - - - - - void P_ArchiveWorld (void) { int i; @@ -117,10 +60,7 @@ void P_ArchiveWorld (void) line_t* li; side_t* si; short* put; - put = (short *)save_p; - - for (i=0, sec = sectors ; i<numsectors ; i++,sec++) { *put++ = sec->floorheight >> FRACBITS; @@ -131,9 +71,6 @@ void P_ArchiveWorld (void) *put++ = sec->special; *put++ = sec->tag; } - - - for (i=0, li = lines ; i<numlines ; i++,li++) { *put++ = li->flags; @@ -143,9 +80,7 @@ void P_ArchiveWorld (void) { if (li->sidenum[j] == -1) continue; - si = &sides[li->sidenum[j]]; - *put++ = si->textureoffset >> FRACBITS; *put++ = si->rowoffset >> FRACBITS; *put++ = si->toptexture; @@ -153,15 +88,8 @@ void P_ArchiveWorld (void) *put++ = si->midtexture; } } - save_p = (byte *)put; } - - - - - - void P_UnArchiveWorld (void) { int i; @@ -170,10 +98,7 @@ void P_UnArchiveWorld (void) line_t* li; side_t* si; short* get; - get = (short *)save_p; - - for (i=0, sec = sectors ; i<numsectors ; i++,sec++) { sec->floorheight = *get++ << FRACBITS; @@ -186,8 +111,6 @@ void P_UnArchiveWorld (void) sec->specialdata = 0; sec->soundtarget = 0; } - - for (i=0, li = lines ; i<numlines ; i++,li++) { li->flags = *get++; @@ -207,32 +130,15 @@ void P_UnArchiveWorld (void) } save_p = (byte *)get; } - - - - - - - - typedef enum { tc_end, tc_mobj - } thinkerclass_t; - - - - - - void P_ArchiveThinkers (void) { thinker_t* th; mobj_t* mobj; - - for (th = thinkercap.next ; th != &thinkercap ; th=th->next) { if (th->function.acp1 == (actionf_p1)P_MobjThinker) @@ -243,47 +149,30 @@ void P_ArchiveThinkers (void) memcpy (mobj, th, sizeof(*mobj)); save_p += sizeof(*mobj); mobj->state = (state_t *)(mobj->state - states); - if (mobj->player) mobj->player = (player_t *)((mobj->player-players) + 1); continue; } - - } - - *save_p++ = tc_end; } - - - - - - void P_UnArchiveThinkers (void) { byte tclass; thinker_t* currentthinker; thinker_t* next; mobj_t* mobj; - - currentthinker = thinkercap.next; while (currentthinker != &thinkercap) { next = currentthinker->next; - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) P_RemoveMobj ((mobj_t *)currentthinker); else Z_Free (currentthinker); - currentthinker = next; } P_InitThinkers (); - - while (1) { tclass = *save_p++; @@ -291,7 +180,6 @@ void P_UnArchiveThinkers (void) { case tc_end: return; - case tc_mobj: PADSAVEP(); mobj = Z_Malloc (sizeof(*mobj), PU_LEVEL, NULL); @@ -311,19 +199,11 @@ void P_UnArchiveThinkers (void) mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; P_AddThinker (&mobj->thinker); break; - default: I_Error ("Unknown tclass %i in savegame",tclass); } - } - } - - - - - enum { tc_ceiling, @@ -334,22 +214,7 @@ enum tc_strobe, tc_glow, tc_endspecials - } specials_e; - - - - - - - - - - - - - - void P_ArchiveSpecials (void) { thinker_t* th; @@ -361,8 +226,6 @@ void P_ArchiveSpecials (void) strobe_t* strobe; glow_t* glow; int i; - - for (th = thinkercap.next ; th != &thinkercap ; th=th->next) { if (th->function.acv == (actionf_v)NULL) @@ -370,7 +233,6 @@ void P_ArchiveSpecials (void) for (i = 0; i < MAXCEILINGS;i++) if (activeceilings[i] == (ceiling_t *)th) break; - if (i<MAXCEILINGS) { *save_p++ = tc_ceiling; @@ -382,7 +244,6 @@ void P_ArchiveSpecials (void) } continue; } - if (th->function.acp1 == (actionf_p1)T_MoveCeiling) { *save_p++ = tc_ceiling; @@ -393,7 +254,6 @@ void P_ArchiveSpecials (void) ceiling->sector = (sector_t *)(ceiling->sector - sectors); continue; } - if (th->function.acp1 == (actionf_p1)T_VerticalDoor) { *save_p++ = tc_door; @@ -404,7 +264,6 @@ void P_ArchiveSpecials (void) door->sector = (sector_t *)(door->sector - sectors); continue; } - if (th->function.acp1 == (actionf_p1)T_MoveFloor) { *save_p++ = tc_floor; @@ -415,7 +274,6 @@ void P_ArchiveSpecials (void) floor->sector = (sector_t *)(floor->sector - sectors); continue; } - if (th->function.acp1 == (actionf_p1)T_PlatRaise) { *save_p++ = tc_plat; @@ -426,7 +284,6 @@ void P_ArchiveSpecials (void) plat->sector = (sector_t *)(plat->sector - sectors); continue; } - if (th->function.acp1 == (actionf_p1)T_LightFlash) { *save_p++ = tc_flash; @@ -437,7 +294,6 @@ void P_ArchiveSpecials (void) flash->sector = (sector_t *)(flash->sector - sectors); continue; } - if (th->function.acp1 == (actionf_p1)T_StrobeFlash) { *save_p++ = tc_strobe; @@ -448,7 +304,6 @@ void P_ArchiveSpecials (void) strobe->sector = (sector_t *)(strobe->sector - sectors); continue; } - if (th->function.acp1 == (actionf_p1)T_Glow) { *save_p++ = tc_glow; @@ -460,16 +315,8 @@ void P_ArchiveSpecials (void) continue; } } - - *save_p++ = tc_endspecials; - } - - - - - void P_UnArchiveSpecials (void) { byte tclass; @@ -480,9 +327,6 @@ void P_UnArchiveSpecials (void) lightflash_t* flash; strobe_t* strobe; glow_t* glow; - - - while (1) { tclass = *save_p++; @@ -490,7 +334,6 @@ void P_UnArchiveSpecials (void) { case tc_endspecials: return; - case tc_ceiling: PADSAVEP(); ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL); @@ -498,14 +341,11 @@ void P_UnArchiveSpecials (void) save_p += sizeof(*ceiling); ceiling->sector = &sectors[(int)ceiling->sector]; ceiling->sector->specialdata = ceiling; - if (ceiling->thinker.function.acp1) ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling; - P_AddThinker (&ceiling->thinker); P_AddActiveCeiling(ceiling); break; - case tc_door: PADSAVEP(); door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL); @@ -516,7 +356,6 @@ void P_UnArchiveSpecials (void) door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor; P_AddThinker (&door->thinker); break; - case tc_floor: PADSAVEP(); floor = Z_Malloc (sizeof(*floor), PU_LEVEL, NULL); @@ -527,7 +366,6 @@ void P_UnArchiveSpecials (void) floor->thinker.function.acp1 = (actionf_p1)T_MoveFloor; P_AddThinker (&floor->thinker); break; - case tc_plat: PADSAVEP(); plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL); @@ -535,14 +373,11 @@ void P_UnArchiveSpecials (void) save_p += sizeof(*plat); plat->sector = &sectors[(int)plat->sector]; plat->sector->specialdata = plat; - if (plat->thinker.function.acp1) plat->thinker.function.acp1 = (actionf_p1)T_PlatRaise; - P_AddThinker (&plat->thinker); P_AddActivePlat(plat); break; - case tc_flash: PADSAVEP(); flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL); @@ -552,7 +387,6 @@ void P_UnArchiveSpecials (void) flash->thinker.function.acp1 = (actionf_p1)T_LightFlash; P_AddThinker (&flash->thinker); break; - case tc_strobe: PADSAVEP(); strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL); @@ -562,7 +396,6 @@ void P_UnArchiveSpecials (void) strobe->thinker.function.acp1 = (actionf_p1)T_StrobeFlash; P_AddThinker (&strobe->thinker); break; - case tc_glow: PADSAVEP(); glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL); @@ -572,13 +405,9 @@ void P_UnArchiveSpecials (void) glow->thinker.function.acp1 = (actionf_p1)T_Glow; P_AddThinker (&glow->thinker); break; - default: I_Error ("P_UnarchiveSpecials:Unknown tclass %i " "in savegame",tclass); } - } - } - diff --git a/src/p_saveg.h b/src/p_saveg.h @@ -1,36 +1,8 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __P_SAVEG__ #define __P_SAVEG__ - - #ifdef __GNUG__ #pragma interface #endif - - - - void P_ArchivePlayers (void); void P_UnArchivePlayers (void); void P_ArchiveWorld (void); @@ -39,13 +11,5 @@ void P_ArchiveThinkers (void); void P_UnArchiveThinkers (void); void P_ArchiveSpecials (void); void P_UnArchiveSpecials (void); - extern byte* save_p; - - #endif - - - - - diff --git a/src/p_setup.c b/src/p_setup.c @@ -1,159 +1,59 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #include <math.h> - #include "z_zone.h" - #include "m_swap.h" #include "m_bbox.h" - #include "g_game.h" - #include "i_system.h" #include "w_wad.h" - #include "doomdef.h" #include "p_local.h" - #include "s_sound.h" - #include "doomstat.h" - - void P_SpawnMapThing (mapthing_t* mthing); - - - - - - int numvertexes; vertex_t* vertexes; - int numsegs; seg_t* segs; - int numsectors; sector_t* sectors; - int numsubsectors; subsector_t* subsectors; - int numnodes; node_t* nodes; - int numlines; line_t* lines; - int numsides; side_t* sides; - - - - - - - - - - int bmapwidth; int bmapheight; short* blockmap; - short* blockmaplump; - fixed_t bmaporgx; fixed_t bmaporgy; - mobj_t** blocklinks; - - - - - - - - - byte* rejectmatrix; - - - #define MAX_DEATHMATCH_STARTS 10 - mapthing_t deathmatchstarts[MAX_DEATHMATCH_STARTS]; mapthing_t* deathmatch_p; mapthing_t playerstarts[MAXPLAYERS]; - - - - - - - - void P_LoadVertexes (int lump) { byte* data; int i; mapvertex_t* ml; vertex_t* li; - - - numvertexes = W_LumpLength (lump) / sizeof(mapvertex_t); - - vertexes = Z_Malloc (numvertexes*sizeof(vertex_t),PU_LEVEL,0); - - data = W_CacheLumpNum (lump,PU_STATIC); - ml = (mapvertex_t *)data; li = vertexes; - - - for (i=0 ; i<numvertexes ; i++, li++, ml++) { li->x = SHORT(ml->x)<<FRACBITS; li->y = SHORT(ml->y)<<FRACBITS; } - - Z_Free (data); } - - - - - - void P_LoadSegs (int lump) { byte* data; @@ -163,19 +63,16 @@ void P_LoadSegs (int lump) line_t* ldef; int linedef; int side; - numsegs = W_LumpLength (lump) / sizeof(mapseg_t); segs = Z_Malloc (numsegs*sizeof(seg_t),PU_LEVEL,0); memset (segs, 0, numsegs*sizeof(seg_t)); data = W_CacheLumpNum (lump,PU_STATIC); - ml = (mapseg_t *)data; li = segs; for (i=0 ; i<numsegs ; i++, li++, ml++) { li->v1 = &vertexes[SHORT(ml->v1)]; li->v2 = &vertexes[SHORT(ml->v2)]; - li->angle = (SHORT(ml->angle))<<16; li->offset = (SHORT(ml->offset))<<16; linedef = SHORT(ml->linedef); @@ -189,55 +86,37 @@ void P_LoadSegs (int lump) else li->backsector = 0; } - Z_Free (data); } - - - - - void P_LoadSubsectors (int lump) { byte* data; int i; mapsubsector_t* ms; subsector_t* ss; - numsubsectors = W_LumpLength (lump) / sizeof(mapsubsector_t); subsectors = Z_Malloc (numsubsectors*sizeof(subsector_t),PU_LEVEL,0); data = W_CacheLumpNum (lump,PU_STATIC); - ms = (mapsubsector_t *)data; memset (subsectors,0, numsubsectors*sizeof(subsector_t)); ss = subsectors; - for (i=0 ; i<numsubsectors ; i++, ss++, ms++) { ss->numlines = SHORT(ms->numsegs); ss->firstline = SHORT(ms->firstseg); } - Z_Free (data); } - - - - - - void P_LoadSectors (int lump) { byte* data; int i; mapsector_t* ms; sector_t* ss; - numsectors = W_LumpLength (lump) / sizeof(mapsector_t); sectors = Z_Malloc (numsectors*sizeof(sector_t),PU_LEVEL,0); memset (sectors, 0, numsectors*sizeof(sector_t)); data = W_CacheLumpNum (lump,PU_STATIC); - ms = (mapsector_t *)data; ss = sectors; for (i=0 ; i<numsectors ; i++, ss++, ms++) @@ -251,14 +130,8 @@ void P_LoadSectors (int lump) ss->tag = SHORT(ms->tag); ss->thinglist = NULL; } - Z_Free (data); } - - - - - void P_LoadNodes (int lump) { byte* data; @@ -267,14 +140,11 @@ void P_LoadNodes (int lump) int k; mapnode_t* mn; node_t* no; - numnodes = W_LumpLength (lump) / sizeof(mapnode_t); nodes = Z_Malloc (numnodes*sizeof(node_t),PU_LEVEL,0); data = W_CacheLumpNum (lump,PU_STATIC); - mn = (mapnode_t *)data; no = nodes; - for (i=0 ; i<numnodes ; i++, no++, mn++) { no->x = SHORT(mn->x)<<FRACBITS; @@ -288,14 +158,8 @@ void P_LoadNodes (int lump) no->bbox[j][k] = SHORT(mn->bbox[j][k])<<FRACBITS; } } - Z_Free (data); } - - - - - void P_LoadThings (int lump) { byte* data; @@ -303,16 +167,12 @@ void P_LoadThings (int lump) mapthing_t* mt; int numthings; boolean spawn; - data = W_CacheLumpNum (lump,PU_STATIC); numthings = W_LumpLength (lump) / sizeof(mapthing_t); - mt = (mapthing_t *)data; for (i=0 ; i<numthings ; i++, mt++) { spawn = true; - - if ( gamemode != commercial) { switch(mt->type) @@ -333,25 +193,15 @@ void P_LoadThings (int lump) } if (spawn == false) break; - - mt->x = SHORT(mt->x); mt->y = SHORT(mt->y); mt->angle = SHORT(mt->angle); mt->type = SHORT(mt->type); mt->options = SHORT(mt->options); - P_SpawnMapThing (mt); } - Z_Free (data); } - - - - - - void P_LoadLineDefs (int lump) { byte* data; @@ -360,12 +210,10 @@ void P_LoadLineDefs (int lump) line_t* ld; vertex_t* v1; vertex_t* v2; - numlines = W_LumpLength (lump) / sizeof(maplinedef_t); lines = Z_Malloc (numlines*sizeof(line_t),PU_LEVEL,0); memset (lines, 0, numlines*sizeof(line_t)); data = W_CacheLumpNum (lump,PU_STATIC); - mld = (maplinedef_t *)data; ld = lines; for (i=0 ; i<numlines ; i++, mld++, ld++) @@ -377,7 +225,6 @@ void P_LoadLineDefs (int lump) v2 = ld->v2 = &vertexes[SHORT(mld->v2)]; ld->dx = v2->x - v1->x; ld->dy = v2->y - v1->y; - if (!ld->dx) ld->slopetype = ST_VERTICAL; else if (!ld->dy) @@ -389,7 +236,6 @@ void P_LoadLineDefs (int lump) else ld->slopetype = ST_NEGATIVE; } - if (v1->x < v2->x) { ld->bbox[BOXLEFT] = v1->x; @@ -400,7 +246,6 @@ void P_LoadLineDefs (int lump) ld->bbox[BOXLEFT] = v2->x; ld->bbox[BOXRIGHT] = v1->x; } - if (v1->y < v2->y) { ld->bbox[BOXBOTTOM] = v1->y; @@ -411,40 +256,29 @@ void P_LoadLineDefs (int lump) ld->bbox[BOXBOTTOM] = v2->y; ld->bbox[BOXTOP] = v1->y; } - ld->sidenum[0] = SHORT(mld->sidenum[0]); ld->sidenum[1] = SHORT(mld->sidenum[1]); - if (ld->sidenum[0] != -1) ld->frontsector = sides[ld->sidenum[0]].sector; else ld->frontsector = 0; - if (ld->sidenum[1] != -1) ld->backsector = sides[ld->sidenum[1]].sector; else ld->backsector = 0; } - Z_Free (data); } - - - - - void P_LoadSideDefs (int lump) { byte* data; int i; mapsidedef_t* msd; side_t* sd; - numsides = W_LumpLength (lump) / sizeof(mapsidedef_t); sides = Z_Malloc (numsides*sizeof(side_t),PU_LEVEL,0); memset (sides, 0, numsides*sizeof(side_t)); data = W_CacheLumpNum (lump,PU_STATIC); - msd = (mapsidedef_t *)data; sd = sides; for (i=0 ; i<numsides ; i++, msd++, sd++) @@ -456,44 +290,25 @@ void P_LoadSideDefs (int lump) sd->midtexture = R_TextureNumForName(msd->midtexture); sd->sector = &sectors[SHORT(msd->sector)]; } - Z_Free (data); } - - - - - void P_LoadBlockMap (int lump) { int i; int count; - blockmaplump = W_CacheLumpNum (lump,PU_LEVEL); blockmap = blockmaplump+4; count = W_LumpLength (lump)/2; - for (i=0 ; i<count ; i++) blockmaplump[i] = SHORT(blockmaplump[i]); - bmaporgx = blockmaplump[0]<<FRACBITS; bmaporgy = blockmaplump[1]<<FRACBITS; bmapwidth = blockmaplump[2]; bmapheight = blockmaplump[3]; - - count = sizeof(*blocklinks)* bmapwidth*bmapheight; blocklinks = Z_Malloc (count,PU_LEVEL, 0); memset (blocklinks, 0, count); } - - - - - - - - void P_GroupLines (void) { line_t** linebuffer; @@ -506,31 +321,24 @@ void P_GroupLines (void) seg_t* seg; fixed_t bbox[4]; int block; - - ss = subsectors; for (i=0 ; i<numsubsectors ; i++, ss++) { seg = &segs[ss->firstline]; ss->sector = seg->sidedef->sector; } - - li = lines; total = 0; for (i=0 ; i<numlines ; i++, li++) { total++; li->frontsector->linecount++; - if (li->backsector && li->backsector != li->frontsector) { li->backsector->linecount++; total++; } } - - linebuffer = Z_Malloc (total*4, PU_LEVEL, 0); sector = sectors; for (i=0 ; i<numsectors ; i++, sector++) @@ -549,35 +357,22 @@ void P_GroupLines (void) } if (linebuffer - sector->lines != sector->linecount) I_Error ("P_GroupLines: miscounted"); - - sector->soundorg.x = (bbox[BOXRIGHT]+bbox[BOXLEFT])/2; sector->soundorg.y = (bbox[BOXTOP]+bbox[BOXBOTTOM])/2; - - block = (bbox[BOXTOP]-bmaporgy+MAXRADIUS)>>MAPBLOCKSHIFT; block = block >= bmapheight ? bmapheight-1 : block; sector->blockbox[BOXTOP]=block; - block = (bbox[BOXBOTTOM]-bmaporgy-MAXRADIUS)>>MAPBLOCKSHIFT; block = block < 0 ? 0 : block; sector->blockbox[BOXBOTTOM]=block; - block = (bbox[BOXRIGHT]-bmaporgx+MAXRADIUS)>>MAPBLOCKSHIFT; block = block >= bmapwidth ? bmapwidth-1 : block; sector->blockbox[BOXRIGHT]=block; - block = (bbox[BOXLEFT]-bmaporgx-MAXRADIUS)>>MAPBLOCKSHIFT; block = block < 0 ? 0 : block; sector->blockbox[BOXLEFT]=block; } - } - - - - - void P_SetupLevel ( int episode, @@ -588,7 +383,6 @@ P_SetupLevel int i; char lumpname[9]; int lumpnum; - totalkills = totalitems = totalsecret = wminfo.maxfrags = 0; wminfo.partime = 180; for (i=0 ; i<MAXPLAYERS ; i++) @@ -596,15 +390,8 @@ P_SetupLevel players[i].killcount = players[i].secretcount = players[i].itemcount = 0; } - - - players[consoleplayer].viewz = 1; - - S_Start (); - - #if 0 if (debugfile) { @@ -614,15 +401,8 @@ P_SetupLevel else #endif Z_FreeTags (PU_LEVEL, PU_PURGELEVEL-1); - - - P_InitThinkers (); - - W_Reload (); - - if ( gamemode == commercial) { if (map<10) @@ -638,30 +418,21 @@ P_SetupLevel lumpname[3] = '0' + map; lumpname[4] = 0; } - lumpnum = W_GetNumForName (lumpname); - leveltime = 0; - - P_LoadBlockMap (lumpnum+ML_BLOCKMAP); P_LoadVertexes (lumpnum+ML_VERTEXES); P_LoadSectors (lumpnum+ML_SECTORS); P_LoadSideDefs (lumpnum+ML_SIDEDEFS); - P_LoadLineDefs (lumpnum+ML_LINEDEFS); P_LoadSubsectors (lumpnum+ML_SSECTORS); P_LoadNodes (lumpnum+ML_NODES); P_LoadSegs (lumpnum+ML_SEGS); - rejectmatrix = W_CacheLumpNum (lumpnum+ML_REJECT,PU_LEVEL); P_GroupLines (); - bodyqueslot = 0; deathmatch_p = deathmatchstarts; P_LoadThings (lumpnum+ML_THINGS); - - if (deathmatch) { for (i=0 ; i<MAXPLAYERS ; i++) @@ -670,37 +441,15 @@ P_SetupLevel players[i].mo = NULL; G_DeathMatchSpawnPlayer (i); } - } - - iquehead = iquetail = 0; - - P_SpawnSpecials (); - - - - - if (precache) R_PrecacheLevel (); - - - } - - - - - - void P_Init (void) { P_InitSwitchList (); P_InitPicAnims (); R_InitSprites (sprnames); } - - - diff --git a/src/p_setup.h b/src/p_setup.h @@ -1,48 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __P_SETUP__ #define __P_SETUP__ - - #ifdef __GNUG__ #pragma interface #endif - - - void P_SetupLevel ( int episode, int map, int playermask, skill_t skill); - - void P_Init (void); - #endif - - - - - diff --git a/src/p_sight.c b/src/p_sight.c @@ -1,54 +1,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include "doomdef.h" - #include "i_system.h" #include "p_local.h" - - #include "r_state.h" - - - - fixed_t sightzstart; fixed_t topslope; fixed_t bottomslope; - divline_t strace; fixed_t t2x; fixed_t t2y; - int sightcounts[2]; - - - - - - int P_DivlineSide ( fixed_t x, @@ -59,50 +19,32 @@ P_DivlineSide fixed_t dy; fixed_t left; fixed_t right; - if (!node->dx) { if (x==node->x) return 2; - if (x <= node->x) return node->dy > 0; - return node->dy < 0; } - if (!node->dy) { if (x==node->y) return 2; - if (y <= node->y) return node->dx < 0; - return node->dx > 0; } - dx = (x - node->x); dy = (y - node->y); - left = (node->dy>>FRACBITS) * (dx>>FRACBITS); right = (dy>>FRACBITS) * (node->dx>>FRACBITS); - if (right < left) return 0; - if (left == right) return 2; return 1; } - - - - - - - - fixed_t P_InterceptVector2 ( divline_t* v2, @@ -111,25 +53,14 @@ P_InterceptVector2 fixed_t frac; fixed_t num; fixed_t den; - den = FixedMul (v1->dy>>8,v2->dx) - FixedMul(v1->dx>>8,v2->dy); - if (den == 0) return 0; - - num = FixedMul ( (v1->x - v2->x)>>8 ,v1->dy) + FixedMul ( (v2->y - v1->y)>>8 , v1->dx); frac = FixedDiv (num , den); - return frac; } - - - - - - boolean P_CrossSubsector (int num) { seg_t* seg; @@ -147,116 +78,74 @@ boolean P_CrossSubsector (int num) vertex_t* v2; fixed_t frac; fixed_t slope; - #ifdef RANGECHECK if (num>=numsubsectors) I_Error ("P_CrossSubsector: ss %i with numss = %i", num, numsubsectors); #endif - sub = &subsectors[num]; - - count = sub->numlines; seg = &segs[sub->firstline]; - for ( ; count ; seg++, count--) { line = seg->linedef; - - if (line->validcount == validcount) continue; - line->validcount = validcount; - v1 = line->v1; v2 = line->v2; s1 = P_DivlineSide (v1->x,v1->y, &strace); s2 = P_DivlineSide (v2->x, v2->y, &strace); - - if (s1 == s2) continue; - divl.x = v1->x; divl.y = v1->y; divl.dx = v2->x - v1->x; divl.dy = v2->y - v1->y; s1 = P_DivlineSide (strace.x, strace.y, &divl); s2 = P_DivlineSide (t2x, t2y, &divl); - - if (s1 == s2) continue; - - - if ( !(line->flags & ML_TWOSIDED) ) return false; - - front = seg->frontsector; back = seg->backsector; - - if (front->floorheight == back->floorheight && front->ceilingheight == back->ceilingheight) continue; - - - if (front->ceilingheight < back->ceilingheight) opentop = front->ceilingheight; else opentop = back->ceilingheight; - - if (front->floorheight > back->floorheight) openbottom = front->floorheight; else openbottom = back->floorheight; - - if (openbottom >= opentop) return false; - frac = P_InterceptVector2 (&strace, &divl); - if (front->floorheight != back->floorheight) { slope = FixedDiv (openbottom - sightzstart , frac); if (slope > bottomslope) bottomslope = slope; } - if (front->ceilingheight != back->ceilingheight) { slope = FixedDiv (opentop - sightzstart , frac); if (slope < topslope) topslope = slope; } - if (topslope <= bottomslope) return false; } - return true; } - - - - - - - - boolean P_CrossBSPNode (int bspnum) { node_t* bsp; int side; - if (bspnum & NF_SUBSECTOR) { if (bspnum == -1) @@ -264,36 +153,18 @@ boolean P_CrossBSPNode (int bspnum) else return P_CrossSubsector (bspnum&(~NF_SUBSECTOR)); } - bsp = &nodes[bspnum]; - - side = P_DivlineSide (strace.x, strace.y, (divline_t *)bsp); if (side == 2) side = 0; - - if (!P_CrossBSPNode (bsp->children[side]) ) return false; - - if (side == P_DivlineSide (t2x, t2y,(divline_t *)bsp)) { - return true; } - - return P_CrossBSPNode (bsp->children[side^1]); } - - - - - - - - boolean P_CheckSight ( mobj_t* t1, @@ -304,44 +175,26 @@ P_CheckSight int pnum; int bytenum; int bitnum; - - - - s1 = (t1->subsector->sector - sectors); s2 = (t2->subsector->sector - sectors); pnum = s1*numsectors + s2; bytenum = pnum>>3; bitnum = 1 << (pnum&7); - - if (rejectmatrix[bytenum]&bitnum) { sightcounts[0]++; - - return false; } - - - sightcounts[1]++; - validcount++; - sightzstart = t1->z + t1->height - (t1->height>>2); topslope = (t2->z+t2->height) - sightzstart; bottomslope = (t2->z) - sightzstart; - strace.x = t1->x; strace.y = t1->y; t2x = t2->x; t2y = t2->y; strace.dx = t2->x - t1->x; strace.dy = t2->y - t1->y; - - return P_CrossBSPNode (numnodes-1); } - - diff --git a/src/p_spec.c b/src/p_spec.c @@ -1,60 +1,17 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdlib.h> - #include "doomdef.h" #include "doomstat.h" - #include "i_system.h" #include "z_zone.h" #include "m_argv.h" #include "m_random.h" #include "w_wad.h" - #include "r_local.h" #include "p_local.h" - #include "g_game.h" - #include "s_sound.h" - - #include "r_state.h" - - #include "sounds.h" - - - - - - typedef struct { boolean istexture; @@ -62,12 +19,7 @@ typedef struct int basepic; int numpics; int speed; - } anim_t; - - - - typedef struct { boolean istexture; @@ -75,27 +27,9 @@ typedef struct char startname[9]; int speed; } animdef_t; - - - #define MAXANIMS 32 - extern anim_t anims[MAXANIMS]; extern anim_t* lastanim; - - - - - - - - - - - - - - animdef_t animdefs[] = { {false, "NUKAGE3", "NUKAGE1", 8}, @@ -103,16 +37,12 @@ animdef_t animdefs[] = {false, "SWATER4", "SWATER1", 8}, {false, "LAVA4", "LAVA1", 8}, {false, "BLOOD3", "BLOOD1", 8}, - - {false, "RROCK08", "RROCK05", 8}, {false, "SLIME04", "SLIME01", 8}, {false, "SLIME08", "SLIME05", 8}, {false, "SLIME12", "SLIME09", 8}, - {true, "BLODGR4", "BLODGR1", 8}, {true, "SLADRIP3", "SLADRIP1", 8}, - {true, "BLODRIP4", "BLODRIP1", 8}, {true, "FIREWALL", "FIREWALA", 8}, {true, "GSTFONT3", "GSTFONT1", 8}, @@ -120,44 +50,27 @@ animdef_t animdefs[] = {true, "FIREMAG3", "FIREMAG1", 8}, {true, "FIREBLU2", "FIREBLU1", 8}, {true, "ROCKRED3", "ROCKRED1", 8}, - {true, "BFALL4", "BFALL1", 8}, {true, "SFALL4", "SFALL1", 8}, {true, "WFALL4", "WFALL1", 8}, {true, "DBRAIN4", "DBRAIN1", 8}, - {-1} }; - anim_t anims[MAXANIMS]; anim_t* lastanim; - - - - - #define MAXLINEANIMS 64 - extern short numlinespecials; extern line_t* linespeciallist[MAXLINEANIMS]; - - - void P_InitPicAnims (void) { int i; - - - lastanim = anims; for (i=0 ; animdefs[i].istexture != -1 ; i++) { if (animdefs[i].istexture) { - if (R_CheckTextureNumForName(animdefs[i].startname) == -1) continue; - lastanim->picnum = R_TextureNumForName (animdefs[i].endname); lastanim->basepic = R_TextureNumForName (animdefs[i].startname); } @@ -165,39 +78,19 @@ void P_InitPicAnims (void) { if (W_CheckNumForName(animdefs[i].startname) == -1) continue; - lastanim->picnum = R_FlatNumForName (animdefs[i].endname); lastanim->basepic = R_FlatNumForName (animdefs[i].startname); } - lastanim->istexture = animdefs[i].istexture; lastanim->numpics = lastanim->picnum - lastanim->basepic + 1; - if (lastanim->numpics < 2) I_Error ("P_InitPicAnims: bad cycle from %s to %s", animdefs[i].startname, animdefs[i].endname); - lastanim->speed = animdefs[i].speed; lastanim++; } - } - - - - - - - - - - - - - - - side_t* getSide ( int currentSector, @@ -206,14 +99,6 @@ getSide { return &sides[ (sectors[currentSector].lines[line])->sidenum[side] ]; } - - - - - - - - sector_t* getSector ( int currentSector, @@ -222,13 +107,6 @@ getSector { return sides[ (sectors[currentSector].lines[line])->sidenum[side] ].sector; } - - - - - - - int twoSided ( int sector, @@ -236,15 +114,6 @@ twoSided { return (sectors[sector].lines[line])->flags & ML_TWOSIDED; } - - - - - - - - - sector_t* getNextSector ( line_t* line, @@ -252,77 +121,45 @@ getNextSector { if (!(line->flags & ML_TWOSIDED)) return NULL; - if (line->frontsector == sec) return line->backsector; - return line->frontsector; } - - - - - - - fixed_t P_FindLowestFloorSurrounding(sector_t* sec) { int i; line_t* check; sector_t* other; fixed_t floor = sec->floorheight; - for (i=0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); - if (!other) continue; - if (other->floorheight < floor) floor = other->floorheight; } return floor; } - - - - - - - fixed_t P_FindHighestFloorSurrounding(sector_t *sec) { int i; line_t* check; sector_t* other; fixed_t floor = -500*FRACUNIT; - for (i=0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); - if (!other) continue; - if (other->floorheight > floor) floor = other->floorheight; } return floor; } - - - - - - - - - #define MAX_ADJOINING_SECTORS 20 - fixed_t P_FindNextHighestFloor ( sector_t* sec, @@ -334,22 +171,15 @@ P_FindNextHighestFloor line_t* check; sector_t* other; fixed_t height = currentheight; - - fixed_t heightlist[MAX_ADJOINING_SECTORS]; - for (i=0, h=0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); - if (!other) continue; - if (other->floorheight > height) heightlist[h++] = other->floorheight; - - if ( h >= MAX_ADJOINING_SECTORS ) { fprintf( stderr, @@ -357,25 +187,14 @@ P_FindNextHighestFloor break; } } - - if (!h) return currentheight; - min = heightlist[0]; - - for (i = 1;i < h;i++) if (heightlist[i] < min) min = heightlist[i]; - return min; } - - - - - fixed_t P_FindLowestCeilingSurrounding(sector_t* sec) { @@ -383,71 +202,45 @@ P_FindLowestCeilingSurrounding(sector_t* sec) line_t* check; sector_t* other; fixed_t height = MAXINT; - for (i=0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); - if (!other) continue; - if (other->ceilingheight < height) height = other->ceilingheight; } return height; } - - - - - fixed_t P_FindHighestCeilingSurrounding(sector_t* sec) { int i; line_t* check; sector_t* other; fixed_t height = 0; - for (i=0 ;i < sec->linecount ; i++) { check = sec->lines[i]; other = getNextSector(check,sec); - if (!other) continue; - if (other->ceilingheight > height) height = other->ceilingheight; } return height; } - - - - - - int P_FindSectorFromLineTag ( line_t* line, int start ) { int i; - for (i=start+1;i<numsectors;i++) if (sectors[i].tag == line->tag) return i; - return -1; } - - - - - - - int P_FindMinSurroundingLight ( sector_t* sector, @@ -457,35 +250,18 @@ P_FindMinSurroundingLight int min; line_t* line; sector_t* check; - min = max; for (i=0 ; i < sector->linecount ; i++) { line = sector->lines[i]; check = getNextSector(line,sector); - if (!check) continue; - if (check->lightlevel < min) min = check->lightlevel; } return min; } - - - - - - - - - - - - - - void P_CrossSpecialLine ( int linenum, @@ -494,13 +270,9 @@ P_CrossSpecialLine { line_t* line; int ok; - line = &lines[linenum]; - - if (!thing->player) { - switch(thing->type) { case MT_ROCKET: @@ -511,10 +283,8 @@ P_CrossSpecialLine case MT_BRUISERSHOT: return; break; - default: break; } - ok = 0; switch(line->special) { @@ -531,510 +301,323 @@ P_CrossSpecialLine if (!ok) return; } - - - switch (line->special) { - - case 2: - EV_DoDoor(line,open); line->special = 0; break; - case 3: - EV_DoDoor(line,close); line->special = 0; break; - case 4: - EV_DoDoor(line,normal); line->special = 0; break; - case 5: - EV_DoFloor(line,raiseFloor); line->special = 0; break; - case 6: - EV_DoCeiling(line,fastCrushAndRaise); line->special = 0; break; - case 8: - EV_BuildStairs(line,build8); line->special = 0; break; - case 10: - EV_DoPlat(line,downWaitUpStay,0); line->special = 0; break; - case 12: - EV_LightTurnOn(line,0); line->special = 0; break; - case 13: - EV_LightTurnOn(line,255); line->special = 0; break; - case 16: - EV_DoDoor(line,close30ThenOpen); line->special = 0; break; - case 17: - EV_StartLightStrobing(line); line->special = 0; break; - case 19: - EV_DoFloor(line,lowerFloor); line->special = 0; break; - case 22: - EV_DoPlat(line,raiseToNearestAndChange,0); line->special = 0; break; - case 25: - EV_DoCeiling(line,crushAndRaise); line->special = 0; break; - case 30: - - EV_DoFloor(line,raiseToTexture); line->special = 0; break; - case 35: - EV_LightTurnOn(line,35); line->special = 0; break; - case 36: - EV_DoFloor(line,turboLower); line->special = 0; break; - case 37: - EV_DoFloor(line,lowerAndChange); line->special = 0; break; - case 38: - EV_DoFloor( line, lowerFloorToLowest ); line->special = 0; break; - case 39: - EV_Teleport( line, side, thing ); line->special = 0; break; - case 40: - EV_DoCeiling( line, raiseToHighest ); EV_DoFloor( line, lowerFloorToLowest ); line->special = 0; break; - case 44: - EV_DoCeiling( line, lowerAndCrush ); line->special = 0; break; - case 52: - G_ExitLevel (); break; - case 53: - EV_DoPlat(line,perpetualRaise,0); line->special = 0; break; - case 54: - EV_StopPlat(line); line->special = 0; break; - case 56: - EV_DoFloor(line,raiseFloorCrush); line->special = 0; break; - case 57: - EV_CeilingCrushStop(line); line->special = 0; break; - case 58: - EV_DoFloor(line,raiseFloor24); line->special = 0; break; - case 59: - EV_DoFloor(line,raiseFloor24AndChange); line->special = 0; break; - case 104: - EV_TurnTagLightsOff(line); line->special = 0; break; - case 108: - EV_DoDoor (line,blazeRaise); line->special = 0; break; - case 109: - EV_DoDoor (line,blazeOpen); line->special = 0; break; - case 100: - EV_BuildStairs(line,turbo16); line->special = 0; break; - case 110: - EV_DoDoor (line,blazeClose); line->special = 0; break; - case 119: - EV_DoFloor(line,raiseFloorToNearest); line->special = 0; break; - case 121: - EV_DoPlat(line,blazeDWUS,0); line->special = 0; break; - case 124: - G_SecretExitLevel (); break; - case 125: - if (!thing->player) { EV_Teleport( line, side, thing ); line->special = 0; } break; - case 130: - EV_DoFloor(line,raiseFloorTurbo); line->special = 0; break; - case 141: - EV_DoCeiling(line,silentCrushAndRaise); line->special = 0; break; - - case 72: - EV_DoCeiling( line, lowerAndCrush ); break; - case 73: - EV_DoCeiling(line,crushAndRaise); break; - case 74: - EV_CeilingCrushStop(line); break; - case 75: - EV_DoDoor(line,close); break; - case 76: - EV_DoDoor(line,close30ThenOpen); break; - case 77: - EV_DoCeiling(line,fastCrushAndRaise); break; - case 79: - EV_LightTurnOn(line,35); break; - case 80: - EV_LightTurnOn(line,0); break; - case 81: - EV_LightTurnOn(line,255); break; - case 82: - EV_DoFloor( line, lowerFloorToLowest ); break; - case 83: - EV_DoFloor(line,lowerFloor); break; - case 84: - EV_DoFloor(line,lowerAndChange); break; - case 86: - EV_DoDoor(line,open); break; - case 87: - EV_DoPlat(line,perpetualRaise,0); break; - case 88: - EV_DoPlat(line,downWaitUpStay,0); break; - case 89: - EV_StopPlat(line); break; - case 90: - EV_DoDoor(line,normal); break; - case 91: - EV_DoFloor(line,raiseFloor); break; - case 92: - EV_DoFloor(line,raiseFloor24); break; - case 93: - EV_DoFloor(line,raiseFloor24AndChange); break; - case 94: - EV_DoFloor(line,raiseFloorCrush); break; - case 95: - - EV_DoPlat(line,raiseToNearestAndChange,0); break; - case 96: - - EV_DoFloor(line,raiseToTexture); break; - case 97: - EV_Teleport( line, side, thing ); break; - case 98: - EV_DoFloor(line,turboLower); break; - case 105: - EV_DoDoor (line,blazeRaise); break; - case 106: - EV_DoDoor (line,blazeOpen); break; - case 107: - EV_DoDoor (line,blazeClose); break; - case 120: - EV_DoPlat(line,blazeDWUS,0); break; - case 126: - if (!thing->player) EV_Teleport( line, side, thing ); break; - case 128: - EV_DoFloor(line,raiseFloorToNearest); break; - case 129: - EV_DoFloor(line,raiseFloorTurbo); break; } } - - - - - - - void P_ShootSpecialLine ( mobj_t* thing, line_t* line ) { int ok; - - if (!thing->player) { ok = 0; switch(line->special) { case 46: - ok = 1; break; } if (!ok) return; } - switch(line->special) { case 24: - EV_DoFloor(line,raiseFloor); P_ChangeSwitchTexture(line,0); break; - case 46: - EV_DoDoor(line,open); P_ChangeSwitchTexture(line,1); break; - case 47: - EV_DoPlat(line,raiseToNearestAndChange,0); P_ChangeSwitchTexture(line,0); break; } } - - - - - - - - void P_PlayerInSpecialSector (player_t* player) { sector_t* sector; - sector = player->mo->subsector->sector; - - if (player->mo->z != sector->floorheight) return; - - switch (sector->special) { case 5: - if (!player->powers[pw_ironfeet]) if (!(leveltime&0x1f)) P_DamageMobj (player->mo, NULL, NULL, 10); break; - case 7: - if (!player->powers[pw_ironfeet]) if (!(leveltime&0x1f)) P_DamageMobj (player->mo, NULL, NULL, 5); break; - case 16: - case 4: - if (!player->powers[pw_ironfeet] || (P_Random()<5) ) { @@ -1042,24 +625,17 @@ void P_PlayerInSpecialSector (player_t* player) P_DamageMobj (player->mo, NULL, NULL, 20); } break; - case 9: - player->secretcount++; sector->special = 0; break; - case 11: - player->cheats &= ~CF_GODMODE; - if (!(leveltime&0x1f)) P_DamageMobj (player->mo, NULL, NULL, 20); - if (player->health <= 10) G_ExitLevel(); break; - default: I_Error ("P_PlayerInSpecialSector: " "unknown special %i", @@ -1067,34 +643,20 @@ void P_PlayerInSpecialSector (player_t* player) break; }; } - - - - - - - - boolean levelTimer; int levelTimeCount; - void P_UpdateSpecials (void) { anim_t* anim; int pic; int i; line_t* line; - - - if (levelTimer == true) { levelTimeCount--; if (!levelTimeCount) G_ExitLevel(); } - - for (anim = anims ; anim < lastanim ; anim++) { for (i=anim->basepic ; i<anim->basepic+anim->numpics ; i++) @@ -1106,23 +668,16 @@ void P_UpdateSpecials (void) flattranslation[i] = pic; } } - - - for (i = 0; i < numlinespecials; i++) { line = linespeciallist[i]; switch(line->special) { case 48: - sides[line->sidenum[0]].textureoffset += FRACUNIT; break; } } - - - for (i = 0; i < MAXBUTTONS; i++) if (buttonlist[i].btimer) { @@ -1135,12 +690,10 @@ void P_UpdateSpecials (void) sides[buttonlist[i].line->sidenum[0]].toptexture = buttonlist[i].btexture; break; - case middle: sides[buttonlist[i].line->sidenum[0]].midtexture = buttonlist[i].btexture; break; - case bottom: sides[buttonlist[i].line->sidenum[0]].bottomtexture = buttonlist[i].btexture; @@ -1150,14 +703,7 @@ void P_UpdateSpecials (void) memset(&buttonlist[i],0,sizeof(button_t)); } } - } - - - - - - int EV_DoDonut(line_t* line) { sector_t* s1; @@ -1167,17 +713,13 @@ int EV_DoDonut(line_t* line) int rtn; int i; floormove_t* floor; - secnum = -1; rtn = 0; while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) { s1 = &sectors[secnum]; - - if (s1->specialdata) continue; - rtn = 1; s2 = getNextSector(s1->lines[0],s1); for (i = 0;i < s2->linecount;i++) @@ -1186,8 +728,6 @@ int EV_DoDonut(line_t* line) (s2->lines[i]->backsector == s1)) continue; s3 = s2->lines[i]->backsector; - - floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); P_AddThinker (&floor->thinker); s2->specialdata = floor; @@ -1200,8 +740,6 @@ int EV_DoDonut(line_t* line) floor->texture = s3->floorpic; floor->newspecial = 0; floor->floordestheight = s3->floorheight; - - floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); P_AddThinker (&floor->thinker); s1->specialdata = floor; @@ -1217,44 +755,23 @@ int EV_DoDonut(line_t* line) } return rtn; } - - - - - - - - - - - - short numlinespecials; line_t* linespeciallist[MAXLINEANIMS]; - - - void P_SpawnSpecials (void) { sector_t* sector; int i; int episode; - episode = 1; if (W_CheckNumForName("texture2") >= 0) episode = 2; - - - levelTimer = false; - i = M_CheckParm("-avg"); if (i && deathmatch) { levelTimer = true; levelTimeCount = 20 * 60 * 35; } - i = M_CheckParm("-timer"); if (i && deathmatch) { @@ -1263,98 +780,64 @@ void P_SpawnSpecials (void) levelTimer = true; levelTimeCount = time; } - - sector = sectors; for (i=0 ; i<numsectors ; i++, sector++) { if (!sector->special) continue; - switch (sector->special) { case 1: - P_SpawnLightFlash (sector); break; - case 2: - P_SpawnStrobeFlash(sector,FASTDARK,0); break; - case 3: - P_SpawnStrobeFlash(sector,SLOWDARK,0); break; - case 4: - P_SpawnStrobeFlash(sector,FASTDARK,0); sector->special = 4; break; - case 8: - P_SpawnGlowingLight(sector); break; case 9: - totalsecret++; break; - case 10: - P_SpawnDoorCloseIn30 (sector); break; - case 12: - P_SpawnStrobeFlash (sector, SLOWDARK, 1); break; - case 13: - P_SpawnStrobeFlash (sector, FASTDARK, 1); break; - case 14: - P_SpawnDoorRaiseIn5Mins (sector, i); break; - case 17: P_SpawnFireFlicker(sector); break; } } - - - numlinespecials = 0; for (i = 0;i < numlines; i++) { switch(lines[i].special) { case 48: - linespeciallist[numlinespecials] = &lines[i]; numlinespecials++; break; } } - - - for (i = 0;i < MAXCEILINGS;i++) activeceilings[i] = NULL; - for (i = 0;i < MAXPLATS;i++) activeplats[i] = NULL; - for (i = 0;i < MAXBUTTONS;i++) memset(&buttonlist[i],0,sizeof(button_t)); - - - } diff --git a/src/p_spec.h b/src/p_spec.h @@ -1,126 +1,61 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #ifndef __P_SPEC__ #define __P_SPEC__ - - - - - extern boolean levelTimer; extern int levelTimeCount; - - - #define MO_TELEPORTMAN 14 - - - void P_InitPicAnims (void); - - void P_SpawnSpecials (void); - - void P_UpdateSpecials (void); - - boolean P_UseSpecialLine ( mobj_t* thing, line_t* line, int side ); - void P_ShootSpecialLine ( mobj_t* thing, line_t* line ); - void P_CrossSpecialLine ( int linenum, int side, mobj_t* thing ); - void P_PlayerInSpecialSector (player_t* player); - int twoSided ( int sector, int line ); - sector_t* getSector ( int currentSector, int line, int side ); - side_t* getSide ( int currentSector, int line, int side ); - fixed_t P_FindLowestFloorSurrounding(sector_t* sec); fixed_t P_FindHighestFloorSurrounding(sector_t* sec); - fixed_t P_FindNextHighestFloor ( sector_t* sec, int currentheight ); - fixed_t P_FindLowestCeilingSurrounding(sector_t* sec); fixed_t P_FindHighestCeilingSurrounding(sector_t* sec); - int P_FindSectorFromLineTag ( line_t* line, int start ); - int P_FindMinSurroundingLight ( sector_t* sector, int max ); - sector_t* getNextSector ( line_t* line, sector_t* sec ); - - - - - int EV_DoDonut(line_t* line); - - - - - - typedef struct { thinker_t thinker; @@ -128,11 +63,7 @@ typedef struct int count; int maxlight; int minlight; - } fireflicker_t; - - - typedef struct { thinker_t thinker; @@ -142,11 +73,7 @@ typedef struct int minlight; int maxtime; int mintime; - } lightflash_t; - - - typedef struct { thinker_t thinker; @@ -156,12 +83,7 @@ typedef struct int maxlight; int darktime; int brighttime; - } strobe_t; - - - - typedef struct { thinker_t thinker; @@ -169,61 +91,40 @@ typedef struct int minlight; int maxlight; int direction; - } glow_t; - - #define GLOWSPEED 8 #define STROBEBRIGHT 5 #define FASTDARK 15 #define SLOWDARK 35 - void P_SpawnFireFlicker (sector_t* sector); void T_LightFlash (lightflash_t* flash); void P_SpawnLightFlash (sector_t* sector); void T_StrobeFlash (strobe_t* flash); - void P_SpawnStrobeFlash ( sector_t* sector, int fastOrSlow, int inSync ); - void EV_StartLightStrobing(line_t* line); void EV_TurnTagLightsOff(line_t* line); - void EV_LightTurnOn ( line_t* line, int bright ); - void T_Glow(glow_t* g); void P_SpawnGlowingLight(sector_t* sector); - - - - - - - typedef struct { char name1[9]; char name2[9]; short episode; - } switchlist_t; - - typedef enum { top, middle, bottom - } bwhere_e; - - typedef struct { line_t* line; @@ -231,45 +132,23 @@ typedef struct int btexture; int btimer; mobj_t* soundorg; - } button_t; - - - - - #define MAXSWITCHES 50 - - #define MAXBUTTONS 16 - - #define BUTTONTIME 35 - extern button_t buttonlist[MAXBUTTONS]; - void P_ChangeSwitchTexture ( line_t* line, int useAgain ); - void P_InitSwitchList(void); - - - - - typedef enum { up, down, waiting, in_stasis - } plat_e; - - - typedef enum { perpetualRaise, @@ -277,11 +156,7 @@ typedef enum raiseAndChange, raiseToNearestAndChange, blazeDWUS - } plattype_e; - - - typedef struct { thinker_t thinker; @@ -296,35 +171,21 @@ typedef struct boolean crush; int tag; plattype_e type; - } plat_t; - - - #define PLATWAIT 3 #define PLATSPEED FRACUNIT #define MAXPLATS 30 - - extern plat_t* activeplats[MAXPLATS]; - void T_PlatRaise(plat_t* plat); - int EV_DoPlat ( line_t* line, plattype_e type, int amount ); - void P_AddActivePlat(plat_t* plat); void P_RemoveActivePlat(plat_t* plat); void EV_StopPlat(line_t* line); void P_ActivateInStasis(int tag); - - - - - typedef enum { normal, @@ -335,11 +196,7 @@ typedef enum blazeRaise, blazeOpen, blazeClose - } vldoor_e; - - - typedef struct { thinker_t thinker; @@ -347,74 +204,44 @@ typedef struct sector_t* sector; fixed_t topheight; fixed_t speed; - - int direction; - - int topwait; - - int topcountdown; - } vldoor_t; - - - #define VDOORSPEED FRACUNIT*2 #define VDOORWAIT 150 - void EV_VerticalDoor ( line_t* line, mobj_t* thing ); - int EV_DoDoor ( line_t* line, vldoor_e type ); - int EV_DoLockedDoor ( line_t* line, vldoor_e type, mobj_t* thing ); - void T_VerticalDoor (vldoor_t* door); void P_SpawnDoorCloseIn30 (sector_t* sec); - void P_SpawnDoorRaiseIn5Mins ( sector_t* sec, int secnum ); - - - #if 0 - - - typedef enum { sd_opening, sd_waiting, sd_closing - } sd_e; - - - typedef enum { sdt_openOnly, sdt_closeOnly, sdt_openAndClose - } sdt_e; - - - - typedef struct { thinker_t thinker; @@ -426,11 +253,7 @@ typedef struct sector_t* frontsector; sector_t* backsector; sd_e status; - } slidedoor_t; - - - typedef struct { char frontFrame1[9]; @@ -441,42 +264,22 @@ typedef struct char backFrame2[9]; char backFrame3[9]; char backFrame4[9]; - } slidename_t; - - - typedef struct { int frontFrames[4]; int backFrames[4]; - } slideframe_t; - - - - #define SNUMFRAMES 4 - #define SDOORWAIT 35*3 #define SWAITTICS 4 - - #define MAXSLIDEDOORS 5 - void P_InitSlidingDoorFrames(void); - void EV_SlidingDoor ( line_t* line, mobj_t* thing ); #endif - - - - - - typedef enum { lowerToFloor, @@ -485,11 +288,7 @@ typedef enum crushAndRaise, fastCrushAndRaise, silentCrushAndRaise - } ceiling_e; - - - typedef struct { thinker_t thinker; @@ -499,88 +298,44 @@ typedef struct fixed_t topheight; fixed_t speed; boolean crush; - - int direction; - - int tag; int olddirection; - } ceiling_t; - - - - - #define CEILSPEED FRACUNIT #define CEILWAIT 150 #define MAXCEILINGS 30 - extern ceiling_t* activeceilings[MAXCEILINGS]; - int EV_DoCeiling ( line_t* line, ceiling_e type ); - void T_MoveCeiling (ceiling_t* ceiling); void P_AddActiveCeiling(ceiling_t* c); void P_RemoveActiveCeiling(ceiling_t* c); int EV_CeilingCrushStop(line_t* line); void P_ActivateInStasisCeiling(line_t* line); - - - - - typedef enum { - lowerFloor, - - lowerFloorToLowest, - - turboLower, - - raiseFloor, - - raiseFloorToNearest, - - raiseToTexture, - - - lowerAndChange, - raiseFloor24, raiseFloor24AndChange, raiseFloorCrush, - - raiseFloorTurbo, donutRaise, raiseFloor512 - } floor_e; - - - - typedef enum { build8, turbo16 - } stair_e; - - - typedef struct { thinker_t thinker; @@ -592,21 +347,14 @@ typedef struct short texture; fixed_t floordestheight; fixed_t speed; - } floormove_t; - - - #define FLOORSPEED FRACUNIT - typedef enum { ok, crushed, pastdest - } result_e; - result_e T_MovePlane ( sector_t* sector, @@ -615,31 +363,18 @@ T_MovePlane boolean crush, int floorOrCeiling, int direction ); - int EV_BuildStairs ( line_t* line, stair_e type ); - int EV_DoFloor ( line_t* line, floor_e floortype ); - void T_MoveFloor( floormove_t* floor); - - - - int EV_Teleport ( line_t* line, int side, mobj_t* thing ); - #endif - - - - - diff --git a/src/p_switch.c b/src/p_switch.c @@ -1,51 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #include "i_system.h" #include "doomdef.h" #include "p_local.h" - #include "g_game.h" - #include "s_sound.h" - - #include "sounds.h" - - #include "doomstat.h" #include "r_state.h" - - - - - switchlist_t alphSwitchList[] = { - {"SW1BRCOM", "SW2BRCOM", 1}, {"SW1BRN1", "SW2BRN1", 1}, {"SW1BRN2", "SW2BRN2", 1}, @@ -65,8 +27,6 @@ switchlist_t alphSwitchList[] = {"SW1STON2", "SW2STON2", 1}, {"SW1STONE", "SW2STONE", 1}, {"SW1STRTN", "SW2STRTN", 1}, - - {"SW1BLUE", "SW2BLUE", 2}, {"SW1CMT", "SW2CMT", 2}, {"SW1GARG", "SW2GARG", 2}, @@ -77,8 +37,6 @@ switchlist_t alphSwitchList[] = {"SW1SKIN", "SW2SKIN", 2}, {"SW1VINE", "SW2VINE", 2}, {"SW1WOOD", "SW2WOOD", 2}, - - {"SW1PANEL", "SW2PANEL", 3}, {"SW1ROCK", "SW2ROCK", 3}, {"SW1MET2", "SW2MET2", 3}, @@ -90,32 +48,22 @@ switchlist_t alphSwitchList[] = {"SW1TEK", "SW2TEK", 3}, {"SW1MARB", "SW2MARB", 3}, {"SW1SKULL", "SW2SKULL", 3}, - {"\0", "\0", 0} }; - int switchlist[MAXSWITCHES * 2]; int numswitches; button_t buttonlist[MAXBUTTONS]; - - - - - void P_InitSwitchList(void) { int i; int index; int episode; - episode = 1; - if (gamemode == registered) episode = 2; else if ( gamemode == commercial ) episode = 3; - for (index = 0,i = 0;i < MAXSWITCHES;i++) { if (!alphSwitchList[i].episode) @@ -124,19 +72,16 @@ void P_InitSwitchList(void) switchlist[index] = -1; break; } - if (alphSwitchList[i].episode <= episode) { #if 0 int value; - if (R_CheckTextureNumForName(alphSwitchList[i].name1) < 0) { I_Error("Can't find switch texture '%s'!", alphSwitchList[i].name1); continue; } - value = R_TextureNumForName(alphSwitchList[i].name1); #endif switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1); @@ -144,11 +89,6 @@ void P_InitSwitchList(void) } } } - - - - - void P_StartButton ( line_t* line, @@ -157,20 +97,14 @@ P_StartButton int time ) { int i; - - for (i = 0;i < MAXBUTTONS;i++) { if (buttonlist[i].btimer && buttonlist[i].line == line) { - return; } } - - - for (i = 0;i < MAXBUTTONS;i++) { if (!buttonlist[i].btimer) @@ -183,18 +117,8 @@ P_StartButton return; } } - I_Error("P_StartButton: no button slots left!"); } - - - - - - - - - void P_ChangeSwitchTexture ( line_t* line, @@ -205,30 +129,22 @@ P_ChangeSwitchTexture int texBot; int i; int sound; - if (!useAgain) line->special = 0; - texTop = sides[line->sidenum[0]].toptexture; texMid = sides[line->sidenum[0]].midtexture; texBot = sides[line->sidenum[0]].bottomtexture; - sound = sfx_swtchn; - - if (line->special == 11) sound = sfx_swtchx; - for (i = 0;i < numswitches*2;i++) { if (switchlist[i] == texTop) { S_StartSound(buttonlist->soundorg,sound); sides[line->sidenum[0]].toptexture = switchlist[i^1]; - if (useAgain) P_StartButton(line,top,switchlist[i],BUTTONTIME); - return; } else @@ -237,10 +153,8 @@ P_ChangeSwitchTexture { S_StartSound(buttonlist->soundorg,sound); sides[line->sidenum[0]].midtexture = switchlist[i^1]; - if (useAgain) P_StartButton(line, middle,switchlist[i],BUTTONTIME); - return; } else @@ -249,59 +163,35 @@ P_ChangeSwitchTexture { S_StartSound(buttonlist->soundorg,sound); sides[line->sidenum[0]].bottomtexture = switchlist[i^1]; - if (useAgain) P_StartButton(line, bottom,switchlist[i],BUTTONTIME); - return; } } } } } - - - - - - - - - - - boolean P_UseSpecialLine ( mobj_t* thing, line_t* line, int side ) { - - - if (side) { switch(line->special) { case 124: - - break; - default: return false; break; } } - - - if (!thing->player) { - if (line->flags & ML_SECRET) return false; - switch(line->special) { case 1: @@ -309,344 +199,225 @@ P_UseSpecialLine case 33: case 34: break; - default: return false; break; } } - - - switch (line->special) { - case 1: case 26: case 27: case 28: - case 31: case 32: case 33: case 34: - case 117: case 118: EV_VerticalDoor (line, thing); break; - - - - - - - case 7: - if (EV_BuildStairs(line,build8)) P_ChangeSwitchTexture(line,0); break; - case 9: - if (EV_DoDonut(line)) P_ChangeSwitchTexture(line,0); break; - case 11: - P_ChangeSwitchTexture(line,0); G_ExitLevel (); break; - case 14: - if (EV_DoPlat(line,raiseAndChange,32)) P_ChangeSwitchTexture(line,0); break; - case 15: - if (EV_DoPlat(line,raiseAndChange,24)) P_ChangeSwitchTexture(line,0); break; - case 18: - if (EV_DoFloor(line, raiseFloorToNearest)) P_ChangeSwitchTexture(line,0); break; - case 20: - if (EV_DoPlat(line,raiseToNearestAndChange,0)) P_ChangeSwitchTexture(line,0); break; - case 21: - if (EV_DoPlat(line,downWaitUpStay,0)) P_ChangeSwitchTexture(line,0); break; - case 23: - if (EV_DoFloor(line,lowerFloorToLowest)) P_ChangeSwitchTexture(line,0); break; - case 29: - if (EV_DoDoor(line,normal)) P_ChangeSwitchTexture(line,0); break; - case 41: - if (EV_DoCeiling(line,lowerToFloor)) P_ChangeSwitchTexture(line,0); break; - case 71: - if (EV_DoFloor(line,turboLower)) P_ChangeSwitchTexture(line,0); break; - case 49: - if (EV_DoCeiling(line,crushAndRaise)) P_ChangeSwitchTexture(line,0); break; - case 50: - if (EV_DoDoor(line,close)) P_ChangeSwitchTexture(line,0); break; - case 51: - P_ChangeSwitchTexture(line,0); G_SecretExitLevel (); break; - case 55: - if (EV_DoFloor(line,raiseFloorCrush)) P_ChangeSwitchTexture(line,0); break; - case 101: - if (EV_DoFloor(line,raiseFloor)) P_ChangeSwitchTexture(line,0); break; - case 102: - if (EV_DoFloor(line,lowerFloor)) P_ChangeSwitchTexture(line,0); break; - case 103: - if (EV_DoDoor(line,open)) P_ChangeSwitchTexture(line,0); break; - case 111: - if (EV_DoDoor (line,blazeRaise)) P_ChangeSwitchTexture(line,0); break; - case 112: - if (EV_DoDoor (line,blazeOpen)) P_ChangeSwitchTexture(line,0); break; - case 113: - if (EV_DoDoor (line,blazeClose)) P_ChangeSwitchTexture(line,0); break; - case 122: - if (EV_DoPlat(line,blazeDWUS,0)) P_ChangeSwitchTexture(line,0); break; - case 127: - if (EV_BuildStairs(line,turbo16)) P_ChangeSwitchTexture(line,0); break; - case 131: - if (EV_DoFloor(line,raiseFloorTurbo)) P_ChangeSwitchTexture(line,0); break; - case 133: - case 135: - case 137: - if (EV_DoLockedDoor (line,blazeOpen,thing)) P_ChangeSwitchTexture(line,0); break; - case 140: - if (EV_DoFloor(line,raiseFloor512)) P_ChangeSwitchTexture(line,0); break; - - case 42: - if (EV_DoDoor(line,close)) P_ChangeSwitchTexture(line,1); break; - case 43: - if (EV_DoCeiling(line,lowerToFloor)) P_ChangeSwitchTexture(line,1); break; - case 45: - if (EV_DoFloor(line,lowerFloor)) P_ChangeSwitchTexture(line,1); break; - case 60: - if (EV_DoFloor(line,lowerFloorToLowest)) P_ChangeSwitchTexture(line,1); break; - case 61: - if (EV_DoDoor(line,open)) P_ChangeSwitchTexture(line,1); break; - case 62: - if (EV_DoPlat(line,downWaitUpStay,1)) P_ChangeSwitchTexture(line,1); break; - case 63: - if (EV_DoDoor(line,normal)) P_ChangeSwitchTexture(line,1); break; - case 64: - if (EV_DoFloor(line,raiseFloor)) P_ChangeSwitchTexture(line,1); break; - case 66: - if (EV_DoPlat(line,raiseAndChange,24)) P_ChangeSwitchTexture(line,1); break; - case 67: - if (EV_DoPlat(line,raiseAndChange,32)) P_ChangeSwitchTexture(line,1); break; - case 65: - if (EV_DoFloor(line,raiseFloorCrush)) P_ChangeSwitchTexture(line,1); break; - case 68: - if (EV_DoPlat(line,raiseToNearestAndChange,0)) P_ChangeSwitchTexture(line,1); break; - case 69: - if (EV_DoFloor(line, raiseFloorToNearest)) P_ChangeSwitchTexture(line,1); break; - case 70: - if (EV_DoFloor(line,turboLower)) P_ChangeSwitchTexture(line,1); break; - case 114: - if (EV_DoDoor (line,blazeRaise)) P_ChangeSwitchTexture(line,1); break; - case 115: - if (EV_DoDoor (line,blazeOpen)) P_ChangeSwitchTexture(line,1); break; - case 116: - if (EV_DoDoor (line,blazeClose)) P_ChangeSwitchTexture(line,1); break; - case 123: - if (EV_DoPlat(line,blazeDWUS,0)) P_ChangeSwitchTexture(line,1); break; - case 132: - if (EV_DoFloor(line,raiseFloorTurbo)) P_ChangeSwitchTexture(line,1); break; - case 99: - case 134: - case 136: - if (EV_DoLockedDoor (line,blazeOpen,thing)) P_ChangeSwitchTexture(line,1); break; - case 138: - EV_LightTurnOn(line,255); P_ChangeSwitchTexture(line,1); break; - case 139: - EV_LightTurnOn(line,35); P_ChangeSwitchTexture(line,1); break; - } - return true; } - diff --git a/src/p_telept.c b/src/p_telept.c @@ -1,47 +1,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #include "doomdef.h" - #include "s_sound.h" - #include "p_local.h" - - - #include "sounds.h" - - #include "r_state.h" - - - - - - int EV_Teleport ( line_t* line, @@ -58,17 +19,10 @@ EV_Teleport fixed_t oldx; fixed_t oldy; fixed_t oldz; - - if (thing->flags & MF_MISSILE) return 0; - - - if (side == 1) return 0; - - tag = line->tag; for (i = 0; i < numsectors; i++) { @@ -79,46 +33,30 @@ EV_Teleport thinker != &thinkercap; thinker = thinker->next) { - if (thinker->function.acp1 != (actionf_p1)P_MobjThinker) continue; - m = (mobj_t *)thinker; - - if (m->type != MT_TELEPORTMAN ) continue; - sector = m->subsector->sector; - if (sector-sectors != i ) continue; - oldx = thing->x; oldy = thing->y; oldz = thing->z; - if (!P_TeleportMove (thing, m->x, m->y)) return 0; - thing->z = thing->floorz; if (thing->player) thing->player->viewz = thing->z+thing->player->viewheight; - - fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG); S_StartSound (fog, sfx_telept); an = m->angle >> ANGLETOFINESHIFT; fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an] , thing->z, MT_TFOG); - - S_StartSound (fog, sfx_telept); - - if (thing->player) thing->reactiontime = 18; - thing->angle = m->angle; thing->momx = thing->momy = thing->momz = 0; return 1; @@ -127,4 +65,3 @@ EV_Teleport } return 0; } - diff --git a/src/p_tick.c b/src/p_tick.c @@ -1,65 +1,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include "z_zone.h" #include "p_local.h" - #include "doomstat.h" - - int leveltime; - - - - - - - - - - - - thinker_t thinkercap; - - - - - void P_InitThinkers (void) { thinkercap.prev = thinkercap.next = &thinkercap; } - - - - - - - - void P_AddThinker (thinker_t* thinker) { thinkercap.prev->next = thinker; @@ -67,45 +14,21 @@ void P_AddThinker (thinker_t* thinker) thinker->prev = thinkercap.prev; thinkercap.prev = thinker; } - - - - - - - - void P_RemoveThinker (thinker_t* thinker) { - thinker->function.acv = (actionf_v)(-1); } - - - - - - - void P_AllocateThinker (thinker_t* thinker) { } - - - - - - void P_RunThinkers (void) { thinker_t* currentthinker; - currentthinker = thinkercap.next; while (currentthinker != &thinkercap) { if ( currentthinker->function.acv == (actionf_v)(-1) ) { - currentthinker->next->prev = currentthinker->prev; currentthinker->prev->next = currentthinker->next; Z_Free (currentthinker); @@ -118,22 +41,11 @@ void P_RunThinkers (void) currentthinker = currentthinker->next; } } - - - - - - - void P_Ticker (void) { int i; - - if (paused) return; - - if ( !netgame && menuactive && !demoplayback @@ -141,16 +53,11 @@ void P_Ticker (void) { return; } - - for (i=0 ; i<MAXPLAYERS ; i++) if (playeringame[i]) P_PlayerThink (&players[i]); - P_RunThinkers (); P_UpdateSpecials (); P_RespawnSpecials (); - - leveltime++; } diff --git a/src/p_tick.h b/src/p_tick.h @@ -1,44 +1,7 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __P_TICK__ #define __P_TICK__ - - #ifdef __GNUG__ #pragma interface #endif - - - - - void P_Ticker (void); - - - #endif - - - - - diff --git a/src/p_user.c b/src/p_user.c @@ -1,58 +1,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "doomdef.h" #include "d_event.h" - #include "p_local.h" - #include "doomstat.h" - - - - #define INVERSECOLORMAP 32 - - - - - - - #define MAXBOB 0x100000 - boolean onground; - - - - - - void P_Thrust ( player_t* player, @@ -60,71 +12,43 @@ P_Thrust fixed_t move ) { angle >>= ANGLETOFINESHIFT; - player->mo->momx += FixedMul(move,finecosine[angle]); player->mo->momy += FixedMul(move,finesine[angle]); } - - - - - - - - void P_CalcHeight (player_t* player) { int angle; fixed_t bob; - - - - - - - player->bob = FixedMul (player->mo->momx, player->mo->momx) + FixedMul (player->mo->momy,player->mo->momy); - player->bob >>= 2; - if (player->bob>MAXBOB) player->bob = MAXBOB; - if ((player->cheats & CF_NOMOMENTUM) || !onground) { player->viewz = player->mo->z + VIEWHEIGHT; - if (player->viewz > player->mo->ceilingz-4*FRACUNIT) player->viewz = player->mo->ceilingz-4*FRACUNIT; - player->viewz = player->mo->z + player->viewheight; return; } - angle = (FINEANGLES/20*leveltime)&FINEMASK; bob = FixedMul ( player->bob/2, finesine[angle]); - - - if (player->playerstate == PST_LIVE) { player->viewheight += player->deltaviewheight; - if (player->viewheight > VIEWHEIGHT) { player->viewheight = VIEWHEIGHT; player->deltaviewheight = 0; } - if (player->viewheight < VIEWHEIGHT/2) { player->viewheight = VIEWHEIGHT/2; if (player->deltaviewheight <= 0) player->deltaviewheight = 1; } - if (player->deltaviewheight) { player->deltaviewheight += FRACUNIT/4; @@ -133,83 +57,48 @@ void P_CalcHeight (player_t* player) } } player->viewz = player->mo->z + player->viewheight + bob; - if (player->viewz > player->mo->ceilingz-4*FRACUNIT) player->viewz = player->mo->ceilingz-4*FRACUNIT; } - - - - - - void P_MovePlayer (player_t* player) { ticcmd_t* cmd; - cmd = &player->cmd; - player->mo->angle += (cmd->angleturn<<16); - - - onground = (player->mo->z <= player->mo->floorz); - if (cmd->forwardmove && onground) P_Thrust (player, player->mo->angle, cmd->forwardmove*2048); - if (cmd->sidemove && onground) P_Thrust (player, player->mo->angle-ANG90, cmd->sidemove*2048); - if ( (cmd->forwardmove || cmd->sidemove) && player->mo->state == &states[S_PLAY] ) { P_SetMobjState (player->mo, S_PLAY_RUN1); } } - - - - - - - - #define ANG5 (ANG90/18) - void P_DeathThink (player_t* player) { angle_t angle; angle_t delta; - P_MovePsprites (player); - - if (player->viewheight > 6*FRACUNIT) player->viewheight -= FRACUNIT; - if (player->viewheight < 6*FRACUNIT) player->viewheight = 6*FRACUNIT; - player->deltaviewheight = 0; onground = (player->mo->z <= player->mo->floorz); P_CalcHeight (player); - if (player->attacker && player->attacker != player->mo) { angle = R_PointToAngle2 (player->mo->x, player->mo->y, player->attacker->x, player->attacker->y); - delta = angle - player->mo->angle; - if (delta < ANG5 || delta > (unsigned)-ANG5) { - - player->mo->angle = angle; - if (player->damagecount) player->damagecount--; } @@ -220,29 +109,17 @@ void P_DeathThink (player_t* player) } else if (player->damagecount) player->damagecount--; - - if (player->cmd.buttons & BT_USE) player->playerstate = PST_REBORN; } - - - - - - void P_PlayerThink (player_t* player) { ticcmd_t* cmd; weapontype_t newweapon; - - if (player->cheats & CF_NOCLIP) player->mo->flags |= MF_NOCLIP; else player->mo->flags &= ~MF_NOCLIP; - - cmd = &player->cmd; if (player->mo->flags & MF_JUSTATTACKED) { @@ -251,40 +128,23 @@ void P_PlayerThink (player_t* player) cmd->sidemove = 0; player->mo->flags &= ~MF_JUSTATTACKED; } - - if (player->playerstate == PST_DEAD) { P_DeathThink (player); return; } - - - - if (player->mo->reactiontime) player->mo->reactiontime--; else P_MovePlayer (player); - P_CalcHeight (player); - if (player->mo->subsector->sector->special) P_PlayerInSpecialSector (player); - - - - if (cmd->buttons & BT_SPECIAL) cmd->buttons = 0; - if (cmd->buttons & BT_CHANGE) { - - - newweapon = (cmd->buttons&BT_WEAPONMASK)>>BT_WEAPONSHIFT; - if (newweapon == wp_fist && player->weaponowned[wp_chainsaw] && !(player->readyweapon == wp_chainsaw @@ -292,7 +152,6 @@ void P_PlayerThink (player_t* player) { newweapon = wp_chainsaw; } - if ( (gamemode == commercial) && newweapon == wp_shotgun && player->weaponowned[wp_supershotgun] @@ -300,13 +159,9 @@ void P_PlayerThink (player_t* player) { newweapon = wp_supershotgun; } - - if (player->weaponowned[newweapon] && newweapon != player->readyweapon) { - - if ((newweapon != wp_plasma && newweapon != wp_bfg) || (gamemode != shareware) ) @@ -315,8 +170,6 @@ void P_PlayerThink (player_t* player) } } } - - if (cmd->buttons & BT_USE) { if (!player->usedown) @@ -327,37 +180,22 @@ void P_PlayerThink (player_t* player) } else player->usedown = false; - - P_MovePsprites (player); - - - - if (player->powers[pw_strength]) player->powers[pw_strength]++; - if (player->powers[pw_invulnerability]) player->powers[pw_invulnerability]--; - if (player->powers[pw_invisibility]) if (! --player->powers[pw_invisibility] ) player->mo->flags &= ~MF_SHADOW; - if (player->powers[pw_infrared]) player->powers[pw_infrared]--; - if (player->powers[pw_ironfeet]) player->powers[pw_ironfeet]--; - if (player->damagecount) player->damagecount--; - if (player->bonuscount) player->bonuscount--; - - - if (player->powers[pw_invulnerability]) { if (player->powers[pw_invulnerability] > 4*32 @@ -371,7 +209,6 @@ void P_PlayerThink (player_t* player) if (player->powers[pw_infrared] > 4*32 || (player->powers[pw_infrared]&8) ) { - player->fixedcolormap = 1; } else @@ -380,5 +217,3 @@ void P_PlayerThink (player_t* player) else player->fixedcolormap = 0; } - - diff --git a/src/r_bsp.c b/src/r_bsp.c @@ -1,103 +1,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #include "doomdef.h" - #include "m_bbox.h" - #include "i_system.h" - #include "r_main.h" #include "r_plane.h" #include "r_things.h" - - #include "doomstat.h" #include "r_state.h" - - - - - seg_t* curline; side_t* sidedef; line_t* linedef; sector_t* frontsector; sector_t* backsector; - drawseg_t drawsegs[MAXDRAWSEGS]; drawseg_t* ds_p; - - void R_StoreWallRange ( int start, int stop ); - - - - - - - void R_ClearDrawSegs (void) { ds_p = drawsegs; } - - - - - - - - typedef struct { int first; int last; - } cliprange_t; - - #define MAXSEGS 32 - - cliprange_t* newend; cliprange_t solidsegs[MAXSEGS]; - - - - - - - - - - void R_ClipSolidWallSegment ( int first, @@ -105,23 +36,16 @@ R_ClipSolidWallSegment { cliprange_t* next; cliprange_t* start; - - - start = solidsegs; while (start->last < first-1) start++; - if (first < start->first) { if (last < start->first-1) { - - R_StoreWallRange (first, last); next = newend; newend++; - while (next != start) { *next = *(next-1); @@ -131,115 +55,64 @@ R_ClipSolidWallSegment next->last = last; return; } - - R_StoreWallRange (first, start->first - 1); - start->first = first; } - - if (last <= start->last) return; - next = start; while (last >= (next+1)->first-1) { - R_StoreWallRange (next->last + 1, (next+1)->first - 1); next++; - if (last <= next->last) { - - start->last = next->last; goto crunch; } } - - R_StoreWallRange (next->last + 1, last); - start->last = last; - - - crunch: if (next == start) { - return; } - - while (next++ != newend) { - *++start = *next; } - newend = start+1; } - - - - - - - - - - void R_ClipPassWallSegment ( int first, int last ) { cliprange_t* start; - - - start = solidsegs; while (start->last < first-1) start++; - if (first < start->first) { if (last < start->first-1) { - R_StoreWallRange (first, last); return; } - - R_StoreWallRange (first, start->first - 1); } - - if (last <= start->last) return; - while (last >= (start+1)->first-1) { - R_StoreWallRange (start->last + 1, (start+1)->first - 1); start++; - if (last <= start->last) return; } - - R_StoreWallRange (start->last + 1, last); } - - - - - - void R_ClearClipSegs (void) { solidsegs[0].first = -0x7fffffff; @@ -248,12 +121,6 @@ void R_ClearClipSegs (void) solidsegs[1].last = 0x7fffffff; newend = solidsegs+2; } - - - - - - void R_AddLine (seg_t* line) { int x1; @@ -262,80 +129,46 @@ void R_AddLine (seg_t* line) angle_t angle2; angle_t span; angle_t tspan; - curline = line; - - angle1 = R_PointToAngle (line->v1->x, line->v1->y); angle2 = R_PointToAngle (line->v2->x, line->v2->y); - - - span = angle1 - angle2; - - if (span >= ANG180) return; - - rw_angle1 = angle1; angle1 -= viewangle; angle2 -= viewangle; - tspan = angle1 + clipangle; if (tspan > 2*clipangle) { tspan -= 2*clipangle; - - if (tspan >= span) return; - angle1 = clipangle; } tspan = clipangle - angle2; if (tspan > 2*clipangle) { tspan -= 2*clipangle; - - if (tspan >= span) return; angle2 = -clipangle; } - - - angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; x1 = viewangletox[angle1]; x2 = viewangletox[angle2]; - - if (x1 == x2) return; - backsector = line->backsector; - - if (!backsector) goto clipsolid; - - if (backsector->ceilingheight <= frontsector->floorheight || backsector->floorheight >= frontsector->ceilingheight) goto clipsolid; - - if (backsector->ceilingheight != frontsector->ceilingheight || backsector->floorheight != frontsector->floorheight) goto clippass; - - - - - - if (backsector->ceilingpic == frontsector->ceilingpic && backsector->floorpic == frontsector->floorpic && backsector->lightlevel == frontsector->lightlevel @@ -343,23 +176,12 @@ void R_AddLine (seg_t* line) { return; } - - clippass: R_ClipPassWallSegment (x1, x2-1); return; - clipsolid: R_ClipSolidWallSegment (x1, x2-1); } - - - - - - - - int checkcoord[12][4] = { {3,0,2,1}, @@ -374,143 +196,95 @@ int checkcoord[12][4] = {2,1,3,1}, {2,1,3,0} }; - - boolean R_CheckBBox (fixed_t* bspcoord) { int boxx; int boxy; int boxpos; - fixed_t x1; fixed_t y1; fixed_t x2; fixed_t y2; - angle_t angle1; angle_t angle2; angle_t span; angle_t tspan; - cliprange_t* start; - int sx1; int sx2; - - - if (viewx <= bspcoord[BOXLEFT]) boxx = 0; else if (viewx < bspcoord[BOXRIGHT]) boxx = 1; else boxx = 2; - if (viewy >= bspcoord[BOXTOP]) boxy = 0; else if (viewy > bspcoord[BOXBOTTOM]) boxy = 1; else boxy = 2; - boxpos = (boxy<<2)+boxx; if (boxpos == 5) return true; - x1 = bspcoord[checkcoord[boxpos][0]]; y1 = bspcoord[checkcoord[boxpos][1]]; x2 = bspcoord[checkcoord[boxpos][2]]; y2 = bspcoord[checkcoord[boxpos][3]]; - - angle1 = R_PointToAngle (x1, y1) - viewangle; angle2 = R_PointToAngle (x2, y2) - viewangle; - span = angle1 - angle2; - - if (span >= ANG180) return true; - tspan = angle1 + clipangle; - if (tspan > 2*clipangle) { tspan -= 2*clipangle; - - if (tspan >= span) return false; - angle1 = clipangle; } tspan = clipangle - angle2; if (tspan > 2*clipangle) { tspan -= 2*clipangle; - - if (tspan >= span) return false; - angle2 = -clipangle; } - - - - - angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; sx1 = viewangletox[angle1]; sx2 = viewangletox[angle2]; - - if (sx1 == sx2) return false; sx2--; - start = solidsegs; while (start->last < sx2) start++; - if (sx1 >= start->first && sx2 <= start->last) { - return false; } - return true; } - - - - - - - - - void R_Subsector (int num) { int count; seg_t* line; subsector_t* sub; - #ifdef RANGECHECK if (num>=numsubsectors) I_Error ("R_Subsector: ss %i with numss = %i", num, numsubsectors); #endif - sscount++; sub = &subsectors[num]; frontsector = sub->sector; count = sub->numlines; line = &segs[sub->firstline]; - if (frontsector->floorheight < viewz) { floorplane = R_FindPlane (frontsector->floorheight, @@ -519,7 +293,6 @@ void R_Subsector (int num) } else floorplane = NULL; - if (frontsector->ceilingheight > viewz || frontsector->ceilingpic == skyflatnum) { @@ -529,30 +302,17 @@ void R_Subsector (int num) } else ceilingplane = NULL; - R_AddSprites (frontsector); - while (count--) { R_AddLine (line); line++; } } - - - - - - - - - void R_RenderBSPNode (int bspnum) { node_t* bsp; int side; - - if (bspnum & NF_SUBSECTOR) { if (bspnum == -1) @@ -561,18 +321,9 @@ void R_RenderBSPNode (int bspnum) R_Subsector (bspnum&(~NF_SUBSECTOR)); return; } - bsp = &nodes[bspnum]; - - side = R_PointOnSide (viewx, viewy, bsp); - - R_RenderBSPNode (bsp->children[side]); - - if (R_CheckBBox (bsp->bbox[side^1])) R_RenderBSPNode (bsp->children[side^1]); } - - diff --git a/src/r_bsp.h b/src/r_bsp.h @@ -1,72 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_BSP__ #define __R_BSP__ - #ifdef __GNUG__ #pragma interface #endif - - extern seg_t* curline; extern side_t* sidedef; extern line_t* linedef; extern sector_t* frontsector; extern sector_t* backsector; - extern int rw_x; extern int rw_stopx; - extern boolean segtextured; - - extern boolean markfloor; extern boolean markceiling; - extern boolean skymap; - extern drawseg_t drawsegs[MAXDRAWSEGS]; extern drawseg_t* ds_p; - extern lighttable_t** hscalelight; extern lighttable_t** vscalelight; extern lighttable_t** dscalelight; - - typedef void (*drawfunc_t) (int start, int stop); - - - void R_ClearClipSegs (void); void R_ClearDrawSegs (void); - - void R_RenderBSPNode (int bspnum); - - #endif - - - - - diff --git a/src/r_data.c b/src/r_data.c @@ -1,69 +1,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "i_system.h" #include "z_zone.h" - #include "m_swap.h" - #include "w_wad.h" - #include "doomdef.h" #include "r_local.h" #include "p_local.h" - #include "doomstat.h" #include "r_sky.h" - #ifdef LINUX #include <alloca.h> #endif - - #include "r_data.h" - - - - - - - - - - - - - - - - - - - typedef struct { short originx; @@ -72,13 +19,6 @@ typedef struct short stepdir; short colormap; } mappatch_t; - - - - - - - typedef struct { char name[8]; @@ -89,96 +29,43 @@ typedef struct short patchcount; mappatch_t patches[1]; } maptexture_t; - - - - - typedef struct { - - - int originx; int originy; int patch; } texpatch_t; - - - - - typedef struct { - char name[8]; short width; short height; - - - short patchcount; texpatch_t patches[1]; - } texture_t; - - - int firstflat; int lastflat; int numflats; - int firstpatch; int lastpatch; int numpatches; - int firstspritelump; int lastspritelump; int numspritelumps; - int numtextures; texture_t** textures; - - int* texturewidthmask; - fixed_t* textureheight; int* texturecompositesize; short** texturecolumnlump; unsigned short** texturecolumnofs; byte** texturecomposite; - - int* flattranslation; int* texturetranslation; - - fixed_t* spritewidth; fixed_t* spriteoffset; fixed_t* spritetopoffset; - lighttable_t *colormaps; - - - - - - - - - - - - - - - - - - - - - void R_DrawColumnInCache ( column_t* patch, @@ -190,39 +77,24 @@ R_DrawColumnInCache int position; byte* source; byte* dest; - dest = (byte *)cache + 3; - while (patch->topdelta != 0xff) { source = (byte *)patch + 3; count = patch->length; position = originy + patch->topdelta; - if (position < 0) { count += position; position = 0; } - if (position + count > cacheheight) count = cacheheight - position; - if (count > 0) memcpy (cache + position, source, count); - patch = (column_t *)( (byte *)patch + patch->length + 4); } } - - - - - - - - - void R_GenerateComposite (int texnum) { byte* block; @@ -236,19 +108,13 @@ void R_GenerateComposite (int texnum) column_t* patchcol; short* collump; unsigned short* colofs; - texture = textures[texnum]; - block = Z_Malloc (texturecompositesize[texnum], PU_STATIC, &texturecomposite[texnum]); - collump = texturecolumnlump[texnum]; colofs = texturecolumnofs[texnum]; - - patch = texture->patches; - for (i=0 , patch = texture->patches; i<texture->patchcount; i++, patch++) @@ -256,21 +122,16 @@ void R_GenerateComposite (int texnum) realpatch = W_CacheLumpNum (patch->patch, PU_CACHE); x1 = patch->originx; x2 = x1 + SHORT(realpatch->width); - if (x1<0) x = 0; else x = x1; - if (x2 > texture->width) x2 = texture->width; - for ( ; x<x2 ; x++) { - if (collump[x] >= 0) continue; - patchcol = (column_t *)((byte *)realpatch + LONG(realpatch->columnofs[x-x1])); R_DrawColumnInCache (patchcol, @@ -278,19 +139,9 @@ void R_GenerateComposite (int texnum) patch->originy, texture->height); } - } - - - Z_ChangeTag (block, PU_CACHE); } - - - - - - void R_GenerateLookup (int texnum) { texture_t* texture; @@ -303,24 +154,14 @@ void R_GenerateLookup (int texnum) int i; short* collump; unsigned short* colofs; - texture = textures[texnum]; - - texturecomposite[texnum] = 0; - texturecompositesize[texnum] = 0; collump = texturecolumnlump[texnum]; colofs = texturecolumnofs[texnum]; - - - - - patchcount = (byte *)alloca (texture->width); memset (patchcount, 0, texture->width); patch = texture->patches; - for (i=0 , patch = texture->patches; i<texture->patchcount; i++, patch++) @@ -328,12 +169,10 @@ void R_GenerateLookup (int texnum) realpatch = W_CacheLumpNum (patch->patch, PU_CACHE); x1 = patch->originx; x2 = x1 + SHORT(realpatch->width); - if (x1 < 0) x = 0; else x = x1; - if (x2 > texture->width) x2 = texture->width; for ( ; x<x2 ; x++) @@ -343,7 +182,6 @@ void R_GenerateLookup (int texnum) colofs[x] = LONG(realpatch->columnofs[x-x1])+3; } } - for (x=0 ; x<texture->width ; x++) { if (!patchcount[x]) @@ -352,31 +190,19 @@ void R_GenerateLookup (int texnum) texture->name); return; } - - if (patchcount[x] > 1) { - collump[x] = -1; colofs[x] = texturecompositesize[texnum]; - if (texturecompositesize[texnum] > 0x10000-texture->height) { I_Error ("R_GenerateLookup: texture %i is >64k", texnum); } - texturecompositesize[texnum] += texture->height; } } } - - - - - - - byte* R_GetColumn ( int tex, @@ -384,48 +210,30 @@ R_GetColumn { int lump; int ofs; - col &= texturewidthmask[tex]; lump = texturecolumnlump[tex][col]; ofs = texturecolumnofs[tex][col]; - if (lump > 0) return (byte *)W_CacheLumpNum(lump,PU_CACHE)+ofs; - if (!texturecomposite[tex]) R_GenerateComposite (tex); - return texturecomposite[tex] + ofs; } - - - - - - - - - void R_InitTextures (void) { maptexture_t* mtexture; texture_t* texture; mappatch_t* mpatch; texpatch_t* patch; - int i; int j; - int* maptex; int* maptex2; int* maptex1; - char name[9]; char* names; char* name_p; - int* patchlookup; - int totalwidth; int nummappatches; int offset; @@ -433,36 +241,25 @@ void R_InitTextures (void) int maxoff2; int numtextures1; int numtextures2; - int* directory; - int temp1; int temp2; int temp3; - - - name[8] = 0; names = W_CacheLumpName ("PNAMES", PU_STATIC); nummappatches = LONG ( *((int *)names) ); name_p = names+4; patchlookup = alloca (nummappatches*sizeof(*patchlookup)); - for (i=0 ; i<nummappatches ; i++) { strncpy (name,name_p+i*8, 8); patchlookup[i] = W_CheckNumForName (name); } Z_Free (names); - - - - maptex = maptex1 = W_CacheLumpName ("TEXTURE1", PU_STATIC); numtextures1 = LONG(*maptex); maxoff = W_LumpLength (W_GetNumForName ("TEXTURE1")); directory = maptex+1; - if (W_CheckNumForName ("TEXTURE2") != -1) { maptex2 = W_CacheLumpName ("TEXTURE2", PU_STATIC); @@ -476,7 +273,6 @@ void R_InitTextures (void) maxoff2 = 0; } numtextures = numtextures1 + numtextures2; - textures = Z_Malloc (numtextures*4, PU_STATIC, 0); texturecolumnlump = Z_Malloc (numtextures*4, PU_STATIC, 0); texturecolumnofs = Z_Malloc (numtextures*4, PU_STATIC, 0); @@ -484,10 +280,7 @@ void R_InitTextures (void) texturecompositesize = Z_Malloc (numtextures*4, PU_STATIC, 0); texturewidthmask = Z_Malloc (numtextures*4, PU_STATIC, 0); textureheight = Z_Malloc (numtextures*4, PU_STATIC, 0); - totalwidth = 0; - - temp1 = W_GetNumForName ("S_START"); temp2 = W_GetNumForName ("S_END") - 1; temp3 = ((temp2-temp1+63)/64) + ((numtextures+63)/64); @@ -498,40 +291,30 @@ void R_InitTextures (void) for (i = 0; i < temp3; i++) printf("\x8"); printf("\x8\x8\x8\x8\x8\x8\x8\x8\x8\x8"); - for (i=0 ; i<numtextures ; i++, directory++) { if (!(i&63)) printf ("."); - if (i == numtextures1) { - maptex = maptex2; maxoff = maxoff2; directory = maptex+1; } - offset = LONG(*directory); - if (offset > maxoff) I_Error ("R_InitTextures: bad texture directory"); - mtexture = (maptexture_t *) ( (byte *)maptex + offset); - texture = textures[i] = Z_Malloc (sizeof(texture_t) + sizeof(texpatch_t)*(SHORT(mtexture->patchcount)-1), PU_STATIC, 0); - texture->width = SHORT(mtexture->width); texture->height = SHORT(mtexture->height); texture->patchcount = SHORT(mtexture->patchcount); - memcpy (texture->name, mtexture->name, sizeof(texture->name)); mpatch = &mtexture->patches[0]; patch = &texture->patches[0]; - for (j=0 ; j<texture->patchcount ; j++, mpatch++, patch++) { patch->originx = SHORT(mpatch->originx); @@ -545,110 +328,61 @@ void R_InitTextures (void) } texturecolumnlump[i] = Z_Malloc (texture->width*2, PU_STATIC,0); texturecolumnofs[i] = Z_Malloc (texture->width*2, PU_STATIC,0); - j = 1; while (j*2 <= texture->width) j<<=1; - texturewidthmask[i] = j-1; textureheight[i] = texture->height<<FRACBITS; - totalwidth += texture->width; } - Z_Free (maptex1); if (maptex2) Z_Free (maptex2); - - for (i=0 ; i<numtextures ; i++) R_GenerateLookup (i); - - texturetranslation = Z_Malloc ((numtextures+1)*4, PU_STATIC, 0); - for (i=0 ; i<numtextures ; i++) texturetranslation[i] = i; } - - - - - - void R_InitFlats (void) { int i; - firstflat = W_GetNumForName ("F_START") + 1; lastflat = W_GetNumForName ("F_END") - 1; numflats = lastflat - firstflat + 1; - - flattranslation = Z_Malloc ((numflats+1)*4, PU_STATIC, 0); - for (i=0 ; i<numflats ; i++) flattranslation[i] = i; } - - - - - - - - void R_InitSpriteLumps (void) { int i; patch_t *patch; - firstspritelump = W_GetNumForName ("S_START") + 1; lastspritelump = W_GetNumForName ("S_END") - 1; - numspritelumps = lastspritelump - firstspritelump + 1; spritewidth = Z_Malloc (numspritelumps*4, PU_STATIC, 0); spriteoffset = Z_Malloc (numspritelumps*4, PU_STATIC, 0); spritetopoffset = Z_Malloc (numspritelumps*4, PU_STATIC, 0); - for (i=0 ; i< numspritelumps ; i++) { if (!(i&63)) printf ("."); - patch = W_CacheLumpNum (firstspritelump+i, PU_CACHE); spritewidth[i] = SHORT(patch->width)<<FRACBITS; spriteoffset[i] = SHORT(patch->leftoffset)<<FRACBITS; spritetopoffset[i] = SHORT(patch->topoffset)<<FRACBITS; } } - - - - - - void R_InitColormaps (void) { int lump, length; - - - lump = W_GetNumForName("COLORMAP"); length = W_LumpLength (lump) + 255; colormaps = Z_Malloc (length, PU_STATIC, 0); colormaps = (byte *)( ((int)colormaps + 255)&~0xff); W_ReadLump (lump,colormaps); } - - - - - - - - - void R_InitData (void) { R_InitTextures (); @@ -660,20 +394,11 @@ void R_InitData (void) R_InitColormaps (); printf ("\nInitColormaps"); } - - - - - - - int R_FlatNumForName (char* name) { int i; char namet[9]; - i = W_CheckNumForName (name); - if (i == -1) { namet[8] = 0; @@ -682,43 +407,20 @@ int R_FlatNumForName (char* name) } return i - firstflat; } - - - - - - - - - int R_CheckTextureNumForName (char *name) { int i; - - if (name[0] == '-') return 0; - for (i=0 ; i<numtextures ; i++) if (!strncasecmp (textures[i]->name, name, 8) ) return i; - return -1; } - - - - - - - - int R_TextureNumForName (char* name) { int i; - i = R_CheckTextureNumForName (name); - if (i==-1) { I_Error ("R_TextureNumForName: %s not found", @@ -726,48 +428,31 @@ int R_TextureNumForName (char* name) } return i; } - - - - - - - - int flatmemory; int texturememory; int spritememory; - void R_PrecacheLevel (void) { char* flatpresent; char* texturepresent; char* spritepresent; - int i; int j; int k; int lump; - texture_t* texture; thinker_t* th; spriteframe_t* sf; - if (demoplayback) return; - - flatpresent = alloca(numflats); memset (flatpresent,0,numflats); - for (i=0 ; i<numsectors ; i++) { flatpresent[sectors[i].floorpic] = 1; flatpresent[sectors[i].ceilingpic] = 1; } - flatmemory = 0; - for (i=0 ; i<numflats ; i++) { if (flatpresent[i]) @@ -777,34 +462,21 @@ void R_PrecacheLevel (void) W_CacheLumpNum(lump, PU_CACHE); } } - - texturepresent = alloca(numtextures); memset (texturepresent,0, numtextures); - for (i=0 ; i<numsides ; i++) { texturepresent[sides[i].toptexture] = 1; texturepresent[sides[i].midtexture] = 1; texturepresent[sides[i].bottomtexture] = 1; } - - - - - - - texturepresent[skytexture] = 1; - texturememory = 0; for (i=0 ; i<numtextures ; i++) { if (!texturepresent[i]) continue; - texture = textures[i]; - for (j=0 ; j<texture->patchcount ; j++) { lump = texture->patches[j].patch; @@ -812,23 +484,18 @@ void R_PrecacheLevel (void) W_CacheLumpNum(lump , PU_CACHE); } } - - spritepresent = alloca(numsprites); memset (spritepresent,0, numsprites); - for (th = thinkercap.next ; th != &thinkercap ; th=th->next) { if (th->function.acp1 == (actionf_p1)P_MobjThinker) spritepresent[((mobj_t *)th)->sprite] = 1; } - spritememory = 0; for (i=0 ; i<numsprites ; i++) { if (!spritepresent[i]) continue; - for (j=0 ; j<sprites[i].numframes ; j++) { sf = &sprites[i].spriteframes[j]; @@ -841,7 +508,3 @@ void R_PrecacheLevel (void) } } } - - - - diff --git a/src/r_data.h b/src/r_data.h @@ -1,62 +1,17 @@ - - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_DATA__ #define __R_DATA__ - #include "r_defs.h" #include "r_state.h" - #ifdef __GNUG__ #pragma interface #endif - - byte* R_GetColumn ( int tex, int col ); - - - void R_InitData (void); void R_PrecacheLevel (void); - - - - - int R_FlatNumForName (char* name); - - - - int R_TextureNumForName (char *name); int R_CheckTextureNumForName (char *name); - #endif - - - - - diff --git a/src/r_defs.h b/src/r_defs.h @@ -1,103 +1,30 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_DEFS__ #define __R_DEFS__ - - - #include "doomdef.h" - - - #include "m_fixed.h" - - - #include "d_think.h" - #include "p_mobj.h" - - - #ifdef __GNUG__ #pragma interface #endif - - - - - #define SIL_NONE 0 #define SIL_BOTTOM 1 #define SIL_TOP 2 #define SIL_BOTH 3 - #define MAXDRAWSEGS 256 - - - - - - - - - - - - - - - typedef struct { fixed_t x; fixed_t y; - } vertex_t; - - - struct line_s; - - - - - - - typedef struct { thinker_t thinker; fixed_t x; fixed_t y; fixed_t z; - } degenmobj_t; - - - - - typedef struct { fixed_t floorheight; @@ -107,252 +34,97 @@ typedef struct short lightlevel; short special; short tag; - - int soundtraversed; - - mobj_t* soundtarget; - - int blockbox[4]; - - degenmobj_t soundorg; - - int validcount; - - mobj_t* thinglist; - - void* specialdata; - int linecount; struct line_s** lines; - } sector_t; - - - - - - - - typedef struct { - fixed_t textureoffset; - - fixed_t rowoffset; - - - short toptexture; short bottomtexture; short midtexture; - - sector_t* sector; - } side_t; - - - - - - typedef enum { ST_HORIZONTAL, ST_VERTICAL, ST_POSITIVE, ST_NEGATIVE - } slopetype_t; - - - typedef struct line_s { - vertex_t* v1; vertex_t* v2; - - fixed_t dx; fixed_t dy; - - short flags; short special; short tag; - - - short sidenum[2]; - - - fixed_t bbox[4]; - - slopetype_t slopetype; - - - sector_t* frontsector; sector_t* backsector; - - int validcount; - - void* specialdata; } line_t; - - - - - - - - - - - typedef struct subsector_s { sector_t* sector; short numlines; short firstline; - } subsector_t; - - - - - - typedef struct { vertex_t* v1; vertex_t* v2; - fixed_t offset; - angle_t angle; - side_t* sidedef; line_t* linedef; - - - - sector_t* frontsector; sector_t* backsector; - } seg_t; - - - - - - typedef struct { - fixed_t x; fixed_t y; fixed_t dx; fixed_t dy; - - fixed_t bbox[2][4]; - - unsigned short children[2]; - } node_t; - - - - - typedef struct { byte topdelta; byte length; } post_t; - - typedef post_t column_t; - - - - - - - - - - - - - - - - - - - - - typedef byte lighttable_t; - - - - - - - typedef struct drawseg_s { seg_t* curline; int x1; int x2; - fixed_t scale1; fixed_t scale2; fixed_t scalestep; - - int silhouette; - - fixed_t bsilheight; - - fixed_t tsilheight; - - - short* sprtopclip; short* sprbottomclip; short* maskedtexturecol; - } drawseg_t; - - - - - - - - typedef struct { short width; @@ -360,103 +132,36 @@ typedef struct short leftoffset; short topoffset; int columnofs[8]; - } patch_t; - - - - - - - - - - typedef struct vissprite_s { - struct vissprite_s* prev; struct vissprite_s* next; - int x1; int x2; - - fixed_t gx; fixed_t gy; - - fixed_t gz; fixed_t gzt; - - fixed_t startfrac; - fixed_t scale; - - fixed_t xiscale; - fixed_t texturemid; int patch; - - - lighttable_t* colormap; - int mobjflags; - } vissprite_t; - - - - - - - - - - - - - - - - - typedef struct { - - - boolean rotate; - - short lump[8]; - - byte flip[8]; - } spriteframe_t; - - - - - - - typedef struct { int numframes; spriteframe_t* spriteframes; - } spritedef_t; - - - - - - typedef struct { fixed_t height; @@ -464,27 +169,11 @@ typedef struct int lightlevel; int minx; int maxx; - - - byte pad1; - - byte top[SCREENWIDTH]; byte pad2; byte pad3; - byte bottom[SCREENWIDTH]; byte pad4; - } visplane_t; - - - - #endif - - - - - diff --git a/src/r_draw.c b/src/r_draw.c @@ -1,63 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "doomdef.h" - #include "i_system.h" #include "z_zone.h" #include "w_wad.h" - #include "r_local.h" - - #include "v_video.h" - - #include "doomstat.h" - - - #define MAXWIDTH 1120 #define MAXHEIGHT 832 - - #define SBARHEIGHT 32 - - - - - - - - - - - byte* viewimage; int viewwidth; int scaledviewwidth; @@ -66,89 +16,40 @@ int viewwindowx; int viewwindowy; byte* ylookup[MAXHEIGHT]; int columnofs[MAXWIDTH]; - - - - - byte translations[3][256]; - - - - - - - - lighttable_t* dc_colormap; int dc_x; int dc_yl; int dc_yh; fixed_t dc_iscale; fixed_t dc_texturemid; - - byte* dc_source; - - int dccount; - - - - - - - - void R_DrawColumn (void) { int count; byte* dest; fixed_t frac; fixed_t fracstep; - count = dc_yh - dc_yl; - - if (count < 0) return; - #ifdef RANGECHECK if ((unsigned)dc_x >= SCREENWIDTH || dc_yl < 0 || dc_yh >= SCREENHEIGHT) I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x); #endif - - - - dest = ylookup[dc_yl] + columnofs[dc_x]; - - - fracstep = dc_iscale; frac = dc_texturemid + (dc_yl-centery)*fracstep; - - - - do { - - *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; - dest += SCREENWIDTH; frac += fracstep; - } while (count--); } - - - - - #if 0 void R_DrawColumn (void) { @@ -156,45 +57,35 @@ void R_DrawColumn (void) byte* source; byte* dest; byte* colormap; - unsigned frac; unsigned fracstep; unsigned fracstep2; unsigned fracstep3; unsigned fracstep4; - count = dc_yh - dc_yl + 1; - source = dc_source; colormap = dc_colormap; dest = ylookup[dc_yl] + columnofs[dc_x]; - fracstep = dc_iscale<<9; frac = (dc_texturemid + (dc_yl-centery)*dc_iscale)<<9; - fracstep2 = fracstep+fracstep; fracstep3 = fracstep2+fracstep; fracstep4 = fracstep3+fracstep; - while (count >= 8) { dest[0] = colormap[source[frac>>25]]; dest[SCREENWIDTH] = colormap[source[(frac+fracstep)>>25]]; dest[SCREENWIDTH*2] = colormap[source[(frac+fracstep2)>>25]]; dest[SCREENWIDTH*3] = colormap[source[(frac+fracstep3)>>25]]; - frac += fracstep4; - dest[SCREENWIDTH*4] = colormap[source[frac>>25]]; dest[SCREENWIDTH*5] = colormap[source[(frac+fracstep)>>25]]; dest[SCREENWIDTH*6] = colormap[source[(frac+fracstep2)>>25]]; dest[SCREENWIDTH*7] = colormap[source[(frac+fracstep3)>>25]]; - frac += fracstep4; dest += SCREENWIDTH*8; count -= 8; } - while (count > 0) { *dest = colormap[source[frac>>25]]; @@ -204,8 +95,6 @@ void R_DrawColumn (void) } } #endif - - void R_DrawColumnLow (void) { int count; @@ -213,51 +102,32 @@ void R_DrawColumnLow (void) byte* dest2; fixed_t frac; fixed_t fracstep; - count = dc_yh - dc_yl; - - if (count < 0) return; - #ifdef RANGECHECK if ((unsigned)dc_x >= SCREENWIDTH || dc_yl < 0 || dc_yh >= SCREENHEIGHT) { - I_Error ("R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x); } - #endif - dc_x <<= 1; - dest = ylookup[dc_yl] + columnofs[dc_x]; dest2 = ylookup[dc_yl] + columnofs[dc_x+1]; - fracstep = dc_iscale; frac = dc_texturemid + (dc_yl-centery)*fracstep; - do { - *dest2 = *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; dest += SCREENWIDTH; dest2 += SCREENWIDTH; frac += fracstep; - } while (count--); } - - - - - #define FUZZTABLE 50 #define FUZZOFF (SCREENWIDTH) - - int fuzzoffset[FUZZTABLE] = { FUZZOFF,-FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF, @@ -268,40 +138,20 @@ int fuzzoffset[FUZZTABLE] = FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF, FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF,FUZZOFF,-FUZZOFF,FUZZOFF }; - int fuzzpos = 0; - - - - - - - - - - void R_DrawFuzzColumn (void) { int count; byte* dest; fixed_t frac; fixed_t fracstep; - - if (!dc_yl) dc_yl = 1; - - if (dc_yh == viewheight-1) dc_yh = viewheight - 2; - count = dc_yh - dc_yl; - - if (count < 0) return; - - #ifdef RANGECHECK if ((unsigned)dc_x >= SCREENWIDTH || dc_yl < 0 || dc_yh >= SCREENHEIGHT) @@ -310,10 +160,6 @@ void R_DrawFuzzColumn (void) dc_yl, dc_yh, dc_x); } #endif - - - - /* WATCOM code if (detailshift) { @@ -335,62 +181,29 @@ void R_DrawFuzzColumn (void) outp (SC_INDEX+1,1<<(dc_x&3)); dest = destview + dc_yl*80 + (dc_x>>2); }*/ - - - dest = ylookup[dc_yl] + columnofs[dc_x]; - - fracstep = dc_iscale; frac = dc_texturemid + (dc_yl-centery)*fracstep; - - - - do { - - - - *dest = colormaps[6*256+dest[fuzzoffset[fuzzpos]]]; - - if (++fuzzpos == FUZZTABLE) fuzzpos = 0; - dest += SCREENWIDTH; - frac += fracstep; } while (count--); } - - - - - - - - - - - - - byte* dc_translation; byte* translationtables; - void R_DrawTranslatedColumn (void) { int count; byte* dest; fixed_t frac; fixed_t fracstep; - count = dc_yh - dc_yl; if (count < 0) return; - #ifdef RANGECHECK if ((unsigned)dc_x >= SCREENWIDTH || dc_yl < 0 @@ -399,11 +212,7 @@ void R_DrawTranslatedColumn (void) I_Error ( "R_DrawColumn: %i to %i at %i", dc_yl, dc_yh, dc_x); } - #endif - - - /* Keep for fixing. if (detailshift) { @@ -411,110 +220,53 @@ void R_DrawTranslatedColumn (void) outp (SC_INDEX+1,12); else outp (SC_INDEX+1,3); - dest = destview + dc_yl*80 + (dc_x>>1); } else { outp (SC_INDEX+1,1<<(dc_x&3)); - dest = destview + dc_yl*80 + (dc_x>>2); }*/ - - - dest = ylookup[dc_yl] + columnofs[dc_x]; - - fracstep = dc_iscale; frac = dc_texturemid + (dc_yl-centery)*fracstep; - - do { - - - - - *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; dest += SCREENWIDTH; - frac += fracstep; } while (count--); } - - - - - - - - - - - void R_InitTranslationTables (void) { int i; - translationtables = Z_Malloc (256*3+255, PU_STATIC, 0); translationtables = (byte *)(( (int)translationtables + 255 )& ~255); - - for (i=0 ; i<256 ; i++) { if (i >= 0x70 && i<= 0x7f) { - translationtables[i] = 0x60 + (i&0xf); translationtables [i+256] = 0x40 + (i&0xf); translationtables [i+512] = 0x20 + (i&0xf); } else { - translationtables[i] = translationtables[i+256] = translationtables[i+512] = i; } } } - - - - - - - - - - - - - - - - int ds_y; int ds_x1; int ds_x2; - lighttable_t* ds_colormap; - fixed_t ds_xfrac; fixed_t ds_yfrac; fixed_t ds_xstep; fixed_t ds_ystep; - - byte* ds_source; - - int dscount; - - - - void R_DrawSpan (void) { fixed_t xfrac; @@ -522,7 +274,6 @@ void R_DrawSpan (void) byte* dest; int count; int spot; - #ifdef RANGECHECK if (ds_x2 < ds_x1 || ds_x1<0 @@ -532,62 +283,38 @@ void R_DrawSpan (void) I_Error( "R_DrawSpan: %i to %i at %i", ds_x1,ds_x2,ds_y); } - #endif - - xfrac = ds_xfrac; yfrac = ds_yfrac; - dest = ylookup[ds_y] + columnofs[ds_x1]; - - count = ds_x2 - ds_x1; - do { - spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63); - - - *dest++ = ds_colormap[ds_source[spot]]; - - xfrac += ds_xstep; yfrac += ds_ystep; - } while (count--); } - - - - - #if 0 void R_DrawSpan (void) { unsigned position, step; - byte* source; byte* colormap; byte* dest; - unsigned count; usingned spot; unsigned value; unsigned temp; unsigned xtemp; unsigned ytemp; - position = ((ds_xfrac<<10)&0xffff0000) | ((ds_yfrac>>6)&0xffff); step = ((ds_xstep<<10)&0xffff0000) | ((ds_ystep>>6)&0xffff); - source = ds_source; colormap = ds_colormap; dest = ylookup[ds_y] + columnofs[ds_x1]; count = ds_x2 - ds_x1 + 1; - while (count >= 4) { ytemp = position>>4; @@ -596,28 +323,24 @@ void R_DrawSpan (void) spot = xtemp | ytemp; position += step; dest[0] = colormap[source[spot]]; - ytemp = position>>4; ytemp = ytemp & 4032; xtemp = position>>26; spot = xtemp | ytemp; position += step; dest[1] = colormap[source[spot]]; - ytemp = position>>4; ytemp = ytemp & 4032; xtemp = position>>26; spot = xtemp | ytemp; position += step; dest[2] = colormap[source[spot]]; - ytemp = position>>4; ytemp = ytemp & 4032; xtemp = position>>26; spot = xtemp | ytemp; position += step; dest[3] = colormap[source[spot]]; - count -= 4; dest += 4; } @@ -633,11 +356,6 @@ void R_DrawSpan (void) } } #endif - - - - - void R_DrawSpanLow (void) { fixed_t xfrac; @@ -645,7 +363,6 @@ void R_DrawSpanLow (void) byte* dest; int count; int spot; - #ifdef RANGECHECK if (ds_x2 < ds_x1 || ds_x1<0 @@ -655,77 +372,38 @@ void R_DrawSpanLow (void) I_Error( "R_DrawSpan: %i to %i at %i", ds_x1,ds_x2,ds_y); } - #endif - xfrac = ds_xfrac; yfrac = ds_yfrac; - - ds_x1 <<= 1; ds_x2 <<= 1; - dest = ylookup[ds_y] + columnofs[ds_x1]; - - count = ds_x2 - ds_x1; do { spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63); - - *dest++ = ds_colormap[ds_source[spot]]; *dest++ = ds_colormap[ds_source[spot]]; - xfrac += ds_xstep; yfrac += ds_ystep; - } while (count--); } - - - - - - - - void R_InitBuffer ( int width, int height ) { int i; - - - - viewwindowx = (SCREENWIDTH-width) >> 1; - - for (i=0 ; i<width ; i++) columnofs[i] = viewwindowx + i; - - if (width == SCREENWIDTH) viewwindowy = 0; else viewwindowy = (SCREENHEIGHT-SBARHEIGHT-height) >> 1; - - for (i=0 ; i<height ; i++) ylookup[i] = screens[0] + (i+viewwindowy)*SCREENWIDTH; } - - - - - - - - - - void R_FillBackScreen (void) { byte* src; @@ -733,26 +411,17 @@ void R_FillBackScreen (void) int x; int y; patch_t* patch; - - char name1[] = "FLOOR7_2"; - - char name2[] = "GRNROCK"; - char* name; - if (scaledviewwidth == 320) return; - if ( gamemode == commercial) name = name2; else name = name1; - src = W_CacheLumpName (name, PU_CACHE); dest = screens[1]; - for (y=0 ; y<SCREENHEIGHT-SBARHEIGHT ; y++) { for (x=0 ; x<SCREENWIDTH/64 ; x++) @@ -760,116 +429,73 @@ void R_FillBackScreen (void) memcpy (dest, src+((y&63)<<6), 64); dest += 64; } - if (SCREENWIDTH&63) { memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63); dest += (SCREENWIDTH&63); } } - patch = W_CacheLumpName ("brdr_t",PU_CACHE); - for (x=0 ; x<scaledviewwidth ; x+=8) V_DrawPatch (viewwindowx+x,viewwindowy-8,1,patch); patch = W_CacheLumpName ("brdr_b",PU_CACHE); - for (x=0 ; x<scaledviewwidth ; x+=8) V_DrawPatch (viewwindowx+x,viewwindowy+viewheight,1,patch); patch = W_CacheLumpName ("brdr_l",PU_CACHE); - for (y=0 ; y<viewheight ; y+=8) V_DrawPatch (viewwindowx-8,viewwindowy+y,1,patch); patch = W_CacheLumpName ("brdr_r",PU_CACHE); - for (y=0 ; y<viewheight ; y+=8) V_DrawPatch (viewwindowx+scaledviewwidth,viewwindowy+y,1,patch); - - - V_DrawPatch (viewwindowx-8, viewwindowy-8, 1, W_CacheLumpName ("brdr_tl",PU_CACHE)); - V_DrawPatch (viewwindowx+scaledviewwidth, viewwindowy-8, 1, W_CacheLumpName ("brdr_tr",PU_CACHE)); - V_DrawPatch (viewwindowx-8, viewwindowy+viewheight, 1, W_CacheLumpName ("brdr_bl",PU_CACHE)); - V_DrawPatch (viewwindowx+scaledviewwidth, viewwindowy+viewheight, 1, W_CacheLumpName ("brdr_br",PU_CACHE)); } - - - - - void R_VideoErase ( unsigned ofs, int count ) { - - - - - memcpy (screens[0]+ofs, screens[1]+ofs, count); } - - - - - - - void V_MarkRect ( int x, int y, int width, int height ); - void R_DrawViewBorder (void) { int top; int side; int ofs; int i; - if (scaledviewwidth == SCREENWIDTH) return; - top = ((SCREENHEIGHT-SBARHEIGHT)-viewheight)/2; side = (SCREENWIDTH-scaledviewwidth)/2; - - R_VideoErase (0, top*SCREENWIDTH+side); - - ofs = (viewheight+top)*SCREENWIDTH-side; R_VideoErase (ofs, top*SCREENWIDTH+side); - - ofs = top*SCREENWIDTH + SCREENWIDTH-side; side <<= 1; - for (i=1 ; i<viewheight ; i++) { R_VideoErase (ofs, side); ofs += SCREENWIDTH; } - - V_MarkRect (0,0,SCREENWIDTH, SCREENHEIGHT-SBARHEIGHT); } - - diff --git a/src/r_draw.h b/src/r_draw.h @@ -1,115 +1,43 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_DRAW__ #define __R_DRAW__ - - #ifdef __GNUG__ #pragma interface #endif - - extern lighttable_t* dc_colormap; extern int dc_x; extern int dc_yl; extern int dc_yh; extern fixed_t dc_iscale; extern fixed_t dc_texturemid; - - extern byte* dc_source; - - - - - void R_DrawColumn (void); void R_DrawColumnLow (void); - - void R_DrawFuzzColumn (void); void R_DrawFuzzColumnLow (void); - - - - void R_DrawTranslatedColumn (void); void R_DrawTranslatedColumnLow (void); - void R_VideoErase ( unsigned ofs, int count ); - extern int ds_y; extern int ds_x1; extern int ds_x2; - extern lighttable_t* ds_colormap; - extern fixed_t ds_xfrac; extern fixed_t ds_yfrac; extern fixed_t ds_xstep; extern fixed_t ds_ystep; - - extern byte* ds_source; - extern byte* translationtables; extern byte* dc_translation; - - - - void R_DrawSpan (void); - - void R_DrawSpanLow (void); - - void R_InitBuffer ( int width, int height ); - - - - void R_InitTranslationTables (void); - - - - void R_FillBackScreen (void); - - void R_DrawViewBorder (void); - - - #endif - - - - - diff --git a/src/r_local.h b/src/r_local.h @@ -1,42 +1,8 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_LOCAL__ #define __R_LOCAL__ - - #include "tables.h" - - #include "doomdef.h" - - #include "r_data.h" - - - - - - #include "r_main.h" #include "r_bsp.h" #include "r_segs.h" @@ -44,10 +10,4 @@ #include "r_data.h" #include "r_things.h" #include "r_draw.h" - #endif - - - - - diff --git a/src/r_main.c b/src/r_main.c @@ -1,139 +1,45 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdlib.h> #include <math.h> - - #include "doomdef.h" #include "d_net.h" - #include "m_bbox.h" - #include "r_local.h" #include "r_sky.h" - - - - - - #define FIELDOFVIEW 2048 - - - int viewangleoffset; - - int validcount = 1; - - lighttable_t* fixedcolormap; extern lighttable_t** walllights; - int centerx; int centery; - fixed_t centerxfrac; fixed_t centeryfrac; fixed_t projection; - - int framecount; - int sscount; int linecount; int loopcount; - fixed_t viewx; fixed_t viewy; fixed_t viewz; - angle_t viewangle; - fixed_t viewcos; fixed_t viewsin; - player_t* viewplayer; - - int detailshift; - - - - angle_t clipangle; - - - - - int viewangletox[FINEANGLES/2]; - - - - angle_t xtoviewangle[SCREENWIDTH+1]; - - - - - - - - - fixed_t* finecosine = &finesine[FINEANGLES/4]; - - lighttable_t* scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; lighttable_t* scalelightfixed[MAXLIGHTSCALE]; lighttable_t* zlight[LIGHTLEVELS][MAXLIGHTZ]; - - int extralight; - - - void (*colfunc) (void); void (*basecolfunc) (void); void (*fuzzcolfunc) (void); void (*transcolfunc) (void); void (*spanfunc) (void); - - - - - - - - void R_AddPointToBox ( int x, @@ -149,14 +55,6 @@ R_AddPointToBox if (y> box[BOXTOP]) box[BOXTOP] = y; } - - - - - - - - int R_PointOnSide ( fixed_t x, @@ -167,49 +65,36 @@ R_PointOnSide fixed_t dy; fixed_t left; fixed_t right; - if (!node->dx) { if (x <= node->x) return node->dy > 0; - return node->dy < 0; } if (!node->dy) { if (y <= node->y) return node->dx < 0; - return node->dx > 0; } - dx = (x - node->x); dy = (y - node->y); - - if ( (node->dy ^ node->dx ^ dx ^ dy)&0x80000000 ) { if ( (node->dy ^ dx) & 0x80000000 ) { - return 1; } return 0; } - left = FixedMul ( node->dy>>FRACBITS , dx ); right = FixedMul ( dy , node->dx>>FRACBITS ); - if (right < left) { - return 0; } - return 1; } - - int R_PointOnSegSide ( fixed_t x, @@ -224,69 +109,40 @@ R_PointOnSegSide fixed_t dy; fixed_t left; fixed_t right; - lx = line->v1->x; ly = line->v1->y; - ldx = line->v2->x - lx; ldy = line->v2->y - ly; - if (!ldx) { if (x <= lx) return ldy > 0; - return ldy < 0; } if (!ldy) { if (y <= ly) return ldx < 0; - return ldx > 0; } - dx = (x - lx); dy = (y - ly); - - if ( (ldy ^ ldx ^ dx ^ dy)&0x80000000 ) { if ( (ldy ^ dx) & 0x80000000 ) { - return 1; } return 0; } - left = FixedMul ( ldy>>FRACBITS , dx ); right = FixedMul ( dy , ldx>>FRACBITS ); - if (right < left) { - return 0; } - return 1; } - - - - - - - - - - - - - - - - angle_t R_PointToAngle ( fixed_t x, @@ -294,85 +150,63 @@ R_PointToAngle { x -= viewx; y -= viewy; - if ( (!x) && (!y) ) return 0; - if (x>= 0) { - if (y>= 0) { - - if (x>y) { - return tantoangle[ SlopeDiv(y,x)]; } else { - return ANG90-1-tantoangle[ SlopeDiv(x,y)]; } } else { - y = -y; - if (x>y) { - return -tantoangle[SlopeDiv(y,x)]; } else { - return ANG270+tantoangle[ SlopeDiv(x,y)]; } } } else { - x = -x; - if (y>= 0) { - if (x>y) { - return ANG180-1-tantoangle[ SlopeDiv(y,x)]; } else { - return ANG90+ tantoangle[ SlopeDiv(x,y)]; } } else { - y = -y; - if (x>y) { - return ANG180+tantoangle[ SlopeDiv(y,x)]; } else { - return ANG270-1-tantoangle[ SlopeDiv(x,y)]; } } } return 0; } - - angle_t R_PointToAngle2 ( fixed_t x1, @@ -382,11 +216,8 @@ R_PointToAngle2 { viewx = x1; viewy = y1; - return R_PointToAngle (x2, y2); } - - fixed_t R_PointToDist ( fixed_t x, @@ -397,41 +228,24 @@ R_PointToDist fixed_t dy; fixed_t temp; fixed_t dist; - dx = abs(x - viewx); dy = abs(y - viewy); - if (dy>dx) { temp = dx; dx = dy; dy = temp; } - angle = (tantoangle[ FixedDiv(dy,dx)>>DBITS ]+ANG90) >> ANGLETOFINESHIFT; - - dist = FixedDiv (dx, finesine[angle] ); - return dist; } - - - - - - - void R_InitPointToAngle (void) { - #if 0 int i; long t; float f; - - - for (i=0 ; i<=SLOPERANGE ; i++) { f = atan( (float)i/SLOPERANGE )/(3.141592657*2); @@ -440,15 +254,6 @@ void R_InitPointToAngle (void) } #endif } - - - - - - - - - fixed_t R_ScaleFromGlobalAngle (angle_t visangle) { fixed_t scale; @@ -458,15 +263,12 @@ fixed_t R_ScaleFromGlobalAngle (angle_t visangle) int sineb; fixed_t num; int den; - - #if 0 { fixed_t dist; fixed_t z; fixed_t sinv; fixed_t cosv; - sinv = finesine[(visangle-rw_normalangle)>>ANGLETOFINESHIFT]; dist = FixedDiv (rw_distance, sinv); cosv = finecosine[(viewangle-visangle)>>ANGLETOFINESHIFT]; @@ -475,20 +277,15 @@ fixed_t R_ScaleFromGlobalAngle (angle_t visangle) return scale; } #endif - anglea = ANG90 + (visangle-viewangle); angleb = ANG90 + (visangle-rw_normalangle); - - sinea = finesine[anglea>>ANGLETOFINESHIFT]; sineb = finesine[angleb>>ANGLETOFINESHIFT]; num = FixedMul(projection,sineb)<<detailshift; den = FixedMul(rw_distance,sinea); - if (den > num>>16) { scale = FixedDiv (num, den); - if (scale > 64*FRACUNIT) scale = 64*FRACUNIT; else if (scale < 256) @@ -496,25 +293,15 @@ fixed_t R_ScaleFromGlobalAngle (angle_t visangle) } else scale = 64*FRACUNIT; - return scale; } - - - - - - void R_InitTables (void) { - #if 0 int i; float a; float fv; int t; - - for (i=0 ; i<FINEANGLES/2 ; i++) { a = (i-FINEANGLES/4+0.5)*PI*2/FINEANGLES; @@ -522,40 +309,22 @@ void R_InitTables (void) t = fv; finetangent[i] = t; } - - for (i=0 ; i<5*FINEANGLES/4 ; i++) { - a = (i+0.5)*PI*2/FINEANGLES; t = FRACUNIT*sin (a); finesine[i] = t; } #endif - } - - - - - - void R_InitTextureMapping (void) { int i; int x; int t; fixed_t focallength; - - - - - - - focallength = FixedDiv (centerxfrac, finetangent[FINEANGLES/4+FIELDOFVIEW/2] ); - for (i=0 ; i<FINEANGLES/2 ; i++) { if (finetangent[i] > FRACUNIT*2) @@ -566,7 +335,6 @@ void R_InitTextureMapping (void) { t = FixedMul (finetangent[i], focallength); t = (centerxfrac - t+FRACUNIT-1)>>FRACBITS; - if (t < -1) t = -1; else if (t>viewwidth+1) @@ -574,10 +342,6 @@ void R_InitTextureMapping (void) } viewangletox[i] = t; } - - - - for (x=0;x<=viewwidth;x++) { i = 0; @@ -585,31 +349,18 @@ void R_InitTextureMapping (void) i++; xtoviewangle[x] = (i<<ANGLETOFINESHIFT)-ANG90; } - - for (i=0 ; i<FINEANGLES/2 ; i++) { t = FixedMul (finetangent[i], focallength); t = centerx - t; - if (viewangletox[i] == -1) viewangletox[i] = 0; else if (viewangletox[i] == viewwidth+1) viewangletox[i] = viewwidth; } - clipangle = xtoviewangle[0]; } - - - - - - - - #define DISTMAP 2 - void R_InitLightTables (void) { int i; @@ -617,9 +368,6 @@ void R_InitLightTables (void) int level; int startmap; int scale; - - - for (i=0 ; i< LIGHTLEVELS ; i++) { startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS; @@ -628,31 +376,17 @@ void R_InitLightTables (void) scale = FixedDiv ((SCREENWIDTH/2*FRACUNIT), (j+1)<<LIGHTZSHIFT); scale >>= LIGHTSCALESHIFT; level = startmap - scale/DISTMAP; - if (level < 0) level = 0; - if (level >= NUMCOLORMAPS) level = NUMCOLORMAPS-1; - zlight[i][j] = colormaps + level*256; } } } - - - - - - - - - boolean setsizeneeded; int setblocks; int setdetail; - - void R_SetViewSize ( int blocks, @@ -662,11 +396,6 @@ R_SetViewSize setblocks = blocks; setdetail = detail; } - - - - - void R_ExecuteSetViewSize (void) { fixed_t cosadj; @@ -675,9 +404,7 @@ void R_ExecuteSetViewSize (void) int j; int level; int startmap; - setsizeneeded = false; - if (setblocks == 11) { scaledviewwidth = SCREENWIDTH; @@ -688,16 +415,13 @@ void R_ExecuteSetViewSize (void) scaledviewwidth = setblocks*32; viewheight = (setblocks*168/10)&~7; } - detailshift = setdetail; viewwidth = scaledviewwidth>>detailshift; - centery = viewheight/2; centerx = viewwidth/2; centerxfrac = centerx<<FRACBITS; centeryfrac = centery<<FRACBITS; projection = centerxfrac; - if (!detailshift) { colfunc = basecolfunc = R_DrawColumn; @@ -712,63 +436,39 @@ void R_ExecuteSetViewSize (void) transcolfunc = R_DrawTranslatedColumn; spanfunc = R_DrawSpanLow; } - R_InitBuffer (scaledviewwidth, viewheight); - R_InitTextureMapping (); - - pspritescale = FRACUNIT*viewwidth/SCREENWIDTH; pspriteiscale = FRACUNIT*SCREENWIDTH/viewwidth; - - for (i=0 ; i<viewwidth ; i++) screenheightarray[i] = viewheight; - - for (i=0 ; i<viewheight ; i++) { dy = ((i-viewheight/2)<<FRACBITS)+FRACUNIT/2; dy = abs(dy); yslope[i] = FixedDiv ( (viewwidth<<detailshift)/2*FRACUNIT, dy); } - for (i=0 ; i<viewwidth ; i++) { cosadj = abs(finecosine[xtoviewangle[i]>>ANGLETOFINESHIFT]); distscale[i] = FixedDiv (FRACUNIT,cosadj); } - - - for (i=0 ; i< LIGHTLEVELS ; i++) { startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS; for (j=0 ; j<MAXLIGHTSCALE ; j++) { level = startmap - j*SCREENWIDTH/(viewwidth<<detailshift)/DISTMAP; - if (level < 0) level = 0; - if (level >= NUMCOLORMAPS) level = NUMCOLORMAPS-1; - scalelight[i][j] = colormaps + level*256; } } } - - - - - - extern int detailLevel; extern int screenblocks; - - - void R_Init (void) { R_InitData (); @@ -776,9 +476,7 @@ void R_Init (void) R_InitPointToAngle (); printf ("\nR_InitPointToAngle"); R_InitTables (); - printf ("\nR_InitTables"); - R_SetViewSize (screenblocks, detailLevel); R_InitPlanes (); printf ("\nR_InitPlanes"); @@ -788,14 +486,8 @@ void R_Init (void) printf ("\nR_InitSkyMap"); R_InitTranslationTables (); printf ("\nR_InitTranslationsTables"); - framecount = 0; } - - - - - subsector_t* R_PointInSubsector ( fixed_t x, @@ -804,94 +496,55 @@ R_PointInSubsector node_t* node; int side; int nodenum; - - if (!numnodes) return subsectors; - nodenum = numnodes-1; - while (! (nodenum & NF_SUBSECTOR) ) { node = &nodes[nodenum]; side = R_PointOnSide (x, y, node); nodenum = node->children[side]; } - return &subsectors[nodenum & ~NF_SUBSECTOR]; } - - - - - - void R_SetupFrame (player_t* player) { int i; - viewplayer = player; viewx = player->mo->x; viewy = player->mo->y; viewangle = player->mo->angle + viewangleoffset; extralight = player->extralight; - viewz = player->viewz; - viewsin = finesine[viewangle>>ANGLETOFINESHIFT]; viewcos = finecosine[viewangle>>ANGLETOFINESHIFT]; - sscount = 0; - if (player->fixedcolormap) { fixedcolormap = colormaps + player->fixedcolormap*256*sizeof(lighttable_t); - walllights = scalelightfixed; - for (i=0 ; i<MAXLIGHTSCALE ; i++) scalelightfixed[i] = fixedcolormap; } else fixedcolormap = 0; - framecount++; validcount++; } - - - - - - void R_RenderPlayerView (player_t* player) { R_SetupFrame (player); - - R_ClearClipSegs (); R_ClearDrawSegs (); R_ClearPlanes (); R_ClearSprites (); - - NetUpdate (); - - R_RenderBSPNode (numnodes-1); - - NetUpdate (); - R_DrawPlanes (); - - NetUpdate (); - R_DrawMasked (); - - NetUpdate (); } diff --git a/src/r_main.h b/src/r_main.h @@ -1,172 +1,76 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_MAIN__ #define __R_MAIN__ - #include "d_player.h" #include "r_data.h" - - #ifdef __GNUG__ #pragma interface #endif - - - - - extern fixed_t viewcos; extern fixed_t viewsin; - extern int viewwidth; extern int viewheight; extern int viewwindowx; extern int viewwindowy; - - - extern int centerx; extern int centery; - extern fixed_t centerxfrac; extern fixed_t centeryfrac; extern fixed_t projection; - extern int validcount; - extern int linecount; extern int loopcount; - - - - - - - - - - #define LIGHTLEVELS 16 #define LIGHTSEGSHIFT 4 - #define MAXLIGHTSCALE 48 #define LIGHTSCALESHIFT 12 #define MAXLIGHTZ 128 #define LIGHTZSHIFT 20 - extern lighttable_t* scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; extern lighttable_t* scalelightfixed[MAXLIGHTSCALE]; extern lighttable_t* zlight[LIGHTLEVELS][MAXLIGHTZ]; - extern int extralight; extern lighttable_t* fixedcolormap; - - - - #define NUMCOLORMAPS 32 - - - - - extern int detailshift; - - - - - - extern void (*colfunc) (void); extern void (*basecolfunc) (void); extern void (*fuzzcolfunc) (void); - extern void (*spanfunc) (void); - - - - int R_PointOnSide ( fixed_t x, fixed_t y, node_t* node ); - int R_PointOnSegSide ( fixed_t x, fixed_t y, seg_t* line ); - angle_t R_PointToAngle ( fixed_t x, fixed_t y ); - angle_t R_PointToAngle2 ( fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2 ); - fixed_t R_PointToDist ( fixed_t x, fixed_t y ); - - fixed_t R_ScaleFromGlobalAngle (angle_t visangle); - subsector_t* R_PointInSubsector ( fixed_t x, fixed_t y ); - void R_AddPointToBox ( int x, int y, fixed_t* box ); - - - - - - - - void R_RenderPlayerView (player_t *player); - - void R_Init (void); - - void R_SetViewSize (int blocks, int detail); - #endif - - - - - diff --git a/src/r_plane.c b/src/r_plane.c @@ -1,120 +1,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdlib.h> - #include "i_system.h" #include "z_zone.h" #include "w_wad.h" - #include "doomdef.h" #include "doomstat.h" - #include "r_local.h" #include "r_sky.h" - - - planefunction_t floorfunc; planefunction_t ceilingfunc; - - - - - - #define MAXVISPLANES 128 visplane_t visplanes[MAXVISPLANES]; visplane_t* lastvisplane; visplane_t* floorplane; visplane_t* ceilingplane; - - #define MAXOPENINGS SCREENWIDTH*64 short openings[MAXOPENINGS]; short* lastopening; - - - - - - - short floorclip[SCREENWIDTH]; short ceilingclip[SCREENWIDTH]; - - - - - int spanstart[SCREENHEIGHT]; int spanstop[SCREENHEIGHT]; - - - - lighttable_t** planezlight; fixed_t planeheight; - fixed_t yslope[SCREENHEIGHT]; fixed_t distscale[SCREENWIDTH]; fixed_t basexscale; fixed_t baseyscale; - fixed_t cachedheight[SCREENHEIGHT]; fixed_t cacheddistance[SCREENHEIGHT]; fixed_t cachedxstep[SCREENHEIGHT]; fixed_t cachedystep[SCREENHEIGHT]; - - - - - - - void R_InitPlanes (void) { - } - - - - - - - - - - - - - - - void R_MapPlane ( int y, @@ -125,7 +43,6 @@ R_MapPlane fixed_t distance; fixed_t length; unsigned index; - #ifdef RANGECHECK if (x2 < x1 || x1<0 @@ -135,7 +52,6 @@ R_MapPlane I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y); } #endif - if (planeheight != cachedheight[y]) { cachedheight[y] = planeheight; @@ -149,69 +65,40 @@ R_MapPlane ds_xstep = cachedxstep[y]; ds_ystep = cachedystep[y]; } - length = FixedMul (distance,distscale[x1]); angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT; ds_xfrac = viewx + FixedMul(finecosine[angle], length); ds_yfrac = -viewy - FixedMul(finesine[angle], length); - if (fixedcolormap) ds_colormap = fixedcolormap; else { index = distance >> LIGHTZSHIFT; - if (index >= MAXLIGHTZ ) index = MAXLIGHTZ-1; - ds_colormap = planezlight[index]; } - ds_y = y; ds_x1 = x1; ds_x2 = x2; - - spanfunc (); } - - - - - - void R_ClearPlanes (void) { int i; angle_t angle; - - for (i=0 ; i<viewwidth ; i++) { floorclip[i] = viewheight; ceilingclip[i] = -1; } - lastvisplane = visplanes; lastopening = openings; - - memset (cachedheight, 0, sizeof(cachedheight)); - - angle = (viewangle-ANG90)>>ANGLETOFINESHIFT; - - basexscale = FixedDiv (finecosine[angle],centerxfrac); baseyscale = -FixedDiv (finesine[angle],centerxfrac); } - - - - - - - visplane_t* R_FindPlane ( fixed_t height, @@ -219,13 +106,11 @@ R_FindPlane int lightlevel ) { visplane_t* check; - if (picnum == skyflatnum) { height = 0; lightlevel = 0; } - for (check=visplanes; check<lastvisplane; check++) { if (height == check->height @@ -235,31 +120,19 @@ R_FindPlane break; } } - - if (check < lastvisplane) return check; - if (lastvisplane - visplanes == MAXVISPLANES) I_Error ("R_FindPlane: no more visplanes"); - lastvisplane++; - check->height = height; check->picnum = picnum; check->lightlevel = lightlevel; check->minx = SCREENWIDTH; check->maxx = -1; - memset (check->top,0xff,sizeof(check->top)); - return check; } - - - - - visplane_t* R_CheckPlane ( visplane_t* pl, @@ -271,7 +144,6 @@ R_CheckPlane int unionl; int unionh; int x; - if (start < pl->minx) { intrl = pl->minx; @@ -282,7 +154,6 @@ R_CheckPlane unionl = pl->minx; intrl = start; } - if (stop > pl->maxx) { intrh = pl->maxx; @@ -293,38 +164,24 @@ R_CheckPlane unionh = pl->maxx; intrh = stop; } - for (x=intrl ; x<= intrh ; x++) if (pl->top[x] != 0xff) break; - if (x > intrh) { pl->minx = unionl; pl->maxx = unionh; - - return pl; } - - lastvisplane->height = pl->height; lastvisplane->picnum = pl->picnum; lastvisplane->lightlevel = pl->lightlevel; - pl = lastvisplane++; pl->minx = start; pl->maxx = stop; - memset (pl->top,0xff,sizeof(pl->top)); - return pl; } - - - - - void R_MakeSpans ( int x, @@ -343,7 +200,6 @@ R_MakeSpans R_MapPlane (b1,spanstart[b1],x-1); b1--; } - while (t2 < t1 && t2<=b2) { spanstart[t2] = x; @@ -355,13 +211,6 @@ R_MakeSpans b2--; } } - - - - - - - void R_DrawPlanes (void) { visplane_t* pl; @@ -369,43 +218,30 @@ void R_DrawPlanes (void) int x; int stop; int angle; - #ifdef RANGECHECK if (ds_p - drawsegs > MAXDRAWSEGS) I_Error ("R_DrawPlanes: drawsegs overflow (%i)", ds_p - drawsegs); - if (lastvisplane - visplanes > MAXVISPLANES) I_Error ("R_DrawPlanes: visplane overflow (%i)", lastvisplane - visplanes); - if (lastopening - openings > MAXOPENINGS) I_Error ("R_DrawPlanes: opening overflow (%i)", lastopening - openings); #endif - for (pl = visplanes ; pl < lastvisplane ; pl++) { if (pl->minx > pl->maxx) continue; - - - if (pl->picnum == skyflatnum) { dc_iscale = pspriteiscale>>detailshift; - - - - - dc_colormap = colormaps; dc_texturemid = skytexturemid; for (x=pl->minx ; x <= pl->maxx ; x++) { dc_yl = pl->top[x]; dc_yh = pl->bottom[x]; - if (dc_yl <= dc_yh) { angle = (viewangle + xtoviewangle[x])>>ANGLETOSKYSHIFT; @@ -416,28 +252,19 @@ void R_DrawPlanes (void) } continue; } - - ds_source = W_CacheLumpNum(firstflat + flattranslation[pl->picnum], PU_STATIC); - planeheight = abs(pl->height-viewz); light = (pl->lightlevel >> LIGHTSEGSHIFT)+extralight; - if (light >= LIGHTLEVELS) light = LIGHTLEVELS-1; - if (light < 0) light = 0; - planezlight = zlight[light]; - pl->top[pl->maxx+1] = 0xff; pl->top[pl->minx-1] = 0xff; - stop = pl->maxx + 1; - for (x=pl->minx ; x<= stop ; x++) { R_MakeSpans(x,pl->top[x-1], @@ -445,7 +272,6 @@ void R_DrawPlanes (void) pl->top[x], pl->bottom[x]); } - Z_ChangeTag (ds_source, PU_CACHE); } } diff --git a/src/r_plane.h b/src/r_plane.h @@ -1,60 +1,24 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_PLANE__ #define __R_PLANE__ - - #include "r_data.h" - #ifdef __GNUG__ #pragma interface #endif - - - extern short* lastopening; - - typedef void (*planefunction_t) (int top, int bottom); - extern planefunction_t floorfunc; extern planefunction_t ceilingfunc_t; - extern short floorclip[SCREENWIDTH]; extern short ceilingclip[SCREENWIDTH]; - extern fixed_t yslope[SCREENHEIGHT]; extern fixed_t distscale[SCREENWIDTH]; - void R_InitPlanes (void); void R_ClearPlanes (void); - void R_MapPlane ( int y, int x1, int x2 ); - void R_MakeSpans ( int x, @@ -62,26 +26,15 @@ R_MakeSpans int b1, int t2, int b2 ); - void R_DrawPlanes (void); - visplane_t* R_FindPlane ( fixed_t height, int picnum, int lightlevel ); - visplane_t* R_CheckPlane ( visplane_t* pl, int start, int stop ); - - - #endif - - - - - diff --git a/src/r_segs.c b/src/r_segs.c @@ -1,65 +1,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdlib.h> - #include "i_system.h" - #include "doomdef.h" #include "doomstat.h" - #include "r_local.h" #include "r_sky.h" - - - - - boolean segtextured; - - boolean markfloor; boolean markceiling; - boolean maskedtexture; int toptexture; int bottomtexture; int midtexture; - - angle_t rw_normalangle; - int rw_angle1; - - - - int rw_x; int rw_stopx; angle_t rw_centerangle; @@ -70,33 +23,20 @@ fixed_t rw_scalestep; fixed_t rw_midtexturemid; fixed_t rw_toptexturemid; fixed_t rw_bottomtexturemid; - int worldtop; int worldbottom; int worldhigh; int worldlow; - fixed_t pixhigh; fixed_t pixlow; fixed_t pixhighstep; fixed_t pixlowstep; - fixed_t topfrac; fixed_t topstep; - fixed_t bottomfrac; fixed_t bottomstep; - - lighttable_t** walllights; - short* maskedtexturecol; - - - - - - void R_RenderMaskedSegRange ( drawseg_t* ds, @@ -107,38 +47,26 @@ R_RenderMaskedSegRange column_t* col; int lightnum; int texnum; - - - - - curline = ds->curline; frontsector = curline->frontsector; backsector = curline->backsector; texnum = texturetranslation[curline->sidedef->midtexture]; - lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight; - if (curline->v1->y == curline->v2->y) lightnum--; else if (curline->v1->x == curline->v2->x) lightnum++; - if (lightnum < 0) walllights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) walllights = scalelight[LIGHTLEVELS-1]; else walllights = scalelight[lightnum]; - maskedtexturecol = ds->maskedtexturecol; - rw_scalestep = ds->scalestep; spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; mfloorclip = ds->sprbottomclip; mceilingclip = ds->sprtopclip; - - if (curline->linedef->flags & ML_DONTPEGBOTTOM) { dc_texturemid = frontsector->floorheight > backsector->floorheight @@ -152,55 +80,31 @@ R_RenderMaskedSegRange dc_texturemid = dc_texturemid - viewz; } dc_texturemid += curline->sidedef->rowoffset; - if (fixedcolormap) dc_colormap = fixedcolormap; - - for (dc_x = x1 ; dc_x <= x2 ; dc_x++) { - if (maskedtexturecol[dc_x] != MAXSHORT) { if (!fixedcolormap) { index = spryscale>>LIGHTSCALESHIFT; - if (index >= MAXLIGHTSCALE ) index = MAXLIGHTSCALE-1; - dc_colormap = walllights[index]; } - sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); dc_iscale = 0xffffffffu / (unsigned)spryscale; - - col = (column_t *)( (byte *)R_GetColumn(texnum,maskedtexturecol[dc_x]) -3); - R_DrawMaskedColumn (col); maskedtexturecol[dc_x] = MAXSHORT; } spryscale += rw_scalestep; } - } - - - - - - - - - - - - #define HEIGHTBITS 12 #define HEIGHTUNIT (1<<HEIGHTBITS) - void R_RenderSegLoop (void) { angle_t angle; @@ -211,38 +115,26 @@ void R_RenderSegLoop (void) fixed_t texturecolumn; int top; int bottom; - - - for ( ; rw_x < rw_stopx ; rw_x++) { - yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS; - - if (yl < ceilingclip[rw_x]+1) yl = ceilingclip[rw_x]+1; - if (markceiling) { top = ceilingclip[rw_x]+1; bottom = yl-1; - if (bottom >= floorclip[rw_x]) bottom = floorclip[rw_x]-1; - if (top <= bottom) { ceilingplane->top[rw_x] = top; ceilingplane->bottom[rw_x] = bottom; } } - yh = bottomfrac>>HEIGHTBITS; - if (yh >= floorclip[rw_x]) yh = floorclip[rw_x]-1; - if (markfloor) { top = yh+1; @@ -255,29 +147,20 @@ void R_RenderSegLoop (void) floorplane->bottom[rw_x] = bottom; } } - - if (segtextured) { - angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT; texturecolumn = rw_offset-FixedMul(finetangent[angle],rw_distance); texturecolumn >>= FRACBITS; - index = rw_scale>>LIGHTSCALESHIFT; - if (index >= MAXLIGHTSCALE ) index = MAXLIGHTSCALE-1; - dc_colormap = walllights[index]; dc_x = rw_x; dc_iscale = 0xffffffffu / (unsigned)rw_scale; } - - if (midtexture) { - dc_yl = yl; dc_yh = yh; dc_texturemid = rw_midtexturemid; @@ -288,16 +171,12 @@ void R_RenderSegLoop (void) } else { - if (toptexture) { - mid = pixhigh>>HEIGHTBITS; pixhigh += pixhighstep; - if (mid >= floorclip[rw_x]) mid = floorclip[rw_x]-1; - if (mid >= yl) { dc_yl = yl; @@ -312,21 +191,15 @@ void R_RenderSegLoop (void) } else { - if (markceiling) ceilingclip[rw_x] = yl-1; } - if (bottomtexture) { - mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS; pixlow += pixlowstep; - - if (mid <= ceilingclip[rw_x]) mid = ceilingclip[rw_x]+1; - if (mid <= yh) { dc_yl = mid; @@ -342,33 +215,19 @@ void R_RenderSegLoop (void) } else { - if (markfloor) floorclip[rw_x] = yh+1; } - if (maskedtexture) { - - maskedtexturecol[rw_x] = texturecolumn; } } - rw_scale += rw_scalestep; topfrac += topstep; bottomfrac += bottomstep; } } - - - - - - - - - void R_StoreWallRange ( int start, @@ -379,44 +238,29 @@ R_StoreWallRange angle_t distangle, offsetangle; fixed_t vtop; int lightnum; - - if (ds_p == &drawsegs[MAXDRAWSEGS]) return; - #ifdef RANGECHECK if (start >=viewwidth || start > stop) I_Error ("Bad R_RenderWallRange: %i to %i", start , stop); #endif - sidedef = curline->sidedef; linedef = curline->linedef; - - linedef->flags |= ML_MAPPED; - - rw_normalangle = curline->angle + ANG90; offsetangle = abs(rw_normalangle-rw_angle1); - if (offsetangle > ANG90) offsetangle = ANG90; - distangle = ANG90 - offsetangle; hyp = R_PointToDist (curline->v1->x, curline->v1->y); sineval = finesine[distangle>>ANGLETOFINESHIFT]; rw_distance = FixedMul (hyp, sineval); - - ds_p->x1 = rw_x = start; ds_p->x2 = stop; ds_p->curline = curline; rw_stopx = stop+1; - - ds_p->scale1 = rw_scale = R_ScaleFromGlobalAngle (viewangle + xtoviewangle[start]); - if (stop > start ) { ds_p->scale2 = R_ScaleFromGlobalAngle (viewangle + xtoviewangle[stop]); @@ -425,16 +269,13 @@ R_StoreWallRange } else { - #if 0 if (rw_distance < FRACUNIT/2) { fixed_t trx,try; fixed_t gxt,gyt; - trx = curline->v1->x - viewx; try = curline->v1->y - viewy; - gxt = FixedMul(trx,viewcos); gyt = -FixedMul(try,viewsin); ds_p->scale1 = FixedDiv(projection, gxt-gyt)<<detailshift; @@ -442,35 +283,25 @@ R_StoreWallRange #endif ds_p->scale2 = ds_p->scale1; } - - - worldtop = frontsector->ceilingheight - viewz; worldbottom = frontsector->floorheight - viewz; - midtexture = toptexture = bottomtexture = maskedtexture = 0; ds_p->maskedtexturecol = NULL; - if (!backsector) { - midtexture = texturetranslation[sidedef->midtexture]; - markfloor = markceiling = true; if (linedef->flags & ML_DONTPEGBOTTOM) { vtop = frontsector->floorheight + textureheight[sidedef->midtexture]; - rw_midtexturemid = vtop - viewz; } else { - rw_midtexturemid = worldtop; } rw_midtexturemid += sidedef->rowoffset; - ds_p->silhouette = SIL_BOTH; ds_p->sprtopclip = screenheightarray; ds_p->sprbottomclip = negonearray; @@ -479,10 +310,8 @@ R_StoreWallRange } else { - ds_p->sprtopclip = ds_p->sprbottomclip = NULL; ds_p->silhouette = 0; - if (frontsector->floorheight > backsector->floorheight) { ds_p->silhouette = SIL_BOTTOM; @@ -492,9 +321,7 @@ R_StoreWallRange { ds_p->silhouette = SIL_BOTTOM; ds_p->bsilheight = MAXINT; - } - if (frontsector->ceilingheight < backsector->ceilingheight) { ds_p->silhouette |= SIL_TOP; @@ -504,34 +331,26 @@ R_StoreWallRange { ds_p->silhouette |= SIL_TOP; ds_p->tsilheight = MININT; - } - if (backsector->ceilingheight <= frontsector->floorheight) { ds_p->sprbottomclip = negonearray; ds_p->bsilheight = MAXINT; ds_p->silhouette |= SIL_BOTTOM; } - if (backsector->floorheight >= frontsector->ceilingheight) { ds_p->sprtopclip = screenheightarray; ds_p->tsilheight = MININT; ds_p->silhouette |= SIL_TOP; } - worldhigh = backsector->ceilingheight - viewz; worldlow = backsector->floorheight - viewz; - - if (frontsector->ceilingpic == skyflatnum && backsector->ceilingpic == skyflatnum) { worldtop = worldhigh; } - - if (worldlow != worldbottom || backsector->floorpic != frontsector->floorpic || backsector->lightlevel != frontsector->lightlevel) @@ -540,11 +359,8 @@ R_StoreWallRange } else { - markfloor = false; } - - if (worldhigh != worldtop || backsector->ceilingpic != frontsector->ceilingpic || backsector->lightlevel != frontsector->lightlevel) @@ -553,25 +369,18 @@ R_StoreWallRange } else { - markceiling = false; } - if (backsector->ceilingheight <= frontsector->floorheight || backsector->floorheight >= frontsector->ceilingheight) { - markceiling = markfloor = true; } - - if (worldhigh < worldtop) { - toptexture = texturetranslation[sidedef->toptexture]; if (linedef->flags & ML_DONTPEGTOP) { - rw_toptexturemid = worldtop; } else @@ -579,20 +388,14 @@ R_StoreWallRange vtop = backsector->ceilingheight + textureheight[sidedef->toptexture]; - - rw_toptexturemid = vtop - viewz; } } if (worldlow > worldbottom) { - bottomtexture = texturetranslation[sidedef->bottomtexture]; - if (linedef->flags & ML_DONTPEGBOTTOM ) { - - rw_bottomtexturemid = worldtop; } else @@ -600,52 +403,34 @@ R_StoreWallRange } rw_toptexturemid += sidedef->rowoffset; rw_bottomtexturemid += sidedef->rowoffset; - - if (sidedef->midtexture) { - maskedtexture = true; ds_p->maskedtexturecol = maskedtexturecol = lastopening - rw_x; lastopening += rw_stopx - rw_x; } } - - segtextured = midtexture | toptexture | bottomtexture | maskedtexture; - if (segtextured) { offsetangle = rw_normalangle-rw_angle1; - if (offsetangle > ANG180) offsetangle = -offsetangle; - if (offsetangle > ANG90) offsetangle = ANG90; - sineval = finesine[offsetangle >>ANGLETOFINESHIFT]; rw_offset = FixedMul (hyp, sineval); - if (rw_normalangle-rw_angle1 < ANG180) rw_offset = -rw_offset; - rw_offset += sidedef->textureoffset + curline->offset; rw_centerangle = ANG90 + viewangle - rw_normalangle; - - - - - if (!fixedcolormap) { lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight; - if (curline->v1->y == curline->v2->y) lightnum--; else if (curline->v1->x == curline->v2->x) lightnum++; - if (lightnum < 0) walllights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) @@ -654,65 +439,41 @@ R_StoreWallRange walllights = scalelight[lightnum]; } } - - - - - - if (frontsector->floorheight >= viewz) { - markfloor = false; } - if (frontsector->ceilingheight <= viewz && frontsector->ceilingpic != skyflatnum) { - markceiling = false; } - - - worldtop >>= 4; worldbottom >>= 4; - topstep = -FixedMul (rw_scalestep, worldtop); topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); - bottomstep = -FixedMul (rw_scalestep,worldbottom); bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); - if (backsector) { worldhigh >>= 4; worldlow >>= 4; - if (worldhigh < worldtop) { pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); pixhighstep = -FixedMul (rw_scalestep,worldhigh); } - if (worldlow > worldbottom) { pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale); pixlowstep = -FixedMul (rw_scalestep,worldlow); } } - - if (markceiling) ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1); - if (markfloor) floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1); - R_RenderSegLoop (); - - - if ( ((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip) { @@ -720,7 +481,6 @@ R_StoreWallRange ds_p->sprtopclip = lastopening - start; lastopening += rw_stopx - start; } - if ( ((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) && !ds_p->sprbottomclip) { @@ -728,7 +488,6 @@ R_StoreWallRange ds_p->sprbottomclip = lastopening - start; lastopening += rw_stopx - start; } - if (maskedtexture && !(ds_p->silhouette&SIL_TOP)) { ds_p->silhouette |= SIL_TOP; @@ -741,4 +500,3 @@ R_StoreWallRange } ds_p++; } - diff --git a/src/r_segs.h b/src/r_segs.h @@ -1,44 +1,11 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_SEGS__ #define __R_SEGS__ - - #ifdef __GNUG__ #pragma interface #endif - - void R_RenderMaskedSegRange ( drawseg_t* ds, int x1, int x2 ); - - #endif - - - - - diff --git a/src/r_sky.c b/src/r_sky.c @@ -1,60 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "m_fixed.h" - - #include "r_data.h" - - #ifdef __GNUG__ #pragma implementation "r_sky.h" #endif #include "r_sky.h" - - - - int skyflatnum; int skytexture; int skytexturemid; - - - - - - - void R_InitSkyMap (void) { - skytexturemid = 100*FRACUNIT; } - diff --git a/src/r_sky.h b/src/r_sky.h @@ -1,48 +1,11 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_SKY__ #define __R_SKY__ - - #ifdef __GNUG__ #pragma interface #endif - - #define SKYFLATNAME "F_SKY1" - - #define ANGLETOSKYSHIFT 22 - extern int skytexture; extern int skytexturemid; - - void R_InitSkyMap (void); - #endif - - - - - diff --git a/src/r_state.h b/src/r_state.h @@ -1,138 +1,52 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_STATE__ #define __R_STATE__ - - #include "d_player.h" #include "r_data.h" - - - #ifdef __GNUG__ #pragma interface #endif - - - - - - - - - extern fixed_t* textureheight; - - extern fixed_t* spritewidth; - extern fixed_t* spriteoffset; extern fixed_t* spritetopoffset; - extern lighttable_t* colormaps; - extern int viewwidth; extern int scaledviewwidth; extern int viewheight; - extern int firstflat; - - extern int* flattranslation; extern int* texturetranslation; - - - extern int firstspritelump; extern int lastspritelump; extern int numspritelumps; - - - - - - extern int numsprites; extern spritedef_t* sprites; - extern int numvertexes; extern vertex_t* vertexes; - extern int numsegs; extern seg_t* segs; - extern int numsectors; extern sector_t* sectors; - extern int numsubsectors; extern subsector_t* subsectors; - extern int numnodes; extern node_t* nodes; - extern int numlines; extern line_t* lines; - extern int numsides; extern side_t* sides; - - - - - extern fixed_t viewx; extern fixed_t viewy; extern fixed_t viewz; - extern angle_t viewangle; extern player_t* viewplayer; - - - extern angle_t clipangle; - extern int viewangletox[FINEANGLES/2]; extern angle_t xtoviewangle[SCREENWIDTH+1]; - - extern fixed_t rw_distance; extern angle_t rw_normalangle; - - - - extern int rw_angle1; - - extern int sscount; - extern visplane_t* floorplane; extern visplane_t* ceilingplane; - - #endif - - - - - diff --git a/src/r_things.c b/src/r_things.c @@ -1,105 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> #include <stdlib.h> - - #include "doomdef.h" #include "m_swap.h" - #include "i_system.h" #include "z_zone.h" #include "w_wad.h" - #include "r_local.h" - #include "doomstat.h" - - - #define MINZ (FRACUNIT*4) #define BASEYCENTER 100 - - - - - - typedef struct { int x1; int x2; - int column; int topclip; int bottomclip; - } maskdraw_t; - - - - - - - - - - fixed_t pspritescale; fixed_t pspriteiscale; - lighttable_t** spritelights; - - - short negonearray[SCREENWIDTH]; short screenheightarray[SCREENWIDTH]; - - - - - - - - spritedef_t* sprites; int numsprites; - spriteframe_t sprtemp[29]; int maxframe; char* spritename; - - - - - - - - void R_InstallSpriteLump ( int lump, @@ -108,25 +35,19 @@ R_InstallSpriteLump boolean flipped ) { int r; - if (frame >= 29 || rotation > 8) I_Error("R_InstallSpriteLump: " "Bad frame characters in lump %i", lump); - if ((int)frame > maxframe) maxframe = frame; - if (rotation == 0) { - if (sprtemp[frame].rotate == false) I_Error ("R_InitSprites: Sprite %s frame %c has " "multip rot=0 lump", spritename, 'A'+frame); - if (sprtemp[frame].rotate == true) I_Error ("R_InitSprites: Sprite %s frame %c has rotations " "and a rot=0 lump", spritename, 'A'+frame); - sprtemp[frame].rotate = false; for (r=0 ; r<8 ; r++) { @@ -135,43 +56,18 @@ R_InstallSpriteLump } return; } - - if (sprtemp[frame].rotate == false) I_Error ("R_InitSprites: Sprite %s frame %c has rotations " "and a rot=0 lump", spritename, 'A'+frame); - sprtemp[frame].rotate = true; - - rotation--; if (sprtemp[frame].lump[rotation] != -1) I_Error ("R_InitSprites: Sprite %s : %c : %c " "has two lumps mapped to it", spritename, 'A'+frame, '1'+rotation); - sprtemp[frame].lump[rotation] = lump - firstspritelump; sprtemp[frame].flip[rotation] = (byte)flipped; } - - - - - - - - - - - - - - - - - - - void R_InitSpriteDefs (char** namelist) { char** check; @@ -183,49 +79,32 @@ void R_InitSpriteDefs (char** namelist) int start; int end; int patched; - - check = namelist; while (*check != NULL) check++; - numsprites = check-namelist; - if (!numsprites) return; - sprites = Z_Malloc(numsprites *sizeof(*sprites), PU_STATIC, NULL); - start = firstspritelump-1; end = lastspritelump+1; - - - - for (i=0 ; i<numsprites ; i++) { spritename = namelist[i]; memset (sprtemp,-1, sizeof(sprtemp)); - maxframe = -1; intname = *(int *)namelist[i]; - - - for (l=start+1 ; l<end ; l++) { if (*(int *)lumpinfo[l].name == intname) { frame = lumpinfo[l].name[4] - 'A'; rotation = lumpinfo[l].name[5] - '0'; - if (modifiedgame) patched = W_GetNumForName (lumpinfo[l].name); else patched = l; - R_InstallSpriteLump (patched, frame, rotation, false); - if (lumpinfo[l].name[6]) { frame = lumpinfo[l].name[6] - 'A'; @@ -234,32 +113,23 @@ void R_InitSpriteDefs (char** namelist) } } } - - if (maxframe == -1) { sprites[i].numframes = 0; continue; } - maxframe++; - for (frame = 0 ; frame < maxframe ; frame++) { switch ((int)sprtemp[frame].rotate) { case -1: - I_Error ("R_InitSprites: No patches found " "for %s frame %c", namelist[i], frame+'A'); break; - case 0: - break; - case 1: - for (rotation=0 ; rotation<8 ; rotation++) if (sprtemp[frame].lump[rotation] == -1) I_Error ("R_InitSprites: Sprite %s frame %c " @@ -268,129 +138,66 @@ void R_InitSpriteDefs (char** namelist) break; } } - - sprites[i].numframes = maxframe; sprites[i].spriteframes = Z_Malloc (maxframe * sizeof(spriteframe_t), PU_STATIC, NULL); memcpy (sprites[i].spriteframes, sprtemp, maxframe*sizeof(spriteframe_t)); } - } - - - - - - - vissprite_t vissprites[MAXVISSPRITES]; vissprite_t* vissprite_p; int newvissprite; - - - - - - - void R_InitSprites (char** namelist) { int i; - for (i=0 ; i<SCREENWIDTH ; i++) { negonearray[i] = -1; } - R_InitSpriteDefs (namelist); } - - - - - - - void R_ClearSprites (void) { vissprite_p = vissprites; } - - - - - vissprite_t overflowsprite; - vissprite_t* R_NewVisSprite (void) { if (vissprite_p == &vissprites[MAXVISSPRITES]) return &overflowsprite; - vissprite_p++; return vissprite_p-1; } - - - - - - - - - short* mfloorclip; short* mceilingclip; - fixed_t spryscale; fixed_t sprtopscreen; - void R_DrawMaskedColumn (column_t* column) { int topscreen; int bottomscreen; fixed_t basetexturemid; - basetexturemid = dc_texturemid; - for ( ; column->topdelta != 0xff ; ) { - - topscreen = sprtopscreen + spryscale*column->topdelta; bottomscreen = topscreen + spryscale*column->length; - dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; dc_yh = (bottomscreen-1)>>FRACBITS; - if (dc_yh >= mfloorclip[dc_x]) dc_yh = mfloorclip[dc_x]-1; if (dc_yl <= mceilingclip[dc_x]) dc_yl = mceilingclip[dc_x]+1; - if (dc_yl <= dc_yh) { dc_source = (byte *)column + 3; dc_texturemid = basetexturemid - (column->topdelta<<FRACBITS); - - - - colfunc (); } column = (column_t *)( (byte *)column + column->length + 4); } - dc_texturemid = basetexturemid; } - - - - - - - void R_DrawVisSprite ( vissprite_t* vis, @@ -401,15 +208,10 @@ R_DrawVisSprite int texturecolumn; fixed_t frac; patch_t* patch; - - patch = W_CacheLumpNum (vis->patch+firstspritelump, PU_CACHE); - dc_colormap = vis->colormap; - if (!dc_colormap) { - colfunc = fuzzcolfunc; } else if (vis->mobjflags & MF_TRANSLATION) @@ -418,13 +220,11 @@ R_DrawVisSprite dc_translation = translationtables - 256 + ( (vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT-8) ); } - dc_iscale = abs(vis->xiscale)>>detailshift; dc_texturemid = vis->texturemid; frac = vis->startfrac; spryscale = vis->scale; sprtopscreen = centeryfrac - FixedMul(dc_texturemid,spryscale); - for (dc_x=vis->x1 ; dc_x<=vis->x2 ; dc_x++, frac += vis->xiscale) { texturecolumn = frac>>FRACBITS; @@ -436,71 +236,41 @@ R_DrawVisSprite LONG(patch->columnofs[texturecolumn])); R_DrawMaskedColumn (column); } - colfunc = basecolfunc; } - - - - - - - - void R_ProjectSprite (mobj_t* thing) { fixed_t tr_x; fixed_t tr_y; - fixed_t gxt; fixed_t gyt; - fixed_t tx; fixed_t tz; - fixed_t xscale; - int x1; int x2; - spritedef_t* sprdef; spriteframe_t* sprframe; int lump; - unsigned rot; boolean flip; - int index; - vissprite_t* vis; - angle_t ang; fixed_t iscale; - - tr_x = thing->x - viewx; tr_y = thing->y - viewy; - gxt = FixedMul(tr_x,viewcos); gyt = -FixedMul(tr_y,viewsin); - tz = gxt-gyt; - - if (tz < MINZ) return; - xscale = FixedDiv(projection, tz); - gxt = -FixedMul(tr_x,viewsin); gyt = FixedMul(tr_y,viewcos); tx = -(gyt+gxt); - - if (abs(tx)>(tz<<2)) return; - - #ifdef RANGECHECK if ((unsigned)thing->sprite >= numsprites) I_Error ("R_ProjectSprite: invalid sprite number %i ", @@ -513,10 +283,8 @@ void R_ProjectSprite (mobj_t* thing) thing->sprite, thing->frame); #endif sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK]; - if (sprframe->rotate) { - ang = R_PointToAngle (thing->x, thing->y); rot = (ang-thing->angle+(unsigned)(ANG45/2)*9)>>29; lump = sprframe->lump[rot]; @@ -524,27 +292,17 @@ void R_ProjectSprite (mobj_t* thing) } else { - lump = sprframe->lump[0]; flip = (boolean)sprframe->flip[0]; } - - tx -= spriteoffset[lump]; x1 = (centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS; - - if (x1 > viewwidth) return; - tx += spritewidth[lump]; x2 = ((centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS) - 1; - - if (x2 < 0) return; - - vis = R_NewVisSprite (); vis->mobjflags = thing->flags; vis->scale = xscale<<detailshift; @@ -556,7 +314,6 @@ void R_ProjectSprite (mobj_t* thing) vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; iscale = FixedDiv (FRACUNIT, xscale); - if (flip) { vis->startfrac = spritewidth[lump]-1; @@ -567,80 +324,46 @@ void R_ProjectSprite (mobj_t* thing) vis->startfrac = 0; vis->xiscale = iscale; } - if (vis->x1 > x1) vis->startfrac += vis->xiscale*(vis->x1-x1); vis->patch = lump; - - if (thing->flags & MF_SHADOW) { - vis->colormap = NULL; } else if (fixedcolormap) { - vis->colormap = fixedcolormap; } else if (thing->frame & FF_FULLBRIGHT) { - vis->colormap = colormaps; } - else { - index = xscale>>(LIGHTSCALESHIFT-detailshift); - if (index >= MAXLIGHTSCALE) index = MAXLIGHTSCALE-1; - vis->colormap = spritelights[index]; } } - - - - - - - - void R_AddSprites (sector_t* sec) { mobj_t* thing; int lightnum; - - - - - if (sec->validcount == validcount) return; - - sec->validcount = validcount; - lightnum = (sec->lightlevel >> LIGHTSEGSHIFT)+extralight; - if (lightnum < 0) spritelights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) spritelights = scalelight[LIGHTLEVELS-1]; else spritelights = scalelight[lightnum]; - - for (thing = sec->thinglist ; thing ; thing = thing->snext) R_ProjectSprite (thing); } - - - - - void R_DrawPSprite (pspdef_t* psp) { fixed_t tx; @@ -652,8 +375,6 @@ void R_DrawPSprite (pspdef_t* psp) boolean flip; vissprite_t* vis; vissprite_t avis; - - #ifdef RANGECHECK if ( (unsigned)psp->state->sprite >= numsprites) I_Error ("R_ProjectSprite: invalid sprite number %i ", @@ -666,35 +387,23 @@ void R_DrawPSprite (pspdef_t* psp) psp->state->sprite, psp->state->frame); #endif sprframe = &sprdef->spriteframes[ psp->state->frame & FF_FRAMEMASK ]; - lump = sprframe->lump[0]; flip = (boolean)sprframe->flip[0]; - - tx = psp->sx-160*FRACUNIT; - tx -= spriteoffset[lump]; x1 = (centerxfrac + FixedMul (tx,pspritescale) ) >>FRACBITS; - - if (x1 > viewwidth) return; - tx += spritewidth[lump]; x2 = ((centerxfrac + FixedMul (tx, pspritescale) ) >>FRACBITS) - 1; - - if (x2 < 0) return; - - vis = &avis; vis->mobjflags = 0; vis->texturemid = (BASEYCENTER<<FRACBITS)+FRACUNIT/2-(psp->sy-spritetopoffset[lump]); vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; vis->scale = pspritescale<<detailshift; - if (flip) { vis->xiscale = -pspriteiscale; @@ -705,65 +414,44 @@ void R_DrawPSprite (pspdef_t* psp) vis->xiscale = pspriteiscale; vis->startfrac = 0; } - if (vis->x1 > x1) vis->startfrac += vis->xiscale*(vis->x1-x1); - vis->patch = lump; - if (viewplayer->powers[pw_invisibility] > 4*32 || viewplayer->powers[pw_invisibility] & 8) { - vis->colormap = NULL; } else if (fixedcolormap) { - vis->colormap = fixedcolormap; } else if (psp->state->frame & FF_FULLBRIGHT) { - vis->colormap = colormaps; } else { - vis->colormap = spritelights[MAXLIGHTSCALE-1]; } - R_DrawVisSprite (vis, vis->x1, vis->x2); } - - - - - - void R_DrawPlayerSprites (void) { int i; int lightnum; pspdef_t* psp; - - lightnum = (viewplayer->mo->subsector->sector->lightlevel >> LIGHTSEGSHIFT) +extralight; - if (lightnum < 0) spritelights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) spritelights = scalelight[LIGHTLEVELS-1]; else spritelights = scalelight[lightnum]; - - mfloorclip = screenheightarray; mceilingclip = negonearray; - - for (i=0, psp=viewplayer->psprites; i<NUMPSPRITES; i++,psp++) @@ -772,16 +460,7 @@ void R_DrawPlayerSprites (void) R_DrawPSprite (psp); } } - - - - - - - vissprite_t vsprsortedhead; - - void R_SortVisSprites (void) { int i; @@ -790,27 +469,19 @@ void R_SortVisSprites (void) vissprite_t* best; vissprite_t unsorted; fixed_t bestscale; - count = vissprite_p - vissprites; - unsorted.next = unsorted.prev = &unsorted; - if (!count) return; - for (ds=vissprites ; ds<vissprite_p ; ds++) { ds->next = ds+1; ds->prev = ds-1; } - vissprites[0].prev = &unsorted; unsorted.next = &vissprites[0]; (vissprite_p-1)->next = &unsorted; unsorted.prev = vissprite_p-1; - - - vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead; for (i=0 ; i<count ; i++) { @@ -831,12 +502,6 @@ void R_SortVisSprites (void) vsprsortedhead.prev = best; } } - - - - - - void R_DrawSprite (vissprite_t* spr) { drawseg_t* ds; @@ -848,28 +513,19 @@ void R_DrawSprite (vissprite_t* spr) fixed_t scale; fixed_t lowscale; int silhouette; - for (x = spr->x1 ; x<=spr->x2 ; x++) clipbot[x] = cliptop[x] = -2; - - - - for (ds=ds_p-1 ; ds >= drawsegs ; ds--) { - if (ds->x1 > spr->x2 || ds->x2 < spr->x1 || (!ds->silhouette && !ds->maskedtexturecol) ) { - continue; } - r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1; r2 = ds->x2 > spr->x2 ? spr->x2 : ds->x2; - if (ds->scale1 > ds->scale2) { lowscale = ds->scale2; @@ -880,45 +536,33 @@ void R_DrawSprite (vissprite_t* spr) lowscale = ds->scale1; scale = ds->scale2; } - if (scale < spr->scale || ( lowscale < spr->scale && !R_PointOnSegSide (spr->gx, spr->gy, ds->curline) ) ) { - if (ds->maskedtexturecol) R_RenderMaskedSegRange (ds, r1, r2); - continue; } - - - silhouette = ds->silhouette; - if (spr->gz >= ds->bsilheight) silhouette &= ~SIL_BOTTOM; - if (spr->gzt <= ds->tsilheight) silhouette &= ~SIL_TOP; - if (silhouette == 1) { - for (x=r1 ; x<=r2 ; x++) if (clipbot[x] == -2) clipbot[x] = ds->sprbottomclip[x]; } else if (silhouette == 2) { - for (x=r1 ; x<=r2 ; x++) if (cliptop[x] == -2) cliptop[x] = ds->sprtopclip[x]; } else if (silhouette == 3) { - for (x=r1 ; x<=r2 ; x++) { if (clipbot[x] == -2) @@ -927,61 +571,35 @@ void R_DrawSprite (vissprite_t* spr) cliptop[x] = ds->sprtopclip[x]; } } - } - - - - for (x = spr->x1 ; x<=spr->x2 ; x++) { if (clipbot[x] == -2) clipbot[x] = viewheight; - if (cliptop[x] == -2) cliptop[x] = -1; } - mfloorclip = clipbot; mceilingclip = cliptop; R_DrawVisSprite (spr, spr->x1, spr->x2); } - - - - - - - void R_DrawMasked (void) { vissprite_t* spr; drawseg_t* ds; - R_SortVisSprites (); - if (vissprite_p > vissprites) { - for (spr = vsprsortedhead.next ; spr != &vsprsortedhead ; spr=spr->next) { - R_DrawSprite (spr); } } - - for (ds=ds_p-1 ; ds >= drawsegs ; ds--) if (ds->maskedtexturecol) R_RenderMaskedSegRange (ds, ds->x1, ds->x2); - - - if (!viewangleoffset) R_DrawPlayerSprites (); } - - - diff --git a/src/r_things.h b/src/r_things.h @@ -1,76 +1,31 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __R_THINGS__ #define __R_THINGS__ - - #ifdef __GNUG__ #pragma interface #endif - #define MAXVISSPRITES 128 - extern vissprite_t vissprites[MAXVISSPRITES]; extern vissprite_t* vissprite_p; extern vissprite_t vsprsortedhead; - - - extern short negonearray[SCREENWIDTH]; extern short screenheightarray[SCREENWIDTH]; - - extern short* mfloorclip; extern short* mceilingclip; extern fixed_t spryscale; extern fixed_t sprtopscreen; - extern fixed_t pspritescale; extern fixed_t pspriteiscale; - - void R_DrawMaskedColumn (column_t* column); - - void R_SortVisSprites (void); - void R_AddSprites (sector_t* sec); void R_AddPSprites (void); void R_DrawSprites (void); void R_InitSprites (char** namelist); void R_ClearSprites (void); void R_DrawMasked (void); - void R_ClipVisSprite ( vissprite_t* vis, int xl, int xh ); - - #endif - - - - - diff --git a/src/s_sound.c b/src/s_sound.c @@ -1,144 +1,51 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> #include <stdlib.h> - #include "i_system.h" #include "i_sound.h" #include "sounds.h" #include "s_sound.h" - #include "z_zone.h" #include "m_random.h" #include "w_wad.h" - #include "doomdef.h" #include "p_local.h" - #include "doomstat.h" - - - const char snd_prefixen[] = { 'P', 'P', 'A', 'S', 'S', 'S', 'M', 'M', 'M', 'S', 'S', 'S' }; - #define S_MAX_VOLUME 127 - - - #define S_CLIPPING_DIST (1200*0x10000) - - - - - #define S_CLOSE_DIST (160*0x10000) - - #define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS) - - #define NORM_VOLUME snd_MaxVolume - #define NORM_PITCH 128 #define NORM_PRIORITY 64 #define NORM_SEP 128 - #define S_PITCH_PERTURB 1 #define S_STEREO_SWING (96*0x10000) - - #define S_IFRACVOL 30 - #define NA 0 #define S_NUMCHANNELS 2 - - - - extern int snd_MusicDevice; extern int snd_SfxDevice; - extern int snd_DesiredMusicDevice; extern int snd_DesiredSfxDevice; - - - typedef struct { - sfxinfo_t* sfxinfo; - - void* origin; - - int handle; - } channel_t; - - - static channel_t* channels; - - - - int snd_SfxVolume = 15; - - int snd_MusicVolume = 15; - - - - static boolean mus_paused; - - static musicinfo_t* mus_playing=0; - - - - int numChannels; - static int nextcleanup; - - - - - - int S_getChannel ( void* origin, sfxinfo_t* sfxinfo ); - - int S_AdjustSoundParams ( mobj_t* listener, @@ -146,79 +53,38 @@ S_AdjustSoundParams int* vol, int* sep, int* pitch ); - void S_StopChannel(int cnum); - - - - - - - - void S_Init ( int sfxVolume, int musicVolume ) { int i; - fprintf( stderr, "S_Init: default sfx volume %d\n", sfxVolume); - - I_SetChannels(); - S_SetSfxVolume(sfxVolume); - S_SetMusicVolume(musicVolume); - - - - channels = (channel_t *) Z_Malloc(numChannels*sizeof(channel_t), PU_STATIC, 0); - - for (i=0 ; i<numChannels ; i++) channels[i].sfxinfo = 0; - - mus_paused = 0; - - for (i=1 ; i<NUMSFX ; i++) S_sfx[i].lumpnum = S_sfx[i].usefulness = -1; } - - - - - - - - - void S_Start(void) { int cnum; int mnum; - - - for (cnum=0 ; cnum<numChannels ; cnum++) if (channels[cnum].sfxinfo) S_StopChannel(cnum); - - mus_paused = 0; - if (gamemode == commercial) mnum = mus_runnin + gamemap - 1; else { int spmus[]= { - - mus_e3m4, mus_e3m2, mus_e3m3, @@ -229,64 +95,40 @@ void S_Start(void) mus_e2m5, mus_e1m9 }; - if (gameepisode < 4) mnum = mus_e1m1 + (gameepisode-1)*9 + gamemap-1; else mnum = spmus[gamemap-1]; } - - - - - S_ChangeMusic(mnum, true); - nextcleanup = 15; } - - - - - void S_StartSoundAtVolume ( void* origin_p, int sfx_id, int volume ) { - int rc; int sep; int pitch; int priority; sfxinfo_t* sfx; int cnum; - mobj_t* origin = (mobj_t *) origin_p; - - - /*fprintf( stderr, "S_StartSoundAtVolume: playing sound %d (%s)\n", sfx_id, S_sfx[sfx_id].name );*/ - - if (sfx_id < 1 || sfx_id > NUMSFX) I_Error("Bad sfx #: %d", sfx_id); - sfx = &S_sfx[sfx_id]; - - if (sfx->link) { pitch = sfx->pitch; priority = sfx->priority; volume += sfx->volume; - if (volume < 1) return; - if (volume > snd_SfxVolume) volume = snd_SfxVolume; } @@ -295,10 +137,6 @@ S_StartSoundAtVolume pitch = NORM_PITCH; priority = NORM_PRIORITY; } - - - - if (origin && origin != players[consoleplayer].mo) { rc = S_AdjustSoundParams(players[consoleplayer].mo, @@ -306,13 +144,11 @@ S_StartSoundAtVolume &volume, &sep, &pitch); - if ( origin->x == players[consoleplayer].mo->x && origin->y == players[consoleplayer].mo->y) { sep = NORM_SEP; } - if (!rc) return; } @@ -320,13 +156,10 @@ S_StartSoundAtVolume { sep = NORM_SEP; } - - if (sfx_id >= sfx_sawup && sfx_id <= sfx_sawhit) { pitch += 8 - (M_Random()&15); - if (pitch<0) pitch = 0; else if (pitch>255) @@ -336,54 +169,26 @@ S_StartSoundAtVolume && sfx_id != sfx_tink) { pitch += 16 - (M_Random()&31); - if (pitch<0) pitch = 0; else if (pitch>255) pitch = 255; } - - S_StopSound(origin); - - cnum = S_getChannel(origin, sfx); - if (cnum<0) return; - - - - - - - - if (sfx->lumpnum < 0) sfx->lumpnum = I_GetSfxLumpNum(sfx); - #ifndef SNDSRV - if (!sfx->data) { fprintf( stderr, "S_StartSoundAtVolume: 16bit and not pre-cached - wtf?\n"); - - - - - - - } #endif - - if (sfx->usefulness++ < 0) sfx->usefulness = 1; - - - channels[cnum].handle = I_StartSound(sfx_id, /*sfx->data,*/ volume, @@ -391,30 +196,21 @@ S_StartSoundAtVolume pitch, priority); } - void S_StartSound ( void* origin, int sfx_id ) { #ifdef SAWDEBUG - - #endif - S_StartSoundAtVolume(origin, sfx_id, snd_SfxVolume); - - - #ifdef SAWDEBUG { int i; int n; - static mobj_t* last_saw_origins[10] = {1,1,1,1,1,1,1,1,1,1}; static int first_saw=0; static int next_saw=0; - if (sfx_id == sfx_sawidl || sfx_id == sfx_sawful || sfx_id == sfx_sawhit) @@ -426,19 +222,16 @@ S_StartSound last_saw_origins[i], origin, sfx_id); - last_saw_origins[next_saw] = origin; next_saw = (next_saw + 1) % 10; if (next_saw == first_saw) first_saw = (first_saw + 1) % 10; - for (n=i=0; i<numChannels ; i++) { if (channels[i].sfxinfo == &S_sfx[sfx_sawidl] || channels[i].sfxinfo == &S_sfx[sfx_sawful] || channels[i].sfxinfo == &S_sfx[sfx_sawhit]) n++; } - if (n>1) { for (i=0; i<numChannels ; i++) @@ -460,17 +253,10 @@ S_StartSound } } #endif - } - - - - void S_StopSound(void *origin) { - int cnum; - for (cnum=0 ; cnum<numChannels ; cnum++) { if (channels[cnum].sfxinfo && channels[cnum].origin == origin) @@ -480,18 +266,6 @@ void S_StopSound(void *origin) } } } - - - - - - - - - - - - void S_PauseSound(void) { if (mus_playing && !mus_paused) @@ -500,7 +274,6 @@ void S_PauseSound(void) mus_paused = true; } } - void S_ResumeSound(void) { if (mus_playing && mus_paused) @@ -509,11 +282,6 @@ void S_ResumeSound(void) mus_paused = false; } } - - - - - void S_UpdateSounds(void* listener_p) { int audible; @@ -523,14 +291,7 @@ void S_UpdateSounds(void* listener_p) int pitch; sfxinfo_t* sfx; channel_t* c; - mobj_t* listener = (mobj_t*)listener_p; - - - - - - /*if (gametic > nextcleanup) { for (i=1 ; i<NUMSFX ; i++) @@ -547,21 +308,17 @@ void S_UpdateSounds(void* listener_p) } nextcleanup = gametic + 15; }*/ - for (cnum=0 ; cnum<numChannels ; cnum++) { c = &channels[cnum]; sfx = c->sfxinfo; - if (c->sfxinfo) { if (I_SoundIsPlaying(c->handle)) { - volume = snd_SfxVolume; pitch = NORM_PITCH; sep = NORM_SEP; - if (sfx->link) { pitch = sfx->pitch; @@ -576,9 +333,6 @@ void S_UpdateSounds(void* listener_p) volume = snd_SfxVolume; } } - - - if (c->origin && listener_p != c->origin) { audible = S_AdjustSoundParams(listener, @@ -586,7 +340,6 @@ void S_UpdateSounds(void* listener_p) &volume, &sep, &pitch); - if (!audible) { S_StopChannel(cnum); @@ -597,20 +350,11 @@ void S_UpdateSounds(void* listener_p) } else { - - S_StopChannel(cnum); } } } - - - - - } - - void S_SetMusicVolume(int volume) { if (volume < 0 || volume > 127) @@ -618,32 +362,20 @@ void S_SetMusicVolume(int volume) I_Error("Attempt to set music volume at %d", volume); } - I_SetMusicVolume(127); I_SetMusicVolume(volume); snd_MusicVolume = volume; } - - - void S_SetSfxVolume(int volume) { - if (volume < 0 || volume > 127) I_Error("Attempt to set sfx volume at %d", volume); - snd_SfxVolume = volume; - } - - - - void S_StartMusic(int m_id) { S_ChangeMusic(m_id, false); } - void S_ChangeMusic ( int musicnum, @@ -651,7 +383,6 @@ S_ChangeMusic { musicinfo_t* music; char namebuf[9]; - if ( (musicnum <= mus_None) || (musicnum >= NUMMUSIC) ) { @@ -659,59 +390,38 @@ S_ChangeMusic } else music = &S_music[musicnum]; - if (mus_playing == music) return; - - S_StopMusic(); - - if (!music->lumpnum) { sprintf(namebuf, "d_%s", music->name); music->lumpnum = W_GetNumForName(namebuf); } - - music->data = (void *) W_CacheLumpNum(music->lumpnum, PU_MUSIC); music->handle = I_RegisterSong(music->data); - - I_PlaySong(music->handle, looping); - mus_playing = music; } - - void S_StopMusic(void) { if (mus_playing) { if (mus_paused) I_ResumeSong(mus_playing->handle); - I_StopSong(mus_playing->handle); I_UnRegisterSong(mus_playing->handle); Z_ChangeTag(mus_playing->data, PU_CACHE); - mus_playing->data = 0; mus_playing = 0; } } - - - - void S_StopChannel(int cnum) { - int i; channel_t* c = &channels[cnum]; - if (c->sfxinfo) { - if (I_SoundIsPlaying(c->handle)) { #ifdef SAWDEBUG @@ -720,9 +430,6 @@ void S_StopChannel(int cnum) #endif I_StopSound(c->handle); } - - - for (i=0 ; i<numChannels ; i++) { if (cnum != i @@ -731,22 +438,10 @@ void S_StopChannel(int cnum) break; } } - - c->sfxinfo->usefulness--; - c->sfxinfo = 0; } } - - - - - - - - - int S_AdjustSoundParams ( mobj_t* listener, @@ -759,38 +454,24 @@ S_AdjustSoundParams fixed_t adx; fixed_t ady; angle_t angle; - - - adx = abs(listener->x - source->x); ady = abs(listener->y - source->y); - - approx_dist = adx + ady - ((adx < ady ? adx : ady)>>1); - if (gamemap != 8 && approx_dist > S_CLIPPING_DIST) { return 0; } - - angle = R_PointToAngle2(listener->x, listener->y, source->x, source->y); - if (angle > listener->angle) angle = angle - listener->angle; else angle = angle + (0xffffffff - listener->angle); - angle >>= ANGLETOFINESHIFT; - - *sep = 128 - (FixedMul(S_STEREO_SWING,finesine[angle])>>FRACBITS); - - if (approx_dist < S_CLOSE_DIST) { *vol = snd_SfxVolume; @@ -799,40 +480,25 @@ S_AdjustSoundParams { if (approx_dist > S_CLIPPING_DIST) approx_dist = S_CLIPPING_DIST; - *vol = 15+ ((snd_SfxVolume-15) *((S_CLIPPING_DIST - approx_dist)>>FRACBITS)) / S_ATTENUATOR; } else { - *vol = (snd_SfxVolume * ((S_CLIPPING_DIST - approx_dist)>>FRACBITS)) / S_ATTENUATOR; } - return (*vol > 0); } - - - - - - - - int S_getChannel ( void* origin, sfxinfo_t* sfxinfo ) { - int cnum; - channel_t* c; - - for (cnum=0 ; cnum<numChannels ; cnum++) { if (!channels[cnum].sfxinfo) @@ -843,35 +509,21 @@ S_getChannel break; } } - - if (cnum == numChannels) { - for (cnum=0 ; cnum<numChannels ; cnum++) if (channels[cnum].sfxinfo->priority >= sfxinfo->priority) break; - if (cnum == numChannels) { - return -1; } else { - S_StopChannel(cnum); } } - c = &channels[cnum]; - - c->sfxinfo = sfxinfo; c->origin = origin; - return cnum; } - - - - diff --git a/src/s_sound.h b/src/s_sound.h @@ -1,109 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __S_SOUND__ #define __S_SOUND__ - - #ifdef __GNUG__ #pragma interface #endif - - - - - - - - void S_Init ( int sfxVolume, int musicVolume ); - - - - - - - - - void S_Start(void); - - - - - - void S_StartSound ( void* origin, int sound_id ); - - - - void S_StartSoundAtVolume ( void* origin, int sound_id, int volume ); - - - void S_StopSound(void* origin); - - - void S_StartMusic(int music_id); - - - void S_ChangeMusic ( int music_id, int looping ); - - void S_StopMusic(void); - - void S_PauseSound(void); void S_ResumeSound(void); - - - - - void S_UpdateSounds(void* listener); - void S_SetMusicVolume(int volume); void S_SetSfxVolume(int volume); - - #endif - - - - - diff --git a/src/sounds.c b/src/sounds.c @@ -1,38 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - static const char - - #include "doomtype.h" #include "sounds.h" - - - - - musicinfo_t S_music[] = { { 0 }, @@ -104,17 +72,9 @@ musicinfo_t S_music[] = { "dm2ttl", 0 }, { "dm2int", 0 } }; - - - - - - sfxinfo_t S_sfx[] = { - { "none", false, 0, 0, -1, -1, 0 }, - { "pistol", false, 64, 0, -1, -1, 0 }, { "shotgn", false, 64, 0, -1, -1, 0 }, { "sgcock", false, 64, 0, -1, -1, 0 }, @@ -224,4 +184,3 @@ sfxinfo_t S_sfx[] = { "skeatk", false, 70, 0, -1, -1, 0 }, { "radio", false, 60, 0, -1, -1, 0 } }; - diff --git a/src/sounds.h b/src/sounds.h @@ -1,101 +1,27 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __SOUNDS__ #define __SOUNDS__ - - - - - typedef struct sfxinfo_struct sfxinfo_t; - struct sfxinfo_struct { - char* name; - - int singularity; - - int priority; - - sfxinfo_t* link; - - int pitch; - - int volume; - - void* data; - - - - int usefulness; - - int lumpnum; }; - - - - - - - typedef struct { - char* name; - - int lumpnum; - - void* data; - - int handle; - } musicinfo_t; - - - - - extern sfxinfo_t S_sfx[]; - - extern musicinfo_t S_music[]; - - - - - typedef enum { mus_None, @@ -168,12 +94,6 @@ typedef enum mus_dm2int, NUMMUSIC } musicenum_t; - - - - - - typedef enum { sfx_None, @@ -287,11 +207,4 @@ typedef enum sfx_radio, NUMSFX } sfxenum_t; - #endif - - - - - - diff --git a/src/st_lib.c b/src/st_lib.c @@ -1,65 +1,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - #include <ctype.h> - #include "doomdef.h" - #include "z_zone.h" #include "v_video.h" - #include "m_swap.h" - #include "i_system.h" - #include "w_wad.h" - #include "st_stuff.h" #include "st_lib.h" #include "r_local.h" - - - extern boolean automapactive; - - - - - - - - patch_t* sttminus; - void STlib_init(void) { sttminus = (patch_t *) W_CacheLumpName("STTMINUS", PU_STATIC); } - - - void STlib_initNum ( st_number_t* n, @@ -78,75 +32,45 @@ STlib_initNum n->on = on; n->p = pl; } - - - - - - - void STlib_drawNum ( st_number_t* n, boolean refresh ) { - int numdigits = n->width; int num = *n->num; - int w = SHORT(n->p[0]->width); int h = SHORT(n->p[0]->height); int x = n->x; - int neg; - n->oldnum = *n->num; - neg = num < 0; - if (neg) { if (numdigits == 2 && num < -9) num = -9; else if (numdigits == 3 && num < -99) num = -99; - num = -num; } - - x = n->x - numdigits*w; - if (n->y - ST_Y < 0) I_Error("drawNum: n->y - ST_Y < 0"); - V_CopyRect(x, n->y - ST_Y, BG, w*numdigits, h, x, n->y, FG); - - if (num == 1994) return; - x = n->x; - - if (!num) V_DrawPatch(x - w, n->y, FG, n->p[ 0 ]); - - while (num && numdigits--) { x -= w; V_DrawPatch(x, n->y, FG, n->p[ num % 10 ]); num /= 10; } - - if (neg) V_DrawPatch(x - 8, n->y, FG, sttminus); } - - - void STlib_updateNum ( st_number_t* n, @@ -154,9 +78,6 @@ STlib_updateNum { if (*n->on) STlib_drawNum(n, refresh); } - - - void STlib_initPercent ( st_percent_t* p, @@ -170,10 +91,6 @@ STlib_initPercent STlib_initNum(&p->n, x, y, pl, num, on, 3); p->p = percent; } - - - - void STlib_updatePercent ( st_percent_t* per, @@ -181,12 +98,8 @@ STlib_updatePercent { if (refresh && *per->n.on) V_DrawPatch(per->n.x, per->n.y, FG, per->p); - STlib_updateNum(&per->n, refresh); } - - - void STlib_initMultIcon ( st_multicon_t* i, @@ -203,9 +116,6 @@ STlib_initMultIcon i->on = on; i->p = il; } - - - void STlib_updateMultIcon ( st_multicon_t* mi, @@ -215,7 +125,6 @@ STlib_updateMultIcon int h; int x; int y; - if (*mi->on && (mi->oldinum != *mi->inum || refresh) && (*mi->inum!=-1)) @@ -226,19 +135,14 @@ STlib_updateMultIcon y = mi->y - SHORT(mi->p[mi->oldinum]->topoffset); w = SHORT(mi->p[mi->oldinum]->width); h = SHORT(mi->p[mi->oldinum]->height); - if (y - ST_Y < 0) I_Error("updateMultIcon: y - ST_Y < 0"); - V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG); } V_DrawPatch(mi->x, mi->y, FG, mi->p[*mi->inum]); mi->oldinum = *mi->inum; } } - - - void STlib_initBinIcon ( st_binicon_t* b, @@ -255,9 +159,6 @@ STlib_initBinIcon b->on = on; b->p = i; } - - - void STlib_updateBinIcon ( st_binicon_t* bi, @@ -267,7 +168,6 @@ STlib_updateBinIcon int y; int w; int h; - if (*bi->on && (bi->oldval != *bi->val || refresh)) { @@ -275,17 +175,12 @@ STlib_updateBinIcon y = bi->y - SHORT(bi->p->topoffset); w = SHORT(bi->p->width); h = SHORT(bi->p->height); - if (y - ST_Y < 0) I_Error("updateBinIcon: y - ST_Y < 0"); - if (*bi->val) V_DrawPatch(bi->x, bi->y, FG, bi->p); else V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG); - bi->oldval = *bi->val; } - } - diff --git a/src/st_lib.h b/src/st_lib.h @@ -1,157 +1,45 @@ - - - - - - - - - - - - - - - - - - - - - #ifndef __STLIB__ #define __STLIB__ - - - #include "r_defs.h" - - - - - #define BG 4 #define FG 0 - - - - - - - - - typedef struct { - - int x; int y; - - int width; - - int oldnum; - - int* num; - - - boolean* on; - - patch_t** p; - - int data; - } st_number_t; - - - - - typedef struct { - st_number_t n; - - patch_t* p; - } st_percent_t; - - - - typedef struct { - int x; int y; - - int oldinum; - - int* inum; - - - boolean* on; - - patch_t** p; - - int data; - } st_multicon_t; - - - - - - typedef struct { - int x; int y; - - int oldval; - - boolean* val; - - - boolean* on; - - patch_t* p; int data; - } st_binicon_t; - - - - - - - - - - - void STlib_init(void); - - - - void STlib_initNum ( st_number_t* n, @@ -161,14 +49,10 @@ STlib_initNum int* num, boolean* on, int width ); - void STlib_updateNum ( st_number_t* n, boolean refresh ); - - - void STlib_initPercent ( st_percent_t* p, @@ -178,15 +62,10 @@ STlib_initPercent int* num, boolean* on, patch_t* percent ); - - void STlib_updatePercent ( st_percent_t* per, int refresh ); - - - void STlib_initMultIcon ( st_multicon_t* mi, @@ -195,15 +74,10 @@ STlib_initMultIcon patch_t** il, int* inum, boolean* on ); - - void STlib_updateMultIcon ( st_multicon_t* mi, boolean refresh ); - - - void STlib_initBinIcon ( st_binicon_t* b, @@ -212,15 +86,8 @@ STlib_initBinIcon patch_t* i, boolean* val, boolean* on ); - void STlib_updateBinIcon ( st_binicon_t* bi, boolean refresh ); - #endif - - - - - diff --git a/src/st_stuff.c b/src/st_stuff.c @@ -1,166 +1,76 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> - #include "i_system.h" #include "i_video.h" #include "z_zone.h" #include "m_random.h" #include "w_wad.h" - #include "doomdef.h" - #include "g_game.h" - #include "st_stuff.h" #include "st_lib.h" #include "r_local.h" - #include "p_local.h" #include "p_inter.h" - #include "am_map.h" #include "m_cheat.h" - #include "s_sound.h" - - #include "v_video.h" - - #include "doomstat.h" - - #include "dstrings.h" #include "sounds.h" - - - - - - - - #define STARTREDPALS 1 #define STARTBONUSPALS 9 #define NUMREDPALS 8 #define NUMBONUSPALS 4 - #define RADIATIONPAL 13 - - - #define ST_FACEPROBABILITY 96 - - #define ST_TOGGLECHAT KEY_ENTER - - #define ST_X 0 #define ST_X2 104 - #define ST_FX 143 #define ST_FY 169 - - - #define ST_TALLNUMWIDTH (tallnum[0]->width) - - #define ST_NUMPAINFACES 5 #define ST_NUMSTRAIGHTFACES 3 #define ST_NUMTURNFACES 2 #define ST_NUMSPECIALFACES 3 - #define ST_FACESTRIDE \ (ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES) - #define ST_NUMEXTRAFACES 2 - #define ST_NUMFACES \ (ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES) - #define ST_TURNOFFSET (ST_NUMSTRAIGHTFACES) #define ST_OUCHOFFSET (ST_TURNOFFSET + ST_NUMTURNFACES) #define ST_EVILGRINOFFSET (ST_OUCHOFFSET + 1) #define ST_RAMPAGEOFFSET (ST_EVILGRINOFFSET + 1) #define ST_GODFACE (ST_NUMPAINFACES*ST_FACESTRIDE) #define ST_DEADFACE (ST_GODFACE+1) - #define ST_FACESX 143 #define ST_FACESY 168 - #define ST_EVILGRINCOUNT (2*TICRATE) #define ST_STRAIGHTFACECOUNT (TICRATE/2) #define ST_TURNCOUNT (1*TICRATE) #define ST_OUCHCOUNT (1*TICRATE) #define ST_RAMPAGEDELAY (2*TICRATE) - #define ST_MUCHPAIN 20 - - - - - - - - - - - #define ST_AMMOWIDTH 3 #define ST_AMMOX 44 #define ST_AMMOY 171 - - #define ST_HEALTHWIDTH 3 #define ST_HEALTHX 90 #define ST_HEALTHY 171 - - #define ST_ARMSX 111 #define ST_ARMSY 172 #define ST_ARMSBGX 104 #define ST_ARMSBGY 168 #define ST_ARMSXSPACE 12 #define ST_ARMSYSPACE 10 - - #define ST_FRAGSX 138 #define ST_FRAGSY 171 #define ST_FRAGSWIDTH 2 - - #define ST_ARMORWIDTH 3 #define ST_ARMORX 221 #define ST_ARMORY 171 - - #define ST_KEY0WIDTH 8 #define ST_KEY0HEIGHT 5 #define ST_KEY0X 239 @@ -171,8 +81,6 @@ #define ST_KEY2WIDTH ST_KEY0WIDTH #define ST_KEY2X 239 #define ST_KEY2Y 191 - - #define ST_AMMO0WIDTH 3 #define ST_AMMO0HEIGHT 6 #define ST_AMMO0X 288 @@ -186,9 +94,6 @@ #define ST_AMMO3WIDTH ST_AMMO0WIDTH #define ST_AMMO3X 288 #define ST_AMMO3Y 185 - - - #define ST_MAXAMMO0WIDTH 3 #define ST_MAXAMMO0HEIGHT 5 #define ST_MAXAMMO0X 314 @@ -202,240 +107,106 @@ #define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH #define ST_MAXAMMO3X 314 #define ST_MAXAMMO3Y 185 - - #define ST_WEAPON0X 110 #define ST_WEAPON0Y 172 - - #define ST_WEAPON1X 122 #define ST_WEAPON1Y 172 - - #define ST_WEAPON2X 134 #define ST_WEAPON2Y 172 - - #define ST_WEAPON3X 110 #define ST_WEAPON3Y 181 - - #define ST_WEAPON4X 122 #define ST_WEAPON4Y 181 - - #define ST_WEAPON5X 134 #define ST_WEAPON5Y 181 - - #define ST_WPNSX 109 #define ST_WPNSY 191 - - #define ST_DETHX 109 #define ST_DETHY 191 - - - - - #define ST_MSGTEXTX 0 #define ST_MSGTEXTY 0 - #define ST_MSGWIDTH 52 - #define ST_MSGHEIGHT 1 - #define ST_OUTTEXTX 0 #define ST_OUTTEXTY 6 - - #define ST_OUTWIDTH 52 - #define ST_OUTHEIGHT 1 - #define ST_MAPWIDTH \ (strlen(mapnames[(gameepisode-1)*9+(gamemap-1)])) - #define ST_MAPTITLEX \ (SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH) - #define ST_MAPTITLEY 0 #define ST_MAPHEIGHT 1 - - - static player_t* plyr; - - static boolean st_firsttime; - - static int veryfirsttime = 1; - - static int lu_palette; - - static unsigned int st_clock; - - static int st_msgcounter=0; - - static st_chatstateenum_t st_chatstate; - - static st_stateenum_t st_gamestate; - - static boolean st_statusbaron; - - static boolean st_chat; - - static boolean st_oldchat; - - static boolean st_cursoron; - - static boolean st_notdeathmatch; - - static boolean st_armson; - - static boolean st_fragson; - - static patch_t* sbar; - - static patch_t* tallnum[10]; - - static patch_t* tallpercent; - - static patch_t* shortnum[10]; - - static patch_t* keys[NUMCARDS]; - - static patch_t* faces[ST_NUMFACES]; - - static patch_t* faceback; - - static patch_t* armsbg; - - static patch_t* arms[6][2]; - - static st_number_t w_ready; - - static st_number_t w_frags; - - static st_percent_t w_health; - - static st_binicon_t w_armsbg; - - - static st_multicon_t w_arms[6]; - - static st_multicon_t w_faces; - - static st_multicon_t w_keyboxes[3]; - - static st_percent_t w_armor; - - static st_number_t w_ammo[4]; - - static st_number_t w_maxammo[4]; - - - - static int st_fragscount; - - static int st_oldhealth = -1; - - static boolean oldweaponsowned[NUMWEAPONS]; - - static int st_facecount = 0; - - static int st_faceindex = 0; - - static int keyboxes[3]; - - static int st_randomnumber; - - - - - - unsigned char cheat_mus_seq[] = { 0xb2, 0x26, 0xb6, 0xae, 0xea, 1, 0, 0, 0xff }; - unsigned char cheat_choppers_seq[] = { 0xb2, 0x26, 0xe2, 0x32, 0xf6, 0x2a, 0x2a, 0xa6, 0x6a, 0xea, 0xff }; - unsigned char cheat_god_seq[] = { 0xb2, 0x26, 0x26, 0xaa, 0x26, 0xff }; - unsigned char cheat_ammo_seq[] = { 0xb2, 0x26, 0xf2, 0x66, 0xa2, 0xff }; - unsigned char cheat_ammonokey_seq[] = { 0xb2, 0x26, 0x66, 0xa2, 0xff }; - - - unsigned char cheat_noclip_seq[] = { 0xb2, 0x26, 0xea, 0x2a, 0xb2, 0xea, 0x2a, 0xf6, 0x2a, 0x26, 0xff }; - - unsigned char cheat_commercial_noclip_seq[] = { 0xb2, 0x26, 0xe2, 0x36, 0xb2, 0x2a, 0xff }; - - - unsigned char cheat_powerup_seq[7][10] = { { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x6e, 0xff }, @@ -446,29 +217,20 @@ unsigned char cheat_powerup_seq[7][10] = { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0x36, 0xff }, { 0xb2, 0x26, 0x62, 0xa6, 0x32, 0xf6, 0x36, 0x26, 0xff } }; - - unsigned char cheat_clev_seq[] = { 0xb2, 0x26, 0xe2, 0x36, 0xa6, 0x6e, 1, 0, 0, 0xff }; - - - unsigned char cheat_mypos_seq[] = { 0xb2, 0x26, 0xb6, 0xba, 0x2a, 0xf6, 0xea, 0xff }; - - - cheatseq_t cheat_mus = { cheat_mus_seq, 0 }; cheatseq_t cheat_god = { cheat_god_seq, 0 }; cheatseq_t cheat_ammo = { cheat_ammo_seq, 0 }; cheatseq_t cheat_ammonokey = { cheat_ammonokey_seq, 0 }; cheatseq_t cheat_noclip = { cheat_noclip_seq, 0 }; cheatseq_t cheat_commercial_noclip = { cheat_commercial_noclip_seq, 0 }; - cheatseq_t cheat_powerup[7] = { { cheat_powerup_seq[0], 0 }, @@ -479,45 +241,25 @@ cheatseq_t cheat_powerup[7] = { cheat_powerup_seq[5], 0 }, { cheat_powerup_seq[6], 0 } }; - cheatseq_t cheat_choppers = { cheat_choppers_seq, 0 }; cheatseq_t cheat_clev = { cheat_clev_seq, 0 }; cheatseq_t cheat_mypos = { cheat_mypos_seq, 0 }; - - - extern char* mapnames[]; - - - - - void ST_Stop(void); - void ST_refreshBackground(void) { - if (st_statusbaron) { V_DrawPatch(ST_X, 0, BG, sbar); - if (netgame) V_DrawPatch(ST_FX, 0, BG, faceback); - V_CopyRect(ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG); } - } - - - - boolean ST_Responder (event_t* ev) { int i; - - if (ev->type == ev_keyup && ((ev->data1 & 0xffff0000) == AM_MSGHEADER)) { @@ -527,23 +269,15 @@ ST_Responder (event_t* ev) st_gamestate = AutomapState; st_firsttime = true; break; - case AM_MSGEXITED: - st_gamestate = FirstPersonState; break; } } - - else if (ev->type == ev_keydown) { if (!netgame) { - - - - if (cht_CheckCheat(&cheat_god, ev->data1)) { plyr->cheats ^= CF_GODMODE; @@ -551,58 +285,43 @@ ST_Responder (event_t* ev) { if (plyr->mo) plyr->mo->health = 100; - plyr->health = 100; plyr->message = STSTR_DQDON; } else plyr->message = STSTR_DQDOFF; } - else if (cht_CheckCheat(&cheat_ammonokey, ev->data1)) { plyr->armorpoints = 200; plyr->armortype = 2; - for (i=0;i<NUMWEAPONS;i++) plyr->weaponowned[i] = true; - for (i=0;i<NUMAMMO;i++) plyr->ammo[i] = plyr->maxammo[i]; - plyr->message = STSTR_FAADDED; } - else if (cht_CheckCheat(&cheat_ammo, ev->data1)) { plyr->armorpoints = 200; plyr->armortype = 2; - for (i=0;i<NUMWEAPONS;i++) plyr->weaponowned[i] = true; - for (i=0;i<NUMAMMO;i++) plyr->ammo[i] = plyr->maxammo[i]; - for (i=0;i<NUMCARDS;i++) plyr->cards[i] = true; - plyr->message = STSTR_KFAADDED; } - else if (cht_CheckCheat(&cheat_mus, ev->data1)) { - char buf[3]; int musnum; - plyr->message = STSTR_MUS; cht_GetParam(&cheat_mus, buf); - if (gamemode == commercial) { musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1; - if (((buf[0]-'0')*10 + buf[1]-'0') > 35) plyr->message = STSTR_NOMUS; else @@ -611,26 +330,21 @@ ST_Responder (event_t* ev) else { musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1'); - if (((buf[0]-'1')*9 + buf[1]-'1') > 31) plyr->message = STSTR_NOMUS; else S_ChangeMusic(musnum, 1); } } - - else if ( cht_CheckCheat(&cheat_noclip, ev->data1) || cht_CheckCheat(&cheat_commercial_noclip,ev->data1) ) { plyr->cheats ^= CF_NOCLIP; - if (plyr->cheats & CF_NOCLIP) plyr->message = STSTR_NCON; else plyr->message = STSTR_NCOFF; } - for (i=0;i<6;i++) { if (cht_CheckCheat(&cheat_powerup[i], ev->data1)) @@ -641,24 +355,19 @@ ST_Responder (event_t* ev) plyr->powers[i] = 1; else plyr->powers[i] = 0; - plyr->message = STSTR_BEHOLDX; } } - - if (cht_CheckCheat(&cheat_powerup[6], ev->data1)) { plyr->message = STSTR_BEHOLD; } - else if (cht_CheckCheat(&cheat_choppers, ev->data1)) { plyr->weaponowned[wp_chainsaw] = true; plyr->powers[pw_invulnerability] = true; plyr->message = STSTR_CHOPPERS; } - else if (cht_CheckCheat(&cheat_mypos, ev->data1)) { static char buf[ST_MSGWIDTH]; @@ -669,16 +378,12 @@ ST_Responder (event_t* ev) plyr->message = buf; } } - - if (cht_CheckCheat(&cheat_clev, ev->data1)) { char buf[3]; int epsd; int map; - cht_GetParam(&cheat_clev, buf); - if (gamemode == commercial) { epsd = 0; @@ -689,49 +394,34 @@ ST_Responder (event_t* ev) epsd = buf[0] - '0'; map = buf[1] - '0'; } - - if (epsd < 1) return false; - if (map < 1) return false; - - if ((gamemode == retail) && ((epsd > 4) || (map > 9))) return false; - if ((gamemode == registered) && ((epsd > 3) || (map > 9))) return false; - if ((gamemode == shareware) && ((epsd > 1) || (map > 9))) return false; - if ((gamemode == commercial) && (( epsd > 1) || (map > 34))) return false; - - plyr->message = STSTR_CLEV; G_DeferedInitNew(gameskill, epsd, map); } } return false; } - - - int ST_calcPainOffset(void) { int health; static int lastcalc; static int oldhealth = -1; - health = plyr->health > 100 ? 100 : plyr->health; - if (health != oldhealth) { lastcalc = ST_FACESTRIDE * (((100 - health) * ST_NUMPAINFACES) / 101); @@ -739,14 +429,6 @@ int ST_calcPainOffset(void) } return lastcalc; } - - - - - - - - void ST_updateFaceWidget(void) { int i; @@ -755,10 +437,8 @@ void ST_updateFaceWidget(void) static int lastattackdown = -1; static int priority = 0; boolean doevilgrin; - if (priority < 10) { - if (!plyr->health) { priority = 9; @@ -766,14 +446,11 @@ void ST_updateFaceWidget(void) st_facecount = 1; } } - if (priority < 9) { if (plyr->bonuscount) { - doevilgrin = false; - for (i=0;i<NUMWEAPONS;i++) { if (oldweaponsowned[i] != plyr->weaponowned[i]) @@ -784,24 +461,19 @@ void ST_updateFaceWidget(void) } if (doevilgrin) { - priority = 8; st_facecount = ST_EVILGRINCOUNT; st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET; } } - } - if (priority < 8) { if (plyr->damagecount && plyr->attacker && plyr->attacker != plyr->mo) { - priority = 7; - if (plyr->health - st_oldhealth > ST_MUCHPAIN) { st_facecount = ST_TURNCOUNT; @@ -813,46 +485,35 @@ void ST_updateFaceWidget(void) plyr->mo->y, plyr->attacker->x, plyr->attacker->y); - if (badguyangle > plyr->mo->angle) { - diffang = badguyangle - plyr->mo->angle; i = diffang > ANG180; } else { - diffang = plyr->mo->angle - badguyangle; i = diffang <= ANG180; } - - st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset(); - if (diffang < ANG45) { - st_faceindex += ST_RAMPAGEOFFSET; } else if (i) { - st_faceindex += ST_TURNOFFSET; } else { - st_faceindex += ST_TURNOFFSET+1; } } } } - if (priority < 7) { - if (plyr->damagecount) { if (plyr->health - st_oldhealth > ST_MUCHPAIN) @@ -867,14 +528,10 @@ void ST_updateFaceWidget(void) st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; } - } - } - if (priority < 6) { - if (plyr->attackdown) { if (lastattackdown==-1) @@ -889,86 +546,45 @@ void ST_updateFaceWidget(void) } else lastattackdown = -1; - } - if (priority < 5) { - if ((plyr->cheats & CF_GODMODE) || plyr->powers[pw_invulnerability]) { priority = 4; - st_faceindex = ST_GODFACE; st_facecount = 1; - } - } - - if (!st_facecount) { st_faceindex = ST_calcPainOffset() + (st_randomnumber % 3); st_facecount = ST_STRAIGHTFACECOUNT; priority = 0; } - st_facecount--; - } - void ST_updateWidgets(void) { static int largeammo = 1994; int i; - - - - if (weaponinfo[plyr->readyweapon].ammo == am_noammo) w_ready.num = &largeammo; else w_ready.num = &plyr->ammo[weaponinfo[plyr->readyweapon].ammo]; - - - - - - - - - w_ready.data = plyr->readyweapon; - - - - - - - for (i=0;i<3;i++) { keyboxes[i] = plyr->cards[i] ? i : -1; - if (plyr->cards[i+3]) keyboxes[i] = i+3; } - - ST_updateFaceWidget(); - - st_notdeathmatch = !deathmatch; - - st_armson = st_statusbaron && !deathmatch; - - st_fragson = deathmatch && st_statusbaron; st_fragscount = 0; - for (i=0 ; i<MAXPLAYERS ; i++) { if (i != consoleplayer) @@ -976,202 +592,124 @@ void ST_updateWidgets(void) else st_fragscount -= plyr->frags[i]; } - - if (!--st_msgcounter) st_chat = st_oldchat; - } - void ST_Ticker (void) { - st_clock++; st_randomnumber = M_Random(); ST_updateWidgets(); st_oldhealth = plyr->health; - } - static int st_palette = 0; - void ST_doPaletteStuff(void) { - int palette; byte* pal; int cnt; int bzc; - cnt = plyr->damagecount; - if (plyr->powers[pw_strength]) { - bzc = 12 - (plyr->powers[pw_strength]>>6); - if (bzc > cnt) cnt = bzc; } - if (cnt) { palette = (cnt+7)>>3; - if (palette >= NUMREDPALS) palette = NUMREDPALS-1; - palette += STARTREDPALS; } - else if (plyr->bonuscount) { palette = (plyr->bonuscount+7)>>3; - if (palette >= NUMBONUSPALS) palette = NUMBONUSPALS-1; - palette += STARTBONUSPALS; } - else if ( plyr->powers[pw_ironfeet] > 4*32 || plyr->powers[pw_ironfeet]&8) palette = RADIATIONPAL; else palette = 0; - if (palette != st_palette) { st_palette = palette; pal = (byte *) W_CacheLumpNum (lu_palette, PU_CACHE)+palette*768; I_SetPalette (pal); } - } - void ST_drawWidgets(boolean refresh) { int i; - - st_armson = st_statusbaron && !deathmatch; - - st_fragson = deathmatch && st_statusbaron; - STlib_updateNum(&w_ready, refresh); - for (i=0;i<4;i++) { STlib_updateNum(&w_ammo[i], refresh); STlib_updateNum(&w_maxammo[i], refresh); } - STlib_updatePercent(&w_health, refresh); STlib_updatePercent(&w_armor, refresh); - STlib_updateBinIcon(&w_armsbg, refresh); - for (i=0;i<6;i++) STlib_updateMultIcon(&w_arms[i], refresh); - STlib_updateMultIcon(&w_faces, refresh); - for (i=0;i<3;i++) STlib_updateMultIcon(&w_keyboxes[i], refresh); - STlib_updateNum(&w_frags, refresh); - } - void ST_doRefresh(void) { - st_firsttime = false; - - ST_refreshBackground(); - - ST_drawWidgets(true); - } - void ST_diffDraw(void) { - ST_drawWidgets(false); } - void ST_Drawer (boolean fullscreen, boolean refresh) { - st_statusbaron = (!fullscreen) || automapactive; st_firsttime = st_firsttime || refresh; - - ST_doPaletteStuff(); - - if (st_firsttime) ST_doRefresh(); - else ST_diffDraw(); - } - void ST_loadGraphics(void) { - int i; int j; int facenum; - char namebuf[9]; - - for (i=0;i<10;i++) { sprintf(namebuf, "STTNUM%d", i); tallnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); - sprintf(namebuf, "STYSNUM%d", i); shortnum[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); } - - - tallpercent = (patch_t *) W_CacheLumpName("STTPRCNT", PU_STATIC); - - for (i=0;i<NUMCARDS;i++) { sprintf(namebuf, "STKEYS%d", i); keys[i] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); } - - armsbg = (patch_t *) W_CacheLumpName("STARMS", PU_STATIC); - - for (i=0;i<6;i++) { sprintf(namebuf, "STGNUM%d", i+2); - - arms[i][0] = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); - - arms[i][1] = shortnum[i+2]; } - - sprintf(namebuf, "STFB%d", consoleplayer); faceback = (patch_t *) W_CacheLumpName(namebuf, PU_STATIC); - - sbar = (patch_t *) W_CacheLumpName("STBAR", PU_STATIC); - - facenum = 0; for (i=0;i<ST_NUMPAINFACES;i++) { @@ -1193,96 +731,58 @@ void ST_loadGraphics(void) } faces[facenum++] = W_CacheLumpName("STFGOD0", PU_STATIC); faces[facenum++] = W_CacheLumpName("STFDEAD0", PU_STATIC); - } - void ST_loadData(void) { lu_palette = W_GetNumForName ("PLAYPAL"); ST_loadGraphics(); } - void ST_unloadGraphics(void) { - int i; - - for (i=0;i<10;i++) { Z_ChangeTag(tallnum[i], PU_CACHE); Z_ChangeTag(shortnum[i], PU_CACHE); } - Z_ChangeTag(tallpercent, PU_CACHE); - - Z_ChangeTag(armsbg, PU_CACHE); - - for (i=0;i<6;i++) Z_ChangeTag(arms[i][0], PU_CACHE); - - for (i=0;i<NUMCARDS;i++) Z_ChangeTag(keys[i], PU_CACHE); - Z_ChangeTag(sbar, PU_CACHE); Z_ChangeTag(faceback, PU_CACHE); - for (i=0;i<ST_NUMFACES;i++) Z_ChangeTag(faces[i], PU_CACHE); - - - - - } - void ST_unloadData(void) { ST_unloadGraphics(); } - void ST_initData(void) { - int i; - st_firsttime = true; plyr = &players[consoleplayer]; - st_clock = 0; st_chatstate = StartChatState; st_gamestate = FirstPersonState; - st_statusbaron = true; st_oldchat = st_chat = false; st_cursoron = false; - st_faceindex = 0; st_palette = -1; - st_oldhealth = -1; - for (i=0;i<NUMWEAPONS;i++) oldweaponsowned[i] = plyr->weaponowned[i]; - for (i=0;i<3;i++) keyboxes[i] = -1; - STlib_init(); - } - - - void ST_createWidgets(void) { - int i; - - STlib_initNum(&w_ready, ST_AMMOX, ST_AMMOY, @@ -1290,11 +790,7 @@ void ST_createWidgets(void) &plyr->ammo[weaponinfo[plyr->readyweapon].ammo], &st_statusbaron, ST_AMMOWIDTH ); - - w_ready.data = plyr->readyweapon; - - STlib_initPercent(&w_health, ST_HEALTHX, ST_HEALTHY, @@ -1302,16 +798,12 @@ void ST_createWidgets(void) &plyr->health, &st_statusbaron, tallpercent); - - STlib_initBinIcon(&w_armsbg, ST_ARMSBGX, ST_ARMSBGY, armsbg, &st_notdeathmatch, &st_statusbaron); - - for(i=0;i<6;i++) { STlib_initMultIcon(&w_arms[i], @@ -1320,8 +812,6 @@ void ST_createWidgets(void) arms[i], (int *) &plyr->weaponowned[i+1], &st_armson); } - - STlib_initNum(&w_frags, ST_FRAGSX, ST_FRAGSY, @@ -1329,46 +819,36 @@ void ST_createWidgets(void) &st_fragscount, &st_fragson, ST_FRAGSWIDTH); - - STlib_initMultIcon(&w_faces, ST_FACESX, ST_FACESY, faces, &st_faceindex, &st_statusbaron); - - STlib_initPercent(&w_armor, ST_ARMORX, ST_ARMORY, tallnum, &plyr->armorpoints, &st_statusbaron, tallpercent); - - STlib_initMultIcon(&w_keyboxes[0], ST_KEY0X, ST_KEY0Y, keys, &keyboxes[0], &st_statusbaron); - STlib_initMultIcon(&w_keyboxes[1], ST_KEY1X, ST_KEY1Y, keys, &keyboxes[1], &st_statusbaron); - STlib_initMultIcon(&w_keyboxes[2], ST_KEY2X, ST_KEY2Y, keys, &keyboxes[2], &st_statusbaron); - - STlib_initNum(&w_ammo[0], ST_AMMO0X, ST_AMMO0Y, @@ -1376,7 +856,6 @@ void ST_createWidgets(void) &plyr->ammo[0], &st_statusbaron, ST_AMMO0WIDTH); - STlib_initNum(&w_ammo[1], ST_AMMO1X, ST_AMMO1Y, @@ -1384,7 +863,6 @@ void ST_createWidgets(void) &plyr->ammo[1], &st_statusbaron, ST_AMMO1WIDTH); - STlib_initNum(&w_ammo[2], ST_AMMO2X, ST_AMMO2Y, @@ -1392,7 +870,6 @@ void ST_createWidgets(void) &plyr->ammo[2], &st_statusbaron, ST_AMMO2WIDTH); - STlib_initNum(&w_ammo[3], ST_AMMO3X, ST_AMMO3Y, @@ -1400,8 +877,6 @@ void ST_createWidgets(void) &plyr->ammo[3], &st_statusbaron, ST_AMMO3WIDTH); - - STlib_initNum(&w_maxammo[0], ST_MAXAMMO0X, ST_MAXAMMO0Y, @@ -1409,7 +884,6 @@ void ST_createWidgets(void) &plyr->maxammo[0], &st_statusbaron, ST_MAXAMMO0WIDTH); - STlib_initNum(&w_maxammo[1], ST_MAXAMMO1X, ST_MAXAMMO1Y, @@ -1417,7 +891,6 @@ void ST_createWidgets(void) &plyr->maxammo[1], &st_statusbaron, ST_MAXAMMO1WIDTH); - STlib_initNum(&w_maxammo[2], ST_MAXAMMO2X, ST_MAXAMMO2Y, @@ -1425,7 +898,6 @@ void ST_createWidgets(void) &plyr->maxammo[2], &st_statusbaron, ST_MAXAMMO2WIDTH); - STlib_initNum(&w_maxammo[3], ST_MAXAMMO3X, ST_MAXAMMO3Y, @@ -1433,34 +905,23 @@ void ST_createWidgets(void) &plyr->maxammo[3], &st_statusbaron, ST_MAXAMMO3WIDTH); - } - static boolean st_stopped = true; - - void ST_Start (void) { - if (!st_stopped) ST_Stop(); - ST_initData(); ST_createWidgets(); st_stopped = false; - } - void ST_Stop (void) { if (st_stopped) return; - I_SetPalette (W_CacheLumpNum (lu_palette, PU_CACHE)); - st_stopped = true; } - void ST_Init (void) { veryfirsttime = 0; diff --git a/src/st_stuff.h b/src/st_stuff.h @@ -1,86 +1,25 @@ - - - - - - - - - - - - - - - - - - - - - - - #ifndef __STSTUFF_H__ #define __STSTUFF_H__ - #include "doomtype.h" #include "d_event.h" - - - #define ST_HEIGHT 32*SCREEN_MUL #define ST_WIDTH SCREENWIDTH #define ST_Y (SCREENHEIGHT - ST_HEIGHT) - - - - - - - boolean ST_Responder (event_t* ev); - - void ST_Ticker (void); - - void ST_Drawer (boolean fullscreen, boolean refresh); - - void ST_Start (void); - - void ST_Init (void); - - - - typedef enum { AutomapState, FirstPersonState - } st_stateenum_t; - - - typedef enum { StartChatState, WaitDestState, GetChatState - } st_chatstateenum_t; - - boolean ST_Responder(event_t* ev); - - - #endif - - - - - diff --git a/src/tables.c b/src/tables.c @@ -1,67 +1,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "tables.h" - - - - int SlopeDiv ( unsigned num, unsigned den) { unsigned ans; - if (den < 512) return SLOPERANGE; - ans = (num<<3)/(den>>8); - return ans <= SLOPERANGE ? ans : SLOPERANGE; } - - - - int finetangent[4096] = { -170910304,-56965752,-34178904,-24413316,-18988036,-15535599,-13145455,-11392683, @@ -577,8 +525,6 @@ int finetangent[4096] = 5512368,5892567,6329090,6835455,7429880,8137527,8994149,10052327, 11392683,13145455,15535599,18988036,24413316,34178904,56965752,170910304 }; - - int finesine[10240] = { 25,75,125,175,226,276,326,376, @@ -1862,9 +1808,6 @@ int finesine[10240] = 65531,65531,65532,65532,65533,65533,65534,65534, 65534,65535,65535,65535,65535,65535,65535,65535 }; - - - angle_t tantoangle[2049] = { 0,333772,667544,1001315,1335086,1668857,2002626,2336395, @@ -2125,4 +2068,3 @@ angle_t tantoangle[2049] = 535533216,535700704,535868128,536035456,536202720,536369888,536536992,536704000, 536870912 }; - diff --git a/src/tables.h b/src/tables.h @@ -1,100 +1,28 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #ifndef __TABLES__ #define __TABLES__ - - - #ifdef LINUX #include <math.h> #else #define PI 3.141592657 #endif - - #include "m_fixed.h" - #define FINEANGLES 8192 #define FINEMASK (FINEANGLES-1) - - - #define ANGLETOFINESHIFT 19 - - extern fixed_t finesine[5*FINEANGLES/4]; - - extern fixed_t* finecosine; - - - extern fixed_t finetangent[FINEANGLES/2]; - - #define ANG45 0x20000000 #define ANG90 0x40000000 #define ANG180 0x80000000 #define ANG270 0xc0000000 - - #define SLOPERANGE 2048 #define SLOPEBITS 11 #define DBITS (FRACBITS-SLOPEBITS) - typedef unsigned angle_t; - - - - - extern angle_t tantoangle[SLOPERANGE+1]; - - - - int SlopeDiv ( unsigned num, unsigned den); - - #endif - - - - - diff --git a/src/v_video.c b/src/v_video.c @@ -1,51 +1,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "i_system.h" #include "r_local.h" - #include "doomdef.h" #include "doomdata.h" - #include "m_bbox.h" #include "m_swap.h" - #include "v_video.h" - - - byte* screens[5]; - int dirtybox[4]; - - - - byte gammatable[5][256] = { {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, @@ -64,7 +25,6 @@ byte gammatable[5][256] = 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223, 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239, 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255}, - {2,4,5,7,8,10,11,12,14,15,16,18,19,20,21,23,24,25,26,27,29,30,31, 32,33,34,36,37,38,39,40,41,42,44,45,46,47,48,49,50,51,52,54,55, 56,57,58,59,60,61,62,63,64,65,66,67,69,70,71,72,73,74,75,76,77, @@ -80,7 +40,6 @@ byte gammatable[5][256] = 219,220,221,222,222,223,224,225,226,227,228,229,230,230,231,232, 233,234,235,236,237,237,238,239,240,241,242,243,244,245,245,246, 247,248,249,250,251,252,252,253,254,255}, - {4,7,9,11,13,15,17,19,21,22,24,26,27,29,30,32,33,35,36,38,39,40,42, 43,45,46,47,48,50,51,52,54,55,56,57,59,60,61,62,63,65,66,67,68,69, 70,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93, @@ -96,7 +55,6 @@ byte gammatable[5][256] = 229,230,231,231,232,233,234,235,235,236,237,238,238,239,240,241,241, 242,243,244,244,245,246,247,247,248,249,250,251,251,252,253,254,254, 255}, - {8,12,16,19,22,24,27,29,31,34,36,38,40,41,43,45,47,49,50,52,53,55, 57,58,60,61,63,64,65,67,68,70,71,72,74,75,76,77,79,80,81,82,84,85, 86,87,88,90,91,92,93,94,95,96,98,99,100,101,102,103,104,105,106,107, @@ -112,7 +70,6 @@ byte gammatable[5][256] = 231,231,232,233,233,234,235,235,236,237,237,238,238,239,240,240,241, 242,242,243,244,244,245,246,246,247,247,248,249,249,250,251,251,252, 253,253,254,254,255}, - {16,23,28,32,36,39,42,45,48,50,53,55,57,60,62,64,66,68,69,71,73,75,76, 78,80,81,83,84,86,87,89,90,92,93,94,96,97,98,100,101,102,103,105,106, 107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124, @@ -129,14 +86,7 @@ byte gammatable[5][256] = 243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251, 251,252,252,253,254,254,255,255} }; - - - int usegamma; - - - - void V_MarkRect ( int x, @@ -147,11 +97,6 @@ V_MarkRect M_AddToBox (dirtybox, x, y); M_AddToBox (dirtybox, x+width-1, y+height-1); } - - - - - void V_CopyRect ( int srcx, @@ -165,7 +110,6 @@ V_CopyRect { byte* src; byte* dest; - #ifdef RANGECHECK if (srcx<0 ||srcx+width >SCREENWIDTH @@ -181,10 +125,8 @@ V_CopyRect } #endif V_MarkRect (destx, desty, width, height); - src = screens[srcscrn]+SCREENWIDTH*srcy+srcx; dest = screens[destscrn]+SCREENWIDTH*desty+destx; - for ( ; height>0 ; height--) { memcpy (dest, src, width); @@ -192,12 +134,6 @@ V_CopyRect dest += SCREENWIDTH; } } - - - - - - void V_DrawPatch ( int x, @@ -205,7 +141,6 @@ V_DrawPatch int scrn, patch_t* patch ) { - int count; int col; column_t* column; @@ -213,7 +148,6 @@ V_DrawPatch byte* dest; byte* source; int w; - y -= SHORT(patch->topoffset); x -= SHORT(patch->leftoffset); #ifdef RANGECHECK @@ -224,31 +158,23 @@ V_DrawPatch || (unsigned)scrn>4) { fprintf( stderr, "Patch at %d,%d exceeds LFB\n", x,y ); - fprintf( stderr, "V_DrawPatch: bad patch (ignored)\n"); return; } #endif - if (!scrn) V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); - col = 0; desttop = screens[scrn]+y*SCREENWIDTH+x; - w = SHORT(patch->width); - for ( ; col<w ; x++, col++, desttop++) { column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); - - while (column->topdelta != 0xff ) { source = (byte *)column + 3; dest = desttop + column->topdelta*SCREENWIDTH; count = column->length; - while (count--) { *dest = *source++; @@ -259,12 +185,6 @@ V_DrawPatch } } } - - - - - - void V_DrawPatchFlipped ( int x, @@ -272,7 +192,6 @@ V_DrawPatchFlipped int scrn, patch_t* patch ) { - int count; int col; column_t* column; @@ -280,7 +199,6 @@ V_DrawPatchFlipped byte* dest; byte* source; int w; - y -= SHORT(patch->topoffset); x -= SHORT(patch->leftoffset); #ifdef RANGECHECK @@ -294,26 +212,19 @@ V_DrawPatchFlipped I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped"); } #endif - if (!scrn) V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); - col = 0; desttop = screens[scrn]+y*SCREENWIDTH+x; - w = SHORT(patch->width); - for ( ; col<w ; x++, col++, desttop++) { column = (column_t *)((byte *)patch + LONG(patch->columnofs[w-1-col])); - - while (column->topdelta != 0xff ) { source = (byte *)column + 3; dest = desttop + column->topdelta*SCREENWIDTH; count = column->length; - while (count--) { *dest = *source++; @@ -324,13 +235,6 @@ V_DrawPatchFlipped } } } - - - - - - - void V_DrawPatchDirect ( int x, @@ -339,7 +243,6 @@ V_DrawPatchDirect patch_t* patch ) { V_DrawPatch (x,y,scrn, patch); - /* int count; int col; @@ -348,10 +251,8 @@ V_DrawPatchDirect byte* dest; byte* source; int w; - y -= SHORT(patch->topoffset); x -= SHORT(patch->leftoffset); - #ifdef RANGECHECK if (x<0 ||x+SHORT(patch->width) >SCREENWIDTH @@ -362,24 +263,17 @@ V_DrawPatchDirect I_Error ("Bad V_DrawPatchDirect"); } #endif - - desttop = destscreen + y*SCREENWIDTH/4 + (x>>2); - w = SHORT(patch->width); for ( col = 0 ; col<w ; col++) { outp (SC_INDEX+1,1<<(x&3)); column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); - - - while (column->topdelta != 0xff ) { source = (byte *)column + 3; dest = desttop + column->topdelta*SCREENWIDTH/4; count = column->length; - while (count--) { *dest = *source++; @@ -392,13 +286,6 @@ V_DrawPatchDirect desttop++; }*/ } - - - - - - - void V_DrawBlock ( int x, @@ -409,7 +296,6 @@ V_DrawBlock byte* src ) { byte* dest; - #ifdef RANGECHECK if (x<0 ||x+width >SCREENWIDTH @@ -420,11 +306,8 @@ V_DrawBlock I_Error ("Bad V_DrawBlock"); } #endif - V_MarkRect (x, y, width, height); - dest = screens[scrn] + y*SCREENWIDTH+x; - while (height--) { memcpy (dest, src, width); @@ -432,13 +315,6 @@ V_DrawBlock dest += SCREENWIDTH; } } - - - - - - - void V_GetBlock ( int x, @@ -449,7 +325,6 @@ V_GetBlock byte* dest ) { byte* src; - #ifdef RANGECHECK if (x<0 ||x+width >SCREENWIDTH @@ -460,9 +335,7 @@ V_GetBlock I_Error ("Bad V_DrawBlock"); } #endif - src = screens[scrn] + y*SCREENWIDTH+x; - while (height--) { memcpy (dest, src, width); @@ -470,22 +343,11 @@ V_GetBlock dest += width; } } - - - - - - - void V_Init (void) { int i; byte* base; - - - base = I_AllocLow (SCREENWIDTH*SCREENHEIGHT*4); - for (i=0 ; i<4 ; i++) screens[i] = base + i*SCREENWIDTH*SCREENHEIGHT; } diff --git a/src/v_video.h b/src/v_video.h @@ -1,62 +1,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - #ifndef __V_VIDEO__ #define __V_VIDEO__ - #include "doomtype.h" - #include "doomdef.h" - - #include "r_data.h" - - - - - #define CENTERY (SCREENHEIGHT/2) - - - - - - - extern byte* screens[5]; - extern int dirtybox[4]; - extern byte gammatable[5][256]; extern int usegamma; - - - - void V_Init (void); - - void V_CopyRect ( int srcx, @@ -67,23 +19,18 @@ V_CopyRect int destx, int desty, int destscrn ); - void V_DrawPatch ( int x, int y, int scrn, patch_t* patch); - void V_DrawPatchDirect ( int x, int y, int scrn, patch_t* patch ); - - - void V_DrawBlock ( int x, @@ -92,8 +39,6 @@ V_DrawBlock int width, int height, byte* src ); - - void V_GetBlock ( int x, @@ -102,18 +47,10 @@ V_GetBlock int width, int height, byte* dest ); - - void V_MarkRect ( int x, int y, int width, int height ); - #endif - - - - - diff --git a/src/w_wad.c b/src/w_wad.c @@ -1,29 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #ifdef NORMALUNIX #include <ctype.h> #include <sys/types.h> @@ -35,51 +9,29 @@ #include <alloca.h> #define O_BINARY 0 #endif - #include "doomtype.h" #include "m_swap.h" #include "i_system.h" #include "z_zone.h" - #ifdef __GNUG__ #pragma implementation "w_wad.h" #endif #include "w_wad.h" - - - - - - - - - - - lumpinfo_t* lumpinfo; int numlumps; - void** lumpcache; - - #define strcmpi strcasecmp - void strupr (char* s) { while (*s) { *s = toupper(*s); s++; } } - int filelength (int handle) { struct stat fileinfo; - if (fstat (handle,&fileinfo) == -1) I_Error ("Error fstating"); - return fileinfo.st_size; } - - void ExtractFileBase ( char* path, @@ -87,55 +39,24 @@ ExtractFileBase { char* src; int length; - src = path + strlen(path) - 1; - - while (src != path && *(src-1) != '\\' && *(src-1) != '/') { src--; } - - memset (dest,0,8); length = 0; - while (*src && *src != '.') { if (++length == 9) I_Error ("Filename base of %s >8 chars",path); - *dest++ = toupper((int)*src++); } } - - - - - - - - - - - - - - - - - - - - - - int reloadlump; char* reloadname; - - void W_AddFile (char *filename) { wadinfo_t header; @@ -147,29 +68,21 @@ void W_AddFile (char *filename) filelump_t* fileinfo; filelump_t singleinfo; int storehandle; - - - - if (filename[0] == '~') { filename++; reloadname = filename; reloadlump = numlumps; } - if ( (handle = open (filename,O_RDONLY | O_BINARY)) == -1) { printf (" couldn't open %s\n",filename); return; } - printf (" adding %s\n",filename); startlump = numlumps; - if (strcmpi (filename+strlen(filename)-3 , "wad" ) ) { - fileinfo = &singleinfo; singleinfo.filepos = 0; singleinfo.size = LONG(filelength(handle)); @@ -178,18 +91,14 @@ void W_AddFile (char *filename) } else { - read (handle, &header, sizeof(header)); if (strncmp(header.identification,"IWAD",4)) { - if (strncmp(header.identification,"PWAD",4)) { I_Error ("Wad file %s doesn't have IWAD " "or PWAD id\n", filename); } - - } header.numlumps = LONG(header.numlumps); header.infotableofs = LONG(header.infotableofs); @@ -199,18 +108,11 @@ void W_AddFile (char *filename) read (handle, fileinfo, length); numlumps += header.numlumps; } - - - lumpinfo = realloc (lumpinfo, numlumps*sizeof(lumpinfo_t)); - if (!lumpinfo) I_Error ("Couldn't realloc lumpinfo"); - lump_p = &lumpinfo[startlump]; - storehandle = reloadname ? -1 : handle; - for (i=startlump ; i<numlumps ; i++,lump_p++, fileinfo++) { lump_p->handle = storehandle; @@ -218,19 +120,9 @@ void W_AddFile (char *filename) lump_p->size = LONG(fileinfo->size); strncpy (lump_p->name, fileinfo->name, 8); } - if (reloadname) close (handle); } - - - - - - - - - void W_Reload (void) { wadinfo_t header; @@ -240,13 +132,10 @@ void W_Reload (void) int handle; int length; filelump_t* fileinfo; - if (!reloadname) return; - if ( (handle = open (reloadname,O_RDONLY | O_BINARY)) == -1) I_Error ("W_Reload: couldn't open %s",reloadname); - read (handle, &header, sizeof(header)); lumpcount = LONG(header.numlumps); header.infotableofs = LONG(header.infotableofs); @@ -254,126 +143,59 @@ void W_Reload (void) fileinfo = alloca (length); lseek (handle, header.infotableofs, SEEK_SET); read (handle, fileinfo, length); - - lump_p = &lumpinfo[reloadlump]; - for (i=reloadlump ; i<reloadlump+lumpcount ; i++,lump_p++, fileinfo++) { if (lumpcache[i]) Z_Free (lumpcache[i]); - lump_p->position = LONG(fileinfo->filepos); lump_p->size = LONG(fileinfo->size); } - close (handle); } - - - - - - - - - - - - - - - - void W_InitMultipleFiles (char** filenames) { int size; - - numlumps = 0; - - lumpinfo = malloc(1); - for ( ; *filenames ; filenames++) W_AddFile (*filenames); - if (!numlumps) I_Error ("W_InitFiles: no files found"); - - size = numlumps * sizeof(*lumpcache); lumpcache = malloc (size); - if (!lumpcache) I_Error ("Couldn't allocate lumpcache"); - memset (lumpcache,0, size); } - - - - - - - - void W_InitFile (char* filename) { char* names[2]; - names[0] = filename; names[1] = NULL; W_InitMultipleFiles (names); } - - - - - - int W_NumLumps (void) { return numlumps; } - - - - - - - - int W_CheckNumForName (char* name) { union { char s[9]; int x[2]; - } name8; - int v1; int v2; lumpinfo_t* lump_p; - - strncpy (name8.s,name,8); - - name8.s[8] = 0; - - strupr (name8.s); - v1 = name8.x[0]; v2 = name8.x[1]; - - - lump_p = lumpinfo + numlumps; - while (lump_p-- != lumpinfo) { if ( *(int *)lump_p->name == v1 @@ -382,50 +204,22 @@ int W_CheckNumForName (char* name) return lump_p - lumpinfo; } } - - return -1; } - - - - - - - - int W_GetNumForName (char* name) { int i; - i = W_CheckNumForName (name); - if (i == -1) I_Error ("W_GetNumForName: %s not found!", name); - return i; } - - - - - - int W_LumpLength (int lump) { if (lump >= numlumps) I_Error ("W_LumpLength: %i >= numlumps",lump); - return lumpinfo[lump].size; } - - - - - - - - void W_ReadLump ( int lump, @@ -434,74 +228,43 @@ W_ReadLump int c; lumpinfo_t* l; int handle; - if (lump >= numlumps) I_Error ("W_ReadLump: %i >= numlumps",lump); - l = lumpinfo+lump; - - - if (l->handle == -1) { - if ( (handle = open (reloadname,O_RDONLY | O_BINARY)) == -1) I_Error ("W_ReadLump: couldn't open %s",reloadname); } else handle = l->handle; - lseek (handle, l->position, SEEK_SET); c = read (handle, dest, l->size); - if (c < l->size) I_Error ("W_ReadLump: only read %i of %i on lump %i", c,l->size,lump); - if (l->handle == -1) close (handle); - - } - - - - - - - void* W_CacheLumpNum ( int lump, int tag ) { byte* ptr; - if ((unsigned)lump >= numlumps) I_Error ("W_CacheLumpNum: %i >= numlumps",lump); - if (!lumpcache[lump]) { - - - ptr = Z_Malloc (W_LumpLength (lump), tag, &lumpcache[lump]); W_ReadLump (lump, lumpcache[lump]); } else { - Z_ChangeTag (lumpcache[lump],tag); } - return lumpcache[lump]; } - - - - - - void* W_CacheLumpName ( char* name, @@ -509,14 +272,8 @@ W_CacheLumpName { return W_CacheLumpNum (W_GetNumForName(name), tag); } - - - - - int info[2500][10]; int profilecount; - void W_Profile (void) { int i; @@ -526,8 +283,6 @@ void W_Profile (void) FILE* f; int j; char name[9]; - - for (i=0 ; i<numlumps ; i++) { ptr = lumpcache[i]; @@ -547,29 +302,20 @@ void W_Profile (void) info[i][profilecount] = ch; } profilecount++; - f = fopen ("waddump.txt","w"); name[8] = 0; - for (i=0 ; i<numlumps ; i++) { memcpy (name,lumpinfo[i].name,8); - for (j=0 ; j<8 ; j++) if (!name[j]) break; - for ( ; j<8 ; j++) name[j] = ' '; - fprintf (f,"%s ",name); - for (j=0 ; j<profilecount ; j++) fprintf (f," %c",info[i][j]); - fprintf (f,"\n"); } fclose (f); } - - diff --git a/src/w_wad.h b/src/w_wad.h @@ -1,58 +1,20 @@ - - - - - - - - - - - - - - - - - - - - - - #ifndef __W_WAD__ #define __W_WAD__ - - #ifdef __GNUG__ #pragma interface #endif - - - - - typedef struct { - char identification[4]; int numlumps; int infotableofs; - } wadinfo_t; - - typedef struct { int filepos; int size; char name[8]; - } filelump_t; - - - - typedef struct { char name[8]; @@ -60,30 +22,15 @@ typedef struct int position; int size; } lumpinfo_t; - - extern void** lumpcache; extern lumpinfo_t* lumpinfo; extern int numlumps; - void W_InitMultipleFiles (char** filenames); void W_Reload (void); - int W_CheckNumForName (char* name); int W_GetNumForName (char* name); - int W_LumpLength (int lump); void W_ReadLump (int lump, void *dest); - void* W_CacheLumpNum (int lump, int tag); void* W_CacheLumpName (char* name, int tag); - - - - #endif - - - - - diff --git a/src/wi_stuff.c b/src/wi_stuff.c @@ -1,180 +1,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include <stdio.h> - #include "z_zone.h" - #include "m_random.h" #include "m_swap.h" - #include "i_system.h" - #include "w_wad.h" - #include "g_game.h" - #include "r_local.h" #include "s_sound.h" - #include "doomstat.h" - - #include "sounds.h" - - #include "v_video.h" - #include "wi_stuff.h" - - - - - - - - - - - - - - #define NUMEPISODES 4 #define NUMMAPS 9 - - - - - - - - - - - - #define WI_TITLEY 2 #define WI_SPACINGY 33 - - #define SP_STATSX 50 #define SP_STATSY 50 - #define SP_TIMEX 16 #define SP_TIMEY (SCREENHEIGHT-32) - - - #define NG_STATSY 50 #define NG_STATSX (32 + SHORT(star->width)/2 + 32*!dofrags) - #define NG_SPACINGX 64 - - - #define DM_MATRIXX 42 #define DM_MATRIXY 68 - #define DM_SPACINGX 40 - #define DM_TOTALSX 269 - #define DM_KILLERSX 10 #define DM_KILLERSY 100 #define DM_VICTIMSX 5 #define DM_VICTIMSY 50 - - - - typedef enum { ANIM_ALWAYS, ANIM_RANDOM, ANIM_LEVEL - } animenum_t; - typedef struct { int x; int y; - } point_t; - - - - - - typedef struct { animenum_t type; - - int period; - - int nanims; - - point_t loc; - - - - int data1; - - - - int data2; - - patch_t* p[3]; - - - - int nexttic; - - int lastdrawn; - - int ctr; - - int state; - } anim_t; - - static point_t lnodes[NUMEPISODES][NUMMAPS] = { - { { 185, 164 }, { 148, 143 }, @@ -186,8 +68,6 @@ static point_t lnodes[NUMEPISODES][NUMMAPS] = { 135, 29 }, { 71, 24 } }, - - { { 254, 25 }, { 97, 50 }, @@ -199,8 +79,6 @@ static point_t lnodes[NUMEPISODES][NUMMAPS] = { 148, 140 }, { 235, 158 } }, - - { { 156, 168 }, { 48, 154 }, @@ -212,15 +90,7 @@ static point_t lnodes[NUMEPISODES][NUMMAPS] = { 140, 25 }, { 281, 136 } } - }; - - - - - - - static anim_t epsd0animinfo[] = { { ANIM_ALWAYS, TICRATE/3, 3, { 224, 104 } }, @@ -234,7 +104,6 @@ static anim_t epsd0animinfo[] = { ANIM_ALWAYS, TICRATE/3, 3, { 80, 16 } }, { ANIM_ALWAYS, TICRATE/3, 3, { 64, 24 } } }; - static anim_t epsd1animinfo[] = { { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 1 }, @@ -247,7 +116,6 @@ static anim_t epsd1animinfo[] = { ANIM_LEVEL, TICRATE/3, 3, { 192, 144 }, 8 }, { ANIM_LEVEL, TICRATE/3, 1, { 128, 136 }, 8 } }; - static anim_t epsd2animinfo[] = { { ANIM_ALWAYS, TICRATE/3, 3, { 104, 168 } }, @@ -257,212 +125,105 @@ static anim_t epsd2animinfo[] = { ANIM_ALWAYS, TICRATE/3, 3, { 120, 32 } }, { ANIM_ALWAYS, TICRATE/4, 3, { 40, 0 } } }; - static int NUMANIMS[NUMEPISODES] = { sizeof(epsd0animinfo)/sizeof(anim_t), sizeof(epsd1animinfo)/sizeof(anim_t), sizeof(epsd2animinfo)/sizeof(anim_t) }; - static anim_t *anims[NUMEPISODES] = { epsd0animinfo, epsd1animinfo, epsd2animinfo }; - - - - - - - - - #define FB 0 - - - #define SP_KILLS 0 #define SP_ITEMS 2 #define SP_SECRET 4 #define SP_FRAGS 6 #define SP_TIME 8 #define SP_PAR ST_TIME - #define SP_PAUSE 1 - - #define SHOWNEXTLOCDELAY 4 - - - - static int acceleratestage; - - static int me; - - static stateenum_t state; - - static wbstartstruct_t* wbs; - static wbplayerstruct_t* plrs; - - static int cnt; - - static int bcnt; - - static int firstrefresh; - static int cnt_kills[MAXPLAYERS]; static int cnt_items[MAXPLAYERS]; static int cnt_secret[MAXPLAYERS]; static int cnt_time; static int cnt_par; static int cnt_pause; - - static int NUMCMAPS; - - - - - - - static patch_t* bg; - - static patch_t* yah[2]; - - static patch_t* splat; - - static patch_t* percent; static patch_t* colon; - - static patch_t* num[10]; - - static patch_t* wiminus; - - static patch_t* finished; - - static patch_t* entering; - - static patch_t* sp_secret; - - static patch_t* kills; static patch_t* secret; static patch_t* items; static patch_t* frags; - - static patch_t* time; static patch_t* par; static patch_t* sucks; - - static patch_t* killers; static patch_t* victims; - - static patch_t* total; static patch_t* star; static patch_t* bstar; - - static patch_t* p[MAXPLAYERS]; - - static patch_t* bp[MAXPLAYERS]; - - static patch_t** lnames; - - - - - - - - - void WI_slamBackground(void) { memcpy(screens[0], screens[1], SCREENWIDTH * SCREENHEIGHT); V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); } - - - boolean WI_Responder(event_t* ev) { return false; } - - - void WI_drawLF(void) { int y = WI_TITLEY; - - V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->last]->width))/2, y, FB, lnames[wbs->last]); - - y += (5*SHORT(lnames[wbs->last]->height))/4; - V_DrawPatch((SCREENWIDTH - SHORT(finished->width))/2, y, FB, finished); } - - - - void WI_drawEL(void) { int y = WI_TITLEY; - - V_DrawPatch((SCREENWIDTH - SHORT(entering->width))/2, y, FB, entering); - - y += (5*SHORT(lnames[wbs->next]->height))/4; - V_DrawPatch((SCREENWIDTH - SHORT(lnames[wbs->next]->width))/2, y, FB, lnames[wbs->next]); - } - void WI_drawOnLnode ( int n, patch_t* c[] ) { - int i; int left; int top; int right; int bottom; boolean fits = false; - i = 0; do { @@ -470,7 +231,6 @@ WI_drawOnLnode top = lnodes[wbs->epsd][n].y - SHORT(c[i]->topoffset); right = left + SHORT(c[i]->width); bottom = top + SHORT(c[i]->height); - if (left >= 0 && right < SCREENWIDTH && top >= 0 @@ -483,7 +243,6 @@ WI_drawOnLnode i++; } } while (!fits && i!=2); - if (fits && i<2) { V_DrawPatch(lnodes[wbs->epsd][n].x, lnodes[wbs->epsd][n].y, @@ -491,32 +250,21 @@ WI_drawOnLnode } else { - printf("Could not place patch on level %d", n+1); } } - - - void WI_initAnimatedBack(void) { int i; anim_t* a; - if (gamemode == commercial) return; - if (wbs->epsd > 2) return; - for (i=0;i<NUMANIMS[wbs->epsd];i++) { a = &anims[wbs->epsd][i]; - - a->ctr = -1; - - if (a->type == ANIM_ALWAYS) a->nexttic = bcnt + 1 + (M_Random()%a->period); else if (a->type == ANIM_RANDOM) @@ -524,24 +272,18 @@ void WI_initAnimatedBack(void) else if (a->type == ANIM_LEVEL) a->nexttic = bcnt + 1; } - } - void WI_updateAnimatedBack(void) { int i; anim_t* a; - if (gamemode == commercial) return; - if (wbs->epsd > 2) return; - for (i=0;i<NUMANIMS[wbs->epsd];i++) { a = &anims[wbs->epsd][i]; - if (bcnt == a->nexttic) { switch (a->type) @@ -550,7 +292,6 @@ void WI_updateAnimatedBack(void) if (++a->ctr >= a->nanims) a->ctr = 0; a->nexttic = bcnt + a->period; break; - case ANIM_RANDOM: a->ctr++; if (a->ctr == a->nanims) @@ -560,9 +301,7 @@ void WI_updateAnimatedBack(void) } else a->nexttic = bcnt + a->period; break; - case ANIM_LEVEL: - if (!(state == StatCount && i == 7) && wbs->next == a->data1) { @@ -573,39 +312,23 @@ void WI_updateAnimatedBack(void) break; } } - } - } - void WI_drawAnimatedBack(void) { int i; anim_t* a; - if (commercial) return; - if (wbs->epsd > 2) return; - for (i=0 ; i<NUMANIMS[wbs->epsd] ; i++) { a = &anims[wbs->epsd][i]; - if (a->ctr >= 0) V_DrawPatch(a->loc.x, a->loc.y, FB, a->p[a->ctr]); } - } - - - - - - - - int WI_drawNum ( int x, @@ -613,24 +336,19 @@ WI_drawNum int n, int digits ) { - int fontwidth = SHORT(num[0]->width); int neg; int temp; - if (digits < 0) { if (!n) { - digits = 1; } else { - digits = 0; temp = n; - while (temp) { temp /= 10; @@ -638,31 +356,21 @@ WI_drawNum } } } - neg = n < 0; if (neg) n = -n; - - if (n == 1994) return 0; - - while (digits--) { x -= fontwidth; V_DrawPatch(x, y, FB, num[ n % 10 ]); n /= 10; } - - if (neg) V_DrawPatch(x-=8, y, FB, wiminus); - return x; - } - void WI_drawPercent ( int x, @@ -671,112 +379,77 @@ WI_drawPercent { if (p < 0) return; - V_DrawPatch(x, y, FB, percent); WI_drawNum(x, y, p, -1); } - - - - - - - void WI_drawTime ( int x, int y, int t ) { - int div; int n; - if (t<0) return; - if (t <= 61*59) { div = 1; - do { n = (t / div) % 60; x = WI_drawNum(x, y, n, 2) - SHORT(colon->width); div *= 60; - - if (div==60 || t / div) V_DrawPatch(x, y, FB, colon); - } while (t / div); } else { - V_DrawPatch(x - SHORT(sucks->width), y, FB, sucks); } } - - void WI_End(void) { void WI_unloadData(void); WI_unloadData(); } - void WI_initNoState(void) { state = NoState; acceleratestage = 0; cnt = 10; } - void WI_updateNoState(void) { - WI_updateAnimatedBack(); - if (!--cnt) { WI_End(); G_WorldDone(); } - } - static boolean snl_pointeron = false; - - void WI_initShowNextLoc(void) { state = ShowNextLoc; acceleratestage = 0; cnt = SHOWNEXTLOCDELAY * TICRATE; - WI_initAnimatedBack(); } - void WI_updateShowNextLoc(void) { WI_updateAnimatedBack(); - if (!--cnt || acceleratestage) WI_initNoState(); else snl_pointeron = (cnt & 31) < 20; } - void WI_drawShowNextLoc(void) { - int i; int last; - WI_slamBackground(); - - WI_drawAnimatedBack(); - if ( gamemode != commercial) { if (wbs->epsd > 2) @@ -784,40 +457,27 @@ void WI_drawShowNextLoc(void) WI_drawEL(); return; } - last = (wbs->last == 8) ? wbs->next - 1 : wbs->last; - - for (i=0 ; i<=last ; i++) WI_drawOnLnode(i, &splat); - - if (wbs->didsecret) WI_drawOnLnode(8, &splat); - - if (snl_pointeron) WI_drawOnLnode(wbs->next, yah); } - - if ( (gamemode != commercial) || wbs->next != 30) WI_drawEL(); - } - void WI_drawNoState(void) { snl_pointeron = true; WI_drawShowNextLoc(); } - int WI_fragSum(int playernum) { int i; int frags = 0; - for (i=0 ; i<MAXPLAYERS ; i++) { if (playeringame[i] @@ -826,36 +486,20 @@ int WI_fragSum(int playernum) frags += plrs[playernum].frags[i]; } } - - - frags -= plrs[playernum].frags[playernum]; - - - return frags; } - - - static int dm_state; static int dm_frags[MAXPLAYERS][MAXPLAYERS]; static int dm_totals[MAXPLAYERS]; - - - void WI_initDeathmatchStats(void) { - int i; int j; - state = StatCount; acceleratestage = 0; dm_state = 1; - cnt_pause = TICRATE; - for (i=0 ; i<MAXPLAYERS ; i++) { if (playeringame[i]) @@ -863,30 +507,20 @@ void WI_initDeathmatchStats(void) for (j=0 ; j<MAXPLAYERS ; j++) if (playeringame[j]) dm_frags[i][j] = 0; - dm_totals[i] = 0; } } - WI_initAnimatedBack(); } - - - void WI_updateDeathmatchStats(void) { - int i; int j; - boolean stillticking; - WI_updateAnimatedBack(); - if (acceleratestage && dm_state != 4) { acceleratestage = 0; - for (i=0 ; i<MAXPLAYERS ; i++) { if (playeringame[i]) @@ -894,24 +528,17 @@ void WI_updateDeathmatchStats(void) for (j=0 ; j<MAXPLAYERS ; j++) if (playeringame[j]) dm_frags[i][j] = plrs[i].frags[j]; - dm_totals[i] = WI_fragSum(i); } } - - S_StartSound(0, sfx_barexp); dm_state = 4; } - - if (dm_state == 2) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); - stillticking = false; - for (i=0 ; i<MAXPLAYERS ; i++) { if (playeringame[i]) @@ -925,39 +552,31 @@ void WI_updateDeathmatchStats(void) dm_frags[i][j]--; else dm_frags[i][j]++; - if (dm_frags[i][j] > 99) dm_frags[i][j] = 99; - if (dm_frags[i][j] < -99) dm_frags[i][j] = -99; - stillticking = true; } } dm_totals[i] = WI_fragSum(i); - if (dm_totals[i] > 99) dm_totals[i] = 99; - if (dm_totals[i] < -99) dm_totals[i] = -99; } - } if (!stillticking) { S_StartSound(0, sfx_barexp); dm_state++; } - } else if (dm_state == 4) { if (acceleratestage) { S_StartSound(0, sfx_slop); - if ( gamemode == commercial) WI_initNoState(); else @@ -973,41 +592,26 @@ void WI_updateDeathmatchStats(void) } } } - - - void WI_drawDeathmatchStats(void) { - int i; int j; int x; int y; int w; - int lh; - lh = WI_SPACINGY; - WI_slamBackground(); - - WI_drawAnimatedBack(); WI_drawLF(); - - V_DrawPatch(DM_TOTALSX-SHORT(total->width)/2, DM_MATRIXY-WI_SPACINGY+10, FB, total); - V_DrawPatch(DM_KILLERSX, DM_KILLERSY, FB, killers); V_DrawPatch(DM_VICTIMSX, DM_VICTIMSY, FB, victims); - - x = DM_MATRIXX + DM_SPACINGX; y = DM_MATRIXY; - for (i=0 ; i<MAXPLAYERS ; i++) { if (playeringame[i]) @@ -1016,19 +620,16 @@ void WI_drawDeathmatchStats(void) DM_MATRIXY - WI_SPACINGY, FB, p[i]); - V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2, y, FB, p[i]); - if (i == me) { V_DrawPatch(x-SHORT(p[i]->width)/2, DM_MATRIXY - WI_SPACINGY, FB, bstar); - V_DrawPatch(DM_MATRIXX-SHORT(p[i]->width)/2, y, FB, @@ -1037,30 +638,21 @@ void WI_drawDeathmatchStats(void) } else { - - - - } x += DM_SPACINGX; y += WI_SPACINGY; } - - y = DM_MATRIXY+10; w = SHORT(num[0]->width); - for (i=0 ; i<MAXPLAYERS ; i++) { x = DM_MATRIXX + DM_SPACINGX; - if (playeringame[i]) { for (j=0 ; j<MAXPLAYERS ; j++) { if (playeringame[j]) WI_drawNum(x+w, y, dm_frags[i][j], 2); - x += DM_SPACINGX; } WI_drawNum(DM_TOTALSX+w, y, dm_totals[i], 2); @@ -1068,89 +660,63 @@ void WI_drawDeathmatchStats(void) y += WI_SPACINGY; } } - static int cnt_frags[MAXPLAYERS]; static int dofrags; static int ng_state; - void WI_initNetgameStats(void) { - int i; - state = StatCount; acceleratestage = 0; ng_state = 1; - cnt_pause = TICRATE; - for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; - cnt_kills[i] = cnt_items[i] = cnt_secret[i] = cnt_frags[i] = 0; - dofrags += WI_fragSum(i); } - dofrags = !!dofrags; - WI_initAnimatedBack(); } - - - void WI_updateNetgameStats(void) { - int i; int fsum; - boolean stillticking; - WI_updateAnimatedBack(); - if (acceleratestage && ng_state != 10) { acceleratestage = 0; - for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; - cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills; cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems; cnt_secret[i] = (plrs[i].ssecret * 100) / wbs->maxsecret; - if (dofrags) cnt_frags[i] = WI_fragSum(i); } S_StartSound(0, sfx_barexp); ng_state = 10; } - if (ng_state == 2) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); - stillticking = false; - for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; - cnt_kills[i] += 2; - if (cnt_kills[i] >= (plrs[i].skills * 100) / wbs->maxkills) cnt_kills[i] = (plrs[i].skills * 100) / wbs->maxkills; else stillticking = true; } - if (!stillticking) { S_StartSound(0, sfx_barexp); @@ -1161,14 +727,11 @@ void WI_updateNetgameStats(void) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); - stillticking = false; - for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; - cnt_items[i] += 2; if (cnt_items[i] >= (plrs[i].sitems * 100) / wbs->maxitems) cnt_items[i] = (plrs[i].sitems * 100) / wbs->maxitems; @@ -1185,22 +748,17 @@ void WI_updateNetgameStats(void) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); - stillticking = false; - for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; - cnt_secret[i] += 2; - if (cnt_secret[i] >= (plrs[i].ssecret * 100) / wbs->maxsecret) cnt_secret[i] = (plrs[i].ssecret * 100) / wbs->maxsecret; else stillticking = true; } - if (!stillticking) { S_StartSound(0, sfx_barexp); @@ -1211,22 +769,17 @@ void WI_updateNetgameStats(void) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); - stillticking = false; - for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; - cnt_frags[i] += 1; - if (cnt_frags[i] >= (fsum = WI_fragSum(i))) cnt_frags[i] = fsum; else stillticking = true; } - if (!stillticking) { S_StartSound(0, sfx_pldeth); @@ -1253,66 +806,43 @@ void WI_updateNetgameStats(void) } } } - - - void WI_drawNetgameStats(void) { int i; int x; int y; int pwidth = SHORT(percent->width); - WI_slamBackground(); - - WI_drawAnimatedBack(); - WI_drawLF(); - - V_DrawPatch(NG_STATSX+NG_SPACINGX-SHORT(kills->width), NG_STATSY, FB, kills); - V_DrawPatch(NG_STATSX+2*NG_SPACINGX-SHORT(items->width), NG_STATSY, FB, items); - V_DrawPatch(NG_STATSX+3*NG_SPACINGX-SHORT(secret->width), NG_STATSY, FB, secret); - if (dofrags) V_DrawPatch(NG_STATSX+4*NG_SPACINGX-SHORT(frags->width), NG_STATSY, FB, frags); - - y = NG_STATSY + SHORT(kills->height); - for (i=0 ; i<MAXPLAYERS ; i++) { if (!playeringame[i]) continue; - x = NG_STATSX; V_DrawPatch(x-SHORT(p[i]->width), y, FB, p[i]); - if (i == me) V_DrawPatch(x-SHORT(p[i]->width), y, FB, star); - x += NG_SPACINGX; WI_drawPercent(x-pwidth, y+10, cnt_kills[i]); x += NG_SPACINGX; WI_drawPercent(x-pwidth, y+10, cnt_items[i]); x += NG_SPACINGX; WI_drawPercent(x-pwidth, y+10, cnt_secret[i]); x += NG_SPACINGX; - if (dofrags) WI_drawNum(x, y+10, cnt_frags[i], -1); - y += WI_SPACINGY; } - } - static int sp_state; - void WI_initStats(void) { state = StatCount; @@ -1321,15 +851,11 @@ void WI_initStats(void) cnt_kills[0] = cnt_items[0] = cnt_secret[0] = -1; cnt_time = cnt_par = -1; cnt_pause = TICRATE; - WI_initAnimatedBack(); } - void WI_updateStats(void) { - WI_updateAnimatedBack(); - if (acceleratestage && sp_state != 10) { acceleratestage = 0; @@ -1341,14 +867,11 @@ void WI_updateStats(void) S_StartSound(0, sfx_barexp); sp_state = 10; } - if (sp_state == 2) { cnt_kills[0] += 2; - if (!(bcnt&3)) S_StartSound(0, sfx_pistol); - if (cnt_kills[0] >= (plrs[me].skills * 100) / wbs->maxkills) { cnt_kills[0] = (plrs[me].skills * 100) / wbs->maxkills; @@ -1359,10 +882,8 @@ void WI_updateStats(void) else if (sp_state == 4) { cnt_items[0] += 2; - if (!(bcnt&3)) S_StartSound(0, sfx_pistol); - if (cnt_items[0] >= (plrs[me].sitems * 100) / wbs->maxitems) { cnt_items[0] = (plrs[me].sitems * 100) / wbs->maxitems; @@ -1373,10 +894,8 @@ void WI_updateStats(void) else if (sp_state == 6) { cnt_secret[0] += 2; - if (!(bcnt&3)) S_StartSound(0, sfx_pistol); - if (cnt_secret[0] >= (plrs[me].ssecret * 100) / wbs->maxsecret) { cnt_secret[0] = (plrs[me].ssecret * 100) / wbs->maxsecret; @@ -1384,23 +903,17 @@ void WI_updateStats(void) sp_state++; } } - else if (sp_state == 8) { if (!(bcnt&3)) S_StartSound(0, sfx_pistol); - cnt_time += 3; - if (cnt_time >= plrs[me].stime / TICRATE) cnt_time = plrs[me].stime / TICRATE; - cnt_par += 3; - if (cnt_par >= wbs->partime / TICRATE) { cnt_par = wbs->partime / TICRATE; - if (cnt_time >= plrs[me].stime / TICRATE) { S_StartSound(0, sfx_barexp); @@ -1413,7 +926,6 @@ void WI_updateStats(void) if (acceleratestage) { S_StartSound(0, sfx_sgcock); - if (gamemode == commercial) WI_initNoState(); else @@ -1428,49 +940,32 @@ void WI_updateStats(void) cnt_pause = TICRATE; } } - } - void WI_drawStats(void) { - int lh; - lh = (3*SHORT(num[0]->height))/2; - WI_slamBackground(); - - WI_drawAnimatedBack(); - WI_drawLF(); - V_DrawPatch(SP_STATSX, SP_STATSY, FB, kills); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY, cnt_kills[0]); - V_DrawPatch(SP_STATSX, SP_STATSY+lh, FB, items); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+lh, cnt_items[0]); - V_DrawPatch(SP_STATSX, SP_STATSY+2*lh, FB, sp_secret); WI_drawPercent(SCREENWIDTH - SP_STATSX, SP_STATSY+2*lh, cnt_secret[0]); - V_DrawPatch(SP_TIMEX, SP_TIMEY, FB, time); WI_drawTime(SCREENWIDTH/2 - SP_TIMEX, SP_TIMEY, cnt_time); - if (wbs->epsd < 3) { V_DrawPatch(SCREENWIDTH/2 + SP_TIMEX, SP_TIMEY, FB, par); WI_drawTime(SCREENWIDTH - SP_TIMEX, SP_TIMEY, cnt_par); } - } - void WI_checkForAccelerate(void) { int i; player_t *player; - - for (i=0, player = players ; i<MAXPLAYERS ; i++, player++) { if (playeringame[i]) @@ -1494,26 +989,17 @@ void WI_checkForAccelerate(void) } } } - - - - void WI_Ticker(void) { - bcnt++; - if (bcnt == 1) { - if ( gamemode == commercial ) S_ChangeMusic(mus_dm2int, true); else S_ChangeMusic(mus_inter, true); } - WI_checkForAccelerate(); - switch (state) { case StatCount: @@ -1521,52 +1007,31 @@ void WI_Ticker(void) else if (netgame) WI_updateNetgameStats(); else WI_updateStats(); break; - case ShowNextLoc: WI_updateShowNextLoc(); break; - case NoState: WI_updateNoState(); break; } - } - void WI_loadData(void) { int i; int j; char name[9]; anim_t* a; - if (gamemode == commercial) strcpy(name, "INTERPIC"); else sprintf(name, "WIMAP%d", wbs->epsd); - if ( gamemode == retail ) { if (wbs->epsd == 3) strcpy(name,"INTERPIC"); } - - bg = W_CacheLumpName(name, PU_CACHE); V_DrawPatch(0, 0, 1, bg); - - - - - - - - - - - - - if (gamemode == commercial) { NUMCMAPS = 32; @@ -1587,16 +1052,9 @@ void WI_loadData(void) sprintf(name, "WILV%d%d", wbs->epsd, i); lnames[i] = W_CacheLumpName(name, PU_STATIC); } - - yah[0] = W_CacheLumpName("WIURH0", PU_STATIC); - - yah[1] = W_CacheLumpName("WIURH1", PU_STATIC); - - splat = W_CacheLumpName("WISPLAT", PU_STATIC); - if (wbs->epsd < 3) { for (j=0;j<NUMANIMS[wbs->epsd];j++) @@ -1604,115 +1062,64 @@ void WI_loadData(void) a = &anims[wbs->epsd][j]; for (i=0;i<a->nanims;i++) { - if (wbs->epsd != 1 || j != 8) { - sprintf(name, "WIA%d%.2d%.2d", wbs->epsd, j, i); a->p[i] = W_CacheLumpName(name, PU_STATIC); } else { - a->p[i] = anims[1][4].p[i]; } } } } } - - wiminus = W_CacheLumpName("WIMINUS", PU_STATIC); - for (i=0;i<10;i++) { - sprintf(name, "WINUM%d", i); num[i] = W_CacheLumpName(name, PU_STATIC); } - - percent = W_CacheLumpName("WIPCNT", PU_STATIC); - - finished = W_CacheLumpName("WIF", PU_STATIC); - - entering = W_CacheLumpName("WIENTER", PU_STATIC); - - kills = W_CacheLumpName("WIOSTK", PU_STATIC); - - secret = W_CacheLumpName("WIOSTS", PU_STATIC); - - sp_secret = W_CacheLumpName("WISCRT2", PU_STATIC); - - if (french) { - if (netgame && !deathmatch) items = W_CacheLumpName("WIOBJ", PU_STATIC); else items = W_CacheLumpName("WIOSTI", PU_STATIC); } else items = W_CacheLumpName("WIOSTI", PU_STATIC); - - frags = W_CacheLumpName("WIFRGS", PU_STATIC); - - colon = W_CacheLumpName("WICOLON", PU_STATIC); - - time = W_CacheLumpName("WITIME", PU_STATIC); - - sucks = W_CacheLumpName("WISUCKS", PU_STATIC); - - par = W_CacheLumpName("WIPAR", PU_STATIC); - - killers = W_CacheLumpName("WIKILRS", PU_STATIC); - - victims = W_CacheLumpName("WIVCTMS", PU_STATIC); - - total = W_CacheLumpName("WIMSTT", PU_STATIC); - - star = W_CacheLumpName("STFST01", PU_STATIC); - - bstar = W_CacheLumpName("STFDEAD0", PU_STATIC); - for (i=0 ; i<MAXPLAYERS ; i++) { - sprintf(name, "STPB%d", i); p[i] = W_CacheLumpName(name, PU_STATIC); - - sprintf(name, "WIBP%d", i+1); bp[i] = W_CacheLumpName(name, PU_STATIC); } - } - void WI_unloadData(void) { int i; int j; - Z_ChangeTag(wiminus, PU_CACHE); - for (i=0 ; i<10 ; i++) Z_ChangeTag(num[i], PU_CACHE); - if (gamemode == commercial) { for (i=0 ; i<NUMCMAPS ; i++) @@ -1722,12 +1129,9 @@ void WI_unloadData(void) { Z_ChangeTag(yah[0], PU_CACHE); Z_ChangeTag(yah[1], PU_CACHE); - Z_ChangeTag(splat, PU_CACHE); - for (i=0 ; i<NUMMAPS ; i++) Z_ChangeTag(lnames[i], PU_CACHE); - if (wbs->epsd < 3) { for (j=0;j<NUMANIMS[wbs->epsd];j++) @@ -1738,9 +1142,7 @@ void WI_unloadData(void) } } } - Z_Free(lnames); - Z_ChangeTag(percent, PU_CACHE); Z_ChangeTag(colon, PU_CACHE); Z_ChangeTag(finished, PU_CACHE); @@ -1753,20 +1155,14 @@ void WI_unloadData(void) Z_ChangeTag(time, PU_CACHE); Z_ChangeTag(sucks, PU_CACHE); Z_ChangeTag(par, PU_CACHE); - Z_ChangeTag(victims, PU_CACHE); Z_ChangeTag(killers, PU_CACHE); Z_ChangeTag(total, PU_CACHE); - - - for (i=0 ; i<MAXPLAYERS ; i++) Z_ChangeTag(p[i], PU_CACHE); - for (i=0 ; i<MAXPLAYERS ; i++) Z_ChangeTag(bp[i], PU_CACHE); } - void WI_Drawer (void) { switch (state) @@ -1779,23 +1175,17 @@ void WI_Drawer (void) else WI_drawStats(); break; - case ShowNextLoc: WI_drawShowNextLoc(); break; - case NoState: WI_drawNoState(); break; } } - - void WI_initVariables(wbstartstruct_t* wbstartstruct) { - wbs = wbstartstruct; - #ifdef RANGECHECKING if (gamemode != commercial) { @@ -1812,33 +1202,25 @@ void WI_initVariables(wbstartstruct_t* wbstartstruct) RNGCHECK(wbs->pnum, 0, MAXPLAYERS); RNGCHECK(wbs->pnum, 0, MAXPLAYERS); #endif - acceleratestage = 0; cnt = bcnt = 0; firstrefresh = 1; me = wbs->pnum; plrs = wbs->plyr; - if (!wbs->maxkills) wbs->maxkills = 1; - if (!wbs->maxitems) wbs->maxitems = 1; - if (!wbs->maxsecret) wbs->maxsecret = 1; - if ( gamemode != retail ) if (wbs->epsd > 2) wbs->epsd -= 3; } - void WI_Start(wbstartstruct_t* wbstartstruct) { - WI_initVariables(wbstartstruct); WI_loadData(); - if (deathmatch) WI_initDeathmatchStats(); else if (netgame) diff --git a/src/wi_stuff.h b/src/wi_stuff.h @@ -1,54 +1,13 @@ - - - - - - - - - - - - - - - - - - - - - #ifndef __WI_STUFF__ #define __WI_STUFF__ - - - #include "doomdef.h" - - - typedef enum { NoState = -1, StatCount, ShowNextLoc - } stateenum_t; - - void WI_Ticker (void); - - - void WI_Drawer (void); - - void WI_Start(wbstartstruct_t* wbstartstruct); - #endif - - - - - diff --git a/src/z_zone.c b/src/z_zone.c @@ -1,183 +1,78 @@ - - - - - - - - - - - - - - - - - - - - - - - - #include "z_zone.h" #include "i_system.h" #include "doomdef.h" - - - - - - - - - - - - - #define ZONEID 0x1d4a11 - - typedef struct { - int size; - - memblock_t blocklist; - memblock_t* rover; - } memzone_t; - - - memzone_t* mainzone; - - - - - - void Z_ClearZone (memzone_t* zone) { memblock_t* block; - - zone->blocklist.next = zone->blocklist.prev = block = (memblock_t *)( (byte *)zone + sizeof(memzone_t) ); - zone->blocklist.user = (void *)zone; zone->blocklist.tag = PU_STATIC; zone->rover = block; - block->prev = block->next = &zone->blocklist; - - block->user = NULL; - block->size = zone->size - sizeof(memzone_t); } - - - - - - void Z_Init (void) { memblock_t* block; int size; - mainzone = (memzone_t *)I_ZoneBase (&size); mainzone->size = size; - - mainzone->blocklist.next = mainzone->blocklist.prev = block = (memblock_t *)( (byte *)mainzone + sizeof(memzone_t) ); - mainzone->blocklist.user = (void *)mainzone; mainzone->blocklist.tag = PU_STATIC; mainzone->rover = block; - block->prev = block->next = &mainzone->blocklist; - - block->user = NULL; - block->size = mainzone->size - sizeof(memzone_t); } - - - - - void Z_Free (void* ptr) { memblock_t* block; memblock_t* other; - block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); - if (block->id != ZONEID) I_Error ("Z_Free: freed a pointer without ZONEID"); - if (block->user > (void **)0x100) { - - - - *block->user = 0; } - - block->user = NULL; block->tag = 0; block->id = 0; - other = block->prev; - if (!other->user) { - other->size += block->size; other->next = block->next; other->next->prev = other; - if (block == mainzone->rover) mainzone->rover = other; - block = other; } - other = block->next; if (!other->user) { - block->size += other->size; block->next = other->next; block->next->prev = block; - if (other == mainzone->rover) mainzone->rover = block; } } - - - - - - - #define MINFRAGMENT 64 - - void* Z_Malloc ( int size, @@ -189,48 +84,27 @@ Z_Malloc memblock_t* rover; memblock_t* newblock; memblock_t* base; - size = (size + 3) & ~3; - - - - - - - size += sizeof(memblock_t); - - - base = mainzone->rover; - if (!base->prev->user) base = base->prev; - rover = base; start = base->prev; - do { if (rover == start) { - I_Error ("Z_Malloc: failed on allocation of %i bytes", size); } - if (rover->user) { if (rover->tag < PU_PURGELEVEL) { - - base = rover = rover->next; } else { - - - base = base->prev; Z_Free ((byte *)rover+sizeof(memblock_t)); base = base->next; @@ -240,31 +114,21 @@ Z_Malloc else rover = rover->next; } while (base->user || base->size < size); - - - extra = base->size - size; - if (extra > MINFRAGMENT) { - newblock = (memblock_t *) ((byte *)base + size ); newblock->size = extra; - - newblock->user = NULL; newblock->tag = 0; newblock->prev = base; newblock->next = base->next; newblock->next->prev = newblock; - base->next = newblock; base->size = size; } - if (user) { - base->user = user; *(void **)user = (void *) ((byte *)base + sizeof(memblock_t)); } @@ -272,25 +136,13 @@ Z_Malloc { if (tag >= PU_PURGELEVEL) I_Error ("Z_Malloc: an owner is required for purgable blocks"); - - base->user = (void *)2; } base->tag = tag; - - mainzone->rover = base->next; - base->id = ZONEID; - return (void *) ((byte *)base + sizeof(memblock_t)); } - - - - - - void Z_FreeTags ( int lowtag, @@ -298,161 +150,99 @@ Z_FreeTags { memblock_t* block; memblock_t* next; - for (block = mainzone->blocklist.next ; block != &mainzone->blocklist ; block = next) { - next = block->next; - - if (!block->user) continue; - if (block->tag >= lowtag && block->tag <= hightag) Z_Free ( (byte *)block+sizeof(memblock_t)); } } - - - - - - - void Z_DumpHeap ( int lowtag, int hightag ) { memblock_t* block; - printf ("zone size: %i location: %p\n", mainzone->size,mainzone); - printf ("tag range: %i to %i\n", lowtag, hightag); - for (block = mainzone->blocklist.next ; ; block = block->next) { if (block->tag >= lowtag && block->tag <= hightag) printf ("block:%p size:%7i user:%p tag:%3i\n", block, block->size, block->user, block->tag); - if (block->next == &mainzone->blocklist) { - break; } - if ( (byte *)block + block->size != (byte *)block->next) printf ("ERROR: block size does not touch the next block\n"); - if ( block->next->prev != block) printf ("ERROR: next block doesn't have proper back link\n"); - if (!block->user && !block->next->user) printf ("ERROR: two consecutive free blocks\n"); } } - - - - - void Z_FileDumpHeap (FILE* f) { memblock_t* block; - fprintf (f,"zone size: %i location: %p\n",mainzone->size,mainzone); - for (block = mainzone->blocklist.next ; ; block = block->next) { fprintf (f,"block:%p size:%7i user:%p tag:%3i\n", block, block->size, block->user, block->tag); - if (block->next == &mainzone->blocklist) { - break; } - if ( (byte *)block + block->size != (byte *)block->next) fprintf (f,"ERROR: block size does not touch the next block\n"); - if ( block->next->prev != block) fprintf (f,"ERROR: next block doesn't have proper back link\n"); - if (!block->user && !block->next->user) fprintf (f,"ERROR: two consecutive free blocks\n"); } } - - - - - - void Z_CheckHeap (void) { memblock_t* block; - for (block = mainzone->blocklist.next ; ; block = block->next) { if (block->next == &mainzone->blocklist) { - break; } - if ( (byte *)block + block->size != (byte *)block->next) I_Error ("Z_CheckHeap: block size does not touch the next block\n"); - if ( block->next->prev != block) I_Error ("Z_CheckHeap: next block doesn't have proper back link\n"); - if (!block->user && !block->next->user) I_Error ("Z_CheckHeap: two consecutive free blocks\n"); } } - - - - - - - void Z_ChangeTag2 ( void* ptr, int tag ) { memblock_t* block; - block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); - if (block->id != ZONEID) I_Error ("Z_ChangeTag: freed a pointer without ZONEID"); - if (tag >= PU_PURGELEVEL && (unsigned)block->user < 0x100) I_Error ("Z_ChangeTag: an owner is required for purgable blocks"); - block->tag = tag; } - - - - - - int Z_FreeMemory (void) { memblock_t* block; int free; - free = 0; - for (block = mainzone->blocklist.next ; block != &mainzone->blocklist; block = block->next) @@ -462,4 +252,3 @@ int Z_FreeMemory (void) } return free; } - diff --git a/src/z_zone.h b/src/z_zone.h @@ -1,49 +1,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - #ifndef __Z_ZONE__ #define __Z_ZONE__ - #include <stdio.h> - - - - - #define PU_STATIC 1 #define PU_SOUND 2 #define PU_MUSIC 3 #define PU_DAVE 4 #define PU_LEVEL 50 #define PU_LEVSPEC 51 - #define PU_PURGELEVEL 100 #define PU_CACHE 101 - - void Z_Init (void); void* Z_Malloc (int size, int tag, void *ptr); void Z_Free (void *ptr); @@ -53,8 +18,6 @@ void Z_FileDumpHeap (FILE *f); void Z_CheckHeap (void); void Z_ChangeTag2 (void *ptr, int tag); int Z_FreeMemory (void); - - typedef struct memblock_s { int size; @@ -64,23 +27,10 @@ typedef struct memblock_s struct memblock_s* next; struct memblock_s* prev; } memblock_t; - - - - - #define Z_ChangeTag(p,t) \ { \ if (( (memblock_t *)( (byte *)(p) - sizeof(memblock_t)))->id!=0x1d4a11) \ I_Error("Z_CT at "__FILE__":%i",__LINE__); \ Z_ChangeTag2(p,t); \ }; - - - #endif - - - - -