From 25b9216b6b5a37816953c03c7effcd5ed7511b05 Mon Sep 17 00:00:00 2001 From: maraakate Date: Sun, 21 Apr 2024 01:10:13 -0400 Subject: [PATCH] Run through formatter. --- AM_MAP.C | 1708 ++++++++++++++++++++++++++-------------------------- CT_CHAT.C | 122 ++-- D_MAIN.C | 360 +++++------ D_NET.C | 342 +++++------ F_FINALE.C | 170 +++--- G_GAME.C | 664 ++++++++++---------- INFO.C | 1062 ++++++++++++++++---------------- IN_LUDE.C | 412 ++++++------- I_CYBER.C | 63 +- I_SOUND.C | 78 +-- MN_MENU.C | 434 ++++++------- M_MISC.C | 380 ++++++------ P_CEILNG.C | 86 +-- P_DOORS.C | 86 +-- P_ENEMY.C | 842 +++++++++++++------------- P_FLOOR.C | 190 +++--- P_INTER.C | 436 +++++++------- P_LIGHTS.C | 96 +-- P_MAP.C | 840 +++++++++++++------------- P_MAPUTL.C | 384 ++++++------ P_MOBJ.C | 678 ++++++++++----------- P_PLATS.C | 100 +-- P_PSPR.C | 444 +++++++------- P_SETUP.C | 388 ++++++------ P_SIGHT.C | 204 +++---- P_SPEC.C | 372 ++++++------ P_SWITCH.C | 212 +++---- P_TELEPT.C | 60 +- P_TICK.C | 253 ++++---- P_USER.C | 392 ++++++------ R_BSP.C | 204 +++---- R_DATA.C | 392 ++++++------ R_DRAW.C | 252 ++++---- R_MAIN.C | 486 +++++++-------- R_PLANE.C | 178 +++--- R_SEGS.C | 298 ++++----- R_THINGS.C | 454 +++++++------- SB_BAR.C | 464 +++++++------- SOUNDS.C | 2 +- V_VIDEO.C | 96 +-- W_WAD.C | 160 ++--- Z_ZONE.C | 162 ++--- deh_ammo.c | 102 ++-- deh_cht.c | 168 +++--- deh_frme.c | 200 +++--- deh_io.c | 318 +++++----- deh_main.c | 536 ++++++++--------- deh_map.c | 172 +++--- deh_misc.c | 148 ++--- deh_ptr.c | 168 +++--- deh_snd.c | 104 ++-- deh_text.c | 550 ++++++++--------- deh_thng.c | 148 ++--- deh_wpn.c | 94 +-- md5.c | 322 +++++----- s_sound.c | 242 ++++---- sys_dosw.c | 490 +++++++-------- w_merge.c | 952 ++++++++++++++--------------- 58 files changed, 9879 insertions(+), 9841 deletions(-) diff --git a/AM_MAP.C b/AM_MAP.C index 11da9a2..b803642 100644 --- a/AM_MAP.C +++ b/AM_MAP.C @@ -17,34 +17,34 @@ char *LevelNames[] = { // EPISODE 1 - THE CITY OF THE DAMNED "E1M1: THE DOCKS", - "E1M2: THE DUNGEONS", - "E1M3: THE GATEHOUSE", - "E1M4: THE GUARD TOWER", - "E1M5: THE CITADEL", - "E1M6: THE CATHEDRAL", - "E1M7: THE CRYPTS", - "E1M8: HELL'S MAW", - "E1M9: THE GRAVEYARD", + "E1M2: THE DUNGEONS", + "E1M3: THE GATEHOUSE", + "E1M4: THE GUARD TOWER", + "E1M5: THE CITADEL", + "E1M6: THE CATHEDRAL", + "E1M7: THE CRYPTS", + "E1M8: HELL'S MAW", + "E1M9: THE GRAVEYARD", // EPISODE 2 - HELL'S MAW "E2M1: THE CRATER", - "E2M2: THE LAVA PITS", - "E2M3: THE RIVER OF FIRE", - "E2M4: THE ICE GROTTO", - "E2M5: THE CATACOMBS", - "E2M6: THE LABYRINTH", - "E2M7: THE GREAT HALL", - "E2M8: THE PORTALS OF CHAOS", - "E2M9: THE GLACIER", + "E2M2: THE LAVA PITS", + "E2M3: THE RIVER OF FIRE", + "E2M4: THE ICE GROTTO", + "E2M5: THE CATACOMBS", + "E2M6: THE LABYRINTH", + "E2M7: THE GREAT HALL", + "E2M8: THE PORTALS OF CHAOS", + "E2M9: THE GLACIER", // EPISODE 3 - THE DOME OF D'SPARIL - "E3M1: THE STOREHOUSE", - "E3M2: THE CESSPOOL", - "E3M3: THE CONFLUENCE", - "E3M4: THE AZURE FORTRESS", - "E3M5: THE OPHIDIAN LAIR", - "E3M6: THE HALLS OF FEAR", - "E3M7: THE CHASM", - "E3M8: D'SPARIL'S KEEP", - "E3M9: THE AQUIFER", + "E3M1: THE STOREHOUSE", + "E3M2: THE CESSPOOL", + "E3M3: THE CONFLUENCE", + "E3M4: THE AZURE FORTRESS", + "E3M5: THE OPHIDIAN LAIR", + "E3M6: THE HALLS OF FEAR", + "E3M7: THE CHASM", + "E3M8: D'SPARIL'S KEEP", + "E3M9: THE AQUIFER", // EPISODE 4: THE OSSUARY "E4M1: CATAFALQUE", "E4M2: BLOCKHOUSE", @@ -74,7 +74,7 @@ static int leveljuststarted = 1; // kluge until AM_LevelInit() is called boolean automapactive = false; static int finit_width = SCREENWIDTH; -static int finit_height = SCREENHEIGHT-42; +static int finit_height = SCREENHEIGHT - 42; static int f_x, f_y; // location of window on screen static int f_w, f_h; // size of window on screen static int lightlev; // used for funky strobing effect @@ -120,12 +120,12 @@ static int followplayer = 1; // specifies whether to follow the player around static char cheat_amap[] = { 'r','a','v','m','a','p' }; -static byte cheatcount=0; +static byte cheatcount = 0; extern boolean viewactive; int drawTime; // FS: Draw time clock -static byte antialias[NUMALIAS][8]= +static byte antialias[NUMALIAS][8] = { {96, 97, 98, 99, 100, 101, 102, 103}, {110, 109, 108, 107, 106, 105, 104, 103}, @@ -137,8 +137,8 @@ static byte *aliasmax[NUMALIAS] = { };*/ static byte *maplump; // pointer to the raw data for the automap background. -static short mapystart=0; // y-value for the start of the map bitmap...used in the paralax stuff. -static short mapxstart=0; //x-value for the bitmap. +static short mapystart = 0; // y-value for the start of the map bitmap...used in the paralax stuff. +static short mapxstart = 0; //x-value for the bitmap. //byte screens[][SCREENWIDTH*SCREENHEIGHT]; //void V_MarkRect (int x, int y, int width, int height); @@ -169,43 +169,45 @@ void AM_getIslope(mline_t *ml, islope_t *is) void AM_activateNewScale(void) { - m_x += m_w/2; - m_y += m_h/2; - m_w = FTOM(f_w); - m_h = FTOM(f_h); - m_x -= m_w/2; - m_y -= m_h/2; - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; + m_x += m_w / 2; + m_y += m_h / 2; + m_w = FTOM(f_w); + m_h = FTOM(f_h); + m_x -= m_w / 2; + m_y -= m_h / 2; + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; } void AM_saveScaleAndLoc(void) { - old_m_x = m_x; - old_m_y = m_y; - old_m_w = m_w; - old_m_h = m_h; + old_m_x = m_x; + old_m_y = m_y; + 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) - { - m_x = old_m_x; - m_y = old_m_y; - } else { - m_x = plr->mo->x - m_w/2; - m_y = plr->mo->y - m_h/2; - } - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; + m_w = old_m_w; + m_h = old_m_h; + if (!followplayer) + { + m_x = old_m_x; + m_y = old_m_y; + } + else + { + m_x = plr->mo->x - m_w / 2; + m_y = plr->mo->y - m_h / 2; + } + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; - // Change the scaling multipliers - scale_mtof = FixedDiv(f_w< 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; + 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< max_x) - { - m_x = max_x - m_w/2; - m_paninc.x=0; - } - else if (m_x + m_w/2 < min_x) - { - m_x = min_x - m_w/2; - m_paninc.x=0; - } - if (m_y + m_h/2 > max_y) - { - m_y = max_y - m_h/2; - m_paninc.y=0; - } - else if (m_y + m_h/2 < min_y) - { - m_y = min_y - m_h/2; - m_paninc.y=0; - } -/* - mapxstart += MTOF(m_paninc.x+FRACUNIT/2); - mapystart -= MTOF(m_paninc.y+FRACUNIT/2); - if(mapxstart >= finit_width) - mapxstart -= finit_width; - if(mapxstart < 0) - mapxstart += finit_width; - if(mapystart >= finit_height) - mapystart -= finit_height; - if(mapystart < 0) - mapystart += finit_height; -*/ - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; + if (m_x + m_w / 2 > max_x) + { + m_x = max_x - m_w / 2; + m_paninc.x = 0; + } + else if (m_x + m_w / 2 < min_x) + { + m_x = min_x - m_w / 2; + m_paninc.x = 0; + } + if (m_y + m_h / 2 > max_y) + { + m_y = max_y - m_h / 2; + m_paninc.y = 0; + } + else if (m_y + m_h / 2 < min_y) + { + m_y = min_y - m_h / 2; + m_paninc.y = 0; + } + /* + mapxstart += MTOF(m_paninc.x+FRACUNIT/2); + mapystart -= MTOF(m_paninc.y+FRACUNIT/2); + if(mapxstart >= finit_width) + mapxstart -= finit_width; + if(mapxstart < 0) + mapxstart += finit_width; + if(mapystart >= finit_height) + mapystart -= finit_height; + if(mapystart < 0) + mapystart += finit_height; + */ + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; } void AM_initVariables(void) { - int pnum; + int pnum; thinker_t *think; mobj_t *mo; @@ -303,59 +305,59 @@ void AM_initVariables(void) //static event_t st_notify = { ev_keyup, AM_MSGENTERED }; - automapactive = true; - fb = screen; + automapactive = true; + fb = screen; - 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); + f_oldloc.x = MAXINT; + amclock = 0; + lightlev = 0; - // find player to center on initially - if (!playeringame[pnum = consoleplayer]) - for (pnum=0;pnummo->x; - oldplr.y = plr->mo->y; - m_x = plr->mo->x - m_w/2; - m_y = plr->mo->y - m_h/2; - AM_changeWindowLoc(); + m_paninc.x = m_paninc.y = 0; + ftom_zoommul = FRACUNIT; + mtof_zoommul = FRACUNIT; - // for saving & restoring - old_m_x = m_x; - old_m_y = m_y; - old_m_w = m_w; - old_m_h = m_h; + m_w = FTOM(f_w); + m_h = FTOM(f_h); + + // find player to center on initially + if (!playeringame[pnum = consoleplayer]) + for (pnum = 0; pnum < MAXPLAYERS; pnum++) if (playeringame[pnum]) break; + plr = &players[pnum]; + oldplr.x = plr->mo->x; + oldplr.y = plr->mo->y; + m_x = plr->mo->x - m_w / 2; + m_y = plr->mo->y - m_h / 2; + AM_changeWindowLoc(); + + // for saving & restoring + old_m_x = m_x; + old_m_y = m_y; + old_m_w = m_w; + old_m_h = m_h; // load in the location of keys, if in baby mode - memset(KeyPoints, 0, sizeof(vertex_t)*3); - if(gameskill == sk_baby) + memset(KeyPoints, 0, sizeof(vertex_t) * 3); + if (gameskill == sk_baby) { - for(think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thinkercap.next; think != &thinkercap; think = think->next) { - if(think->function != P_MobjThinker) + if (think->function != P_MobjThinker) { //not a mobj continue; } mo = (mobj_t *)think; - if(mo->type == MT_CKEY) + if (mo->type == MT_CKEY) { KeyPoints[0].x = mo->x; KeyPoints[0].y = mo->y; } - else if(mo->type == MT_AKYY) + else if (mo->type == MT_AKYY) { KeyPoints[1].x = mo->x; KeyPoints[1].y = mo->y; } - else if(mo->type == MT_BKYY) + else if (mo->type == MT_BKYY) { KeyPoints[2].x = mo->x; KeyPoints[2].y = mo->y; @@ -363,20 +365,20 @@ void AM_initVariables(void) } } - // inform the status bar of the change -//c ST_Responder(&st_notify); + // inform the status bar of the change + //c 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); - }*/ - maplump = W_CacheLumpName("AUTOPAGE", PU_STATIC); + //int i; + //char namebuf[9]; + /* for (i=0;i<10;i++) + { + sprintf(namebuf, "AMMNUM%d", i); + marknums[i] = W_CacheLumpName(namebuf, PU_STATIC); + }*/ + maplump = W_CacheLumpName("AUTOPAGE", PU_STATIC); } /*void AM_unloadPics(void) @@ -400,20 +402,20 @@ void AM_clearMarks(void) void AM_LevelInit(void) { - leveljuststarted = 0; + leveljuststarted = 0; - f_x = f_y = 0; - f_w = finit_width; - f_h = finit_height; + f_x = f_y = 0; + f_w = finit_width; + f_h = finit_height; mapxstart = mapystart = 0; -// AM_clearMarks(); + // 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); + 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); } static boolean stopped = true; @@ -429,216 +431,216 @@ void AM_Stop (void) void AM_Start (void) { - static int lastlevel = -1, lastepisode = -1; + static int lastlevel = -1, lastepisode = -1; - if (!stopped) AM_Stop(); - stopped = false; - if(gamestate != GS_LEVEL) - { + if (!stopped) AM_Stop(); + stopped = false; + if (gamestate != GS_LEVEL) + { return; // don't show automap if we aren't in a game! - } - if (lastlevel != gamemap || lastepisode != gameepisode) - { - AM_LevelInit(); - lastlevel = gamemap; - lastepisode = gameepisode; - } - AM_initVariables(); - AM_loadPics(); + } + if (lastlevel != gamemap || lastepisode != gameepisode) + { + AM_LevelInit(); + lastlevel = gamemap; + lastepisode = gameepisode; + } + AM_initVariables(); + AM_loadPics(); } // set the window scale to the maximum size void AM_minOutWindowScale(void) { - scale_mtof = min_scale_mtof; - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); - AM_activateNewScale(); + scale_mtof = min_scale_mtof; + scale_ftom = FixedDiv(FRACUNIT, scale_mtof); + AM_activateNewScale(); } // set the window scale to the minimum size void AM_maxOutWindowScale(void) { - scale_mtof = max_scale_mtof; - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); - AM_activateNewScale(); + 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; + int rc; + static int cheatstate = 0; + static int bigstate = 0; - rc = false; - if (!automapactive) - { - if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY - && gamestate == GS_LEVEL) - { - AM_Start (); - viewactive = false; -// viewactive = true; - rc = true; - } - } - else if (ev->type == ev_keydown) - { - - rc = true; - switch(ev->data1) - { - case AM_PANRIGHTKEY: // pan right - if (!followplayer) m_paninc.x = FTOM(F_PANINC); - else rc = false; - break; - case AM_PANLEFTKEY: // pan left - if (!followplayer) m_paninc.x = -FTOM(F_PANINC); - else rc = false; - break; - case AM_PANUPKEY: // pan up - if (!followplayer) m_paninc.y = FTOM(F_PANINC); - else rc = false; - break; - case AM_PANDOWNKEY: // pan down - if (!followplayer) m_paninc.y = -FTOM(F_PANINC); - else rc = false; - break; - case AM_ZOOMOUTKEY: // zoom out - mtof_zoommul = M_ZOOMOUT; - ftom_zoommul = M_ZOOMIN; - break; - case AM_ZOOMINKEY: // zoom in - mtof_zoommul = M_ZOOMIN; - ftom_zoommul = M_ZOOMOUT; - break; - case AM_ENDKEY: - bigstate = 0; - viewactive = true; - AM_Stop (); - break; - case AM_GOBIGKEY: - bigstate = !bigstate; - if (bigstate) + rc = false; + if (!automapactive) + { + if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY + && gamestate == GS_LEVEL) + { + AM_Start (); + viewactive = false; + // viewactive = true; + rc = true; + } + } + else if (ev->type == ev_keydown) { - AM_saveScaleAndLoc(); - AM_minOutWindowScale(); + + rc = true; + switch (ev->data1) + { + case AM_PANRIGHTKEY: // pan right + if (!followplayer) m_paninc.x = FTOM(F_PANINC); + else rc = false; + break; + case AM_PANLEFTKEY: // pan left + if (!followplayer) m_paninc.x = -FTOM(F_PANINC); + else rc = false; + break; + case AM_PANUPKEY: // pan up + if (!followplayer) m_paninc.y = FTOM(F_PANINC); + else rc = false; + break; + case AM_PANDOWNKEY: // pan down + if (!followplayer) m_paninc.y = -FTOM(F_PANINC); + else rc = false; + break; + case AM_ZOOMOUTKEY: // zoom out + mtof_zoommul = M_ZOOMOUT; + ftom_zoommul = M_ZOOMIN; + break; + case AM_ZOOMINKEY: // zoom in + mtof_zoommul = M_ZOOMIN; + ftom_zoommul = M_ZOOMOUT; + break; + case AM_ENDKEY: + bigstate = 0; + viewactive = true; + AM_Stop (); + break; + case AM_GOBIGKEY: + bigstate = !bigstate; + if (bigstate) + { + AM_saveScaleAndLoc(); + AM_minOutWindowScale(); + } + else AM_restoreScaleAndLoc(); + break; + case AM_FOLLOWKEY: + followplayer = !followplayer; + f_oldloc.x = MAXINT; + P_SetMessage(plr, followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF, true); + break; + /* + case AM_GRIDKEY: + grid = !grid; + plr->message = grid ? AMSTR_GRIDON : AMSTR_GRIDOFF; + break; + case AM_MARKKEY: + sprintf(buffer, "%s %d", AMSTR_MARKEDSPOT, markpointnum); + plr->message = buffer; + AM_addMark(); + break; + case AM_CLEARMARKKEY: + AM_clearMarks(); + plr->message = AMSTR_MARKSCLEARED; + break; + */ + default: + cheatstate = 0; + rc = false; + } + if (cheat_amap[cheatcount] == ev->data1 && !netgame) + cheatcount++; + else + cheatcount = 0; + if (cheatcount == 6) + { + cheatcount = 0; + rc = false; + cheating = (cheating + 1) % 3; + } } - else AM_restoreScaleAndLoc(); - break; - case AM_FOLLOWKEY: - followplayer = !followplayer; - f_oldloc.x = MAXINT; - P_SetMessage(plr, followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF, true); - break; -/* - case AM_GRIDKEY: - grid = !grid; - plr->message = grid ? AMSTR_GRIDON : AMSTR_GRIDOFF; - break; - case AM_MARKKEY: - sprintf(buffer, "%s %d", AMSTR_MARKEDSPOT, markpointnum); - plr->message = buffer; - AM_addMark(); - break; - case AM_CLEARMARKKEY: - AM_clearMarks(); - plr->message = AMSTR_MARKSCLEARED; - break; -*/ - default: - cheatstate=0; - rc = false; - } - if(cheat_amap[cheatcount]==ev->data1 && !netgame) - cheatcount++; - else - cheatcount=0; - if(cheatcount==6) - { - cheatcount=0; - rc = false; - cheating = (cheating+1) % 3; - } - } - else if (ev->type == ev_keyup) - { - rc = false; - switch (ev->data1) - { - case AM_PANRIGHTKEY: - if (!followplayer) m_paninc.x = 0; - break; - case AM_PANLEFTKEY: - if (!followplayer) m_paninc.x = 0; - break; - case AM_PANUPKEY: - if (!followplayer) m_paninc.y = 0; - break; - case AM_PANDOWNKEY: - if (!followplayer) m_paninc.y = 0; - break; - case AM_ZOOMOUTKEY: - case AM_ZOOMINKEY: - mtof_zoommul = FRACUNIT; - ftom_zoommul = FRACUNIT; - break; - } - } + else if (ev->type == ev_keyup) + { + rc = false; + switch (ev->data1) + { + case AM_PANRIGHTKEY: + if (!followplayer) m_paninc.x = 0; + break; + case AM_PANLEFTKEY: + if (!followplayer) m_paninc.x = 0; + break; + case AM_PANUPKEY: + if (!followplayer) m_paninc.y = 0; + break; + case AM_PANDOWNKEY: + if (!followplayer) m_paninc.y = 0; + break; + case AM_ZOOMOUTKEY: + case AM_ZOOMINKEY: + mtof_zoommul = FRACUNIT; + ftom_zoommul = FRACUNIT; + break; + } + } - return rc; + return rc; } void AM_changeWindowScale(void) { - // Change the scaling multipliers - scale_mtof = FixedMul(scale_mtof, mtof_zoommul); - scale_ftom = FixedDiv(FRACUNIT, scale_mtof); + // Change the scaling multipliers + 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) AM_maxOutWindowScale(); - else AM_activateNewScale(); + if (scale_mtof < min_scale_mtof) AM_minOutWindowScale(); + else if (scale_mtof > max_scale_mtof) AM_maxOutWindowScale(); + 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)); -// m_y = FTOM(MTOF(plr->mo->y - m_h/2)); -// m_x = plr->mo->x - m_w/2; -// m_y = plr->mo->y - m_h/2; - m_x = FTOM(MTOF(plr->mo->x)) - m_w/2; - m_y = FTOM(MTOF(plr->mo->y)) - m_h/2; - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; - - // do the parallax parchment scrolling. -/* - dmapx = (MTOF(plr->mo->x)-MTOF(f_oldloc.x)); //fixed point - dmapy = (MTOF(f_oldloc.y)-MTOF(plr->mo->y)); - - if(f_oldloc.x == MAXINT) //to eliminate an error when the user first - dmapx=0; //goes into the automap. - mapxstart += dmapx; - mapystart += dmapy; - - while(mapxstart >= finit_width) - mapxstart -= finit_width; - while(mapxstart < 0) - mapxstart += finit_width; - while(mapystart >= finit_height) - mapystart -= finit_height; - while(mapystart < 0) - mapystart += finit_height; -*/ - f_oldloc.x = plr->mo->x; - f_oldloc.y = plr->mo->y; - } + if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y) + { + // m_x = FTOM(MTOF(plr->mo->x - m_w/2)); + // m_y = FTOM(MTOF(plr->mo->y - m_h/2)); + // m_x = plr->mo->x - m_w/2; + // m_y = plr->mo->y - m_h/2; + m_x = FTOM(MTOF(plr->mo->x)) - m_w / 2; + m_y = FTOM(MTOF(plr->mo->y)) - m_h / 2; + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; + + // do the parallax parchment scrolling. + /* + dmapx = (MTOF(plr->mo->x)-MTOF(f_oldloc.x)); //fixed point + dmapy = (MTOF(f_oldloc.y)-MTOF(plr->mo->y)); + + if(f_oldloc.x == MAXINT) //to eliminate an error when the user first + dmapx=0; //goes into the automap. + mapxstart += dmapx; + mapystart += dmapy; + + while(mapxstart >= finit_width) + mapxstart -= finit_width; + while(mapxstart < 0) + mapxstart += finit_width; + while(mapystart >= finit_height) + mapystart -= finit_height; + while(mapystart < 0) + mapystart += finit_height; + */ + f_oldloc.x = plr->mo->x; + f_oldloc.y = plr->mo->y; + } } // Ripped out for Heretic @@ -653,9 +655,9 @@ void AM_updateLightLev(void) // Change light level if (amclock>nexttic) { - lightlev = litelevels[litelevelscnt++]; - if (litelevelscnt == sizeof(litelevels)/sizeof(int)) litelevelscnt = 0; - nexttic = amclock + 6 - (amclock % 6); + lightlev = litelevels[litelevelscnt++]; + if (litelevelscnt == sizeof(litelevels)/sizeof(int)) litelevelscnt = 0; + nexttic = amclock + 6 - (amclock % 6); } } */ @@ -663,19 +665,19 @@ void AM_updateLightLev(void) void AM_Ticker (void) { - if (!automapactive) return; + if (!automapactive) return; - amclock++; + amclock++; - if (followplayer) AM_doFollowPlayer(); + if (followplayer) AM_doFollowPlayer(); - // Change the zoom if necessary - if (ftom_zoommul != FRACUNIT) AM_changeWindowScale(); + // Change the zoom if necessary + if (ftom_zoommul != FRACUNIT) AM_changeWindowScale(); - // Change x,y location - if (m_paninc.x || m_paninc.y) AM_changeWindowLoc(); - // Update light level -// AM_updateLightLev(); + // Change x,y location + if (m_paninc.x || m_paninc.y) AM_changeWindowLoc(); + // Update light level + // AM_updateLightLev(); } @@ -685,54 +687,54 @@ void AM_clearFB(int color) int dmapx; int dmapy; - if(followplayer) + if (followplayer) { - dmapx = (MTOF(plr->mo->x)-MTOF(oldplr.x)); //fixed point - dmapy = (MTOF(oldplr.y)-MTOF(plr->mo->y)); + dmapx = (MTOF(plr->mo->x) - MTOF(oldplr.x)); //fixed point + dmapy = (MTOF(oldplr.y) - MTOF(plr->mo->y)); oldplr.x = plr->mo->x; oldplr.y = plr->mo->y; -// if(f_oldloc.x == MAXINT) //to eliminate an error when the user first -// dmapx=0; //goes into the automap. - mapxstart += dmapx>>1; - mapystart += dmapy>>1; + // if(f_oldloc.x == MAXINT) //to eliminate an error when the user first + // dmapx=0; //goes into the automap. + mapxstart += dmapx >> 1; + mapystart += dmapy >> 1; - while(mapxstart >= finit_width) + while (mapxstart >= finit_width) mapxstart -= finit_width; - while(mapxstart < 0) + while (mapxstart < 0) mapxstart += finit_width; - while(mapystart >= finit_height) + while (mapystart >= finit_height) mapystart -= finit_height; - while(mapystart < 0) + while (mapystart < 0) mapystart += finit_height; } else { - mapxstart += (MTOF(m_paninc.x)>>1); - mapystart -= (MTOF(m_paninc.y)>>1); - if(mapxstart >= finit_width) + mapxstart += (MTOF(m_paninc.x) >> 1); + mapystart -= (MTOF(m_paninc.y) >> 1); + if (mapxstart >= finit_width) mapxstart -= finit_width; - if(mapxstart < 0) + if (mapxstart < 0) mapxstart += finit_width; - if(mapystart >= finit_height) - mapystart -= finit_height; - if(mapystart < 0) - mapystart += finit_height; + if (mapystart >= finit_height) + mapystart -= finit_height; + if (mapystart < 0) + mapystart += finit_height; } //blit the automap background to the screen. - j=mapystart*finit_width; - for(i=0;i= finit_height*finit_width) - j=0; + if (j >= finit_height * finit_width) + j = 0; } -// memcpy(screen, maplump, finit_width*finit_height); -// memset(fb, color, f_w*f_h); + // memcpy(screen, maplump, finit_width*finit_height); + // memset(fb, color, f_w*f_h); } // Based on Cohen-Sutherland clipping algorithm but with a slightly @@ -741,10 +743,10 @@ void AM_clearFB(int color) boolean AM_clipMline(mline_t *ml, fline_t *fl) { - enum { LEFT=1, RIGHT=2, BOTTOM=4, TOP=8 }; - register outcode1 = 0, outcode2 = 0, outside; - fpoint_t tmp; - int dx, dy; + enum { LEFT = 1, RIGHT = 2, BOTTOM = 4, TOP = 8 }; + register outcode1 = 0, outcode2 = 0, outside; + fpoint_t tmp; + int dx, dy; #define DOOUTCODE(oc, mx, my) \ (oc) = 0; \ @@ -753,75 +755,77 @@ boolean AM_clipMline(mline_t *ml, fline_t *fl) if ((mx) < 0) (oc) |= LEFT; \ else if ((mx) >= f_w) (oc) |= RIGHT - // do trivial rejects and outcodes - 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; // trivially outside - - 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; // trivially outside - - // transform to frame-buffer coordinates. - 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) - { - // may be partially inside box - // find an outside point - if (outcode1) outside = outcode1; - else outside = outcode2; - // clip to each side - if (outside & TOP) - { - dy = fl->a.y - fl->b.y; - dx = fl->b.x - fl->a.x; - tmp.x = fl->a.x + (dx*(fl->a.y))/dy; - tmp.y = 0; - } - else if (outside & BOTTOM) - { - dy = fl->a.y - fl->b.y; - dx = fl->b.x - fl->a.x; - tmp.x = fl->a.x + (dx*(fl->a.y-f_h))/dy; - tmp.y = f_h-1; - } - else if (outside & RIGHT) - { - dy = fl->b.y - fl->a.y; - dx = fl->b.x - fl->a.x; - tmp.y = fl->a.y + (dy*(f_w-1 - fl->a.x))/dx; - tmp.x = f_w-1; - } - else if (outside & LEFT) - { - dy = fl->b.y - fl->a.y; - dx = fl->b.x - fl->a.x; - tmp.y = fl->a.y + (dy*(-fl->a.x))/dx; - tmp.x = 0; - } - if (outside == outcode1) - { - fl->a = tmp; - DOOUTCODE(outcode1, fl->a.x, fl->a.y); - } else { - fl->b = tmp; - DOOUTCODE(outcode2, fl->b.x, fl->b.y); - } - if (outcode1 & outcode2) return false; // trivially outside - } + // do trivial rejects and outcodes + 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; // trivially outside + + 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; // trivially outside + + // transform to frame-buffer coordinates. + 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) + { + // may be partially inside box + // find an outside point + if (outcode1) outside = outcode1; + else outside = outcode2; + // clip to each side + if (outside & TOP) + { + dy = fl->a.y - fl->b.y; + dx = fl->b.x - fl->a.x; + tmp.x = fl->a.x + (dx * (fl->a.y)) / dy; + tmp.y = 0; + } + else if (outside & BOTTOM) + { + dy = fl->a.y - fl->b.y; + dx = fl->b.x - fl->a.x; + tmp.x = fl->a.x + (dx * (fl->a.y - f_h)) / dy; + tmp.y = f_h - 1; + } + else if (outside & RIGHT) + { + dy = fl->b.y - fl->a.y; + dx = fl->b.x - fl->a.x; + tmp.y = fl->a.y + (dy * (f_w - 1 - fl->a.x)) / dx; + tmp.x = f_w - 1; + } + else if (outside & LEFT) + { + dy = fl->b.y - fl->a.y; + dx = fl->b.x - fl->a.x; + tmp.y = fl->a.y + (dy * (-fl->a.x)) / dx; + tmp.x = 0; + } + if (outside == outcode1) + { + fl->a = tmp; + DOOUTCODE(outcode1, fl->a.x, fl->a.y); + } + else + { + fl->b = tmp; + DOOUTCODE(outcode2, fl->b.x, fl->b.y); + } + if (outcode1 & outcode2) return false; // trivially outside + } - return true; + return true; } #undef DOOUTCODE @@ -830,77 +834,79 @@ boolean AM_clipMline(mline_t *ml, fline_t *fl) void AM_drawFline(fline_t *fl, int color) { - register int x, y, dx, dy, sx, sy, ax, ay, d; - static fuck = 0; + register int x, y, dx, dy, sx, sy, ax, ay, d; + static fuck = 0; - switch(color) - { + switch (color) + { case WALLCOLORS: - DrawWuLine(fl->a.x, fl->a.y, fl->b.x, fl->b.y, &antialias[0][0], 8, 3); + DrawWuLine(fl->a.x, fl->a.y, fl->b.x, fl->b.y, &antialias[0][0], 8, 3); break; case FDWALLCOLORS: - DrawWuLine(fl->a.x, fl->a.y, fl->b.x, fl->b.y, &antialias[1][0], 8, 3); + DrawWuLine(fl->a.x, fl->a.y, fl->b.x, fl->b.y, &antialias[1][0], 8, 3); break; case CDWALLCOLORS: - DrawWuLine(fl->a.x, fl->a.y, fl->b.x, fl->b.y, &antialias[2][0], 8, 3); + DrawWuLine(fl->a.x, fl->a.y, fl->b.x, fl->b.y, &antialias[2][0], 8, 3); break; default: - { - // For debugging only - 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 - || fl->b.y < 0 || fl->b.y >= f_h) - { - fprintf(stderr, "fuck %d \r", fuck++); - return; - } - - #define DOT(xx,yy,cc) fb[(yy)*f_w+(xx)]=(cc) //the MACRO! - - 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; - while (1) - { - DOT(x,y,color); - if (x == fl->b.x) return; - if (d>=0) - { - y += sy; - d -= ax; - } - x += sx; - d += ay; - } - } else { - d = ax - ay/2; - while (1) - { - DOT(x, y, color); - if (y == fl->b.y) return; - if (d >= 0) - { + { + // For debugging only + 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 + || fl->b.y < 0 || fl->b.y >= f_h) + { + fprintf(stderr, "fuck %d \r", fuck++); + return; + } + +#define DOT(xx,yy,cc) fb[(yy)*f_w+(xx)]=(cc) //the MACRO! + + 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; + while (1) + { + DOT(x, y, color); + if (x == fl->b.x) return; + if (d >= 0) + { + y += sy; + d -= ax; + } x += sx; - d -= ay; - } - y += sy; - d += ax; - } - } - } - } + d += ay; + } + } + else + { + d = ax - ay / 2; + while (1) + { + DOT(x, y, color); + if (y == fl->b.y) return; + if (d >= 0) + { + x += sx; + d -= ay; + } + y += sy; + d += ax; + } + } + } + } } /* Wu antialiased line drawer. @@ -912,375 +918,399 @@ void AM_drawFline(fline_t *fl, int color) * IntensityBits = log base 2 of NumLevels; the # of bits used to describe * the intensity of the drawing color. 2**IntensityBits==NumLevels */ -void PUTDOT(short xx,short yy,byte *cc, byte *cm) +void PUTDOT(short xx, short yy, byte *cc, byte *cm) { static int oldyy; static int oldyyshifted; - byte *oldcc=cc; - - if(xx < 32) - cc += 7-(xx>>2); - else if(xx > (finit_width - 32)) - cc += 7-((finit_width-xx) >> 2); -// if(cc==oldcc) //make sure that we don't double fade the corners. -// { - if(yy < 32) - cc += 7-(yy>>2); - else if(yy > (finit_height - 32)) - cc += 7-((finit_height-yy) >> 2); -// } - if(cc > cm && cm != NULL) + byte *oldcc = cc; + + if (xx < 32) + cc += 7 - (xx >> 2); + else if (xx > (finit_width - 32)) + cc += 7 - ((finit_width - xx) >> 2); + // if(cc==oldcc) //make sure that we don't double fade the corners. + // { + if (yy < 32) + cc += 7 - (yy >> 2); + else if (yy > (finit_height - 32)) + cc += 7 - ((finit_height - yy) >> 2); + // } + if (cc > cm && cm != NULL) { cc = cm; } - else if(cc > oldcc+6) // don't let the color escape from the fade table... + else if (cc > oldcc + 6) // don't let the color escape from the fade table... { - cc=oldcc+6; + cc = oldcc + 6; } - if(yy == oldyy+1) + if (yy == oldyy + 1) { oldyy++; oldyyshifted += 320; } - else if(yy == oldyy-1) + else if (yy == oldyy - 1) { oldyy--; oldyyshifted -= 320; } - else if(yy != oldyy) + else if (yy != oldyy) { oldyy = yy; - oldyyshifted = yy*320; + oldyyshifted = yy * 320; } - fb[oldyyshifted+xx] = *(cc); -// fb[(yy)*f_w+(xx)]=*(cc); + fb[oldyyshifted + xx] = *(cc); + // fb[(yy)*f_w+(xx)]=*(cc); } void DrawWuLine(int X0, int Y0, int X1, int Y1, byte *BaseColor, int NumLevels, unsigned short IntensityBits) { - unsigned short IntensityShift, ErrorAdj, ErrorAcc; - unsigned short ErrorAccTemp, Weighting, WeightingComplementMask; - short DeltaX, DeltaY, Temp, XDir; - - /* Make sure the line runs top to bottom */ - if (Y0 > Y1) { - Temp = Y0; Y0 = Y1; Y1 = Temp; - Temp = X0; X0 = X1; X1 = Temp; - } - /* Draw the initial pixel, which is always exactly intersected by - the line and so needs no weighting */ - PUTDOT(X0, Y0, &BaseColor[0], NULL); - - if ((DeltaX = X1 - X0) >= 0) { - XDir = 1; - } else { - XDir = -1; - DeltaX = -DeltaX; /* make DeltaX positive */ - } - /* Special-case horizontal, vertical, and diagonal lines, which - require no weighting because they go right through the center of - every pixel */ - if ((DeltaY = Y1 - Y0) == 0) { - /* Horizontal line */ - while (DeltaX-- != 0) { - X0 += XDir; - PUTDOT(X0, Y0, &BaseColor[0], NULL); - } - return; - } - if (DeltaX == 0) { - /* Vertical line */ - do { - Y0++; - PUTDOT(X0, Y0, &BaseColor[0], NULL); - } while (--DeltaY != 0); - return; - } + unsigned short IntensityShift, ErrorAdj, ErrorAcc; + unsigned short ErrorAccTemp, Weighting, WeightingComplementMask; + short DeltaX, DeltaY, Temp, XDir; + + /* Make sure the line runs top to bottom */ + if (Y0 > Y1) + { + Temp = Y0; Y0 = Y1; Y1 = Temp; + Temp = X0; X0 = X1; X1 = Temp; + } + /* Draw the initial pixel, which is always exactly intersected by + the line and so needs no weighting */ + PUTDOT(X0, Y0, &BaseColor[0], NULL); + + if ((DeltaX = X1 - X0) >= 0) + { + XDir = 1; + } + else + { + XDir = -1; + DeltaX = -DeltaX; /* make DeltaX positive */ + } + /* Special-case horizontal, vertical, and diagonal lines, which + require no weighting because they go right through the center of + every pixel */ + if ((DeltaY = Y1 - Y0) == 0) + { + /* Horizontal line */ + while (DeltaX-- != 0) + { + X0 += XDir; + PUTDOT(X0, Y0, &BaseColor[0], NULL); + } + return; + } + if (DeltaX == 0) + { + /* Vertical line */ + do + { + Y0++; + PUTDOT(X0, Y0, &BaseColor[0], NULL); + } while (--DeltaY != 0); + return; + } //diagonal line. - if (DeltaX == DeltaY) { - do { - X0 += XDir; - Y0++; - PUTDOT(X0, Y0, &BaseColor[0], NULL); - } while (--DeltaY != 0); - return; - } - /* Line is not horizontal, diagonal, or vertical */ - ErrorAcc = 0; /* initialize the line error accumulator to 0 */ - /* # of bits by which to shift ErrorAcc to get intensity level */ - IntensityShift = 16 - IntensityBits; - /* Mask used to flip all bits in an intensity weighting, producing the - result (1 - intensity weighting) */ - WeightingComplementMask = NumLevels - 1; - /* Is this an X-major or Y-major line? */ - if (DeltaY > DeltaX) { - /* Y-major line; calculate 16-bit fixed-point fractional part of a - pixel that X advances each time Y advances 1 pixel, truncating the - result so that we won't overrun the endpoint along the X axis */ - ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; - /* Draw all pixels other than the first and last */ - while (--DeltaY) { - ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ - ErrorAcc += ErrorAdj; /* calculate error for next pixel */ - if (ErrorAcc <= ErrorAccTemp) { - /* The error accumulator turned over, so advance the X coord */ - X0 += XDir; - } - Y0++; /* Y-major, so always advance Y */ - /* The IntensityBits most significant bits of ErrorAcc give us the - intensity weighting for this pixel, and the complement of the - weighting for the paired pixel */ - Weighting = ErrorAcc >> IntensityShift; + if (DeltaX == DeltaY) + { + do + { + X0 += XDir; + Y0++; + PUTDOT(X0, Y0, &BaseColor[0], NULL); + } while (--DeltaY != 0); + return; + } + /* Line is not horizontal, diagonal, or vertical */ + ErrorAcc = 0; /* initialize the line error accumulator to 0 */ + /* # of bits by which to shift ErrorAcc to get intensity level */ + IntensityShift = 16 - IntensityBits; + /* Mask used to flip all bits in an intensity weighting, producing the + result (1 - intensity weighting) */ + WeightingComplementMask = NumLevels - 1; + /* Is this an X-major or Y-major line? */ + if (DeltaY > DeltaX) + { + /* Y-major line; calculate 16-bit fixed-point fractional part of a + pixel that X advances each time Y advances 1 pixel, truncating the + result so that we won't overrun the endpoint along the X axis */ + ErrorAdj = ((unsigned long)DeltaX << 16) / (unsigned long)DeltaY; + /* Draw all pixels other than the first and last */ + while (--DeltaY) + { + ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ + ErrorAcc += ErrorAdj; /* calculate error for next pixel */ + if (ErrorAcc <= ErrorAccTemp) + { + /* The error accumulator turned over, so advance the X coord */ + X0 += XDir; + } + Y0++; /* Y-major, so always advance Y */ + /* The IntensityBits most significant bits of ErrorAcc give us the + intensity weighting for this pixel, and the complement of the + weighting for the paired pixel */ + Weighting = ErrorAcc >> IntensityShift; PUTDOT(X0, Y0, &BaseColor[Weighting], &BaseColor[7]); - PUTDOT(X0 + XDir, Y0, - &BaseColor[(Weighting ^ WeightingComplementMask)], &BaseColor[7]); - } - /* Draw the final pixel, which is always exactly intersected by the line - and so needs no weighting */ - PUTDOT(X1, Y1, &BaseColor[0], NULL); - return; - } - /* It's an X-major line; calculate 16-bit fixed-point fractional part of a - pixel that Y advances each time X advances 1 pixel, truncating the - result to avoid overrunning the endpoint along the X axis */ - ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; - /* Draw all pixels other than the first and last */ - while (--DeltaX) { - ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ - ErrorAcc += ErrorAdj; /* calculate error for next pixel */ - if (ErrorAcc <= ErrorAccTemp) { - /* The error accumulator turned over, so advance the Y coord */ - Y0++; - } - X0 += XDir; /* X-major, so always advance X */ - /* The IntensityBits most significant bits of ErrorAcc give us the - intensity weighting for this pixel, and the complement of the - weighting for the paired pixel */ - Weighting = ErrorAcc >> IntensityShift; - PUTDOT(X0, Y0, &BaseColor[Weighting], &BaseColor[7]); - PUTDOT(X0, Y0 + 1, - &BaseColor[(Weighting ^ WeightingComplementMask)], &BaseColor[7]); - - } - /* Draw the final pixel, which is always exactly intersected by the line - and so needs no weighting */ - PUTDOT(X1, Y1, &BaseColor[0], NULL); + PUTDOT(X0 + XDir, Y0, + &BaseColor[(Weighting ^ WeightingComplementMask)], &BaseColor[7]); + } + /* Draw the final pixel, which is always exactly intersected by the line + and so needs no weighting */ + PUTDOT(X1, Y1, &BaseColor[0], NULL); + return; + } + /* It's an X-major line; calculate 16-bit fixed-point fractional part of a + pixel that Y advances each time X advances 1 pixel, truncating the + result to avoid overrunning the endpoint along the X axis */ + ErrorAdj = ((unsigned long)DeltaY << 16) / (unsigned long)DeltaX; + /* Draw all pixels other than the first and last */ + while (--DeltaX) + { + ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ + ErrorAcc += ErrorAdj; /* calculate error for next pixel */ + if (ErrorAcc <= ErrorAccTemp) + { + /* The error accumulator turned over, so advance the Y coord */ + Y0++; + } + X0 += XDir; /* X-major, so always advance X */ + /* The IntensityBits most significant bits of ErrorAcc give us the + intensity weighting for this pixel, and the complement of the + weighting for the paired pixel */ + Weighting = ErrorAcc >> IntensityShift; + PUTDOT(X0, Y0, &BaseColor[Weighting], &BaseColor[7]); + PUTDOT(X0, Y0 + 1, + &BaseColor[(Weighting ^ WeightingComplementMask)], &BaseColor[7]); + + } + /* Draw the final pixel, which is always exactly intersected by the line + and so needs no weighting */ + PUTDOT(X1, Y1, &BaseColor[0], NULL); } void AM_drawMline(mline_t *ml, int color) { - static fline_t fl; + static fline_t fl; - if (AM_clipMline(ml, &fl)) - AM_drawFline(&fl, color); // draws it on frame buffer using fb coords + if (AM_clipMline(ml, &fl)) + AM_drawFline(&fl, color); // draws it on frame buffer using fb coords } void AM_drawGrid(int color) { - fixed_t x, y; - fixed_t start, end; - mline_t ml; - - // Figure out start of vertical gridlines - start = m_x; - if ((start-bmaporgx)%(MAPBLOCKUNITS<x; - l.a.y = lines[i].v1->y; - l.b.x = lines[i].v2->x; - l.b.y = lines[i].v2->y; - if (cheating || (lines[i].flags & ML_MAPPED)) - { - if ((lines[i].flags & LINE_NEVERSEE) && !cheating) - continue; - if (!lines[i].backsector) - { - AM_drawMline(&l, WALLCOLORS+lightlev); - } else { - if (lines[i].special == 39) - { // teleporters - AM_drawMline(&l, WALLCOLORS+WALLRANGE/2); - } else if (lines[i].flags & ML_SECRET) // secret door - { - if (cheating) AM_drawMline(&l, 0); - else AM_drawMline(&l, WALLCOLORS+lightlev); - } - else if(lines[i].special > 25 && lines[i].special < 35) + for (i = 0; i < numlines; i++) { - switch(lines[i].special) + l.a.x = lines[i].v1->x; + l.a.y = lines[i].v1->y; + l.b.x = lines[i].v2->x; + l.b.y = lines[i].v2->y; + if (cheating || (lines[i].flags & ML_MAPPED)) { - case 26: - case 32: - AM_drawMline(&l, BLUEKEY); - break; - case 27: - case 34: - AM_drawMline(&l, YELLOWKEY); - break; - case 28: - case 33: - AM_drawMline(&l, GREENKEY); - break; - default: - break; + if ((lines[i].flags & LINE_NEVERSEE) && !cheating) + continue; + if (!lines[i].backsector) + { + AM_drawMline(&l, WALLCOLORS + lightlev); + } + else + { + if (lines[i].special == 39) + { // teleporters + AM_drawMline(&l, WALLCOLORS + WALLRANGE / 2); + } + else if (lines[i].flags & ML_SECRET) // secret door + { + if (cheating) AM_drawMline(&l, 0); + else AM_drawMline(&l, WALLCOLORS + lightlev); + } + else if (lines[i].special > 25 && lines[i].special < 35) + { + switch (lines[i].special) + { + case 26: + case 32: + AM_drawMline(&l, BLUEKEY); + break; + case 27: + case 34: + AM_drawMline(&l, YELLOWKEY); + break; + case 28: + case 33: + AM_drawMline(&l, GREENKEY); + break; + default: + break; + } + } + else if (lines[i].backsector->floorheight + != lines[i].frontsector->floorheight) + { + AM_drawMline(&l, FDWALLCOLORS + lightlev); // floor level change + } + else if (lines[i].backsector->ceilingheight + != lines[i].frontsector->ceilingheight) + { + AM_drawMline(&l, CDWALLCOLORS + lightlev); // ceiling level change + } + else if (cheating) + { + AM_drawMline(&l, TSWALLCOLORS + lightlev); + } + } + } + else if (plr->powers[pw_allmap]) + { + if (!(lines[i].flags & LINE_NEVERSEE)) AM_drawMline(&l, GRAYS + 3); } } - else if (lines[i].backsector->floorheight - != lines[i].frontsector->floorheight) { - AM_drawMline(&l, FDWALLCOLORS + lightlev); // floor level change - } else if (lines[i].backsector->ceilingheight - != lines[i].frontsector->ceilingheight) { - AM_drawMline(&l, CDWALLCOLORS+lightlev); // ceiling level change - } else if (cheating) { - AM_drawMline(&l, TSWALLCOLORS+lightlev); - } - } - } else if (plr->powers[pw_allmap]) - { - if (!(lines[i].flags & LINE_NEVERSEE)) AM_drawMline(&l, GRAYS+3); - } - } } void AM_rotate(fixed_t *x, fixed_t *y, angle_t a) { - fixed_t tmpx; + 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; + 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, int lineguylines, fixed_t scale, - angle_t angle, int color, fixed_t x, fixed_t y) + angle_t angle, int color, fixed_t x, fixed_t y) { - int i; - mline_t l; + int i; + mline_t l; - for (i=0;imo->angle, WHITE, plr->mo->x, plr->mo->y); - */ //cheat key player pointer is the same as non-cheat pointer.. + if (!netgame) + { + /* + if (cheating) AM_drawLineCharacter(cheat_player_arrow, NUMCHEATPLYRLINES, 0, + plr->mo->angle, WHITE, plr->mo->x, plr->mo->y); + */ //cheat key player pointer is the same as non-cheat pointer.. AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, plr->mo->angle, - WHITE, plr->mo->x, plr->mo->y); - return; - } + WHITE, plr->mo->x, plr->mo->y); + return; + } - for (i=0;ipowers[pw_invisibility]) color = 102; // *close* to the automap color + else color = their_colors[their_color]; + AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, p->mo->angle, + color, p->mo->x, p->mo->y); } - if (!playeringame[i]) continue; - if (p->powers[pw_invisibility]) color = 102; // *close* to the automap color - 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, int colorrange) { - int i; - mobj_t *t; + int i; + mobj_t *t; - for (i=0;iangle, colors+lightlev, t->x, t->y); - t = t->snext; - } - } + for (i = 0; i < numsectors; i++) + { + t = sectors[i].thinglist; + while (t) + { + AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, + 16 << FRACBITS, t->angle, colors + lightlev, t->x, t->y); + t = t->snext; + } + } } /* @@ -1290,32 +1320,32 @@ void AM_drawMarks(void) for (i=0;iwidth); - h = SHORT(marknums[i]->height); - fx = CXMTOF(markpoints[i].x); - fy = CYMTOF(markpoints[i].y); - if (fx >= f_x && fx <= f_w - w && fy >= f_y && fy <= f_h - h) - V_DrawPatch(fx, fy, marknums[i]); - } + if (markpoints[i].x != -1) + { + w = SHORT(marknums[i]->width); + h = SHORT(marknums[i]->height); + fx = CXMTOF(markpoints[i].x); + fy = CYMTOF(markpoints[i].y); + if (fx >= f_x && fx <= f_w - w && fy >= f_y && fy <= f_h - h) + V_DrawPatch(fx, fy, marknums[i]); + } } } */ void AM_drawkeys(void) { - if(KeyPoints[0].x != 0 || KeyPoints[0].y != 0) + if (KeyPoints[0].x != 0 || KeyPoints[0].y != 0) { AM_drawLineCharacter(keysquare, NUMKEYSQUARELINES, 0, 0, YELLOWKEY, KeyPoints[0].x, KeyPoints[0].y); } - if(KeyPoints[1].x != 0 || KeyPoints[1].y != 0) + if (KeyPoints[1].x != 0 || KeyPoints[1].y != 0) { AM_drawLineCharacter(keysquare, NUMKEYSQUARELINES, 0, 0, GREENKEY, KeyPoints[1].x, KeyPoints[1].y); } - if(KeyPoints[2].x != 0 || KeyPoints[2].y != 0) + if (KeyPoints[2].x != 0 || KeyPoints[2].y != 0) { AM_drawLineCharacter(keysquare, NUMKEYSQUARELINES, 0, 0, BLUEKEY, KeyPoints[2].x, KeyPoints[2].y); @@ -1324,12 +1354,12 @@ void AM_drawkeys(void) void AM_drawCrosshair(int color) { - fb[(f_w*(f_h+1))/2] = color; // single point for now + fb[(f_w * (f_h + 1)) / 2] = color; // single point for now } void AM_DrawTime(void) { - struct tm *local = NULL; + struct tm *local = NULL; time_t utc = 0; const char *timefmt = NULL; char st[80]; @@ -1353,23 +1383,23 @@ void AM_Drawer(void) if (!automapactive) return; - UpdateState |= I_FULLSCRN; - AM_clearFB(BACKGROUND); - if (grid) AM_drawGrid(GRIDCOLORS); - AM_drawWalls(); - AM_drawPlayers(); - if (cheating==2) - AM_drawThings(THINGCOLORS, THINGRANGE); + UpdateState |= I_FULLSCRN; + AM_clearFB(BACKGROUND); + if (grid) AM_drawGrid(GRIDCOLORS); + AM_drawWalls(); + AM_drawPlayers(); + if (cheating == 2) + AM_drawThings(THINGCOLORS, THINGRANGE); - if(gameskill == sk_baby) + if (gameskill == sk_baby) { AM_drawkeys(); } - if((gameepisode < (ExtendedWAD ? 6 : 4)) && gamemap < 10) + if ((gameepisode < (ExtendedWAD ? 6 : 4)) && gamemap < 10) { - MN_DrTextA(DEH_String(LevelNames[(gameepisode-1)*9+gamemap-1]), 20, 135); + MN_DrTextA(DEH_String(LevelNames[(gameepisode - 1) * 9 + gamemap - 1]), 20, 135); } - sprintf(secrets, "SECRETS FOUND: %i/%i", players[consoleplayer].secretcount,totalsecret); // FS + sprintf(secrets, "SECRETS FOUND: %i/%i", players[consoleplayer].secretcount, totalsecret); // FS MN_DrTextA(secrets, 20, 145); // FS if (drawTime) diff --git a/CT_CHAT.C b/CT_CHAT.C index f5142ae..ad9418f 100644 --- a/CT_CHAT.C +++ b/CT_CHAT.C @@ -47,7 +47,7 @@ int tail; byte ChatQueue[QUEUESIZE]; int chat_dest[MAXPLAYERS]; char chat_msg[MAXPLAYERS][MESSAGESIZE]; -char plr_lastmsg[MAXPLAYERS][MESSAGESIZE+9]; // add in the length of the pre-string +char plr_lastmsg[MAXPLAYERS][MESSAGESIZE + 9]; // add in the length of the pre-string int msgptr[MAXPLAYERS]; int msglen[MAXPLAYERS]; @@ -84,14 +84,14 @@ void CT_Init(void) tail = 0; chatmodeon = false; memset(ChatQueue, 0, QUEUESIZE); - for(i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < MAXPLAYERS; i++) { chat_dest[i] = 0; msgptr[i] = 0; - memset(plr_lastmsg[i], 0, MESSAGESIZE+9); + memset(plr_lastmsg[i], 0, MESSAGESIZE + 9); memset(chat_msg[i], 0, MESSAGESIZE); } - FontABaseLump = W_GetNumForName("FONTA_S")+1; + FontABaseLump = W_GetNumForName("FONTA_S") + 1; return; } @@ -119,49 +119,49 @@ boolean CT_Responder(event_t *ev) int sendto; - if(!netgame) + if (!netgame) { return false; } - if(ev->data1 == KEY_LALT || ev->data2 == KEY_RALT) + if (ev->data1 == KEY_LALT || ev->data2 == KEY_RALT) { altdown = (ev->type == ev_keydown); return false; } - if(ev->data1 == KEY_RSHIFT) + if (ev->data1 == KEY_RSHIFT) { shiftdown = (ev->type == ev_keydown); return false; } - if(ev->type != ev_keydown) + if (ev->type != ev_keydown) { return false; } - if(!chatmodeon) + if (!chatmodeon) { sendto = 0; - if(ev->data1 == CT_KEY_ALL) + if (ev->data1 == CT_KEY_ALL) { sendto = CT_PLR_ALL; } - else if(ev->data1 == CT_KEY_GREEN) + else if (ev->data1 == CT_KEY_GREEN) { sendto = CT_PLR_GREEN; } - else if(ev->data1 == CT_KEY_YELLOW) + else if (ev->data1 == CT_KEY_YELLOW) { sendto = CT_PLR_YELLOW; } - else if(ev->data1 == CT_KEY_RED) + else if (ev->data1 == CT_KEY_RED) { sendto = CT_PLR_RED; } - else if(ev->data1 == CT_KEY_BLUE) + else if (ev->data1 == CT_KEY_BLUE) { sendto = CT_PLR_BLUE; } - if(sendto == 0 || (sendto != CT_PLR_ALL && !playeringame[sendto-1]) - || sendto == consoleplayer+1) + if (sendto == 0 || (sendto != CT_PLR_ALL && !playeringame[sendto - 1]) + || sendto == consoleplayer + 1) { return false; } @@ -171,18 +171,18 @@ boolean CT_Responder(event_t *ev) } else { - if(altdown) + if (altdown) { - if(ev->data1 >= '0' && ev->data1 <= '9') + if (ev->data1 >= '0' && ev->data1 <= '9') { - if(ev->data1 == '0') + if (ev->data1 == '0') { // macro 0 comes after macro 9 - ev->data1 = '9'+1; + ev->data1 = '9' + 1; } - macro = chat_macros[ev->data1-'1']; + macro = chat_macros[ev->data1 - '1']; CT_queueChatChar(KEY_ENTER); //send old message CT_queueChatChar(chat_dest[consoleplayer]); // chose the dest. - while(*macro) + while (*macro) { CT_queueChatChar(toupper(*macro++)); } @@ -191,31 +191,31 @@ boolean CT_Responder(event_t *ev) return true; } } - if(ev->data1 == KEY_ENTER) + if (ev->data1 == KEY_ENTER) { CT_queueChatChar(KEY_ENTER); CT_Stop(); return true; } - else if(ev->data1 == KEY_ESCAPE) + else if (ev->data1 == KEY_ESCAPE) { CT_queueChatChar(CT_ESCAPE); CT_Stop(); return true; } - else if(ev->data1 >= 'a' && ev->data1 <= 'z') + else if (ev->data1 >= 'a' && ev->data1 <= 'z') { - CT_queueChatChar(ev->data1-32); + CT_queueChatChar(ev->data1 - 32); return true; } - else if(shiftdown) + else if (shiftdown) { - if(ev->data1 == '1') + if (ev->data1 == '1') { CT_queueChatChar('!'); return true; } - else if(ev->data1 == '/') + else if (ev->data1 == '/') { CT_queueChatChar('?'); return true; @@ -223,9 +223,9 @@ boolean CT_Responder(event_t *ev) } else { - if(ev->data1 == ' ' || ev->data1 == ',' || ev->data1 == '.' - || (ev->data1 >= '0' && ev->data1 <= '9') || ev->data1 == '\'' - || ev->data1 == KEY_BACKSPACE || ev->data1 == '-' || ev->data1 == '=') + if (ev->data1 == ' ' || ev->data1 == ',' || ev->data1 == '.' + || (ev->data1 >= '0' && ev->data1 <= '9') || ev->data1 == '\'' + || ev->data1 == KEY_BACKSPACE || ev->data1 == '-' || ev->data1 == '=') { CT_queueChatChar(ev->data1); return true; @@ -248,32 +248,32 @@ void CT_Ticker(void) char c; int numplayers; - for(i=0; i < MAXPLAYERS; i++) + for (i = 0; i < MAXPLAYERS; i++) { - if(!playeringame[i]) + if (!playeringame[i]) { continue; } - if((c = players[i].cmd.chatchar) != 0) + if ((c = players[i].cmd.chatchar) != 0) { - if(c <= 5) + if (c <= 5) { chat_dest[i] = c; continue; } - else if(c == CT_ESCAPE) + else if (c == CT_ESCAPE) { CT_ClearChatMessage(i); } - else if(c == KEY_ENTER) + else if (c == KEY_ENTER) { numplayers = 0; - for(j = 0; j < MAXPLAYERS; j++) + for (j = 0; j < MAXPLAYERS; j++) { numplayers += playeringame[j]; } CT_AddChar(i, 0); // set the end of message character - if(numplayers > 2) + if (numplayers > 2) { strcpy(plr_lastmsg[i], CT_FromPlrText[i]); strcat(plr_lastmsg[i], chat_msg[i]); @@ -282,18 +282,18 @@ void CT_Ticker(void) { strcpy(plr_lastmsg[i], chat_msg[i]); } - if(i != consoleplayer && (chat_dest[i] == consoleplayer+1 + if (i != consoleplayer && (chat_dest[i] == consoleplayer + 1 || chat_dest[i] == CT_PLR_ALL) && *chat_msg[i]) { - P_SetMessage(&players[consoleplayer], plr_lastmsg[i], + P_SetMessage(&players[consoleplayer], plr_lastmsg[i], true); S_StartSound(NULL, sfx_chat); } - else if(i == consoleplayer && (*chat_msg[i])) + else if (i == consoleplayer && (*chat_msg[i])) { - if(numplayers > 1) + if (numplayers > 1) { - P_SetMessage(&players[consoleplayer], "-MESSAGE SENT-", + P_SetMessage(&players[consoleplayer], "-MESSAGE SENT-", true); S_StartSound(NULL, sfx_chat); } @@ -306,7 +306,7 @@ void CT_Ticker(void) } CT_ClearChatMessage(i); } - else if(c == KEY_BACKSPACE) + else if (c == KEY_BACKSPACE) { CT_BackSpace(i); } @@ -331,19 +331,19 @@ void CT_Drawer(void) int x; patch_t *patch; - if(chatmodeon) + if (chatmodeon) { x = 25; - for(i = 0; i < msgptr[consoleplayer]; i++) + for (i = 0; i < msgptr[consoleplayer]; i++) { - if(chat_msg[consoleplayer][i] < 33) + if (chat_msg[consoleplayer][i] < 33) { x += 6; } else { - patch=W_CacheLumpNum(FontABaseLump+ - chat_msg[consoleplayer][i]-33, PU_CACHE); + patch = W_CacheLumpNum(FontABaseLump + + chat_msg[consoleplayer][i] - 33, PU_CACHE); V_DrawPatch(x, 10, patch); x += patch->width; } @@ -362,12 +362,12 @@ void CT_Drawer(void) void CT_queueChatChar(char ch) { - if((tail+1)&(QUEUESIZE-1) == head) + if ((tail + 1) & (QUEUESIZE - 1) == head) { // the queue is full return; } ChatQueue[tail] = ch; - tail = (tail+1)&(QUEUESIZE-1); + tail = (tail + 1) & (QUEUESIZE - 1); } //=========================================================================== @@ -380,12 +380,12 @@ char CT_dequeueChatChar(void) { byte temp; - if(head == tail) + if (head == tail) { // queue is empty return 0; } temp = ChatQueue[head]; - head = (head+1)&(QUEUESIZE-1); + head = (head + 1) & (QUEUESIZE - 1); return temp; } @@ -399,19 +399,19 @@ void CT_AddChar(int player, char c) { patch_t *patch; - if(msgptr[player]+1 >= MESSAGESIZE || msglen[player] >= MESSAGELEN) + if (msgptr[player] + 1 >= MESSAGESIZE || msglen[player] >= MESSAGELEN) { // full. return; } chat_msg[player][msgptr[player]] = c; msgptr[player]++; - if(c < 33) + if (c < 33) { msglen[player] += 6; } else { - patch = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE); + patch = W_CacheLumpNum(FontABaseLump + c - 33, PU_CACHE); msglen[player] += patch->width; } } @@ -428,19 +428,19 @@ void CT_BackSpace(int player) patch_t *patch; char c; - if(msgptr[player] == 0) + if (msgptr[player] == 0) { // message is already blank return; } msgptr[player]--; c = chat_msg[player][msgptr[player]]; - if(c < 33) + if (c < 33) { msglen[player] -= 6; } else { - patch = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE); + patch = W_CacheLumpNum(FontABaseLump + c - 33, PU_CACHE); msglen[player] -= patch->width; } chat_msg[player][msgptr[player]] = 0; diff --git a/D_MAIN.C b/D_MAIN.C index 3096d6a..3d6fd60 100644 --- a/D_MAIN.C +++ b/D_MAIN.C @@ -64,9 +64,9 @@ boolean convertsave = false; // FS: Convert Save fixed_t FixedDiv(fixed_t a, fixed_t b) { - if((abs(a)>>14) >= abs(b)) + if ((abs(a) >> 14) >= abs(b)) { - return((a^b)<0 ? MININT : MAXINT); + return((a ^ b) < 0 ? MININT : MAXINT); } return(FixedDiv2(a, b)); } @@ -98,7 +98,7 @@ int eventtail; void D_PostEvent(event_t *ev) { events[eventhead] = *ev; - eventhead = (++eventhead)&(MAXEVENTS-1); + eventhead = (++eventhead) & (MAXEVENTS - 1); } //--------------------------------------------------------------------------- @@ -113,14 +113,14 @@ void D_ProcessEvents(void) { event_t *ev; - for(; eventtail != eventhead; eventtail = (++eventtail)&(MAXEVENTS-1)) + for (; eventtail != eventhead; eventtail = (++eventtail) & (MAXEVENTS - 1)) { ev = &events[eventtail]; - if(F_Responder(ev)) + if (F_Responder(ev)) { continue; } - if(MN_Responder(ev)) + if (MN_Responder(ev)) { continue; } @@ -139,11 +139,11 @@ void DrawMessage(void) player_t *player; player = &players[consoleplayer]; - if(player->messageTics <= 0 || !player->message) + if (player->messageTics <= 0 || !player->message) { // No message return; } - MN_DrTextA(player->message, 160-MN_TextAWidth(player->message)/2, 1); + MN_DrTextA(player->message, 160 - MN_TextAWidth(player->message) / 2, 1); } //--------------------------------------------------------------------------- @@ -164,43 +164,43 @@ void D_Display(void) extern boolean askforquit; // Change the view size if needed - if(setsizeneeded) + if (setsizeneeded) { R_ExecuteSetViewSize(); } -// -// do buffered drawing -// + // + // do buffered drawing + // switch (gamestate) { - case GS_LEVEL: - if (!gametic) + case GS_LEVEL: + if (!gametic) + break; + if (automapactive) + AM_Drawer (); + else + R_RenderPlayerView (&players[displayplayer]); + CT_Drawer(); + UpdateState |= I_FULLVIEW; + SB_Drawer(); + break; + case GS_INTERMISSION: + IN_Drawer (); + break; + case GS_FINALE: + F_Drawer (); + break; + case GS_DEMOSCREEN: + D_PageDrawer (); break; - if (automapactive) - AM_Drawer (); - else - R_RenderPlayerView (&players[displayplayer]); - CT_Drawer(); - UpdateState |= I_FULLVIEW; - SB_Drawer(); - break; - case GS_INTERMISSION: - IN_Drawer (); - break; - case GS_FINALE: - F_Drawer (); - break; - case GS_DEMOSCREEN: - D_PageDrawer (); - break; } - if(paused && !MenuActive && !askforquit) + if (paused && !MenuActive && !askforquit) { - if(!netgame) + if (!netgame) { - V_DrawPatch(160, viewwindowy+5, W_CacheLumpName("PAUSED", + V_DrawPatch(160, viewwindowy + 5, W_CacheLumpName("PAUSED", PU_CACHE)); } else @@ -230,24 +230,24 @@ void D_Display(void) void D_DoomLoop(void) { - if(M_CheckParm("-debugfile")) + if (M_CheckParm("-debugfile")) { char filename[20]; sprintf(filename, "debug%i.txt", consoleplayer); - debugfile = fopen(filename,"w"); + debugfile = fopen(filename, "w"); } I_InitGraphics(); - while(1) + while (1) { // Frame syncronous IO operations I_StartFrame(); // Process one or more tics - if(singletics) + if (singletics) { I_StartTic(); D_ProcessEvents(); - G_BuildTiccmd(&netcmds[consoleplayer][maketic%BACKUPTICS]); + G_BuildTiccmd(&netcmds[consoleplayer][maketic % BACKUPTICS]); if (advancedemo) D_DoAdvanceDemo (); G_Ticker(); @@ -276,7 +276,7 @@ void D_DoomLoop(void) int demosequence; int pagetic; -char *pagename; +char *pagename; /* @@ -309,7 +309,7 @@ extern boolean MenuActive; void D_PageDrawer(void) { V_DrawRawScreen(W_CacheLumpName(pagename, PU_CACHE)); - if(demosequence == 1) + if (demosequence == 1) { V_DrawPatch(4, 160, W_CacheLumpName("ADVISOR", PU_CACHE)); } @@ -337,7 +337,7 @@ void D_DoAdvanceDemo (void) usergame = false; // can't save / end game here paused = false; gameaction = ga_nothing; - demosequence = (demosequence+1)%7; + demosequence = (demosequence + 1) % 7; switch (demosequence) { case 0: @@ -372,7 +372,7 @@ void D_DoAdvanceDemo (void) case 5: pagetic = 200; gamestate = GS_DEMOSCREEN; - if(shareware) + if (shareware) { pagename = "ORDER"; } @@ -422,21 +422,21 @@ void D_CheckRecordFrom (void) char file[256]; p = M_CheckParm ("-recordfrom"); - if (!p || p > myargc-2) + if (!p || p > myargc - 2) return; - if(cdrom) + if (cdrom) { - sprintf(file, SAVEGAMENAMECD"%c.hsg",myargv[p+1][0]); + sprintf(file, SAVEGAMENAMECD"%c.hsg", myargv[p + 1][0]); } else { - sprintf(file, SAVEGAMENAME"%c.hsg",myargv[p+1][0]); + sprintf(file, SAVEGAMENAME"%c.hsg", myargv[p + 1][0]); } G_LoadGame (file); G_DoLoadGame (); // load the gameskill etc info from savegame - G_RecordDemo (gameskill, 1, gameepisode, gamemap, myargv[p+2]); + G_RecordDemo (gameskill, 1, gameepisode, gamemap, myargv[p + 2]); D_DoomLoop (); // never returns } @@ -490,32 +490,32 @@ char exrnwads2[80]; void wadprintf(void) { - if(debugmode || M_CheckParm ("-faststart") || faststart) // FS: Fast Start + if (debugmode || M_CheckParm ("-faststart") || faststart) // FS: Fast Start { return; } - #ifdef __WATCOMC__ +#ifdef __WATCOMC__ _settextposition(23, 2); _setbkcolor(1); _settextcolor(0); _outtext(exrnwads); _settextposition(24, 2); _outtext(exrnwads2); - #endif +#endif } void D_AddFile(char *file, int flag) { int numwadfiles; char *new; -// char text[256]; + // char text[256]; - for(numwadfiles = 0; wadfiles[numwadfiles]; numwadfiles++); - new = malloc(strlen(file)+1); + for (numwadfiles = 0; wadfiles[numwadfiles]; numwadfiles++); + new = malloc(strlen(file) + 1); strcpy(new, file); - if(strlen(exrnwads)+strlen(file) < 78 && flag) // FS + if (strlen(exrnwads) + strlen(file) < 78 && flag) // FS { - if(strlen(exrnwads)) + if (strlen(exrnwads)) { strcat(exrnwads, ", "); } @@ -525,9 +525,9 @@ void D_AddFile(char *file, int flag) } strcat(exrnwads, file); } - else if(strlen(exrnwads2)+strlen(file) < 79 && flag) // FS + else if (strlen(exrnwads2) + strlen(file) < 79 && flag) // FS { - if(strlen(exrnwads2)) + if (strlen(exrnwads2)) { strcat(exrnwads2, ", "); } @@ -555,7 +555,7 @@ void D_AddFile(char *file, int flag) int thermMax; int thermCurrent; -char *startup; // * to text screen +char *startup; // * to text screen char smsg[80]; // status bar line // @@ -564,9 +564,9 @@ char smsg[80]; // status bar line byte *hscreen; -void hgotoxy(int x,int y) +void hgotoxy(int x, int y) { - hscreen = (byte *)(0xb8000 + y*160 + x*2); + hscreen = (byte *)(0xb8000 + y * 160 + x * 2); } void hput(unsigned char c, unsigned char a) @@ -580,15 +580,15 @@ void hprintf(char *string, unsigned char a) #ifdef __WATCOMC__ int i; - if(M_CheckParm ("-faststart") || faststart) // FS: Fast Start + if (M_CheckParm ("-faststart") || faststart) // FS: Fast Start return; - if(debugmode) + if (debugmode) { puts(string); return; } - for(i = 0; i < strlen(string); i++) + for (i = 0; i < strlen(string); i++) { hput(string[i], a); } @@ -597,42 +597,42 @@ void hprintf(char *string, unsigned char a) void drawstatus(void) { - if(debugmode || M_CheckParm ("-faststart") || faststart ) // FS: Fast Start + if (debugmode || M_CheckParm ("-faststart") || faststart) // FS: Fast Start { return; } - #ifdef __WATCOMC__ +#ifdef __WATCOMC__ _settextposition(25, 2); _setbkcolor(1); _settextcolor(15); _outtext(smsg); _settextposition(25, 1); - #endif +#endif } void status(char *string) { - strcat(smsg,string); + strcat(smsg, string); drawstatus(); } void DrawThermo(void) { - #ifdef __WATCOMC__ - unsigned char *screen; +#ifdef __WATCOMC__ + unsigned char *screen; int progress; int i; - if(debugmode || M_CheckParm ("-faststart") || faststart) // FS: Fast Start + if (debugmode || M_CheckParm ("-faststart") || faststart) // FS: Fast Start { return; } #if 0 - progress = (98*thermCurrent)/thermMax; - screen = (char *)0xb8000 + (THERM_Y*160 + THERM_X*2); - for (i = 0;i < progress/2; i++) + progress = (98 * thermCurrent) / thermMax; + screen = (char *)0xb8000 + (THERM_Y * 160 + THERM_X * 2); + for (i = 0; i < progress / 2; i++) { - switch(i) + switch (i) { case 4: case 9: @@ -643,11 +643,11 @@ void DrawThermo(void) case 39: case 44: *screen++ = 0xb3; - *screen++ = (THERMCOLOR<<4)+15; + *screen++ = (THERMCOLOR << 4) + 15; break; case 24: *screen++ = 0xba; - *screen++ = (THERMCOLOR<<4)+15; + *screen++ = (THERMCOLOR << 4) + 15; break; default: *screen++ = 0xdb; @@ -655,23 +655,23 @@ void DrawThermo(void) break; } } - if (progress&1) + if (progress & 1) { *screen++ = 0xdd; *screen++ = 0x40 + THERMCOLOR; } #else - progress = (50*thermCurrent)/thermMax+2; -// screen = (char *)0xb8000 + (THERM_Y*160 + THERM_X*2); - hgotoxy(THERM_X,THERM_Y); + progress = (50 * thermCurrent) / thermMax + 2; + // screen = (char *)0xb8000 + (THERM_Y*160 + THERM_X*2); + hgotoxy(THERM_X, THERM_Y); for (i = 0; i < progress; i++) { -// *screen++ = 0xdb; -// *screen++ = 0x2a; - hput(0xdb,0x2a); + // *screen++ = 0xdb; + // *screen++ = 0x2a; + hput(0xdb, 0x2a); } #endif - #endif +#endif } #ifdef __WATCOMC__ @@ -679,7 +679,7 @@ void blitStartup(void) { byte *textScreen; - if(debugmode || M_CheckParm("-faststart") || faststart) // FS: Fast Start + if (debugmode || M_CheckParm("-faststart") || faststart) // FS: Fast Start { return; } @@ -700,26 +700,26 @@ void blitStartup(void) #endif char tmsg[300]; -void tprintf(char *msg,int initflag) +void tprintf(char *msg, int initflag) { - if(debugmode || M_CheckParm ("-faststart") || faststart) // FS: Fast Start + if (debugmode || M_CheckParm ("-faststart") || faststart) // FS: Fast Start { printf("%s", msg); return; } #if 0 - #ifdef __WATCOMC__ +#ifdef __WATCOMC__ char temp[80]; int start; int add; int i; - #endif +#endif - #ifdef __WATCOMC__ +#ifdef __WATCOMC__ if (initflag) tmsg[0] = 0; - strcat(tmsg,msg); + strcat(tmsg, msg); blitStartup(); DrawThermo(); _setbkcolor(4); @@ -727,18 +727,18 @@ void tprintf(char *msg,int initflag) for (add = start = i = 0; i <= strlen(tmsg); i++) if ((tmsg[i] == '\n') || (!tmsg[i])) { - memset(temp,0,80); - strncpy(temp,tmsg+start,i-start); - _settextposition(MSG_Y+add,40-strlen(temp)/2); + memset(temp, 0, 80); + strncpy(temp, tmsg + start, i - start); + _settextposition(MSG_Y + add, 40 - strlen(temp) / 2); _outtext(temp); - start = i+1; + start = i + 1; add++; } - _settextposition(25,1); + _settextposition(25, 1); drawstatus(); - #else +#else printf(msg); - #endif +#endif #endif } @@ -760,7 +760,7 @@ void CheckAbortStartup(void) #ifdef __WATCOMC__ extern int lastpress; - if(lastpress == 1) + if (lastpress == 1) { // Abort if escape pressed CleanExit(); } @@ -804,7 +804,7 @@ void D_DoomMain(void) noartiskip = M_CheckParm("-noartiskip"); debugmode = M_CheckParm("-debug"); - if(M_CheckParm("-oldsave")) // FS: Load old saves + if (M_CheckParm("-oldsave")) // FS: Load old saves { savestringsize = 24; savegamesize = 0x30000; @@ -817,14 +817,14 @@ void D_DoomMain(void) // FS: Define a custom main WAD p = M_CheckParm("-mainwad"); - if(p) + if (p) { - wadfiles[0] = myargv[p+1]; + wadfiles[0] = myargv[p + 1]; } - + // wadfiles[0] is a char * to the main wad fp = fopen(wadfiles[0], "rb"); - if(fp) + if (fp) { fclose(fp); } @@ -836,7 +836,7 @@ void D_DoomMain(void) // Check for -CDROM cdrom = false; #ifdef __WATCOMC__ - if(M_CheckParm("-cdrom")) + if (M_CheckParm("-cdrom")) { cdrom = true; mkdir("c:\\heretic.cd"); @@ -846,12 +846,12 @@ void D_DoomMain(void) // -FILE [filename] [filename] ... // Add files to the wad list. p = M_CheckParm("-file"); - if(p) + if (p) { // the parms after p are wadfile/lump names, until end of parms // or another - preceded parm - while(++p != myargc && myargv[p][0] != '-') + while (++p != myargc && myargv[p][0] != '-') { - D_AddFile(myargv[p], 1); + D_AddFile(myargv[p], 1); } } @@ -860,67 +860,67 @@ void D_DoomMain(void) // and sets the start episode and the start map. devMap = false; p = M_CheckParm("-devmap"); - if(p && p < myargc-2) + if (p && p < myargc - 2) { - e = myargv[p+1][0]; - m = myargv[p+2][0]; + e = myargv[p + 1][0]; + m = myargv[p + 2][0]; sprintf(file, MAPDIR"E%cM%c.wad", e, m); - D_AddFile(file, 1); + D_AddFile(file, 1); printf("DEVMAP: Episode %c, Map %c.\n", e, m); - startepisode = e-'0'; - startmap = m-'0'; + startepisode = e - '0'; + startmap = m - '0'; autostart = true; devMap = true; } p = M_CheckParm("-playdemo"); - if(!p) + if (!p) { p = M_CheckParm("-timedemo"); } - if (p && p < myargc-1) + if (p && p < myargc - 1) { - sprintf(file, "%s.lmp", myargv[p+1]); + sprintf(file, "%s.lmp", myargv[p + 1]); D_AddFile(file, 1); - printf("Playing demo %s.lmp.\n", myargv[p+1]); + printf("Playing demo %s.lmp.\n", myargv[p + 1]); } -// -// get skill / episode / map from parms -// - if(M_CheckParm("-deathmatch")) + // + // get skill / episode / map from parms + // + if (M_CheckParm("-deathmatch")) { deathmatch = true; } p = M_CheckParm("-skill"); - if(p && p < myargc-1) + if (p && p < myargc - 1) { - startskill = myargv[p+1][0]-'1'; - if(startskill < sk_baby || startskill > sk_nightmare) // FS: Make sure it's valid. Was fucking up my Kali gamin'! + startskill = myargv[p + 1][0] - '1'; + if (startskill < sk_baby || startskill > sk_nightmare) // FS: Make sure it's valid. Was fucking up my Kali gamin'! I_Error("Invalid Skill parameter! Valid options are 1 through 5."); autostart = true; } p = M_CheckParm("-episode"); - if(p && p < myargc-1) + if (p && p < myargc - 1) { - startepisode = myargv[p+1][0]-'0'; + startepisode = myargv[p + 1][0] - '0'; startmap = 1; autostart = true; } p = M_CheckParm("-warp"); - if(p && p < myargc-2) + if (p && p < myargc - 2) { - startepisode = myargv[p+1][0]-'0'; - startmap = myargv[p+2][0]-'0'; + startepisode = myargv[p + 1][0] - '0'; + startmap = myargv[p + 2][0] - '0'; autostart = true; } -// -// init subsystems -// + // + // init subsystems + // printf("V_Init: allocate screens.\n"); V_Init(); @@ -928,18 +928,18 @@ void D_DoomMain(void) printf("M_LoadDefaults: Load system defaults.\n"); M_LoadDefaults(); M_LoadExtendedDefaults(); // FS: For EXTEND.CFG - + printf("Z_Init: Init zone memory allocation daemon.\n"); Z_Init(); printf("W_Init: Init WADfiles.\n"); W_InitMultipleFiles(wadfiles); - if(W_CheckNumForName("E2M1") == -1) + if (W_CheckNumForName("E2M1") == -1) { // Can't find episode 2 maps, must be the shareware WAD shareware = true; } - else if(W_CheckNumForName("EXTENDED") != -1) + else if (W_CheckNumForName("EXTENDED") != -1) { // Found extended lump, must be the extended WAD ExtendedWAD = true; } @@ -949,9 +949,9 @@ void D_DoomMain(void) I_StartupJoystick(); #endif startup = W_CacheLumpName("LOADING", PU_CACHE); - #ifdef __WATCOMC__ +#ifdef __WATCOMC__ blitStartup(); - #endif +#endif // // Build status bar line! @@ -966,39 +966,39 @@ void D_DoomMain(void) if (autostart) { char temp[64]; - sprintf(temp, "Warp to Episode %d, Map %d, Skill %d ", startepisode, startmap, startskill+1); + sprintf(temp, "Warp to Episode %d, Map %d, Skill %d ", startepisode, startmap, startskill + 1); status(temp); } wadprintf(); // print the added wadfiles - tprintf("MN_Init: Init menu system.\n",1); + tprintf("MN_Init: Init menu system.\n", 1); MN_Init(); CT_Init(); - tprintf("R_Init: Init Heretic refresh daemon - ",1); - hgotoxy(17,7); - hprintf("Loading graphics",0x3f); + tprintf("R_Init: Init Heretic refresh daemon - ", 1); + hgotoxy(17, 7); + hprintf("Loading graphics", 0x3f); R_Init(); - tprintf("\nP_Init: Init Playloop state.\n",1); - hgotoxy(17,8); - hprintf("Init game engine.",0x3f); + tprintf("\nP_Init: Init Playloop state.\n", 1); + hgotoxy(17, 8); + hprintf("Init game engine.", 0x3f); P_Init(); IncThermo(); - tprintf("I_Init: Setting up machine state.\n",1); + tprintf("I_Init: Setting up machine state.\n", 1); I_Init(); IncThermo(); - tprintf("D_CheckNetGame: Checking network game status.\n",1); - if(hasGUS) + tprintf("D_CheckNetGame: Checking network game status.\n", 1); + if (hasGUS) { - hgotoxy(17,10); // FS + hgotoxy(17, 10); // FS } else { - hgotoxy(17,9); // FS + hgotoxy(17, 9); // FS } hprintf("Checking network game status.", 0x3f); D_CheckNetGame(); @@ -1008,26 +1008,26 @@ void D_DoomMain(void) I_CheckExternDriver(); // Check for an external device driver #endif - tprintf("SB_Init: Loading patches.\n",1); + tprintf("SB_Init: Loading patches.\n", 1); SB_Init(); IncThermo(); -// -// start the apropriate game based on parms -// + // + // start the apropriate game based on parms + // - // FS: Idea from DOOM output intermission stats to a file + // FS: Idea from DOOM output intermission stats to a file p = M_CheckParm ("-statcopy"); - if (p && pretransmitfrom))/4; - for (i=0 ; iretransmitfrom)[i] * (i+1); + 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; } @@ -80,16 +80,16 @@ int ExpandTics (int low) { int delta; - delta = low - (maketic&0xff); + delta = low - (maketic & 0xff); if (delta >= -64 && delta <= 64) - return (maketic&~0xff) + low; + return (maketic & ~0xff) + low; if (delta > 64) - return (maketic&~0xff) - 256 + low; + return (maketic & ~0xff) - 256 + low; if (delta < -64) - return (maketic&~0xff) + 256 + low; + return (maketic & ~0xff) + 256 + low; - I_Error ("ExpandTics: strange value %i at maketic %i",low,maketic); + I_Error ("ExpandTics: strange value %i at maketic %i", low, maketic); return 0; } @@ -126,20 +126,20 @@ void HSendPacket (int node, int flags) doomcom->remotenode = node; doomcom->datalength = NetbufferSize (); -if (debugfile) -{ - int i; - int realretrans; - if (netbuffer->checksum & NCMD_RETRANSMIT) - 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 ; idatalength ; i++) - fprintf (debugfile,"%i ",((byte *)netbuffer)[i]); - fprintf (debugfile,"\n"); -} + if (debugfile) + { + int i; + int realretrans; + if (netbuffer->checksum & NCMD_RETRANSMIT) + 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 (); } @@ -177,37 +177,37 @@ boolean HGetPacket (void) if (doomcom->datalength != NetbufferSize ()) { if (debugfile) - fprintf (debugfile,"bad packet length %i\n",doomcom->datalength); + fprintf (debugfile, "bad packet length %i\n", doomcom->datalength); return false; } - if (NetbufferChecksum () != (netbuffer->checksum&NCMD_CHECKSUM) ) + if (NetbufferChecksum () != (netbuffer->checksum & NCMD_CHECKSUM)) { if (debugfile) - fprintf (debugfile,"bad packet checksum\n"); + 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 + if (debugfile) { - if (netbuffer->checksum & NCMD_RETRANSMIT) - realretrans = ExpandTics (netbuffer->retransmitfrom); + int realretrans; + int i; + + if (netbuffer->checksum & NCMD_SETUP) + fprintf (debugfile, "setup packet\n"); 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 ; idatalength ; i++) - fprintf (debugfile,"%i ",((byte *)netbuffer)[i]); - fprintf (debugfile,"\n"); + { + if (netbuffer->checksum & NCMD_RETRANSMIT) + 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"); + } } -} return true; } @@ -226,7 +226,7 @@ void GetPackets (void) { int netconsole; int netnode; - ticcmd_t *src, *dest; + ticcmd_t *src, *dest; int realend; int realstart; @@ -242,7 +242,7 @@ void GetPackets (void) // Figure out what the rest of the bytes are // realstart = ExpandTics (netbuffer->starttic); - realend = (realstart+netbuffer->numtics); + realend = (realstart + netbuffer->numtics); // // check for exiting the game @@ -256,8 +256,8 @@ void GetPackets (void) strcpy (exitmsg, "PLAYER 1 LEFT THE GAME"); exitmsg[7] += netconsole; players[consoleplayer].message = exitmsg; -// if (demorecording) -// G_CheckDemoStatus (); + // if (demorecording) + // G_CheckDemoStatus (); continue; } @@ -272,12 +272,12 @@ void GetPackets (void) // // check for retransmit request // - if ( resendcount[netnode] <= 0 - && (netbuffer->checksum & NCMD_RETRANSMIT) ) + if (resendcount[netnode] <= 0 + && (netbuffer->checksum & NCMD_RETRANSMIT)) { resendto[netnode] = ExpandTics(netbuffer->retransmitfrom); -if (debugfile) -fprintf (debugfile,"retransmit from %i\n", resendto[netnode]); + if (debugfile) + fprintf (debugfile, "retransmit from %i\n", resendto[netnode]); resendcount[netnode] = RESENDCOUNT; } else @@ -291,8 +291,8 @@ fprintf (debugfile,"retransmit from %i\n", resendto[netnode]); if (realend < nettics[netnode]) { -if (debugfile) -fprintf (debugfile,"out of order packet (%i + %i)\n" ,realstart,netbuffer->numtics); + if (debugfile) + fprintf (debugfile, "out of order packet (%i + %i)\n", realstart, netbuffer->numtics); continue; } @@ -301,33 +301,33 @@ fprintf (debugfile,"out of order packet (%i + %i)\n" ,realstart,netbuffer->numti // if (realstart > nettics[netnode]) { - // stop processing until the other system resends the missed tics -if (debugfile) -fprintf (debugfile,"missed tics from %i (%i - %i)\n", netnode, realstart, nettics[netnode]); + // stop processing until the other system resends the missed tics + if (debugfile) + fprintf (debugfile, "missed tics from %i (%i - %i)\n", netnode, realstart, nettics[netnode]); remoteresend[netnode] = true; continue; } -// -// update command store from the packet -// -{ - int start; + // + // update command store from the packet + // + { + int start; - remoteresend[netnode] = false; + remoteresend[netnode] = false; - start = nettics[netnode] - realstart; - src = &netbuffer->cmds[start]; + start = nettics[netnode] - realstart; + src = &netbuffer->cmds[start]; - while (nettics[netnode] < realend) - { - dest = &netcmds[netconsole][nettics[netnode]%BACKUPTICS]; - nettics[netnode]++; - *dest = *src; - src++; + while (nettics[netnode] < realend) + { + dest = &netcmds[netconsole][nettics[netnode] % BACKUPTICS]; + nettics[netnode]++; + *dest = *src; + src++; + } } } -} } @@ -347,14 +347,14 @@ void NetUpdate (void) { int nowtime; int newtics; - int i,j; + int i, j; int realstart; int gameticdiv; -// -// check time -// - nowtime = I_GetTime ()/ticdup; + // + // check time + // + nowtime = I_GetTime () / ticdup; newtics = nowtime - gametime; gametime = nowtime; @@ -375,18 +375,18 @@ void NetUpdate (void) netbuffer->player = consoleplayer; -// -// build new ticcmds for console player -// - gameticdiv = gametic/ticdup; - for (i=0 ; i= BACKUPTICS/2-1) + if (maketic - gameticdiv >= BACKUPTICS / 2 - 1) break; // can't hold any more //printf ("mk:%i ",maketic); - G_BuildTiccmd (&localcmds[maketic%BACKUPTICS]); + G_BuildTiccmd (&localcmds[maketic % BACKUPTICS]); maketic++; } @@ -397,7 +397,7 @@ void NetUpdate (void) // // send the packet to the other nodes // - for (i=0 ; inumnodes ; i++) + for (i = 0; i < doomcom->numnodes; i++) if (nodeingame[i]) { netbuffer->starttic = realstart = resendto[i]; @@ -407,9 +407,9 @@ void NetUpdate (void) resendto[i] = maketic - doomcom->extratics; - for (j=0 ; j< netbuffer->numtics ; j++) + for (j = 0; j < netbuffer->numtics; j++) netbuffer->cmds[j] = - localcmds[(realstart+j)%BACKUPTICS]; + localcmds[(realstart + j) % BACKUPTICS]; if (remoteresend[i]) { @@ -423,9 +423,9 @@ void NetUpdate (void) } } -// -// listen for other packets -// + // + // listen for other packets + // listen: GetPackets (); @@ -450,8 +450,8 @@ void CheckAbort (void) I_StartTic (); I_StartTic (); - for ( ; eventtail != eventhead - ; eventtail = (++eventtail)&(MAXEVENTS-1) ) + for (; eventtail != eventhead + ; eventtail = (++eventtail) & (MAXEVENTS - 1)) { ev = &events[eventtail]; if (ev->type == ev_keydown && ev->data1 == KEY_ESCAPE) @@ -473,7 +473,7 @@ void D_ArbitrateNetStart (void) boolean gotinfo[MAXNETNODES]; autostart = true; - memset (gotinfo,0,sizeof(gotinfo)); + memset (gotinfo, 0, sizeof(gotinfo)); if (doomcom->consoleplayer) { // listen for setup info from key player @@ -493,52 +493,52 @@ void D_ArbitrateNetStart (void) respawnparm = (netbuffer->retransmitfrom & 0x10) > 0; //startmap = netbuffer->starttic & 0x3f; //startepisode = netbuffer->starttic >> 6; - startmap = netbuffer->starttic&15; - startepisode = netbuffer->starttic>>4; + startmap = netbuffer->starttic & 15; + startepisode = netbuffer->starttic >> 4; return; } } } else - { // key player, send the setup info + { // key player, send the setup info // mprintf ("sending network start info...\n"); do { CheckAbort (); - for (i=0 ; inumnodes ; i++) + for (i = 0; i < doomcom->numnodes; i++) { netbuffer->retransmitfrom = startskill; if (deathmatch) - netbuffer->retransmitfrom |= (deathmatch<<6); + netbuffer->retransmitfrom |= (deathmatch << 6); if (nomonsters) netbuffer->retransmitfrom |= 0x20; if (respawnparm) netbuffer->retransmitfrom |= 0x10; //netbuffer->starttic = startepisode * 64 + startmap; - netbuffer->starttic = (startepisode<<4)+startmap; + netbuffer->starttic = (startepisode << 4) + startmap; netbuffer->player = VERSION; //netbuffer->numtics = 0; // original code /* SG 4/14/98 quick hack - we fill up about 2 tic buffers * should calculate our size/sizeof(ticcmd_t) */ - netbuffer->numtics = 2; + netbuffer->numtics = 2; HSendPacket (i, NCMD_SETUP); } #if 1 - for(i = 10 ; i && HGetPacket(); --i) + for (i = 10; i && HGetPacket(); --i) { - if((netbuffer->player&0x7f) < MAXNETNODES) - gotinfo[netbuffer->player&0x7f] = true; + if ((netbuffer->player & 0x7f) < MAXNETNODES) + gotinfo[netbuffer->player & 0x7f] = true; } #else while (HGetPacket ()) { - gotinfo[netbuffer->player&0x7f] = true; + gotinfo[netbuffer->player & 0x7f] = true; } #endif - for (i=1 ; inumnodes ; i++) + for (i = 1; i < doomcom->numnodes; i++) if (!gotinfo[i]) break; } while (i < doomcom->numnodes); @@ -560,15 +560,15 @@ void D_CheckNetGame (void) { int i; - for (i=0 ; iid != DOOMCOM_ID) I_Error ("Doomcom buffer invalid!"); @@ -576,20 +576,20 @@ void D_CheckNetGame (void) consoleplayer = displayplayer = doomcom->consoleplayer; if (netgame) D_ArbitrateNetStart (); -//printf ("startskill %i deathmatch: %i startmap: %i startepisode: %i\n", startskill, deathmatch, startmap, startepisode); + //printf ("startskill %i deathmatch: %i startmap: %i startepisode: %i\n", startskill, deathmatch, startmap, startepisode); -// read values out of doomcom + // read values out of doomcom ticdup = doomcom->ticdup; - maxsend = BACKUPTICS/(2*ticdup)-1; - if (maxsend<1) + maxsend = BACKUPTICS / (2 * ticdup) - 1; + if (maxsend < 1) maxsend = 1; - for (i=0 ; inumplayers ; i++) + for (i = 0; i < doomcom->numplayers; i++) playeringame[i] = true; - for (i=0 ; inumnodes ; i++) + for (i = 0; i < doomcom->numnodes; i++) nodeingame[i] = true; -//printf ("player %i of %i (%i nodes)\n", consoleplayer+1, doomcom->numplayers, doomcom->numnodes); + //printf ("player %i of %i (%i nodes)\n", consoleplayer+1, doomcom->numplayers, doomcom->numnodes); } @@ -614,12 +614,12 @@ void D_QuitNetGame (void) if (!netgame || !usergame || consoleplayer == -1 || demoplayback) return; -// send a bunch of packets for security + // send a bunch of packets for security netbuffer->player = consoleplayer; netbuffer->numtics = 0; - for (i=0 ; i<4 ; i++) + for (i = 0; i < 4; i++) { - for (j=1 ; jnumnodes ; j++) + for (j = 1; j < doomcom->numnodes; j++) if (nodeingame[j]) HSendPacket (j, NCMD_EXIT); I_WaitVBL (1); @@ -651,21 +651,21 @@ void TryRunTics (void) int counts; int numplaying; -// -// get real tics -// - entertic = I_GetTime ()/ticdup; + // + // get real tics + // + entertic = I_GetTime () / ticdup; realtics = entertic - oldentertics; oldentertics = entertic; -// -// get available tics -// + // + // get available tics + // NetUpdate (); lowtic = MAXINT; numplaying = 0; - for (i=0 ; inumnodes ; i++) + for (i = 0; i < doomcom->numnodes; i++) { if (nodeingame[i]) { @@ -674,14 +674,14 @@ void TryRunTics (void) lowtic = nettics[i]; } } - availabletics = lowtic - gametic/ticdup; + availabletics = lowtic - gametic / ticdup; -// -// decide how many tics to run -// - if (realtics < availabletics-1) - counts = realtics+1; + // + // decide how many tics to run + // + if (realtics < availabletics - 1) + counts = realtics + 1; else if (realtics < availabletics) counts = realtics; else @@ -691,17 +691,17 @@ void TryRunTics (void) frameon++; -if (debugfile) - fprintf (debugfile,"=======real: %i avail: %i game: %i\n",realtics, availabletics,counts); + if (debugfile) + fprintf (debugfile, "=======real: %i avail: %i game: %i\n", realtics, availabletics, counts); if (!demoplayback) { - //============================================================================= - // - // ideally nettics[0] should be 1 - 3 tics above lowtic - // if we are consistantly slower, speed up time - // - for (i=0 ; i nettics[nodeforplayer[i]]); + frameskip[frameon & 3] = (oldnettics > nettics[nodeforplayer[i]]); oldnettics = nettics[0]; if (frameskip[0] && frameskip[1] && frameskip[2] && frameskip[3]) { skiptics = 1; - // printf ("+"); + // printf ("+"); } } - //============================================================================= + //============================================================================= } // demoplayback // // wait for new tics if needed // - while (lowtic < gametic/ticdup + counts) - { + while (lowtic < gametic / ticdup + counts) + { - NetUpdate (); - lowtic = MAXINT; + NetUpdate (); + lowtic = MAXINT; - for (i=0 ; inumnodes ; i++) - if (nodeingame[i] && nettics[i] < lowtic) - lowtic = nettics[i]; + 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 (lowtic < gametic / ticdup) + I_Error ("TryRunTics: lowtic < gametic"); - // don't stay in here forever -- give the menu a chance to work - if (I_GetTime ()/ticdup - entertic >= 20) - { - MN_Ticker (); - return; - } + // don't stay in here forever -- give the menu a chance to work + if (I_GetTime () / ticdup - entertic >= 20) + { + MN_Ticker (); + return; } + } -// -// run the count * ticdup dics -// + // + // run the count * ticdup dics + // while (counts--) { - for (i=0 ; i lowtic) + if (gametic / ticdup > lowtic) I_Error ("gametic>lowtic"); if (advancedemo) D_DoAdvanceDemo (); @@ -766,14 +766,14 @@ if (debugfile) // // modify command for duplicated tics // - if (i != ticdup-1) + if (i != ticdup - 1) { - ticcmd_t *cmd; + ticcmd_t *cmd; int buf; int j; - buf = (gametic/ticdup)%BACKUPTICS; - for (j=0 ; jchatchar = 0; @@ -793,9 +793,9 @@ int NetGetPlayerCount(void) int saveplayers; saveplayers = 0; - for(i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < MAXPLAYERS; i++) { - if(playeringame[i]) + if (playeringame[i]) { saveplayers++; } diff --git a/F_FINALE.C b/F_FINALE.C index 917f437..51c8344 100644 --- a/F_FINALE.C +++ b/F_FINALE.C @@ -11,13 +11,13 @@ int finalecount; #define TEXTSPEED 3 #define TEXTWAIT 250 -char *e1text = E1TEXT; -char *e2text = E2TEXT; -char *e3text = E3TEXT; -char *e4text = E4TEXT; -char *e5text = E5TEXT; -char *finaletext; -char *finaleflat; +char *e1text = E1TEXT; +char *e2text = E2TEXT; +char *e3text = E3TEXT; +char *e4text = E4TEXT; +char *e5text = E5TEXT; +char *finaletext; +char *finaleflat; int FontABaseLump; @@ -43,7 +43,7 @@ void F_StartFinale (void) players[consoleplayer].messageTics = 1; players[consoleplayer].message = NULL; - switch(gameepisode) + switch (gameepisode) { case 1: finaleflat = "FLOOR25"; @@ -69,7 +69,7 @@ void F_StartFinale (void) finalestage = 0; finalecount = 0; - FontABaseLump = W_GetNumForName("FONTA_S")+1; + FontABaseLump = W_GetNumForName("FONTA_S") + 1; I_ShutdownVRGoggles(false); @@ -80,15 +80,15 @@ void F_StartFinale (void) boolean F_Responder (event_t *event) { - if(event->type != ev_keydown) + if (event->type != ev_keydown) { return false; } - if(finalestage == 1 && gameepisode == 2) + if (finalestage == 1 && gameepisode == 2) { // we're showing the water pic, make any key kick to demo mode finalestage++; - memset((byte *)0xa0000, 0, SCREENWIDTH*SCREENHEIGHT); - memset(screen, 0, SCREENWIDTH*SCREENHEIGHT); + memset((byte *)0xa0000, 0, SCREENWIDTH * SCREENHEIGHT); + memset(screen, 0, SCREENWIDTH * SCREENHEIGHT); I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); return true; } @@ -107,19 +107,19 @@ boolean F_Responder (event_t *event) void F_Ticker (void) { finalecount++; - if (!finalestage && finalecount>strlen (finaletext)*TEXTSPEED + TEXTWAIT) + if (!finalestage && finalecount > strlen (finaletext) * TEXTSPEED + TEXTWAIT) { finalecount = 0; - if(!finalestage) + if (!finalestage) { finalestage = 1; } -// wipegamestate = -1; // force a wipe -/* - if (gameepisode == 3) - S_StartMusic (mus_bunny); -*/ + // wipegamestate = -1; // force a wipe + /* + if (gameepisode == 3) + S_StartMusic (mus_bunny); + */ } } @@ -137,46 +137,46 @@ void F_Ticker (void) void F_TextWrite (void) { - byte *src, *dest; - int x,y; + byte *src, *dest; + int x, y; int count; - char *ch; + char *ch; int c; int cx, cy; patch_t *w; -// -// erase the entire screen to a tiled background -// + // + // erase the entire screen to a tiled background + // src = W_CacheLumpName(finaleflat, PU_CACHE); dest = screen; - for (y=0 ; ywidth > SCREENWIDTH) + w = W_CacheLumpNum(FontABaseLump + c - 33, PU_CACHE); + if (cx + w->width > SCREENWIDTH) break; V_DrawPatch(cx, cy, w); cx += w->width; @@ -216,55 +216,55 @@ void F_TextWrite (void) void F_Cast (void) { - byte *src, *dest; - int x,y,w; + byte *src, *dest; + int x, y, w; int count; - char *ch; + char *ch; int c; int cx, cy; -// -// erase the entire screen to a tiled background -// - src = W_CacheLumpName ( "FWATER1" , PU_CACHE); + // + // erase the entire screen to a tiled background + // + src = W_CacheLumpName ("FWATER1", PU_CACHE); dest = screen; - for (y=0 ; ycolumnofs[col])); - desttop = screen+x; + desttop = screen + x; -// step through the posts in a column + // step through the posts in a column - while (column->topdelta != 0xff ) + while (column->topdelta != 0xff) { source = (byte *)column + 3; - dest = desttop + column->topdelta*SCREENWIDTH; + dest = desttop + column->topdelta * SCREENWIDTH; count = column->length; while (count--) @@ -272,7 +272,7 @@ void F_DrawPatchCol (int x, patch_t *patch, int col) *dest = *source++; dest += SCREENWIDTH; } - column = (column_t *)( (byte *)column + column->length+ 4 ); + column = (column_t *)((byte *)column + column->length + 4); } } @@ -290,28 +290,28 @@ void F_DemonScroll(void) static int yval = 0; static int nextscroll = 0; - if(finalecount < nextscroll) + if (finalecount < nextscroll) { return; } p1 = W_CacheLumpName("FINAL1", PU_LEVEL); p2 = W_CacheLumpName("FINAL2", PU_LEVEL); - if(finalecount < 70) + if (finalecount < 70) { - memcpy(screen, p1, SCREENHEIGHT*SCREENWIDTH); + memcpy(screen, p1, SCREENHEIGHT * SCREENWIDTH); nextscroll = finalecount; return; } - if(yval < 64000) + if (yval < 64000) { - memcpy(screen, p2+SCREENHEIGHT*SCREENWIDTH-yval, yval); - memcpy(screen+yval, p1, SCREENHEIGHT*SCREENWIDTH-yval); + memcpy(screen, p2 + SCREENHEIGHT * SCREENWIDTH - yval, yval); + memcpy(screen + yval, p1, SCREENHEIGHT * SCREENWIDTH - yval); yval += SCREENWIDTH; - nextscroll = finalecount+3; + nextscroll = finalecount + 3; } else { //else, we'll just sit here and wait, for now - memcpy(screen, p2, SCREENWIDTH*SCREENHEIGHT); + memcpy(screen, p2, SCREENWIDTH * SCREENHEIGHT); } } @@ -329,16 +329,16 @@ void F_DrawUnderwater(void) extern boolean MenuActive; extern boolean askforquit; - switch(finalestage) + switch (finalestage) { case 1: - if(!underwawa) + if (!underwawa) { underwawa = true; - memset((byte *)0xa0000, 0, SCREENWIDTH*SCREENHEIGHT); + memset((byte *)0xa0000, 0, SCREENWIDTH * SCREENHEIGHT); I_SetPalette(W_CacheLumpName("E2PAL", PU_CACHE)); memcpy(screen, W_CacheLumpName("E2END", PU_CACHE), - SCREENWIDTH*SCREENHEIGHT); + SCREENWIDTH * SCREENHEIGHT); } paused = false; MenuActive = false; @@ -347,7 +347,7 @@ void F_DrawUnderwater(void) break; case 2: memcpy(screen, W_CacheLumpName("TITLE", PU_CACHE), - SCREENWIDTH*SCREENHEIGHT); + SCREENWIDTH * SCREENHEIGHT); //D_StartTitle(); // go to intro/demo mode. } } @@ -365,7 +365,7 @@ void F_DrawUnderwater(void) void F_BunnyScroll (void) { int scrolled, x; - patch_t *p1, *p2; + patch_t *p1, *p2; char name[10]; int stage; static int laststage; @@ -375,30 +375,30 @@ void F_BunnyScroll (void) V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT); - scrolled = 320 - (finalecount-230)/2; + scrolled = 320 - (finalecount - 230) / 2; if (scrolled > 320) scrolled = 320; if (scrolled < 0) scrolled = 0; - for ( x=0 ; x 6) stage = 6; if (stage > laststage) @@ -407,8 +407,8 @@ void F_BunnyScroll (void) laststage = stage; } - sprintf (name,"END%i",stage); - V_DrawPatch ((SCREENWIDTH-13*8)/2, (SCREENHEIGHT-8*8)/2, W_CacheLumpName (name,PU_CACHE)); + sprintf (name, "END%i", stage); + V_DrawPatch ((SCREENWIDTH - 13 * 8) / 2, (SCREENHEIGHT - 8 * 8) / 2, W_CacheLumpName (name, PU_CACHE)); } #endif @@ -430,7 +430,7 @@ void F_Drawer(void) switch (gameepisode) { case 1: - if(shareware) + if (shareware) { V_DrawRawScreen(W_CacheLumpName("ORDER", PU_CACHE)); } diff --git a/G_GAME.C b/G_GAME.C index 84edbc0..dae629d 100644 --- a/G_GAME.C +++ b/G_GAME.C @@ -97,14 +97,14 @@ int totalkills, totalitems, totalsecret; // for intermission char demoname[32]; boolean demorecording; boolean demoplayback; -byte *demobuffer, *demo_p; +byte *demobuffer, *demo_p; boolean singledemo; // quit after playing a demo from cmdline boolean precache = true; // if true, load all graphics at start short consistancy[MAXPLAYERS][BACKUPTICS]; -byte *savebuffer, *save_p; +byte *savebuffer, *save_p; int savestringsize = 256; // FS: Now a parameter int savegamesize = 0x100000; // FS: Now a parameter @@ -140,9 +140,9 @@ int art_flask; // FS: Custom artifact keys #define MAXPLMOVE 0x32 -fixed_t forwardmove[2] = {0x19, 0x32}; -fixed_t sidemove[2] = {0x18, 0x28}; -fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn +fixed_t forwardmove[2] = { 0x19, 0x32 }; +fixed_t sidemove[2] = { 0x18, 0x28 }; +fixed_t angleturn[3] = { 640, 1280, 320 }; // + slow turn #define SLOWTURNTICS 6 #define NUMKEYS 256 @@ -152,15 +152,15 @@ int lookheld; boolean mousearray[4]; -boolean *mousebuttons = &mousearray[1]; - // allow [-1] +boolean *mousebuttons = &mousearray[1]; +// allow [-1] int mousex, mousey; // mouse values are used once int dclicktime, dclickstate, dclicks; int dclicktime2, dclickstate2, dclicks2; int joyxmove, joyymove; // joystick values are repeated boolean joyarray[5]; -boolean *joybuttons = &joyarray[1]; // allow [-1] +boolean *joybuttons = &joyarray[1]; // allow [-1] int savegameslot; char savedescription[32]; @@ -214,34 +214,34 @@ void G_BuildTiccmd (ticcmd_t *cmd) #endif - memset (cmd,0,sizeof(*cmd)); + memset (cmd, 0, sizeof(*cmd)); //cmd->consistancy = // consistancy[consoleplayer][(maketic*ticdup)%BACKUPTICS]; cmd->consistancy = - consistancy[consoleplayer][maketic%BACKUPTICS]; + consistancy[consoleplayer][maketic % BACKUPTICS]; if (isCyberPresent) I_ReadCyberCmd (cmd); -//printf ("cons: %i\n",cmd->consistancy); + //printf ("cons: %i\n",cmd->consistancy); strafe = gamekeydown[key_strafe] || mousebuttons[mousebstrafe] || joybuttons[joybstrafe]; speed = alwaysrun || gamekeydown[key_speed] || joybuttons[joybspeed] || joybuttons[joybspeed]; #ifdef __WATCOMC__ - if(useexterndriver) + if (useexterndriver) { - speed |= (i_ExternData->buttons&EBT_SPEED); - strafe |= (i_ExternData->buttons&EBT_STRAFE); + speed |= (i_ExternData->buttons & EBT_SPEED); + strafe |= (i_ExternData->buttons & EBT_STRAFE); } #endif forward = side = look = arti = flyheight = 0; -// -// use two stage accelerative turning on the keyboard and joystick -// + // + // use two stage accelerative turning on the keyboard and joystick + // if (joyxmove < 0 || joyxmove > 0 - || gamekeydown[key_right] || gamekeydown[key_left]) + || gamekeydown[key_right] || gamekeydown[key_left]) turnheld += ticdup; else turnheld = 0; @@ -250,7 +250,7 @@ void G_BuildTiccmd (ticcmd_t *cmd) else tspeed = speed; - if(gamekeydown[key_lookdown] || gamekeydown[key_lookup]) + if (gamekeydown[key_lookdown] || gamekeydown[key_lookup]) { lookheld += ticdup; } @@ -258,7 +258,7 @@ void G_BuildTiccmd (ticcmd_t *cmd) { lookheld = 0; } - if(lookheld < SLOWTURNTICS) + if (lookheld < SLOWTURNTICS) { lspeed = 1; } @@ -267,10 +267,10 @@ void G_BuildTiccmd (ticcmd_t *cmd) lspeed = 2; } -// -// let movement keys cancel each other out -// - if(strafe) + // + // let movement keys cancel each other out + // + if (strafe) { if (gamekeydown[key_right]) side += sidemove[speed]; @@ -307,41 +307,41 @@ void G_BuildTiccmd (ticcmd_t *cmd) side -= sidemove[speed]; // Look up/down/center keys - if(gamekeydown[key_lookup]) + if (gamekeydown[key_lookup]) { look = lspeed; } - if(gamekeydown[key_lookdown]) + if (gamekeydown[key_lookdown]) { look = -lspeed; } #ifdef __WATCOMC__ - if(gamekeydown[key_lookcenter] && !useexterndriver) + if (gamekeydown[key_lookcenter] && !useexterndriver) { look = TOCENTER; } #else - if(gamekeydown[key_lookcenter]) + if (gamekeydown[key_lookcenter]) { look = TOCENTER; } #endif #ifdef __WATCOMC__ - if(useexterndriver && look != TOCENTER && (gamestate == GS_LEVEL || + if (useexterndriver && look != TOCENTER && (gamestate == GS_LEVEL || gamestate == GS_INTERMISSION)) { - if(i_ExternData->moveForward) + if (i_ExternData->moveForward) { forward += i_ExternData->moveForward; - if(speed) + if (speed) { forward <<= 1; } } - if(i_ExternData->angleTurn) + if (i_ExternData->angleTurn) { - if(strafe) + if (strafe) { side += i_ExternData->angleTurn; } @@ -350,39 +350,39 @@ void G_BuildTiccmd (ticcmd_t *cmd) cmd->angleturn += i_ExternData->angleTurn; } } - if(i_ExternData->moveSideways) + if (i_ExternData->moveSideways) { side += i_ExternData->moveSideways; - if(speed) + if (speed) { side <<= 1; } } - if(i_ExternData->buttons&EBT_CENTERVIEW) + if (i_ExternData->buttons & EBT_CENTERVIEW) { look = TOCENTER; oldAngle = 0; } - else if(i_ExternData->pitch) + else if (i_ExternData->pitch) { - angleDelta = i_ExternData->pitch-oldAngle; - if(abs(angleDelta) < 35) + angleDelta = i_ExternData->pitch - oldAngle; + if (abs(angleDelta) < 35) { - look = angleDelta/5; + look = angleDelta / 5; } else { - look = 7*(angleDelta > 0 ? 1 : -1); + look = 7 * (angleDelta > 0 ? 1 : -1); } - if(look == TOCENTER) + if (look == TOCENTER) { look++; } - oldAngle += look*5; + oldAngle += look * 5; } - if(i_ExternData->flyDirection) + if (i_ExternData->flyDirection) { - if(i_ExternData->flyDirection > 0) + if (i_ExternData->flyDirection > 0) { flyheight = 5; } @@ -391,79 +391,79 @@ void G_BuildTiccmd (ticcmd_t *cmd) flyheight = -5; } } - if(abs(newViewAngleOff-i_ExternData->angleHead) < 3000) + if (abs(newViewAngleOff - i_ExternData->angleHead) < 3000) { newViewAngleOff = i_ExternData->angleHead; } - if(i_ExternData->buttons&EBT_FIRE) + if (i_ExternData->buttons & EBT_FIRE) { cmd->buttons |= BT_ATTACK; } - if(i_ExternData->buttons&EBT_OPENDOOR) + if (i_ExternData->buttons & EBT_OPENDOOR) { cmd->buttons |= BT_USE; } - if(i_ExternData->buttons&EBT_PAUSE) + if (i_ExternData->buttons & EBT_PAUSE) { cmd->buttons = BT_SPECIAL | BTS_PAUSE; i_ExternData->buttons &= ~EBT_PAUSE; } - if(externInvKey&EBT_USEARTIFACT) + if (externInvKey & EBT_USEARTIFACT) { ev.type = ev_keyup; ev.data1 = key_useartifact; D_PostEvent(&ev); externInvKey &= ~EBT_USEARTIFACT; } - else if(i_ExternData->buttons&EBT_USEARTIFACT) + else if (i_ExternData->buttons & EBT_USEARTIFACT) { externInvKey |= EBT_USEARTIFACT; ev.type = ev_keydown; ev.data1 = key_useartifact; D_PostEvent(&ev); } - if(externInvKey&EBT_INVENTORYRIGHT) + if (externInvKey & EBT_INVENTORYRIGHT) { ev.type = ev_keyup; ev.data1 = key_invright; D_PostEvent(&ev); externInvKey &= ~EBT_INVENTORYRIGHT; } - else if(i_ExternData->buttons&EBT_INVENTORYRIGHT) + else if (i_ExternData->buttons & EBT_INVENTORYRIGHT) { externInvKey |= EBT_INVENTORYRIGHT; ev.type = ev_keydown; ev.data1 = key_invright; D_PostEvent(&ev); } - if(externInvKey&EBT_INVENTORYLEFT) + if (externInvKey & EBT_INVENTORYLEFT) { ev.type = ev_keyup; ev.data1 = key_invleft; D_PostEvent(&ev); externInvKey &= ~EBT_INVENTORYLEFT; } - else if(i_ExternData->buttons&EBT_INVENTORYLEFT) + else if (i_ExternData->buttons & EBT_INVENTORYLEFT) { externInvKey |= EBT_INVENTORYLEFT; ev.type = ev_keydown; ev.data1 = key_invleft; D_PostEvent(&ev); } - if(i_ExternData->buttons&EBT_FLYDROP) + if (i_ExternData->buttons & EBT_FLYDROP) { flyheight = TOCENTER; } - if(gamestate == GS_LEVEL) + if (gamestate == GS_LEVEL) { - if(externInvKey&EBT_MAP) + if (externInvKey & EBT_MAP) { // AutoMap ev.type = ev_keyup; ev.data1 = AM_STARTKEY; D_PostEvent(&ev); externInvKey &= ~EBT_MAP; } - else if(i_ExternData->buttons&EBT_MAP) + else if (i_ExternData->buttons & EBT_MAP) { externInvKey |= EBT_MAP; ev.type = ev_keydown; @@ -472,25 +472,25 @@ void G_BuildTiccmd (ticcmd_t *cmd) } } #if 0 - if((i = (i_ExternData->buttons>>EBT_WEAPONSHIFT)&EBT_WEAPONMASK) != 0) + if ((i = (i_ExternData->buttons >> EBT_WEAPONSHIFT) & EBT_WEAPONMASK) != 0) { cmd->buttons |= BT_CHANGE; - cmd->buttons |= (i-1)<buttons |= (i - 1) << BT_WEAPONSHIFT; } #endif - if(i_ExternData->buttons&EBT_WEAPONCYCLE) + if (i_ExternData->buttons & EBT_WEAPONCYCLE) { int curWeapon; player_t *pl; pl = &players[consoleplayer]; curWeapon = pl->readyweapon; - for(curWeapon = (curWeapon+1)&7; curWeapon != pl->readyweapon; - curWeapon = (curWeapon+1)&7) + for (curWeapon = (curWeapon + 1) & 7; curWeapon != pl->readyweapon; + curWeapon = (curWeapon + 1) & 7) { - if(pl->weaponowned[curWeapon]) + if (pl->weaponowned[curWeapon]) { - if(curWeapon >= wp_goldwand && curWeapon <= wp_mace && + if (curWeapon >= wp_goldwand && curWeapon <= wp_mace && !pl->ammo[wpnlev1info[curWeapon].ammo]) { // weapon that requires ammo is empty continue; @@ -499,25 +499,25 @@ void G_BuildTiccmd (ticcmd_t *cmd) } } cmd->buttons |= BT_CHANGE; - cmd->buttons |= curWeapon<buttons |= curWeapon << BT_WEAPONSHIFT; } } #endif // Fly up/down/drop keys - if(gamekeydown[key_flyup]) + if (gamekeydown[key_flyup]) { flyheight = 5; // note that the actual flyheight will be twice this } - if(gamekeydown[key_flydown]) + if (gamekeydown[key_flydown]) { flyheight = -5; } - if(gamekeydown[key_flycenter]) + if (gamekeydown[key_flycenter]) { flyheight = TOCENTER; #ifdef __WATCOMC__ - if(!useexterndriver) + if (!useexterndriver) { look = TOCENTER; } @@ -527,11 +527,11 @@ void G_BuildTiccmd (ticcmd_t *cmd) } // Use artifact key - if(gamekeydown[key_useartifact]) + if (gamekeydown[key_useartifact]) { - if(gamekeydown[key_speed] && !noartiskip) + if (gamekeydown[key_speed] && !noartiskip) { - if(players[consoleplayer].inventory[inv_ptr].type != arti_none) + if (players[consoleplayer].inventory[inv_ptr].type != arti_none) { gamekeydown[key_useartifact] = false; cmd->arti = 0xff; // skip artifact code @@ -539,7 +539,7 @@ void G_BuildTiccmd (ticcmd_t *cmd) } else { - if(inventory) + if (inventory) { players[consoleplayer].readyArtifact = players[consoleplayer].inventory[inv_ptr].type; @@ -547,14 +547,14 @@ void G_BuildTiccmd (ticcmd_t *cmd) cmd->arti = 0; usearti = false; } - else if(usearti) + else if (usearti) { cmd->arti = players[consoleplayer].inventory[inv_ptr].type; usearti = false; } } } - if(gamekeydown[127] && !cmd->arti + if (gamekeydown[127] && !cmd->arti && !players[consoleplayer].powers[pw_weaponlevel2]) { gamekeydown[127] = false; @@ -562,86 +562,86 @@ void G_BuildTiccmd (ticcmd_t *cmd) } -// -// buttons -// + // + // buttons + // cmd->chatchar = CT_dequeueChatChar(); if (gamekeydown[key_fire] || mousebuttons[mousebfire] || joybuttons[joybfire]) cmd->buttons |= BT_ATTACK; - if (gamekeydown[key_use] || joybuttons[joybuse] ) + if (gamekeydown[key_use] || joybuttons[joybuse]) { cmd->buttons |= BT_USE; dclicks = 0; // clear double clicks if hit use button } - if(use_wpnbinds) /* FS: Custom weapon keys */ + if (use_wpnbinds) /* FS: Custom weapon keys */ { - if(gamekeydown[wpn_crossbow]) + if (gamekeydown[wpn_crossbow]) { cmd->buttons |= BT_CHANGE; - cmd->buttons |= 2<buttons |= 2 << BT_WEAPONSHIFT; } - if(gamekeydown[wpn_dragon]) + if (gamekeydown[wpn_dragon]) { cmd->buttons |= BT_CHANGE; - cmd->buttons |= 3<buttons |= 3 << BT_WEAPONSHIFT; } - if(gamekeydown[wpn_hellstaff]) + if (gamekeydown[wpn_hellstaff]) { cmd->buttons |= BT_CHANGE; - cmd->buttons |= 4<buttons |= 4 << BT_WEAPONSHIFT; } - if(gamekeydown[wpn_phoenix]) + if (gamekeydown[wpn_phoenix]) { cmd->buttons |= BT_CHANGE; - cmd->buttons |= 5<buttons |= 5 << BT_WEAPONSHIFT; } } - if(use_artbinds) /* FS: Custom artifact keys */ + if (use_artbinds) /* FS: Custom artifact keys */ { - if(gamekeydown[art_torch]) + if (gamekeydown[art_torch]) { gamekeydown[art_torch] = false; - if(players[consoleplayer].powers[pw_infrared]) + if (players[consoleplayer].powers[pw_infrared]) { players[consoleplayer].powers[pw_infrared] = 0; } else - P_GivePower(&players[consoleplayer],pw_infrared); + P_GivePower(&players[consoleplayer], pw_infrared); } - if(gamekeydown[art_flask]) + if (gamekeydown[art_flask]) { gamekeydown[art_flask] = false; cmd->arti = arti_health; } } - for(i = 0; i < NUMWEAPONS-2; i++) + for (i = 0; i < NUMWEAPONS - 2; i++) { - if(gamekeydown['1'+i]) + if (gamekeydown['1' + i]) { cmd->buttons |= BT_CHANGE; - cmd->buttons |= i<buttons |= i << BT_WEAPONSHIFT; break; } } -// -// mouse -// + // + // mouse + // if (mousebuttons[mousebforward]) { forward += forwardmove[speed]; } -// -// forward double click -// - if (mousebuttons[mousebforward] != dclickstate && dclicktime > 1 ) + // + // forward double click + // + if (mousebuttons[mousebforward] != dclickstate && dclicktime > 1) { dclickstate = mousebuttons[mousebforward]; if (dclickstate) @@ -664,12 +664,12 @@ void G_BuildTiccmd (ticcmd_t *cmd) } } -// -// strafe double click -// + // + // strafe double click + // bstrafe = mousebuttons[mousebstrafe] -|| joybuttons[joybstrafe]; - if (bstrafe != dclickstate2 && dclicktime2 > 1 ) + || joybuttons[joybstrafe]; + if (bstrafe != dclickstate2 && dclicktime2 > 1) { dclickstate2 = bstrafe; if (dclickstate2) @@ -694,11 +694,11 @@ void G_BuildTiccmd (ticcmd_t *cmd) if (strafe) { - side += mousex*2; + side += mousex * 2; } else { - cmd->angleturn -= mousex*0x8; + cmd->angleturn -= mousex * 0x8; } forward += mousey; mousex = mousey = 0; @@ -714,23 +714,23 @@ void G_BuildTiccmd (ticcmd_t *cmd) cmd->forwardmove += forward; cmd->sidemove += side; - if(players[consoleplayer].playerstate == PST_LIVE) + if (players[consoleplayer].playerstate == PST_LIVE) { - if(look < 0) + if (look < 0) { look += 16; } cmd->lookfly = look; } - if(flyheight < 0) + if (flyheight < 0) { flyheight += 16; } - cmd->lookfly |= flyheight<<4; + cmd->lookfly |= flyheight << 4; -// -// special buttons -// + // + // special buttons + // if (sendpause) { sendpause = false; @@ -740,7 +740,7 @@ void G_BuildTiccmd (ticcmd_t *cmd) if (sendsave) { sendsave = false; - cmd->buttons = BT_SPECIAL | BTS_SAVEGAME | (savegameslot<buttons = BT_SPECIAL | BTS_SAVEGAME | (savegameslot << BTS_SAVESHIFT); } } @@ -760,11 +760,11 @@ void G_DoLoadLevel (void) levelstarttic = gametic; // for time calculation gamestate = GS_LEVEL; - for (i=0 ; itype == ev_keyup && ev->data1 == key_useartifact) + if (ev->type == ev_keyup && ev->data1 == key_useartifact) { // flag to denote that it's okay to use an artifact - if(!inventory) + if (!inventory) { plr->readyArtifact = plr->inventory[inv_ptr].type; } @@ -814,121 +814,121 @@ boolean G_Responder(event_t *ev) } // Check for spy mode player cycle - if(gamestate == GS_LEVEL && ev->type == ev_keydown + if (gamestate == GS_LEVEL && ev->type == ev_keydown && ev->data1 == KEY_F12 && !deathmatch) { // Cycle the display player do { displayplayer++; - if(displayplayer == MAXPLAYERS) + if (displayplayer == MAXPLAYERS) { displayplayer = 0; } - } while(!playeringame[displayplayer] + } while (!playeringame[displayplayer] && displayplayer != consoleplayer); return(true); } - if(gamestate == GS_LEVEL) + if (gamestate == GS_LEVEL) { - if(CT_Responder(ev)) + if (CT_Responder(ev)) { // Chat ate the event return(true); } - if(SB_Responder(ev)) + if (SB_Responder(ev)) { // Status bar ate the event return(true); } - if(AM_Responder(ev)) + if (AM_Responder(ev)) { // Automap ate the event return(true); } } - switch(ev->type) + switch (ev->type) { case ev_keydown: - if(ev->data1 == key_invleft) + if (ev->data1 == key_invleft) { - inventoryTics = 5*35; - if(!inventory) + inventoryTics = 5 * 35; + if (!inventory) { inventory = true; break; } inv_ptr--; - if(inv_ptr < 0) + if (inv_ptr < 0) { inv_ptr = 0; } else { curpos--; - if(curpos < 0) + if (curpos < 0) { curpos = 0; } } return(true); } - if(ev->data1 == key_invright) + if (ev->data1 == key_invright) { - inventoryTics = 5*35; - if(!inventory) + inventoryTics = 5 * 35; + if (!inventory) { inventory = true; break; } inv_ptr++; - if(inv_ptr >= plr->inventorySlotNum) + if (inv_ptr >= plr->inventorySlotNum) { inv_ptr--; - if(inv_ptr < 0) + if (inv_ptr < 0) inv_ptr = 0; } else { curpos++; - if(curpos > 6) + if (curpos > 6) { curpos = 6; } } return(true); } - if(ev->data1 == KEY_PAUSE && !MenuActive) + if (ev->data1 == KEY_PAUSE && !MenuActive) { sendpause = true; return(true); } - if(ev->data1 < NUMKEYS) + if (ev->data1 < NUMKEYS) { gamekeydown[ev->data1] = true; } return(true); // eat key down events case ev_keyup: - if(ev->data1 < NUMKEYS) + if (ev->data1 < NUMKEYS) { gamekeydown[ev->data1] = false; } return(false); // always let key up events filter down case ev_mouse: - mousebuttons[0] = ev->data1&1; - mousebuttons[1] = ev->data1&2; - mousebuttons[2] = ev->data1&4; - mousex = ev->data2*(mouseSensitivity+5)/10; + mousebuttons[0] = ev->data1 & 1; + mousebuttons[1] = ev->data1 & 2; + mousebuttons[2] = ev->data1 & 4; + mousex = ev->data2 * (mouseSensitivity + 5) / 10; if (!novert) // FS: Disable vertical movement { if (mouseSensitivity < 20) // FS: Cap because it gets wonky { - mousey = ev->data3*(mouseSensitivity+5)/10; + mousey = ev->data3 * (mouseSensitivity + 5) / 10; } else { - mousey = ev->data3*(25)/10; + mousey = ev->data3 * (25) / 10; } return(true); // eat events } @@ -939,10 +939,10 @@ boolean G_Responder(event_t *ev) } case ev_joystick: - joybuttons[0] = ev->data1&1; - joybuttons[1] = ev->data1&2; - joybuttons[2] = ev->data1&4; - joybuttons[3] = ev->data1&8; + joybuttons[0] = ev->data1 & 1; + joybuttons[1] = ev->data1 & 2; + joybuttons[2] = ev->data1 & 4; + joybuttons[3] = ev->data1 & 8; joyxmove = ev->data2; joyymove = ev->data3; return(true); // eat events @@ -964,63 +964,63 @@ boolean G_Responder(event_t *ev) void G_Ticker (void) { int i, buf; - ticcmd_t *cmd; + ticcmd_t *cmd; -// -// do player reborns if needed -// - for (i=0 ; i BACKUPTICS && consistancy[i][buf] != cmd->consistancy) { I_Error ("consistency failure (%i should be %i)", - cmd->consistancy, consistancy[i][buf]); + cmd->consistancy, consistancy[i][buf]); } if (players[i].mo) consistancy[i][buf] = players[i].mo->x; @@ -1048,61 +1048,61 @@ void G_Ticker (void) } } } -// -// check for special buttons -// - for (i=0 ; i>BTS_SAVESHIFT; - gameaction = ga_savegame; - break; + break; + + case BTS_SAVEGAME: + if (!savedescription[0]) + { + if (netgame) + { + strcpy (savedescription, "NET GAME"); + } + else + { + strcpy(savedescription, "SAVE GAME"); + } + } + savegameslot = + (players[i].cmd.buttons & BTS_SAVEMASK) >> BTS_SAVESHIFT; + gameaction = ga_savegame; + break; } } } // turn inventory off after a certain amount of time - if(inventory && !(--inventoryTics)) + if (inventory && !(--inventoryTics)) { players[consoleplayer].readyArtifact = players[consoleplayer].inventory[inv_ptr].type; inventory = false; cmd->arti = 0; } -// -// do main actions -// -// -// do main actions -// + // + // do main actions + // + // + // do main actions + // switch (gamestate) { case GS_LEVEL: @@ -1145,12 +1145,12 @@ also see P_SpawnPlayer in P_Things void G_InitPlayer (int player) { - player_t *p; + player_t *p; -// set up the saved info + // set up the saved info p = &players[player]; -// clear everything else to defaults + // clear everything else to defaults G_PlayerReborn (player); } @@ -1177,18 +1177,18 @@ void G_PlayerFinishLevel(int player) p = &players[player]; - if(M_CheckParm("-oldrules")) // FS: Old Rules + if (M_CheckParm("-oldrules")) // FS: Old Rules { - for(i=0; iinventorySlotNum; i++) + for (i = 0; i < p->inventorySlotNum; i++) { p->inventory[i].count = 1; } p->artifactCount = p->inventorySlotNum; - if(!deathmatch) + if (!deathmatch) { - for(i = 0; i < 16; i++) + for (i = 0; i < 16; i++) { P_PlayerUseArtifact(p, arti_fly); } @@ -1198,7 +1198,7 @@ void G_PlayerFinishLevel(int player) memset(p->powers, 0, sizeof(p->powers)); memset(p->keys, 0, sizeof(p->keys)); playerkeys = 0; - if(p->chickenTics) + if (p->chickenTics) { p->readyweapon = p->mo->special1; // Restore weapon p->chickenTics = 0; @@ -1212,7 +1212,7 @@ void G_PlayerFinishLevel(int player) p->bonuscount = 0; p->rain1 = NULL; p->rain2 = NULL; - if(p == &players[consoleplayer]) + if (p == &players[consoleplayer]) { SB_state = -1; // refresh the status bar } @@ -1242,12 +1242,12 @@ void G_PlayerReborn(int player) ultimatemsg = false; // FS: Clear it out coop = false; // FS: Clear it out - coopbackpack = false; // FS: Clear it out - coopkeys[3-1] = false; // FS: Clear it out - secret = false; + coopbackpack = false; // FS: Clear it out + coopkeys[3 - 1] = false; // FS: Clear it out + secret = false; memcpy(frags, players[player].frags, sizeof(frags)); - if(netgame && !deathmatch && !M_CheckParm("-oldrules")) // FS: Check for Coop + if (netgame && !deathmatch && !M_CheckParm("-oldrules")) // FS: Check for Coop { coop = true; memcpy(coopkeys, players[player].keys, sizeof(players[player].keys)); // FS: Keep keys in Coop @@ -1263,12 +1263,12 @@ void G_PlayerReborn(int player) p = &players[player]; - if(p->didsecret) + if (p->didsecret) { secret = true; } - if(!coop) // FS: Check for Coop + if (!coop) // FS: Check for Coop { memset(p, 0, sizeof(*p)); } @@ -1279,7 +1279,7 @@ void G_PlayerReborn(int player) { memcpy(players[player].keys, coopkeys, sizeof(players[player].keys)); // FS: Keep keys in Coop } - + players[player].killcount = killcount; players[player].itemcount = itemcount; players[player].secretcount = secretcount; @@ -1305,31 +1305,31 @@ void G_PlayerReborn(int player) { p->ammo[am_crossbow] = 15; } - if (p->ammo[am_goldwand] < 50) + if (p->ammo[am_goldwand] < 50) { p->ammo[am_goldwand] = 50; } } - for(i = 0; i < NUMAMMO; i++) + for (i = 0; i < NUMAMMO; i++) { p->maxammo[i] = maxammo[i]; } - if(gamemap == 9 || secret) + if (gamemap == 9 || secret) { p->didsecret = true; } if (coop && coopbackpack) // FS: Give the user their backpack if they had it { - for(i = 0; i < NUMAMMO; i++) + for (i = 0; i < NUMAMMO; i++) { p->maxammo[i] *= 2; } p->backpack = true; } - if(p == &players[consoleplayer]) + if (p == &players[consoleplayer]) { SB_state = -1; // refresh the status bar inv_ptr = 0; // reset the inventory pointer @@ -1352,29 +1352,29 @@ void P_SpawnPlayer (mapthing_t *mthing); boolean G_CheckSpot (int playernum, mapthing_t *mthing) { - fixed_t x,y; + fixed_t x, y; subsector_t *ss; unsigned an; - mobj_t *mo; + mobj_t *mo; x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; players[playernum].mo->flags2 &= ~MF2_PASSMOBJ; - if (!P_CheckPosition (players[playernum].mo, x, y) ) + if (!P_CheckPosition (players[playernum].mo, x, y)) { players[playernum].mo->flags2 |= MF2_PASSMOBJ; return false; } players[playernum].mo->flags2 |= MF2_PASSMOBJ; -// spawn a teleport fog - ss = R_PointInSubsector (x,y); - an = ( ANG45 * (mthing->angle/45) ) >> ANGLETOFINESHIFT; + // spawn a teleport fog + 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+TELEFOGHEIGHT -, MT_TFOG); + mo = P_SpawnMobj (x + 20 * finecosine[an], y + 20 * finesine[an] + , ss->sector->floorheight + TELEFOGHEIGHT + , MT_TFOG); if (players[consoleplayer].viewz != 1) S_StartSound (mo, sfx_telept); // don't start sound on first frame @@ -1394,25 +1394,25 @@ boolean G_CheckSpot (int playernum, mapthing_t *mthing) void G_DeathMatchSpawnPlayer (int playernum) { - int i,j; + 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++) + for (j = 0; j < 20; j++) { i = P_Random() % selections; - if (G_CheckSpot (playernum, &deathmatchstarts[i]) ) + if (G_CheckSpot (playernum, &deathmatchstarts[i])) { - deathmatchstarts[i].type = playernum+1; + deathmatchstarts[i].type = playernum + 1; P_SpawnPlayer (&deathmatchstarts[i]); return; } } -// no good spot, so the player will probably get stuck + // no good spot, so the player will probably get stuck P_SpawnPlayer (&playerstarts[playernum]); } @@ -1443,18 +1443,18 @@ void G_DoReborn (int playernum) return; } - if (G_CheckSpot (playernum, &playerstarts[playernum]) ) + if (G_CheckSpot (playernum, &playerstarts[playernum])) { P_SpawnPlayer (&playerstarts[playernum]); return; } // try to spawn at one of the other players spots - for (i=0 ; i sk_nightmare) + if (skill > sk_nightmare) skill = sk_nightmare; - if(episode < 1) + if (episode < 1) episode = 1; // Up to 9 episodes for testing - if(episode > 9) + if (episode > 9) episode = 9; - if(map < 1) + if (map < 1) map = 1; - if(map > 9) + if (map > 9) map = 9; M_ClearRandom(); - if(respawnparm) + if (respawnparm) { respawnmonsters = true; } @@ -1747,13 +1747,13 @@ void G_InitNew(skill_t skill, int episode, int map) } // Set monster missile speeds speed = skill == sk_nightmare; - for(i = 0; MonsterMissileInfo[i].type != -1; i++) + for (i = 0; MonsterMissileInfo[i].type != -1; i++) { mobjinfo[MonsterMissileInfo[i].type].speed - = MonsterMissileInfo[i].speed[speed]< 5) + if (episode > 5) { skytexture = R_TextureNumForName(DEH_String("SKY1")); } else { - skytexture = R_TextureNumForName(DEH_String(skyLumpNames[episode-1])); + skytexture = R_TextureNumForName(DEH_String(skyLumpNames[episode - 1])); } G_DoLoadLevel(); @@ -1802,7 +1802,7 @@ void G_ReadDemoTiccmd (ticcmd_t *cmd) } cmd->forwardmove = ((signed char)*demo_p++); cmd->sidemove = ((signed char)*demo_p++); - cmd->angleturn = ((unsigned char)*demo_p++)<<8; + cmd->angleturn = ((unsigned char)*demo_p++) << 8; cmd->buttons = (unsigned char)*demo_p++; cmd->lookfly = (unsigned char)*demo_p++; cmd->arti = (unsigned char)*demo_p++; @@ -1814,7 +1814,7 @@ void G_WriteDemoTiccmd (ticcmd_t *cmd) G_CheckDemoStatus (); *demo_p++ = cmd->forwardmove; *demo_p++ = cmd->sidemove; - *demo_p++ = cmd->angleturn>>8; + *demo_p++ = cmd->angleturn >> 8; *demo_p++ = cmd->buttons; *demo_p++ = cmd->lookfly; *demo_p++ = cmd->arti; @@ -1840,12 +1840,12 @@ void G_RecordDemo (skill_t skill, int numplayers, int episode, int map, char *na usergame = false; strcpy (demoname, name); strcat (demoname, ".lmp"); - demobuffer = demo_p = Z_Malloc (0x20000,PU_STATIC,NULL); + demobuffer = demo_p = Z_Malloc (0x20000, PU_STATIC, NULL); *demo_p++ = skill; *demo_p++ = episode; *demo_p++ = map; - for (i=0 ; i>16); - SV_WriteByte(leveltime>>8); + SV_WriteByte(leveltime >> 16); + SV_WriteByte(leveltime >> 8); SV_WriteByte(leveltime); P_ArchivePlayers(); P_ArchiveWorld(); @@ -2023,13 +2023,13 @@ void G_DoSaveGame(void) P_ArchiveSpecials(); SV_Close(name); - if(convertsave) // FS: Convert Save + if (convertsave) // FS: Convert Save G_LoadGame(name); gameaction = ga_nothing; savedescription[0] = 0; - if(convertsave) // FS: Convert old saves + if (convertsave) // FS: Convert old saves { P_SetMessage(&players[consoleplayer], "SAVE CONVERTED!", true); convertsave = false; @@ -2049,7 +2049,7 @@ void SV_Open(char *fileName) MallocFailureOk = true; save_p = savebuffer = Z_Malloc(savegamesize, PU_STATIC, NULL); MallocFailureOk = false; - if(savebuffer == NULL) + if (savebuffer == NULL) { // Not enough memory - use file save method SaveGameType = SVG_FILE; SaveGameFP = fopen(fileName, "wb"); @@ -2071,10 +2071,10 @@ void SV_Close(char *fileName) int length; SV_WriteByte(SAVE_GAME_TERMINATOR); - if(SaveGameType == SVG_RAM) + if (SaveGameType == SVG_RAM) { - length = save_p-savebuffer; - if(length > savegamesize) + length = save_p - savebuffer; + if (length > savegamesize) { I_Error("Savegame buffer overrun"); } @@ -2095,7 +2095,7 @@ void SV_Close(char *fileName) void SV_Write(void *buffer, int size) { - if(SaveGameType == SVG_RAM) + if (SaveGameType == SVG_RAM) { memcpy(save_p, buffer, size); save_p += size; diff --git a/INFO.C b/INFO.C index 759a42c..c124cfd 100644 --- a/INFO.C +++ b/INFO.C @@ -1372,8 +1372,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -1399,8 +1399,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -1426,8 +1426,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -1453,12 +1453,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1480,12 +1480,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1507,12 +1507,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_SHADOW|MF_COUNTITEM, // flags +MF_SPECIAL | MF_SHADOW | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1534,12 +1534,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1561,12 +1561,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1588,12 +1588,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1615,12 +1615,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1642,12 +1642,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1668,13 +1668,13 @@ S_NULL, // crashstate S_EGGFXI1_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -18*FRACUNIT, // speed -8*FRACUNIT, // radius -8*FRACUNIT, // height +18 * FRACUNIT, // speed +8 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 1, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -1696,12 +1696,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1723,12 +1723,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1750,12 +1750,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1777,12 +1777,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_phohit, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOGRAVITY|MF_SHADOW, // flags +MF_NOGRAVITY | MF_SHADOW, // flags 0 // flags2 }, @@ -1804,12 +1804,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_COUNTITEM, // flags +MF_SPECIAL | MF_COUNTITEM, // flags MF2_FLOATBOB // flags2 }, @@ -1831,13 +1831,13 @@ S_POD_DIE1, // deathstate S_NULL, // xdeathstate sfx_podexp, // deathsound 0, // speed -16*FRACUNIT, // radius -54*FRACUNIT, // height +16 * FRACUNIT, // radius +54 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SOLID|MF_NOBLOOD|MF_SHOOTABLE|MF_DROPOFF, // flags -MF2_WINDTHRUST|MF2_PUSHABLE|MF2_SLIDE|MF2_PASSMOBJ|MF2_TELESTOMP // flags2 +MF_SOLID | MF_NOBLOOD | MF_SHOOTABLE | MF_DROPOFF, // flags +MF2_WINDTHRUST | MF2_PUSHABLE | MF2_SLIDE | MF2_PASSMOBJ | MF2_TELESTOMP // flags2 }, { // MT_PODGOO @@ -1858,13 +1858,13 @@ S_PODGOOX, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -2*FRACUNIT, // radius -4*FRACUNIT, // height +2 * FRACUNIT, // radius +4 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF, // flags -MF2_NOTELEPORT|MF2_LOGRAV|MF2_CANNOTPUSH // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF, // flags +MF2_NOTELEPORT | MF2_LOGRAV | MF2_CANNOTPUSH // flags2 }, { // MT_PODGENERATOR @@ -1885,12 +1885,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOSECTOR, // flags +MF_NOBLOCKMAP | MF_NOSECTOR, // flags 0 // flags2 }, @@ -1912,13 +1912,13 @@ S_SPLASHX, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -2*FRACUNIT, // radius -4*FRACUNIT, // height +2 * FRACUNIT, // radius +4 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF, // flags -MF2_NOTELEPORT|MF2_LOGRAV|MF2_CANNOTPUSH // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF, // flags +MF2_NOTELEPORT | MF2_LOGRAV | MF2_CANNOTPUSH // flags2 }, { // MT_SPLASHBASE @@ -1939,8 +1939,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -1966,8 +1966,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -1993,12 +1993,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SHADOW, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_SHADOW, // flags 0 // flags2 }, @@ -2020,13 +2020,13 @@ S_SLUDGECHUNKX, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -2*FRACUNIT, // radius -4*FRACUNIT, // height +2 * FRACUNIT, // radius +4 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF, // flags -MF2_NOTELEPORT|MF2_LOGRAV|MF2_CANNOTPUSH // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF, // flags +MF2_NOTELEPORT | MF2_LOGRAV | MF2_CANNOTPUSH // flags2 }, { // MT_SLUDGESPLASH @@ -2047,8 +2047,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2074,12 +2074,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -70*FRACUNIT, // height +20 * FRACUNIT, // radius +70 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPAWNCEILING|MF_NOGRAVITY, // flags +MF_SPAWNCEILING | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2101,12 +2101,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -60*FRACUNIT, // height +20 * FRACUNIT, // radius +60 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPAWNCEILING|MF_NOGRAVITY, // flags +MF_SPAWNCEILING | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2128,12 +2128,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -45*FRACUNIT, // height +20 * FRACUNIT, // radius +45 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPAWNCEILING|MF_NOGRAVITY, // flags +MF_SPAWNCEILING | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2155,12 +2155,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -35*FRACUNIT, // height +20 * FRACUNIT, // radius +35 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPAWNCEILING|MF_NOGRAVITY, // flags +MF_SPAWNCEILING | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2182,12 +2182,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -60*FRACUNIT, // height +20 * FRACUNIT, // radius +60 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPAWNCEILING|MF_NOGRAVITY, // flags +MF_SPAWNCEILING | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2209,8 +2209,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -12*FRACUNIT, // radius -54*FRACUNIT, // height +12 * FRACUNIT, // radius +54 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2236,8 +2236,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -16*FRACUNIT, // radius -34*FRACUNIT, // height +16 * FRACUNIT, // radius +34 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2263,8 +2263,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -8*FRACUNIT, // radius -32*FRACUNIT, // height +8 * FRACUNIT, // radius +32 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2290,8 +2290,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -12*FRACUNIT, // radius -64*FRACUNIT, // height +12 * FRACUNIT, // radius +64 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2317,12 +2317,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -8*FRACUNIT, // radius -36*FRACUNIT, // height +8 * FRACUNIT, // radius +36 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, // flags +MF_SOLID | MF_SPAWNCEILING | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2344,12 +2344,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -12*FRACUNIT, // radius -68*FRACUNIT, // height +12 * FRACUNIT, // radius +68 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, // flags +MF_SOLID | MF_SPAWNCEILING | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2371,8 +2371,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -16*FRACUNIT, // radius -44*FRACUNIT, // height +16 * FRACUNIT, // radius +44 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2398,8 +2398,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -12*FRACUNIT, // radius -32*FRACUNIT, // height +12 * FRACUNIT, // radius +32 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2425,8 +2425,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -14*FRACUNIT, // radius -128*FRACUNIT, // height +14 * FRACUNIT, // radius +128 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2452,12 +2452,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -23*FRACUNIT, // height +20 * FRACUNIT, // radius +23 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPAWNCEILING|MF_NOGRAVITY, // flags +MF_SPAWNCEILING | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2479,12 +2479,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -27*FRACUNIT, // height +20 * FRACUNIT, // radius +27 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPAWNCEILING|MF_NOGRAVITY, // flags +MF_SPAWNCEILING | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2506,8 +2506,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2533,12 +2533,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -8*FRACUNIT, // radius -104*FRACUNIT, // height +8 * FRACUNIT, // radius +104 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SOLID|MF_SPAWNCEILING|MF_NOGRAVITY, // flags +MF_SOLID | MF_SPAWNCEILING | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2560,8 +2560,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -16*FRACUNIT, // radius -50*FRACUNIT, // height +16 * FRACUNIT, // radius +50 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2587,8 +2587,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -16*FRACUNIT, // radius -50*FRACUNIT, // height +16 * FRACUNIT, // radius +50 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2614,8 +2614,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -16*FRACUNIT, // radius -50*FRACUNIT, // height +16 * FRACUNIT, // radius +50 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2641,12 +2641,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -16*FRACUNIT, // radius -16*FRACUNIT, // height +16 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SOLID|MF_NOGRAVITY, // flags +MF_SOLID | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2668,8 +2668,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -12*FRACUNIT, // radius -20*FRACUNIT, // height +12 * FRACUNIT, // radius +20 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -2694,14 +2694,14 @@ S_NULL, // crashstate S_VOLCANOBALLX1, // deathstate S_NULL, // xdeathstate sfx_volhit, // deathsound -2*FRACUNIT, // speed -8*FRACUNIT, // radius -8*FRACUNIT, // height +2 * FRACUNIT, // speed +8 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 2, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF, // flags -MF2_LOGRAV|MF2_NOTELEPORT|MF2_FIREDAMAGE // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF, // flags +MF2_LOGRAV | MF2_NOTELEPORT | MF2_FIREDAMAGE // flags2 }, { // MT_VOLCANOTBLAST @@ -2721,14 +2721,14 @@ S_NULL, // crashstate S_VOLCANOTBALLX1, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound -2*FRACUNIT, // speed -8*FRACUNIT, // radius -6*FRACUNIT, // height +2 * FRACUNIT, // speed +8 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 1, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF, // flags -MF2_LOGRAV|MF2_NOTELEPORT|MF2_FIREDAMAGE // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF, // flags +MF2_LOGRAV | MF2_NOTELEPORT | MF2_FIREDAMAGE // flags2 }, { // MT_TELEGLITGEN @@ -2749,12 +2749,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOSECTOR, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_NOSECTOR, // flags 0 // flags2 }, @@ -2776,12 +2776,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_NOSECTOR, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_NOSECTOR, // flags 0 // flags2 }, @@ -2803,12 +2803,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_MISSILE, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_MISSILE, // flags 0 // flags2 }, @@ -2830,12 +2830,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_MISSILE, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_MISSILE, // flags 0 // flags2 }, @@ -2857,12 +2857,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2884,12 +2884,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOSECTOR, // flags +MF_NOBLOCKMAP | MF_NOSECTOR, // flags 0 // flags2 }, @@ -2911,12 +2911,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2938,12 +2938,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2965,12 +2965,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -2992,8 +2992,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -3019,12 +3019,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SHADOW, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_SHADOW, // flags 0 // flags2 }, @@ -3046,12 +3046,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SHADOW, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_SHADOW, // flags 0 // flags2 }, @@ -3073,8 +3073,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -3099,13 +3099,13 @@ S_NULL, // crashstate S_BLASTERFXI1_1, // deathstate S_NULL, // xdeathstate sfx_blshit, // deathsound -184*FRACUNIT, // speed -12*FRACUNIT, // radius -8*FRACUNIT, // height +184 * FRACUNIT, // speed +12 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 2, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -3127,13 +3127,13 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SHADOW, // flags -MF2_NOTELEPORT|MF2_CANNOTPUSH // flags2 +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_SHADOW, // flags +MF2_NOTELEPORT | MF2_CANNOTPUSH // flags2 }, { // MT_RIPPER @@ -3153,14 +3153,14 @@ S_NULL, // crashstate S_RIPPERX1, // deathstate S_NULL, // xdeathstate sfx_hrnhit, // deathsound -14*FRACUNIT, // speed -8*FRACUNIT, // radius -6*FRACUNIT, // height +14 * FRACUNIT, // speed +8 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 1, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_NOTELEPORT|MF2_RIP // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_NOTELEPORT | MF2_RIP // flags2 }, { // MT_BLASTERPUFF1 @@ -3181,12 +3181,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -3208,12 +3208,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -3235,8 +3235,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -3261,14 +3261,14 @@ S_NULL, // crashstate S_MACEFXI1_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -20*FRACUNIT, // speed -8*FRACUNIT, // radius -6*FRACUNIT, // height +20 * FRACUNIT, // speed +8 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 2, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_FLOORBOUNCE|MF2_THRUGHOST|MF2_NOTELEPORT // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_FLOORBOUNCE | MF2_THRUGHOST | MF2_NOTELEPORT // flags2 }, { // MT_MACEFX2 @@ -3288,14 +3288,14 @@ S_NULL, // crashstate S_MACEFXI2_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -10*FRACUNIT, // speed -8*FRACUNIT, // radius -6*FRACUNIT, // height +10 * FRACUNIT, // speed +8 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 6, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF, // flags -MF2_LOGRAV|MF2_FLOORBOUNCE|MF2_THRUGHOST|MF2_NOTELEPORT // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF, // flags +MF2_LOGRAV | MF2_FLOORBOUNCE | MF2_THRUGHOST | MF2_NOTELEPORT // flags2 }, { // MT_MACEFX3 @@ -3315,14 +3315,14 @@ S_NULL, // crashstate S_MACEFXI1_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -7*FRACUNIT, // speed -8*FRACUNIT, // radius -6*FRACUNIT, // height +7 * FRACUNIT, // speed +8 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 4, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF, // flags -MF2_LOGRAV|MF2_FLOORBOUNCE|MF2_THRUGHOST|MF2_NOTELEPORT // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF, // flags +MF2_LOGRAV | MF2_FLOORBOUNCE | MF2_THRUGHOST | MF2_NOTELEPORT // flags2 }, { // MT_MACEFX4 @@ -3342,14 +3342,14 @@ S_NULL, // crashstate S_MACEFXI4_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -7*FRACUNIT, // speed -8*FRACUNIT, // radius -6*FRACUNIT, // height +7 * FRACUNIT, // speed +8 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 18, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF, // flags -MF2_LOGRAV|MF2_FLOORBOUNCE|MF2_THRUGHOST|MF2_TELESTOMP // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF, // flags +MF2_LOGRAV | MF2_FLOORBOUNCE | MF2_THRUGHOST | MF2_TELESTOMP // flags2 }, { // MT_WSKULLROD @@ -3370,8 +3370,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -3396,20 +3396,20 @@ S_NULL, // crashstate S_HRODFXI1_1, // deathstate S_NULL, // xdeathstate sfx_hrnhit, // deathsound -22*FRACUNIT, // speed -12*FRACUNIT, // radius -8*FRACUNIT, // height +22 * FRACUNIT, // speed +12 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 3, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_WINDTHRUST|MF2_NOTELEPORT // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_WINDTHRUST | MF2_NOTELEPORT // flags2 }, { // MT_HORNRODFX2 -1, // doomednum S_HRODFX2_1, // spawnstate -4*35, // spawnhealth +4 * 35, // spawnhealth S_NULL, // seestate sfx_hrnsht, // seesound 8, // reactiontime @@ -3423,13 +3423,13 @@ S_NULL, // crashstate S_HRODFXI2_1, // deathstate S_NULL, // xdeathstate sfx_ramphit, // deathsound -22*FRACUNIT, // speed -12*FRACUNIT, // radius -8*FRACUNIT, // height +22 * FRACUNIT, // speed +12 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 10, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -3450,13 +3450,13 @@ S_NULL, // crashstate S_RAINPLR1X_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -12*FRACUNIT, // speed -5*FRACUNIT, // radius -12*FRACUNIT, // height +12 * FRACUNIT, // speed +5 * FRACUNIT, // radius +12 * FRACUNIT, // height 100, // mass 5, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -3477,13 +3477,13 @@ S_NULL, // crashstate S_RAINPLR2X_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -12*FRACUNIT, // speed -5*FRACUNIT, // radius -12*FRACUNIT, // height +12 * FRACUNIT, // speed +5 * FRACUNIT, // radius +12 * FRACUNIT, // height 100, // mass 5, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -3504,13 +3504,13 @@ S_NULL, // crashstate S_RAINPLR3X_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -12*FRACUNIT, // speed -5*FRACUNIT, // radius -12*FRACUNIT, // height +12 * FRACUNIT, // speed +5 * FRACUNIT, // radius +12 * FRACUNIT, // height 100, // mass 5, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -3531,13 +3531,13 @@ S_NULL, // crashstate S_RAINPLR4X_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -12*FRACUNIT, // speed -5*FRACUNIT, // radius -12*FRACUNIT, // height +12 * FRACUNIT, // speed +5 * FRACUNIT, // radius +12 * FRACUNIT, // height 100, // mass 5, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -3558,13 +3558,13 @@ S_NULL, // crashstate S_GWANDFXI1_1, // deathstate S_NULL, // xdeathstate sfx_gldhit, // deathsound -22*FRACUNIT, // speed -10*FRACUNIT, // radius -6*FRACUNIT, // height +22 * FRACUNIT, // speed +10 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 2, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -3585,13 +3585,13 @@ S_NULL, // crashstate S_GWANDFXI1_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -18*FRACUNIT, // speed -10*FRACUNIT, // radius -6*FRACUNIT, // height +18 * FRACUNIT, // speed +10 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 1, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -3613,12 +3613,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -3640,12 +3640,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -3667,8 +3667,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -3693,14 +3693,14 @@ S_NULL, // crashstate S_PHOENIXFXI1_1, // deathstate S_NULL, // xdeathstate sfx_phohit, // deathsound -20*FRACUNIT, // speed -11*FRACUNIT, // radius -8*FRACUNIT, // height +20 * FRACUNIT, // speed +11 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 20, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_THRUGHOST|MF2_NOTELEPORT // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_THRUGHOST | MF2_NOTELEPORT // flags2 }, { // MT_PHOENIXPUFF @@ -3721,13 +3721,13 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_SHADOW, // flags -MF2_NOTELEPORT|MF2_CANNOTPUSH // flags2 +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_SHADOW, // flags +MF2_NOTELEPORT | MF2_CANNOTPUSH // flags2 }, { // MT_PHOENIXFX2 @@ -3747,14 +3747,14 @@ S_NULL, // crashstate S_PHOENIXFXI2_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -10*FRACUNIT, // speed -6*FRACUNIT, // radius -8*FRACUNIT, // height +10 * FRACUNIT, // speed +6 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 2, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_NOTELEPORT|MF2_FIREDAMAGE // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_NOTELEPORT | MF2_FIREDAMAGE // flags2 }, { // MT_MISC15 @@ -3775,8 +3775,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -3801,13 +3801,13 @@ S_NULL, // crashstate S_CRBOWFXI1_1, // deathstate S_NULL, // xdeathstate sfx_hrnhit, // deathsound -30*FRACUNIT, // speed -11*FRACUNIT, // radius -8*FRACUNIT, // height +30 * FRACUNIT, // speed +11 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 10, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -3828,13 +3828,13 @@ S_NULL, // crashstate S_CRBOWFXI1_1, // deathstate S_NULL, // xdeathstate sfx_hrnhit, // deathsound -32*FRACUNIT, // speed -11*FRACUNIT, // radius -8*FRACUNIT, // height +32 * FRACUNIT, // speed +11 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 6, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -3855,14 +3855,14 @@ S_NULL, // crashstate S_CRBOWFXI3_1, // deathstate S_NULL, // xdeathstate sfx_hrnhit, // deathsound -20*FRACUNIT, // speed -11*FRACUNIT, // radius -8*FRACUNIT, // height +20 * FRACUNIT, // speed +11 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 2, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_WINDTHRUST|MF2_THRUGHOST|MF2_NOTELEPORT // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_WINDTHRUST | MF2_THRUGHOST | MF2_NOTELEPORT // flags2 }, { // MT_CRBOWFX4 @@ -3883,8 +3883,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -3910,8 +3910,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -3937,13 +3937,13 @@ S_BLOODSPLATTERX, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -2*FRACUNIT, // radius -4*FRACUNIT, // height +2 * FRACUNIT, // radius +4 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF, // flags -MF2_NOTELEPORT|MF2_CANNOTPUSH // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF, // flags +MF2_NOTELEPORT | MF2_CANNOTPUSH // flags2 }, { // MT_PLAYER @@ -3964,13 +3964,13 @@ S_PLAY_DIE1, // deathstate S_PLAY_XDIE1, // xdeathstate sfx_plrdth, // deathsound 0, // speed -16*FRACUNIT, // radius -56*FRACUNIT, // height +16 * FRACUNIT, // radius +56 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_PICKUP|MF_NOTDMATCH, // flags -MF2_WINDTHRUST|MF2_FOOTCLIP|MF2_SLIDE|MF2_PASSMOBJ|MF2_TELESTOMP // flags2 +MF_SOLID | MF_SHOOTABLE | MF_DROPOFF | MF_PICKUP | MF_NOTDMATCH, // flags +MF2_WINDTHRUST | MF2_FOOTCLIP | MF2_SLIDE | MF2_PASSMOBJ | MF2_TELESTOMP // flags2 }, { // MT_BLOODYSKULL @@ -3991,13 +3991,13 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -4*FRACUNIT, // radius -4*FRACUNIT, // height +4 * FRACUNIT, // radius +4 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_DROPOFF, // flags -MF2_LOGRAV|MF2_CANNOTPUSH // flags2 +MF_NOBLOCKMAP | MF_DROPOFF, // flags +MF2_LOGRAV | MF2_CANNOTPUSH // flags2 }, { // MT_CHICPLAYER @@ -4018,13 +4018,13 @@ S_CHICKEN_DIE1, // deathstate S_NULL, // xdeathstate sfx_chicdth, // deathsound 0, // speed -16*FRACUNIT, // radius -24*FRACUNIT, // height +16 * FRACUNIT, // radius +24 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SOLID|MF_SHOOTABLE|MF_DROPOFF|MF_NOTDMATCH, // flags -MF2_WINDTHRUST|MF2_SLIDE|MF2_PASSMOBJ|MF2_FOOTCLIP|MF2_LOGRAV|MF2_TELESTOMP // flags2 +MF_SOLID | MF_SHOOTABLE | MF_DROPOFF | MF_NOTDMATCH, // flags +MF2_WINDTHRUST | MF2_SLIDE | MF2_PASSMOBJ | MF2_FOOTCLIP | MF2_LOGRAV | MF2_TELESTOMP // flags2 }, { // MT_CHICKEN @@ -4045,13 +4045,13 @@ S_CHICKEN_DIE1, // deathstate S_NULL, // xdeathstate sfx_chicdth, // deathsound 4, // speed -9*FRACUNIT, // radius -22*FRACUNIT, // height +9 * FRACUNIT, // radius +22 * FRACUNIT, // height 40, // mass 0, // damage sfx_chicact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_DROPOFF, // flags -MF2_WINDTHRUST|MF2_FOOTCLIP|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL | MF_DROPOFF, // flags +MF2_WINDTHRUST | MF2_FOOTCLIP | MF2_PASSMOBJ // flags2 }, { // MT_FEATHER @@ -4072,13 +4072,13 @@ S_FEATHERX, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -2*FRACUNIT, // radius -4*FRACUNIT, // height +2 * FRACUNIT, // radius +4 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF, // flags -MF2_NOTELEPORT|MF2_LOGRAV|MF2_CANNOTPUSH|MF2_WINDTHRUST // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF, // flags +MF2_NOTELEPORT | MF2_LOGRAV | MF2_CANNOTPUSH | MF2_WINDTHRUST // flags2 }, { // MT_MUMMY @@ -4099,13 +4099,13 @@ S_MUMMY_DIE1, // deathstate S_NULL, // xdeathstate sfx_mumdth, // deathsound 12, // speed -22*FRACUNIT, // radius -62*FRACUNIT, // height +22 * FRACUNIT, // radius +62 * FRACUNIT, // height 75, // mass 0, // damage sfx_mumact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ // flags2 }, { // MT_MUMMYLEADER @@ -4126,13 +4126,13 @@ S_MUMMY_DIE1, // deathstate S_NULL, // xdeathstate sfx_mumdth, // deathsound 12, // speed -22*FRACUNIT, // radius -62*FRACUNIT, // height +22 * FRACUNIT, // radius +62 * FRACUNIT, // height 75, // mass 0, // damage sfx_mumact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ // flags2 }, { // MT_MUMMYGHOST @@ -4153,13 +4153,13 @@ S_MUMMY_DIE1, // deathstate S_NULL, // xdeathstate sfx_mumdth, // deathsound 12, // speed -22*FRACUNIT, // radius -62*FRACUNIT, // height +22 * FRACUNIT, // radius +62 * FRACUNIT, // height 75, // mass 0, // damage sfx_mumact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_SHADOW, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL | MF_SHADOW, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ // flags2 }, { // MT_MUMMYLEADERGHOST @@ -4180,13 +4180,13 @@ S_MUMMY_DIE1, // deathstate S_NULL, // xdeathstate sfx_mumdth, // deathsound 12, // speed -22*FRACUNIT, // radius -62*FRACUNIT, // height +22 * FRACUNIT, // radius +62 * FRACUNIT, // height 75, // mass 0, // damage sfx_mumact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_SHADOW, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL | MF_SHADOW, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ // flags2 }, { // MT_MUMMYSOUL @@ -4207,12 +4207,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY, // flags 0 // flags2 }, @@ -4233,13 +4233,13 @@ S_NULL, // crashstate S_MUMMYFXI1_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -9*FRACUNIT, // speed -8*FRACUNIT, // radius -14*FRACUNIT, // height +9 * FRACUNIT, // speed +8 * FRACUNIT, // radius +14 * FRACUNIT, // height 100, // mass 4, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -4261,13 +4261,13 @@ S_BEAST_DIE1, // deathstate S_BEAST_XDIE1, // xdeathstate sfx_bstdth, // deathsound 14, // speed -32*FRACUNIT, // radius -74*FRACUNIT, // height +32 * FRACUNIT, // radius +74 * FRACUNIT, // height 200, // mass 0, // damage sfx_bstact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ // flags2 }, { // MT_BEASTBALL @@ -4287,14 +4287,14 @@ S_NULL, // crashstate S_BEASTBALLX1, // deathstate S_NULL, // xdeathstate 0, // deathsound -12*FRACUNIT, // speed -9*FRACUNIT, // radius -8*FRACUNIT, // height +12 * FRACUNIT, // speed +9 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 4, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_WINDTHRUST|MF2_NOTELEPORT // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_WINDTHRUST | MF2_NOTELEPORT // flags2 }, { // MT_BURNBALL @@ -4314,13 +4314,13 @@ S_NULL, // crashstate S_BEASTBALLX1, // deathstate S_NULL, // xdeathstate 0, // deathsound -10*FRACUNIT, // speed -6*FRACUNIT, // radius -8*FRACUNIT, // height +10 * FRACUNIT, // speed +6 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 2, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_MISSILE, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_MISSILE, // flags MF2_NOTELEPORT // flags2 }, @@ -4341,13 +4341,13 @@ S_NULL, // crashstate S_BEASTBALLX1, // deathstate S_NULL, // xdeathstate 0, // deathsound -10*FRACUNIT, // speed -6*FRACUNIT, // radius -8*FRACUNIT, // height +10 * FRACUNIT, // speed +6 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 2, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_MISSILE, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_MISSILE, // flags MF2_NOTELEPORT // flags2 }, @@ -4368,13 +4368,13 @@ S_NULL, // crashstate S_PUFFY1, // deathstate S_NULL, // xdeathstate 0, // deathsound -10*FRACUNIT, // speed -6*FRACUNIT, // radius -8*FRACUNIT, // height +10 * FRACUNIT, // speed +6 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 2, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY|MF_MISSILE, // flags +MF_NOBLOCKMAP | MF_NOGRAVITY | MF_MISSILE, // flags MF2_NOTELEPORT // flags2 }, @@ -4396,13 +4396,13 @@ S_SNAKE_DIE1, // deathstate S_NULL, // xdeathstate sfx_snkdth, // deathsound 10, // speed -22*FRACUNIT, // radius -70*FRACUNIT, // height +22 * FRACUNIT, // radius +70 * FRACUNIT, // height 100, // mass 0, // damage sfx_snkact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ // flags2 }, { // MT_SNAKEPRO_A @@ -4422,14 +4422,14 @@ S_NULL, // crashstate S_SNAKEPRO_AX1, // deathstate S_NULL, // xdeathstate 0, // deathsound -14*FRACUNIT, // speed -12*FRACUNIT, // radius -8*FRACUNIT, // height +14 * FRACUNIT, // speed +12 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 1, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_WINDTHRUST|MF2_NOTELEPORT // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_WINDTHRUST | MF2_NOTELEPORT // flags2 }, { // MT_SNAKEPRO_B @@ -4449,13 +4449,13 @@ S_NULL, // crashstate S_SNAKEPRO_BX1, // deathstate S_NULL, // xdeathstate 0, // deathsound -14*FRACUNIT, // speed -12*FRACUNIT, // radius -8*FRACUNIT, // height +14 * FRACUNIT, // speed +12 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 3, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -4477,12 +4477,12 @@ S_HEAD_DIE1, // deathstate S_NULL, // xdeathstate sfx_heddth, // deathsound 6, // speed -40*FRACUNIT, // radius -72*FRACUNIT, // height +40 * FRACUNIT, // radius +72 * FRACUNIT, // height 325, // mass 0, // damage sfx_hedact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_NOBLOOD, // flags +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL | MF_NOBLOOD, // flags MF2_PASSMOBJ // flags2 }, @@ -4503,14 +4503,14 @@ S_NULL, // crashstate S_HEADFXI1_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -13*FRACUNIT, // speed -12*FRACUNIT, // radius -6*FRACUNIT, // height +13 * FRACUNIT, // speed +12 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 1, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_NOTELEPORT|MF2_THRUGHOST // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_NOTELEPORT | MF2_THRUGHOST // flags2 }, { // MT_HEADFX2 @@ -4530,13 +4530,13 @@ S_NULL, // crashstate S_HEADFXI2_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -8*FRACUNIT, // speed -12*FRACUNIT, // radius -6*FRACUNIT, // height +8 * FRACUNIT, // speed +12 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 3, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -4557,14 +4557,14 @@ S_NULL, // crashstate S_HEADFXI3_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -10*FRACUNIT, // speed -14*FRACUNIT, // radius -12*FRACUNIT, // height +10 * FRACUNIT, // speed +14 * FRACUNIT, // radius +12 * FRACUNIT, // height 100, // mass 5, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_WINDTHRUST|MF2_NOTELEPORT // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_WINDTHRUST | MF2_NOTELEPORT // flags2 }, { // MT_WHIRLWIND @@ -4584,13 +4584,13 @@ S_NULL, // crashstate S_HEADFXI4_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -10*FRACUNIT, // speed -16*FRACUNIT, // radius -74*FRACUNIT, // height +10 * FRACUNIT, // speed +16 * FRACUNIT, // radius +74 * FRACUNIT, // height 100, // mass 1, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY|MF_SHADOW, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY | MF_SHADOW, // flags MF2_NOTELEPORT // flags2 }, @@ -4612,13 +4612,13 @@ S_CLINK_DIE1, // deathstate S_NULL, // xdeathstate sfx_clkdth, // deathsound 14, // speed -20*FRACUNIT, // radius -64*FRACUNIT, // height +20 * FRACUNIT, // radius +64 * FRACUNIT, // height 75, // mass 0, // damage sfx_clkact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_NOBLOOD, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL | MF_NOBLOOD, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ // flags2 }, { // MT_WIZARD @@ -4639,12 +4639,12 @@ S_WIZARD_DIE1, // deathstate S_NULL, // xdeathstate sfx_wizdth, // deathsound 12, // speed -16*FRACUNIT, // radius -68*FRACUNIT, // height +16 * FRACUNIT, // radius +68 * FRACUNIT, // height 100, // mass 0, // damage sfx_wizact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_FLOAT|MF_NOGRAVITY, // flags +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL | MF_FLOAT | MF_NOGRAVITY, // flags MF2_PASSMOBJ // flags2 }, @@ -4665,13 +4665,13 @@ S_NULL, // crashstate S_WIZFXI1_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -18*FRACUNIT, // speed -10*FRACUNIT, // radius -6*FRACUNIT, // height +18 * FRACUNIT, // speed +10 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 3, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -4693,13 +4693,13 @@ S_IMP_DIE1, // deathstate S_IMP_XDIE1, // xdeathstate sfx_impdth, // deathsound 10, // speed -16*FRACUNIT, // radius -36*FRACUNIT, // height +16 * FRACUNIT, // radius +36 * FRACUNIT, // height 50, // mass 0, // damage sfx_impact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL, // flags -MF2_SPAWNFLOAT|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_FLOAT | MF_NOGRAVITY | MF_COUNTKILL, // flags +MF2_SPAWNFLOAT | MF2_PASSMOBJ // flags2 }, { // MT_IMPLEADER @@ -4720,13 +4720,13 @@ S_IMP_DIE1, // deathstate S_IMP_XDIE1, // xdeathstate sfx_impdth, // deathsound 10, // speed -16*FRACUNIT, // radius -36*FRACUNIT, // height +16 * FRACUNIT, // radius +36 * FRACUNIT, // height 50, // mass 0, // damage sfx_impact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_FLOAT|MF_NOGRAVITY|MF_COUNTKILL, // flags -MF2_SPAWNFLOAT|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_FLOAT | MF_NOGRAVITY | MF_COUNTKILL, // flags +MF2_SPAWNFLOAT | MF2_PASSMOBJ // flags2 }, { // MT_IMPCHUNK1 @@ -4747,8 +4747,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -4774,8 +4774,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -4800,14 +4800,14 @@ S_NULL, // crashstate S_IMPFXI1, // deathstate S_NULL, // xdeathstate 0, // deathsound -10*FRACUNIT, // speed -8*FRACUNIT, // radius -8*FRACUNIT, // height +10 * FRACUNIT, // speed +8 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 1, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_WINDTHRUST|MF2_NOTELEPORT // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_WINDTHRUST | MF2_NOTELEPORT // flags2 }, { // MT_KNIGHT @@ -4828,13 +4828,13 @@ S_KNIGHT_DIE1, // deathstate S_NULL, // xdeathstate sfx_kgtdth, // deathsound 12, // speed -24*FRACUNIT, // radius -78*FRACUNIT, // height +24 * FRACUNIT, // radius +78 * FRACUNIT, // height 150, // mass 0, // damage sfx_kgtact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ // flags2 }, { // MT_KNIGHTGHOST @@ -4855,13 +4855,13 @@ S_KNIGHT_DIE1, // deathstate S_NULL, // xdeathstate sfx_kgtdth, // deathsound 12, // speed -24*FRACUNIT, // radius -78*FRACUNIT, // height +24 * FRACUNIT, // radius +78 * FRACUNIT, // height 150, // mass 0, // damage sfx_kgtact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_SHADOW, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL | MF_SHADOW, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ // flags2 }, { // MT_KNIGHTAXE @@ -4881,14 +4881,14 @@ S_NULL, // crashstate S_SPINAXEX1, // deathstate S_NULL, // xdeathstate sfx_hrnhit, // deathsound -9*FRACUNIT, // speed -10*FRACUNIT, // radius -8*FRACUNIT, // height +9 * FRACUNIT, // speed +10 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 2, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_WINDTHRUST|MF2_NOTELEPORT|MF2_THRUGHOST // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_WINDTHRUST | MF2_NOTELEPORT | MF2_THRUGHOST // flags2 }, { // MT_REDAXE @@ -4908,14 +4908,14 @@ S_NULL, // crashstate S_REDAXEX1, // deathstate S_NULL, // xdeathstate sfx_hrnhit, // deathsound -9*FRACUNIT, // speed -10*FRACUNIT, // radius -8*FRACUNIT, // height +9 * FRACUNIT, // speed +10 * FRACUNIT, // radius +8 * FRACUNIT, // height 100, // mass 7, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_NOTELEPORT|MF2_THRUGHOST // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_NOTELEPORT | MF2_THRUGHOST // flags2 }, { // MT_SORCERER1 @@ -4936,13 +4936,13 @@ S_SRCR1_DIE1, // deathstate S_NULL, // xdeathstate sfx_sbtdth, // deathsound 16, // speed -28*FRACUNIT, // radius -100*FRACUNIT, // height +28 * FRACUNIT, // radius +100 * FRACUNIT, // height 800, // mass 0, // damage sfx_sbtact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ|MF2_BOSS // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ | MF2_BOSS // flags2 }, { // MT_SRCRFX1 @@ -4962,14 +4962,14 @@ S_NULL, // crashstate S_SRCRFXI1_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -20*FRACUNIT, // speed -10*FRACUNIT, // radius -10*FRACUNIT, // height +20 * FRACUNIT, // speed +10 * FRACUNIT, // radius +10 * FRACUNIT, // height 100, // mass 10, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_NOTELEPORT|MF2_FIREDAMAGE // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_NOTELEPORT | MF2_FIREDAMAGE // flags2 }, { // MT_SORCERER2 @@ -4990,13 +4990,13 @@ S_SOR2_DIE1, // deathstate S_NULL, // xdeathstate 0, // deathsound 14, // speed -16*FRACUNIT, // radius -70*FRACUNIT, // height +16 * FRACUNIT, // radius +70 * FRACUNIT, // height 300, // mass 0, // damage sfx_soract, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_DROPOFF, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ|MF2_BOSS // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL | MF_DROPOFF, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ | MF2_BOSS // flags2 }, { // MT_SOR2FX1 @@ -5016,13 +5016,13 @@ S_NULL, // crashstate S_SOR2FXI1_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -20*FRACUNIT, // speed -10*FRACUNIT, // radius -6*FRACUNIT, // height +20 * FRACUNIT, // speed +10 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 1, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -5044,13 +5044,13 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOGRAVITY, // flags -MF2_NOTELEPORT|MF2_CANNOTPUSH // flags2 +MF_NOBLOCKMAP | MF_NOGRAVITY, // flags +MF2_NOTELEPORT | MF2_CANNOTPUSH // flags2 }, { // MT_SOR2FX2 @@ -5070,13 +5070,13 @@ S_NULL, // crashstate S_SOR2FXI2_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -6*FRACUNIT, // speed -10*FRACUNIT, // radius -6*FRACUNIT, // height +6 * FRACUNIT, // speed +10 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 10, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags MF2_NOTELEPORT // flags2 }, @@ -5098,8 +5098,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5125,13 +5125,13 @@ S_MNTR_DIE1, // deathstate S_NULL, // xdeathstate sfx_mindth, // deathsound 16, // speed -28*FRACUNIT, // radius -100*FRACUNIT, // height +28 * FRACUNIT, // radius +100 * FRACUNIT, // height 800, // mass 7, // damage sfx_minact, // activesound -MF_SOLID|MF_SHOOTABLE|MF_COUNTKILL|MF_DROPOFF, // flags -MF2_FOOTCLIP|MF2_PASSMOBJ|MF2_BOSS // flags2 +MF_SOLID | MF_SHOOTABLE | MF_COUNTKILL | MF_DROPOFF, // flags +MF2_FOOTCLIP | MF2_PASSMOBJ | MF2_BOSS // flags2 }, { // MT_MNTRFX1 @@ -5151,14 +5151,14 @@ S_NULL, // crashstate S_MNTRFXI1_1, // deathstate S_NULL, // xdeathstate 0, // deathsound -20*FRACUNIT, // speed -10*FRACUNIT, // radius -6*FRACUNIT, // height +20 * FRACUNIT, // speed +10 * FRACUNIT, // radius +6 * FRACUNIT, // height 100, // mass 3, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_NOTELEPORT|MF2_FIREDAMAGE // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_NOTELEPORT | MF2_FIREDAMAGE // flags2 }, { // MT_MNTRFX2 @@ -5178,14 +5178,14 @@ S_NULL, // crashstate S_MNTRFXI2_1, // deathstate S_NULL, // xdeathstate sfx_phohit, // deathsound -14*FRACUNIT, // speed -5*FRACUNIT, // radius -12*FRACUNIT, // height +14 * FRACUNIT, // speed +5 * FRACUNIT, // radius +12 * FRACUNIT, // height 100, // mass 4, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_NOTELEPORT|MF2_FIREDAMAGE // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_NOTELEPORT | MF2_FIREDAMAGE // flags2 }, { // MT_MNTRFX3 @@ -5206,13 +5206,13 @@ S_MNTRFXI2_1, // deathstate S_NULL, // xdeathstate sfx_phohit, // deathsound 0, // speed -8*FRACUNIT, // radius -16*FRACUNIT, // height +8 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 4, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY, // flags -MF2_NOTELEPORT|MF2_FIREDAMAGE // flags2 +MF_NOBLOCKMAP | MF_MISSILE | MF_DROPOFF | MF_NOGRAVITY, // flags +MF2_NOTELEPORT | MF2_FIREDAMAGE // flags2 }, { // MT_AKYY @@ -5233,12 +5233,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_NOTDMATCH, // flags +MF_SPECIAL | MF_NOTDMATCH, // flags 0 // flags2 }, @@ -5260,12 +5260,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_NOTDMATCH, // flags +MF_SPECIAL | MF_NOTDMATCH, // flags 0 // flags2 }, @@ -5287,12 +5287,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_SPECIAL|MF_NOTDMATCH, // flags +MF_SPECIAL | MF_NOTDMATCH, // flags 0 // flags2 }, @@ -5314,8 +5314,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5341,8 +5341,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5368,8 +5368,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5395,8 +5395,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5422,8 +5422,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5449,8 +5449,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5476,8 +5476,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5503,8 +5503,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5530,8 +5530,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5557,8 +5557,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5584,8 +5584,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5611,8 +5611,8 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound @@ -5638,12 +5638,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOSECTOR, // flags +MF_NOBLOCKMAP | MF_NOSECTOR, // flags 0 // flags2 }, @@ -5665,12 +5665,12 @@ S_NULL, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed -20*FRACUNIT, // radius -16*FRACUNIT, // height +20 * FRACUNIT, // radius +16 * FRACUNIT, // height 100, // mass 0, // damage sfx_None, // activesound -MF_NOBLOCKMAP|MF_NOSECTOR, // flags +MF_NOBLOCKMAP | MF_NOSECTOR, // flags 0 // flags2 } }; diff --git a/IN_LUDE.C b/IN_LUDE.C index 8b1caf5..58d26ff 100644 --- a/IN_LUDE.C +++ b/IN_LUDE.C @@ -167,7 +167,7 @@ void IN_Start(void) void IN_WaitStop(void) { - if(!--cnt) + if (!--cnt) { IN_Stop(); G_WorldDone(); @@ -206,37 +206,37 @@ void IN_InitStats(void) didStatCopy = 0; // FS: For statcopy - if(!netgame) + if (!netgame) { gametype = SINGLE; - time = leveltime/35; - hours = time/3600; - time -= hours*3600; - minutes = time/60; - time -= minutes*60; + time = leveltime / 35; + hours = time / 3600; + time -= hours * 3600; + minutes = time / 60; + time -= minutes * 60; seconds = time; } - else if(netgame && !deathmatch) + else if (netgame && !deathmatch) { gametype = COOPERATIVE; - memset(killPercent, 0, MAXPLAYERS*sizeof(int)); - memset(bonusPercent, 0, MAXPLAYERS*sizeof(int)); - memset(secretPercent, 0, MAXPLAYERS*sizeof(int)); - for(i=0; i slaughterfrags) + if (totalFrags[i] > slaughterfrags) { - slaughterboy = 1< 3 && interstate >= 1) + if (gameepisode > 3 && interstate >= 1) { // Extended Wad levels: skip directly to the next level interstate = 3; } - switch(interstate) + switch (interstate) { case 0: - oldintertime = intertime+300; - if(gameepisode > 3) + oldintertime = intertime + 300; + if (gameepisode > 3) { - oldintertime = intertime+1200; + oldintertime = intertime + 1200; } break; case 1: - oldintertime = intertime+200; + oldintertime = intertime + 200; break; case 2: oldintertime = MAXINT; @@ -398,15 +398,15 @@ void IN_Ticker(void) break; } } - if(skipintermission) + if (skipintermission) { - if(interstate == 0 && intertime < 150) + if (interstate == 0 && intertime < 150) { intertime = 150; skipintermission = false; return; } - else if(interstate < 2 && gameepisode < 4) + else if (interstate < 2 && gameepisode < 4) { interstate = 2; skipintermission = false; @@ -430,13 +430,13 @@ void IN_Ticker(void) void IN_CheckForSkip(void) { int i; - player_t *player; + player_t *player; - for (i=0, player = players ; icmd.buttons&BT_ATTACK) + if (player->cmd.buttons & BT_ATTACK) { if (!player->attackdown) { @@ -448,7 +448,7 @@ void IN_CheckForSkip(void) { player->attackdown = false; } - if (player->cmd.buttons&BT_USE) + if (player->cmd.buttons & BT_USE) { if (!player->usedown) { @@ -474,26 +474,26 @@ void IN_Drawer(void) { static int oldinterstate; - if(!intermission) + if (!intermission) { return; } - if(interstate == 3) + if (interstate == 3) { return; } UpdateState |= I_FULLSCRN; - if(oldinterstate != 2 && interstate == 2) + if (oldinterstate != 2 && interstate == 2) { S_StartSound(NULL, sfx_pstop); } oldinterstate = interstate; - switch(interstate) + switch (interstate) { case 0: // draw stats IN_DrawStatBack(); - switch(gametype) + switch (gametype) { case SINGLE: IN_DrawSingleStats(); @@ -507,21 +507,21 @@ void IN_Drawer(void) } break; case 1: // leaving old level - if(gameepisode < 4) + if (gameepisode < 4) { V_DrawPatch(0, 0, patchINTERPIC); IN_DrawOldLevel(); } break; case 2: // going to the next level - if(gameepisode < 4) + if (gameepisode < 4) { V_DrawPatch(0, 0, patchINTERPIC); IN_DrawYAH(); } break; case 3: // waiting before going to the next level - if(gameepisode < 4) + if (gameepisode < 4) { V_DrawPatch(0, 0, patchINTERPIC); } @@ -549,17 +549,17 @@ void IN_DrawStatBack(void) src = W_CacheLumpName ("FLOOR16", PU_CACHE); dest = screen; - for (y=0 ; y= 30) + if (sounds < 1 && intertime >= 30) { S_StartSound(NULL, sfx_dorcls); sounds++; @@ -685,11 +685,11 @@ void IN_DrawSingleStats(void) IN_DrawNumber(players[consoleplayer].killcount, 200, 65, 3); V_DrawShadowedPatch(237, 65, FontBSlash); IN_DrawNumber(totalkills, 248, 65, 3); - if(intertime < 60) + if (intertime < 60) { return; } - if(sounds < 2 && intertime >= 60) + if (sounds < 2 && intertime >= 60) { S_StartSound(NULL, sfx_dorcls); sounds++; @@ -697,11 +697,11 @@ void IN_DrawSingleStats(void) IN_DrawNumber(players[consoleplayer].itemcount, 200, 90, 3); V_DrawShadowedPatch(237, 90, FontBSlash); IN_DrawNumber(totalitems, 248, 90, 3); - if(intertime < 90) + if (intertime < 90) { return; } - if(sounds < 3 && intertime >= 90) + if (sounds < 3 && intertime >= 90) { S_StartSound(NULL, sfx_dorcls); sounds++; @@ -709,27 +709,27 @@ void IN_DrawSingleStats(void) IN_DrawNumber(players[consoleplayer].secretcount, 200, 115, 3); V_DrawShadowedPatch(237, 115, FontBSlash); IN_DrawNumber(totalsecret, 248, 115, 3); - if(intertime < 150) + if (intertime < 150) { return; } - if(sounds < 4 && intertime >= 150) + if (sounds < 4 && intertime >= 150) { S_StartSound(NULL, sfx_dorcls); sounds++; } - if(!ExtendedWAD || gameepisode < 4) + if (!ExtendedWAD || gameepisode < 4) { IN_DrTextB("TIME", 85, 160); IN_DrawTime(155, 160, hours, minutes, seconds); } else { - x = 160-MN_TextAWidth("NOW ENTERING:")/2; + x = 160 - MN_TextAWidth("NOW ENTERING:") / 2; MN_DrTextA("NOW ENTERING:", x, 160); - x = 160-MN_TextBWidth(DEH_String(LevelNames[(gameepisode-1)*9+gamemap-1])+7)/2; - IN_DrTextB(DEH_String(LevelNames[(gameepisode-1)*9+gamemap-1])+7, x, 170); + x = 160 - MN_TextBWidth(DEH_String(LevelNames[(gameepisode - 1) * 9 + gamemap - 1]) + 7) / 2; + IN_DrTextB(DEH_String(LevelNames[(gameepisode - 1) * 9 + gamemap - 1]) + 7, x, 170); skipintermission = false; } } @@ -753,34 +753,34 @@ void IN_DrawCoopStats(void) IN_DrTextB("KILLS", 95, 35); IN_DrTextB("BONUS", 155, 35); IN_DrTextB("SECRET", 232, 35); - x = 160-MN_TextBWidth(DEH_String(LevelNames[(gameepisode-1)*9+prevmap-1])+7)/2; - IN_DrTextB(DEH_String(LevelNames[(gameepisode-1)*9+prevmap-1])+7, x, 3); - x = 160-MN_TextAWidth("FINISHED")/2; + x = 160 - MN_TextBWidth(DEH_String(LevelNames[(gameepisode - 1) * 9 + prevmap - 1]) + 7) / 2; + IN_DrTextB(DEH_String(LevelNames[(gameepisode - 1) * 9 + prevmap - 1]) + 7, x, 3); + x = 160 - MN_TextAWidth("FINISHED") / 2; MN_DrTextA("FINISHED", x, 25); ypos = 50; - for(i=0; i= 40 && sounds < 1) + else if (intertime >= 40 && sounds < 1) { S_StartSound(NULL, sfx_dorcls); sounds++; } - IN_DrawNumber(killPercent[i], 85, ypos+10, 3); - V_DrawShadowedPatch(121, ypos+10, FontBPercent); - IN_DrawNumber(bonusPercent[i], 160, ypos+10, 3); - V_DrawShadowedPatch(196, ypos+10, FontBPercent); - IN_DrawNumber(secretPercent[i], 237, ypos+10, 3); - V_DrawShadowedPatch(273, ypos+10, FontBPercent); + IN_DrawNumber(killPercent[i], 85, ypos + 10, 3); + V_DrawShadowedPatch(121, ypos + 10, FontBPercent); + IN_DrawNumber(bonusPercent[i], 160, ypos + 10, 3); + V_DrawShadowedPatch(196, ypos + 10, FontBPercent); + IN_DrawNumber(secretPercent[i], 237, ypos + 10, 3); + V_DrawShadowedPatch(273, ypos + 10, FontBPercent); ypos += 37; } } @@ -810,68 +810,68 @@ void IN_DrawDMStats(void) IN_DrTextB("TOTAL", 265, 30); MN_DrTextA("VICTIMS", 140, 8); - for(i=0; i<7; i++) + for (i = 0; i < 7; i++) { - MN_DrTextA(KillersText[i], 10, 80+9*i); + MN_DrTextA(KillersText[i], 10, 80 + 9 * i); } - if(intertime < 20) + if (intertime < 20) { - for(i=0; i>FRACBITS, W_CacheLumpNum(patchFaceOkayBase+i, PU_CACHE)); - V_DrawShadowedPatch(((xpos<>FRACBITS, 18, W_CacheLumpNum(patchFaceDeadBase+i, PU_CACHE)); + V_DrawShadowedPatch(40, ((ypos << FRACBITS) + dSlideY[i] * intertime) + >> FRACBITS, W_CacheLumpNum(patchFaceOkayBase + i, PU_CACHE)); + V_DrawShadowedPatch(((xpos << FRACBITS) + dSlideX[i] * intertime) + >> FRACBITS, 18, W_CacheLumpNum(patchFaceDeadBase + i, PU_CACHE)); } } sounds = 0; return; } - if(intertime >= 20 && sounds < 1) + if (intertime >= 20 && sounds < 1) { S_StartSound(NULL, sfx_dorcls); sounds++; } - if(intertime >= 100 && slaughterboy && sounds < 2) + if (intertime >= 100 && slaughterboy && sounds < 2) { S_StartSound(NULL, sfx_wpnup); sounds++; } - for(i=0; i 99) + if (val > 99) { val = 99; } } - if(val > 9) + if (val > 9) { realdigits++; - if(digits < realdigits) + if (digits < realdigits) { realdigits = digits; val = 9; } } - if(val > 99) + if (val > 99) { realdigits++; - if(digits < realdigits) + if (digits < realdigits) { realdigits = digits; val = 99; } } - if(val > 999) + if (val > 999) { realdigits++; - if(digits < realdigits) + if (digits < realdigits) { realdigits = digits; val = 999; } } - if(digits == 4) + if (digits == 4) { - patch = FontBNumbers[val/1000]; - V_DrawShadowedPatch(xpos+6-patch->width/2-12, y, patch); + patch = FontBNumbers[val / 1000]; + V_DrawShadowedPatch(xpos + 6 - patch->width / 2 - 12, y, patch); } - if(digits > 2) + if (digits > 2) { - if(realdigits > 2) + if (realdigits > 2) { - patch = FontBNumbers[val/100]; - V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch); + patch = FontBNumbers[val / 100]; + V_DrawShadowedPatch(xpos + 6 - patch->width / 2, y, patch); } xpos += 12; } - val = val%100; - if(digits > 1) + val = val % 100; + if (digits > 1) { - if(val > 9) + if (val > 9) { - patch = FontBNumbers[val/10]; - V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch); + patch = FontBNumbers[val / 10]; + V_DrawShadowedPatch(xpos + 6 - patch->width / 2, y, patch); } - else if(digits == 2 || oldval > 99) + else if (digits == 2 || oldval > 99) { V_DrawShadowedPatch(xpos, y, FontBNumbers[0]); } xpos += 12; } - val = val%10; + val = val % 10; patch = FontBNumbers[val]; - V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch); - if(neg) + V_DrawShadowedPatch(xpos + 6 - patch->width / 2, y, patch); + if (neg) { patch = FontBNegative; - V_DrawShadowedPatch(xpos+6-patch->width/2-12*(realdigits), y, patch); + V_DrawShadowedPatch(xpos + 6 - patch->width / 2 - 12 * (realdigits), y, patch); } } @@ -1009,17 +1009,17 @@ void IN_DrTextB(char *text, int x, int y) char c; patch_t *p; - while((c = *text++) != 0) + while ((c = *text++) != 0) { - if(c < 33) + if (c < 33) { x += 8; } else { - p = W_CacheLumpNum(FontBLump+c-33, PU_CACHE); + p = W_CacheLumpNum(FontBLump + c - 33, PU_CACHE); V_DrawShadowedPatch(x, y, p); - x += p->width-1; + x += p->width - 1; } } } @@ -1027,17 +1027,17 @@ void IN_DrTextB(char *text, int x, int y) char *IN_CheckStatArgv(void) // FS: Check for -statcopy and default to stats.txt { int p; - char *statfile; + char *statfile; - if(p = M_CheckParm("-statcopy")) + if (p = M_CheckParm("-statcopy")) { - if(p && p\n\n - PLAYER 1\n * KILLS: %i/%i\n * ITEMS: %i/%i\n * SECRETS: %i/%i\n * TIME: %i:%i:%i\n\n", - gameepisode, prevmap, DEH_String(LevelNames[(gameepisode-1)*9+prevmap-1])+7, gameskill+1, players[consoleplayer].killcount,totalkills, players[consoleplayer].itemcount, totalitems,players[consoleplayer].secretcount,totalsecret,hours,minutes,seconds); - fseek(f,0, SEEK_END); + sprintf(buffer, "MAP: E%iM%i %s\nSKILL: %i\n\n\n - PLAYER 1\n * KILLS: %i/%i\n * ITEMS: %i/%i\n * SECRETS: %i/%i\n * TIME: %i:%i:%i\n\n", + gameepisode, prevmap, DEH_String(LevelNames[(gameepisode - 1) * 9 + prevmap - 1]) + 7, gameskill + 1, players[consoleplayer].killcount, totalkills, players[consoleplayer].itemcount, totalitems, players[consoleplayer].secretcount, totalsecret, hours, minutes, seconds); + fseek(f, 0, SEEK_END); fputs(buffer, f); fflush(f); fclose(f); @@ -1078,10 +1078,10 @@ void IN_PrintCoopStats(void) char statfile[256]; static char buffer[2048]; // FS: For statcopy - if(!IN_CheckStatArgv()) + if (!IN_CheckStatArgv()) return; - if(didStatCopy < 1) + if (didStatCopy < 1) { strcpy(statfile, IN_CheckStatArgv()); @@ -1093,17 +1093,17 @@ void IN_PrintCoopStats(void) return; } - sprintf(buffer,"MAP: E%iM%i %s\nSKILL: %i\n\n\n", gameepisode, prevmap, DEH_String(LevelNames[(gameepisode-1)*9+prevmap-1])+7, gameskill+1); + sprintf(buffer, "MAP: E%iM%i %s\nSKILL: %i\n\n\n", gameepisode, prevmap, DEH_String(LevelNames[(gameepisode - 1) * 9 + prevmap - 1]) + 7, gameskill + 1); fputs(buffer, f); fflush(f); - for(i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < MAXPLAYERS; i++) { - if(playeringame[i]) + if (playeringame[i]) { - sprintf(buffer," - PLAYER %i\n * KILLS: %i/%i\n * ITEMS: %i/%i\n * SECRETS: %i/%i\n\n", i+1, players[i].killcount, totalkills, players[i].itemcount, totalitems, players[i].secretcount, totalsecret); + sprintf(buffer, " - PLAYER %i\n * KILLS: %i/%i\n * ITEMS: %i/%i\n * SECRETS: %i/%i\n\n", i + 1, players[i].killcount, totalkills, players[i].itemcount, totalitems, players[i].secretcount, totalsecret); - fseek(f,0, SEEK_END); + fseek(f, 0, SEEK_END); fputs(buffer, f); fflush(f); } @@ -1122,10 +1122,10 @@ void IN_PrintDMStats(void) char statfile[256]; static char buffer[2048]; // FS: For statcopy - if(!IN_CheckStatArgv()) + if (!IN_CheckStatArgv()) return; - if(didStatCopy < 1) + if (didStatCopy < 1) { strcpy(statfile, IN_CheckStatArgv()); @@ -1137,18 +1137,18 @@ void IN_PrintDMStats(void) return; } - sprintf(buffer,"MAP: E%iM%i %s\n\n\n", gameepisode, prevmap, DEH_String(LevelNames[(gameepisode-1)*9+prevmap-1])+7); + sprintf(buffer, "MAP: E%iM%i %s\n\n\n", gameepisode, prevmap, DEH_String(LevelNames[(gameepisode - 1) * 9 + prevmap - 1]) + 7); fputs(buffer, f); fflush(f); - for(i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < MAXPLAYERS; i++) { totalFrags[i] = 0; - if(playeringame[i]) + if (playeringame[i]) { totalFrags[i] += players[i].frags[i]; - sprintf(buffer," - PLAYER %i\n * FRAGS: %i\n\n", i+1, totalFrags[i]); - fseek(f,0, SEEK_END); + sprintf(buffer, " - PLAYER %i\n * FRAGS: %i\n\n", i + 1, totalFrags[i]); + fseek(f, 0, SEEK_END); fputs(buffer, f); fflush(f); } diff --git a/I_CYBER.C b/I_CYBER.C index a245ef8..87927b3 100644 --- a/I_CYBER.C +++ b/I_CYBER.C @@ -47,18 +47,20 @@ normal speed to help aiming. #define DOSMEMSIZE 64 // enough for any SWIFT structure -typedef struct { - short x; - short y; - short z; - short pitch; - short roll; - short yaw; - short buttons; +typedef struct +{ + short x; + short y; + short z; + short pitch; + short roll; + short yaw; + short buttons; } SWIFT_3DStatus; // DPMI real mode interrupt structure -static struct rminfo { +static struct rminfo +{ long EDI; long ESI; long EBP; @@ -68,16 +70,17 @@ static struct rminfo { long ECX; long EAX; short flags; - short ES,DS,FS,GS,IP,CS,SP,SS; + short ES, DS, FS, GS, IP, CS, SP, SS; } RMI; -typedef struct { - unsigned char deviceType; - unsigned char majorVersion; - unsigned char minorVersion; - unsigned char absRelFlags; - unsigned char centeringFlags; - unsigned char reserved[5]; +typedef struct +{ + unsigned char deviceType; + unsigned char majorVersion; + unsigned char minorVersion; + unsigned char absRelFlags; + unsigned char centeringFlags; + unsigned char reserved[5]; } StaticDeviceData; // values for deviceType: @@ -85,7 +88,7 @@ typedef struct { short selector; unsigned short segment; // segment of DOS memory block -SWIFT_3DStatus *cyberstat; +SWIFT_3DStatus *cyberstat; int isCyberPresent; // is CyberMan present? @@ -110,7 +113,7 @@ void I_StartupCyberMan(void) isCyberPresent = 0; cyberstat = (SWIFT_3DStatus *)I_AllocLow (DOSMEMSIZE); - segment = (int)cyberstat>>4; + segment = (int)cyberstat >> 4; pbuf = (StaticDeviceData *)cyberstat; memset(pbuf, 0, sizeof (StaticDeviceData)); @@ -126,7 +129,7 @@ void I_StartupCyberMan(void) regs.w.cx = 0; regs.x.edi = FP_OFF(&RMI); sregs.es = FP_SEG(&RMI); - int386x( DPMI_INT, ®s, ®s, &sregs ); + int386x(DPMI_INT, ®s, ®s, &sregs); if ((short)RMI.EAX != 1) { @@ -145,7 +148,7 @@ void I_StartupCyberMan(void) else { sprintf(cyberMsg, "CyberMan: SWIFT device is not a CyberMan! (type=%d)\n", pbuf->deviceType); - tprintf(cyberMsg,1 ); + tprintf(cyberMsg, 1); } } else @@ -185,12 +188,12 @@ void I_ReadCyberCmd (ticcmd_t *cmd) regs.w.cx = 0; regs.x.edi = FP_OFF(&RMI); sregs.es = FP_SEG(&RMI); - int386x( DPMI_INT, ®s, ®s, &sregs ); + int386x(DPMI_INT, ®s, ®s, &sregs); if (cyberstat->y < -7900) - cmd->forwardmove = 0xc800/2048; + cmd->forwardmove = 0xc800 / 2048; else if (cyberstat->y > 7900) - cmd->forwardmove = -0xc800/2048; + cmd->forwardmove = -0xc800 / 2048; if (cyberstat->buttons & 4) cmd->buttons |= BT_ATTACK; @@ -203,11 +206,11 @@ void I_ReadCyberCmd (ticcmd_t *cmd) if (cyberstat->buttons & 1) { // strafe if (cyberstat->x < -7900) - cmd->sidemove = -0xc800/2048; + cmd->sidemove = -0xc800 / 2048; else if (cyberstat->x > 7900) - cmd->sidemove = 0xc800/2048; + cmd->sidemove = 0xc800 / 2048; else - cmd->sidemove = delta*40/2048; + cmd->sidemove = delta * 40 / 2048; } else { @@ -216,7 +219,7 @@ void I_ReadCyberCmd (ticcmd_t *cmd) else if (cyberstat->x > 7900) cmd->angleturn = -0x280; else - cmd->angleturn = -delta*0xa/16; + cmd->angleturn = -delta * 0xa / 16; } @@ -240,7 +243,7 @@ void I_Tactile (int on, int off, int total) memset(&RMI, 0, sizeof(RMI)); RMI.EAX = 0x5330; // SWIFT: Get Position and Buttons - RMI.EBX = on*256+off; + RMI.EBX = on * 256 + off; RMI.ECX = total; memset(&sregs, 0, sizeof (sregs)); regs.w.ax = 0x0300; // DPMI: simulate interrupt @@ -248,5 +251,5 @@ void I_Tactile (int on, int off, int total) regs.w.cx = 0; regs.x.edi = FP_OFF(&RMI); sregs.es = FP_SEG(&RMI); - int386x( DPMI_INT, ®s, ®s, &sregs ); + int386x(DPMI_INT, ®s, ®s, &sregs); } diff --git a/I_SOUND.C b/I_SOUND.C index b8a4a73..fcad10a 100644 --- a/I_SOUND.C +++ b/I_SOUND.C @@ -20,7 +20,7 @@ void I_StartupTimer (void) #ifndef NOTIMER extern int I_TimerISR(void); - tprintf("I_StartupTimer()\n",0); + tprintf("I_StartupTimer()\n", 0); /* installs master timer. Must be done before StartupTimer()! */ TSM_Install(SND_TICRATE); tsm_ID = TSM_NewService (I_TimerISR, 35, 255, 0); /* max priority */ @@ -39,7 +39,7 @@ void I_ShutdownTimer (void) /* sound information */ #if 0 -const char *dnames[] = {"None", +const char *dnames[] = { "None", "PC_Speaker", "Adlib", "Sound_Blaster", @@ -47,7 +47,7 @@ const char *dnames[] = {"None", "Gravis_Ultrasound", "MPU", "AWE32" - }; +}; #endif const char snd_prefixen[] = { 'P', 'P', 'A', 'S', 'S', 'S', 'M', 'M', 'M', 'S' }; @@ -55,16 +55,16 @@ const char snd_prefixen[] = { 'P', 'P', 'A', 'S', 'S', 'S', 'M', 'M', 'M', 'S' } int snd_Channels; int snd_DesiredMusicDevice, snd_DesiredSfxDevice; int snd_MusicDevice, /* current music card # (index to dmxCodes) */ - snd_SfxDevice, /* current sfx card # (index to dmxCodes) */ - snd_MaxVolume, /* maximum volume for sound */ - snd_MusicVolume; /* maximum volume for music */ +snd_SfxDevice, /* current sfx card # (index to dmxCodes) */ +snd_MaxVolume, /* maximum volume for sound */ +snd_MusicVolume; /* maximum volume for music */ int dmxCodes[NUM_SCARDS]; /* the dmx code for a given card */ int snd_SBport, snd_SBirq, snd_SBdma; /* sound blaster variables */ int snd_Mport; /* midi variables */ extern boolean snd_MusicAvail, /* whether music is available */ - snd_SfxAvail; /* whether sfx are available */ +snd_SfxAvail; /* whether sfx are available */ void I_PauseSong (int handle) { @@ -78,8 +78,8 @@ void I_ResumeSong (int handle) void I_SetMusicVolume (int volume) { - MUS_SetMasterVolume(volume*8); -// snd_MusicVolume = volume; + MUS_SetMasterVolume(volume * 8); + // snd_MusicVolume = volume; } void I_SetSfxVolume (int volume) @@ -91,7 +91,7 @@ int I_RegisterSong (void *data) { int rc = MUS_RegisterSong(data); #ifdef SNDDEBUG - if (rc<0) + if (rc < 0) printf("MUS_Reg() returned %d\n", rc); #endif return rc; @@ -128,7 +128,7 @@ void I_StopSong (int handle) /* MUST be called before I_UnregisterSong(). */ #endif /* Fucking kluge pause */ - for (s=ticcount; ticcount - s < 10; ); + for (s = ticcount; ticcount - s < 10; ); } void I_PlaySong (int handle, boolean looping) @@ -158,7 +158,7 @@ int I_GetSfxLumpNum (sfxinfo_t *sound) { char namebuf[9]; - if(sound->name == 0) + if (sound->name == 0) return 0; if (sound->link) sound = sound->link; @@ -227,7 +227,7 @@ void I_sndArbitrateCards (void) /* figure out what i've got to initialize */ gus = snd_MusicDevice == snd_GUS || snd_SfxDevice == snd_GUS; sb = snd_SfxDevice == snd_SB || snd_MusicDevice == snd_SB; - adlib = snd_MusicDevice == snd_Adlib ; + adlib = snd_MusicDevice == snd_Adlib; pc = snd_SfxDevice == snd_PC; midi = snd_MusicDevice == snd_MPU; @@ -247,15 +247,15 @@ void I_sndArbitrateCards (void) { hasGUS = true; tprintf("SB_Init: Loading GUS patches.\n", 1); - hgotoxy(17,9); + hgotoxy(17, 9); hprintf("Loading GUS patches.", 0x3f); p = M_CheckParm("-usegusini"); /* FS: Use an external GUS ini file */ if (p) { - if(p < myargc-1) + if (p < myargc - 1) { - char *gusfile = myargv[p+1]; + char *gusfile = myargv[p + 1]; gusfilelength = M_ReadFile(gusfile, &gusbuffer); GF1_SetMap((char *)gusbuffer, gusfilelength); Z_Free(gusbuffer); @@ -286,37 +286,37 @@ void I_sndArbitrateCards (void) if (sb) { - if(debugmode) + if (debugmode) { - sprintf(tmp,"cfg p=%03xh, i=%d, d=%d\n", snd_SBport, snd_SBirq, snd_SBdma); - tprintf(tmp,0); + sprintf(tmp, "cfg p=%03xh, i=%d, d=%d\n", snd_SBport, snd_SBirq, snd_SBdma); + tprintf(tmp, 0); } retval = SB_Detect(&snd_SBport, &snd_SBirq, &snd_SBdma, 0); if (retval) { - sprintf(tmp,"SB isn't responding at p=%03xh, i=%d, d=%d, retval=%d\n", snd_SBport, snd_SBirq, snd_SBdma, retval); - tprintf(tmp,0); + sprintf(tmp, "SB isn't responding at p=%03xh, i=%d, d=%d, retval=%d\n", snd_SBport, snd_SBirq, snd_SBdma, retval); + tprintf(tmp, 0); } else { SB_SetCard(snd_SBport, snd_SBirq, snd_SBdma); } - if(debugmode) + if (debugmode) { - sprintf(tmp,"SB_Detect returned p=%03xh,i=%d,d=%d,retval=%d\n", snd_SBport, snd_SBirq, snd_SBdma, retval); - tprintf(tmp,0); + sprintf(tmp, "SB_Detect returned p=%03xh,i=%d,d=%d,retval=%d\n", snd_SBport, snd_SBirq, snd_SBdma, retval); + tprintf(tmp, 0); } } if (adlib) { - retval = AL_Detect(&wait,0); + retval = AL_Detect(&wait, 0); if (retval) { sprintf(tmp, "Dude. The Adlib isn't responding retval=%d.\n", retval); - tprintf(tmp,1); + tprintf(tmp, 1); } else { @@ -328,15 +328,15 @@ void I_sndArbitrateCards (void) { if (debugmode) { - sprintf(tmp,"cfg p=%03xh\n", snd_Mport); - tprintf(tmp,0); + sprintf(tmp, "cfg p=%03xh\n", snd_Mport); + tprintf(tmp, 0); } retval = MPU_Detect(&snd_Mport, &i); if (retval) { - sprintf(tmp,"The MPU-401 isn't reponding @ p=%03xh, retval=%d.\n", snd_Mport, retval); - tprintf(tmp,0); + sprintf(tmp, "The MPU-401 isn't reponding @ p=%03xh, retval=%d.\n", snd_Mport, retval); + tprintf(tmp, 0); } else { @@ -352,7 +352,7 @@ void I_StartupSound (void) int rc, i; if (debugmode) - tprintf("I_StartupSound: Hope you hear a pop.\n",1); + tprintf("I_StartupSound: Hope you hear a pop.\n", 1); dmxCodes[0] = 0; dmxCodes[snd_PC] = AHW_PC_SPEAKER; @@ -371,20 +371,20 @@ void I_StartupSound (void) if (debugmode) { - sprintf(tmp," Music device #%d & dmxCode=%d\n", snd_MusicDevice, dmxCodes[snd_MusicDevice]); - tprintf(tmp,0); - sprintf(tmp," Sfx device #%d & dmxCode=%d\n", snd_SfxDevice, dmxCodes[snd_SfxDevice]); - tprintf(tmp,0); + sprintf(tmp, " Music device #%d & dmxCode=%d\n", snd_MusicDevice, dmxCodes[snd_MusicDevice]); + tprintf(tmp, 0); + sprintf(tmp, " Sfx device #%d & dmxCode=%d\n", snd_SfxDevice, dmxCodes[snd_SfxDevice]); + tprintf(tmp, 0); } - tprintf(" calling DMX_Init\n",0); + tprintf(" calling DMX_Init\n", 0); rc = DMX_Init(SND_TICRATE, SND_MAXSONGS, dmxCodes[snd_MusicDevice], - dmxCodes[snd_SfxDevice]); + dmxCodes[snd_SfxDevice]); if (debugmode) { - sprintf(tmp," DMX_Init() returned %d\n", rc); - tprintf(tmp,0); + sprintf(tmp, " DMX_Init() returned %d\n", rc); + tprintf(tmp, 0); } } diff --git a/MN_MENU.C b/MN_MENU.C index bc7de95..4515b10 100644 --- a/MN_MENU.C +++ b/MN_MENU.C @@ -123,8 +123,8 @@ boolean askforquit; boolean typeofask; static boolean FileMenuKeySteal; static boolean slottextloaded; -static char SlotText[6][SLOTTEXTLEN+2]; -static char oldSlotText[SLOTTEXTLEN+2]; +static char SlotText[6][SLOTTEXTLEN + 2]; +static char oldSlotText[SLOTTEXTLEN + 2]; static int SlotStatus[6]; static int slotptr; static int currentSlot; @@ -303,7 +303,7 @@ void MN_Init(void) MenuActive = false; messageson = true; SkullBaseLump = W_GetNumForName("M_SKL00"); - if(ExtendedWAD) + if (ExtendedWAD) { // Add episodes 4 and 5 to the menu EpisodeMenu.itemCount = 5; EpisodeMenu.y -= ITEM_HEIGHT; @@ -318,8 +318,8 @@ void MN_Init(void) static void InitFonts(void) { - FontABaseLump = W_GetNumForName("FONTA_S")+1; - FontBBaseLump = W_GetNumForName("FONTB_S")+1; + FontABaseLump = W_GetNumForName("FONTA_S") + 1; + FontBBaseLump = W_GetNumForName("FONTB_S") + 1; } //--------------------------------------------------------------------------- @@ -335,17 +335,17 @@ void MN_DrTextA(char *text, int x, int y) char c; patch_t *p; - while((c = *text++) != 0) + while ((c = *text++) != 0) { - if(c < 33) + if (c < 33) { x += 5; } else { - p = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE); + p = W_CacheLumpNum(FontABaseLump + c - 33, PU_CACHE); V_DrawPatch(x, y, p); - x += p->width-1; + x += p->width - 1; } } } @@ -365,16 +365,16 @@ int MN_TextAWidth(char *text) patch_t *p; width = 0; - while((c = *text++) != 0) + while ((c = *text++) != 0) { - if(c < 33) + if (c < 33) { width += 5; } else { - p = W_CacheLumpNum(FontABaseLump+c-33, PU_CACHE); - width += p->width-1; + p = W_CacheLumpNum(FontABaseLump + c - 33, PU_CACHE); + width += p->width - 1; } } return(width); @@ -393,17 +393,17 @@ void MN_DrTextB(char *text, int x, int y) char c; patch_t *p; - while((c = *text++) != 0) + while ((c = *text++) != 0) { - if(c < 33) + if (c < 33) { x += 8; } else { - p = W_CacheLumpNum(FontBBaseLump+c-33, PU_CACHE); + p = W_CacheLumpNum(FontBBaseLump + c - 33, PU_CACHE); V_DrawPatch(x, y, p); - x += p->width-1; + x += p->width - 1; } } } @@ -423,16 +423,16 @@ int MN_TextBWidth(char *text) patch_t *p; width = 0; - while((c = *text++) != 0) + while ((c = *text++) != 0) { - if(c < 33) + if (c < 33) { width += 5; } else { - p = W_CacheLumpNum(FontBBaseLump+c-33, PU_CACHE); - width += p->width-1; + p = W_CacheLumpNum(FontBBaseLump + c - 33, PU_CACHE); + width += p->width - 1; } } return(width); @@ -446,7 +446,7 @@ int MN_TextBWidth(char *text) void MN_Ticker(void) { - if(MenuActive == false) + if (MenuActive == false) { return; } @@ -476,25 +476,25 @@ void MN_Drawer(void) MenuItem_t *item; char *selName; - if(MenuActive == false) + if (MenuActive == false) { - if(askforquit) + if (askforquit) { - MN_DrTextA(QuitEndMsg[typeofask-1], 160- - MN_TextAWidth(QuitEndMsg[typeofask-1])/2, 80); - if(typeofask == 3) + MN_DrTextA(QuitEndMsg[typeofask - 1], 160 - + MN_TextAWidth(QuitEndMsg[typeofask - 1]) / 2, 80); + if (typeofask == 3) { - MN_DrTextA(SlotText[quicksave-1], 160- - MN_TextAWidth(SlotText[quicksave-1])/2, 90); - MN_DrTextA("?", 160+ - MN_TextAWidth(SlotText[quicksave-1])/2, 90); + MN_DrTextA(SlotText[quicksave - 1], 160 - + MN_TextAWidth(SlotText[quicksave - 1]) / 2, 90); + MN_DrTextA("?", 160 + + MN_TextAWidth(SlotText[quicksave - 1]) / 2, 90); } - if(typeofask == 4) + if (typeofask == 4) { - MN_DrTextA(SlotText[quickload-1], 160- - MN_TextAWidth(SlotText[quickload-1])/2, 90); - MN_DrTextA("?", 160+ - MN_TextAWidth(SlotText[quickload-1])/2, 90); + MN_DrTextA(SlotText[quickload - 1], 160 - + MN_TextAWidth(SlotText[quickload - 1]) / 2, 90); + MN_DrTextA("?", 160 + + MN_TextAWidth(SlotText[quickload - 1]) / 2, 90); } UpdateState |= I_FULLSCRN; } @@ -503,34 +503,34 @@ void MN_Drawer(void) else { UpdateState |= I_FULLSCRN; - if(InfoType) + if (InfoType) { MN_DrawInfo(); return; } - if(screenblocks < 10) + if (screenblocks < 10) { BorderNeedRefresh = true; } - if(CurrentMenu->drawFunc != NULL) + if (CurrentMenu->drawFunc != NULL) { CurrentMenu->drawFunc(); } x = CurrentMenu->x; y = CurrentMenu->y; item = CurrentMenu->items; - for(i = 0; i < CurrentMenu->itemCount; i++) + for (i = 0; i < CurrentMenu->itemCount; i++) { - if(item->type != ITT_EMPTY && item->text) + if (item->type != ITT_EMPTY && item->text) { MN_DrTextB(DEH_String(item->text), x, y); // FS: For HHE } y += ITEM_HEIGHT; item++; } - y = CurrentMenu->y+(CurrentItPos*ITEM_HEIGHT)+SELECTOR_YOFFSET; - selName = MenuTime&16 ? "M_SLCTR1" : "M_SLCTR2"; - V_DrawPatch(x+SELECTOR_XOFFSET, y, + y = CurrentMenu->y + (CurrentItPos * ITEM_HEIGHT) + SELECTOR_YOFFSET; + selName = MenuTime & 16 ? "M_SLCTR1" : "M_SLCTR2"; + V_DrawPatch(x + SELECTOR_XOFFSET, y, W_CacheLumpName(selName, PU_CACHE)); } } @@ -545,11 +545,11 @@ static void DrawMainMenu(void) { int frame; - frame = (MenuTime/3)%18; + frame = (MenuTime / 3) % 18; V_DrawPatch(88, 0, W_CacheLumpName("M_HTIC", PU_CACHE)); - V_DrawPatch(40, 10, W_CacheLumpNum(SkullBaseLump+(17-frame), + V_DrawPatch(40, 10, W_CacheLumpNum(SkullBaseLump + (17 - frame), PU_CACHE)); - V_DrawPatch(232, 10, W_CacheLumpNum(SkullBaseLump+frame, PU_CACHE)); + V_DrawPatch(232, 10, W_CacheLumpNum(SkullBaseLump + frame, PU_CACHE)); } //--------------------------------------------------------------------------- @@ -580,7 +580,7 @@ static void DrawSkillMenu(void) static void DrawFilesMenu(void) { -// clear out the quicksave/quickload stuff + // clear out the quicksave/quickload stuff quicksave = 0; quickload = 0; players[consoleplayer].message = NULL; @@ -595,8 +595,8 @@ static void DrawFilesMenu(void) static void DrawLoadMenu(void) { - MN_DrTextB("LOAD GAME", 160-MN_TextBWidth("LOAD GAME")/2, 10); - if(!slottextloaded) + MN_DrTextB("LOAD GAME", 160 - MN_TextBWidth("LOAD GAME") / 2, 10); + if (!slottextloaded) { MN_LoadSlotText(); } @@ -611,8 +611,8 @@ static void DrawLoadMenu(void) static void DrawSaveMenu(void) { - MN_DrTextB("SAVE GAME", 160-MN_TextBWidth("SAVE GAME")/2, 10); - if(!slottextloaded) + MN_DrTextB("SAVE GAME", 160 - MN_TextBWidth("SAVE GAME") / 2, 10); + if (!slottextloaded) { MN_LoadSlotText(); } @@ -635,7 +635,7 @@ void MN_LoadSlotText(void) for (i = 0; i < 6; i++) { - if(cdrom) + if (cdrom) { sprintf(name, SAVEGAMENAMECD"%d.hsg", i); } @@ -671,12 +671,12 @@ static void DrawFileSlots(Menu_t *menu) x = menu->x; y = menu->y; - for(i = 0; i < 6; i++) + for (i = 0; i < 6; i++) { V_DrawPatch(x, y, W_CacheLumpName("M_FSLOT", PU_CACHE)); - if(SlotStatus[i]) + if (SlotStatus[i]) { - MN_DrTextA(SlotText[i], x+5, y+5); + MN_DrTextA(SlotText[i], x + 5, y + 5); } y += ITEM_HEIGHT; } @@ -693,7 +693,7 @@ static void DrawOptionsMenu(void) extern boolean usePalFlash; extern int headBob; - if(messageson) + if (messageson) { MN_DrTextB("ON", 196, 35); } @@ -702,7 +702,7 @@ static void DrawOptionsMenu(void) MN_DrTextB("OFF", 196, 35); } - if(usePalFlash) // FS: Draw Pal Flash + if (usePalFlash) // FS: Draw Pal Flash { MN_DrTextB("ON", 240, 55); } @@ -711,7 +711,7 @@ static void DrawOptionsMenu(void) MN_DrTextB("OFF", 240, 55); } - if(headBob) // FS: Headbob Toggle + if (headBob) // FS: Headbob Toggle { MN_DrTextB("ON", 188, 75); } @@ -720,7 +720,7 @@ static void DrawOptionsMenu(void) MN_DrTextB("OFF", 188, 75); } - DrawSlider(&OptionsMenu, 5, 10, mouseSensitivity/5); // FS: We using 20 now and was 3,10, etc.. + DrawSlider(&OptionsMenu, 5, 10, mouseSensitivity / 5); // FS: We using 20 now and was 3,10, etc.. } //--------------------------------------------------------------------------- @@ -731,7 +731,7 @@ static void DrawOptionsMenu(void) static void DrawOptions2Menu(void) { - DrawSlider(&Options2Menu, 1, 9, screenblocks-3); + DrawSlider(&Options2Menu, 1, 9, screenblocks - 3); DrawSlider(&Options2Menu, 3, 16, snd_MaxVolume); DrawSlider(&Options2Menu, 5, 16, snd_MusicVolume); } @@ -744,17 +744,17 @@ static void DrawOptions2Menu(void) static boolean SCNetCheck(int option) { - - if(!netgame) + + if (!netgame) { // okay to go into the menu return true; } - - - if(NetGetPlayerCount() == 1) + + + if (NetGetPlayerCount() == 1) return true; - - switch(option) + + switch (option) { case 1: P_SetMessage(&players[consoleplayer], @@ -782,7 +782,7 @@ static boolean SCQuitGame(int option) MenuActive = false; askforquit = true; typeofask = 1; //quit game - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -805,14 +805,14 @@ static boolean M_DeleteSaveResponse(int ch) // FS: Ask if we want to delete the static boolean SCEndGame(int option) { - if(demoplayback || netgame) + if (demoplayback || netgame) { return false; } MenuActive = false; askforquit = true; typeofask = 2; //endgame - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -828,7 +828,7 @@ static boolean SCEndGame(int option) static boolean SCMessages(int option) { messageson ^= 1; - if(messageson) + if (messageson) { P_SetMessage(&players[consoleplayer], DEH_String("MESSAGES ON"), true); } @@ -844,7 +844,7 @@ static boolean SCPalFlashes(int option) // FS: Palette Flashes Toggle { extern boolean usePalFlash; usePalFlash ^= 1; - if(usePalFlash) + if (usePalFlash) { P_SetMessage(&players[consoleplayer], "PALETTE FLASHES ON", true); } @@ -860,7 +860,7 @@ static boolean SCHeadBob(int option) // FS: Headbob Toggle { extern int headBob; headBob ^= 1; - if(headBob) + if (headBob) { P_SetMessage(&players[consoleplayer], "HEADBOBBING ON", true); } @@ -882,11 +882,11 @@ static boolean SCLoadGame(int option) { char name[256]; - if(!SlotStatus[option]) + if (!SlotStatus[option]) { // slot's empty...don't try and load return false; } - if(cdrom) + if (cdrom) { sprintf(name, SAVEGAMENAMECD"%d.hsg", option); } @@ -898,9 +898,9 @@ static boolean SCLoadGame(int option) G_LoadGame(name); MN_DeactivateMenu(); BorderNeedRefresh = true; - if(quickload == -1) + if (quickload == -1) { - quickload = option+1; + quickload = option + 1; players[consoleplayer].message = NULL; players[consoleplayer].messageTics = 1; } @@ -917,20 +917,20 @@ static boolean SCSaveGame(int option) { char *ptr; - if(!FileMenuKeySteal) + if (!FileMenuKeySteal) { FileMenuKeySteal = true; strcpy(oldSlotText, SlotText[option]); ptr = SlotText[option]; - while(*ptr) + while (*ptr) { ptr++; } *ptr = '['; - *(ptr+1) = 0; + *(ptr + 1) = 0; SlotStatus[option]++; currentSlot = option; - slotptr = ptr-SlotText[option]; + slotptr = ptr - SlotText[option]; return false; } else @@ -941,9 +941,9 @@ static boolean SCSaveGame(int option) MN_DeactivateMenu(); } BorderNeedRefresh = true; - if(quicksave == -1) + if (quicksave == -1) { - quicksave = option+1; + quicksave = option + 1; players[consoleplayer].message = NULL; players[consoleplayer].messageTics = 1; } @@ -958,7 +958,7 @@ static boolean SCSaveGame(int option) static boolean SCEpisode(int option) { - if(shareware && option > 1) + if (shareware && option > 1) { P_SetMessage(&players[consoleplayer], "ONLY AVAILABLE IN THE REGISTERED VERSION", true); @@ -992,14 +992,14 @@ static boolean SCSkill(int option) static boolean SCMouseSensi(int option) { - if(option == RIGHT_DIR) + if (option == RIGHT_DIR) { - if(mouseSensitivity < 50) // FS: Go up to 50 + if (mouseSensitivity < 50) // FS: Go up to 50 { mouseSensitivity++; } } - else if(mouseSensitivity) + else if (mouseSensitivity) { mouseSensitivity--; } @@ -1014,14 +1014,14 @@ static boolean SCMouseSensi(int option) static boolean SCSfxVolume(int option) { - if(option == RIGHT_DIR) + if (option == RIGHT_DIR) { - if(snd_MaxVolume < 15) + if (snd_MaxVolume < 15) { snd_MaxVolume++; } } - else if(snd_MaxVolume) + else if (snd_MaxVolume) { snd_MaxVolume--; } @@ -1038,14 +1038,14 @@ static boolean SCSfxVolume(int option) static boolean SCMusicVolume(int option) { - if(option == RIGHT_DIR) + if (option == RIGHT_DIR) { - if(snd_MusicVolume < 15) + if (snd_MusicVolume < 15) { snd_MusicVolume++; } } - else if(snd_MusicVolume) + else if (snd_MusicVolume) { snd_MusicVolume--; } @@ -1061,14 +1061,14 @@ static boolean SCMusicVolume(int option) static boolean SCScreenSize(int option) { - if(option == RIGHT_DIR) + if (option == RIGHT_DIR) { - if(screenblocks < 11) + if (screenblocks < 11) { screenblocks++; } } - else if(screenblocks > 3) + else if (screenblocks > 3) { screenblocks--; } @@ -1086,7 +1086,7 @@ static boolean SCInfo(int option) { InfoType = 1; S_StartSound(NULL, sfx_dorcls); - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -1125,30 +1125,30 @@ boolean MN_Responder(event_t *event) char tempstring[80]; // FS #endif - if(event->data1 == KEY_RSHIFT) + if (event->data1 == KEY_RSHIFT) { shiftdown = (event->type == ev_keydown); } - if(event->type != ev_keydown) + if (event->type != ev_keydown) { return(false); } key = event->data1; - if(InfoType) + if (InfoType) { - if(shareware) + if (shareware) { - InfoType = (InfoType+1)%5; + InfoType = (InfoType + 1) % 5; } else { - InfoType = (InfoType+1)%4; + InfoType = (InfoType + 1) % 4; } - if(key == KEY_ESCAPE) + if (key == KEY_ESCAPE) { InfoType = 0; } - if(!InfoType) + if (!InfoType) { paused = false; MN_DeactivateMenu(); @@ -1159,21 +1159,21 @@ boolean MN_Responder(event_t *event) return(true); //make the info screen eat the keypress } - if(ravpic && key == KEY_F1) + if (ravpic && key == KEY_F1) { G_ScreenShot(); return(true); } - if(askforquit) + if (askforquit) { - switch(key) + switch (key) { case KEY_ENTER: // FS: Wanted the option case 'y': - if(askforquit) + if (askforquit) { - switch(typeofask) + switch (typeofask) { case 1: G_CheckDemoStatus(); @@ -1181,7 +1181,7 @@ boolean MN_Responder(event_t *event) break; case 2: players[consoleplayer].messageTics = 0; - //set the msg to be cleared + //set the msg to be cleared players[consoleplayer].message = NULL; typeofask = 0; askforquit = false; @@ -1192,23 +1192,23 @@ boolean MN_Responder(event_t *event) case 3: P_SetMessage(&players[consoleplayer], "QUICKSAVING....", false); FileMenuKeySteal = true; - SCSaveGame(quicksave-1); + SCSaveGame(quicksave - 1); askforquit = false; typeofask = 0; BorderNeedRefresh = true; return true; case 4: P_SetMessage(&players[consoleplayer], "QUICKLOADING....", false); - SCLoadGame(quickload-1); + SCLoadGame(quickload - 1); askforquit = false; typeofask = 0; BorderNeedRefresh = true; return true; case 5: // FS: Delete saves - sprintf(savename,SAVEGAMENAME"%d.hsg",saveOn); + sprintf(savename, SAVEGAMENAME"%d.hsg", saveOn); remove(savename); - S_StartSound(NULL,sfx_dorcls); - for (z = 0; z < SLOTTEXTLEN+2; z++) + S_StartSound(NULL, sfx_dorcls); + for (z = 0; z < SLOTTEXTLEN + 2; z++) { SlotText[saveOn][z] = 0; // empty the string oldSlotText[z] = 0; @@ -1228,7 +1228,7 @@ boolean MN_Responder(event_t *event) return false; case 'n': case KEY_ESCAPE: - if(askforquit) + if (askforquit) { players[consoleplayer].messageTics = 1; //set the msg to be cleared askforquit = false; @@ -1242,50 +1242,50 @@ boolean MN_Responder(event_t *event) } return false; // don't let the keys filter thru } - if(MenuActive == false && !chatmodeon) + if (MenuActive == false && !chatmodeon) { - switch(key) + switch (key) { #ifdef USE_VRGOGGLES case KEY_INS: - if(usevrgoggles) + if (usevrgoggles) { vrdist = FixedMul(vrdist, 72090);//vrdist + 72090; - if(vrdist >295000) + if (vrdist > 295000) vrdist = 29500; - printf(tempstring,"VR DIST INCR %1.1f\n", ((float)vrdist/(float)65536)); -// P_SetMessage(&players[consoleplayer], tempstring, false); + printf(tempstring, "VR DIST INCR %1.1f\n", ((float)vrdist / (float)65536)); + // P_SetMessage(&players[consoleplayer], tempstring, false); } break; case KEY_DEL: - if(usevrgoggles) + if (usevrgoggles) { vrdist = FixedMul(vrdist, 59758);//vrdist - 59578; - if (vrdist<20000) - vrdist=20000; - printf(tempstring,"VR DIST DECR %1.1f\n", ((float)vrdist/(float)65536)); -// P_SetMessage(&players[consoleplayer], tempstring, false); + if (vrdist < 20000) + vrdist = 20000; + printf(tempstring, "VR DIST DECR %1.1f\n", ((float)vrdist / (float)65536)); + // P_SetMessage(&players[consoleplayer], tempstring, false); } break; case KEY_PGUP: - if(usevrgoggles) + if (usevrgoggles) { vrangle = vrangle + 1; - printf(tempstring,"VR ANG INCR %d\n", vrangle); -// P_SetMessage(&players[consoleplayer], tempstring, false); + printf(tempstring, "VR ANG INCR %d\n", vrangle); + // P_SetMessage(&players[consoleplayer], tempstring, false); } break; case KEY_PGDN: - if(usevrgoggles) + if (usevrgoggles) { vrangle = vrangle - 1; - printf(tempstring,"VR ANG DECR %d\n", vrangle); -// P_SetMessage(&players[consoleplayer], tempstring, false); + printf(tempstring, "VR ANG DECR %d\n", vrangle); + // P_SetMessage(&players[consoleplayer], tempstring, false); } break; #endif case KEY_MINUS: - if(automapactive) + if (automapactive) { // Don't screen size in automap return(false); } @@ -1295,7 +1295,7 @@ boolean MN_Responder(event_t *event) UpdateState |= I_FULLSCRN; return(true); case KEY_EQUALS: - if(automapactive) + if (automapactive) { // Don't screen size in automap return(false); } @@ -1310,14 +1310,14 @@ boolean MN_Responder(event_t *event) MenuActive = true; return(true); case KEY_F2: // save game - if(gamestate == GS_LEVEL && !demoplayback) + if (gamestate == GS_LEVEL && !demoplayback) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &SaveMenu; CurrentItPos = CurrentMenu->oldItPos; - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -1326,14 +1326,14 @@ boolean MN_Responder(event_t *event) } return true; case KEY_F3: // load game - if(SCNetCheck(2)) + if (SCNetCheck(2)) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &LoadMenu; CurrentItPos = CurrentMenu->oldItPos; - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -1347,7 +1347,7 @@ boolean MN_Responder(event_t *event) MenuTime = 0; CurrentMenu = &Options2Menu; CurrentItPos = CurrentMenu->oldItPos; - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -1355,7 +1355,7 @@ boolean MN_Responder(event_t *event) slottextloaded = false; //reload the slot text, when needed return true; case KEY_F5: // F5 isn't used in Heretic. (detail level) - if(usePalFlash == true) + if (usePalFlash == true) { P_SetMessage(&players[consoleplayer], "PALETTE FLASHES OFF", false); usePalFlash = false; @@ -1369,16 +1369,16 @@ boolean MN_Responder(event_t *event) } return true; case KEY_F6: // quicksave - if(gamestate == GS_LEVEL && !demoplayback) + if (gamestate == GS_LEVEL && !demoplayback) { - if(!quicksave || quicksave == -1) + if (!quicksave || quicksave == -1) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &SaveMenu; CurrentItPos = CurrentMenu->oldItPos; - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -1392,7 +1392,7 @@ boolean MN_Responder(event_t *event) { askforquit = true; typeofask = 3; - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -1401,7 +1401,7 @@ boolean MN_Responder(event_t *event) } return true; case KEY_F7: // endgame - if(gamestate == GS_LEVEL && !demoplayback) + if (gamestate == GS_LEVEL && !demoplayback) { S_StartSound(NULL, sfx_chat); SCEndGame(0); @@ -1411,14 +1411,14 @@ boolean MN_Responder(event_t *event) SCMessages(0); return true; case KEY_F9: // quickload - if(!quickload || quickload == -1) + if (!quickload || quickload == -1) { MenuActive = true; FileMenuKeySteal = false; MenuTime = 0; CurrentMenu = &LoadMenu; CurrentItPos = CurrentMenu->oldItPos; - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -1431,7 +1431,7 @@ boolean MN_Responder(event_t *event) else { askforquit = true; - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -1441,40 +1441,40 @@ boolean MN_Responder(event_t *event) return true; case KEY_F10: // quit // if(gamestate == GS_LEVEL) // FS: Quit with F10 at title screen like Doom - { - SCQuitGame(0); - S_StartSound(NULL, sfx_chat); - } - return true; + { + SCQuitGame(0); + S_StartSound(NULL, sfx_chat); + } + return true; case KEY_F11: // F11 - gamma mode correction usegamma++; - if((usegamma > 4) || (usegamma < 0)) + if ((usegamma > 4) || (usegamma < 0)) { usegamma = 0; } I_SetPalette((byte *)W_CacheLumpName("PLAYPAL", PU_CACHE)); - switch(usegamma) // FS: Could be smart but it's 2AM. I'm lazy, and you won't ever play this version. + switch (usegamma) // FS: Could be smart but it's 2AM. I'm lazy, and you won't ever play this version. { case 0: - P_SetMessage(&players[consoleplayer],"GAMMA CORRECTION OFF", false); + P_SetMessage(&players[consoleplayer], "GAMMA CORRECTION OFF", false); break; case 1: - P_SetMessage(&players[consoleplayer],"GAMMA CORRECTION LEVEL 1", false); + P_SetMessage(&players[consoleplayer], "GAMMA CORRECTION LEVEL 1", false); break; case 2: - P_SetMessage(&players[consoleplayer],"GAMMA CORRECTION LEVEL 2", false); + P_SetMessage(&players[consoleplayer], "GAMMA CORRECTION LEVEL 2", false); break; case 3: - P_SetMessage(&players[consoleplayer],"GAMMA CORRECTION LEVEL 3", false); + P_SetMessage(&players[consoleplayer], "GAMMA CORRECTION LEVEL 3", false); break; case 4: - P_SetMessage(&players[consoleplayer],"GAMMA CORRECTION LEVEL 4", false); + P_SetMessage(&players[consoleplayer], "GAMMA CORRECTION LEVEL 4", false); break; } return true; case KEY_F12: /* FS: Always run toggle */ - if(alwaysrun) + if (alwaysrun) { P_SetMessage(&players[consoleplayer], "ALWAYS RUN OFF", false); alwaysrun = 0; @@ -1490,37 +1490,37 @@ boolean MN_Responder(event_t *event) } - if(MenuActive == false) + if (MenuActive == false) { - if(key == KEY_ESCAPE || gamestate == GS_DEMOSCREEN || demoplayback) + if (key == KEY_ESCAPE || gamestate == GS_DEMOSCREEN || demoplayback) { MN_ActivateMenu(); return(true); } return(false); } - if(!FileMenuKeySteal) + if (!FileMenuKeySteal) { item = &CurrentMenu->items[CurrentItPos]; - switch(key) + switch (key) { - case (0x80+0x53): // FS: KEY_DEL + case (0x80 + 0x53): // FS: KEY_DEL // FS: Ask us if we want to delete the current save - if(CurrentMenu == &LoadMenu || CurrentMenu == &SaveMenu) + if (CurrentMenu == &LoadMenu || CurrentMenu == &SaveMenu) { - sprintf(savename,SAVEGAMENAME"%d.hsg",item->option); + sprintf(savename, SAVEGAMENAME"%d.hsg", item->option); saveOn = item->option; - if(!access(savename,0)) + if (!access(savename, 0)) { M_DeleteSaveResponse(0); } } - return true; + return true; break; case KEY_DOWNARROW: do { - if(CurrentItPos+1 > CurrentMenu->itemCount-1) + if (CurrentItPos + 1 > CurrentMenu->itemCount - 1) { CurrentItPos = 0; } @@ -1528,27 +1528,27 @@ boolean MN_Responder(event_t *event) { CurrentItPos++; } - } while(CurrentMenu->items[CurrentItPos].type == ITT_EMPTY); + } while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY); S_StartSound(NULL, sfx_switch); return(true); break; case KEY_UPARROW: do { - if(CurrentItPos == 0) + if (CurrentItPos == 0) { - CurrentItPos = CurrentMenu->itemCount-1; + CurrentItPos = CurrentMenu->itemCount - 1; } else { CurrentItPos--; } - } while(CurrentMenu->items[CurrentItPos].type == ITT_EMPTY); + } while (CurrentMenu->items[CurrentItPos].type == ITT_EMPTY); S_StartSound(NULL, sfx_switch); return(true); break; case KEY_LEFTARROW: - if(item->type == ITT_LRFUNC && item->func != NULL) + if (item->type == ITT_LRFUNC && item->func != NULL) { item->func(LEFT_DIR); S_StartSound(NULL, sfx_keyup); @@ -1556,7 +1556,7 @@ boolean MN_Responder(event_t *event) return(true); break; case KEY_RIGHTARROW: - if(item->type == ITT_LRFUNC && item->func != NULL) + if (item->type == ITT_LRFUNC && item->func != NULL) { item->func(RIGHT_DIR); S_StartSound(NULL, sfx_keyup); @@ -1564,22 +1564,22 @@ boolean MN_Responder(event_t *event) return(true); break; case KEY_ENTER: - if(item->type == ITT_SETMENU) + if (item->type == ITT_SETMENU) { SetMenu(item->menu); } - else if(item->func != NULL) + else if (item->func != NULL) { CurrentMenu->oldItPos = CurrentItPos; - if(item->type == ITT_LRFUNC) + if (item->type == ITT_LRFUNC) { item->func(RIGHT_DIR); } - else if(item->type == ITT_EFUNC) + else if (item->type == ITT_EFUNC) { - if(item->func(item->option)) + if (item->func(item->option)) { - if(item->menu != MENU_NONE) + if (item->menu != MENU_NONE) { SetMenu(item->menu); } @@ -1594,7 +1594,7 @@ boolean MN_Responder(event_t *event) return(true); case KEY_BACKSPACE: S_StartSound(NULL, sfx_switch); - if(CurrentMenu->prevMenu == MENU_NONE) + if (CurrentMenu->prevMenu == MENU_NONE) { MN_DeactivateMenu(); } @@ -1604,11 +1604,11 @@ boolean MN_Responder(event_t *event) } return(true); default: - for(i = 0; i < CurrentMenu->itemCount; i++) + for (i = 0; i < CurrentMenu->itemCount; i++) { - if(CurrentMenu->items[i].text) + if (CurrentMenu->items[i].text) { - if(toupper(key) + if (toupper(key) == toupper(CurrentMenu->items[i].text[0])) { CurrentItPos = i; @@ -1623,9 +1623,9 @@ boolean MN_Responder(event_t *event) else { // Editing file names textBuffer = &SlotText[currentSlot][slotptr]; - if(key == KEY_BACKSPACE) + if (key == KEY_BACKSPACE) { - if(slotptr) + if (slotptr) { *textBuffer-- = 0; *textBuffer = ASCII_CURSOR; @@ -1633,39 +1633,39 @@ boolean MN_Responder(event_t *event) } return(true); } - if(key == KEY_ESCAPE) + if (key == KEY_ESCAPE) { - memset(SlotText[currentSlot], 0, SLOTTEXTLEN+2); + memset(SlotText[currentSlot], 0, SLOTTEXTLEN + 2); strcpy(SlotText[currentSlot], oldSlotText); SlotStatus[currentSlot]--; MN_DeactivateMenu(); return(true); } - if(key == KEY_ENTER) + if (key == KEY_ENTER) { SlotText[currentSlot][slotptr] = 0; // clear the cursor item = &CurrentMenu->items[CurrentItPos]; CurrentMenu->oldItPos = CurrentItPos; - if(item->type == ITT_EFUNC) + if (item->type == ITT_EFUNC) { item->func(item->option); - if(item->menu != MENU_NONE) + if (item->menu != MENU_NONE) { SetMenu(item->menu); } } return(true); } - if(slotptr < SLOTTEXTLEN && key != KEY_BACKSPACE) + if (slotptr < SLOTTEXTLEN && key != KEY_BACKSPACE) { - if((key >= 'a' && key <= 'z')) + if ((key >= 'a' && key <= 'z')) { - *textBuffer++ = key-32; + *textBuffer++ = key - 32; *textBuffer = ASCII_CURSOR; slotptr++; return(true); } - if(((key >= '0' && key <= '9') || key == ' ' + if (((key >= '0' && key <= '9') || key == ' ' || key == ',' || key == '.' || key == '-') && !shiftdown) { @@ -1674,7 +1674,7 @@ boolean MN_Responder(event_t *event) slotptr++; return(true); } - if(shiftdown && key == '1') + if (shiftdown && key == '1') { *textBuffer++ = '!'; *textBuffer = ASCII_CURSOR; @@ -1695,11 +1695,11 @@ boolean MN_Responder(event_t *event) void MN_ActivateMenu(void) { - if(MenuActive) + if (MenuActive) { return; } - if(paused) + if (paused) { S_ResumeSound(); } @@ -1708,7 +1708,7 @@ void MN_ActivateMenu(void) MenuTime = 0; CurrentMenu = &MainMenu; CurrentItPos = CurrentMenu->oldItPos; - if(!netgame && !demoplayback) + if (!netgame && !demoplayback) { paused = true; } @@ -1726,12 +1726,12 @@ void MN_DeactivateMenu(void) { CurrentMenu->oldItPos = CurrentItPos; MenuActive = false; - if(!netgame) + if (!netgame) { paused = false; } S_StartSound(NULL, sfx_dorcls); - if(soundchanged) + if (soundchanged) { S_SetMaxVolume(true); //recalc the sound curve soundchanged = false; @@ -1749,10 +1749,10 @@ void MN_DeactivateMenu(void) void MN_DrawInfo(void) { I_SetPalette(W_CacheLumpName("PLAYPAL", PU_CACHE)); - memcpy(screen, (byte *)W_CacheLumpNum(W_GetNumForName("TITLE")+InfoType, - PU_CACHE), SCREENWIDTH*SCREENHEIGHT); -// V_DrawPatch(0, 0, W_CacheLumpNum(W_GetNumForName("TITLE")+InfoType, -// PU_CACHE)); + memcpy(screen, (byte *)W_CacheLumpNum(W_GetNumForName("TITLE") + InfoType, + PU_CACHE), SCREENWIDTH * SCREENHEIGHT); + // V_DrawPatch(0, 0, W_CacheLumpNum(W_GetNumForName("TITLE")+InfoType, + // PU_CACHE)); } @@ -1782,14 +1782,14 @@ static void DrawSlider(Menu_t *menu, int item, int width, int slot) int x2; int count; - x = menu->x+24; - y = menu->y+2+(item*ITEM_HEIGHT); - V_DrawPatch(x-32, y, W_CacheLumpName("M_SLDLT", PU_CACHE)); - for(x2 = x, count = width; count--; x2 += 8) + x = menu->x + 24; + y = menu->y + 2 + (item * ITEM_HEIGHT); + V_DrawPatch(x - 32, y, W_CacheLumpName("M_SLDLT", PU_CACHE)); + for (x2 = x, count = width; count--; x2 += 8) { - V_DrawPatch(x2, y, W_CacheLumpName(count&1 ? "M_SLDMD1" + V_DrawPatch(x2, y, W_CacheLumpName(count & 1 ? "M_SLDMD1" : "M_SLDMD2", PU_CACHE)); } V_DrawPatch(x2, y, W_CacheLumpName("M_SLDRT", PU_CACHE)); - V_DrawPatch(x+4+slot*8, y+7, W_CacheLumpName("M_SLDKB", PU_CACHE)); + V_DrawPatch(x + 4 + slot * 8, y + 7, W_CacheLumpName("M_SLDKB", PU_CACHE)); } diff --git a/M_MISC.C b/M_MISC.C index eb01797..c7fe321 100644 --- a/M_MISC.C +++ b/M_MISC.C @@ -29,41 +29,41 @@ char **myargv; boolean M_ValidEpisodeMap(int episode, int map) { - if(episode < 1 || map < 1 || map > 9) + if (episode < 1 || map < 1 || map > 9) { return false; } - if(shareware) + if (shareware) { // Shareware version checks - if(episode != 1) + if (episode != 1) { return false; } } - else if(ExtendedWAD) + else if (ExtendedWAD) { // Extended version checks - if(episode == 6) + if (episode == 6) { - if(map > 3) + if (map > 3) { return false; } } - else if(episode > 5) + else if (episode > 5) { return false; } } else { // Registered version checks - if(episode == 4) + if (episode == 4) { - if(map != 1) + if (map != 1) { return false; } } - else if(episode > 3) + else if (episode > 3) { return false; } @@ -87,9 +87,9 @@ int M_CheckParm (char *check) { int i; - for (i = 1;ibox[BOXRIGHT]) + else if (x > box[BOXRIGHT]) box[BOXRIGHT] = x; - if (ybox[BOXTOP]) + else if (y > box[BOXTOP]) box[BOXTOP] = y; } @@ -211,12 +211,12 @@ int M_ReadFile (char const *name, byte **buffer) { int handle, count, length; struct stat fileinfo; - byte *buf; + byte *buf; handle = open (name, O_RDONLY | O_BINARY, 0666); if (handle == -1) I_Error ("Couldn't read file %s", name); - if (fstat (handle,&fileinfo) == -1) + if (fstat (handle, &fileinfo) == -1) I_Error ("Couldn't read file %s", name); length = fileinfo.st_size; buf = Z_Malloc (length, PU_STATIC, NULL); @@ -242,9 +242,9 @@ void M_FindResponseFile(void) { int i; - for(i = 1; i < myargc; i++) + for (i = 1; i < myargc; i++) { - if(myargv[i][0] == '@') + if (myargv[i][0] == '@') { FILE *handle; int size; @@ -258,53 +258,53 @@ void M_FindResponseFile(void) // READ THE RESPONSE FILE INTO MEMORY handle = fopen(&myargv[i][1], "rb"); - if(!handle) + if (!handle) { printf("\nNo such response file!"); exit(1); } - printf("Found response file %s!\n",&myargv[i][1]); - fseek (handle,0,SEEK_END); + printf("Found response file %s!\n", &myargv[i][1]); + fseek (handle, 0, SEEK_END); size = ftell(handle); - fseek (handle,0,SEEK_SET); + fseek (handle, 0, SEEK_SET); file = malloc (size); - fread (file,size,1,handle); + fread (file, size, 1, handle); fclose (handle); // KEEP ALL CMDLINE ARGS FOLLOWING @RESPONSEFILE ARG - for (index = 0,k = i+1; k < myargc; k++) + 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 = malloc(sizeof(char *) * MAXARGVS); + memset(myargv, 0, sizeof(char *) * MAXARGVS); myargv[0] = firstargv; - + infile = file; indexinfile = k = 0; indexinfile++; // SKIP PAST ARGV[0] (KEEP IT) do { - myargv[indexinfile++] = infile+k; - while(k < size && + myargv[indexinfile++] = infile + k; + while (k < size && - ((*(infile+k)>= ' '+1) && (*(infile+k)<='z'))) + ((*(infile + k) >= ' ' + 1) && (*(infile + k) <= 'z'))) k++; - *(infile+k) = 0; - while(k < size && - ((*(infile+k)<= ' ') || (*(infile+k)>'z'))) + *(infile + k) = 0; + while (k < size && + ((*(infile + k) <= ' ') || (*(infile + k) > 'z'))) k++; - } while(k < size); - - for (k = 0;k < index;k++) + } while (k < size); + + for (k = 0; k < index; k++) myargv[indexinfile++] = moreargs[k]; myargc = indexinfile; // DISPLAY ARGS - if(M_CheckParm("-debug")) + if (M_CheckParm("-debug")) { printf("%d command-line args:\n", myargc); - for(k = 1; k < myargc; k++) + for (k = 1; k < myargc; k++) { printf("%s\n", myargv[k]); } @@ -326,11 +326,11 @@ void M_ForceUppercase(char *text) { char c; - while((c = *text) != 0) + while ((c = *text) != 0) { - if(c >= 'a' && c <= 'z') + if (c >= 'a' && c <= 'z') { - *text++ = c-('a'-'A'); + *text++ = c - ('a' - 'A'); } else { @@ -399,8 +399,8 @@ extern char *chat_macros[10]; typedef struct { - char *name; - int *location; + char *name; + int *location; int defaultvalue; int scantranslate; // PC scan code hack int untranslated; // lousy hack @@ -410,7 +410,7 @@ typedef struct extern int snd_Channels; extern int snd_DesiredMusicDevice, snd_DesiredSfxDevice; extern int snd_MusicDevice, // current music card # (index to dmxCodes) - snd_SfxDevice; // current sfx card # (index to dmxCodes) +snd_SfxDevice; // current sfx card # (index to dmxCodes) extern int snd_SBport, snd_SBirq, snd_SBdma; // sound blaster variables extern int snd_Mport; // midi variables @@ -516,16 +516,16 @@ default_t defaults[] = { "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 }, - { "chatmacro3", (int *) &chat_macros[3], (int) HUSTR_CHATMACRO3 }, - { "chatmacro4", (int *) &chat_macros[4], (int) HUSTR_CHATMACRO4 }, - { "chatmacro5", (int *) &chat_macros[5], (int) HUSTR_CHATMACRO5 }, - { "chatmacro6", (int *) &chat_macros[6], (int) HUSTR_CHATMACRO6 }, - { "chatmacro7", (int *) &chat_macros[7], (int) HUSTR_CHATMACRO7 }, - { "chatmacro8", (int *) &chat_macros[8], (int) HUSTR_CHATMACRO8 }, - { "chatmacro9", (int *) &chat_macros[9], (int) HUSTR_CHATMACRO9 } + { "chatmacro0", (int *)&chat_macros[0], (int)HUSTR_CHATMACRO0 }, + { "chatmacro1", (int *)&chat_macros[1], (int)HUSTR_CHATMACRO1 }, + { "chatmacro2", (int *)&chat_macros[2], (int)HUSTR_CHATMACRO2 }, + { "chatmacro3", (int *)&chat_macros[3], (int)HUSTR_CHATMACRO3 }, + { "chatmacro4", (int *)&chat_macros[4], (int)HUSTR_CHATMACRO4 }, + { "chatmacro5", (int *)&chat_macros[5], (int)HUSTR_CHATMACRO5 }, + { "chatmacro6", (int *)&chat_macros[6], (int)HUSTR_CHATMACRO6 }, + { "chatmacro7", (int *)&chat_macros[7], (int)HUSTR_CHATMACRO7 }, + { "chatmacro8", (int *)&chat_macros[8], (int)HUSTR_CHATMACRO8 }, + { "chatmacro9", (int *)&chat_macros[9], (int)HUSTR_CHATMACRO9 } }; default_t extendeddefaults[] = @@ -544,12 +544,12 @@ default_t extendeddefaults[] = { "wpn_dragon", &wpn_dragon, 45, 1 }, // FS: X { "wpn_hellstaff", &wpn_hellstaff, 46, 1 }, // FS: C { "wpn_phoenix", &wpn_phoenix, 16, 1 }, // FS: Q - + // FS: Use custom artifact binds { "use_artbinds", &use_artbinds, 0 }, { "art_torch", &art_torch, 33, 1 }, // FS: F { "art_flask", &art_flask, 34, 1 }, // FS: G - + { "alwaysrun", &alwaysrun, 1 }, /* FS: SimulEyes VR Goggles stuff */ @@ -571,27 +571,29 @@ char *defaultfile; void M_SaveDefaults (void) { - int i,v; - FILE *f; + int i, v; + FILE *f; f = fopen (defaultfile, "w"); if (!f) return; // can't write the file, but don't complain - for (i=0 ; i -0xfff - && defaults[i].defaultvalue < 0xfff) + && defaults[i].defaultvalue < 0xfff) { v = *defaults[i].location; - fprintf (f,"%s\t\t%i\n",defaults[i].name,v); - } else { - fprintf (f,"%s\t\t\"%s\"\n",defaults[i].name, - * (char **) (defaults[i].location)); + fprintf (f, "%s\t\t%i\n", defaults[i].name, v); + } + else + { + fprintf (f, "%s\t\t\"%s\"\n", defaults[i].name, + *(char **)(defaults[i].location)); } } @@ -600,14 +602,14 @@ void M_SaveDefaults (void) void M_SaveExtendedDefaults (void) { - int i,v; - FILE *f; + int i, v; + FILE *f; f = fopen ("extend.cfg", "w"); if (!f) return; // can't write the file, but don't complain - for (i=0 ; i -0xfff && extendeddefaults[i].defaultvalue < 0xfff) || !strcmp(extendeddefaults[i].name, "vrdist")) /* FS: FIXME HACK: Hack it up, johnny. */ { v = *extendeddefaults[i].location; - fprintf (f,"%s\t\t%i\n",extendeddefaults[i].name,v); + fprintf (f, "%s\t\t%i\n", extendeddefaults[i].name, v); } else { - fprintf (f,"%s\t\t\"%s\"\n",extendeddefaults[i].name, * (char **) (extendeddefaults[i].location)); + fprintf (f, "%s\t\t\"%s\"\n", extendeddefaults[i].name, *(char **)(extendeddefaults[i].location)); } } @@ -641,30 +643,30 @@ extern char *basedefault; void M_LoadDefaults (void) { int i, len; - FILE *f; + FILE *f; char def[80]; char strparm[100]; - char *newstring; + char *newstring; int parm; boolean isstring; -// -// set everything to base values -// - numdefaults = sizeof(defaults)/sizeof(defaults[0]); - for (i=0 ; imanufacturer = 0x0a; // PCX id pcx->version = 5; // 256 color @@ -845,23 +847,23 @@ void WritePCXfile (char *filename, byte *data, int width, int height, byte *pale pcx->bits_per_pixel = 8; // 256 color pcx->xmin = 0; pcx->ymin = 0; - pcx->xmax = SHORT(width-1); - pcx->ymax = SHORT(height-1); + pcx->xmax = SHORT(width - 1); + pcx->ymax = SHORT(height - 1); pcx->hres = SHORT(width); pcx->vres = SHORT(height); - memset (pcx->palette,0,sizeof(pcx->palette)); + memset (pcx->palette, 0, sizeof(pcx->palette)); pcx->color_planes = 1; // chunky image pcx->bytes_per_line = SHORT(width); pcx->palette_type = SHORT(2); // not a grey scale - memset (pcx->filler,0,sizeof(pcx->filler)); + memset (pcx->filler, 0, sizeof(pcx->filler)); -// -// pack the image -// + // + // pack the image + // pack = &pcx->data; - for (i=0 ; idirection) + + switch (ceiling->direction) { case 0: // IN STASIS break; case 1: // UP - res = T_MovePlane(ceiling->sector,ceiling->speed, - ceiling->topheight,false,1,ceiling->direction); - if(!(leveltime&7)) + res = T_MovePlane(ceiling->sector, ceiling->speed, + ceiling->topheight, false, 1, ceiling->direction); + if (!(leveltime & 7)) S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_dormov); if (res == pastdest) - switch(ceiling->type) + switch (ceiling->type) { case raiseToHighest: P_RemoveActiveCeiling(ceiling); @@ -46,12 +46,12 @@ void T_MoveCeiling (ceiling_t *ceiling) } break; case -1: // DOWN - res = T_MovePlane(ceiling->sector,ceiling->speed, - ceiling->bottomheight,ceiling->crush,1,ceiling->direction); - if (!(leveltime&7)) - S_StartSound((mobj_t *)&ceiling->sector->soundorg,sfx_dormov); + res = T_MovePlane(ceiling->sector, ceiling->speed, + ceiling->bottomheight, ceiling->crush, 1, ceiling->direction); + if (!(leveltime & 7)) + S_StartSound((mobj_t *)&ceiling->sector->soundorg, sfx_dormov); if (res == pastdest) - switch(ceiling->type) + switch (ceiling->type) { case crushAndRaise: ceiling->speed = CEILSPEED; @@ -66,16 +66,16 @@ void T_MoveCeiling (ceiling_t *ceiling) break; } else - if (res == crushed) - switch(ceiling->type) - { - case crushAndRaise: - case lowerAndCrush: - ceiling->speed = CEILSPEED / 8; - break; - default: - break; - } + if (res == crushed) + switch (ceiling->type) + { + case crushAndRaise: + case lowerAndCrush: + ceiling->speed = CEILSPEED / 8; + break; + default: + break; + } break; } } @@ -88,17 +88,17 @@ void T_MoveCeiling (ceiling_t *ceiling) //================================================================== int EV_DoCeiling (line_t *line, ceiling_e type) { - int secnum,rtn; - sector_t *sec; - ceiling_t *ceiling; - + int secnum, rtn; + sector_t *sec; + ceiling_t *ceiling; + secnum = -1; rtn = 0; - + // // Reactivate in-stasis ceilings...for certain types. // - switch(type) + switch (type) { case fastCrushAndRaise: case crushAndRaise: @@ -106,13 +106,13 @@ int EV_DoCeiling (line_t *line, ceiling_e type) default: break; } - - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + + while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) { sec = §ors[secnum]; if (sec->specialdata) continue; - + // // new door thinker // @@ -123,12 +123,12 @@ int EV_DoCeiling (line_t *line, ceiling_e type) ceiling->thinker.function = T_MoveCeiling; ceiling->sector = sec; ceiling->crush = false; - switch(type) + switch (type) { case fastCrushAndRaise: ceiling->crush = true; ceiling->topheight = sec->ceilingheight; - ceiling->bottomheight = sec->floorheight + (8*FRACUNIT); + ceiling->bottomheight = sec->floorheight + (8 * FRACUNIT); ceiling->direction = -1; ceiling->speed = CEILSPEED * 2; break; @@ -139,7 +139,7 @@ int EV_DoCeiling (line_t *line, ceiling_e type) case lowerToFloor: ceiling->bottomheight = sec->floorheight; if (type != lowerToFloor) - ceiling->bottomheight += 8*FRACUNIT; + ceiling->bottomheight += 8 * FRACUNIT; ceiling->direction = -1; ceiling->speed = CEILSPEED; break; @@ -149,7 +149,7 @@ int EV_DoCeiling (line_t *line, ceiling_e type) ceiling->speed = CEILSPEED; break; } - + ceiling->tag = sec->tag; ceiling->type = type; P_AddActiveCeiling(ceiling); @@ -165,7 +165,7 @@ int EV_DoCeiling (line_t *line, ceiling_e type) void P_AddActiveCeiling(ceiling_t *c) { int i; - for (i = 0; i < MAXCEILINGS;i++) + for (i = 0; i < MAXCEILINGS; i++) if (activeceilings[i] == NULL) { activeceilings[i] = c; @@ -181,8 +181,8 @@ void P_AddActiveCeiling(ceiling_t *c) void P_RemoveActiveCeiling(ceiling_t *c) { int i; - - for (i = 0;i < MAXCEILINGS;i++) + + for (i = 0; i < MAXCEILINGS; i++) if (activeceilings[i] == c) { activeceilings[i]->sector->specialdata = NULL; @@ -200,8 +200,8 @@ void P_RemoveActiveCeiling(ceiling_t *c) void P_ActivateInStasisCeiling(line_t *line) { int i; - - for (i = 0;i < MAXCEILINGS;i++) + + for (i = 0; i < MAXCEILINGS; i++) if (activeceilings[i] && (activeceilings[i]->tag == line->tag) && (activeceilings[i]->direction == 0)) { @@ -216,13 +216,13 @@ void P_ActivateInStasisCeiling(line_t *line) // Stop a ceiling from crushing! // //================================================================== -int EV_CeilingCrushStop(line_t *line) +int EV_CeilingCrushStop(line_t *line) { int i; int rtn; - + rtn = 0; - for (i = 0;i < MAXCEILINGS;i++) + for (i = 0; i < MAXCEILINGS; i++) if (activeceilings[i] && (activeceilings[i]->tag == line->tag) && (activeceilings[i]->direction != 0)) { diff --git a/P_DOORS.C b/P_DOORS.C index cbae091..83e1a0d 100644 --- a/P_DOORS.C +++ b/P_DOORS.C @@ -22,11 +22,11 @@ void T_VerticalDoor(vldoor_t *door) { result_e res; - switch(door->direction) + switch (door->direction) { case 0: // WAITING - if(!--door->topcountdown) - switch(door->type) + if (!--door->topcountdown) + switch (door->type) { case doornormal: door->direction = -1; // time to go back down @@ -43,9 +43,9 @@ void T_VerticalDoor(vldoor_t *door) } break; case 2: // INITIAL WAIT - if(!--door->topcountdown) + if (!--door->topcountdown) { - switch(door->type) + switch (door->type) { case raiseIn5Mins: door->direction = 1; @@ -61,9 +61,9 @@ void T_VerticalDoor(vldoor_t *door) case -1: // DOWN res = T_MovePlane(door->sector, door->speed, door->sector->floorheight, false, 1, door->direction); - if(res == pastdest) + if (res == pastdest) { - switch(door->type) + switch (door->type) { case doornormal: case doorclose: @@ -74,22 +74,22 @@ void T_VerticalDoor(vldoor_t *door) break; case close30ThenOpen: door->direction = 0; - door->topcountdown = 35*30; + door->topcountdown = 35 * 30; break; default: break; } } - else if(res == crushed) + else if (res == crushed) { - switch(door->type) + switch (door->type) { case doorclose: // DON'T GO BACK UP! break; default: door->direction = 1; S_StartSound((mobj_t *) - &door->sector->soundorg,sfx_doropn); + &door->sector->soundorg, sfx_doropn); break; } } @@ -97,9 +97,9 @@ void T_VerticalDoor(vldoor_t *door) case 1: // UP res = T_MovePlane(door->sector, door->speed, door->topheight, false, 1, door->direction); - if(res == pastdest) + if (res == pastdest) { - switch(door->type) + switch (door->type) { case doornormal: door->direction = 0; // wait at top @@ -136,10 +136,10 @@ int EV_DoDoor(line_t *line, vldoor_e type, fixed_t speed) secnum = -1; retcode = 0; - while((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) + while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) { sec = §ors[secnum]; - if(sec->specialdata) + if (sec->specialdata) { continue; } @@ -150,11 +150,11 @@ int EV_DoDoor(line_t *line, vldoor_e type, fixed_t speed) sec->specialdata = door; door->thinker.function = T_VerticalDoor; door->sector = sec; - switch(type) + switch (type) { case doorclose: door->topheight = P_FindLowestCeilingSurrounding(sec); - door->topheight -= 4*FRACUNIT; + door->topheight -= 4 * FRACUNIT; door->direction = -1; S_StartSound((mobj_t *)&door->sector->soundorg, sfx_doropn); break; @@ -167,8 +167,8 @@ int EV_DoDoor(line_t *line, vldoor_e type, fixed_t speed) case dooropen: door->direction = 1; door->topheight = P_FindLowestCeilingSurrounding(sec); - door->topheight -= 4*FRACUNIT; - if(door->topheight != sec->ceilingheight) + door->topheight -= 4 * FRACUNIT; + if (door->topheight != sec->ceilingheight) { S_StartSound((mobj_t *)&door->sector->soundorg, sfx_doropn); @@ -191,26 +191,26 @@ int EV_DoDoor(line_t *line, vldoor_e type, fixed_t speed) //================================================================== void EV_VerticalDoor(line_t *line, mobj_t *thing) { - player_t *player; + player_t *player; int secnum; - sector_t *sec; - vldoor_t *door; + sector_t *sec; + vldoor_t *door; int side; - + side = 0; // only front sides can be used // // Check for locks // player = thing->player; - switch(line->special) + switch (line->special) { case 26: // Blue Lock case 32: - if(!player) + if (!player) { return; } - if(!player->keys[key_blue]) + if (!player->keys[key_blue]) { P_SetMessage(player, TXT_NEEDBLUEKEY, false); S_StartSound(player->mo, sfx_plroof); // FS: was NULL @@ -219,11 +219,11 @@ void EV_VerticalDoor(line_t *line, mobj_t *thing) break; case 27: // Yellow Lock case 34: - if(!player) + if (!player) { return; } - if(!player->keys[key_yellow]) + if (!player->keys[key_yellow]) { P_SetMessage(player, TXT_NEEDYELLOWKEY, false); S_StartSound(player->mo, sfx_plroof); // FS: was NULL @@ -232,11 +232,11 @@ void EV_VerticalDoor(line_t *line, mobj_t *thing) break; case 28: // Green Lock case 33: - if(!player) + if (!player) { return; } - if(!player->keys[key_green]) + if (!player->keys[key_green]) { P_SetMessage(player, TXT_NEEDGREENKEY, false); S_StartSound(player->mo, sfx_plroof); // FS: was NULL @@ -246,24 +246,24 @@ void EV_VerticalDoor(line_t *line, mobj_t *thing) } // if the sector has an active thinker, use it - sec = sides[line->sidenum[side^1]].sector; - secnum = sec-sectors; - if(sec->specialdata) + sec = sides[line->sidenum[side ^ 1]].sector; + secnum = sec - sectors; + if (sec->specialdata) { door = sec->specialdata; - switch(line->special) + switch (line->special) { case 1: // ONLY FOR "RAISE" DOORS, NOT "OPEN"s case 26: case 27: case 28: - if(door->direction == -1) + if (door->direction == -1) { door->direction = 1; // go back up } else { - if(!thing->player) + if (!thing->player) { // Monsters don't close doors return; } @@ -274,7 +274,7 @@ void EV_VerticalDoor(line_t *line, mobj_t *thing) } // for proper sound - switch(line->special) + switch (line->special) { case 1: // NORMAL DOOR SOUND case 31: @@ -296,7 +296,7 @@ void EV_VerticalDoor(line_t *line, mobj_t *thing) door->thinker.function = T_VerticalDoor; door->sector = sec; door->direction = 1; - switch(line->special) + switch (line->special) { case 1: case 26: @@ -314,12 +314,12 @@ void EV_VerticalDoor(line_t *line, mobj_t *thing) } door->speed = VDOORSPEED; door->topwait = VDOORWAIT; - + // // find the top and bottom of the movement range // door->topheight = P_FindLowestCeilingSurrounding(sec); - door->topheight -= 4*FRACUNIT; + door->topheight -= 4 * FRACUNIT; } //================================================================== @@ -340,7 +340,7 @@ void P_SpawnDoorCloseIn30(sector_t *sec) door->direction = 0; door->type = doornormal; door->speed = VDOORSPEED; - door->topcountdown = 30*35; + door->topcountdown = 30 * 35; } //================================================================== @@ -362,7 +362,7 @@ void P_SpawnDoorRaiseIn5Mins(sector_t *sec, int secnum) door->type = raiseIn5Mins; door->speed = VDOORSPEED; door->topheight = P_FindLowestCeilingSurrounding(sec); - door->topheight -= 4*FRACUNIT; + door->topheight -= 4 * FRACUNIT; door->topwait = VDOORWAIT; - door->topcountdown = 5*60*35; + door->topcountdown = 5 * 60 * 35; } diff --git a/P_ENEMY.C b/P_ENEMY.C index 1079bb2..131c118 100644 --- a/P_ENEMY.C +++ b/P_ENEMY.C @@ -45,7 +45,7 @@ void P_InitMonsters(void) void P_AddBossSpot(fixed_t x, fixed_t y, angle_t angle) { - if(BossSpotCount == MAX_BOSS_SPOTS) + if (BossSpotCount == MAX_BOSS_SPOTS) { I_Error("Too many boss spots."); } @@ -70,26 +70,26 @@ void P_RecursiveSound(sector_t *sec, int soundblocks) sector_t *other; // Wake up all monsters in this sector - if(sec->validcount == validcount && sec->soundtraversed <= soundblocks+1) + if (sec->validcount == validcount && sec->soundtraversed <= soundblocks + 1) { // Already flooded return; } sec->validcount = validcount; - sec->soundtraversed = soundblocks+1; + sec->soundtraversed = soundblocks + 1; sec->soundtarget = soundtarget; - for(i = 0; i < sec->linecount; i++) + for (i = 0; i < sec->linecount; i++) { check = sec->lines[i]; - if(!(check->flags&ML_TWOSIDED)) + if (!(check->flags & ML_TWOSIDED)) { continue; } P_LineOpening(check); - if(openrange <= 0) + if (openrange <= 0) { // Closed door continue; } - if(sides[check->sidenum[0]].sector == sec) + if (sides[check->sidenum[0]].sector == sec) { other = sides[check->sidenum[1]].sector; } @@ -97,9 +97,9 @@ void P_RecursiveSound(sector_t *sec, int soundblocks) { other = sides[check->sidenum[0]].sector; } - if(check->flags&ML_SOUNDBLOCK) + if (check->flags & ML_SOUNDBLOCK) { - if(!soundblocks) + if (!soundblocks) { P_RecursiveSound(other, 1); } @@ -138,25 +138,25 @@ boolean P_CheckMeleeRange(mobj_t *actor) mobj_t *mo; fixed_t dist; - if(!actor->target) + if (!actor->target) { return(false); } mo = actor->target; - dist = P_AproxDistance(mo->x-actor->x, mo->y-actor->y); - if(dist >= MELEERANGE) + dist = P_AproxDistance(mo->x - actor->x, mo->y - actor->y); + if (dist >= MELEERANGE) { return(false); } - if(!P_CheckSight(actor, mo)) + if (!P_CheckSight(actor, mo)) { return(false); } - if(mo->z > actor->z+actor->height) + if (mo->z > actor->z + actor->height) { // Target is higher than the attacker return(false); } - else if(actor->z > mo->z+mo->height) + else if (actor->z > mo->z + mo->height) { // Attacker is higher return(false); } @@ -173,34 +173,34 @@ boolean P_CheckMissileRange(mobj_t *actor) { fixed_t dist; - if(!P_CheckSight(actor, actor->target)) + if (!P_CheckSight(actor, actor->target)) { return(false); } - if(actor->flags&MF_JUSTHIT) + if (actor->flags & MF_JUSTHIT) { // The target just hit the enemy, so fight back! actor->flags &= ~MF_JUSTHIT; return(true); } - if(actor->reactiontime) + if (actor->reactiontime) { // Don't attack yet return(false); } - dist = (P_AproxDistance(actor->x-actor->target->x, - actor->y-actor->target->y)>>FRACBITS)-64; - if(!actor->info->meleestate) + dist = (P_AproxDistance(actor->x - actor->target->x, + actor->y - actor->target->y) >> FRACBITS) - 64; + if (!actor->info->meleestate) { // No melee attack, so fire more frequently dist -= 128; } - if(actor->type == MT_IMP) + if (actor->type == MT_IMP) { // Imp's fly attack from far away dist >>= 1; } - if(dist > 200) + if (dist > 200) { dist = 200; } - if(P_Random() < dist) + if (P_Random() < dist) { return(false); } @@ -217,11 +217,11 @@ boolean P_CheckMissileRange(mobj_t *actor) ================ */ -fixed_t xspeed[8] = {FRACUNIT,47000,0,-47000,-FRACUNIT,-47000,0,47000}; -fixed_t yspeed[8] = {0,47000,FRACUNIT,47000,0,-47000,-FRACUNIT,-47000}; +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 line_t *spechit[MAXSPECIALCROSS]; extern int numspechit; boolean P_Move(mobj_t *actor) @@ -230,17 +230,17 @@ boolean P_Move(mobj_t *actor) line_t *ld; boolean good; - if(actor->movedir == DI_NODIR) + if (actor->movedir == DI_NODIR) { return(false); } - tryx = actor->x+actor->info->speed*xspeed[actor->movedir]; - tryy = actor->y+actor->info->speed*yspeed[actor->movedir]; - if(!P_TryMove(actor, tryx, tryy)) + tryx = actor->x + actor->info->speed * xspeed[actor->movedir]; + tryy = actor->y + actor->info->speed * yspeed[actor->movedir]; + if (!P_TryMove(actor, tryx, tryy)) { // open any specials - if(actor->flags&MF_FLOAT && floatok) + if (actor->flags & MF_FLOAT && floatok) { // must adjust height - if(actor->z < tmfloorz) + if (actor->z < tmfloorz) { actor->z += FLOATSPEED; } @@ -251,17 +251,17 @@ boolean P_Move(mobj_t *actor) actor->flags |= MF_INFLOAT; return(true); } - if(!numspechit) + if (!numspechit) { return false; } actor->movedir = DI_NODIR; good = false; - while(numspechit--) + while (numspechit--) { ld = spechit[numspechit]; // if the special isn't a door that can be opened, return false - if(P_UseSpecialLine(actor, ld)) + if (P_UseSpecialLine(actor, ld)) { good = true; } @@ -272,9 +272,9 @@ boolean P_Move(mobj_t *actor) { actor->flags &= ~MF_INFLOAT; } - if(!(actor->flags&MF_FLOAT)) + if (!(actor->flags & MF_FLOAT)) { - if(actor->z > actor->floorz) + if (actor->z > actor->floorz) { P_HitFloor(actor); } @@ -296,11 +296,11 @@ boolean P_Move(mobj_t *actor) boolean P_TryWalk(mobj_t *actor) { - if(!P_Move(actor)) + if (!P_Move(actor)) { return(false); } - actor->movecount = P_Random()&15; + actor->movecount = P_Random() & 15; return(true); } @@ -313,111 +313,111 @@ boolean P_TryWalk(mobj_t *actor) */ dirtype_t opposite[] = -{DI_WEST, DI_SOUTHWEST, DI_SOUTH, DI_SOUTHEAST, DI_EAST, DI_NORTHEAST, -DI_NORTH, DI_NORTHWEST, DI_NODIR}; +{ 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}; +dirtype_t diags[] = { DI_NORTHWEST,DI_NORTHEAST,DI_SOUTHWEST,DI_SOUTHEAST }; void P_NewChaseDir (mobj_t *actor) { - fixed_t deltax,deltay; + fixed_t deltax, deltay; dirtype_t d[3]; dirtype_t tdir, olddir, turnaround; if (!actor->target) I_Error ("P_NewChaseDir: called with no target"); - + olddir = actor->movedir; - turnaround=opposite[olddir]; + 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; + 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; + 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; + d[2] = DI_NODIR; -// try direct route + // try direct route if (d[1] != DI_NODIR && d[2] != DI_NODIR) { - actor->movedir = diags[((deltay<0)<<1)+(deltax>0)]; + actor->movedir = diags[((deltay < 0) << 1) + (deltax > 0)]; if (actor->movedir != turnaround && P_TryWalk(actor)) return; } -// try other directions - if (P_Random() > 200 || abs(deltay)>abs(deltax)) + // try other directions + if (P_Random() > 200 || abs(deltay) > abs(deltax)) { - tdir=d[1]; - d[1]=d[2]; - d[2]=tdir; + tdir = d[1]; + 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) + 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; /*either moved forward or attacked*/ } - if (d[2]!=DI_NODIR) + if (d[2] != DI_NODIR) { - actor->movedir =d[2]; + actor->movedir = d[2]; if (P_TryWalk(actor)) return; } -/* there is no direct path to the player, so pick another direction */ + /* there is no direct path to the player, so pick another direction */ - if (olddir!=DI_NODIR) + if (olddir != DI_NODIR) { - actor->movedir =olddir; + actor->movedir = olddir; if (P_TryWalk(actor)) return; } - if (P_Random()&1) /*randomly determine direction of search*/ + if (P_Random() & 1) /*randomly determine direction of search*/ { - for (tdir=DI_EAST ; tdir<=DI_SOUTHEAST ; tdir++) + for (tdir = DI_EAST; tdir <= DI_SOUTHEAST; tdir++) { - if (tdir!=turnaround) + if (tdir != turnaround) { - actor->movedir =tdir; - if ( P_TryWalk(actor) ) + actor->movedir = tdir; + if (P_TryWalk(actor)) return; } } } else { - for (tdir=DI_SOUTHEAST ; tdir >= DI_EAST;tdir--) + for (tdir = DI_SOUTHEAST; tdir >= DI_EAST; tdir--) { - if (tdir!=turnaround) + if (tdir != turnaround) { - actor->movedir =tdir; - if ( P_TryWalk(actor) ) - return; + actor->movedir = tdir; + if (P_TryWalk(actor)) + return; } } } - if (turnaround != DI_NODIR) + if (turnaround != DI_NODIR) { - actor->movedir =turnaround; - if ( P_TryWalk(actor) ) + actor->movedir = turnaround; + if (P_TryWalk(actor)) return; } @@ -439,36 +439,36 @@ boolean P_LookForMonsters(mobj_t *actor) mobj_t *mo; thinker_t *think; - if(!P_CheckSight(players[0].mo, actor)) + if (!P_CheckSight(players[0].mo, actor)) { // Player can't see monster return(false); } count = 0; - for(think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thinkercap.next; think != &thinkercap; think = think->next) { - if(think->function != P_MobjThinker) + if (think->function != P_MobjThinker) { // Not a mobj thinker continue; } mo = (mobj_t *)think; - if(!(mo->flags&MF_COUNTKILL) || (mo == actor) || (mo->health <= 0)) + if (!(mo->flags & MF_COUNTKILL) || (mo == actor) || (mo->health <= 0)) { // Not a valid monster continue; } - if(P_AproxDistance(actor->x-mo->x, actor->y-mo->y) + if (P_AproxDistance(actor->x - mo->x, actor->y - mo->y) > MONS_LOOK_RANGE) { // Out of range continue; } - if(P_Random() < 16) + if (P_Random() < 16) { // Skip continue; } - if(count++ > MONS_LOOK_LIMIT) + if (count++ > MONS_LOOK_LIMIT) { // Stop searching return(false); } - if(!P_CheckSight(actor, mo)) + if (!P_CheckSight(actor, mo)) { // Out of sight continue; } @@ -498,18 +498,18 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround) angle_t an; fixed_t dist; - if(!netgame && players[0].health <= 0) + if (!netgame && players[0].health <= 0) { // Single player game and player is dead, look for monsters return(P_LookForMonsters(actor)); } sector = actor->subsector->sector; c = 0; - stop = (actor->lastlook-1)&3; - for( ; ; actor->lastlook = (actor->lastlook+1)&3 ) + 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; // done looking @@ -518,11 +518,11 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround) continue; // dead if (!P_CheckSight (actor, player->mo)) continue; // out of sight - + if (!allaround) { - an = R_PointToAngle2 (actor->x, actor->y, - player->mo->x, player->mo->y) - actor->angle; + an = R_PointToAngle2 (actor->x, actor->y, + player->mo->x, player->mo->y) - actor->angle; if (an > ANG90 && an < ANG270) { dist = P_AproxDistance (player->mo->x - actor->x, @@ -532,16 +532,16 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround) continue; // behind back } } - if(player->mo->flags&MF_SHADOW) + if (player->mo->flags & MF_SHADOW) { // Player is invisible - if((P_AproxDistance(player->mo->x-actor->x, - player->mo->y-actor->y) > 2*MELEERANGE) + if ((P_AproxDistance(player->mo->x - actor->x, + player->mo->y - actor->y) > 2 * MELEERANGE) && P_AproxDistance(player->mo->momx, player->mo->momy) - < 5*FRACUNIT) + < 5 * FRACUNIT) { // Player is sneaking - can't detect return(false); } - if(P_Random() < 225) + if (P_Random() < 225) { // Player isn't sneaking, but still didn't detect return(false); } @@ -572,14 +572,14 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround) void A_Look (mobj_t *actor) { - mobj_t *targ; - + mobj_t *targ; + actor->threshold = 0; // any shot will wake up targ = actor->subsector->sector->soundtarget; - if (targ && (targ->flags & MF_SHOOTABLE) ) + if (targ && (targ->flags & MF_SHOOTABLE)) { actor->target = targ; - if ( actor->flags & MF_AMBUSH ) + if (actor->flags & MF_AMBUSH) { if (P_CheckSight (actor, actor->target)) goto seeyou; @@ -587,36 +587,36 @@ void A_Look (mobj_t *actor) else goto seeyou; } - - - if (!P_LookForPlayers (actor, false) ) + + + if (!P_LookForPlayers (actor, false)) return; - -// go into chase state + + // go into chase state seeyou: if (actor->info->seesound) { int sound; - -/* - switch (actor->info->seesound) - { - case sfx_posit1: - case sfx_posit2: - 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; - } -*/ + + /* + switch (actor->info->seesound) + { + case sfx_posit1: + case sfx_posit2: + 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; + } + */ sound = actor->info->seesound; - if(actor->flags2&MF2_BOSS) + if (actor->flags2 & MF2_BOSS) { // Full volume S_StartSound(NULL, sound); } @@ -643,67 +643,67 @@ void A_Chase(mobj_t *actor) { int delta; - if(actor->reactiontime) + if (actor->reactiontime) { actor->reactiontime--; } // Modify target threshold - if(actor->threshold) + if (actor->threshold) { actor->threshold--; } - if(gameskill == sk_nightmare) + if (gameskill == sk_nightmare) { // Monsters move faster in nightmare mode - actor->tics -= actor->tics/2; - if(actor->tics < 3) + actor->tics -= actor->tics / 2; + if (actor->tics < 3) { actor->tics = 3; } } -// -// turn towards movement direction if not there yet -// - if(actor->movedir < 8) + // + // turn towards movement direction if not there yet + // + if (actor->movedir < 8) { - actor->angle &= (7<<29); - delta = actor->angle-(actor->movedir << 29); - if(delta > 0) + actor->angle &= (7 << 29); + delta = actor->angle - (actor->movedir << 29); + if (delta > 0) { - actor->angle -= ANG90/2; + actor->angle -= ANG90 / 2; } - else if(delta < 0) + else if (delta < 0) { - actor->angle += ANG90/2; + actor->angle += ANG90 / 2; } } - if(!actor->target || !(actor->target->flags&MF_SHOOTABLE)) + if (!actor->target || !(actor->target->flags & MF_SHOOTABLE)) { // look for a new target - if(P_LookForPlayers(actor, true)) + if (P_LookForPlayers(actor, true)) { // got a new target return; } P_SetMobjState(actor, actor->info->spawnstate); return; } - -// -// don't attack twice in a row -// - if(actor->flags & MF_JUSTATTACKED) + + // + // don't attack twice in a row + // + if (actor->flags & MF_JUSTATTACKED) { actor->flags &= ~MF_JUSTATTACKED; if (gameskill != sk_nightmare) P_NewChaseDir (actor); return; } - -// -// check for melee attack -// + + // + // check for melee attack + // if (actor->info->meleestate && P_CheckMeleeRange (actor)) { if (actor->info->attacksound) @@ -712,9 +712,9 @@ void A_Chase(mobj_t *actor) return; } -// -// check for missile attack -// + // + // check for missile attack + // if (actor->info->missilestate) { if (gameskill < sk_nightmare && actor->movecount) @@ -727,33 +727,33 @@ void A_Chase(mobj_t *actor) } nomissile: -// -// possibly choose another target -// - if (netgame && !actor->threshold && !P_CheckSight (actor, actor->target) ) + // + // possibly choose another target + // + if (netgame && !actor->threshold && !P_CheckSight (actor, actor->target)) { - if (P_LookForPlayers(actor,true)) + if (P_LookForPlayers(actor, true)) return; // got a new target } - -// -// chase towards player -// - if (--actor->movecount<0 || !P_Move (actor)) + + // + // chase towards player + // + if (--actor->movecount < 0 || !P_Move (actor)) { P_NewChaseDir (actor); } -// -// make active sound -// - if(actor->info->activesound && P_Random() < 3) + // + // make active sound + // + if (actor->info->activesound && P_Random() < 3) { - if(actor->type == MT_WIZARD && P_Random() < 128) + if (actor->type == MT_WIZARD && P_Random() < 128) { S_StartSound(actor, actor->info->seesound); } - else if(actor->type == MT_SORCERER2) + else if (actor->type == MT_SORCERER2) { S_StartSound(NULL, actor->info->activesound); } @@ -772,16 +772,16 @@ nomissile: void A_FaceTarget(mobj_t *actor) { - if(!actor->target) + 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) + if (actor->target->flags & MF_SHADOW) { // Target is a ghost - actor->angle += (P_Random()-P_Random())<<21; + actor->angle += (P_Random() - P_Random()) << 21; } } @@ -793,7 +793,7 @@ void A_FaceTarget(mobj_t *actor) void A_Pain(mobj_t *actor) { - if(actor->info->painsound) + if (actor->info->painsound) { S_StartSound(actor, actor->info->painsound); } @@ -809,10 +809,10 @@ void A_DripBlood(mobj_t *actor) { mobj_t *mo; - mo = P_SpawnMobj(actor->x+((P_Random()-P_Random())<<11), - actor->y+((P_Random()-P_Random())<<11), actor->z, MT_BLOOD); - mo->momx = (P_Random()-P_Random())<<10; - mo->momy = (P_Random()-P_Random())<<10; + mo = P_SpawnMobj(actor->x + ((P_Random() - P_Random()) << 11), + actor->y + ((P_Random() - P_Random()) << 11), actor->z, MT_BLOOD); + mo->momx = (P_Random() - P_Random()) << 10; + mo->momy = (P_Random() - P_Random()) << 10; mo->flags2 |= MF2_LOGRAV; } @@ -824,11 +824,11 @@ void A_DripBlood(mobj_t *actor) void A_KnightAttack(mobj_t *actor) { - if(!actor->target) + if (!actor->target) { return; } - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(actor->target, actor, actor, HITDICE(3)); S_StartSound(actor, sfx_kgtat2); @@ -836,7 +836,7 @@ void A_KnightAttack(mobj_t *actor) } // Throw axe S_StartSound(actor, actor->info->attacksound); - if(actor->type == MT_KNIGHTGHOST || P_Random() < 40) + if (actor->type == MT_KNIGHTGHOST || P_Random() < 40) { // Red axe P_SpawnMissile(actor, actor->target, MT_REDAXE); return; @@ -856,14 +856,14 @@ void A_ImpExplode(mobj_t *actor) mobj_t *mo; mo = P_SpawnMobj(actor->x, actor->y, actor->z, MT_IMPCHUNK1); - mo->momx = (P_Random() - P_Random ())<<10; - mo->momy = (P_Random() - P_Random ())<<10; - mo->momz = 9*FRACUNIT; + mo->momx = (P_Random() - P_Random ()) << 10; + mo->momy = (P_Random() - P_Random ()) << 10; + mo->momz = 9 * FRACUNIT; mo = P_SpawnMobj(actor->x, actor->y, actor->z, MT_IMPCHUNK2); - mo->momx = (P_Random() - P_Random ())<<10; - mo->momy = (P_Random() - P_Random ())<<10; - mo->momz = 9*FRACUNIT; - if(actor->special1 == 666) + mo->momx = (P_Random() - P_Random ()) << 10; + mo->momy = (P_Random() - P_Random ()) << 10; + mo->momz = 9 * FRACUNIT; + if (actor->special1 == 666) { // Extreme death crash P_SetMobjState(actor, S_IMP_XCRASH1); } @@ -877,11 +877,11 @@ void A_ImpExplode(mobj_t *actor) void A_BeastPuff(mobj_t *actor) { - if(P_Random() > 64) + if (P_Random() > 64) { - P_SpawnMobj(actor->x+((P_Random()-P_Random())<<10), - actor->y+((P_Random()-P_Random())<<10), - actor->z+((P_Random()-P_Random())<<10), MT_PUFFY); + P_SpawnMobj(actor->x + ((P_Random() - P_Random()) << 10), + actor->y + ((P_Random() - P_Random()) << 10), + actor->z + ((P_Random() - P_Random()) << 10), MT_PUFFY); } } @@ -893,14 +893,14 @@ void A_BeastPuff(mobj_t *actor) void A_ImpMeAttack(mobj_t *actor) { - if(!actor->target) + if (!actor->target) { return; } S_StartSound(actor, actor->info->attacksound); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { - P_DamageMobj(actor->target, actor, actor, 5+(P_Random()&7)); + P_DamageMobj(actor->target, actor, actor, 5 + (P_Random() & 7)); } } @@ -916,7 +916,7 @@ void A_ImpMsAttack(mobj_t *actor) angle_t an; int dist; - if(!actor->target || P_Random() > 64) + if (!actor->target || P_Random() > 64) { P_SetMobjState(actor, actor->info->seestate); return; @@ -926,15 +926,15 @@ void A_ImpMsAttack(mobj_t *actor) S_StartSound(actor, actor->info->attacksound); A_FaceTarget(actor); an = actor->angle >> ANGLETOFINESHIFT; - actor->momx = FixedMul(12*FRACUNIT, finecosine[an]); - actor->momy = FixedMul(12*FRACUNIT, finesine[an]); - dist = P_AproxDistance(dest->x-actor->x, dest->y-actor->y); - dist = dist/(12*FRACUNIT); - if(dist < 1) + actor->momx = FixedMul(12 * FRACUNIT, finecosine[an]); + actor->momy = FixedMul(12 * FRACUNIT, finesine[an]); + dist = P_AproxDistance(dest->x - actor->x, dest->y - actor->y); + dist = dist / (12 * FRACUNIT); + if (dist < 1) { dist = 1; } - actor->momz = (dest->z+(dest->height>>1)-actor->z)/dist; + actor->momz = (dest->z + (dest->height >> 1) - actor->z) / dist; } //---------------------------------------------------------------------------- @@ -947,14 +947,14 @@ void A_ImpMsAttack(mobj_t *actor) void A_ImpMsAttack2(mobj_t *actor) { - if(!actor->target) + if (!actor->target) { return; } S_StartSound(actor, actor->info->attacksound); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { - P_DamageMobj(actor->target, actor, actor, 5+(P_Random()&7)); + P_DamageMobj(actor->target, actor, actor, 5 + (P_Random() & 7)); return; } P_SpawnMissile(actor, actor->target, MT_IMPBALL); @@ -970,7 +970,7 @@ void A_ImpDeath(mobj_t *actor) { actor->flags &= ~MF_SOLID; actor->flags2 |= MF2_FOOTCLIP; - if(actor->z <= actor->floorz) + if (actor->z <= actor->floorz) { P_SetMobjState(actor, S_IMP_CRASH1); } @@ -999,7 +999,7 @@ void A_ImpXDeath1(mobj_t *actor) void A_ImpXDeath2(mobj_t *actor) { actor->flags &= ~MF_NOGRAVITY; - if(actor->z <= actor->floorz) + if (actor->z <= actor->floorz) { P_SetMobjState(actor, S_IMP_CRASH1); } @@ -1024,7 +1024,7 @@ boolean P_UpdateChicken(mobj_t *actor, int tics) mobj_t oldChicken; actor->special1 -= tics; - if(actor->special1 > 0) + if (actor->special1 > 0) { return(false); } @@ -1035,7 +1035,7 @@ boolean P_UpdateChicken(mobj_t *actor, int tics) oldChicken = *actor; P_SetMobjState(actor, S_FREETARGMOBJ); mo = P_SpawnMobj(x, y, z, moType); - if(P_TestMobjLocation(mo) == false) + if (P_TestMobjLocation(mo) == false) { // Didn't fit P_RemoveMobj(mo); mo = P_SpawnMobj(x, y, z, MT_CHICKEN); @@ -1043,13 +1043,13 @@ boolean P_UpdateChicken(mobj_t *actor, int tics) mo->flags = oldChicken.flags; mo->health = oldChicken.health; mo->target = oldChicken.target; - mo->special1 = 5*35; // Next try in 5 seconds + mo->special1 = 5 * 35; // Next try in 5 seconds mo->special2 = moType; return(false); } mo->angle = oldChicken.angle; mo->target = oldChicken.target; - fog = P_SpawnMobj(x, y, z+TELEFOGHEIGHT, MT_TFOG); + fog = P_SpawnMobj(x, y, z + TELEFOGHEIGHT, MT_TFOG); S_StartSound(fog, sfx_telept); return(true); } @@ -1062,17 +1062,17 @@ boolean P_UpdateChicken(mobj_t *actor, int tics) void A_ChicAttack(mobj_t *actor) { - if(P_UpdateChicken(actor, 18)) + if (P_UpdateChicken(actor, 18)) { return; } - if(!actor->target) + if (!actor->target) { return; } - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { - P_DamageMobj(actor->target, actor, actor, 1+(P_Random()&1)); + P_DamageMobj(actor->target, actor, actor, 1 + (P_Random() & 1)); } } @@ -1084,7 +1084,7 @@ void A_ChicAttack(mobj_t *actor) void A_ChicLook(mobj_t *actor) { - if(P_UpdateChicken(actor, 10)) + if (P_UpdateChicken(actor, 10)) { return; } @@ -1099,7 +1099,7 @@ void A_ChicLook(mobj_t *actor) void A_ChicChase(mobj_t *actor) { - if(P_UpdateChicken(actor, 3)) + if (P_UpdateChicken(actor, 3)) { return; } @@ -1114,7 +1114,7 @@ void A_ChicChase(mobj_t *actor) void A_ChicPain(mobj_t *actor) { - if(P_UpdateChicken(actor, 10)) + if (P_UpdateChicken(actor, 10)) { return; } @@ -1133,23 +1133,23 @@ void A_Feathers(mobj_t *actor) int count; mobj_t *mo; - if(actor->health > 0) + if (actor->health > 0) { // Pain count = P_Random() < 32 ? 2 : 1; } else { // Death - count = 5+(P_Random()&3); + count = 5 + (P_Random() & 3); } - for(i = 0; i < count; i++) + for (i = 0; i < count; i++) { - mo = P_SpawnMobj(actor->x, actor->y, actor->z+20*FRACUNIT, + mo = P_SpawnMobj(actor->x, actor->y, actor->z + 20 * FRACUNIT, MT_FEATHER); mo->target = actor; - mo->momx = (P_Random()-P_Random())<<8; - mo->momy = (P_Random()-P_Random())<<8; - mo->momz = FRACUNIT+(P_Random()<<9); - P_SetMobjState(mo, S_FEATHER1+(P_Random()&7)); + mo->momx = (P_Random() - P_Random()) << 8; + mo->momy = (P_Random() - P_Random()) << 8; + mo->momz = FRACUNIT + (P_Random() << 9); + P_SetMobjState(mo, S_FEATHER1 + (P_Random() & 7)); } } @@ -1161,12 +1161,12 @@ void A_Feathers(mobj_t *actor) void A_MummyAttack(mobj_t *actor) { - if(!actor->target) + if (!actor->target) { return; } S_StartSound(actor, actor->info->attacksound); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(actor->target, actor, actor, HITDICE(2)); S_StartSound(actor, sfx_mumat2); @@ -1187,19 +1187,19 @@ void A_MummyAttack2(mobj_t *actor) { mobj_t *mo; - if(!actor->target) + if (!actor->target) { return; } //S_StartSound(actor, actor->info->attacksound); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(actor->target, actor, actor, HITDICE(2)); return; } mo = P_SpawnMissile(actor, actor->target, MT_MUMMYFX1); //mo = P_SpawnMissile(actor, actor->target, MT_EGGFX); - if(mo != NULL) + if (mo != NULL) { mo->special1 = (int)actor->target; } @@ -1213,7 +1213,7 @@ void A_MummyAttack2(mobj_t *actor) void A_MummyFX1Seek(mobj_t *actor) { - P_SeekerMissile(actor, ANGLE_1*10, ANGLE_1*20); + P_SeekerMissile(actor, ANGLE_1 * 10, ANGLE_1 * 20); } //---------------------------------------------------------------------------- @@ -1226,7 +1226,7 @@ void A_MummySoul(mobj_t *mummy) { mobj_t *mo; - mo = P_SpawnMobj(mummy->x, mummy->y, mummy->z+10*FRACUNIT, MT_MUMMYSOUL); + mo = P_SpawnMobj(mummy->x, mummy->y, mummy->z + 10 * FRACUNIT, MT_MUMMYSOUL); mo->momz = FRACUNIT; } @@ -1250,7 +1250,7 @@ void A_Sor1Pain(mobj_t *actor) void A_Sor1Chase(mobj_t *actor) { - if(actor->special1) + if (actor->special1) { actor->special1--; actor->tics -= 3; @@ -1272,33 +1272,33 @@ void A_Srcr1Attack(mobj_t *actor) fixed_t momz; angle_t angle; - if(!actor->target) + if (!actor->target) { return; } S_StartSound(actor, actor->info->attacksound); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(actor->target, actor, actor, HITDICE(8)); return; } - if(actor->health > (actor->info->spawnhealth/3)*2) + if (actor->health > (actor->info->spawnhealth / 3) * 2) { // Spit one fireball P_SpawnMissile(actor, actor->target, MT_SRCRFX1); } else { // Spit three fireballs mo = P_SpawnMissile(actor, actor->target, MT_SRCRFX1); - if(mo) + if (mo) { momz = mo->momz; angle = mo->angle; - P_SpawnMissileAngle(actor, MT_SRCRFX1, angle-ANGLE_1*3, momz); - P_SpawnMissileAngle(actor, MT_SRCRFX1, angle+ANGLE_1*3, momz); + P_SpawnMissileAngle(actor, MT_SRCRFX1, angle - ANGLE_1 * 3, momz); + P_SpawnMissileAngle(actor, MT_SRCRFX1, angle + ANGLE_1 * 3, momz); } - if(actor->health < actor->info->spawnhealth/3) + if (actor->health < actor->info->spawnhealth / 3) { // Maybe attack again - if(actor->special1) + if (actor->special1) { // Just attacked, so don't attack again actor->special1 = 0; } @@ -1344,7 +1344,7 @@ void P_DSparilTeleport(mobj_t *actor) fixed_t prevZ; mobj_t *mo; - if(!BossSpotCount) + if (!BossSpotCount) { // No spots return; } @@ -1352,20 +1352,20 @@ void P_DSparilTeleport(mobj_t *actor) do { i++; - x = BossSpots[i%BossSpotCount].x; - y = BossSpots[i%BossSpotCount].y; - } while(P_AproxDistance(actor->x-x, actor->y-y) < 128*FRACUNIT); + x = BossSpots[i % BossSpotCount].x; + y = BossSpots[i % BossSpotCount].y; + } while (P_AproxDistance(actor->x - x, actor->y - y) < 128 * FRACUNIT); prevX = actor->x; prevY = actor->y; prevZ = actor->z; - if(P_TeleportMove(actor, x, y)) + if (P_TeleportMove(actor, x, y)) { mo = P_SpawnMobj(prevX, prevY, prevZ, MT_SOR2TELEFADE); S_StartSound(mo, sfx_telept); P_SetMobjState(actor, S_SOR2_TELE1); S_StartSound(actor, sfx_telept); actor->z = actor->floorz; - actor->angle = BossSpots[i%BossSpotCount].angle; + actor->angle = BossSpots[i % BossSpotCount].angle; actor->momx = actor->momy = actor->momz = 0; } } @@ -1383,11 +1383,11 @@ void A_Srcr2Decide(mobj_t *actor) 192, 120, 120, 120, 64, 64, 32, 16, 0 }; - if(!BossSpotCount) + if (!BossSpotCount) { // No spots return; } - if(P_Random() < chance[actor->health/(actor->info->spawnhealth/8)]) + if (P_Random() < chance[actor->health / (actor->info->spawnhealth / 8)]) { P_DSparilTeleport(actor); } @@ -1403,23 +1403,23 @@ void A_Srcr2Attack(mobj_t *actor) { int chance; - if(!actor->target) + if (!actor->target) { return; } S_StartSound(NULL, actor->info->attacksound); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(actor->target, actor, actor, HITDICE(20)); return; } - chance = actor->health < actor->info->spawnhealth/2 ? 96 : 48; - if(P_Random() < chance) + chance = actor->health < actor->info->spawnhealth / 2 ? 96 : 48; + if (P_Random() < chance) { // Wizard spawners P_SpawnMissileAngle(actor, MT_SOR2FX2, - actor->angle-ANG45, FRACUNIT/2); + actor->angle - ANG45, FRACUNIT / 2); P_SpawnMissileAngle(actor, MT_SOR2FX2, - actor->angle+ANG45, FRACUNIT/2); + actor->angle + ANG45, FRACUNIT / 2); } else { // Blue bolt @@ -1438,12 +1438,12 @@ void A_BlueSpark(mobj_t *actor) int i; mobj_t *mo; - for(i = 0; i < 2; i++) + for (i = 0; i < 2; i++) { mo = P_SpawnMobj(actor->x, actor->y, actor->z, MT_SOR2FXSPARK); - mo->momx = (P_Random()-P_Random())<<9; - mo->momy = (P_Random()-P_Random())<<9; - mo->momz = FRACUNIT+(P_Random()<<8); + mo->momx = (P_Random() - P_Random()) << 9; + mo->momy = (P_Random() - P_Random()) << 9; + mo->momz = FRACUNIT + (P_Random() << 8); } } @@ -1459,8 +1459,8 @@ void A_GenWizard(mobj_t *actor) mobj_t *fog; mo = P_SpawnMobj(actor->x, actor->y, - actor->z-mobjinfo[MT_WIZARD].height/2, MT_WIZARD); - if(P_TestMobjLocation(mo) == false) + actor->z - mobjinfo[MT_WIZARD].height / 2, MT_WIZARD); + if (P_TestMobjLocation(mo) == false) { // Didn't fit P_RemoveMobj(mo); return; @@ -1492,7 +1492,7 @@ void A_Sor2DthInit(mobj_t *actor) void A_Sor2DthLoop(mobj_t *actor) { - if(--actor->special1) + if (--actor->special1) { // Need to loop P_SetMobjState(actor, S_SOR2_DIE4); } @@ -1504,12 +1504,12 @@ void A_Sor2DthLoop(mobj_t *actor) // //---------------------------------------------------------------------------- -void A_SorZap(mobj_t *actor) {S_StartSound(NULL, sfx_sorzap);} -void A_SorRise(mobj_t *actor) {S_StartSound(NULL, sfx_sorrise);} -void A_SorDSph(mobj_t *actor) {S_StartSound(NULL, sfx_sordsph);} -void A_SorDExp(mobj_t *actor) {S_StartSound(NULL, sfx_sordexp);} -void A_SorDBon(mobj_t *actor) {S_StartSound(NULL, sfx_sordbon);} -void A_SorSightSnd(mobj_t *actor) {S_StartSound(NULL, sfx_sorsit);} +void A_SorZap(mobj_t *actor) { S_StartSound(NULL, sfx_sorzap); } +void A_SorRise(mobj_t *actor) { S_StartSound(NULL, sfx_sorrise); } +void A_SorDSph(mobj_t *actor) { S_StartSound(NULL, sfx_sordsph); } +void A_SorDExp(mobj_t *actor) { S_StartSound(NULL, sfx_sordexp); } +void A_SorDBon(mobj_t *actor) { S_StartSound(NULL, sfx_sordbon); } +void A_SorSightSnd(mobj_t *actor) { S_StartSound(NULL, sfx_sorsit); } //---------------------------------------------------------------------------- // @@ -1523,17 +1523,17 @@ void A_MinotaurAtk1(mobj_t *actor) { player_t *player; - if(!actor->target) + if (!actor->target) { return; } S_StartSound(actor, sfx_stfpow); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(actor->target, actor, actor, HITDICE(4)); - if((player = actor->target->player) != NULL) + if ((player = actor->target->player) != NULL) { // Squish the player - player->deltaviewheight = -16*FRACUNIT; + player->deltaviewheight = -16 * FRACUNIT; } } } @@ -1555,29 +1555,29 @@ void A_MinotaurDecide(mobj_t *actor) int dist; target = actor->target; - if(!target) + if (!target) { return; } S_StartSound(actor, sfx_minsit); - dist = P_AproxDistance(actor->x-target->x, actor->y-target->y); - if(target->z+target->height > actor->z - && target->z+target->height < actor->z+actor->height - && dist < 8*64*FRACUNIT - && dist > 1*64*FRACUNIT + dist = P_AproxDistance(actor->x - target->x, actor->y - target->y); + if (target->z + target->height > actor->z + && target->z + target->height < actor->z + actor->height + && dist < 8 * 64 * FRACUNIT + && dist > 1 * 64 * FRACUNIT && P_Random() < 150) { // Charge attack // Don't call the state function right away P_SetMobjStateNF(actor, S_MNTR_ATK4_1); actor->flags |= MF_SKULLFLY; A_FaceTarget(actor); - angle = actor->angle>>ANGLETOFINESHIFT; + angle = actor->angle >> ANGLETOFINESHIFT; actor->momx = FixedMul(MNTR_CHARGE_SPEED, finecosine[angle]); actor->momy = FixedMul(MNTR_CHARGE_SPEED, finesine[angle]); - actor->special1 = 35/2; // Charge duration + actor->special1 = 35 / 2; // Charge duration } - else if(target->z == target->floorz - && dist < 9*64*FRACUNIT + else if (target->z == target->floorz + && dist < 9 * 64 * FRACUNIT && P_Random() < 220) { // Floor fire attack P_SetMobjState(actor, S_MNTR_ATK3_1); @@ -1601,10 +1601,10 @@ void A_MinotaurCharge(mobj_t *actor) { mobj_t *puff; - if(actor->special1) + if (actor->special1) { puff = P_SpawnMobj(actor->x, actor->y, actor->z, MT_PHOENIXPUFF); - puff->momz = 2*FRACUNIT; + puff->momz = 2 * FRACUNIT; actor->special1--; } else @@ -1628,26 +1628,26 @@ void A_MinotaurAtk2(mobj_t *actor) angle_t angle; fixed_t momz; - if(!actor->target) + if (!actor->target) { return; } S_StartSound(actor, sfx_minat2); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(actor->target, actor, actor, HITDICE(5)); return; } mo = P_SpawnMissile(actor, actor->target, MT_MNTRFX1); - if(mo) + if (mo) { S_StartSound(mo, sfx_minat2); momz = mo->momz; angle = mo->angle; - P_SpawnMissileAngle(actor, MT_MNTRFX1, angle-(ANG45/8), momz); - P_SpawnMissileAngle(actor, MT_MNTRFX1, angle+(ANG45/8), momz); - P_SpawnMissileAngle(actor, MT_MNTRFX1, angle-(ANG45/16), momz); - P_SpawnMissileAngle(actor, MT_MNTRFX1, angle+(ANG45/16), momz); + P_SpawnMissileAngle(actor, MT_MNTRFX1, angle - (ANG45 / 8), momz); + P_SpawnMissileAngle(actor, MT_MNTRFX1, angle + (ANG45 / 8), momz); + P_SpawnMissileAngle(actor, MT_MNTRFX1, angle - (ANG45 / 16), momz); + P_SpawnMissileAngle(actor, MT_MNTRFX1, angle + (ANG45 / 16), momz); } } @@ -1664,27 +1664,27 @@ void A_MinotaurAtk3(mobj_t *actor) mobj_t *mo; player_t *player; - if(!actor->target) + if (!actor->target) { return; } - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(actor->target, actor, actor, HITDICE(5)); - if((player = actor->target->player) != NULL) + if ((player = actor->target->player) != NULL) { // Squish the player - player->deltaviewheight = -16*FRACUNIT; + player->deltaviewheight = -16 * FRACUNIT; } } else { mo = P_SpawnMissile(actor, actor->target, MT_MNTRFX2); - if(mo != NULL) + if (mo != NULL) { S_StartSound(mo, sfx_minat1); } } - if(P_Random() < 192 && actor->special2 == 0) + if (P_Random() < 192 && actor->special2 == 0) { P_SetMobjState(actor, S_MNTR_ATK3_4); actor->special2 = 1; @@ -1702,8 +1702,8 @@ void A_MntrFloorFire(mobj_t *actor) mobj_t *mo; actor->z = actor->floorz; - mo = P_SpawnMobj(actor->x+((P_Random()-P_Random())<<10), - actor->y+((P_Random()-P_Random())<<10), ONFLOORZ, MT_MNTRFX3); + mo = P_SpawnMobj(actor->x + ((P_Random() - P_Random()) << 10), + actor->y + ((P_Random() - P_Random()) << 10), ONFLOORZ, MT_MNTRFX3); mo->target = actor->target; mo->momx = 1; // Force block checking P_CheckMissileSpawn(mo); @@ -1717,12 +1717,12 @@ void A_MntrFloorFire(mobj_t *actor) void A_BeastAttack(mobj_t *actor) { - if(!actor->target) + if (!actor->target) { return; } S_StartSound(actor, actor->info->attacksound); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(actor->target, actor, actor, HITDICE(3)); return; @@ -1754,35 +1754,35 @@ void A_HeadAttack(mobj_t *actor) // Distance threshold = 8 cells target = actor->target; - if(target == NULL) + if (target == NULL) { return; } A_FaceTarget(actor); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(target, actor, actor, HITDICE(6)); return; } - dist = P_AproxDistance(actor->x-target->x, actor->y-target->y) - > 8*64*FRACUNIT; + dist = P_AproxDistance(actor->x - target->x, actor->y - target->y) + > 8 * 64 * FRACUNIT; randAttack = P_Random(); - if(randAttack < atkResolve1[dist]) + if (randAttack < atkResolve1[dist]) { // Ice ball P_SpawnMissile(actor, target, MT_HEADFX1); - S_StartSound(actor, sfx_hedat2); + S_StartSound(actor, sfx_hedat2); } - else if(randAttack < atkResolve2[dist]) + else if (randAttack < atkResolve2[dist]) { // Fire column baseFire = P_SpawnMissile(actor, target, MT_HEADFX3); - if(baseFire != NULL) + if (baseFire != NULL) { P_SetMobjState(baseFire, S_HEADFX3_4); // Don't grow - for(i = 0; i < 5; i++) + for (i = 0; i < 5; i++) { fire = P_SpawnMobj(baseFire->x, baseFire->y, baseFire->z, MT_HEADFX3); - if(i == 0) + if (i == 0) { S_StartSound(actor, sfx_hedat1); } @@ -1792,7 +1792,7 @@ void A_HeadAttack(mobj_t *actor) fire->momy = baseFire->momy; fire->momz = baseFire->momz; fire->damage = 0; - fire->health = (i+1)*2; + fire->health = (i + 1) * 2; P_CheckMissileSpawn(fire); } } @@ -1800,13 +1800,13 @@ void A_HeadAttack(mobj_t *actor) else { // Whirlwind mo = P_SpawnMissile(actor, target, MT_WHIRLWIND); - if(mo != NULL) + if (mo != NULL) { - mo->z -= 32*FRACUNIT; + mo->z -= 32 * FRACUNIT; mo->special1 = (int)target; mo->special2 = 50; // Timer for active sound - mo->health = 20*TICSPERSEC; // Duration - S_StartSound(actor, sfx_hedat3); + mo->health = 20 * TICSPERSEC; // Duration + S_StartSound(actor, sfx_hedat3); } } } @@ -1820,24 +1820,24 @@ void A_HeadAttack(mobj_t *actor) void A_WhirlwindSeek(mobj_t *actor) { actor->health -= 3; - if(actor->health < 0) + if (actor->health < 0) { actor->momx = actor->momy = actor->momz = 0; P_SetMobjState(actor, mobjinfo[actor->type].deathstate); actor->flags &= ~MF_MISSILE; return; } - if((actor->special2 -= 3) < 0) + if ((actor->special2 -= 3) < 0) { - actor->special2 = 58+(P_Random()&31); + actor->special2 = 58 + (P_Random() & 31); S_StartSound(actor, sfx_hedat3); } - if(actor->special1 - && (((mobj_t *)(actor->special1))->flags&MF_SHADOW)) + if (actor->special1 + && (((mobj_t *)(actor->special1))->flags & MF_SHADOW)) { return; } - P_SeekerMissile(actor, ANGLE_1*10, ANGLE_1*30); + P_SeekerMissile(actor, ANGLE_1 * 10, ANGLE_1 * 30); } //---------------------------------------------------------------------------- @@ -1852,16 +1852,16 @@ void A_HeadIceImpact(mobj_t *ice) angle_t angle; mobj_t *shard; - for(i = 0; i < 8; i++) + for (i = 0; i < 8; i++) { shard = P_SpawnMobj(ice->x, ice->y, ice->z, MT_HEADFX2); - angle = i*ANG45; + angle = i * ANG45; shard->target = ice->target; shard->angle = angle; angle >>= ANGLETOFINESHIFT; shard->momx = FixedMul(shard->info->speed, finecosine[angle]); shard->momy = FixedMul(shard->info->speed, finesine[angle]); - shard->momz = -.6*FRACUNIT; + shard->momz = -.6 * FRACUNIT; P_CheckMissileSpawn(shard); } } @@ -1875,8 +1875,8 @@ void A_HeadIceImpact(mobj_t *ice) void A_HeadFireGrow(mobj_t *fire) { fire->health--; - fire->z += 9*FRACUNIT; - if(fire->health == 0) + fire->z += 9 * FRACUNIT; + if (fire->health == 0) { fire->damage = fire->info->damage; P_SetMobjState(fire, S_HEADFX3_4); @@ -1891,7 +1891,7 @@ void A_HeadFireGrow(mobj_t *fire) void A_SnakeAttack(mobj_t *actor) { - if(!actor->target) + if (!actor->target) { P_SetMobjState(actor, S_SNAKE_WALK1); return; @@ -1909,7 +1909,7 @@ void A_SnakeAttack(mobj_t *actor) void A_SnakeAttack2(mobj_t *actor) { - if(!actor->target) + if (!actor->target) { P_SetMobjState(actor, S_SNAKE_WALK1); return; @@ -1929,14 +1929,14 @@ void A_ClinkAttack(mobj_t *actor) { int damage; - if(!actor->target) + if (!actor->target) { return; } S_StartSound(actor, actor->info->attacksound); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { - damage = ((P_Random()%7)+3); + damage = ((P_Random() % 7) + 3); P_DamageMobj(actor->target, actor, actor, damage); } } @@ -1989,23 +1989,23 @@ void A_WizAtk3(mobj_t *actor) fixed_t momz; actor->flags &= ~MF_SHADOW; - if(!actor->target) + if (!actor->target) { return; } S_StartSound(actor, actor->info->attacksound); - if(P_CheckMeleeRange(actor)) + if (P_CheckMeleeRange(actor)) { P_DamageMobj(actor->target, actor, actor, HITDICE(4)); return; } mo = P_SpawnMissile(actor, actor->target, MT_WIZFX1); - if(mo) + if (mo) { momz = mo->momz; angle = mo->angle; - P_SpawnMissileAngle(actor, MT_WIZFX1, angle-(ANG45/8), momz); - P_SpawnMissileAngle(actor, MT_WIZFX1, angle+(ANG45/8), momz); + P_SpawnMissileAngle(actor, MT_WIZFX1, angle - (ANG45 / 8), momz); + P_SpawnMissileAngle(actor, MT_WIZFX1, angle + (ANG45 / 8), momz); } } @@ -2017,7 +2017,7 @@ void A_WizAtk3(mobj_t *actor) void A_Scream(mobj_t *actor) { - switch(actor->type) + switch (actor->type) { case MT_CHICPLAYER: case MT_SORCERER1: @@ -2027,15 +2027,15 @@ void A_Scream(mobj_t *actor) break; case MT_PLAYER: // Handle the different player death screams - if(actor->special1 < 10) + if (actor->special1 < 10) { // Wimpy death sound S_StartSound(actor, sfx_plrwdth); } - else if(actor->health > -50) + else if (actor->health > -50) { // Normal death sound S_StartSound(actor, actor->info->deathsound); } - else if(actor->health > -100) + else if (actor->health > -100) { // Crazy death sound S_StartSound(actor, sfx_plrcdth); } @@ -2060,15 +2060,15 @@ void P_DropItem(mobj_t *source, mobjtype_t type, int special, int chance) { mobj_t *mo; - if(P_Random() > chance) + if (P_Random() > chance) { return; } mo = P_SpawnMobj(source->x, source->y, - source->z+(source->height>>1), type); - mo->momx = (P_Random()-P_Random())<<8; - mo->momy = (P_Random()-P_Random())<<8; - mo->momz = FRACUNIT*5+(P_Random()<<10); + source->z + (source->height >> 1), type); + mo->momx = (P_Random() - P_Random()) << 8; + mo->momy = (P_Random() - P_Random()) << 8; + mo->momz = FRACUNIT * 5 + (P_Random() << 10); mo->flags |= MF_DROPPED; mo->health = special; } @@ -2083,7 +2083,7 @@ void A_NoBlocking(mobj_t *actor) { actor->flags &= ~MF_SOLID; // Check for monsters dropping things - switch(actor->type) + switch (actor->type) { case MT_MUMMY: case MT_MUMMYLEADER: @@ -2134,17 +2134,17 @@ void A_Explode(mobj_t *actor) int damage; damage = 128; - switch(actor->type) + switch (actor->type) { case MT_FIREBOMB: // Time Bombs - actor->z += 32*FRACUNIT; + actor->z += 32 * FRACUNIT; actor->flags &= ~MF_SHADOW; break; case MT_MNTRFX2: // Minotaur floor fire damage = 24; break; case MT_SOR2FX1: // D'Sparil missile - damage = 80+(P_Random()&31); + damage = 80 + (P_Random() & 31); break; default: break; @@ -2167,19 +2167,19 @@ void A_PodPain(mobj_t *actor) mobj_t *goo; chance = P_Random(); - if(chance < 128) + if (chance < 128) { return; } count = chance > 240 ? 2 : 1; - for(i = 0; i < count; i++) + for (i = 0; i < count; i++) { goo = P_SpawnMobj(actor->x, actor->y, - actor->z+48*FRACUNIT, MT_PODGOO); + actor->z + 48 * FRACUNIT, MT_PODGOO); goo->target = actor; - goo->momx = (P_Random()-P_Random())<<9; - goo->momy = (P_Random()-P_Random())<<9; - goo->momz = FRACUNIT/2+(P_Random()<<9); + goo->momx = (P_Random() - P_Random()) << 9; + goo->momy = (P_Random() - P_Random()) << 9; + goo->momz = FRACUNIT / 2 + (P_Random() << 9); } } @@ -2193,10 +2193,10 @@ void A_RemovePod(mobj_t *actor) { mobj_t *mo; - if(actor->special2) + if (actor->special2) { mo = (mobj_t *)actor->special2; - if(mo->special1 > 0) + if (mo->special1 > 0) { mo->special1--; } @@ -2218,7 +2218,7 @@ void A_MakePod(mobj_t *actor) fixed_t y; fixed_t z; - if(actor->special1 == MAX_GEN_PODS) + if (actor->special1 == MAX_GEN_PODS) { // Too many generated pods return; } @@ -2226,13 +2226,13 @@ void A_MakePod(mobj_t *actor) y = actor->y; z = actor->z; mo = P_SpawnMobj(x, y, ONFLOORZ, MT_POD); - if(P_CheckPosition(mo, x, y) == false) + if (P_CheckPosition(mo, x, y) == false) { // Didn't fit P_RemoveMobj(mo); return; } P_SetMobjState(mo, S_POD_GROW1); - P_ThrustMobj(mo, P_Random()<<24, (fixed_t)(4.5*FRACUNIT)); + P_ThrustMobj(mo, P_Random() << 24, (fixed_t)(4.5 * FRACUNIT)); S_StartSound(mo, sfx_newpod); actor->special1++; // Increment generated pod count mo->special2 = (int)actor; // Link the generator to the pod @@ -2252,15 +2252,15 @@ void P_Massacre(void) mobj_t *mo; thinker_t *think; - for(think = thinkercap.next; think != &thinkercap; + for (think = thinkercap.next; think != &thinkercap; think = think->next) { - if(think->function != P_MobjThinker) + if (think->function != P_MobjThinker) { // Not a mobj thinker continue; } mo = (mobj_t *)think; - if((mo->flags&MF_COUNTKILL) && (mo->health > 0)) + if ((mo->flags & MF_COUNTKILL) && (mo->health > 0)) { P_DamageMobj(mo, NULL, NULL, 10000); } @@ -2290,28 +2290,28 @@ void A_BossDeath(mobj_t *actor) -1 }; - if(gamemap != 8) + if (gamemap != 8) { // Not a boss level return; } - if(actor->type != bossType[gameepisode-1]) + if (actor->type != bossType[gameepisode - 1]) { // Not considered a boss in this episode return; } // Make sure all bosses are dead - for(think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = thinkercap.next; think != &thinkercap; think = think->next) { - if(think->function != P_MobjThinker) + if (think->function != P_MobjThinker) { // Not a mobj thinker continue; } mo = (mobj_t *)think; - if((mo != actor) && (mo->type == actor->type) && (mo->health > 0)) + if ((mo != actor) && (mo->type == actor->type) && (mo->health > 0)) { // Found a living boss return; } } - if(gameepisode > 1) + if (gameepisode > 1) { // Kill any remaining monsters P_Massacre(); } @@ -2329,7 +2329,7 @@ void A_ESound(mobj_t *mo) { int sound = 0; - switch(mo->type) + switch (mo->type) { case MT_SOUNDWATERFALL: sound = sfx_waterfl; @@ -2353,10 +2353,10 @@ void A_SpawnTeleGlitter(mobj_t *actor) { mobj_t *mo; - mo = P_SpawnMobj(actor->x+((P_Random()&31)-16)*FRACUNIT, - actor->y+((P_Random()&31)-16)*FRACUNIT, + mo = P_SpawnMobj(actor->x + ((P_Random() & 31) - 16) * FRACUNIT, + actor->y + ((P_Random() & 31) - 16) * FRACUNIT, actor->subsector->sector->floorheight, MT_TELEGLITTER); - mo->momz = FRACUNIT/4; + mo->momz = FRACUNIT / 4; } //---------------------------------------------------------------------------- @@ -2369,10 +2369,10 @@ void A_SpawnTeleGlitter2(mobj_t *actor) { mobj_t *mo; - mo = P_SpawnMobj(actor->x+((P_Random()&31)-16)*FRACUNIT, - actor->y+((P_Random()&31)-16)*FRACUNIT, + mo = P_SpawnMobj(actor->x + ((P_Random() & 31) - 16) * FRACUNIT, + actor->y + ((P_Random() & 31) - 16) * FRACUNIT, actor->subsector->sector->floorheight, MT_TELEGLITTER2); - mo->momz = FRACUNIT/4; + mo->momz = FRACUNIT / 4; } //---------------------------------------------------------------------------- @@ -2383,9 +2383,9 @@ void A_SpawnTeleGlitter2(mobj_t *actor) void A_AccTeleGlitter(mobj_t *actor) { - if(++actor->health > 35) + if (++actor->health > 35) { - actor->momz += actor->momz/2; + actor->momz += actor->momz / 2; } } @@ -2400,7 +2400,7 @@ void A_InitKeyGizmo(mobj_t *gizmo) mobj_t *mo; statenum_t state = 0; - switch(gizmo->type) + switch (gizmo->type) { case MT_KEYGIZMOBLUE: state = S_KGZ_BLUEFLOAT1; @@ -2414,7 +2414,7 @@ void A_InitKeyGizmo(mobj_t *gizmo) default: break; } - mo = P_SpawnMobj(gizmo->x, gizmo->y, gizmo->z+60*FRACUNIT, + mo = P_SpawnMobj(gizmo->x, gizmo->y, gizmo->z + 60 * FRACUNIT, MT_KEYGIZMOFLOAT); P_SetMobjState(mo, state); } @@ -2427,7 +2427,7 @@ void A_InitKeyGizmo(mobj_t *gizmo) void A_VolcanoSet(mobj_t *volcano) { - volcano->tics = 105+(P_Random()&127); + volcano->tics = 105 + (P_Random() & 127); } //---------------------------------------------------------------------------- @@ -2443,18 +2443,18 @@ void A_VolcanoBlast(mobj_t *volcano) mobj_t *blast; angle_t angle; - count = 1+(P_Random()%3); - for(i = 0; i < count; i++) + count = 1 + (P_Random() % 3); + for (i = 0; i < count; i++) { blast = P_SpawnMobj(volcano->x, volcano->y, - volcano->z+44*FRACUNIT, MT_VOLCANOBLAST); // MT_VOLCANOBLAST + volcano->z + 44 * FRACUNIT, MT_VOLCANOBLAST); // MT_VOLCANOBLAST blast->target = volcano; - angle = P_Random()<<24; + angle = P_Random() << 24; blast->angle = angle; angle >>= ANGLETOFINESHIFT; - blast->momx = FixedMul(1*FRACUNIT, finecosine[angle]); - blast->momy = FixedMul(1*FRACUNIT, finesine[angle]); - blast->momz = (2.5*FRACUNIT)+(P_Random()<<10); + blast->momx = FixedMul(1 * FRACUNIT, finecosine[angle]); + blast->momy = FixedMul(1 * FRACUNIT, finesine[angle]); + blast->momz = (2.5 * FRACUNIT) + (P_Random() << 10); S_StartSound(blast, sfx_volsht); P_CheckMissileSpawn(blast); } @@ -2472,24 +2472,24 @@ void A_VolcBallImpact(mobj_t *ball) mobj_t *tiny; angle_t angle; - if(ball->z <= ball->floorz) + if (ball->z <= ball->floorz) { ball->flags |= MF_NOGRAVITY; ball->flags2 &= ~MF2_LOGRAV; - ball->z += 28*FRACUNIT; + ball->z += 28 * FRACUNIT; //ball->momz = 3*FRACUNIT; } P_RadiusAttack(ball, ball->target, 25); - for(i = 0; i < 4; i++) + for (i = 0; i < 4; i++) { tiny = P_SpawnMobj(ball->x, ball->y, ball->z, MT_VOLCANOTBLAST); tiny->target = ball; - angle = i*ANG90; + angle = i * ANG90; tiny->angle = angle; angle >>= ANGLETOFINESHIFT; - tiny->momx = FixedMul(FRACUNIT*.7, finecosine[angle]); - tiny->momy = FixedMul(FRACUNIT*.7, finesine[angle]); - tiny->momz = FRACUNIT+(P_Random()<<9); + tiny->momx = FixedMul(FRACUNIT * .7, finecosine[angle]); + tiny->momy = FixedMul(FRACUNIT * .7, finesine[angle]); + tiny->momz = FRACUNIT + (P_Random() << 9); P_CheckMissileSpawn(tiny); } } @@ -2506,12 +2506,12 @@ void A_SkullPop(mobj_t *actor) player_t *player; actor->flags &= ~MF_SOLID; - mo = P_SpawnMobj(actor->x, actor->y, actor->z+48*FRACUNIT, + mo = P_SpawnMobj(actor->x, actor->y, actor->z + 48 * FRACUNIT, MT_BLOODYSKULL); //mo->target = actor; - mo->momx = (P_Random()-P_Random())<<9; - mo->momy = (P_Random()-P_Random())<<9; - mo->momz = FRACUNIT*2+(P_Random()<<6); + mo->momx = (P_Random() - P_Random()) << 9; + mo->momy = (P_Random() - P_Random()) << 9; + mo->momz = FRACUNIT * 2 + (P_Random() << 6); // Attach player mobj to bloody skull player = actor->player; actor->player = NULL; @@ -2531,7 +2531,7 @@ void A_SkullPop(mobj_t *actor) void A_CheckSkullFloor(mobj_t *actor) { - if(actor->z <= actor->floorz) + if (actor->z <= actor->floorz) { P_SetMobjState(actor, S_BLOODYSKULLX1); } @@ -2545,7 +2545,7 @@ void A_CheckSkullFloor(mobj_t *actor) void A_CheckSkullDone(mobj_t *actor) { - if(actor->special2 == 666) + if (actor->special2 == 666) { P_SetMobjState(actor, S_BLOODYSKULLX2); } @@ -2559,7 +2559,7 @@ void A_CheckSkullDone(mobj_t *actor) void A_CheckBurnGone(mobj_t *actor) { - if(actor->special2 == 666) + if (actor->special2 == 666) { P_SetMobjState(actor, S_PLAY_FDTH20); } @@ -2574,10 +2574,10 @@ void A_CheckBurnGone(mobj_t *actor) void A_FreeTargMobj(mobj_t *mo) { mo->momx = mo->momy = mo->momz = 0; - mo->z = mo->ceilingz+4*FRACUNIT; - mo->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY|MF_SOLID); - mo->flags |= MF_CORPSE|MF_DROPOFF|MF_NOGRAVITY; - mo->flags2 &= ~(MF2_PASSMOBJ|MF2_LOGRAV); + mo->z = mo->ceilingz + 4 * FRACUNIT; + mo->flags &= ~(MF_SHOOTABLE | MF_FLOAT | MF_SKULLFLY | MF_SOLID); + mo->flags |= MF_CORPSE | MF_DROPOFF | MF_NOGRAVITY; + mo->flags2 &= ~(MF2_PASSMOBJ | MF2_LOGRAV); mo->player = NULL; } @@ -2593,11 +2593,11 @@ int bodyqueslot; void A_AddPlayerCorpse(mobj_t *actor) { - if(bodyqueslot >= BODYQUESIZE) + if (bodyqueslot >= BODYQUESIZE) { // Too many player corpses - remove an old one - P_RemoveMobj(bodyque[bodyqueslot%BODYQUESIZE]); + P_RemoveMobj(bodyque[bodyqueslot % BODYQUESIZE]); } - bodyque[bodyqueslot%BODYQUESIZE] = actor; + bodyque[bodyqueslot % BODYQUESIZE] = actor; bodyqueslot++; } diff --git a/P_FLOOR.C b/P_FLOOR.C index 3959dad..68cc1d2 100644 --- a/P_FLOOR.C +++ b/P_FLOOR.C @@ -17,27 +17,27 @@ // Move a plane (floor or ceiling) and check for crushing // //================================================================== -result_e T_MovePlane(sector_t *sector,fixed_t speed, - fixed_t dest,boolean crush,int floorOrCeiling,int direction) +result_e T_MovePlane(sector_t *sector, fixed_t speed, + fixed_t dest, boolean crush, int floorOrCeiling, int direction) { boolean flag; fixed_t lastpos; - - switch(floorOrCeiling) + + switch (floorOrCeiling) { case 0: // FLOOR - switch(direction) + switch (direction) { case -1: // DOWN if (sector->floorheight - speed < dest) { lastpos = sector->floorheight; sector->floorheight = dest; - flag = P_ChangeSector(sector,crush); + flag = P_ChangeSector(sector, crush); if (flag == true) { - sector->floorheight =lastpos; - P_ChangeSector(sector,crush); + sector->floorheight = lastpos; + P_ChangeSector(sector, crush); //return crushed; } return pastdest; @@ -46,26 +46,26 @@ result_e T_MovePlane(sector_t *sector,fixed_t speed, { lastpos = sector->floorheight; sector->floorheight -= speed; - flag = P_ChangeSector(sector,crush); + flag = P_ChangeSector(sector, crush); if (flag == true) { sector->floorheight = lastpos; - P_ChangeSector(sector,crush); + P_ChangeSector(sector, crush); return crushed; } } break; - + case 1: // UP if (sector->floorheight + speed > dest) { lastpos = sector->floorheight; sector->floorheight = dest; - flag = P_ChangeSector(sector,crush); + flag = P_ChangeSector(sector, crush); if (flag == true) { sector->floorheight = lastpos; - P_ChangeSector(sector,crush); + P_ChangeSector(sector, crush); //return crushed; } return pastdest; @@ -74,33 +74,33 @@ result_e T_MovePlane(sector_t *sector,fixed_t speed, { lastpos = sector->floorheight; sector->floorheight += speed; - flag = P_ChangeSector(sector,crush); + flag = P_ChangeSector(sector, crush); if (flag == true) { if (crush == true) return crushed; sector->floorheight = lastpos; - P_ChangeSector(sector,crush); + P_ChangeSector(sector, crush); return crushed; } } break; } break; - + case 1: // CEILING - switch(direction) + switch (direction) { case -1: // DOWN if (sector->ceilingheight - speed < dest) { lastpos = sector->ceilingheight; sector->ceilingheight = dest; - flag = P_ChangeSector(sector,crush); + flag = P_ChangeSector(sector, crush); if (flag == true) { sector->ceilingheight = lastpos; - P_ChangeSector(sector,crush); + P_ChangeSector(sector, crush); //return crushed; } return pastdest; @@ -109,28 +109,28 @@ result_e T_MovePlane(sector_t *sector,fixed_t speed, { lastpos = sector->ceilingheight; sector->ceilingheight -= speed; - flag = P_ChangeSector(sector,crush); + flag = P_ChangeSector(sector, crush); if (flag == true) { if (crush == true) return crushed; sector->ceilingheight = lastpos; - P_ChangeSector(sector,crush); + P_ChangeSector(sector, crush); return crushed; } } break; - + case 1: // UP if (sector->ceilingheight + speed > dest) { lastpos = sector->ceilingheight; sector->ceilingheight = dest; - flag = P_ChangeSector(sector,crush); + flag = P_ChangeSector(sector, crush); if (flag == true) { sector->ceilingheight = lastpos; - P_ChangeSector(sector,crush); + P_ChangeSector(sector, crush); //return crushed; } return pastdest; @@ -139,20 +139,20 @@ result_e T_MovePlane(sector_t *sector,fixed_t speed, { lastpos = sector->ceilingheight; sector->ceilingheight += speed; - flag = P_ChangeSector(sector,crush); - #if 0 + flag = P_ChangeSector(sector, crush); +#if 0 if (flag == true) { sector->ceilingheight = lastpos; - P_ChangeSector(sector,crush); + P_ChangeSector(sector, crush); return crushed; } - #endif +#endif } break; } break; - + } return ok; } @@ -166,9 +166,9 @@ 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)) + 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_dormov); } @@ -176,12 +176,12 @@ void T_MoveFloor(floormove_t *floor) if (res == pastdest) { floor->sector->specialdata = NULL; - if(floor->type == raiseBuildStep) + if (floor->type == raiseBuildStep) { S_StartSound((mobj_t *)&floor->sector->soundorg, sfx_pstop); } if (floor->direction == 1) - switch(floor->type) + switch (floor->type) { case donutRaise: floor->sector->special = floor->newspecial; @@ -190,7 +190,7 @@ void T_MoveFloor(floormove_t *floor) break; } else if (floor->direction == -1) - switch(floor->type) + switch (floor->type) { case lowerAndChange: floor->sector->special = floor->newspecial; @@ -208,24 +208,24 @@ void T_MoveFloor(floormove_t *floor) // HANDLE FLOOR TYPES // //================================================================== -int EV_DoFloor(line_t *line,floor_e floortype) +int EV_DoFloor(line_t *line, floor_e floortype) { int secnum; int rtn; int i; - sector_t *sec; - floormove_t *floor; + sector_t *sec; + floormove_t *floor; secnum = -1; rtn = 0; - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) { sec = §ors[secnum]; - + // ALREADY MOVING? IF SO, KEEP GOING... if (sec->specialdata) continue; - + // // new floor thinker // @@ -236,28 +236,28 @@ int EV_DoFloor(line_t *line,floor_e floortype) floor->thinker.function = T_MoveFloor; floor->type = floortype; floor->crush = false; - switch(floortype) + switch (floortype) { case lowerFloor: floor->direction = -1; floor->sector = sec; floor->speed = FLOORSPEED; - floor->floordestheight = + floor->floordestheight = P_FindHighestFloorSurrounding(sec); break; case lowerFloorToLowest: floor->direction = -1; floor->sector = sec; floor->speed = FLOORSPEED; - floor->floordestheight = + floor->floordestheight = P_FindLowestFloorSurrounding(sec); break; case turboLower: floor->direction = -1; floor->sector = sec; floor->speed = FLOORSPEED * 4; - floor->floordestheight = (8*FRACUNIT) + - P_FindHighestFloorSurrounding(sec); + floor->floordestheight = (8 * FRACUNIT) + + P_FindHighestFloorSurrounding(sec); break; case raiseFloorCrush: floor->crush = true; @@ -265,84 +265,84 @@ int EV_DoFloor(line_t *line,floor_e floortype) floor->direction = 1; floor->sector = sec; floor->speed = FLOORSPEED; - floor->floordestheight = + floor->floordestheight = P_FindLowestCeilingSurrounding(sec); if (floor->floordestheight > sec->ceilingheight) floor->floordestheight = sec->ceilingheight; - floor->floordestheight -= (8*FRACUNIT)* + floor->floordestheight -= (8 * FRACUNIT) * (floortype == raiseFloorCrush); break; case raiseFloorToNearest: floor->direction = 1; floor->sector = sec; floor->speed = FLOORSPEED; - floor->floordestheight = - P_FindNextHighestFloor(sec,sec->floorheight); + floor->floordestheight = + P_FindNextHighestFloor(sec, sec->floorheight); break; case raiseFloor24: floor->direction = 1; floor->sector = sec; floor->speed = FLOORSPEED; floor->floordestheight = floor->sector->floorheight + - 24 * FRACUNIT; + 24 * FRACUNIT; break; case raiseFloor24AndChange: floor->direction = 1; floor->sector = sec; floor->speed = FLOORSPEED; floor->floordestheight = floor->sector->floorheight + - 24 * FRACUNIT; + 24 * FRACUNIT; 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; - for (i = 0; i < sec->linecount; i++) - if (twoSided (secnum, i) ) - { - side = getSide(secnum,i,0); - if (side->bottomtexture >= 0) - if (textureheight[side->bottomtexture] < - minsize) - minsize = - textureheight[side->bottomtexture]; - side = getSide(secnum,i,1); - if (side->bottomtexture >= 0) - if (textureheight[side->bottomtexture] < - minsize) - minsize = - textureheight[side->bottomtexture]; - } - floor->floordestheight = floor->sector->floorheight + - minsize; - } - break; + { + int minsize = MAXINT; + side_t *side; + + floor->direction = 1; + floor->sector = sec; + floor->speed = FLOORSPEED; + for (i = 0; i < sec->linecount; i++) + if (twoSided (secnum, i)) + { + side = getSide(secnum, i, 0); + if (side->bottomtexture >= 0) + if (textureheight[side->bottomtexture] < + minsize) + minsize = + textureheight[side->bottomtexture]; + side = getSide(secnum, i, 1); + if (side->bottomtexture >= 0) + if (textureheight[side->bottomtexture] < + minsize) + minsize = + textureheight[side->bottomtexture]; + } + floor->floordestheight = floor->sector->floorheight + + minsize; + } + break; case lowerAndChange: floor->direction = -1; floor->sector = sec; floor->speed = FLOORSPEED; - floor->floordestheight = + floor->floordestheight = P_FindLowestFloorSurrounding(sec); floor->texture = sec->floorpic; for (i = 0; i < sec->linecount; i++) - if ( twoSided(secnum, i) ) + if (twoSided(secnum, i)) { - if (getSide(secnum,i,0)->sector-sectors == secnum) + if (getSide(secnum, i, 0)->sector - sectors == secnum) { - sec = getSector(secnum,i,1); + sec = getSector(secnum, i, 1); floor->texture = sec->floorpic; floor->newspecial = sec->special; break; } else { - sec = getSector(secnum,i,0); + sec = getSector(secnum, i, 0); floor->texture = sec->floorpic; floor->newspecial = sec->special; break; @@ -369,15 +369,15 @@ int EV_BuildStairs(line_t *line, fixed_t stepDelta) int texture; int ok; int rtn; - sector_t *sec, *tsec; - floormove_t *floor; + sector_t *sec, *tsec; + floormove_t *floor; secnum = -1; rtn = 0; - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) { sec = §ors[secnum]; - + // ALREADY MOVING? IF SO, KEEP GOING... if (sec->specialdata) continue; @@ -386,7 +386,7 @@ int EV_BuildStairs(line_t *line, fixed_t stepDelta) // new floor thinker // rtn = 1; - height = sec->floorheight+stepDelta; + height = sec->floorheight + stepDelta; floor = Z_Malloc (sizeof(*floor), PU_LEVSPEC, 0); P_AddThinker (&floor->thinker); sec->specialdata = floor; @@ -396,7 +396,7 @@ int EV_BuildStairs(line_t *line, fixed_t stepDelta) floor->sector = sec; floor->speed = FLOORSPEED; floor->floordestheight = height; - + texture = sec->floorpic; // @@ -407,13 +407,13 @@ int EV_BuildStairs(line_t *line, fixed_t stepDelta) do { ok = 0; - for (i = 0;i < sec->linecount;i++) + for (i = 0; i < sec->linecount; i++) { - if ( !((sec->lines[i])->flags & ML_TWOSIDED) ) + if (!((sec->lines[i])->flags & ML_TWOSIDED)) continue; - + tsec = (sec->lines[i])->frontsector; - newsecnum = tsec-sectors; + newsecnum = tsec - sectors; if (secnum != newsecnum) continue; tsec = (sec->lines[i])->backsector; @@ -439,7 +439,7 @@ int EV_BuildStairs(line_t *line, fixed_t stepDelta) ok = 1; break; } - } while(ok); + } while (ok); } return(rtn); } diff --git a/P_INTER.C b/P_INTER.C index 4fbcafc..328e4f3 100644 --- a/P_INTER.C +++ b/P_INTER.C @@ -64,15 +64,15 @@ boolean ultimatemsg; void P_SetMessage(player_t *player, char *message, boolean ultmsg) { extern boolean messageson; - - if((ultimatemsg || !messageson) && !ultmsg) + + if ((ultimatemsg || !messageson) && !ultmsg) { return; } player->message = message; player->messageTics = MESSAGETICS; BorderTopRefresh = true; - if(ultmsg) + if (ultmsg) { ultimatemsg = true; } @@ -92,39 +92,39 @@ boolean P_GiveAmmo(player_t *player, ammotype_t ammo, int count) int prevAmmo; //weapontype_t changeWeapon; - if(ammo == am_noammo) + if (ammo == am_noammo) { return(false); } - if(ammo < 0 || ammo > NUMAMMO) + if (ammo < 0 || ammo > NUMAMMO) { I_Error("P_GiveAmmo: bad type %i", ammo); } - if(player->ammo[ammo] == player->maxammo[ammo]) + if (player->ammo[ammo] == player->maxammo[ammo]) { return(false); } - if(gameskill == sk_baby || gameskill == sk_nightmare) + if (gameskill == sk_baby || gameskill == sk_nightmare) { // extra ammo in baby mode and nightmare mode - count += count>>1; + count += count >> 1; } prevAmmo = player->ammo[ammo]; player->ammo[ammo] += count; - if(player->ammo[ammo] > player->maxammo[ammo]) + if (player->ammo[ammo] > player->maxammo[ammo]) { player->ammo[ammo] = player->maxammo[ammo]; } - if(prevAmmo) + if (prevAmmo) { // Don't attempt to change weapons if the player already had // ammo of the type just given return(true); } - if(player->readyweapon == wp_staff + if (player->readyweapon == wp_staff || player->readyweapon == wp_gauntlets) { - if(player->weaponowned[GetAmmoChange[ammo]]) + if (player->weaponowned[GetAmmoChange[ammo]]) { player->pendingweapon = GetAmmoChange[ammo]; } @@ -146,9 +146,9 @@ boolean P_GiveWeapon(player_t *player, weapontype_t weapon) boolean gaveAmmo; boolean gaveWeapon; - if(netgame && !deathmatch) + if (netgame && !deathmatch) { // Cooperative net-game - if(player->weaponowned[weapon]) + if (player->weaponowned[weapon]) { return(false); } @@ -158,7 +158,7 @@ boolean P_GiveWeapon(player_t *player, weapontype_t weapon) GetWeaponAmmo[weapon]); player->pendingweapon = weapon; - if(!M_CheckParm("-oldrules")) // FS: Some hacky shit to show the pickup messages in netgames for always stay + if (!M_CheckParm("-oldrules")) // FS: Some hacky shit to show the pickup messages in netgames for always stay { switch (weapon) { @@ -183,7 +183,7 @@ boolean P_GiveWeapon(player_t *player, weapontype_t weapon) } } - if(player == &players[consoleplayer]) + if (player == &players[consoleplayer]) { S_StartSound(NULL, sfx_wpnup); } @@ -191,7 +191,7 @@ boolean P_GiveWeapon(player_t *player, weapontype_t weapon) } gaveAmmo = P_GiveAmmo(player, wpnlev1info[weapon].ammo, GetWeaponAmmo[weapon]); - if(player->weaponowned[weapon]) + if (player->weaponowned[weapon]) { gaveWeapon = false; } @@ -199,7 +199,7 @@ boolean P_GiveWeapon(player_t *player, weapontype_t weapon) { gaveWeapon = true; player->weaponowned[weapon] = true; - if(WeaponValue[weapon] > WeaponValue[player->readyweapon]) + if (WeaponValue[weapon] > WeaponValue[player->readyweapon]) { // Only switch to more powerful weapons player->pendingweapon = weapon; } @@ -220,16 +220,16 @@ boolean P_GiveBody(player_t *player, int num) int max; max = MAXHEALTH; - if(player->chickenTics) + if (player->chickenTics) { max = MAXCHICKENHEALTH; } - if(player->health >= max) + if (player->health >= max) { return(false); } player->health += num; - if(player->health > max) + if (player->health > max) { player->health = max; } @@ -249,8 +249,8 @@ boolean P_GiveArmor(player_t *player, int armortype) { int hits; - hits = armortype*100; - if(player->armorpoints >= hits) + hits = armortype * 100; + if (player->armorpoints >= hits) { return(false); } @@ -269,15 +269,15 @@ void P_GiveKey(player_t *player, keytype_t key) { extern int playerkeys; extern vertex_t KeyPoints[]; - int i; // FS: Give keys to all players in Coop - - if(player->keys[key]) + int i; // FS: Give keys to all players in Coop + + if (player->keys[key]) { return; } - if(player == &players[consoleplayer]) + if (player == &players[consoleplayer]) { - playerkeys |= 1<powers[power] > BLINKTHRESHOLD) + if (player->powers[power] > BLINKTHRESHOLD) { // Already have it return(false); } player->powers[power] = INVULNTICS; return(true); } - if(power == pw_weaponlevel2) + if (power == pw_weaponlevel2) { - if(player->powers[power] > BLINKTHRESHOLD) + if (player->powers[power] > BLINKTHRESHOLD) { // Already have it return(false); } player->powers[power] = WPNLEV2TICS; return(true); } - if(power == pw_invisibility) + if (power == pw_invisibility) { - if(player->powers[power] > BLINKTHRESHOLD) + if (player->powers[power] > BLINKTHRESHOLD) { // Already have it return(false); } @@ -354,24 +354,24 @@ boolean P_GivePower(player_t *player, powertype_t power) player->mo->flags |= MF_SHADOW; return(true); } - if(power == pw_flight) + if (power == pw_flight) { - if(player->powers[power] > BLINKTHRESHOLD) + if (player->powers[power] > BLINKTHRESHOLD) { // Already have it return(false); } player->powers[power] = FLIGHTTICS; player->mo->flags2 |= MF2_FLY; player->mo->flags |= MF_NOGRAVITY; - if(player->mo->z <= player->mo->floorz) + if (player->mo->z <= player->mo->floorz) { player->flyheight = 10; // thrust the player in the air a bit } return(true); } - if(power == pw_infrared) + if (power == pw_infrared) { - if(player->powers[power] > BLINKTHRESHOLD) + if (player->powers[power] > BLINKTHRESHOLD) { // Already have it return(false); } @@ -379,7 +379,7 @@ boolean P_GivePower(player_t *player, powertype_t power) return(true); } - if(player->powers[power]) + if (player->powers[power]) { return(false); // already got it } @@ -400,11 +400,11 @@ boolean P_GiveArtifact(player_t *player, artitype_t arti, mobj_t *mo) int i; i = 0; - while(player->inventory[i].type != arti && i < player->inventorySlotNum) + while (player->inventory[i].type != arti && i < player->inventorySlotNum) { i++; } - if(i == player->inventorySlotNum) + if (i == player->inventorySlotNum) { player->inventory[i].count = 1; player->inventory[i].type = arti; @@ -412,18 +412,18 @@ boolean P_GiveArtifact(player_t *player, artitype_t arti, mobj_t *mo) } else { - if(player->inventory[i].count >= 16) + if (player->inventory[i].count >= 16) { // Player already has 16 of this item return(false); } player->inventory[i].count++; } - if(player->artifactCount == 0) + if (player->artifactCount == 0) { player->readyArtifact = arti; } player->artifactCount++; - if(mo && (mo->flags&MF_COUNTITEM)) + if (mo && (mo->flags & MF_COUNTITEM)) { player->itemcount++; } @@ -442,7 +442,7 @@ boolean P_GiveArtifact(player_t *player, artitype_t arti, mobj_t *mo) void P_SetDormantArtifact(mobj_t *arti) { arti->flags &= ~MF_SPECIAL; - if(netgame && (arti->type != MT_ARTIINVULNERABILITY) // FS: Respawn items Was deathmatch + if (netgame && (arti->type != MT_ARTIINVULNERABILITY) // FS: Respawn items Was deathmatch && (arti->type != MT_ARTIINVISIBILITY) && !M_CheckParm("-oldrules")) { P_SetMobjState(arti, S_DORMANTARTI1); @@ -490,7 +490,7 @@ void P_HideSpecialThing(mobj_t *thing) void A_RestoreSpecialThing1(mobj_t *thing) { - if(thing->type == MT_WMACE) + if (thing->type == MT_WMACE) { // Do random mace placement P_RepositionMace(thing); } @@ -524,46 +524,46 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher) int sound; boolean respawn; - delta = special->z-toucher->z; - if(delta > toucher->height || delta < -32*FRACUNIT) + delta = special->z - toucher->z; + if (delta > toucher->height || delta < -32 * FRACUNIT) { // Out of reach return; } - if(toucher->health <= 0) + if (toucher->health <= 0) { // Toucher is dead return; } sound = sfx_itemup; player = toucher->player; respawn = true; - switch(special->sprite) + switch (special->sprite) { // Items case SPR_PTN1: // Item_HealingPotion - if(!P_GiveBody(player, 10)) + if (!P_GiveBody(player, 10)) { return; } P_SetMessage(player, TXT_ITEMHEALTH, false); break; case SPR_SHLD: // Item_Shield1 - if(!P_GiveArmor(player, 1)) + if (!P_GiveArmor(player, 1)) { return; } P_SetMessage(player, TXT_ITEMSHIELD1, false); break; case SPR_SHD2: // Item_Shield2 - if(!P_GiveArmor(player, 2)) + if (!P_GiveArmor(player, 2)) { return; } P_SetMessage(player, TXT_ITEMSHIELD2, false); break; case SPR_BAGH: // Item_BagOfHolding - if(!player->backpack) + if (!player->backpack) { - for(i = 0; i < NUMAMMO; i++) + for (i = 0; i < NUMAMMO; i++) { player->maxammo[i] *= 2; } @@ -577,212 +577,212 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher) P_SetMessage(player, TXT_ITEMBAGOFHOLDING, false); break; case SPR_SPMP: // Item_SuperMap - if(!P_GivePower(player, pw_allmap)) + if (!P_GivePower(player, pw_allmap)) { return; } P_SetMessage(player, TXT_ITEMSUPERMAP, false); break; - // Keys + // Keys case SPR_BKYY: // Key_Blue - if(!player->keys[key_blue]) + if (!player->keys[key_blue]) { P_SetMessage(player, TXT_GOTBLUEKEY, false); } P_GiveKey(player, key_blue); sound = sfx_keyup; - if(!netgame) + if (!netgame) { break; } return; case SPR_CKYY: // Key_Yellow - if(!player->keys[key_yellow]) + if (!player->keys[key_yellow]) { P_SetMessage(player, TXT_GOTYELLOWKEY, false); } sound = sfx_keyup; P_GiveKey(player, key_yellow); - if(!netgame) + if (!netgame) { break; } return; case SPR_AKYY: // Key_Green - if(!player->keys[key_green]) + if (!player->keys[key_green]) { P_SetMessage(player, TXT_GOTGREENKEY, false); } sound = sfx_keyup; P_GiveKey(player, key_green); - if(!netgame) + if (!netgame) { break; } return; - // Artifacts + // Artifacts case SPR_PTN2: // Arti_HealingPotion - if(P_GiveArtifact(player, arti_health, special)) + if (P_GiveArtifact(player, arti_health, special)) { P_SetMessage(player, TXT_ARTIHEALTH, false); P_SetDormantArtifact(special); } return; case SPR_SOAR: // Arti_Fly - if(P_GiveArtifact(player, arti_fly, special)) + if (P_GiveArtifact(player, arti_fly, special)) { P_SetMessage(player, TXT_ARTIFLY, false); P_SetDormantArtifact(special); } return; case SPR_INVU: // Arti_Invulnerability - if(P_GiveArtifact(player, arti_invulnerability, special)) + if (P_GiveArtifact(player, arti_invulnerability, special)) { P_SetMessage(player, TXT_ARTIINVULNERABILITY, false); P_SetDormantArtifact(special); } return; case SPR_PWBK: // Arti_TomeOfPower - if(P_GiveArtifact(player, arti_tomeofpower, special)) + if (P_GiveArtifact(player, arti_tomeofpower, special)) { P_SetMessage(player, TXT_ARTITOMEOFPOWER, false); P_SetDormantArtifact(special); } return; case SPR_INVS: // Arti_Invisibility - if(P_GiveArtifact(player, arti_invisibility, special)) + if (P_GiveArtifact(player, arti_invisibility, special)) { P_SetMessage(player, TXT_ARTIINVISIBILITY, false); P_SetDormantArtifact(special); } return; case SPR_EGGC: // Arti_Egg - if(P_GiveArtifact(player, arti_egg, special)) + if (P_GiveArtifact(player, arti_egg, special)) { P_SetMessage(player, TXT_ARTIEGG, false); P_SetDormantArtifact(special); } return; case SPR_SPHL: // Arti_SuperHealth - if(P_GiveArtifact(player, arti_superhealth, special)) + if (P_GiveArtifact(player, arti_superhealth, special)) { P_SetMessage(player, TXT_ARTISUPERHEALTH, false); P_SetDormantArtifact(special); } return; case SPR_TRCH: // Arti_Torch - if(P_GiveArtifact(player, arti_torch, special)) + if (P_GiveArtifact(player, arti_torch, special)) { P_SetMessage(player, TXT_ARTITORCH, false); P_SetDormantArtifact(special); } return; case SPR_FBMB: // Arti_FireBomb - if(P_GiveArtifact(player, arti_firebomb, special)) + if (P_GiveArtifact(player, arti_firebomb, special)) { P_SetMessage(player, TXT_ARTIFIREBOMB, false); P_SetDormantArtifact(special); } return; case SPR_ATLP: // Arti_Teleport - if(P_GiveArtifact(player, arti_teleport, special)) + if (P_GiveArtifact(player, arti_teleport, special)) { P_SetMessage(player, TXT_ARTITELEPORT, false); P_SetDormantArtifact(special); } return; - // Ammo + // Ammo case SPR_AMG1: // Ammo_GoldWandWimpy - if(!P_GiveAmmo(player, am_goldwand, special->health)) + if (!P_GiveAmmo(player, am_goldwand, special->health)) { return; } P_SetMessage(player, TXT_AMMOGOLDWAND1, false); break; case SPR_AMG2: // Ammo_GoldWandHefty - if(!P_GiveAmmo(player, am_goldwand, special->health)) + if (!P_GiveAmmo(player, am_goldwand, special->health)) { return; } P_SetMessage(player, TXT_AMMOGOLDWAND2, false); break; case SPR_AMM1: // Ammo_MaceWimpy - if(!P_GiveAmmo(player, am_mace, special->health)) + if (!P_GiveAmmo(player, am_mace, special->health)) { return; } P_SetMessage(player, TXT_AMMOMACE1, false); break; case SPR_AMM2: // Ammo_MaceHefty - if(!P_GiveAmmo(player, am_mace, special->health)) + if (!P_GiveAmmo(player, am_mace, special->health)) { return; } P_SetMessage(player, TXT_AMMOMACE2, false); break; case SPR_AMC1: // Ammo_CrossbowWimpy - if(!P_GiveAmmo(player, am_crossbow, special->health)) + if (!P_GiveAmmo(player, am_crossbow, special->health)) { return; } P_SetMessage(player, TXT_AMMOCROSSBOW1, false); break; case SPR_AMC2: // Ammo_CrossbowHefty - if(!P_GiveAmmo(player, am_crossbow, special->health)) + if (!P_GiveAmmo(player, am_crossbow, special->health)) { return; } P_SetMessage(player, TXT_AMMOCROSSBOW2, false); break; case SPR_AMB1: // Ammo_BlasterWimpy - if(!P_GiveAmmo(player, am_blaster, special->health)) + if (!P_GiveAmmo(player, am_blaster, special->health)) { return; } P_SetMessage(player, TXT_AMMOBLASTER1, false); break; case SPR_AMB2: // Ammo_BlasterHefty - if(!P_GiveAmmo(player, am_blaster, special->health)) + if (!P_GiveAmmo(player, am_blaster, special->health)) { return; } P_SetMessage(player, TXT_AMMOBLASTER2, false); break; case SPR_AMS1: // Ammo_SkullRodWimpy - if(!P_GiveAmmo(player, am_skullrod, special->health)) + if (!P_GiveAmmo(player, am_skullrod, special->health)) { return; } P_SetMessage(player, TXT_AMMOSKULLROD1, false); break; case SPR_AMS2: // Ammo_SkullRodHefty - if(!P_GiveAmmo(player, am_skullrod, special->health)) + if (!P_GiveAmmo(player, am_skullrod, special->health)) { return; } P_SetMessage(player, TXT_AMMOSKULLROD2, false); break; case SPR_AMP1: // Ammo_PhoenixRodWimpy - if(!P_GiveAmmo(player, am_phoenixrod, special->health)) + if (!P_GiveAmmo(player, am_phoenixrod, special->health)) { return; } P_SetMessage(player, TXT_AMMOPHOENIXROD1, false); break; case SPR_AMP2: // Ammo_PhoenixRodHefty - if(!P_GiveAmmo(player, am_phoenixrod, special->health)) + if (!P_GiveAmmo(player, am_phoenixrod, special->health)) { return; } P_SetMessage(player, TXT_AMMOPHOENIXROD2, false); break; - // Weapons + // Weapons case SPR_WMCE: // Weapon_Mace - if(!P_GiveWeapon(player, wp_mace)) + if (!P_GiveWeapon(player, wp_mace)) { return; } @@ -790,7 +790,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher) sound = sfx_wpnup; break; case SPR_WBOW: // Weapon_Crossbow - if(!P_GiveWeapon(player, wp_crossbow)) + if (!P_GiveWeapon(player, wp_crossbow)) { return; } @@ -798,7 +798,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher) sound = sfx_wpnup; break; case SPR_WBLS: // Weapon_Blaster - if(!P_GiveWeapon(player, wp_blaster)) + if (!P_GiveWeapon(player, wp_blaster)) { return; } @@ -806,7 +806,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher) sound = sfx_wpnup; break; case SPR_WSKL: // Weapon_SkullRod - if(!P_GiveWeapon(player, wp_skullrod)) + if (!P_GiveWeapon(player, wp_skullrod)) { return; } @@ -814,7 +814,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher) sound = sfx_wpnup; break; case SPR_WPHX: // Weapon_PhoenixRod - if(!P_GiveWeapon(player, wp_phoenixrod)) + if (!P_GiveWeapon(player, wp_phoenixrod)) { return; } @@ -822,7 +822,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher) sound = sfx_wpnup; break; case SPR_WGNT: // Weapon_Gauntlets - if(!P_GiveWeapon(player, wp_gauntlets)) + if (!P_GiveWeapon(player, wp_gauntlets)) { return; } @@ -832,11 +832,11 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher) default: I_Error("P_SpecialThing: Unknown gettable thing"); } - if(special->flags&MF_COUNTITEM) + if (special->flags & MF_COUNTITEM) { player->itemcount++; } - if((netgame && respawn && !(special->flags&MF_DROPPED) && !M_CheckParm("-oldrules")) || M_CheckParm("-respawnitems")) // FS: Respawning Items Was deathmatch + if ((netgame && respawn && !(special->flags & MF_DROPPED) && !M_CheckParm("-oldrules")) || M_CheckParm("-respawnitems")) // FS: Respawning Items Was deathmatch { P_HideSpecialThing(special); } @@ -845,7 +845,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher) P_RemoveMobj(special); } player->bonuscount += BONUSADD; - if(player == &players[consoleplayer]) + if (player == &players[consoleplayer]) { S_StartSound(NULL, sound); SB_PaletteFlash(); @@ -864,45 +864,45 @@ void P_KillMobj(mobj_t *source, mobj_t *target) player_t *player, *playermsg; // FS: For Player Died message int playnum; // FS: For Player Died message - target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SKULLFLY|MF_NOGRAVITY); - target->flags |= MF_CORPSE|MF_DROPOFF; + target->flags &= ~(MF_SHOOTABLE | MF_FLOAT | MF_SKULLFLY | MF_NOGRAVITY); + target->flags |= MF_CORPSE | MF_DROPOFF; target->flags2 &= ~MF2_PASSMOBJ; target->height >>= 2; - if(source && source->player) + if (source && source->player) { - if(target->flags&MF_COUNTKILL) + if (target->flags & MF_COUNTKILL) { // Count for intermission source->player->killcount++; } - if(target->player) + if (target->player) { // Frag stuff - if(target == source) + if (target == source) { // Self-frag - target->player->frags[target->player-players]--; + target->player->frags[target->player - players]--; } else { - source->player->frags[target->player-players]++; - if(source->player == &players[consoleplayer]) + source->player->frags[target->player - players]++; + if (source->player == &players[consoleplayer]) { S_StartSound(NULL, sfx_gfrag); } - if(source->player->chickenTics) + if (source->player->chickenTics) { // Make a super chicken P_GivePower(source->player, pw_weaponlevel2); } } } } - else if(!netgame && (target->flags&MF_COUNTKILL)) + else if (!netgame && (target->flags & MF_COUNTKILL)) { // Count all monster deaths players[0].killcount++; } - if(target->player) + if (target->player) { - if(!source) + if (!source) { // Self-frag - target->player->frags[target->player-players]--; + target->player->frags[target->player - players]--; } target->flags &= ~MF_SOLID; target->flags2 &= ~MF2_FLY; @@ -914,20 +914,20 @@ void P_KillMobj(mobj_t *source, mobj_t *target) if (netgame && !deathmatch && !M_CheckParm("-oldrules")) // FS: Broadcast death in coop { - for (z = 0; z player) + if (player == target->player) { playnum = z; } } - + for (i = 0; i < MAXPLAYERS; i++) { player = &players[i]; - switch(playnum) + switch (playnum) { case 0: P_SetMessage(player, "PLAYER 1 DIED!", true); @@ -949,14 +949,14 @@ void P_KillMobj(mobj_t *source, mobj_t *target) } P_DropWeapon(target->player); - if(target->flags2&MF2_FIREDAMAGE) + if (target->flags2 & MF2_FIREDAMAGE) { // Player flame death P_SetMobjState(target, S_PLAY_FDTH1); //S_StartSound(target, sfx_hedat1); // Burn sound return; } } - if(target->health < -(target->info->spawnhealth>>1) + if (target->health < -(target->info->spawnhealth >> 1) && target->info->xdeathstate) { // Extreme death P_SetMobjState(target, target->info->xdeathstate); @@ -965,8 +965,8 @@ void P_KillMobj(mobj_t *source, mobj_t *target) { // Normal death P_SetMobjState(target, target->info->deathstate); } - target->tics -= P_Random()&3; -// I_StartSound(&actor->r, actor->info->deathsound); + target->tics -= P_Random() & 3; + // I_StartSound(&actor->r, actor->info->deathsound); } //--------------------------------------------------------------------------- @@ -982,13 +982,13 @@ void P_MinotaurSlam(mobj_t *source, mobj_t *target) angle = R_PointToAngle2(source->x, source->y, target->x, target->y); angle >>= ANGLETOFINESHIFT; - thrust = 16*FRACUNIT+(P_Random()<<10); + thrust = 16 * FRACUNIT + (P_Random() << 10); target->momx += FixedMul(thrust, finecosine[angle]); target->momy += FixedMul(thrust, finesine[angle]); P_DamageMobj(target, NULL, NULL, HITDICE(6)); - if(target->player) + if (target->player) { - target->reactiontime = 14+(P_Random()&7); + target->reactiontime = 14 + (P_Random() & 7); } } @@ -1002,23 +1002,23 @@ void P_TouchWhirlwind(mobj_t *target) { int randVal; - target->angle += (P_Random()-P_Random())<<20; - target->momx += (P_Random()-P_Random())<<10; - target->momy += (P_Random()-P_Random())<<10; - if(leveltime&16 && !(target->flags2&MF2_BOSS)) + target->angle += (P_Random() - P_Random()) << 20; + target->momx += (P_Random() - P_Random()) << 10; + target->momy += (P_Random() - P_Random()) << 10; + if (leveltime & 16 && !(target->flags2 & MF2_BOSS)) { randVal = P_Random(); - if(randVal > 160) + if (randVal > 160) { randVal = 160; } - target->momz += randVal<<10; - if(target->momz > 12*FRACUNIT) + target->momz += randVal << 10; + if (target->momz > 12 * FRACUNIT) { - target->momz = 12*FRACUNIT; + target->momz = 12 * FRACUNIT; } } - if(!(leveltime&7)) + if (!(leveltime & 7)) { P_DamageMobj(target, NULL, NULL, 3); } @@ -1043,16 +1043,16 @@ boolean P_ChickenMorphPlayer(player_t *player) angle_t angle; int oldFlags2; - if(player->chickenTics) + if (player->chickenTics) { - if((player->chickenTics < CHICKENTICS-TICSPERSEC) + if ((player->chickenTics < CHICKENTICS - TICSPERSEC) && !player->powers[pw_weaponlevel2]) { // Make a super chicken P_GivePower(player, pw_weaponlevel2); } return(false); } - if(player->powers[pw_invulnerability]) + if (player->powers[pw_invulnerability]) { // Immune when invulnerable return(false); } @@ -1063,7 +1063,7 @@ boolean P_ChickenMorphPlayer(player_t *player) angle = pmo->angle; oldFlags2 = pmo->flags2; P_SetMobjState(pmo, S_FREETARGMOBJ); - fog = P_SpawnMobj(x, y, z+TELEFOGHEIGHT, MT_TFOG); + fog = P_SpawnMobj(x, y, z + TELEFOGHEIGHT, MT_TFOG); S_StartSound(fog, sfx_telept); chicken = P_SpawnMobj(x, y, z, MT_CHICPLAYER); chicken->special1 = player->readyweapon; @@ -1074,7 +1074,7 @@ boolean P_ChickenMorphPlayer(player_t *player) player->armorpoints = player->armortype = 0; player->powers[pw_invisibility] = 0; player->powers[pw_weaponlevel2] = 0; - if(oldFlags2&MF2_FLY) + if (oldFlags2 & MF2_FLY) { chicken->flags2 |= MF2_FLY; } @@ -1101,12 +1101,12 @@ boolean P_ChickenMorph(mobj_t *actor) angle_t angle; int ghost; - if(actor->player) + if (actor->player) { return(false); } moType = actor->type; - switch(moType) + switch (moType) { case MT_POD: case MT_CHICKEN: @@ -1122,14 +1122,14 @@ boolean P_ChickenMorph(mobj_t *actor) y = actor->y; z = actor->z; angle = actor->angle; - ghost = actor->flags&MF_SHADOW; + ghost = actor->flags & MF_SHADOW; target = actor->target; P_SetMobjState(actor, S_FREETARGMOBJ); - fog = P_SpawnMobj(x, y, z+TELEFOGHEIGHT, MT_TFOG); + fog = P_SpawnMobj(x, y, z + TELEFOGHEIGHT, MT_TFOG); S_StartSound(fog, sfx_telept); chicken = P_SpawnMobj(x, y, z, MT_CHICKEN); chicken->special2 = moType; - chicken->special1 = CHICKENTICS+P_Random(); + chicken->special1 = CHICKENTICS + P_Random(); chicken->flags |= ghost; chicken->target = target; chicken->angle = angle; @@ -1146,12 +1146,12 @@ boolean P_AutoUseChaosDevice(player_t *player) { int i; - for(i = 0; i < player->inventorySlotNum; i++) + for (i = 0; i < player->inventorySlotNum; i++) { - if(player->inventory[i].type == arti_teleport) + if (player->inventory[i].type == arti_teleport) { P_PlayerUseArtifact(player, arti_teleport); - player->health = player->mo->health = (player->health+1)/2; + player->health = player->mo->health = (player->health + 1) / 2; return(true); } } @@ -1174,49 +1174,49 @@ void P_AutoUseHealth(player_t *player, int saveHealth) int superSlot; normalCount = superCount = 0; - for(i = 0; i < player->inventorySlotNum; i++) + for (i = 0; i < player->inventorySlotNum; i++) { - if(player->inventory[i].type == arti_health) + if (player->inventory[i].type == arti_health) { normalSlot = i; normalCount = player->inventory[i].count; } - else if(player->inventory[i].type == arti_superhealth) + else if (player->inventory[i].type == arti_superhealth) { superSlot = i; superCount = player->inventory[i].count; } } - if((gameskill == sk_baby) && (normalCount*25 >= saveHealth)) + if ((gameskill == sk_baby) && (normalCount * 25 >= saveHealth)) { // Use quartz flasks - count = (saveHealth+24)/25; - for(i = 0; i < count; i++) + count = (saveHealth + 24) / 25; + for (i = 0; i < count; i++) { player->health += 25; P_PlayerRemoveArtifact(player, normalSlot); } } - else if(superCount*100 >= saveHealth) + else if (superCount * 100 >= saveHealth) { // Use mystic urns - count = (saveHealth+99)/100; - for(i = 0; i < count; i++) + count = (saveHealth + 99) / 100; + for (i = 0; i < count; i++) { player->health += 100; P_PlayerRemoveArtifact(player, superSlot); } } - else if((gameskill == sk_baby) - && (superCount*100+normalCount*25 >= saveHealth)) + else if ((gameskill == sk_baby) + && (superCount * 100 + normalCount * 25 >= saveHealth)) { // Use mystic urns and quartz flasks - count = (saveHealth+24)/25; - saveHealth -= count*25; - for(i = 0; i < count; i++) + count = (saveHealth + 24) / 25; + saveHealth -= count * 25; + for (i = 0; i < count; i++) { player->health += 25; P_PlayerRemoveArtifact(player, normalSlot); } - count = (saveHealth+99)/100; - for(i = 0; i < count; i++) + count = (saveHealth + 99) / 100; + for (i = 0; i < count; i++) { player->health += 100; P_PlayerRemoveArtifact(player, normalSlot); @@ -1254,37 +1254,37 @@ void P_DamageMobj fixed_t thrust; int temp; - if(!(target->flags&MF_SHOOTABLE)) + if (!(target->flags & MF_SHOOTABLE)) { // Shouldn't happen return; } - if(target->health <= 0) + if (target->health <= 0) { return; } - if(target->flags&MF_SKULLFLY) + if (target->flags & MF_SKULLFLY) { - if(target->type == MT_MINOTAUR) + if (target->type == MT_MINOTAUR) { // Minotaur is invulnerable during charge attack return; } target->momx = target->momy = target->momz = 0; } player = target->player; - if(player && gameskill == sk_baby) + if (player && gameskill == sk_baby) { // Take half damage in trainer mode damage >>= 1; } // Special damage types - if(inflictor) + if (inflictor) { - switch(inflictor->type) + switch (inflictor->type) { case MT_EGGFX: - if(player) + if (player) { P_ChickenMorphPlayer(player); } @@ -1297,24 +1297,24 @@ void P_DamageMobj P_TouchWhirlwind(target); return; case MT_MINOTAUR: - if(inflictor->flags&MF_SKULLFLY) + if (inflictor->flags & MF_SKULLFLY) { // Slam only when in charge mode P_MinotaurSlam(inflictor, target); return; } break; case MT_MACEFX4: // Death ball - if((target->flags2&MF2_BOSS) || target->type == MT_HEAD) + if ((target->flags2 & MF2_BOSS) || target->type == MT_HEAD) { // Don't allow cheap boss kills break; } - else if(target->player) + else if (target->player) { // Player specific checks - if(target->player->powers[pw_invulnerability]) + if (target->player->powers[pw_invulnerability]) { // Can't hurt invulnerable players break; } - if(P_AutoUseChaosDevice(target->player)) + if (P_AutoUseChaosDevice(target->player)) { // Player was saved using chaos device return; } @@ -1322,7 +1322,7 @@ void P_DamageMobj damage = 10000; // Something's gonna die break; case MT_PHOENIXFX2: // Flame thrower - if(target->player && P_Random() < 128) + if (target->player && P_Random() < 128) { // Freeze player for a bit target->reactiontime += 4; } @@ -1331,14 +1331,14 @@ void P_DamageMobj case MT_RAINPLR2: case MT_RAINPLR3: case MT_RAINPLR4: - if(target->flags2&MF2_BOSS) + if (target->flags2 & MF2_BOSS) { // Decrease damage for bosses - damage = (P_Random()&7)+1; + damage = (P_Random() & 7) + 1; } break; case MT_HORNRODFX2: case MT_PHOENIXFX1: - if(target->type == MT_SORCERER2 && P_Random() < 96) + if (target->type == MT_SORCERER2 && P_Random() < 96) { // D'Sparil teleports away P_DSparilTeleport(target); return; @@ -1346,10 +1346,10 @@ void P_DamageMobj break; case MT_BLASTERFX1: case MT_RIPPER: - if(target->type == MT_HEAD) + if (target->type == MT_HEAD) { // Less damage to Ironlich bosses - damage = P_Random()&1; - if(!damage) + damage = P_Random() & 1; + if (!damage) { return; } @@ -1360,32 +1360,32 @@ void P_DamageMobj } } // Push the target unless source is using the gauntlets - if(inflictor && (!source || !source->player + if (inflictor && (!source || !source->player || source->player->readyweapon != wp_gauntlets) - && !(inflictor->flags2&MF2_NODMGTHRUST)) + && !(inflictor->flags2 & MF2_NODMGTHRUST)) { ang = R_PointToAngle2(inflictor->x, inflictor->y, target->x, target->y); //thrust = damage*(FRACUNIT>>3)*100/target->info->mass; - thrust = damage*(FRACUNIT>>3)*150/target->info->mass; + thrust = damage * (FRACUNIT >> 3) * 150 / target->info->mass; // make fall forwards sometimes - if((damage < 40) && (damage > target->health) - && (target->z-inflictor->z > 64*FRACUNIT) && (P_Random()&1)) + if ((damage < 40) && (damage > target->health) + && (target->z - inflictor->z > 64 * FRACUNIT) && (P_Random() & 1)) { ang += ANG180; thrust *= 4; } ang >>= ANGLETOFINESHIFT; - if(source && source->player && (source == inflictor) + if (source && source->player && (source == inflictor) && source->player->powers[pw_weaponlevel2] && source->player->readyweapon == wp_staff) { // Staff power level 2 - target->momx += FixedMul(10*FRACUNIT, finecosine[ang]); - target->momy += FixedMul(10*FRACUNIT, finesine[ang]); - if(!(target->flags&MF_NOGRAVITY)) + target->momx += FixedMul(10 * FRACUNIT, finecosine[ang]); + target->momy += FixedMul(10 * FRACUNIT, finesine[ang]); + if (!(target->flags & MF_NOGRAVITY)) { - target->momz += 5*FRACUNIT; + target->momz += 5 * FRACUNIT; } } else @@ -1398,29 +1398,29 @@ void P_DamageMobj // // player specific // - if(player) + if (player) { - if(damage < 1000 && ((player->cheats&CF_GODMODE) || player->powers[pw_invulnerability])) + if (damage < 1000 && ((player->cheats & CF_GODMODE) || player->powers[pw_invulnerability])) { return; } - if(source && (source->type == MT_PLAYER && source->player != player && (!M_CheckParm("-oldrules") && netgame && !deathmatch))) // FS: No friendly fire + if (source && (source->type == MT_PLAYER && source->player != player && (!M_CheckParm("-oldrules") && netgame && !deathmatch))) // FS: No friendly fire { - if(P_GetPlayerNum(source->player) != P_GetPlayerNum(target->player)) // FS: Make sure we still get self-damage + if (P_GetPlayerNum(source->player) != P_GetPlayerNum(target->player)) // FS: Make sure we still get self-damage return; } - if(player->armortype) + if (player->armortype) { - if(player->armortype == 1) + if (player->armortype == 1) { - saved = damage>>1; + saved = damage >> 1; } else { - saved = (damage>>1)+(damage>>2); + saved = (damage >> 1) + (damage >> 2); } - if(player->armorpoints <= saved) + if (player->armorpoints <= saved) { // armor is used up saved = player->armorpoints; @@ -1429,27 +1429,27 @@ void P_DamageMobj player->armorpoints -= saved; damage -= saved; } - if(damage >= player->health + if (damage >= player->health && ((gameskill == sk_baby) || netgame) // FS: Was Deathmatch MAKE OLDRULES && !player->chickenTics) { // Try to use some inventory health - P_AutoUseHealth(player, damage-player->health+1); + P_AutoUseHealth(player, damage - player->health + 1); } player->health -= damage; // mirror mobj health here for Dave - if(player->health < 0) + if (player->health < 0) { player->health = 0; } player->attacker = source; player->damagecount += damage; // add damage after armor / invuln - if(player->damagecount > 100) + if (player->damagecount > 100) { player->damagecount = 100; // teleport stomp does 10k points... } temp = damage < 100 ? damage : 100; - if(player == &players[consoleplayer]) + if (player == &players[consoleplayer]) { - I_Tactile(40, 10, 40+temp*2); + I_Tactile(40, 10, 40 + temp * 2); SB_PaletteFlash(); } } @@ -1458,18 +1458,18 @@ void P_DamageMobj // do the damage // target->health -= damage; - if(target->health <= 0) + if (target->health <= 0) { // Death target->special1 = damage; - if(target->type == MT_POD && source && source->type != MT_POD) + if (target->type == MT_POD && source && source->type != MT_POD) { // Make sure players get frags for chain-reaction kills target->target = source; } - if(player && inflictor && !player->chickenTics) + if (player && inflictor && !player->chickenTics) { // Check for flame death - if((inflictor->flags2&MF2_FIREDAMAGE) + if ((inflictor->flags2 & MF2_FIREDAMAGE) || ((inflictor->type == MT_PHOENIXFX1) - && (target->health > -50) && (damage > 25))) + && (target->health > -50) && (damage > 25))) { target->flags2 |= MF2_FIREDAMAGE; } @@ -1477,21 +1477,21 @@ void P_DamageMobj P_KillMobj(source, target); return; } - if((P_Random() < target->info->painchance) - && !(target->flags&MF_SKULLFLY)) + if ((P_Random() < target->info->painchance) + && !(target->flags & MF_SKULLFLY)) { target->flags |= MF_JUSTHIT; // fight back! P_SetMobjState(target, target->info->painstate); } target->reactiontime = 0; // we're awake now... - if(!target->threshold && source && !(source->flags2&MF2_BOSS) + if (!target->threshold && source && !(source->flags2 & MF2_BOSS) && !(target->type == MT_SORCERER2 && source->type == MT_WIZARD)) { // Target actor is not intent on another actor, // so make him chase after source target->target = source; target->threshold = BASETHRESHOLD; - if(target->state == &states[target->info->spawnstate] + if (target->state == &states[target->info->spawnstate] && target->info->seestate != S_NULL) { P_SetMobjState(target, target->info->seestate); diff --git a/P_LIGHTS.C b/P_LIGHTS.C index 30d3c40..7ec64a4 100644 --- a/P_LIGHTS.C +++ b/P_LIGHTS.C @@ -21,16 +21,16 @@ void T_LightFlash (lightflash_t *flash) { if (--flash->count) return; - + if (flash->sector->lightlevel == flash->maxlight) { - flash-> sector->lightlevel = flash->minlight; - flash->count = (P_Random()&flash->mintime)+1; + flash->sector->lightlevel = flash->minlight; + flash->count = (P_Random() & flash->mintime) + 1; } else { - flash-> sector->lightlevel = flash->maxlight; - flash->count = (P_Random()&flash->maxtime)+1; + flash->sector->lightlevel = flash->maxlight; + flash->count = (P_Random() & flash->maxtime) + 1; } } @@ -45,20 +45,20 @@ void T_LightFlash (lightflash_t *flash) //================================================================== void P_SpawnLightFlash (sector_t *sector) { - lightflash_t *flash; - + lightflash_t *flash; + sector->special = 0; // nothing special about it during gameplay - - flash = Z_Malloc ( sizeof(*flash), PU_LEVSPEC, 0); + + flash = Z_Malloc (sizeof(*flash), PU_LEVSPEC, 0); P_AddThinker (&flash->thinker); flash->thinker.function = T_LightFlash; flash->sector = sector; flash->maxlight = sector->lightlevel; - flash->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel); + flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel); flash->maxtime = 64; flash->mintime = 7; - flash->count = (P_Random()&flash->maxtime)+1; + flash->count = (P_Random() & flash->maxtime) + 1; } //================================================================== @@ -78,16 +78,16 @@ void T_StrobeFlash (strobe_t *flash) { if (--flash->count) return; - + if (flash->sector->lightlevel == flash->minlight) { - flash-> sector->lightlevel = flash->maxlight; + flash->sector->lightlevel = flash->maxlight; flash->count = flash->brighttime; } else { - flash-> sector->lightlevel = flash->minlight; - flash->count =flash->darktime; + flash->sector->lightlevel = flash->minlight; + flash->count = flash->darktime; } } @@ -99,11 +99,11 @@ void T_StrobeFlash (strobe_t *flash) // After the map has been loaded, scan each sector for specials that spawn thinkers // //================================================================== -void P_SpawnStrobeFlash (sector_t *sector,int fastOrSlow, int inSync) +void P_SpawnStrobeFlash (sector_t *sector, int fastOrSlow, int inSync) { - strobe_t *flash; - - flash = Z_Malloc ( sizeof(*flash), PU_LEVSPEC, 0); + strobe_t *flash; + + flash = Z_Malloc (sizeof(*flash), PU_LEVSPEC, 0); P_AddThinker (&flash->thinker); flash->sector = sector; flash->darktime = fastOrSlow; @@ -111,13 +111,13 @@ void P_SpawnStrobeFlash (sector_t *sector,int fastOrSlow, int inSync) flash->thinker.function = T_StrobeFlash; flash->maxlight = sector->lightlevel; flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel); - + if (flash->minlight == flash->maxlight) flash->minlight = 0; sector->special = 0; // nothing special about it during gameplay if (!inSync) - flash->count = (P_Random()&7)+1; + flash->count = (P_Random() & 7) + 1; else flash->count = 1; } @@ -130,16 +130,16 @@ void P_SpawnStrobeFlash (sector_t *sector,int fastOrSlow, int inSync) void EV_StartLightStrobing(line_t *line) { int secnum; - sector_t *sec; - + sector_t *sec; + secnum = -1; - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) { sec = §ors[secnum]; if (sec->specialdata) continue; - - P_SpawnStrobeFlash (sec,SLOWDARK, 0); + + P_SpawnStrobeFlash (sec, SLOWDARK, 0); } } @@ -148,24 +148,24 @@ void EV_StartLightStrobing(line_t *line) // TURN LINE'S TAG LIGHTS OFF // //================================================================== -void EV_TurnTagLightsOff(line_t *line) +void EV_TurnTagLightsOff(line_t *line) { int i; int j; int min; - sector_t *sector; - sector_t *tsec; - line_t *templine; - + sector_t *sector; + sector_t *tsec; + line_t *templine; + sector = sectors; - for (j = 0;j < numsectors; j++, sector++) + for (j = 0; j < numsectors; j++, sector++) if (sector->tag == line->tag) { min = sector->lightlevel; - for (i = 0;i < sector->linecount; i++) + for (i = 0; i < sector->linecount; i++) { templine = sector->lines[i]; - tsec = getNextSector(templine,sector); + tsec = getNextSector(templine, sector); if (!tsec) continue; if (tsec->lightlevel < min) @@ -184,13 +184,13 @@ void EV_LightTurnOn(line_t *line, int bright) { int i; int j; - sector_t *sector; - sector_t *temp; - line_t *templine; - + sector_t *sector; + sector_t *temp; + line_t *templine; + sector = sectors; - - for (i=0;itag == line->tag) { // @@ -199,17 +199,17 @@ void EV_LightTurnOn(line_t *line, int bright) // if (!bright) { - for (j = 0;j < sector->linecount; j++) + for (j = 0; j < sector->linecount; j++) { templine = sector->lines[j]; - temp = getNextSector(templine,sector); + temp = getNextSector(templine, sector); if (!temp) continue; if (temp->lightlevel > bright) bright = temp->lightlevel; } } - sector-> lightlevel = bright; + sector->lightlevel = bright; } } @@ -220,7 +220,7 @@ void EV_LightTurnOn(line_t *line, int bright) //================================================================== void T_Glow(glow_t *g) { - switch(g->direction) + switch (g->direction) { case -1: // DOWN g->sector->lightlevel -= GLOWSPEED; @@ -243,12 +243,12 @@ void T_Glow(glow_t *g) void P_SpawnGlowingLight(sector_t *sector) { - glow_t *g; - - g = Z_Malloc( sizeof(*g), PU_LEVSPEC, 0); + 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->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel); g->maxlight = sector->lightlevel; g->thinker.function = T_Glow; g->direction = -1; diff --git a/P_MAP.C b/P_MAP.C index ed51193..3cf6d21 100644 --- a/P_MAP.C +++ b/P_MAP.C @@ -23,7 +23,7 @@ mobj_t NOTES mobj_ts are used to tell the refresh where to draw an image, tell the world simulation when objects are contacted, and tell the sound driver how to position a sound. The refresh uses the next and prev links to follow lists of things in sectors as they are being drawn. The sprite, frame, and angle elements determine which patch_t is used to draw the sprite if it is visible. The sprite and frame values are allmost allways set from state_t structures. The statescr.exe utility generates the states.h and states.c files that contain the sprite/frame numbers from the statescr.txt source file. The xyz origin point represents a point at the bottom middle of the sprite (between the feet of a biped). This is the default origin position for patch_ts grabbed with lumpy.exe. A walking creature will have its z equal to the floor it is standing on. - + The sound code uses the x,y, and subsector fields to do stereo positioning of any sound effited by the mobj_t. The play simulation uses the blocklinks, x,y,z, radius, height to determine when mobj_ts are touching each other, touching lines in the map, or hit by trace lines (gunshots, lines of sight, etc). The mobj_t->flags element has various bit flags used by the simulation. @@ -32,7 +32,7 @@ The play simulation uses the blocklinks, x,y,z, radius, height to determine when Every mobj_t is linked into a single sector based on it's origin coordinates. The subsector_t is found with R_PointInSubsector(x,y), and the sector_t can be found with subsector->sector. The sector links are only used by the rendering code, the play simulation does not care about them at all. -Any mobj_t that needs to be acted upon be something else in the play world (block movement, be shot, etc) will also need to be linked into the blockmap. If the thing has the MF_NOBLOCK flag set, it will not use the block links. It can still interact with other things, but only as the instigator (missiles will run into other things, but nothing can run into a missile). Each block in the grid is 128*128 units, and knows about every line_t that it contains a piece of, and every interactable mobj_t that has it's origin contained. +Any mobj_t that needs to be acted upon be something else in the play world (block movement, be shot, etc) will also need to be linked into the blockmap. If the thing has the MF_NOBLOCK flag set, it will not use the block links. It can still interact with other things, but only as the instigator (missiles will run into other things, but nothing can run into a missile). Each block in the grid is 128*128 units, and knows about every line_t that it contains a piece of, and every interactable mobj_t that has it's origin contained. A valid mobj_t is a mobj_t that has the proper subsector_t filled in for it's xy coordinates and is linked into the subsector's sector or has the MF_NOSECTOR flag set (the subsector_t needs to be valid even if MF_NOSECTOR is set), and is linked into a blockmap block or has the MF_NOBLOCKMAP flag set. Links should only be modified by the P_[Un]SetThingPosition () functions. Do not change the MF_NO? flags while a thing is valid. @@ -41,7 +41,7 @@ A valid mobj_t is a mobj_t that has the proper subsector_t filled in for it's xy */ fixed_t tmbbox[4]; -mobj_t *tmthing; +mobj_t *tmthing; int tmflags; fixed_t tmx, tmy; @@ -52,12 +52,12 @@ fixed_t tmfloorz, tmceilingz, tmdropoffz; // keep track of the line that lowers the ceiling, so missiles don't explode // against sky hack walls -line_t *ceilingline; +line_t *ceilingline; // keep track of special lines as they are hit, but don't process them // until the move is proven valid #define MAXSPECIALCROSS 8 -line_t *spechit[MAXSPECIALCROSS]; +line_t *spechit[MAXSPECIALCROSS]; int numspechit; mobj_t *onmobj; //generic global onmobj...used for landing on pods/players @@ -66,7 +66,7 @@ mobj_t *onmobj; //generic global onmobj...used for landing on pods/players =============================================================================== TELEPORT MOVE - + =============================================================================== */ @@ -81,24 +81,24 @@ mobj_t *onmobj; //generic global onmobj...used for landing on pods/players boolean PIT_StompThing (mobj_t *thing) { fixed_t blockdist; - - if (!(thing->flags & MF_SHOOTABLE) ) + + if (!(thing->flags & MF_SHOOTABLE)) return true; - + blockdist = thing->radius + tmthing->radius; - if ( abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist ) + if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) return true; // didn't hit it - + if (thing == tmthing) return true; // don't clip against self - if(!(tmthing->flags2&MF2_TELESTOMP)) + if (!(tmthing->flags2 & MF2_TELESTOMP)) { // Not allowed to stomp things return(false); } - + P_DamageMobj (thing, tmthing, tmthing, 10000); - + return true; } @@ -113,62 +113,62 @@ boolean PIT_StompThing (mobj_t *thing) boolean P_TeleportMove (mobj_t *thing, fixed_t x, fixed_t y) { - int xl,xh,yl,yh,bx,by; - subsector_t *newsubsec; + int xl, xh, yl, yh, bx, by; + subsector_t *newsubsec; -// -// kill anything occupying the position -// + // + // kill anything occupying the position + // 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); + newsubsec = R_PointInSubsector (x, y); ceilingline = NULL; - -// -// the base floor / ceiling is from the subsector that contains the -// point. Any contacted lines the step closer together will adjust them -// + + // + // the base floor / ceiling is from the subsector that contains the + // point. Any contacted lines the step closer together will adjust them + // tmfloorz = tmdropoffz = newsubsec->sector->floorheight; tmceilingz = newsubsec->sector->ceilingheight; - + validcount++; numspechit = 0; -// -// stomp on any things contacted -// - 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)) + // + // stomp on any things contacted + // + 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; - -// -// the move is ok, so link the thing into its new position -// + + // + // the move is ok, so link the thing into its new position + // P_UnsetThingPosition (thing); thing->floorz = tmfloorz; - thing->ceilingz = tmceilingz; + thing->ceilingz = tmceilingz; thing->x = x; thing->y = y; P_SetThingPosition (thing); - + return true; } @@ -176,7 +176,7 @@ boolean P_TeleportMove (mobj_t *thing, fixed_t x, fixed_t y) =============================================================================== MOVEMENT ITERATOR FUNCTIONS - + =============================================================================== */ @@ -192,32 +192,32 @@ boolean P_TeleportMove (mobj_t *thing, fixed_t x, fixed_t y) boolean PIT_CheckLine(line_t *ld) { if (tmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] - || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] - || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] - || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) + || tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] + || tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] + || tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) { return(true); } - if(P_BoxOnLineSide(tmbbox, ld) != -1) + if (P_BoxOnLineSide(tmbbox, ld) != -1) { return(true); } -// a line has been hit -/* -= -= The moving thing's destination position will cross the given line. -= If this should not be allowed, return false. -= If the line is special, keep track of it to process later if the move -= is proven ok. NOTE: specials are NOT sorted by order, so two special lines -= that are only 8 pixels apart could be crossed in either order. -*/ + // a line has been hit + /* + = + = The moving thing's destination position will cross the given line. + = If this should not be allowed, return false. + = If the line is special, keep track of it to process later if the move + = is proven ok. NOTE: specials are NOT sorted by order, so two special lines + = that are only 8 pixels apart could be crossed in either order. + */ - if(!ld->backsector) + if (!ld->backsector) { // One sided line - if(tmthing->flags&MF_MISSILE) + if (tmthing->flags & MF_MISSILE) { // Missiles can trigger impact specials - if(ld->special) + if (ld->special) { spechit[numspechit] = ld; numspechit++; @@ -225,13 +225,13 @@ boolean PIT_CheckLine(line_t *ld) } return false; } - if(!(tmthing->flags&MF_MISSILE)) + if (!(tmthing->flags & MF_MISSILE)) { - if(ld->flags&ML_BLOCKING) + if (ld->flags & ML_BLOCKING) { // Explicitly blocking everything return(false); } - if(!tmthing->player && ld->flags&ML_BLOCKMONSTERS + if (!tmthing->player && ld->flags & ML_BLOCKMONSTERS && tmthing->type != MT_POD) { // Block monsters only return(false); @@ -239,20 +239,20 @@ boolean PIT_CheckLine(line_t *ld) } P_LineOpening(ld); // set openrange, opentop, openbottom // adjust floor / ceiling heights - if(opentop < tmceilingz) + if (opentop < tmceilingz) { tmceilingz = opentop; ceilingline = ld; } - if(openbottom > tmfloorz) + if (openbottom > tmfloorz) { tmfloorz = openbottom; } - if(lowfloor < tmdropoffz) + if (lowfloor < tmdropoffz) { tmdropoffz = lowfloor; } - if(ld->special) + if (ld->special) { // Contacted a special line, add it to the list spechit[numspechit] = ld; numspechit++; @@ -272,41 +272,41 @@ boolean PIT_CheckThing(mobj_t *thing) boolean solid; int damage; - if(!(thing->flags&(MF_SOLID|MF_SPECIAL|MF_SHOOTABLE))) + if (!(thing->flags & (MF_SOLID | MF_SPECIAL | MF_SHOOTABLE))) { // Can't hit thing return(true); } - blockdist = thing->radius+tmthing->radius; - if(abs(thing->x-tmx) >= blockdist || abs(thing->y-tmy) >= blockdist) + blockdist = thing->radius + tmthing->radius; + if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) { // Didn't hit thing return(true); } - if(thing == tmthing) + if (thing == tmthing) { // Don't clip against self return(true); } - if(tmthing->flags2&MF2_PASSMOBJ) + if (tmthing->flags2 & MF2_PASSMOBJ) { // check if a mobj passed over/under another object - if((tmthing->type == MT_IMP || tmthing->type == MT_WIZARD) + if ((tmthing->type == MT_IMP || tmthing->type == MT_WIZARD) && (thing->type == MT_IMP || thing->type == MT_WIZARD)) { // don't let imps/wizards fly over other imps/wizards return false; } - if(tmthing->z > thing->z+thing->height - && !(thing->flags&MF_SPECIAL)) - { + if (tmthing->z > thing->z + thing->height + && !(thing->flags & MF_SPECIAL)) + { return(true); } - else if(tmthing->z+tmthing->height < thing->z - && !(thing->flags&MF_SPECIAL)) + else if (tmthing->z + tmthing->height < thing->z + && !(thing->flags & MF_SPECIAL)) { // under thing return(true); } } // Check for skulls slamming into things - if(tmthing->flags&MF_SKULLFLY) + if (tmthing->flags & MF_SKULLFLY) { - damage = ((P_Random()%8)+1)*tmthing->damage; + damage = ((P_Random() % 8) + 1) * tmthing->damage; P_DamageMobj(thing, tmthing, tmthing, damage); tmthing->flags &= ~MF_SKULLFLY; tmthing->momx = tmthing->momy = tmthing->momz = 0; @@ -314,60 +314,60 @@ boolean PIT_CheckThing(mobj_t *thing) return(false); } // Check for missile - if(tmthing->flags&MF_MISSILE) + if (tmthing->flags & MF_MISSILE) { // Check for passing through a ghost - if((thing->flags&MF_SHADOW) && (tmthing->flags2&MF2_THRUGHOST)) + if ((thing->flags & MF_SHADOW) && (tmthing->flags2 & MF2_THRUGHOST)) { return(true); } // Check if it went over / under - if(tmthing->z > thing->z+thing->height) + if (tmthing->z > thing->z + thing->height) { // Over thing return(true); } - if(tmthing->z+tmthing->height < thing->z) + if (tmthing->z + tmthing->height < thing->z) { // Under thing return(true); } - if(tmthing->target && tmthing->target->type == thing->type) + if (tmthing->target && tmthing->target->type == thing->type) { // Don't hit same species as originator - if(thing == tmthing->target) + if (thing == tmthing->target) { // Don't missile self return(true); } - if(thing->type != MT_PLAYER) + if (thing->type != MT_PLAYER) { // Hit same species as originator, explode, no damage return(false); } } - if(!(thing->flags&MF_SHOOTABLE)) + if (!(thing->flags & MF_SHOOTABLE)) { // Didn't do any damage - return!(thing->flags&MF_SOLID); + return!(thing->flags & MF_SOLID); } - if(tmthing->flags2&MF2_RIP) + if (tmthing->flags2 & MF2_RIP) { - if(!(thing->flags&MF_NOBLOOD)) + if (!(thing->flags & MF_NOBLOOD)) { // Ok to spawn some blood P_RipperBlood(tmthing); } S_StartSound(tmthing, sfx_ripslop); - damage = ((P_Random()&3)+2)*tmthing->damage; + damage = ((P_Random() & 3) + 2) * tmthing->damage; P_DamageMobj(thing, tmthing, tmthing->target, damage); - if(thing->flags2&MF2_PUSHABLE - && !(tmthing->flags2&MF2_CANNOTPUSH)) + if (thing->flags2 & MF2_PUSHABLE + && !(tmthing->flags2 & MF2_CANNOTPUSH)) { // Push thing - thing->momx += tmthing->momx>>2; - thing->momy += tmthing->momy>>2; + thing->momx += tmthing->momx >> 2; + thing->momy += tmthing->momy >> 2; } numspechit = 0; return(true); } // Do damage - damage = ((P_Random()%8)+1)*tmthing->damage; - if(damage) + damage = ((P_Random() % 8) + 1) * tmthing->damage; + if (damage) { - if(!(thing->flags&MF_NOBLOOD) && P_Random() < 192) + if (!(thing->flags & MF_NOBLOOD) && P_Random() < 192) { P_BloodSplatter(tmthing->x, tmthing->y, tmthing->z, thing); } @@ -375,22 +375,22 @@ boolean PIT_CheckThing(mobj_t *thing) } return(false); } - if(thing->flags2&MF2_PUSHABLE && !(tmthing->flags2&MF2_CANNOTPUSH)) + if (thing->flags2 & MF2_PUSHABLE && !(tmthing->flags2 & MF2_CANNOTPUSH)) { // Push thing - thing->momx += tmthing->momx>>2; - thing->momy += tmthing->momy>>2; + thing->momx += tmthing->momx >> 2; + thing->momy += tmthing->momy >> 2; } // Check for special thing - if(thing->flags&MF_SPECIAL) + if (thing->flags & MF_SPECIAL) { - solid = thing->flags&MF_SOLID; - if(tmflags&MF_PICKUP) + solid = thing->flags & MF_SOLID; + if (tmflags & MF_PICKUP) { // Can be picked up by tmthing P_TouchSpecialThing(thing, tmthing); // Can remove thing } return(!solid); } - return(!(thing->flags&MF_SOLID)); + return(!(thing->flags & MF_SOLID)); } //--------------------------------------------------------------------------- @@ -403,39 +403,39 @@ boolean PIT_CheckOnmobjZ(mobj_t *thing) { fixed_t blockdist; - if(!(thing->flags&(MF_SOLID|MF_SPECIAL|MF_SHOOTABLE))) + if (!(thing->flags & (MF_SOLID | MF_SPECIAL | MF_SHOOTABLE))) { // Can't hit thing return(true); } - blockdist = thing->radius+tmthing->radius; - if(abs(thing->x-tmx) >= blockdist || abs(thing->y-tmy) >= blockdist) + blockdist = thing->radius + tmthing->radius; + if (abs(thing->x - tmx) >= blockdist || abs(thing->y - tmy) >= blockdist) { // Didn't hit thing return(true); } - if(thing == tmthing) + if (thing == tmthing) { // Don't clip against self return(true); } - if(tmthing->z > thing->z+thing->height) - { + if (tmthing->z > thing->z + thing->height) + { return(true); } - else if(tmthing->z+tmthing->height < thing->z) + else if (tmthing->z + tmthing->height < thing->z) { // under thing return(true); } - if(thing->flags&MF_SOLID) + if (thing->flags & MF_SOLID) { onmobj = thing; } - return(!(thing->flags&MF_SOLID)); + return(!(thing->flags & MF_SOLID)); } /* =============================================================================== - MOVEMENT CLIPPING - + MOVEMENT CLIPPING + =============================================================================== */ @@ -454,11 +454,11 @@ boolean P_TestMobjLocation(mobj_t *mobj) flags = mobj->flags; mobj->flags &= ~MF_PICKUP; - if(P_CheckPosition(mobj, mobj->x, mobj->y)) + if (P_CheckPosition(mobj, mobj->x, mobj->y)) { // XY is ok, now check Z mobj->flags = flags; - if((mobj->z < mobj->floorz) - || (mobj->z+mobj->height > mobj->ceilingz)) + if ((mobj->z < mobj->floorz) + || (mobj->z + mobj->height > mobj->ceilingz)) { // Bad Z return(false); } @@ -496,62 +496,62 @@ numspeciallines boolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y) { - int xl,xh,yl,yh,bx,by; - subsector_t *newsubsec; + int xl, xh, yl, yh, bx, 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); + newsubsec = R_PointInSubsector (x, y); ceilingline = NULL; - -// -// the base floor / ceiling is from the subsector that contains the -// point. Any contacted lines the step closer together will adjust them -// + + // + // the base floor / ceiling is from the subsector that contains the + // point. Any contacted lines the step closer together will adjust them + // tmfloorz = tmdropoffz = newsubsec->sector->floorheight; tmceilingz = newsubsec->sector->ceilingheight; - + validcount++; numspechit = 0; - if ( tmflags & MF_NOCLIP ) + if (tmflags & MF_NOCLIP) return true; -// -// check things first, possibly picking things up -// the bounding box is extended by MAXRADIUS because mobj_ts are grouped -// into mapblocks based on their origin point, and can overlap into adjacent -// blocks by up to MAXRADIUS units -// - 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)) + // + // check things first, possibly picking things up + // the bounding box is extended by MAXRADIUS because mobj_ts are grouped + // into mapblocks based on their origin point, and can overlap into adjacent + // blocks by up to MAXRADIUS units + // + 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; -// -// check lines -// - 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)) + // + // check lines + // + 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; @@ -566,57 +566,57 @@ boolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y) mobj_t *P_CheckOnmobj(mobj_t *thing) { - int xl,xh,yl,yh,bx,by; - subsector_t *newsubsec; + int xl, xh, yl, yh, bx, by; + subsector_t *newsubsec; fixed_t x; fixed_t y; mobj_t oldmo; - + x = thing->x; y = thing->y; tmthing = thing; tmflags = thing->flags; oldmo = *thing; // save the old mobj before the fake zmovement P_FakeZMovement(tmthing); - + 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); + newsubsec = R_PointInSubsector (x, y); ceilingline = NULL; - -// -// the base floor / ceiling is from the subsector that contains the -// point. Any contacted lines the step closer together will adjust them -// + + // + // the base floor / ceiling is from the subsector that contains the + // point. Any contacted lines the step closer together will adjust them + // tmfloorz = tmdropoffz = newsubsec->sector->floorheight; tmceilingz = newsubsec->sector->ceilingheight; - + validcount++; numspechit = 0; - if ( tmflags & MF_NOCLIP ) + if (tmflags & MF_NOCLIP) return NULL; -// -// check things first, possibly picking things up -// the bounding box is extended by MAXRADIUS because mobj_ts are grouped -// into mapblocks based on their origin point, and can overlap into adjacent -// blocks by up to MAXRADIUS units -// - 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_CheckOnmobjZ)) + // + // check things first, possibly picking things up + // the bounding box is extended by MAXRADIUS because mobj_ts are grouped + // into mapblocks based on their origin point, and can overlap into adjacent + // blocks by up to MAXRADIUS units + // + 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_CheckOnmobjZ)) { *tmthing = oldmo; return onmobj; @@ -636,67 +636,67 @@ void P_FakeZMovement(mobj_t *mo) { int dist; int delta; -// -// adjust height -// + // + // adjust height + // mo->z += mo->momz; - if(mo->flags&MF_FLOAT && mo->target) + if (mo->flags & MF_FLOAT && mo->target) { // float down towards target if too close - if(!(mo->flags&MF_SKULLFLY) && !(mo->flags&MF_INFLOAT)) + 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)) + 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; + else if (delta > 0 && dist < (delta * 3)) + mo->z += FLOATSPEED; } } - if(mo->player && mo->flags2&MF2_FLY && !(mo->z <= mo->floorz) - && leveltime&2) + if (mo->player && mo->flags2 & MF2_FLY && !(mo->z <= mo->floorz) + && leveltime & 2) { - mo->z += finesine[(FINEANGLES/20*leveltime>>2)&FINEMASK]; + mo->z += finesine[(FINEANGLES / 20 * leveltime >> 2) & FINEMASK]; } -// -// clip movement -// - if(mo->z <= mo->floorz) + // + // clip movement + // + if (mo->z <= mo->floorz) { // Hit the floor mo->z = mo->floorz; - if(mo->momz < 0) + if (mo->momz < 0) { mo->momz = 0; } - if(mo->flags&MF_SKULLFLY) + if (mo->flags & MF_SKULLFLY) { // The skull slammed into something mo->momz = -mo->momz; } - if(mo->info->crashstate && (mo->flags&MF_CORPSE)) + if (mo->info->crashstate && (mo->flags & MF_CORPSE)) { return; } } - else if(mo->flags2&MF2_LOGRAV) + else if (mo->flags2 & MF2_LOGRAV) { - if(mo->momz == 0) - mo->momz = -(GRAVITY>>3)*2; + if (mo->momz == 0) + mo->momz = -(GRAVITY >> 3) * 2; else - mo->momz -= GRAVITY>>3; + mo->momz -= GRAVITY >> 3; } - else if (! (mo->flags & MF_NOGRAVITY) ) + else if (!(mo->flags & MF_NOGRAVITY)) { if (mo->momz == 0) - mo->momz = -GRAVITY*2; + mo->momz = -GRAVITY * 2; else mo->momz -= GRAVITY; } - + if (mo->z + mo->height > mo->ceilingz) { // hit the ceiling if (mo->momz > 0) mo->momz = 0; - mo->z = mo->ceilingz - mo->height; + mo->z = mo->ceilingz - mo->height; if (mo->flags & MF_SKULLFLY) { // the skull slammed into something mo->momz = -mo->momz; @@ -714,15 +714,15 @@ void CheckMissileImpact(mobj_t *mobj) { int i; - if(!numspechit || !(mobj->flags&MF_MISSILE) || !mobj->target) + if (!numspechit || !(mobj->flags & MF_MISSILE) || !mobj->target) { return; } - if(!mobj->target->player) + if (!mobj->target->player) { return; } - for(i = numspechit-1; i >= 0; i--) + for (i = numspechit - 1; i >= 0; i--) { P_ShootSpecialLine(mobj->target, spechit[i]); } @@ -743,98 +743,98 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y) { fixed_t oldx, oldy; int side, oldside; - line_t *ld; + line_t *ld; floatok = false; - if(!P_CheckPosition(thing, x, y)) + if (!P_CheckPosition(thing, x, y)) { // Solid wall or thing CheckMissileImpact(thing); return false; } - if(!(thing->flags&MF_NOCLIP)) + if (!(thing->flags & MF_NOCLIP)) { - if(tmceilingz-tmfloorz < thing->height) + if (tmceilingz - tmfloorz < thing->height) { // Doesn't fit CheckMissileImpact(thing); return false; } floatok = true; - if(!(thing->flags&MF_TELEPORT) - && tmceilingz-thing->z < thing->height - && !(thing->flags2&MF2_FLY)) + if (!(thing->flags & MF_TELEPORT) + && tmceilingz - thing->z < thing->height + && !(thing->flags2 & MF2_FLY)) { // mobj must lower itself to fit CheckMissileImpact(thing); return false; } - if(thing->flags2&MF2_FLY) + if (thing->flags2 & MF2_FLY) { - if(thing->z+thing->height > tmceilingz) + if (thing->z + thing->height > tmceilingz) { - thing->momz = -8*FRACUNIT; + thing->momz = -8 * FRACUNIT; return false; } - else if(thing->z < tmfloorz && tmfloorz-tmdropoffz > 24*FRACUNIT) + else if (thing->z < tmfloorz && tmfloorz - tmdropoffz > 24 * FRACUNIT) { - thing->momz = 8*FRACUNIT; + thing->momz = 8 * FRACUNIT; return false; } } - if(!(thing->flags&MF_TELEPORT) + if (!(thing->flags & MF_TELEPORT) // The Minotaur floor fire (MT_MNTRFX2) can step up any amount && thing->type != MT_MNTRFX2 - && tmfloorz-thing->z > 24*FRACUNIT) + && tmfloorz - thing->z > 24 * FRACUNIT) { // Too big a step up CheckMissileImpact(thing); return false; } - if((thing->flags&MF_MISSILE) && tmfloorz > thing->z) + if ((thing->flags & MF_MISSILE) && tmfloorz > thing->z) { CheckMissileImpact(thing); } - if(!(thing->flags&(MF_DROPOFF|MF_FLOAT)) - && tmfloorz-tmdropoffz > 24*FRACUNIT) + if (!(thing->flags & (MF_DROPOFF | MF_FLOAT)) + && tmfloorz - tmdropoffz > 24 * FRACUNIT) { // Can't move over a dropoff return false; } } -// -// the move is ok, so link the thing into its new position -// + // + // the move is ok, so link the thing into its new position + // P_UnsetThingPosition (thing); oldx = thing->x; oldy = thing->y; thing->floorz = tmfloorz; - thing->ceilingz = tmceilingz; + thing->ceilingz = tmceilingz; thing->x = x; thing->y = y; P_SetThingPosition (thing); - - if(thing->flags2&MF2_FOOTCLIP && P_GetThingFloorType(thing) != FLOOR_SOLID) + + if (thing->flags2 & MF2_FOOTCLIP && P_GetThingFloorType(thing) != FLOOR_SOLID) { thing->flags2 |= MF2_FEETARECLIPPED; } - else if(thing->flags2&MF2_FEETARECLIPPED) + else if (thing->flags2 & MF2_FEETARECLIPPED) { thing->flags2 &= ~MF2_FEETARECLIPPED; } - -// -// if any special lines were hit, do the effect -// - if (! (thing->flags&(MF_TELEPORT|MF_NOCLIP)) ) + + // + // if any special lines were hit, do the effect + // + if (!(thing->flags & (MF_TELEPORT | MF_NOCLIP))) while (numspechit--) { - // see if the line was crossed + // see if the line was crossed ld = spechit[numspechit]; side = P_PointOnLineSide (thing->x, thing->y, ld); oldside = P_PointOnLineSide (oldx, oldy, ld); if (side != oldside) { if (ld->special) - P_CrossSpecialLine (ld-lines, oldside, thing); + P_CrossSpecialLine (ld - lines, oldside, thing); } } @@ -859,27 +859,27 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y) boolean P_ThingHeightClip (mobj_t *thing) { boolean onfloor; - + onfloor = (thing->z == thing->floorz); - - P_CheckPosition (thing, thing->x, thing->y); + + P_CheckPosition (thing, thing->x, thing->y); // what about stranding a monster partially off an edge? - + thing->floorz = tmfloorz; thing->ceilingz = tmceilingz; - + if (onfloor) - // walking monsters rise and fall with the floor + // walking monsters rise and fall with the floor thing->z = thing->floorz; else { // don't adjust a floating monster unless forced to - if (thing->z+thing->height > thing->ceilingz) + if (thing->z + thing->height > thing->ceilingz) thing->z = thing->ceilingz - thing->height; } - + if (thing->ceilingz - thing->floorz < thing->height) return false; - + return true; } @@ -895,8 +895,8 @@ Allows the player to slide along any angled walls */ fixed_t bestslidefrac, secondslidefrac; -line_t *bestslideline, *secondslideline; -mobj_t *slidemo; +line_t *bestslideline, *secondslideline; +mobj_t *slidemo; fixed_t tmxmove, tmymove; @@ -914,8 +914,8 @@ void P_HitSlideLine (line_t *ld) int side; angle_t lineangle, moveangle, deltaangle; fixed_t movelen, newlen; - - + + if (ld->slopetype == ST_HORIZONTAL) { tmymove = 0; @@ -926,25 +926,25 @@ void P_HitSlideLine (line_t *ld) tmxmove = 0; return; } - + side = P_PointOnLineSide (slidemo->x, slidemo->y, ld); - - lineangle = R_PointToAngle2 (0,0, ld->dx, ld->dy); + + lineangle = R_PointToAngle2 (0, 0, ld->dx, ld->dy); if (side == 1) lineangle += ANG180; - moveangle = R_PointToAngle2 (0,0, tmxmove, tmymove); - deltaangle = moveangle-lineangle; + moveangle = R_PointToAngle2 (0, 0, tmxmove, tmymove); + deltaangle = moveangle - lineangle; if (deltaangle > ANG180) deltaangle += ANG180; -// I_Error ("SlideLine: ang>ANG180"); + // I_Error ("SlideLine: ang>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]); + tmxmove = FixedMul (newlen, finecosine[lineangle]); + tmymove = FixedMul (newlen, finesine[lineangle]); } /* @@ -957,13 +957,13 @@ void P_HitSlideLine (line_t *ld) boolean PTR_SlideTraverse (intercept_t *in) { - line_t *li; - + line_t *li; + if (!in->isaline) I_Error ("PTR_SlideTraverse: not a line?"); - + li = in->d.line; - if ( ! (li->flags & ML_TWOSIDED) ) + if (!(li->flags & ML_TWOSIDED)) { if (P_PointOnLineSide (slidemo->x, slidemo->y, li)) return true; // don't hit the back side @@ -973,17 +973,17 @@ boolean PTR_SlideTraverse (intercept_t *in) P_LineOpening (li); // set openrange, opentop, openbottom if (openrange < slidemo->height) goto isblocking; // doesn't fit - + if (opentop - slidemo->z < slidemo->height) goto isblocking; // mobj is too high - if (openbottom - slidemo->z > 24*FRACUNIT ) + if (openbottom - slidemo->z > 24 * FRACUNIT) goto isblocking; // too big a step up return true; // this line doesn't block movement - + // the line does block movement, see if it is closer than best so far -isblocking: +isblocking: if (in->frac < bestslidefrac) { secondslidefrac = bestslidefrac; @@ -991,7 +991,7 @@ isblocking: bestslidefrac = in->frac; bestslideline = li; } - + return false; // stop } @@ -1015,13 +1015,13 @@ void P_SlideMove (mobj_t *mo) fixed_t trailx, traily; fixed_t newx, newy; int hitcount; - + slidemo = mo; hitcount = 0; retry: if (++hitcount == 3) goto stairstep; // don't loop forever - + // // trace along the three leading corners // @@ -1035,7 +1035,7 @@ retry: leadx = mo->x - mo->radius; trailx = mo->x + mo->radius; } - + if (mo->momy > 0) { leady = mo->y + mo->radius; @@ -1046,45 +1046,45 @@ retry: 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 ); -// -// move up to the wall -// - if (bestslidefrac == FRACUNIT+1) + 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); + + // + // move up to the wall + // + if (bestslidefrac == FRACUNIT + 1) { // the move most have hit the middle, so stairstep stairstep: if (!P_TryMove (mo, mo->x, mo->y + mo->momy)) P_TryMove (mo, mo->x + mo->momx, mo->y); return; } - + bestslidefrac -= 0x800; // fudge a bit to make sure it doesn't hit if (bestslidefrac > 0) { newx = FixedMul (mo->momx, bestslidefrac); newy = FixedMul (mo->momy, bestslidefrac); - if (!P_TryMove (mo, mo->x+newx, mo->y+newy)) + if (!P_TryMove (mo, mo->x + newx, mo->y + newy)) goto stairstep; } - -// -// now continue along the wall -// - bestslidefrac = FRACUNIT-(bestslidefrac+0x800); // remainder + + // + // now continue along the wall + // + bestslidefrac = FRACUNIT - (bestslidefrac + 0x800); // remainder if (bestslidefrac > FRACUNIT) bestslidefrac = FRACUNIT; if (bestslidefrac <= 0) return; - + tmxmove = FixedMul (mo->momx, bestslidefrac); tmymove = FixedMul (mo->momy, bestslidefrac); @@ -1092,8 +1092,8 @@ stairstep: mo->momx = tmxmove; mo->momy = tmymove; - - if (!P_TryMove (mo, mo->x+tmxmove, mo->y+tmymove)) + + if (!P_TryMove (mo, mo->x + tmxmove, mo->y + tmymove)) { goto retry; } @@ -1110,8 +1110,8 @@ stairstep: */ -mobj_t *linetarget; // who got hit (or NULL) -mobj_t *shootthing; +mobj_t *linetarget; // who got hit (or NULL) +mobj_t *shootthing; fixed_t shootz; // height if not aiming up or down // ???: use slope for monsters? int la_damage; @@ -1132,63 +1132,63 @@ extern fixed_t topslope, bottomslope; // slopes to top and bottom of target boolean PTR_AimTraverse (intercept_t *in) { - line_t *li; - mobj_t *th; + line_t *li; + mobj_t *th; fixed_t slope, thingtopslope, thingbottomslope; fixed_t dist; - + if (in->isaline) { li = in->d.line; - if ( !(li->flags & ML_TWOSIDED) ) + if (!(li->flags & ML_TWOSIDED)) return false; // stop // // crosses a two sided line // a two sided line will restrict the possible target ranges P_LineOpening (li); - + if (openbottom >= opentop) return false; // stop - + dist = FixedMul (attackrange, in->frac); if (li->frontsector->floorheight != li->backsector->floorheight) { - slope = FixedDiv (openbottom - shootz , dist); + slope = FixedDiv (openbottom - shootz, dist); if (slope > bottomslope) bottomslope = slope; } - + if (li->frontsector->ceilingheight != li->backsector->ceilingheight) { - slope = FixedDiv (opentop - shootz , dist); + slope = FixedDiv (opentop - shootz, dist); if (slope < topslope) topslope = slope; } - + if (topslope <= bottomslope) return false; // stop - + return true; // shot continues } - -// -// shoot a thing -// + + // + // shoot a thing + // th = in->d.thing; if (th == shootthing) return true; // can't shoot self - if (!(th->flags&MF_SHOOTABLE)) + if (!(th->flags & MF_SHOOTABLE)) return true; // corpse or something - if(th->type == MT_POD) + if (th->type == MT_POD) { // Can't auto-aim at pods return(true); } -// check angles to see if the thing can be aimed at + // check angles to see if the thing can be aimed at dist = FixedMul (attackrange, in->frac); - thingtopslope = FixedDiv (th->z+th->height - shootz , dist); + thingtopslope = FixedDiv (th->z + th->height - shootz, dist); if (thingtopslope < bottomslope) return true; // shot over the thing thingbottomslope = FixedDiv (th->z - shootz, dist); @@ -1203,7 +1203,7 @@ boolean PTR_AimTraverse (intercept_t *in) if (thingbottomslope < bottomslope) thingbottomslope = bottomslope; - aimslope = (thingtopslope+thingbottomslope)/2; + aimslope = (thingtopslope + thingbottomslope) / 2; linetarget = th; return false; // don't go any farther @@ -1220,10 +1220,10 @@ boolean PTR_AimTraverse (intercept_t *in) boolean PTR_ShootTraverse (intercept_t *in) { - fixed_t x,y,z; + fixed_t x, y, z; fixed_t frac; - line_t *li; - mobj_t *th; + line_t *li; + mobj_t *th; fixed_t slope; fixed_t dist; fixed_t thingtopslope, thingbottomslope; @@ -1234,37 +1234,37 @@ boolean PTR_ShootTraverse (intercept_t *in) li = in->d.line; if (li->special) P_ShootSpecialLine (shootthing, li); - if ( !(li->flags & ML_TWOSIDED) ) + if (!(li->flags & ML_TWOSIDED)) goto hitline; -// -// crosses a two sided line -// + // + // crosses a two sided line + // P_LineOpening (li); - + dist = FixedMul (attackrange, in->frac); if (li->frontsector->floorheight != li->backsector->floorheight) { - slope = FixedDiv (openbottom - shootz , dist); + slope = FixedDiv (openbottom - shootz, dist); if (slope > aimslope) goto hitline; } - + if (li->frontsector->ceilingheight != li->backsector->ceilingheight) { - slope = FixedDiv (opentop - shootz , dist); + slope = FixedDiv (opentop - shootz, dist); if (slope < aimslope) goto hitline; } - + return true; // shot continues // // hit line // hitline: // position a bit closer - frac = in->frac - FixedDiv (4*FRACUNIT,attackrange); + 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)); @@ -1273,34 +1273,34 @@ hitline: { if (z > li->frontsector->ceilingheight) return false; // don't shoot the sky! - if (li->backsector && li->backsector->ceilingpic == skyflatnum) + if (li->backsector && li->backsector->ceilingpic == skyflatnum) return false; // it's a sky hack wall } - - P_SpawnPuff (x,y,z); + + P_SpawnPuff (x, y, z); return false; // don't go any farther } - -// -// shoot a thing -// + + // + // shoot a thing + // th = in->d.thing; if (th == shootthing) return true; // can't shoot self - if (!(th->flags&MF_SHOOTABLE)) + if (!(th->flags & MF_SHOOTABLE)) return true; // corpse or something // // check for physical attacks on a ghost // - if(th->flags&MF_SHADOW && shootthing->player->readyweapon == wp_staff) + if (th->flags & MF_SHADOW && shootthing->player->readyweapon == wp_staff) { return(true); } -// check angles to see if the thing can be aimed at + // check angles to see if the thing can be aimed at dist = FixedMul (attackrange, in->frac); - thingtopslope = FixedDiv (th->z+th->height - shootz , dist); + thingtopslope = FixedDiv (th->z + th->height - shootz, dist); if (thingtopslope < aimslope) return true; // shot over the thing thingbottomslope = FixedDiv (th->z - shootz, dist); @@ -1311,11 +1311,11 @@ hitline: // hit thing // // position a bit closer - frac = in->frac - FixedDiv (10*FRACUNIT,attackrange); + 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(PuffType == MT_BLASTERPUFF1) + if (PuffType == MT_BLASTERPUFF1) { // Make blaster big puff mo = P_SpawnMobj(x, y, z, MT_BLASTERPUFF2); S_StartSound(mo, sfx_blshit); @@ -1324,9 +1324,9 @@ hitline: { P_SpawnPuff(x, y, z); } - if(la_damage) + if (la_damage) { - if(!(in->d.thing->flags&MF_NOBLOOD) && P_Random() < 192) + if (!(in->d.thing->flags & MF_NOBLOOD) && P_Random() < 192) { P_BloodSplatter(x, y, z, in->d.thing); } @@ -1346,20 +1346,20 @@ hitline: fixed_t P_AimLineAttack (mobj_t *t1, angle_t angle, fixed_t distance) { fixed_t x2, 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; // can't shoot outside view angles - bottomslope = -100*FRACUNIT/160; + 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; // can't shoot outside view angles + bottomslope = -100 * FRACUNIT / 160; attackrange = distance; linetarget = NULL; - - P_PathTraverse ( t1->x, t1->y, x2, y2 - , PT_ADDLINES|PT_ADDTHINGS, PTR_AimTraverse ); - + + P_PathTraverse (t1->x, t1->y, x2, y2 + , PT_ADDLINES | PT_ADDTHINGS, PTR_AimTraverse); + if (linetarget) return aimslope; return 0; @@ -1380,22 +1380,22 @@ fixed_t P_AimLineAttack (mobj_t *t1, angle_t angle, fixed_t distance) void P_LineAttack (mobj_t *t1, angle_t angle, fixed_t distance, fixed_t slope, int damage) { fixed_t x2, y2; - + angle >>= ANGLETOFINESHIFT; shootthing = t1; la_damage = damage; - x2 = t1->x + (distance>>FRACBITS)*finecosine[angle]; - y2 = t1->y + (distance>>FRACBITS)*finesine[angle]; - shootz = t1->z + (t1->height>>1) + 8*FRACUNIT; - if(t1->flags2&MF2_FEETARECLIPPED) + x2 = t1->x + (distance >> FRACBITS) * finecosine[angle]; + y2 = t1->y + (distance >> FRACBITS) * finesine[angle]; + shootz = t1->z + (t1->height >> 1) + 8 * FRACUNIT; + if (t1->flags2 & MF2_FEETARECLIPPED) { shootz -= FOOTCLIPSIZE; } attackrange = distance; aimslope = slope; - - P_PathTraverse ( t1->x, t1->y, x2, y2 - , PT_ADDLINES|PT_ADDTHINGS, PTR_ShootTraverse ); + + P_PathTraverse (t1->x, t1->y, x2, y2 + , PT_ADDLINES | PT_ADDTHINGS, PTR_ShootTraverse); } @@ -1408,7 +1408,7 @@ void P_LineAttack (mobj_t *t1, angle_t angle, fixed_t distance, fixed_t slope, i ============================================================================== */ -mobj_t *usething; +mobj_t *usething; boolean PTR_UseTraverse (intercept_t *in) { @@ -1420,12 +1420,12 @@ boolean PTR_UseTraverse (intercept_t *in) //S_StartSound (usething, sfx_noway); return false; // can't use through a wall } - return true ; // not a special line, but keep checking + return true; // not a special line, but keep checking } - + if (P_PointOnLineSide (usething->x, usething->y, in->d.line) == 1) return false; // don't use back sides - + P_UseSpecialLine (usething, in->d.line); return false; // can't use for than one special line in a row @@ -1438,23 +1438,23 @@ boolean PTR_UseTraverse (intercept_t *in) = P_UseLines = = Looks for special lines in front of the player to activate -================ +================ */ void P_UseLines (player_t *player) { int angle; fixed_t x1, y1, x2, 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 ); + x2 = x1 + (USERANGE >> FRACBITS) * finecosine[angle]; + y2 = y1 + (USERANGE >> FRACBITS) * finesine[angle]; + + P_PathTraverse (x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse); } @@ -1467,8 +1467,8 @@ void P_UseLines (player_t *player) ============================================================================== */ -mobj_t *bombsource; -mobj_t *bombspot; +mobj_t *bombsource; +mobj_t *bombspot; int bombdamage; /* @@ -1484,11 +1484,11 @@ boolean PIT_RadiusAttack (mobj_t *thing) { fixed_t dx, dy, dist; - if(!(thing->flags&MF_SHOOTABLE)) + if (!(thing->flags & MF_SHOOTABLE)) { return true; } - if(thing->type == MT_MINOTAUR || thing->type == MT_SORCERER1 + if (thing->type == MT_MINOTAUR || thing->type == MT_SORCERER1 || thing->type == MT_SORCERER2) { // Episode 2 and 3 bosses take no damage from PIT_RadiusAttack return(true); @@ -1497,15 +1497,15 @@ boolean PIT_RadiusAttack (mobj_t *thing) dy = abs(thing->y - bombspot->y); dist = dx > dy ? dx : dy; dist = (dist - thing->radius) >> FRACBITS; - if(dist < 0) + if (dist < 0) { dist = 0; } - if(dist >= bombdamage) + if (dist >= bombdamage) { // Out of range return true; } - if(P_CheckSight(thing, bombspot)) + if (P_CheckSight(thing, bombspot)) { // OK to damage, target is in direct path P_DamageMobj(thing, bombspot, bombsource, bombdamage - dist); } @@ -1523,16 +1523,16 @@ boolean PIT_RadiusAttack (mobj_t *thing) void P_RadiusAttack (mobj_t *spot, mobj_t *source, int damage) { - int x,y, xl, xh, yl, yh; + int x, y, xl, xh, yl, yh; fixed_t dist; - - dist = (damage+MAXRADIUS)<y + dist - bmaporgy)>>MAPBLOCKSHIFT; - yl = (spot->y - dist - bmaporgy)>>MAPBLOCKSHIFT; - xh = (spot->x + dist - bmaporgx)>>MAPBLOCKSHIFT; - xl = (spot->x - dist - bmaporgx)>>MAPBLOCKSHIFT; + + dist = (damage + MAXRADIUS) << FRACBITS; + yh = (spot->y + dist - bmaporgy) >> MAPBLOCKSHIFT; + yl = (spot->y - dist - bmaporgy) >> MAPBLOCKSHIFT; + xh = (spot->x + dist - bmaporgx) >> MAPBLOCKSHIFT; + xl = (spot->x - dist - bmaporgx) >> MAPBLOCKSHIFT; bombspot = spot; - if(spot->type == MT_POD && spot->target) + if (spot->type == MT_POD && spot->target) { bombsource = spot->target; } @@ -1541,9 +1541,9 @@ void P_RadiusAttack (mobj_t *spot, mobj_t *source, int damage) bombsource = source; } bombdamage = damage; - for (y=yl ; y<=yh ; y++) - for (x=xl ; x<=xh ; x++) - P_BlockThingsIterator (x, y, PIT_RadiusAttack ); + for (y = yl; y <= yh; y++) + for (x = xl; x <= xh; x++) + P_BlockThingsIterator (x, y, PIT_RadiusAttack); } @@ -1576,8 +1576,8 @@ boolean nofit; boolean PIT_ChangeSector (mobj_t *thing) { - mobj_t *mo; - + mobj_t *mo; + if (P_ThingHeightClip (thing)) return true; // keep checking @@ -1597,19 +1597,19 @@ boolean PIT_ChangeSector (mobj_t *thing) return true; // keep checking } - if (! (thing->flags & MF_SHOOTABLE) ) + if (!(thing->flags & MF_SHOOTABLE)) return true; // assume it is bloody gibs or something - + nofit = true; - if (crushchange && !(leveltime&3) ) + if (crushchange && !(leveltime & 3)) { - P_DamageMobj(thing,NULL,NULL,10); + P_DamageMobj(thing, NULL, NULL, 10); // spray blood in a random direction - 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; + 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; // keep checking (crush other things) } @@ -1623,18 +1623,18 @@ boolean PIT_ChangeSector (mobj_t *thing) boolean P_ChangeSector (sector_t *sector, boolean crunch) { - int x,y; - + int x, y; + nofit = false; crushchange = crunch; - -// recheck heights for all things near the moving sector - for (x=sector->blockbox[BOXLEFT] ; x<= sector->blockbox[BOXRIGHT] ; x++) - for (y=sector->blockbox[BOXBOTTOM];y<= sector->blockbox[BOXTOP] ; y++) + // recheck heights for all things near the moving sector + + 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/P_MAPUTL.C b/P_MAPUTL.C index 874f902..45b9df4 100644 --- a/P_MAPUTL.C +++ b/P_MAPUTL.C @@ -21,8 +21,8 @@ fixed_t P_AproxDistance (fixed_t dx, fixed_t dy) dx = abs(dx); dy = abs(dy); if (dx < dy) - return dx+dy-(dx>>1); - return dx+dy-(dy>>1); + return dx + dy - (dx >> 1); + return dx + dy - (dy >> 1); } @@ -37,9 +37,9 @@ fixed_t P_AproxDistance (fixed_t dx, fixed_t dy) int P_PointOnLineSide (fixed_t x, fixed_t y, line_t *line) { - fixed_t dx,dy; + fixed_t dx, dy; fixed_t left, right; - + if (!line->dx) { if (x <= line->v1->x) @@ -52,13 +52,13 @@ int P_PointOnLineSide (fixed_t x, fixed_t y, line_t *line) 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 ); - + + left = FixedMul (line->dy >> FRACBITS, dx); + right = FixedMul (dy, line->dx >> FRACBITS); + if (right < left) return 0; // front side return 1; // back side @@ -78,35 +78,35 @@ int P_PointOnLineSide (fixed_t x, fixed_t y, line_t *line) int P_BoxOnLineSide (fixed_t *tmbox, line_t *ld) { int p1, p2; - + switch (ld->slopetype) { - case ST_HORIZONTAL: - p1 = tmbox[BOXTOP] > ld->v1->y; - p2 = tmbox[BOXBOTTOM] > ld->v1->y; - if (ld->dx < 0) - { - p1 ^= 1; - p2 ^= 1; - } - break; - case ST_VERTICAL: - p1 = tmbox[BOXRIGHT] < ld->v1->x; - p2 = tmbox[BOXLEFT] < ld->v1->x; - if (ld->dy < 0) - { - p1 ^= 1; - 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; + case ST_HORIZONTAL: + p1 = tmbox[BOXTOP] > ld->v1->y; + p2 = tmbox[BOXBOTTOM] > ld->v1->y; + if (ld->dx < 0) + { + p1 ^= 1; + p2 ^= 1; + } + break; + case ST_VERTICAL: + p1 = tmbox[BOXRIGHT] < ld->v1->x; + p2 = tmbox[BOXLEFT] < ld->v1->x; + if (ld->dy < 0) + { + p1 ^= 1; + 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) @@ -125,9 +125,9 @@ int P_BoxOnLineSide (fixed_t *tmbox, line_t *ld) int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t *line) { - fixed_t dx,dy; + fixed_t dx, dy; fixed_t left, right; - + if (!line->dx) { if (x <= line->x) @@ -140,21 +140,21 @@ int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t *line) return line->dx < 0; return line->dx > 0; } - + dx = (x - line->x); dy = (y - line->y); - -// try to quickly decide by looking at sign bits - if ( (line->dy ^ line->dx ^ dx ^ dy)&0x80000000 ) + + // try to quickly decide by looking at sign bits + if ((line->dy ^ line->dx ^ dx ^ dy) & 0x80000000) { - if ( (line->dy ^ dx) & 0x80000000 ) + if ((line->dy ^ dx) & 0x80000000) return 1; // (left is negative) return 0; } - - left = FixedMul ( line->dy>>8, dx>>8 ); - right = FixedMul ( dy>>8 , line->dx>>8 ); - + + left = FixedMul (line->dy >> 8, dx >> 8); + right = FixedMul (dy >> 8, line->dx >> 8); + if (right < left) return 0; // front side return 1; // back side @@ -194,35 +194,35 @@ fixed_t P_InterceptVector (divline_t *v2, divline_t *v1) { #if 1 fixed_t frac, num, den; - - den = FixedMul (v1->dy>>8,v2->dx) - FixedMul(v1->dx>>8,v2->dy); + + den = FixedMul (v1->dy >> 8, v2->dx) - FixedMul(v1->dx >> 8, v2->dy); if (den == 0) return 0; -// I_Error ("P_InterceptVector: parallel"); - num = FixedMul ( (v1->x - v2->x)>>8 ,v1->dy) + - FixedMul ( (v2->y - v1->y)>>8 , v1->dx); - frac = FixedDiv (num , den); + // I_Error ("P_InterceptVector: parallel"); + 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, num, den, v1x,v1y,v1dx,v1dy,v2x,v2y,v2dx,v2dy; - - v1x = (float)v1->x/FRACUNIT; - v1y = (float)v1->y/FRACUNIT; - v1dx = (float)v1->dx/FRACUNIT; - v1dy = (float)v1->dy/FRACUNIT; - v2x = (float)v2->x/FRACUNIT; - v2y = (float)v2->y/FRACUNIT; - v2dx = (float)v2->dx/FRACUNIT; - v2dy = (float)v2->dy/FRACUNIT; - - den = v1dy*v2dx - v1dx*v2dy; + float frac, num, den, v1x, v1y, v1dx, v1dy, v2x, v2y, v2dx, v2dy; + + v1x = (float)v1->x / FRACUNIT; + v1y = (float)v1->y / FRACUNIT; + v1dx = (float)v1->dx / FRACUNIT; + v1dy = (float)v1->dy / FRACUNIT; + v2x = (float)v2->x / FRACUNIT; + 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; // parallel - num = (v1x - v2x)*v1dy + (v2y - v1y)*v1dx; + num = (v1x - v2x) * v1dy + (v2y - v1y) * v1dx; frac = num / den; - return frac*FRACUNIT; + return frac * FRACUNIT; #endif } @@ -241,17 +241,17 @@ fixed_t lowfloor; void P_LineOpening (line_t *linedef) { - sector_t *front, *back; - + sector_t *front, *back; + if (linedef->sidenum[1] == -1) { // single sided line openrange = 0; return; } - + front = linedef->frontsector; back = linedef->backsector; - + if (front->ceilingheight < back->ceilingheight) opentop = front->ceilingheight; else @@ -266,7 +266,7 @@ void P_LineOpening (line_t *linedef) openbottom = back->floorheight; lowfloor = front->floorheight; } - + openrange = opentop - openbottom; } @@ -281,7 +281,7 @@ void P_LineOpening (line_t *linedef) /* =================== = -= P_UnsetThingPosition += P_UnsetThingPosition = = Unlinks a thing from block map and sectors = @@ -292,7 +292,7 @@ void P_UnsetThingPosition (mobj_t *thing) { int blockx, blocky; - if ( ! (thing->flags & MF_NOSECTOR) ) + if (!(thing->flags & MF_NOSECTOR)) { // inert things don't need to be in blockmap // unlink from subsector if (thing->snext) @@ -302,8 +302,8 @@ void P_UnsetThingPosition (mobj_t *thing) else thing->subsector->sector->thinglist = thing->snext; } - - if ( ! (thing->flags & MF_NOBLOCKMAP) ) + + if (!(thing->flags & MF_NOBLOCKMAP)) { // inert things don't need to be in blockmap // unlink from block map if (thing->bnext) @@ -312,11 +312,11 @@ void P_UnsetThingPosition (mobj_t *thing) thing->bprev->bnext = thing->bnext; else { - blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT; - blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT; - if (blockx>=0 && blockx < bmapwidth - && blocky>=0 && blocky bnext; + blockx = (thing->x - bmaporgx) >> MAPBLOCKSHIFT; + blocky = (thing->y - bmaporgy) >> MAPBLOCKSHIFT; + if (blockx >= 0 && blockx < bmapwidth + && blocky >= 0 && blocky < bmapheight) + blocklinks[blocky * bmapwidth + blockx] = thing->bnext; } } } @@ -325,7 +325,7 @@ void P_UnsetThingPosition (mobj_t *thing) /* =================== = -= P_SetThingPosition += P_SetThingPosition = = Links a thing into both a block and a subsector based on it's x y = Sets thing->subsector properly @@ -335,37 +335,37 @@ void P_UnsetThingPosition (mobj_t *thing) void P_SetThingPosition (mobj_t *thing) { - subsector_t *ss; - sector_t *sec; + subsector_t *ss; + sector_t *sec; int blockx, blocky; - mobj_t **link; - -// -// link into subsector -// - ss = R_PointInSubsector (thing->x,thing->y); + mobj_t **link; + + // + // link into subsector + // + ss = R_PointInSubsector (thing->x, thing->y); thing->subsector = ss; - if ( ! (thing->flags & MF_NOSECTOR) ) + if (!(thing->flags & MF_NOSECTOR)) { // invisible things don't go into the sector links sec = ss->sector; - + thing->sprev = NULL; thing->snext = sec->thinglist; if (sec->thinglist) sec->thinglist->sprev = thing; sec->thinglist = thing; } - -// -// link into blockmap -// - if ( ! (thing->flags & MF_NOBLOCKMAP) ) + + // + // link into blockmap + // + if (!(thing->flags & MF_NOBLOCKMAP)) { // inert things don't need to be in blockmap - blockx = (thing->x - bmaporgx)>>MAPBLOCKSHIFT; - blocky = (thing->y - bmaporgy)>>MAPBLOCKSHIFT; - if (blockx>=0 && blockx < bmapwidth && blocky>=0 && blocky x - bmaporgx) >> MAPBLOCKSHIFT; + blocky = (thing->y - bmaporgy) >> MAPBLOCKSHIFT; + if (blockx >= 0 && blockx < bmapwidth && blocky >= 0 && blocky < bmapheight) { - link = &blocklinks[blocky*bmapwidth+blockx]; + link = &blocklinks[blocky * bmapwidth + blockx]; thing->bprev = NULL; thing->bnext = *link; if (*link) @@ -403,29 +403,29 @@ If the function returns false, exit with false without checking anything else. =================== */ -boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t*) ) +boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t *)) { int offset; - short *list; - line_t *ld; - - if (x<0 || y<0 || x>=bmapwidth || y>=bmapheight) + short *list; + line_t *ld; + + if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight) return true; - offset = y*bmapwidth+x; - - offset = *(blockmap+offset); + offset = y * bmapwidth + x; + + offset = *(blockmap + offset); - for ( list = blockmaplump+offset ; *list != -1 ; list++) + for (list = blockmaplump + offset; *list != -1; list++) { ld = &lines[*list]; if (ld->validcount == validcount) continue; // line has already been checked ld->validcount = validcount; - - if ( !func(ld) ) + + if (!func(ld)) return false; } - + return true; // everything was checked } @@ -438,16 +438,16 @@ boolean P_BlockLinesIterator (int x, int y, boolean(*func)(line_t*) ) ================== */ -boolean P_BlockThingsIterator (int x, int y, boolean(*func)(mobj_t*) ) +boolean P_BlockThingsIterator (int x, int y, boolean(*func)(mobj_t *)) { - mobj_t *mobj; - - if (x<0 || y<0 || x>=bmapwidth || y>=bmapheight) + mobj_t *mobj; + + if (x < 0 || y < 0 || x >= bmapwidth || y >= bmapheight) return true; - for (mobj = blocklinks[y*bmapwidth+x] ; mobj ; mobj = mobj->bnext) - if (!func( mobj ) ) - return false; + for (mobj = blocklinks[y * bmapwidth + x]; mobj; mobj = mobj->bnext) + if (!func(mobj)) + return false; return true; } @@ -483,10 +483,10 @@ boolean PIT_AddLineIntercepts (line_t *ld) int s1, s2; fixed_t frac; divline_t dl; - -// avoid precision problems with two routines - if ( trace.dx > FRACUNIT*16 || trace.dy > FRACUNIT*16 - || trace.dx < -FRACUNIT*16 || trace.dy < -FRACUNIT*16) + + // avoid precision problems with two routines + if (trace.dx > FRACUNIT * 16 || trace.dy > FRACUNIT * 16 + || trace.dx < -FRACUNIT * 16 || trace.dy < -FRACUNIT * 16) { s1 = P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &trace); s2 = P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &trace); @@ -494,7 +494,7 @@ boolean PIT_AddLineIntercepts (line_t *ld) else { s1 = P_PointOnLineSide (trace.x, trace.y, ld); - s2 = P_PointOnLineSide (trace.x+trace.dx, trace.y+trace.dy, ld); + s2 = P_PointOnLineSide (trace.x + trace.dx, trace.y + trace.dy, ld); } if (s1 == s2) return true; // line isn't crossed @@ -506,11 +506,11 @@ boolean PIT_AddLineIntercepts (line_t *ld) frac = P_InterceptVector (&trace, &dl); if (frac < 0) return true; // behind source - + // try to early out the check if (earlyout && frac < FRACUNIT && !ld->backsector) return false; // stop checking - + intercept_p->frac = frac; intercept_p->isaline = true; intercept_p->d.line = ld; @@ -529,43 +529,43 @@ boolean PIT_AddLineIntercepts (line_t *ld) ================== */ -boolean PIT_AddThingIntercepts (mobj_t *thing) +boolean PIT_AddThingIntercepts (mobj_t *thing) { - fixed_t x1,y1, x2,y2; + fixed_t x1, y1, x2, y2; int s1, s2; boolean tracepositive; divline_t dl; fixed_t frac; - - tracepositive = (trace.dx ^ trace.dy)>0; - + + tracepositive = (trace.dx ^ trace.dy) > 0; + // check a corner to corner crossection for hit - + if (tracepositive) { x1 = thing->x - thing->radius; y1 = thing->y + thing->radius; - + x2 = thing->x + thing->radius; - y2 = thing->y - thing->radius; + y2 = thing->y - thing->radius; } else { x1 = thing->x - thing->radius; y1 = thing->y - thing->radius; - + x2 = thing->x + thing->radius; - y2 = thing->y + thing->radius; + y2 = thing->y + thing->radius; } s1 = P_PointOnDivlineSide (x1, y1, &trace); s2 = P_PointOnDivlineSide (x2, y2, &trace); if (s1 == s2) return true; // line isn't crossed - + dl.x = x1; dl.y = y1; - dl.dx = x2-x1; - dl.dy = y2-y1; + dl.dx = x2 - x1; + dl.dy = y2 - y1; frac = P_InterceptVector (&trace, &dl); if (frac < 0) return true; // behind source @@ -587,31 +587,31 @@ boolean PIT_AddThingIntercepts (mobj_t *thing) ==================== */ -boolean P_TraverseIntercepts ( traverser_t func, fixed_t maxfrac ) +boolean P_TraverseIntercepts (traverser_t func, fixed_t maxfrac) { int count; fixed_t dist; - intercept_t *scan, *in; - + intercept_t *scan, *in; + count = intercept_p - intercepts; in = 0; // shut up compiler warning - + while (count--) { dist = MAXINT; - for (scan = intercepts ; scanfrac < dist) { dist = scan->frac; in = scan; } - + if (dist > maxfrac) return true; // checked everything in range #if 0 { // don't check these yet, ther may be others inserted in = scan = intercepts; - for ( scan = intercepts ; scanfrac > maxfrac) *in++ = *scan; intercept_p = in; @@ -619,11 +619,11 @@ boolean P_TraverseIntercepts ( traverser_t func, fixed_t maxfrac ) } #endif - if ( !func (in) ) + if (!func (in)) return false; // don't bother going farther in->frac = MAXINT; } - + return true; // everything was traversed } @@ -642,21 +642,21 @@ boolean P_TraverseIntercepts ( traverser_t func, fixed_t maxfrac ) boolean P_PathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, boolean (*trav) (intercept_t *)) { - fixed_t xt1,yt1,xt2,yt2; - fixed_t xstep,ystep; + fixed_t xt1, yt1, xt2, yt2; + fixed_t xstep, ystep; fixed_t partial; fixed_t xintercept, yintercept; int mapx, mapy, mapxstep, mapystep; int count; - + earlyout = flags & PT_EARLYOUT; - + validcount++; intercept_p = intercepts; - - if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0) + + if (((x1 - bmaporgx) & (MAPBLOCKSIZE - 1)) == 0) x1 += FRACUNIT; // don't side exactly on a line - if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0) + if (((y1 - bmaporgy) & (MAPBLOCKSIZE - 1)) == 0) y1 += FRACUNIT; // don't side exactly on a line trace.x = x1; trace.y = y1; @@ -665,96 +665,96 @@ boolean P_PathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, x1 -= bmaporgx; y1 -= bmaporgy; - xt1 = x1>>MAPBLOCKSHIFT; - yt1 = y1>>MAPBLOCKSHIFT; + xt1 = x1 >> MAPBLOCKSHIFT; + yt1 = y1 >> MAPBLOCKSHIFT; x2 -= bmaporgx; y2 -= bmaporgy; - xt2 = x2>>MAPBLOCKSHIFT; - yt2 = y2>>MAPBLOCKSHIFT; + xt2 = x2 >> MAPBLOCKSHIFT; + yt2 = y2 >> MAPBLOCKSHIFT; if (xt2 > xt1) { mapxstep = 1; - partial = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1)); - ystep = FixedDiv (y2-y1,abs(x2-x1)); + partial = FRACUNIT - ((x1 >> MAPBTOFRAC) & (FRACUNIT - 1)); + ystep = FixedDiv (y2 - y1, abs(x2 - x1)); } else if (xt2 < xt1) { mapxstep = -1; - partial = (x1>>MAPBTOFRAC)&(FRACUNIT-1); - ystep = FixedDiv (y2-y1,abs(x2-x1)); + partial = (x1 >> MAPBTOFRAC) & (FRACUNIT - 1); + ystep = FixedDiv (y2 - y1, abs(x2 - x1)); } else { mapxstep = 0; partial = FRACUNIT; - ystep = 256*FRACUNIT; - } - yintercept = (y1>>MAPBTOFRAC) + FixedMul (partial, ystep); + ystep = 256 * FRACUNIT; + } + yintercept = (y1 >> MAPBTOFRAC) + FixedMul (partial, ystep); + - if (yt2 > yt1) { mapystep = 1; - partial = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1)); - xstep = FixedDiv (x2-x1,abs(y2-y1)); + partial = FRACUNIT - ((y1 >> MAPBTOFRAC) & (FRACUNIT - 1)); + xstep = FixedDiv (x2 - x1, abs(y2 - y1)); } else if (yt2 < yt1) { mapystep = -1; - partial = (y1>>MAPBTOFRAC)&(FRACUNIT-1); - xstep = FixedDiv (x2-x1,abs(y2-y1)); + partial = (y1 >> MAPBTOFRAC) & (FRACUNIT - 1); + xstep = FixedDiv (x2 - x1, abs(y2 - y1)); } else { mapystep = 0; partial = FRACUNIT; - xstep = 256*FRACUNIT; - } - xintercept = (x1>>MAPBTOFRAC) + FixedMul (partial, xstep); + xstep = 256 * FRACUNIT; + } + xintercept = (x1 >> MAPBTOFRAC) + FixedMul (partial, xstep); - -// -// step through map blocks -// Count is present to prevent a round off error from skipping the break + + // + // step through map blocks + // Count is present to prevent a round off error from skipping the break mapx = xt1; mapy = yt1; - - for (count = 0 ; count < 64 ; count++) + + for (count = 0; count < 64; count++) { if (flags & PT_ADDLINES) { - if (!P_BlockLinesIterator (mapx, mapy,PIT_AddLineIntercepts)) + if (!P_BlockLinesIterator (mapx, mapy, PIT_AddLineIntercepts)) return false; // early out } if (flags & PT_ADDTHINGS) { - if (!P_BlockThingsIterator (mapx, mapy,PIT_AddThingIntercepts)) + if (!P_BlockThingsIterator (mapx, mapy, PIT_AddThingIntercepts)) return false; // early out } - + if (mapx == xt2 && mapy == yt2) break; - - if ( (yintercept >> FRACBITS) == mapy) + + if ((yintercept >> FRACBITS) == mapy) { yintercept += ystep; mapx += mapxstep; } - else if ( (xintercept >> FRACBITS) == mapx) + else if ((xintercept >> FRACBITS) == mapx) { xintercept += xstep; mapy += mapystep; } - + } -// -// go through the sorted list -// - return P_TraverseIntercepts ( trav, FRACUNIT ); + // + // go through the sorted list + // + return P_TraverseIntercepts (trav, FRACUNIT); } diff --git a/P_MOBJ.C b/P_MOBJ.C index 6a9232d..5776b65 100644 --- a/P_MOBJ.C +++ b/P_MOBJ.C @@ -44,7 +44,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) { state_t *st; - if(state == S_NULL) + if (state == S_NULL) { // Remove mobj mobj->state = S_NULL; P_RemoveMobj(mobj); @@ -55,7 +55,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state) mobj->tics = st->tics; mobj->sprite = st->sprite; mobj->frame = st->frame; - if(st->action) + if (st->action) { // Call action function st->action(mobj); } @@ -74,7 +74,7 @@ boolean P_SetMobjStateNF(mobj_t *mobj, statenum_t state) { state_t *st; - if(state == S_NULL) + if (state == S_NULL) { // Remove mobj mobj->state = S_NULL; P_RemoveMobj(mobj); @@ -96,9 +96,9 @@ boolean P_SetMobjStateNF(mobj_t *mobj, statenum_t state) void P_ExplodeMissile(mobj_t *mo) { - if(mo->type == MT_WHIRLWIND) + if (mo->type == MT_WHIRLWIND) { - if(++mo->special2 < 60) + if (++mo->special2 < 60) { return; } @@ -107,7 +107,7 @@ void P_ExplodeMissile(mobj_t *mo) P_SetMobjState(mo, mobjinfo[mo->type].deathstate); //mo->tics -= P_Random()&3; mo->flags &= ~MF_MISSILE; - if(mo->info->deathsound) + if (mo->info->deathsound) { S_StartSound(mo, mo->info->deathsound); } @@ -156,12 +156,12 @@ int P_FaceMobj(mobj_t *source, mobj_t *target, angle_t *delta) angle1 = source->angle; angle2 = R_PointToAngle2(source->x, source->y, target->x, target->y); - if(angle2 > angle1) + if (angle2 > angle1) { - diff = angle2-angle1; - if(diff > ANGLE_180) + diff = angle2 - angle1; + if (diff > ANGLE_180) { - *delta = ANGLE_MAX-diff; + *delta = ANGLE_MAX - diff; return(0); } else @@ -172,10 +172,10 @@ int P_FaceMobj(mobj_t *source, mobj_t *target, angle_t *delta) } else { - diff = angle1-angle2; - if(diff > ANGLE_180) + diff = angle1 - angle2; + if (diff > ANGLE_180) { - *delta = ANGLE_MAX-diff; + *delta = ANGLE_MAX - diff; return(1); } else @@ -204,25 +204,25 @@ boolean P_SeekerMissile(mobj_t *actor, angle_t thresh, angle_t turnMax) mobj_t *target; target = (mobj_t *)actor->special1; - if(target == NULL) + if (target == NULL) { return(false); } - if(!(target->flags&MF_SHOOTABLE)) + if (!(target->flags & MF_SHOOTABLE)) { // Target died actor->special1 = 0; return(false); } dir = P_FaceMobj(actor, target, &delta); - if(delta > thresh) + if (delta > thresh) { delta >>= 1; - if(delta > turnMax) + if (delta > turnMax) { delta = turnMax; } } - if(dir) + if (dir) { // Turn clockwise actor->angle += delta; } @@ -230,19 +230,19 @@ boolean P_SeekerMissile(mobj_t *actor, angle_t thresh, angle_t turnMax) { // Turn counter clockwise actor->angle -= delta; } - angle = actor->angle>>ANGLETOFINESHIFT; + angle = actor->angle >> ANGLETOFINESHIFT; actor->momx = FixedMul(actor->info->speed, finecosine[angle]); actor->momy = FixedMul(actor->info->speed, finesine[angle]); - if(actor->z+actor->height < target->z || - target->z+target->height < actor->z) + if (actor->z + actor->height < target->z || + target->z + target->height < actor->z) { // Need to seek vertically - dist = P_AproxDistance(target->x-actor->x, target->y-actor->y); - dist = dist/actor->info->speed; - if(dist < 1) + dist = P_AproxDistance(target->x - actor->x, target->y - actor->y); + dist = dist / actor->info->speed; + if (dist < 1) { dist = 1; } - actor->momz = (target->z-actor->z)/dist; + actor->momz = (target->z - actor->z) / dist; } return(true); } @@ -264,11 +264,11 @@ void P_XYMovement(mobj_t *mo) player_t *player; fixed_t xmove, ymove; int special; - static int windTab[3] = {2048*5, 2048*10, 2048*25}; + static int windTab[3] = { 2048 * 5, 2048 * 10, 2048 * 25 }; - if(!mo->momx && !mo->momy) + if (!mo->momx && !mo->momy) { - if(mo->flags&MF_SKULLFLY) + if (mo->flags & MF_SKULLFLY) { // A flying mobj slammed into something mo->flags &= ~MF_SKULLFLY; mo->momx = mo->momy = mo->momz = 0; @@ -277,38 +277,38 @@ void P_XYMovement(mobj_t *mo) return; } special = mo->subsector->sector->special; - if(mo->flags2&MF2_WINDTHRUST) + if (mo->flags2 & MF2_WINDTHRUST) { - switch(special) + switch (special) { case 40: case 41: case 42: // Wind_East - P_ThrustMobj(mo, 0, windTab[special-40]); + P_ThrustMobj(mo, 0, windTab[special - 40]); break; case 43: case 44: case 45: // Wind_North - P_ThrustMobj(mo, ANG90, windTab[special-43]); + P_ThrustMobj(mo, ANG90, windTab[special - 43]); break; case 46: case 47: case 48: // Wind_South - P_ThrustMobj(mo, ANG270, windTab[special-46]); + P_ThrustMobj(mo, ANG270, windTab[special - 46]); break; case 49: case 50: case 51: // Wind_West - P_ThrustMobj(mo, ANG180, windTab[special-49]); + P_ThrustMobj(mo, ANG180, windTab[special - 49]); break; } } player = mo->player; - if(mo->momx > MAXMOVE) + if (mo->momx > MAXMOVE) { mo->momx = MAXMOVE; } - else if(mo->momx < -MAXMOVE) + else if (mo->momx < -MAXMOVE) { mo->momx = -MAXMOVE; } - if(mo->momy > MAXMOVE) + if (mo->momy > MAXMOVE) { mo->momy = MAXMOVE; } - else if(mo->momy < -MAXMOVE) + else if (mo->momy < -MAXMOVE) { mo->momy = -MAXMOVE; } @@ -316,10 +316,10 @@ void P_XYMovement(mobj_t *mo) ymove = mo->momy; do { - if(xmove > MAXMOVE/2 || ymove > MAXMOVE/2) + if (xmove > MAXMOVE / 2 || ymove > MAXMOVE / 2) { - ptryx = mo->x+xmove/2; - ptryy = mo->y+ymove/2; + ptryx = mo->x + xmove / 2; + ptryy = mo->y + ymove / 2; xmove >>= 1; ymove >>= 1; } @@ -329,18 +329,18 @@ void P_XYMovement(mobj_t *mo) ptryy = mo->y + ymove; xmove = ymove = 0; } - if(!P_TryMove(mo, ptryx, ptryy)) + if (!P_TryMove(mo, ptryx, ptryy)) { // Blocked move - if(mo->flags2&MF2_SLIDE) + if (mo->flags2 & MF2_SLIDE) { // Try to slide along it P_SlideMove(mo); } - else if(mo->flags&MF_MISSILE) + else if (mo->flags & MF_MISSILE) { // Explode a missile - if(ceilingline && ceilingline->backsector + if (ceilingline && ceilingline->backsector && ceilingline->backsector->ceilingpic == skyflatnum) { // Hack to prevent missiles exploding against the sky - if(mo->type == MT_BLOODYSKULL) + if (mo->type == MT_BLOODYSKULL) { mo->momx = mo->momy = 0; mo->momz = -FRACUNIT; @@ -364,53 +364,53 @@ void P_XYMovement(mobj_t *mo) mo->momx = mo->momy = 0; } } - } while(xmove || ymove); + } while (xmove || ymove); // Friction - if(player && player->cheats&CF_NOMOMENTUM) + if (player && player->cheats & CF_NOMOMENTUM) { // Debug option for no sliding at all mo->momx = mo->momy = 0; return; } - if(mo->flags&(MF_MISSILE|MF_SKULLFLY)) + if (mo->flags & (MF_MISSILE | MF_SKULLFLY)) { // No friction for missiles return; } - if(mo->z > mo->floorz && !(mo->flags2&MF2_FLY) && !(mo->flags2&MF2_ONMOBJ)) + if (mo->z > mo->floorz && !(mo->flags2 & MF2_FLY) && !(mo->flags2 & MF2_ONMOBJ)) { // No friction when falling return; } - if(mo->flags&MF_CORPSE) + if (mo->flags & MF_CORPSE) { // Don't stop sliding if halfway off a step with some momentum - if(mo->momx > FRACUNIT/4 || mo->momx < -FRACUNIT/4 - || mo->momy > FRACUNIT/4 || mo->momy < -FRACUNIT/4) + if (mo->momx > FRACUNIT / 4 || mo->momx < -FRACUNIT / 4 + || mo->momy > FRACUNIT / 4 || mo->momy < -FRACUNIT / 4) { - if(mo->floorz != mo->subsector->sector->floorheight) + if (mo->floorz != mo->subsector->sector->floorheight) { return; } } } - if(mo->momx > -STOPSPEED && mo->momx < STOPSPEED + if (mo->momx > -STOPSPEED && mo->momx < STOPSPEED && mo->momy > -STOPSPEED && mo->momy < STOPSPEED && (!player || (player->cmd.forwardmove == 0 - && player->cmd.sidemove == 0))) + && player->cmd.sidemove == 0))) { // If in a walking frame, stop moving - if(player) + if (player) { - if(player->chickenTics) + if (player->chickenTics) { - if((unsigned)((player->mo->state-states) - -S_CHICPLAY_RUN1) < 4) + if ((unsigned)((player->mo->state - states) + - S_CHICPLAY_RUN1) < 4) { P_SetMobjState(player->mo, S_CHICPLAY); } } else { - if((unsigned)((player->mo->state-states) - -S_PLAY_RUN1) < 4) + if ((unsigned)((player->mo->state - states) + - S_PLAY_RUN1) < 4) { P_SetMobjState(player->mo, S_PLAY); } @@ -421,13 +421,13 @@ void P_XYMovement(mobj_t *mo) } else { - if(mo->flags2&MF2_FLY && !(mo->z <= mo->floorz) - &&!(mo->flags2&MF2_ONMOBJ)) + if (mo->flags2 & MF2_FLY && !(mo->z <= mo->floorz) + && !(mo->flags2 & MF2_ONMOBJ)) { mo->momx = FixedMul(mo->momx, FRICTION_FLY); mo->momy = FixedMul(mo->momy, FRICTION_FLY); } - else if(special == 15) // Friction_Low + else if (special == 15) // Friction_Low { mo->momx = FixedMul(mo->momx, FRICTION_LOW); mo->momy = FixedMul(mo->momy, FRICTION_LOW); @@ -453,50 +453,50 @@ void P_ZMovement(mobj_t *mo) { int dist; int delta; -// -// check for smooth step up -// + // + // check for smooth step up + // if (mo->player && mo->z < mo->floorz) { - mo->player->viewheight -= mo->floorz-mo->z; - mo->player->deltaviewheight = (VIEWHEIGHT - mo->player->viewheight)>>3; + mo->player->viewheight -= mo->floorz - mo->z; + mo->player->deltaviewheight = (VIEWHEIGHT - mo->player->viewheight) >> 3; } -// -// adjust height -// + // + // adjust height + // mo->z += mo->momz; - if(mo->flags&MF_FLOAT && mo->target) + if (mo->flags & MF_FLOAT && mo->target) { // float down towards target if too close - if(!(mo->flags&MF_SKULLFLY) && !(mo->flags&MF_INFLOAT)) + 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)) + 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)) + else if (delta > 0 && dist < (delta * 3)) mo->z += FLOATSPEED; } } - if(mo->player && mo->flags2&MF2_FLY && !(mo->z <= mo->floorz) - && leveltime&2) + if (mo->player && mo->flags2 & MF2_FLY && !(mo->z <= mo->floorz) + && leveltime & 2) { - mo->z += finesine[(FINEANGLES/20*leveltime>>2)&FINEMASK]; + mo->z += finesine[(FINEANGLES / 20 * leveltime >> 2) & FINEMASK]; } -// -// clip movement -// - if(mo->z <= mo->floorz) + // + // clip movement + // + if (mo->z <= mo->floorz) { // Hit the floor - if(mo->flags&MF_MISSILE) + if (mo->flags & MF_MISSILE) { mo->z = mo->floorz; - if(mo->flags2&MF2_FLOORBOUNCE) + if (mo->flags2 & MF2_FLOORBOUNCE) { P_FloorBounceMissile(mo); return; } - else if(mo->type == MT_MNTRFX2) + else if (mo->type == MT_MNTRFX2) { // Minotaur floor fire can go up steps return; } @@ -506,20 +506,20 @@ void P_ZMovement(mobj_t *mo) return; } } - if(mo->z-mo->momz > mo->floorz) + if (mo->z - mo->momz > mo->floorz) { // Spawn splashes, etc. P_HitFloor(mo); } mo->z = mo->floorz; - if(mo->momz < 0) + if (mo->momz < 0) { - if(mo->player && mo->momz < -GRAVITY*8 - && !(mo->flags2&MF2_FLY)) // squat down + if (mo->player && mo->momz < -GRAVITY * 8 + && !(mo->flags2 & MF2_FLY)) // squat down { - mo->player->deltaviewheight = mo->momz>>3; + mo->player->deltaviewheight = mo->momz >> 3; S_StartSound(mo, sfx_plroof); #ifdef __WATCOMC__ - if(!useexterndriver) + if (!useexterndriver) { mo->player->centering = true; } @@ -529,27 +529,27 @@ void P_ZMovement(mobj_t *mo) } mo->momz = 0; } - if(mo->flags&MF_SKULLFLY) + if (mo->flags & MF_SKULLFLY) { // The skull slammed into something mo->momz = -mo->momz; } - if(mo->info->crashstate && (mo->flags&MF_CORPSE)) + if (mo->info->crashstate && (mo->flags & MF_CORPSE)) { P_SetMobjState(mo, mo->info->crashstate); return; } } - else if(mo->flags2&MF2_LOGRAV) + else if (mo->flags2 & MF2_LOGRAV) { - if(mo->momz == 0) - mo->momz = -(GRAVITY>>3)*2; + if (mo->momz == 0) + mo->momz = -(GRAVITY >> 3) * 2; else - mo->momz -= GRAVITY>>3; + mo->momz -= GRAVITY >> 3; } - else if (! (mo->flags & MF_NOGRAVITY) ) + else if (!(mo->flags & MF_NOGRAVITY)) { if (mo->momz == 0) - mo->momz = -GRAVITY*2; + mo->momz = -GRAVITY * 2; else mo->momz -= GRAVITY; } @@ -565,9 +565,9 @@ void P_ZMovement(mobj_t *mo) } if (mo->flags & MF_MISSILE) { - if(mo->subsector->sector->ceilingpic == skyflatnum) + if (mo->subsector->sector->ceilingpic == skyflatnum) { - if(mo->type == MT_BLOODYSKULL) + if (mo->type == MT_BLOODYSKULL) { mo->momx = mo->momy = 0; mo->momz = -FRACUNIT; @@ -595,46 +595,46 @@ void P_ZMovement(mobj_t *mo) void P_NightmareRespawn (mobj_t *mobj) { - fixed_t x,y,z; - subsector_t *ss; - mobj_t *mo; - mapthing_t *mthing; - + fixed_t x, y, z; + 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) ) + + if (!P_CheckPosition (mobj, x, y)) return; // somthing is occupying it's position // spawn a teleport fog at old spot mo = P_SpawnMobj (mobj->x, mobj->y, - mobj->subsector->sector->floorheight+TELEFOGHEIGHT, MT_TFOG); + mobj->subsector->sector->floorheight + TELEFOGHEIGHT, MT_TFOG); S_StartSound (mo, sfx_telept); -// spawn a teleport fog at the new spot - ss = R_PointInSubsector (x,y); - mo = P_SpawnMobj (x, y, ss->sector->floorheight+TELEFOGHEIGHT, MT_TFOG); + // spawn a teleport fog at the new spot + ss = R_PointInSubsector (x, y); + mo = P_SpawnMobj (x, y, ss->sector->floorheight + TELEFOGHEIGHT, MT_TFOG); S_StartSound (mo, sfx_telept); -// spawn the new monster + // spawn the new monster mthing = &mobj->spawnpoint; - -// spawn it + + // spawn it 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); + 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; - -// remove the old monster + + // remove the old monster P_RemoveMobj (mobj); } @@ -656,41 +656,41 @@ void P_BlasterMobjThinker(mobj_t *mobj) boolean changexy; // Handle movement - if(mobj->momx || mobj->momy || + if (mobj->momx || mobj->momy || (mobj->z != mobj->floorz) || mobj->momz) { - xfrac = mobj->momx>>3; - yfrac = mobj->momy>>3; - zfrac = mobj->momz>>3; + xfrac = mobj->momx >> 3; + yfrac = mobj->momy >> 3; + zfrac = mobj->momz >> 3; changexy = xfrac || yfrac; - for(i = 0; i < 8; i++) + for (i = 0; i < 8; i++) { - if(changexy) + if (changexy) { - if(!P_TryMove(mobj, mobj->x+xfrac, mobj->y+yfrac)) + if (!P_TryMove(mobj, mobj->x + xfrac, mobj->y + yfrac)) { // Blocked move P_ExplodeMissile(mobj); return; } } mobj->z += zfrac; - if(mobj->z <= mobj->floorz) + if (mobj->z <= mobj->floorz) { // Hit the floor mobj->z = mobj->floorz; P_HitFloor(mobj); P_ExplodeMissile(mobj); return; } - if(mobj->z+mobj->height > mobj->ceilingz) + if (mobj->z + mobj->height > mobj->ceilingz) { // Hit the ceiling - mobj->z = mobj->ceilingz-mobj->height; + mobj->z = mobj->ceilingz - mobj->height; P_ExplodeMissile(mobj); return; } - if(changexy && (P_Random() < 64)) + if (changexy && (P_Random() < 64)) { - z = mobj->z-8*FRACUNIT; - if(z < mobj->floorz) + z = mobj->z - 8 * FRACUNIT; + if (z < mobj->floorz) { z = mobj->floorz; } @@ -699,12 +699,12 @@ void P_BlasterMobjThinker(mobj_t *mobj) } } // Advance the state - if(mobj->tics != -1) + if (mobj->tics != -1) { mobj->tics--; - while(!mobj->tics) + while (!mobj->tics) { - if(!P_SetMobjState(mobj, mobj->state->nextstate)) + if (!P_SetMobjState(mobj, mobj->state->nextstate)) { // mobj was removed return; } @@ -721,47 +721,47 @@ void P_BlasterMobjThinker(mobj_t *mobj) void P_MobjThinker(mobj_t *mobj) { mobj_t *onmo; - + // Handle X and Y momentums - if(mobj->momx || mobj->momy || (mobj->flags&MF_SKULLFLY)) + if (mobj->momx || mobj->momy || (mobj->flags & MF_SKULLFLY)) { P_XYMovement(mobj); - if(mobj->thinker.function == (think_t)-1) + if (mobj->thinker.function == (think_t)-1) { // mobj was removed return; } } - if(mobj->flags2&MF2_FLOATBOB) + if (mobj->flags2 & MF2_FLOATBOB) { // Floating item bobbing motion - mobj->z = mobj->floorz+FloatBobOffsets[(mobj->health++)&63]; + mobj->z = mobj->floorz + FloatBobOffsets[(mobj->health++) & 63]; } - else if((mobj->z != mobj->floorz) || mobj->momz) + else if ((mobj->z != mobj->floorz) || mobj->momz) { // Handle Z momentum and gravity - if(mobj->flags2&MF2_PASSMOBJ) + if (mobj->flags2 & MF2_PASSMOBJ) { - if(!(onmo = P_CheckOnmobj(mobj))) + if (!(onmo = P_CheckOnmobj(mobj))) { P_ZMovement(mobj); } else { - if(mobj->player && mobj->momz < 0) + if (mobj->player && mobj->momz < 0) { mobj->flags2 |= MF2_ONMOBJ; mobj->momz = 0; } - if(mobj->player && (onmo->player || onmo->type == MT_POD)) + if (mobj->player && (onmo->player || onmo->type == MT_POD)) { mobj->momx = onmo->momx; mobj->momy = onmo->momy; - if(onmo->z < onmo->floorz) + if (onmo->z < onmo->floorz) { - mobj->z += onmo->floorz-onmo->z; - if(onmo->player) + mobj->z += onmo->floorz - onmo->z; + if (onmo->player) { - onmo->player->viewheight -= onmo->floorz-onmo->z; - onmo->player->deltaviewheight = (VIEWHEIGHT- - onmo->player->viewheight)>>3; + onmo->player->viewheight -= onmo->floorz - onmo->z; + onmo->player->deltaviewheight = (VIEWHEIGHT - + onmo->player->viewheight) >> 3; } onmo->z = onmo->floorz; } @@ -772,22 +772,22 @@ void P_MobjThinker(mobj_t *mobj) { P_ZMovement(mobj); } - if(mobj->thinker.function == (think_t)-1) + if (mobj->thinker.function == (think_t)-1) { // mobj was removed return; } } -// -// cycle through states, calling action functions at transitions -// - if(mobj->tics != -1) + // + // cycle through states, calling action functions at transitions + // + if (mobj->tics != -1) { mobj->tics--; // you can cycle through multiple states in a tic - while(!mobj->tics) + while (!mobj->tics) { - if(!P_SetMobjState(mobj, mobj->state->nextstate)) + if (!P_SetMobjState(mobj, mobj->state->nextstate)) { // mobj was removed return; } @@ -795,24 +795,24 @@ void P_MobjThinker(mobj_t *mobj) } else { // Check for monster respawn - if(!(mobj->flags&MF_COUNTKILL)) + if (!(mobj->flags & MF_COUNTKILL)) { return; } - if(!respawnmonsters) + if (!respawnmonsters) { return; } mobj->movecount++; - if(mobj->movecount < 12*35) + if (mobj->movecount < 12 * 35) { return; } - if(leveltime&31) + if (leveltime & 31) { return; } - if(P_Random() > 4) + if (P_Random() > 4) { return; } @@ -848,11 +848,11 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->flags2 = info->flags2; mobj->damage = info->damage; mobj->health = info->spawnhealth; - if(gameskill != sk_nightmare) + if (gameskill != sk_nightmare) { mobj->reactiontime = info->reactiontime; } - mobj->lastlook = P_Random()%MAXPLAYERS; + mobj->lastlook = P_Random() % MAXPLAYERS; // Set the state, but do not use P_SetMobjState, because action // routines can't be called yet. If the spawnstate has an action @@ -867,21 +867,21 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) P_SetThingPosition(mobj); mobj->floorz = mobj->subsector->sector->floorheight; mobj->ceilingz = mobj->subsector->sector->ceilingheight; - if(z == ONFLOORZ) + if (z == ONFLOORZ) { mobj->z = mobj->floorz; } - else if(z == ONCEILINGZ) + else if (z == ONCEILINGZ) { - mobj->z = mobj->ceilingz-mobj->info->height; + mobj->z = mobj->ceilingz - mobj->info->height; } - else if(z == FLOATRANDZ) + else if (z == FLOATRANDZ) { - space = ((mobj->ceilingz)-(mobj->info->height))-mobj->floorz; - if(space > 48*FRACUNIT) + space = ((mobj->ceilingz) - (mobj->info->height)) - mobj->floorz; + if (space > 48 * FRACUNIT) { - space -= 40*FRACUNIT; - mobj->z = ((space*P_Random())>>8)+mobj->floorz+40*FRACUNIT; + space -= 40 * FRACUNIT; + mobj->z = ((space * P_Random()) >> 8) + mobj->floorz + 40 * FRACUNIT; } else { @@ -892,7 +892,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) { mobj->z = z; } - if(mobj->flags2&MF2_FOOTCLIP && P_GetThingFloorType(mobj) != FLOOR_SOLID + if (mobj->flags2 & MF2_FOOTCLIP && P_GetThingFloorType(mobj) != FLOOR_SOLID && mobj->floorz == mobj->subsector->sector->floorheight) { mobj->flags2 |= MF2_FEETARECLIPPED; @@ -917,11 +917,11 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) void P_RemoveMobj(mobj_t *mobj) { -// unlink from sector and block lists + // unlink from sector and block lists P_UnsetThingPosition (mobj); -// stop any playing sound + // stop any playing sound S_StopSound(mobj); -// free block + // free block P_RemoveThinker((thinker_t *)mobj); } @@ -933,40 +933,40 @@ void P_RemoveMobj(mobj_t *mobj) = = P_SpawnPlayer = -= Called when a player is spawned on the level += Called when a player is spawned on the level = Most of the player structure stays unchanged between levels ============ */ void P_SpawnPlayer(mapthing_t *mthing) { - player_t *p; - fixed_t x,y,z; - mobj_t *mobj; + player_t *p; + fixed_t x, y, z; + mobj_t *mobj; int i; extern int playerkeys; - if (!playeringame[mthing->type-1]) + if (!playeringame[mthing->type - 1]) return; // not playing - - p = &players[mthing->type-1]; + + p = &players[mthing->type - 1]; if (p->playerstate == PST_REBORN) - G_PlayerReborn (mthing->type-1); + G_PlayerReborn (mthing->type - 1); x = mthing->x << FRACBITS; y = mthing->y << FRACBITS; z = ONFLOORZ; - mobj = P_SpawnMobj (x,y,z, MT_PLAYER); + mobj = P_SpawnMobj (x, y, z, MT_PLAYER); if (mthing->type > 1) // set color translations for player sprites - mobj->flags |= (mthing->type-1)<angle = ANG45 * (mthing->angle/45); + 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->playerstate = PST_LIVE; p->refire = 0; p->message = NULL; p->damagecount = 0; @@ -978,23 +978,23 @@ void P_SpawnPlayer(mapthing_t *mthing) p->fixedcolormap = 0; p->viewheight = VIEWHEIGHT; P_SetupPsprites(p); // setup gun psprite - if(deathmatch) + if (deathmatch) { // Give all keys in death match mode - for(i = 0; i < NUMKEYS; i++) + for (i = 0; i < NUMKEYS; i++) { p->keys[i] = true; - if(p == &players[consoleplayer]) + if (p == &players[consoleplayer]) { playerkeys = 7; UpdateState |= I_STATBAR; } } } - else if(p == &players[consoleplayer]) + else if (p == &players[consoleplayer]) { playerkeys = 0; UpdateState |= I_STATBAR; - } + } } //---------------------------------------------------------------------------- @@ -1012,23 +1012,23 @@ void P_SpawnMapThing(mapthing_t *mthing) mobj_t *mobj; fixed_t x, y, z; -// count deathmatch start positions - if(mthing->type == 11) + // count deathmatch start positions + if (mthing->type == 11) { - if(deathmatch_p < &deathmatchstarts[10]) + if (deathmatch_p < &deathmatchstarts[10]) { memcpy(deathmatch_p, mthing, sizeof(*mthing)); deathmatch_p++; } return; } - -// check for players specially - if(mthing->type <= 4) + + // check for players specially + if (mthing->type <= 4) { // save spots for respawning in network games - playerstarts[mthing->type-1] = *mthing; - if(!deathmatch) + playerstarts[mthing->type - 1] = *mthing; + if (!deathmatch) { P_SpawnPlayer(mthing); } @@ -1036,52 +1036,52 @@ void P_SpawnMapThing(mapthing_t *mthing) } // Ambient sound sequences - if(mthing->type >= 1200 && mthing->type < 1300) + if (mthing->type >= 1200 && mthing->type < 1300) { - P_AddAmbientSfx(mthing->type-1200); + P_AddAmbientSfx(mthing->type - 1200); return; } // Check for boss spots - if(mthing->type == 56) // Monster_BossSpot + if (mthing->type == 56) // Monster_BossSpot { - P_AddBossSpot(mthing->x<y<angle/45)); + P_AddBossSpot(mthing->x << FRACBITS, mthing->y << FRACBITS, + ANG45 * (mthing->angle / 45)); return; } -// check for apropriate skill level - if (!netgame && (mthing->options & 16) ) + // check for apropriate skill level + 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) ) + bit = 1 << (gameskill - 1); + if (!(mthing->options & bit)) return; - -// find which type to spawn - for (i=0 ; i< NUMMOBJTYPES ; i++) + + // find which type to spawn + 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); - -// don't spawn keys and players in deathmatch + + if (i == NUMMOBJTYPES) + I_Error ("P_SpawnMapThing: Unknown type %i at (%i, %i)", mthing->type + , mthing->x, mthing->y); + + // don't spawn keys and players in deathmatch if (deathmatch && mobjinfo[i].flags & MF_NOTDMATCH) return; - -// don't spawn any monsters if -nomonsters - if (nomonsters && (mobjinfo[i].flags & MF_COUNTKILL) ) + + // don't spawn any monsters if -nomonsters + if (nomonsters && (mobjinfo[i].flags & MF_COUNTKILL)) return; -// spawn it - switch(i) + // spawn it + switch (i) { // Special stuff case MT_WSKULLROD: case MT_WPHOENIXROD: @@ -1094,13 +1094,13 @@ void P_SpawnMapThing(mapthing_t *mthing) case MT_ARTISUPERHEAL: case MT_ARTITELEPORT: case MT_ITEMSHIELD2: - if(shareware) + if (shareware) { // Don't place on map in shareware version return; } break; case MT_WMACE: - if(!shareware) + if (!shareware) { // Put in the mace spot list P_AddMaceSpot(mthing); return; @@ -1109,13 +1109,13 @@ void P_SpawnMapThing(mapthing_t *mthing) default: break; } - x = mthing->x<y<x << FRACBITS; + y = mthing->y << FRACBITS; + if (mobjinfo[i].flags & MF_SPAWNCEILING) { z = ONCEILINGZ; } - else if(mobjinfo[i].flags2&MF2_SPAWNFLOAT) + else if (mobjinfo[i].flags2 & MF2_SPAWNFLOAT) { z = FLOATRANDZ; } @@ -1124,25 +1124,25 @@ void P_SpawnMapThing(mapthing_t *mthing) z = ONFLOORZ; } mobj = P_SpawnMobj(x, y, z, i); - if(mobj->flags2&MF2_FLOATBOB) + if (mobj->flags2 & MF2_FLOATBOB) { // Seed random starting index for bobbing motion mobj->health = P_Random(); } - if(mobj->tics > 0) + if (mobj->tics > 0) { - mobj->tics = 1+(P_Random()%mobj->tics); + mobj->tics = 1 + (P_Random() % mobj->tics); } - if(mobj->flags&MF_COUNTKILL) + if (mobj->flags & MF_COUNTKILL) { totalkills++; mobj->spawnpoint = *mthing; } - if(mobj->flags&MF_COUNTITEM) + if (mobj->flags & MF_COUNTITEM) { totalitems++; } - mobj->angle = ANG45*(mthing->angle/45); - if(mthing->options&MTF_AMBUSH) + mobj->angle = ANG45 * (mthing->angle / 45); + if (mthing->options & MTF_AMBUSH) { mobj->flags |= MF_AMBUSH; } @@ -1168,13 +1168,13 @@ void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z) { mobj_t *puff; - z += ((P_Random()-P_Random())<<10); + z += ((P_Random() - P_Random()) << 10); puff = P_SpawnMobj(x, y, z, PuffType); - if(puff->info->attacksound) + if (puff->info->attacksound) { S_StartSound(puff, puff->info->attacksound); } - switch(PuffType) + switch (PuffType) { case MT_BEAKPUFF: case MT_STAFFPUFF: @@ -1182,7 +1182,7 @@ void P_SpawnPuff(fixed_t x, fixed_t y, fixed_t z) break; case MT_GAUNTLETPUFF1: case MT_GAUNTLETPUFF2: - puff->momz = .8*FRACUNIT; + puff->momz = .8 * FRACUNIT; default: break; } @@ -1200,7 +1200,7 @@ 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 *th; - + z += ((P_Random()-P_Random())<<10); th = P_SpawnMobj (x,y,z, MT_BLOOD); th->momz = FRACUNIT*2; @@ -1225,9 +1225,9 @@ void P_BloodSplatter(fixed_t x, fixed_t y, fixed_t z, mobj_t *originator) mo = P_SpawnMobj(x, y, z, MT_BLOODSPLATTER); mo->target = originator; - mo->momx = (P_Random()-P_Random())<<9; - mo->momy = (P_Random()-P_Random())<<9; - mo->momz = FRACUNIT*2; + mo->momx = (P_Random() - P_Random()) << 9; + mo->momy = (P_Random() - P_Random()) << 9; + mo->momz = FRACUNIT * 2; } //--------------------------------------------------------------------------- @@ -1241,14 +1241,14 @@ void P_RipperBlood(mobj_t *mo) mobj_t *th; fixed_t x, y, z; - x = mo->x+((P_Random()-P_Random())<<12); - y = mo->y+((P_Random()-P_Random())<<12); - z = mo->z+((P_Random()-P_Random())<<12); + x = mo->x + ((P_Random() - P_Random()) << 12); + y = mo->y + ((P_Random() - P_Random()) << 12); + z = mo->z + ((P_Random() - P_Random()) << 12); th = P_SpawnMobj(x, y, z, MT_BLOOD); th->flags |= MF_NOGRAVITY; - th->momx = mo->momx>>1; - th->momy = mo->momy>>1; - th->tics += P_Random()&3; + th->momx = mo->momx >> 1; + th->momy = mo->momy >> 1; + th->tics += P_Random() & 3; } //--------------------------------------------------------------------------- @@ -1260,17 +1260,17 @@ void P_RipperBlood(mobj_t *mo) int P_GetThingFloorType(mobj_t *thing) { return(TerrainTypes[thing->subsector->sector->floorpic]); -/* - if(thing->subsector->sector->floorpic - == W_GetNumForName("FLTWAWA1")-firstflat) - { - return(FLOOR_WATER); - } - else - { - return(FLOOR_SOLID); - } -*/ + /* + if(thing->subsector->sector->floorpic + == W_GetNumForName("FLTWAWA1")-firstflat) + { + return(FLOOR_WATER); + } + else + { + return(FLOOR_SOLID); + } + */ } //--------------------------------------------------------------------------- @@ -1283,34 +1283,34 @@ int P_HitFloor(mobj_t *thing) { mobj_t *mo; - if(thing->floorz != thing->subsector->sector->floorheight) + if (thing->floorz != thing->subsector->sector->floorheight) { // don't splash if landing on the edge above water/lava/etc.... return(FLOOR_SOLID); } - switch(P_GetThingFloorType(thing)) + switch (P_GetThingFloorType(thing)) { case FLOOR_WATER: P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_SPLASHBASE); mo = P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_SPLASH); mo->target = thing; - mo->momx = (P_Random()-P_Random())<<8; - mo->momy = (P_Random()-P_Random())<<8; - mo->momz = 2*FRACUNIT+(P_Random()<<8); + mo->momx = (P_Random() - P_Random()) << 8; + mo->momy = (P_Random() - P_Random()) << 8; + mo->momz = 2 * FRACUNIT + (P_Random() << 8); S_StartSound(mo, sfx_gloop); return(FLOOR_WATER); case FLOOR_LAVA: P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_LAVASPLASH); mo = P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_LAVASMOKE); - mo->momz = FRACUNIT+(P_Random()<<7); + mo->momz = FRACUNIT + (P_Random() << 7); S_StartSound(mo, sfx_burn); return(FLOOR_LAVA); case FLOOR_SLUDGE: P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_SLUDGESPLASH); mo = P_SpawnMobj(thing->x, thing->y, ONFLOORZ, MT_SLUDGECHUNK); mo->target = thing; - mo->momx = (P_Random()-P_Random())<<8; - mo->momy = (P_Random()-P_Random())<<8; - mo->momz = FRACUNIT+(P_Random()<<8); + mo->momx = (P_Random() - P_Random()) << 8; + mo->momy = (P_Random() - P_Random()) << 8; + mo->momz = FRACUNIT + (P_Random() << 8); return(FLOOR_SLUDGE); } return(FLOOR_SOLID); @@ -1331,10 +1331,10 @@ boolean P_CheckMissileSpawn(mobj_t *missile) // move a little forward so an angle can be computed if it // immediately explodes - missile->x += (missile->momx>>1); - missile->y += (missile->momy>>1); - missile->z += (missile->momz>>1); - if(!P_TryMove(missile, missile->x, missile->y)) + missile->x += (missile->momx >> 1); + missile->y += (missile->momy >> 1); + missile->z += (missile->momz >> 1); + if (!P_TryMove(missile, missile->x, missile->y)) { P_ExplodeMissile(missile); return(false); @@ -1358,51 +1358,51 @@ mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type) angle_t an; int dist; - switch(type) + switch (type) { case MT_MNTRFX1: // Minotaur swing attack missile - z = source->z+40*FRACUNIT; + z = source->z + 40 * FRACUNIT; break; case MT_MNTRFX2: // Minotaur floor fire missile z = ONFLOORZ; break; case MT_SRCRFX1: // Sorcerer Demon fireball - z = source->z+48*FRACUNIT; + z = source->z + 48 * FRACUNIT; break; case MT_KNIGHTAXE: // Knight normal axe case MT_REDAXE: // Knight red power axe - z = source->z+36*FRACUNIT; + z = source->z + 36 * FRACUNIT; break; default: - z = source->z+32*FRACUNIT; + z = source->z + 32 * FRACUNIT; break; } - if(source->flags2&MF2_FEETARECLIPPED) + if (source->flags2 & MF2_FEETARECLIPPED) { z -= FOOTCLIPSIZE; } th = P_SpawnMobj(source->x, source->y, z, type); - if(th->info->seesound) + if (th->info->seesound) { S_StartSound(th, th->info->seesound); } th->target = source; // Originator an = R_PointToAngle2(source->x, source->y, dest->x, dest->y); - if(dest->flags&MF_SHADOW) + if (dest->flags & MF_SHADOW) { // Invisible target - an += (P_Random()-P_Random())<<21; + an += (P_Random() - P_Random()) << 21; } 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 = dist / th->info->speed; + if (dist < 1) { dist = 1; } - th->momz = (dest->z-source->z)/dist; + th->momz = (dest->z - source->z) / dist; return(P_CheckMissileSpawn(th) ? th : NULL); } @@ -1421,27 +1421,27 @@ mobj_t *P_SpawnMissileAngle(mobj_t *source, mobjtype_t type, fixed_t z; mobj_t *mo; - switch(type) + switch (type) { case MT_MNTRFX1: // Minotaur swing attack missile - z = source->z+40*FRACUNIT; + z = source->z + 40 * FRACUNIT; break; case MT_MNTRFX2: // Minotaur floor fire missile z = ONFLOORZ; break; case MT_SRCRFX1: // Sorcerer Demon fireball - z = source->z+48*FRACUNIT; + z = source->z + 48 * FRACUNIT; break; default: - z = source->z+32*FRACUNIT; + z = source->z + 32 * FRACUNIT; break; } - if(source->flags2&MF2_FEETARECLIPPED) + if (source->flags2 & MF2_FEETARECLIPPED) { z -= FOOTCLIPSIZE; } mo = P_SpawnMobj(source->x, source->y, z, type); - if(mo->info->seesound) + if (mo->info->seesound) { S_StartSound(mo, mo->info->seesound); } @@ -1470,54 +1470,54 @@ mobj_t *P_SpawnPlayerMissile(mobj_t *source, mobjtype_t type) // Try to find a target an = source->angle; - slope = P_AimLineAttack(source, an, 16*64*FRACUNIT); - if(!linetarget) + slope = P_AimLineAttack(source, an, 16 * 64 * FRACUNIT); + if (!linetarget) { - an += 1<<26; - 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); + an -= 2 << 26; + slope = P_AimLineAttack(source, an, 16 * 64 * FRACUNIT); } - if(!linetarget) + if (!linetarget) { an = source->angle; - slope = ((source->player->lookdir)<player->lookdir) << FRACBITS) / 173; } } x = source->x; y = source->y; - z = source->z + 4*8*FRACUNIT+((source->player->lookdir)<flags2&MF2_FEETARECLIPPED) + z = source->z + 4 * 8 * FRACUNIT + ((source->player->lookdir) << FRACBITS) / 173; + if (source->flags2 & MF2_FEETARECLIPPED) { z -= FOOTCLIPSIZE; } MissileMobj = P_SpawnMobj(x, y, z, type); - if(MissileMobj->info->seesound) + if (MissileMobj->info->seesound) { S_StartSound(MissileMobj, MissileMobj->info->seesound); } MissileMobj->target = source; MissileMobj->angle = an; MissileMobj->momx = FixedMul(MissileMobj->info->speed, - finecosine[an>>ANGLETOFINESHIFT]); + finecosine[an >> ANGLETOFINESHIFT]); MissileMobj->momy = FixedMul(MissileMobj->info->speed, - finesine[an>>ANGLETOFINESHIFT]); + finesine[an >> ANGLETOFINESHIFT]); MissileMobj->momz = FixedMul(MissileMobj->info->speed, slope); - if(MissileMobj->type == MT_BLASTERFX1) + if (MissileMobj->type == MT_BLASTERFX1) { // Ultra-fast ripper spawning missile - MissileMobj->x += (MissileMobj->momx>>3); - MissileMobj->y += (MissileMobj->momy>>3); - MissileMobj->z += (MissileMobj->momz>>3); + MissileMobj->x += (MissileMobj->momx >> 3); + MissileMobj->y += (MissileMobj->momy >> 3); + MissileMobj->z += (MissileMobj->momz >> 3); } else { // Normal missile - MissileMobj->x += (MissileMobj->momx>>1); - MissileMobj->y += (MissileMobj->momy>>1); - MissileMobj->z += (MissileMobj->momz>>1); + MissileMobj->x += (MissileMobj->momx >> 1); + MissileMobj->y += (MissileMobj->momy >> 1); + MissileMobj->z += (MissileMobj->momz >> 1); } - if(!P_TryMove(MissileMobj, MissileMobj->x, MissileMobj->y)) + if (!P_TryMove(MissileMobj, MissileMobj->x, MissileMobj->y)) { // Exploded immediately P_ExplodeMissile(MissileMobj); return(NULL); @@ -1537,42 +1537,42 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle) angle_t an; fixed_t x, y, z, slope; -// -// see which target is to be aimed at -// + // + // see which target is to be aimed at + // an = angle; - slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); + slope = P_AimLineAttack (source, an, 16 * 64 * FRACUNIT); if (!linetarget) { - an += 1<<26; - slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); + an += 1 << 26; + slope = P_AimLineAttack (source, an, 16 * 64 * FRACUNIT); if (!linetarget) { - an -= 2<<26; - slope = P_AimLineAttack (source, an, 16*64*FRACUNIT); + an -= 2 << 26; + slope = P_AimLineAttack (source, an, 16 * 64 * FRACUNIT); } if (!linetarget) { an = angle; - slope = ((source->player->lookdir)<player->lookdir) << FRACBITS) / 173; } } x = source->x; y = source->y; - z = source->z + 4*8*FRACUNIT+((source->player->lookdir)<flags2&MF2_FEETARECLIPPED) + z = source->z + 4 * 8 * FRACUNIT + ((source->player->lookdir) << FRACBITS) / 173; + if (source->flags2 & MF2_FEETARECLIPPED) { z -= FOOTCLIPSIZE; } th = P_SpawnMobj(x, y, z, type); - if(th->info->seesound) + if (th->info->seesound) { S_StartSound(th, th->info->seesound); } th->target = source; th->angle = an; - th->momx = FixedMul(th->info->speed, finecosine[an>>ANGLETOFINESHIFT]); - th->momy = FixedMul(th->info->speed, finesine[an>>ANGLETOFINESHIFT]); + th->momx = FixedMul(th->info->speed, finecosine[an >> ANGLETOFINESHIFT]); + th->momy = FixedMul(th->info->speed, finesine[an >> ANGLETOFINESHIFT]); th->momz = FixedMul(th->info->speed, slope); return(P_CheckMissileSpawn(th) ? th : NULL); } @@ -1585,14 +1585,14 @@ mobj_t *P_SPMAngle(mobj_t *source, mobjtype_t type, angle_t angle) void A_ContMobjSound(mobj_t *actor) { - switch(actor->type) + switch (actor->type) { case MT_KNIGHTAXE: S_StartSound(actor, sfx_kgtatk); break; case MT_MUMMYFX1: S_StartSound(actor, sfx_mumhed); - break; + break; default: break; } diff --git a/P_PLATS.C b/P_PLATS.C index f7e5414..390276c 100644 --- a/P_PLATS.C +++ b/P_PLATS.C @@ -5,31 +5,31 @@ #include "P_local.h" #include "soundst.h" -plat_t *activeplats[MAXPLATS]; +plat_t *activeplats[MAXPLATS]; //================================================================== // // Move a plat up and down // //================================================================== -void T_PlatRaise(plat_t *plat) +void T_PlatRaise(plat_t *plat) { result_e res; - switch(plat->status) + switch (plat->status) { case up: - res = T_MovePlane(plat->sector,plat->speed, - plat->high,plat->crush,0,1); - if(!(leveltime&31)) + res = T_MovePlane(plat->sector, plat->speed, + plat->high, plat->crush, 0, 1); + if (!(leveltime & 31)) { S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_stnmov); } - if(plat->type == raiseAndChange + if (plat->type == raiseAndChange || plat->type == raiseToNearestAndChange) { - if(!(leveltime&7)) + if (!(leveltime & 7)) { S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_stnmov); @@ -42,26 +42,26 @@ void T_PlatRaise(plat_t *plat) S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_pstart); } else - if (res == pastdest) - { - plat->count = plat->wait; - plat->status = waiting; - S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_pstop); - switch(plat->type) + if (res == pastdest) { - case downWaitUpStay: - P_RemoveActivePlat(plat); - break; - case raiseAndChange: - P_RemoveActivePlat(plat); - break; - default: - break; + plat->count = plat->wait; + plat->status = waiting; + S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_pstop); + switch (plat->type) + { + case downWaitUpStay: + P_RemoveActivePlat(plat); + break; + case raiseAndChange: + P_RemoveActivePlat(plat); + break; + default: + break; + } } - } break; case down: - res = T_MovePlane(plat->sector,plat->speed,plat->low,false,0,-1); + res = T_MovePlane(plat->sector, plat->speed, plat->low, false, 0, -1); if (res == pastdest) { plat->count = plat->wait; @@ -70,7 +70,7 @@ void T_PlatRaise(plat_t *plat) } else { - if(!(leveltime&31)) + if (!(leveltime & 31)) { S_StartSound((mobj_t *)&plat->sector->soundorg, sfx_stnmov); @@ -97,20 +97,20 @@ void T_PlatRaise(plat_t *plat) // "amount" is only used for SOME platforms. // //================================================================== -int EV_DoPlat(line_t *line,plattype_e type,int amount) +int EV_DoPlat(line_t *line, plattype_e type, int amount) { - plat_t *plat; + plat_t *plat; int secnum; int rtn; - sector_t *sec; - + sector_t *sec; + secnum = -1; rtn = 0; - + // // Activate all plats that are in_stasis // - switch(type) + switch (type) { case perpetualRaise: P_ActivateInStasis(line->tag); @@ -118,41 +118,41 @@ int EV_DoPlat(line_t *line,plattype_e type,int amount) default: break; } - - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + + while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) { sec = §ors[secnum]; if (sec->specialdata) continue; - + // // Find lowest & highest floors around sector // rtn = 1; - plat = Z_Malloc( sizeof(*plat), PU_LEVSPEC, 0); + 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 = T_PlatRaise; plat->crush = false; plat->tag = line->tag; - switch(type) + switch (type) { case raiseToNearestAndChange: - plat->speed = PLATSPEED/2; + plat->speed = PLATSPEED / 2; sec->floorpic = sides[line->sidenum[0]].sector->floorpic; - plat->high = P_FindNextHighestFloor(sec,sec->floorheight); + plat->high = P_FindNextHighestFloor(sec, sec->floorheight); plat->wait = 0; plat->status = up; sec->special = 0; // NO MORE DAMAGE, IF APPLICABLE S_StartSound((mobj_t *)&sec->soundorg, sfx_stnmov); break; case raiseAndChange: - plat->speed = PLATSPEED/2; + plat->speed = PLATSPEED / 2; sec->floorpic = sides[line->sidenum[0]].sector->floorpic; - plat->high = sec->floorheight + amount*FRACUNIT; + plat->high = sec->floorheight + amount * FRACUNIT; plat->wait = 0; plat->status = up; S_StartSound((mobj_t *)&sec->soundorg, sfx_stnmov); @@ -163,7 +163,7 @@ int EV_DoPlat(line_t *line,plattype_e type,int amount) if (plat->low > sec->floorheight) plat->low = sec->floorheight; plat->high = sec->floorheight; - plat->wait = 35*PLATWAIT; + plat->wait = 35 * PLATWAIT; plat->status = down; S_StartSound((mobj_t *)&sec->soundorg, sfx_pstart); break; @@ -175,8 +175,8 @@ int EV_DoPlat(line_t *line,plattype_e type,int amount) plat->high = P_FindHighestFloorSurrounding(sec); if (plat->high < sec->floorheight) plat->high = sec->floorheight; - plat->wait = 35*PLATWAIT; - plat->status = P_Random()&1; + plat->wait = 35 * PLATWAIT; + plat->status = P_Random() & 1; S_StartSound((mobj_t *)&sec->soundorg, sfx_pstart); break; } @@ -188,8 +188,8 @@ int EV_DoPlat(line_t *line,plattype_e type,int amount) void P_ActivateInStasis(int tag) { int i; - - for (i = 0;i < MAXPLATS;i++) + + for (i = 0; i < MAXPLATS; i++) if (activeplats[i] && (activeplats[i])->tag == tag && (activeplats[i])->status == in_stasis) @@ -202,8 +202,8 @@ void P_ActivateInStasis(int tag) void EV_StopPlat(line_t *line) { int j; - - for (j = 0;j < MAXPLATS;j++) + + for (j = 0; j < MAXPLATS; j++) if (activeplats[j] && ((activeplats[j])->status != in_stasis) && ((activeplats[j])->tag == line->tag)) { @@ -216,7 +216,7 @@ void EV_StopPlat(line_t *line) void P_AddActivePlat(plat_t *plat) { int i; - for (i = 0;i < MAXPLATS;i++) + for (i = 0; i < MAXPLATS; i++) { if (activeplats[i] == NULL) { @@ -230,7 +230,7 @@ void P_AddActivePlat(plat_t *plat) void P_RemoveActivePlat(plat_t *plat) { int i; - for (i = 0;i < MAXPLATS;i++) + for (i = 0; i < MAXPLATS; i++) if (plat == activeplats[i]) { (activeplats[i])->sector->specialdata = NULL; diff --git a/P_PSPR.C b/P_PSPR.C index febcd5f..1e834ff 100644 --- a/P_PSPR.C +++ b/P_PSPR.C @@ -239,12 +239,12 @@ void P_OpenWeapons(void) void P_AddMaceSpot(mapthing_t *mthing) { - if(MaceSpotCount == MAX_MACE_SPOTS) + if (MaceSpotCount == MAX_MACE_SPOTS) { I_Error("Too many mace spots."); } - MaceSpots[MaceSpotCount].x = mthing->x<y<x << FRACBITS; + MaceSpots[MaceSpotCount].y = mthing->y << FRACBITS; MaceSpotCount++; } @@ -262,7 +262,7 @@ void P_RepositionMace(mobj_t *mo) subsector_t *ss; P_UnsetThingPosition(mo); - spot = P_Random()%MaceSpotCount; + spot = P_Random() % MaceSpotCount; mo->x = MaceSpots[spot].x; mo->y = MaceSpots[spot].y; ss = R_PointInSubsector(mo->x, mo->y); @@ -283,15 +283,15 @@ void P_CloseWeapons(void) { int spot; - if(!MaceSpotCount) + if (!MaceSpotCount) { // No maces placed return; } - if(!deathmatch && P_Random() < 64) + if (!deathmatch && P_Random() < 64) { // Sometimes doesn't show up if not in deathmatch return; } - spot = P_Random()%MaceSpotCount; + spot = P_Random() % MaceSpotCount; P_SpawnMobj(MaceSpots[spot].x, MaceSpots[spot].y, ONFLOORZ, MT_WMACE); } @@ -309,7 +309,7 @@ void P_SetPsprite(player_t *player, int position, statenum_t stnum) psp = &player->psprites[position]; do { - if(!stnum) + if (!stnum) { // Object removed itself. psp->state = NULL; break; @@ -317,21 +317,21 @@ void P_SetPsprite(player_t *player, int position, statenum_t stnum) state = &states[stnum]; psp->state = state; psp->tics = state->tics; // could be 0 - if(state->misc1) + if (state->misc1) { // Set coordinates. - psp->sx = state->misc1<sy = state->misc2<sx = state->misc1 << FRACBITS; + psp->sy = state->misc2 << FRACBITS; } - if(state->action) + if (state->action) { // Call action routine. state->action(player, psp); - if(!psp->state) + if (!psp->state) { break; } } stnum = psp->state->nextstate; - } while(!psp->tics); // An initial state of 0 could cycle through. + } while (!psp->tics); // An initial state of 0 could cycle through. } /* @@ -383,7 +383,7 @@ void P_ActivateBeak(player_t *player) void P_PostChickenWeapon(player_t *player, weapontype_t weapon) { - if(weapon == wp_beak) + if (weapon == wp_beak) { // Should never happen weapon = wp_staff; } @@ -405,15 +405,15 @@ void P_BringUpWeapon(player_t *player) { statenum_t new; - if(player->pendingweapon == wp_nochange) + if (player->pendingweapon == wp_nochange) { player->pendingweapon = player->readyweapon; } - if(player->pendingweapon == wp_gauntlets) + if (player->pendingweapon == wp_gauntlets) { S_StartSound(player->mo, sfx_gntact); } - if(player->powers[pw_weaponlevel2]) + if (player->powers[pw_weaponlevel2]) { new = wpnlev2info[player->pendingweapon].upstate; } @@ -442,7 +442,7 @@ boolean P_CheckAmmo(player_t *player) int count; ammo = wpnlev1info[player->readyweapon].ammo; - if(player->powers[pw_weaponlevel2] && !deathmatch) + if (player->powers[pw_weaponlevel2] && !deathmatch) { ammoUse = WeaponAmmoUsePL2; } @@ -451,42 +451,42 @@ boolean P_CheckAmmo(player_t *player) ammoUse = WeaponAmmoUsePL1; } count = ammoUse[player->readyweapon]; - if(ammo == am_noammo || player->ammo[ammo] >= count) + if (ammo == am_noammo || player->ammo[ammo] >= count) { return(true); } // out of ammo, pick a weapon to change to do { - if(player->weaponowned[wp_skullrod] + if (player->weaponowned[wp_skullrod] && player->ammo[am_skullrod] > ammoUse[wp_skullrod]) { player->pendingweapon = wp_skullrod; } - else if(player->weaponowned[wp_blaster] + else if (player->weaponowned[wp_blaster] && player->ammo[am_blaster] > ammoUse[wp_blaster]) { player->pendingweapon = wp_blaster; } - else if(player->weaponowned[wp_crossbow] + else if (player->weaponowned[wp_crossbow] && player->ammo[am_crossbow] > ammoUse[wp_crossbow]) { player->pendingweapon = wp_crossbow; } - else if(player->weaponowned[wp_mace] + else if (player->weaponowned[wp_mace] && player->ammo[am_mace] > ammoUse[wp_mace]) { player->pendingweapon = wp_mace; } - else if(player->ammo[am_goldwand] > ammoUse[wp_goldwand]) + else if (player->ammo[am_goldwand] > ammoUse[wp_goldwand]) { player->pendingweapon = wp_goldwand; } - else if(player->weaponowned[wp_gauntlets]) + else if (player->weaponowned[wp_gauntlets]) { player->pendingweapon = wp_gauntlets; } - else if(player->weaponowned[wp_phoenixrod] + else if (player->weaponowned[wp_phoenixrod] && player->ammo[am_phoenixrod] > ammoUse[wp_phoenixrod]) { player->pendingweapon = wp_phoenixrod; @@ -495,8 +495,8 @@ boolean P_CheckAmmo(player_t *player) { player->pendingweapon = wp_staff; } - } while(player->pendingweapon == wp_nochange); - if(player->powers[pw_weaponlevel2]) + } while (player->pendingweapon == wp_nochange); + if (player->powers[pw_weaponlevel2]) { P_SetPsprite(player, ps_weapon, wpnlev2info[player->readyweapon].downstate); @@ -520,7 +520,7 @@ void P_FireWeapon(player_t *player) weaponinfo_t *wpinfo; statenum_t attackState; - if(!P_CheckAmmo(player)) + if (!P_CheckAmmo(player)) { return; } @@ -531,7 +531,7 @@ void P_FireWeapon(player_t *player) : wpinfo[player->readyweapon].atkstate; P_SetPsprite(player, ps_weapon, attackState); P_NoiseAlert(player->mo, player->mo); - if(player->readyweapon == wp_gauntlets && !player->refire) + if (player->readyweapon == wp_gauntlets && !player->refire) { // Play the sound for the initial gauntlet attack S_StartSound(player->mo, sfx_gntuse); } @@ -547,7 +547,7 @@ void P_FireWeapon(player_t *player) void P_DropWeapon(player_t *player) { - if(player->powers[pw_weaponlevel2]) + if (player->powers[pw_weaponlevel2]) { P_SetPsprite(player, ps_weapon, wpnlev2info[player->readyweapon].downstate); @@ -571,19 +571,19 @@ void A_WeaponReady(player_t *player, pspdef_t *psp) { int angle; - if(player->chickenTics) + if (player->chickenTics) { // Change to the chicken beak P_ActivateBeak(player); return; } // Change player from attack state - if(player->mo->state == &states[S_PLAY_ATK1] + if (player->mo->state == &states[S_PLAY_ATK1] || player->mo->state == &states[S_PLAY_ATK2]) { P_SetMobjState(player->mo, S_PLAY); } // Check for staff PL2 active sound - if((player->readyweapon == wp_staff) + if ((player->readyweapon == wp_staff) && (psp->state == &states[S_STAFFREADY2_1]) && P_Random() < 128) { @@ -591,9 +591,9 @@ void A_WeaponReady(player_t *player, pspdef_t *psp) } // Put the weapon away if the player has a pending weapon or has // died. - if(player->pendingweapon != wp_nochange || !player->health) + if (player->pendingweapon != wp_nochange || !player->health) { - if(player->powers[pw_weaponlevel2]) + if (player->powers[pw_weaponlevel2]) { P_SetPsprite(player, ps_weapon, wpnlev2info[player->readyweapon].downstate); @@ -607,9 +607,9 @@ void A_WeaponReady(player_t *player, pspdef_t *psp) } // Check for fire. The phoenix rod does not auto fire. - if(player->cmd.buttons&BT_ATTACK) + if (player->cmd.buttons & BT_ATTACK) { - if(!player->attackdown || (player->readyweapon != wp_phoenixrod)) + if (!player->attackdown || (player->readyweapon != wp_phoenixrod)) { player->attackdown = true; P_FireWeapon(player); @@ -622,10 +622,10 @@ void A_WeaponReady(player_t *player, pspdef_t *psp) } // Bob the weapon based on movement speed. - angle = (128*leveltime)&FINEMASK; - psp->sx = FRACUNIT+FixedMul(player->bob, finecosine[angle]); - angle &= FINEANGLES/2-1; - psp->sy = WEAPONTOP+FixedMul(player->bob, finesine[angle]); + angle = (128 * leveltime) & FINEMASK; + psp->sx = FRACUNIT + FixedMul(player->bob, finecosine[angle]); + angle &= FINEANGLES / 2 - 1; + psp->sy = WEAPONTOP + FixedMul(player->bob, finesine[angle]); } //--------------------------------------------------------------------------- @@ -636,7 +636,7 @@ void A_WeaponReady(player_t *player, pspdef_t *psp) void P_UpdateBeak(player_t *player, pspdef_t *psp) { - psp->sy = WEAPONTOP+(player->chickenPeck<<(FRACBITS-1)); + psp->sy = WEAPONTOP + (player->chickenPeck << (FRACBITS - 1)); } //--------------------------------------------------------------------------- @@ -647,11 +647,11 @@ void P_UpdateBeak(player_t *player, pspdef_t *psp) void A_BeakReady(player_t *player, pspdef_t *psp) { - if(player->cmd.buttons&BT_ATTACK) + if (player->cmd.buttons & BT_ATTACK) { // Chicken beak attack player->attackdown = true; P_SetMobjState(player->mo, S_CHICPLAY_ATK1); - if(player->powers[pw_weaponlevel2]) + if (player->powers[pw_weaponlevel2]) { P_SetPsprite(player, ps_weapon, S_BEAKATK2_1); } @@ -663,7 +663,7 @@ void A_BeakReady(player_t *player, pspdef_t *psp) } else { - if(player->mo->state == &states[S_CHICPLAY_ATK1]) + if (player->mo->state == &states[S_CHICPLAY_ATK1]) { // Take out of attack state P_SetMobjState(player->mo, S_CHICPLAY); } @@ -681,7 +681,7 @@ void A_BeakReady(player_t *player, pspdef_t *psp) void A_ReFire(player_t *player, pspdef_t *psp) { - if((player->cmd.buttons&BT_ATTACK) + if ((player->cmd.buttons & BT_ATTACK) && player->pendingweapon == wp_nochange && player->health) { player->refire++; @@ -702,7 +702,7 @@ void A_ReFire(player_t *player, pspdef_t *psp) void A_Lower(player_t *player, pspdef_t *psp) { - if(player->chickenTics) + if (player->chickenTics) { psp->sy = WEAPONBOTTOM; } @@ -710,18 +710,18 @@ void A_Lower(player_t *player, pspdef_t *psp) { psp->sy += LOWERSPEED; } - if(psp->sy < WEAPONBOTTOM) + if (psp->sy < WEAPONBOTTOM) { // Not lowered all the way yet return; } - if(player->playerstate == PST_DEAD) + if (player->playerstate == PST_DEAD) { // Player is dead, so don't bring up a pending weapon psp->sy = WEAPONBOTTOM; return; } - if(!player->health) + if (!player->health) { // Player is dead, so keep the weapon off screen - P_SetPsprite(player, ps_weapon, S_NULL); + P_SetPsprite(player, ps_weapon, S_NULL); return; } player->readyweapon = player->pendingweapon; @@ -750,12 +750,12 @@ void A_BeakRaise(player_t *player, pspdef_t *psp) void A_Raise(player_t *player, pspdef_t *psp) { psp->sy -= RAISESPEED; - if(psp->sy > WEAPONTOP) + if (psp->sy > WEAPONTOP) { // Not raised all the way yet return; } psp->sy = WEAPONTOP; - if(player->powers[pw_weaponlevel2]) + if (player->powers[pw_weaponlevel2]) { P_SetPsprite(player, ps_weapon, wpnlev2info[player->readyweapon].readystate); @@ -782,24 +782,24 @@ void P_BulletSlope (mobj_t *mo) { angle_t an; -// -// see which target is to be aimed at -// + // + // see which target is to be aimed at + // an = mo->angle; - bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT); + bulletslope = P_AimLineAttack (mo, an, 16 * 64 * FRACUNIT); if (!linetarget) { - an += 1<<26; - bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT); + an += 1 << 26; + bulletslope = P_AimLineAttack (mo, an, 16 * 64 * FRACUNIT); if (!linetarget) { - an -= 2<<26; - bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT); + an -= 2 << 26; + bulletslope = P_AimLineAttack (mo, an, 16 * 64 * FRACUNIT); } if (!linetarget) { - an += 2<<26; - bulletslope = (mo->player->lookdir<player->lookdir << FRACBITS) / 173; } } } @@ -822,19 +822,19 @@ void A_BeakAttackPL1(player_t *player, pspdef_t *psp) int damage; int slope; - damage = 1+(P_Random()&3); + damage = 1 + (P_Random() & 3); angle = player->mo->angle; slope = P_AimLineAttack(player->mo, angle, MELEERANGE); PuffType = MT_BEAKPUFF; P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); - if(linetarget) + if (linetarget) { player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, linetarget->x, linetarget->y); } - S_StartSound(player->mo, sfx_chicpk1+(P_Random()%3)); + S_StartSound(player->mo, sfx_chicpk1 + (P_Random() % 3)); player->chickenPeck = 12; - psp->tics -= P_Random()&7; + psp->tics -= P_Random() & 7; } //---------------------------------------------------------------------------- @@ -854,14 +854,14 @@ void A_BeakAttackPL2(player_t *player, pspdef_t *psp) slope = P_AimLineAttack(player->mo, angle, MELEERANGE); PuffType = MT_BEAKPUFF; P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); - if(linetarget) + if (linetarget) { player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, linetarget->x, linetarget->y); } - S_StartSound(player->mo, sfx_chicpk1+(P_Random()%3)); + S_StartSound(player->mo, sfx_chicpk1 + (P_Random() % 3)); player->chickenPeck = 12; - psp->tics -= P_Random()&3; + psp->tics -= P_Random() & 3; } //---------------------------------------------------------------------------- @@ -876,13 +876,13 @@ void A_StaffAttackPL1(player_t *player, pspdef_t *psp) int damage; int slope; - damage = 5+(P_Random()&15); + damage = 5 + (P_Random() & 15); angle = player->mo->angle; - angle += (P_Random()-P_Random())<<18; + angle += (P_Random() - P_Random()) << 18; slope = P_AimLineAttack(player->mo, angle, MELEERANGE); PuffType = MT_STAFFPUFF; P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); - if(linetarget) + if (linetarget) { //S_StartSound(player->mo, sfx_stfhit); // turn to face target @@ -904,13 +904,13 @@ void A_StaffAttackPL2(player_t *player, pspdef_t *psp) int slope; // P_inter.c:P_DamageMobj() handles target momentums - damage = 18+(P_Random()&63); + damage = 18 + (P_Random() & 63); angle = player->mo->angle; - angle += (P_Random()-P_Random())<<18; + angle += (P_Random() - P_Random()) << 18; slope = P_AimLineAttack(player->mo, angle, MELEERANGE); PuffType = MT_STAFFPUFF2; P_LineAttack(player->mo, angle, MELEERANGE, slope, damage); - if(linetarget) + if (linetarget) { //S_StartSound(player->mo, sfx_stfpow); // turn to face target @@ -937,9 +937,9 @@ void A_FireBlasterPL1(player_t *player, pspdef_t *psp) P_BulletSlope(mo); damage = HITDICE(4); angle = mo->angle; - if(player->refire) + if (player->refire) { - angle += (P_Random()-P_Random())<<18; + angle += (P_Random() - P_Random()) << 18; } PuffType = MT_BLASTERPUFF1; P_LineAttack(mo, angle, MISSILERANGE, bulletslope, damage); @@ -959,7 +959,7 @@ void A_FireBlasterPL2(player_t *player, pspdef_t *psp) player->ammo[am_blaster] -= deathmatch ? USE_BLSR_AMMO_1 : USE_BLSR_AMMO_2; mo = P_SpawnPlayerMissile(player->mo, MT_BLASTERFX1); - if(mo) + if (mo) { mo->thinker.function = P_BlasterMobjThinker; } @@ -981,11 +981,11 @@ void A_FireGoldWandPL1(player_t *player, pspdef_t *psp) mo = player->mo; player->ammo[am_goldwand] -= USE_GWND_AMMO_1; P_BulletSlope(mo); - damage = 7+(P_Random()&7); + damage = 7 + (P_Random() & 7); angle = mo->angle; - if(player->refire) + if (player->refire) { - angle += (P_Random()-P_Random())<<18; + angle += (P_Random() - P_Random()) << 18; } PuffType = MT_GOLDWANDPUFF1; P_LineAttack(mo, angle, MISSILERANGE, bulletslope, damage); @@ -1012,14 +1012,14 @@ void A_FireGoldWandPL2(player_t *player, pspdef_t *psp) PuffType = MT_GOLDWANDPUFF2; P_BulletSlope(mo); momz = FixedMul(mobjinfo[MT_GOLDWANDFX2].speed, bulletslope); - P_SpawnMissileAngle(mo, MT_GOLDWANDFX2, mo->angle-(ANG45/8), momz); - P_SpawnMissileAngle(mo, MT_GOLDWANDFX2, mo->angle+(ANG45/8), momz); - angle = mo->angle-(ANG45/8); - for(i = 0; i < 5; i++) + P_SpawnMissileAngle(mo, MT_GOLDWANDFX2, mo->angle - (ANG45 / 8), momz); + P_SpawnMissileAngle(mo, MT_GOLDWANDFX2, mo->angle + (ANG45 / 8), momz); + angle = mo->angle - (ANG45 / 8); + for (i = 0; i < 5; i++) { - damage = 1+(P_Random()&7); + damage = 1 + (P_Random() & 7); P_LineAttack(mo, angle, MISSILERANGE, bulletslope, damage); - angle += ((ANG45/8)*2)/4; + angle += ((ANG45 / 8) * 2) / 4; } S_StartSound(player->mo, sfx_gldhit); } @@ -1036,24 +1036,24 @@ void A_FireMacePL1B(player_t *player, pspdef_t *psp) mobj_t *ball; angle_t angle; - if(player->ammo[am_mace] < USE_MACE_AMMO_1) + if (player->ammo[am_mace] < USE_MACE_AMMO_1) { return; } player->ammo[am_mace] -= USE_MACE_AMMO_1; pmo = player->mo; - ball = P_SpawnMobj(pmo->x, pmo->y, pmo->z+28*FRACUNIT - - FOOTCLIPSIZE*(pmo->flags2&MF2_FEETARECLIPPED != 0), MT_MACEFX2); - ball->momz = 2*FRACUNIT+((player->lookdir)<<(FRACBITS-5)); + ball = P_SpawnMobj(pmo->x, pmo->y, pmo->z + 28 * FRACUNIT + - FOOTCLIPSIZE * (pmo->flags2 & MF2_FEETARECLIPPED != 0), MT_MACEFX2); + ball->momz = 2 * FRACUNIT + ((player->lookdir) << (FRACBITS - 5)); angle = pmo->angle; ball->target = pmo; ball->angle = angle; - ball->z += (player->lookdir)<<(FRACBITS-4); + ball->z += (player->lookdir) << (FRACBITS - 4); angle >>= ANGLETOFINESHIFT; - ball->momx = (pmo->momx>>1) - +FixedMul(ball->info->speed, finecosine[angle]); - ball->momy = (pmo->momy>>1) - +FixedMul(ball->info->speed, finesine[angle]); + ball->momx = (pmo->momx >> 1) + + FixedMul(ball->info->speed, finecosine[angle]); + ball->momy = (pmo->momy >> 1) + + FixedMul(ball->info->speed, finesine[angle]); S_StartSound(ball, sfx_lobsht); P_CheckMissileSpawn(ball); } @@ -1068,21 +1068,21 @@ void A_FireMacePL1(player_t *player, pspdef_t *psp) { mobj_t *ball; - if(P_Random() < 28) + if (P_Random() < 28) { A_FireMacePL1B(player, psp); return; } - if(player->ammo[am_mace] < USE_MACE_AMMO_1) + if (player->ammo[am_mace] < USE_MACE_AMMO_1) { return; } player->ammo[am_mace] -= USE_MACE_AMMO_1; - psp->sx = ((P_Random()&3)-2)*FRACUNIT; - psp->sy = WEAPONTOP+(P_Random()&3)*FRACUNIT; + psp->sx = ((P_Random() & 3) - 2) * FRACUNIT; + psp->sy = WEAPONTOP + (P_Random() & 3) * FRACUNIT; ball = P_SPMAngle(player->mo, MT_MACEFX1, player->mo->angle - +(((P_Random()&7)-4)<<24)); - if(ball) + + (((P_Random() & 7) - 4) << 24)); + if (ball) { ball->special1 = 16; // tics till dropoff } @@ -1098,21 +1098,21 @@ void A_MacePL1Check(mobj_t *ball) { angle_t angle; - if(ball->special1 == 0) + if (ball->special1 == 0) { return; } ball->special1 -= 4; - if(ball->special1 > 0) + if (ball->special1 > 0) { return; } ball->special1 = 0; ball->flags2 |= MF2_LOGRAV; - angle = ball->angle>>ANGLETOFINESHIFT; - ball->momx = FixedMul(7*FRACUNIT, finecosine[angle]); - ball->momy = FixedMul(7*FRACUNIT, finesine[angle]); - ball->momz -= ball->momz>>1; + angle = ball->angle >> ANGLETOFINESHIFT; + ball->momx = FixedMul(7 * FRACUNIT, finecosine[angle]); + ball->momy = FixedMul(7 * FRACUNIT, finesine[angle]); + ball->momz -= ball->momz >> 1; } //---------------------------------------------------------------------------- @@ -1123,16 +1123,16 @@ void A_MacePL1Check(mobj_t *ball) void A_MaceBallImpact(mobj_t *ball) { - if((ball->z <= ball->floorz) && (P_HitFloor(ball) != FLOOR_SOLID)) + if ((ball->z <= ball->floorz) && (P_HitFloor(ball) != FLOOR_SOLID)) { // Landed in some sort of liquid P_RemoveMobj(ball); return; } - if((ball->health != MAGIC_JUNK) && (ball->z <= ball->floorz) + if ((ball->health != MAGIC_JUNK) && (ball->z <= ball->floorz) && ball->momz) { // Bounce ball->health = MAGIC_JUNK; - ball->momz = (ball->momz*192)>>8; + ball->momz = (ball->momz * 192) >> 8; ball->flags2 &= ~MF2_FLOORBOUNCE; P_SetMobjState(ball, ball->info->spawnstate); S_StartSound(ball, sfx_bounce); @@ -1156,42 +1156,42 @@ void A_MaceBallImpact2(mobj_t *ball) mobj_t *tiny; angle_t angle; - if((ball->z <= ball->floorz) && (P_HitFloor(ball) != FLOOR_SOLID)) + if ((ball->z <= ball->floorz) && (P_HitFloor(ball) != FLOOR_SOLID)) { // Landed in some sort of liquid P_RemoveMobj(ball); return; } - if((ball->z != ball->floorz) || (ball->momz < 2*FRACUNIT)) + if ((ball->z != ball->floorz) || (ball->momz < 2 * FRACUNIT)) { // Explode ball->momx = ball->momy = ball->momz = 0; ball->flags |= MF_NOGRAVITY; - ball->flags2 &= ~(MF2_LOGRAV|MF2_FLOORBOUNCE); + ball->flags2 &= ~(MF2_LOGRAV | MF2_FLOORBOUNCE); } else { // Bounce - ball->momz = (ball->momz*192)>>8; + ball->momz = (ball->momz * 192) >> 8; P_SetMobjState(ball, ball->info->spawnstate); tiny = P_SpawnMobj(ball->x, ball->y, ball->z, MT_MACEFX3); - angle = ball->angle+ANG90; + angle = ball->angle + ANG90; tiny->target = ball->target; tiny->angle = angle; angle >>= ANGLETOFINESHIFT; - tiny->momx = (ball->momx>>1)+FixedMul(ball->momz-FRACUNIT, + tiny->momx = (ball->momx >> 1) + FixedMul(ball->momz - FRACUNIT, finecosine[angle]); - tiny->momy = (ball->momy>>1)+FixedMul(ball->momz-FRACUNIT, + tiny->momy = (ball->momy >> 1) + FixedMul(ball->momz - FRACUNIT, finesine[angle]); tiny->momz = ball->momz; P_CheckMissileSpawn(tiny); tiny = P_SpawnMobj(ball->x, ball->y, ball->z, MT_MACEFX3); - angle = ball->angle-ANG90; + angle = ball->angle - ANG90; tiny->target = ball->target; tiny->angle = angle; angle >>= ANGLETOFINESHIFT; - tiny->momx = (ball->momx>>1)+FixedMul(ball->momz-FRACUNIT, + tiny->momx = (ball->momx >> 1) + FixedMul(ball->momz - FRACUNIT, finecosine[angle]); - tiny->momy = (ball->momy>>1)+FixedMul(ball->momz-FRACUNIT, + tiny->momy = (ball->momy >> 1) + FixedMul(ball->momz - FRACUNIT, finesine[angle]); tiny->momz = ball->momz; P_CheckMissileSpawn(tiny); @@ -1211,12 +1211,12 @@ void A_FireMacePL2(player_t *player, pspdef_t *psp) player->ammo[am_mace] -= deathmatch ? USE_MACE_AMMO_1 : USE_MACE_AMMO_2; mo = P_SpawnPlayerMissile(player->mo, MT_MACEFX4); - if(mo) + if (mo) { mo->momx += player->mo->momx; mo->momy += player->mo->momy; - mo->momz = 2*FRACUNIT+((player->lookdir)<<(FRACBITS-5)); - if(linetarget) + mo->momz = 2 * FRACUNIT + ((player->lookdir) << (FRACBITS - 5)); + if (linetarget) { mo->special1 = (int)linetarget; } @@ -1237,18 +1237,18 @@ void A_DeathBallImpact(mobj_t *ball) angle_t angle; boolean newAngle; - if((ball->z <= ball->floorz) && (P_HitFloor(ball) != FLOOR_SOLID)) + if ((ball->z <= ball->floorz) && (P_HitFloor(ball) != FLOOR_SOLID)) { // Landed in some sort of liquid P_RemoveMobj(ball); return; } - if((ball->z <= ball->floorz) && ball->momz) + if ((ball->z <= ball->floorz) && ball->momz) { // Bounce newAngle = false; target = (mobj_t *)ball->special1; - if(target) + if (target) { - if(!(target->flags&MF_SHOOTABLE)) + if (!(target->flags & MF_SHOOTABLE)) { // Target died ball->special1 = 0; } @@ -1262,10 +1262,10 @@ void A_DeathBallImpact(mobj_t *ball) else { // Find new target angle = 0; - for(i = 0; i < 16; i++) + for (i = 0; i < 16; i++) { - P_AimLineAttack(ball, angle, 10*64*FRACUNIT); - if(linetarget && ball->target != linetarget) + P_AimLineAttack(ball, angle, 10 * 64 * FRACUNIT); + if (linetarget && ball->target != linetarget) { ball->special1 = (int)linetarget; angle = R_PointToAngle2(ball->x, ball->y, @@ -1273,10 +1273,10 @@ void A_DeathBallImpact(mobj_t *ball) newAngle = true; break; } - angle += ANGLE_45/2; + angle += ANGLE_45 / 2; } } - if(newAngle) + if (newAngle) { ball->angle = angle; angle >>= ANGLETOFINESHIFT; @@ -1306,10 +1306,10 @@ void A_SpawnRippers(mobj_t *actor) angle_t angle; mobj_t *ripper; - for(i = 0; i < 8; i++) + for (i = 0; i < 8; i++) { ripper = P_SpawnMobj(actor->x, actor->y, actor->z, MT_RIPPER); - angle = i*ANG45; + angle = i * ANG45; ripper->target = actor->target; ripper->angle = angle; angle >>= ANGLETOFINESHIFT; @@ -1332,8 +1332,8 @@ void A_FireCrossbowPL1(player_t *player, pspdef_t *psp) pmo = player->mo; player->ammo[am_crossbow] -= USE_CBOW_AMMO_1; P_SpawnPlayerMissile(pmo, MT_CRBOWFX1); - P_SPMAngle(pmo, MT_CRBOWFX3, pmo->angle-(ANG45/10)); - P_SPMAngle(pmo, MT_CRBOWFX3, pmo->angle+(ANG45/10)); + P_SPMAngle(pmo, MT_CRBOWFX3, pmo->angle - (ANG45 / 10)); + P_SPMAngle(pmo, MT_CRBOWFX3, pmo->angle + (ANG45 / 10)); } //---------------------------------------------------------------------------- @@ -1350,10 +1350,10 @@ void A_FireCrossbowPL2(player_t *player, pspdef_t *psp) player->ammo[am_crossbow] -= deathmatch ? USE_CBOW_AMMO_1 : USE_CBOW_AMMO_2; P_SpawnPlayerMissile(pmo, MT_CRBOWFX2); - P_SPMAngle(pmo, MT_CRBOWFX2, pmo->angle-(ANG45/10)); - P_SPMAngle(pmo, MT_CRBOWFX2, pmo->angle+(ANG45/10)); - P_SPMAngle(pmo, MT_CRBOWFX3, pmo->angle-(ANG45/5)); - P_SPMAngle(pmo, MT_CRBOWFX3, pmo->angle+(ANG45/5)); + P_SPMAngle(pmo, MT_CRBOWFX2, pmo->angle - (ANG45 / 10)); + P_SPMAngle(pmo, MT_CRBOWFX2, pmo->angle + (ANG45 / 10)); + P_SPMAngle(pmo, MT_CRBOWFX3, pmo->angle - (ANG45 / 5)); + P_SPMAngle(pmo, MT_CRBOWFX3, pmo->angle + (ANG45 / 5)); } //---------------------------------------------------------------------------- @@ -1366,11 +1366,11 @@ void A_BoltSpark(mobj_t *bolt) { mobj_t *spark; - if(P_Random() > 50) + if (P_Random() > 50) { spark = P_SpawnMobj(bolt->x, bolt->y, bolt->z, MT_CRBOWFX4); - spark->x += (P_Random()-P_Random())<<10; - spark->y += (P_Random()-P_Random())<<10; + spark->x += (P_Random() - P_Random()) << 10; + spark->y += (P_Random() - P_Random()) << 10; } } @@ -1384,14 +1384,14 @@ void A_FireSkullRodPL1(player_t *player, pspdef_t *psp) { mobj_t *mo; - if(player->ammo[am_skullrod] < USE_SKRD_AMMO_1) + if (player->ammo[am_skullrod] < USE_SKRD_AMMO_1) { return; } player->ammo[am_skullrod] -= USE_SKRD_AMMO_1; mo = P_SpawnPlayerMissile(player->mo, MT_HORNRODFX1); // Randomize the first frame - if(mo && P_Random() > 128) + if (mo && P_Random() > 128) { P_SetMobjState(mo, S_HRODFX1_2); } @@ -1415,7 +1415,7 @@ void A_FireSkullRodPL2(player_t *player, pspdef_t *psp) // Use MissileMobj instead of the return value from // P_SpawnPlayerMissile because we need to give info to the mobj // even if it exploded immediately. - if(netgame) + if (netgame) { // Multi-player game MissileMobj->special2 = P_GetPlayerNum(player); } @@ -1423,7 +1423,7 @@ void A_FireSkullRodPL2(player_t *player, pspdef_t *psp) { // Always use red missiles in single player games MissileMobj->special2 = 2; } - if(linetarget) + if (linetarget) { MissileMobj->special1 = (int)linetarget; } @@ -1438,7 +1438,7 @@ void A_FireSkullRodPL2(player_t *player, pspdef_t *psp) void A_SkullRodPL2Seek(mobj_t *actor) { - P_SeekerMissile(actor, ANGLE_1*10, ANGLE_1*30); + P_SeekerMissile(actor, ANGLE_1 * 10, ANGLE_1 * 30); } //---------------------------------------------------------------------------- @@ -1453,20 +1453,20 @@ void A_AddPlayerRain(mobj_t *actor) player_t *player; playerNum = netgame ? actor->special2 : 0; - if(!playeringame[playerNum]) + if (!playeringame[playerNum]) { // Player left the game return; } player = &players[playerNum]; - if(player->health <= 0) + if (player->health <= 0) { // Player is dead return; } - if(player->rain1 && player->rain2) + if (player->rain1 && player->rain2) { // Terminate an active rain - if(player->rain1->health < player->rain2->health) + if (player->rain1->health < player->rain2->health) { - if(player->rain1->health > 16) + if (player->rain1->health > 16) { player->rain1->health = 16; } @@ -1474,7 +1474,7 @@ void A_AddPlayerRain(mobj_t *actor) } else { - if(player->rain2->health > 16) + if (player->rain2->health > 16) { player->rain2->health = 16; } @@ -1482,7 +1482,7 @@ void A_AddPlayerRain(mobj_t *actor) } } // Add rain mobj to list - if(player->rain1) + if (player->rain1) { player->rain2 = actor; } @@ -1506,42 +1506,42 @@ void A_SkullRodStorm(mobj_t *actor) int playerNum; player_t *player; - if(actor->health-- == 0) + if (actor->health-- == 0) { P_SetMobjState(actor, S_NULL); playerNum = netgame ? actor->special2 : 0; - if(!playeringame[playerNum]) + if (!playeringame[playerNum]) { // Player left the game return; } player = &players[playerNum]; - if(player->health <= 0) + if (player->health <= 0) { // Player is dead return; } - if(player->rain1 == actor) + if (player->rain1 == actor) { player->rain1 = NULL; } - else if(player->rain2 == actor) + else if (player->rain2 == actor) { player->rain2 = NULL; } return; } - if(P_Random() < 25) + if (P_Random() < 25) { // Fudge rain frequency return; } - x = actor->x+((P_Random()&127)-64)*FRACUNIT; - y = actor->y+((P_Random()&127)-64)*FRACUNIT; - mo = P_SpawnMobj(x, y, ONCEILINGZ, MT_RAINPLR1+actor->special2); + x = actor->x + ((P_Random() & 127) - 64) * FRACUNIT; + y = actor->y + ((P_Random() & 127) - 64) * FRACUNIT; + mo = P_SpawnMobj(x, y, ONCEILINGZ, MT_RAINPLR1 + actor->special2); mo->target = actor->target; mo->momx = 1; // Force collision detection mo->momz = -mo->info->speed; mo->special2 = actor->special2; // Transfer player number P_CheckMissileSpawn(mo); - if(!(actor->special1&31)) + if (!(actor->special1 & 31)) { S_StartSound(actor, sfx_ramrain); } @@ -1556,11 +1556,11 @@ void A_SkullRodStorm(mobj_t *actor) void A_RainImpact(mobj_t *actor) { - if(actor->z > actor->floorz) + if (actor->z > actor->floorz) { - P_SetMobjState(actor, S_RAINAIRXPLR1_1+actor->special2); + P_SetMobjState(actor, S_RAINAIRXPLR1_1 + actor->special2); } - else if(P_Random() < 40) + else if (P_Random() < 40) { P_HitFloor(actor); } @@ -1574,7 +1574,7 @@ void A_RainImpact(mobj_t *actor) void A_HideInCeiling(mobj_t *actor) { - actor->z = actor->ceilingz+4*FRACUNIT; + actor->z = actor->ceilingz + 4 * FRACUNIT; } //---------------------------------------------------------------------------- @@ -1590,10 +1590,10 @@ void A_FirePhoenixPL1(player_t *player, pspdef_t *psp) player->ammo[am_phoenixrod] -= USE_PHRD_AMMO_1; P_SpawnPlayerMissile(player->mo, MT_PHOENIXFX1); //P_SpawnPlayerMissile(player->mo, MT_MNTRFX2); - angle = player->mo->angle+ANG180; + angle = player->mo->angle + ANG180; angle >>= ANGLETOFINESHIFT; - player->mo->momx += FixedMul(4*FRACUNIT, finecosine[angle]); - player->mo->momy += FixedMul(4*FRACUNIT, finesine[angle]); + player->mo->momx += FixedMul(4 * FRACUNIT, finecosine[angle]); + player->mo->momy += FixedMul(4 * FRACUNIT, finesine[angle]); } //---------------------------------------------------------------------------- @@ -1607,18 +1607,18 @@ void A_PhoenixPuff(mobj_t *actor) mobj_t *puff; angle_t angle; - P_SeekerMissile(actor, ANGLE_1*5, ANGLE_1*10); + P_SeekerMissile(actor, ANGLE_1 * 5, ANGLE_1 * 10); puff = P_SpawnMobj(actor->x, actor->y, actor->z, MT_PHOENIXPUFF); - angle = actor->angle+ANG90; + angle = actor->angle + ANG90; angle >>= ANGLETOFINESHIFT; - puff->momx = FixedMul(FRACUNIT*1.3, finecosine[angle]); - puff->momy = FixedMul(FRACUNIT*1.3, finesine[angle]); + puff->momx = FixedMul(FRACUNIT * 1.3, finecosine[angle]); + puff->momy = FixedMul(FRACUNIT * 1.3, finesine[angle]); puff->momz = 0; puff = P_SpawnMobj(actor->x, actor->y, actor->z, MT_PHOENIXPUFF); - angle = actor->angle-ANG90; + angle = actor->angle - ANG90; angle >>= ANGLETOFINESHIFT; - puff->momx = FixedMul(FRACUNIT*1.3, finecosine[angle]); - puff->momy = FixedMul(FRACUNIT*1.3, finesine[angle]); + puff->momx = FixedMul(FRACUNIT * 1.3, finecosine[angle]); + puff->momy = FixedMul(FRACUNIT * 1.3, finesine[angle]); puff->momz = 0; } @@ -1649,7 +1649,7 @@ void A_FirePhoenixPL2(player_t *player, pspdef_t *psp) fixed_t x, y, z; fixed_t slope; - if(--player->flamecount == 0) + if (--player->flamecount == 0) { // Out of flame P_SetPsprite(player, ps_weapon, S_PHOENIXATK2_4); player->refire = 0; @@ -1657,26 +1657,26 @@ void A_FirePhoenixPL2(player_t *player, pspdef_t *psp) } pmo = player->mo; angle = pmo->angle; - x = pmo->x+((P_Random()-P_Random())<<9); - y = pmo->y+((P_Random()-P_Random())<<9); - z = pmo->z+26*FRACUNIT+((player->lookdir)<flags2&MF2_FEETARECLIPPED) + x = pmo->x + ((P_Random() - P_Random()) << 9); + y = pmo->y + ((P_Random() - P_Random()) << 9); + z = pmo->z + 26 * FRACUNIT + ((player->lookdir) << FRACBITS) / 173; + if (pmo->flags2 & MF2_FEETARECLIPPED) { z -= FOOTCLIPSIZE; } - slope = ((player->lookdir)<lookdir) << FRACBITS) / 173 + (FRACUNIT / 10); mo = P_SpawnMobj(x, y, z, MT_PHOENIXFX2); mo->target = pmo; mo->angle = angle; - mo->momx = pmo->momx+FixedMul(mo->info->speed, - finecosine[angle>>ANGLETOFINESHIFT]); - mo->momy = pmo->momy+FixedMul(mo->info->speed, - finesine[angle>>ANGLETOFINESHIFT]); + mo->momx = pmo->momx + FixedMul(mo->info->speed, + finecosine[angle >> ANGLETOFINESHIFT]); + mo->momy = pmo->momy + FixedMul(mo->info->speed, + finesine[angle >> ANGLETOFINESHIFT]); mo->momz = FixedMul(mo->info->speed, slope); - if(!player->refire || !(leveltime%38)) + if (!player->refire || !(leveltime % 38)) { S_StartSound(player->mo, sfx_phopow); - } + } P_CheckMissileSpawn(mo); } @@ -1699,7 +1699,7 @@ void A_ShutdownPhoenixPL2(player_t *player, pspdef_t *psp) void A_FlameEnd(mobj_t *actor) { - actor->momz += 1.5*FRACUNIT; + actor->momz += 1.5 * FRACUNIT; } //---------------------------------------------------------------------------- @@ -1710,7 +1710,7 @@ void A_FlameEnd(mobj_t *actor) void A_FloatPuff(mobj_t *puff) { - puff->momz += 1.8*FRACUNIT; + puff->momz += 1.8 * FRACUNIT; } //--------------------------------------------------------------------------- @@ -1727,28 +1727,28 @@ void A_GauntletAttack(player_t *player, pspdef_t *psp) int randVal; fixed_t dist; - psp->sx = ((P_Random()&3)-2)*FRACUNIT; - psp->sy = WEAPONTOP+(P_Random()&3)*FRACUNIT; + psp->sx = ((P_Random() & 3) - 2) * FRACUNIT; + psp->sy = WEAPONTOP + (P_Random() & 3) * FRACUNIT; angle = player->mo->angle; - if(player->powers[pw_weaponlevel2]) + if (player->powers[pw_weaponlevel2]) { damage = HITDICE(2); - dist = 4*MELEERANGE; - angle += (P_Random()-P_Random())<<17; + dist = 4 * MELEERANGE; + angle += (P_Random() - P_Random()) << 17; PuffType = MT_GAUNTLETPUFF2; } else { damage = HITDICE(2); - dist = MELEERANGE+1; - angle += (P_Random()-P_Random())<<18; + dist = MELEERANGE + 1; + angle += (P_Random() - P_Random()) << 18; PuffType = MT_GAUNTLETPUFF1; } slope = P_AimLineAttack(player->mo, angle, dist); P_LineAttack(player->mo, angle, dist, slope, damage); - if(!linetarget) + if (!linetarget) { - if(P_Random() > 64) + if (P_Random() > 64) { player->extralight = !player->extralight; } @@ -1756,11 +1756,11 @@ void A_GauntletAttack(player_t *player, pspdef_t *psp) return; } randVal = P_Random(); - if(randVal < 64) + if (randVal < 64) { player->extralight = 0; } - else if(randVal < 160) + else if (randVal < 160) { player->extralight = 1; } @@ -1768,9 +1768,9 @@ void A_GauntletAttack(player_t *player, pspdef_t *psp) { player->extralight = 2; } - if(player->powers[pw_weaponlevel2]) + if (player->powers[pw_weaponlevel2]) { - P_GiveBody(player, damage>>1); + P_GiveBody(player, damage >> 1); S_StartSound(player->mo, sfx_gntpow); } else @@ -1780,19 +1780,19 @@ void A_GauntletAttack(player_t *player, pspdef_t *psp) // turn to face target angle = R_PointToAngle2(player->mo->x, player->mo->y, linetarget->x, linetarget->y); - if(angle-player->mo->angle > ANG180) + if (angle - player->mo->angle > ANG180) { - if(angle-player->mo->angle < -ANG90/20) - player->mo->angle = angle+ANG90/21; + if (angle - player->mo->angle < -ANG90 / 20) + player->mo->angle = angle + ANG90 / 21; else - player->mo->angle -= ANG90/20; + player->mo->angle -= ANG90 / 20; } else { - if(angle-player->mo->angle > ANG90/20) - player->mo->angle = angle-ANG90/21; + if (angle - player->mo->angle > ANG90 / 20) + player->mo->angle = angle - ANG90 / 21; else - player->mo->angle += ANG90/20; + player->mo->angle += ANG90 / 20; } player->mo->flags |= MF_JUSTATTACKED; } @@ -1825,7 +1825,7 @@ void P_SetupPsprites(player_t *player) int i; // Remove all psprites - for(i = 0; i < NUMPSPRITES; i++) + for (i = 0; i < NUMPSPRITES; i++) { player->psprites[i].state = NULL; } @@ -1849,15 +1849,15 @@ void P_MovePsprites(player_t *player) state_t *state; psp = &player->psprites[0]; - for(i = 0; i < NUMPSPRITES; i++, psp++) + for (i = 0; i < NUMPSPRITES; i++, psp++) { - if((state = psp->state) != 0) // a null state means not active + if ((state = psp->state) != 0) // a null state means not active { // drop tic count and possibly change state - if(psp->tics != -1) // a -1 tic count never changes + if (psp->tics != -1) // a -1 tic count never changes { psp->tics--; - if(!psp->tics) + if (!psp->tics) { P_SetPsprite(player, i, psp->state->nextstate); } diff --git a/P_SETUP.C b/P_SETUP.C index 713d8f2..686df2f 100644 --- a/P_SETUP.C +++ b/P_SETUP.C @@ -10,33 +10,33 @@ void P_SpawnMapThing (mapthing_t *mthing); int numvertexes; -vertex_t *vertexes; +vertex_t *vertexes; int numsegs; -seg_t *segs; +seg_t *segs; int numsectors; -sector_t *sectors; +sector_t *sectors; int numsubsectors; -subsector_t *subsectors; +subsector_t *subsectors; int numnodes; -node_t *nodes; +node_t *nodes; int numlines; -line_t *lines; +line_t *lines; int numsides; -side_t *sides; +side_t *sides; -short *blockmaplump; // offsets in blockmap are from here -short *blockmap; +short *blockmaplump; // offsets in blockmap are from here +short *blockmap; int bmapwidth, bmapheight; // in mapblocks fixed_t bmaporgx, bmaporgy; // origin of block map -mobj_t **blocklinks; // for thing chains +mobj_t **blocklinks; // for thing chains -byte *rejectmatrix; // for fast sight rejection +byte *rejectmatrix; // for fast sight rejection mapthing_t deathmatchstarts[10], *deathmatch_p; mapthing_t playerstarts[MAXPLAYERS]; @@ -51,23 +51,23 @@ mapthing_t playerstarts[MAXPLAYERS]; void P_LoadVertexes (int lump) { - byte *data; + byte *data; int i; - mapvertex_t *ml; - vertex_t *li; - + 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); - + 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 ; ix = SHORT(ml->x)<y = SHORT(ml->y)<x = SHORT(ml->x) << FRACBITS; + li->y = SHORT(ml->y) << FRACBITS; } - + Z_Free (data); } @@ -82,39 +82,39 @@ void P_LoadVertexes (int lump) void P_LoadSegs (int lump) { - byte *data; + byte *data; int i; - mapseg_t *ml; - seg_t *li; - line_t *ldef; + mapseg_t *ml; + seg_t *li; + line_t *ldef; int linedef, 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); - + 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 ; iv1 = &vertexes[SHORT(ml->v1)]; li->v2 = &vertexes[SHORT(ml->v2)]; - - li->angle = (SHORT(ml->angle))<<16; - li->offset = (SHORT(ml->offset))<<16; + + li->angle = (SHORT(ml->angle)) << 16; + li->offset = (SHORT(ml->offset)) << 16; linedef = SHORT(ml->linedef); ldef = &lines[linedef]; li->linedef = ldef; side = SHORT(ml->side); li->sidedef = &sides[ldef->sidenum[side]]; li->frontsector = sides[ldef->sidenum[side]].sector; - if (ldef-> flags & ML_TWOSIDED) - li->backsector = sides[ldef->sidenum[side^1]].sector; + if (ldef->flags & ML_TWOSIDED) + li->backsector = sides[ldef->sidenum[side ^ 1]].sector; else li->backsector = 0; } - + Z_Free (data); } @@ -129,24 +129,24 @@ void P_LoadSegs (int lump) void P_LoadSubsectors (int lump) { - byte *data; + byte *data; int i; - mapsubsector_t *ms; - subsector_t *ss; - + 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); - + 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)); + memset (subsectors, 0, numsubsectors * sizeof(subsector_t)); ss = subsectors; - for (i=0 ; inumlines = SHORT(ms->numsegs); ss->firstline = SHORT(ms->firstseg); } - + Z_Free (data); } @@ -161,22 +161,22 @@ void P_LoadSubsectors (int lump) void P_LoadSectors (int lump) { - byte *data; + byte *data; int i; - mapsector_t *ms; - sector_t *ss; - + 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); - + 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 ; ifloorheight = SHORT(ms->floorheight)<ceilingheight = SHORT(ms->ceilingheight)<floorheight = SHORT(ms->floorheight) << FRACBITS; + ss->ceilingheight = SHORT(ms->ceilingheight) << FRACBITS; ss->floorpic = R_FlatNumForName(ms->floorpic); ss->ceilingpic = R_FlatNumForName(ms->ceilingpic); ss->lightlevel = SHORT(ms->lightlevel); @@ -184,7 +184,7 @@ void P_LoadSectors (int lump) ss->tag = SHORT(ms->tag); ss->thinglist = NULL; } - + Z_Free (data); } @@ -199,31 +199,31 @@ void P_LoadSectors (int lump) void P_LoadNodes (int lump) { - byte *data; - int i,j,k; - mapnode_t *mn; - node_t *no; - + byte *data; + int i, j, 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); - + 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 ; ix = SHORT(mn->x)<y = SHORT(mn->y)<dx = SHORT(mn->dx)<dy = SHORT(mn->dy)<x = SHORT(mn->x) << FRACBITS; + no->y = SHORT(mn->y) << FRACBITS; + no->dx = SHORT(mn->dx) << FRACBITS; + no->dy = SHORT(mn->dy) << FRACBITS; + for (j = 0; j < 2; j++) { no->children[j] = SHORT(mn->children[j]); - for (k=0 ; k<4 ; k++) - no->bbox[j][k] = SHORT(mn->bbox[j][k])<bbox[j][k] = SHORT(mn->bbox[j][k]) << FRACBITS; } } - + Z_Free (data); } @@ -239,16 +239,16 @@ void P_LoadNodes (int lump) void P_LoadThings (int lump) { - byte *data; + byte *data; int i; - mapthing_t *mt; + mapthing_t *mt; int numthings; - - data = W_CacheLumpNum (lump,PU_STATIC); + + data = W_CacheLumpNum (lump, PU_STATIC); numthings = W_LumpLength (lump) / sizeof(mapthing_t); - + mt = (mapthing_t *)data; - for (i=0 ; ix = SHORT(mt->x); mt->y = SHORT(mt->y); @@ -257,7 +257,7 @@ void P_LoadThings (int lump) mt->options = SHORT(mt->options); P_SpawnMapThing (mt); } - + Z_Free (data); } @@ -274,20 +274,20 @@ void P_LoadThings (int lump) void P_LoadLineDefs (int lump) { - byte *data; + byte *data; int i; - maplinedef_t *mld; - line_t *ld; - vertex_t *v1, *v2; - + maplinedef_t *mld; + line_t *ld; + vertex_t *v1, *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); - + 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 ; iflags = SHORT(mld->flags); ld->special = SHORT(mld->special); @@ -302,12 +302,12 @@ void P_LoadLineDefs (int lump) ld->slopetype = ST_HORIZONTAL; else { - if (FixedDiv (ld->dy , ld->dx) > 0) + if (FixedDiv (ld->dy, ld->dx) > 0) ld->slopetype = ST_POSITIVE; else ld->slopetype = ST_NEGATIVE; } - + if (v1->x < v2->x) { ld->bbox[BOXLEFT] = v1->x; @@ -339,7 +339,7 @@ void P_LoadLineDefs (int lump) else ld->backsector = 0; } - + Z_Free (data); } @@ -354,28 +354,28 @@ void P_LoadLineDefs (int lump) void P_LoadSideDefs (int lump) { - byte *data; + byte *data; int i; - mapsidedef_t *msd; - side_t *sd; - + 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); - + 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 ; itextureoffset = SHORT(msd->textureoffset)<rowoffset = SHORT(msd->rowoffset)<textureoffset = SHORT(msd->textureoffset) << FRACBITS; + sd->rowoffset = SHORT(msd->rowoffset) << FRACBITS; sd->toptexture = R_TextureNumForName(msd->toptexture); sd->bottomtexture = R_TextureNumForName(msd->bottomtexture); sd->midtexture = R_TextureNumForName(msd->midtexture); sd->sector = §ors[SHORT(msd->sector)]; } - + Z_Free (data); } @@ -392,21 +392,21 @@ void P_LoadSideDefs (int lump) void P_LoadBlockMap (int lump) { int i, count; - - blockmaplump = W_CacheLumpNum (lump,PU_LEVEL); - blockmap = blockmaplump+4; - count = W_LumpLength (lump)/2; - for (i=0 ; ifirstline]; ss->sector = seg->sidedef->sector; } -// count number of lines in each sector + // count number of lines in each sector li = lines; total = 0; - for (i=0 ; ifrontsector->linecount++; @@ -455,16 +455,16 @@ void P_GroupLines (void) total++; } } - -// build line tables for each sector - linebuffer = Z_Malloc (total*4, PU_LEVEL, 0); + + // build line tables for each sector + linebuffer = Z_Malloc (total * 4, PU_LEVEL, 0); sector = sectors; - for (i=0 ; ilines = linebuffer; li = lines; - for (j=0 ; jfrontsector == sector || li->backsector == sector) { @@ -475,29 +475,29 @@ void P_GroupLines (void) } if (linebuffer - sector->lines != sector->linecount) I_Error ("P_GroupLines: miscounted"); - + // set the degenmobj_t to the middle of the bounding box - sector->soundorg.x = (bbox[BOXRIGHT]+bbox[BOXLEFT])/2; - sector->soundorg.y = (bbox[BOXTOP]+bbox[BOXBOTTOM])/2; - + sector->soundorg.x = (bbox[BOXRIGHT] + bbox[BOXLEFT]) / 2; + sector->soundorg.y = (bbox[BOXTOP] + bbox[BOXBOTTOM]) / 2; + // adjust bounding box to map blocks - block = (bbox[BOXTOP]-bmaporgy+MAXRADIUS)>>MAPBLOCKSHIFT; - block = block >= bmapheight ? bmapheight-1 : block; - sector->blockbox[BOXTOP]=block; + block = (bbox[BOXTOP] - bmaporgy + MAXRADIUS) >> MAPBLOCKSHIFT; + block = block >= bmapheight ? bmapheight - 1 : block; + sector->blockbox[BOXTOP] = block; - block = (bbox[BOXBOTTOM]-bmaporgy-MAXRADIUS)>>MAPBLOCKSHIFT; + block = (bbox[BOXBOTTOM] - bmaporgy - MAXRADIUS) >> MAPBLOCKSHIFT; block = block < 0 ? 0 : block; - sector->blockbox[BOXBOTTOM]=block; + sector->blockbox[BOXBOTTOM] = block; - block = (bbox[BOXRIGHT]-bmaporgx+MAXRADIUS)>>MAPBLOCKSHIFT; - block = block >= bmapwidth ? bmapwidth-1 : block; - sector->blockbox[BOXRIGHT]=block; + block = (bbox[BOXRIGHT] - bmaporgx + MAXRADIUS) >> MAPBLOCKSHIFT; + block = block >= bmapwidth ? bmapwidth - 1 : block; + sector->blockbox[BOXRIGHT] = block; - block = (bbox[BOXLEFT]-bmaporgx-MAXRADIUS)>>MAPBLOCKSHIFT; + block = (bbox[BOXLEFT] - bmaporgx - MAXRADIUS) >> MAPBLOCKSHIFT; block = block < 0 ? 0 : block; - sector->blockbox[BOXLEFT]=block; + sector->blockbox[BOXLEFT] = block; } - + } //============================================================================= @@ -517,47 +517,47 @@ void P_SetupLevel (int episode, int map, int playermask, skill_t skill) int parm; char lumpname[9]; int lumpnum; - mobj_t *mobj; + mobj_t *mobj; extern int noprecache; // FS: No graphics precaching totalkills = totalitems = totalsecret = 0; - for (i=0 ; id.line; -// -// crosses a two sided line -// + // + // crosses a two sided line + // P_LineOpening (li); if (openbottom >= opentop) // quick test for totally closed doors @@ -45,21 +45,21 @@ boolean PTR_SightTraverse (intercept_t *in) if (li->frontsector->floorheight != li->backsector->floorheight) { - slope = FixedDiv (openbottom - sightzstart , in->frac); + slope = FixedDiv (openbottom - sightzstart, in->frac); if (slope > bottomslope) bottomslope = slope; } - + if (li->frontsector->ceilingheight != li->backsector->ceilingheight) { - slope = FixedDiv (opentop - sightzstart , in->frac); + slope = FixedDiv (opentop - sightzstart, in->frac); if (slope < topslope) topslope = slope; } - + if (topslope <= bottomslope) return false; // stop - + return true; // keep going } @@ -73,35 +73,35 @@ boolean PTR_SightTraverse (intercept_t *in) =================== */ -boolean P_SightBlockLinesIterator (int x, int y ) +boolean P_SightBlockLinesIterator (int x, int y) { int offset; - short *list; - line_t *ld; + short *list; + line_t *ld; int s1, s2; divline_t dl; - - offset = y*bmapwidth+x; - - offset = *(blockmap+offset); - for ( list = blockmaplump+offset ; *list != -1 ; list++) + offset = y * bmapwidth + x; + + offset = *(blockmap + offset); + + for (list = blockmaplump + offset; *list != -1; list++) { ld = &lines[*list]; if (ld->validcount == validcount) continue; // line has already been checked ld->validcount = validcount; - + s1 = P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &trace); s2 = P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &trace); if (s1 == s2) continue; // line isn't crossed P_MakeDivline (ld, &dl); s1 = P_PointOnDivlineSide (trace.x, trace.y, &dl); - s2 = P_PointOnDivlineSide (trace.x+trace.dx, trace.y+trace.dy, &dl); + s2 = P_PointOnDivlineSide (trace.x + trace.dx, trace.y + trace.dy, &dl); if (s1 == s2) continue; // line isn't crossed - + // try to early out the check if (!ld->backsector) return false; // stop checking @@ -109,9 +109,9 @@ boolean P_SightBlockLinesIterator (int x, int y ) // store the line for later intersection testing intercept_p->d.line = ld; intercept_p++; - + } - + return true; // everything was checked } @@ -124,43 +124,43 @@ boolean P_SightBlockLinesIterator (int x, int y ) ==================== */ -boolean P_SightTraverseIntercepts ( void ) +boolean P_SightTraverseIntercepts (void) { int count; fixed_t dist; - intercept_t *scan, *in; + intercept_t *scan, *in; divline_t dl; - + count = intercept_p - intercepts; -// -// calculate intercept distance -// - for (scan = intercepts ; scand.line, &dl); - scan->frac = P_InterceptVector (&trace, &dl); + scan->frac = P_InterceptVector (&trace, &dl); } - -// -// go through in order -// + + // + // go through in order + // in = 0; // shut up compiler warning - + while (count--) { dist = MAXINT; - for (scan = intercepts ; scanfrac < dist) { dist = scan->frac; in = scan; } - - if ( !PTR_SightTraverse (in) ) + + if (!PTR_SightTraverse (in)) return false; // don't bother going farther in->frac = MAXINT; } - + return true; // everything was traversed } @@ -178,19 +178,19 @@ boolean P_SightTraverseIntercepts ( void ) boolean P_SightPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) { - fixed_t xt1,yt1,xt2,yt2; - fixed_t xstep,ystep; + fixed_t xt1, yt1, xt2, yt2; + fixed_t xstep, ystep; fixed_t partial; fixed_t xintercept, yintercept; int mapx, mapy, mapxstep, mapystep; int count; - + validcount++; intercept_p = intercepts; - - if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0) + + if (((x1 - bmaporgx) & (MAPBLOCKSIZE - 1)) == 0) x1 += FRACUNIT; // don't side exactly on a line - if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0) + if (((y1 - bmaporgy) & (MAPBLOCKSIZE - 1)) == 0) y1 += FRACUNIT; // don't side exactly on a line trace.x = x1; trace.y = y1; @@ -199,100 +199,100 @@ boolean P_SightPathTraverse (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) x1 -= bmaporgx; y1 -= bmaporgy; - xt1 = x1>>MAPBLOCKSHIFT; - yt1 = y1>>MAPBLOCKSHIFT; + xt1 = x1 >> MAPBLOCKSHIFT; + yt1 = y1 >> MAPBLOCKSHIFT; x2 -= bmaporgx; y2 -= bmaporgy; - xt2 = x2>>MAPBLOCKSHIFT; - yt2 = y2>>MAPBLOCKSHIFT; + xt2 = x2 >> MAPBLOCKSHIFT; + yt2 = y2 >> MAPBLOCKSHIFT; -// points should never be out of bounds, but check once instead of -// each block - if (xt1<0 || yt1<0 || xt1>=bmapwidth || yt1>=bmapheight - || xt2<0 || yt2<0 || xt2>=bmapwidth || yt2>=bmapheight) + // points should never be out of bounds, but check once instead of + // each block + if (xt1 < 0 || yt1 < 0 || xt1 >= bmapwidth || yt1 >= bmapheight + || xt2 < 0 || yt2 < 0 || xt2 >= bmapwidth || yt2 >= bmapheight) return false; if (xt2 > xt1) { mapxstep = 1; - partial = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1)); - ystep = FixedDiv (y2-y1,abs(x2-x1)); + partial = FRACUNIT - ((x1 >> MAPBTOFRAC) & (FRACUNIT - 1)); + ystep = FixedDiv (y2 - y1, abs(x2 - x1)); } else if (xt2 < xt1) { mapxstep = -1; - partial = (x1>>MAPBTOFRAC)&(FRACUNIT-1); - ystep = FixedDiv (y2-y1,abs(x2-x1)); + partial = (x1 >> MAPBTOFRAC) & (FRACUNIT - 1); + ystep = FixedDiv (y2 - y1, abs(x2 - x1)); } else { mapxstep = 0; partial = FRACUNIT; - ystep = 256*FRACUNIT; - } - yintercept = (y1>>MAPBTOFRAC) + FixedMul (partial, ystep); + ystep = 256 * FRACUNIT; + } + yintercept = (y1 >> MAPBTOFRAC) + FixedMul (partial, ystep); + - if (yt2 > yt1) { mapystep = 1; - partial = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1)); - xstep = FixedDiv (x2-x1,abs(y2-y1)); + partial = FRACUNIT - ((y1 >> MAPBTOFRAC) & (FRACUNIT - 1)); + xstep = FixedDiv (x2 - x1, abs(y2 - y1)); } else if (yt2 < yt1) { mapystep = -1; - partial = (y1>>MAPBTOFRAC)&(FRACUNIT-1); - xstep = FixedDiv (x2-x1,abs(y2-y1)); + partial = (y1 >> MAPBTOFRAC) & (FRACUNIT - 1); + xstep = FixedDiv (x2 - x1, abs(y2 - y1)); } else { mapystep = 0; partial = FRACUNIT; - xstep = 256*FRACUNIT; - } - xintercept = (x1>>MAPBTOFRAC) + FixedMul (partial, xstep); - - -// -// step through map blocks -// Count is present to prevent a round off error from skipping the break + xstep = 256 * FRACUNIT; + } + xintercept = (x1 >> MAPBTOFRAC) + FixedMul (partial, xstep); + + + // + // step through map blocks + // Count is present to prevent a round off error from skipping the break mapx = xt1; mapy = yt1; - - for (count = 0 ; count < 64 ; count++) + + for (count = 0; count < 64; count++) { if (!P_SightBlockLinesIterator (mapx, mapy)) { -sightcounts[1]++; + sightcounts[1]++; return false; // early out } - + if (mapx == xt2 && mapy == yt2) break; - - if ( (yintercept >> FRACBITS) == mapy) + + if ((yintercept >> FRACBITS) == mapy) { yintercept += ystep; mapx += mapxstep; } - else if ( (xintercept >> FRACBITS) == mapx) + else if ((xintercept >> FRACBITS) == mapx) { xintercept += xstep; mapy += mapystep; } - + } -// -// couldn't early out, so go through the sorted list -// -sightcounts[2]++; + // + // couldn't early out, so go through the sorted list + // + sightcounts[2]++; - return P_SightTraverseIntercepts ( ); + return P_SightTraverseIntercepts (); } @@ -313,29 +313,29 @@ boolean P_CheckSight (mobj_t *t1, mobj_t *t2) int s1, s2; int pnum, bytenum, bitnum; -// -// check for trivial rejection -// + // + // check for trivial rejection + // 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) + pnum = s1 * numsectors + s2; + bytenum = pnum >> 3; + bitnum = 1 << (pnum & 7); + + if (rejectmatrix[bytenum] & bitnum) { -sightcounts[0]++; + sightcounts[0]++; return false; // can't possibly be connected } -// -// check precisely -// - sightzstart = t1->z + t1->height - (t1->height>>2); - topslope = (t2->z+t2->height) - sightzstart; + // + // check precisely + // + sightzstart = t1->z + t1->height - (t1->height >> 2); + topslope = (t2->z + t2->height) - sightzstart; bottomslope = (t2->z) - sightzstart; - return P_SightPathTraverse ( t1->x, t1->y, t2->x, t2->y ); + return P_SightPathTraverse (t1->x, t1->y, t2->x, t2->y); } diff --git a/P_SPEC.C b/P_SPEC.C index dd3efe6..5a96627 100644 --- a/P_SPEC.C +++ b/P_SPEC.C @@ -210,7 +210,7 @@ void P_InitLava(void) { memset(&LavaInflictor, 0, sizeof(mobj_t)); LavaInflictor.type = MT_PHOENIXFX2; - LavaInflictor.flags2 = MF2_FIREDAMAGE|MF2_NODMGTHRUST; + LavaInflictor.flags2 = MF2_FIREDAMAGE | MF2_NODMGTHRUST; } //---------------------------------------------------------------------------- @@ -225,15 +225,15 @@ void P_InitTerrainTypes(void) int lump; int size; - size = (numflats+1)*sizeof(int); + size = (numflats + 1) * sizeof(int); TerrainTypes = Z_Malloc(size, PU_STATIC, 0); memset(TerrainTypes, 0, size); - for(i = 0; TerrainTypeDefs[i].type != -1; i++) + for (i = 0; TerrainTypeDefs[i].type != -1; i++) { lump = W_CheckNumForName(TerrainTypeDefs[i].name); - if(lump != -1) + if (lump != -1) { - TerrainTypes[lump-firstflat] = TerrainTypeDefs[i].type; + TerrainTypes[lump - firstflat] = TerrainTypeDefs[i].type; } } } @@ -249,11 +249,11 @@ void P_InitPicAnims(void) int i; lastanim = anims; - for(i = 0; animdefs[i].istexture != -1; i++) + for (i = 0; animdefs[i].istexture != -1; i++) { - if(animdefs[i].istexture) + if (animdefs[i].istexture) { // Texture animation - if(R_CheckTextureNumForName(animdefs[i].startname) == -1) + if (R_CheckTextureNumForName(animdefs[i].startname) == -1) { // Texture doesn't exist continue; } @@ -262,7 +262,7 @@ void P_InitPicAnims(void) } else { // Flat animation - if(W_CheckNumForName(animdefs[i].startname) == -1) + if (W_CheckNumForName(animdefs[i].startname) == -1) { // Flat doesn't exist continue; } @@ -270,8 +270,8 @@ void P_InitPicAnims(void) lastanim->basepic = R_FlatNumForName(animdefs[i].startname); } lastanim->istexture = animdefs[i].istexture; - lastanim->numpics = lastanim->picnum-lastanim->basepic+1; - if(lastanim->numpics < 2) + 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); @@ -293,25 +293,25 @@ void P_InitPicAnims(void) // Will return a side_t* given the number of the current sector, // the line number, and the side (0/1) that you want. // -side_t *getSide(int currentSector,int line, int side) +side_t *getSide(int currentSector, int line, int side) { - return &sides[ (sectors[currentSector].lines[line])->sidenum[side] ]; + return &sides[(sectors[currentSector].lines[line])->sidenum[side]]; } // // Will return a sector_t* given the number of the current sector, // the line number and the side (0/1) that you want. // -sector_t *getSector(int currentSector,int line,int side) +sector_t *getSector(int currentSector, int line, int side) { - return sides[ (sectors[currentSector].lines[line])->sidenum[side] ].sector; + return sides[(sectors[currentSector].lines[line])->sidenum[side]].sector; } // // Given the sector number and the line number, will tell you whether // the line is two-sided or not. // -int twoSided(int sector,int line) +int twoSided(int sector, int line) { return (sectors[sector].lines[line])->flags & ML_TWOSIDED; } @@ -321,14 +321,14 @@ int twoSided(int sector,int line) // Return sector_t * of sector next to current. NULL if not two-sided line // //================================================================== -sector_t *getNextSector(line_t *line,sector_t *sec) +sector_t *getNextSector(line_t *line, sector_t *sec) { if (!(line->flags & ML_TWOSIDED)) return NULL; - + if (line->frontsector == sec) return line->backsector; - + return line->frontsector; } @@ -340,14 +340,14 @@ sector_t *getNextSector(line_t *line,sector_t *sec) fixed_t P_FindLowestFloorSurrounding(sector_t *sec) { int i; - line_t *check; - sector_t *other; + line_t *check; + sector_t *other; fixed_t floor = sec->floorheight; - - for (i=0 ;i < sec->linecount ; i++) + + for (i = 0; i < sec->linecount; i++) { check = sec->lines[i]; - other = getNextSector(check,sec); + other = getNextSector(check, sec); if (!other) continue; if (other->floorheight < floor) @@ -364,16 +364,16 @@ fixed_t P_FindLowestFloorSurrounding(sector_t *sec) 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++) + 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); + other = getNextSector(check, sec); if (!other) - continue; + continue; if (other->floorheight > floor) floor = other->floorheight; } @@ -385,34 +385,34 @@ fixed_t P_FindHighestFloorSurrounding(sector_t *sec) // FIND NEXT HIGHEST FLOOR IN SURROUNDING SECTORS // //================================================================== -fixed_t P_FindNextHighestFloor(sector_t *sec,int currentheight) +fixed_t P_FindNextHighestFloor(sector_t *sec, int currentheight) { int i; int h; int min; - line_t *check; - sector_t *other; + line_t *check; + sector_t *other; fixed_t height = currentheight; fixed_t heightlist[20]; // 20 adjoining sectors max! - - for (i =0,h = 0 ;i < sec->linecount ; i++) + + for (i = 0, h = 0; i < sec->linecount; i++) { check = sec->lines[i]; - other = getNextSector(check,sec); + other = getNextSector(check, sec); if (!other) continue; if (other->floorheight > height) heightlist[h++] = other->floorheight; } - + // // Find lowest height in list // min = heightlist[0]; - for (i = 1;i < h;i++) + for (i = 1; i < h; i++) if (heightlist[i] < min) min = heightlist[i]; - + return min; } @@ -424,14 +424,14 @@ fixed_t P_FindNextHighestFloor(sector_t *sec,int currentheight) fixed_t P_FindLowestCeilingSurrounding(sector_t *sec) { int i; - line_t *check; - sector_t *other; + line_t *check; + sector_t *other; fixed_t height = MAXINT; - - for (i=0 ;i < sec->linecount ; i++) + + for (i = 0; i < sec->linecount; i++) { check = sec->lines[i]; - other = getNextSector(check,sec); + other = getNextSector(check, sec); if (!other) continue; if (other->ceilingheight < height) @@ -448,14 +448,14 @@ fixed_t P_FindLowestCeilingSurrounding(sector_t *sec) fixed_t P_FindHighestCeilingSurrounding(sector_t *sec) { int i; - line_t *check; - sector_t *other; + line_t *check; + sector_t *other; fixed_t height = 0; - - for (i=0 ;i < sec->linecount ; i++) + + for (i = 0; i < sec->linecount; i++) { check = sec->lines[i]; - other = getNextSector(check,sec); + other = getNextSector(check, sec); if (!other) continue; if (other->ceilingheight > height) @@ -469,11 +469,11 @@ fixed_t P_FindHighestCeilingSurrounding(sector_t *sec) // RETURN NEXT SECTOR # THAT LINE TAG REFERS TO // //================================================================== -int P_FindSectorFromLineTag(line_t *line,int start) +int P_FindSectorFromLineTag(line_t *line, int start) { int i; - - for (i=start+1;itag) return i; return -1; @@ -484,18 +484,18 @@ int P_FindSectorFromLineTag(line_t *line,int start) // Find minimum light from an adjacent sector // //================================================================== -int P_FindMinSurroundingLight(sector_t *sector,int max) +int P_FindMinSurroundingLight(sector_t *sector, int max) { int i; int min; - line_t *line; - sector_t *check; - + line_t *line; + sector_t *check; + min = max; - for (i=0 ; i < sector->linecount ; i++) + for (i = 0; i < sector->linecount; i++) { line = sector->lines[i]; - check = getNextSector(line,sector); + check = getNextSector(line, sector); if (!check) continue; if (check->lightlevel < min) @@ -532,9 +532,9 @@ void P_CrossSpecialLine(int linenum, int side, mobj_t *thing) line_t *line; line = &lines[linenum]; - if(!thing->player) + if (!thing->player) { // Check if trigger allowed by non-player mobj - switch(line->special) + switch (line->special) { case 39: // Trigger_TELEPORT case 97: // Retrigger_TELEPORT @@ -547,53 +547,53 @@ void P_CrossSpecialLine(int linenum, int side, mobj_t *thing) break; } } - switch(line->special) + switch (line->special) { //==================================================== // TRIGGERS //==================================================== case 2: // Open Door - EV_DoDoor(line,dooropen,VDOORSPEED); + EV_DoDoor(line, dooropen, VDOORSPEED); line->special = 0; break; case 3: // Close Door - EV_DoDoor(line,doorclose,VDOORSPEED); + EV_DoDoor(line, doorclose, VDOORSPEED); line->special = 0; break; case 4: // Raise Door - EV_DoDoor(line,doornormal,VDOORSPEED); + EV_DoDoor(line, doornormal, VDOORSPEED); line->special = 0; break; case 5: // Raise Floor - EV_DoFloor(line,raiseFloor); + EV_DoFloor(line, raiseFloor); line->special = 0; break; case 6: // Fast Ceiling Crush & Raise - EV_DoCeiling(line,fastCrushAndRaise); + EV_DoCeiling(line, fastCrushAndRaise); line->special = 0; break; case 8: // Trigger_Build_Stairs (8 pixel steps) - EV_BuildStairs(line, 8*FRACUNIT); + EV_BuildStairs(line, 8 * FRACUNIT); line->special = 0; break; case 106: // Trigger_Build_Stairs_16 (16 pixel steps) - EV_BuildStairs(line, 16*FRACUNIT); + EV_BuildStairs(line, 16 * FRACUNIT); line->special = 0; break; case 10: // PlatDownWaitUp - EV_DoPlat(line,downWaitUpStay,0); + EV_DoPlat(line, downWaitUpStay, 0); line->special = 0; break; case 12: // Light Turn On - brightest near - EV_LightTurnOn(line,0); + EV_LightTurnOn(line, 0); line->special = 0; break; case 13: // Light Turn On 255 - EV_LightTurnOn(line,255); + EV_LightTurnOn(line, 255); line->special = 0; break; case 16: // Close Door 30 - EV_DoDoor(line,close30ThenOpen,VDOORSPEED); + EV_DoDoor(line, close30ThenOpen, VDOORSPEED); line->special = 0; break; case 17: // Start Light Strobing @@ -601,49 +601,49 @@ void P_CrossSpecialLine(int linenum, int side, mobj_t *thing) line->special = 0; break; case 19: // Lower Floor - EV_DoFloor(line,lowerFloor); + EV_DoFloor(line, lowerFloor); line->special = 0; break; case 22: // Raise floor to nearest height and change texture - EV_DoPlat(line,raiseToNearestAndChange,0); + EV_DoPlat(line, raiseToNearestAndChange, 0); line->special = 0; break; case 25: // Ceiling Crush and Raise - EV_DoCeiling(line,crushAndRaise); + EV_DoCeiling(line, crushAndRaise); line->special = 0; break; case 30: // Raise floor to shortest texture height // on either side of lines - EV_DoFloor(line,raiseToTexture); + EV_DoFloor(line, raiseToTexture); line->special = 0; break; case 35: // Lights Very Dark - EV_LightTurnOn(line,35); + EV_LightTurnOn(line, 35); line->special = 0; break; case 36: // Lower Floor (TURBO) - EV_DoFloor(line,turboLower); + EV_DoFloor(line, turboLower); line->special = 0; break; case 37: // LowerAndChange - EV_DoFloor(line,lowerAndChange); + EV_DoFloor(line, lowerAndChange); line->special = 0; break; case 38: // Lower Floor To Lowest - EV_DoFloor( line, lowerFloorToLowest ); + EV_DoFloor(line, lowerFloorToLowest); line->special = 0; break; case 39: // TELEPORT! - EV_Teleport( line, side, thing ); + EV_Teleport(line, side, thing); line->special = 0; break; case 40: // RaiseCeilingLowerFloor - EV_DoCeiling( line, raiseToHighest ); - EV_DoFloor( line, lowerFloorToLowest ); + EV_DoCeiling(line, raiseToHighest); + EV_DoFloor(line, lowerFloorToLowest); line->special = 0; break; case 44: // Ceiling Crush - EV_DoCeiling( line, lowerAndCrush ); + EV_DoCeiling(line, lowerAndCrush); line->special = 0; break; case 52: // EXIT! @@ -651,7 +651,7 @@ void P_CrossSpecialLine(int linenum, int side, mobj_t *thing) line->special = 0; break; case 53: // Perpetual Platform Raise - EV_DoPlat(line,perpetualRaise,0); + EV_DoPlat(line, perpetualRaise, 0); line->special = 0; break; case 54: // Platform Stop @@ -659,7 +659,7 @@ void P_CrossSpecialLine(int linenum, int side, mobj_t *thing) line->special = 0; break; case 56: // Raise Floor Crush - EV_DoFloor(line,raiseFloorCrush); + EV_DoFloor(line, raiseFloorCrush); line->special = 0; break; case 57: // Ceiling Crush Stop @@ -667,11 +667,11 @@ void P_CrossSpecialLine(int linenum, int side, mobj_t *thing) line->special = 0; break; case 58: // Raise Floor 24 - EV_DoFloor(line,raiseFloor24); + EV_DoFloor(line, raiseFloor24); line->special = 0; break; case 59: // Raise Floor 24 And Change - EV_DoFloor(line,raiseFloor24AndChange); + EV_DoFloor(line, raiseFloor24AndChange); line->special = 0; break; case 104: // Turn lights off in sector(tag) @@ -683,88 +683,88 @@ void P_CrossSpecialLine(int linenum, int side, mobj_t *thing) line->special = 0; break; - //==================================================== - // RE-DOABLE TRIGGERS - //==================================================== + //==================================================== + // RE-DOABLE TRIGGERS + //==================================================== case 72: // Ceiling Crush - EV_DoCeiling( line, lowerAndCrush ); + EV_DoCeiling(line, lowerAndCrush); break; case 73: // Ceiling Crush and Raise - EV_DoCeiling(line,crushAndRaise); + EV_DoCeiling(line, crushAndRaise); break; case 74: // Ceiling Crush Stop EV_CeilingCrushStop(line); break; case 75: // Close Door - EV_DoDoor(line,doorclose,VDOORSPEED); + EV_DoDoor(line, doorclose, VDOORSPEED); break; case 76: // Close Door 30 - EV_DoDoor(line,close30ThenOpen,VDOORSPEED); + EV_DoDoor(line, close30ThenOpen, VDOORSPEED); break; case 77: // Fast Ceiling Crush & Raise - EV_DoCeiling(line,fastCrushAndRaise); + EV_DoCeiling(line, fastCrushAndRaise); break; case 79: // Lights Very Dark - EV_LightTurnOn(line,35); + EV_LightTurnOn(line, 35); break; case 80: // Light Turn On - brightest near - EV_LightTurnOn(line,0); + EV_LightTurnOn(line, 0); break; case 81: // Light Turn On 255 - EV_LightTurnOn(line,255); + EV_LightTurnOn(line, 255); break; case 82: // Lower Floor To Lowest - EV_DoFloor( line, lowerFloorToLowest ); + EV_DoFloor(line, lowerFloorToLowest); break; case 83: // Lower Floor - EV_DoFloor(line,lowerFloor); + EV_DoFloor(line, lowerFloor); break; case 84: // LowerAndChange - EV_DoFloor(line,lowerAndChange); + EV_DoFloor(line, lowerAndChange); break; case 86: // Open Door - EV_DoDoor(line,dooropen,VDOORSPEED); + EV_DoDoor(line, dooropen, VDOORSPEED); break; case 87: // Perpetual Platform Raise - EV_DoPlat(line,perpetualRaise,0); + EV_DoPlat(line, perpetualRaise, 0); break; case 88: // PlatDownWaitUp - EV_DoPlat(line,downWaitUpStay,0); + EV_DoPlat(line, downWaitUpStay, 0); break; case 89: // Platform Stop EV_StopPlat(line); break; case 90: // Raise Door - EV_DoDoor(line,doornormal,VDOORSPEED); + EV_DoDoor(line, doornormal, VDOORSPEED); break; case 100: // Retrigger_Raise_Door_Turbo - EV_DoDoor(line, doornormal, VDOORSPEED*3); + EV_DoDoor(line, doornormal, VDOORSPEED * 3); break; case 91: // Raise Floor - EV_DoFloor(line,raiseFloor); + EV_DoFloor(line, raiseFloor); break; case 92: // Raise Floor 24 - EV_DoFloor(line,raiseFloor24); + EV_DoFloor(line, raiseFloor24); break; case 93: // Raise Floor 24 And Change - EV_DoFloor(line,raiseFloor24AndChange); + EV_DoFloor(line, raiseFloor24AndChange); break; case 94: // Raise Floor Crush - EV_DoFloor(line,raiseFloorCrush); + EV_DoFloor(line, raiseFloorCrush); break; case 95: // Raise floor to nearest height and change texture - EV_DoPlat(line,raiseToNearestAndChange,0); + EV_DoPlat(line, raiseToNearestAndChange, 0); break; case 96: // Raise floor to shortest texture height // on either side of lines - EV_DoFloor(line,raiseToTexture); + EV_DoFloor(line, raiseToTexture); break; case 97: // TELEPORT! - EV_Teleport( line, side, thing ); + EV_Teleport(line, side, thing); break; case 98: // Lower Floor (TURBO) - EV_DoFloor(line,turboLower); + EV_DoFloor(line, turboLower); break; } } @@ -779,9 +779,9 @@ void P_CrossSpecialLine(int linenum, int side, mobj_t *thing) void P_ShootSpecialLine(mobj_t *thing, line_t *line) { - if(!thing->player) + if (!thing->player) { // Check if trigger allowed by non-player mobj - switch(line->special) + switch (line->special) { case 46: // Impact_OpenDoor break; @@ -790,7 +790,7 @@ void P_ShootSpecialLine(mobj_t *thing, line_t *line) break; } } - switch(line->special) + switch (line->special) { case 24: // Impact_RaiseFloor EV_DoFloor(line, raiseFloor); @@ -819,43 +819,43 @@ void P_PlayerInSpecialSector(player_t *player) { sector_t *sector; static int pushTab[5] = { - 2048*5, - 2048*10, - 2048*25, - 2048*30, - 2048*35 + 2048 * 5, + 2048 * 10, + 2048 * 25, + 2048 * 30, + 2048 * 35 }; sector = player->mo->subsector->sector; - if(player->mo->z != sector->floorheight) + if (player->mo->z != sector->floorheight) { // Player is not touching the floor return; } - switch(sector->special) + switch (sector->special) { case 7: // Damage_Sludge - if(!(leveltime&31)) + if (!(leveltime & 31)) { P_DamageMobj(player->mo, NULL, NULL, 4); } break; case 5: // Damage_LavaWimpy - if(!(leveltime&15)) + if (!(leveltime & 15)) { P_DamageMobj(player->mo, &LavaInflictor, NULL, 5); P_HitFloor(player->mo); } break; case 16: // Damage_LavaHefty - if(!(leveltime&15)) + if (!(leveltime & 15)) { P_DamageMobj(player->mo, &LavaInflictor, NULL, 8); P_HitFloor(player->mo); } break; case 4: // Scroll_EastLavaDamage - P_Thrust(player, 0, 2048*28); - if(!(leveltime&15)) + P_Thrust(player, 0, 2048 * 28); + if (!(leveltime & 15)) { P_DamageMobj(player->mo, &LavaInflictor, NULL, 5); P_HitFloor(player->mo); @@ -882,16 +882,16 @@ void P_PlayerInSpecialSector(player_t *player) break; case 25: case 26: case 27: case 28: case 29: // Scroll_North - P_Thrust(player, ANG90, pushTab[sector->special-25]); + P_Thrust(player, ANG90, pushTab[sector->special - 25]); break; case 20: case 21: case 22: case 23: case 24: // Scroll_East - P_Thrust(player, 0, pushTab[sector->special-20]); + P_Thrust(player, 0, pushTab[sector->special - 20]); break; case 30: case 31: case 32: case 33: case 34: // Scroll_South - P_Thrust(player, ANG270, pushTab[sector->special-30]); + P_Thrust(player, ANG270, pushTab[sector->special - 30]); break; case 35: case 36: case 37: case 38: case 39: // Scroll_West - P_Thrust(player, ANG180, pushTab[sector->special-35]); + P_Thrust(player, ANG180, pushTab[sector->special - 35]); break; case 40: case 41: case 42: case 43: case 44: case 45: @@ -925,12 +925,12 @@ void P_UpdateSpecials(void) line_t *line; // Animate flats and textures - for(anim = anims; anim < lastanim; anim++) + for (anim = anims; anim < lastanim; anim++) { - for(i = anim->basepic; i < anim->basepic+anim->numpics; i++) + for (i = anim->basepic; i < anim->basepic + anim->numpics; i++) { - pic = anim->basepic+((leveltime/anim->speed+i)%anim->numpics); - if(anim->istexture) + pic = anim->basepic + ((leveltime / anim->speed + i) % anim->numpics); + if (anim->istexture) { texturetranslation[i] = pic; } @@ -941,10 +941,10 @@ void P_UpdateSpecials(void) } } // Update scrolling texture offsets - for(i = 0; i < numlinespecials; i++) + for (i = 0; i < numlinespecials; i++) { line = linespeciallist[i]; - switch(line->special) + switch (line->special) { case 48: // Effect_Scroll_Left sides[line->sidenum[0]].textureoffset += FRACUNIT; @@ -955,14 +955,14 @@ void P_UpdateSpecials(void) } } // Handle buttons - for(i = 0; i < MAXBUTTONS; i++) + for (i = 0; i < MAXBUTTONS; i++) { - if(buttonlist[i].btimer) + if (buttonlist[i].btimer) { buttonlist[i].btimer--; - if(!buttonlist[i].btimer) + if (!buttonlist[i].btimer) { - switch(buttonlist[i].where) + switch (buttonlist[i].where) { case top: sides[buttonlist[i].line->sidenum[0]].toptexture = @@ -981,7 +981,7 @@ void P_UpdateSpecials(void) memset(&buttonlist[i], 0, sizeof(button_t)); } } - } + } } //============================================================ @@ -991,27 +991,27 @@ void P_UpdateSpecials(void) //============================================================ int EV_DoDonut(line_t *line) { - sector_t *s1; - sector_t *s2; - sector_t *s3; + sector_t *s1; + sector_t *s2; + sector_t *s3; int secnum; int rtn; int i; - floormove_t *floor; - + floormove_t *floor; + secnum = -1; rtn = 0; - while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) + while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) { s1 = §ors[secnum]; - + // ALREADY MOVING? IF SO, KEEP GOING... if (s1->specialdata) continue; - + rtn = 1; - s2 = getNextSector(s1->lines[0],s1); - for (i = 0;i < s2->linecount;i++) + s2 = getNextSector(s1->lines[0], s1); + for (i = 0; i < s2->linecount; i++) { if ((!s2->lines[i]->flags & ML_TWOSIDED) || (s2->lines[i]->backsector == s1)) @@ -1033,7 +1033,7 @@ int EV_DoDonut(line_t *line) floor->texture = s3->floorpic; floor->newspecial = 0; floor->floordestheight = s3->floorheight; - + // // Spawn lowering donut-hole // @@ -1071,23 +1071,23 @@ int EV_DoDonut(line_t *line) */ short numlinespecials; -line_t *linespeciallist[MAXLINEANIMS]; +line_t *linespeciallist[MAXLINEANIMS]; void P_SpawnSpecials (void) { - sector_t *sector; + sector_t *sector; int i; int episode; episode = 1; if (W_CheckNumForName("texture2") >= 0) episode = 2; - + // // Init special SECTORs // sector = sectors; - for (i=0 ; ispecial) continue; @@ -1097,13 +1097,13 @@ void P_SpawnSpecials (void) P_SpawnLightFlash (sector); break; case 2: // STROBE FAST - P_SpawnStrobeFlash(sector,FASTDARK,0); + P_SpawnStrobeFlash(sector, FASTDARK, 0); break; case 3: // STROBE SLOW - P_SpawnStrobeFlash(sector,SLOWDARK,0); + P_SpawnStrobeFlash(sector, SLOWDARK, 0); break; case 4: // STROBE FAST/DEATH SLIME - P_SpawnStrobeFlash(sector,FASTDARK,0); + P_SpawnStrobeFlash(sector, FASTDARK, 0); sector->special = 4; break; case 8: // GLOWING LIGHT @@ -1126,14 +1126,14 @@ void P_SpawnSpecials (void) break; } } - - + + // // Init line EFFECTs // numlinespecials = 0; - for (i = 0;i < numlines; i++) - switch(lines[i].special) + for (i = 0; i < numlines; i++) + switch (lines[i].special) { case 48: // Effect_Scroll_Left case 99: // Effect_Scroll_Right @@ -1141,16 +1141,16 @@ void P_SpawnSpecials (void) numlinespecials++; break; } - + // // Init other misc stuff // - for (i = 0;i < MAXCEILINGS;i++) + for (i = 0; i < MAXCEILINGS; i++) activeceilings[i] = NULL; - for (i = 0;i < MAXPLATS;i++) + for (i = 0; i < MAXPLATS; i++) activeplats[i] = NULL; - for (i = 0;i < MAXBUTTONS;i++) - memset(&buttonlist[i],0,sizeof(button_t)); + for (i = 0; i < MAXBUTTONS; i++) + memset(&buttonlist[i], 0, sizeof(button_t)); } //---------------------------------------------------------------------------- @@ -1163,7 +1163,7 @@ void P_InitAmbientSound(void) { AmbSfxCount = 0; AmbSfxVolume = 0; - AmbSfxTics = 10*TICSPERSEC; + AmbSfxTics = 10 * TICSPERSEC; AmbSfxPtr = AmbSndSeqInit; } @@ -1177,7 +1177,7 @@ void P_InitAmbientSound(void) void P_AddAmbientSfx(int sequence) { - if(AmbSfxCount == MAX_AMBIENT_SFX) + if (AmbSfxCount == MAX_AMBIENT_SFX) { I_Error("Too many ambient sound sequences"); } @@ -1198,11 +1198,11 @@ void P_AmbientSound(void) int sound; boolean done; - if(!AmbSfxCount) + if (!AmbSfxCount) { // No ambient sound sequences on current level return; } - if(--AmbSfxTics) + if (--AmbSfxTics) { return; } @@ -1210,10 +1210,10 @@ void P_AmbientSound(void) do { cmd = *AmbSfxPtr++; - switch(cmd) + switch (cmd) { case afxcmd_play: - AmbSfxVolume = P_Random()>>2; + AmbSfxVolume = P_Random() >> 2; S_StartSoundAtVolume(NULL, *AmbSfxPtr++, AmbSfxVolume); break; case afxcmd_playabsvol: @@ -1224,14 +1224,14 @@ void P_AmbientSound(void) case afxcmd_playrelvol: sound = *AmbSfxPtr++; AmbSfxVolume += *AmbSfxPtr++; - if(AmbSfxVolume < 0) + if (AmbSfxVolume < 0) { AmbSfxVolume = 0; } - else if(AmbSfxVolume > 127) + else if (AmbSfxVolume > 127) { AmbSfxVolume = 127; - } + } S_StartSoundAtVolume(NULL, sound, AmbSfxVolume); break; case afxcmd_delay: @@ -1239,17 +1239,17 @@ void P_AmbientSound(void) done = true; break; case afxcmd_delayrand: - AmbSfxTics = P_Random()&(*AmbSfxPtr++); + AmbSfxTics = P_Random() & (*AmbSfxPtr++); done = true; break; case afxcmd_end: - AmbSfxTics = 6*TICSPERSEC+P_Random(); - AmbSfxPtr = LevelAmbientSfx[P_Random()%AmbSfxCount]; + AmbSfxTics = 6 * TICSPERSEC + P_Random(); + AmbSfxPtr = LevelAmbientSfx[P_Random() % AmbSfxCount]; done = true; break; default: I_Error("P_AmbientSound: Unknown afxcmd %d", cmd); break; } - } while(done == false); + } while (done == false); } diff --git a/P_SWITCH.C b/P_SWITCH.C index b8caf2a..a053f2d 100644 --- a/P_SWITCH.C +++ b/P_SWITCH.C @@ -54,7 +54,7 @@ switchlist_t alphSwitchList[] = {"SW1STON2", "SW2STON2", 1}, {"SW1STONE", "SW2STONE", 1}, {"SW1STRTN", "SW2STRTN", 1}, - + {"SW1BLUE", "SW2BLUE", 2}, {"SW1CMT", "SW2CMT", 2}, {"SW1GARG", "SW2GARG", 2}, @@ -88,20 +88,20 @@ void P_InitSwitchList(void) int i; int index; int episode; - + episode = 1; if (!shareware) episode = 2; - - for (index = 0,i = 0;i < MAXSWITCHES;i++) + + for (index = 0, i = 0; i < MAXSWITCHES; i++) { if (!alphSwitchList[i].episode) { - numswitches = index/2; + numswitches = index / 2; switchlist[index] = -1; break; } - + if (alphSwitchList[i].episode <= episode) { switchlist[index++] = R_TextureNumForName(alphSwitchList[i].name1); @@ -115,11 +115,11 @@ void P_InitSwitchList(void) // Start a button counting down till it turns off. // //================================================================== -void P_StartButton(line_t *line,bwhere_e w,int texture,int time) +void P_StartButton(line_t *line, bwhere_e w, int texture, int time) { int i; - - for (i = 0;i < MAXBUTTONS;i++) + + for (i = 0; i < MAXBUTTONS; i++) if (!buttonlist[i].btimer) { buttonlist[i].line = line; @@ -129,7 +129,7 @@ void P_StartButton(line_t *line,bwhere_e w,int texture,int time) buttonlist[i].soundorg = (mobj_t *)&line->frontsector->soundorg; return; } - + I_Error("P_StartButton: no button slots left!"); } @@ -139,14 +139,14 @@ void P_StartButton(line_t *line,bwhere_e w,int texture,int time) // Tell it if switch is ok to use again (1=yes, it's a button). // //================================================================== -void P_ChangeSwitchTexture(line_t *line,int useAgain) +void P_ChangeSwitchTexture(line_t *line, int useAgain) { int texTop; int texMid; int texBot; int i; int sound; - + if (!useAgain) line->special = 0; @@ -157,34 +157,34 @@ void P_ChangeSwitchTexture(line_t *line,int useAgain) sound = sfx_switch; //if (line->special == 11) // EXIT SWITCH? // sound = sfx_swtchx; - - for (i = 0;i < numswitches*2;i++) + + for (i = 0; i < numswitches * 2; i++) if (switchlist[i] == texTop) { - S_StartSound(buttonlist->soundorg,sound); - sides[line->sidenum[0]].toptexture = switchlist[i^1]; + S_StartSound(buttonlist->soundorg, sound); + sides[line->sidenum[0]].toptexture = switchlist[i ^ 1]; if (useAgain) - P_StartButton(line,top,switchlist[i],BUTTONTIME); + P_StartButton(line, top, switchlist[i], BUTTONTIME); return; } else - if (switchlist[i] == texMid) - { - S_StartSound(buttonlist->soundorg,sound); - sides[line->sidenum[0]].midtexture = switchlist[i^1]; - if (useAgain) - P_StartButton(line, middle,switchlist[i],BUTTONTIME); - return; - } - else - if (switchlist[i] == texBot) - { - S_StartSound(buttonlist->soundorg,sound); - sides[line->sidenum[0]].bottomtexture = switchlist[i^1]; - if (useAgain) - P_StartButton(line, bottom,switchlist[i],BUTTONTIME); - return; - } + if (switchlist[i] == texMid) + { + S_StartSound(buttonlist->soundorg, sound); + sides[line->sidenum[0]].midtexture = switchlist[i ^ 1]; + if (useAgain) + P_StartButton(line, middle, switchlist[i], BUTTONTIME); + return; + } + else + if (switchlist[i] == texBot) + { + S_StartSound(buttonlist->soundorg, sound); + sides[line->sidenum[0]].bottomtexture = switchlist[i ^ 1]; + if (useAgain) + P_StartButton(line, bottom, switchlist[i], BUTTONTIME); + return; + } } /* @@ -197,8 +197,8 @@ void P_ChangeSwitchTexture(line_t *line,int useAgain) =============================================================================== */ -boolean P_UseSpecialLine ( mobj_t *thing, line_t *line) -{ +boolean P_UseSpecialLine (mobj_t *thing, line_t *line) +{ // // Switches that other things can activate // @@ -206,7 +206,7 @@ boolean P_UseSpecialLine ( mobj_t *thing, line_t *line) { if (line->flags & ML_SECRET) return false; // never open secret doors - switch(line->special) + switch (line->special) { case 1: // MANUAL DOOR RAISE case 32: // MANUAL BLUE @@ -217,7 +217,7 @@ boolean P_UseSpecialLine ( mobj_t *thing, line_t *line) return false; } } - + // // do something // @@ -237,24 +237,24 @@ boolean P_UseSpecialLine ( mobj_t *thing, line_t *line) case 34: // Yellow locked door open EV_VerticalDoor (line, thing); break; - //=============================================== - // SWITCHES - //=============================================== + //=============================================== + // SWITCHES + //=============================================== case 7: // Switch_Build_Stairs (8 pixel steps) - if(EV_BuildStairs(line, 8*FRACUNIT)) + if (EV_BuildStairs(line, 8 * FRACUNIT)) { P_ChangeSwitchTexture(line, 0); } break; case 107: // Switch_Build_Stairs_16 (16 pixel steps) - if(EV_BuildStairs(line, 16*FRACUNIT)) + if (EV_BuildStairs(line, 16 * FRACUNIT)) { P_ChangeSwitchTexture(line, 0); } break; case 9: // Change Donut if (EV_DoDonut(line)) - P_ChangeSwitchTexture(line,0); + P_ChangeSwitchTexture(line, 0); break; case 11: // Exit level if (netgame && M_CheckParm("-noexit")) // FS: No Exit! @@ -263,51 +263,51 @@ boolean P_UseSpecialLine ( mobj_t *thing, line_t *line) break; } G_ExitLevel (); - P_ChangeSwitchTexture(line,0); + P_ChangeSwitchTexture(line, 0); break; case 14: // Raise Floor 32 and change texture - if (EV_DoPlat(line,raiseAndChange,32)) - P_ChangeSwitchTexture(line,0); + if (EV_DoPlat(line, raiseAndChange, 32)) + P_ChangeSwitchTexture(line, 0); break; case 15: // Raise Floor 24 and change texture - if (EV_DoPlat(line,raiseAndChange,24)) - P_ChangeSwitchTexture(line,0); + if (EV_DoPlat(line, raiseAndChange, 24)) + P_ChangeSwitchTexture(line, 0); break; case 18: // Raise Floor to next highest floor if (EV_DoFloor(line, raiseFloorToNearest)) - P_ChangeSwitchTexture(line,0); + P_ChangeSwitchTexture(line, 0); break; case 20: // Raise Plat next highest floor and change texture - if (EV_DoPlat(line,raiseToNearestAndChange,0)) - P_ChangeSwitchTexture(line,0); + if (EV_DoPlat(line, raiseToNearestAndChange, 0)) + P_ChangeSwitchTexture(line, 0); break; case 21: // PlatDownWaitUpStay - if (EV_DoPlat(line,downWaitUpStay,0)) - P_ChangeSwitchTexture(line,0); + if (EV_DoPlat(line, downWaitUpStay, 0)) + P_ChangeSwitchTexture(line, 0); break; case 23: // Lower Floor to Lowest - if (EV_DoFloor(line,lowerFloorToLowest)) - P_ChangeSwitchTexture(line,0); + if (EV_DoFloor(line, lowerFloorToLowest)) + P_ChangeSwitchTexture(line, 0); break; case 29: // Raise Door - if (EV_DoDoor(line,doornormal,VDOORSPEED)) - P_ChangeSwitchTexture(line,0); + if (EV_DoDoor(line, doornormal, VDOORSPEED)) + P_ChangeSwitchTexture(line, 0); break; case 41: // Lower Ceiling to Floor - if (EV_DoCeiling(line,lowerToFloor)) - P_ChangeSwitchTexture(line,0); + if (EV_DoCeiling(line, lowerToFloor)) + P_ChangeSwitchTexture(line, 0); break; case 71: // Turbo Lower Floor - if (EV_DoFloor(line,turboLower)) - P_ChangeSwitchTexture(line,0); + if (EV_DoFloor(line, turboLower)) + P_ChangeSwitchTexture(line, 0); break; case 49: // Lower Ceiling And Crush - if (EV_DoCeiling(line,lowerAndCrush)) - P_ChangeSwitchTexture(line,0); + if (EV_DoCeiling(line, lowerAndCrush)) + P_ChangeSwitchTexture(line, 0); break; case 50: // Close Door - if (EV_DoDoor(line,doorclose,VDOORSPEED)) - P_ChangeSwitchTexture(line,0); + if (EV_DoDoor(line, doorclose, VDOORSPEED)) + P_ChangeSwitchTexture(line, 0); break; case 51: // Secret EXIT if (netgame && M_CheckParm("-noexit")) // FS: No Exit! @@ -316,85 +316,85 @@ boolean P_UseSpecialLine ( mobj_t *thing, line_t *line) break; } G_SecretExitLevel (); - P_ChangeSwitchTexture(line,0); + P_ChangeSwitchTexture(line, 0); break; case 55: // Raise Floor Crush - if (EV_DoFloor(line,raiseFloorCrush)) - P_ChangeSwitchTexture(line,0); + if (EV_DoFloor(line, raiseFloorCrush)) + P_ChangeSwitchTexture(line, 0); break; case 101: // Raise Floor - if (EV_DoFloor(line,raiseFloor)) - P_ChangeSwitchTexture(line,0); + if (EV_DoFloor(line, raiseFloor)) + P_ChangeSwitchTexture(line, 0); break; case 102: // Lower Floor to Surrounding floor height - if (EV_DoFloor(line,lowerFloor)) - P_ChangeSwitchTexture(line,0); + if (EV_DoFloor(line, lowerFloor)) + P_ChangeSwitchTexture(line, 0); break; case 103: // Open Door - if (EV_DoDoor(line,dooropen,VDOORSPEED)) - P_ChangeSwitchTexture(line,0); + if (EV_DoDoor(line, dooropen, VDOORSPEED)) + P_ChangeSwitchTexture(line, 0); break; - //=============================================== - // BUTTONS - //=============================================== + //=============================================== + // BUTTONS + //=============================================== case 42: // Close Door - if (EV_DoDoor(line,doorclose,VDOORSPEED)) - P_ChangeSwitchTexture(line,1); + if (EV_DoDoor(line, doorclose, VDOORSPEED)) + P_ChangeSwitchTexture(line, 1); break; case 43: // Lower Ceiling to Floor - if (EV_DoCeiling(line,lowerToFloor)) - P_ChangeSwitchTexture(line,1); + if (EV_DoCeiling(line, lowerToFloor)) + P_ChangeSwitchTexture(line, 1); break; case 45: // Lower Floor to Surrounding floor height - if (EV_DoFloor(line,lowerFloor)) - P_ChangeSwitchTexture(line,1); + if (EV_DoFloor(line, lowerFloor)) + P_ChangeSwitchTexture(line, 1); break; case 60: // Lower Floor to Lowest - if (EV_DoFloor(line,lowerFloorToLowest)) - P_ChangeSwitchTexture(line,1); + if (EV_DoFloor(line, lowerFloorToLowest)) + P_ChangeSwitchTexture(line, 1); break; case 61: // Open Door - if (EV_DoDoor(line,dooropen,VDOORSPEED)) - P_ChangeSwitchTexture(line,1); + if (EV_DoDoor(line, dooropen, VDOORSPEED)) + P_ChangeSwitchTexture(line, 1); break; case 62: // PlatDownWaitUpStay - if (EV_DoPlat(line,downWaitUpStay,1)) - P_ChangeSwitchTexture(line,1); + if (EV_DoPlat(line, downWaitUpStay, 1)) + P_ChangeSwitchTexture(line, 1); break; case 63: // Raise Door - if (EV_DoDoor(line,doornormal,VDOORSPEED)) - P_ChangeSwitchTexture(line,1); + if (EV_DoDoor(line, doornormal, VDOORSPEED)) + P_ChangeSwitchTexture(line, 1); break; case 64: // Raise Floor to ceiling - if (EV_DoFloor(line,raiseFloor)) - P_ChangeSwitchTexture(line,1); + if (EV_DoFloor(line, raiseFloor)) + P_ChangeSwitchTexture(line, 1); break; case 66: // Raise Floor 24 and change texture - if (EV_DoPlat(line,raiseAndChange,24)) - P_ChangeSwitchTexture(line,1); + if (EV_DoPlat(line, raiseAndChange, 24)) + P_ChangeSwitchTexture(line, 1); break; case 67: // Raise Floor 32 and change texture - if (EV_DoPlat(line,raiseAndChange,32)) - P_ChangeSwitchTexture(line,1); + if (EV_DoPlat(line, raiseAndChange, 32)) + P_ChangeSwitchTexture(line, 1); break; case 65: // Raise Floor Crush - if (EV_DoFloor(line,raiseFloorCrush)) - P_ChangeSwitchTexture(line,1); + if (EV_DoFloor(line, raiseFloorCrush)) + P_ChangeSwitchTexture(line, 1); break; case 68: // Raise Plat to next highest floor and change texture - if (EV_DoPlat(line,raiseToNearestAndChange,0)) - P_ChangeSwitchTexture(line,1); + if (EV_DoPlat(line, raiseToNearestAndChange, 0)) + P_ChangeSwitchTexture(line, 1); break; case 69: // Raise Floor to next highest floor if (EV_DoFloor(line, raiseFloorToNearest)) - P_ChangeSwitchTexture(line,1); + P_ChangeSwitchTexture(line, 1); break; case 70: // Turbo Lower Floor - if (EV_DoFloor(line,turboLower)) - P_ChangeSwitchTexture(line,1); + if (EV_DoFloor(line, turboLower)) + P_ChangeSwitchTexture(line, 1); break; } - + return true; } diff --git a/P_TELEPT.C b/P_TELEPT.C index 614e2c2..ed93b6e 100644 --- a/P_TELEPT.C +++ b/P_TELEPT.C @@ -25,36 +25,36 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, angle_t angle) oldx = thing->x; oldy = thing->y; oldz = thing->z; - aboveFloor = thing->z-thing->floorz; - if(!P_TeleportMove(thing, x, y)) + aboveFloor = thing->z - thing->floorz; + if (!P_TeleportMove(thing, x, y)) { return(false); } - if(thing->player) + if (thing->player) { player = thing->player; - if(player->powers[pw_flight] && aboveFloor) + if (player->powers[pw_flight] && aboveFloor) { - thing->z = thing->floorz+aboveFloor; - if(thing->z+thing->height > thing->ceilingz) + thing->z = thing->floorz + aboveFloor; + if (thing->z + thing->height > thing->ceilingz) { - thing->z = thing->ceilingz-thing->height; + thing->z = thing->ceilingz - thing->height; } - player->viewz = thing->z+player->viewheight; + player->viewz = thing->z + player->viewheight; } else { thing->z = thing->floorz; - player->viewz = thing->z+player->viewheight; + player->viewz = thing->z + player->viewheight; player->lookdir = 0; } } - else if(thing->flags&MF_MISSILE) + else if (thing->flags & MF_MISSILE) { - thing->z = thing->floorz+aboveFloor; - if(thing->z+thing->height > thing->ceilingz) + thing->z = thing->floorz + aboveFloor; + if (thing->z + thing->height > thing->ceilingz) { - thing->z = thing->ceilingz-thing->height; + thing->z = thing->ceilingz - thing->height; } } else @@ -62,27 +62,27 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, angle_t angle) thing->z = thing->floorz; } // Spawn teleport fog at source and destination - fogDelta = thing->flags&MF_MISSILE ? 0 : TELEFOGHEIGHT; - fog = P_SpawnMobj(oldx, oldy, oldz+fogDelta, MT_TFOG); + fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT; + fog = P_SpawnMobj(oldx, oldy, oldz + fogDelta, MT_TFOG); S_StartSound(fog, sfx_telept); - an = angle>>ANGLETOFINESHIFT; - fog = P_SpawnMobj(x+20*finecosine[an], - y+20*finesine[an], thing->z+fogDelta, MT_TFOG); + an = angle >> ANGLETOFINESHIFT; + fog = P_SpawnMobj(x + 20 * finecosine[an], + y + 20 * finesine[an], thing->z + fogDelta, MT_TFOG); S_StartSound(fog, sfx_telept); - if(thing->player && !thing->player->powers[pw_weaponlevel2]) + if (thing->player && !thing->player->powers[pw_weaponlevel2]) { // Freeze player for about .5 sec thing->reactiontime = 18; } thing->angle = angle; - if(thing->flags2&MF2_FOOTCLIP && P_GetThingFloorType(thing) != FLOOR_SOLID) + if (thing->flags2 & MF2_FOOTCLIP && P_GetThingFloorType(thing) != FLOOR_SOLID) { thing->flags2 |= MF2_FEETARECLIPPED; } - else if(thing->flags2&MF2_FEETARECLIPPED) + else if (thing->flags2 & MF2_FEETARECLIPPED) { thing->flags2 &= ~MF2_FEETARECLIPPED; } - if(thing->flags&MF_MISSILE) + if (thing->flags & MF_MISSILE) { angle >>= ANGLETOFINESHIFT; thing->momx = FixedMul(thing->info->speed, finecosine[angle]); @@ -109,34 +109,34 @@ boolean EV_Teleport(line_t *line, int side, mobj_t *thing) thinker_t *thinker; sector_t *sector; - if(thing->flags2&MF2_NOTELEPORT) + if (thing->flags2 & MF2_NOTELEPORT) { return(false); } - if(side == 1) + if (side == 1) { // Don't teleport when crossing back side return(false); } tag = line->tag; - for(i = 0; i < numsectors; i++) + for (i = 0; i < numsectors; i++) { - if(sectors[i].tag == tag) + if (sectors[i].tag == tag) { thinker = thinkercap.next; - for(thinker = thinkercap.next; thinker != &thinkercap; + for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { - if(thinker->function != P_MobjThinker) + if (thinker->function != P_MobjThinker) { // Not a mobj continue; } m = (mobj_t *)thinker; - if(m->type != MT_TELEPORTMAN ) + if (m->type != MT_TELEPORTMAN) { // Not a teleportman continue; } sector = m->subsector->sector; - if(sector-sectors != i) + if (sector - sectors != i) { // Wrong sector continue; } diff --git a/P_TICK.C b/P_TICK.C index bbed129..f5b8c30 100644 --- a/P_TICK.C +++ b/P_TICK.C @@ -1,4 +1,3 @@ - // P_tick.c #include "DoomDef.h" @@ -21,19 +20,19 @@ void P_ArchivePlayers(void) int j; player_t dest; - for(i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < MAXPLAYERS; i++) { - if(!playeringame[i]) + if (!playeringame[i]) { continue; } memcpy(&dest, &players[i], sizeof(player_t)); - for(j = 0; j < NUMPSPRITES; j++) + for (j = 0; j < NUMPSPRITES; j++) { - if(dest.psprites[j].state) + if (dest.psprites[j].state) { dest.psprites[j].state = - (state_t *)(dest.psprites[j].state-states); + (state_t *)(dest.psprites[j].state - states); } } SV_Write(&dest, sizeof(player_t)); @@ -50,21 +49,21 @@ void P_ArchivePlayers(void) void P_UnArchivePlayers (void) { - int i,j; + int i, j; - for (i=0 ; ifloorheight>>FRACBITS); - SV_WriteWord(sec->ceilingheight>>FRACBITS); + SV_WriteWord(sec->floorheight >> FRACBITS); + SV_WriteWord(sec->ceilingheight >> FRACBITS); SV_WriteWord(sec->floorpic); SV_WriteWord(sec->ceilingpic); SV_WriteWord(sec->lightlevel); @@ -99,20 +98,20 @@ void P_ArchiveWorld(void) } // Lines - for(i = 0, li = lines; i < numlines; i++, li++) + for (i = 0, li = lines; i < numlines; i++, li++) { SV_WriteWord(li->flags); SV_WriteWord(li->special); SV_WriteWord(li->tag); - for(j = 0; j < 2; j++) + for (j = 0; j < 2; j++) { - if(li->sidenum[j] == -1) + if (li->sidenum[j] == -1) { continue; } si = &sides[li->sidenum[j]]; - SV_WriteWord(si->textureoffset>>FRACBITS); - SV_WriteWord(si->rowoffset>>FRACBITS); + SV_WriteWord(si->textureoffset >> FRACBITS); + SV_WriteWord(si->rowoffset >> FRACBITS); SV_WriteWord(si->toptexture); SV_WriteWord(si->bottomtexture); SV_WriteWord(si->midtexture); @@ -130,18 +129,18 @@ void P_ArchiveWorld(void) void P_UnArchiveWorld (void) { - int i,j; - sector_t *sec; - line_t *li; - side_t *si; - short *get; - + int i, j; + sector_t *sec; + line_t *li; + side_t *si; + short *get; + get = (short *)save_p; - -// -// do sectors -// - for (i=0, sec = sectors ; ifloorheight = *get++ << FRACBITS; sec->ceilingheight = *get++ << FRACBITS; @@ -152,17 +151,17 @@ void P_UnArchiveWorld (void) sec->tag = *get++; // needed? sec->specialdata = 0; sec->soundtarget = 0; - } + } -// -// do lines -// - for (i=0, li = lines ; iflags = *get++; li->special = *get++; li->tag = *get++; - for (j=0 ; j<2 ; j++) + for (j = 0; j < 2; j++) { if (li->sidenum[j] == -1) continue; @@ -174,8 +173,8 @@ void P_UnArchiveWorld (void) si->midtexture = *get++; } } - - save_p = (byte *)get; + + save_p = (byte *)get; } //============================================================================= @@ -199,16 +198,16 @@ void P_ArchiveThinkers(void) thinker_t *th; mobj_t mobj; - for(th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if(th->function == P_MobjThinker) + if (th->function == P_MobjThinker) { SV_WriteByte(tc_mobj); memcpy(&mobj, th, sizeof(mobj_t)); - mobj.state = (state_t *)(mobj.state-states); - if(mobj.player) + mobj.state = (state_t *)(mobj.state - states); + if (mobj.player) { - mobj.player = (player_t *)((mobj.player-players)+1); + mobj.player = (player_t *)((mobj.player - players) + 1); } SV_Write(&mobj, sizeof(mobj_t)); continue; @@ -231,12 +230,12 @@ void P_ArchiveThinkers(void) void P_UnArchiveThinkers (void) { byte tclass; - thinker_t *currentthinker, *next; - mobj_t *mobj; - -// -// remove all the current thinkers -// + thinker_t *currentthinker, *next; + mobj_t *mobj; + + // + // remove all the current thinkers + // currentthinker = thinkercap.next; while (currentthinker != &thinkercap) { @@ -248,39 +247,39 @@ void P_UnArchiveThinkers (void) currentthinker = next; } P_InitThinkers (); - -// read in saved thinkers + + // read in saved thinkers while (1) { tclass = *save_p++; switch (tclass) { - case tc_end: - return; // end of list - - case tc_mobj: - mobj = Z_Malloc (sizeof(*mobj), PU_LEVEL, NULL); - memcpy (mobj, save_p, sizeof(*mobj)); - save_p += sizeof(*mobj); - mobj->state = &states[(int)mobj->state]; - mobj->target = NULL; - if (mobj->player) - { - mobj->player = &players[(int)mobj->player-1]; - mobj->player->mo = mobj; - } - P_SetThingPosition (mobj); - mobj->info = &mobjinfo[mobj->type]; - mobj->floorz = mobj->subsector->sector->floorheight; - mobj->ceilingz = mobj->subsector->sector->ceilingheight; - mobj->thinker.function = P_MobjThinker; - P_AddThinker (&mobj->thinker); - break; - - default: - I_Error ("Unknown tclass %i in savegame",tclass); + case tc_end: + return; // end of list + + case tc_mobj: + mobj = Z_Malloc (sizeof(*mobj), PU_LEVEL, NULL); + memcpy (mobj, save_p, sizeof(*mobj)); + save_p += sizeof(*mobj); + mobj->state = &states[(int)mobj->state]; + mobj->target = NULL; + if (mobj->player) + { + mobj->player = &players[(int)mobj->player - 1]; + mobj->player->mo = mobj; + } + P_SetThingPosition (mobj); + mobj->info = &mobjinfo[mobj->type]; + mobj->floorz = mobj->subsector->sector->floorheight; + mobj->ceilingz = mobj->subsector->sector->ceilingheight; + mobj->thinker.function = P_MobjThinker; + P_AddThinker (&mobj->thinker); + break; + + default: + I_Error ("Unknown tclass %i in savegame", tclass); } - + } } @@ -305,19 +304,19 @@ enum tc_strobe, tc_glow, tc_endspecials -} specials_e; +} specials_e; void P_ArchiveSpecials(void) { -/* -T_MoveCeiling, (ceiling_t: sector_t * swizzle), - active list -T_VerticalDoor, (vldoor_t: sector_t * swizzle), -T_MoveFloor, (floormove_t: sector_t * swizzle), -T_LightFlash, (lightflash_t: sector_t * swizzle), -T_StrobeFlash, (strobe_t: sector_t *), -T_Glow, (glow_t: sector_t *), -T_PlatRaise, (plat_t: sector_t *), - active list -*/ + /* + T_MoveCeiling, (ceiling_t: sector_t * swizzle), - active list + T_VerticalDoor, (vldoor_t: sector_t * swizzle), + T_MoveFloor, (floormove_t: sector_t * swizzle), + T_LightFlash, (lightflash_t: sector_t * swizzle), + T_StrobeFlash, (strobe_t: sector_t *), + T_Glow, (glow_t: sector_t *), + T_PlatRaise, (plat_t: sector_t *), - active list + */ thinker_t *th; ceiling_t ceiling; @@ -328,61 +327,61 @@ T_PlatRaise, (plat_t: sector_t *), - active list strobe_t strobe; glow_t glow; - for(th = thinkercap.next; th != &thinkercap; th = th->next) + for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if(th->function == T_MoveCeiling) + if (th->function == T_MoveCeiling) { SV_WriteByte(tc_ceiling); memcpy(&ceiling, th, sizeof(ceiling_t)); - ceiling.sector = (sector_t *)(ceiling.sector-sectors); + ceiling.sector = (sector_t *)(ceiling.sector - sectors); SV_Write(&ceiling, sizeof(ceiling_t)); continue; } - if(th->function == T_VerticalDoor) + if (th->function == T_VerticalDoor) { SV_WriteByte(tc_door); memcpy(&door, th, sizeof(vldoor_t)); - door.sector = (sector_t *)(door.sector-sectors); + door.sector = (sector_t *)(door.sector - sectors); SV_Write(&door, sizeof(vldoor_t)); continue; } - if(th->function == T_MoveFloor) + if (th->function == T_MoveFloor) { SV_WriteByte(tc_floor); memcpy(&floor, th, sizeof(floormove_t)); - floor.sector = (sector_t *)(floor.sector-sectors); + floor.sector = (sector_t *)(floor.sector - sectors); SV_Write(&floor, sizeof(floormove_t)); continue; } - if(th->function == T_PlatRaise) + if (th->function == T_PlatRaise) { SV_WriteByte(tc_plat); memcpy(&plat, th, sizeof(plat_t)); - plat.sector = (sector_t *)(plat.sector-sectors); + plat.sector = (sector_t *)(plat.sector - sectors); SV_Write(&plat, sizeof(plat_t)); continue; } - if(th->function == T_LightFlash) + if (th->function == T_LightFlash) { SV_WriteByte(tc_flash); memcpy(&flash, th, sizeof(lightflash_t)); - flash.sector = (sector_t *)(flash.sector-sectors); + flash.sector = (sector_t *)(flash.sector - sectors); SV_Write(&flash, sizeof(lightflash_t)); continue; } - if(th->function == T_StrobeFlash) + if (th->function == T_StrobeFlash) { SV_WriteByte(tc_strobe); memcpy(&strobe, th, sizeof(strobe_t)); - strobe.sector = (sector_t *)(strobe.sector-sectors); + strobe.sector = (sector_t *)(strobe.sector - sectors); SV_Write(&strobe, sizeof(strobe_t)); continue; } - if(th->function == T_Glow) + if (th->function == T_Glow) { SV_WriteByte(tc_glow); memcpy(&glow, th, sizeof(glow_t)); - glow.sector = (sector_t *)(glow.sector-sectors); + glow.sector = (sector_t *)(glow.sector - sectors); SV_Write(&glow, sizeof(glow_t)); continue; } @@ -402,16 +401,16 @@ T_PlatRaise, (plat_t: sector_t *), - active list void P_UnArchiveSpecials (void) { byte tclass; - ceiling_t *ceiling; - vldoor_t *door; - floormove_t *floor; - plat_t *plat; + ceiling_t *ceiling; + vldoor_t *door; + floormove_t *floor; + plat_t *plat; lightflash_t *flash; - strobe_t *strobe; - glow_t *glow; - - -// read in saved thinkers + strobe_t *strobe; + glow_t *glow; + + + // read in saved thinkers while (1) { tclass = *save_p++; @@ -419,7 +418,7 @@ void P_UnArchiveSpecials (void) { case tc_endspecials: return; // end of list - + case tc_ceiling: ceiling = Z_Malloc (sizeof(*ceiling), PU_LEVEL, NULL); memcpy (ceiling, save_p, sizeof(*ceiling)); @@ -451,7 +450,7 @@ void P_UnArchiveSpecials (void) floor->thinker.function = T_MoveFloor; P_AddThinker (&floor->thinker); break; - + case tc_plat: plat = Z_Malloc (sizeof(*plat), PU_LEVEL, NULL); memcpy (plat, save_p, sizeof(*plat)); @@ -463,7 +462,7 @@ void P_UnArchiveSpecials (void) P_AddThinker (&plat->thinker); P_AddActivePlat(plat); break; - + case tc_flash: flash = Z_Malloc (sizeof(*flash), PU_LEVEL, NULL); memcpy (flash, save_p, sizeof(*flash)); @@ -472,7 +471,7 @@ void P_UnArchiveSpecials (void) flash->thinker.function = T_LightFlash; P_AddThinker (&flash->thinker); break; - + case tc_strobe: strobe = Z_Malloc (sizeof(*strobe), PU_LEVEL, NULL); memcpy (strobe, save_p, sizeof(*strobe)); @@ -481,7 +480,7 @@ void P_UnArchiveSpecials (void) strobe->thinker.function = T_StrobeFlash; P_AddThinker (&strobe->thinker); break; - + case tc_glow: glow = Z_Malloc (sizeof(*glow), PU_LEVEL, NULL); memcpy (glow, save_p, sizeof(*glow)); @@ -490,12 +489,12 @@ void P_UnArchiveSpecials (void) glow->thinker.function = T_Glow; P_AddThinker (&glow->thinker); break; - + default: I_Error ("P_UnarchiveSpecials:Unknown tclass %i " - "in savegame",tclass); + "in savegame", tclass); } - + } } @@ -525,7 +524,7 @@ thinker_t thinkercap; // both the head and tail of the thinker list void P_InitThinkers (void) { - thinkercap.prev = thinkercap.next = &thinkercap; + thinkercap.prev = thinkercap.next = &thinkercap; } @@ -588,7 +587,7 @@ void P_AllocateThinker (thinker_t *thinker) void P_RunThinkers (void) { - thinker_t *currentthinker; + thinker_t *currentthinker; currentthinker = thinkercap.next; while (currentthinker != &thinkercap) @@ -618,20 +617,20 @@ void P_Ticker(void) { int i; - if(paused) + if (paused) { return; } - for(i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < MAXPLAYERS; i++) { - if(playeringame[i]) + if (playeringame[i]) { P_PlayerThink(&players[i]); } } - if(TimerGame) + if (TimerGame) { - if(!--TimerGame) + if (!--TimerGame) { G_ExitLevel(); } diff --git a/P_USER.C b/P_USER.C index b6c5f4a..db502ba 100644 --- a/P_USER.C +++ b/P_USER.C @@ -45,15 +45,15 @@ boolean WeaponInShareware[] = void P_Thrust(player_t *player, angle_t angle, fixed_t move) { angle >>= ANGLETOFINESHIFT; - if(player->powers[pw_flight] && !(player->mo->z <= player->mo->floorz)) + if (player->powers[pw_flight] && !(player->mo->z <= player->mo->floorz)) { player->mo->momx += FixedMul(move, finecosine[angle]); player->mo->momy += FixedMul(move, finesine[angle]); } - else if(player->mo->subsector->sector->special == 15) // Friction_Low + else if (player->mo->subsector->sector->special == 15) // Friction_Low { - player->mo->momx += FixedMul(move>>2, finecosine[angle]); - player->mo->momy += FixedMul(move>>2, finesine[angle]); + player->mo->momx += FixedMul(move >> 2, finecosine[angle]); + player->mo->momy += FixedMul(move >> 2, finesine[angle]); } else { @@ -91,24 +91,24 @@ void P_CalcHeight (player_t *player) } else { - player->bob = FixedMul (player->mo->momx, player->mo->momx) + FixedMul (player->mo->momy,player->mo->momy); + 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->mo->flags2&MF2_FLY && !onground) + + if (player->mo->flags2 & MF2_FLY && !onground) { - player->bob = FRACUNIT/2; + player->bob = FRACUNIT / 2; } if ((player->cheats & CF_NOMOMENTUM)) { player->viewz = player->mo->z + VIEWHEIGHT; - if (player->viewz > player->mo->ceilingz-4*FRACUNIT) - player->viewz = player->mo->ceilingz-4*FRACUNIT; + if (player->viewz > player->mo->ceilingz - 4 * FRACUNIT) + player->viewz = player->mo->ceilingz - 4 * FRACUNIT; // The following line was in the Id source and appears // phares 2/25/98 // to be a bug. player->viewz is checked in a similar @@ -118,12 +118,12 @@ void P_CalcHeight (player_t *player) return; } - angle = (FINEANGLES/20*leveltime)&FINEMASK; - bob = FixedMul ( player->bob/2, finesine[angle]); + angle = (FINEANGLES / 20 * leveltime) & FINEMASK; + bob = FixedMul (player->bob / 2, finesine[angle]); -// -// move viewheight -// + // + // move viewheight + // if (player->playerstate == PST_LIVE) { player->viewheight += player->deltaviewheight; @@ -132,42 +132,42 @@ void P_CalcHeight (player_t *player) player->viewheight = VIEWHEIGHT; player->deltaviewheight = 0; } - if (player->viewheight < VIEWHEIGHT/2) + if (player->viewheight < VIEWHEIGHT / 2) { - player->viewheight = VIEWHEIGHT/2; + player->viewheight = VIEWHEIGHT / 2; if (player->deltaviewheight <= 0) player->deltaviewheight = 1; } if (player->deltaviewheight) { - player->deltaviewheight += FRACUNIT/4; + player->deltaviewheight += FRACUNIT / 4; if (!player->deltaviewheight) player->deltaviewheight = 1; } } - if(player->chickenTics) + if (player->chickenTics) { - player->viewz = player->mo->z+player->viewheight-(20*FRACUNIT); + player->viewz = player->mo->z + player->viewheight - (20 * FRACUNIT); } else { - player->viewz = player->mo->z+player->viewheight+bob; + player->viewz = player->mo->z + player->viewheight + bob; } - if(player->mo->flags2&MF2_FEETARECLIPPED + if (player->mo->flags2 & MF2_FEETARECLIPPED && player->playerstate != PST_DEAD && player->mo->z <= player->mo->floorz) { player->viewz -= FOOTCLIPSIZE; } - if(player->viewz > player->mo->ceilingz-4*FRACUNIT) + if (player->viewz > player->mo->ceilingz - 4 * FRACUNIT) { - player->viewz = player->mo->ceilingz-4*FRACUNIT; + player->viewz = player->mo->ceilingz - 4 * FRACUNIT; } - if(player->viewz < player->mo->floorz+4*FRACUNIT) + if (player->viewz < player->mo->floorz + 4 * FRACUNIT) { - player->viewz = player->mo->floorz+4*FRACUNIT; + player->viewz = player->mo->floorz + 4 * FRACUNIT; } } @@ -186,91 +186,91 @@ void P_MovePlayer(player_t *player) ticcmd_t *cmd; cmd = &player->cmd; - player->mo->angle += (cmd->angleturn<<16); + player->mo->angle += (cmd->angleturn << 16); onground = (player->mo->z <= player->mo->floorz - || (player->mo->flags2&MF2_ONMOBJ)); + || (player->mo->flags2 & MF2_ONMOBJ)); - if(player->chickenTics) + if (player->chickenTics) { // Chicken speed - if(cmd->forwardmove && (onground||player->mo->flags2&MF2_FLY)) - P_Thrust(player, player->mo->angle, cmd->forwardmove*2500); - if(cmd->sidemove && (onground||player->mo->flags2&MF2_FLY)) - P_Thrust(player, player->mo->angle-ANG90, cmd->sidemove*2500); + if (cmd->forwardmove && (onground || player->mo->flags2 & MF2_FLY)) + P_Thrust(player, player->mo->angle, cmd->forwardmove * 2500); + if (cmd->sidemove && (onground || player->mo->flags2 & MF2_FLY)) + P_Thrust(player, player->mo->angle - ANG90, cmd->sidemove * 2500); } else { // Normal speed - if(cmd->forwardmove && (onground||player->mo->flags2&MF2_FLY)) - P_Thrust(player, player->mo->angle, cmd->forwardmove*2048); - if(cmd->sidemove && (onground||player->mo->flags2&MF2_FLY)) - P_Thrust(player, player->mo->angle-ANG90, cmd->sidemove*2048); + if (cmd->forwardmove && (onground || player->mo->flags2 & MF2_FLY)) + P_Thrust(player, player->mo->angle, cmd->forwardmove * 2048); + if (cmd->sidemove && (onground || player->mo->flags2 & MF2_FLY)) + P_Thrust(player, player->mo->angle - ANG90, cmd->sidemove * 2048); } - if(cmd->forwardmove || cmd->sidemove) + if (cmd->forwardmove || cmd->sidemove) { - if(player->chickenTics) + if (player->chickenTics) { - if(player->mo->state == &states[S_CHICPLAY]) + if (player->mo->state == &states[S_CHICPLAY]) { P_SetMobjState(player->mo, S_CHICPLAY_RUN1); } } else { - if(player->mo->state == &states[S_PLAY]) + if (player->mo->state == &states[S_PLAY]) { P_SetMobjState(player->mo, S_PLAY_RUN1); } } } - look = cmd->lookfly&15; - if(look > 7) + look = cmd->lookfly & 15; + if (look > 7) { look -= 16; } - if(look) + if (look) { - if(look == TOCENTER) + if (look == TOCENTER) { player->centering = true; } else { - player->lookdir += 5*look; - if(player->lookdir > 90 || player->lookdir < -110) + player->lookdir += 5 * look; + if (player->lookdir > 90 || player->lookdir < -110) { - player->lookdir -= 5*look; + player->lookdir -= 5 * look; } } } - if(player->centering) + if (player->centering) { - if(player->lookdir > 0) + if (player->lookdir > 0) { player->lookdir -= 8; } - else if(player->lookdir < 0) + else if (player->lookdir < 0) { player->lookdir += 8; } - if(abs(player->lookdir) < 8) + if (abs(player->lookdir) < 8) { player->lookdir = 0; player->centering = false; } } - fly = cmd->lookfly>>4; - if(fly > 7) + fly = cmd->lookfly >> 4; + if (fly > 7) { fly -= 16; } - if(fly && player->powers[pw_flight]) + if (fly && player->powers[pw_flight]) { - if(fly != TOCENTER) + if (fly != TOCENTER) { - player->flyheight = fly*2; - if(!(player->mo->flags2&MF2_FLY)) + player->flyheight = fly * 2; + if (!(player->mo->flags2 & MF2_FLY)) { player->mo->flags2 |= MF2_FLY; player->mo->flags |= MF_NOGRAVITY; @@ -282,14 +282,14 @@ void P_MovePlayer(player_t *player) player->mo->flags &= ~MF_NOGRAVITY; } } - else if(fly > 0) + else if (fly > 0) { P_PlayerUseArtifact(player, arti_fly); } - if(player->mo->flags2&MF2_FLY) + if (player->mo->flags2 & MF2_FLY) { - player->mo->momz = player->flyheight*FRACUNIT; - if(player->flyheight) + player->mo->momz = player->flyheight * FRACUNIT; + if (player->flyheight) { player->flyheight /= 2; } @@ -316,21 +316,21 @@ void P_DeathThink(player_t *player) P_MovePsprites(player); onground = (player->mo->z <= player->mo->floorz); - if(player->mo->type == MT_BLOODYSKULL) + if (player->mo->type == MT_BLOODYSKULL) { // Flying bloody skull - player->viewheight = 6*FRACUNIT; + player->viewheight = 6 * FRACUNIT; player->deltaviewheight = 0; //player->damagecount = 20; - if(onground) + if (onground) { - if(player->lookdir < 60) + if (player->lookdir < 60) { - lookDelta = (60-player->lookdir)/8; - if(lookDelta < 1 && (leveltime&1)) + lookDelta = (60 - player->lookdir) / 8; + if (lookDelta < 1 && (leveltime & 1)) { lookDelta = 1; } - else if(lookDelta > 6) + else if (lookDelta > 6) { lookDelta = 6; } @@ -341,51 +341,51 @@ void P_DeathThink(player_t *player) else { // Fall to ground player->deltaviewheight = 0; - if(player->viewheight > 6*FRACUNIT) + if (player->viewheight > 6 * FRACUNIT) player->viewheight -= FRACUNIT; - if(player->viewheight < 6*FRACUNIT) - player->viewheight = 6*FRACUNIT; - if(player->lookdir > 0) + if (player->viewheight < 6 * FRACUNIT) + player->viewheight = 6 * FRACUNIT; + if (player->lookdir > 0) { player->lookdir -= 6; } - else if(player->lookdir < 0) + else if (player->lookdir < 0) { player->lookdir += 6; } - if(abs(player->lookdir) < 6) + if (abs(player->lookdir) < 6) { player->lookdir = 0; } } P_CalcHeight(player); - if(player->attacker && player->attacker != player->mo) + 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) + delta = angle - player->mo->angle; + if (delta < ANG5 || delta > (unsigned) - ANG5) { // Looking at killer, so fade damage flash down player->mo->angle = angle; - if(player->damagecount) + if (player->damagecount) { player->damagecount--; } } - else if(delta < ANG180) + else if (delta < ANG180) player->mo->angle += ANG5; else player->mo->angle -= ANG5; } - else if(player->damagecount) + else if (player->damagecount) { player->damagecount--; } - if(player->cmd.buttons&BT_USE) + if (player->cmd.buttons & BT_USE) { - if(player == &players[consoleplayer]) + if (player == &players[consoleplayer]) { I_SetPalette((byte *)W_CacheLumpName("PLAYPAL", PU_CACHE)); inv_ptr = 0; @@ -410,26 +410,26 @@ void P_ChickenPlayerThink(player_t *player) { mobj_t *pmo; - if(player->health > 0) + if (player->health > 0) { // Handle beak movement P_UpdateBeak(player, &player->psprites[ps_weapon]); } - if(player->chickenTics&15) + if (player->chickenTics & 15) { return; } pmo = player->mo; - if(!(pmo->momx+pmo->momy) && P_Random() < 160) + if (!(pmo->momx + pmo->momy) && P_Random() < 160) { // Twitch view angle - pmo->angle += (P_Random()-P_Random())<<19; + pmo->angle += (P_Random() - P_Random()) << 19; } - if((pmo->z <= pmo->floorz) && (P_Random() < 32)) + if ((pmo->z <= pmo->floorz) && (P_Random() < 32)) { // Jump and noise pmo->momz += FRACUNIT; P_SetMobjState(pmo, S_CHICPLAY_PAIN); return; } - if(P_Random() < 48) + if (P_Random() < 48) { // Just noise S_StartSound(pmo, sfx_chicact); } @@ -445,9 +445,9 @@ int P_GetPlayerNum(player_t *player) { int i; - for(i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < MAXPLAYERS; i++) { - if(player == &players[i]) + if (player == &players[i]) { return(i); } @@ -485,7 +485,7 @@ boolean P_UndoPlayerChicken(player_t *player) oldFlags2 = pmo->flags2; P_SetMobjState(pmo, S_FREETARGMOBJ); mo = P_SpawnMobj(x, y, z, MT_PLAYER); - if(P_TestMobjLocation(mo) == false) + if (P_TestMobjLocation(mo) == false) { // Didn't fit P_RemoveMobj(mo); mo = P_SpawnMobj(x, y, z, MT_CHICPLAYER); @@ -496,18 +496,18 @@ boolean P_UndoPlayerChicken(player_t *player) mo->flags = oldFlags; mo->flags2 = oldFlags2; player->mo = mo; - player->chickenTics = 2*35; + player->chickenTics = 2 * 35; return(false); } playerNum = P_GetPlayerNum(player); - if(playerNum != 0) + if (playerNum != 0) { // Set color translation - mo->flags |= playerNum<flags |= playerNum << MF_TRANSSHIFT; } mo->angle = angle; mo->player = player; mo->reactiontime = 18; - if(oldFlags2&MF2_FLY) + if (oldFlags2 & MF2_FLY) { mo->flags2 |= MF2_FLY; mo->flags |= MF_NOGRAVITY; @@ -517,8 +517,8 @@ boolean P_UndoPlayerChicken(player_t *player) player->health = mo->health = MAXHEALTH; player->mo = mo; angle >>= ANGLETOFINESHIFT; - fog = P_SpawnMobj(x+20*finecosine[angle], - y+20*finesine[angle], z+TELEFOGHEIGHT, MT_TFOG); + fog = P_SpawnMobj(x + 20 * finecosine[angle], + y + 20 * finesine[angle], z + TELEFOGHEIGHT, MT_TFOG); S_StartSound(fog, sfx_telept); P_PostChickenWeapon(player, weapon); return(true); @@ -538,7 +538,7 @@ void P_PlayerThink(player_t *player) extern boolean ultimatemsg; // No-clip cheat - if(player->cheats&CF_NOCLIP) + if (player->cheats & CF_NOCLIP) { player->mo->flags |= MF_NOCLIP; } @@ -547,32 +547,32 @@ void P_PlayerThink(player_t *player) player->mo->flags &= ~MF_NOCLIP; } cmd = &player->cmd; - if(player->mo->flags&MF_JUSTATTACKED) + if (player->mo->flags & MF_JUSTATTACKED) { // Gauntlets attack auto forward motion cmd->angleturn = 0; - cmd->forwardmove = 0xc800/512; + cmd->forwardmove = 0xc800 / 512; cmd->sidemove = 0; player->mo->flags &= ~MF_JUSTATTACKED; } -// messageTics is above the rest of the counters so that messages will -// go away, even in death. + // messageTics is above the rest of the counters so that messages will + // go away, even in death. player->messageTics--; // Can go negative - if(!player->messageTics) + if (!player->messageTics) { // Refresh the screen when a message goes away ultimatemsg = false; // clear out any chat messages. BorderTopRefresh = true; } - if(player->playerstate == PST_DEAD) + if (player->playerstate == PST_DEAD) { P_DeathThink(player); return; } - if(player->chickenTics) + if (player->chickenTics) { P_ChickenPlayerThink(player); } // Handle movement - if(player->mo->reactiontime) + if (player->mo->reactiontime) { // Player is frozen player->mo->reactiontime--; } @@ -581,13 +581,13 @@ void P_PlayerThink(player_t *player) P_MovePlayer(player); } P_CalcHeight(player); - if(player->mo->subsector->sector->special) + if (player->mo->subsector->sector->special) { P_PlayerInSpecialSector(player); } - if(cmd->arti) + if (cmd->arti) { // Use an artifact - if(cmd->arti == 0xff) + if (cmd->arti == 0xff) { P_PlayerNextArtifact(player); } @@ -597,34 +597,34 @@ void P_PlayerThink(player_t *player) } } // Check for weapon change - if(cmd->buttons&BT_SPECIAL) + if (cmd->buttons & BT_SPECIAL) { // A special event has no other buttons cmd->buttons = 0; } - if(cmd->buttons&BT_CHANGE) + if (cmd->buttons & BT_CHANGE) { // The actual changing of the weapon is done when the weapon // psprite can do it (A_WeaponReady), so it doesn't happen in // the middle of an attack. - newweapon = (cmd->buttons&BT_WEAPONMASK)>>BT_WEAPONSHIFT; - if(newweapon == wp_staff && player->weaponowned[wp_gauntlets] + newweapon = (cmd->buttons & BT_WEAPONMASK) >> BT_WEAPONSHIFT; + if (newweapon == wp_staff && player->weaponowned[wp_gauntlets] && !(player->readyweapon == wp_gauntlets)) { newweapon = wp_gauntlets; } - if(player->weaponowned[newweapon] + if (player->weaponowned[newweapon] && newweapon != player->readyweapon) { - if(WeaponInShareware[newweapon] || !shareware) + if (WeaponInShareware[newweapon] || !shareware) { player->pendingweapon = newweapon; } } } // Check for use - if(cmd->buttons&BT_USE) + if (cmd->buttons & BT_USE) { - if(!player->usedown) + if (!player->usedown) { P_UseLines(player); player->usedown = true; @@ -635,13 +635,13 @@ void P_PlayerThink(player_t *player) player->usedown = false; } // Chicken counter - if(player->chickenTics) + if (player->chickenTics) { - if(player->chickenPeck) + if (player->chickenPeck) { // Chicken attack counter player->chickenPeck -= 3; } - if(!--player->chickenTics) + if (!--player->chickenTics) { // Attempt to undo the chicken P_UndoPlayerChicken(player); } @@ -649,32 +649,32 @@ void P_PlayerThink(player_t *player) // Cycle psprites P_MovePsprites(player); // Other Counters - if(player->powers[pw_invulnerability]) + if (player->powers[pw_invulnerability]) { player->powers[pw_invulnerability]--; } - if(player->powers[pw_invisibility]) + if (player->powers[pw_invisibility]) { - if(!--player->powers[pw_invisibility]) + if (!--player->powers[pw_invisibility]) { player->mo->flags &= ~MF_SHADOW; } } - if(player->powers[pw_infrared] && M_CheckParm("-oldrules")) // FS: Old rules! For Torch + if (player->powers[pw_infrared] && M_CheckParm("-oldrules")) // FS: Old rules! For Torch { player->powers[pw_infrared]--; } - if(player->powers[pw_flight]) + if (player->powers[pw_flight]) { - if(!--player->powers[pw_flight]) + if (!--player->powers[pw_flight]) { #ifdef __WATCOMC__ - if(player->mo->z != player->mo->floorz && !useexterndriver) + if (player->mo->z != player->mo->floorz && !useexterndriver) { player->centering = true; } #else - if(player->mo->z != player->mo->floorz) + if (player->mo->z != player->mo->floorz) { player->centering = true; } @@ -685,21 +685,21 @@ void P_PlayerThink(player_t *player) BorderTopRefresh = true; //make sure the sprite's cleared out } } - if(player->powers[pw_weaponlevel2]) + if (player->powers[pw_weaponlevel2]) { - if(!--player->powers[pw_weaponlevel2]) + if (!--player->powers[pw_weaponlevel2]) { - if((player->readyweapon == wp_phoenixrod) + if ((player->readyweapon == wp_phoenixrod) && (player->psprites[ps_weapon].state - != &states[S_PHOENIXREADY]) + != &states[S_PHOENIXREADY]) && (player->psprites[ps_weapon].state - != &states[S_PHOENIXUP])) + != &states[S_PHOENIXUP])) { P_SetPsprite(player, ps_weapon, S_PHOENIXREADY); player->ammo[am_phoenixrod] -= USE_PHRD_AMMO_2; player->refire = 0; } - else if((player->readyweapon == wp_gauntlets) + else if ((player->readyweapon == wp_gauntlets) || (player->readyweapon == wp_staff)) { player->pendingweapon = player->readyweapon; @@ -707,19 +707,19 @@ void P_PlayerThink(player_t *player) BorderTopRefresh = true; } } - if(player->damagecount) + if (player->damagecount) { player->damagecount--; } - if(player->bonuscount) + if (player->bonuscount) { player->bonuscount--; } // Colormaps - if(player->powers[pw_invulnerability]) + if (player->powers[pw_invulnerability]) { - if(player->powers[pw_invulnerability] > BLINKTHRESHOLD - || (player->powers[pw_invulnerability]&8)) + if (player->powers[pw_invulnerability] > BLINKTHRESHOLD + || (player->powers[pw_invulnerability] & 8)) { player->fixedcolormap = INVERSECOLORMAP; } @@ -728,11 +728,11 @@ void P_PlayerThink(player_t *player) player->fixedcolormap = 0; } } - else if(player->powers[pw_infrared]) + else if (player->powers[pw_infrared]) { if (player->powers[pw_infrared] <= BLINKTHRESHOLD) { - if(player->powers[pw_infrared]&8) + if (player->powers[pw_infrared] & 8) { player->fixedcolormap = 0; } @@ -741,12 +741,12 @@ void P_PlayerThink(player_t *player) player->fixedcolormap = 1; } } - else if(!(leveltime&16) && player == &players[consoleplayer]) + else if (!(leveltime & 16) && player == &players[consoleplayer]) { - if(newtorch) + if (newtorch) { - if(player->fixedcolormap+newtorchdelta > 7 - || player->fixedcolormap+newtorchdelta < 1 + if (player->fixedcolormap + newtorchdelta > 7 + || player->fixedcolormap + newtorchdelta < 1 || newtorch == player->fixedcolormap) { newtorch = 0; @@ -758,9 +758,9 @@ void P_PlayerThink(player_t *player) } else { - newtorch = (M_Random()&7)+1; + newtorch = (M_Random() & 7) + 1; newtorchdelta = (newtorch == player->fixedcolormap) ? - 0 : ((newtorch > player->fixedcolormap) ? 1 : -1); + 0 : ((newtorch > player->fixedcolormap) ? 1 : -1); } } } @@ -784,19 +784,19 @@ void P_ArtiTele(player_t *player) fixed_t destY; angle_t destAngle; - if(deathmatch) + if (deathmatch) { - selections = deathmatch_p-deathmatchstarts; - i = P_Random()%selections; - destX = deathmatchstarts[i].x<mo, destX, destY, destAngle); S_StartSound(NULL, sfx_wpnup); // Full volume laugh @@ -813,21 +813,21 @@ void P_PlayerNextArtifact(player_t *player) extern int inv_ptr; extern int curpos; - if(player == &players[consoleplayer]) + if (player == &players[consoleplayer]) { inv_ptr--; - if(inv_ptr < 6) + if (inv_ptr < 6) { curpos--; - if(curpos < 0) + if (curpos < 0) { curpos = 0; } } - if(inv_ptr < 0) + if (inv_ptr < 0) { - inv_ptr = player->inventorySlotNum-1; - if(inv_ptr < 6) + inv_ptr = player->inventorySlotNum - 1; + if (inv_ptr < 6) { curpos = inv_ptr; } @@ -854,31 +854,31 @@ void P_PlayerRemoveArtifact(player_t *player, int slot) extern int curpos; player->artifactCount--; - if(!(--player->inventory[slot].count)) + if (!(--player->inventory[slot].count)) { // Used last of a type - compact the artifact list player->readyArtifact = arti_none; player->inventory[slot].type = arti_none; - for(i = slot+1; i < player->inventorySlotNum; i++) + for (i = slot + 1; i < player->inventorySlotNum; i++) { - player->inventory[i-1] = player->inventory[i]; + player->inventory[i - 1] = player->inventory[i]; } player->inventorySlotNum--; - if(player == &players[consoleplayer]) + if (player == &players[consoleplayer]) { // Set position markers and get next readyArtifact inv_ptr--; - if(inv_ptr < 6) + if (inv_ptr < 6) { curpos--; - if(curpos < 0) + if (curpos < 0) { curpos = 0; } } - if(inv_ptr >= player->inventorySlotNum) + if (inv_ptr >= player->inventorySlotNum) { - inv_ptr = player->inventorySlotNum-1; + inv_ptr = player->inventorySlotNum - 1; } - if(inv_ptr < 0) + if (inv_ptr < 0) { inv_ptr = 0; } @@ -898,14 +898,14 @@ void P_PlayerUseArtifact(player_t *player, artitype_t arti) { int i; - for(i = 0; i < player->inventorySlotNum; i++) + for (i = 0; i < player->inventorySlotNum; i++) { - if(player->inventory[i].type == arti) + if (player->inventory[i].type == arti) { // Found match - try to use - if(P_UseArtifact(player, arti)) + if (P_UseArtifact(player, arti)) { // Artifact was used - remove it from inventory P_PlayerRemoveArtifact(player, i); - if(player == &players[consoleplayer]) + if (player == &players[consoleplayer]) { S_StartSound(NULL, sfx_artiuse); ArtifactFlash = 4; @@ -933,36 +933,36 @@ boolean P_UseArtifact(player_t *player, artitype_t arti) mobj_t *mo; angle_t angle; - switch(arti) + switch (arti) { case arti_invulnerability: - if(!P_GivePower(player, pw_invulnerability)) + if (!P_GivePower(player, pw_invulnerability)) { return(false); } break; case arti_invisibility: - if(!P_GivePower(player, pw_invisibility)) + if (!P_GivePower(player, pw_invisibility)) { return(false); } break; case arti_health: - if(!P_GiveBody(player, 25)) + if (!P_GiveBody(player, 25)) { return(false); } break; case arti_superhealth: - if(!P_GiveBody(player, 100)) + if (!P_GiveBody(player, 100)) { return(false); } break; case arti_tomeofpower: - if(player->chickenTics) + if (player->chickenTics) { // Attempt to undo chicken - if(P_UndoPlayerChicken(player) == false) + if (P_UndoPlayerChicken(player) == false) { // Failed P_DamageMobj(player->mo, NULL, NULL, 10000); } @@ -974,43 +974,43 @@ boolean P_UseArtifact(player_t *player, artitype_t arti) } else { - if(!P_GivePower(player, pw_weaponlevel2)) + if (!P_GivePower(player, pw_weaponlevel2)) { return(false); } - if(player->readyweapon == wp_staff) + if (player->readyweapon == wp_staff) { P_SetPsprite(player, ps_weapon, S_STAFFREADY2_1); } - else if(player->readyweapon == wp_gauntlets) + else if (player->readyweapon == wp_gauntlets) { P_SetPsprite(player, ps_weapon, S_GAUNTLETREADY2_1); } } break; case arti_torch: - if(!P_GivePower(player, pw_infrared)) + if (!P_GivePower(player, pw_infrared)) { return(false); } break; case arti_firebomb: - angle = player->mo->angle>>ANGLETOFINESHIFT; - mo = P_SpawnMobj(player->mo->x+24*finecosine[angle], - player->mo->y+24*finesine[angle], player->mo->z - 15*FRACUNIT* - (player->mo->flags2&MF2_FEETARECLIPPED != 0), MT_FIREBOMB); + angle = player->mo->angle >> ANGLETOFINESHIFT; + mo = P_SpawnMobj(player->mo->x + 24 * finecosine[angle], + player->mo->y + 24 * finesine[angle], player->mo->z - 15 * FRACUNIT * + (player->mo->flags2 & MF2_FEETARECLIPPED != 0), MT_FIREBOMB); mo->target = player->mo; break; case arti_egg: mo = player->mo; P_SpawnPlayerMissile(mo, MT_EGGFX); - P_SPMAngle(mo, MT_EGGFX, mo->angle-(ANG45/6)); - P_SPMAngle(mo, MT_EGGFX, mo->angle+(ANG45/6)); - P_SPMAngle(mo, MT_EGGFX, mo->angle-(ANG45/3)); - P_SPMAngle(mo, MT_EGGFX, mo->angle+(ANG45/3)); + P_SPMAngle(mo, MT_EGGFX, mo->angle - (ANG45 / 6)); + P_SPMAngle(mo, MT_EGGFX, mo->angle + (ANG45 / 6)); + P_SPMAngle(mo, MT_EGGFX, mo->angle - (ANG45 / 3)); + P_SPMAngle(mo, MT_EGGFX, mo->angle + (ANG45 / 3)); break; case arti_fly: - if(!P_GivePower(player, pw_flight)) + if (!P_GivePower(player, pw_flight)) { return(false); } diff --git a/R_BSP.C b/R_BSP.C index 8a52720..f182d1d 100644 --- a/R_BSP.C +++ b/R_BSP.C @@ -3,10 +3,10 @@ #include "DoomDef.h" #include "R_local.h" -seg_t *curline; -side_t *sidedef; -line_t *linedef; -sector_t *frontsector, *backsector; +seg_t *curline; +side_t *sidedef; +line_t *linedef; +sector_t *frontsector, *backsector; drawseg_t drawsegs[MAXDRAWSEGS], *ds_p; @@ -49,43 +49,43 @@ cliprange_t solidsegs[MAXSEGS], *newend; // newend is one past the last valid se void R_ClipSolidWallSegment (int first, int last) { - cliprange_t *next, *start; + cliprange_t *next, *start; -// find the first range that touches the range (adjacent pixels are touching) + // find the first range that touches the range (adjacent pixels are touching) start = solidsegs; - while (start->last < first-1) + while (start->last < first - 1) start++; if (first < start->first) { - if (last < start->first-1) + if (last < start->first - 1) { // post is entirely visible (above start), so insert a new clippost R_StoreWallRange (first, last); next = newend; newend++; while (next != start) { - *next = *(next-1); + *next = *(next - 1); next--; } next->first = first; next->last = last; return; } - - // there is a fragment above *start + + // there is a fragment above *start R_StoreWallRange (first, start->first - 1); start->first = first; // adjust the clip size } - + if (last <= start->last) return; // bottom contained in start - + next = start; - while (last >= (next+1)->first-1) + while (last >= (next + 1)->first - 1) { // there is a fragment between two posts - R_StoreWallRange (next->last + 1, (next+1)->first - 1); + R_StoreWallRange (next->last + 1, (next + 1)->first - 1); next++; if (last <= next->last) { // bottom is contained in next @@ -93,12 +93,12 @@ void R_ClipSolidWallSegment (int first, int last) goto crunch; } } - + // there is a fragment after *next R_StoreWallRange (next->last + 1, last); start->last = last; // adjust the clip size - - + + // remove start+1 to next from the clip list, // because start now covers their area crunch: @@ -107,7 +107,7 @@ crunch: while (next++ != newend) // remove a post *++start = *next; - newend = start+1; + newend = start + 1; } /* @@ -121,37 +121,37 @@ crunch: void R_ClipPassWallSegment (int first, int last) { - cliprange_t *start; + cliprange_t *start; -// find the first range that touches the range (adjacent pixels are touching) + // find the first range that touches the range (adjacent pixels are touching) start = solidsegs; - while (start->last < first-1) + while (start->last < first - 1) start++; if (first < start->first) { - if (last < start->first-1) + if (last < start->first - 1) { // post is entirely visible (above start) R_StoreWallRange (first, last); return; } - - // there is a fragment above *start + + // there is a fragment above *start R_StoreWallRange (first, start->first - 1); } - + if (last <= start->last) return; // bottom contained in start - - while (last >= (start+1)->first-1) + + while (last >= (start + 1)->first - 1) { // there is a fragment between two posts - R_StoreWallRange (start->last + 1, (start+1)->first - 1); + R_StoreWallRange (start->last + 1, (start + 1)->first - 1); start++; if (last <= start->last) return; } - + // there is a fragment after *next R_StoreWallRange (start->last + 1, last); } @@ -172,7 +172,7 @@ void R_ClearClipSegs (void) solidsegs[0].last = -1; solidsegs[1].first = viewwidth; solidsegs[1].last = 0x7fffffff; - newend = solidsegs+2; + newend = solidsegs + 2; } @@ -192,20 +192,20 @@ void R_AddLine (seg_t *line) { int x1, x2; angle_t angle1, angle2, span, tspan; - + #ifdef __NeXT__ RD_DrawLineCheck (line); #endif curline = line; -// OPTIMIZE: quickly reject orthogonal back sides + // OPTIMIZE: quickly reject orthogonal back sides angle1 = R_PointToAngle (line->v1->x, line->v1->y); angle2 = R_PointToAngle (line->v2->x, line->v2->y); -// -// clip to view edges -// OPTIMIZE: make constant out of 2*clipangle (FIELDOFVIEW) + // + // clip to view edges + // OPTIMIZE: make constant out of 2*clipangle (FIELDOFVIEW) span = angle1 - angle2; if (span >= ANG180) return; // back side @@ -213,60 +213,60 @@ void R_AddLine (seg_t *line) rw_angle1 = angle1; // global angle needed by segcalc angle1 -= viewangle; angle2 -= viewangle; - + tspan = angle1 + clipangle; - if (tspan > 2*clipangle) + if (tspan > 2 * clipangle) { - tspan -= 2*clipangle; + tspan -= 2 * clipangle; if (tspan >= span) return; // totally off the left edge angle1 = clipangle; } tspan = clipangle - angle2; - if (tspan > 2*clipangle) + if (tspan > 2 * clipangle) { - tspan -= 2*clipangle; + tspan -= 2 * clipangle; if (tspan >= span) return; // totally off the left edge angle2 = -clipangle; } -// -// the seg is in the view range, but not necessarily visible -// - angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; - angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; + // + // the seg is in the view range, but not necessarily visible + // + angle1 = (angle1 + ANG90) >> ANGLETOFINESHIFT; + angle2 = (angle2 + ANG90) >> ANGLETOFINESHIFT; x1 = viewangletox[angle1]; x2 = viewangletox[angle2]; if (x1 == x2) return; // does not cross a pixel - + backsector = line->backsector; if (!backsector) goto clipsolid; // single sided line - + if (backsector->ceilingheight <= frontsector->floorheight - || backsector->floorheight >= frontsector->ceilingheight) + || backsector->floorheight >= frontsector->ceilingheight) goto clipsolid; // closed door - + if (backsector->ceilingheight != frontsector->ceilingheight - || backsector->floorheight != frontsector->floorheight) + || backsector->floorheight != frontsector->floorheight) goto clippass; // window - + // reject empty lines used for triggers and special events if (backsector->ceilingpic == frontsector->ceilingpic - && backsector->floorpic == frontsector->floorpic - && backsector->lightlevel == frontsector->lightlevel - && curline->sidedef->midtexture == 0) - return; - + && backsector->floorpic == frontsector->floorpic + && backsector->lightlevel == frontsector->lightlevel + && curline->sidedef->midtexture == 0) + return; + clippass: - R_ClipPassWallSegment (x1, x2-1); + R_ClipPassWallSegment (x1, x2 - 1); return; - + clipsolid: - R_ClipSolidWallSegment (x1, x2-1); + R_ClipSolidWallSegment (x1, x2 - 1); } //============================================================================ @@ -301,32 +301,32 @@ boolean R_CheckBBox (fixed_t *bspcoord) int boxx, boxy, boxpos; fixed_t x1, y1, x2, y2; angle_t angle1, angle2, span, tspan; - cliprange_t *start; + cliprange_t *start; int sx1, sx2; - + #ifdef __NeXT__ RD_DrawBBox (bspcoord); #endif -// find the corners of the box that define the edges from current viewpoint + // find the corners of the box that define the edges from current viewpoint 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; + + boxpos = (boxy << 2) + boxx; if (boxpos == 5) return true; - + x1 = bspcoord[checkcoord[boxpos][0]]; y1 = bspcoord[checkcoord[boxpos][1]]; x2 = bspcoord[checkcoord[boxpos][2]]; @@ -334,45 +334,45 @@ boolean R_CheckBBox (fixed_t *bspcoord) #ifdef __NeXT__ -// RD_DisplayLine (x1, y1, x2, y2, 0.1); + // RD_DisplayLine (x1, y1, x2, y2, 0.1); #endif - + // // check clip list for an open space // angle1 = R_PointToAngle (x1, y1) - viewangle; angle2 = R_PointToAngle (x2, y2) - viewangle; - + span = angle1 - angle2; if (span >= ANG180) return true; // sitting on a line tspan = angle1 + clipangle; - if (tspan > 2*clipangle) + if (tspan > 2 * clipangle) { - tspan -= 2*clipangle; + tspan -= 2 * clipangle; if (tspan >= span) return false; // totally off the left edge angle1 = clipangle; } tspan = clipangle - angle2; - if (tspan > 2*clipangle) + if (tspan > 2 * clipangle) { - tspan -= 2*clipangle; + tspan -= 2 * clipangle; if (tspan >= span) return false; // totally off the left edge angle2 = -clipangle; } -// find the first clippost that touches the source post (adjacent pixels are touching) - angle1 = (angle1+ANG90)>>ANGLETOFINESHIFT; - angle2 = (angle2+ANG90)>>ANGLETOFINESHIFT; + // find the first clippost that touches the source post (adjacent pixels are touching) + angle1 = (angle1 + ANG90) >> ANGLETOFINESHIFT; + angle2 = (angle2 + ANG90) >> ANGLETOFINESHIFT; sx1 = viewangletox[angle1]; sx2 = viewangletox[angle2]; if (sx1 == sx2) return false; // does not cross a pixel sx2--; - + start = solidsegs; while (start->last < sx2) start++; @@ -395,12 +395,12 @@ boolean R_CheckBBox (fixed_t *bspcoord) void R_Subsector (int num) { int count; - seg_t *line; - subsector_t *sub; - + seg_t *line; + subsector_t *sub; + #ifdef RANGECHECK - if (num>=numsubsectors) - I_Error ("R_Subsector: ss %i with numss = %i",num, numsubsectors); + if (num >= numsubsectors) + I_Error ("R_Subsector: ss %i with numss = %i", num, numsubsectors); #endif sscount++; @@ -411,18 +411,18 @@ void R_Subsector (int num) if (frontsector->floorheight < viewz) floorplane = R_FindPlane (frontsector->floorheight, - frontsector->floorpic, frontsector->lightlevel, - frontsector->special); + frontsector->floorpic, frontsector->lightlevel, + frontsector->special); else floorplane = NULL; - if (frontsector->ceilingheight > viewz - || frontsector->ceilingpic == skyflatnum) + if (frontsector->ceilingheight > viewz + || frontsector->ceilingpic == skyflatnum) ceilingplane = R_FindPlane (frontsector->ceilingheight, - frontsector->ceilingpic, frontsector->lightlevel, 0); + frontsector->ceilingpic, frontsector->lightlevel, 0); else ceilingplane = NULL; - - R_AddSprites (frontsector); + + R_AddSprites (frontsector); while (count--) { @@ -442,33 +442,33 @@ void R_Subsector (int num) void R_RenderBSPNode (int bspnum) { - node_t *bsp; + node_t *bsp; int side; if (bspnum & NF_SUBSECTOR) { - if (bspnum == -1) + if (bspnum == -1) R_Subsector (0); else - R_Subsector (bspnum&(~NF_SUBSECTOR)); + R_Subsector (bspnum & (~NF_SUBSECTOR)); return; } - + bsp = &nodes[bspnum]; - + #ifdef __NeXT__ RD_DrawNodeLine (bsp); #endif - -// -// decide which side the view point is on -// + + // + // decide which side the view point is on + // side = R_PointOnSide (viewx, viewy, bsp); R_RenderBSPNode (bsp->children[side]); // recursively divide front space - - if (R_CheckBBox (bsp->bbox[side^1])) // possibly divide back space - R_RenderBSPNode (bsp->children[side^1]); + + if (R_CheckBBox (bsp->bbox[side ^ 1])) // possibly divide back space + R_RenderBSPNode (bsp->children[side ^ 1]); } diff --git a/R_DATA.C b/R_DATA.C index 3e63496..6ae5516 100644 --- a/R_DATA.C +++ b/R_DATA.C @@ -34,22 +34,22 @@ int firstpatch, lastpatch, numpatches; int firstspritelump, lastspritelump, numspritelumps; int numtextures; -texture_t **textures; -int *texturewidthmask; -fixed_t *textureheight; // needed for texture pegging -int *texturecompositesize; -short **texturecolumnlump; -unsigned short **texturecolumnofs; -byte **texturecomposite; - -int *flattranslation; // for global animation -int *texturetranslation; // for global animation - -fixed_t *spritewidth; // needed for pre rendering -fixed_t *spriteoffset; -fixed_t *spritetopoffset; - -lighttable_t *colormaps; +texture_t **textures; +int *texturewidthmask; +fixed_t *textureheight; // needed for texture pegging +int *texturecompositesize; +short **texturecolumnlump; +unsigned short **texturecolumnofs; +byte **texturecomposite; + +int *flattranslation; // for global animation +int *texturetranslation; // for global animation + +fixed_t *spritewidth; // needed for pre rendering +fixed_t *spriteoffset; +fixed_t *spritetopoffset; + +lighttable_t *colormaps; extern int faststart; // FS @@ -80,10 +80,10 @@ will have new column_ts generated. void R_DrawColumnInCache (column_t *patch, byte *cache, int originy, int cacheheight) { int count, position; - byte *source, *dest; - + byte *source, *dest; + dest = (byte *)cache + 3; - + while (patch->topdelta != 0xff) { source = (byte *)patch + 3; @@ -98,8 +98,8 @@ void R_DrawColumnInCache (column_t *patch, byte *cache, int originy, int cachehe count = cacheheight - position; if (count > 0) memcpy (cache + position, source, count); - - patch = (column_t *)( (byte *)patch + patch->length + 4); + + patch = (column_t *)((byte *)patch + patch->length + 4); } } @@ -114,53 +114,53 @@ void R_DrawColumnInCache (column_t *patch, byte *cache, int originy, int cachehe void R_GenerateComposite (int texnum) { - byte *block; - texture_t *texture; - texpatch_t *patch; - patch_t *realpatch; + byte *block; + texture_t *texture; + texpatch_t *patch; + patch_t *realpatch; int x, x1, x2; int i; - column_t *patchcol; - short *collump; + column_t *patchcol; + short *collump; unsigned short *colofs; - + texture = textures[texnum]; - block = Z_Malloc (texturecompositesize[texnum], PU_STATIC, - &texturecomposite[texnum]); + block = Z_Malloc (texturecompositesize[texnum], PU_STATIC, + &texturecomposite[texnum]); collump = texturecolumnlump[texnum]; colofs = texturecolumnofs[texnum]; - -// -// composite the columns together -// + + // + // composite the columns together + // patch = texture->patches; - - for (i=0 , patch = texture->patches; ipatchcount ; i++, patch++) + + for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { realpatch = W_CacheLumpNum (patch->patch, PU_CACHE); x1 = patch->originx; x2 = x1 + SHORT(realpatch->width); - if (x1<0) + if (x1 < 0) x = 0; else x = x1; if (x2 > texture->width) x2 = texture->width; - for ( ; x= 0) continue; // column does not have multiple patches - patchcol = (column_t *)((byte *)realpatch + - LONG(realpatch->columnofs[x-x1])); + patchcol = (column_t *)((byte *)realpatch + + LONG(realpatch->columnofs[x - x1])); R_DrawColumnInCache (patchcol, block + colofs[x], patch->originy, - texture->height); + texture->height); } - + } -// now that the texture has been built, it is purgable + // now that the texture has been built, it is purgable Z_ChangeTag (block, PU_CACHE); } @@ -175,32 +175,32 @@ void R_GenerateComposite (int texnum) void R_GenerateLookup (int texnum) { - texture_t *texture; - byte *patchcount; // [texture->width] - texpatch_t *patch; - patch_t *realpatch; + texture_t *texture; + byte *patchcount; // [texture->width] + texpatch_t *patch; + patch_t *realpatch; int x, x1, x2; int i; - short *collump; - unsigned short *colofs; - + short *collump; + unsigned short *colofs; + texture = textures[texnum]; texturecomposite[texnum] = 0; // composited not created yet texturecompositesize[texnum] = 0; collump = texturecolumnlump[texnum]; colofs = texturecolumnofs[texnum]; - -// -// count the number of columns that are covered by more than one patch -// fill in the lump / offset, so columns with only a single patch are -// all done -// + + // + // count the number of columns that are covered by more than one patch + // fill in the lump / offset, so columns with only a single patch are + // all done + // patchcount = (byte *)alloca (texture->width); memset (patchcount, 0, texture->width); patch = texture->patches; - - for (i=0 , patch = texture->patches; ipatchcount ; i++, patch++) + + for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { realpatch = W_CacheLumpNum (patch->patch, PU_CACHE); x1 = patch->originx; @@ -211,31 +211,31 @@ void R_GenerateLookup (int texnum) x = x1; if (x2 > texture->width) x2 = texture->width; - for ( ; xpatch; - colofs[x] = LONG(realpatch->columnofs[x-x1])+3; + colofs[x] = LONG(realpatch->columnofs[x - x1]) + 3; } } - - for (x=0 ; xwidth ; x++) + + for (x = 0; x < texture->width; x++) { if (!patchcount[x]) { printf ("R_GenerateLookup: column without a patch (%s)\n", texture->name); return; } -// I_Error ("R_GenerateLookup: column without a patch"); + // I_Error ("R_GenerateLookup: column without a patch"); if (patchcount[x] > 1) { collump[x] = -1; // use the cached block colofs[x] = texturecompositesize[texnum]; - if (texturecompositesize[texnum] > 0x10000-texture->height) - I_Error ("R_GenerateLookup: texture %i is >64k",texnum); + if (texturecompositesize[texnum] > 0x10000 - texture->height) + I_Error ("R_GenerateLookup: texture %i is >64k", texnum); texturecompositesize[texnum] += texture->height; } - } + } } @@ -250,12 +250,12 @@ void R_GenerateLookup (int texnum) byte *R_GetColumn (int tex, int col) { int lump, ofs; - + col &= texturewidthmask[tex]; lump = texturecolumnlump[tex][col]; ofs = texturecolumnofs[tex][col]; if (lump > 0) - return (byte *)W_CacheLumpNum(lump,PU_CACHE)+ofs; + return (byte *)W_CacheLumpNum(lump, PU_CACHE) + ofs; if (!texturecomposite[tex]) R_GenerateComposite (tex); return texturecomposite[tex] + ofs; @@ -274,43 +274,43 @@ byte *R_GetColumn (int tex, int col) void R_InitTextures (void) { - maptexture_t *mtexture; - texture_t *texture; - mappatch_t *mpatch; - texpatch_t *patch; - int i,j; - int *maptex, *maptex2, *maptex1; + maptexture_t *mtexture; + texture_t *texture; + mappatch_t *mpatch; + texpatch_t *patch; + int i, j; + int *maptex, *maptex2, *maptex1; char name[9], *names, *name_p; - int *patchlookup; + int *patchlookup; int totalwidth; int nummappatches; int offset, maxoff, maxoff2; int numtextures1, numtextures2; - int *directory; - int temp1,temp2,temp3; // FS: Doom shit + int *directory; + int temp1, temp2, temp3; // FS: Doom shit // // load the patch names from pnames.lmp // 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 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, + 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); @@ -387,22 +387,22 @@ void R_InitTextures (void) memcpy (texture->name, mtexture->name, sizeof(texture->name)); mpatch = &mtexture->patches[0]; patch = &texture->patches[0]; - for (j=0 ; jpatchcount ; j++, mpatch++, patch++) + for (j = 0; j < texture->patchcount; j++, mpatch++, patch++) { patch->originx = SHORT(mpatch->originx); patch->originy = SHORT(mpatch->originy); patch->patch = patchlookup[SHORT(mpatch->patch)]; if (patch->patch == -1) - I_Error ("R_InitTextures: Missing patch in texture %s",texture->name); - } - texturecolumnlump[i] = Z_Malloc (texture->width*2, PU_STATIC,0); - texturecolumnofs[i] = Z_Malloc (texture->width*2, PU_STATIC,0); + I_Error ("R_InitTextures: Missing patch in texture %s", texture->name); + } + 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<width) + j <<= 1; + texturewidthmask[i] = j - 1; + textureheight[i] = texture->height << FRACBITS; + totalwidth += texture->width; } @@ -410,20 +410,20 @@ void R_InitTextures (void) if (maptex2) Z_Free (maptex2); -// -// precalculate whatever possible -// - for(i = 0; i < numtextures; i++) + // + // precalculate whatever possible + // + for (i = 0; i < numtextures; i++) { R_GenerateLookup(i); CheckAbortStartup(); } -// -// translation table for global animation -// - texturetranslation = Z_Malloc ((numtextures+1)*4, PU_STATIC, 0); - for (i=0 ; iwidth)<leftoffset)<topoffset)<width) << FRACBITS; + spriteoffset[i] = SHORT(patch->leftoffset) << FRACBITS; + spritetopoffset[i] = SHORT(patch->topoffset) << FRACBITS; } } @@ -502,15 +502,15 @@ void R_InitSpriteLumps (void) void R_InitColormaps (void) { int lump, length; -// -// load in the light tables -// 256 byte align tables -// + // + // load in the light tables + // 256 byte align tables + // 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); + colormaps = (byte *)(((int)colormaps + 255) & ~0xff); + W_ReadLump (lump, colormaps); } @@ -559,8 +559,8 @@ int R_FlatNumForName (char *name) if (i == -1) { namet[8] = 0; - memcpy (namet, name,8); - I_Error ("R_FlatNumForName: %s not found",namet); + memcpy (namet, name, 8); + I_Error ("R_FlatNumForName: %s not found", namet); } return i - firstflat; } @@ -577,14 +577,14 @@ int R_FlatNumForName (char *name) int R_CheckTextureNumForName (char *name) { int i; - + if (name[0] == '-') // no texture marker return 0; - - for (i=0 ; iname, name, 8) ) + + for (i = 0; i < numtextures; i++) + if (!strncasecmp (textures[i]->name, name, 8)) return i; - + return -1; } @@ -601,11 +601,11 @@ int R_TextureNumForName (char *name) { int i; //char namet[9]; - + i = R_CheckTextureNumForName (name); - if (i==-1) - I_Error ("R_TextureNumForName: %s not found",name); - + if (i == -1) + I_Error ("R_TextureNumForName: %s not found", name); + return i; } @@ -623,91 +623,91 @@ int flatmemory, texturememory, spritememory; void R_PrecacheLevel (void) { - char *flatpresent; - char *texturepresent; - char *spritepresent; - int i,j,k, lump; - texture_t *texture; - thinker_t *th; - spriteframe_t *sf; + char *flatpresent; + char *texturepresent; + char *spritepresent; + int i, j, k, lump; + texture_t *texture; + thinker_t *th; + spriteframe_t *sf; if (demoplayback) return; - -// -// precache flats -// + + // + // precache flats + // flatpresent = alloca(numflats); - memset (flatpresent,0,numflats); - for (i=0 ; ipatchcount ; j++) + for (j = 0; j < texture->patchcount; j++) { lump = texture->patches[j].patch; texturememory += lumpinfo[lump].size; - W_CacheLumpNum(lump , PU_CACHE); + W_CacheLumpNum(lump, PU_CACHE); } } - -// -// precache sprites -// + + // + // precache sprites + // spritepresent = alloca(numsprites); - memset (spritepresent,0, numsprites); - - for (th = thinkercap.next ; th != &thinkercap ; th=th->next) + memset (spritepresent, 0, numsprites); + + for (th = thinkercap.next; th != &thinkercap; th = th->next) { if (th->function == P_MobjThinker) spritepresent[((mobj_t *)th)->sprite] = 1; } - + spritememory = 0; - for (i=0 ; ilump[k]; spritememory += lumpinfo[lump].size; - W_CacheLumpNum(lump , PU_CACHE); + W_CacheLumpNum(lump, PU_CACHE); } } } diff --git a/R_DRAW.C b/R_DRAW.C index 82f1bad..b224034 100644 --- a/R_DRAW.C +++ b/R_DRAW.C @@ -27,13 +27,13 @@ byte *tinttable; // used for translucent sprites ================== */ -lighttable_t *dc_colormap; +lighttable_t *dc_colormap; int dc_x; int dc_yl; int dc_yh; fixed_t dc_iscale; fixed_t dc_texturemid; -byte *dc_source; // first pixel in a column (possibly virtual) +byte *dc_source; // first pixel in a column (possibly virtual) int dccount; // just for profiling @@ -43,26 +43,26 @@ int dccount; // just for profiling void R_DrawColumn (void) { int count; - byte *dest; - fixed_t frac, fracstep; + byte *dest; + fixed_t frac, 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]; - + dest = ylookup[dc_yl] + columnofs[dc_x]; + fracstep = dc_iscale; - frac = dc_texturemid + (dc_yl-centery)*fracstep; + frac = dc_texturemid + (dc_yl - centery) * fracstep; do { - *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; + *dest = dc_colormap[dc_source[(frac >> FRACBITS) & 127]]; dest += SCREENWIDTH; frac += fracstep; } while (count--); @@ -74,27 +74,27 @@ void R_DrawColumn (void) void R_DrawColumnLow (void) { int count; - byte *dest; - fixed_t frac, fracstep; + byte *dest; + fixed_t frac, 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); -// dccount++; + // dccount++; #endif - dest = ylookup[dc_yl] + columnofs[dc_x]; - + dest = ylookup[dc_yl] + columnofs[dc_x]; + fracstep = dc_iscale; - frac = dc_texturemid + (dc_yl-centery)*fracstep; + frac = dc_texturemid + (dc_yl - centery) * fracstep; do { - *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; + *dest = dc_colormap[dc_source[(frac >> FRACBITS) & 127]]; dest += SCREENWIDTH; frac += fracstep; } while (count--); @@ -112,18 +112,18 @@ int fuzzpos = 0; void R_DrawFuzzColumn (void) { int count; - byte *dest; - fixed_t frac, fracstep; + byte *dest; + fixed_t frac, fracstep; if (!dc_yl) dc_yl = 1; - if (dc_yh == viewheight-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) I_Error ("R_DrawFuzzColumn: %i to %i at %i", dc_yl, dc_yh, dc_x); @@ -132,22 +132,22 @@ void R_DrawFuzzColumn (void) dest = ylookup[dc_yl] + columnofs[dc_x]; fracstep = dc_iscale; - frac = dc_texturemid + (dc_yl-centery)*fracstep; + frac = dc_texturemid + (dc_yl - centery) * fracstep; -// OLD FUZZY INVISO SPRITE STUFF -/* do - { - *dest = colormaps[6*256+dest[fuzzoffset[fuzzpos]]]; - if (++fuzzpos == FUZZTABLE) - fuzzpos = 0; - dest += SCREENWIDTH; - frac += fracstep; - } while (count--); -*/ + // OLD FUZZY INVISO SPRITE STUFF + /* do + { + *dest = colormaps[6*256+dest[fuzzoffset[fuzzpos]]]; + if (++fuzzpos == FUZZTABLE) + fuzzpos = 0; + dest += SCREENWIDTH; + frac += fracstep; + } while (count--); + */ do { - *dest = tinttable[((*dest)<<8)+dc_colormap[dc_source[(frac>>FRACBITS)&127]]]; + *dest = tinttable[((*dest) << 8) + dc_colormap[dc_source[(frac >> FRACBITS) & 127]]]; //*dest = dest[SCREENWIDTH*10+5]; @@ -156,7 +156,7 @@ void R_DrawFuzzColumn (void) // *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; dest += SCREENWIDTH; frac += fracstep; - } while(count--); + } while (count--); } /* @@ -173,26 +173,26 @@ byte *translationtables; void R_DrawTranslatedColumn (void) { int count; - byte *dest; - fixed_t frac, fracstep; + byte *dest; + fixed_t frac, 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; + frac = dc_texturemid + (dc_yl - centery) * fracstep; do { - *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; + *dest = dc_colormap[dc_translation[dc_source[frac >> FRACBITS]]]; dest += SCREENWIDTH; frac += fracstep; } while (count--); @@ -201,27 +201,27 @@ void R_DrawTranslatedColumn (void) void R_DrawTranslatedFuzzColumn (void) { int count; - byte *dest; - fixed_t frac, fracstep; + byte *dest; + fixed_t frac, 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; + frac = dc_texturemid + (dc_yl - centery) * fracstep; do { - *dest = tinttable[((*dest)<<8) - +dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]]; + *dest = tinttable[((*dest) << 8) + + dc_colormap[dc_translation[dc_source[frac >> FRACBITS]]]]; dest += SCREENWIDTH; frac += fracstep; } while (count--); @@ -241,22 +241,22 @@ void R_InitTranslationTables (void) tinttable = W_CacheLumpName("TINTTAB", PU_STATIC); // Allocate translation tables - translationtables = Z_Malloc(256*3+255, PU_STATIC, 0); - translationtables = (byte *)(( (int)translationtables + 255 )& ~255); + translationtables = Z_Malloc(256 * 3 + 255, PU_STATIC, 0); + translationtables = (byte *)(((int)translationtables + 255) & ~255); // Fill out the translation tables - for(i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { - if(i >= 225 && i <= 240) + if (i >= 225 && i <= 240) { - translationtables[i] = 114+(i-225); // yellow - translationtables[i+256] = 145+(i-225); // red - translationtables[i+512] = 190+(i-225); // blue + translationtables[i] = 114 + (i - 225); // yellow + translationtables[i + 256] = 145 + (i - 225); // red + translationtables[i + 512] = 190 + (i - 225); // blue } else { - translationtables[i] = translationtables[i+256] - = translationtables[i+512] = i; + translationtables[i] = translationtables[i + 256] + = translationtables[i + 512] = i; } } } @@ -272,12 +272,12 @@ void R_InitTranslationTables (void) int ds_y; int ds_x1; int ds_x2; -lighttable_t *ds_colormap; +lighttable_t *ds_colormap; fixed_t ds_xfrac; fixed_t ds_yfrac; fixed_t ds_xstep; fixed_t ds_ystep; -byte *ds_source; // start of a 64*64 tile image +byte *ds_source; // start of a 64*64 tile image int dscount; // just for profiling @@ -287,24 +287,24 @@ int dscount; // just for profiling void R_DrawSpan (void) { fixed_t xfrac, yfrac; - byte *dest; + byte *dest; int count, spot; - + #ifdef RANGECHECK - if (ds_x2 < ds_x1 || ds_x1<0 || ds_x2>=SCREENWIDTH - || (unsigned)ds_y>SCREENHEIGHT) - I_Error ("R_DrawSpan: %i to %i at %i",ds_x1,ds_x2,ds_y); -// dscount++; + if (ds_x2 < ds_x1 || ds_x1<0 || ds_x2 >= SCREENWIDTH + || (unsigned)ds_y>SCREENHEIGHT) + I_Error ("R_DrawSpan: %i to %i at %i", ds_x1, ds_x2, ds_y); + // dscount++; #endif - + xfrac = ds_xfrac; yfrac = ds_yfrac; - - dest = ylookup[ds_y] + columnofs[ds_x1]; + + dest = ylookup[ds_y] + columnofs[ds_x1]; count = ds_x2 - ds_x1; do { - spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63); + spot = ((yfrac >> (16 - 6)) & (63 * 64)) + ((xfrac >> 16) & 63); *dest++ = ds_colormap[ds_source[spot]]; xfrac += ds_xstep; yfrac += ds_ystep; @@ -317,24 +317,24 @@ void R_DrawSpan (void) void R_DrawSpanLow (void) { fixed_t xfrac, yfrac; - byte *dest; + byte *dest; int count, spot; - + #ifdef RANGECHECK - if (ds_x2 < ds_x1 || ds_x1<0 || ds_x2>=SCREENWIDTH - || (unsigned)ds_y>SCREENHEIGHT) - I_Error ("R_DrawSpan: %i to %i at %i",ds_x1,ds_x2,ds_y); -// dscount++; + if (ds_x2 < ds_x1 || ds_x1<0 || ds_x2 >= SCREENWIDTH + || (unsigned)ds_y>SCREENHEIGHT) + I_Error ("R_DrawSpan: %i to %i at %i", ds_x1, ds_x2, ds_y); + // dscount++; #endif - + xfrac = ds_xfrac; yfrac = ds_yfrac; - - dest = ylookup[ds_y] + columnofs[ds_x1]; + + dest = ylookup[ds_y] + columnofs[ds_x1]; count = ds_x2 - ds_x1; do { - spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63); + spot = ((yfrac >> (16 - 6)) & (63 * 64)) + ((xfrac >> 16) & 63); *dest++ = ds_colormap[ds_source[spot]]; xfrac += ds_xstep; yfrac += ds_ystep; @@ -354,16 +354,16 @@ void R_DrawSpanLow (void) void R_InitBuffer (int width, int height) { int i; - - viewwindowx = (SCREENWIDTH-width) >> 1; - for (i=0 ; i> 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> 1; + for (i = 0; i < height; i++) + ylookup[i] = screen + (i + viewwindowy) * SCREENWIDTH; } @@ -380,13 +380,13 @@ boolean BorderNeedRefresh; void R_DrawViewBorder (void) { - byte *src, *dest; - int x,y; - + byte *src, *dest; + int x, y; + if (scaledviewwidth == SCREENWIDTH) return; - if(shareware) + if (shareware) { src = W_CacheLumpName ("FLOOR04", PU_CACHE); } @@ -395,39 +395,39 @@ void R_DrawViewBorder (void) src = W_CacheLumpName ("FLAT513", PU_CACHE); } dest = screen; - - for (y=0 ; y box[BOXRIGHT]) + if (x > box[BOXRIGHT]) box[BOXRIGHT] = x; - if (y< box[BOXBOTTOM]) + if (y < box[BOXBOTTOM]) box[BOXBOTTOM] = y; - if (y> box[BOXTOP]) + if (y > box[BOXTOP]) box[BOXTOP] = y; } @@ -106,7 +106,7 @@ void R_AddPointToBox (int x, int y, fixed_t *box) int R_PointOnSide (fixed_t x, fixed_t y, node_t *node) { - fixed_t dx,dy; + fixed_t dx, dy; fixed_t left, right; if (!node->dx) @@ -125,16 +125,16 @@ int R_PointOnSide (fixed_t x, fixed_t y, node_t *node) dx = (x - node->x); dy = (y - node->y); -// try to quickly decide by looking at sign bits - if ( (node->dy ^ node->dx ^ dx ^ dy)&0x80000000 ) + // try to quickly decide by looking at sign bits + if ((node->dy ^ node->dx ^ dx ^ dy) & 0x80000000) { - if ( (node->dy ^ dx) & 0x80000000 ) + if ((node->dy ^ dx) & 0x80000000) return 1; // (left is negative) return 0; } - left = FixedMul ( node->dy>>FRACBITS , dx ); - right = FixedMul ( dy , node->dx>>FRACBITS ); + left = FixedMul (node->dy >> FRACBITS, dx); + right = FixedMul (dy, node->dx >> FRACBITS); if (right < left) return 0; // front side @@ -146,7 +146,7 @@ int R_PointOnSegSide (fixed_t x, fixed_t y, seg_t *line) { fixed_t lx, ly; fixed_t ldx, ldy; - fixed_t dx,dy; + fixed_t dx, dy; fixed_t left, right; lx = line->v1->x; @@ -171,16 +171,16 @@ int R_PointOnSegSide (fixed_t x, fixed_t y, seg_t *line) dx = (x - lx); dy = (y - ly); -// try to quickly decide by looking at sign bits - if ( (ldy ^ ldx ^ dx ^ dy)&0x80000000 ) + // try to quickly decide by looking at sign bits + if ((ldy ^ ldx ^ dx ^ dy) & 0x80000000) { - if ( (ldy ^ dx) & 0x80000000 ) + if ((ldy ^ dx) & 0x80000000) return 1; // (left is negative) return 0; } - left = FixedMul ( ldy>>FRACBITS , dx ); - right = FixedMul ( dy , ldx>>FRACBITS ); + left = FixedMul (ldy >> FRACBITS, dx); + right = FixedMul (dy, ldx >> FRACBITS); if (right < left) return 0; // front side @@ -206,7 +206,7 @@ int R_PointOnSegSide (fixed_t x, fixed_t y, seg_t *line) #define DBITS (FRACBITS-SLOPEBITS) -extern int tantoangle[SLOPERANGE+1]; // get from tables.c +extern int tantoangle[SLOPERANGE + 1]; // get from tables.c // int tantoangle[SLOPERANGE+1]; @@ -215,7 +215,7 @@ int SlopeDiv (unsigned num, unsigned den) unsigned ans; if (den < 512) return SLOPERANGE; - ans = (num<<3)/(den>>8); + ans = (num << 3) / (den >> 8); return ans <= SLOPERANGE ? ans : SLOPERANGE; } @@ -223,43 +223,43 @@ angle_t R_PointToAngle (fixed_t x, fixed_t y) { x -= viewx; y -= viewy; - if ( (!x) && (!y) ) + if ((!x) && (!y)) return 0; - if (x>= 0) + if (x >= 0) { // x >=0 - if (y>= 0) + if (y >= 0) { // y>= 0 - if (x>y) - return tantoangle[ SlopeDiv(y,x)]; // octant 0 + if (x > y) + return tantoangle[SlopeDiv(y, x)]; // octant 0 else - return ANG90-1-tantoangle[ SlopeDiv(x,y)]; // octant 1 + return ANG90 - 1 - tantoangle[SlopeDiv(x, y)]; // octant 1 } else { // y<0 y = -y; - if (x>y) - return -tantoangle[SlopeDiv(y,x)]; // octant 8 + if (x > y) + return -tantoangle[SlopeDiv(y, x)]; // octant 8 else - return ANG270+tantoangle[ SlopeDiv(x,y)]; // octant 7 + return ANG270 + tantoangle[SlopeDiv(x, y)]; // octant 7 } } else { // x<0 x = -x; - if (y>= 0) + if (y >= 0) { // y>= 0 - if (x>y) - return ANG180-1-tantoangle[ SlopeDiv(y,x)]; // octant 3 + if (x > y) + return ANG180 - 1 - tantoangle[SlopeDiv(y, x)]; // octant 3 else - return ANG90+ tantoangle[ SlopeDiv(x,y)]; // octant 2 + return ANG90 + tantoangle[SlopeDiv(x, y)]; // octant 2 } else { // y<0 y = -y; - if (x>y) - return ANG180+tantoangle[ SlopeDiv(y,x)]; // octant 4 + if (x > y) + return ANG180 + tantoangle[SlopeDiv(y, x)]; // octant 4 else - return ANG270-1-tantoangle[ SlopeDiv(x,y)]; // octant 5 + return ANG270 - 1 - tantoangle[SlopeDiv(x, y)]; // octant 5 } } @@ -284,16 +284,16 @@ fixed_t R_PointToDist (fixed_t x, fixed_t y) dx = abs(x - viewx); dy = abs(y - viewy); - if (dy>dx) + if (dy > dx) { temp = dx; dx = dy; dy = temp; } - angle = (tantoangle[ FixedDiv(dy,dx)>>DBITS ]+ANG90) >> ANGLETOFINESHIFT; + angle = (tantoangle[FixedDiv(dy, dx) >> DBITS] + ANG90) >> ANGLETOFINESHIFT; - dist = FixedDiv (dx, finesine[angle] ); // use as cosine + dist = FixedDiv (dx, finesine[angle]); // use as cosine return dist; } @@ -310,18 +310,18 @@ fixed_t R_PointToDist (fixed_t x, fixed_t y) void R_InitPointToAngle (void) { -// now getting from tables.c + // now getting from tables.c #if 0 int i; long t; float f; -// -// slope (tangent) to angle lookup -// - for (i=0 ; i<=SLOPERANGE ; i++) + // + // slope (tangent) to angle lookup + // + for (i = 0; i <= SLOPERANGE; i++) { - f = atan( (float)i/SLOPERANGE )/(3.141592657*2); - t = 0xffffffff*f; + f = atan((float)i / SLOPERANGE) / (3.141592657 * 2); + t = 0xffffffff * f; tantoangle[i] = t; } #endif @@ -344,39 +344,39 @@ fixed_t R_ScaleFromGlobalAngle (angle_t visangle) fixed_t scale; int anglea, angleb; int sinea, sineb; - fixed_t num,den; + fixed_t num, den; #if 0 -{ - fixed_t dist,z; - fixed_t sinv, cosv; - - sinv = finesine[(visangle-rw_normalangle)>>ANGLETOFINESHIFT]; - dist = FixedDiv (rw_distance, sinv); - cosv = finecosine[(viewangle-visangle)>>ANGLETOFINESHIFT]; - z = abs(FixedMul (dist, cosv)); - scale = FixedDiv(projection, z); - return scale; -} + { + fixed_t dist, z; + fixed_t sinv, cosv; + + sinv = finesine[(visangle - rw_normalangle) >> ANGLETOFINESHIFT]; + dist = FixedDiv (rw_distance, sinv); + cosv = finecosine[(viewangle - visangle) >> ANGLETOFINESHIFT]; + z = abs(FixedMul (dist, cosv)); + scale = FixedDiv(projection, z); + return scale; + } #endif - anglea = ANG90 + (visangle-viewangle); - angleb = ANG90 + (visangle-rw_normalangle); -// bothe sines are allways positive - sinea = finesine[anglea>>ANGLETOFINESHIFT]; - sineb = finesine[angleb>>ANGLETOFINESHIFT]; - num = FixedMul(projection,sineb)< num>>16) + anglea = ANG90 + (visangle - viewangle); + angleb = ANG90 + (visangle - rw_normalangle); + // bothe sines are allways positive + 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; + if (scale > 64 * FRACUNIT) + scale = 64 * FRACUNIT; else if (scale < 256) scale = 256; } else - scale = 64*FRACUNIT; + scale = 64 * FRACUNIT; return scale; } @@ -393,31 +393,31 @@ fixed_t R_ScaleFromGlobalAngle (angle_t visangle) void R_InitTables (void) { -// now getting from tables.c + // now getting from tables.c #if 0 int i; float a, fv; int t; -// -// viewangle tangent table -// - for (i=0 ; i FRACUNIT*2) + if (finetangent[i] > FRACUNIT * 2) t = -1; - else if (finetangent[i] < -FRACUNIT*2) - t = viewwidth+1; + else if (finetangent[i] < -FRACUNIT * 2) + t = viewwidth + 1; else { t = FixedMul (finetangent[i], focallength); - t = (centerxfrac - t+FRACUNIT-1)>>FRACBITS; + t = (centerxfrac - t + FRACUNIT - 1) >> FRACBITS; if (t < -1) t = -1; - else if (t>viewwidth+1) - t = viewwidth+1; + else if (t > viewwidth + 1) + t = viewwidth + 1; } viewangletox[i] = t; } -// -// scan viewangletox[] to generate xtoviewangleangle[] -// -// xtoviewangle will give the smallest view angle that maps to x - for (x=0;x<=viewwidth;x++) + // + // scan viewangletox[] to generate xtoviewangleangle[] + // + // xtoviewangle will give the smallest view angle that maps to x + for (x = 0; x <= viewwidth; x++) { i = 0; - while (viewangletox[i]>x) + while (viewangletox[i] > x) i++; - xtoviewangle[x] = (i<>= LIGHTSCALESHIFT; - level = startmap - scale/DISTMAP; + level = startmap - scale / DISTMAP; if (level < 0) level = 0; if (level >= NUMCOLORMAPS) - level = NUMCOLORMAPS-1; - zlight[i][j] = colormaps + level*256; + level = NUMCOLORMAPS - 1; + zlight[i][j] = colormaps + level * 256; } } } @@ -568,7 +568,7 @@ void R_SetViewSize (int blocks, int detail) void R_ExecuteSetViewSize (void) { fixed_t cosadj, dy; - int i,j, level, startmap; + int i, j, level, startmap; setsizeneeded = false; @@ -579,17 +579,17 @@ void R_ExecuteSetViewSize (void) } else { - scaledviewwidth = setblocks*32; - viewheight = (setblocks*158/10); + scaledviewwidth = setblocks * 32; + viewheight = (setblocks * 158 / 10); } detailshift = setdetail; - viewwidth = scaledviewwidth>>detailshift; + viewwidth = scaledviewwidth >> detailshift; - centery = viewheight/2; - centerx = viewwidth/2; - centerxfrac = centerx<>ANGLETOFINESHIFT]); - distscale[i] = FixedDiv (FRACUNIT,cosadj); + cosadj = abs(finecosine[xtoviewangle[i] >> ANGLETOFINESHIFT]); + distscale[i] = FixedDiv (FRACUNIT, cosadj); } -// -// Calculate the light levels to use for each level / scale combination -// - for (i=0 ; i< LIGHTLEVELS ; i++) + // + // Calculate the light levels to use for each level / scale combination + // + for (i = 0; i < LIGHTLEVELS; i++) { - startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS; - for (j=0 ; j= NUMCOLORMAPS) - level = NUMCOLORMAPS-1; - scalelight[i][j] = colormaps + level*256; + level = NUMCOLORMAPS - 1; + scalelight[i][j] = colormaps + level * 256; } } -// -// draw the border -// + // + // draw the border + // R_DrawViewBorder (); // erase old menu stuff } @@ -711,15 +711,15 @@ void R_Init (void) subsector_t *R_PointInSubsector (fixed_t x, fixed_t y) { - node_t *node; + node_t *node; int side, nodenum; if (!numnodes) // single subsector is a special case return subsectors; - nodenum = numnodes-1; + nodenum = numnodes - 1; - while (! (nodenum & NF_SUBSECTOR) ) + while (!(nodenum & NF_SUBSECTOR)) { node = &nodes[nodenum]; side = R_PointOnSide (x, y, node); @@ -745,14 +745,14 @@ void R_SetupFrame(player_t *player) //drawbsp = 1; viewplayer = player; #ifdef __WATCOMC__ - viewangleoffset = newViewAngleOff<mo->angle+viewangleoffset; - tableAngle = viewangle>>ANGLETOFINESHIFT; - if(player->chickenTics && player->chickenPeck) + viewangle = player->mo->angle + viewangleoffset; + tableAngle = viewangle >> ANGLETOFINESHIFT; + if (player->chickenTics && player->chickenPeck) { // Set chicken attack view position - viewx = player->mo->x+player->chickenPeck*finecosine[tableAngle]; - viewy = player->mo->y+player->chickenPeck*finesine[tableAngle]; + viewx = player->mo->x + player->chickenPeck * finecosine[tableAngle]; + viewy = player->mo->y + player->chickenPeck * finesine[tableAngle]; } else { // Normal view position @@ -761,27 +761,27 @@ void R_SetupFrame(player_t *player) } extralight = player->extralight; viewz = player->viewz; - - tempCentery = viewheight/2+(player->lookdir)*screenblocks/10; - if(centery != tempCentery) + + tempCentery = viewheight / 2 + (player->lookdir) * screenblocks / 10; + if (centery != tempCentery) { centery = tempCentery; - centeryfrac = centery<fixedcolormap) + if (player->fixedcolormap) { - fixedcolormap = colormaps+player->fixedcolormap - *256*sizeof(lighttable_t); + fixedcolormap = colormaps + player->fixedcolormap + * 256 * sizeof(lighttable_t); walllights = scalelightfixed; - for(i = 0; i < MAXLIGHTSCALE; i++) + for (i = 0; i < MAXLIGHTSCALE; i++) { scalelightfixed[i] = fixedcolormap; } @@ -792,9 +792,9 @@ void R_SetupFrame(player_t *player) } framecount++; validcount++; - if(BorderNeedRefresh) + if (BorderNeedRefresh) { - if(setblocks < 10) + if (setblocks < 10) { R_DrawViewBorder(); } @@ -802,9 +802,9 @@ void R_SetupFrame(player_t *player) BorderTopRefresh = false; UpdateState |= I_FULLSCRN; } - if(BorderTopRefresh) + if (BorderTopRefresh) { - if(setblocks < 10) + if (setblocks < 10) { R_DrawTopBorder(); } @@ -816,31 +816,31 @@ void R_SetupFrame(player_t *player) RD_ClearMapWindow (); #endif #ifdef __WATCOMC__ - destview = destscreen+(viewwindowx>>2)+viewwindowy*80; + destview = destscreen + (viewwindowx >> 2) + viewwindowy * 80; #endif } #ifdef USE_VRGOGGLES -void R_SetupFrame_VRLeft (player_t* player) -{ - int i; - int calcangle; +void R_SetupFrame_VRLeft (player_t *player) +{ + int i; + int calcangle; int tableAngle; int tempCentery; - calcangle = (vrangle*vrdist); + calcangle = (vrangle * vrdist); //drawbsp = 1; viewplayer = player; #ifdef __WATCOMC__ - viewangleoffset = newViewAngleOff<mo->angle+viewangleoffset-calcangle; - tableAngle = viewangle>>ANGLETOFINESHIFT; - if(player->chickenTics && player->chickenPeck) + viewangle = player->mo->angle + viewangleoffset - calcangle; + tableAngle = viewangle >> ANGLETOFINESHIFT; + if (player->chickenTics && player->chickenPeck) { // Set chicken attack view position - viewx = player->mo->x+player->chickenPeck*finecosine[tableAngle]; - viewy = player->mo->y+player->chickenPeck*finesine[tableAngle]; + viewx = player->mo->x + player->chickenPeck * finecosine[tableAngle]; + viewy = player->mo->y + player->chickenPeck * finesine[tableAngle]; } else { // Normal view position @@ -849,27 +849,27 @@ void R_SetupFrame_VRLeft (player_t* player) } extralight = player->extralight; viewz = player->viewz; - - tempCentery = viewheight/2+(player->lookdir)*screenblocks/10; - if(centery != tempCentery) + + tempCentery = viewheight / 2 + (player->lookdir) * screenblocks / 10; + if (centery != tempCentery) { centery = tempCentery; - centeryfrac = centery<fixedcolormap) + if (player->fixedcolormap) { - fixedcolormap = colormaps+player->fixedcolormap - *256*sizeof(lighttable_t); + fixedcolormap = colormaps + player->fixedcolormap + * 256 * sizeof(lighttable_t); walllights = scalelightfixed; - for(i = 0; i < MAXLIGHTSCALE; i++) + for (i = 0; i < MAXLIGHTSCALE; i++) { scalelightfixed[i] = fixedcolormap; } @@ -881,29 +881,29 @@ void R_SetupFrame_VRLeft (player_t* player) framecount++; validcount++; - SVRDosSetImage(LEFT,0,0,320,200,screen); + SVRDosSetImage(LEFT, 0, 0, 320, 200, screen); } -void R_SetupFrame_VRRight (player_t* player) -{ - int i; - int calcangle; +void R_SetupFrame_VRRight (player_t *player) +{ + int i; + int calcangle; int tableAngle; int tempCentery; - calcangle = (vrangle*vrdist); + calcangle = (vrangle * vrdist); //drawbsp = 1; viewplayer = player; #ifdef __WATCOMC__ - viewangleoffset = newViewAngleOff<mo->angle+viewangleoffset+calcangle; - tableAngle = viewangle>>ANGLETOFINESHIFT; - if(player->chickenTics && player->chickenPeck) + viewangle = player->mo->angle + viewangleoffset + calcangle; + tableAngle = viewangle >> ANGLETOFINESHIFT; + if (player->chickenTics && player->chickenPeck) { // Set chicken attack view position - viewx = player->mo->x+player->chickenPeck*finecosine[tableAngle]; - viewy = player->mo->y+player->chickenPeck*finesine[tableAngle]; + viewx = player->mo->x + player->chickenPeck * finecosine[tableAngle]; + viewy = player->mo->y + player->chickenPeck * finesine[tableAngle]; } else { // Normal view position @@ -912,27 +912,27 @@ void R_SetupFrame_VRRight (player_t* player) } extralight = player->extralight; viewz = player->viewz; - - tempCentery = viewheight/2+(player->lookdir)*screenblocks/10; - if(centery != tempCentery) + + tempCentery = viewheight / 2 + (player->lookdir) * screenblocks / 10; + if (centery != tempCentery) { centery = tempCentery; - centeryfrac = centery<fixedcolormap) + if (player->fixedcolormap) { - fixedcolormap = colormaps+player->fixedcolormap - *256*sizeof(lighttable_t); + fixedcolormap = colormaps + player->fixedcolormap + * 256 * sizeof(lighttable_t); walllights = scalelightfixed; - for(i = 0; i < MAXLIGHTSCALE; i++) + for (i = 0; i < MAXLIGHTSCALE; i++) { scalelightfixed[i] = fixedcolormap; } @@ -944,15 +944,15 @@ void R_SetupFrame_VRRight (player_t* player) framecount++; validcount++; - SVRDosSetImage(RIGHT,0,0,320,200,screen); + SVRDosSetImage(RIGHT, 0, 0, 320, 200, screen); } #else -void R_SetupFrame_VRLeft (player_t* player) +void R_SetupFrame_VRLeft (player_t *player) { I_Error("VR Goggles rendering without compiled VR support!"); } -void R_SetupFrame_VRRight (player_t* player) +void R_SetupFrame_VRRight (player_t *player) { I_Error("VR Goggles rendering without compiled VR support!"); } @@ -968,7 +968,7 @@ void R_SetupFrame_VRRight (player_t* player) void R_RenderPlayerView (player_t *player) { - if(usevrgoggles) + if (usevrgoggles) R_SetupFrame_VRLeft(player); else R_SetupFrame (player); @@ -983,7 +983,7 @@ void R_RenderPlayerView (player_t *player) NetUpdate (); // the head node is the last node output - R_RenderBSPNode (numnodes-1); + R_RenderBSPNode (numnodes - 1); // check for new console commands NetUpdate (); @@ -997,8 +997,8 @@ void R_RenderPlayerView (player_t *player) // check for new console commands NetUpdate (); - - if(usevrgoggles) /* FS: Now draw the Right Eye, but this time don't poll the NetUpdate as it's unnecessary to do it so many times and this happens so quickly */ + + if (usevrgoggles) /* FS: Now draw the Right Eye, but this time don't poll the NetUpdate as it's unnecessary to do it so many times and this happens so quickly */ { /* FS: Gotta draw all the HUD/Messages stuff twice or it's only going to come out of one eye. */ CT_Drawer(); @@ -1016,7 +1016,7 @@ void R_RenderPlayerView (player_t *player) R_ClearSprites (); // the head node is the last node output - R_RenderBSPNode (numnodes-1); + R_RenderBSPNode (numnodes - 1); R_DrawPlanes (); R_DrawMasked (); } diff --git a/R_PLANE.C b/R_PLANE.C index dd082e1..f76e924 100644 --- a/R_PLANE.C +++ b/R_PLANE.C @@ -20,7 +20,7 @@ fixed_t skyiscale; // visplane_t visplanes[MAXVISPLANES], *lastvisplane; -visplane_t *floorplane, *ceilingplane; +visplane_t *floorplane, *ceilingplane; short openings[MAXOPENINGS], *lastopening; @@ -42,7 +42,7 @@ int spanstop[SCREENHEIGHT]; // // texture mapping // -lighttable_t **planezlight; +lighttable_t **planezlight; fixed_t planeheight; fixed_t yslope[SCREENHEIGHT]; @@ -68,7 +68,7 @@ fixed_t cachedystep[SCREENHEIGHT]; void R_InitSkyMap (void) { skyflatnum = R_FlatNumForName ("F_SKY1"); - skytexturemid = 200*FRACUNIT; + skytexturemid = 200 * FRACUNIT; skyiscale = FRACUNIT; } @@ -110,10 +110,10 @@ void R_MapPlane (int y, int x1, int x2) angle_t angle; fixed_t distance, length; unsigned index; - + #ifdef RANGECHECK - if (x2 < x1 || x1<0 || x2>=viewwidth || (unsigned)y>viewheight) - I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y); + if (x2 < x1 || x1<0 || x2 >= viewwidth || (unsigned)y>viewheight) + I_Error ("R_MapPlane: %i, %i at %i", x1, x2, y); #endif if (planeheight != cachedheight[y]) @@ -121,8 +121,8 @@ void R_MapPlane (int y, int x1, int x2) cachedheight[y] = planeheight; distance = cacheddistance[y] = FixedMul (planeheight, yslope[y]); - ds_xstep = cachedxstep[y] = FixedMul (distance,basexscale); - ds_ystep = cachedystep[y] = FixedMul (distance,baseyscale); + ds_xstep = cachedxstep[y] = FixedMul (distance, basexscale); + ds_ystep = cachedystep[y] = FixedMul (distance, baseyscale); } else { @@ -130,9 +130,9 @@ void R_MapPlane (int y, int x1, int x2) ds_xstep = cachedxstep[y]; ds_ystep = cachedystep[y]; } - - length = FixedMul (distance,distscale[x1]); - angle = (viewangle + xtoviewangle[x1])>>ANGLETOFINESHIFT; + + length = FixedMul (distance, distscale[x1]); + angle = (viewangle + xtoviewangle[x1]) >> ANGLETOFINESHIFT; ds_xfrac = viewx + FixedMul(finecosine[angle], length); ds_yfrac = -viewy - FixedMul(finesine[angle], length); @@ -141,15 +141,15 @@ void R_MapPlane (int y, int x1, int x2) else { index = distance >> LIGHTZSHIFT; - if (index >= MAXLIGHTZ ) - index = MAXLIGHTZ-1; + if (index >= MAXLIGHTZ) + index = MAXLIGHTZ - 1; ds_colormap = planezlight[index]; } - + ds_y = y; ds_x1 = x1; ds_x2 = x2; - + spanfunc (); // high or low detail } @@ -168,11 +168,11 @@ void R_ClearPlanes (void) { int i; angle_t angle; - -// -// opening / clipping determination -// - for (i=0 ; i>ANGLETOFINESHIFT; // left to right mapping - + + // + // texture calculation + // + memset (cachedheight, 0, sizeof(cachedheight)); + angle = (viewangle - ANG90) >> ANGLETOFINESHIFT; // left to right mapping + // scale will be unit scale at SCREENWIDTH/2 distance - basexscale = FixedDiv (finecosine[angle],centerxfrac); - baseyscale = -FixedDiv (finesine[angle],centerxfrac); + basexscale = FixedDiv (finecosine[angle], centerxfrac); + baseyscale = -FixedDiv (finesine[angle], centerxfrac); } @@ -207,28 +207,28 @@ visplane_t *R_FindPlane(fixed_t height, int picnum, { visplane_t *check; - if(picnum == skyflatnum) + if (picnum == skyflatnum) { // all skies map together height = 0; lightlevel = 0; } - for(check = visplanes; check < lastvisplane; check++) + for (check = visplanes; check < lastvisplane; check++) { - if(height == check->height - && picnum == check->picnum - && lightlevel == check->lightlevel - && special == check->special) + if (height == check->height + && picnum == check->picnum + && lightlevel == check->lightlevel + && special == check->special) break; } - if(check < lastvisplane) + if (check < lastvisplane) { return(check); } - if(lastvisplane-visplanes == MAXVISPLANES) + if (lastvisplane - visplanes == MAXVISPLANES) { I_Error("R_FindPlane: no more visplanes"); } @@ -240,7 +240,7 @@ visplane_t *R_FindPlane(fixed_t height, int picnum, check->special = special; check->minx = SCREENWIDTH; check->maxx = -1; - memset(check->top,0xff,sizeof(check->top)); + memset(check->top, 0xff, sizeof(check->top)); return(check); } @@ -257,7 +257,7 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop) int intrl, intrh; int unionl, unionh; int x; - + if (start < pl->minx) { intrl = pl->minx; @@ -268,7 +268,7 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop) unionl = pl->minx; intrl = start; } - + if (stop > pl->maxx) { intrh = pl->maxx; @@ -280,7 +280,7 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop) intrh = stop; } - for (x=intrl ; x<= intrh ; x++) + for (x = intrl; x <= intrh; x++) if (pl->top[x] != 0xff) break; @@ -290,8 +290,8 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop) pl->maxx = unionh; return pl; // use the same one } - -// make a new visplane + + // make a new visplane lastvisplane->height = pl->height; lastvisplane->picnum = pl->picnum; @@ -300,8 +300,8 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop) pl = lastvisplane++; pl->minx = start; pl->maxx = stop; - memset (pl->top,0xff,sizeof(pl->top)); - + memset (pl->top, 0xff, sizeof(pl->top)); + return pl; } @@ -319,23 +319,23 @@ visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop) void R_MakeSpans (int x, int t1, int b1, int t2, int b2) { - while (t1 < t2 && t1<=b1) + while (t1 < t2 && t1 <= b1) { - R_MapPlane (t1,spanstart[t1],x-1); + R_MapPlane (t1, spanstart[t1], x - 1); t1++; } - while (b1 > b2 && b1>=t1) + while (b1 > b2 && b1 >= t1) { - R_MapPlane (b1,spanstart[b1],x-1); + R_MapPlane (b1, spanstart[b1], x - 1); b1--; } - - while (t2 < t1 && t2<=b2) + + while (t2 < t1 && t2 <= b2) { spanstart[t2] = x; t2++; } - while (b2 > b1 && b2>=t2) + while (b2 > b1 && b2 >= t2) { spanstart[b2] = x; b2--; @@ -355,18 +355,18 @@ void R_MakeSpans (int x, int t1, int b1, int t2, int b2) void R_DrawPlanes (void) { - visplane_t *pl; + visplane_t *pl; int light; int x, stop; int angle; byte *tempSource; - + byte *dest; int count; fixed_t frac, fracstep; - -extern byte *ylookup[MAXHEIGHT]; -extern int columnofs[MAXWIDTH]; + + extern byte *ylookup[MAXHEIGHT]; + extern int columnofs[MAXWIDTH]; #ifdef RANGECHECK if (ds_p - drawsegs > MAXDRAWSEGS) @@ -377,68 +377,68 @@ extern int columnofs[MAXWIDTH]; I_Error ("R_DrawPlanes: opening overflow (%i)", lastopening - openings); #endif - for (pl = visplanes ; pl < lastvisplane ; pl++) + for (pl = visplanes; pl < lastvisplane; pl++) { if (pl->minx > pl->maxx) continue; - // - // sky flat - // + // + // sky flat + // if (pl->picnum == skyflatnum) { dc_iscale = skyiscale; dc_colormap = colormaps;// sky is allways drawn full bright dc_texturemid = skytexturemid; - for (x=pl->minx ; x <= pl->maxx ; x++) + 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; + angle = (viewangle + xtoviewangle[x]) >> ANGLETOSKYSHIFT; dc_x = x; dc_source = R_GetColumn(skytexture, angle); 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); + 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]; - + dest = ylookup[dc_yl] + columnofs[dc_x]; + fracstep = 1; - frac = (dc_texturemid>>FRACBITS) + (dc_yl-centery); + frac = (dc_texturemid >> FRACBITS) + (dc_yl - centery); do { *dest = dc_source[frac]; dest += SCREENWIDTH; frac += fracstep; } while (count--); - -// colfunc (); + + // colfunc (); } } continue; } - - // - // regular flat - // + + // + // regular flat + // tempSource = W_CacheLumpNum(firstflat + flattranslation[pl->picnum], PU_STATIC); - switch(pl->special) + switch (pl->special) { case 25: case 26: case 27: case 28: case 29: // Scroll_North ds_source = tempSource; break; case 20: case 21: case 22: case 23: case 24: // Scroll_East - ds_source = tempSource+((63-((leveltime>>1)&63))<< - (pl->special-20)&63); + ds_source = tempSource + ((63 - ((leveltime >> 1) & 63)) << + (pl->special - 20) & 63); //ds_source = tempSource+((leveltime>>1)&63); break; case 30: case 31: case 32: case 33: case 34: // Scroll_South @@ -448,27 +448,27 @@ extern int columnofs[MAXWIDTH]; ds_source = tempSource; break; case 4: // Scroll_EastLavaDamage - ds_source = tempSource+(((63-((leveltime>>1)&63))<<3)&63); + ds_source = tempSource + (((63 - ((leveltime >> 1) & 63)) << 3) & 63); break; default: ds_source = tempSource; } - planeheight = abs(pl->height-viewz); - light = (pl->lightlevel >> LIGHTSEGSHIFT)+extralight; + planeheight = abs(pl->height - viewz); + light = (pl->lightlevel >> LIGHTSEGSHIFT) + extralight; if (light >= LIGHTLEVELS) - light = LIGHTLEVELS-1; + light = LIGHTLEVELS - 1; if (light < 0) light = 0; planezlight = zlight[light]; - pl->top[pl->maxx+1] = 0xff; - pl->top[pl->minx-1] = 0xff; - + 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],pl->bottom[x-1] - ,pl->top[x],pl->bottom[x]); - + for (x = pl->minx; x <= stop; x++) + R_MakeSpans (x, pl->top[x - 1], pl->bottom[x - 1] + , pl->top[x], pl->bottom[x]); + Z_ChangeTag (tempSource, PU_CACHE); } } diff --git a/R_SEGS.C b/R_SEGS.C index 983173c..67dcfd2 100644 --- a/R_SEGS.C +++ b/R_SEGS.C @@ -46,9 +46,9 @@ fixed_t topfrac, topstep; fixed_t bottomfrac, bottomstep; -lighttable_t **walllights; +lighttable_t **walllights; -short *maskedtexturecol; +short *maskedtexturecol; /* ================ @@ -61,20 +61,20 @@ short *maskedtexturecol; void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) { unsigned index; - column_t *col; + column_t *col; int lightnum; int texnum; -// -// calculate light table -// use different light tables for horizontal / vertical / diagonal -// OPTIMIZE: get rid of LIGHTSEGSHIFT globally + // + // calculate light table + // use different light tables for horizontal / vertical / diagonal + // OPTIMIZE: get rid of LIGHTSEGSHIFT globally curline = ds->curline; frontsector = curline->frontsector; backsector = curline->backsector; texnum = texturetranslation[curline->sidedef->midtexture]; - lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight; + lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT) + extralight; if (curline->v1->y == curline->v2->y) lightnum--; else if (curline->v1->x == curline->v2->x) @@ -82,60 +82,60 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) if (lightnum < 0) walllights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) - walllights = scalelight[LIGHTLEVELS-1]; + walllights = scalelight[LIGHTLEVELS - 1]; else walllights = scalelight[lightnum]; maskedtexturecol = ds->maskedtexturecol; rw_scalestep = ds->scalestep; - spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep; + spryscale = ds->scale1 + (x1 - ds->x1) * rw_scalestep; mfloorclip = ds->sprbottomclip; mceilingclip = ds->sprtopclip; -// -// find positioning -// + // + // find positioning + // if (curline->linedef->flags & ML_DONTPEGBOTTOM) { dc_texturemid = frontsector->floorheight > backsector->floorheight - ? frontsector->floorheight : backsector->floorheight; + ? frontsector->floorheight : backsector->floorheight; dc_texturemid = dc_texturemid + textureheight[texnum] - viewz; } else { - dc_texturemid =frontsector->ceilingheightceilingheight - ? frontsector->ceilingheight : backsector->ceilingheight; + dc_texturemid = frontsector->ceilingheight < backsector->ceilingheight + ? frontsector->ceilingheight : backsector->ceilingheight; dc_texturemid = dc_texturemid - viewz; } dc_texturemid += curline->sidedef->rowoffset; if (fixedcolormap) dc_colormap = fixedcolormap; -// -// draw the columns -// - for (dc_x = x1 ; dc_x <= x2 ; dc_x++) + // + // draw the columns + // + for (dc_x = x1; dc_x <= x2; dc_x++) { - // calculate lighting + // calculate lighting if (maskedtexturecol[dc_x] != MAXSHORT) { if (!fixedcolormap) { - index = spryscale>>LIGHTSCALESHIFT; - if (index >= MAXLIGHTSCALE ) - index = MAXLIGHTSCALE-1; + index = spryscale >> LIGHTSCALESHIFT; + if (index >= MAXLIGHTSCALE) + index = MAXLIGHTSCALE - 1; dc_colormap = walllights[index]; } sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); dc_iscale = 0xffffffffu / (unsigned)spryscale; - // - // draw the texture - // + // + // draw the texture + // col = (column_t *)( - (byte *)R_GetColumn(texnum,maskedtexturecol[dc_x]) -3); + (byte *)R_GetColumn(texnum, maskedtexturecol[dc_x]) - 3); R_DrawMaskedColumn (col, -1); maskedtexturecol[dc_x] = MAXSHORT; @@ -168,22 +168,22 @@ void R_RenderSegLoop (void) fixed_t texturecolumn; int top, bottom; -// texturecolumn = 0; // shut up compiler warning + // texturecolumn = 0; // shut up compiler warning - for ( ; rw_x < rw_stopx ; rw_x++) + for (; rw_x < rw_stopx; rw_x++) { -// -// mark floor / ceiling areas -// - yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS; - if (yl < ceilingclip[rw_x]+1) - yl = ceilingclip[rw_x]+1; // no space above wall + // + // mark floor / ceiling areas + // + yl = (topfrac + HEIGHTUNIT - 1) >> HEIGHTBITS; + if (yl < ceilingclip[rw_x] + 1) + yl = ceilingclip[rw_x] + 1; // no space above wall if (markceiling) { - top = ceilingclip[rw_x]+1; - bottom = yl-1; + top = ceilingclip[rw_x] + 1; + bottom = yl - 1; if (bottom >= floorclip[rw_x]) - bottom = floorclip[rw_x]-1; + bottom = floorclip[rw_x] - 1; if (top <= bottom) { ceilingplane->top[rw_x] = top; @@ -191,15 +191,15 @@ void R_RenderSegLoop (void) } } - yh = bottomfrac>>HEIGHTBITS; + yh = bottomfrac >> HEIGHTBITS; if (yh >= floorclip[rw_x]) - yh = floorclip[rw_x]-1; + yh = floorclip[rw_x] - 1; if (markfloor) { - top = yh+1; - bottom = floorclip[rw_x]-1; + top = yh + 1; + bottom = floorclip[rw_x] - 1; if (top <= ceilingclip[rw_x]) - top = ceilingclip[rw_x]+1; + top = ceilingclip[rw_x] + 1; if (top <= bottom) { floorplane->top[rw_x] = top; @@ -207,33 +207,33 @@ void R_RenderSegLoop (void) } } -// -// texturecolumn and lighting are independent of wall tiers -// + // + // texturecolumn and lighting are independent of wall tiers + // if (segtextured) { - // calculate texture offset - angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT; - texturecolumn = rw_offset-FixedMul(finetangent[angle],rw_distance); + // calculate texture offset + angle = (rw_centerangle + xtoviewangle[rw_x]) >> ANGLETOFINESHIFT; + texturecolumn = rw_offset - FixedMul(finetangent[angle], rw_distance); texturecolumn >>= FRACBITS; - // calculate lighting - index = rw_scale>>LIGHTSCALESHIFT; - if (index >= MAXLIGHTSCALE ) - index = MAXLIGHTSCALE-1; + // calculate lighting + index = rw_scale >> LIGHTSCALESHIFT; + if (index >= MAXLIGHTSCALE) + index = MAXLIGHTSCALE - 1; dc_colormap = walllights[index]; dc_x = rw_x; dc_iscale = 0xffffffffu / (unsigned)rw_scale; } -// -// draw the wall tiers -// + // + // draw the wall tiers + // if (midtexture) { // single sided line dc_yl = yl; dc_yh = yh; dc_texturemid = rw_midtexturemid; - dc_source = R_GetColumn(midtexture,texturecolumn); + dc_source = R_GetColumn(midtexture, texturecolumn); colfunc (); ceilingclip[rw_x] = viewheight; floorclip[rw_x] = -1; @@ -242,51 +242,51 @@ void R_RenderSegLoop (void) { // two sided line if (toptexture) { // top wall - mid = pixhigh>>HEIGHTBITS; + mid = pixhigh >> HEIGHTBITS; pixhigh += pixhighstep; if (mid >= floorclip[rw_x]) - mid = floorclip[rw_x]-1; + mid = floorclip[rw_x] - 1; if (mid >= yl) { dc_yl = yl; dc_yh = mid; dc_texturemid = rw_toptexturemid; - dc_source = R_GetColumn(toptexture,texturecolumn); + dc_source = R_GetColumn(toptexture, texturecolumn); colfunc (); ceilingclip[rw_x] = mid; } else - ceilingclip[rw_x] = yl-1; + ceilingclip[rw_x] = yl - 1; } else { // no top wall if (markceiling) - ceilingclip[rw_x] = yl-1; + ceilingclip[rw_x] = yl - 1; } if (bottomtexture) { // bottom wall - mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS; + mid = (pixlow + HEIGHTUNIT - 1) >> HEIGHTBITS; pixlow += pixlowstep; if (mid <= ceilingclip[rw_x]) - mid = ceilingclip[rw_x]+1; // no space above wall + mid = ceilingclip[rw_x] + 1; // no space above wall if (mid <= yh) { dc_yl = mid; dc_yh = yh; dc_texturemid = rw_bottomtexturemid; dc_source = R_GetColumn(bottomtexture, - texturecolumn); + texturecolumn); colfunc (); floorclip[rw_x] = mid; } else - floorclip[rw_x] = yh+1; + floorclip[rw_x] = yh + 1; } else { // no bottom wall if (markfloor) - floorclip[rw_x] = yh+1; + floorclip[rw_x] = yh + 1; } if (maskedtexture) @@ -326,8 +326,8 @@ void R_StoreWallRange (int start, int stop) return; // don't overflow and crash #ifdef RANGECHECK - if (start >=viewwidth || start > stop) - I_Error ("Bad R_RenderWallRange: %i to %i", start , stop); + if (start >= viewwidth || start > stop) + I_Error ("Bad R_RenderWallRange: %i to %i", start, stop); #endif #ifdef __NeXT__ RD_DrawLine (curline); @@ -336,65 +336,65 @@ void R_StoreWallRange (int start, int stop) sidedef = curline->sidedef; linedef = curline->linedef; -// mark the segment as visible for auto map + // mark the segment as visible for auto map linedef->flags |= ML_MAPPED; -// -// calculate rw_distance for scale calculation -// + // + // calculate rw_distance for scale calculation + // rw_normalangle = curline->angle + ANG90; - offsetangle = abs(rw_normalangle-rw_angle1); + 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]; + 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; + rw_stopx = stop + 1; -// -// calculate scale at both ends and step -// + // + // calculate scale at both ends and step + // ds_p->scale1 = rw_scale = R_ScaleFromGlobalAngle (viewangle + xtoviewangle[start]); - if (stop > start ) + if (stop > start) { ds_p->scale2 = R_ScaleFromGlobalAngle (viewangle + xtoviewangle[stop]); ds_p->scalestep = rw_scalestep = - (ds_p->scale2 - rw_scale) / (stop-start); + (ds_p->scale2 - rw_scale) / (stop - start); } else { - // - // try to fix the stretched line bug - // + // + // try to fix the stretched line bug + // #if 0 - if (rw_distance < FRACUNIT/2) + if (rw_distance < FRACUNIT / 2) { - fixed_t trx,try; - fixed_t gxt,gyt; + 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); + gxt = FixedMul(trx, viewcos); + gyt = -FixedMul(try, viewsin); + ds_p->scale1 = FixedDiv(projection, gxt - gyt); } #endif ds_p->scale2 = ds_p->scale1; } -// -// calculate texture boundaries and decide if floor / ceiling marks -// are needed -// + // + // calculate texture boundaries and decide if floor / ceiling marks + // are needed + // worldtop = frontsector->ceilingheight - viewz; worldbottom = frontsector->floorheight - viewz; @@ -403,16 +403,16 @@ void R_StoreWallRange (int start, int stop) if (!backsector) { -// -// single sided line -// + // + // single sided line + // midtexture = texturetranslation[sidedef->midtexture]; // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; if (linedef->flags & ML_DONTPEGBOTTOM) { vtop = frontsector->floorheight + - textureheight[sidedef->midtexture]; + textureheight[sidedef->midtexture]; rw_midtexturemid = vtop - viewz; // bottom of texture at bottom } else @@ -426,9 +426,9 @@ void R_StoreWallRange (int start, int stop) } else { -// -// two sided line -// + // + // two sided line + // ds_p->sprtopclip = ds_p->sprbottomclip = NULL; ds_p->silhouette = 0; if (frontsector->floorheight > backsector->floorheight) @@ -440,7 +440,7 @@ void R_StoreWallRange (int start, int stop) { ds_p->silhouette = SIL_BOTTOM; ds_p->bsilheight = MAXINT; -// ds_p->sprbottomclip = negonearray; + // ds_p->sprbottomclip = negonearray; } if (frontsector->ceilingheight < backsector->ceilingheight) { @@ -451,7 +451,7 @@ void R_StoreWallRange (int start, int stop) { ds_p->silhouette |= SIL_TOP; ds_p->tsilheight = MININT; -// ds_p->sprtopclip = screenheightarray; + // ds_p->sprtopclip = screenheightarray; } if (backsector->ceilingheight <= frontsector->floorheight) @@ -471,25 +471,25 @@ void R_StoreWallRange (int start, int stop) // hack to allow height changes in outdoor areas if (frontsector->ceilingpic == skyflatnum - && backsector->ceilingpic == skyflatnum) + && backsector->ceilingpic == skyflatnum) worldtop = worldhigh; if (worldlow != worldbottom - || backsector->floorpic != frontsector->floorpic - || backsector->lightlevel != frontsector->lightlevel) + || backsector->floorpic != frontsector->floorpic + || backsector->lightlevel != frontsector->lightlevel) markfloor = true; else markfloor = false; // same plane on both sides if (worldhigh != worldtop - || backsector->ceilingpic != frontsector->ceilingpic - || backsector->lightlevel != frontsector->lightlevel) + || backsector->ceilingpic != frontsector->ceilingpic + || backsector->lightlevel != frontsector->lightlevel) markceiling = true; else markceiling = false; // same plane on both sides if (backsector->ceilingheight <= frontsector->floorheight - || backsector->floorheight >= frontsector->ceilingheight) + || backsector->floorheight >= frontsector->ceilingheight) markceiling = markfloor = true; // closed door if (worldhigh < worldtop) @@ -507,7 +507,7 @@ void R_StoreWallRange (int start, int stop) if (worldlow > worldbottom) { // bottom texture bottomtexture = texturetranslation[sidedef->bottomtexture]; - if (linedef->flags & ML_DONTPEGBOTTOM ) + if (linedef->flags & ML_DONTPEGBOTTOM) { // bottom of texture at bottom rw_bottomtexturemid = worldtop;// top of texture at top } @@ -528,32 +528,32 @@ void R_StoreWallRange (int start, int stop) } } -// -// calculate rw_offset (only needed for textured lines) -// + // + // calculate rw_offset (only needed for textured lines) + // segtextured = midtexture | toptexture | bottomtexture | maskedtexture; if (segtextured) { - offsetangle = rw_normalangle-rw_angle1; + offsetangle = rw_normalangle - rw_angle1; if (offsetangle > ANG180) offsetangle = -offsetangle; if (offsetangle > ANG90) offsetangle = ANG90; - sineval = finesine[offsetangle >>ANGLETOFINESHIFT]; + sineval = finesine[offsetangle >> ANGLETOFINESHIFT]; rw_offset = FixedMul (hyp, sineval); - if (rw_normalangle-rw_angle1 < ANG180) + if (rw_normalangle - rw_angle1 < ANG180) rw_offset = -rw_offset; rw_offset += sidedef->textureoffset + curline->offset; rw_centerangle = ANG90 + viewangle - rw_normalangle; - // - // calculate light table - // use different light tables for horizontal / vertical / diagonal - // OPTIMIZE: get rid of LIGHTSEGSHIFT globally + // + // calculate light table + // use different light tables for horizontal / vertical / diagonal + // OPTIMIZE: get rid of LIGHTSEGSHIFT globally if (!fixedcolormap) { - lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight; + lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT) + extralight; if (curline->v1->y == curline->v2->y) lightnum--; else if (curline->v1->x == curline->v2->x) @@ -561,21 +561,21 @@ void R_StoreWallRange (int start, int stop) if (lightnum < 0) walllights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) - walllights = scalelight[LIGHTLEVELS-1]; + walllights = scalelight[LIGHTLEVELS - 1]; else walllights = scalelight[lightnum]; } } -// -// if a floor / ceiling plane is on the wrong side of the view plane -// it is definately invisible and doesn't need to be marked -// + // + // if a floor / ceiling plane is on the wrong side of the view plane + // it is definately invisible and doesn't need to be marked + // if (frontsector->floorheight >= viewz) markfloor = false; // above view plane if (frontsector->ceilingheight <= viewz - && frontsector->ceilingpic != skyflatnum) + && frontsector->ceilingpic != skyflatnum) markceiling = false; // below view plane // @@ -585,10 +585,10 @@ void R_StoreWallRange (int start, int stop) worldbottom >>= 4; topstep = -FixedMul (rw_scalestep, worldtop); - topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale); + topfrac = (centeryfrac >> 4) - FixedMul (worldtop, rw_scale); - bottomstep = -FixedMul (rw_scalestep,worldbottom); - bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale); + bottomstep = -FixedMul (rw_scalestep, worldbottom); + bottomfrac = (centeryfrac >> 4) - FixedMul (worldbottom, rw_scale); if (backsector) { @@ -597,47 +597,47 @@ void R_StoreWallRange (int start, int stop) if (worldhigh < worldtop) { - pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale); - pixhighstep = -FixedMul (rw_scalestep,worldhigh); + 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); + pixlow = (centeryfrac >> 4) - FixedMul (worldlow, rw_scale); + pixlowstep = -FixedMul (rw_scalestep, worldlow); } } -// -// render it -// + // + // render it + // if (markceiling) - ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1); + ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx - 1); if (markfloor) - floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1); + floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx - 1); R_RenderSegLoop (); -// -// save sprite clipping info -// - if ( ((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip) + // + // save sprite clipping info + // + if (((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip) { - memcpy (lastopening, ceilingclip+start, 2*(rw_stopx-start)); + memcpy (lastopening, ceilingclip + start, 2 * (rw_stopx - start)); ds_p->sprtopclip = lastopening - start; lastopening += rw_stopx - start; } - if ( ((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) && !ds_p->sprbottomclip) + if (((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) && !ds_p->sprbottomclip) { - memcpy (lastopening, floorclip+start, 2*(rw_stopx-start)); + memcpy (lastopening, floorclip + start, 2 * (rw_stopx - start)); ds_p->sprbottomclip = lastopening - start; lastopening += rw_stopx - start; } - if (maskedtexture && !(ds_p->silhouette&SIL_TOP)) + if (maskedtexture && !(ds_p->silhouette & SIL_TOP)) { ds_p->silhouette |= SIL_TOP; ds_p->tsilheight = MININT; } - if (maskedtexture && !(ds_p->silhouette&SIL_BOTTOM)) + if (maskedtexture && !(ds_p->silhouette & SIL_BOTTOM)) { ds_p->silhouette |= SIL_BOTTOM; ds_p->bsilheight = MAXINT; diff --git a/R_THINGS.C b/R_THINGS.C index 3a59fe0..5720a9e 100644 --- a/R_THINGS.C +++ b/R_THINGS.C @@ -27,7 +27,7 @@ This is not the same as the angle, which increases counter clockwise fixed_t pspritescale, pspriteiscale; -lighttable_t **spritelights; +lighttable_t **spritelights; // constant arrays used for psprite clipping and initializing clipping short negonearray[SCREENWIDTH]; @@ -42,12 +42,12 @@ short screenheightarray[SCREENWIDTH]; */ // variables used to look up and range check thing_t sprites patches -spritedef_t *sprites; +spritedef_t *sprites; int numsprites; spriteframe_t sprtemp[26]; int maxframe; -char *spritename; +char *spritename; @@ -72,16 +72,16 @@ void R_InstallSpriteLump (int lump, unsigned frame, unsigned rotation, boolean f if (rotation == 0) { -// the lump should be used for all rotations + // the lump should be used for all rotations if (sprtemp[frame].rotate == false) I_Error ("R_InitSprites: Sprite %s frame %c has multip rot=0 lump" - , spritename, 'A'+frame); + , 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); + , spritename, 'A' + frame); sprtemp[frame].rotate = false; - for (r=0 ; r<8 ; r++) + for (r = 0; r < 8; r++) { sprtemp[frame].lump[r] = lump - firstspritelump; sprtemp[frame].flip[r] = (byte)flipped; @@ -89,17 +89,17 @@ void R_InstallSpriteLump (int lump, unsigned frame, unsigned rotation, boolean f return; } -// the lump is only used for one rotation + // the lump is only used for one rotation if (sprtemp[frame].rotate == false) I_Error ("R_InitSprites: Sprite %s frame %c has rotations and a rot=0 lump" - , spritename, 'A'+frame); + , spritename, 'A' + frame); sprtemp[frame].rotate = true; rotation--; // make 0 based 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); + , spritename, 'A' + frame, '1' + rotation); sprtemp[frame].lump[rotation] = lump - firstspritelump; sprtemp[frame].flip[rotation] = (byte)flipped; @@ -124,31 +124,31 @@ void R_InstallSpriteLump (int lump, unsigned frame, unsigned rotation, boolean f void R_InitSpriteDefs (char **namelist) { - char **check; + char **check; int i, l, intname, frame, rotation; int start, end; -// count the number of sprite names + // count the number of sprite names check = namelist; while (*check != NULL) check++; - numsprites = check-namelist; + numsprites = check - namelist; if (!numsprites) return; - sprites = Z_Malloc(numsprites *sizeof(*sprites), PU_STATIC, NULL); + sprites = Z_Malloc(numsprites * sizeof(*sprites), PU_STATIC, NULL); - start = firstspritelump-1; - end = lastspritelump+1; + start = firstspritelump - 1; + end = lastspritelump + 1; -// scan all the lump names for each of the names, noting the highest -// frame letter -// Just compare 4 characters as ints - for (i=0 ; itopdelta != 0xff ; ) + for (; column->topdelta != 0xff; ) { -// calculate unclipped screen coordinates for post - topscreen = sprtopscreen + spryscale*column->topdelta; - bottomscreen = topscreen + spryscale*column->length; - dc_yl = (topscreen+FRACUNIT-1)>>FRACBITS; - dc_yh = (bottomscreen-1)>>FRACBITS; + // calculate unclipped screen coordinates for post + 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; + dc_yh = mfloorclip[dc_x] - 1; if (dc_yl <= mceilingclip[dc_x]) - dc_yl = mceilingclip[dc_x]+1; + dc_yl = mceilingclip[dc_x] + 1; - if(dc_yh >= baseclip && baseclip != -1) + if (dc_yh >= baseclip && baseclip != -1) dc_yh = baseclip; if (dc_yl <= dc_yh) { dc_source = (byte *)column + 3; - dc_texturemid = basetexturemid - (column->topdelta<topdelta; + dc_texturemid = basetexturemid - (column->topdelta << FRACBITS); + // dc_source = (byte *)column + 3 - column->topdelta; colfunc (); // either R_DrawColumn or R_DrawFuzzColumn } - column = (column_t *)( (byte *)column + column->length + 4); + column = (column_t *)((byte *)column + column->length + 4); } dc_texturemid = basetexturemid; @@ -345,78 +345,78 @@ void R_DrawMaskedColumn (column_t *column, signed int baseclip) void R_DrawVisSprite (vissprite_t *vis, int x1, int x2) { - column_t *column; + column_t *column; int texturecolumn; fixed_t frac; - patch_t *patch; + patch_t *patch; fixed_t baseclip; - patch = W_CacheLumpNum(vis->patch+firstspritelump, PU_CACHE); + patch = W_CacheLumpNum(vis->patch + firstspritelump, PU_CACHE); dc_colormap = vis->colormap; -// if(!dc_colormap) -// colfunc = fuzzcolfunc; // NULL colormap = shadow draw + // if(!dc_colormap) + // colfunc = fuzzcolfunc; // NULL colormap = shadow draw - if(vis->mobjflags&MF_SHADOW) + if (vis->mobjflags & MF_SHADOW) { - if(vis->mobjflags&MF_TRANSLATION) + if (vis->mobjflags & MF_TRANSLATION) { colfunc = R_DrawTranslatedFuzzColumn; dc_translation = translationtables - 256 + - ((vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT-8)); + ((vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT - 8)); } else { // Draw using shadow column function colfunc = fuzzcolfunc; } } - else if(vis->mobjflags&MF_TRANSLATION) + else if (vis->mobjflags & MF_TRANSLATION) { // Draw using translated column function colfunc = R_DrawTranslatedColumn; dc_translation = translationtables - 256 + - ( (vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT-8) ); + ((vis->mobjflags & MF_TRANSLATION) >> (MF_TRANSSHIFT - 8)); } - dc_iscale = abs(vis->xiscale)>>detailshift; + dc_iscale = abs(vis->xiscale) >> detailshift; dc_texturemid = vis->texturemid; frac = vis->startfrac; spryscale = vis->scale; - sprtopscreen = centeryfrac - FixedMul(dc_texturemid,spryscale); + sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale); -// check to see if weapon is a vissprite - if(vis->psprite) + // check to see if weapon is a vissprite + if (vis->psprite) { - dc_texturemid += FixedMul(((centery-viewheight/2)<xiscale); - sprtopscreen += (viewheight/2-centery)<footclip && !vis->psprite) + if (vis->footclip && !vis->psprite) { - sprbotscreen = sprtopscreen+FixedMul(patch->height<height << FRACBITS, spryscale); - baseclip = (sprbotscreen-FixedMul(vis->footclip<>FRACBITS; + baseclip = (sprbotscreen - FixedMul(vis->footclip << FRACBITS, + spryscale)) >> FRACBITS; } else { baseclip = -1; } - for (dc_x=vis->x1 ; dc_x<=vis->x2 ; dc_x++, frac += vis->xiscale) + for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) { - texturecolumn = frac>>FRACBITS; + texturecolumn = frac >> FRACBITS; #ifdef RANGECHECK if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) I_Error ("R_DrawSpriteRange: bad texturecolumn"); #endif - column = (column_t *) ((byte *)patch + - LONG(patch->columnofs[texturecolumn])); - R_DrawMaskedColumn (column, baseclip); + column = (column_t *)((byte *)patch + + LONG(patch->columnofs[texturecolumn])); + R_DrawMaskedColumn (column, baseclip); } colfunc = basecolfunc; @@ -436,45 +436,45 @@ void R_DrawVisSprite (vissprite_t *vis, int x1, int x2) void R_ProjectSprite (mobj_t *thing) { - fixed_t trx,try; - fixed_t gxt,gyt; - fixed_t tx,tz; + fixed_t trx, try; + fixed_t gxt, gyt; + fixed_t tx, tz; fixed_t xscale; int x1, x2; - spritedef_t *sprdef; - spriteframe_t *sprframe; + spritedef_t *sprdef; + spriteframe_t *sprframe; int lump; unsigned rot; boolean flip; int index; - vissprite_t *vis; + vissprite_t *vis; angle_t ang; fixed_t iscale; - if(thing->flags2&MF2_DONTDRAW) + if (thing->flags2 & MF2_DONTDRAW) { // Never make a vissprite when MF2_DONTDRAW is flagged. return; } -// -// transform the origin point -// + // + // transform the origin point + // trx = thing->x - viewx; try = thing->y - viewy; - gxt = FixedMul(trx,viewcos); - gyt = -FixedMul(try,viewsin); - tz = gxt-gyt; + gxt = FixedMul(trx, viewcos); + gyt = -FixedMul(try, viewsin); + tz = gxt - gyt; if (tz < MINZ) return; // thing is behind view plane xscale = FixedDiv(projection, tz); - gxt = -FixedMul(trx,viewsin); - gyt = FixedMul(try,viewcos); - tx = -(gyt+gxt); - - if (abs(tx)>(tz<<2)) + gxt = -FixedMul(trx, viewsin); + gyt = FixedMul(try, viewcos); + tx = -(gyt + gxt); + + if (abs(tx) > (tz << 2)) return; // too far off the side // @@ -482,20 +482,20 @@ void R_ProjectSprite (mobj_t *thing) // #ifdef RANGECHECK if ((unsigned)thing->sprite >= numsprites) - I_Error ("R_ProjectSprite: invalid sprite number %i ",thing->sprite); + I_Error ("R_ProjectSprite: invalid sprite number %i ", thing->sprite); #endif sprdef = &sprites[thing->sprite]; #ifdef RANGECHECK - if ( (thing->frame&FF_FRAMEMASK) >= sprdef->numframes ) + if ((thing->frame & FF_FRAMEMASK) >= sprdef->numframes) I_Error ("R_ProjectSprite: invalid sprite frame %i : %i " - ,thing->sprite, thing->frame); + , thing->sprite, thing->frame); #endif - sprframe = &sprdef->spriteframes[ thing->frame & FF_FRAMEMASK]; + sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK]; if (sprframe->rotate) { // choose a different rotation based on player view ang = R_PointToAngle (thing->x, thing->y); - rot = (ang-thing->angle+(unsigned)(ANG45/2)*9)>>29; + rot = (ang - thing->angle + (unsigned)(ANG45 / 2) * 9) >> 29; lump = sprframe->lump[rot]; flip = (boolean)sprframe->flip[rot]; } @@ -505,15 +505,15 @@ void R_ProjectSprite (mobj_t *thing) flip = (boolean)sprframe->flip[0]; } -// -// calculate edges of the shape -// + // + // calculate edges of the shape + // tx -= spriteoffset[lump]; - x1 = (centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS; + x1 = (centerxfrac + FixedMul (tx, xscale)) >> FRACBITS; if (x1 > viewwidth) return; // off the right side - tx += spritewidth[lump]; - x2 = ((centerxfrac + FixedMul (tx,xscale) ) >>FRACBITS) - 1; + tx += spritewidth[lump]; + x2 = ((centerxfrac + FixedMul (tx, xscale)) >> FRACBITS) - 1; if (x2 < 0) return; // off the left side @@ -524,27 +524,27 @@ void R_ProjectSprite (mobj_t *thing) vis = R_NewVisSprite (); vis->mobjflags = thing->flags; vis->psprite = false; - vis->scale = xscale<scale = xscale << detailshift; vis->gx = thing->x; vis->gy = thing->y; vis->gz = thing->z; vis->gzt = thing->z + spritetopoffset[lump]; // foot clipping - if(thing->flags2&MF2_FEETARECLIPPED + if (thing->flags2 & MF2_FEETARECLIPPED && thing->z <= thing->subsector->sector->floorheight) { vis->footclip = 10; } else vis->footclip = 0; - vis->texturemid = vis->gzt - viewz - (vis->footclip<texturemid = vis->gzt - viewz - (vis->footclip << FRACBITS); vis->x1 = x1 < 0 ? 0 : x1; - vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; + vis->x2 = x2 >= viewwidth ? viewwidth - 1 : x2; iscale = FixedDiv (FRACUNIT, xscale); if (flip) { - vis->startfrac = spritewidth[lump]-1; + vis->startfrac = spritewidth[lump] - 1; vis->xiscale = -iscale; } else @@ -553,15 +553,15 @@ void R_ProjectSprite (mobj_t *thing) vis->xiscale = iscale; } if (vis->x1 > x1) - vis->startfrac += vis->xiscale*(vis->x1-x1); + vis->startfrac += vis->xiscale * (vis->x1 - x1); vis->patch = lump; -// -// get light level -// + // + // get light level + // -// if (thing->flags & MF_SHADOW) -// vis->colormap = NULL; // shadow draw -// else ... + // if (thing->flags & MF_SHADOW) + // vis->colormap = NULL; // shadow draw + // else ... if (fixedcolormap) vis->colormap = fixedcolormap; // fixed map @@ -569,9 +569,9 @@ void R_ProjectSprite (mobj_t *thing) vis->colormap = colormaps; // full bright else { // diminished light - index = xscale>>(LIGHTSCALESHIFT-detailshift); + index = xscale >> (LIGHTSCALESHIFT - detailshift); if (index >= MAXLIGHTSCALE) - index = MAXLIGHTSCALE-1; + index = MAXLIGHTSCALE - 1; vis->colormap = spritelights[index]; } } @@ -589,7 +589,7 @@ void R_ProjectSprite (mobj_t *thing) void R_AddSprites (sector_t *sec) { - mobj_t *thing; + mobj_t *thing; int lightnum; if (sec->validcount == validcount) @@ -597,16 +597,16 @@ void R_AddSprites (sector_t *sec) sec->validcount = validcount; - lightnum = (sec->lightlevel >> LIGHTSEGSHIFT)+extralight; + lightnum = (sec->lightlevel >> LIGHTSEGSHIFT) + extralight; if (lightnum < 0) spritelights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) - spritelights = scalelight[LIGHTLEVELS-1]; + spritelights = scalelight[LIGHTLEVELS - 1]; else spritelights = scalelight[lightnum]; - for (thing = sec->thinglist ; thing ; thing = thing->snext) + for (thing = sec->thinglist; thing; thing = thing->snext) R_ProjectSprite (thing); } @@ -622,66 +622,66 @@ void R_AddSprites (sector_t *sec) int PSpriteSY[NUMWEAPONS] = { 0, // staff - 5*FRACUNIT, // goldwand - 15*FRACUNIT, // crossbow - 15*FRACUNIT, // blaster - 15*FRACUNIT, // skullrod - 15*FRACUNIT, // phoenix rod - 15*FRACUNIT, // mace - 15*FRACUNIT, // gauntlets - 15*FRACUNIT // beak + 5 * FRACUNIT, // goldwand + 15 * FRACUNIT, // crossbow + 15 * FRACUNIT, // blaster + 15 * FRACUNIT, // skullrod + 15 * FRACUNIT, // phoenix rod + 15 * FRACUNIT, // mace + 15 * FRACUNIT, // gauntlets + 15 * FRACUNIT // beak }; void R_DrawPSprite (pspdef_t *psp) { fixed_t tx; int x1, x2; - spritedef_t *sprdef; - spriteframe_t *sprframe; + spritedef_t *sprdef; + spriteframe_t *sprframe; int lump; boolean flip; - vissprite_t *vis, avis; + vissprite_t *vis, avis; int tempangle; -// -// decide which patch to use -// + // + // decide which patch to use + // #ifdef RANGECHECK - if ( (unsigned)psp->state->sprite >= numsprites) + if ((unsigned)psp->state->sprite >= numsprites) I_Error ("R_ProjectSprite: invalid sprite number %i " - , psp->state->sprite); + , psp->state->sprite); #endif sprdef = &sprites[psp->state->sprite]; #ifdef RANGECHECK - if ( (psp->state->frame & FF_FRAMEMASK) >= sprdef->numframes) + if ((psp->state->frame & FF_FRAMEMASK) >= sprdef->numframes) I_Error ("R_ProjectSprite: invalid sprite frame %i : %i " - , psp->state->sprite, psp->state->frame); + , psp->state->sprite, psp->state->frame); #endif - sprframe = &sprdef->spriteframes[ psp->state->frame & FF_FRAMEMASK ]; + sprframe = &sprdef->spriteframes[psp->state->frame & FF_FRAMEMASK]; lump = sprframe->lump[0]; flip = (boolean)sprframe->flip[0]; -// -// calculate edges of the shape -// - tx = psp->sx-160*FRACUNIT; + // + // calculate edges of the shape + // + tx = psp->sx - 160 * FRACUNIT; tx -= spriteoffset[lump]; - if(viewangleoffset) + if (viewangleoffset) { - tempangle = ((centerxfrac/1024)*(viewangleoffset>>ANGLETOFINESHIFT)); + tempangle = ((centerxfrac / 1024) * (viewangleoffset >> ANGLETOFINESHIFT)); } else { tempangle = 0; } - x1 = (centerxfrac + FixedMul (tx,pspritescale)+tempangle ) >>FRACBITS; + x1 = (centerxfrac + FixedMul (tx, pspritescale) + tempangle) >> FRACBITS; if (x1 > viewwidth) return; // off the right side - tx += spritewidth[lump]; - x2 = ((centerxfrac + FixedMul (tx, pspritescale)+tempangle ) >>FRACBITS) - 1; + tx += spritewidth[lump]; + x2 = ((centerxfrac + FixedMul (tx, pspritescale) + tempangle) >> FRACBITS) - 1; if (x2 < 0) return; // off the left side @@ -691,18 +691,18 @@ void R_DrawPSprite (pspdef_t *psp) vis = &avis; vis->mobjflags = 0; vis->psprite = true; - vis->texturemid = (BASEYCENTER<sy-spritetopoffset[lump]); - if(viewheight == SCREENHEIGHT) + vis->texturemid = (BASEYCENTER << FRACBITS) + FRACUNIT / 2 - (psp->sy - spritetopoffset[lump]); + if (viewheight == SCREENHEIGHT) { vis->texturemid -= PSpriteSY[players[consoleplayer].readyweapon]; } vis->x1 = x1 < 0 ? 0 : x1; - vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - vis->scale = pspritescale<x2 = x2 >= viewwidth ? viewwidth - 1 : x2; + vis->scale = pspritescale << detailshift; if (flip) { vis->xiscale = -pspriteiscale; - vis->startfrac = spritewidth[lump]-1; + vis->startfrac = spritewidth[lump] - 1; } else { @@ -710,22 +710,22 @@ void R_DrawPSprite (pspdef_t *psp) vis->startfrac = 0; } if (vis->x1 > x1) - vis->startfrac += vis->xiscale*(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) + if (viewplayer->powers[pw_invisibility] > 4 * 32 || + viewplayer->powers[pw_invisibility] & 8) { // Invisibility - vis->colormap = spritelights[MAXLIGHTSCALE-1]; + vis->colormap = spritelights[MAXLIGHTSCALE - 1]; vis->mobjflags |= MF_SHADOW; } - else if(fixedcolormap) + else if (fixedcolormap) { // Fixed color vis->colormap = fixedcolormap; } - else if(psp->state->frame & FF_FULLBRIGHT) + else if (psp->state->frame & FF_FULLBRIGHT) { // Full bright vis->colormap = colormaps; @@ -733,7 +733,7 @@ void R_DrawPSprite (pspdef_t *psp) else { // local light - vis->colormap = spritelights[MAXLIGHTSCALE-1]; + vis->colormap = spritelights[MAXLIGHTSCALE - 1]; } R_DrawVisSprite(vis, vis->x1, vis->x2); } @@ -749,29 +749,29 @@ void R_DrawPSprite (pspdef_t *psp) void R_DrawPlayerSprites (void) { int i, lightnum; - pspdef_t *psp; + pspdef_t *psp; -// -// get light level -// + // + // get light level + // lightnum = (viewplayer->mo->subsector->sector->lightlevel >> LIGHTSEGSHIFT) - +extralight; + + extralight; if (lightnum < 0) spritelights = scalelight[0]; else if (lightnum >= LIGHTLEVELS) - spritelights = scalelight[LIGHTLEVELS-1]; + spritelights = scalelight[LIGHTLEVELS - 1]; else spritelights = scalelight[lightnum]; -// -// clip to screen bounds -// + // + // clip to screen bounds + // mfloorclip = screenheightarray; mceilingclip = negonearray; -// -// add all active psprites -// - for (i=0, psp=viewplayer->psprites ; ipsprites; i < NUMPSPRITES; i++, psp++) if (psp->state) R_DrawPSprite (psp); @@ -791,7 +791,7 @@ vissprite_t vsprsortedhead; void R_SortVisSprites (void) { int i, count; - vissprite_t *ds, *best; + vissprite_t *ds, *best; vissprite_t unsorted; fixed_t bestscale; @@ -801,25 +801,25 @@ void R_SortVisSprites (void) if (!count) return; - for (ds=vissprites ; dsnext = ds+1; - ds->prev = ds-1; + 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; + (vissprite_p - 1)->next = &unsorted; + unsorted.prev = vissprite_p - 1; -// -// pull the vissprites out by scale -// + // + // pull the vissprites out by scale + // best = 0; // shut up the compiler warning vsprsortedhead.next = vsprsortedhead.prev = &vsprsortedhead; - for (i=0 ; inext) + for (ds = unsorted.next; ds != &unsorted; ds = ds->next) { if (ds->scale < bestscale) { @@ -848,26 +848,26 @@ void R_SortVisSprites (void) void R_DrawSprite (vissprite_t *spr) { - drawseg_t *ds; + drawseg_t *ds; short clipbot[SCREENWIDTH], cliptop[SCREENWIDTH]; int x, r1, r2; fixed_t scale, lowscale; int silhouette; - for (x = spr->x1 ; x<=spr->x2 ; x++) + for (x = spr->x1; x <= spr->x2; x++) clipbot[x] = cliptop[x] = -2; -// -// scan drawsegs from end to start for obscuring segs -// the first drawseg that has a greater scale is the clip seg -// - for (ds=ds_p-1 ; ds >= drawsegs ; ds--) + // + // scan drawsegs from end to start for obscuring segs + // the first drawseg that has a greater scale is the clip seg + // + for (ds = ds_p - 1; ds >= drawsegs; ds--) { // // determine if the drawseg obscures the sprite // if (ds->x1 > spr->x2 || ds->x2 < spr->x1 || - (!ds->silhouette && !ds->maskedtexturecol) ) + (!ds->silhouette && !ds->maskedtexturecol)) continue; // doesn't cover sprite r1 = ds->x1 < spr->x1 ? spr->x1 : ds->x1; @@ -883,17 +883,17 @@ void R_DrawSprite (vissprite_t *spr) scale = ds->scale2; } - if (scale < spr->scale || ( lowscale < spr->scale - && !R_PointOnSegSide (spr->gx, spr->gy, ds->curline) ) ) + if (scale < spr->scale || (lowscale < spr->scale + && !R_PointOnSegSide (spr->gx, spr->gy, ds->curline))) { if (ds->maskedtexturecol) // masked mid texture R_RenderMaskedSegRange (ds, r1, r2); continue; // seg is behind sprite } -// -// clip this piece of the sprite -// + // + // clip this piece of the sprite + // silhouette = ds->silhouette; if (spr->gz >= ds->bsilheight) silhouette &= ~SIL_BOTTOM; @@ -902,19 +902,19 @@ void R_DrawSprite (vissprite_t *spr) if (silhouette == 1) { // bottom sil - for (x=r1 ; x<=r2 ; x++) + for (x = r1; x <= r2; x++) if (clipbot[x] == -2) clipbot[x] = ds->sprbottomclip[x]; } else if (silhouette == 2) { // top sil - for (x=r1 ; x<=r2 ; x++) + for (x = r1; x <= r2; x++) if (cliptop[x] == -2) cliptop[x] = ds->sprtopclip[x]; } else if (silhouette == 3) { // both - for (x=r1 ; x<=r2 ; x++) + for (x = r1; x <= r2; x++) { if (clipbot[x] == -2) clipbot[x] = ds->sprbottomclip[x]; @@ -925,12 +925,12 @@ void R_DrawSprite (vissprite_t *spr) } -// -// all clipping has been performed, so draw the sprite -// + // + // all clipping has been performed, so draw the sprite + // -// check for unclipped columns - for (x = spr->x1 ; x<=spr->x2 ; x++) + // check for unclipped columns + for (x = spr->x1; x <= spr->x2; x++) { if (clipbot[x] == -2) clipbot[x] = viewheight; @@ -954,39 +954,39 @@ void R_DrawSprite (vissprite_t *spr) void R_DrawMasked (void) { - vissprite_t *spr; - drawseg_t *ds; + vissprite_t *spr; + drawseg_t *ds; R_SortVisSprites (); if (vissprite_p > vissprites) { - // draw all vissprites back to front + // draw all vissprites back to front - for (spr = vsprsortedhead.next ; spr != &vsprsortedhead - ; spr=spr->next) + for (spr = vsprsortedhead.next; spr != &vsprsortedhead + ; spr = spr->next) R_DrawSprite (spr); } -// -// render any remaining masked mid textures -// - for (ds=ds_p-1 ; ds >= drawsegs ; ds--) + // + // render any remaining masked mid textures + // + for (ds = ds_p - 1; ds >= drawsegs; ds--) if (ds->maskedtexturecol) R_RenderMaskedSegRange (ds, ds->x1, ds->x2); -// -// draw the psprites on top of everything -// -// Added for the sideviewing with an external device - if (viewangleoffset <= 1024<= - -1024<= + -1024 << ANGLETOFINESHIFT) + { // don't draw on side views R_DrawPlayerSprites (); } -// if (!viewangleoffset) // don't draw on side views -// R_DrawPlayerSprites (); + // if (!viewangleoffset) // don't draw on side views + // R_DrawPlayerSprites (); } diff --git a/SB_BAR.C b/SB_BAR.C index d8ac715..5186263 100644 --- a/SB_BAR.C +++ b/SB_BAR.C @@ -306,11 +306,11 @@ static byte CheatIDDQDSeq[] = /* FS: From Doom */ static byte CheatIDMUSSeq[] = { - CHEAT_ENCRYPT('i'), - CHEAT_ENCRYPT('d'), - CHEAT_ENCRYPT('m'), - CHEAT_ENCRYPT('u'), - CHEAT_ENCRYPT('s'), + CHEAT_ENCRYPT('i'), + CHEAT_ENCRYPT('d'), + CHEAT_ENCRYPT('m'), + CHEAT_ENCRYPT('u'), + CHEAT_ENCRYPT('s'), 0, 0, 0xff, 0 }; @@ -366,7 +366,7 @@ void SB_Init(void) PatchBARBACK = W_CacheLumpName("BARBACK", PU_STATIC); PatchINVBAR = W_CacheLumpName("INVBAR", PU_STATIC); PatchCHAIN = W_CacheLumpName("CHAIN", PU_STATIC); - if(deathmatch) + if (deathmatch) { PatchSTATBAR = W_CacheLumpName("STATBAR", PU_STATIC); } @@ -374,7 +374,7 @@ void SB_Init(void) { PatchSTATBAR = W_CacheLumpName("LIFEBAR", PU_STATIC); } - if(!netgame) + if (!netgame) { // single player game uses red life gem PatchLIFEGEM = W_CacheLumpName("LIFEGEM2", PU_STATIC); } @@ -390,25 +390,25 @@ void SB_Init(void) PatchINVLFGEM2 = W_CacheLumpName("INVGEML2", PU_STATIC); PatchINVRTGEM1 = W_CacheLumpName("INVGEMR1", PU_STATIC); PatchINVRTGEM2 = W_CacheLumpName("INVGEMR2", PU_STATIC); - PatchBLACKSQ = W_CacheLumpName("BLACKSQ", PU_STATIC); + PatchBLACKSQ = W_CacheLumpName("BLACKSQ", PU_STATIC); PatchARMCLEAR = W_CacheLumpName("ARMCLEAR", PU_STATIC); PatchCHAINBACK = W_CacheLumpName("CHAINBACK", PU_STATIC); startLump = W_GetNumForName("IN0"); - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) { - PatchINumbers[i] = W_CacheLumpNum(startLump+i, PU_STATIC); + PatchINumbers[i] = W_CacheLumpNum(startLump + i, PU_STATIC); } PatchNEGATIVE = W_CacheLumpName("NEGNUM", PU_STATIC); FontBNumBase = W_GetNumForName("FONTB16"); startLump = W_GetNumForName("SMALLIN0"); - for(i = 0; i < 10; i++) + for (i = 0; i < 10; i++) { - PatchSmNumbers[i] = W_CacheLumpNum(startLump+i, PU_STATIC); + PatchSmNumbers[i] = W_CacheLumpNum(startLump + i, PU_STATIC); } playpalette = W_GetNumForName("PLAYPAL"); spinbooklump = W_GetNumForName("SPINBK0"); spinflylump = W_GetNumForName("SPFLY0"); - for(i = 0; i < 256; i++) + for (i = 0; i < 256; i++) { CheatLookup[i] = CHEAT_ENCRYPT(i); } @@ -425,36 +425,36 @@ void SB_Ticker(void) int delta; int curHealth; - if(leveltime&1) + if (leveltime & 1) { - ChainWiggle = P_Random()&1; + ChainWiggle = P_Random() & 1; } curHealth = players[consoleplayer].mo->health; - if(curHealth < 0) + if (curHealth < 0) { curHealth = 0; } - if(curHealth < HealthMarker) + if (curHealth < HealthMarker) { - delta = (HealthMarker-curHealth)>>2; - if(delta < 1) + delta = (HealthMarker - curHealth) >> 2; + if (delta < 1) { delta = 1; } - else if(delta > 8) + else if (delta > 8) { delta = 8; } HealthMarker -= delta; } - else if(curHealth > HealthMarker) + else if (curHealth > HealthMarker) { - delta = (curHealth-HealthMarker)>>2; - if(delta < 1) + delta = (curHealth - HealthMarker) >> 2; + if (delta < 1) { delta = 1; } - else if(delta > 8) + else if (delta > 8) { delta = 8; } @@ -476,34 +476,34 @@ static void DrINumber(signed int val, int x, int y) int oldval; oldval = val; - if(val < 0) + if (val < 0) { - if(val < -9) + if (val < -9) { - V_DrawPatch(x+1, y+1, W_CacheLumpName("LAME", PU_CACHE)); + V_DrawPatch(x + 1, y + 1, W_CacheLumpName("LAME", PU_CACHE)); } else { val = -val; - V_DrawPatch(x+18, y, PatchINumbers[val]); - V_DrawPatch(x+9, y, PatchNEGATIVE); + V_DrawPatch(x + 18, y, PatchINumbers[val]); + V_DrawPatch(x + 9, y, PatchNEGATIVE); } return; } - if(val > 99) + if (val > 99) { - patch = PatchINumbers[val/100]; + patch = PatchINumbers[val / 100]; V_DrawPatch(x, y, patch); } - val = val%100; - if(val > 9 || oldval > 99) + val = val % 100; + if (val > 9 || oldval > 99) { - patch = PatchINumbers[val/10]; - V_DrawPatch(x+9, y, patch); + patch = PatchINumbers[val / 10]; + V_DrawPatch(x + 9, y, patch); } - val = val%10; + val = val % 10; patch = PatchINumbers[val]; - V_DrawPatch(x+18, y, patch); + V_DrawPatch(x + 18, y, patch); } //--------------------------------------------------------------------------- @@ -522,26 +522,26 @@ static void DrBNumber(signed int val, int x, int y) oldval = val; xpos = x; - if(val < 0) + if (val < 0) { val = 0; } - if(val > 99) + if (val > 99) { - patch = W_CacheLumpNum(FontBNumBase+val/100, PU_CACHE); - V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch); + patch = W_CacheLumpNum(FontBNumBase + val / 100, PU_CACHE); + V_DrawShadowedPatch(xpos + 6 - patch->width / 2, y, patch); } - val = val%100; + val = val % 100; xpos += 12; - if(val > 9 || oldval > 99) + if (val > 9 || oldval > 99) { - patch = W_CacheLumpNum(FontBNumBase+val/10, PU_CACHE); - V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch); + patch = W_CacheLumpNum(FontBNumBase + val / 10, PU_CACHE); + V_DrawShadowedPatch(xpos + 6 - patch->width / 2, y, patch); } - val = val%10; + val = val % 10; xpos += 12; - patch = W_CacheLumpNum(FontBNumBase+val, PU_CACHE); - V_DrawShadowedPatch(xpos+6-patch->width/2, y, patch); + patch = W_CacheLumpNum(FontBNumBase + val, PU_CACHE); + V_DrawShadowedPatch(xpos + 6 - patch->width / 2, y, patch); } //--------------------------------------------------------------------------- @@ -556,18 +556,18 @@ static void DrSmallNumber(int val, int x, int y) { patch_t *patch; - if(val == 1) + if (val == 1) { return; } - if(val > 9) + if (val > 9) { - patch = PatchSmNumbers[val/10]; + patch = PatchSmNumbers[val / 10]; V_DrawPatch(x, y, patch); } - val = val%10; + val = val % 10; patch = PatchSmNumbers[val]; - V_DrawPatch(x+4, y, patch); + V_DrawPatch(x + 4, y, patch); } //--------------------------------------------------------------------------- @@ -581,11 +581,11 @@ static void ShadeLine(int x, int y, int height, int shade) byte *dest; byte *shades; - shades = colormaps+9*256+shade*2*256; - dest = screen+y*SCREENWIDTH+x; - while(height--) + shades = colormaps + 9 * 256 + shade * 2 * 256; + dest = screen + y * SCREENWIDTH + x; + while (height--) { - *(dest) = *(shades+*dest); + *(dest) = *(shades + *dest); dest += SCREENWIDTH; } } @@ -600,10 +600,10 @@ static void ShadeChain(void) { int i; - for(i = 0; i < 16; i++) + for (i = 0; i < 16; i++) { - ShadeLine(277+i, 190, 10, i/2); - ShadeLine(19+i, 190, 10, 7-(i/2)); + ShadeLine(277 + i, 190, 10, i / 2); + ShadeLine(19 + i, 190, 10, 7 - (i / 2)); } } @@ -623,14 +623,14 @@ static void DrawSoundInfo(void) char text[32]; int x; int y; - int xPos[7] = {1, 75, 112, 156, 200, 230, 260}; + int xPos[7] = { 1, 75, 112, 156, 200, 230, 260 }; - if(leveltime&16) + if (leveltime & 16) { MN_DrTextA("*** SOUND DEBUG INFO ***", xPos[0], 20); } S_GetChannelInfo(&s); - if(s.channelCount == 0) + if (s.channelCount == 0) { return; } @@ -642,12 +642,12 @@ static void DrawSoundInfo(void) MN_DrTextA("ID", xPos[x++], 30); MN_DrTextA("PRI", xPos[x++], 30); MN_DrTextA("DIST", xPos[x++], 30); - for(i = 0; i < s.channelCount; i++) + for (i = 0; i < s.channelCount; i++) { c = &s.chan[i]; x = 0; - y = 40+i*10; - if(c->mo == NULL) + y = 40 + i * 10; + if (c->mo == NULL) { // Channel is unused MN_DrTextA("------", xPos[0], y); continue; @@ -657,9 +657,9 @@ static void DrawSoundInfo(void) MN_DrTextA(text, xPos[x++], y); sprintf(text, "%d", c->mo->type); MN_DrTextA(text, xPos[x++], y); - sprintf(text, "%d", c->mo->x>>FRACBITS); + sprintf(text, "%d", c->mo->x >> FRACBITS); MN_DrTextA(text, xPos[x++], y); - sprintf(text, "%d", c->mo->y>>FRACBITS); + sprintf(text, "%d", c->mo->y >> FRACBITS); MN_DrTextA(text, xPos[x++], y); sprintf(text, "%d", c->id); MN_DrTextA(text, xPos[x++], y); @@ -724,22 +724,22 @@ void SB_Drawer(void) static boolean hitCenterFrame; // Sound info debug stuff - if(DebugSound == true) + if (DebugSound == true) { DrawSoundInfo(); } CPlayer = &players[consoleplayer]; - if(viewheight == SCREENHEIGHT && !automapactive) + if (viewheight == SCREENHEIGHT && !automapactive) { DrawFullScreenStuff(); SB_state = -1; } else { - if(SB_state == -1) + if (SB_state == -1) { V_DrawPatch(0, 158, PatchBARBACK); - if(players[consoleplayer].cheats&CF_GODMODE) + if (players[consoleplayer].cheats & CF_GODMODE) { V_DrawPatch(16, 167, W_CacheLumpName("GOD1", PU_CACHE)); V_DrawPatch(287, 167, W_CacheLumpName("GOD2", PU_CACHE)); @@ -747,9 +747,9 @@ void SB_Drawer(void) oldhealth = -1; } DrawCommonBar(); - if(!inventory) + if (!inventory) { - if(SB_state != 0) + if (SB_state != 0) { // Main interface V_DrawPatch(34, 160, PatchSTATBAR); @@ -766,7 +766,7 @@ void SB_Drawer(void) } else { - if(SB_state != 1) + if (SB_state != 1) { V_DrawPatch(34, 160, PatchINVBAR); } @@ -777,37 +777,37 @@ void SB_Drawer(void) SB_PaletteFlash(); // Flight icons - if(CPlayer->powers[pw_flight]) + if (CPlayer->powers[pw_flight]) { - if(CPlayer->powers[pw_flight] > BLINKTHRESHOLD - || !(CPlayer->powers[pw_flight]&16)) + if (CPlayer->powers[pw_flight] > BLINKTHRESHOLD + || !(CPlayer->powers[pw_flight] & 16)) { - frame = (leveltime/3)&15; - if(CPlayer->mo->flags2&MF2_FLY) + frame = (leveltime / 3) & 15; + if (CPlayer->mo->flags2 & MF2_FLY) { - if(hitCenterFrame && (frame != 15 && frame != 0)) + if (hitCenterFrame && (frame != 15 && frame != 0)) { - V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump+15, + V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump + 15, PU_CACHE)); } else { - V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump+frame, + V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump + frame, PU_CACHE)); hitCenterFrame = false; } } else { - if(!hitCenterFrame && (frame != 15 && frame != 0)) + if (!hitCenterFrame && (frame != 15 && frame != 0)) { - V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump+frame, + V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump + frame, PU_CACHE)); hitCenterFrame = false; } else { - V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump+15, + V_DrawPatch(20, 17, W_CacheLumpNum(spinflylump + 15, PU_CACHE)); hitCenterFrame = true; } @@ -822,13 +822,13 @@ void SB_Drawer(void) } } - if(CPlayer->powers[pw_weaponlevel2] && !CPlayer->chickenTics) + if (CPlayer->powers[pw_weaponlevel2] && !CPlayer->chickenTics) { - if(CPlayer->powers[pw_weaponlevel2] > BLINKTHRESHOLD - || !(CPlayer->powers[pw_weaponlevel2]&16)) + if (CPlayer->powers[pw_weaponlevel2] > BLINKTHRESHOLD + || !(CPlayer->powers[pw_weaponlevel2] & 16)) { - frame = (leveltime/3)&15; - V_DrawPatch(300, 17, W_CacheLumpNum(spinbooklump+frame, PU_CACHE)); + frame = (leveltime / 3) & 15; + V_DrawPatch(300, 17, W_CacheLumpNum(spinbooklump + frame, PU_CACHE)); BorderTopRefresh = true; UpdateState |= I_MESSAGES; } @@ -851,21 +851,21 @@ void SB_PaletteFlash(void) CPlayer = &players[consoleplayer]; - if(CPlayer->damagecount) + if (CPlayer->damagecount) { - palette = (CPlayer->damagecount+7)>>3; - if(palette >= NUMREDPALS) + palette = (CPlayer->damagecount + 7) >> 3; + if (palette >= NUMREDPALS) { - palette = NUMREDPALS-1; + palette = NUMREDPALS - 1; } palette += STARTREDPALS; } - else if(CPlayer->bonuscount) + else if (CPlayer->bonuscount) { - palette = (CPlayer->bonuscount+7)>>3; - if(palette >= NUMBONUSPALS) + palette = (CPlayer->bonuscount + 7) >> 3; + if (palette >= NUMBONUSPALS) { - palette = NUMBONUSPALS-1; + palette = NUMBONUSPALS - 1; } palette += STARTBONUSPALS; } @@ -877,10 +877,10 @@ void SB_PaletteFlash(void) if (usePalFlash == false || usevrgoggles) /* FS: Palette flashing toggle or FIXME: No palette flashing with SimulEyes as it fucks up the shutters */ palette = 0; - if(palette != sb_palette) + if (palette != sb_palette) { sb_palette = palette; - pal = (byte *)W_CacheLumpNum(playpalette, PU_CACHE)+palette*768; + pal = (byte *)W_CacheLumpNum(playpalette, PU_CACHE) + palette * 768; I_SetPalette(pal); } } @@ -899,23 +899,23 @@ void DrawCommonBar(void) V_DrawPatch(0, 148, PatchLTFCTOP); V_DrawPatch(290, 148, PatchRTFCTOP); - if(oldhealth != HealthMarker) + if (oldhealth != HealthMarker) { oldhealth = HealthMarker; healthPos = HealthMarker; - if(healthPos < 0) + if (healthPos < 0) { healthPos = 0; } - if(healthPos > 100) + if (healthPos > 100) { healthPos = 100; } - healthPos = (healthPos*256)/100; - chainY = (HealthMarker == CPlayer->mo->health) ? 191 : 191+ChainWiggle; + healthPos = (healthPos * 256) / 100; + chainY = (HealthMarker == CPlayer->mo->health) ? 191 : 191 + ChainWiggle; V_DrawPatch(0, 190, PatchCHAINBACK); - V_DrawPatch(2+(healthPos%17), chainY, PatchCHAIN); - V_DrawPatch(17+healthPos, chainY, PatchLIFEGEM); + V_DrawPatch(2 + (healthPos % 17), chainY, PatchCHAIN); + V_DrawPatch(17 + healthPos, chainY, PatchLIFEGEM); V_DrawPatch(0, 190, PatchLTFACE); V_DrawPatch(276, 190, PatchRTFACE); ShadeChain(); @@ -935,7 +935,7 @@ void DrawMainBar(void) int temp; // Ready artifact - if(ArtifactFlash) + if (ArtifactFlash) { V_DrawPatch(180, 161, PatchBLACKSQ); V_DrawPatch(182, 161, W_CacheLumpNum(W_GetNumForName("useartia") @@ -944,13 +944,13 @@ void DrawMainBar(void) oldarti = -1; // so that the correct artifact fills in after the flash UpdateState |= I_STATBAR; } - else if(oldarti != CPlayer->readyArtifact + else if (oldarti != CPlayer->readyArtifact || oldartiCount != CPlayer->inventory[inv_ptr].count) { V_DrawPatch(180, 161, PatchBLACKSQ); - if(CPlayer->readyArtifact > 0) + if (CPlayer->readyArtifact > 0) { - V_DrawPatch(179,160, W_CacheLumpName(patcharti[CPlayer->readyArtifact], + V_DrawPatch(179, 160, W_CacheLumpName(patcharti[CPlayer->readyArtifact], PU_CACHE)); DrSmallNumber(CPlayer->inventory[inv_ptr].count, 201, 182); } @@ -960,14 +960,14 @@ void DrawMainBar(void) } // Frags - if(deathmatch) + if (deathmatch) { temp = 0; - for(i = 0; i < MAXPLAYERS; i++) + for (i = 0; i < MAXPLAYERS; i++) { temp += CPlayer->frags[i]; } - if(temp != oldfrags) + if (temp != oldfrags) { V_DrawPatch(57, 171, PatchARMCLEAR); DrINumber(temp, 61, 170); @@ -978,15 +978,15 @@ void DrawMainBar(void) else { temp = HealthMarker; - if(temp < 0) + if (temp < 0) { temp = 0; } - else if(temp > 100) + else if (temp > 100) { temp = 100; } - if(oldlife != temp) + if (oldlife != temp) { oldlife = temp; V_DrawPatch(57, 171, PatchARMCLEAR); @@ -996,17 +996,17 @@ void DrawMainBar(void) } // Keys - if(oldkeys != playerkeys) + if (oldkeys != playerkeys) { - if(CPlayer->keys[key_yellow]) + if (CPlayer->keys[key_yellow]) { V_DrawPatch(153, 164, W_CacheLumpName("ykeyicon", PU_CACHE)); } - if(CPlayer->keys[key_green]) + if (CPlayer->keys[key_green]) { V_DrawPatch(153, 172, W_CacheLumpName("gkeyicon", PU_CACHE)); } - if(CPlayer->keys[key_blue]) + if (CPlayer->keys[key_blue]) { V_DrawPatch(153, 180, W_CacheLumpName("bkeyicon", PU_CACHE)); } @@ -1015,14 +1015,14 @@ void DrawMainBar(void) } // Ammo temp = CPlayer->ammo[wpnlev1info[CPlayer->readyweapon].ammo]; - if(oldammo != temp || oldweapon != CPlayer->readyweapon) + if (oldammo != temp || oldweapon != CPlayer->readyweapon) { V_DrawPatch(108, 161, PatchBLACKSQ); - if(temp && CPlayer->readyweapon > 0 && CPlayer->readyweapon < 7) + if (temp && CPlayer->readyweapon > 0 && CPlayer->readyweapon < 7) { DrINumber(temp, 109, 162); V_DrawPatch(111, 172, W_CacheLumpName( - ammopic[CPlayer->readyweapon-1], PU_CACHE)); + ammopic[CPlayer->readyweapon - 1], PU_CACHE)); } oldammo = temp; oldweapon = CPlayer->readyweapon; @@ -1030,7 +1030,7 @@ void DrawMainBar(void) } // Armor - if(oldarmor != CPlayer->armorpoints) + if (oldarmor != CPlayer->armorpoints) { V_DrawPatch(224, 171, PatchARMCLEAR); DrINumber(CPlayer->armorpoints, 228, 170); @@ -1050,28 +1050,28 @@ void DrawInventoryBar(void) int i; int x; - x = inv_ptr-curpos; + x = inv_ptr - curpos; UpdateState |= I_STATBAR; V_DrawPatch(34, 160, PatchINVBAR); - for(i = 0; i < 7; i++) + for (i = 0; i < 7; i++) { - if(CPlayer->inventorySlotNum > x+i - && CPlayer->inventory[x+i].type != arti_none) + if (CPlayer->inventorySlotNum > x + i + && CPlayer->inventory[x + i].type != arti_none) { - V_DrawPatch(50+i*31, 160, W_CacheLumpName( - patcharti[CPlayer->inventory[x+i].type], PU_CACHE)); - DrSmallNumber(CPlayer->inventory[x+i].count, 69+i*31, 182); + V_DrawPatch(50 + i * 31, 160, W_CacheLumpName( + patcharti[CPlayer->inventory[x + i].type], PU_CACHE)); + DrSmallNumber(CPlayer->inventory[x + i].count, 69 + i * 31, 182); } } - V_DrawPatch(50+curpos*31, 189, PatchSELECTBOX); - if(x != 0) + V_DrawPatch(50 + curpos * 31, 189, PatchSELECTBOX); + if (x != 0) { - V_DrawPatch(38, 159,!(leveltime&4) ? PatchINVLFGEM1 : + V_DrawPatch(38, 159, !(leveltime & 4) ? PatchINVLFGEM1 : PatchINVLFGEM2); } - if(CPlayer->inventorySlotNum-x > 7) + if (CPlayer->inventorySlotNum - x > 7) { - V_DrawPatch(269, 159,!(leveltime&4) ? + V_DrawPatch(269, 159, !(leveltime & 4) ? PatchINVRTGEM1 : PatchINVRTGEM2); } } @@ -1083,7 +1083,7 @@ void DrawFullScreenStuff(void) int temp; UpdateState |= I_FULLSCRN; - if(CPlayer->mo->health > 0) + if (CPlayer->mo->health > 0) { DrBNumber(CPlayer->mo->health, 5, 180); } @@ -1095,17 +1095,17 @@ void DrawFullScreenStuff(void) /* FS: For Armor */ if (!inventory) DrBNumber(CPlayer->armorpoints, 240, 180); - + /* FS: For Ammo */ if (!inventory) - { + { temp = CPlayer->ammo[wpnlev1info[CPlayer->readyweapon].ammo]; { - if(temp && CPlayer->readyweapon > 0 && CPlayer->readyweapon < 7) + if (temp && CPlayer->readyweapon > 0 && CPlayer->readyweapon < 7) { if (temp < 100) { - switch(CPlayer->readyweapon) + switch (CPlayer->readyweapon) { case 1: case 2: @@ -1121,40 +1121,40 @@ void DrawFullScreenStuff(void) DrINumber(temp, 25, 162); V_DrawPatch(0, 162, W_CacheLumpName( - ammopic[CPlayer->readyweapon-1], PU_CACHE)); + ammopic[CPlayer->readyweapon - 1], PU_CACHE)); } } } /* FS: Draw keys */ - if(CPlayer->keys[key_yellow]) + if (CPlayer->keys[key_yellow]) { V_DrawPatch(286, 162, W_CacheLumpName("ykeyicon", PU_CACHE)); } - if(CPlayer->keys[key_green]) + if (CPlayer->keys[key_green]) { V_DrawPatch(296, 162, W_CacheLumpName("gkeyicon", PU_CACHE)); } - if(CPlayer->keys[key_blue]) + if (CPlayer->keys[key_blue]) { V_DrawPatch(306, 162, W_CacheLumpName("bkeyicon", PU_CACHE)); } - if(deathmatch) + if (deathmatch) { temp = 0; - for(i=0; ifrags[i]; } } DrINumber(temp, 45, 185); } - if(!inventory) + if (!inventory) { - if(CPlayer->readyArtifact > 0) + if (CPlayer->readyArtifact > 0) { V_DrawFuzzPatch(286, 170, W_CacheLumpName("ARTIBOX", PU_CACHE)); @@ -1165,28 +1165,28 @@ void DrawFullScreenStuff(void) } else { - x = inv_ptr-curpos; - for(i = 0; i < 7; i++) + x = inv_ptr - curpos; + for (i = 0; i < 7; i++) { - V_DrawFuzzPatch(50+i*31, 168, W_CacheLumpName("ARTIBOX", + V_DrawFuzzPatch(50 + i * 31, 168, W_CacheLumpName("ARTIBOX", PU_CACHE)); - if(CPlayer->inventorySlotNum > x+i - && CPlayer->inventory[x+i].type != arti_none) + if (CPlayer->inventorySlotNum > x + i + && CPlayer->inventory[x + i].type != arti_none) { - V_DrawPatch(50+i*31, 168, W_CacheLumpName( - patcharti[CPlayer->inventory[x+i].type], PU_CACHE)); - DrSmallNumber(CPlayer->inventory[x+i].count, 69+i*31, 190); + V_DrawPatch(50 + i * 31, 168, W_CacheLumpName( + patcharti[CPlayer->inventory[x + i].type], PU_CACHE)); + DrSmallNumber(CPlayer->inventory[x + i].count, 69 + i * 31, 190); } } - V_DrawPatch(50+curpos*31, 197, PatchSELECTBOX); - if(x != 0) + V_DrawPatch(50 + curpos * 31, 197, PatchSELECTBOX); + if (x != 0) { - V_DrawPatch(38, 167, !(leveltime&4) ? PatchINVLFGEM1 : + V_DrawPatch(38, 167, !(leveltime & 4) ? PatchINVLFGEM1 : PatchINVLFGEM2); } - if(CPlayer->inventorySlotNum-x > 7) + if (CPlayer->inventorySlotNum - x > 7) { - V_DrawPatch(269, 167, !(leveltime&4) ? + V_DrawPatch(269, 167, !(leveltime & 4) ? PatchINVRTGEM1 : PatchINVRTGEM2); } } @@ -1200,9 +1200,9 @@ void DrawFullScreenStuff(void) boolean SB_Responder(event_t *event) { - if(event->type == ev_keydown) + if (event->type == ev_keydown) { - if(HandleCheats(event->data1)) + if (HandleCheats(event->data1)) { // Need to eat the key return(true); } @@ -1226,21 +1226,21 @@ static boolean HandleCheats(byte key) #if 0 if (!M_CheckParm("-cheats")) /* FS: Cheating in multiplayer */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) { // Can't cheat in a net-game, or in nightmare mode return(false); } } #endif - if(players[consoleplayer].health <= 0) + if (players[consoleplayer].health <= 0) { // Dead players can't cheat return(false); } eat = false; - for(i = 0; Cheats[i].func != NULL; i++) + for (i = 0; Cheats[i].func != NULL; i++) { - if(CheatAddKey(&Cheats[i], key, &eat)) + if (CheatAddKey(&Cheats[i], key, &eat)) { Cheats[i].func(&players[consoleplayer], &Cheats[i]); } @@ -1258,18 +1258,18 @@ static boolean HandleCheats(byte key) static boolean CheatAddKey(Cheat_t *cheat, byte key, boolean *eat) { - if(!cheat->pos) + if (!cheat->pos) { cheat->pos = cheat->sequence; cheat->currentArg = 0; } - if(*cheat->pos == 0) + if (*cheat->pos == 0) { *eat = true; cheat->args[cheat->currentArg++] = key; cheat->pos++; } - else if(CheatLookup[key] == *cheat->pos) + else if (CheatLookup[key] == *cheat->pos) { cheat->pos++; } @@ -1278,7 +1278,7 @@ static boolean CheatAddKey(Cheat_t *cheat, byte key, boolean *eat) cheat->pos = cheat->sequence; cheat->currentArg = 0; } - if(*cheat->pos == 0xff) + if (*cheat->pos == 0xff) { cheat->pos = cheat->sequence; cheat->currentArg = 0; @@ -1297,13 +1297,13 @@ static void CheatGodFunc(player_t *player, Cheat_t *cheat) { if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); player->cheats ^= CF_GODMODE; - if(player->cheats&CF_GODMODE) + if (player->cheats & CF_GODMODE) { P_SetMessage(player, TXT_CHEATGODON, false); } @@ -1318,13 +1318,13 @@ static void CheatNoClipFunc(player_t *player, Cheat_t *cheat) { if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); player->cheats ^= CF_NOCLIP; - if(player->cheats&CF_NOCLIP) + if (player->cheats & CF_NOCLIP) { P_SetMessage(player, TXT_CHEATNOCLIPON, false); } @@ -1341,32 +1341,32 @@ static void CheatWeaponsFunc(player_t *player, Cheat_t *cheat) if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); player->armorpoints = 200; player->armortype = 2; - if(!player->backpack) + if (!player->backpack) { - for(i = 0; i < NUMAMMO; i++) + for (i = 0; i < NUMAMMO; i++) { player->maxammo[i] *= 2; } player->backpack = true; } - for(i = 0; i < NUMWEAPONS-1; i++) + for (i = 0; i < NUMWEAPONS - 1; i++) { player->weaponowned[i] = true; } - if(shareware) + if (shareware) { player->weaponowned[wp_skullrod] = false; player->weaponowned[wp_phoenixrod] = false; player->weaponowned[wp_mace] = false; } - for(i = 0; i < NUMAMMO; i++) + for (i = 0; i < NUMAMMO; i++) { player->ammo[i] = player->maxammo[i]; } @@ -1377,12 +1377,12 @@ static void CheatPowerFunc(player_t *player, Cheat_t *cheat) { if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); - if(player->powers[pw_weaponlevel2]) + if (player->powers[pw_weaponlevel2]) { player->powers[pw_weaponlevel2] = 0; P_SetMessage(player, TXT_CHEATPOWEROFF, false); @@ -1398,12 +1398,12 @@ static void CheatHealthFunc(player_t *player, Cheat_t *cheat) { if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); - if(player->chickenTics) + if (player->chickenTics) { player->health = player->mo->health = MAXCHICKENHEALTH; } @@ -1420,7 +1420,7 @@ static void CheatKeysFunc(player_t *player, Cheat_t *cheat) if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } @@ -1436,13 +1436,13 @@ static void CheatSoundFunc(player_t *player, Cheat_t *cheat) { if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); DebugSound = !DebugSound; - if(DebugSound) + if (DebugSound) { P_SetMessage(player, TXT_CHEATSOUNDON, false); } @@ -1458,13 +1458,13 @@ static void CheatTickerFunc(player_t *player, Cheat_t *cheat) if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); DisplayTicker = !DisplayTicker; - if(DisplayTicker) + if (DisplayTicker) { P_SetMessage(player, TXT_CHEATTICKERON, false); } @@ -1478,7 +1478,7 @@ static void CheatArtifact1Func(player_t *player, Cheat_t *cheat) { if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } @@ -1490,7 +1490,7 @@ static void CheatArtifact2Func(player_t *player, Cheat_t *cheat) { if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } @@ -1507,38 +1507,38 @@ static void CheatArtifact3Func(player_t *player, Cheat_t *cheat) if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); - type = cheat->args[0]-'a'+1; - count = cheat->args[1]-'0'; - if(type == 26 && count == 0) + type = cheat->args[0] - 'a' + 1; + count = cheat->args[1] - '0'; + if (type == 26 && count == 0) { // All artifacts - for(i = arti_none+1; i < NUMARTIFACTS; i++) + for (i = arti_none + 1; i < NUMARTIFACTS; i++) { - if(shareware && (i == arti_superhealth + if (shareware && (i == arti_superhealth || i == arti_teleport)) { continue; } - for(j = 0; j < 16; j++) + for (j = 0; j < 16; j++) { P_GiveArtifact(player, i, NULL); } } P_SetMessage(player, TXT_CHEATARTIFACTS3, false); } - else if(type > arti_none && type < NUMARTIFACTS + else if (type > arti_none && type < NUMARTIFACTS && count > 0 && count < 10) { - if(shareware && (type == arti_superhealth || type == arti_teleport)) + if (shareware && (type == arti_superhealth || type == arti_teleport)) { P_SetMessage(player, TXT_CHEATARTIFACTSFAIL, false); return; } - for(i = 0; i < count; i++) + for (i = 0; i < count; i++) { P_GiveArtifact(player, type, NULL); } @@ -1557,14 +1557,14 @@ static void CheatWarpFunc(player_t *player, Cheat_t *cheat) if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); - episode = cheat->args[0]-'0'; - map = cheat->args[1]-'0'; - if(M_ValidEpisodeMap(episode, map)) + episode = cheat->args[0] - '0'; + map = cheat->args[1] - '0'; + if (M_ValidEpisodeMap(episode, map)) { G_DeferedInitNew(gameskill, episode, map); P_SetMessage(player, TXT_CHEATWARP, false); @@ -1573,23 +1573,23 @@ static void CheatWarpFunc(player_t *player, Cheat_t *cheat) static void CheatChickenFunc(player_t *player, Cheat_t *cheat) { - extern boolean P_UndoPlayerChicken(player_t *player); + extern boolean P_UndoPlayerChicken(player_t * player); if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); - if(player->chickenTics) + if (player->chickenTics) { - if(P_UndoPlayerChicken(player)) + if (P_UndoPlayerChicken(player)) { P_SetMessage(player, TXT_CHEATCHICKENOFF, false); } } - else if(P_ChickenMorphPlayer(player)) + else if (P_ChickenMorphPlayer(player)) { P_SetMessage(player, TXT_CHEATCHICKENON, false); } @@ -1599,7 +1599,7 @@ static void CheatMassacreFunc(player_t *player, Cheat_t *cheat) { if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } @@ -1614,16 +1614,16 @@ static void CheatIDKFAFunc(player_t *player, Cheat_t *cheat) if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } S_StartSound(NULL, sfx_dorcls); - if(player->chickenTics) + if (player->chickenTics) { return; } - for(i = 1; i < 8; i++) + for (i = 1; i < 8; i++) { player->weaponowned[i] = false; } @@ -1635,7 +1635,7 @@ static void CheatIDDQDFunc(player_t *player, Cheat_t *cheat) { if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } @@ -1651,17 +1651,17 @@ static void CheatIDMUSFunc(player_t *player, Cheat_t *cheat) S_StartSound(NULL, sfx_dorcls); - episode = cheat->args[0]-'0'; - map = cheat->args[1]-'0'; + episode = cheat->args[0] - '0'; + map = cheat->args[1] - '0'; - if(M_ValidEpisodeMap(episode, map)) + if (M_ValidEpisodeMap(episode, map)) { P_SetMessage(player, "MUSIC CHANGE", true); - S_StartSong((episode-1)*9 + map-1, true); + S_StartSong((episode - 1) * 9 + map - 1, true); } else if (episode == 9) { - switch(map) + switch (map) { case 9: P_SetMessage(player, "MUSIC CHANGE", true); @@ -1690,27 +1690,27 @@ static void CheatFinishLevelFunc (player_t *player, Cheat_t *cheat) { if (!M_CheckParm("-cheats")) /* FS */ { - if(netgame || gameskill == sk_nightmare) + if (netgame || gameskill == sk_nightmare) return; } - + S_StartSound(NULL, sfx_dorcls); - switch(gamemap) + switch (gamemap) { case 3: - if(gameepisode == 5) + if (gameepisode == 5) G_SecretExitLevel(); else G_ExitLevel(); - break; + break; case 4: - if(gameepisode == 2 || gameepisode == 3 || gameepisode == 4) + if (gameepisode == 2 || gameepisode == 3 || gameepisode == 4) G_SecretExitLevel(); else G_ExitLevel(); break; case 6: - if(gameepisode == 1) + if (gameepisode == 1) G_SecretExitLevel(); else G_ExitLevel(); diff --git a/SOUNDS.C b/SOUNDS.C index 8fff4dc..839b274 100644 --- a/SOUNDS.C +++ b/SOUNDS.C @@ -163,7 +163,7 @@ sfxinfo_t S_sfx[] = { "sbtpai", NULL, 32, -1, NULL, 0, 2 }, { "plroof", NULL, 32, -1, NULL, 0, 2 }, { "plrpai", NULL, 32, -1, NULL, 0, 2 }, - { "plrdth", NULL, 80, -1, NULL, 0, 2 }, + { "plrdth", NULL, 80, -1, NULL, 0, 2 }, { "gibdth", NULL, 100, -1, NULL, 0, 2 }, { "plrwdth", NULL, 80, -1, NULL, 0, 2 }, { "plrcdth", NULL, 100, -1, NULL, 0, 2 }, diff --git a/V_VIDEO.C b/V_VIDEO.C index 70e4b83..7d90df6 100644 --- a/V_VIDEO.C +++ b/V_VIDEO.C @@ -42,29 +42,29 @@ void V_DrawPatch(int x, int y, patch_t *patch) y -= SHORT(patch->topoffset); x -= SHORT(patch->leftoffset); - if(x < 0 || x+SHORT(patch->width) > SCREENWIDTH || y < 0 - || y+SHORT(patch->height) > SCREENHEIGHT) + if (x < 0 || x + SHORT(patch->width) > SCREENWIDTH || y < 0 + || y + SHORT(patch->height) > SCREENHEIGHT) { I_Error("Bad V_DrawPatch"); } col = 0; - desttop = screen+y*SCREENWIDTH+x; + desttop = screen + y * SCREENWIDTH + x; w = SHORT(patch->width); - for(; col < w; x++, col++, desttop++) + for (; col < w; x++, col++, desttop++) { - column = (column_t *)((byte *)patch+LONG(patch->columnofs[col])); + column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); // Step through the posts in a column - while(column->topdelta != 0xff) + while (column->topdelta != 0xff) { - source = (byte *)column+3; - dest = desttop+column->topdelta*SCREENWIDTH; + source = (byte *)column + 3; + dest = desttop + column->topdelta * SCREENWIDTH; count = column->length; - while(count--) + while (count--) { *dest = *source++; dest += SCREENWIDTH; } - column = (column_t *)((byte *)column+column->length+4); + column = (column_t *)((byte *)column + column->length + 4); } } } @@ -82,41 +82,41 @@ extern byte *tinttable; void V_DrawFuzzPatch (int x, int y, patch_t *patch) { - int count,col; - column_t *column; - byte *desttop, *dest, *source; + int count, col; + column_t *column; + byte *desttop, *dest, *source; int w; - + y -= SHORT(patch->topoffset); x -= SHORT(patch->leftoffset); - if (x<0||x+SHORT(patch->width) >SCREENWIDTH || y<0 || y+SHORT(patch->height)>SCREENHEIGHT) + if (x<0 || x + SHORT(patch->width) >SCREENWIDTH || y<0 || y + SHORT(patch->height)>SCREENHEIGHT) I_Error ("Bad V_DrawPatch"); col = 0; - desttop = screen+y*SCREENWIDTH+x; - + desttop = screen + y * SCREENWIDTH + x; + w = SHORT(patch->width); - for ( ; colcolumnofs[col])); -// step through the posts in a column - - while (column->topdelta != 0xff ) + // step through the posts in a column + + while (column->topdelta != 0xff) { source = (byte *)column + 3; - dest = desttop + column->topdelta*SCREENWIDTH; + dest = desttop + column->topdelta * SCREENWIDTH; count = column->length; - + while (count--) { - *dest = tinttable[((*dest)<<8) + *source++]; + *dest = tinttable[((*dest) << 8) + *source++]; dest += SCREENWIDTH; } - column = (column_t *)( (byte *)column + column->length + 4 ); + column = (column_t *)((byte *)column + column->length + 4); } - } + } } /* @@ -131,48 +131,48 @@ void V_DrawFuzzPatch (int x, int y, patch_t *patch) void V_DrawShadowedPatch(int x, int y, patch_t *patch) { - int count,col; - column_t *column; - byte *desttop, *dest, *source; - byte *desttop2, *dest2; + int count, col; + column_t *column; + byte *desttop, *dest, *source; + byte *desttop2, *dest2; int w; - + y -= SHORT(patch->topoffset); x -= SHORT(patch->leftoffset); - if (x<0||x+SHORT(patch->width) >SCREENWIDTH || y<0 || y+SHORT(patch->height)>SCREENHEIGHT) + if (x<0 || x + SHORT(patch->width) >SCREENWIDTH || y<0 || y + SHORT(patch->height)>SCREENHEIGHT) I_Error ("Bad V_DrawPatch"); col = 0; - desttop = screen+y*SCREENWIDTH+x; - desttop2 = screen+(y+2)*SCREENWIDTH+x+2; - + desttop = screen + y * SCREENWIDTH + x; + desttop2 = screen + (y + 2) * SCREENWIDTH + x + 2; + w = SHORT(patch->width); - for ( ; colcolumnofs[col])); -// step through the posts in a column - - while (column->topdelta != 0xff ) + // step through the posts in a column + + while (column->topdelta != 0xff) { source = (byte *)column + 3; - dest = desttop + column->topdelta*SCREENWIDTH; - dest2 = desttop2 + column->topdelta*SCREENWIDTH; + dest = desttop + column->topdelta * SCREENWIDTH; + dest2 = desttop2 + column->topdelta * SCREENWIDTH; count = column->length; - + while (count--) { - *dest2 = tinttable[((*dest2)<<8)]; + *dest2 = tinttable[((*dest2) << 8)]; dest2 += SCREENWIDTH; *dest = *source++; dest += SCREENWIDTH; } - column = (column_t *)( (byte *)column + column->length -+ 4 ); + column = (column_t *)((byte *)column + column->length + + 4); } - } + } } //--------------------------------------------------------------------------- @@ -183,7 +183,7 @@ void V_DrawShadowedPatch(int x, int y, patch_t *patch) void V_DrawRawScreen(byte *raw) { - memcpy(screen, raw, SCREENWIDTH*SCREENHEIGHT); + memcpy(screen, raw, SCREENWIDTH * SCREENHEIGHT); } //--------------------------------------------------------------------------- @@ -195,5 +195,5 @@ void V_DrawRawScreen(byte *raw) void V_Init(void) { // I_AllocLow will put screen in low dos memory on PCs. - screen = I_AllocLow(SCREENWIDTH*SCREENHEIGHT); + screen = I_AllocLow(SCREENWIDTH * SCREENHEIGHT); } diff --git a/W_WAD.C b/W_WAD.C index 20ce6e9..d9a0cf7 100644 --- a/W_WAD.C +++ b/W_WAD.C @@ -43,10 +43,10 @@ typedef struct // GLOBALS //============= -lumpinfo_t *lumpinfo; // location of each lump on disk +lumpinfo_t *lumpinfo; // location of each lump on disk int numlumps; -void **lumpcache; +void **lumpcache; //=================== @@ -57,8 +57,8 @@ void **lumpcache; void strupr (char *s) { - while (*s) - *s++ = toupper(*s); + while (*s) + *s++ = toupper(*s); } /* @@ -71,12 +71,12 @@ void strupr (char *s) int filelength (int handle) { - struct stat fileinfo; - - if (fstat (handle,&fileinfo) == -1) - I_Error ("Error fstating"); + struct stat fileinfo; - return fileinfo.st_size; + if (fstat (handle, &fileinfo) == -1) + I_Error ("Error fstating"); + + return fileinfo.st_size; } #endif @@ -84,26 +84,26 @@ int filelength (int handle) void ExtractFileBase (char *path, char *dest) { - char *src; + char *src; int length; src = path + strlen(path) - 1; -// -// back up until a \ or the start -// - while (src != path && *(src-1) != '\\' && *(src-1) != '/') + // + // back up until a \ or the start + // + while (src != path && *(src - 1) != '\\' && *(src - 1) != '/') src--; -// -// copy up to eight characters -// - memset (dest,0,8); + // + // copy up to eight characters + // + memset (dest, 0, 8); length = 0; while (*src && *src != '.') { if (++length == 9) - I_Error ("Filename base of %s >8 chars",path); + I_Error ("Filename base of %s >8 chars", path); *dest++ = toupper((int)*src++); } } @@ -131,57 +131,57 @@ void ExtractFileBase (char *path, char *dest) void W_AddFile (char *filename) { wadinfo_t header; - lumpinfo_t *lump_p; + lumpinfo_t *lump_p; unsigned i; int handle, length; int startlump; - filelump_t *fileinfo, singleinfo; - -// -// open the file and add to directory -// - if ( (handle = open (filename,O_RDONLY | O_BINARY)) == -1) + filelump_t *fileinfo, singleinfo; + + // + // open the file and add to directory + // + if ((handle = open (filename, O_RDONLY | O_BINARY)) == -1) return; startlump = numlumps; - - if (strcmpi (filename+strlen(filename)-3 , "wad" ) ) + + if (strcmpi (filename + strlen(filename) - 3, "wad")) { - // single lump file + // single lump file fileinfo = &singleinfo; singleinfo.filepos = 0; singleinfo.size = LONG(filelength(handle)); ExtractFileBase (filename, singleinfo.name); numlumps++; } - else + else { - // WAD file + // WAD file read (handle, &header, sizeof(header)); - if (strncmp(header.identification,"IWAD",4)) + if (strncmp(header.identification, "IWAD", 4)) { - if (strncmp(header.identification,"PWAD",4)) + if (strncmp(header.identification, "PWAD", 4)) I_Error ("Wad file %s doesn't have IWAD or PWAD id\n" - ,filename); + , filename); } header.numlumps = LONG(header.numlumps); header.infotableofs = LONG(header.infotableofs); - length = header.numlumps*sizeof(filelump_t); + length = header.numlumps * sizeof(filelump_t); fileinfo = alloca (length); lseek (handle, header.infotableofs, SEEK_SET); read (handle, fileinfo, length); numlumps += header.numlumps; } -// -// Fill in lumpinfo -// - lumpinfo = realloc (lumpinfo, numlumps*sizeof(lumpinfo_t)); + // + // Fill in lumpinfo + // + lumpinfo = realloc (lumpinfo, numlumps * sizeof(lumpinfo_t)); if (!lumpinfo) I_Error ("Couldn't realloc lumpinfo"); lump_p = &lumpinfo[startlump]; - - for (i=startlump ; ihandle = handle; lump_p->position = LONG(fileinfo->filepos); @@ -214,29 +214,29 @@ void W_AddFile (char *filename) */ void W_InitMultipleFiles (char **filenames) -{ +{ int size; - -// -// open all the files, load headers, and count lumps -// + + // + // open all the files, load headers, and count lumps + // numlumps = 0; lumpinfo = malloc(1); // will be realloced as lumps are added - for ( ; *filenames ; filenames++) + for (; *filenames; filenames++) W_AddFile (*filenames); if (!numlumps) I_Error ("W_InitFiles: no files found"); - -// -// set up caching -// + + // + // set up caching + // size = numlumps * sizeof(*lumpcache); lumpcache = malloc (size); if (!lumpcache) I_Error ("Couldn't allocate lumpcache"); - memset (lumpcache,0, size); + memset (lumpcache, 0, size); } @@ -253,7 +253,7 @@ void W_InitMultipleFiles (char **filenames) void W_InitFile (char *filename) { - char *names[2]; + char *names[2]; names[0] = filename; names[1] = NULL; @@ -290,12 +290,12 @@ int W_NumLumps (void) int W_CheckNumForName (char *name) { char name8[9]; - int v1,v2; - lumpinfo_t *lump_p; + int v1, v2; + lumpinfo_t *lump_p; -// make the name into two integers for easy compares + // make the name into two integers for easy compares - strncpy (name8,name,8); + strncpy (name8, name, 8); name8[8] = 0; // in case the name was a fill 8 chars strupr (name8); // case insensitive @@ -303,12 +303,12 @@ int W_CheckNumForName (char *name) v2 = *(int *)&name8[4]; -// scan backwards so patch lump files take precedence + // scan backwards so patch lump files take precedence lump_p = lumpinfo + numlumps; while (lump_p-- != lumpinfo) - if ( *(int *)lump_p->name == v1 && *(int *)&lump_p->name[4] == v2) + if (*(int *)lump_p->name == v1 && *(int *)&lump_p->name[4] == v2) return lump_p - lumpinfo; @@ -334,7 +334,7 @@ int W_GetNumForName (char *name) if (i != -1) return i; - I_Error ("W_GetNumForName: %s not found!",name); + I_Error ("W_GetNumForName: %s not found!", name); return -1; } @@ -352,7 +352,7 @@ int W_GetNumForName (char *name) int W_LumpLength (int lump) { if (lump >= numlumps) - I_Error ("W_LumpLength: %i >= numlumps",lump); + I_Error ("W_LumpLength: %i >= numlumps", lump); return lumpinfo[lump].size; } @@ -370,18 +370,18 @@ int W_LumpLength (int lump) void W_ReadLump (int lump, void *dest) { int c; - lumpinfo_t *l; - + lumpinfo_t *l; + if (lump >= numlumps) - I_Error ("W_ReadLump: %i >= numlumps",lump); - l = lumpinfo+lump; - + I_Error ("W_ReadLump: %i >= numlumps", lump); + l = lumpinfo + lump; + I_BeginRead (); - + lseek (l->handle, l->position, SEEK_SET); c = read (l->handle, dest, l->size); if (c < l->size) - I_Error ("W_ReadLump: only read %i of %i on lump %i",c,l->size,lump); + I_Error ("W_ReadLump: only read %i of %i on lump %i", c, l->size, lump); I_EndRead (); } @@ -395,13 +395,13 @@ void W_ReadLump (int lump, void *dest) ==================== */ -void *W_CacheLumpNum (int lump, int tag) +void *W_CacheLumpNum (int lump, int tag) { -byte *ptr; + byte *ptr; if ((unsigned)lump >= numlumps) - I_Error ("W_CacheLumpNum: %i >= numlumps",lump); - + I_Error ("W_CacheLumpNum: %i >= numlumps", lump); + if (!lumpcache[lump]) { // read the lump in //printf ("cache miss on lump %i\n",lump); @@ -410,10 +410,10 @@ byte *ptr; } else { -//printf ("cache hit on lump %i\n",lump); - Z_ChangeTag (lumpcache[lump],tag); + //printf ("cache hit on lump %i\n",lump); + Z_ChangeTag (lumpcache[lump], tag); } - + return lumpcache[lump]; } @@ -426,7 +426,7 @@ byte *ptr; ==================== */ -void *W_CacheLumpName (char *name, int tag) +void *W_CacheLumpName (char *name, int tag) { return W_CacheLumpNum (W_GetNumForName(name), tag); } @@ -454,10 +454,10 @@ void W_Profile (void) FILE *f; int j; char name[9]; - - + + for (i=0 ; iblocklist.next = zone->blocklist.prev = block = - (memblock_t *)( (byte *)zone + sizeof(memzone_t) ); + (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; // free block block->size = zone->size - sizeof(memzone_t); @@ -67,21 +67,21 @@ void Z_ClearZone (memzone_t *zone) void Z_Init (void) { - memblock_t *block; + memblock_t *block; int size; MallocFailureOk = false; mainzone = (memzone_t *)I_ZoneBase (&size); mainzone->size = size; -// set the entire zone to one free block + // set the entire zone to one free block mainzone->blocklist.next = mainzone->blocklist.prev = block = - (memblock_t *)( (byte *)mainzone + sizeof(memzone_t) ); + (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; // free block block->size = mainzone->size - sizeof(memzone_t); @@ -98,18 +98,18 @@ void Z_Init (void) void Z_Free (void *ptr) { - memblock_t *block, *other; - - block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); + memblock_t *block, *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) // smaller values are not pointers *block->user = 0; // clear the user's mark block->user = NULL; // mark as free block->tag = 0; block->id = 0; - + other = block->prev; if (!other->user) { // merge with previous free block @@ -120,7 +120,7 @@ void Z_Free (void *ptr) mainzone->rover = other; block = other; } - + other = block->next; if (!other->user) { // merge the next free block onto the end @@ -147,30 +147,30 @@ void Z_Free (void *ptr) void *Z_Malloc (int size, int tag, void *user) { int extra; - memblock_t *start, *rover, *new, *base; + memblock_t *start, *rover, *new, *base; -// -// scan through the block list looking for the first free block -// of sufficient size, throwing out any purgable blocks along the way -// + // + // scan through the block list looking for the first free block + // of sufficient size, throwing out any purgable blocks along the way + // size += sizeof(memblock_t); // account for size of block header - - + + // // if there is a free block behind the rover, back up over them // base = mainzone->rover; if (!base->prev->user) base = base->prev; - + rover = base; start = base->prev; - + do { - if(rover == start) + if (rover == start) { // Scanned all the way around the list - if(MallocFailureOk == true) + if (MallocFailureOk == true) { return NULL; } @@ -182,13 +182,13 @@ void *Z_Malloc (int size, int tag, void *user) if (rover->user) { if (rover->tag < PU_PURGELEVEL) - // hit a block that can't be purged, so move base past it + // hit a block that can't be purged, so move base past it base = rover = rover->next; else { - // free the rover block (adding the size to base) + // free the rover block (adding the size to base) base = base->prev; // the rover can be the base block - Z_Free ((byte *)rover+sizeof(memblock_t)); + Z_Free ((byte *)rover + sizeof(memblock_t)); base = base->next; rover = base->next; } @@ -196,14 +196,14 @@ void *Z_Malloc (int size, int tag, void *user) else rover = rover->next; } while (base->user || base->size < size); - -// -// found a block big enough -// + + // + // found a block big enough + // extra = base->size - size; - if (extra > MINFRAGMENT) + if (extra > MINFRAGMENT) { // there will be a free fragment after the allocated block - new = (memblock_t *) ((byte *)base + size ); + new = (memblock_t *)((byte *)base + size); new->size = extra; new->user = NULL; // free block new->tag = 0; @@ -213,11 +213,11 @@ void *Z_Malloc (int size, int tag, void *user) base->next = new; base->size = size; } - + if (user) { base->user = user; // mark as an in use block - *(void **)user = (void *) ((byte *)base + sizeof(memblock_t)); + *(void **)user = (void *)((byte *)base + sizeof(memblock_t)); } else { @@ -226,11 +226,11 @@ void *Z_Malloc (int size, int tag, void *user) base->user = (void *)2; // mark as in use, but unowned } base->tag = tag; - + mainzone->rover = base->next; // next allocation will start looking here - + base->id = ZONEID; - return (void *) ((byte *)base + sizeof(memblock_t)); + return (void *)((byte *)base + sizeof(memblock_t)); } @@ -244,16 +244,16 @@ void *Z_Malloc (int size, int tag, void *user) void Z_FreeTags (int lowtag, int hightag) { - memblock_t *block, *next; - - for (block = mainzone->blocklist.next ; block != &mainzone->blocklist - ; block = next) + memblock_t *block, *next; + + for (block = mainzone->blocklist.next; block != &mainzone->blocklist + ; block = next) { next = block->next; // get link before freeing if (!block->user) continue; // free block if (block->tag >= lowtag && block->tag <= hightag) - Z_Free ( (byte *)block+sizeof(memblock_t)); + Z_Free ((byte *)block + sizeof(memblock_t)); } } @@ -267,22 +267,22 @@ void Z_FreeTags (int lowtag, int hightag) 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) + 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); - + block, block->size, block->user, block->tag); + if (block->next == &mainzone->blocklist) break; // all blocks have been hit - if ( (byte *)block + block->size != (byte *)block->next) + if ((byte *)block + block->size != (byte *)block->next) printf ("ERROR: block size does not touch the next block\n"); - if ( block->next->prev != block) + 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"); @@ -299,23 +299,23 @@ void Z_DumpHeap (int lowtag, int hightag) 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) + 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); - + fprintf (f, "block:%p size:%7i user:%p tag:%3i\n", + block, block->size, block->user, block->tag); + if (block->next == &mainzone->blocklist) break; // all blocks have been hit - 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 ((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"); + fprintf (f, "ERROR: two consecutive free blocks\n"); } } @@ -329,15 +329,15 @@ void Z_FileDumpHeap (FILE *f) void Z_CheckHeap (void) { - memblock_t *block; - - for (block = mainzone->blocklist.next ; ; block = block->next) + memblock_t *block; + + for (block = mainzone->blocklist.next; ; block = block->next) { if (block->next == &mainzone->blocklist) break; // all blocks have been hit - if ( (byte *)block + block->size != (byte *)block->next) + 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) + 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"); @@ -355,9 +355,9 @@ void Z_CheckHeap (void) void Z_ChangeTag2 (void *ptr, int tag) { - memblock_t *block; - - block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); + 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) @@ -376,12 +376,12 @@ void Z_ChangeTag2 (void *ptr, int tag) int Z_FreeMemory (void) { - memblock_t *block; + memblock_t *block; int free; - + free = 0; - for (block = mainzone->blocklist.next ; block != &mainzone->blocklist - ; block = block->next) + for (block = mainzone->blocklist.next; block != &mainzone->blocklist + ; block = block->next) if (!block->user || block->tag >= PU_PURGELEVEL) free += block->size; return free; diff --git a/deh_ammo.c b/deh_ammo.c index 71168d8..ee80c53 100644 --- a/deh_ammo.c +++ b/deh_ammo.c @@ -38,78 +38,78 @@ static void *DEH_AmmoStart(deh_context_t *context, char *line) { - int ammo_number = 0; - - if (sscanf(line, "Ammo %i", &ammo_number) != 1) - { - DEH_Warning(context, "Parse error on section start"); - return NULL; - } - - if (ammo_number < 0 || ammo_number >= NUMAMMO) - { - DEH_Warning(context, "Invalid ammo number: %i", ammo_number); - return NULL; - } - - return &maxammo[ammo_number]; + int ammo_number = 0; + + if (sscanf(line, "Ammo %i", &ammo_number) != 1) + { + DEH_Warning(context, "Parse error on section start"); + return NULL; + } + + if (ammo_number < 0 || ammo_number >= NUMAMMO) + { + DEH_Warning(context, "Invalid ammo number: %i", ammo_number); + return NULL; + } + + return &maxammo[ammo_number]; } static void DEH_AmmoParseLine(deh_context_t *context, char *line, void *tag) { - char *variable_name, *value; - int ivalue; - int ammo_number; + char *variable_name, *value; + int ivalue; + int ammo_number; - if (tag == NULL) - return; + if (tag == NULL) + return; - ammo_number = ((int *) tag) - maxammo; + ammo_number = ((int *)tag) - maxammo; - // Parse the assignment + // Parse the assignment - if (!DEH_ParseAssignment(line, &variable_name, &value)) - { - // Failed to parse + if (!DEH_ParseAssignment(line, &variable_name, &value)) + { + // Failed to parse - DEH_Warning(context, "Failed to parse assignment"); - return; - } + DEH_Warning(context, "Failed to parse assignment"); + return; + } - ivalue = atoi(value); + ivalue = atoi(value); - // maxammo + // maxammo printf("ammo_number: %i\n", ammo_number); // FS - if (!strcasecmp(variable_name, "Per ammo")) - GetWeaponAmmo[ammo_number] = ivalue; - - else if (!strcasecmp(variable_name, "Max ammo")) - maxammo[ammo_number-2] = ivalue; - else - { - DEH_Warning(context, "Field named '%s' not found", variable_name); - } + if (!strcasecmp(variable_name, "Per ammo")) + GetWeaponAmmo[ammo_number] = ivalue; + + else if (!strcasecmp(variable_name, "Max ammo")) + maxammo[ammo_number - 2] = ivalue; + else + { + DEH_Warning(context, "Field named '%s' not found", variable_name); + } } static void DEH_AmmoMD5Hash(md5_context_t *context) { - int i; + int i; - for (i=0; i cheat->length) // FS - { - printf("Cheat sequence longer than supported by Vanilla dehacked for cheat:\n%s\nPress a key to continue...\n", variable_name); - getchar(); - break; - } + if (!deh_allow_long_cheats && i > cheat->length) // FS + { + printf("Cheat sequence longer than supported by Vanilla dehacked for cheat:\n%s\nPress a key to continue...\n", variable_name); + getchar(); + break; + } - if (deh_apply_cheats) - { - cheat->seq->sequence[i] = SCRAMBLE(unsvalue[i]); - } - ++i; + if (deh_apply_cheats) + { + cheat->seq->sequence[i] = SCRAMBLE(unsvalue[i]); + } + ++i; - // Absolute limit - don't exceed + // Absolute limit - don't exceed - if (i >= MAX_CHEAT_LEN - arrlen(cheat->seq->p)) - { - DEH_Error(context, "Cheat sequence too long!"); - return; - } - } + if (i >= MAX_CHEAT_LEN - arrlen(cheat->seq->p)) + { + DEH_Error(context, "Cheat sequence too long!"); + return; + } + } if (deh_apply_cheats) { - if(!strcasecmp("Change Music", variable_name)) // FS: Hack for these cheats the want a variable + if (!strcasecmp("Change Music", variable_name)) // FS: Hack for these cheats the want a variable { cheat->seq->sequence[i] = 1; - cheat->seq->sequence[i+1] = 0; - cheat->seq->sequence[i+2] = 0; - cheat->seq->sequence[i+3] = 0xff; + cheat->seq->sequence[i + 1] = 0; + cheat->seq->sequence[i + 2] = 0; + cheat->seq->sequence[i + 3] = 0xff; } - else if(!strcasecmp("Level Warp", variable_name)) + else if (!strcasecmp("Level Warp", variable_name)) { cheat->seq->sequence[i] = 1; - cheat->seq->sequence[i+1] = 0; - cheat->seq->sequence[i+2] = 0; - cheat->seq->sequence[i+3] = 0xff; + cheat->seq->sequence[i + 1] = 0; + cheat->seq->sequence[i + 2] = 0; + cheat->seq->sequence[i + 3] = 0xff; } else cheat->seq->sequence[i] = 0xff; @@ -163,11 +163,11 @@ static void DEH_CheatParseLine(deh_context_t *context, char *line, void *tag) deh_section_t deh_section_cheat = { - "Cheat", - NULL, - DEH_CheatStart, - DEH_CheatParseLine, - NULL, - NULL, + "Cheat", + NULL, + DEH_CheatStart, + DEH_CheatParseLine, + NULL, + NULL, }; #endif diff --git a/deh_frme.c b/deh_frme.c index 1177334..e93ef58 100644 --- a/deh_frme.c +++ b/deh_frme.c @@ -36,41 +36,41 @@ #include "deh_map.h" DEH_BEGIN_MAPPING(state_mapping, state_t) - DEH_MAPPING("Sprite number", sprite) - DEH_MAPPING("Sprite subnumber", frame) - DEH_MAPPING("Duration", tics) - DEH_MAPPING("Next frame", nextstate) - DEH_MAPPING("Unknown 1", misc1) - DEH_MAPPING("Unknown 2", misc2) - DEH_UNSUPPORTED_MAPPING("Codep frame") + DEH_MAPPING("Sprite number", sprite) + DEH_MAPPING("Sprite subnumber", frame) + DEH_MAPPING("Duration", tics) + DEH_MAPPING("Next frame", nextstate) + DEH_MAPPING("Unknown 1", misc1) + DEH_MAPPING("Unknown 2", misc2) + DEH_UNSUPPORTED_MAPPING("Codep frame") DEH_END_MAPPING static void *DEH_FrameStart(deh_context_t *context, char *line) { - int frame_number = 0; - state_t *state; - - if (sscanf(line, "Frame %i", &frame_number) != 1) - { - DEH_Warning(context, "Parse error on section start"); - return NULL; - } - - if (frame_number < 0 || frame_number >= NUMSTATES) - { - DEH_Warning(context, "Invalid frame number: %i", frame_number); - return NULL; - } - - if (frame_number >= DEH_VANILLA_NUMSTATES) - { - DEH_Warning(context, "Attempt to modify frame %i: this will cause " - "problems in Vanilla dehacked.", frame_number); - } - - state = &states[frame_number]; - - return state; + int frame_number = 0; + state_t *state; + + if (sscanf(line, "Frame %i", &frame_number) != 1) + { + DEH_Warning(context, "Parse error on section start"); + return NULL; + } + + if (frame_number < 0 || frame_number >= NUMSTATES) + { + DEH_Warning(context, "Invalid frame number: %i", frame_number); + return NULL; + } + + if (frame_number >= DEH_VANILLA_NUMSTATES) + { + DEH_Warning(context, "Attempt to modify frame %i: this will cause " + "problems in Vanilla dehacked.", frame_number); + } + + state = &states[frame_number]; + + return state; } // Simulate a frame overflow: Doom has 967 frames in the states[] array, but @@ -84,90 +84,90 @@ static void *DEH_FrameStart(deh_context_t *context, char *line) static void DEH_FrameOverflow(deh_context_t *context, char *varname, int value) { #if 0 - if (!strcasecmp(varname, "Duration")) - { - weaponinfo[0].ammo = value; - } - else if (!strcasecmp(varname, "Codep frame")) - { - weaponinfo[0].upstate = value; - } - else if (!strcasecmp(varname, "Next frame")) - { - weaponinfo[0].downstate = value; - } - else if (!strcasecmp(varname, "Unknown 1")) - { - weaponinfo[0].readystate = value; - } - else if (!strcasecmp(varname, "Unknown 2")) - { - weaponinfo[0].atkstate = value; - } - else - { - DEH_Error(context, "Unable to simulate frame overflow: field '%s'", - varname); - } + if (!strcasecmp(varname, "Duration")) + { + weaponinfo[0].ammo = value; + } + else if (!strcasecmp(varname, "Codep frame")) + { + weaponinfo[0].upstate = value; + } + else if (!strcasecmp(varname, "Next frame")) + { + weaponinfo[0].downstate = value; + } + else if (!strcasecmp(varname, "Unknown 1")) + { + weaponinfo[0].readystate = value; + } + else if (!strcasecmp(varname, "Unknown 2")) + { + weaponinfo[0].atkstate = value; + } + else + { + DEH_Error(context, "Unable to simulate frame overflow: field '%s'", + varname); + } #endif } static void DEH_FrameParseLine(deh_context_t *context, char *line, void *tag) { - state_t *state; - char *variable_name, *value; - int ivalue; - - if (tag == NULL) - return; - - state = (state_t *) tag; - - // Parse the assignment - - if (!DEH_ParseAssignment(line, &variable_name, &value)) - { - // Failed to parse - - DEH_Warning(context, "Failed to parse assignment"); - return; - } - - // all values are integers - - ivalue = atoi(value); - - if (state == &states[NUMSTATES - 1]) - { - DEH_FrameOverflow(context, variable_name, ivalue); - } - else - { - // set the appropriate field - - DEH_SetMapping(context, &state_mapping, state, variable_name, ivalue); - } + state_t *state; + char *variable_name, *value; + int ivalue; + + if (tag == NULL) + return; + + state = (state_t *)tag; + + // Parse the assignment + + if (!DEH_ParseAssignment(line, &variable_name, &value)) + { + // Failed to parse + + DEH_Warning(context, "Failed to parse assignment"); + return; + } + + // all values are integers + + ivalue = atoi(value); + + if (state == &states[NUMSTATES - 1]) + { + DEH_FrameOverflow(context, variable_name, ivalue); + } + else + { + // set the appropriate field + + DEH_SetMapping(context, &state_mapping, state, variable_name, ivalue); + } } static void DEH_FrameMD5Sum(md5_context_t *context) { - int i; + int i; - for (i=0; ireadbuffer_size = 128; - context->readbuffer = Z_Malloc(context->readbuffer_size, PU_STATIC, NULL); - context->linenum = 0; - context->last_was_newline = true; + context->readbuffer_size = 128; + context->readbuffer = Z_Malloc(context->readbuffer_size, PU_STATIC, NULL); + context->linenum = 0; + context->last_was_newline = true; - return context; + return context; } // Open a dehacked file for reading @@ -91,215 +91,215 @@ static deh_context_t *DEH_NewContext(void) deh_context_t *DEH_OpenFile(char *filename) { - FILE *fstream; - deh_context_t *context; + FILE *fstream; + deh_context_t *context; - fstream = fopen(filename, "r"); + fstream = fopen(filename, "r"); - if (fstream == NULL) - return NULL; + if (fstream == NULL) + return NULL; - context = DEH_NewContext(); + context = DEH_NewContext(); - context->type = DEH_INPUT_FILE; - context->stream = fstream; - context->filename = strdup(filename); + context->type = DEH_INPUT_FILE; + context->stream = fstream; + context->filename = strdup(filename); - return context; + return context; } // Open a WAD lump for reading. deh_context_t *DEH_OpenLump(int lumpnum) { - deh_context_t *context; - void *lump; + deh_context_t *context; + void *lump; - lump = W_CacheLumpNum(lumpnum, PU_STATIC); + lump = W_CacheLumpNum(lumpnum, PU_STATIC); - context = DEH_NewContext(); + context = DEH_NewContext(); - context->type = DEH_INPUT_LUMP; - context->lumpnum = lumpnum; - context->input_buffer = lump; - context->input_buffer_len = W_LumpLength(lumpnum); - context->input_buffer_pos = 0; + context->type = DEH_INPUT_LUMP; + context->lumpnum = lumpnum; + context->input_buffer = lump; + context->input_buffer_len = W_LumpLength(lumpnum); + context->input_buffer_pos = 0; - context->filename = malloc(9); - strncpy(context->filename, lumpinfo[lumpnum].name, 8); - context->filename[8] = '\0'; + context->filename = malloc(9); + strncpy(context->filename, lumpinfo[lumpnum].name, 8); + context->filename[8] = '\0'; - return context; + return context; } // Close dehacked file void DEH_CloseFile(deh_context_t *context) { - if (context->type == DEH_INPUT_FILE) - { - fclose(context->stream); - } - else if (context->type == DEH_INPUT_LUMP) - { - Z_ChangeTag((void*)context->lumpnum, PU_CACHE);// W_ReleaseLumpNum(context->lumpnum); - } - - Z_Free(context->readbuffer); - Z_Free(context); + if (context->type == DEH_INPUT_FILE) + { + fclose(context->stream); + } + else if (context->type == DEH_INPUT_LUMP) + { + Z_ChangeTag((void *)context->lumpnum, PU_CACHE);// W_ReleaseLumpNum(context->lumpnum); + } + + Z_Free(context->readbuffer); + Z_Free(context); } int DEH_GetCharFile(deh_context_t *context) { - if (feof(context->stream)) - { - // end of file + if (feof(context->stream)) + { + // end of file - return -1; - } + return -1; + } - return fgetc(context->stream); + return fgetc(context->stream); } int DEH_GetCharLump(deh_context_t *context) { - int result; + int result; - if (context->input_buffer_pos >= context->input_buffer_len) - { - return -1; - } + if (context->input_buffer_pos >= context->input_buffer_len) + { + return -1; + } - result = context->input_buffer[context->input_buffer_pos]; - ++context->input_buffer_pos; + result = context->input_buffer[context->input_buffer_pos]; + ++context->input_buffer_pos; - return result; + return result; } // Reads a single character from a dehacked file int DEH_GetChar(deh_context_t *context) { - int result = 0; + int result = 0; - // Read characters, but ignore carriage returns - // Essentially this is a DOS->Unix conversion + // Read characters, but ignore carriage returns + // Essentially this is a DOS->Unix conversion - do - { - switch (context->type) - { - case DEH_INPUT_FILE: - result = DEH_GetCharFile(context); - break; + do + { + switch (context->type) + { + case DEH_INPUT_FILE: + result = DEH_GetCharFile(context); + break; - case DEH_INPUT_LUMP: - result = DEH_GetCharLump(context); - break; - } - } while (result == '\r'); + case DEH_INPUT_LUMP: + result = DEH_GetCharLump(context); + break; + } + } while (result == '\r'); - // Track the current line number + // Track the current line number - if (context->last_was_newline) - { - ++context->linenum; - } + if (context->last_was_newline) + { + ++context->linenum; + } - context->last_was_newline = result == '\n'; + context->last_was_newline = result == '\n'; - return result; + return result; } // Increase the read buffer size static void IncreaseReadBuffer(deh_context_t *context) { - char *newbuffer; - int newbuffer_size; + char *newbuffer; + int newbuffer_size; - newbuffer_size = context->readbuffer_size * 2; - newbuffer = Z_Malloc(newbuffer_size, PU_STATIC, NULL); + newbuffer_size = context->readbuffer_size * 2; + newbuffer = Z_Malloc(newbuffer_size, PU_STATIC, NULL); - memcpy(newbuffer, context->readbuffer, context->readbuffer_size); + memcpy(newbuffer, context->readbuffer, context->readbuffer_size); - Z_Free(context->readbuffer); + Z_Free(context->readbuffer); - context->readbuffer = newbuffer; - context->readbuffer_size = newbuffer_size; + context->readbuffer = newbuffer; + context->readbuffer_size = newbuffer_size; } // Read a whole line char *DEH_ReadLine(deh_context_t *context) { - int c; - int pos; - - for (pos = 0;;) - { - c = DEH_GetChar(context); - - if (c < 0) - { - // end of file - - return NULL; - } - - // cope with lines of any length: increase the buffer size - - if (pos >= context->readbuffer_size) - { - IncreaseReadBuffer(context); - } - - if (c == '\n') - { - // end of line: a full line has been read - - context->readbuffer[pos] = '\0'; - break; - } - else if (c != '\0') - { - // normal character; don't allow NUL characters to be - // added. - - context->readbuffer[pos] = (char) c; - ++pos; - } - } - - return context->readbuffer; + int c; + int pos; + + for (pos = 0;;) + { + c = DEH_GetChar(context); + + if (c < 0) + { + // end of file + + return NULL; + } + + // cope with lines of any length: increase the buffer size + + if (pos >= context->readbuffer_size) + { + IncreaseReadBuffer(context); + } + + if (c == '\n') + { + // end of line: a full line has been read + + context->readbuffer[pos] = '\0'; + break; + } + else if (c != '\0') + { + // normal character; don't allow NUL characters to be + // added. + + context->readbuffer[pos] = (char)c; + ++pos; + } + } + + return context->readbuffer; } void DEH_Warning(deh_context_t *context, char *msg, ...) { - va_list args; + va_list args; - va_start(args, msg); - - fprintf(stderr, "%s:%i: warning: ", context->filename, context->linenum); - vfprintf(stderr, msg, args); - fprintf(stderr, "\n"); + va_start(args, msg); - va_end(args); + fprintf(stderr, "%s:%i: warning: ", context->filename, context->linenum); + vfprintf(stderr, msg, args); + fprintf(stderr, "\n"); + + va_end(args); } void DEH_Error(deh_context_t *context, char *msg, ...) { - va_list args; + va_list args; + + va_start(args, msg); - va_start(args, msg); - - fprintf(stderr, "%s:%i: ", context->filename, context->linenum); - vfprintf(stderr, msg, args); - fprintf(stderr, "\n"); + fprintf(stderr, "%s:%i: ", context->filename, context->linenum); + vfprintf(stderr, msg, args); + fprintf(stderr, "\n"); - va_end(args); + va_end(args); - I_Error("Error parsing dehacked file"); + I_Error("Error parsing dehacked file"); } diff --git a/deh_main.c b/deh_main.c index 07bed1d..667899d 100644 --- a/deh_main.c +++ b/deh_main.c @@ -33,9 +33,9 @@ #include "deh_defs.h" #include "deh_io.h" -static char *deh_signatures[] = +static char *deh_signatures[] = { - "Patch File for HHE v1.1" + "Patch File for HHE v1.1" }; // deh_ammo.c: @@ -75,84 +75,84 @@ boolean deh_apply_cheats = true; static deh_section_t *section_types[] = { - &deh_section_ammo, -// &deh_section_cheat, - &deh_section_frame, - &deh_section_misc, - &deh_section_pointer, - &deh_section_sound, - &deh_section_text, - &deh_section_thing, - &deh_section_weapon, + &deh_section_ammo, + // &deh_section_cheat, + &deh_section_frame, + &deh_section_misc, + &deh_section_pointer, + &deh_section_sound, + &deh_section_text, + &deh_section_thing, + &deh_section_weapon, }; // Called on startup to call the Init functions static void InitializeSections(void) { - unsigned int i; - - for (i=0; iinit != NULL) - { - section_types[i]->init(); - } - } + unsigned int i; + + for (i = 0; i < arrlen(section_types); ++i) + { + if (section_types[i]->init != NULL) + { + section_types[i]->init(); + } + } } // Given a section name, get the section structure which corresponds static deh_section_t *GetSectionByName(char *name) { - unsigned int i; + unsigned int i; - for (i=0; iname, name)) - { - return section_types[i]; - } - } + for (i = 0; i < arrlen(section_types); ++i) + { + if (!strcasecmp(section_types[i]->name, name)) + { + return section_types[i]; + } + } - return NULL; + return NULL; } // Is the string passed just whitespace? static boolean IsWhitespace(char *s) { - for (; *s; ++s) - { - if (!isspace(*s)) - return false; - } + for (; *s; ++s) + { + if (!isspace(*s)) + return false; + } - return true; + return true; } // Strip whitespace from the start and end of a string static char *CleanString(char *s) { - char *strending; + char *strending; - // Leading whitespace + // Leading whitespace - while (*s && isspace(*s)) - ++s; + while (*s && isspace(*s)) + ++s; - // Trailing whitespace - - strending = s + strlen(s) - 1; + // Trailing whitespace - while (s[0] != '\0' && isspace(*strending)) - { - *strending = '\0'; - --strending; - } + strending = s + strlen(s) - 1; - return s; + while (s[0] != '\0' && isspace(*strending)) + { + *strending = '\0'; + --strending; + } + + return s; } // This pattern is used a lot of times in different sections, @@ -167,284 +167,284 @@ static char *CleanString(char *s) boolean DEH_ParseAssignment(char *line, char **variable_name, char **value) { - char *p; - - // find the equals - - p = strchr(line, '='); - - if (p == NULL && p-line > 2) - { - return false; - } - - // variable name at the start - // turn the '=' into a \0 to terminate the string here - - *p = '\0'; - *variable_name = CleanString(line); - - // value immediately follows the '=' - - *value = CleanString(p+1); - - return true; + char *p; + + // find the equals + + p = strchr(line, '='); + + if (p == NULL && p - line > 2) + { + return false; + } + + // variable name at the start + // turn the '=' into a \0 to terminate the string here + + *p = '\0'; + *variable_name = CleanString(line); + + // value immediately follows the '=' + + *value = CleanString(p + 1); + + return true; } static boolean CheckSignatures(deh_context_t *context) { - size_t i; - char *line; - - // Read the first line + size_t i; + char *line; - line = DEH_ReadLine(context); + // Read the first line - if (line == NULL) - { - return false; - } + line = DEH_ReadLine(context); - // Check all signatures to see if one matches + if (line == NULL) + { + return false; + } - for (i=0; iend != NULL) - { - current_section->end(context, tag); - } - - //printf("end %s tag\n", current_section->name); - current_section = NULL; - } - } - else - { - if (current_section != NULL) - { - // parse this line - - current_section->line_parser(context, line, tag); - } - else - { - // possibly the start of a new section - - sscanf(line, "%19s", section_name); - - current_section = GetSectionByName(section_name); - - if (current_section != NULL) - { - tag = current_section->start(context, line); - //printf("started %s tag\n", section_name); - } - else - { - //printf("unknown section name %s\n", section_name); - } - } - } - } + deh_section_t *current_section = NULL; + char section_name[20]; + void *tag = NULL; + char *line; + + // Read the header and check it matches the signature + + if (!CheckSignatures(context)) + { + DEH_Error(context, "This is not a valid dehacked patch file!"); + } + + // Read the file + + for (;;) + { + // read a new line + + line = DEH_ReadLine(context); + + // end of file? + + if (line == NULL) + { + return; + } + + while (line[0] != '\0' && isspace(line[0])) + ++line; + + if (line[0] == '#') + { + // comment + + DEH_ParseComment(line); + continue; + } + + if (IsWhitespace(line)) + { + if (current_section != NULL) + { + // end of section + + if (current_section->end != NULL) + { + current_section->end(context, tag); + } + + //printf("end %s tag\n", current_section->name); + current_section = NULL; + } + } + else + { + if (current_section != NULL) + { + // parse this line + + current_section->line_parser(context, line, tag); + } + else + { + // possibly the start of a new section + + sscanf(line, "%19s", section_name); + + current_section = GetSectionByName(section_name); + + if (current_section != NULL) + { + tag = current_section->start(context, line); + //printf("started %s tag\n", section_name); + } + else + { + //printf("unknown section name %s\n", section_name); + } + } + } + } } // Parses a dehacked file int DEH_LoadFile(char *filename) { - deh_context_t *context; + deh_context_t *context; + + // Vanilla dehacked files don't allow long string or cheat replacements. + + deh_allow_long_strings = false; + deh_allow_long_cheats = false; - // Vanilla dehacked files don't allow long string or cheat replacements. + printf(" loading %s\n", filename); - deh_allow_long_strings = false; - deh_allow_long_cheats = false; + context = DEH_OpenFile(filename); - printf(" loading %s\n", filename); + if (context == NULL) + { + fprintf(stderr, "DEH_LoadFile: Unable to open %s\n", filename); + return 0; + } - context = DEH_OpenFile(filename); + DEH_ParseContext(context); - if (context == NULL) - { - fprintf(stderr, "DEH_LoadFile: Unable to open %s\n", filename); - return 0; - } - - DEH_ParseContext(context); - - DEH_CloseFile(context); + DEH_CloseFile(context); - return 1; + return 1; } // Load dehacked file from WAD lump. int DEH_LoadLump(int lumpnum) { - deh_context_t *context; + deh_context_t *context; - // If it's in a lump, it's probably designed for a modern source port, - // so allow it to do long string and cheat replacements. + // If it's in a lump, it's probably designed for a modern source port, + // so allow it to do long string and cheat replacements. - deh_allow_long_strings = true; - deh_allow_long_cheats = true; + deh_allow_long_strings = true; + deh_allow_long_cheats = true; - context = DEH_OpenLump(lumpnum); + context = DEH_OpenLump(lumpnum); - if (context == NULL) - { - fprintf(stderr, "DEH_LoadFile: Unable to open lump %i\n", lumpnum); - return 0; - } + if (context == NULL) + { + fprintf(stderr, "DEH_LoadFile: Unable to open lump %i\n", lumpnum); + return 0; + } - DEH_ParseContext(context); + DEH_ParseContext(context); - DEH_CloseFile(context); + DEH_CloseFile(context); - return 1; + return 1; } int DEH_LoadLumpByName(char *name) { - int lumpnum; + int lumpnum; - lumpnum = W_CheckNumForName(name); + lumpnum = W_CheckNumForName(name); - if (lumpnum == -1) - { - fprintf(stderr, "DEH_LoadLumpByName: '%s' lump not found\n", name); - return 0; - } + if (lumpnum == -1) + { + fprintf(stderr, "DEH_LoadLumpByName: '%s' lump not found\n", name); + return 0; + } - return DEH_LoadLump(lumpnum); + return DEH_LoadLump(lumpnum); } // Checks the command line for -deh argument void DEH_Init(void) { - char *filename; - int p; - - InitializeSections(); - - //! - // @category mod - // - // Ignore cheats in dehacked files. - // - - if (M_CheckParm("-nocheats") > 0) - { - deh_apply_cheats = false; - } - - //! - // @arg - // @category mod - // - // Load the given dehacked patch(es) - // - - p = M_CheckParm("-hhe"); - - if (p > 0) - { - ++p; - - while (p < myargc && myargv[p][0] != '-') - { - filename = myargv[p]; // FS: D_TryFindWADByName(myargv[p]); - DEH_LoadFile(filename); - ++p; - } - } + char *filename; + int p; + + InitializeSections(); + + //! + // @category mod + // + // Ignore cheats in dehacked files. + // + + if (M_CheckParm("-nocheats") > 0) + { + deh_apply_cheats = false; + } + + //! + // @arg + // @category mod + // + // Load the given dehacked patch(es) + // + + p = M_CheckParm("-hhe"); + + if (p > 0) + { + ++p; + + while (p < myargc && myargv[p][0] != '-') + { + filename = myargv[p]; // FS: D_TryFindWADByName(myargv[p]); + DEH_LoadFile(filename); + ++p; + } + } } diff --git a/deh_map.c b/deh_map.c index b1a0846..4a3261d 100644 --- a/deh_map.c +++ b/deh_map.c @@ -39,96 +39,96 @@ // Set the value of a particular field in a structure by name // -boolean DEH_SetMapping(deh_context_t *context, deh_mapping_t *mapping, - void *structptr, char *name, int value) +boolean DEH_SetMapping(deh_context_t *context, deh_mapping_t *mapping, + void *structptr, char *name, int value) { - int i; - - for (i=0; mapping->entries[i].name != NULL; ++i) - { - deh_mapping_entry_t *entry = &mapping->entries[i]; - - if (!strcasecmp(entry->name, name)) - { - void *location; - - if (entry->location == NULL) - { - DEH_Warning(context, "Field '%s' is unsupported", name); - return false; - } - - location = (uint8_t *)structptr + ((uint8_t *)entry->location - (uint8_t *)mapping->base); - - //printf("Setting %p::%s to %i (%i bytes)\n", - // structptr, name, value, entry->size); - - switch (entry->size) - { - case 1: - * ((uint8_t *) location) = value; - break; - case 2: - * ((uint16_t *) location) = value; - break; - case 4: - * ((uint32_t *) location) = value; - break; - default: - DEH_Error(context, "Unknown field type for '%s' (BUG)", name); - return false; - } - - return true; - } - } - - // field with this name not found - - DEH_Warning(context, "Field named '%s' not found", name); - - return false; + int i; + + for (i = 0; mapping->entries[i].name != NULL; ++i) + { + deh_mapping_entry_t *entry = &mapping->entries[i]; + + if (!strcasecmp(entry->name, name)) + { + void *location; + + if (entry->location == NULL) + { + DEH_Warning(context, "Field '%s' is unsupported", name); + return false; + } + + location = (uint8_t *)structptr + ((uint8_t *)entry->location - (uint8_t *)mapping->base); + + //printf("Setting %p::%s to %i (%i bytes)\n", + // structptr, name, value, entry->size); + + switch (entry->size) + { + case 1: + *((uint8_t *)location) = value; + break; + case 2: + *((uint16_t *)location) = value; + break; + case 4: + *((uint32_t *)location) = value; + break; + default: + DEH_Error(context, "Unknown field type for '%s' (BUG)", name); + return false; + } + + return true; + } + } + + // field with this name not found + + DEH_Warning(context, "Field named '%s' not found", name); + + return false; } void DEH_StructMD5Sum(md5_context_t *context, deh_mapping_t *mapping, - void *structptr) + void *structptr) { - int i; - - // Go through each mapping - - for (i=0; mapping->entries[i].name != NULL; ++i) - { - deh_mapping_entry_t *entry = &mapping->entries[i]; - void *location; - - if (entry->location == NULL) - { - // Unsupported field - - continue; - } - - // Add in data for this field - - location = (uint8_t *)structptr + ((uint8_t *)entry->location - (uint8_t *)mapping->base); - - switch (entry->size) - { - case 1: - MD5_UpdateInt32(context, *((uint8_t *) location)); - break; - case 2: - MD5_UpdateInt32(context, *((uint16_t *) location)); - break; - case 4: - MD5_UpdateInt32(context, *((uint32_t *) location)); - break; - default: - I_Error("Unknown dehacked mapping field type for '%s' (BUG)", - entry->name); - break; - } - } + int i; + + // Go through each mapping + + for (i = 0; mapping->entries[i].name != NULL; ++i) + { + deh_mapping_entry_t *entry = &mapping->entries[i]; + void *location; + + if (entry->location == NULL) + { + // Unsupported field + + continue; + } + + // Add in data for this field + + location = (uint8_t *)structptr + ((uint8_t *)entry->location - (uint8_t *)mapping->base); + + switch (entry->size) + { + case 1: + MD5_UpdateInt32(context, *((uint8_t *)location)); + break; + case 2: + MD5_UpdateInt32(context, *((uint16_t *)location)); + break; + case 4: + MD5_UpdateInt32(context, *((uint32_t *)location)); + break; + default: + I_Error("Unknown dehacked mapping field type for '%s' (BUG)", + entry->name); + break; + } + } } diff --git a/deh_misc.c b/deh_misc.c index 400c984..87df8c2 100644 --- a/deh_misc.c +++ b/deh_misc.c @@ -143,98 +143,98 @@ int deh_species_infighting = DEH_DEFAULT_SPECIES_INFIGHTING; static struct { - char *deh_name; - int *value; + char *deh_name; + int *value; } misc_settings[] = { - {"Initial Health", &deh_initial_health}, - {"Initial Bullets", &deh_initial_bullets}, - {"Max Health", &deh_max_health}, - {"Max Armor", &deh_max_armor}, - {"Green Armor Class", &deh_green_armor_class}, - {"Blue Armor Class", &deh_blue_armor_class}, - {"Max Soulsphere", &deh_max_soulsphere}, - {"Soulsphere Health", &deh_soulsphere_health}, - {"Megasphere Health", &deh_megasphere_health}, - {"God Mode Health", &deh_god_mode_health}, - {"IDFA Armor", &deh_idfa_armor}, - {"IDFA Armor Class", &deh_idfa_armor_class}, - {"IDKFA Armor", &deh_idkfa_armor}, - {"IDKFA Armor Class", &deh_idkfa_armor_class}, - {"BFG Cells/Shot", &deh_bfg_cells_per_shot}, + {"Initial Health", &deh_initial_health}, + {"Initial Bullets", &deh_initial_bullets}, + {"Max Health", &deh_max_health}, + {"Max Armor", &deh_max_armor}, + {"Green Armor Class", &deh_green_armor_class}, + {"Blue Armor Class", &deh_blue_armor_class}, + {"Max Soulsphere", &deh_max_soulsphere}, + {"Soulsphere Health", &deh_soulsphere_health}, + {"Megasphere Health", &deh_megasphere_health}, + {"God Mode Health", &deh_god_mode_health}, + {"IDFA Armor", &deh_idfa_armor}, + {"IDFA Armor Class", &deh_idfa_armor_class}, + {"IDKFA Armor", &deh_idkfa_armor}, + {"IDKFA Armor Class", &deh_idkfa_armor_class}, + {"BFG Cells/Shot", &deh_bfg_cells_per_shot}, }; static void *DEH_MiscStart(deh_context_t *context, char *line) { - return NULL; + return NULL; } static void DEH_MiscParseLine(deh_context_t *context, char *line, void *tag) { - char *variable_name, *value; - int ivalue; - size_t i; - - if (!DEH_ParseAssignment(line, &variable_name, &value)) - { - // Failed to parse - - DEH_Warning(context, "Failed to parse assignment"); - return; - } - - ivalue = atoi(value); - - if (!strcasecmp(variable_name, "Monsters Infight")) - { - // See notes above. - - if (ivalue == 202) - { - deh_species_infighting = 0; - } - else if (ivalue == 221) - { - deh_species_infighting = 1; - } - else - { - DEH_Warning(context, - "Invalid value for 'Monsters Infight': %i", ivalue); - } - - return; - } - - for (i=0; i= NUMSTATES) - { - DEH_Warning(context, "Invalid frame number: %i", frame_number); - return NULL; - } - - return &states[frame_number]; + int frame_number = 0; + + // FIXME: can the third argument here be something other than "Frame" + // or are we ok? + + if (sscanf(line, "Pointer %*i (%*s %i)", &frame_number) != 1) + { + DEH_Warning(context, "Parse error on section start"); + return NULL; + } + + if (frame_number < 0 || frame_number >= NUMSTATES) + { + DEH_Warning(context, "Invalid frame number: %i", frame_number); + return NULL; + } + + return &states[frame_number]; } static void DEH_PointerParseLine(deh_context_t *context, char *line, void *tag) { - state_t *state; - char *variable_name, *value; - int ivalue; - - if (tag == NULL) - return; - - state = (state_t *) tag; - - // Parse the assignment - - if (!DEH_ParseAssignment(line, &variable_name, &value)) - { - // Failed to parse - DEH_Warning(context, "Failed to parse assignment"); - return; - } - - //printf("Set %s to %s for state\n", variable_name, value); - - // all values are integers - - ivalue = atoi(value); - - // set the appropriate field - - if (!strcasecmp(variable_name, "Codep frame")) - { - if (ivalue < 0 || ivalue >= NUMSTATES) - { - DEH_Warning(context, "Invalid state '%i'", ivalue); - } - else - { - state->action = codeptrs[ivalue]; - } - } - else - { - DEH_Warning(context, "Unknown variable name '%s'", variable_name); - } + state_t *state; + char *variable_name, *value; + int ivalue; + + if (tag == NULL) + return; + + state = (state_t *)tag; + + // Parse the assignment + + if (!DEH_ParseAssignment(line, &variable_name, &value)) + { + // Failed to parse + DEH_Warning(context, "Failed to parse assignment"); + return; + } + + //printf("Set %s to %s for state\n", variable_name, value); + + // all values are integers + + ivalue = atoi(value); + + // set the appropriate field + + if (!strcasecmp(variable_name, "Codep frame")) + { + if (ivalue < 0 || ivalue >= NUMSTATES) + { + DEH_Warning(context, "Invalid state '%i'", ivalue); + } + else + { + state->action = codeptrs[ivalue]; + } + } + else + { + DEH_Warning(context, "Unknown variable name '%s'", variable_name); + } } static void DEH_PointerMD5Sum(md5_context_t *context) { - int i; + int i; - for (i=0; i= NUMSFX) - { - DEH_Warning(context, "Invalid sound number: %i", sound_number); - return NULL; - } - - if (sound_number >= DEH_VANILLA_NUMSFX) - { - DEH_Warning(context, "Attempt to modify SFX %i. This will cause " - "problems in Vanilla dehacked.", sound_number); - } - - return &S_sfx[sound_number]; + int sound_number = 0; + + if (sscanf(line, "Sound %i", &sound_number) != 1) + { + DEH_Warning(context, "Parse error on section start"); + return NULL; + } + + if (sound_number < 0 || sound_number >= NUMSFX) + { + DEH_Warning(context, "Invalid sound number: %i", sound_number); + return NULL; + } + + if (sound_number >= DEH_VANILLA_NUMSFX) + { + DEH_Warning(context, "Attempt to modify SFX %i. This will cause " + "problems in Vanilla dehacked.", sound_number); + } + + return &S_sfx[sound_number]; } static void DEH_SoundParseLine(deh_context_t *context, char *line, void *tag) { - sfxinfo_t *sfx; - char *variable_name, *value; - int ivalue; - - if (tag == NULL) - return; + sfxinfo_t *sfx; + char *variable_name, *value; + int ivalue; - sfx = (sfxinfo_t *) tag; + if (tag == NULL) + return; - // Parse the assignment + sfx = (sfxinfo_t *)tag; - if (!DEH_ParseAssignment(line, &variable_name, &value)) - { - // Failed to parse - DEH_Warning(context, "Failed to parse assignment"); - return; - } - - // all values are integers + // Parse the assignment - ivalue = atoi(value); - - // Set the field value + if (!DEH_ParseAssignment(line, &variable_name, &value)) + { + // Failed to parse + DEH_Warning(context, "Failed to parse assignment"); + return; + } - DEH_SetMapping(context, &sound_mapping, sfx, variable_name, ivalue); + // all values are integers + + ivalue = atoi(value); + + // Set the field value + + DEH_SetMapping(context, &sound_mapping, sfx, variable_name, ivalue); } deh_section_t deh_section_sound = { - "Sound", - NULL, - DEH_SoundStart, - DEH_SoundParseLine, - NULL, - NULL, + "Sound", + NULL, + DEH_SoundStart, + DEH_SoundParseLine, + NULL, + NULL, }; diff --git a/deh_text.c b/deh_text.c index 2ef80bf..edbf0c9 100644 --- a/deh_text.c +++ b/deh_text.c @@ -36,10 +36,10 @@ #define vsnprintf _vsnprintf // FS: Watcom needs this -typedef struct +typedef struct { - char *from_text; - char *to_text; + char *from_text; + char *to_text; } deh_substitution_t; static deh_substitution_t **hash_table; @@ -51,16 +51,16 @@ static int hash_table_length = -1; static unsigned int strhash(char *s) { - char *p = s; - unsigned int h = *p; - - if (h) - { - for (p += 1; *p; p++) - h = (h << 5) - h + *p; - } - - return h; + char *p = s; + unsigned int h = *p; + + if (h) + { + for (p += 1; *p; p++) + h = (h << 5) - h + *p; + } + + return h; } // Look up a string to see if it has been replaced with something else @@ -68,89 +68,89 @@ static unsigned int strhash(char *s) char *DEH_String(char *s) { - int entry; + int entry; - // Fallback if we have not initialized the hash table yet + // Fallback if we have not initialized the hash table yet - if (hash_table_length < 0) - return s; + if (hash_table_length < 0) + return s; - entry = strhash(s) % hash_table_length; + entry = strhash(s) % hash_table_length; - while (hash_table[entry] != NULL) - { - if (!strcmp(hash_table[entry]->from_text, s)) - { - // substitution found! + while (hash_table[entry] != NULL) + { + if (!strcmp(hash_table[entry]->from_text, s)) + { + // substitution found! - return hash_table[entry]->to_text; - } + return hash_table[entry]->to_text; + } - entry = (entry + 1) % hash_table_length; - } + entry = (entry + 1) % hash_table_length; + } - // no substitution found + // no substitution found - return s; + return s; } static void DEH_AddToHashtable(deh_substitution_t *sub); static void IncreaseHashtable(void) { - deh_substitution_t **old_table; - int old_table_length; - int i; - - // save the old table - - old_table = hash_table; - old_table_length = hash_table_length; - - // double the size - - hash_table_length *= 2; - hash_table = Z_Malloc(sizeof(deh_substitution_t *) * hash_table_length, - PU_STATIC, NULL); - memset(hash_table, 0, sizeof(deh_substitution_t *) * hash_table_length); - - // go through the old table and insert all the old entries - - for (i=0; i 6) - { - IncreaseHashtable(); - } - - // find where to insert it - - entry = strhash(sub->from_text) % hash_table_length; - - while (hash_table[entry] != NULL) - { - entry = (entry + 1) % hash_table_length; - } - - hash_table[entry] = sub; - ++hash_table_entries; + int entry; + + // if the hash table is more than 60% full, increase its size + + if ((hash_table_entries * 10) / hash_table_length > 6) + { + IncreaseHashtable(); + } + + // find where to insert it + + entry = strhash(sub->from_text) % hash_table_length; + + while (hash_table[entry] != NULL) + { + entry = (entry + 1) % hash_table_length; + } + + hash_table[entry] = sub; + ++hash_table_entries; } // Given a string length, find the maximum length of a @@ -158,112 +158,112 @@ static void DEH_AddToHashtable(deh_substitution_t *sub) static int TXT_MaxStringLength(int len) { - // Enough bytes for the string and the NUL terminator + // Enough bytes for the string and the NUL terminator - len += 1; + len += 1; - // All strings in doom.exe are on 4-byte boundaries, so we may be able - // to support a slightly longer string. - // Extend up to the next 4-byte boundary + // All strings in doom.exe are on 4-byte boundaries, so we may be able + // to support a slightly longer string. + // Extend up to the next 4-byte boundary - len += (4 - (len % 4)) % 4; - - // Less one for the NUL terminator. + len += (4 - (len % 4)) % 4; - return len - 1; + // Less one for the NUL terminator. + + return len - 1; } static void DEH_TextInit(void) { - // init hash table - - hash_table_entries = 0; - hash_table_length = 16; - hash_table = Z_Malloc(sizeof(deh_substitution_t *) * hash_table_length, - PU_STATIC, NULL); - memset(hash_table, 0, sizeof(deh_substitution_t *) * hash_table_length); + // init hash table + + hash_table_entries = 0; + hash_table_length = 16; + hash_table = Z_Malloc(sizeof(deh_substitution_t *) * hash_table_length, + PU_STATIC, NULL); + memset(hash_table, 0, sizeof(deh_substitution_t *) * hash_table_length); } static void *DEH_TextStart(deh_context_t *context, char *line) { - deh_substitution_t *sub; - int fromlen, tolen; - int i; - - if (sscanf(line, "Text %i %i", &fromlen, &tolen) != 2) - { - DEH_Warning(context, "Parse error on section start"); - return NULL; - } - - // Only allow string replacements that are possible in Vanilla Doom. - // Chocolate Doom is unforgiving! - - if (!deh_allow_long_strings && tolen > TXT_MaxStringLength(fromlen)) - { - DEH_Error(context, "Replacement string is longer than the maximum " - "possible in doom.exe"); - return NULL; - } - - sub = Z_Malloc(sizeof(deh_substitution_t), PU_STATIC, NULL); - sub->from_text = Z_Malloc(fromlen + 1, PU_STATIC, NULL); - sub->to_text = Z_Malloc(tolen + 1, PU_STATIC, NULL); - - // read in the "from" text - - for (i=0; ifrom_text[i] = c; - } - - sub->from_text[fromlen] = '\0'; - - // read in the "to" text - - for (i=0; ito_text[i] = c; - } - sub->to_text[tolen] = '\0'; - - DEH_AddToHashtable(sub); - - return NULL; + deh_substitution_t *sub; + int fromlen, tolen; + int i; + + if (sscanf(line, "Text %i %i", &fromlen, &tolen) != 2) + { + DEH_Warning(context, "Parse error on section start"); + return NULL; + } + + // Only allow string replacements that are possible in Vanilla Doom. + // Chocolate Doom is unforgiving! + + if (!deh_allow_long_strings && tolen > TXT_MaxStringLength(fromlen)) + { + DEH_Error(context, "Replacement string is longer than the maximum " + "possible in doom.exe"); + return NULL; + } + + sub = Z_Malloc(sizeof(deh_substitution_t), PU_STATIC, NULL); + sub->from_text = Z_Malloc(fromlen + 1, PU_STATIC, NULL); + sub->to_text = Z_Malloc(tolen + 1, PU_STATIC, NULL); + + // read in the "from" text + + for (i = 0; i < fromlen; ++i) + { + int c; + + c = DEH_GetChar(context); + + sub->from_text[i] = c; + } + + sub->from_text[fromlen] = '\0'; + + // read in the "to" text + + for (i = 0; i < tolen; ++i) + { + int c; + + c = DEH_GetChar(context); + + sub->to_text[i] = c; + } + sub->to_text[tolen] = '\0'; + + DEH_AddToHashtable(sub); + + return NULL; } static void DEH_TextParseLine(deh_context_t *context, char *line, void *tag) { - // not used + // not used } deh_section_t deh_section_text = { - "Text", - DEH_TextInit, - DEH_TextStart, - DEH_TextParseLine, - NULL, - NULL, + "Text", + DEH_TextInit, + DEH_TextStart, + DEH_TextParseLine, + NULL, + NULL, }; typedef enum { - FORMAT_ARG_INVALID, - FORMAT_ARG_INT, - FORMAT_ARG_FLOAT, - FORMAT_ARG_CHAR, - FORMAT_ARG_STRING, - FORMAT_ARG_PTR, - FORMAT_ARG_SAVE_POS + FORMAT_ARG_INVALID, + FORMAT_ARG_INT, + FORMAT_ARG_FLOAT, + FORMAT_ARG_CHAR, + FORMAT_ARG_STRING, + FORMAT_ARG_PTR, + FORMAT_ARG_SAVE_POS } format_arg_t; // Get the type of a format argument. @@ -272,30 +272,30 @@ typedef enum static format_arg_t FormatArgumentType(char c) { - switch (c) - { - case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': - return FORMAT_ARG_INT; + switch (c) + { + case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': + return FORMAT_ARG_INT; - case 'e': case 'E': case 'f': case 'F': case 'g': case 'G': - case 'a': case 'A': - return FORMAT_ARG_FLOAT; + case 'e': case 'E': case 'f': case 'F': case 'g': case 'G': + case 'a': case 'A': + return FORMAT_ARG_FLOAT; - case 'c': case 'C': - return FORMAT_ARG_CHAR; + case 'c': case 'C': + return FORMAT_ARG_CHAR; - case 's': case 'S': - return FORMAT_ARG_STRING; + case 's': case 'S': + return FORMAT_ARG_STRING; - case 'p': - return FORMAT_ARG_PTR; + case 'p': + return FORMAT_ARG_PTR; - case 'n': - return FORMAT_ARG_SAVE_POS; + case 'n': + return FORMAT_ARG_SAVE_POS; - default: - return FORMAT_ARG_INVALID; - } + default: + return FORMAT_ARG_INVALID; + } } // Given the specified string, get the type of the first format @@ -303,181 +303,181 @@ static format_arg_t FormatArgumentType(char c) static format_arg_t NextFormatArgument(char **str) { - format_arg_t argtype; + format_arg_t argtype; - // Search for the '%' starting the next string. + // Search for the '%' starting the next string. - while (**str != '\0') - { - if (**str == '%') - { - ++*str; + while (**str != '\0') + { + if (**str == '%') + { + ++ *str; - // Don't stop for double-%s. + // Don't stop for double-%s. - if (**str != '%') - { - break; - } - } + if (**str != '%') + { + break; + } + } - ++*str; - } + ++ *str; + } - // Find the type of the format string. + // Find the type of the format string. - while (**str != '\0') - { - argtype = FormatArgumentType(**str); + while (**str != '\0') + { + argtype = FormatArgumentType(**str); - if (argtype != FORMAT_ARG_INVALID) - { - ++*str; + if (argtype != FORMAT_ARG_INVALID) + { + ++ *str; - return argtype; - } + return argtype; + } - ++*str; - } + ++ *str; + } - // Stop searching, we have reached the end. + // Stop searching, we have reached the end. - *str = NULL; + *str = NULL; - return FORMAT_ARG_INVALID; + return FORMAT_ARG_INVALID; } // Check if the specified argument type is a valid replacement for // the original. static boolean ValidArgumentReplacement(format_arg_t original, - format_arg_t replacement) + format_arg_t replacement) { - // In general, the original and replacement types should be - // identical. However, there are some cases where the replacement - // is valid and the types don't match. + // In general, the original and replacement types should be + // identical. However, there are some cases where the replacement + // is valid and the types don't match. - // Characters can be represented as ints. + // Characters can be represented as ints. - if (original == FORMAT_ARG_CHAR && replacement == FORMAT_ARG_INT) - { - return true; - } + if (original == FORMAT_ARG_CHAR && replacement == FORMAT_ARG_INT) + { + return true; + } - // Strings are pointers. + // Strings are pointers. - if (original == FORMAT_ARG_STRING && replacement == FORMAT_ARG_PTR) - { - return true; - } + if (original == FORMAT_ARG_STRING && replacement == FORMAT_ARG_PTR) + { + return true; + } - return original == replacement; + return original == replacement; } // Return true if the specified string contains no format arguments. static boolean ValidFormatReplacement(char *original, char *replacement) { - char *rover1; - char *rover2; - int argtype1, argtype2; + char *rover1; + char *rover2; + int argtype1, argtype2; - // Check each argument in turn and compare types. + // Check each argument in turn and compare types. - rover1 = original; rover2 = replacement; + rover1 = original; rover2 = replacement; - for (;;) - { - argtype1 = NextFormatArgument(&rover1); - argtype2 = NextFormatArgument(&rover2); + for (;;) + { + argtype1 = NextFormatArgument(&rover1); + argtype2 = NextFormatArgument(&rover2); - if (argtype2 == FORMAT_ARG_INVALID) - { - // No more arguments left to read from the replacement string. + if (argtype2 == FORMAT_ARG_INVALID) + { + // No more arguments left to read from the replacement string. - break; - } - else if (argtype1 == FORMAT_ARG_INVALID) - { - // Replacement string has more arguments than the original. + break; + } + else if (argtype1 == FORMAT_ARG_INVALID) + { + // Replacement string has more arguments than the original. - return false; - } - else if (!ValidArgumentReplacement(argtype1, argtype2)) - { - // Not a valid replacement argument. + return false; + } + else if (!ValidArgumentReplacement(argtype1, argtype2)) + { + // Not a valid replacement argument. - return false; - } - } + return false; + } + } - return true; + return true; } // Get replacement format string, checking arguments. static char *FormatStringReplacement(char *s) { - char *repl; + char *repl; - repl = DEH_String(s); + repl = DEH_String(s); - if (!ValidFormatReplacement(s, repl)) - { - printf("WARNING: Unsafe dehacked replacement provided for " - "printf format string: %s\n", s); + if (!ValidFormatReplacement(s, repl)) + { + printf("WARNING: Unsafe dehacked replacement provided for " + "printf format string: %s\n", s); - return s; - } + return s; + } - return repl; + return repl; } // printf(), performing a replacement on the format string. void DEH_printf(char *fmt, ...) { - va_list args; - char *repl; + va_list args; + char *repl; - repl = FormatStringReplacement(fmt); + repl = FormatStringReplacement(fmt); - va_start(args, fmt); + va_start(args, fmt); - vprintf(repl, args); + vprintf(repl, args); - va_end(args); + va_end(args); } // fprintf(), performing a replacement on the format string. void DEH_fprintf(FILE *fstream, char *fmt, ...) { - va_list args; - char *repl; + va_list args; + char *repl; - repl = FormatStringReplacement(fmt); + repl = FormatStringReplacement(fmt); - va_start(args, fmt); + va_start(args, fmt); - vfprintf(fstream, repl, args); + vfprintf(fstream, repl, args); - va_end(args); + va_end(args); } // snprintf(), performing a replacement on the format string. void DEH_snprintf(char *buffer, size_t len, char *fmt, ...) { - va_list args; - char *repl; + va_list args; + char *repl; - repl = FormatStringReplacement(fmt); + repl = FormatStringReplacement(fmt); - va_start(args, fmt); + va_start(args, fmt); - vsnprintf(buffer, len, repl, args); + vsnprintf(buffer, len, repl, args); - va_end(args); + va_end(args); } diff --git a/deh_thng.c b/deh_thng.c index e14ab88..5895af6 100644 --- a/deh_thng.c +++ b/deh_thng.c @@ -36,106 +36,106 @@ //#include "info.h" DEH_BEGIN_MAPPING(thing_mapping, mobjinfo_t) - DEH_MAPPING("ID #", doomednum) - DEH_MAPPING("Initial frame", spawnstate) - DEH_MAPPING("Hit points", spawnhealth) - DEH_MAPPING("First moving frame", seestate) - DEH_MAPPING("Alert sound", seesound) - DEH_MAPPING("Reaction time", reactiontime) - DEH_MAPPING("Attack sound", attacksound) - DEH_MAPPING("Injury frame", painstate) - DEH_MAPPING("Pain chance", painchance) - DEH_MAPPING("Pain sound", painsound) - DEH_MAPPING("Close attack frame", meleestate) - DEH_MAPPING("Far attack frame", missilestate) - DEH_MAPPING("Death frame", deathstate) - DEH_MAPPING("Exploding frame", xdeathstate) - DEH_MAPPING("Death sound", deathsound) - DEH_MAPPING("Speed", speed) - DEH_MAPPING("Width", radius) - DEH_MAPPING("Height", height) - DEH_MAPPING("Mass", mass) - DEH_MAPPING("Missile damage", damage) - DEH_MAPPING("Action sound", activesound) - DEH_MAPPING("Bits 1", flags) - DEH_MAPPING("Bits 2", flags2) + DEH_MAPPING("ID #", doomednum) + DEH_MAPPING("Initial frame", spawnstate) + DEH_MAPPING("Hit points", spawnhealth) + DEH_MAPPING("First moving frame", seestate) + DEH_MAPPING("Alert sound", seesound) + DEH_MAPPING("Reaction time", reactiontime) + DEH_MAPPING("Attack sound", attacksound) + DEH_MAPPING("Injury frame", painstate) + DEH_MAPPING("Pain chance", painchance) + DEH_MAPPING("Pain sound", painsound) + DEH_MAPPING("Close attack frame", meleestate) + DEH_MAPPING("Far attack frame", missilestate) + DEH_MAPPING("Death frame", deathstate) + DEH_MAPPING("Exploding frame", xdeathstate) + DEH_MAPPING("Death sound", deathsound) + DEH_MAPPING("Speed", speed) + DEH_MAPPING("Width", radius) + DEH_MAPPING("Height", height) + DEH_MAPPING("Mass", mass) + DEH_MAPPING("Missile damage", damage) + DEH_MAPPING("Action sound", activesound) + DEH_MAPPING("Bits 1", flags) + DEH_MAPPING("Bits 2", flags2) DEH_END_MAPPING static void *DEH_ThingStart(deh_context_t *context, char *line) { - int thing_number = 0; - mobjinfo_t *mobj; - - if (sscanf(line, "Thing %i", &thing_number) != 1) - { - DEH_Warning(context, "Parse error on section start"); - return NULL; - } + int thing_number = 0; + mobjinfo_t *mobj; + + if (sscanf(line, "Thing %i", &thing_number) != 1) + { + DEH_Warning(context, "Parse error on section start"); + return NULL; + } if (thing_number >= 90) // FS: HACK --thing_number; - // dehacked files are indexed from 1 - --thing_number; - - if (thing_number < 0 || thing_number >= NUMMOBJTYPES) - { - DEH_Warning(context, "Invalid thing number: %i", thing_number); - return NULL; - } - mobj = &mobjinfo[thing_number]; - - return mobj; + // dehacked files are indexed from 1 + --thing_number; + + if (thing_number < 0 || thing_number >= NUMMOBJTYPES) + { + DEH_Warning(context, "Invalid thing number: %i", thing_number); + return NULL; + } + mobj = &mobjinfo[thing_number]; + + return mobj; } static void DEH_ThingParseLine(deh_context_t *context, char *line, void *tag) { - mobjinfo_t *mobj; - char *variable_name, *value; - int ivalue; - - if (tag == NULL) - return; + mobjinfo_t *mobj; + char *variable_name, *value; + int ivalue; + + if (tag == NULL) + return; + + mobj = (mobjinfo_t *)tag; + + // Parse the assignment - mobj = (mobjinfo_t *) tag; + if (!DEH_ParseAssignment(line, &variable_name, &value)) + { + // Failed to parse - // Parse the assignment + DEH_Warning(context, "Failed to parse assignment"); + return; + } - if (!DEH_ParseAssignment(line, &variable_name, &value)) - { - // Failed to parse + //printf("Set %s to %s for mobj\n", variable_name, value); - DEH_Warning(context, "Failed to parse assignment"); - return; - } - - //printf("Set %s to %s for mobj\n", variable_name, value); + // all values are integers - // all values are integers + ivalue = atoi(value); - ivalue = atoi(value); - - // Set the field value + // Set the field value - DEH_SetMapping(context, &thing_mapping, mobj, variable_name, ivalue); + DEH_SetMapping(context, &thing_mapping, mobj, variable_name, ivalue); } static void DEH_ThingMD5Sum(md5_context_t *context) { - int i; + int i; - for (i=0; i= NUMWEAPONS) - { - DEH_Warning(context, "Invalid weapon number: %i", weapon_number); - return NULL; - } - - return &wpnlev1info[weapon_number]; // FS: Hax + int weapon_number = 0; + + if (sscanf(line, "Weapon %i", &weapon_number) != 1) + { + DEH_Warning(context, "Parse error on section start"); + return NULL; + } + + if (weapon_number < 0 || weapon_number >= NUMWEAPONS) + { + DEH_Warning(context, "Invalid weapon number: %i", weapon_number); + return NULL; + } + + return &wpnlev1info[weapon_number]; // FS: Hax } static void DEH_WeaponParseLine(deh_context_t *context, char *line, void *tag) { - char *variable_name, *value; - weaponinfo_t *weapon; - int ivalue; - - if (tag == NULL) - return; + char *variable_name, *value; + weaponinfo_t *weapon; + int ivalue; + + if (tag == NULL) + return; - weapon = (weaponinfo_t *) tag; + weapon = (weaponinfo_t *)tag; - if (!DEH_ParseAssignment(line, &variable_name, &value)) - { - // Failed to parse + if (!DEH_ParseAssignment(line, &variable_name, &value)) + { + // Failed to parse - DEH_Warning(context, "Failed to parse assignment"); - return; - } + DEH_Warning(context, "Failed to parse assignment"); + return; + } - ivalue = atoi(value); + ivalue = atoi(value); - DEH_SetMapping(context, &weapon_mapping, weapon, variable_name, ivalue); + DEH_SetMapping(context, &weapon_mapping, weapon, variable_name, ivalue); } static void DEH_WeaponMD5Sum(md5_context_t *context) { - int i; + int i; - for (i=0; ibuf[0] = 0x67452301; - ctx->buf[1] = 0xefcdab89; - ctx->buf[2] = 0x98badcfe; - ctx->buf[3] = 0x10325476; + ctx->buf[0] = 0x67452301; + ctx->buf[1] = 0xefcdab89; + ctx->buf[2] = 0x98badcfe; + ctx->buf[3] = 0x10325476; - ctx->bytes[0] = 0; - ctx->bytes[1] = 0; + ctx->bytes[0] = 0; + ctx->bytes[1] = 0; } /* @@ -71,90 +72,93 @@ MD5_Init(md5_context_t *ctx) void MD5_Update(md5_context_t *ctx, byte const *buf, unsigned len) { - uint32_t t; - - /* Update byte count */ - - t = ctx->bytes[0]; - if ((ctx->bytes[0] = t + len) < t) - ctx->bytes[1]++; /* Carry from low to high */ - - t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */ - if (t > len) { - memcpy((byte *)ctx->in + 64 - t, buf, len); - return; - } - /* First chunk is an odd size */ - memcpy((byte *)ctx->in + 64 - t, buf, t); - ByteSwapBlock(ctx->in, 16); - MD5_Transform(ctx->buf, ctx->in); - buf += t; - len -= t; - - /* Process data in 64-byte chunks */ - while (len >= 64) { - memcpy(ctx->in, buf, 64); - ByteSwapBlock(ctx->in, 16); - MD5_Transform(ctx->buf, ctx->in); - buf += 64; - len -= 64; - } - - /* Handle any remaining bytes of data. */ - memcpy(ctx->in, buf, len); + uint32_t t; + + /* Update byte count */ + + t = ctx->bytes[0]; + if ((ctx->bytes[0] = t + len) < t) + ctx->bytes[1]++; /* Carry from low to high */ + + t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */ + if (t > len) + { + memcpy((byte *)ctx->in + 64 - t, buf, len); + return; + } + /* First chunk is an odd size */ + memcpy((byte *)ctx->in + 64 - t, buf, t); + ByteSwapBlock(ctx->in, 16); + MD5_Transform(ctx->buf, ctx->in); + buf += t; + len -= t; + + /* Process data in 64-byte chunks */ + while (len >= 64) + { + memcpy(ctx->in, buf, 64); + ByteSwapBlock(ctx->in, 16); + MD5_Transform(ctx->buf, ctx->in); + buf += 64; + len -= 64; + } + + /* Handle any remaining bytes of data. */ + memcpy(ctx->in, buf, len); } void MD5_UpdateInt32(md5_context_t *context, unsigned int val) { - byte buf[4]; + byte buf[4]; - buf[0] = (val >> 24) & 0xff; - buf[1] = (val >> 16) & 0xff; - buf[2] = (val >> 8) & 0xff; - buf[3] = val & 0xff; + buf[0] = (val >> 24) & 0xff; + buf[1] = (val >> 16) & 0xff; + buf[2] = (val >> 8) & 0xff; + buf[3] = val & 0xff; - MD5_Update(context, buf, 4); + MD5_Update(context, buf, 4); } void MD5_UpdateString(md5_context_t *context, char *str) { - MD5_Update(context, (byte *) str, strlen(str) + 1); + MD5_Update(context, (byte *)str, strlen(str) + 1); } /* - * Final wrapup - pad to 64-byte boundary with the bit pattern + * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ void MD5_Final(byte digest[16], md5_context_t *ctx) { - int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */ - byte *p = (byte *)ctx->in + count; - - /* Set the first char of padding to 0x80. There is always room. */ - *p++ = 0x80; - - /* Bytes of padding needed to make 56 bytes (-8..55) */ - count = 56 - 1 - count; - - if (count < 0) { /* Padding forces an extra block */ - memset(p, 0, count + 8); - ByteSwapBlock(ctx->in, 16); - MD5_Transform(ctx->buf, ctx->in); - p = (byte *)ctx->in; - count = 56; - } - memset(p, 0, count); - ByteSwapBlock(ctx->in, 14); - - /* Append length in bits and transform */ - ctx->in[14] = ctx->bytes[0] << 3; - ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29; - MD5_Transform(ctx->buf, ctx->in); - - ByteSwapBlock(ctx->buf, 4); - memcpy(digest, ctx->buf, 16); - memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ + int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */ + byte *p = (byte *)ctx->in + count; + + /* Set the first char of padding to 0x80. There is always room. */ + *p++ = 0x80; + + /* Bytes of padding needed to make 56 bytes (-8..55) */ + count = 56 - 1 - count; + + if (count < 0) + { /* Padding forces an extra block */ + memset(p, 0, count + 8); + ByteSwapBlock(ctx->in, 16); + MD5_Transform(ctx->buf, ctx->in); + p = (byte *)ctx->in; + count = 56; + } + memset(p, 0, count); + ByteSwapBlock(ctx->in, 14); + + /* Append length in bits and transform */ + ctx->in[14] = ctx->bytes[0] << 3; + ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29; + MD5_Transform(ctx->buf, ctx->in); + + ByteSwapBlock(ctx->buf, 4); + memcpy(digest, ctx->buf, 16); + memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ } #ifndef ASM_MD5 @@ -179,85 +183,85 @@ MD5_Final(byte digest[16], md5_context_t *ctx) void MD5_Transform(uint32_t buf[4], uint32_t const in[16]) { - register uint32_t a, b, c, d; - - a = buf[0]; - b = buf[1]; - c = buf[2]; - d = buf[3]; - - MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); - MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); - MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); - MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); - MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); - MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); - MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); - MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); - MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); - MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); - MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); - MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); - MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); - MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); - MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); - MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); - - MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); - MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); - MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); - MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); - MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); - MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); - MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); - MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); - MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); - MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); - MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); - MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); - MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); - MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); - MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); - MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); - - MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); - MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); - MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); - MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); - MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); - MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); - MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); - MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); - MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); - MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); - MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); - MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); - MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); - MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); - MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); - MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); - - MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); - MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); - MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); - MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); - MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); - MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); - MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); - MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); - MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); - MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); - MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); - MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); - MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); - MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); - MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); - MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); - - buf[0] += a; - buf[1] += b; - buf[2] += c; - buf[3] += d; + register uint32_t a, b, c, d; + + a = buf[0]; + b = buf[1]; + c = buf[2]; + d = buf[3]; + + MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); + MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); + MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); + MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); + MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); + MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); + MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); + MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); + MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); + MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); + MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); + MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); + MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); + MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); + MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); + MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); + + MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); + MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); + MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); + MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); + MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); + MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); + MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); + MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); + MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); + MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); + MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); + MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); + MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); + MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); + MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); + MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); + + MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); + MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); + MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); + MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); + MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); + MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); + MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); + MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); + MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); + MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); + MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); + MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); + MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); + MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); + MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); + MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); + + MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); + MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); + MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); + MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); + MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); + MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); + MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); + MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); + MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); + MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); + MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); + MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); + MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); + MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); + MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); + MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); + + buf[0] += a; + buf[1] += b; + buf[2] += c; + buf[3] += d; } #endif diff --git a/s_sound.c b/s_sound.c index dadb510..570867b 100644 --- a/s_sound.c +++ b/s_sound.c @@ -46,42 +46,42 @@ void S_Start(void) { int i; - S_StartSong((gameepisode-1)*9 + gamemap-1, true); + S_StartSong((gameepisode - 1) * 9 + gamemap - 1, true); //stop all sounds - for(i=0; i < snd_Channels; i++) + for (i = 0; i < snd_Channels; i++) { - if(channel[i].handle) + if (channel[i].handle) { S_StopSound(channel[i].mo); } } - memset(channel, 0, 8*sizeof(channel_t)); + memset(channel, 0, 8 * sizeof(channel_t)); } void S_StartSong(int song, boolean loop) { - if(song == mus_song) + if (song == mus_song) { // don't replay an old song return; } - if(rs) + if (rs) { I_StopSong(rs); I_UnRegisterSong(rs); Z_ChangeTag(lumpcache[mus_lumpnum], PU_CACHE); #ifdef __WATCOMC__ - _dpmi_unlockregion(mus_sndptr, lumpinfo[mus_lumpnum].size); + _dpmi_unlockregion(mus_sndptr, lumpinfo[mus_lumpnum].size); #endif } - if(song < mus_e1m1 || song > NUMMUSIC) + if (song < mus_e1m1 || song > NUMMUSIC) { return; } mus_lumpnum = W_GetNumForName(S_music[song].name); mus_sndptr = W_CacheLumpNum(mus_lumpnum, PU_MUSIC); #ifdef __WATCOMC__ - _dpmi_lockregion(mus_sndptr, lumpinfo[mus_lumpnum].size); + _dpmi_lockregion(mus_sndptr, lumpinfo[mus_lumpnum].size); #endif rs = I_RegisterSong(mus_sndptr); I_PlaySong(rs, loop); //'true' denotes endless looping. @@ -102,54 +102,54 @@ void S_StartSound(mobj_t *origin, int sound_id) static int sndcount = 0; int chan; - if(sound_id==0 || snd_MaxVolume == 0) + if (sound_id == 0 || snd_MaxVolume == 0) return; - if(origin == NULL) + if (origin == NULL) { origin = players[consoleplayer].mo; } -// calculate the distance before other stuff so that we can throw out -// sounds that are beyond the hearing range. - absx = abs(origin->x-players[consoleplayer].mo->x); - absy = abs(origin->y-players[consoleplayer].mo->y); - dist = absx+absy-(absx > absy ? absy>>1 : absx>>1); + // calculate the distance before other stuff so that we can throw out + // sounds that are beyond the hearing range. + absx = abs(origin->x - players[consoleplayer].mo->x); + absy = abs(origin->y - players[consoleplayer].mo->y); + dist = absx + absy - (absx > absy ? absy >> 1 : absx >> 1); dist >>= FRACBITS; -// dist = P_AproxDistance(origin->x-viewx, origin->y-viewy)>>FRACBITS; + // dist = P_AproxDistance(origin->x-viewx, origin->y-viewy)>>FRACBITS; - if(dist >= MAX_SND_DIST) + if (dist >= MAX_SND_DIST) { -// dist = MAX_SND_DIST - 1; - return; //sound is beyond the hearing range... + // dist = MAX_SND_DIST - 1; + return; //sound is beyond the hearing range... } - if(dist < 0) + if (dist < 0) { dist = 0; } priority = S_sfx[sound_id].priority; - priority *= (10 - (dist/160)); - if(!S_StopSoundID(sound_id, priority)) + priority *= (10 - (dist / 160)); + if (!S_StopSoundID(sound_id, priority)) { return; // other sounds have greater priority } - for(i=0; iplayer) + if (origin->player) { i = snd_Channels; break; // let the player have more than one sound. } - if(origin == channel[i].mo) + if (origin == channel[i].mo) { // only allow other mobjs one sound S_StopSound(channel[i].mo); break; } } - if(i >= snd_Channels) + if (i >= snd_Channels) { - if(sound_id >= sfx_wind) + if (sound_id >= sfx_wind) { - if(AmbChan != -1 && S_sfx[sound_id].priority <= + if (AmbChan != -1 && S_sfx[sound_id].priority <= S_sfx[channel[AmbChan].sound_id].priority) { return; //ambient channel already in use @@ -159,48 +159,48 @@ void S_StartSound(mobj_t *origin, int sound_id) AmbChan = -1; } } - for(i=0; i= snd_Channels) + if (i >= snd_Channels) { //look for a lower priority sound to replace. sndcount++; - if(sndcount >= snd_Channels) + if (sndcount >= snd_Channels) { sndcount = 0; } - for(chan=0; chan < snd_Channels; chan++) + for (chan = 0; chan < snd_Channels; chan++) { - i = (sndcount+chan)%snd_Channels; - if(priority >= channel[i].priority) + i = (sndcount + chan) % snd_Channels; + if (priority >= channel[i].priority) { chan = -1; //denote that sound should be replaced. break; } } - if(chan != -1) + if (chan != -1) { return; //no free channels. } else //replace the lower priority sound. { - if(channel[i].handle) + if (channel[i].handle) { - if(I_SoundIsPlaying(channel[i].handle)) + if (I_SoundIsPlaying(channel[i].handle)) { I_StopSound(channel[i].handle); } - if(S_sfx[channel[i].sound_id].usefulness > 0) + if (S_sfx[channel[i].sound_id].usefulness > 0) { S_sfx[channel[i].sound_id].usefulness--; } - if(AmbChan == i) + if (AmbChan == i) { AmbChan = -1; } @@ -208,11 +208,11 @@ void S_StartSound(mobj_t *origin, int sound_id) } } } - if(S_sfx[sound_id].lumpnum == 0) + if (S_sfx[sound_id].lumpnum == 0) { S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]); } - if(S_sfx[sound_id].snd_ptr == NULL) + if (S_sfx[sound_id].snd_ptr == NULL) { S_sfx[sound_id].snd_ptr = W_CacheLumpNum(S_sfx[sound_id].lumpnum, PU_SOUND); @@ -225,7 +225,7 @@ void S_StartSound(mobj_t *origin, int sound_id) // vol = (snd_MaxVolume*16 + dist*(-snd_MaxVolume*16)/MAX_SND_DIST)>>9; vol = soundCurve[dist]; - if(origin == players[consoleplayer].mo) + if (origin == players[consoleplayer].mo) { sep = 128; } @@ -233,24 +233,24 @@ void S_StartSound(mobj_t *origin, int sound_id) { angle = R_PointToAngle2(players[consoleplayer].mo->x, players[consoleplayer].mo->y, channel[i].mo->x, channel[i].mo->y); - angle = (angle-viewangle)>>24; - sep = angle*2-128; - if(sep < 64) + angle = (angle - viewangle) >> 24; + sep = angle * 2 - 128; + if (sep < 64) sep = -sep; - if(sep > 192) - sep = 512-sep; + if (sep > 192) + sep = 512 - sep; } - channel[i].pitch = (byte)(127+(M_Random()&7)-(M_Random()&7)); + channel[i].pitch = (byte)(127 + (M_Random() & 7) - (M_Random() & 7)); channel[i].handle = I_StartSound(sound_id, S_sfx[sound_id].snd_ptr, vol, sep, channel[i].pitch, 0); channel[i].mo = origin; channel[i].sound_id = sound_id; channel[i].priority = priority; - if(sound_id >= sfx_wind) + if (sound_id >= sfx_wind) { AmbChan = i; } - if(S_sfx[sound_id].usefulness == -1) + if (S_sfx[sound_id].usefulness == -1) { S_sfx[sound_id].usefulness = 1; } @@ -269,36 +269,36 @@ void S_StartSoundAtVolume(mobj_t *origin, int sound_id, int volume) static int sndcount; int chan; - if(sound_id == 0 || snd_MaxVolume == 0) + if (sound_id == 0 || snd_MaxVolume == 0) return; - if(origin == NULL) + if (origin == NULL) { origin = players[consoleplayer].mo; } - if(volume == 0) + if (volume == 0) { return; } - volume = (volume*(snd_MaxVolume+1)*8)>>7; + volume = (volume * (snd_MaxVolume + 1) * 8) >> 7; -// no priority checking, as ambient sounds would be the LOWEST. - for(i=0; i= snd_Channels) + if (i >= snd_Channels) { return; } - if(S_sfx[sound_id].lumpnum == 0) + if (S_sfx[sound_id].lumpnum == 0) { S_sfx[sound_id].lumpnum = I_GetSfxLumpNum(&S_sfx[sound_id]); } - if(S_sfx[sound_id].snd_ptr == NULL) + if (S_sfx[sound_id].snd_ptr == NULL) { S_sfx[sound_id].snd_ptr = W_CacheLumpNum(S_sfx[sound_id].lumpnum, PU_SOUND); @@ -306,12 +306,12 @@ void S_StartSoundAtVolume(mobj_t *origin, int sound_id, int volume) _dpmi_lockregion(S_sfx[sound_id].snd_ptr, lumpinfo[S_sfx[sound_id].lumpnum].size); #endif } - channel[i].pitch = (byte)(127-(M_Random()&3)+(M_Random()&3)); + channel[i].pitch = (byte)(127 - (M_Random() & 3) + (M_Random() & 3)); channel[i].handle = I_StartSound(sound_id, S_sfx[sound_id].snd_ptr, volume, 128, channel[i].pitch, 0); channel[i].mo = origin; channel[i].sound_id = sound_id; channel[i].priority = 1; //super low priority. - if(S_sfx[sound_id].usefulness == -1) + if (S_sfx[sound_id].usefulness == -1) { S_sfx[sound_id].usefulness = 1; } @@ -327,39 +327,39 @@ boolean S_StopSoundID(int sound_id, int priority) int lp; //least priority int found; - if(S_sfx[sound_id].numchannels == -1) + if (S_sfx[sound_id].numchannels == -1) { return(true); } lp = -1; //denote the argument sound_id found = 0; - for(i=0; i= channel[i].priority) + if (priority >= channel[i].priority) { // if we're gonna kill one, then this'll be it lp = i; priority = channel[i].priority; } } } - if(found < S_sfx[sound_id].numchannels) + if (found < S_sfx[sound_id].numchannels) { return(true); } - else if(lp == -1) + else if (lp == -1) { return(false); // don't replace any sounds } - if(channel[lp].handle) + if (channel[lp].handle) { - if(I_SoundIsPlaying(channel[lp].handle)) + if (I_SoundIsPlaying(channel[lp].handle)) { I_StopSound(channel[lp].handle); } - if(S_sfx[channel[i].sound_id].usefulness > 0) + if (S_sfx[channel[i].sound_id].usefulness > 0) { S_sfx[channel[i].sound_id].usefulness--; } @@ -372,18 +372,18 @@ void S_StopSound(mobj_t *origin) { int i; - for(i=0;i 0) + if (S_sfx[channel[i].sound_id].usefulness > 0) { S_sfx[channel[i].sound_id].usefulness--; } channel[i].handle = 0; channel[i].mo = NULL; - if(AmbChan == i) + if (AmbChan == i) { AmbChan = -1; } @@ -395,9 +395,9 @@ void S_SoundLink(mobj_t *oldactor, mobj_t *newactor) { int i; - for(i=0;iid == 0x1d4a11) { // taken directly from the Z_ChangeTag macro Z_ChangeTag2(lumpcache[S_sfx[i].lumpnum], PU_CACHE); #ifdef __WATCOMC__ - _dpmi_unlockregion(S_sfx[i].snd_ptr, lumpinfo[S_sfx[i].lumpnum].size); + _dpmi_unlockregion(S_sfx[i].snd_ptr, lumpinfo[S_sfx[i].lumpnum].size); #endif } } @@ -449,64 +449,64 @@ void S_UpdateSounds(mobj_t *listener) S_sfx[i].snd_ptr = NULL; } } - nextcleanup = gametic+35; //CLEANUP DEBUG cleans every second + nextcleanup = gametic + 35; //CLEANUP DEBUG cleans every second } - for(i=0;i 0) + if (S_sfx[channel[i].sound_id].usefulness > 0) { S_sfx[channel[i].sound_id].usefulness--; } channel[i].handle = 0; channel[i].mo = NULL; channel[i].sound_id = 0; - if(AmbChan == i) + if (AmbChan == i) { AmbChan = -1; } } - if(channel[i].mo == NULL || channel[i].sound_id == 0 + if (channel[i].mo == NULL || channel[i].sound_id == 0 || channel[i].mo == players[consoleplayer].mo) { continue; } else { - absx = abs(channel[i].mo->x-players[consoleplayer].mo->x); - absy = abs(channel[i].mo->y-players[consoleplayer].mo->y); - dist = absx+absy-(absx > absy ? absy>>1 : absx>>1); + absx = abs(channel[i].mo->x - players[consoleplayer].mo->x); + absy = abs(channel[i].mo->y - players[consoleplayer].mo->y); + dist = absx + absy - (absx > absy ? absy >> 1 : absx >> 1); dist >>= FRACBITS; -// dist = P_AproxDistance(channel[i].mo->x-listener->x, channel[i].mo->y-listener->y)>>FRACBITS; + // dist = P_AproxDistance(channel[i].mo->x-listener->x, channel[i].mo->y-listener->y)>>FRACBITS; - if(dist >= MAX_SND_DIST) + if (dist >= MAX_SND_DIST) { S_StopSound(channel[i].mo); continue; } - if(dist < 0) + if (dist < 0) dist = 0; -// calculate the volume based upon the distance from the sound origin. -// vol = (*((byte *)W_CacheLumpName("SNDCURVE", PU_CACHE)+dist)*(snd_MaxVolume*8))>>7; + // calculate the volume based upon the distance from the sound origin. + // vol = (*((byte *)W_CacheLumpName("SNDCURVE", PU_CACHE)+dist)*(snd_MaxVolume*8))>>7; vol = soundCurve[dist]; angle = R_PointToAngle2(players[consoleplayer].mo->x, players[consoleplayer].mo->y, channel[i].mo->x, channel[i].mo->y); - angle = (angle-viewangle)>>24; - sep = angle*2-128; - if(sep < 64) + angle = (angle - viewangle) >> 24; + sep = angle * 2 - 128; + if (sep < 64) sep = -sep; - if(sep > 192) - sep = 512-sep; + if (sep > 192) + sep = 512 - sep; I_UpdateSoundParams(channel[i].handle, vol, sep, channel[i].pitch); priority = S_sfx[channel[i].sound_id].priority; - priority *= (10 - (dist>>8)); + priority *= (10 - (dist >> 8)); channel[i].priority = priority; } } @@ -516,7 +516,7 @@ void S_Init(void) { soundCurve = Z_Malloc(MAX_SND_DIST, PU_STATIC, NULL); I_StartupSound(); - if(snd_Channels > 8) + if (snd_Channels > 8) { snd_Channels = 8; } @@ -533,15 +533,15 @@ void S_GetChannelInfo(SoundInfo_t *s) s->channelCount = snd_Channels; s->musicVolume = snd_MusicVolume; s->soundVolume = snd_MaxVolume; - for(i = 0; i < snd_Channels; i++) + for (i = 0; i < snd_Channels; i++) { c = &s->chan[i]; c->id = channel[i].sound_id; c->priority = channel[i].priority; c->name = S_sfx[c->id].name; c->mo = channel[i].mo; - c->distance = P_AproxDistance(c->mo->x-viewx, c->mo->y-viewy) - >>FRACBITS; + c->distance = P_AproxDistance(c->mo->x - viewx, c->mo->y - viewy) + >> FRACBITS; } } @@ -549,15 +549,15 @@ void S_SetMaxVolume(boolean fullprocess) { int i; - if(!fullprocess) + if (!fullprocess) { - soundCurve[0] = (*((byte *)W_CacheLumpName("SNDCURVE", PU_CACHE))*(snd_MaxVolume*8))>>7; + soundCurve[0] = (*((byte *)W_CacheLumpName("SNDCURVE", PU_CACHE)) * (snd_MaxVolume * 8)) >> 7; } else { - for(i = 0; i < MAX_SND_DIST; i++) + for (i = 0; i < MAX_SND_DIST; i++) { - soundCurve[i] = (*((byte *)W_CacheLumpName("SNDCURVE", PU_CACHE)+i)*(snd_MaxVolume*8))>>7; + soundCurve[i] = (*((byte *)W_CacheLumpName("SNDCURVE", PU_CACHE) + i) * (snd_MaxVolume * 8)) >> 7; } } } @@ -566,12 +566,12 @@ static boolean musicPaused; void S_SetMusicVolume(void) { I_SetMusicVolume(snd_MusicVolume); - if(snd_MusicVolume == 0) + if (snd_MusicVolume == 0) { I_PauseSong(rs); musicPaused = true; } - else if(musicPaused) + else if (musicPaused) { musicPaused = false; I_ResumeSong(rs); @@ -581,10 +581,10 @@ void S_SetMusicVolume(void) void S_ShutDown(void) { extern int tsm_ID; - if(tsm_ID != -1) + if (tsm_ID != -1) { - I_StopSong(rs); - I_UnRegisterSong(rs); - I_ShutdownSound(); + I_StopSong(rs); + I_UnRegisterSong(rs); + I_ShutdownSound(); } } diff --git a/sys_dosw.c b/sys_dosw.c index d442c89..0e61c4d 100644 --- a/sys_dosw.c +++ b/sys_dosw.c @@ -190,26 +190,26 @@ int kbdtail, kbdhead; #define SC_LSHIFT 0x2a byte scantokey[128] = - { -// 0 1 2 3 4 5 6 7 -// 8 9 A B C D E F - 0 , 27, '1', '2', '3', '4', '5', '6', - '7', '8', '9', '0', '-', '=', KEY_BACKSPACE, 9, // 0 - 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', - 'o', 'p', '[', ']', 13 , KEY_RCTRL,'a', 's', // 1 - 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', - 39 , '`', KEY_LSHIFT,92, 'z', 'x', 'c', 'v', // 2 - 'b', 'n', 'm', ',', '.', '/', KEY_RSHIFT,'*', - KEY_RALT,' ', 0 , KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, // 3 - KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10,0 , 0 , KEY_HOME, - KEY_UPARROW,KEY_PGUP,'-',KEY_LEFTARROW,'5',KEY_RIGHTARROW,'+',KEY_END, //4 - KEY_DOWNARROW,KEY_PGDN,KEY_INS,KEY_DEL,0,0, 0, KEY_F11, - KEY_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5 - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6 - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, - 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7 - }; +{ + // 0 1 2 3 4 5 6 7 + // 8 9 A B C D E F + 0 , 27, '1', '2', '3', '4', '5', '6', + '7', '8', '9', '0', '-', '=', KEY_BACKSPACE, 9, // 0 + 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', + 'o', 'p', '[', ']', 13 , KEY_RCTRL,'a', 's', // 1 + 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', + 39 , '`', KEY_LSHIFT,92, 'z', 'x', 'c', 'v', // 2 + 'b', 'n', 'm', ',', '.', '/', KEY_RSHIFT,'*', + KEY_RALT,' ', 0 , KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, // 3 + KEY_F6, KEY_F7, KEY_F8, KEY_F9, KEY_F10,0 , 0 , KEY_HOME, + KEY_UPARROW,KEY_PGUP,'-',KEY_LEFTARROW,'5',KEY_RIGHTARROW,'+',KEY_END, //4 + KEY_DOWNARROW,KEY_PGDN,KEY_INS,KEY_DEL,0,0, 0, KEY_F11, + KEY_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5 + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6 + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, + 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7 +}; //========================================================================== @@ -241,7 +241,7 @@ void I_ColorBorder(void) I_WaitVBL(1); _outbyte(PEL_WRITE_ADR, 0); - for(i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { _outbyte(PEL_DATA, 63); } @@ -259,7 +259,7 @@ void I_UnColorBorder(void) I_WaitVBL(1); _outbyte(PEL_WRITE_ADR, 0); - for(i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { _outbyte(PEL_DATA, 0); } @@ -283,28 +283,28 @@ void I_WaitVBL(int vbls) { int stat; - if(novideo) + if (novideo) { return; } - while(vbls--) + while (vbls--) { do { stat = inp(STATUS_REGISTER_1); - if(stat&8) + if (stat & 8) { break; } - } while(1); + } while (1); do { stat = inp(STATUS_REGISTER_1); - if((stat&8) == 0) + if ((stat & 8) == 0) { break; } - } while(1); + } while (1); } } @@ -320,15 +320,15 @@ void I_SetPalette(byte *palette) { int i; - if(novideo) + if (novideo) { return; } I_WaitVBL(1); _outbyte(PEL_WRITE_ADR, 0); - for(i = 0; i < 768; i++) + for (i = 0; i < 768; i++) { - _outbyte(PEL_DATA, (gammatable[usegamma][*palette++])>>2); + _outbyte(PEL_DATA, (gammatable[usegamma][*palette++]) >> 2); } } @@ -351,24 +351,24 @@ void I_InitVRGoggles (void) return; } - if(netgame) + if (netgame) { I_Error("Can't use VR Goggles in a netgame!\n"); } - if(usevrgoggles) /* FS: Already in this mode, don't fool with it */ + if (usevrgoggles) /* FS: Already in this mode, don't fool with it */ return; #ifdef USE_VRGOGGLES usevrgoggles = true; - pcscreen = destscreen = (byte *)malloc(SCREENHEIGHT*SCREENWIDTH); + pcscreen = destscreen = (byte *)malloc(SCREENHEIGHT * SCREENWIDTH); SVRDosInit(); SVRDosSetMode(SVR_320_200_X); SVRDosSetBlackCode(0); SVRDosSetWhiteCode(255); SVRDosSetRegistration(TRUE); - SVRDosSetImage(LEFT,0,0,320,200,pcscreen); - SVRDosSetImage(RIGHT,0,0,320,200,pcscreen); + SVRDosSetImage(LEFT, 0, 0, 320, 200, pcscreen); + SVRDosSetImage(RIGHT, 0, 0, 320, 200, pcscreen); I_SetPalette((byte *)W_CacheLumpName("PLAYPAL", PU_CACHE)); #endif } @@ -391,15 +391,15 @@ void I_Update (void) int tics; static int lasttic; - if(usevrgoggles) + if (usevrgoggles) return; -// -// blit screen to video -// - if(DisplayTicker) + // + // blit screen to video + // + if (DisplayTicker) { - if(screenblocks > 9 || UpdateState&(I_FULLSCRN|I_MESSAGES)) + if (screenblocks > 9 || UpdateState & (I_FULLSCRN | I_MESSAGES)) { dest = (byte *)screen; } @@ -407,64 +407,64 @@ void I_Update (void) { dest = (byte *)pcscreen; } - tics = ticcount-lasttic; + tics = ticcount - lasttic; lasttic = ticcount; - if(tics > 20) + if (tics > 20) { tics = 20; } - for(i = 0; i < tics; i++) + for (i = 0; i < tics; i++) { *dest = 0xff; dest += 2; } - for(i = tics; i < 20; i++) + for (i = tics; i < 20; i++) { *dest = 0x00; dest += 2; } } - if(UpdateState == I_NOUPDATE) + if (UpdateState == I_NOUPDATE) { return; } - if(UpdateState&I_FULLSCRN) + if (UpdateState & I_FULLSCRN) { - memcpy(pcscreen, screen, SCREENWIDTH*SCREENHEIGHT); + memcpy(pcscreen, screen, SCREENWIDTH * SCREENHEIGHT); UpdateState = I_NOUPDATE; // clear out all draw types } - if(UpdateState&I_FULLVIEW) + if (UpdateState & I_FULLVIEW) { - if(UpdateState&I_MESSAGES && screenblocks > 7) + if (UpdateState & I_MESSAGES && screenblocks > 7) { - for(i = 0; i < - (viewwindowy+viewheight)*SCREENWIDTH; i += SCREENWIDTH) + for (i = 0; i < + (viewwindowy + viewheight) * SCREENWIDTH; i += SCREENWIDTH) { - memcpy(pcscreen+i, screen+i, SCREENWIDTH); + memcpy(pcscreen + i, screen + i, SCREENWIDTH); } - UpdateState &= ~(I_FULLVIEW|I_MESSAGES); + UpdateState &= ~(I_FULLVIEW | I_MESSAGES); } else { - for(i = viewwindowy*SCREENWIDTH+viewwindowx; i < - (viewwindowy+viewheight)*SCREENWIDTH; i += SCREENWIDTH) + for (i = viewwindowy * SCREENWIDTH + viewwindowx; i < + (viewwindowy + viewheight) * SCREENWIDTH; i += SCREENWIDTH) { - memcpy(pcscreen+i, screen+i, viewwidth); + memcpy(pcscreen + i, screen + i, viewwidth); } UpdateState &= ~I_FULLVIEW; } } - if(UpdateState&I_STATBAR) + if (UpdateState & I_STATBAR) { - memcpy(pcscreen+SCREENWIDTH*(SCREENHEIGHT-SBARHEIGHT), - screen+SCREENWIDTH*(SCREENHEIGHT-SBARHEIGHT), - SCREENWIDTH*SBARHEIGHT); + memcpy(pcscreen + SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT), + screen + SCREENWIDTH * (SCREENHEIGHT - SBARHEIGHT), + SCREENWIDTH * SBARHEIGHT); UpdateState &= ~I_STATBAR; } - if(UpdateState&I_MESSAGES) + if (UpdateState & I_MESSAGES) { - memcpy(pcscreen, screen, SCREENWIDTH*28); + memcpy(pcscreen, screen, SCREENWIDTH * 28); UpdateState &= ~I_MESSAGES; } } @@ -477,7 +477,7 @@ void I_Update (void) void I_InitGraphics(void) { - if(novideo) + if (novideo) { return; } @@ -500,7 +500,7 @@ void I_InitGraphics(void) void I_ShutdownVRGoggles (boolean exit) { #ifdef USE_VRGOGGLES - if(usevrgoggles) + if (usevrgoggles) { SVRDosSetMode(SVR_320_200); SVRDosSetRegistration(FALSE); @@ -519,7 +519,7 @@ void I_ShutdownGraphics(void) { I_ShutdownVRGoggles(true); - if(*(byte *)0x449 == 0x13) // don't reset mode if it didn't get set + if (*(byte *)0x449 == 0x13) // don't reset mode if it didn't get set { regs.w.ax = 3; int386(0x10, ®s, ®s); // back to text mode @@ -536,7 +536,7 @@ void I_ShutdownGraphics(void) void I_ReadScreen(byte *scr) { - memcpy(scr, screen, SCREENWIDTH*SCREENHEIGHT); + memcpy(scr, screen, SCREENWIDTH * SCREENHEIGHT); } @@ -626,29 +626,29 @@ void I_StartTic (void) I_ReadMouse (); -// -// keyboard events -// + // + // keyboard events + // while (kbdtail < kbdhead) { - k = keyboardque[kbdtail&(KBDQUESIZE-1)]; + k = keyboardque[kbdtail & (KBDQUESIZE - 1)]; kbdtail++; // extended keyboard shift key bullshit - if ( (k&0x7f)==SC_LSHIFT || (k&0x7f)==SC_RSHIFT ) + if ((k & 0x7f) == SC_LSHIFT || (k & 0x7f) == SC_RSHIFT) { - if ( keyboardque[(kbdtail-2)&(KBDQUESIZE-1)]==0xe0 ) + if (keyboardque[(kbdtail - 2) & (KBDQUESIZE - 1)] == 0xe0) continue; k &= 0x80; k |= SC_RSHIFT; } - if (k==0xe0) + if (k == 0xe0) continue; // special / pause keys - if (keyboardque[(kbdtail-2)&(KBDQUESIZE-1)] == 0xe1) + if (keyboardque[(kbdtail - 2) & (KBDQUESIZE - 1)] == 0xe1) continue; // pause key bullshit - if (k==0xc5 && keyboardque[(kbdtail-2)&(KBDQUESIZE-1)] == 0x9d) + if (k == 0xc5 && keyboardque[(kbdtail - 2) & (KBDQUESIZE - 1)] == 0x9d) { ev.type = ev_keydown; ev.data1 = KEY_PAUSE; @@ -656,28 +656,28 @@ void I_StartTic (void) continue; } - if (k&0x80) + if (k & 0x80) ev.type = ev_keyup; else ev.type = ev_keydown; k &= 0x7f; switch (k) { - case SC_UPARROW: - ev.data1 = KEY_UPARROW; - break; - case SC_DOWNARROW: - ev.data1 = KEY_DOWNARROW; - break; - case SC_LEFTARROW: - ev.data1 = KEY_LEFTARROW; - break; - case SC_RIGHTARROW: - ev.data1 = KEY_RIGHTARROW; - break; - default: - ev.data1 = scantokey[k]; - break; + case SC_UPARROW: + ev.data1 = KEY_UPARROW; + break; + case SC_DOWNARROW: + ev.data1 = KEY_DOWNARROW; + break; + case SC_LEFTARROW: + ev.data1 = KEY_LEFTARROW; + break; + case SC_RIGHTARROW: + ev.data1 = KEY_RIGHTARROW; + break; + default: + ev.data1 = scantokey[k]; + break; } D_PostEvent (&ev); } @@ -693,14 +693,14 @@ void I_ReadKeys (void) while (1) { - while (kbdtail < kbdhead) - { - k = keyboardque[kbdtail&(KBDQUESIZE-1)]; - kbdtail++; - printf ("0x%x\n",k); - if (k == 1) - I_Quit (); - } + while (kbdtail < kbdhead) + { + k = keyboardque[kbdtail & (KBDQUESIZE - 1)]; + kbdtail++; + printf ("0x%x\n", k); + if (k == 1) + I_Quit (); + } } } @@ -728,10 +728,10 @@ void I_StartFrame (void) void I_ColorBlack (int r, int g, int b) { -_outbyte (PEL_WRITE_ADR,0); -_outbyte(PEL_DATA,r); -_outbyte(PEL_DATA,g); -_outbyte(PEL_DATA,b); + _outbyte (PEL_WRITE_ADR, 0); + _outbyte(PEL_DATA, r); + _outbyte(PEL_DATA, g); + _outbyte(PEL_DATA, b); } @@ -771,14 +771,14 @@ int lastpress; void __interrupt I_KeyboardISR (void) { -// Get the scan code + // Get the scan code - keyboardque[kbdhead&(KBDQUESIZE-1)] = lastpress = _inbyte(0x60); + keyboardque[kbdhead & (KBDQUESIZE - 1)] = lastpress = _inbyte(0x60); kbdhead++; -// acknowledge the interrupt + // acknowledge the interrupt - _outbyte(0x20,0x20); + _outbyte(0x20, 0x20); } @@ -798,7 +798,7 @@ void I_StartupKeyboard (void) _dos_setvect (0x8000 | KEYBOARDINT, I_KeyboardISR); #endif -//I_ReadKeys (); + //I_ReadKeys (); } @@ -841,21 +841,21 @@ void I_StartupCyberMan(void); void I_StartupMouse (void) { - int (far *function)(); + int (far * function)(); - // - // General mouse detection - // + // + // General mouse detection + // mousepresent = 0; - if ( M_CheckParm ("-nomouse") || !usemouse ) + if (M_CheckParm ("-nomouse") || !usemouse) return; if (I_ResetMouse () != 0xffff) { - tprintf ("Mouse: not present\n",0); + tprintf ("Mouse: not present\n", 0); return; } - tprintf ("Mouse: detected\n",0); + tprintf ("Mouse: detected\n", 0); mousepresent = 1; @@ -874,7 +874,7 @@ void I_StartupMouse (void) void I_ShutdownMouse (void) { if (!mousepresent) - return; + return; I_ResetMouse (); } @@ -892,15 +892,15 @@ void I_ReadMouse (void) { event_t ev; -// -// mouse events -// + // + // mouse events + // if (!mousepresent) return; ev.type = ev_mouse; - memset (&dpmiregs,0,sizeof(dpmiregs)); + memset (&dpmiregs, 0, sizeof(dpmiregs)); dpmiregs.eax = 3; // read buttons / position DPMIInt (0x33); ev.data1 = dpmiregs.ebx; @@ -931,36 +931,36 @@ boolean WaitJoyButton (void) do { I_WaitVBL (1); - buttons = ((inp(0x201) >> 4)&1)^1; + buttons = ((inp(0x201) >> 4) & 1) ^ 1; if (buttons != oldbuttons) { oldbuttons = buttons; continue; } - if ( (lastpress& 0x7f) == 1 ) + if ((lastpress & 0x7f) == 1) { joystickpresent = false; return false; } - } while ( !buttons); + } while (!buttons); do { I_WaitVBL (1); - buttons = ((inp(0x201) >> 4)&1)^1; + buttons = ((inp(0x201) >> 4) & 1) ^ 1; if (buttons != oldbuttons) { oldbuttons = buttons; continue; } - if ( (lastpress& 0x7f) == 1 ) + if ((lastpress & 0x7f) == 1) { joystickpresent = false; return false; } - } while ( buttons); + } while (buttons); return true; } @@ -984,13 +984,13 @@ void I_StartupJoystick (void) int centerx, centery; joystickpresent = 0; - if ( M_CheckParm ("-nojoy") || !usejoystick ) + if (M_CheckParm ("-nojoy") || !usejoystick) return; if (!I_ReadJoystick ()) { joystickpresent = false; - tprintf ("joystick not found\n",0); + tprintf ("joystick not found\n", 0); return; } printf("joystick found\n"); @@ -1007,15 +1007,15 @@ void I_StartupJoystick (void) if (!WaitJoyButton ()) return; I_ReadJoystick (); - joyxl = (centerx + joystickx)/2; - joyyl = (centerx + joysticky)/2; + joyxl = (centerx + joystickx) / 2; + joyyl = (centerx + joysticky) / 2; printf("\nPush the joystick to the LOWER RIGHT corner and press button 1:"); if (!WaitJoyButton ()) return; I_ReadJoystick (); - joyxh = (centerx + joystickx)/2; - joyyh = (centery + joysticky)/2; + joyxh = (centerx + joystickx) / 2; + joyyh = (centery + joysticky) / 2; printf("\n"); } @@ -1031,15 +1031,15 @@ void I_JoystickEvents (void) { event_t ev; -// -// joystick events -// + // + // joystick events + // if (!joystickpresent) return; I_ReadJoystick (); ev.type = ev_joystick; - ev.data1 = ((inp(0x201) >> 4)&15)^15; + ev.data1 = ((inp(0x201) >> 4) & 15) ^ 15; if (joystickx < joyxl) ev.data2 = -1; @@ -1084,14 +1084,14 @@ void DPMIFarCall (void) regs.w.cx = 0; regs.x.edi = (unsigned)&dpmiregs; segregs.es = segregs.ds; - int386x( DPMI_INT, ®s, ®s, &segregs ); + int386x(DPMI_INT, ®s, ®s, &segregs); } void DPMIInt (int i) { dpmiregs.ss = realstackseg; - dpmiregs.sp = REALSTACKSIZE-4; + dpmiregs.sp = REALSTACKSIZE - 4; segread (&segregs); regs.w.ax = 0x300; @@ -1099,7 +1099,7 @@ void DPMIInt (int i) regs.w.cx = 0; regs.x.edi = (unsigned)&dpmiregs; segregs.es = segregs.ds; - int386x( DPMI_INT, ®s, ®s, &segregs ); + int386x(DPMI_INT, ®s, ®s, &segregs); } @@ -1115,41 +1115,41 @@ void I_StartupDPMI (void) { extern char __begtext; extern char ___argc; - int n,d; + int n, d; -// -// allocate a decent stack for real mode ISRs -// + // + // allocate a decent stack for real mode ISRs + // realstackseg = (int)I_AllocLow (1024) >> 4; -// -// lock the entire program down -// + // + // lock the entire program down + // -// _dpmi_lockregion (&__begtext, &___argc - &__begtext); + // _dpmi_lockregion (&__begtext, &___argc - &__begtext); -// -// catch divide by 0 exception -// + // + // catch divide by 0 exception + // #if 0 segread(&segregs); regs.w.ax = 0x0203; // DPMI set processor exception handler vector regs.w.bx = 0; // int 0 regs.w.cx = segregs.cs; regs.x.edx = (int)&I_DivException; - printf ("%x : %x\n",regs.w.cx, regs.x.edx); - int386( DPMI_INT, ®s, ®s); + printf ("%x : %x\n", regs.w.cx, regs.x.edx); + int386(DPMI_INT, ®s, ®s); #endif #if 0 n = I_SetDivException (); - printf ("return: %i\n",n); + printf ("return: %i\n", n); n = 100; d = 0; - printf ("100 / 0 = %i\n",n/d); + printf ("100 / 0 = %i\n", n / d); -exit (1); + exit (1); #endif } @@ -1168,10 +1168,10 @@ void (__interrupt __far *oldtimerisr) (); void IO_ColorBlack (int r, int g, int b) { -_outbyte (PEL_WRITE_ADR,0); -_outbyte(PEL_DATA,r); -_outbyte(PEL_DATA,g); -_outbyte(PEL_DATA,b); + _outbyte (PEL_WRITE_ADR, 0); + _outbyte(PEL_DATA, r); + _outbyte(PEL_DATA, g); + _outbyte(PEL_DATA, b); } @@ -1188,7 +1188,7 @@ _outbyte(PEL_DATA,b); void __interrupt __far IO_TimerISR (void) { ticcount++; - _outbyte(0x20,0x20); // Ack the interrupt + _outbyte(0x20, 0x20); // Ack the interrupt } /* @@ -1204,11 +1204,11 @@ void __interrupt __far IO_TimerISR (void) void IO_SetTimer0(int speed) { if (speed > 0 && speed < 150) - I_Error ("INT_SetTimer0: %i is a bad value",speed); + I_Error ("INT_SetTimer0: %i is a bad value", speed); - _outbyte(0x43,0x36); // Change timer 0 - _outbyte(0x40,speed); - _outbyte(0x40,speed >> 8); + _outbyte(0x43, 0x36); // Change timer 0 + _outbyte(0x40, speed); + _outbyte(0x40, speed >> 8); } @@ -1256,15 +1256,15 @@ void I_Init (void) extern void I_StartupTimer(void); novideo = M_CheckParm("novideo"); - tprintf("I_StartupDPMI\n",1); + tprintf("I_StartupDPMI\n", 1); I_StartupDPMI(); - tprintf("I_StartupMouse\n",1); + tprintf("I_StartupMouse\n", 1); I_StartupMouse(); -// tprintf("I_StartupJoystick\n",1); -// I_StartupJoystick(); -// tprintf("I_StartupKeyboard\n",1); -// I_StartupKeyboard(); - tprintf("S_Init...\n",1); + // tprintf("I_StartupJoystick\n",1); + // I_StartupJoystick(); + // tprintf("I_StartupKeyboard\n",1); + // I_StartupKeyboard(); + tprintf("S_Init...\n", 1); S_Init(); //IO_StartupTimer(); S_Start(); @@ -1309,10 +1309,10 @@ void I_Error (char *error, ...) D_QuitNetGame (); I_Shutdown (); - va_start (argptr,error); + va_start (argptr, error); regs.x.eax = 0x3; int386(0x10, ®s, ®s); - vprintf (error,argptr); + vprintf (error, argptr); va_end (argptr); printf ("\n"); exit (1); @@ -1338,7 +1338,7 @@ void I_Quit(void) M_SaveExtendedDefaults(); // FS: For EXTEND.CFG scr = (byte *)W_CacheLumpName("ENDTEXT", PU_CACHE); I_Shutdown(); - memcpy((void *)0xb8000, scr, 80*25*2); + memcpy((void *)0xb8000, scr, 80 * 25 * 2); regs.w.ax = 0x0200; regs.h.bh = 0; regs.h.dl = 0; @@ -1362,25 +1362,25 @@ byte *I_ZoneBase (int *size) int heap; int i, z; // FS: Testing Heapsize set int block; - byte *ptr; + byte *ptr; - memset (meminfo,0,sizeof(meminfo)); + memset (meminfo, 0, sizeof(meminfo)); segread(&segregs); segregs.es = segregs.ds; regs.w.ax = 0x500; // get memory info regs.x.edi = (int)&meminfo; - int386x( 0x31, ®s, ®s, &segregs ); + int386x(0x31, ®s, ®s, &segregs); heap = meminfo[0]; // FS: Testing manually setting heapsize z = M_CheckParm("-mem"); - if (z && z>16; - regs.w.cx = heap&0xffff; - int386( 0x31, ®s, ®s); + regs.w.bx = heap >> 16; + regs.w.cx = heap & 0xffff; + int386(0x31, ®s, ®s); if (regs.w.cflag) I_Error ("Couldn't allocate DPMI memory!"); @@ -1419,13 +1419,13 @@ byte *I_ZoneBase (int *size) void I_InitDiskFlash (void) { #if 0 - void *pic; - byte *temp; + void *pic; + byte *temp; - pic = W_CacheLumpName ("STDISK",PU_CACHE); + pic = W_CacheLumpName ("STDISK", PU_CACHE); temp = destscreen; destscreen = (byte *)0xac000; - V_DrawPatchDirect (SCREENWIDTH-16,SCREENHEIGHT-16,0,pic); + V_DrawPatchDirect (SCREENWIDTH - 16, SCREENHEIGHT - 16, 0, pic); destscreen = temp; #endif } @@ -1434,23 +1434,23 @@ void I_InitDiskFlash (void) void I_BeginRead (void) { #if 0 - byte *src,*dest; + byte *src, *dest; int y; if (!grmode) return; -// write through all planes - outp (SC_INDEX,SC_MAPMASK); - outp (SC_INDEX+1,15); -// set write mode 1 - outp (GC_INDEX,GC_MODE); - outp (GC_INDEX+1,inp(GC_INDEX+1)|1); - -// copy to backup - src = currentscreen + 184*80 + 304/4; - dest = (byte *)0xac000 + 184*80 + 288/4; - for (y=0 ; y<16 ; y++) + // write through all planes + outp (SC_INDEX, SC_MAPMASK); + outp (SC_INDEX + 1, 15); + // set write mode 1 + outp (GC_INDEX, GC_MODE); + outp (GC_INDEX + 1, inp(GC_INDEX + 1) | 1); + + // copy to backup + src = currentscreen + 184 * 80 + 304 / 4; + dest = (byte *)0xac000 + 184 * 80 + 288 / 4; + for (y = 0; y < 16; y++) { dest[0] = src[0]; dest[1] = src[1]; @@ -1460,10 +1460,10 @@ void I_BeginRead (void) dest += 80; } -// copy disk over - dest = currentscreen + 184*80 + 304/4; - src = (byte *)0xac000 + 184*80 + 304/4; - for (y=0 ; y<16 ; y++) + // copy disk over + dest = currentscreen + 184 * 80 + 304 / 4; + src = (byte *)0xac000 + 184 * 80 + 304 / 4; + for (y = 0; y < 16; y++) { dest[0] = src[0]; dest[1] = src[1]; @@ -1474,9 +1474,9 @@ void I_BeginRead (void) } -// set write mode 0 - outp (GC_INDEX,GC_MODE); - outp (GC_INDEX+1,inp(GC_INDEX+1)&~1); + // set write mode 0 + outp (GC_INDEX, GC_MODE); + outp (GC_INDEX + 1, inp(GC_INDEX + 1) & ~1); #endif } @@ -1484,24 +1484,24 @@ void I_BeginRead (void) void I_EndRead (void) { #if 0 - byte *src,*dest; + byte *src, *dest; int y; if (!grmode) return; -// write through all planes - outp (SC_INDEX,SC_MAPMASK); - outp (SC_INDEX+1,15); -// set write mode 1 - outp (GC_INDEX,GC_MODE); - outp (GC_INDEX+1,inp(GC_INDEX+1)|1); + // write through all planes + outp (SC_INDEX, SC_MAPMASK); + outp (SC_INDEX + 1, 15); + // set write mode 1 + outp (GC_INDEX, GC_MODE); + outp (GC_INDEX + 1, inp(GC_INDEX + 1) | 1); -// copy disk over - dest = currentscreen + 184*80 + 304/4; - src = (byte *)0xac000 + 184*80 + 288/4; - for (y=0 ; y<16 ; y++) + // copy disk over + dest = currentscreen + 184 * 80 + 304 / 4; + src = (byte *)0xac000 + 184 * 80 + 288 / 4; + for (y = 0; y < 16; y++) { dest[0] = src[0]; dest[1] = src[1]; @@ -1511,9 +1511,9 @@ void I_EndRead (void) dest += 80; } -// set write mode 0 - outp (GC_INDEX,GC_MODE); - outp (GC_INDEX+1,inp(GC_INDEX+1)&~1); + // set write mode 0 + outp (GC_INDEX, GC_MODE); + outp (GC_INDEX + 1, inp(GC_INDEX + 1) & ~1); #endif } @@ -1529,23 +1529,23 @@ void I_EndRead (void) byte *I_AllocLow (int length) { - byte *mem; + byte *mem; // DPMI call 100h allocates DOS memory segread(&segregs); regs.w.ax = 0x0100; // DPMI allocate DOS memory - regs.w.bx = (length+15) / 16; - int386( DPMI_INT, ®s, ®s); -// segment = regs.w.ax; -// selector = regs.w.dx; + regs.w.bx = (length + 15) / 16; + int386(DPMI_INT, ®s, ®s); + // segment = regs.w.ax; + // selector = regs.w.dx; if (regs.w.cflag != 0) I_Error ("I_AllocLow: DOS alloc of %i failed, %i free", - length, regs.w.bx*16); + length, regs.w.bx * 16); - mem = (void *) ((regs.x.eax & 0xFFFF) << 4); + mem = (void *)((regs.x.eax & 0xFFFF) << 4); - memset (mem,0,length); + memset (mem, 0, length); return mem; } @@ -1598,7 +1598,7 @@ typedef struct } doomcom_t; */ // FUCKED LINES -extern doomcom_t *doomcom; +extern doomcom_t *doomcom; /* ==================== @@ -1615,11 +1615,11 @@ void I_InitNetwork (void) i = M_CheckParm ("-net"); if (!i) { - // - // single player game - // - doomcom = malloc (sizeof (*doomcom) ); - memset (doomcom, 0, sizeof(*doomcom) ); + // + // single player game + // + doomcom = malloc (sizeof (*doomcom)); + memset (doomcom, 0, sizeof(*doomcom)); netgame = false; doomcom->id = DOOMCOM_ID; doomcom->numplayers = doomcom->numnodes = 1; @@ -1631,12 +1631,12 @@ void I_InitNetwork (void) } netgame = true; - doomcom = (doomcom_t *)atoi(myargv[i+1]); -//DEBUG -doomcom->skill = startskill; -doomcom->episode = startepisode; -doomcom->map = startmap; -doomcom->deathmatch = deathmatch; + doomcom = (doomcom_t *)atoi(myargv[i + 1]); + //DEBUG + doomcom->skill = startskill; + doomcom->episode = startepisode; + doomcom->map = startmap; + doomcom->deathmatch = deathmatch; } @@ -1663,11 +1663,11 @@ void I_CheckExternDriver(void) { int i; - if(!(i = M_CheckParm("-externdriver"))) + if (!(i = M_CheckParm("-externdriver"))) { return; } - i_ExternData = (externdata_t *)atoi(myargv[i+1]); + i_ExternData = (externdata_t *)atoi(myargv[i + 1]); i_Vector = i_ExternData->vector; useexterndriver = true; @@ -1684,7 +1684,7 @@ void I_ReadExternDriver(void) { event_t ev; - if(useexterndriver) + if (useexterndriver) { DPMIInt(i_Vector); } diff --git a/w_merge.c b/w_merge.c index 74ac208..ad11378 100644 --- a/w_merge.c +++ b/w_merge.c @@ -34,24 +34,24 @@ #include "doomdata.h" #include "w_merge.h" -typedef enum -{ - SECTION_NORMAL, - SECTION_FLATS, - SECTION_SPRITES, +typedef enum +{ + SECTION_NORMAL, + SECTION_FLATS, + SECTION_SPRITES, } section_t; typedef struct { - lumpinfo_t *lumps; - int numlumps; + lumpinfo_t *lumps; + int numlumps; } searchlist_t; typedef struct { - char sprname[4]; - char frame; - lumpinfo_t *angle_lumps[8]; + char sprname[4]; + char frame; + lumpinfo_t *angle_lumps[8]; } sprite_frame_t; static searchlist_t iwad; @@ -74,263 +74,263 @@ static int sprite_frames_alloced; static int FindInList(searchlist_t *list, char *name) { - int i; + int i; - for (i=0; inumlumps; ++i) - { - if (!strncasecmp(list->lumps[i].name, name, 8)) - return i; - } + for (i = 0; i < list->numlumps; ++i) + { + if (!strncasecmp(list->lumps[i].name, name, 8)) + return i; + } - return -1; + return -1; } static boolean SetupList(searchlist_t *list, searchlist_t *src_list, - char *startname, char *endname, - char *startname2, char *endname2) + char *startname, char *endname, + char *startname2, char *endname2) { - int startlump, endlump; - - list->numlumps = 0; - startlump = FindInList(src_list, startname); - - if (startname2 != NULL && startlump < 0) - { - startlump = FindInList(src_list, startname2); - } - - if (startlump >= 0) - { - endlump = FindInList(src_list, endname); - - if (endname2 != NULL && endlump < 0) - { - endlump = FindInList(src_list, endname2); - } - - if (endlump > startlump) - { - list->lumps = src_list->lumps + startlump + 1; - list->numlumps = endlump - startlump - 1; - return true; - } - } - - return false; + int startlump, endlump; + + list->numlumps = 0; + startlump = FindInList(src_list, startname); + + if (startname2 != NULL && startlump < 0) + { + startlump = FindInList(src_list, startname2); + } + + if (startlump >= 0) + { + endlump = FindInList(src_list, endname); + + if (endname2 != NULL && endlump < 0) + { + endlump = FindInList(src_list, endname2); + } + + if (endlump > startlump) + { + list->lumps = src_list->lumps + startlump + 1; + list->numlumps = endlump - startlump - 1; + return true; + } + } + + return false; } // Sets up the sprite/flat search lists static void SetupLists(void) { - // IWAD + // IWAD + + if (!SetupList(&iwad_flats, &iwad, "F_START", "F_END", NULL, NULL)) + { + I_Error("Flats section not found in IWAD"); + } - if (!SetupList(&iwad_flats, &iwad, "F_START", "F_END", NULL, NULL)) - { - I_Error("Flats section not found in IWAD"); - } + if (!SetupList(&iwad_sprites, &iwad, "S_START", "S_END", NULL, NULL)) - if (!SetupList(&iwad_sprites, &iwad, "S_START", "S_END", NULL, NULL)) + { + I_Error("Sprites section not found in IWAD"); + } - { - I_Error("Sprites section not found in IWAD"); - } - - // PWAD + // PWAD - SetupList(&pwad_flats, &pwad, "F_START", "F_END", "FF_START", "FF_END"); - SetupList(&pwad_sprites, &pwad, "S_START", "S_END", "SS_START", "SS_END"); + SetupList(&pwad_flats, &pwad, "F_START", "F_END", "FF_START", "FF_END"); + SetupList(&pwad_sprites, &pwad, "S_START", "S_END", "SS_START", "SS_END"); } // Initialize the replace list static void InitSpriteList(void) { - if (sprite_frames == NULL) - { - sprite_frames_alloced = 128; - sprite_frames = Z_Malloc(sizeof(*sprite_frames) * sprite_frames_alloced, - PU_STATIC, NULL); - } - - num_sprite_frames = 0; + if (sprite_frames == NULL) + { + sprite_frames_alloced = 128; + sprite_frames = Z_Malloc(sizeof(*sprite_frames) * sprite_frames_alloced, + PU_STATIC, NULL); + } + + num_sprite_frames = 0; } // Find a sprite frame static sprite_frame_t *FindSpriteFrame(char *name, int frame) { - sprite_frame_t *result; - int i; + sprite_frame_t *result; + int i; - // Search the list and try to find the frame + // Search the list and try to find the frame - for (i=0; isprname, name, 4) && cur->frame == frame) - { - return cur; - } - } + if (!strncasecmp(cur->sprname, name, 4) && cur->frame == frame) + { + return cur; + } + } - // Not found in list; Need to add to the list + // Not found in list; Need to add to the list - // Grow list? + // Grow list? - if (num_sprite_frames >= sprite_frames_alloced) - { - sprite_frame_t *newframes; + if (num_sprite_frames >= sprite_frames_alloced) + { + sprite_frame_t *newframes; - newframes = Z_Malloc(sprite_frames_alloced * 2 * sizeof(*sprite_frames), - PU_STATIC, NULL); - memcpy(newframes, sprite_frames, - sprite_frames_alloced * sizeof(*sprite_frames)); - Z_Free(sprite_frames); - sprite_frames_alloced *= 2; - sprite_frames = newframes; - } + newframes = Z_Malloc(sprite_frames_alloced * 2 * sizeof(*sprite_frames), + PU_STATIC, NULL); + memcpy(newframes, sprite_frames, + sprite_frames_alloced * sizeof(*sprite_frames)); + Z_Free(sprite_frames); + sprite_frames_alloced *= 2; + sprite_frames = newframes; + } - // Add to end of list - - result = &sprite_frames[num_sprite_frames]; - strncpy(result->sprname, name, 4); - result->frame = frame; + // Add to end of list - for (i=0; i<8; ++i) - result->angle_lumps[i] = NULL; + result = &sprite_frames[num_sprite_frames]; + strncpy(result->sprname, name, 4); + result->frame = frame; - ++num_sprite_frames; + for (i = 0; i < 8; ++i) + result->angle_lumps[i] = NULL; - return result; + ++num_sprite_frames; + + return result; } // Check if sprite lump is needed in the new wad static boolean SpriteLumpNeeded(lumpinfo_t *lump) { - sprite_frame_t *sprite; - int angle_num; - int i; - - // check the first frame - - sprite = FindSpriteFrame(lump->name, lump->name[4]); - angle_num = lump->name[5] - '0'; - - if (angle_num == 0) - { - // must check all frames - - for (i=0; i<8; ++i) - { - if (sprite->angle_lumps[i] == lump) - return true; - } - } - else - { - // check if this lump is being used for this frame - - if (sprite->angle_lumps[angle_num - 1] == lump) - return true; - } - - // second frame if any - - // no second frame? - if (lump->name[6] == '\0') - return false; - - sprite = FindSpriteFrame(lump->name, lump->name[6]); - angle_num = lump->name[7] - '0'; - - if (angle_num == 0) - { - // must check all frames - - for (i=0; i<8; ++i) - { - if (sprite->angle_lumps[i] == lump) - return true; - } - } - else - { - // check if this lump is being used for this frame - - if (sprite->angle_lumps[angle_num - 1] == lump) - return true; - } - - return false; + sprite_frame_t *sprite; + int angle_num; + int i; + + // check the first frame + + sprite = FindSpriteFrame(lump->name, lump->name[4]); + angle_num = lump->name[5] - '0'; + + if (angle_num == 0) + { + // must check all frames + + for (i = 0; i < 8; ++i) + { + if (sprite->angle_lumps[i] == lump) + return true; + } + } + else + { + // check if this lump is being used for this frame + + if (sprite->angle_lumps[angle_num - 1] == lump) + return true; + } + + // second frame if any + + // no second frame? + if (lump->name[6] == '\0') + return false; + + sprite = FindSpriteFrame(lump->name, lump->name[6]); + angle_num = lump->name[7] - '0'; + + if (angle_num == 0) + { + // must check all frames + + for (i = 0; i < 8; ++i) + { + if (sprite->angle_lumps[i] == lump) + return true; + } + } + else + { + // check if this lump is being used for this frame + + if (sprite->angle_lumps[angle_num - 1] == lump) + return true; + } + + return false; } static void AddSpriteLump(lumpinfo_t *lump) { - sprite_frame_t *sprite; - int angle_num; - int i; - - // first angle - - sprite = FindSpriteFrame(lump->name, lump->name[4]); - angle_num = lump->name[5] - '0'; - - if (angle_num == 0) - { - for (i=0; i<8; ++i) - sprite->angle_lumps[i] = lump; - } - else - { - sprite->angle_lumps[angle_num - 1] = lump; - } - - // second angle - - // no second angle? - - if (lump->name[6] == '\0') - return; - - sprite = FindSpriteFrame(lump->name, lump->name[6]); - angle_num = lump->name[7] - '0'; - - if (angle_num == 0) - { - for (i=0; i<8; ++i) - sprite->angle_lumps[i] = lump; - } - else - { - sprite->angle_lumps[angle_num - 1] = lump; - } + sprite_frame_t *sprite; + int angle_num; + int i; + + // first angle + + sprite = FindSpriteFrame(lump->name, lump->name[4]); + angle_num = lump->name[5] - '0'; + + if (angle_num == 0) + { + for (i = 0; i < 8; ++i) + sprite->angle_lumps[i] = lump; + } + else + { + sprite->angle_lumps[angle_num - 1] = lump; + } + + // second angle + + // no second angle? + + if (lump->name[6] == '\0') + return; + + sprite = FindSpriteFrame(lump->name, lump->name[6]); + angle_num = lump->name[7] - '0'; + + if (angle_num == 0) + { + for (i = 0; i < 8; ++i) + sprite->angle_lumps[i] = lump; + } + else + { + sprite->angle_lumps[angle_num - 1] = lump; + } } // Generate the list. Run at the start, before merging static void GenerateSpriteList(void) { - int i; - - InitSpriteList(); - - // Add all sprites from the IWAD - - for (i=0; iname, "F_START", 8)) - { - current_section = SECTION_FLATS; - } - else if (!strncasecmp(lump->name, "S_START", 8)) - { - current_section = SECTION_SPRITES; - } - - newlumps[num_newlumps++] = *lump; - - break; - - case SECTION_FLATS: - - // Have we reached the end of the section? - - if (!strncasecmp(lump->name, "F_END", 8)) - { - // Add all new flats from the PWAD to the end - // of the section - - for (n=0; nname); - - if (lumpindex < 0) - { - newlumps[num_newlumps++] = *lump; - } - } - - break; - - case SECTION_SPRITES: - - // Have we reached the end of the section? - - if (!strncasecmp(lump->name, "S_END", 8)) - { - // add all the pwad sprites - - for (n=0; nname, "F_START", 8) - || !strncasecmp(lump->name, "FF_START", 8)) - { - current_section = SECTION_FLATS; - } - else if (!strncasecmp(lump->name, "S_START", 8) - || !strncasecmp(lump->name, "SS_START", 8)) - { - current_section = SECTION_SPRITES; - } - else - { - // Don't include the headers of sections - - newlumps[num_newlumps++] = *lump; - } - break; - - case SECTION_FLATS: - - // PWAD flats are ignored (already merged) - - if (!strncasecmp(lump->name, "FF_END", 8) - || !strncasecmp(lump->name, "F_END", 8)) - { - // end of section - current_section = SECTION_NORMAL; - } - break; - - case SECTION_SPRITES: - - // PWAD sprites are ignored (already merged) - - if (!strncasecmp(lump->name, "SS_END", 8) - || !strncasecmp(lump->name, "S_END", 8)) - { - // end of section - current_section = SECTION_NORMAL; - } - break; - } - } - - // Switch to the new lumpinfo, and free the old one - - free(lumpinfo); - lumpinfo = newlumps; - numlumps = num_newlumps; + section_t current_section; + lumpinfo_t *newlumps; + int num_newlumps; + int lumpindex; + int i, n; + + // Can't ever have more lumps than we already have + newlumps = malloc(sizeof(lumpinfo_t) * numlumps); + num_newlumps = 0; + + // Add IWAD lumps + current_section = SECTION_NORMAL; + + for (i = 0; i < iwad.numlumps; ++i) + { + lumpinfo_t *lump = &iwad.lumps[i]; + + switch (current_section) + { + case SECTION_NORMAL: + if (!strncasecmp(lump->name, "F_START", 8)) + { + current_section = SECTION_FLATS; + } + else if (!strncasecmp(lump->name, "S_START", 8)) + { + current_section = SECTION_SPRITES; + } + + newlumps[num_newlumps++] = *lump; + + break; + + case SECTION_FLATS: + + // Have we reached the end of the section? + + if (!strncasecmp(lump->name, "F_END", 8)) + { + // Add all new flats from the PWAD to the end + // of the section + + for (n = 0; n < pwad_flats.numlumps; ++n) + { + newlumps[num_newlumps++] = pwad_flats.lumps[n]; + } + + newlumps[num_newlumps++] = *lump; + + // back to normal reading + current_section = SECTION_NORMAL; + } + else + { + // If there is a flat in the PWAD with the same name, + // do not add it now. All PWAD flats are added to the + // end of the section. Otherwise, if it is only in the + // IWAD, add it now + + lumpindex = FindInList(&pwad_flats, lump->name); + + if (lumpindex < 0) + { + newlumps[num_newlumps++] = *lump; + } + } + + break; + + case SECTION_SPRITES: + + // Have we reached the end of the section? + + if (!strncasecmp(lump->name, "S_END", 8)) + { + // add all the pwad sprites + + for (n = 0; n < pwad_sprites.numlumps; ++n) + { + if (SpriteLumpNeeded(&pwad_sprites.lumps[n])) + { + newlumps[num_newlumps++] = pwad_sprites.lumps[n]; + } + } + + // copy the ending + newlumps[num_newlumps++] = *lump; + + // back to normal reading + current_section = SECTION_NORMAL; + } + else + { + // Is this lump holding a sprite to be replaced in the + // PWAD? If so, wait until the end to add it. + + if (SpriteLumpNeeded(lump)) + { + newlumps[num_newlumps++] = *lump; + } + } + + break; + } + } + + // Add PWAD lumps + current_section = SECTION_NORMAL; + + for (i = 0; i < pwad.numlumps; ++i) + { + lumpinfo_t *lump = &pwad.lumps[i]; + + switch (current_section) + { + case SECTION_NORMAL: + if (!strncasecmp(lump->name, "F_START", 8) + || !strncasecmp(lump->name, "FF_START", 8)) + { + current_section = SECTION_FLATS; + } + else if (!strncasecmp(lump->name, "S_START", 8) + || !strncasecmp(lump->name, "SS_START", 8)) + { + current_section = SECTION_SPRITES; + } + else + { + // Don't include the headers of sections + + newlumps[num_newlumps++] = *lump; + } + break; + + case SECTION_FLATS: + + // PWAD flats are ignored (already merged) + + if (!strncasecmp(lump->name, "FF_END", 8) + || !strncasecmp(lump->name, "F_END", 8)) + { + // end of section + current_section = SECTION_NORMAL; + } + break; + + case SECTION_SPRITES: + + // PWAD sprites are ignored (already merged) + + if (!strncasecmp(lump->name, "SS_END", 8) + || !strncasecmp(lump->name, "S_END", 8)) + { + // end of section + current_section = SECTION_NORMAL; + } + break; + } + } + + // Switch to the new lumpinfo, and free the old one + + free(lumpinfo); + lumpinfo = newlumps; + numlumps = num_newlumps; } void W_PrintDirectory(void) { - unsigned int i, n; - - // debug - for (i=0; inumlumps; ++i) - { - int index; + for (i = 0; i < list->numlumps; ++i) + { + int index; - index = FindInList(&pwad, list->lumps[i].name); + index = FindInList(&pwad, list->lumps[i].name); + + if (index > 0) + { + memcpy(&list->lumps[i], &pwad.lumps[index], + sizeof(lumpinfo_t)); + } + } - if (index > 0) - { - memcpy(&list->lumps[i], &pwad.lumps[index], - sizeof(lumpinfo_t)); - } - } - } // Merge sprites and flats in the way NWT does with its -af and -as @@ -598,44 +598,44 @@ static void W_NWTAddLumps(searchlist_t *list) void W_NWTMergeFile(char *filename, int flags) { - int old_numlumps; + int old_numlumps; + + old_numlumps = numlumps; - old_numlumps = numlumps; + // Load PWAD - // Load PWAD + if (W_AddFile(filename) == NULL) + return; - if (W_AddFile(filename) == NULL) - return; + // iwad is at the start, pwad was appended to the end - // iwad is at the start, pwad was appended to the end + iwad.lumps = lumpinfo; + iwad.numlumps = old_numlumps; - iwad.lumps = lumpinfo; - iwad.numlumps = old_numlumps; + pwad.lumps = lumpinfo + old_numlumps; + pwad.numlumps = numlumps - old_numlumps; - pwad.lumps = lumpinfo + old_numlumps; - pwad.numlumps = numlumps - old_numlumps; - - // Setup sprite/flat lists + // Setup sprite/flat lists - SetupLists(); + SetupLists(); - // Merge in flats? - - if (flags & W_NWT_MERGE_FLATS) - { - W_NWTAddLumps(&iwad_flats); - } + // Merge in flats? - // Sprites? + if (flags & W_NWT_MERGE_FLATS) + { + W_NWTAddLumps(&iwad_flats); + } - if (flags & W_NWT_MERGE_SPRITES) - { - W_NWTAddLumps(&iwad_sprites); - } - - // Discard the PWAD + // Sprites? - numlumps = old_numlumps; + if (flags & W_NWT_MERGE_SPRITES) + { + W_NWTAddLumps(&iwad_sprites); + } + + // Discard the PWAD + + numlumps = old_numlumps; } // Simulates the NWT -merge command line parameter. What this does is load @@ -644,51 +644,51 @@ void W_NWTMergeFile(char *filename, int flags) void W_NWTDashMerge(char *filename) { - wad_file_t *wad_file; - int old_numlumps; - int i; + wad_file_t *wad_file; + int old_numlumps; + int i; + + old_numlumps = numlumps; - old_numlumps = numlumps; + // Load PWAD - // Load PWAD + wad_file = W_AddFile(filename); - wad_file = W_AddFile(filename); + if (wad_file == NULL) + { + return; + } - if (wad_file == NULL) - { - return; - } + // iwad is at the start, pwad was appended to the end - // iwad is at the start, pwad was appended to the end + iwad.lumps = lumpinfo; + iwad.numlumps = old_numlumps; - iwad.lumps = lumpinfo; - iwad.numlumps = old_numlumps; + pwad.lumps = lumpinfo + old_numlumps; + pwad.numlumps = numlumps - old_numlumps; - pwad.lumps = lumpinfo + old_numlumps; - pwad.numlumps = numlumps - old_numlumps; - - // Setup sprite/flat lists + // Setup sprite/flat lists - SetupLists(); + SetupLists(); - // Search through the IWAD sprites list. + // Search through the IWAD sprites list. - for (i=0; i= 0) - { - // Replace this entry with an empty string. This is what - // nwt -merge does. + for (i = 0; i < iwad_sprites.numlumps; ++i) + { + if (FindInList(&pwad, iwad_sprites.lumps[i].name) >= 0) + { + // Replace this entry with an empty string. This is what + // nwt -merge does. - strcpy(iwad_sprites.lumps[i].name, ""); - } - } + strcpy(iwad_sprites.lumps[i].name, ""); + } + } - // Discard PWAD - // The PWAD must now be added in again with -file. + // Discard PWAD + // The PWAD must now be added in again with -file. - numlumps = old_numlumps; + numlumps = old_numlumps; - W_CloseFile(wad_file); + W_CloseFile(wad_file); } #endif