Formatted doomclassic code with Astyle

This commit is contained in:
Robert Beckebans 2022-09-05 22:25:33 +02:00
parent f67a6733d9
commit 539c3a93cd
144 changed files with 35422 additions and 31476 deletions

View file

@ -46,7 +46,8 @@ If you have questions concerning this license or the applicable additional terms
#define safeOutputDebug(x)
#endif
struct SplitscreenData {
struct SplitscreenData
{
int PLAYERCOUNT;
int globalSkill;
int globalEpisode;
@ -68,7 +69,8 @@ extern int globalNeedUpsell;
extern bool globalPauseTime;
enum MenuStates{
enum MenuStates
{
MENU_NONE,
MENU_XBOX_SYSTEM,
MENU_PAUSE,
@ -90,7 +92,8 @@ enum MenuStates{
MENU_COUNT
};
typedef struct {
typedef struct
{
int maxPing;
const wchar_t* image;

View file

@ -205,10 +205,22 @@ AM_getIslope
dy = ml->a.y - ml->b.y;
dx = ml->b.x - ml->a.x;
if (!dy) is->islp = (dx<0?-MAXINT:MAXINT);
else is->islp = FixedDiv(dx, dy);
if (!dx) is->slp = (dy<0?-MAXINT:MAXINT);
else is->slp = FixedDiv(dy, dx);
if( !dy )
{
is->islp = ( dx < 0 ? -MAXINT : MAXINT );
}
else
{
is->islp = FixedDiv( dx, dy );
}
if( !dx )
{
is->slp = ( dy < 0 ? -MAXINT : MAXINT );
}
else
{
is->slp = FixedDiv( dy, dx );
}
}
@ -250,7 +262,9 @@ void AM_restoreScaleAndLoc(void)
{
::g->m_x = ::g->old_m_x;
::g->m_y = ::g->old_m_y;
} else {
}
else
{
::g->m_x = ::g->amap_plr->mo->x - ::g->m_w / 2;
::g->m_y = ::g->amap_plr->mo->y - ::g->m_h / 2;
}
@ -289,15 +303,23 @@ void AM_findMinMaxBoundaries(void)
for( i = 0; i < ::g->numvertexes; i++ )
{
if( ::g->vertexes[i].x < ::g->min_x )
{
::g->min_x = ::g->vertexes[i].x;
}
else if( ::g->vertexes[i].x > ::g->max_x )
{
::g->max_x = ::g->vertexes[i].x;
}
if( ::g->vertexes[i].y < ::g->min_y )
{
::g->min_y = ::g->vertexes[i].y;
}
else if( ::g->vertexes[i].y > ::g->max_y )
{
::g->max_y = ::g->vertexes[i].y;
}
}
::g->max_w = ::g->max_x - ::g->min_x;
::g->max_h = ::g->max_y - ::g->min_y;
@ -329,14 +351,22 @@ void AM_changeWindowLoc(void)
::g->m_y += ::g->m_paninc.y;
if( ::g->m_x + ::g->m_w / 2 > ::g->max_x )
{
::g->m_x = ::g->max_x - ::g->m_w / 2;
}
else if( ::g->m_x + ::g->m_w / 2 < ::g->min_x )
{
::g->m_x = ::g->min_x - ::g->m_w / 2;
}
if( ::g->m_y + ::g->m_h / 2 > ::g->max_y )
{
::g->m_y = ::g->max_y - ::g->m_h / 2;
}
else if( ::g->m_y + ::g->m_h / 2 < ::g->min_y )
{
::g->m_y = ::g->min_y - ::g->m_h / 2;
}
::g->m_x2 = ::g->m_x + ::g->m_w;
::g->m_y2 = ::g->m_y + ::g->m_h;
@ -369,7 +399,9 @@ void AM_initVariables(void)
if( !::g->playeringame[pnum = ::g->consoleplayer] )
for( pnum = 0; pnum < MAXPLAYERS; pnum++ )
if( ::g->playeringame[pnum] )
{
break;
}
::g->amap_plr = &::g->players[pnum];
::g->m_x = ::g->amap_plr->mo->x - ::g->m_w / 2;
@ -414,7 +446,9 @@ void AM_clearMarks(void)
int i;
for( i = 0; i < AM_NUMMARKPOINTS; i++ )
{
::g->markpoints[i].x = -1; // means empty
}
::g->markpointnum = 0;
}
@ -435,7 +469,9 @@ void AM_LevelInit(void)
AM_findMinMaxBoundaries();
::g->scale_mtof = FixedDiv( ::g->min_scale_mtof, ( int )( 0.7 * FRACUNIT ) );
if( ::g->scale_mtof > ::g->max_scale_mtof )
{
::g->scale_mtof = ::g->min_scale_mtof;
}
::g->scale_ftom = FixedDiv( FRACUNIT, ::g->scale_mtof );
}
@ -461,7 +497,10 @@ void AM_Stop (void)
void AM_Start( void )
{
if (!::g->stopped) AM_Stop();
if( !::g->stopped )
{
AM_Stop();
}
::g->stopped = false;
if( ::g->lastlevel != ::g->gamemap || ::g->lastepisode != ::g->gameepisode )
{
@ -522,20 +561,44 @@ AM_Responder
switch( ev->data1 )
{
case AM_PANRIGHTKEY: // pan right
if (!::g->followplayer) ::g->m_paninc.x = FTOM(F_PANINC);
else rc = false;
if( !::g->followplayer )
{
::g->m_paninc.x = FTOM( F_PANINC );
}
else
{
rc = false;
}
break;
case AM_PANLEFTKEY: // pan left
if (!::g->followplayer) ::g->m_paninc.x = -FTOM(F_PANINC);
else rc = false;
if( !::g->followplayer )
{
::g->m_paninc.x = -FTOM( F_PANINC );
}
else
{
rc = false;
}
break;
case AM_PANUPKEY: // pan up
if (!::g->followplayer) ::g->m_paninc.y = FTOM(F_PANINC);
else rc = false;
if( !::g->followplayer )
{
::g->m_paninc.y = FTOM( F_PANINC );
}
else
{
rc = false;
}
break;
case AM_PANDOWNKEY: // pan down
if (!::g->followplayer) ::g->m_paninc.y = -FTOM(F_PANINC);
else rc = false;
if( !::g->followplayer )
{
::g->m_paninc.y = -FTOM( F_PANINC );
}
else
{
rc = false;
}
break;
case AM_ZOOMOUTKEY: // zoom out
::g->mtof_zoommul = M_ZOOMOUT;
@ -557,7 +620,10 @@ AM_Responder
AM_saveScaleAndLoc();
AM_minOutWindowScale();
}
else AM_restoreScaleAndLoc();
else
{
AM_restoreScaleAndLoc();
}
break;
case AM_FOLLOWKEY:
::g->followplayer = !::g->followplayer;
@ -594,16 +660,28 @@ AM_Responder
switch( ev->data1 )
{
case AM_PANRIGHTKEY:
if (!::g->followplayer) ::g->m_paninc.x = 0;
if( !::g->followplayer )
{
::g->m_paninc.x = 0;
}
break;
case AM_PANLEFTKEY:
if (!::g->followplayer) ::g->m_paninc.x = 0;
if( !::g->followplayer )
{
::g->m_paninc.x = 0;
}
break;
case AM_PANUPKEY:
if (!::g->followplayer) ::g->m_paninc.y = 0;
if( !::g->followplayer )
{
::g->m_paninc.y = 0;
}
break;
case AM_PANDOWNKEY:
if (!::g->followplayer) ::g->m_paninc.y = 0;
if( !::g->followplayer )
{
::g->m_paninc.y = 0;
}
break;
case AM_ZOOMOUTKEY:
case AM_ZOOMINKEY:
@ -629,12 +707,18 @@ void AM_changeWindowScale(void)
::g->scale_ftom = FixedDiv( FRACUNIT, ::g->scale_mtof );
if( ::g->scale_mtof < ::g->min_scale_mtof )
{
AM_minOutWindowScale();
}
else if( ::g->scale_mtof > ::g->max_scale_mtof )
{
AM_maxOutWindowScale();
}
else
{
AM_activateNewScale();
}
}
//
@ -673,7 +757,10 @@ void AM_updateLightLev(void)
if( ::g->amclock >::g->nexttic )
{
::g->lightlev = litelevels[::g->litelevelscnt++];
if (::g->litelevelscnt == sizeof(litelevels)/sizeof(int)) ::g->litelevelscnt = 0;
if( ::g->litelevelscnt == sizeof( litelevels ) / sizeof( int ) )
{
::g->litelevelscnt = 0;
}
::g->nexttic = ::g->amclock + 6 - ( ::g->amclock % 6 );
}
@ -687,20 +774,28 @@ void AM_Ticker (void)
{
if( !::g->automapactive )
{
return;
}
::g->amclock++;
if( ::g->followplayer )
{
AM_doFollowPlayer();
}
// Change the zoom if necessary
if( ::g->ftom_zoommul != FRACUNIT )
{
AM_changeWindowScale();
}
// Change x,y location
if( ::g->m_paninc.x || ::g->m_paninc.y )
{
AM_changeWindowLoc();
}
// Update light level
// AM_updateLightLev();
@ -750,30 +845,50 @@ AM_clipMline
// do trivial rejects and outcodes
if( ml->a.y > ::g->m_y2 )
{
outcode1 = TOP;
}
else if( ml->a.y < ::g->m_y )
{
outcode1 = BOTTOM;
}
if( ml->b.y > ::g->m_y2 )
{
outcode2 = TOP;
}
else if( ml->b.y < ::g->m_y )
{
outcode2 = BOTTOM;
}
if( outcode1 & outcode2 )
{
return false; // trivially outside
}
if( ml->a.x < ::g->m_x )
{
outcode1 |= LEFT;
}
else if( ml->a.x > ::g->m_x2 )
{
outcode1 |= RIGHT;
}
if( ml->b.x < ::g->m_x )
{
outcode2 |= LEFT;
}
else if( ml->b.x > ::g->m_x2 )
{
outcode2 |= RIGHT;
}
if( outcode1 & outcode2 )
{
return false; // trivially outside
}
// transform to frame-::g->buffer coordinates.
fl->a.x = CXMTOF( ml->a.x );
@ -785,16 +900,22 @@ AM_clipMline
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 )
@ -838,8 +959,10 @@ AM_clipMline
}
if( outcode1 & outcode2 )
{
return false; // trivially outside
}
}
return true;
}
@ -894,7 +1017,10 @@ AM_drawFline
while( 1 )
{
PUTDOT( x, y, color );
if (x == fl->b.x) return;
if( x == fl->b.x )
{
return;
}
if( d >= 0 )
{
y += sy;
@ -910,7 +1036,10 @@ AM_drawFline
while( 1 )
{
PUTDOT( x, y, color );
if (y == fl->b.y) return;
if( y == fl->b.y )
{
return;
}
if( d >= 0 )
{
x += sx;
@ -934,8 +1063,10 @@ AM_drawMline
static fline_t fl;
if( AM_clipMline( ml, &fl ) )
{
AM_drawFline( &fl, color ); // draws it on frame ::g->buffer using ::g->fb coords
}
}
@ -1002,7 +1133,9 @@ void AM_drawWalls(void)
if( ::g->cheating || ( ::g->lines[i].flags & ML_MAPPED ) )
{
if( ( ::g->lines[i].flags & LINE_NEVERSEE ) && !::g->cheating )
{
continue;
}
if( !::g->lines[i].backsector )
{
AM_drawMline( &l, WALLCOLORS +::g->lightlev );
@ -1010,30 +1143,43 @@ void AM_drawWalls(void)
else
{
if( ::g->lines[i].special == 39 )
{ // teleporters
{
// teleporters
AM_drawMline( &l, WALLCOLORS + WALLRANGE / 2 );
}
else if( ::g->lines[i].flags & ML_SECRET ) // secret door
{
if (::g->cheating) AM_drawMline(&l, SECRETWALLCOLORS + ::g->lightlev);
else AM_drawMline(&l, WALLCOLORS+::g->lightlev);
if( ::g->cheating )
{
AM_drawMline( &l, SECRETWALLCOLORS + ::g->lightlev );
}
else
{
AM_drawMline( &l, WALLCOLORS +::g->lightlev );
}
}
else if( ::g->lines[i].backsector->floorheight
!= ::g->lines[i].frontsector->floorheight) {
!= ::g->lines[i].frontsector->floorheight )
{
AM_drawMline( &l, FDWALLCOLORS + ::g->lightlev ); // floor level change
}
else if( ::g->lines[i].backsector->ceilingheight
!= ::g->lines[i].frontsector->ceilingheight) {
!= ::g->lines[i].frontsector->ceilingheight )
{
AM_drawMline( &l, CDWALLCOLORS +::g->lightlev ); // ceiling level change
}
else if (::g->cheating) {
else if( ::g->cheating )
{
AM_drawMline( &l, TSWALLCOLORS +::g->lightlev );
}
}
}
else if( ::g->amap_plr->powers[pw_allmap] )
{
if (!(::g->lines[i].flags & LINE_NEVERSEE)) AM_drawMline(&l, GRAYS+3);
if( !( ::g->lines[i].flags & LINE_NEVERSEE ) )
{
AM_drawMline( &l, GRAYS + 3 );
}
}
}
}
@ -1087,7 +1233,9 @@ AM_drawLineCharacter
}
if( angle )
{
AM_rotate( &l.a.x, &l.a.y, angle );
}
l.a.x += x;
l.a.y += y;
@ -1102,7 +1250,9 @@ AM_drawLineCharacter
}
if( angle )
{
AM_rotate( &l.b.x, &l.b.y, angle );
}
l.b.x += x;
l.b.y += y;
@ -1138,15 +1288,23 @@ void AM_drawPlayers(void)
p = &::g->players[i];
if( ( ::g->deathmatch && !::g->singledemo ) && p != ::g->amap_plr )
{
continue;
}
if( !::g->playeringame[i] )
{
continue;
}
if( p->powers[pw_invisibility] )
{
color = 246; // *close* to black
}
else
{
color = their_colors[their_color];
}
AM_drawLineCharacter
( player_arrow, NUMPLYRLINES, 0, p->mo->angle,
@ -1191,9 +1349,11 @@ void AM_drawMarks(void)
fx = CXMTOF( ::g->markpoints[i].x );
fy = CYMTOF( ::g->markpoints[i].y );
if( fx >= ::g->f_x && fx <= ::g->f_w - w && fy >= ::g->f_y && fy <= ::g->f_h - h )
{
V_DrawPatch( fx / GLOBAL_IMAGE_SCALER, fy / GLOBAL_IMAGE_SCALER, FB, ::g->marknums[i] );
}
}
}
}
@ -1205,15 +1365,22 @@ void AM_drawCrosshair(int color)
void AM_Drawer( void )
{
if (!::g->automapactive) return;
if( !::g->automapactive )
{
return;
}
AM_clearFB( BACKGROUND );
if( ::g->grid )
{
AM_drawGrid( GRIDCOLORS );
}
AM_drawWalls();
AM_drawPlayers();
if( ::g->cheating == 2 )
{
AM_drawThings( THINGCOLORS, THINGRANGE );
}
AM_drawCrosshair( XHAIRCOLORS );
AM_drawMarks();

View file

@ -62,7 +62,8 @@ If you have questions concerning this license or the applicable additional terms
::g->wipedone = true;
// d_main.constructs end //
// d_net.constructs begin //
doomcom_t temp_doomcom = {
doomcom_t temp_doomcom =
{
0
};
memcpy( &::g->doomcom, &temp_doomcom, sizeof( temp_doomcom ) );
@ -72,15 +73,18 @@ memcpy( &::g->doomcom, &temp_doomcom, sizeof(temp_doomcom) );
// f_wipe.constructs end //
// g_game.constructs begin //
::g->precache = true; // if true, load all graphics at start
fixed_t temp_forwardmove[2] = {
fixed_t temp_forwardmove[2] =
{
0x19, 0x32
};
memcpy( ::g->forwardmove, temp_forwardmove, sizeof( temp_forwardmove ) );
fixed_t temp_sidemove[2] = {
fixed_t temp_sidemove[2] =
{
0x18, 0x28
};
memcpy( ::g->sidemove, temp_sidemove, sizeof( temp_sidemove ) );
fixed_t temp_angleturn[3] = {
fixed_t temp_angleturn[3] =
{
640, 1280, 320 // + slow turn
};
memcpy( ::g->angleturn, temp_angleturn, sizeof( temp_angleturn ) );
@ -111,13 +115,15 @@ memcpy( ::g->angleturn, temp_angleturn, sizeof(temp_angleturn) );
// m_cheat.constructs end //
// m_menu.constructs begin //
menuitem_t temp_QuitMenu[3] = {
menuitem_t temp_QuitMenu[3] =
{
{1, "M_ACPT", M_ExitGame, 'a'},
{1, "M_CAN", M_CancelExit, 'c'},
{1, "M_CHG", M_GameSelection, 'g'}
};
memcpy( ::g->QuitMenu, temp_QuitMenu, sizeof( temp_QuitMenu ) );
menu_t temp_QuitDef = {
menu_t temp_QuitDef =
{
qut_end, // # of menu items
&::g->MainDef, // previous menu
::g->QuitMenu, // menuitem_t ->
@ -138,7 +144,8 @@ menuitem_t temp_MainMenu[5]=
{1, "M_QUITG", M_QuitDOOM, 'q'}
};
memcpy( &::g->MainMenu, temp_MainMenu, sizeof( temp_MainMenu ) );
menu_t temp_MainDef = {
menu_t temp_MainDef =
{
main_end,
NULL,
::g->MainMenu,
@ -149,14 +156,16 @@ menu_t temp_MainDef = {
memcpy( &::g->MainDef, &temp_MainDef, sizeof( temp_MainDef ) );
menuitem_t temp_EpisodeMenu[4] = {
menuitem_t temp_EpisodeMenu[4] =
{
{1, "M_EPI1", M_Episode, 'k'},
{1, "M_EPI2", M_Episode, 't'},
{1, "M_EPI3", M_Episode, 'i'},
{1, "M_EPI4", M_Episode, 't'}
};
memcpy( ::g->EpisodeMenu, temp_EpisodeMenu, sizeof( temp_EpisodeMenu ) );
menu_t temp_EpiDef = {
menu_t temp_EpiDef =
{
ep_end, // # of menu items
&::g->MainDef, // previous menu
::g->EpisodeMenu, // menuitem_t ->
@ -166,12 +175,14 @@ menu_t temp_EpiDef = {
};
memcpy( &::g->EpiDef, &temp_EpiDef, sizeof( temp_EpiDef ) );
menuitem_t temp_ExpansionMenu[2] = {
menuitem_t temp_ExpansionMenu[2] =
{
{1, "M_EPI1", M_Expansion, 'h'},
{1, "M_EPI2", M_Expansion, 'n'},
};
memcpy( ::g->ExpansionMenu, temp_ExpansionMenu, sizeof( temp_ExpansionMenu ) );
menu_t temp_ExpDef = {
menu_t temp_ExpDef =
{
ex_end, // # of menu items
&::g->MainDef, // previous menu
::g->ExpansionMenu, // menuitem_t ->
@ -181,12 +192,14 @@ menu_t temp_ExpDef = {
};
memcpy( &::g->ExpDef, &temp_ExpDef, sizeof( temp_ExpDef ) );
menuitem_t temp_LoadExpMenu[2] = {
menuitem_t temp_LoadExpMenu[2] =
{
{1, "M_EPI1", M_LoadExpansion, 'h'},
{1, "M_EPI2", M_LoadExpansion, 'n'},
};
memcpy( ::g->LoadExpMenu, temp_LoadExpMenu, sizeof( temp_LoadExpMenu ) );
menu_t temp_LoadExpDef = {
menu_t temp_LoadExpDef =
{
ex_end, // # of menu items
&::g->MainDef, // previous menu
::g->LoadExpMenu, // menuitem_t ->
@ -196,7 +209,8 @@ menu_t temp_LoadExpDef = {
};
memcpy( &::g->LoadExpDef, &temp_LoadExpDef, sizeof( temp_LoadExpDef ) );
menuitem_t temp_NewGameMenu[5] = {
menuitem_t temp_NewGameMenu[5] =
{
{1, "M_JKILL", M_ChooseSkill, 'i'},
{1, "M_ROUGH", M_ChooseSkill, 'h'},
{1, "M_HURT", M_ChooseSkill, 'h'},
@ -204,7 +218,8 @@ menuitem_t temp_NewGameMenu[5] = {
{1, "M_NMARE", M_ChooseSkill, 'n'}
};
memcpy( ::g->NewGameMenu, temp_NewGameMenu, sizeof( temp_NewGameMenu ) );
menu_t temp_NewDef = {
menu_t temp_NewDef =
{
newg_end, // # of menu items
&::g->EpiDef, // previous menu
::g->NewGameMenu, // menuitem_t ->
@ -213,7 +228,8 @@ menu_t temp_NewDef = {
hurtme // lastOn
};
memcpy( &::g->NewDef, &temp_NewDef, sizeof( temp_NewDef ) );
menuitem_t temp_OptionsMenu[8] = {
menuitem_t temp_OptionsMenu[8] =
{
{1, "M_GDHIGH", M_FullScreen, 'f'},
{1, "M_SCRNSZ", M_ChangeGPad, 'm'},
{1, "M_MESSG", M_ChangeMessages, 'm'},
@ -225,7 +241,8 @@ menuitem_t temp_OptionsMenu[8] = {
{1, "M_SVOL", M_Sound, 's'}
};
memcpy( ::g->OptionsMenu, temp_OptionsMenu, sizeof( temp_OptionsMenu ) );
menu_t temp_OptionsDef = {
menu_t temp_OptionsDef =
{
opt_end,
&::g->MainDef,
::g->OptionsMenu,
@ -234,14 +251,16 @@ menu_t temp_OptionsDef = {
0
};
memcpy( &::g->OptionsDef, &temp_OptionsDef, sizeof( temp_OptionsDef ) );
menuitem_t temp_SoundMenu[4] = {
menuitem_t temp_SoundMenu[4] =
{
{2, "M_SFXVOL", M_SfxVol, 's'},
{ -1, "", 0},
{2, "M_MUSVOL", M_MusicVol, 'm'},
{ -1, "", 0}
};
memcpy( ::g->SoundMenu, temp_SoundMenu, sizeof( temp_SoundMenu ) );
menu_t temp_SoundDef = {
menu_t temp_SoundDef =
{
sound_end,
&::g->OptionsDef,
::g->SoundMenu,
@ -250,7 +269,8 @@ menu_t temp_SoundDef = {
0
};
memcpy( &::g->SoundDef, &temp_SoundDef, sizeof( temp_SoundDef ) );
menuitem_t temp_LoadMenu[6] = {
menuitem_t temp_LoadMenu[6] =
{
{1, "", M_LoadSelect, '1'},
{1, "", M_LoadSelect, '2'},
{1, "", M_LoadSelect, '3'},
@ -259,7 +279,8 @@ menuitem_t temp_LoadMenu[6] = {
{1, "", M_LoadSelect, '6'}
};
memcpy( ::g->LoadMenu, temp_LoadMenu, sizeof( temp_LoadMenu ) );
menu_t temp_LoadDef = {
menu_t temp_LoadDef =
{
load_end,
&::g->MainDef,
::g->LoadMenu,
@ -268,7 +289,8 @@ menu_t temp_LoadDef = {
0
};
memcpy( &::g->LoadDef, &temp_LoadDef, sizeof( temp_LoadDef ) );
menuitem_t temp_SaveMenu[6] = {
menuitem_t temp_SaveMenu[6] =
{
{1, "", M_SaveSelect, '1'},
{1, "", M_SaveSelect, '2'},
{1, "", M_SaveSelect, '3'},
@ -277,7 +299,8 @@ menuitem_t temp_SaveMenu[6] = {
{1, "", M_SaveSelect, '6'}
};
memcpy( ::g->SaveMenu, temp_SaveMenu, sizeof( temp_SaveMenu ) );
menu_t temp_SaveDef = {
menu_t temp_SaveDef =
{
load_end,
&::g->MainDef,
::g->SaveMenu,
@ -286,7 +309,8 @@ menu_t temp_SaveDef = {
0
};
memcpy( &::g->SaveDef, &temp_SaveDef, sizeof( temp_SaveDef ) );
int temp_quitsounds[8] = {
int temp_quitsounds[8] =
{
sfx_pldeth,
sfx_dmpain,
sfx_popain,
@ -297,7 +321,8 @@ int temp_quitsounds[8] = {
sfx_sgtatk
};
memcpy( ::g->quitsounds, temp_quitsounds, sizeof( temp_quitsounds ) );
int temp_quitsounds2[8] = {
int temp_quitsounds2[8] =
{
sfx_vilact,
sfx_getpow,
sfx_boscub,
@ -324,7 +349,8 @@ memcpy( ::g->quitsounds2, temp_quitsounds2, sizeof(temp_quitsounds2) );
{
chat_macros[i] = temp_chat_macros[i];
}
default_t temp_defaults[35] = {
default_t temp_defaults[35] =
{
default_t( "mouse_sensitivity", &::g->mouseSensitivity, 7 ),
default_t( "show_messages", &::g->showMessages, 1 ),
@ -384,7 +410,8 @@ memcpy( ::g->defaults, temp_defaults, sizeof(temp_defaults) );
::g->easy = 0;
// p_enemy.constructs end //
// r_bsp.constructs begin //
int temp_checkcoord[12][4] = {
int temp_checkcoord[12][4] =
{
{3, 0, 2, 1},
{3, 0, 2, 0},
{3, 1, 2, 0},
@ -400,7 +427,8 @@ int temp_checkcoord[12][4] = {
memcpy( ::g->checkcoord, temp_checkcoord, sizeof( temp_checkcoord ) );
// r_bsp.constructs end //
// r_draw.constructs begin //
int temp_fuzzoffset[FUZZTABLE] = {
int temp_fuzzoffset[FUZZTABLE] =
{
FUZZOFF, -FUZZOFF, FUZZOFF, -FUZZOFF, FUZZOFF, FUZZOFF, -FUZZOFF,
FUZZOFF, FUZZOFF, -FUZZOFF, FUZZOFF, FUZZOFF, FUZZOFF, -FUZZOFF,
FUZZOFF, FUZZOFF, FUZZOFF, -FUZZOFF, -FUZZOFF, -FUZZOFF, -FUZZOFF,
@ -416,7 +444,8 @@ memcpy( ::g->fuzzoffset, temp_fuzzoffset, sizeof(temp_fuzzoffset) );
::g->validcount = 1;
// r_main.constructs end //
// sounds.constructs begin //
musicinfo_t temp_S_music[80] = {
musicinfo_t temp_S_music[80] =
{
{ 0 },
{ "e1m1", 0 },
{ "e1m2", 0 },
@ -505,7 +534,8 @@ memcpy( ::g->S_music, temp_S_music, sizeof(temp_S_music) );
::g->mus_playing = 0;
// s_sound.constructs end //
// wi_stuff.constructs begin //
int temp_NUMANIMS[NUMEPISODES] = {
int temp_NUMANIMS[NUMEPISODES] =
{
sizeof( epsd0animinfo ) / sizeof( anim_t ),
sizeof( epsd1animinfo ) / sizeof( anim_t ),
sizeof( epsd2animinfo ) / sizeof( anim_t )

View file

@ -132,13 +132,17 @@ void D_ProcessEvents (void)
// IF STORE DEMO, DO NOT ACCEPT INPUT
if( ( ::g->gamemode == commercial )
&& ( W_CheckNumForName( "map01" ) < 0 ) )
{
return;
}
for( ; ::g->eventtail != ::g->eventhead ; ::g->eventtail = ( ++::g->eventtail ) & ( MAXEVENTS - 1 ) )
{
ev = &::g->events[::g->eventtail];
if( M_Responder( ev ) )
{
continue; // menu ate the event
}
G_Responder( ev );
}
}
@ -166,7 +170,8 @@ void D_Wipe()
::g->wipedone = wipe_ScreenWipe( 0, 0, SCREENWIDTH, SCREENHEIGHT, tics );
// DHM - Nerve :: Demo recording :: Stop large hitch on first frame after the wipe
if ( ::g->wipedone ) {
if( ::g->wipedone )
{
::g->oldtrt_entertics = nowtime / ::g->ticdup;
::g->gametime = nowtime;
::g->wipe = false;
@ -181,7 +186,9 @@ void D_Display (void)
qboolean redrawsbar;
if( ::g->nodrawers )
{
return; // for comparative timing / profiling
}
redrawsbar = false;
@ -200,23 +207,35 @@ void D_Display (void)
wipe_StartScreen( 0, 0, SCREENWIDTH, SCREENHEIGHT );
}
else
{
::g->wipe = false;
}
if( ::g->gamestate == GS_LEVEL && ::g->gametic )
{
HU_Erase();
}
// do buffered drawing
switch( ::g->gamestate )
{
case GS_LEVEL:
if( !::g->gametic )
{
break;
}
if( ::g->automapactive )
{
AM_Drawer();
}
if( ::g->wipe || ( ::g->viewheight != 200 * GLOBAL_IMAGE_SCALER && ::g->fullscreen ) )
{
redrawsbar = true;
}
if( ::g->inhelpscreensstate && !::g->inhelpscreens )
{
redrawsbar = true; // just put away the help screen
}
ST_Drawer( ::g->viewheight == 200 * GLOBAL_IMAGE_SCALER, redrawsbar );
::g->fullscreen = ::g->viewheight == 200 * GLOBAL_IMAGE_SCALER;
break;
@ -239,14 +258,20 @@ void D_Display (void)
// draw the view directly
if( ::g->gamestate == GS_LEVEL && !::g->automapactive && ::g->gametic )
{
R_RenderPlayerView( &::g->players[::g->displayplayer] );
}
if( ::g->gamestate == GS_LEVEL && ::g->gametic )
{
HU_Drawer();
}
// clean up border stuff
if( ::g->gamestate != ::g->oldgamestate && ::g->gamestate != GS_LEVEL )
{
I_SetPalette( ( byte* )W_CacheLumpName( "PLAYPAL", PU_CACHE_SHARED ) );
}
// see if the border needs to be initially drawn
if( ::g->gamestate == GS_LEVEL && ::g->oldgamestate != GS_LEVEL )
@ -259,7 +284,9 @@ void D_Display (void)
if( ::g->gamestate == GS_LEVEL && !::g->automapactive && ::g->scaledviewwidth != ( 320 * GLOBAL_IMAGE_SCALER ) )
{
if( ::g->menuactive || ::g->menuactivestate || !::g->viewactivestate )
{
::g->borderdrawcount = 3;
}
if( ::g->borderdrawcount )
{
R_DrawViewBorder(); // erase old menu stuff
@ -309,7 +336,8 @@ void D_Display (void)
void D_RunFrame( bool Sounds )
{
if (Sounds) {
if( Sounds )
{
// move positional sounds
S_UpdateSounds( ::g->players[::g->consoleplayer].mo );
}
@ -317,7 +345,8 @@ void D_RunFrame( bool Sounds )
// Update display, next frame, with current state.
D_Display();
if (Sounds) {
if( Sounds )
{
// Update sound output.
I_SubmitSound();
}
@ -364,8 +393,10 @@ void D_DoomLoop (void)
void D_PageTicker( void )
{
if( --::g->pagetic < 0 )
{
D_AdvanceDemo();
}
}
@ -401,25 +432,37 @@ void D_DoAdvanceDemo (void)
::g->gameaction = ga_nothing;
if( ::g->gamemode == retail )
{
::g->demosequence = ( ::g->demosequence + 1 ) % 8;
}
else
{
::g->demosequence = ( ::g->demosequence + 1 ) % 6;
}
switch( ::g->demosequence )
{
case 0:
if( ::g->gamemode == commercial )
{
::g->pagetic = 35 * 11;
}
else
{
::g->pagetic = 8 * TICRATE;
}
::g->gamestate = GS_DEMOSCREEN;
::g->pagename = ( char* )"INTERPIC";
if( ::g->gamemode == commercial )
{
S_StartMusic( mus_dm2ttl );
}
else
{
S_StartMusic( mus_intro );
}
break;
case 1:
@ -473,7 +516,8 @@ void D_StartTitle (void)
//
// D_AddExtraWadFile
//
void D_SetExtraWadFile( const char *file ) {
void D_SetExtraWadFile( const char* file )
{
extraWad = file;
}
@ -486,7 +530,9 @@ void D_AddFile (const char *file)
for( numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++ )
if( file == wadfiles[numwadfiles] )
{
return;
}
;
wadfiles[numwadfiles] = file;
}
@ -507,11 +553,14 @@ void IdentifyVersion (void)
::g->gamemission = expansion->pack_type;
if( expansion->type == ExpansionData::PWAD ) {
if( expansion->type == ExpansionData::PWAD )
{
D_AddFile( expansion->iWadFilename );
D_AddFile( expansion->pWadFilename );
} else {
}
else
{
D_AddFile( expansion->iWadFilename );
}
@ -552,9 +601,13 @@ void D_DoomMain (void)
::g->fastparm = M_CheckParm( "-fast" );
::g->devparm = M_CheckParm( "-devparm" );
if( M_CheckParm( "-altdeath" ) || isDeathmatch )
{
::g->deathmatch = 2;
}
else if( M_CheckParm( "-deathmatch" ) )
{
::g->deathmatch = 1;
}
switch( ::g->gamemode )
{
@ -598,7 +651,9 @@ void D_DoomMain (void)
I_Printf( "%s\n", ::g->title );
if( ::g->devparm )
{
I_Printf( D_DEVSTR );
}
if( M_CheckParm( "-cdrom" ) )
{
@ -617,13 +672,17 @@ void D_DoomMain (void)
// until end of parms or another - preceded parm
::g->modifiedgame = true; // homebrew levels
while( ++p != ::g->myargc && ::g->myargv[p][0] != '-' )
{
D_AddFile( ::g->myargv[p] );
}
}
p = M_CheckParm( "-playdemo" );
if( !p )
{
p = M_CheckParm( "-timedemo" );
}
if( p && p < ::g->myargc - 1 )
{
@ -638,17 +697,20 @@ void D_DoomMain (void)
::g->startmap = 1;
::g->autostart = false;
if ( DoomLib::matchParms.gameEpisode != GAME_EPISODE_UNKNOWN ) {
if( DoomLib::matchParms.gameEpisode != GAME_EPISODE_UNKNOWN )
{
::g->startepisode = DoomLib::matchParms.gameEpisode;
::g->autostart = 1;
}
if ( DoomLib::matchParms.gameMap != -1 ) {
if( DoomLib::matchParms.gameMap != -1 )
{
::g->startmap = DoomLib::matchParms.gameMap;
::g->autostart = 1;
}
if ( DoomLib::matchParms.gameSkill != -1) {
if( DoomLib::matchParms.gameSkill != -1 )
{
::g->startskill = ( skill_t )DoomLib::matchParms.gameSkill;
}
@ -681,19 +743,25 @@ void D_DoomMain (void)
time = timeLimit;
I_Printf( "Levels will end after %d minute", time );
if( time > 1 )
{
I_Printf( "s" );
}
I_Printf( ".\n" );
}
p = M_CheckParm( "-avg" );
if( p && p < ::g->myargc - 1 && ::g->deathmatch )
{
I_Printf( "Austin Virtual Gaming: Levels will end after 20 minutes\n" );
}
p = M_CheckParm( "-warp" );
if( p && p < ::g->myargc - 1 )
{
if( ::g->gamemode == commercial )
{
::g->startmap = atoi( ::g->myargv[p + 1] );
}
else
{
::g->startepisode = ::g->myargv[p + 1][0] - '0';
@ -738,8 +806,10 @@ void D_DoomMain (void)
if( ::g->gamemode == registered )
for( i = 0; i < 23; i++ )
if( W_CheckNumForName( name[i] ) < 0 )
{
I_Error( "\nThis is not the registered version." );
}
}
// Iff additonal PWAD files are used, print modified banner
if( ::g->modifiedgame )
@ -805,7 +875,9 @@ bool D_DoomMainPoll(void)
char file[256];
if( D_PollNetworkStart() == false )
{
return false;
}
I_Printf( "S_Init: Setting up sound.\n" );
@ -845,18 +917,25 @@ bool D_DoomMainPoll(void)
if( p && p < ::g->myargc - 1 )
{
if( M_CheckParm( "-cdrom" ) )
{
sprintf( file, "c:\\doomdata\\" SAVEGAMENAME "%c.dsg", ::g->myargv[p + 1][0] );
}
else
{
sprintf( file, SAVEGAMENAME "%c.dsg", ::g->myargv[p + 1][0] );
}
G_LoadGame( file );
}
if( ::g->gameaction != ga_loadgame && ::g->gameaction != ga_playdemo )
{
if (::g->autostart || ::g->netgame ) {
if( ::g->autostart || ::g->netgame )
{
G_InitNew( ::g->startskill, ::g->startepisode, ::g->startmap );
} else if( ::g->gameaction != ga_newgame) {
}
else if( ::g->gameaction != ga_newgame )
{
D_StartTitle(); // start up intro loop
}
}

View file

@ -89,11 +89,14 @@ unsigned NetbufferChecksum (void)
c = 0x1234567;
if ( globalNetworking ) {
if( globalNetworking )
{
l = ( NetbufferSize() - ( intptr_t ) & ( ( ( doomdata_t* )0 )->retransmitfrom ) ) / 4;
for( i = 0 ; i < l ; i++ )
{
c += ( ( unsigned* )&::g->netbuffer->retransmitfrom )[i] * ( i + 1 );
}
}
return c & NCMD_CHECKSUM;
}
@ -108,11 +111,17 @@ int ExpandTics (int low)
delta = low - ( ::g->maketic & 0xff );
if( delta >= -64 && delta <= 64 )
{
return ( ::g->maketic & ~0xff ) + low;
}
if( delta > 64 )
{
return ( ::g->maketic & ~0xff ) - 256 + low;
}
if( delta < -64 )
{
return ( ::g->maketic & ~0xff ) + 256 + low;
}
I_Error( "ExpandTics: strange value %i at ::g->maketic %i", low, ::g->maketic );
return 0;
@ -138,10 +147,14 @@ HSendPacket
}
if( ::g->demoplayback )
{
return;
}
if( !::g->netgame )
{
I_Error( "Tried to transmit to another node" );
}
::g->doomcom.command = CMD_SEND;
::g->doomcom.remotenode = node;
@ -152,16 +165,22 @@ HSendPacket
int i;
int realretrans;
if( ::g->netbuffer->checksum & NCMD_RETRANSMIT )
{
realretrans = ExpandTics( ::g->netbuffer->retransmitfrom );
}
else
{
realretrans = -1;
}
fprintf( ::g->debugfile, "send (%i + %i, R %i) [%i] ",
ExpandTics( ::g->netbuffer->starttic ),
::g->netbuffer->numtics, realretrans, ::g->doomcom.datalength );
for( i = 0 ; i < ::g->doomcom.datalength ; i++ )
{
fprintf( ::g->debugfile, "%i ", ( ( byte* )::g->netbuffer )[i] );
}
fprintf( ::g->debugfile, "\n" );
}
@ -184,21 +203,29 @@ qboolean HGetPacket (void)
}
if( !::g->netgame )
{
return false;
}
if( ::g->demoplayback )
{
return false;
}
::g->doomcom.command = CMD_GET;
I_NetCmd();
if( ::g->doomcom.remotenode == -1 )
{
return false;
}
if( ::g->doomcom.datalength != NetbufferSize() )
{
if( ::g->debugfile )
{
fprintf( ::g->debugfile, "bad packet length %i\n", ::g->doomcom.datalength );
}
return false;
}
@ -207,7 +234,8 @@ qboolean HGetPacket (void)
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
if( !gameLocal->IsSplitscreen() && NetbufferChecksum() != ( ::g->netbuffer->checksum & NCMD_CHECKSUM ) )
{
if (::g->debugfile) {
if( ::g->debugfile )
{
fprintf( ::g->debugfile, "bad packet checksum\n" );
}
@ -221,13 +249,19 @@ qboolean HGetPacket (void)
int i;
if( ::g->netbuffer->checksum & NCMD_SETUP )
{
fprintf( ::g->debugfile, "setup packet\n" );
}
else
{
if( ::g->netbuffer->checksum & NCMD_RETRANSMIT )
{
realretrans = ExpandTics( ::g->netbuffer->retransmitfrom );
}
else
{
realretrans = -1;
}
fprintf( ::g->debugfile, "get %i = (%i + %i, R %i)[%i] ",
::g->doomcom.remotenode,
@ -235,7 +269,9 @@ qboolean HGetPacket (void)
::g->netbuffer->numtics, realretrans, ::g->doomcom.datalength );
for( i = 0 ; i < ::g->doomcom.datalength ; i++ )
{
fprintf( ::g->debugfile, "%i ", ( ( byte* )::g->netbuffer )[i] );
}
fprintf( ::g->debugfile, "\n" );
}
}
@ -258,7 +294,9 @@ void GetPackets (void)
while( HGetPacket() )
{
if( ::g->netbuffer->checksum & NCMD_SETUP )
{
continue; // extra setup packet
}
netconsole = ::g->netbuffer->player & ~PL_DRONE;
netnode = ::g->doomcom.remotenode;
@ -272,14 +310,17 @@ void GetPackets (void)
if( ::g->netbuffer->checksum & NCMD_EXIT )
{
if( !::g->nodeingame[netnode] )
{
continue;
}
::g->nodeingame[netnode] = false;
::g->playeringame[netconsole] = false;
strcpy( ::g->exitmsg, "Player 1 left the game" );
::g->exitmsg[7] += netconsole;
::g->players[::g->consoleplayer].message = ::g->exitmsg;
if( ::g->demorecording ) {
if( ::g->demorecording )
{
G_CheckDemoStatus();
}
continue;
@ -299,15 +340,21 @@ void GetPackets (void)
{
::g->resendto[netnode] = ExpandTics( ::g->netbuffer->retransmitfrom );
if( ::g->debugfile )
{
fprintf( ::g->debugfile, "retransmit from %i\n", ::g->resendto[netnode] );
}
::g->resendcount[netnode] = RESENDCOUNT;
}
else
{
::g->resendcount[netnode]--;
}
// check for out of order / duplicated packet
if( realend == ::g->nettics[netnode] )
{
continue;
}
if( realend < ::g->nettics[netnode] )
{
@ -371,7 +418,9 @@ void NetUpdate ( idUserCmdMgr * userCmdMgr )
::g->gametime = nowtime;
if( newtics <= 0 ) // nothing new to update
{
goto listen;
}
if( ::g->skiptics <= newtics )
{
@ -393,7 +442,8 @@ void NetUpdate ( idUserCmdMgr * userCmdMgr )
{
//I_GetEvents( ::g->I_StartTicCallback () );
D_ProcessEvents();
if (::g->maketic - gameticdiv >= BACKUPTICS/2-1) {
if( ::g->maketic - gameticdiv >= BACKUPTICS / 2 - 1 )
{
printf( "Out of room for ticcmds: maketic = %d, gameticdiv = %d\n", ::g->maketic, gameticdiv );
break; // can't hold any more
}
@ -408,16 +458,22 @@ void NetUpdate ( idUserCmdMgr * userCmdMgr )
if( ::g->singletics )
{
return; // singletic update is syncronous
}
// send the packet to the other ::g->nodes
for (i=0 ; i < ::g->doomcom.numnodes ; i++) {
for( i = 0 ; i < ::g->doomcom.numnodes ; i++ )
{
if (::g->nodeingame[i]) {
if( ::g->nodeingame[i] )
{
::g->netbuffer->starttic = realstart = ::g->resendto[i];
::g->netbuffer->numtics = ::g->maketic - realstart;
if( ::g->netbuffer->numtics > BACKUPTICS )
{
I_Error( "NetUpdate: ::g->netbuffer->numtics > BACKUPTICS" );
}
::g->resendto[i] = ::g->maketic - ::g->doomcom.extratics;
@ -452,7 +508,8 @@ void CheckAbort (void)
{
// DHM - Time starts at 0 tics when starting a multiplayer game, so we can
// check for timeouts easily. If we're still waiting after N seconds, abort.
if ( I_GetTime() > NET_TIMEOUT ) {
if( I_GetTime() > NET_TIMEOUT )
{
// TOOD: Show error & leave net game.
printf( "NET GAME TIMED OUT!\n" );
//gameLocal->showFatalErrorMessage( XuiLookupStringTable(globalStrings,L"Timed out waiting for match start.") );
@ -479,13 +536,17 @@ bool D_ArbitrateNetStart (void)
// listen for setup info from key player
CheckAbort();
if( !HGetPacket() )
{
return false;
}
if( ::g->netbuffer->checksum & NCMD_SETUP )
{
printf( "Received setup info\n" );
if( ::g->netbuffer->player != VERSION )
{
I_Error( "Different DOOM versions cannot play a net game!" );
}
::g->startskill = ( skill_t )( ::g->netbuffer->retransmitfrom & 15 );
::g->deathmatch = ( ::g->netbuffer->retransmitfrom & 0xc0 ) >> 6;
::g->nomonsters = ( ::g->netbuffer->retransmitfrom & 0x20 ) > 0;
@ -507,11 +568,17 @@ bool D_ArbitrateNetStart (void)
::g->netbuffer->retransmitfrom = ::g->startskill;
if( ::g->deathmatch )
{
::g->netbuffer->retransmitfrom |= ( ::g->deathmatch << 6 );
}
if( ::g->nomonsters )
{
::g->netbuffer->retransmitfrom |= 0x20;
}
if( ::g->respawnparm )
{
::g->netbuffer->retransmitfrom |= 0x10;
}
::g->netbuffer->starttic = ::g->startepisode * 64 + ::g->startmap;
::g->netbuffer->player = VERSION;
::g->netbuffer->numtics = 0;
@ -523,13 +590,18 @@ bool D_ArbitrateNetStart (void)
::g->gotinfo[::g->netbuffer->player & 0x7f] = true;
}
for (i=1 ; i < ::g->doomcom.numnodes ; i++) {
for( i = 1 ; i < ::g->doomcom.numnodes ; i++ )
{
if( !::g->gotinfo[i] )
{
break;
}
}
if( i >= ::g->doomcom.numnodes )
{
return true;
}
return false;
}
@ -556,7 +628,9 @@ void D_CheckNetGame (void)
I_InitNetwork();
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
if( ::g->doomcom.id != DOOMCOM_ID )
{
I_Error( "Doomcom buffer invalid!" );
}
#endif
::g->netbuffer = &::g->doomcom.data;
@ -569,8 +643,10 @@ bool D_PollNetworkStart()
if( ::g->netgame )
{
if( D_ArbitrateNetStart() == false )
{
return false;
}
}
I_Printf( "startskill %i deathmatch: %i startmap: %i startepisode: %i\n",
::g->startskill, ::g->deathmatch, ::g->startmap, ::g->startepisode );
@ -579,12 +655,18 @@ bool D_PollNetworkStart()
::g->ticdup = ::g->doomcom.ticdup;
::g->maxsend = BACKUPTICS / ( 2 *::g->ticdup ) - 1;
if( ::g->maxsend < 1 )
{
::g->maxsend = 1;
}
for( i = 0 ; i < ::g->doomcom.numplayers ; i++ )
{
::g->playeringame[i] = true;
}
for( i = 0 ; i < ::g->doomcom.numnodes ; i++ )
{
::g->nodeingame[i] = true;
}
I_Printf( "player %i of %i (%i ::g->nodes)\n",
::g->consoleplayer + 1, ::g->doomcom.numplayers, ::g->doomcom.numnodes );
@ -603,14 +685,18 @@ void D_QuitNetGame (void)
int i;
if( ( !::g->netgame && !::g->usergame ) || ::g->consoleplayer == -1 || ::g->demoplayback || ::g->netbuffer == NULL )
{
return;
}
// send a quit packet to the other nodes
::g->netbuffer->player = ::g->consoleplayer;
::g->netbuffer->numtics = 0;
for ( i=1; i < ::g->doomcom.numnodes; i++ ) {
if ( ::g->nodeingame[i] ) {
for( i = 1; i < ::g->doomcom.numnodes; i++ )
{
if( ::g->nodeingame[i] )
{
HSendPacket( i, NCMD_EXIT );
}
}
@ -641,13 +727,19 @@ void D_QuitNetGame (void)
::g->ticdup = ::g->doomcom.ticdup;
::g->maxsend = BACKUPTICS / ( 2 *::g->ticdup ) - 1;
if( ::g->maxsend < 1 )
{
::g->maxsend = 1;
}
for( i = 0 ; i < ::g->doomcom.numplayers ; i++ )
{
::g->playeringame[i] = true;
}
for( i = 0 ; i < ::g->doomcom.numnodes ; i++ )
{
::g->nodeingame[i] = true;
}
}
@ -670,12 +762,15 @@ bool TryRunTics ( idUserCmdMgr * userCmdMgr )
::g->trt_lowtic = MAXINT;
::g->trt_numplaying = 0;
for (i=0 ; i < ::g->doomcom.numnodes ; i++) {
for( i = 0 ; i < ::g->doomcom.numnodes ; i++ )
{
if (::g->nodeingame[i]) {
if( ::g->nodeingame[i] )
{
::g->trt_numplaying++;
if (::g->nettics[i] < ::g->trt_lowtic) {
if( ::g->nettics[i] < ::g->trt_lowtic )
{
::g->trt_lowtic = ::g->nettics[i];
lowtic_node = i;
}
@ -685,21 +780,28 @@ bool TryRunTics ( idUserCmdMgr * userCmdMgr )
::g->trt_availabletics = ::g->trt_lowtic - ::g->gametic /::g->ticdup;
// decide how many tics to run
if (::g->trt_realtics < ::g->trt_availabletics-1) {
if( ::g->trt_realtics < ::g->trt_availabletics - 1 )
{
::g->trt_counts = ::g->trt_realtics + 1;
} else if (::g->trt_realtics < ::g->trt_availabletics) {
}
else if( ::g->trt_realtics < ::g->trt_availabletics )
{
::g->trt_counts = ::g->trt_realtics;
} else {
}
else
{
::g->trt_counts = ::g->trt_availabletics;
}
if (::g->trt_counts < 1) {
if( ::g->trt_counts < 1 )
{
::g->trt_counts = 1;
}
::g->frameon++;
if (::g->debugfile) {
if( ::g->debugfile )
{
fprintf( ::g->debugfile, "=======real: %i avail: %i game: %i\n", ::g->trt_realtics, ::g->trt_availabletics, ::g->trt_counts );
}
@ -707,17 +809,22 @@ bool TryRunTics ( idUserCmdMgr * userCmdMgr )
{
// ideally ::g->nettics[0] should be 1 - 3 tics above ::g->trt_lowtic
// if we are consistantly slower, speed up time
for (i=0 ; i<MAXPLAYERS ; i++) {
if (::g->playeringame[i]) {
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( ::g->playeringame[i] )
{
break;
}
}
if (::g->consoleplayer == i) {
if( ::g->consoleplayer == i )
{
// the key player does not adapt
}
else {
if (::g->nettics[0] <= ::g->nettics[::g->nodeforplayer[i]]) {
else
{
if( ::g->nettics[0] <= ::g->nettics[::g->nodeforplayer[i]] )
{
::g->gametime--;
//OutputDebugString("-");
}
@ -725,7 +832,8 @@ bool TryRunTics ( idUserCmdMgr * userCmdMgr )
::g->frameskip[::g->frameon & 3] = ( ::g->oldnettics > ::g->nettics[::g->nodeforplayer[i]] );
::g->oldnettics = ::g->nettics[0];
if (::g->frameskip[0] && ::g->frameskip[1] && ::g->frameskip[2] && ::g->frameskip[3]) {
if( ::g->frameskip[0] && ::g->frameskip[1] && ::g->frameskip[2] && ::g->frameskip[3] )
{
::g->skiptics = 1;
//OutputDebugString("+");
}
@ -737,21 +845,26 @@ bool TryRunTics ( idUserCmdMgr * userCmdMgr )
{
int lagtime = 0;
if (::g->trt_lowtic < ::g->gametic/::g->ticdup) {
if( ::g->trt_lowtic < ::g->gametic /::g->ticdup )
{
I_Error( "TryRunTics: ::g->trt_lowtic < gametic" );
}
if ( ::g->lastnettic == 0 ) {
if( ::g->lastnettic == 0 )
{
::g->lastnettic = ::g->trt_entertic;
}
lagtime = ::g->trt_entertic - ::g->lastnettic;
// Detect if a client has stopped sending updates, remove them from the game after 5 secs.
if ( common->IsMultiplayer() && (!::g->demoplayback && ::g->netgame) && lagtime >= TICRATE ) {
if( common->IsMultiplayer() && ( !::g->demoplayback && ::g->netgame ) && lagtime >= TICRATE )
{
if ( lagtime > NET_TIMEOUT ) {
if( lagtime > NET_TIMEOUT )
{
if ( lowtic_node == ::g->nodeforplayer[::g->consoleplayer] ) {
if( lowtic_node == ::g->nodeforplayer[::g->consoleplayer] )
{
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
#ifndef __PS3__
@ -759,12 +872,17 @@ bool TryRunTics ( idUserCmdMgr * userCmdMgr )
gameLocal->Interface.QuitCurrentGame();
#endif
#endif
} else {
if (::g->nodeingame[lowtic_node]) {
}
else
{
if( ::g->nodeingame[lowtic_node] )
{
int i, consoleNum = lowtic_node;
for ( i=0; i < ::g->doomcom.numnodes; i++ ) {
if ( ::g->nodeforplayer[i] == lowtic_node ) {
for( i = 0; i < ::g->doomcom.numnodes; i++ )
{
if( ::g->nodeforplayer[i] == lowtic_node )
{
consoleNum = i;
break;
}
@ -793,12 +911,14 @@ bool TryRunTics ( idUserCmdMgr * userCmdMgr )
{
for( i = 0 ; i < ::g->ticdup ; i++ )
{
if (::g->gametic/::g->ticdup > ::g->trt_lowtic) {
if( ::g->gametic /::g->ticdup > ::g->trt_lowtic )
{
I_Error( "gametic(%d) greater than trt_lowtic(%d), trt_counts(%d)", ::g->gametic, ::g->trt_lowtic, ::g->trt_counts );
return false;
}
if (::g->advancedemo) {
if( ::g->advancedemo )
{
D_DoAdvanceDemo();
}
@ -818,10 +938,12 @@ bool TryRunTics ( idUserCmdMgr * userCmdMgr )
{
cmd = &::g->netcmds[j][buf];
if( cmd->buttons & BT_SPECIAL )
{
cmd->buttons = 0;
}
}
}
}
NetUpdate( userCmdMgr ); // check for new console commands
}

View file

@ -55,13 +55,15 @@ static char* mpArgVPtr[4][10];
static bool drawFullScreen = false;
DoomInterface::DoomInterface() {
DoomInterface::DoomInterface()
{
numplayers = 0;
bFinished[0] = bFinished[1] = bFinished[2] = bFinished[3] = false;
lastTicRun = 0;
}
DoomInterface::~DoomInterface() {
DoomInterface::~DoomInterface()
{
}
@ -74,17 +76,20 @@ void DoomInterface::Startup( int playerscount, bool multiplayer )
globalNetworking = multiplayer;
lastTicRun = 0;
if (DoomLib::Z_Malloc == NULL) {
if( DoomLib::Z_Malloc == NULL )
{
DoomLib::Z_Malloc = Z_Malloc;
}
// Splitscreen
if ( !multiplayer && playerscount > 1 ) {
if( !multiplayer && playerscount > 1 )
{
localdargc += 2; // for the '-net' and the console number
localdargc += playerscount;
}
if ( multiplayer ) {
if( multiplayer )
{
// Force online games to 1 local player for now.
// TODO: We should support local splitscreen and online.
numplayers = 1;
@ -98,24 +103,30 @@ void DoomInterface::Startup( int playerscount, bool multiplayer )
bFinished[i] = false;
DoomLib::InitGlobals( NULL );
if ( globalNetworking ) {
if( globalNetworking )
{
printf( "Starting mulitplayer game, argv = " );
for ( int j = 0; j < mpArgc[0]; ++j ) {
for( int j = 0; j < mpArgc[0]; ++j )
{
printf( " %s", mpArgVPtr[0][j] );
}
printf( "\n" );
DoomLib::InitGame( mpArgc[i], mpArgVPtr[i] );
} else {
}
else
{
DoomLib::InitGame( localdargc, ( char** )dargv[i] );
}
if( DoomLib::skipToLoad ) {
if( DoomLib::skipToLoad )
{
G_LoadGame( DoomLib::loadGamePath );
DoomLib::skipToLoad = false;
::g->menuactive = 0;
}
if( DoomLib::skipToNew ) {
if( DoomLib::skipToNew )
{
static int startLevel = 1;
G_DeferedInitNew( ( skill_t )DoomLib::chosenSkill, DoomLib::chosenEpisode + 1, startLevel );
DoomLib::skipToNew = false;
@ -131,7 +142,8 @@ bool DoomInterface::Frame( int iTime, idUserCmdMgr * userCmdMgr )
int i;
bool bAllFinished = true;
if ( !globalNetworking || ( lastTicRun < iTime ) ) {
if( !globalNetworking || ( lastTicRun < iTime ) )
{
drawFullScreen = false;
@ -144,15 +156,21 @@ bool DoomInterface::Frame( int iTime, idUserCmdMgr * userCmdMgr )
I_SetTime( iTime );
if (bFinished[i] == false) {
if( bFinished[i] == false )
{
bAllFinished = false;
bFinished[i] = DoomLib::Poll();
} else {
}
else
{
if (::g->wipedone) {
if ( !waitingForWipe ) {
if( ::g->wipedone )
{
if( !waitingForWipe )
{
const bool didRunTic = DoomLib::Tic( userCmdMgr );
if ( didRunTic == false ) {
if( didRunTic == false )
{
//printf( "Skipping tic and yielding because not enough time has passed.\n" );
// Give lower priority threads a chance to run.
@ -161,13 +179,15 @@ bool DoomInterface::Frame( int iTime, idUserCmdMgr * userCmdMgr )
}
DoomLib::Frame();
}
if (::g->wipe) {
if( ::g->wipe )
{
DoomLib::Wipe();
// Draw the menus over the wipe.
M_Drawer();
}
if( ::g->gamestate != GS_LEVEL && GetNumPlayers() > 2 ) {
if( ::g->gamestate != GS_LEVEL && GetNumPlayers() > 2 )
{
drawFullScreen = true;
}
}
@ -181,7 +201,9 @@ bool DoomInterface::Frame( int iTime, idUserCmdMgr * userCmdMgr )
DoomLib::SetPlayer( -1 );
lastTicRun = iTime;
} else {
}
else
{
printf( "Skipping this frame becase it's not time to run a tic yet.\n" );
}
@ -190,10 +212,12 @@ bool DoomInterface::Frame( int iTime, idUserCmdMgr * userCmdMgr )
void I_ShutdownNetwork();
void DoomInterface::Shutdown() {
void DoomInterface::Shutdown()
{
int i;
for ( i=0; i < numplayers; i++ ) {
for( i = 0; i < numplayers; i++ )
{
DoomLib::SetPlayer( i );
D_QuitNetGame();
}
@ -201,7 +225,8 @@ void DoomInterface::Shutdown() {
// Shutdown local network state
I_ShutdownNetwork();
for ( i=0; i < numplayers; i++ ) {
for( i = 0; i < numplayers; i++ )
{
DoomLib::SetPlayer( i );
DoomLib::Shutdown();
}
@ -213,11 +238,14 @@ void DoomInterface::Shutdown() {
qboolean G_CheckDemoStatus();
void DoomInterface::QuitCurrentGame() {
for ( int i = 0; i < numplayers; i++ ) {
void DoomInterface::QuitCurrentGame()
{
for( int i = 0; i < numplayers; i++ )
{
DoomLib::SetPlayer( i );
if(::g->netgame) {
if( ::g->netgame )
{
// Shut down networking
D_QuitNetGame();
}
@ -241,12 +269,15 @@ void DoomInterface::QuitCurrentGame() {
I_ShutdownNetwork();
}
void DoomInterface::EndDMGame() {
void DoomInterface::EndDMGame()
{
for ( int i = 0; i < numplayers; i++ ) {
for( int i = 0; i < numplayers; i++ )
{
DoomLib::SetPlayer( i );
if(::g->netgame) {
if( ::g->netgame )
{
D_QuitNetGame();
}
@ -264,23 +295,28 @@ void DoomInterface::EndDMGame() {
}
//static
int DoomInterface::CurrentPlayer() {
int DoomInterface::CurrentPlayer()
{
return DoomLib::GetPlayer();
}
int DoomInterface::GetNumPlayers() const {
int DoomInterface::GetNumPlayers() const
{
return numplayers;
}
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
void DoomInterface::SetNetworking( DoomLib::RecvFunc recv, DoomLib::SendFunc send, DoomLib::SendRemoteFunc sendRemote ) {
void DoomInterface::SetNetworking( DoomLib::RecvFunc recv, DoomLib::SendFunc send, DoomLib::SendRemoteFunc sendRemote )
{
DoomLib::SetNetworking( recv, send, sendRemote );
}
#endif
void DoomInterface::SetMultiplayerPlayers(int localPlayerIndex, int playerCount, int localPlayer, std::vector<std::string> playerAddresses) {
void DoomInterface::SetMultiplayerPlayers( int localPlayerIndex, int playerCount, int localPlayer, std::vector<std::string> playerAddresses )
{
for(int i = 0; i < 10; i++) {
for( int i = 0; i < 10; i++ )
{
mpArgVPtr[localPlayerIndex][i] = mpArgV[localPlayerIndex][i];
}
@ -295,8 +331,10 @@ void DoomInterface::SetMultiplayerPlayers(int localPlayerIndex, int playerCount,
strcpy( mpArgV[localPlayerIndex][5], playerAddresses[localPlayer].c_str() );
int currentArg = 6;
for(int i = 0; i < playerCount; i++) {
if(i != localPlayer) {
for( int i = 0; i < playerCount; i++ )
{
if( i != localPlayer )
{
strcpy( mpArgV[localPlayerIndex][currentArg], playerAddresses[i].c_str() );
currentArg++;
}

View file

@ -57,55 +57,65 @@ bool debugOutput = false;
namespace DoomLib
{
static const char * Expansion_Names[] = {
static const char* Expansion_Names[] =
{
"Ultimate DOOM", "DOOM II: Hell On Earth", "Final DOOM: TNT Evilution", "Final DOOM: Plutonia Experiment", "DOOM II: Master Levels", "DOOM II: No Rest For The Living"
};
static const char* Skill_Names[] = {
static const char* Skill_Names[] =
{
"I'm Too Young To Die!", "Hey, Not Too Rough!", "Hurt Me Plenty!", "Ultra-Violence", "Nightmare"
};
static const char* Filter_Names[] = {
static const char* Filter_Names[] =
{
"#str_friends", "#str_around", "#str_top15"
};
// Game-specific setup values.
static const char * Doom_MapNames[] = {
static const char* Doom_MapNames[] =
{
"E1M1: Hangar", "E1M2: Nuclear Plant", "E1M3: Toxin Refinery", "E1M4: Command Control", "E1M5: Phobos Lab", "E1M6: Central Processing", "E1M7: Computer Station", "E1M8: Phobos Anomaly", "E1M9: Military Base",
"E2M1: Deimos Anomaly", "E2M2: Containment Area", "E2M3: Refinery", "E2M4: Deimos Lab", "E2M5: Command Center", "E2M6: Halls of the Damned", "E2M7: Spawning Vats", "E2M8: Tower of Babel", "E2M9: Fortress of Mystery",
"E3M1: Hell Keep", "E3M2: Slough of Despair", "E3M3: Pandemonium", "E3M4: House of Pain", "E3M5: Unholy Cathedral", "E3M6: MT. Erebus", "E3M7: Gate to Limbo", "E3M8: DIS", "E3M9: Warrens",
"E4M1: Hell Beneath", "E4M2: Perfect Hatred", "E4M3: Sever The Wicked", "E4M4: Unruly Evil", "E4M5: They Will Repent", "E4M6: Against Thee Wickedly", "E4M7: And Hell Followed", "E4M8: Unto The Cruel", "E4M9: Fear"
};
static const char * Doom2_MapNames[] = {
static const char* Doom2_MapNames[] =
{
"1: Entryway", "2: Underhalls", "3: The Gantlet", "4: The Focus", "5: The Waste Tunnels", "6: The Crusher", "7: Dead Simple", "8: Tricks and Traps", "9: The Pit", "10: Refueling Base",
"11: Circle of Death", "12: The Factory", "13: Downtown", "14: The Inmost Dens", "15: Industrial Zone", "16: Suburbs", "17: Tenements", "18: The Courtyard", "19: The Citadel", "20: Gotcha!",
"21: Nirvana", "22: The Catacombs", "23: Barrels O' Fun", "24: The Chasm", "25: Bloodfalls", "26: The Abandoned Mines", "27: Monster Condo", "28: The Spirit World", "29: The Living End",
"30: Icon of Sin", "31: IDKFA", "32: Keen"
};
static const char * TNT_MapNames[] = {
static const char* TNT_MapNames[] =
{
"1: System Control", "2: Human BBQ", "3: Power Control", "4: Wormhole", "5: Hangar", "6: Open Season", "7: Prison", "8: Metal", "9: Stronghold", "10: Redemption", "11: Storage Facility",
"12: Crater", "13: Nukage Processing", "14: Steel Works", "15: Dead Zone", "16: Deepest Reaches", "17: Processing Area", "18: Mill", "19: Shipping & Respawning", "20: Central Processing",
"21: Administration Center", "22: Habitat", "23: Lunar Mining Project", "24: Quarry", "25: Baron's Den", "26: Ballistyx", "27: Mount Pain", "28: Heck", "29: River Styx", "30: Last Call", "31: Pharaoh", "32: Caribbean"
};
static const char * Plut_MapNames[] = {
static const char* Plut_MapNames[] =
{
"1: Congo", "2: Well of Souls", "3: Aztec", "4: Caged", "5: Ghost Town", "6: Baron's Lair", "7: Caughtyard", "8: Realm", "9: Abattoire", "10: Onslaught", "11: Hunted", "12: Speed", "13: The Crypt", "14: Genesis",
"15: The Twilight", "16: The Omen", "17: Compound", "18: Neurosphere", "19: NME", "20: The Death Domain", "21: Slayer", "22: Impossible Mission", "23: Tombstone", "24: The Final Frontier", "25: The Temple of Darkness",
"26: Bunker", "27: Anti-Christ", "28: The Sewers", "29: Odyssey of Noises", "30: The Gateway of Hell", "31: Cyberden", "32: Go 2 It"
};
static const char * Mast_MapNames[] = {
static const char* Mast_MapNames[] =
{
"1: Attack", "2: Canyon", "3: The Catwalk", "4: The Combine", "5: The Fistula", "6: The Garrison", "7: Titan Manor", "8: Paradox", "9: Subspace", "10: Subterra", "11: Trapped On Titan", "12: Virgil's Lead", "13: Minos' Judgement",
"14: Bloodsea Keep", "15: Mephisto's Maosoleum", "16: Nessus", "17: Geryon", "18: Vesperas", "19: Black Tower", "20: The Express Elevator To Hell", "21: Bad Dream"
};
static const char * Nerve_MapNames[] = {
static const char* Nerve_MapNames[] =
{
"1: The Earth Base", "2: The Pain Labs", "3: Canyon of the Dead", "4: Hell Mountain", "5: Vivisection", "6: Inferno of Blood", "7: Baron's Banquet", "8: Tomb of Malevolence", "9: March of Demons"
};
const ExpansionData App_Expansion_Data_Local[] = {
const ExpansionData App_Expansion_Data_Local[] =
{
{ ExpansionData::IWAD, retail, doom, "DOOM", DOOMWADDIR"DOOM.WAD", NULL, "base/textures/DOOMICON.PNG" , Doom_MapNames },
{ ExpansionData::IWAD, commercial, doom2, "DOOM 2", DOOMWADDIR"DOOM2.WAD", NULL, "base/textures/DOOM2ICON.PNG" , Doom2_MapNames },
{ ExpansionData::IWAD, commercial, pack_tnt, "FINAL DOOM: TNT EVILUTION", DOOMWADDIR"TNT.WAD", NULL, "base/textures/TNTICON.PNG" , TNT_MapNames },
@ -116,26 +126,41 @@ namespace DoomLib
int classicRemap[K_LAST_KEY];
const ExpansionData * GetCurrentExpansion() {
const ExpansionData* GetCurrentExpansion()
{
return &App_Expansion_Data_Local[ DoomLib::expansionSelected ];
}
void SetCurrentExpansion( int expansion ) {
void SetCurrentExpansion( int expansion )
{
expansionDirty = true;
expansionSelected = expansion;
}
void SetIdealExpansion( int expansion ) {
void SetIdealExpansion( int expansion )
{
idealExpansion = expansion;
}
idStr currentMapName;
idStr currentDifficulty;
void SetCurrentMapName( idStr name ) { currentMapName = name; }
const idStr & GetCurrentMapName() { return currentMapName; }
void SetCurrentDifficulty( idStr name ) { currentDifficulty = name; }
const idStr & GetCurrentDifficulty() { return currentDifficulty; }
void SetCurrentMapName( idStr name )
{
currentMapName = name;
}
const idStr& GetCurrentMapName()
{
return currentMapName;
}
void SetCurrentDifficulty( idStr name )
{
currentDifficulty = name;
}
const idStr& GetCurrentDifficulty()
{
return currentDifficulty;
}
int currentplayer = -1;
@ -167,7 +192,8 @@ namespace DoomLib
idArray< idSysMutex, 4 > playerScreenMutexes;
void ExitGame() {
void ExitGame()
{
// TODO: If we ever support splitscreen and online,
// we'll have to call D_QuitNetGame for all local players.
DoomLib::SetPlayer( 0 );
@ -176,7 +202,8 @@ namespace DoomLib
session->QuitMatch();
}
void ShowXToContinue( bool activate ) {
void ShowXToContinue( bool activate )
{
}
/*
@ -184,11 +211,15 @@ namespace DoomLib
DoomLib::GetGameSKU
========================
*/
gameSKU_t GetGameSKU() {
gameSKU_t GetGameSKU()
{
if ( common->GetCurrentGame() == DOOM_CLASSIC ) {
if( common->GetCurrentGame() == DOOM_CLASSIC )
{
return GAME_SKU_DOOM1_BFG;
} else if ( common->GetCurrentGame() == DOOM2_CLASSIC ) {
}
else if( common->GetCurrentGame() == DOOM2_CLASSIC )
{
return GAME_SKU_DOOM2_BFG;
}
@ -201,13 +232,15 @@ namespace DoomLib
DoomLib::ActivateGame
========================
*/
void ActivateGame() {
void ActivateGame()
{
Active = true;
// Turn off menu toggler
int originalPlayer = DoomLib::GetPlayer();
for ( int i = 0; i < Interface.GetNumPlayers(); i++ ) {
for( int i = 0; i < Interface.GetNumPlayers(); i++ )
{
DoomLib::SetPlayer( i );
::g->menuactive = false;
}
@ -222,8 +255,10 @@ namespace DoomLib
DoomLib::HandleEndMatch
========================
*/
void HandleEndMatch() {
if ( session->GetGameLobbyBase().IsHost() ) {
void HandleEndMatch()
{
if( session->GetGameLobbyBase().IsHost() )
{
ShowXToContinue( false );
session->EndMatch();
}
@ -245,7 +280,9 @@ extern void I_ProcessSoundEvents();
void DoomLib::InitGlobals( void* ptr /* = NULL */ )
{
if( ptr == NULL )
{
ptr = new Globals;
}
globaldata[currentplayer] = static_cast<Globals*>( ptr );
@ -255,11 +292,13 @@ void DoomLib::InitGlobals( void *ptr /* = NULL */ )
}
void *DoomLib::GetGlobalData( int player ) {
void* DoomLib::GetGlobalData( int player )
{
return globaldata[player];
}
void DoomLib::InitControlRemap() {
void DoomLib::InitControlRemap()
{
memset( classicRemap, K_NONE, sizeof( classicRemap ) );
@ -280,13 +319,18 @@ void DoomLib::InitControlRemap() {
}
keyNum_t DoomLib::RemapControl( keyNum_t key ) {
keyNum_t DoomLib::RemapControl( keyNum_t key )
{
if( classicRemap[ key ] == K_NONE ) {
if( classicRemap[ key ] == K_NONE )
{
return key;
} else {
}
else
{
if( ::g->menuactive && key == K_JOY2 ) {
if( ::g->menuactive && key == K_JOY2 )
{
return K_BACKSPACE;
}
@ -334,7 +378,8 @@ void DoomLib::Frame( int realoffset, int buffer )
// suffers too much, we can try to narrow the scope.
// Just be careful, because the player's screen data is updated in many different
// places.
if ( 0 <= currentplayer && currentplayer <= 4 ) {
if( 0 <= currentplayer && currentplayer <= 4 )
{
idScopedCriticalSection crit( playerScreenMutexes[currentplayer] );
D_RunFrame( true );
@ -381,7 +426,8 @@ fixed_t GetViewY()
return ::g->viewy + ::g->viewyoffset;
}
void DoomLib::Shutdown() {
void DoomLib::Shutdown()
{
//D_QuitNetGame ();
I_ShutdownSound();
I_ShutdownGraphics();
@ -389,12 +435,14 @@ void DoomLib::Shutdown() {
W_Shutdown();
// De-allocate the zone memory (never happened in original doom, until quit)
if ( ::g->mainzone ) {
if( ::g->mainzone )
{
free( ::g->mainzone );
}
// Delete the globals
if ( globaldata[currentplayer] ) {
if( globaldata[currentplayer] )
{
delete globaldata[currentplayer];
globaldata[currentplayer] = NULL;
}
@ -405,13 +453,16 @@ void DoomLib::SetPlayer( int id )
{
currentplayer = id;
if ( id < 0 || id >= MAX_PLAYERS ) {
if( id < 0 || id >= MAX_PLAYERS )
{
g = NULL;
}
else {
else
{
// Big Fucking hack.
if( globalNetworking && session->GetGameLobbyBase().GetMatchParms().matchFlags | MATCH_ONLINE ) {
if( globalNetworking && session->GetGameLobbyBase().GetMatchParms().matchFlags | MATCH_ONLINE )
{
currentplayer = 0;
}
@ -433,7 +484,8 @@ int DoomLib::GetPlayer()
return currentplayer;
}
byte DoomLib::BuildSourceDest( int toNode ) {
byte DoomLib::BuildSourceDest( int toNode )
{
byte sourceDest = 0;
sourceDest |= ::g->consoleplayer << 2;
sourceDest |= RemoteNodeToPlayerIndex( toNode );
@ -442,7 +494,8 @@ byte DoomLib::BuildSourceDest( int toNode ) {
void I_Printf( char* error, ... );
void DoomLib::GetSourceDest( byte sourceDest, int* source, int* dest ) {
void DoomLib::GetSourceDest( byte sourceDest, int* source, int* dest )
{
int src = ( sourceDest & 12 ) >> 2;
int dst = sourceDest & 3;
@ -453,14 +506,16 @@ void DoomLib::GetSourceDest( byte sourceDest, int* source, int* dest ) {
*dest = PlayerIndexToRemoteNode( dst );
}
int nodeMap[4][4] = {
int nodeMap[4][4] =
{
{0, 1, 2, 3}, //Player 0
{1, 0, 2, 3}, //Player 1
{2, 0, 1, 3}, //Player 2
{3, 0, 1, 2} //Player 3
};
int DoomLib::RemoteNodeToPlayerIndex( int node ) {
int DoomLib::RemoteNodeToPlayerIndex( int node )
{
//This needs to be called with the proper doom globals set so this calculation will work properly
/*
@ -479,14 +534,16 @@ int DoomLib::RemoteNodeToPlayerIndex( int node ) {
}
int indexMap[4][4] = {
int indexMap[4][4] =
{
{0, 1, 2, 3}, //Player 0
{1, 0, 2, 3}, //Player 1
{1, 2, 0, 3}, //Player 2
{1, 2, 3, 0} //Player 3
};
int DoomLib::PlayerIndexToRemoteNode( int index ) {
int DoomLib::PlayerIndexToRemoteNode( int index )
{
/*int player = ::g->consoleplayer;
if( index == 0 ) {
return player;
@ -501,11 +558,14 @@ int DoomLib::PlayerIndexToRemoteNode( int index ) {
void I_Error( const char* error, ... );
extern bool useTech5Packets;
void DoomLib::PollNetwork() {
void DoomLib::PollNetwork()
{
#if 0
if ( !useTech5Packets ) {
if( !useTech5Packets )
{
if ( !globalNetworking ) {
if( !globalNetworking )
{
return;
}
@ -514,14 +574,16 @@ void DoomLib::PollNetwork() {
socklen_t fromlen;
doomdata_t sw;
while(1) {
while( 1 )
{
int receivedSize = recvfrom( ::g->insocket, &sw, sizeof( doomdata_t ), MSG_DONTWAIT, &fromaddress, &fromlen );
//c = WSARecvFrom(::g->insocket, &buffer, 1, &num_recieved, &flags, (struct sockaddr*)&fromaddress, &fromlen, 0, 0);
if( receivedSize < 0 )
{
int err = sys_net_errno;
if (err != SYS_NET_EWOULDBLOCK ) {
if( err != SYS_NET_EWOULDBLOCK )
{
I_Error( "GetPacket: %d", err );
//I_Printf ("GetPacket: %s",strerror(errno));
}
@ -541,15 +603,18 @@ void DoomLib::PollNetwork() {
#endif
}
void DoomLib::SendNetwork() {
void DoomLib::SendNetwork()
{
if ( !globalNetworking ) {
if( !globalNetworking )
{
return;
}
//DoomLib::SendRemote();
}
void DoomLib::RunSound() {
void DoomLib::RunSound()
{
I_ProcessSoundEvents();
}

View file

@ -63,7 +63,8 @@ struct rumble_t
};
enum gameSKU_t {
enum gameSKU_t
{
GAME_SKU_DCC = 0, // Doom Classic Complete
GAME_SKU_DOOM1_BFG, // Doom 1 Ran from BFG
GAME_SKU_DOOM2_BFG, // Doom 2 Ran from BFG
@ -75,7 +76,8 @@ enum gameSKU_t {
ExpansionData
================================================================================================
*/
struct ExpansionData {
struct ExpansionData
{
enum { IWAD = 0, PWAD = 1 } type;
GameMode_t gameMode;

View file

@ -108,13 +108,16 @@ void F_StartFinale (void)
// Check for end of episode/mission
bool endOfMission = false;
if ( ( ::g->gamemission == doom || ::g->gamemission == doom2 || ::g->gamemission == pack_tnt || ::g->gamemission == pack_plut ) && ::g->gamemap == 30 ) {
if( ( ::g->gamemission == doom || ::g->gamemission == doom2 || ::g->gamemission == pack_tnt || ::g->gamemission == pack_plut ) && ::g->gamemap == 30 )
{
endOfMission = true;
}
else if ( ::g->gamemission == pack_nerve && ::g->gamemap == 8 ) {
else if( ::g->gamemission == pack_nerve && ::g->gamemap == 8 )
{
endOfMission = true;
}
else if ( ::g->gamemission == pack_master && ::g->gamemap == 21 ) {
else if( ::g->gamemission == pack_master && ::g->gamemap == 21 )
{
endOfMission = true;
}
@ -163,7 +166,8 @@ void F_StartFinale (void)
{
S_ChangeMusic( mus_read_m, true );
if ( ::g->gamemission == doom2 || ::g->gamemission == pack_tnt || ::g->gamemission == pack_plut ) {
if( ::g->gamemission == doom2 || ::g->gamemission == pack_tnt || ::g->gamemission == pack_plut )
{
switch( ::g->gamemap )
{
case 6:
@ -194,7 +198,9 @@ void F_StartFinale (void)
// Ouch.
break;
}
} else if( ::g->gamemission == pack_master ) {
}
else if( ::g->gamemission == pack_master )
{
switch( ::g->gamemap )
{
case 21:
@ -202,8 +208,11 @@ void F_StartFinale (void)
finaletext = c8Text;
break;
}
} else if ( ::g->gamemission == pack_nerve ) {
switch( ::g->gamemap ){
}
else if( ::g->gamemission == pack_nerve )
{
switch( ::g->gamemap )
{
case 8:
finaleflat = "SLIME16";
finaletext = c7text;
@ -231,13 +240,16 @@ bool finaleButtonPressed = false;
bool startButtonPressed = false;
qboolean F_Responder( event_t* event )
{
if( !common->IsMultiplayer() && event->type == ev_keydown && event->data1 == KEY_ESCAPE ) {
if( !common->IsMultiplayer() && event->type == ev_keydown && event->data1 == KEY_ESCAPE )
{
startButtonPressed = true;
return true;
}
if( ::g->finalestage == 2 )
{
return F_CastResponder( event );
}
return false;
}
@ -256,32 +268,43 @@ void F_Ticker (void)
// go on to the next level
for( i = 0 ; i < MAXPLAYERS ; i++ )
if( ::g->players[i].cmd.buttons )
{
break;
}
if( finaleButtonPressed || i < MAXPLAYERS )
{
bool castStarted = false;
if( ::g->gamemission == doom2 || ::g->gamemission == pack_plut || ::g->gamemission == pack_tnt ) {
if (::g->gamemap == 30) {
if( ::g->gamemission == doom2 || ::g->gamemission == pack_plut || ::g->gamemission == pack_tnt )
{
if( ::g->gamemap == 30 )
{
F_StartCast();
castStarted = true;
}
} else if( ::g->gamemission == pack_master ) {
if( :: g->gamemap == 21 ) {
}
else if( ::g->gamemission == pack_master )
{
if( :: g->gamemap == 21 )
{
F_StartCast();
castStarted = true;
}
} else if( ::g->gamemission == pack_nerve ) {
if( :: g->gamemap == 8 ) {
}
else if( ::g->gamemission == pack_nerve )
{
if( :: g->gamemap == 8 )
{
F_StartCast();
castStarted = true;
}
}
if( castStarted == false ) {
if( castStarted == false )
{
::g->gameaction = ga_worlddone;
}
}
@ -299,12 +322,14 @@ void F_Ticker (void)
return;
}
if ( ::g->gamemode == commercial) {
if( ::g->gamemode == commercial )
{
startButtonPressed = false;
return;
}
if( SkipTheText && ( ::g->finalecount > 50) ) {
if( SkipTheText && ( ::g->finalecount > 50 ) )
{
::g->finalecount = static_cast<int>( strlen( finaletext ) ) * TEXTSPEED + TEXTWAIT;
}
@ -314,8 +339,10 @@ void F_Ticker (void)
::g->finalestage = 1;
::g->wipegamestate = ( gamestate_t ) - 1; // force a wipe
if( ::g->gameepisode == 3 )
{
S_StartMusic( mus_bunny );
}
}
startButtonPressed = false;
@ -342,7 +369,8 @@ void F_TextWrite (void)
int cx;
int cy;
if(::g->finalecount == 60 ) {
if( ::g->finalecount == 60 )
{
DoomLib::ShowXToContinue( true );
}
@ -373,12 +401,16 @@ void F_TextWrite (void)
count = ( ::g->finalecount - 10 ) / TEXTSPEED;
if( count < 0 )
{
count = 0;
}
for( ; count ; count-- )
{
c = *ch++;
if( !c )
{
break;
}
if( c == '\n' )
{
cx = 10;
@ -395,7 +427,9 @@ void F_TextWrite (void)
w = SHORT( ::g->hu_font[c]->width );
if( cx + w > SCREENWIDTH )
{
break;
}
V_DrawPatch( cx, cy, 0, ::g->hu_font[c] );
cx += w;
}
@ -440,7 +474,8 @@ castinfo_t castorder[] =
void F_StartCast( void )
{
if ( ::g->finalestage != 2 ) {
if( ::g->finalestage != 2 )
{
::g->wipegamestate = ( gamestate_t ) - 1; // force a screen wipe
::g->castnum = 0;
::g->caststate = &::g->states[mobjinfo[castorder[::g->castnum].type].seestate];
@ -465,12 +500,15 @@ void F_CastTicker (void)
int st;
int sfx;
if( ::g->finalecount == ::g->caststartmenu ) {
if( ::g->finalecount == ::g->caststartmenu )
{
DoomLib::ShowXToContinue( true );
}
if( --::g->casttics > 0 )
{
return; // not time to change state yet
}
if( ::g->caststate->tics == -1 || ::g->caststate->nextstate == S_NULL )
{
@ -478,9 +516,13 @@ void F_CastTicker (void)
::g->castnum++;
::g->castdeath = false;
if( castorder[::g->castnum].name == NULL )
{
::g->castnum = 0;
}
if( mobjinfo[castorder[::g->castnum].type].seesound )
{
S_StartSound( NULL, mobjinfo[castorder[::g->castnum].type].seesound );
}
::g->caststate = &::g->states[mobjinfo[castorder[::g->castnum].type].seestate];
::g->castframes = 0;
}
@ -488,7 +530,9 @@ void F_CastTicker (void)
{
// just advance to next state in animation
if( ::g->caststate == &::g->states[S_PLAY_ATK1] )
{
goto stopattack; // Oh, gross hack!
}
st = ::g->caststate->nextstate;
::g->caststate = &::g->states[st];
::g->castframes++;
@ -496,47 +540,89 @@ void F_CastTicker (void)
// sound hacks....
switch( st )
{
case S_PLAY_ATK1: sfx = sfx_dshtgn; break;
case S_POSS_ATK2: sfx = sfx_pistol; break;
case S_SPOS_ATK2: sfx = sfx_shotgn; break;
case S_VILE_ATK2: sfx = sfx_vilatk; break;
case S_SKEL_FIST2: sfx = sfx_skeswg; break;
case S_SKEL_FIST4: sfx = sfx_skepch; break;
case S_SKEL_MISS2: sfx = sfx_skeatk; break;
case S_PLAY_ATK1:
sfx = sfx_dshtgn;
break;
case S_POSS_ATK2:
sfx = sfx_pistol;
break;
case S_SPOS_ATK2:
sfx = sfx_shotgn;
break;
case S_VILE_ATK2:
sfx = sfx_vilatk;
break;
case S_SKEL_FIST2:
sfx = sfx_skeswg;
break;
case S_SKEL_FIST4:
sfx = sfx_skepch;
break;
case S_SKEL_MISS2:
sfx = sfx_skeatk;
break;
case S_FATT_ATK8:
case S_FATT_ATK5:
case S_FATT_ATK2: sfx = sfx_firsht; break;
case S_FATT_ATK2:
sfx = sfx_firsht;
break;
case S_CPOS_ATK2:
case S_CPOS_ATK3:
case S_CPOS_ATK4: sfx = sfx_shotgn; break;
case S_TROO_ATK3: sfx = sfx_claw; break;
case S_SARG_ATK2: sfx = sfx_sgtatk; break;
case S_CPOS_ATK4:
sfx = sfx_shotgn;
break;
case S_TROO_ATK3:
sfx = sfx_claw;
break;
case S_SARG_ATK2:
sfx = sfx_sgtatk;
break;
case S_BOSS_ATK2:
case S_BOS2_ATK2:
case S_HEAD_ATK2: sfx = sfx_firsht; break;
case S_SKULL_ATK2: sfx = sfx_sklatk; break;
case S_HEAD_ATK2:
sfx = sfx_firsht;
break;
case S_SKULL_ATK2:
sfx = sfx_sklatk;
break;
case S_SPID_ATK2:
case S_SPID_ATK3: sfx = sfx_shotgn; break;
case S_BSPI_ATK2: sfx = sfx_plasma; break;
case S_SPID_ATK3:
sfx = sfx_shotgn;
break;
case S_BSPI_ATK2:
sfx = sfx_plasma;
break;
case S_CYBER_ATK2:
case S_CYBER_ATK4:
case S_CYBER_ATK6: sfx = sfx_rlaunc; break;
case S_PAIN_ATK3: sfx = sfx_sklatk; break;
default: sfx = 0; break;
case S_CYBER_ATK6:
sfx = sfx_rlaunc;
break;
case S_PAIN_ATK3:
sfx = sfx_sklatk;
break;
default:
sfx = 0;
break;
}
if( sfx )
{
S_StartSound( NULL, sfx );
}
}
if( ::g->castframes == 12 )
{
// go into attack frame
::g->castattacking = true;
if( ::g->castonmelee )
{
::g->caststate = &::g->states[mobjinfo[castorder[::g->castnum].type].meleestate];
}
else
{
::g->caststate = &::g->states[mobjinfo[castorder[::g->castnum].type].missilestate];
}
::g->castonmelee ^= 1;
if( ::g->caststate == &::g->states[S_NULL] )
{
@ -563,8 +649,10 @@ void F_CastTicker (void)
::g->casttics = ::g->caststate->tics;
if( ::g->casttics == -1 )
{
::g->casttics = 15;
}
}
//
@ -574,10 +662,14 @@ void F_CastTicker (void)
qboolean F_CastResponder( event_t* ev )
{
if( ev->type != ev_keydown )
{
return false;
}
if( ::g->castdeath )
{
return true; // already in dying frames
}
// go into death frame
::g->castdeath = true;
@ -586,7 +678,9 @@ qboolean F_CastResponder (event_t* ev)
::g->castframes = 0;
::g->castattacking = false;
if( mobjinfo[castorder[::g->castnum].type].deathsound )
{
S_StartSound( NULL, mobjinfo[castorder[::g->castnum].type].deathsound );
}
return true;
}
@ -608,7 +702,9 @@ void F_CastPrint (const char* text)
{
c = *ch++;
if( !c )
{
break;
}
c = toupper( c ) - HU_FONTSTART;
if( c < 0 || c > HU_FONTSIZE )
{
@ -627,7 +723,9 @@ void F_CastPrint (const char* text)
{
c = *ch++;
if( !c )
{
break;
}
c = toupper( c ) - HU_FONTSTART;
if( c < 0 || c > HU_FONTSIZE )
{
@ -669,17 +767,22 @@ void F_CastDrawer (void)
patch = ( patch_t* )W_CacheLumpNum( lump +::g->firstspritelump, PU_CACHE_SHARED );
if( flip )
{
V_DrawPatchFlipped( 160, 170, 0, patch );
}
else
{
V_DrawPatch( 160, 170, 0, patch );
}
}
//
// F_DrawPatchCol
//
void
F_DrawPatchCol( int x, patch_t* patch, int col ) {
F_DrawPatchCol( int x, patch_t* patch, int col )
{
postColumn_t* column;
byte* source;
int count;
@ -703,8 +806,10 @@ F_DrawPatchCol( int x, patch_t* patch, int col ) {
scaledy = desty * GLOBAL_IMAGE_SCALER;
byte src = *source++;
for ( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ ) {
for ( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ ) {
for( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ )
{
for( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ )
{
::g->screens[0][( scaledx + j ) + ( scaledy + i ) * SCREENWIDTH] = src;
}
}
@ -736,20 +841,30 @@ void F_BunnyScroll (void)
scrolled = 320 - ( ::g->finalecount - 230 ) / 2;
if( scrolled > 320 )
{
scrolled = 320;
}
if( scrolled < 0 )
{
scrolled = 0;
}
for( x = 0 ; x < ORIGINAL_WIDTH ; x++ )
{
if( x + scrolled < 320 )
{
F_DrawPatchCol( x, p1, x + scrolled );
}
else
{
F_DrawPatchCol( x, p2, x + scrolled - 320 );
}
}
if( ::g->finalecount < 1130 )
{
return;
}
if( ::g->finalecount < 1180 )
{
V_DrawPatch( ( ORIGINAL_WIDTH - 13 * 8 ) / 2,
@ -760,7 +875,9 @@ void F_BunnyScroll (void)
stage = ( ::g->finalecount - 1180 ) / 5;
if( stage > 6 )
{
stage = 6;
}
if( stage > ::g->laststage )
{
S_StartSound( NULL, sfx_pistol );
@ -784,7 +901,9 @@ void F_Drawer (void)
}
if( !::g->finalestage )
{
F_TextWrite();
}
else
{
switch( ::g->gameepisode )

View file

@ -59,7 +59,9 @@ wipe_shittyColMajorXform
for( y = 0; y < height; y++ )
for( x = 0; x < width; x++ )
{
dest[x * height + y] = array[y * width + x];
}
memcpy( array, dest, width * height * 2 );
@ -97,15 +99,20 @@ wipe_initMelt
::g->wipe_y[i] = ::g->wipe_y[i - 1] + r;
if( ::g->wipe_y[i] > 0 )
{
::g->wipe_y[i] = 0;
}
else if( ::g->wipe_y[i] == -16 )
{
::g->wipe_y[i] = -15;
}
}
return 0;
}
int wipe_doMelt( int width, int height, int ticks ) {
int wipe_doMelt( int width, int height, int ticks )
{
int i;
int j;
int dy;
@ -121,17 +128,21 @@ int wipe_doMelt( int width, int height, int ticks ) {
{
for( i = 0; i < width; i++ )
{
if (::g->wipe_y[i]<0) {
if( ::g->wipe_y[i] < 0 )
{
::g->wipe_y[i]++;
done = false;
}
else if (::g->wipe_y[i] < height) {
else if( ::g->wipe_y[i] < height )
{
dy = ( ::g->wipe_y[i] < 16 * GLOBAL_IMAGE_SCALER ) ? ::g->wipe_y[i] + 1 : 8 * GLOBAL_IMAGE_SCALER;
if( ::g->wipe_y[i] + dy >= height )
{
dy = height - ::g->wipe_y[i];
}
s = &( ( short* )::g->wipe_scr_end )[i * height +::g->wipe_y[i]];
d = &( ( short* )::g->wipe_scr )[::g->wipe_y[i] * width + i];

File diff suppressed because it is too large Load diff

View file

@ -55,7 +55,8 @@ If you have questions concerning this license or the applicable additional terms
#include "defs.h"
#include "structs.h"
struct Globals {
struct Globals
{
void InitGlobals();
#include "vars.h"
};

View file

@ -76,7 +76,9 @@ HUlib_addCharToTextLine
{
if( t->len == HU_MAXLINELENGTH )
{
return false;
}
else
{
t->l[t->len++] = ch;
@ -90,7 +92,10 @@ HUlib_addCharToTextLine
qboolean HUlib_delCharFromTextLine( hu_textline_t* t )
{
if (!t->len) return false;
if( !t->len )
{
return false;
}
else
{
t->l[--t->len] = 0;
@ -122,7 +127,9 @@ HUlib_drawTextLine
{
w = SHORT( l->f[c - l->sc]->width );
if( x + w > SCREENWIDTH )
{
break;
}
V_DrawPatchDirect( x, l->y, FG, l->f[c - l->sc] );
x += w;
}
@ -130,9 +137,11 @@ HUlib_drawTextLine
{
x += 4;
if( x >= SCREENWIDTH )
{
break;
}
}
}
// draw the cursor if requested
if( drawcursor
@ -161,7 +170,9 @@ void HUlib_eraseTextLine(hu_textline_t* l)
for( y = l->y, yoffset = y * SCREENWIDTH ; y < l->y + lh ; y++, yoffset += SCREENWIDTH )
{
if( y < ::g->viewwindowy || y >= ::g->viewwindowy + ::g->viewheight )
{
R_VideoErase( yoffset, SCREENWIDTH ); // erase entire line
}
else
{
R_VideoErase( yoffset, ::g->viewwindowx ); // erase left border
@ -172,7 +183,10 @@ void HUlib_eraseTextLine(hu_textline_t* l)
}
::g->lastautomapactive = ::g->automapactive;
if (l->needsupdate) l->needsupdate--;
if( l->needsupdate )
{
l->needsupdate--;
}
}
@ -207,12 +221,16 @@ void HUlib_addLineToSText(hu_stext_t* s)
// add a clear line
if( ++s->cl == s->h )
{
s->cl = 0;
}
HUlib_clearTextLine( &s->l[s->cl] );
// everything needs updating
for( i = 0 ; i < s->h ; i++ )
{
s->l[i].needsupdate = 4;
}
}
@ -225,11 +243,15 @@ HUlib_addMessageToSText
HUlib_addLineToSText( s );
if( prefix )
while( *prefix )
{
HUlib_addCharToTextLine( &s->l[s->cl], *( prefix++ ) );
}
while( *msg )
{
HUlib_addCharToTextLine( &s->l[s->cl], *( msg++ ) );
}
}
void HUlib_drawSText( hu_stext_t* s )
{
@ -237,14 +259,18 @@ void HUlib_drawSText(hu_stext_t* s)
hu_textline_t* l;
if( !*s->on )
{
return; // if not on, don't draw
}
// draw everything
for( i = 0 ; i < s->h ; i++ )
{
idx = s->cl - i;
if( idx < 0 )
{
idx += s->h; // handle queue of ::g->lines
}
l = &s->l[idx];
@ -262,7 +288,9 @@ void HUlib_eraseSText(hu_stext_t* s)
for( i = 0 ; i < s->h ; i++ )
{
if( s->laston && !*s->on )
{
s->l[i].needsupdate = 4;
}
HUlib_eraseTextLine( &s->l[i] );
}
s->laston = *s->on;
@ -289,14 +317,18 @@ HUlib_initIText
void HUlib_delCharFromIText( hu_itext_t* it )
{
if( it->l.len != it->lm )
{
HUlib_delCharFromTextLine( &it->l );
}
}
void HUlib_eraseLineFromIText( hu_itext_t* it )
{
while( it->lm != it->l.len )
{
HUlib_delCharFromTextLine( &it->l );
}
}
// Resets left margin as well
void HUlib_resetIText( hu_itext_t* it )
@ -311,7 +343,9 @@ HUlib_addPrefixToIText
char* str )
{
while( *str )
{
HUlib_addCharToTextLine( &it->l, *( str++ ) );
}
it->lm = it->l.len;
}
@ -324,13 +358,17 @@ HUlib_keyInIText
{
if( ch >= ' ' && ch <= '_' )
{
HUlib_addCharToTextLine( &it->l, ( char ) ch );
else
if (ch == KEY_BACKSPACE)
}
else if( ch == KEY_BACKSPACE )
{
HUlib_delCharFromIText( it );
else
if (ch != KEY_ENTER)
}
else if( ch != KEY_ENTER )
{
return false; // did not eat key
}
return true; // ate the key
@ -342,7 +380,9 @@ void HUlib_drawIText(hu_itext_t* it)
hu_textline_t* l = &it->l;
if( !*it->on )
{
return;
}
HUlib_drawTextLine( l, true ); // draw the line w/ cursor
}
@ -350,7 +390,9 @@ void HUlib_drawIText(hu_itext_t* it)
void HUlib_eraseIText( hu_itext_t* it )
{
if( it->laston && !*it->on )
{
it->l.needsupdate = 4;
}
HUlib_eraseTextLine( &it->l );
it->laston = *it->on;
}

View file

@ -346,7 +346,9 @@ void HU_Start(void)
const char* s;
if( ::g->headsupactive )
{
HU_Stop();
}
::g->plr = &::g->players[::g->consoleplayer];
::g->message_on = false;
@ -375,14 +377,18 @@ void HU_Start(void)
break;
case commercial:
default:
if( DoomLib::expansionSelected == 5 ) {
if( DoomLib::expansionSelected == 5 )
{
int map = ::g->gamemap;
if( ::g->gamemap > 9 ) {
if( ::g->gamemap > 9 )
{
map = 0;
}
s = DoomLib::GetCurrentExpansion()->mapNames[ map - 1 ];
} else {
}
else
{
s = DoomLib::GetCurrentExpansion()->mapNames[ ::g->gamemap - 1 ];
}
@ -391,7 +397,9 @@ void HU_Start(void)
}
while( *s )
{
HUlib_addCharToTextLine( &::g->w_title, *( s++ ) );
}
// create the chat widget
HUlib_initIText( &::g->w_chat,
@ -401,7 +409,9 @@ void HU_Start(void)
// create the inputbuffer widgets
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
HUlib_initIText( &::g->w_inputbuffer[i], 0, 0, 0, 0, &::g->always_off );
}
::g->headsupactive = true;
@ -413,7 +423,9 @@ void HU_Drawer(void)
HUlib_drawSText( &::g->w_message );
HUlib_drawIText( &::g->w_chat );
if( ::g->automapactive )
{
HUlib_drawTextLine( &::g->w_title, false );
}
}
@ -506,7 +518,9 @@ qboolean HU_Responder(event_t *ev)
numplayers = 0;
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
numplayers += ::g->playeringame[i];
}
if( ev->data1 == KEY_RSHIFT )
{
@ -520,7 +534,9 @@ qboolean HU_Responder(event_t *ev)
}
if( ev->type != ev_keydown )
{
return false;
}
if( !::g->chat_on )
{
@ -553,20 +569,30 @@ qboolean HU_Responder(event_t *ev)
{
::g->num_nobrainers++;
if( ::g->num_nobrainers < 3 )
{
::g->plr->message = HUSTR_TALKTOSELF1;
}
else if( ::g->num_nobrainers < 6 )
{
::g->plr->message = HUSTR_TALKTOSELF2;
}
else if( ::g->num_nobrainers < 9 )
{
::g->plr->message = HUSTR_TALKTOSELF3;
}
else if( ::g->num_nobrainers < 32 )
{
::g->plr->message = HUSTR_TALKTOSELF4;
}
else
{
::g->plr->message = HUSTR_TALKTOSELF5;
}
}
}
}
}
}
else
{
c = ev->data1;
@ -575,7 +601,9 @@ qboolean HU_Responder(event_t *ev)
{
c = c - '0';
if( c > 9 )
{
return false;
}
// I_PrintfE( "got here\n");
macromessage = temp_chat_macros[c];
@ -584,7 +612,9 @@ qboolean HU_Responder(event_t *ev)
// send the macro message
while( *macromessage )
{
HU_queueChatChar( *macromessage++ );
}
HU_queueChatChar( KEY_ENTER );
// leave chat mode and notify that it was sent
@ -596,7 +626,9 @@ qboolean HU_Responder(event_t *ev)
else
{
if( ::g->shiftdown || ( c >= 'a' && c <= 'z' ) )
{
c = shiftxform[c];
}
eatkey = HUlib_keyInIText( &::g->w_chat, c );
if( eatkey )
{
@ -616,9 +648,11 @@ qboolean HU_Responder(event_t *ev)
}
}
else if( c == KEY_ESCAPE )
{
::g->chat_on = false;
}
}
}
return eatkey;

View file

@ -53,27 +53,35 @@ extern int PLAYERCOUNT;
#define NUM_BUTTONS 4
static bool Cheat_God() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_God()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
::g->plyr->cheats ^= CF_GODMODE;
if( ::g->plyr->cheats & CF_GODMODE )
{
if( ::g->plyr->mo )
{
::g->plyr->mo->health = 100;
}
::g->plyr->health = 100;
::g->plyr->message = STSTR_DQDON;
}
else
{
::g->plyr->message = STSTR_DQDOFF;
}
return true;
}
#include "g_game.h"
static bool Cheat_NextLevel() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_NextLevel()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
G_ExitLevel();
@ -81,8 +89,10 @@ static bool Cheat_NextLevel() {
return true;
}
static bool Cheat_GiveAll() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_GiveAll()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
@ -91,20 +101,28 @@ static bool Cheat_GiveAll() {
int i;
for( i = 0; i < NUMWEAPONS; i++ )
{
::g->plyr->weaponowned[i] = true;
}
for( i = 0; i < NUMAMMO; i++ )
{
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
}
for( i = 0; i < NUMCARDS; i++ )
{
::g->plyr->cards[i] = true;
}
::g->plyr->message = STSTR_KFAADDED;
return true;
}
static bool Cheat_GiveAmmo() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_GiveAmmo()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
::g->plyr->armorpoints = 200;
@ -112,17 +130,23 @@ static bool Cheat_GiveAmmo() {
int i;
for( i = 0; i < NUMWEAPONS; i++ )
{
::g->plyr->weaponowned[i] = true;
}
for( i = 0; i < NUMAMMO; i++ )
{
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
}
::g->plyr->message = STSTR_KFAADDED;
return true;
}
static bool Cheat_Choppers() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_Choppers()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
::g->plyr->weaponowned[wp_chainsaw] = true;
@ -132,19 +156,28 @@ static bool Cheat_Choppers() {
extern qboolean P_GivePower( player_t* player, int /*powertype_t*/ power );
static void TogglePowerUp( int i ) {
static void TogglePowerUp( int i )
{
if( !::g->plyr->powers[i] )
{
P_GivePower( ::g->plyr, i );
}
else if( i != pw_strength )
{
::g->plyr->powers[i] = 1;
}
else
{
::g->plyr->powers[i] = 0;
}
::g->plyr->message = STSTR_BEHOLDX;
}
static bool Cheat_GiveInvul() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_GiveInvul()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
@ -152,8 +185,10 @@ static bool Cheat_GiveInvul() {
return true;
}
static bool Cheat_GiveBerserk() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_GiveBerserk()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
@ -161,8 +196,10 @@ static bool Cheat_GiveBerserk() {
return true;
}
static bool Cheat_GiveBlur() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_GiveBlur()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
@ -170,8 +207,10 @@ static bool Cheat_GiveBlur() {
return true;
}
static bool Cheat_GiveRad() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_GiveRad()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
@ -179,8 +218,10 @@ static bool Cheat_GiveRad() {
return true;
}
static bool Cheat_GiveMap() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_GiveMap()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
@ -188,8 +229,10 @@ static bool Cheat_GiveMap() {
return true;
}
static bool Cheat_GiveLight() {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
static bool Cheat_GiveLight()
{
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false;
}
@ -214,7 +257,8 @@ struct cheatcode_t
cheat_command function;
};
static cheatcode_t codes[] = {
static cheatcode_t codes[] =
{
{ {0, 1, 1, 0}, Cheat_God }, // a b b a
{ {0, 0, 1, 1}, Cheat_NextLevel }, // a a b b
{ {1, 0, 1, 0}, Cheat_GiveAmmo }, // b a b a
@ -231,7 +275,8 @@ static cheatcode_t codes[] = {
const static int numberOfCodes = sizeof( codes ) / sizeof( codes[0] );
void BeginTrackingCheat() {
void BeginTrackingCheat()
{
#if ALLOW_CHEATS
tracking = true;
currentCheatLength = 0;
@ -239,7 +284,8 @@ void BeginTrackingCheat() {
#endif
}
void EndTrackingCheat() {
void EndTrackingCheat()
{
#if ALLOW_CHEATS
tracking = false;
#endif
@ -247,16 +293,22 @@ void EndTrackingCheat() {
extern void S_StartSound( void* origin, int sfx_id );
void CheckCheat( int button ) {
void CheckCheat( int button )
{
#if ALLOW_CHEATS
if( tracking && !::g->netgame ) {
if( tracking && !::g->netgame )
{
currentCode[ currentCheatLength++ ] = button;
if( currentCheatLength == NUM_BUTTONS ) {
for( int i = 0; i < numberOfCodes; ++i) {
if( memcmp( &codes[i].code[0], &currentCode[0], sizeof(currentCode) ) == 0 ) {
if(codes[i].function()) {
if( currentCheatLength == NUM_BUTTONS )
{
for( int i = 0; i < numberOfCodes; ++i )
{
if( memcmp( &codes[i].code[0], &currentCode[0], sizeof( currentCode ) ) == 0 )
{
if( codes[i].function() )
{
S_StartSound( 0, sfx_cybsit );
}
}
@ -303,11 +355,13 @@ int I_PollMouseInputEvents( controller_t *con)
return numEvents;
}
int I_ReturnMouseInputEvent( const int n, event_t* e) {
int I_ReturnMouseInputEvent( const int n, event_t* e )
{
e->type = ev_mouse;
e->data1 = e->data2 = e->data3 = 0;
switch(::g->mouseEvents[n].type) {
switch( ::g->mouseEvents[n].type )
{
case IETAxis:
switch( ::g->mouseEvents[n].action )
{
@ -326,7 +380,8 @@ int I_ReturnMouseInputEvent( const int n, event_t* e) {
return 0;
}
int I_PollJoystickInputEvents( controller_t *con ) {
int I_PollJoystickInputEvents( controller_t* con )
{
int numEvents = 0;
return numEvents;
@ -349,10 +404,12 @@ static int xlatekey(int key)
rc = '1';
break;
case 1: // B
if( ::g->menuactive ) {
if( ::g->menuactive )
{
rc = KEY_BACKSPACE;
}
else {
else
{
rc = '2';
}
break;
@ -373,37 +430,45 @@ static int xlatekey(int key)
rc = KEY_RCTRL;
break;
case 8: // Up
if( ::g->menuactive ) {
if( ::g->menuactive )
{
rc = KEY_UPARROW;
}
else {
else
{
//rc = KEY_ENTER;
rc = '3';
}
break;
case 9:
if( ::g->menuactive ) {
if( ::g->menuactive )
{
rc = KEY_DOWNARROW;
}
else {
else
{
//rc = KEY_TAB;
rc = '5';
}
break;
case 10:
if( ::g->menuactive ) {
if( ::g->menuactive )
{
rc = KEY_UPARROW;
}
else {
else
{
//rc = '1';
rc = '6';
}
break;
case 11:
if( ::g->menuactive ) {
if( ::g->menuactive )
{
rc = KEY_DOWNARROW;
}
else {
else
{
//rc = '2';
rc = '4';
}
@ -422,7 +487,8 @@ static int xlatekey(int key)
return rc;
}
int I_ReturnJoystickInputEvent( const int n, event_t* e) {
int I_ReturnJoystickInputEvent( const int n, event_t* e )
{
e->data1 = e->data2 = e->data3 = 0;
@ -450,9 +516,13 @@ int I_ReturnJoystickInputEvent( const int n, event_t* e) {
case IETButtonAnalog:
case IETButtonDigital:
if( ::g->joyEvents[n].data )
{
e->type = ev_keydown;
}
else
{
e->type = ev_keyup;
}
e->data1 = xlatekey( ::g->joyEvents[n].action );
return 1;
@ -463,7 +533,8 @@ int I_ReturnJoystickInputEvent( const int n, event_t* e) {
return 0;
}
void I_EndJoystickInputEvents() {
void I_EndJoystickInputEvents()
{
int i;
for( i = 0; i < 18; i++ )
{

View file

@ -51,7 +51,8 @@ If you have questions concerning this license or the applicable additional terms
void NetSend( void );
qboolean NetListen( void );
namespace {
namespace
{
bool IsValidSocket( int socketDescriptor );
int GetLastSocketError();
@ -63,7 +64,8 @@ namespace {
between WinSock (used on Xbox) and BSD sockets, which the PS3 follows more closely.
========================
*/
bool IsValidSocket( int socketDescriptor ) {
bool IsValidSocket( int socketDescriptor )
{
return false;
}
@ -72,7 +74,8 @@ namespace {
Returns the last error reported by the platform's socket library.
========================
*/
int GetLastSocketError() {
int GetLastSocketError()
{
return 0;
}
}
@ -83,7 +86,8 @@ namespace {
int DOOMPORT = 1002; // DHM - Nerve :: On original XBox, ports 1000 - 1255 saved you a byte on every packet. 360 too?
unsigned long GetServerIP() {
unsigned long GetServerIP()
{
//return ::g->sendaddress[::g->doomcom.consoleplayer].sin_addr.s_addr;
return 0;
}
@ -161,17 +165,27 @@ void I_InitNetwork (void)
{
::g->doomcom.ticdup = ::g->myargv[i + 1][0] - '0';
if( ::g->doomcom.ticdup < 1 )
{
::g->doomcom.ticdup = 1;
}
if( ::g->doomcom.ticdup > 9 )
{
::g->doomcom.ticdup = 9;
}
}
else
{
::g->doomcom.ticdup = 1;
}
if( M_CheckParm( "-extratic" ) )
{
::g->doomcom.extratics = 1;
}
else
{
::g->doomcom.extratics = 0;
}
p = M_CheckParm( "-port" );
if( p && p < ::g->myargc - 1 )
@ -217,20 +231,24 @@ void I_InitNetwork (void)
const std::size_t colonPosition = ipAddressWithPort.find_last_of( ':' );
std::string ipOnly;
if( colonPosition != std::string::npos && colonPosition + 1 < ipAddressWithPort.size() ) {
if( colonPosition != std::string::npos && colonPosition + 1 < ipAddressWithPort.size() )
{
const std::string portOnly( ipAddressWithPort.substr( colonPosition + 1 ) );
::g->sendaddress[::g->doomcom.numnodes].sin_port = htons( atoi( portOnly.c_str() ) );
ipOnly = ipAddressWithPort.substr( 0, colonPosition );
} else {
}
else
{
// Assume the address doesn't include a port.
ipOnly = ipAddressWithPort;
}
in_addr_t ipAddress = inet_addr( ipOnly.c_str() );
if ( ipAddress == INADDR_NONE ) {
if( ipAddress == INADDR_NONE )
{
I_Error( "Invalid IP Address: %s\n", ipOnly.c_str() );
session->QuitMatch();
common->AddDialog( GDM_OPPONENT_CONNECTION_LOST, DIALOG_ACCEPT, NULL, NULL, false );
@ -243,7 +261,8 @@ void I_InitNetwork (void)
::g->doomcom.numplayers = ::g->doomcom.numnodes;
}
if ( globalNetworking ) {
if( globalNetworking )
{
// Setup sockets
::g->insocket = UDPsocket();
BindToLocalPort( ::g->insocket, htons( DOOMPORT ) );
@ -260,7 +279,8 @@ void I_InitNetwork (void)
}
// DHM - Nerve
void I_ShutdownNetwork() {
void I_ShutdownNetwork()
{
}

View file

@ -79,19 +79,22 @@ int totalBufferSize;
bool waitingForMusic;
bool musicReady;
typedef struct {
typedef struct
{
float x;
float y;
float z;
} vec3_t;
typedef struct {
typedef struct
{
vec3_t OrientTop;
vec3_t OrientFront;
vec3_t Position;
} doomListener_t;
typedef struct tagActiveSound_t {
typedef struct tagActiveSound_t
{
ALuint alSourceVoice;
int id;
int valid;
@ -102,7 +105,8 @@ typedef struct tagActiveSound_t {
} activeSound_t;
// cheap little struct to hold a sound
typedef struct {
typedef struct
{
int vol;
int player;
int pitch;
@ -171,9 +175,13 @@ void* getsfx ( const char* sfxname, int* len )
// If sound requested is not found in current WAD, use pistol as default
if( W_CheckNumForName( name ) == -1 )
{
sfxlump = W_GetNumForName( "dspistol" );
}
else
{
sfxlump = W_GetNumForName( name );
}
// Sound lump headers are 8 bytes.
const int SOUND_LUMP_HEADER_SIZE_IN_BYTES = 8;
@ -188,7 +196,8 @@ void* getsfx ( const char* sfxname, int* len )
sfxmem = ( unsigned char* )malloc( size * sizeof( unsigned char ) );
// Now copy, and convert to Xbox360 native float samples, do initial volume ramp, and scale
for ( int i = 0; i < size; i++ ) {
for( int i = 0; i < size; i++ )
{
sfxmem[i] = sfxSampleStart[i];// * scale;
}
@ -255,7 +264,8 @@ I_StartSound2
//
int I_StartSound2( int id, int player, mobj_t* origin, mobj_t* listener_origin, int pitch, int priority )
{
if ( !soundHardwareInitialized || id == 0 ) {
if( !soundHardwareInitialized || id == 0 )
{
return id;
}
@ -264,13 +274,15 @@ int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin,
int oldest = 0, oldestnum = -1;
// these id's should not overlap
if ( id == sfx_sawup || id == sfx_sawidl || id == sfx_sawful || id == sfx_sawhit || id == sfx_stnmov ) {
if( id == sfx_sawup || id == sfx_sawidl || id == sfx_sawful || id == sfx_sawhit || id == sfx_stnmov )
{
// Loop all channels, check.
for( i = 0; i < NUM_SOUNDBUFFERS; i++ )
{
sound = &activeSounds[i];
if ( sound->valid && ( sound->id == id && sound->player == player ) ) {
if( sound->valid && ( sound->id == id && sound->player == player ) )
{
I_StopSound( sound->id, player );
break;
}
@ -278,26 +290,32 @@ int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin,
}
// find a valid channel, or one that has finished playing
for ( i = 0; i < NUM_SOUNDBUFFERS; i++ ) {
for( i = 0; i < NUM_SOUNDBUFFERS; i++ )
{
sound = &activeSounds[i];
if( !sound->valid )
{
break;
}
if ( !oldest || oldest > sound->start ) {
if( !oldest || oldest > sound->start )
{
oldestnum = i;
oldest = sound->start;
}
ALint sourceState;
alGetSourcei( sound->alSourceVoice, AL_SOURCE_STATE, &sourceState );
if ( sourceState == AL_STOPPED ) {
if( sourceState == AL_STOPPED )
{
break;
}
}
// none found, so use the oldest one
if ( i == NUM_SOUNDBUFFERS ) {
if( i == NUM_SOUNDBUFFERS )
{
i = oldestnum;
sound = &activeSounds[i];
}
@ -305,7 +323,8 @@ int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin,
alSourceStop( sound->alSourceVoice );
// Attach the source voice to the correct buffer
if ( sound->id != id ) {
if( sound->id != id )
{
alSourcei( sound->alSourceVoice, AL_BUFFER, 0 );
alSourcei( sound->alSourceVoice, AL_BUFFER, alBuffers[id] );
}
@ -320,18 +339,25 @@ int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin,
ALfloat x = 0.f;
ALfloat y = 0.f;
ALfloat z = 0.f;
if ( origin ) {
if ( origin == listener_origin ) {
if( origin )
{
if( origin == listener_origin )
{
sound->localSound = true;
} else {
}
else
{
sound->localSound = false;
x = ( ALfloat )( origin->x >> FRACBITS );
z = ( ALfloat )( origin->y >> FRACBITS );
}
} else {
}
else
{
sound->localSound = true;
}
if ( sound->localSound ) {
if( sound->localSound )
{
x = doom_Listener.Position.x;
z = doom_Listener.Position.z;
}
@ -356,8 +382,10 @@ I_ProcessSoundEvents
*/
void I_ProcessSoundEvents( void )
{
for( int i = 0; i < 128; i++ ) {
if( soundEvents[i].pitch ) {
for( int i = 0; i < 128; i++ )
{
if( soundEvents[i].pitch )
{
I_StartSound2( i, soundEvents[i].player, soundEvents[i].originator, soundEvents[i].listener,
soundEvents[i].pitch, soundEvents[i].priority );
}
@ -373,16 +401,21 @@ I_StartSound
int I_StartSound( int id, mobj_t* origin, mobj_t* listener_origin, int vol, int pitch, int priority )
{
// only allow player 0s sounds in intermission and finale screens
if( ::g->gamestate != GS_LEVEL && DoomLib::GetPlayer() != 0 ) {
if( ::g->gamestate != GS_LEVEL && DoomLib::GetPlayer() != 0 )
{
return 0;
}
// if we're only one player or we're trying to play the chainsaw sound, do it normal
// otherwise only allow one sound of each type per frame
if( PLAYERCOUNT == 1 || id == sfx_sawup || id == sfx_sawidl || id == sfx_sawful || id == sfx_sawhit ) {
if( PLAYERCOUNT == 1 || id == sfx_sawup || id == sfx_sawidl || id == sfx_sawful || id == sfx_sawhit )
{
return I_StartSound2( id, ::g->consoleplayer, origin, listener_origin, pitch, priority );
} else {
if( soundEvents[ id ].vol < vol ) {
}
else
{
if( soundEvents[ id ].vol < vol )
{
soundEvents[ id ].player = DoomLib::GetPlayer();
soundEvents[ id ].pitch = pitch;
soundEvents[ id ].priority = priority;
@ -408,15 +441,20 @@ void I_StopSound ( int handle, int player )
int i;
activeSound_t* sound = 0;
for ( i = 0; i < NUM_SOUNDBUFFERS; ++i ) {
for( i = 0; i < NUM_SOUNDBUFFERS; ++i )
{
sound = &activeSounds[i];
if( !sound->valid || sound->id != handle || ( player >= 0 && sound->player != player ) )
{
continue;
}
break;
}
if( i == NUM_SOUNDBUFFERS )
{
return;
}
// Stop the sound
alSourceStop( sound->alSourceVoice );
@ -432,21 +470,26 @@ I_SoundIsPlaying
*/
int I_SoundIsPlaying( int handle )
{
if ( !soundHardwareInitialized ) {
if( !soundHardwareInitialized )
{
return 0;
}
int i;
activeSound_t* sound;
for ( i = 0; i < NUM_SOUNDBUFFERS; ++i ) {
for( i = 0; i < NUM_SOUNDBUFFERS; ++i )
{
sound = &activeSounds[i];
if( !sound->valid || sound->id != handle )
{
continue;
}
ALint sourceState;
alGetSourcei( sound->alSourceVoice, AL_SOURCE_STATE, &sourceState );
if ( sourceState == AL_PLAYING ) {
if( sourceState == AL_PLAYING )
{
return 1;
}
}
@ -463,13 +506,15 @@ I_UpdateSound
// channels and update sound positions.
void I_UpdateSound( void )
{
if ( !soundHardwareInitialized ) {
if( !soundHardwareInitialized )
{
return;
}
// Update listener orientation and position
mobj_t* playerObj = ::g->players[0].mo;
if ( playerObj ) {
if( playerObj )
{
angle_t pAngle = playerObj->angle;
fixed_t fx, fz;
@ -484,7 +529,9 @@ void I_UpdateSound( void )
doom_Listener.Position.x = ( float )( playerObj->x >> FRACBITS );
doom_Listener.Position.y = 0.f;
doom_Listener.Position.z = ( float )( playerObj->y >> FRACBITS );
} else {
}
else
{
doom_Listener.OrientFront.x = 0.f;
doom_Listener.OrientFront.y = 0.f;
doom_Listener.OrientFront.z = 1.f;
@ -496,27 +543,34 @@ void I_UpdateSound( void )
ALfloat listenerOrientation[] = { doom_Listener.OrientFront.x, doom_Listener.OrientFront.y,
doom_Listener.OrientFront.z, doom_Listener.OrientTop.x, doom_Listener.OrientTop.y,
doom_Listener.OrientTop.z };
doom_Listener.OrientTop.z
};
alListenerfv( AL_ORIENTATION, listenerOrientation );
alListener3f( AL_POSITION, doom_Listener.Position.x, doom_Listener.Position.y, doom_Listener.Position.z );
// Update playing source voice positions
int i;
activeSound_t* sound;
for ( i=0; i < NUM_SOUNDBUFFERS; i++ ) {
for( i = 0; i < NUM_SOUNDBUFFERS; i++ )
{
sound = &activeSounds[i];
if ( !sound->valid ) {
if( !sound->valid )
{
continue;
}
ALint sourceState;
alGetSourcei( sound->alSourceVoice, AL_SOURCE_STATE, &sourceState );
if ( sourceState == AL_PLAYING ) {
if ( sound->localSound ) {
if( sourceState == AL_PLAYING )
{
if( sound->localSound )
{
alSource3f( sound->alSourceVoice, AL_POSITION, doom_Listener.Position.x,
doom_Listener.Position.y, doom_Listener.Position.z );
} else {
}
else
{
ALfloat x = ( ALfloat )( sound->originator->x >> FRACBITS );
ALfloat y = 0.f;
ALfloat z = ( ALfloat )( sound->originator->y >> FRACBITS );
@ -546,12 +600,15 @@ void I_ShutdownSound( void )
int done = 0;
int i;
if ( S_initialized ) {
if( S_initialized )
{
// Stop all sounds
for ( i = 0; i < NUM_SOUNDBUFFERS; i++ ) {
for( i = 0; i < NUM_SOUNDBUFFERS; i++ )
{
activeSound_t* sound = &activeSounds[i];
if ( !sound ) {
if( !sound )
{
continue;
}
@ -559,8 +616,10 @@ void I_ShutdownSound( void )
}
// Free allocated sound memory
for ( i = 1; i < NUMSFX; i++ ) {
if ( S_sfx[i].data && !(S_sfx[i].link) ) {
for( i = 1; i < NUMSFX; i++ )
{
if( S_sfx[i].data && !( S_sfx[i].link ) )
{
free( S_sfx[i].data );
}
}
@ -584,12 +643,14 @@ void I_InitSoundHardware( int numOutputChannels_, int channelMask )
::numOutputChannels = numOutputChannels_;
// Initialize source voices
for ( int i = 0; i < NUM_SOUNDBUFFERS; i++ ) {
for( int i = 0; i < NUM_SOUNDBUFFERS; i++ )
{
I_InitSoundChannel( i, numOutputChannels );
}
// Create OpenAL buffers for all sounds
for ( int i = 1; i < NUMSFX; i++ ) {
for( int i = 1; i < NUMSFX; i++ )
{
alGenBuffers( ( ALuint )1, &alBuffers[i] );
}
@ -613,14 +674,17 @@ void I_ShutdownSoundHardware()
I_ShutdownMusic();
// Delete all source voices
for ( int i = 0; i < NUM_SOUNDBUFFERS; ++i ) {
for( int i = 0; i < NUM_SOUNDBUFFERS; ++i )
{
activeSound_t* sound = &activeSounds[i];
if ( !sound ) {
if( !sound )
{
continue;
}
if ( sound->alSourceVoice ) {
if( sound->alSourceVoice )
{
alSourceStop( sound->alSourceVoice );
alSourcei( sound->alSourceVoice, AL_BUFFER, 0 );
alDeleteSources( 1, &sound->alSourceVoice );
@ -628,7 +692,8 @@ void I_ShutdownSoundHardware()
}
// Delete OpenAL buffers for all sounds
for ( int i = 0; i < NUMSFX; i++ ) {
for( int i = 0; i < NUMSFX; i++ )
{
alDeleteBuffers( 1, &alBuffers[i] );
}
}
@ -658,7 +723,8 @@ I_InitSound
*/
void I_InitSound()
{
if ( S_initialized == 0 ) {
if( S_initialized == 0 )
{
// Set up listener parameters
doom_Listener.OrientFront.x = 0.f;
doom_Listener.OrientFront.y = 0.f;
@ -672,17 +738,22 @@ void I_InitSound()
doom_Listener.Position.y = 0.f;
doom_Listener.Position.z = 0.f;
for ( int i = 1; i < NUMSFX; i++ ) {
for( int i = 1; i < NUMSFX; i++ )
{
// Alias? Example is the chaingun sound linked to pistol.
if ( !S_sfx[i].link ) {
if( !S_sfx[i].link )
{
// Load data from WAD file.
S_sfx[i].data = getsfx( S_sfx[i].name, &lengths[i] );
} else {
}
else
{
// Previously loaded already?
S_sfx[i].data = S_sfx[i].link->data;
lengths[i] = lengths[( S_sfx[i].link - S_sfx ) / sizeof( sfxinfo_t ) ];
}
if ( S_sfx[i].data ) {
if( S_sfx[i].data )
{
alBufferData( alBuffers[i], SFX_SAMPLETYPE, ( byte* )S_sfx[i].data, lengths[i], SFX_RATE );
}
}
@ -701,7 +772,8 @@ void I_SubmitSound( void )
// Only do this for player 0, it will still handle positioning
// for other players, but it can't be outside the game
// frame like the soundEvents are.
if ( DoomLib::GetPlayer() == 0 ) {
if( DoomLib::GetPlayer() == 0 )
{
// Do 3D positioning of sounds
I_UpdateSound();
@ -734,7 +806,8 @@ I_InitMusic
*/
void I_InitMusic( void )
{
if ( !Music_initialized ) {
if( !Music_initialized )
{
// Initialize Timidity
Timidity_Init( MIDI_RATE, MIDI_FORMAT, MIDI_CHANNELS, MIDI_RATE, "classicmusic/gravis.cfg" );
@ -761,18 +834,22 @@ I_ShutdownMusic
*/
void I_ShutdownMusic( void )
{
if ( Music_initialized ) {
if ( alMusicSourceVoice ) {
if( Music_initialized )
{
if( alMusicSourceVoice )
{
I_StopSong( 0 );
alSourcei( alMusicSourceVoice, AL_BUFFER, 0 );
alDeleteSources( 1, &alMusicSourceVoice );
}
if ( alMusicBuffer ) {
if( alMusicBuffer )
{
alDeleteBuffers( 1, &alMusicBuffer );
}
if ( musicBuffer ) {
if( musicBuffer )
{
free( musicBuffer );
musicBuffer = NULL;
}
@ -789,7 +866,8 @@ void I_ShutdownMusic( void )
int Mus2Midi( unsigned char* bytes, unsigned char* out, int* len );
namespace {
namespace
{
const int MaxMidiConversionSize = 1024 * 1024;
unsigned char midiConversionBuffer[MaxMidiConversionSize];
}
@ -811,7 +889,8 @@ void I_LoadSong( const char * songname )
doomMusic = Timidity_LoadSongMem( midiConversionBuffer, length );
if ( doomMusic ) {
if( doomMusic )
{
musicBuffer = ( byte* )malloc( MIDI_CHANNELS * MIDI_FORMAT_BYTES * doomMusic->samples );
totalBufferSize = doomMusic->samples * MIDI_CHANNELS * MIDI_FORMAT_BYTES;
Timidity_Start( doomMusic );
@ -820,10 +899,12 @@ void I_LoadSong( const char * songname )
int num_bytes = 0;
int offset = 0;
do {
do
{
rc = Timidity_PlaySome( musicBuffer + offset, MIDI_RATE, &num_bytes );
offset += num_bytes;
} while ( rc != RC_TUNE_END );
}
while( rc != RC_TUNE_END );
Timidity_Stop();
Timidity_FreeSong( doomMusic );
@ -839,14 +920,16 @@ I_PlaySong
*/
void I_PlaySong( const char* songname, int looping )
{
if ( !Music_initialized ) {
if( !Music_initialized )
{
return;
}
I_StopSong( 0 );
// Clear old state
if ( musicBuffer ) {
if( musicBuffer )
{
free( musicBuffer );
musicBuffer = 0;
}
@ -855,7 +938,8 @@ void I_PlaySong( const char *songname, int looping )
I_LoadSong( songname );
waitingForMusic = true;
if ( DoomLib::GetPlayer() >= 0 ) {
if( DoomLib::GetPlayer() >= 0 )
{
::g->mus_looping = looping;
}
}
@ -867,18 +951,23 @@ I_UpdateMusic
*/
void I_UpdateMusic( void )
{
if ( !Music_initialized ) {
if( !Music_initialized )
{
return;
}
if ( alMusicSourceVoice ) {
if( alMusicSourceVoice )
{
// Set the volume
alSourcef( alMusicSourceVoice, AL_GAIN, x_MusicVolume * GLOBAL_VOLUME_MULTIPLIER );
}
if ( waitingForMusic ) {
if ( musicReady && alMusicSourceVoice ) {
if ( musicBuffer ) {
if( waitingForMusic )
{
if( musicReady && alMusicSourceVoice )
{
if( musicBuffer )
{
alSourcei( alMusicSourceVoice, AL_BUFFER, 0 );
alBufferData( alMusicBuffer, MIDI_SAMPLETYPE, musicBuffer, totalBufferSize, MIDI_RATE );
alSourcei( alMusicSourceVoice, AL_BUFFER, alMusicBuffer );
@ -897,7 +986,8 @@ I_PauseSong
*/
void I_PauseSong( int handle )
{
if ( !Music_initialized || !alMusicSourceVoice ) {
if( !Music_initialized || !alMusicSourceVoice )
{
return;
}
@ -911,7 +1001,8 @@ I_ResumeSong
*/
void I_ResumeSong( int handle )
{
if ( !Music_initialized || !alMusicSourceVoice ) {
if( !Music_initialized || !alMusicSourceVoice )
{
return;
}
@ -925,7 +1016,8 @@ I_StopSong
*/
void I_StopSong( int handle )
{
if ( !Music_initialized || !alMusicSourceVoice ) {
if( !Music_initialized || !alMusicSourceVoice )
{
return;
}

View file

@ -65,7 +65,9 @@ void I_ProcessSoundEvents( void ){}
// Starts a sound in a particular sound channel.
int I_StartSound( int id, mobj_t* origin, mobj_t* listener_origin, int vol, int pitch, int priority )
{ return 0; }
{
return 0;
}
// Stops a sound channel.
@ -75,7 +77,9 @@ void I_StopSound(int handle, int player){}
// to see if a channel is still playing.
// Returns 0 if no longer playing, 1 if playing.
int I_SoundIsPlaying( int handle )
{ return 0; }
{
return 0;
}
// Updates the volume, separation,
// and pitch of a sound channel.
@ -99,7 +103,9 @@ void I_ResumeSong(int handle){}
// Registers a song handle to song data.
int I_RegisterSong( void* data, int length )
{ return 0; }
{
return 0;
}
// Called by anything that wishes to start music.
// plays a song, and when the song is done,

View file

@ -90,7 +90,8 @@ bool waitingForMusic;
bool musicReady;
typedef struct tagActiveSound_t {
typedef struct tagActiveSound_t
{
IXAudio2SourceVoice* m_pSourceVoice; // Source voice
X3DAUDIO_DSP_SETTINGS m_DSPSettings;
X3DAUDIO_EMITTER m_Emitter;
@ -105,7 +106,8 @@ typedef struct tagActiveSound_t {
// cheap little struct to hold a sound
typedef struct {
typedef struct
{
int vol;
int player;
int pitch;
@ -172,18 +174,24 @@ void* getsfx ( const char* sfxname, int* len )
sprintf( name, "ds%s", sfxname );
// Scale down the plasma gun, it clips
if ( strcmp( sfxname, "plasma" ) == 0 ) {
if( strcmp( sfxname, "plasma" ) == 0 )
{
scale = 0.75f;
}
if ( strcmp( sfxname, "itemup" ) == 0 ) {
if( strcmp( sfxname, "itemup" ) == 0 )
{
scale = 1.333f;
}
// If sound requested is not found in current WAD, use pistol as default
if( W_CheckNumForName( name ) == -1 )
{
sfxlump = W_GetNumForName( "dspistol" );
}
else
{
sfxlump = W_GetNumForName( name );
}
// Sound lump headers are 8 bytes.
const int SOUND_LUMP_HEADER_SIZE_IN_BYTES = 8;
@ -198,7 +206,8 @@ void* getsfx ( const char* sfxname, int* len )
sfxmem = ( unsigned char* )malloc( size * sizeof( unsigned char ) );
// Now copy, and convert to Xbox360 native float samples, do initial volume ramp, and scale
for ( int i=0; i<size; i++ ) {
for( int i = 0; i < size; i++ )
{
sfxmem[i] = sfxSampleStart[i];// * scale;
}
@ -217,7 +226,8 @@ void* getsfx ( const char* sfxname, int* len )
I_SetChannels
======================
*/
void I_SetChannels() {
void I_SetChannels()
{
// Original Doom set up lookup tables here
}
@ -226,7 +236,8 @@ void I_SetChannels() {
I_SetSfxVolume
======================
*/
void I_SetSfxVolume(int volume) {
void I_SetSfxVolume( int volume )
{
x_SoundVolume = ( ( float )volume / 15.f ) * GLOBAL_VOLUME_MULTIPLIER;
}
@ -261,8 +272,10 @@ I_StartSound2
// priority, it is ignored.
// Pitching (that is, increased speed of playback) is set
//
int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin, int pitch, int priority ) {
if ( !soundHardwareInitialized ) {
int I_StartSound2( int id, int player, mobj_t* origin, mobj_t* listener_origin, int pitch, int priority )
{
if( !soundHardwareInitialized )
{
return id;
}
@ -272,13 +285,15 @@ int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin,
int oldest = 0, oldestnum = -1;
// these id's should not overlap
if ( id == sfx_sawup || id == sfx_sawidl || id == sfx_sawful || id == sfx_sawhit || id == sfx_stnmov ) {
if( id == sfx_sawup || id == sfx_sawidl || id == sfx_sawful || id == sfx_sawhit || id == sfx_stnmov )
{
// Loop all channels, check.
for( i = 0 ; i < NUM_SOUNDBUFFERS ; i++ )
{
sound = &activeSounds[i];
if (sound->valid && ( sound->id == id && sound->player == player ) ) {
if( sound->valid && ( sound->id == id && sound->player == player ) )
{
I_StopSound( sound->id, player );
break;
}
@ -286,19 +301,24 @@ int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin,
}
// find a valid channel, or one that has finished playing
for (i = 0; i < NUM_SOUNDBUFFERS; ++i) {
for( i = 0; i < NUM_SOUNDBUFFERS; ++i )
{
sound = &activeSounds[i];
if( !sound->valid )
{
break;
}
if (!oldest || oldest > sound->start) {
if( !oldest || oldest > sound->start )
{
oldestnum = i;
oldest = sound->start;
}
sound->m_pSourceVoice->GetState( &state );
if ( state.BuffersQueued == 0 ) {
if( state.BuffersQueued == 0 )
{
break;
}
}
@ -334,7 +354,8 @@ int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin,
sound->m_pSourceVoice->SetFrequencyRatio( 1 + ( ( float )pitch - 128.f ) / 95.f );
// Set initial spatialization
if ( origin && origin != listener_origin ) {
if( origin && origin != listener_origin )
{
// Update Emitter Position
sound->m_Emitter.Position.x = ( float )( origin->x >> FRACBITS );
sound->m_Emitter.Position.y = 0.f;
@ -348,7 +369,9 @@ int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin,
sound->m_pSourceVoice->SetOutputMatrix( NULL, 1, numOutputChannels, sound->m_DSPSettings.pMatrixCoefficients );
sound->localSound = false;
} else {
}
else
{
// Local(or Global) sound, fixed speaker volumes
sound->m_pSourceVoice->SetOutputMatrix( NULL, 1, numOutputChannels, localSoundVolumeEntries );
@ -357,12 +380,14 @@ int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin,
// Submit packet
HRESULT hr;
if( FAILED( hr = sound->m_pSourceVoice->SubmitSourceBuffer( &Packet ) ) ) {
if( FAILED( hr = sound->m_pSourceVoice->SubmitSourceBuffer( &Packet ) ) )
{
int fail = 1;
}
// Play the source voice
if( FAILED( hr = sound->m_pSourceVoice->Start( 0 ) ) ) {
if( FAILED( hr = sound->m_pSourceVoice->Start( 0 ) ) )
{
int fail = 1;
}
@ -381,9 +406,12 @@ int I_StartSound2 ( int id, int player, mobj_t *origin, mobj_t *listener_origin,
I_ProcessSoundEvents
======================
*/
void I_ProcessSoundEvents() {
for( int i = 0; i < 128; i++ ) {
if( soundEvents[i].pitch ) {
void I_ProcessSoundEvents()
{
for( int i = 0; i < 128; i++ )
{
if( soundEvents[i].pitch )
{
I_StartSound2( i, soundEvents[i].player, soundEvents[i].originator, soundEvents[i].listener, soundEvents[i].pitch, soundEvents[i].priority );
}
}
@ -395,19 +423,24 @@ void I_ProcessSoundEvents() {
I_StartSound
======================
*/
int I_StartSound ( int id, mobj_t *origin, mobj_t *listener_origin, int vol, int pitch, int priority ) {
int I_StartSound( int id, mobj_t* origin, mobj_t* listener_origin, int vol, int pitch, int priority )
{
// only allow player 0s sounds in intermission and finale screens
if( ::g->gamestate != GS_LEVEL && DoomLib::GetPlayer() != 0 ) {
if( ::g->gamestate != GS_LEVEL && DoomLib::GetPlayer() != 0 )
{
return 0;
}
// if we're only one player or we're trying to play the chainsaw sound, do it normal
// otherwise only allow one sound of each type per frame
if( PLAYERCOUNT == 1 || id == sfx_sawup || id == sfx_sawidl || id == sfx_sawful || id == sfx_sawhit ) {
if( PLAYERCOUNT == 1 || id == sfx_sawup || id == sfx_sawidl || id == sfx_sawful || id == sfx_sawhit )
{
return I_StartSound2( id, ::g->consoleplayer, origin, listener_origin, pitch, priority );
}
else {
if( soundEvents[ id ].vol < vol ) {
else
{
if( soundEvents[ id ].vol < vol )
{
soundEvents[ id ].player = DoomLib::GetPlayer();
soundEvents[ id ].pitch = pitch;
soundEvents[ id ].priority = priority;
@ -438,15 +471,20 @@ void I_StopSound (int handle, int player)
{
sound = &activeSounds[i];
if( !sound->valid || sound->id != handle || ( player >= 0 && sound->player != player ) )
{
continue;
}
break;
}
if( i == NUM_SOUNDBUFFERS )
{
return;
}
// stop the sound
if ( sound->m_pSourceVoice != NULL ) {
if( sound->m_pSourceVoice != NULL )
{
sound->m_pSourceVoice->Stop( 0 );
}
@ -459,8 +497,10 @@ void I_StopSound (int handle, int player)
I_SoundIsPlaying
======================
*/
int I_SoundIsPlaying(int handle) {
if ( !soundHardwareInitialized ) {
int I_SoundIsPlaying( int handle )
{
if( !soundHardwareInitialized )
{
return 0;
}
@ -472,10 +512,13 @@ int I_SoundIsPlaying(int handle) {
{
sound = &activeSounds[i];
if( !sound->valid || sound->id != handle )
{
continue;
}
sound->m_pSourceVoice->GetState( &state );
if ( state.BuffersQueued > 0 ) {
if( state.BuffersQueued > 0 )
{
return 1;
}
}
@ -490,8 +533,10 @@ I_UpdateSound
*/
// Update Listener Position and go through all the
// channels and update speaker volumes for 3D sound.
void I_UpdateSound() {
if ( !soundHardwareInitialized ) {
void I_UpdateSound()
{
if( !soundHardwareInitialized )
{
return;
}
@ -499,16 +544,19 @@ void I_UpdateSound() {
XAUDIO2_VOICE_STATE state;
activeSound_t* sound;
for ( i=0; i < NUM_SOUNDBUFFERS; i++ ) {
for( i = 0; i < NUM_SOUNDBUFFERS; i++ )
{
sound = &activeSounds[i];
if ( !sound->valid || sound->localSound ) {
if( !sound->valid || sound->localSound )
{
continue;
}
sound->m_pSourceVoice->GetState( &state );
if ( state.BuffersQueued > 0 ) {
if( state.BuffersQueued > 0 )
{
mobj_t* playerObj = ::g->players[ sound->player ].mo;
// Update Listener Orientation and Position
@ -548,7 +596,8 @@ void I_UpdateSound() {
I_UpdateSoundParams
======================
*/
void I_UpdateSoundParams( int handle, int vol, int sep, int pitch) {
void I_UpdateSoundParams( int handle, int vol, int sep, int pitch )
{
}
/*
@ -556,28 +605,35 @@ void I_UpdateSoundParams( int handle, int vol, int sep, int pitch) {
I_ShutdownSound
======================
*/
void I_ShutdownSound(void) {
void I_ShutdownSound( void )
{
int done = 0;
int i;
if ( S_initialized ) {
if( S_initialized )
{
// Stop all sounds, but don't destroy the XAudio2 buffers.
for ( i = 0; i < NUM_SOUNDBUFFERS; ++i ) {
for( i = 0; i < NUM_SOUNDBUFFERS; ++i )
{
activeSound_t* sound = &activeSounds[i];
if ( sound == NULL ) {
if( sound == NULL )
{
continue;
}
I_StopSound( sound->id, 0 );
if ( sound->m_pSourceVoice ) {
if( sound->m_pSourceVoice )
{
sound->m_pSourceVoice->FlushSourceBuffers();
}
}
for (i=1 ; i<NUMSFX ; i++) {
if ( S_sfx[i].data && !(S_sfx[i].link) ) {
for( i = 1 ; i < NUMSFX ; i++ )
{
if( S_sfx[i].data && !( S_sfx[i].link ) )
{
//Z_Free( S_sfx[i].data );
free( S_sfx[i].data );
}
@ -599,7 +655,8 @@ Called from the tech4x initialization code. Sets up Doom classic's
sound channels.
======================
*/
void I_InitSoundHardware( int numOutputChannels_, int channelMask ) {
void I_InitSoundHardware( int numOutputChannels_, int channelMask )
{
::numOutputChannels = numOutputChannels_;
// Initialize the X3DAudio
@ -608,7 +665,8 @@ void I_InitSoundHardware( int numOutputChannels_, int channelMask ) {
// SpeedOfSound - not used by doomclassic
X3DAudioInitialize( channelMask, 340.29f, X3DAudioInstance );
for ( int i = 0; i < NUM_SOUNDBUFFERS; ++i ) {
for( int i = 0; i < NUM_SOUNDBUFFERS; ++i )
{
// Initialize source voices
I_InitSoundChannel( i, numOutputChannels );
}
@ -627,26 +685,31 @@ Called from the tech4x shutdown code. Tears down Doom classic's
sound channels.
======================
*/
void I_ShutdownSoundHardware() {
void I_ShutdownSoundHardware()
{
soundHardwareInitialized = false;
I_ShutdownMusic();
for ( int i = 0; i < NUM_SOUNDBUFFERS; ++i ) {
for( int i = 0; i < NUM_SOUNDBUFFERS; ++i )
{
activeSound_t* sound = &activeSounds[i];
if ( sound == NULL ) {
if( sound == NULL )
{
continue;
}
if ( sound->m_pSourceVoice ) {
if( sound->m_pSourceVoice )
{
sound->m_pSourceVoice->Stop();
sound->m_pSourceVoice->FlushSourceBuffers();
sound->m_pSourceVoice->DestroyVoice();
sound->m_pSourceVoice = NULL;
}
if ( sound->m_DSPSettings.pMatrixCoefficients ) {
if( sound->m_DSPSettings.pMatrixCoefficients )
{
delete [] sound->m_DSPSettings.pMatrixCoefficients;
sound->m_DSPSettings.pMatrixCoefficients = NULL;
}
@ -658,7 +721,8 @@ void I_ShutdownSoundHardware() {
I_InitSoundChannel
======================
*/
void I_InitSoundChannel( int channel, int numOutputChannels_ ) {
void I_InitSoundChannel( int channel, int numOutputChannels_ )
{
activeSound_t* soundchannel = &activeSounds[ channel ];
// RB: fixed non-aggregates cannot be initialized with initializer list
@ -726,9 +790,11 @@ void I_InitSoundChannel( int channel, int numOutputChannels_ ) {
I_InitSound
======================
*/
void I_InitSound() {
void I_InitSound()
{
if (S_initialized == 0) {
if( S_initialized == 0 )
{
int i;
// RB: non-aggregates cannot be initialized with initializer list
@ -779,7 +845,8 @@ void I_SubmitSound(void)
// Only do this for player 0, it will still handle positioning
// for other players, but it can't be outside the game
// frame like the soundEvents are.
if ( DoomLib::GetPlayer() == 0 ) {
if( DoomLib::GetPlayer() == 0 )
{
// Do 3D positioning of sounds
I_UpdateSound();
@ -812,7 +879,8 @@ I_InitMusic
*/
void I_InitMusic( void )
{
if ( !Music_initialized ) {
if( !Music_initialized )
{
// Initialize Timidity
Timidity_Init( MIDI_RATE, MIDI_FORMAT, MIDI_CHANNELS, MIDI_RATE, "classicmusic/gravis.cfg" );
@ -849,27 +917,34 @@ void I_ShutdownMusic(void)
{
I_StopSong( 0 );
if ( Music_initialized ) {
if ( pMusicSourceVoice ) {
if( Music_initialized )
{
if( pMusicSourceVoice )
{
pMusicSourceVoice->Stop();
pMusicSourceVoice->FlushSourceBuffers();
pMusicSourceVoice->DestroyVoice();
pMusicSourceVoice = NULL;
}
if ( hMusicThread ) {
if( hMusicThread )
{
DWORD rc;
do {
do
{
GetExitCodeThread( hMusicThread, &rc );
if ( rc == STILL_ACTIVE ) {
if( rc == STILL_ACTIVE )
{
Sleep( 1 );
}
} while( rc == STILL_ACTIVE );
}
while( rc == STILL_ACTIVE );
CloseHandle( hMusicThread );
}
if ( musicBuffer ) {
if( musicBuffer )
{
free( musicBuffer );
}
@ -889,7 +964,8 @@ void I_ShutdownMusic(void)
int Mus2Midi( unsigned char* bytes, unsigned char* out, int* len );
namespace {
namespace
{
const int MaxMidiConversionSize = 1024 * 1024;
unsigned char midiConversionBuffer[MaxMidiConversionSize];
}
@ -899,7 +975,8 @@ namespace {
I_LoadSong
======================
*/
DWORD WINAPI I_LoadSong( LPVOID songname ) {
DWORD WINAPI I_LoadSong( LPVOID songname )
{
idStr lumpName = "d_";
lumpName += static_cast< const char* >( songname );
@ -910,7 +987,8 @@ DWORD WINAPI I_LoadSong( LPVOID songname ) {
doomMusic = Timidity_LoadSongMem( midiConversionBuffer, length );
if ( doomMusic ) {
if( doomMusic )
{
musicBuffer = ( byte* )malloc( MIDI_CHANNELS * MIDI_FORMAT_BYTES * doomMusic->samples );
totalBufferSize = doomMusic->samples * MIDI_CHANNELS * MIDI_FORMAT_BYTES;
@ -920,10 +998,12 @@ DWORD WINAPI I_LoadSong( LPVOID songname ) {
int num_bytes = 0;
int offset = 0;
do {
do
{
rc = Timidity_PlaySome( musicBuffer + offset, MIDI_RATE, &num_bytes );
offset += num_bytes;
} while ( rc != RC_TUNE_END );
}
while( rc != RC_TUNE_END );
Timidity_Stop();
Timidity_FreeSong( doomMusic );
@ -941,11 +1021,13 @@ I_PlaySong
*/
void I_PlaySong( const char* songname, int looping )
{
if ( !Music_initialized ) {
if( !Music_initialized )
{
return;
}
if ( pMusicSourceVoice != NULL ) {
if( pMusicSourceVoice != NULL )
{
// Stop the voice and flush packets before freeing the musicBuffer
pMusicSourceVoice->Stop();
pMusicSourceVoice->FlushSourceBuffers();
@ -954,21 +1036,25 @@ void I_PlaySong( const char *songname, int looping)
// Make sure voice is stopped before we free the buffer
bool isStopped = false;
int d = 0;
while ( !isStopped ) {
while( !isStopped )
{
XAUDIO2_VOICE_STATE test = {};
if ( pMusicSourceVoice != NULL ) {
if( pMusicSourceVoice != NULL )
{
pMusicSourceVoice->GetState( &test );
}
if ( test.pCurrentBufferContext == NULL && test.BuffersQueued == 0 ) {
if( test.pCurrentBufferContext == NULL && test.BuffersQueued == 0 )
{
isStopped = true;
}
//I_Printf( "waiting to stop (%d)\n", d++ );
}
// Clear old state
if ( musicBuffer != NULL ) {
if( musicBuffer != NULL )
{
free( musicBuffer );
musicBuffer = NULL;
}
@ -977,7 +1063,8 @@ void I_PlaySong( const char *songname, int looping)
I_LoadSong( ( LPVOID )songname );
waitingForMusic = true;
if ( DoomLib::GetPlayer() >= 0 ) {
if( DoomLib::GetPlayer() >= 0 )
{
::g->mus_looping = looping;
}
}
@ -987,16 +1074,21 @@ void I_PlaySong( const char *songname, int looping)
I_UpdateMusic
======================
*/
void I_UpdateMusic() {
if ( !Music_initialized ) {
void I_UpdateMusic()
{
if( !Music_initialized )
{
return;
}
if ( waitingForMusic ) {
if( waitingForMusic )
{
if ( musicReady && pMusicSourceVoice != NULL ) {
if( musicReady && pMusicSourceVoice != NULL )
{
if ( musicBuffer ) {
if( musicBuffer )
{
// Set up packet
XAUDIO2_BUFFER Packet = { 0 };
Packet.Flags = XAUDIO2_END_OF_STREAM;
@ -1011,12 +1103,14 @@ void I_UpdateMusic() {
// Submit packet
HRESULT hr;
if( FAILED( hr = pMusicSourceVoice->SubmitSourceBuffer( &Packet ) ) ) {
if( FAILED( hr = pMusicSourceVoice->SubmitSourceBuffer( &Packet ) ) )
{
int fail = 1;
}
// Play the source voice
if( FAILED( hr = pMusicSourceVoice->Start( 0 ) ) ) {
if( FAILED( hr = pMusicSourceVoice->Start( 0 ) ) )
{
int fail = 1;
}
}
@ -1025,7 +1119,8 @@ void I_UpdateMusic() {
}
}
if ( pMusicSourceVoice != NULL ) {
if( pMusicSourceVoice != NULL )
{
// Set the volume
pMusicSourceVoice->SetVolume( x_MusicVolume * GLOBAL_VOLUME_MULTIPLIER );
}
@ -1038,11 +1133,13 @@ I_PauseSong
*/
void I_PauseSong( int handle )
{
if ( !Music_initialized ) {
if( !Music_initialized )
{
return;
}
if ( pMusicSourceVoice != NULL ) {
if( pMusicSourceVoice != NULL )
{
// Stop the music source voice
pMusicSourceVoice->Stop( 0 );
}
@ -1055,12 +1152,14 @@ I_ResumeSong
*/
void I_ResumeSong( int handle )
{
if ( !Music_initialized ) {
if( !Music_initialized )
{
return;
}
// Stop the music source voice
if ( pMusicSourceVoice != NULL ) {
if( pMusicSourceVoice != NULL )
{
pMusicSourceVoice->Start( 0 );
}
}
@ -1072,12 +1171,14 @@ I_StopSong
*/
void I_StopSong( int handle )
{
if ( !Music_initialized ) {
if( !Music_initialized )
{
return;
}
// Stop the music source voice
if ( pMusicSourceVoice != NULL ) {
if( pMusicSourceVoice != NULL )
{
pMusicSourceVoice->Stop( 0 );
}
}

View file

@ -132,7 +132,8 @@ void I_Printf(const char* msg, ...)
va_list argptr;
// Message first.
if( debugOutput ) {
if( debugOutput )
{
va_start( argptr, msg );
vsprintf( pmsg, msg, argptr );
@ -149,7 +150,8 @@ void I_PrintfE(const char* msg, ...)
va_list argptr;
// Message first.
if( debugOutput ) {
if( debugOutput )
{
va_start( argptr, msg );
vsprintf( pmsg, msg, argptr );
@ -167,7 +169,8 @@ void I_Error(const char *error, ...)
va_list argptr;
// Message first.
if( debugOutput ) {
if( debugOutput )
{
va_start( argptr, error );
idStr::vsnPrintf( error_msg, ERROR_MSG_SIZE, error, argptr );

View file

@ -68,12 +68,18 @@ void I_StartFrame (void)
static void I_CombineMouseEvent( const event_t* in, event_t* out )
{
if( fabs( ( float )in->data1 ) > fabs( ( float )out->data1 ) )
{
out->data1 = in->data1;
}
if( fabs( ( float )in->data2 ) > fabs( ( float )out->data2 ) )
{
out->data2 = in->data2;
}
if( fabs( ( float )in->data3 ) > fabs( ( float )out->data3 ) )
{
out->data3 = in->data3;
}
}
void I_GetEvents( controller_t* controller )
{
@ -96,11 +102,15 @@ void I_GetEvents( controller_t *controller )
{
I_ReturnMouseInputEvent( i, &e );
if( e.type == ev_mouse )
{
I_CombineMouseEvent( &e, &e_mouse );
}
else if( e.type == ev_joystick )
{
I_CombineMouseEvent( &e, &e_joystick );
}
}
}
numEvents = I_PollJoystickInputEvents( controller );
if( numEvents )
@ -110,11 +120,16 @@ void I_GetEvents( controller_t *controller )
for( i = 0; i < numEvents; ++i )
{
I_ReturnJoystickInputEvent( i, &e );
if (e.type == ev_keydown || e.type == ev_keyup) {
if( e.type == ev_keydown || e.type == ev_keyup )
{
D_PostEvent( &e );
} else if (e.type == ev_joystick) {
}
else if( e.type == ev_joystick )
{
I_CombineMouseEvent( &e, &e_joystick );
} else if (e.type == ev_mouse) {
}
else if( e.type == ev_mouse )
{
I_CombineMouseEvent( &e, &e_mouse );
}
}
@ -149,7 +164,8 @@ void I_ReadScreen (byte* scr)
memcpy( scr, ::g->screens[0], SCREENWIDTH * SCREENHEIGHT );
}
inline unsigned int I_PackColor( unsigned int a, unsigned int r, unsigned int g, unsigned int b ) {
inline unsigned int I_PackColor( unsigned int a, unsigned int r, unsigned int g, unsigned int b )
{
unsigned int color = 0;
color |= ( r & 255 ) << 24;

File diff suppressed because it is too large Load diff

View file

@ -1166,7 +1166,8 @@ typedef struct
#ifdef _MSC_VER
actionf_p2 action;
#else
struct {
struct
{
actionf_p2 action;
// int filler;
};
@ -1181,7 +1182,8 @@ extern const state_t tempStates[NUMSTATES];
extern const char* const sprnames[NUMSPRITES + 1];
// RB end
typedef enum {
typedef enum
{
MT_PLAYER,
MT_POSSESSED,
MT_SHOTGUY,

View file

@ -49,8 +49,10 @@ int M_CheckParm (const char *check)
for( i = 1; i < ::g->myargc; i++ )
{
if( !idStr::Icmp( check, ::g->myargv[i] ) )
{
return i;
}
}
return 0;
}

View file

@ -52,14 +52,22 @@ M_AddToBox
fixed_t y )
{
if( x < box[BOXLEFT] )
{
box[BOXLEFT] = x;
}
else if( x > box[BOXRIGHT] )
{
box[BOXRIGHT] = x;
}
if( y < box[BOXBOTTOM] )
{
box[BOXBOTTOM] = y;
}
else if( y > box[BOXTOP] )
{
box[BOXTOP] = y;
}
}

View file

@ -53,36 +53,55 @@ cht_CheckCheat
if( ::g->firsttime )
{
::g->firsttime = 0;
for (i=0;i<256;i++) ::g->cheat_xlate_table[i] = SCRAMBLE(i);
for( i = 0; i < 256; i++ )
{
::g->cheat_xlate_table[i] = SCRAMBLE( i );
}
}
if( !cht->p )
{
cht->p = ::g->cheatbuffer + ::g->usedcheatbuffer;
int isize = 0;
while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize];
while( cht->sequence[isize] != 0xff )
{
cht->p[isize] = cht->sequence[isize];
}
cht->p[isize] = 0xff;
::g->usedcheatbuffer += isize;
::g->usedcheatbuffer ++;
}
if( *cht->p == 0 )
{
*( cht->p++ ) = key;
}
else if
(::g->cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++;
( ::g->cheat_xlate_table[( unsigned char )key] == *cht->p )
{
cht->p++;
}
else
{
int isize = 0;
while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize];
while( cht->sequence[isize] != 0xff )
{
cht->p[isize] = cht->sequence[isize];
}
cht->p[isize] = 0xff;
}
if( *cht->p == 1 )
{
cht->p++;
}
else if( *cht->p == 0xff ) // end of sequence character
{
int isize = 0;
while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize];
while( cht->sequence[isize] != 0xff )
{
cht->p[isize] = cht->sequence[isize];
}
cht->p[isize] = 0xff;
rc = 1;
}
@ -103,7 +122,10 @@ cht_GetParam
int isize = 0;
while(cht->sequence[isize] != 0xff) pb[isize] = cht->sequence[isize];
while( cht->sequence[isize] != 0xff )
{
pb[isize] = cht->sequence[isize];
}
pb[isize] = 0xff;
p = &pb[0];
@ -118,7 +140,9 @@ cht_GetParam
while( c && *p != 0xff );
if( *p == 0xff )
{
*buffer = 0;
}
}

View file

@ -63,7 +63,9 @@ FixedDiv
fixed_t b )
{
if( ( abs( a ) >> 14 ) >= abs( b ) )
{
return ( a ^ b ) < 0 ? MININT : MAXINT;
}
return FixedDiv2( a, b );
}
@ -85,7 +87,9 @@ FixedDiv2
c = ( ( double )a ) / ( ( double )b ) * FRACUNIT;
if( c >= 2147483648.0 || c < -2147483648.0 )
{
I_Error( "FixedDiv: divide by zero" );
}
return ( fixed_t ) c;
}

View file

@ -259,12 +259,18 @@ void M_ReadSaveStrings(void)
for( i = 0; i < load_end; i++ )
{
if( common->GetCurrentGame() == DOOM_CLASSIC ) {
if( common->GetCurrentGame() == DOOM_CLASSIC )
{
sprintf( name, "DOOM\\%s%d.dsg", SAVEGAMENAME, i );
} else {
if( DoomLib::idealExpansion == doom2 ) {
}
else
{
if( DoomLib::idealExpansion == doom2 )
{
sprintf( name, "DOOM2\\%s%d.dsg", SAVEGAMENAME, i );
} else {
}
else
{
sprintf( name, "DOOM2_NRFTL\\%s%d.dsg", SAVEGAMENAME, i );
}
@ -327,9 +333,12 @@ void M_DrawSaveLoadBorder(int x,int y)
//
void M_LoadSelect( int choice )
{
if( ::g->gamemode != commercial ) {
if( ::g->gamemode != commercial )
{
G_LoadGame( ::g->savegamepaths[ choice ] );
} else {
}
else
{
strcpy( DoomLib::loadGamePath, ::g->savegamepaths[ choice ] );
DoomLib::SetCurrentExpansion( DoomLib::idealExpansion );
DoomLib::skipToLoad = true;
@ -342,9 +351,12 @@ void M_LoadExpansion(int choice)
{
::g->exp = choice;
if( choice == 0 ) {
if( choice == 0 )
{
DoomLib::SetIdealExpansion( doom2 );
}else {
}
else
{
DoomLib::SetIdealExpansion( pack_nerve );
}
@ -363,9 +375,12 @@ void M_LoadGame (int choice)
return;
}
if (::g->gamemode == commercial) {
if( ::g->gamemode == commercial )
{
M_SetupNextMenu( &::g->LoadExpDef );
} else{
}
else
{
M_SetupNextMenu( &::g->LoadDef );
M_ReadSaveStrings();
}
@ -404,8 +419,10 @@ void M_DoSave(int slot)
// PICK QUICKSAVE SLOT YET?
if( ::g->quickSaveSlot == -2 )
{
::g->quickSaveSlot = slot;
}
}
//
// User wants to save. Start string input for M_Responder
@ -448,14 +465,17 @@ void M_SaveGame (int choice)
M_StartMessage( SAVEDEAD, NULL, false );
return;
}
else if( ::g->plyr && ::g->plyr->mo && ::g->plyr->mo->health <= 0 ) {
else if( ::g->plyr && ::g->plyr->mo && ::g->plyr->mo->health <= 0 )
{
M_StartMessage( "you can't save if you're dead!\n\npress any button", NULL, false );
return;
}
if( ::g->gamestate != GS_LEVEL )
{
return;
}
// Reset back to what expansion we are currently playing.
DoomLib::SetIdealExpansion( DoomLib::expansionSelected );
@ -488,7 +508,9 @@ void M_QuickSave(void)
}
if( ::g->gamestate != GS_LEVEL )
{
return;
}
if( ::g->quickSaveSlot < 0 )
{
@ -649,7 +671,8 @@ void M_DrawMainMenu(void)
//
// M_DrawQuit
//
void M_DrawQuit(void) {
void M_DrawQuit( void )
{
V_DrawPatchDirect( 54, 38, 0, ( patch_t* )W_CacheLumpName( "M_EXITO", PU_CACHE_SHARED ) );
}
@ -673,10 +696,14 @@ void M_NewGame(int choice)
}
if( ::g->gamemode == commercial )
{
M_SetupNextMenu( &::g->ExpDef );
}
else
{
M_SetupNextMenu( &::g->EpiDef );
}
}
//
@ -691,7 +718,9 @@ void M_DrawEpisode(void)
void M_VerifyNightmare( int ch )
{
if( ch != KEY_ENTER )
{
return;
}
G_DeferedInitNew( ( skill_t )nightmare, ::g->epi + 1, 1 );
M_ClearMenus();
@ -706,11 +735,14 @@ void M_ChooseSkill(int choice)
return;
}
*/
if ( ::g->gamemode != commercial ) {
if( ::g->gamemode != commercial )
{
static int startLevel = 1;
G_DeferedInitNew( ( skill_t )choice, ::g->epi + 1, startLevel );
M_ClearMenus();
} else {
}
else
{
DoomLib::SetCurrentExpansion( DoomLib::idealExpansion );
DoomLib::skipToNew = true;
DoomLib::chosenSkill = choice;
@ -736,9 +768,12 @@ void M_Expansion(int choice)
{
::g->exp = choice;
if( choice == 0 ) {
if( choice == 0 )
{
DoomLib::SetIdealExpansion( doom2 );
}else {
}
else
{
DoomLib::SetIdealExpansion( pack_nerve );
}
@ -758,7 +793,8 @@ char msgNames[2][9] =
"M_MSGOFF", "M_MSGON"
};
int M_GetMouseSpeedForMenu( float cvarValue ) {
int M_GetMouseSpeedForMenu( float cvarValue )
{
const float shiftedMouseSpeed = cvarValue - 0.25f;
const float normalizedMouseSpeed = shiftedMouseSpeed / ( 4.0f - 0.25 );
const float scaledMouseSpeed = normalizedMouseSpeed * 15.0f;
@ -811,9 +847,13 @@ void M_ChangeMessages(int choice)
m_show_messages.SetBool( !m_show_messages.GetBool() );
if( !m_show_messages.GetBool() )
{
::g->players[::g->consoleplayer].message = MSGOFF;
}
else
{
::g->players[::g->consoleplayer].message = MSGON ;
}
::g->message_dontfuckwithme = true;
}
@ -833,7 +873,8 @@ void M_ChangeGPad(int choice)
//
// Toggle Fullscreen
//
void M_FullScreen( int choice ) {
void M_FullScreen( int choice )
{
r_fullscreen.SetInteger( r_fullscreen.GetInteger() ? 0 : 1 );
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "vid_restart\n" );
@ -845,7 +886,9 @@ void M_FullScreen( int choice ) {
void M_EndGameResponse( int ch )
{
if( ch != KEY_ENTER )
{
return;
}
::g->currentMenu->lastOn = ::g->itemOn;
M_ClearMenus();
@ -916,7 +959,8 @@ void M_ExitGame(int choice)
common->Quit();
}
void M_CancelExit(int choice) {
void M_CancelExit( int choice )
{
M_SetupNextMenu( &::g->MainDef );
}
@ -934,12 +978,14 @@ void M_ChangeSensitivity(int choice)
switch( choice )
{
case 0:
if ( roundedMouseSpeed > 0 ) {
if( roundedMouseSpeed > 0 )
{
roundedMouseSpeed--;
}
break;
case 1:
if ( roundedMouseSpeed < 15 ) {
if( roundedMouseSpeed < 15 )
{
roundedMouseSpeed++;
}
break;
@ -1087,10 +1133,14 @@ int M_StringWidth(const char* string)
{
c = toupper( string[i] ) - HU_FONTSTART;
if( c < 0 || c >= HU_FONTSIZE )
{
w += 4;
}
else
{
w += SHORT( ::g->hu_font[c]->width );
}
}
return w;
}
@ -1109,7 +1159,9 @@ int M_StringHeight(const char* string)
h = height;
for( i = 0; i < strlen( string ); i++ )
if( string[i] == '\n' )
{
h += height;
}
return h;
}
@ -1139,7 +1191,9 @@ M_WriteText
{
c = *ch++;
if( !c )
{
break;
}
if( c == '\n' )
{
cx = x;
@ -1156,7 +1210,9 @@ M_WriteText
w = SHORT( ::g->hu_font[c]->width );
if( cx + w > SCREENWIDTH )
{
break;
}
V_DrawPatchDirect( cx, cy, 0, ::g->hu_font[c] );
cx += w;
}
@ -1256,15 +1312,17 @@ qboolean M_Responder (event_t* ev)
ch = KEY_BACKSPACE;
::g->mousewait = I_GetTime() + 15;
}
} else
if (ev->type == ev_keydown)
}
else if( ev->type == ev_keydown )
{
ch = ev->data1;
}
}
if( ch == -1 )
{
return false;
}
// Save Game string input
@ -1288,14 +1346,18 @@ qboolean M_Responder (event_t* ev)
case KEY_ENTER:
::g->saveStringEnter = 0;
if( ::g->savegamestrings[::g->saveSlot][0] )
{
M_DoSave( ::g->saveSlot );
}
break;
default:
ch = toupper( ch );
if( ch != 32 )
if( ch - HU_FONTSTART < 0 || ch - HU_FONTSTART >= HU_FONTSIZE )
{
break;
}
if( ch >= 32 && ch <= 127 &&
::g->saveCharIndex < SAVESTRINGSIZE - 1 &&
M_StringWidth( ::g->savegamestrings[::g->saveSlot] ) <
@ -1314,12 +1376,16 @@ qboolean M_Responder (event_t* ev)
{
if( ::g->messageNeedsInput == true &&
!( ch == KEY_ENTER || ch == KEY_BACKSPACE || ch == KEY_ESCAPE ) )
{
return false;
}
::g->menuactive = ::g->messageLastMenuActive;
::g->messageToPrint = 0;
if( ::g->messageRoutine )
{
::g->messageRoutine( ch );
}
S_StartSound( NULL, sfx_swtchx );
return true;
@ -1442,20 +1508,32 @@ qboolean M_Responder (event_t* ev)
do
{
if( ::g->itemOn + 1 > ::g->currentMenu->numitems - 1 )
{
::g->itemOn = 0;
else ::g->itemOn++;
}
else
{
::g->itemOn++;
}
S_StartSound( NULL, sfx_pstop );
} while(::g->currentMenu->menuitems[::g->itemOn].status==-1);
}
while( ::g->currentMenu->menuitems[::g->itemOn].status == -1 );
return true;
case KEY_UPARROW:
do
{
if( !::g->itemOn )
{
::g->itemOn = ::g->currentMenu->numitems - 1;
else ::g->itemOn--;
}
else
{
::g->itemOn--;
}
S_StartSound( NULL, sfx_pstop );
} while(::g->currentMenu->menuitems[::g->itemOn].status==-1);
}
while( ::g->currentMenu->menuitems[::g->itemOn].status == -1 );
return true;
case KEY_LEFTARROW:
@ -1502,7 +1580,9 @@ qboolean M_Responder (event_t* ev)
::g->currentMenu = ::g->currentMenu->prevMenu;
::g->itemOn = ::g->currentMenu->lastOn;
S_StartSound( NULL, sfx_swtchn );
} else if ( ::g->currentMenu == &::g->MainDef && ( !::g->demoplayback && ::g->gamestate != GS_DEMOSCREEN ) ) {
}
else if( ::g->currentMenu == &::g->MainDef && ( !::g->demoplayback && ::g->gamestate != GS_DEMOSCREEN ) )
{
M_ClearMenus();
::g->paused = false;
}
@ -1539,7 +1619,9 @@ void M_StartControlPanel (void)
{
// intro might call this repeatedly
if( ::g->menuactive )
{
return;
}
::g->menuactive = 1;
::g->currentMenu = &::g->MainDef;
@ -1593,10 +1675,14 @@ void M_Drawer (void)
if( !::g->menuactive )
{
return;
}
if( ::g->currentMenu->routine )
{
::g->currentMenu->routine(); // call Draw routine
}
// DRAW MENU
::g->md_x = ::g->currentMenu->x;

View file

@ -90,11 +90,17 @@ M_DrawText
w = SHORT( ::g->hu_font[c]->width );
if( x + w > SCREENWIDTH )
{
break;
}
if( direct )
{
V_DrawPatchDirect( x, y, 0, ::g->hu_font[c] );
}
else
{
V_DrawPatch( x, y, 0, ::g->hu_font[c] );
}
x += w;
}
@ -105,7 +111,8 @@ M_DrawText
//
// M_WriteFile
//
bool M_WriteFile ( char const* name, void* source, int length ) {
bool M_WriteFile( char const* name, void* source, int length )
{
idFile* handle = NULL;
int count;
@ -113,13 +120,17 @@ bool M_WriteFile ( char const* name, void* source, int length ) {
handle = fileSystem->OpenFileWrite( name, "fs_savepath" );
if( handle == NULL )
{
return false;
}
count = handle->Write( source, length );
fileSystem->CloseFile( handle );
if( count < length )
{
return false;
}
return true;
}
@ -128,14 +139,16 @@ bool M_WriteFile ( char const* name, void* source, int length ) {
//
// M_ReadFile
//
int M_ReadFile ( char const* name, byte** buffer ) {
int M_ReadFile( char const* name, byte** buffer )
{
int count, length;
idFile* handle = NULL;
byte* buf;
handle = fileSystem->OpenFileRead( name, false );
if (handle == NULL ) {
if( handle == NULL )
{
I_Error( "Couldn't read file %s", name );
}
@ -144,7 +157,8 @@ int M_ReadFile ( char const* name, byte** buffer ) {
buf = ( byte* )Z_Malloc( handle->Length(), PU_STATIC, NULL );
count = handle->Read( buf, length );
if (count < length ) {
if( count < length )
{
I_Error( "Couldn't read file %s", name );
}
@ -256,7 +270,9 @@ void M_LoadDefaults (void)
// set everything to base values
::g->numdefaults = sizeof( ::g->defaults ) / sizeof( ::g->defaults[0] );
for( i = 0 ; i < ::g->numdefaults ; i++ )
{
*::g->defaults[i].location = ::g->defaults[i].defaultvalue;
}
// check for a custom default file
i = M_CheckParm( "-config" );
@ -266,7 +282,9 @@ void M_LoadDefaults (void)
I_Printf( " default file: %s\n", ::g->defaultfile );
}
else
{
::g->defaultfile = ::g->basedefault;
}
/*
// read the file in, overriding any set ::g->defaults

View file

@ -34,7 +34,8 @@ If you have questions concerning this license or the applicable additional terms
// M_Random
// Returns a 0-255 number
//
const unsigned char rndtable[256] = {
const unsigned char rndtable[256] =
{
0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66 ,
74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36 ,
95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188 ,

View file

@ -35,15 +35,19 @@ If you have questions concerning this license or the applicable additional terms
// reads a variable length integer
unsigned long ReadVarLen( char* buffer ) {
unsigned long ReadVarLen( char* buffer )
{
unsigned long value;
byte c;
if ((value = *buffer++) & 0x80) {
if( ( value = *buffer++ ) & 0x80 )
{
value &= 0x7f;
do {
do
{
value = ( value << 7 ) + ( ( c = *buffer++ ) & 0x7f );
} while (c & 0x80);
}
while( c & 0x80 );
}
return value;
}
@ -54,21 +58,27 @@ int WriteVarLen( long value, byte* out )
long buffer, count = 0;
buffer = value & 0x7f;
while ((value >>= 7) > 0) {
while( ( value >>= 7 ) > 0 )
{
buffer <<= 8;
buffer += 0x80;
buffer += ( value & 0x7f );
}
while (1) {
while( 1 )
{
++count;
*out = ( byte )buffer;
++out;
if( buffer & 0x80 )
{
buffer >>= 8;
}
else
{
break;
}
}
return count;
}
@ -152,8 +162,10 @@ unsigned char MidiMap[] =
};
// The MUS data is stored in little-endian.
namespace {
unsigned short LittleToNative( const unsigned short value ) {
namespace
{
unsigned short LittleToNative( const unsigned short value )
{
return value;
}
}
@ -198,10 +210,13 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
// only 15 supported
if( header.channels > MIDI_MAXCHANNELS - 1 )
{
return 0;
}
// Map channel 15 to 9(percussions)
for (temp = 0; temp < MIDI_MAXCHANNELS; ++temp) {
for( temp = 0; temp < MIDI_MAXCHANNELS; ++temp )
{
channelMap[temp] = -1;
channel_volume[temp] = 0x40;
}
@ -235,7 +250,8 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
out = WriteByte( out, 127 );
// Main Loop
while (cur < end) {
while( cur < end )
{
byte channel;
byte event;
byte temp_buffer[32]; // temp buffer for current iterator
@ -249,7 +265,8 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
// Write variable length delta time
out_local += WriteVarLen( delta_time, out_local );
if (channelMap[channel] < 0) {
if( channelMap[channel] < 0 )
{
// Set all channels to 127 volume
out_local = WriteByte( out_local, 0xB0 + currentChannel );
out_local = WriteByte( out_local, 0x07 );
@ -258,8 +275,10 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
channelMap[channel] = currentChannel++;
if( currentChannel == 9 )
{
++currentChannel;
}
}
status = channelMap[channel];
@ -278,7 +297,9 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
status |= 0x90;
bit1 = *cur & 127;
if( *cur++ & 128 ) // volume bit?
{
channel_volume[channelMap[channel]] = *cur++;
}
bit2 = channel_volume[channelMap[channel]];
break;
case MUSEVENT_PITCHWHEEL:
@ -293,12 +314,15 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
bit2 = ( *cur++ == 12 ) ? header.channels + 1 : 0x00;
break;
case MUSEVENT_CONTROLLERCHANGE:
if (*cur == 0) {
if( *cur == 0 )
{
cur++;
status |= 0xC0;
bit1 = *cur++;
bitc = 1;
} else {
}
else
{
status |= 0xB0;
assert( *cur < sizeof( MidiMap ) / sizeof( MidiMap[0] ) );
bit1 = MidiMap[*cur++];
@ -323,7 +347,9 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
out_local = WriteByte( out_local, status );
out_local = WriteByte( out_local, bit1 );
if( bitc == 2 )
{
out_local = WriteByte( out_local, bit2 );
}
// Write out temp stuff
@ -334,12 +360,17 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
out += out_local - temp_buffer;
}
if (event & 128) {
if( event & 128 )
{
delta_time = 0;
do {
do
{
delta_time = delta_time * 128 + ( *cur & 127 );
} while ((*cur++ & 128));
} else {
}
while( ( *cur++ & 128 ) );
}
else
{
delta_time = 0;
}
}

View file

@ -118,7 +118,8 @@ void T_MoveCeiling (ceiling_t* ceiling)
{
switch( ceiling->type )
{
case silentCrushAndRaise: break;
case silentCrushAndRaise:
break;
default:
S_StartSound( &ceiling->sector->soundorg,
sfx_stnmov );
@ -201,7 +202,9 @@ EV_DoCeiling
{
sec = &::g->sectors[secnum];
if( sec->specialdata )
{
continue;
}
// new door thinker
rtn = 1;
@ -230,7 +233,9 @@ EV_DoCeiling
case lowerToFloor:
ceiling->bottomheight = sec->floorheight;
if( type != lowerToFloor )
{
ceiling->bottomheight += 8 * FRACUNIT;
}
ceiling->direction = -1;
ceiling->speed = CEILSPEED;
break;

View file

@ -209,19 +209,25 @@ EV_DoLockedDoor
p = thing->player;
if( !p )
{
return 0;
}
switch( line->special )
{
case 99: // Blue Lock
case 133:
if( !p )
{
return 0;
}
if( !p->cards[it_bluecard] && !p->cards[it_blueskull] )
{
p->message = PD_BLUEO;
if( p == &::g->players[::g->consoleplayer] )
{
S_StartSound( NULL, sfx_oof );
}
return 0;
}
break;
@ -229,12 +235,16 @@ EV_DoLockedDoor
case 134: // Red Lock
case 135:
if( !p )
{
return 0;
}
if( !p->cards[it_redcard] && !p->cards[it_redskull] )
{
p->message = PD_REDO;
if( p == &::g->players[::g->consoleplayer] )
{
S_StartSound( NULL, sfx_oof );
}
return 0;
}
break;
@ -242,13 +252,17 @@ EV_DoLockedDoor
case 136: // Yellow Lock
case 137:
if( !p )
{
return 0;
}
if( !p->cards[it_yellowcard] &&
!p->cards[it_yellowskull] )
{
p->message = PD_YELLOWO;
if( p == &::g->players[::g->consoleplayer] )
{
S_StartSound( NULL, sfx_oof );
}
return 0;
}
break;
@ -274,7 +288,9 @@ EV_DoDoor
{
sec = &::g->sectors[secnum];
if( sec->specialdata )
{
continue;
}
// new door thinker
@ -369,13 +385,17 @@ EV_VerticalDoor
case 26: // Blue Lock
case 32:
if( !player )
{
return;
}
if( !player->cards[it_bluecard] && !player->cards[it_blueskull] )
{
player->message = PD_BLUEK;
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_oof );
}
return;
}
break;
@ -383,14 +403,18 @@ EV_VerticalDoor
case 27: // Yellow Lock
case 34:
if( !player )
{
return;
}
if( !player->cards[it_yellowcard] &&
!player->cards[it_yellowskull] )
{
player->message = PD_YELLOWK;
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_oof );
}
return;
}
break;
@ -398,13 +422,17 @@ EV_VerticalDoor
case 28: // Red Lock
case 33:
if( !player )
{
return;
}
if( !player->cards[it_redcard] && !player->cards[it_redskull] )
{
player->message = PD_REDK;
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_oof );
}
return;
}
break;
@ -425,11 +453,15 @@ EV_VerticalDoor
case 28:
case 117:
if( door->direction == -1 )
{
door->direction = 1; // go back up
}
else
{
if( !thing->player )
{
return; // JDC: bad guys never close doors
}
door->direction = -1; // start going down immediately
}
@ -438,7 +470,8 @@ EV_VerticalDoor
}
// for proper sound
if (globalNetworking || (player == &::g->players[::g->consoleplayer])) {
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
switch( line->special )
{
case 117: // BLAZING DOOR RAISE

File diff suppressed because it is too large Load diff

View file

@ -121,7 +121,9 @@ T_MovePlane
if( flag == true )
{
if( crush == true )
{
return crushed;
}
sector->floorheight = lastpos;
P_ChangeSector( sector, crush );
return crushed;
@ -161,7 +163,9 @@ T_MovePlane
if( flag == true )
{
if( crush == true )
{
return crushed;
}
sector->ceilingheight = lastpos;
P_ChangeSector( sector, crush );
return crushed;
@ -280,7 +284,9 @@ EV_DoFloor
// ALREADY MOVING? IF SO, KEEP GOING...
if( sec->specialdata )
{
continue;
}
// new floor thinker
rtn = 1;
@ -316,7 +322,9 @@ EV_DoFloor
floor->floordestheight =
P_FindHighestFloorSurrounding( sec );
if( floor->floordestheight != sec->floorheight )
{
floor->floordestheight += 8 * FRACUNIT;
}
break;
case raiseFloorCrush:
@ -328,7 +336,9 @@ EV_DoFloor
floor->floordestheight =
P_FindLowestCeilingSurrounding( sec );
if( floor->floordestheight > sec->ceilingheight )
{
floor->floordestheight = sec->ceilingheight;
}
floor->floordestheight -= ( 8 * FRACUNIT ) *
( floortype == raiseFloorCrush );
break;
@ -483,7 +493,9 @@ EV_BuildStairs
// ALREADY MOVING? IF SO, KEEP GOING...
if( sec->specialdata )
{
continue;
}
// new floor thinker
rtn = 1;
@ -519,24 +531,32 @@ EV_BuildStairs
for( i = 0; i < sec->linecount; i++ )
{
if( !( ( sec->lines[i] )->flags & ML_TWOSIDED ) )
{
continue;
}
tsec = ( sec->lines[i] )->frontsector;
newsecnum = tsec -::g->sectors;
if( secnum != newsecnum )
{
continue;
}
tsec = ( sec->lines[i] )->backsector;
newsecnum = tsec - ::g->sectors;
if( tsec->floorpic != texture )
{
continue;
}
height += stairsize;
if( tsec->specialdata )
{
continue;
}
sec = tsec;
secnum = newsecnum;
@ -553,7 +573,8 @@ EV_BuildStairs
ok = 1;
break;
}
} while(ok);
}
while( ok );
}
return rtn;
}

View file

@ -83,18 +83,28 @@ P_GiveAmmo
int oldammo;
if( ammo == am_noammo )
{
return false;
}
if( ammo < 0 || ammo > NUMAMMO )
{
I_Error( "P_GiveAmmo: bad type %i", ammo );
}
if( player->ammo[ammo] == player->maxammo[ammo] )
{
return false;
}
if( num )
{
num *= clipammo[ammo];
}
else
{
num = clipammo[ammo] / 2;
}
if( ::g->gameskill == sk_baby
|| ::g->gameskill == sk_nightmare )
@ -109,13 +119,17 @@ P_GiveAmmo
player->ammo[ammo] += num;
if( player->ammo[ammo] > player->maxammo[ammo] )
{
player->ammo[ammo] = player->maxammo[ammo];
}
// If non zero ammo,
// don't change up weapons,
// player was lower on purpose.
if( oldammo )
{
return true;
}
// We were down to zero,
// so select a new weapon.
@ -126,10 +140,14 @@ P_GiveAmmo
if( player->readyweapon == wp_fist )
{
if( player->weaponowned[wp_chaingun] )
{
player->pendingweapon = wp_chaingun;
}
else
{
player->pendingweapon = wp_pistol;
}
}
break;
case am_shell:
@ -137,8 +155,10 @@ P_GiveAmmo
|| player->readyweapon == wp_pistol )
{
if( player->weaponowned[wp_shotgun] )
{
player->pendingweapon = wp_shotgun;
}
}
break;
case am_cell:
@ -146,16 +166,20 @@ P_GiveAmmo
|| player->readyweapon == wp_pistol )
{
if( player->weaponowned[wp_plasma] )
{
player->pendingweapon = wp_plasma;
}
}
break;
case am_misl:
if( player->readyweapon == wp_fist )
{
if( player->weaponowned[wp_missile] )
{
player->pendingweapon = wp_missile;
}
}
default:
break;
}
@ -183,19 +207,27 @@ P_GiveWeapon
{
// leave placed weapons forever on net games
if( player->weaponowned[weapon] )
{
return false;
}
player->bonuscount += BONUSADD;
player->weaponowned[weapon] = true;
if( ::g->deathmatch )
{
P_GiveAmmo( player, weaponinfo[weapon].ammo, 5 );
}
else
{
P_GiveAmmo( player, weaponinfo[weapon].ammo, 2 );
}
player->pendingweapon = weapon;
if( player == &::g->players[::g->consoleplayer] )
{
S_StartSound( player->mo, sfx_wpnup );
}
return false;
}
@ -204,15 +236,23 @@ P_GiveWeapon
// give one clip with a dropped weapon,
// two clips with a found weapon
if( dropped )
{
gaveammo = P_GiveAmmo( player, weaponinfo[weapon].ammo, 1 );
else
gaveammo = P_GiveAmmo (player, weaponinfo[weapon].ammo, 2);
}
else
{
gaveammo = P_GiveAmmo( player, weaponinfo[weapon].ammo, 2 );
}
}
else
{
gaveammo = false;
}
if( player->weaponowned[weapon] )
{
gaveweapon = false;
}
else
{
gaveweapon = true;
@ -235,11 +275,15 @@ P_GiveBody
int num )
{
if( player->health >= MAXHEALTH )
{
return false;
}
player->health += num;
if( player->health > MAXHEALTH )
{
player->health = MAXHEALTH;
}
player->mo->health = player->health;
return true;
@ -261,7 +305,9 @@ P_GiveArmor
hits = armortype * 100;
if( player->armorpoints >= hits )
{
return false; // don't pick up
}
player->armortype = armortype;
player->armorpoints = hits;
@ -274,24 +320,34 @@ P_GiveArmor
//
// P_GiveCard
//
void P_GiveCard( player_t* player, card_t card, const char *pickup_message ) {
void P_GiveCard( player_t* player, card_t card, const char* pickup_message )
{
if ( ( ::g->demoplayback && ::g->netgame ) || common->IsMultiplayer() ) {
for ( int i=0; i < MAXPLAYERS; i++ ) {
if ( ::g->playeringame[i] ) {
if( ( ::g->demoplayback && ::g->netgame ) || common->IsMultiplayer() )
{
for( int i = 0; i < MAXPLAYERS; i++ )
{
if( ::g->playeringame[i] )
{
player_t* thePlayer = &::g->players[i];
if( thePlayer->cards[card] )
{
continue;
}
thePlayer->bonuscount = BONUSADD;
thePlayer->message = pickup_message;
thePlayer->cards[card] = 1;
}
}
} else {
}
else
{
if( player->cards[card] )
{
return;
}
player->bonuscount = BONUSADD;
player->message = pickup_message;
@ -341,7 +397,9 @@ P_GivePower
}
if( player->powers[power] )
{
return false; // already got it
}
player->powers[power] = 1;
return true;
@ -378,7 +436,9 @@ P_TouchSpecialThing
// Dead thing touching.
// Can happen with a sliding player corpse.
if( toucher->health <= 0 )
{
return;
}
// Identify by sprite.
switch( special->sprite )
@ -386,13 +446,17 @@ P_TouchSpecialThing
// armor
case SPR_ARM1:
if( !P_GiveArmor( player, 1 ) )
{
return;
}
player->message = GOTARMOR;
break;
case SPR_ARM2:
if( !P_GiveArmor( player, 2 ) )
{
return;
}
player->message = GOTMEGA;
break;
@ -400,7 +464,9 @@ P_TouchSpecialThing
case SPR_BON1:
player->health++; // can go over 100%
if( player->health > 200 )
{
player->health = 200;
}
player->mo->health = player->health;
player->message = GOTHTHBONUS;
break;
@ -408,16 +474,22 @@ P_TouchSpecialThing
case SPR_BON2:
player->armorpoints++; // can go over 100%
if( player->armorpoints > 200 )
{
player->armorpoints = 200;
}
if( !player->armortype )
{
player->armortype = 1;
}
player->message = GOTARMBONUS;
break;
case SPR_SOUL:
player->health += 100;
if( player->health > 200 )
{
player->health = 200;
}
player->mo->health = player->health;
player->message = GOTSUPER;
sound = sfx_getpow;
@ -425,7 +497,9 @@ P_TouchSpecialThing
case SPR_MEGA:
if( ::g->gamemode != commercial )
{
return;
}
player->health = 200;
player->mo->health = player->health;
P_GiveArmor( player, 2 );
@ -440,7 +514,9 @@ P_TouchSpecialThing
//player->message = GOTBLUECARD;
P_GiveCard( player, it_bluecard, GOTBLUECARD );
if( !::g->netgame )
{
break;
}
return;
case SPR_YKEY:
@ -448,7 +524,9 @@ P_TouchSpecialThing
//player->message = GOTYELWCARD;
P_GiveCard( player, it_yellowcard, GOTYELWCARD );
if( !::g->netgame )
{
break;
}
return;
case SPR_RKEY:
@ -456,7 +534,9 @@ P_TouchSpecialThing
//player->message = GOTREDCARD;
P_GiveCard( player, it_redcard, GOTREDCARD );
if( !::g->netgame )
{
break;
}
return;
case SPR_BSKU:
@ -464,7 +544,9 @@ P_TouchSpecialThing
//player->message = GOTBLUESKUL;
P_GiveCard( player, it_blueskull, GOTBLUESKUL );
if( !::g->netgame )
{
break;
}
return;
case SPR_YSKU:
@ -472,7 +554,9 @@ P_TouchSpecialThing
//player->message = GOTYELWSKUL;
P_GiveCard( player, it_yellowskull, GOTYELWSKUL );
if( !::g->netgame )
{
break;
}
return;
case SPR_RSKU:
@ -480,68 +564,92 @@ P_TouchSpecialThing
//player->message = GOTREDSKULL;
P_GiveCard( player, it_redskull, GOTREDSKULL );
if( !::g->netgame )
{
break;
}
return;
// medikits, heals
case SPR_STIM:
if( !P_GiveBody( player, 10 ) )
{
return;
}
player->message = GOTSTIM;
break;
case SPR_MEDI:
if( !P_GiveBody( player, 25 ) )
{
return;
}
if( player->health < 25 )
{
player->message = GOTMEDINEED;
}
else
{
player->message = GOTMEDIKIT;
}
break;
// power ups
case SPR_PINV:
if( !P_GivePower( player, pw_invulnerability ) )
{
return;
}
player->message = GOTINVUL;
sound = sfx_getpow;
break;
case SPR_PSTR:
if( !P_GivePower( player, pw_strength ) )
{
return;
}
player->message = GOTBERSERK;
if( player->readyweapon != wp_fist )
{
player->pendingweapon = wp_fist;
}
sound = sfx_getpow;
break;
case SPR_PINS:
if( !P_GivePower( player, pw_invisibility ) )
{
return;
}
player->message = GOTINVIS;
sound = sfx_getpow;
break;
case SPR_SUIT:
if( !P_GivePower( player, pw_ironfeet ) )
{
return;
}
player->message = GOTSUIT;
sound = sfx_getpow;
break;
case SPR_PMAP:
if( !P_GivePower( player, pw_allmap ) )
{
return;
}
player->message = GOTMAP;
sound = sfx_getpow;
break;
case SPR_PVIS:
if( !P_GivePower( player, pw_infrared ) )
{
return;
}
player->message = GOTVISOR;
sound = sfx_getpow;
break;
@ -551,55 +659,73 @@ P_TouchSpecialThing
if( special->flags & MF_DROPPED )
{
if( !P_GiveAmmo( player, am_clip, 0 ) )
{
return;
}
}
else
{
if( !P_GiveAmmo( player, am_clip, 1 ) )
{
return;
}
}
player->message = GOTCLIP;
break;
case SPR_AMMO:
if( !P_GiveAmmo( player, am_clip, 5 ) )
{
return;
}
player->message = GOTCLIPBOX;
break;
case SPR_ROCK:
if( !P_GiveAmmo( player, am_misl, 1 ) )
{
return;
}
player->message = GOTROCKET;
break;
case SPR_BROK:
if( !P_GiveAmmo( player, am_misl, 5 ) )
{
return;
}
player->message = GOTROCKBOX;
break;
case SPR_CELL:
if( !P_GiveAmmo( player, am_cell, 1 ) )
{
return;
}
player->message = GOTCELL;
break;
case SPR_CELP:
if( !P_GiveAmmo( player, am_cell, 5 ) )
{
return;
}
player->message = GOTCELLBOX;
break;
case SPR_SHEL:
if( !P_GiveAmmo( player, am_shell, 1 ) )
{
return;
}
player->message = GOTSHELLS;
break;
case SPR_SBOX:
if( !P_GiveAmmo( player, am_shell, 5 ) )
{
return;
}
player->message = GOTSHELLBOX;
break;
@ -607,26 +733,36 @@ P_TouchSpecialThing
if( !player->backpack )
{
for( i = 0 ; i < NUMAMMO ; i++ )
{
player->maxammo[i] *= 2;
}
player->backpack = true;
}
for( i = 0 ; i < NUMAMMO ; i++ )
{
P_GiveAmmo( player, ( ammotype_t )i, 1 );
}
player->message = GOTBACKPACK;
break;
// weapons
case SPR_BFUG:
if( !P_GiveWeapon( player, wp_bfg, false ) )
{
return;
}
// DHM - Nerve :: Give achievement
if ( !common->IsMultiplayer() ) {
switch( DoomLib::GetGameSKU() ) {
case GAME_SKU_DOOM2_BFG: {
if( !common->IsMultiplayer() )
{
switch( DoomLib::GetGameSKU() )
{
case GAME_SKU_DOOM2_BFG:
{
idAchievementManager::LocalUser_CompleteAchievement( ACHIEVEMENT_DOOM2_REALLY_BIG_GUN_FIND_BFG_SINGLEPLAYER );
}
default: {
default:
{
// No unlocks for other SKUs.
break;
}
@ -639,42 +775,54 @@ P_TouchSpecialThing
case SPR_MGUN:
if( !P_GiveWeapon( player, wp_chaingun, special->flags & MF_DROPPED ) )
{
return;
}
player->message = GOTCHAINGUN;
sound = sfx_wpnup;
break;
case SPR_CSAW:
if( !P_GiveWeapon( player, wp_chainsaw, false ) )
{
return;
}
player->message = GOTCHAINSAW;
sound = sfx_wpnup;
break;
case SPR_LAUN:
if( !P_GiveWeapon( player, wp_missile, false ) )
{
return;
}
player->message = GOTLAUNCHER;
sound = sfx_wpnup;
break;
case SPR_PLAS:
if( !P_GiveWeapon( player, wp_plasma, false ) )
{
return;
}
player->message = GOTPLASMA;
sound = sfx_wpnup;
break;
case SPR_SHOT:
if( !P_GiveWeapon( player, wp_shotgun, special->flags & MF_DROPPED ) )
{
return;
}
player->message = GOTSHOTGUN;
sound = sfx_wpnup;
break;
case SPR_SGN2:
if( !P_GiveWeapon( player, wp_supershotgun, special->flags & MF_DROPPED ) )
{
return;
}
player->message = GOTSHOTGUN2;
sound = sfx_wpnup;
@ -685,12 +833,16 @@ P_TouchSpecialThing
}
if( special->flags & MF_COUNTITEM )
{
player->itemcount++;
}
P_RemoveMobj( special );
player->bonuscount += BONUSADD;
if( player == &::g->players[::g->consoleplayer] )
{
S_StartSound( player->mo, sound );
}
}
//
// IsOnlineDeathmatchWithLocalProfile
@ -698,28 +850,34 @@ P_TouchSpecialThing
// Helper to simplify the online frag stat tracking. Returns the
// master user's profile if successful, NULL if not.
//
idPlayerProfile * IsOnlineDeathmatchWithLocalProfile() {
if ( !MatchTypeIsOnline( session->GetGameLobbyBase().GetMatchParms().matchFlags ) ) {
idPlayerProfile* IsOnlineDeathmatchWithLocalProfile()
{
if( !MatchTypeIsOnline( session->GetGameLobbyBase().GetMatchParms().matchFlags ) )
{
return NULL;
}
if ( !::g ) {
if( !::g )
{
return NULL;
}
if ( !::g->deathmatch ) {
if( !::g->deathmatch )
{
return NULL;
}
// Assume that the master local user is the one playing.
idLocalUser* user = session->GetSignInManager().GetMasterLocalUser();
if ( user == NULL ) {
if( user == NULL )
{
return NULL;
}
idPlayerProfile* profile = user->GetProfile();
if ( profile == NULL ) {
if( profile == NULL )
{
return NULL;
}
@ -740,7 +898,9 @@ P_KillMobj
target->flags &= ~( MF_SHOOTABLE | MF_FLOAT | MF_SKULLFLY );
if( target->type != MT_SKULL )
{
target->flags &= ~MF_NOGRAVITY;
}
target->flags |= MF_CORPSE | MF_DROPOFF;
target->height >>= 2;
@ -749,15 +909,19 @@ P_KillMobj
{
// count for intermission
if( target->flags & MF_COUNTKILL )
{
source->player->killcount++;
}
if (target->player) {
if( target->player )
{
source->player->frags[target->player -::g->players]++;
// Keep track of the local player's total frags for trophy awards.
// Make sure the killing player is the local player
if ( source->player == &(::g->players[::g->consoleplayer]) ) {
if( source->player == &( ::g->players[::g->consoleplayer] ) )
{
// Make sure this is an online game.
// TODO: PC
}
@ -766,19 +930,24 @@ P_KillMobj
// DHM - Nerve :: Check for killing cyberdemon with fists achievement
// JAF TROPHY int port = gameLocal->GetPortForPlayer( DoomLib::GetPlayer() );
if ( source->player->readyweapon == wp_fist && target->type == MT_CYBORG && !common->IsMultiplayer() ) {
switch( DoomLib::GetGameSKU() ) {
case GAME_SKU_DOOM2_BFG: {
if( source->player->readyweapon == wp_fist && target->type == MT_CYBORG && !common->IsMultiplayer() )
{
switch( DoomLib::GetGameSKU() )
{
case GAME_SKU_DOOM2_BFG:
{
// Removing trophies for DOOM and DOOM II BFG due to point limit.
//gameLocal->UnlockAchievement( Doom2BFG_Trophies::YOU_HAVE_HUGE_GUTS_KILL_CYBERDEMON_WITH_FISTS );
break;
}
case GAME_SKU_DCC: {
case GAME_SKU_DCC:
{
// Not for PC.
//session->GetAchievementSystem().AchievementUnlock( session->GetSignInManager().GetMasterLocalUser(), DOOM_ACHIEVEMENT_KILL_CYBER_DEMON_WITH_FISTS );
break;
}
default: {
default:
{
// No unlocks for other SKUs.
break;
}
@ -786,21 +955,27 @@ P_KillMobj
}
// DHM - Nerve :: Chainsaw kills
if ( source->player->readyweapon == wp_chainsaw && !common->IsMultiplayer() ) {
if( source->player->readyweapon == wp_chainsaw && !common->IsMultiplayer() )
{
source->player->chainsawKills++;
if ( source->player->chainsawKills == 20 ) {
switch( DoomLib::GetGameSKU() ) {
case GAME_SKU_DOOM2_BFG: {
if( source->player->chainsawKills == 20 )
{
switch( DoomLib::GetGameSKU() )
{
case GAME_SKU_DOOM2_BFG:
{
// Removing trophies for DOOM and DOOM II BFG due to point limit.
//gameLocal->UnlockAchievement( Doom2BFG_Trophies::GREAT_COMMUNICATOR_20_CHAINSAW_KILLS );
break;
}
case GAME_SKU_DCC: {
case GAME_SKU_DCC:
{
// Not for PC.
//gameLocal->UnlockAchievement( DOOM_ACHIEVEMENT_20KILLS_CHAINSAW );
break;
}
default: {
default:
{
// No unlocks for other SKUs.
break;
}
@ -809,22 +984,28 @@ P_KillMobj
}
// DHM - Nerve :: Berserker kills
if ( source->player->readyweapon == wp_fist && source->player->powers[pw_strength] && !common->IsMultiplayer()) {
if( source->player->readyweapon == wp_fist && source->player->powers[pw_strength] && !common->IsMultiplayer() )
{
source->player->berserkKills++;
idLib::Printf( "Player has %d berserk kills\n", source->player->berserkKills );
if ( source->player->berserkKills == 20 ) {
switch( DoomLib::GetGameSKU() ) {
case GAME_SKU_DOOM2_BFG: {
if( source->player->berserkKills == 20 )
{
switch( DoomLib::GetGameSKU() )
{
case GAME_SKU_DOOM2_BFG:
{
// Removing trophies for DOOM and DOOM II BFG due to point limit.
//gameLocal->UnlockAchievement( Doom2BFG_Trophies::MAN_AND_A_HALF_20_BERSERK_KILLS );
break;
}
case GAME_SKU_DCC: {
case GAME_SKU_DCC:
{
// Not for PC.
//gameLocal->UnlockAchievement( DOOM_ACHIEVEMENT_20KILLS_BERSERKER );
break;
}
default: {
default:
{
// No unlocks for other SKUs.
break;
}
@ -843,7 +1024,9 @@ P_KillMobj
{
// count environment kills against you
if( !source )
{
target->player->frags[target->player -::g->players]++;
}
target->flags &= ~MF_SOLID;
target->player->playerstate = PST_DEAD;
@ -865,11 +1048,15 @@ P_KillMobj
P_SetMobjState( target, ( statenum_t )target->info->xdeathstate );
}
else
{
P_SetMobjState( target, ( statenum_t )target->info->deathstate );
}
target->tics -= P_Random() & 3;
if( target->tics < 1 )
{
target->tics = 1;
}
// I_StartSound (&actor->r, actor->info->deathsound);
@ -928,10 +1115,14 @@ P_DamageMobj
int temp;
if( !( target->flags & MF_SHOOTABLE ) )
{
return; // shouldn't happen...
}
if( target->health <= 0 )
{
return;
}
if( target->flags & MF_SKULLFLY )
{
@ -940,7 +1131,9 @@ P_DamageMobj
player = target->player;
if( player && ::g->gameskill == sk_baby )
{
damage >>= 1; // take half damage in trainer mode
}
// Some close combat weapons should not
@ -994,7 +1187,8 @@ P_DamageMobj
float additional = 0.5f * damageFloat;
int additional_time = 500.0f * damageFloat;
if( ::g->plyr == player ) {
if( ::g->plyr == player )
{
}
@ -1011,9 +1205,13 @@ P_DamageMobj
if( player->armortype )
{
if( player->armortype == 1 )
{
saved = damage / 3;
}
else
{
saved = damage / 2;
}
if( player->armorpoints <= saved )
{
@ -1026,13 +1224,17 @@ P_DamageMobj
}
player->health -= damage; // mirror mobj health here for Dave
if( player->health < 0 )
{
player->health = 0;
}
player->attacker = source;
player->damagecount += damage; // add damage after armor / invuln
if( player->damagecount > 100 )
{
player->damagecount = 100; // teleport stomp does 10k points...
}
temp = damage < 100 ? damage : 100;
}
@ -1065,8 +1267,10 @@ P_DamageMobj
target->threshold = BASETHRESHOLD;
if( target->state == &::g->states[target->info->spawnstate]
&& target->info->seestate != S_NULL )
{
P_SetMobjState( target, ( statenum_t )target->info->seestate );
}
}
}

View file

@ -52,14 +52,20 @@ void T_FireFlicker (fireflicker_t* flick)
int amount;
if( --flick->count )
{
return;
}
amount = ( P_Random() & 3 ) * 16;
if( flick->sector->lightlevel - amount < flick->minlight )
{
flick->sector->lightlevel = flick->minlight;
}
else
{
flick->sector->lightlevel = flick->maxlight - amount;
}
flick->count = 4;
}
@ -102,7 +108,9 @@ void P_SpawnFireFlicker (sector_t* sector)
void T_LightFlash( lightflash_t* flash )
{
if( --flash->count )
{
return;
}
if( flash->sector->lightlevel == flash->maxlight )
{
@ -159,7 +167,9 @@ void P_SpawnLightFlash (sector_t* sector)
void T_StrobeFlash( strobe_t* flash )
{
if( --flash->count )
{
return;
}
if( flash->sector->lightlevel == flash->minlight )
{
@ -201,16 +211,22 @@ P_SpawnStrobeFlash
flash->minlight = P_FindMinSurroundingLight( sector, sector->lightlevel );
if( flash->minlight == flash->maxlight )
{
flash->minlight = 0;
}
// nothing special about it during gameplay
sector->special = 0;
if( !inSync )
{
flash->count = ( P_Random() & 7 ) + 1;
}
else
{
flash->count = 1;
}
}
//
@ -226,7 +242,9 @@ void EV_StartLightStrobing(line_t* line)
{
sec = &::g->sectors[secnum];
if( sec->specialdata )
{
continue;
}
P_SpawnStrobeFlash( sec, SLOWDARK, 0 );
}
@ -258,10 +276,14 @@ void EV_TurnTagLightsOff(line_t* line)
templine = sector->lines[i];
tsec = getNextSector( templine, sector );
if( !tsec )
{
continue;
}
if( tsec->lightlevel < min )
{
min = tsec->lightlevel;
}
}
sector->lightlevel = min;
}
}
@ -299,12 +321,16 @@ EV_LightTurnOn
temp = getNextSector( templine, sector );
if( !temp )
{
continue;
}
if( temp->lightlevel > bright )
{
bright = temp->lightlevel;
}
}
}
sector-> lightlevel = bright;
}
}

View file

@ -151,7 +151,8 @@ typedef struct
{
fixed_t frac; // along trace line
qboolean isaline;
union {
union
{
mobj_t* thing;
line_t* line;
} d;

View file

@ -74,7 +74,9 @@ qboolean PIT_StompThing (mobj_t* thing)
fixed_t blockdist;
if( !( thing->flags & MF_SHOOTABLE ) )
{
return true;
}
blockdist = thing->radius + ::g->tmthing->radius;
@ -87,11 +89,15 @@ qboolean PIT_StompThing (mobj_t* thing)
// don't clip against self
if( thing == ::g->tmthing )
{
return true;
}
// monsters don't stomp things except on boss level
if( !::g->tmthing->player && ::g->gamemap != 30 )
{
return false;
}
P_DamageMobj( thing, ::g->tmthing, ::g->tmthing, 10000 );
@ -151,7 +157,9 @@ P_TeleportMove
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
@ -183,10 +191,14 @@ qboolean PIT_CheckLine (line_t* ld)
|| ::g->tmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT]
|| ::g->tmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM]
|| ::g->tmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP] )
{
return true;
}
if( P_BoxOnLineSide( ::g->tmbbox, ld ) != -1 )
{
return true;
}
// A line has been hit
@ -200,16 +212,22 @@ qboolean PIT_CheckLine (line_t* ld)
// could be crossed in either order.
if( !ld->backsector )
{
return false; // one sided line
}
if( !( ::g->tmthing->flags & MF_MISSILE ) )
{
if( ld->flags & ML_BLOCKING )
{
return false; // explicitly blocking everything
}
if( !::g->tmthing->player && ld->flags & ML_BLOCKMONSTERS )
{
return false; // block monsters only
}
}
// set ::g->openrange, ::g->opentop, ::g->openbottom
P_LineOpening( ld );
@ -222,10 +240,14 @@ qboolean PIT_CheckLine (line_t* ld)
}
if( ::g->openbottom > ::g->tmfloorz )
{
::g->tmfloorz = ::g->openbottom;
}
if( ::g->lowfloor < ::g->tmdropoffz )
{
::g->tmdropoffz = ::g->lowfloor;
}
// if contacted a special line, add it to the list
if( ld->special && ::g->numspechit < MAXSPECIALCROSS )
@ -247,7 +269,9 @@ qboolean PIT_CheckThing (mobj_t* thing)
int damage;
if( !( thing->flags & ( MF_SOLID | MF_SPECIAL | MF_SHOOTABLE ) ) )
{
return true;
}
blockdist = thing->radius + ::g->tmthing->radius;
@ -260,7 +284,9 @@ qboolean PIT_CheckThing (mobj_t* thing)
// don't clip against self
if( thing == ::g->tmthing )
{
return true;
}
// check for skulls slamming into things
if( ::g->tmthing->flags & MF_SKULLFLY )
@ -283,9 +309,13 @@ qboolean PIT_CheckThing (mobj_t* thing)
{
// see if it went over / under
if( ::g->tmthing->z > thing->z + thing->height )
{
return true; // overhead
}
if( ::g->tmthing->z +::g->tmthing->height < thing->z )
{
return true; // underneath
}
if( ::g->tmthing->target && (
::g->tmthing->target->type == thing->type ||
@ -294,7 +324,9 @@ qboolean PIT_CheckThing (mobj_t* thing)
{
// Don't hit same species as originator.
if( thing == ::g->tmthing->target )
{
return true;
}
if( thing->type != MT_PLAYER )
{
@ -401,7 +433,9 @@ P_CheckPosition
::g->numspechit = 0;
if( ::g->tmflags & MF_NOCLIP )
{
return true;
}
// Check things first, possibly picking things up.
// The bounding box is extended by MAXRADIUS
@ -416,7 +450,9 @@ P_CheckPosition
for( bx = xl ; bx <= xh ; bx++ )
for( by = yl ; by <= yh ; by++ )
if( !P_BlockThingsIterator( bx, by, PIT_CheckThing ) )
{
return false;
}
// check ::g->lines
xl = ( ::g->tmbbox[BOXLEFT] - ::g->bmaporgx ) >> MAPBLOCKSHIFT;
@ -427,7 +463,9 @@ P_CheckPosition
for( bx = xl ; bx <= xh ; bx++ )
for( by = yl ; by <= yh ; by++ )
if( !P_BlockLinesIterator( bx, by, PIT_CheckLine ) )
{
return false;
}
return true;
}
@ -452,27 +490,37 @@ P_TryMove
::g->floatok = false;
if( !P_CheckPosition( thing, x, y ) )
{
return false; // solid wall or thing
}
if( !( thing->flags & MF_NOCLIP ) )
{
if( ::g->tmceilingz - ::g->tmfloorz < thing->height )
{
return false; // doesn't fit
}
::g->floatok = true;
if( !( thing->flags & MF_TELEPORT )
&&::g->tmceilingz - thing->z < thing->height )
{
return false; // mobj must lower itself to fit
}
if( !( thing->flags & MF_TELEPORT )
&& ::g->tmfloorz - thing->z > 24 * FRACUNIT )
{
return false; // too big a step up
}
if( !( thing->flags & ( MF_DROPOFF | MF_FLOAT ) )
&& ::g->tmfloorz - ::g->tmdropoffz > 24 * FRACUNIT )
{
return false; // don't stand over a dropoff
}
}
// the move is ok,
// so link the thing into its new position
@ -499,10 +547,12 @@ P_TryMove
if( side != oldside )
{
if( ld->special )
{
P_CrossSpecialLine( ld -::g->lines, oldside, thing );
}
}
}
}
return true;
}
@ -539,11 +589,15 @@ qboolean P_ThingHeightClip (mobj_t* thing)
{
// don't adjust a floating monster unless forced to
if( thing->z + thing->height > thing->ceilingz )
{
thing->z = thing->ceilingz - thing->height;
}
}
if( thing->ceilingz - thing->floorz < thing->height )
{
return false;
}
return true;
}
@ -594,13 +648,17 @@ void P_HitSlideLine (line_t* ld)
lineangle = R_PointToAngle2( 0, 0, ld->dx, ld->dy );
if( side == 1 )
{
lineangle += ANG180;
}
moveangle = R_PointToAngle2( 0, 0, ::g->tmxmove, ::g->tmymove );
deltaangle = moveangle - lineangle;
if( deltaangle > ANG180 )
{
deltaangle += ANG180;
}
// I_Error ("SlideLine: ang>ANG180");
lineangle >>= ANGLETOFINESHIFT;
@ -622,7 +680,9 @@ qboolean PTR_SlideTraverse (intercept_t* in)
line_t* li;
if( !in->isaline )
{
I_Error( "PTR_SlideTraverse: not a line?" );
}
li = in->d.line;
@ -640,13 +700,19 @@ qboolean PTR_SlideTraverse (intercept_t* in)
P_LineOpening( li );
if( ::g->openrange < ::g->slidemo->height )
{
goto isblocking; // doesn't fit
}
if( ::g->opentop - ::g->slidemo->z < ::g->slidemo->height )
{
goto isblocking; // mobj is too high
}
if( ::g->openbottom - ::g->slidemo->z > 24 * FRACUNIT )
{
goto isblocking; // too big a step up
}
// this line doesn't block movement
return true;
@ -691,7 +757,9 @@ void P_SlideMove (mobj_t* mo)
retry:
if( ++hitcount == 3 )
{
goto stairstep; // don't loop forever
}
// ::g->trace along the three leading corners
@ -732,7 +800,9 @@ void P_SlideMove (mobj_t* mo)
// 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;
}
@ -744,18 +814,24 @@ void P_SlideMove (mobj_t* mo)
newy = FixedMul( mo->momy, ::g->bestslidefrac );
if( !P_TryMove( mo, mo->x + newx, mo->y + newy ) )
{
goto stairstep;
}
}
// Now continue along the wall.
// First calculate remainder.
::g->bestslidefrac = FRACUNIT - ( ::g->bestslidefrac + 0x800 );
if( ::g->bestslidefrac > FRACUNIT )
{
::g->bestslidefrac = FRACUNIT;
}
if( ::g->bestslidefrac <= 0 )
{
return;
}
::g->tmxmove = FixedMul( mo->momx, ::g->bestslidefrac );
::g->tmymove = FixedMul( mo->momy, ::g->bestslidefrac );
@ -803,7 +879,9 @@ PTR_AimTraverse (intercept_t* in)
li = in->d.line;
if( !( li->flags & ML_TWOSIDED ) )
{
return false; // stop
}
// Crosses a two sided line.
// A two sided line will restrict
@ -811,7 +889,9 @@ PTR_AimTraverse (intercept_t* in)
P_LineOpening( li );
if( ::g->openbottom >= ::g->opentop )
{
return false; // stop
}
dist = FixedMul( ::g->attackrange, in->frac );
@ -819,18 +899,24 @@ PTR_AimTraverse (intercept_t* in)
{
slope = FixedDiv( ::g->openbottom - ::g->shootz , dist );
if( slope > ::g->bottomslope )
{
::g->bottomslope = slope;
}
}
if( li->frontsector->ceilingheight != li->backsector->ceilingheight )
{
slope = FixedDiv( ::g->opentop - ::g->shootz , dist );
if( slope < ::g->topslope )
{
::g->topslope = slope;
}
}
if( ::g->topslope <= ::g->bottomslope )
{
return false; // stop
}
return true; // shot continues
}
@ -838,29 +924,41 @@ PTR_AimTraverse (intercept_t* in)
// shoot a thing
th = in->d.thing;
if( th == ::g->shootthing )
{
return true; // can't shoot self
}
if( !( th->flags & MF_SHOOTABLE ) )
{
return true; // corpse or something
}
// check angles to see if the thing can be aimed at
dist = FixedMul( ::g->attackrange, in->frac );
thingtopslope = FixedDiv( th->z + th->height - ::g->shootz , dist );
if( thingtopslope < ::g->bottomslope )
{
return true; // shot over the thing
}
thingbottomslope = FixedDiv( th->z - ::g->shootz, dist );
if( thingbottomslope > ::g->topslope )
{
return true; // shot under the thing
}
// this thing can be hit!
if( thingtopslope > ::g->topslope )
{
thingtopslope = ::g->topslope;
}
if( thingbottomslope < ::g->bottomslope )
{
thingbottomslope = ::g->bottomslope;
}
::g->aimslope = ( thingtopslope + thingbottomslope ) / 2;
::g->linetarget = th;
@ -893,10 +991,14 @@ qboolean PTR_ShootTraverse (intercept_t* in)
li = in->d.line;
if( li->special )
{
P_ShootSpecialLine( ::g->shootthing, li );
}
if( !( li->flags & ML_TWOSIDED ) )
{
goto hitline;
}
// crosses a two sided line
P_LineOpening( li );
@ -907,15 +1009,19 @@ qboolean PTR_ShootTraverse (intercept_t* in)
{
slope = FixedDiv( ::g->openbottom - ::g->shootz , dist );
if( slope > ::g->aimslope )
{
goto hitline;
}
}
if( li->frontsector->ceilingheight != li->backsector->ceilingheight )
{
slope = FixedDiv( ::g->opentop - ::g->shootz , dist );
if( slope < ::g->aimslope )
{
goto hitline;
}
}
// shot continues
return true;
@ -933,20 +1039,27 @@ qboolean PTR_ShootTraverse (intercept_t* in)
{
// don't shoot the sky!
if( z > li->frontsector->ceilingheight )
return false;
// it's a sky hack wall
if (li->backsector && li->backsector->ceilingpic == ::g->skyflatnum)
{
return false;
}
mobj_t * sourceObject = ::g->shootthing;
if( sourceObject ) {
// it's a sky hack wall
if( li->backsector && li->backsector->ceilingpic == ::g->skyflatnum )
{
return false;
}
}
if( ( sourceObject->player) == &(::g->players[DoomLib::GetPlayer()]) ) {
mobj_t* sourceObject = ::g->shootthing;
if( sourceObject )
{
if( ( sourceObject->player ) == &( ::g->players[DoomLib::GetPlayer()] ) )
{
// Fist Punch.
if( ::g->attackrange == MELEERANGE ) {
if( ::g->attackrange == MELEERANGE )
{
}
}
}
@ -961,22 +1074,30 @@ qboolean PTR_ShootTraverse (intercept_t* in)
// shoot a thing
th = in->d.thing;
if( th == ::g->shootthing )
{
return true; // can't shoot self
}
if( !( th->flags & MF_SHOOTABLE ) )
{
return true; // corpse or something
}
// check angles to see if the thing can be aimed at
dist = FixedMul( ::g->attackrange, in->frac );
thingtopslope = FixedDiv( th->z + th->height - ::g->shootz , dist );
if( thingtopslope < ::g->aimslope )
{
return true; // shot over the thing
}
thingbottomslope = FixedDiv( th->z - ::g->shootz, dist );
if( thingbottomslope > ::g->aimslope )
{
return true; // shot under the thing
}
// hit thing
@ -989,17 +1110,21 @@ qboolean PTR_ShootTraverse (intercept_t* in)
// check for friendly fire.
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
if( th && gameLocal->GetMatchParms().GetGameType() != GAME_TYPE_PVP ) {
if( th && gameLocal->GetMatchParms().GetGameType() != GAME_TYPE_PVP )
{
player_t* hitPlayer = th->player;
if( hitPlayer ) {
if( hitPlayer )
{
mobj_t* sourceObject = ::g->shootthing;
if( sourceObject ) {
if( sourceObject )
{
player_t* sourcePlayer = sourceObject->player;
if( sourcePlayer != NULL && sourcePlayer != hitPlayer && !gameLocal->GetMatchParms().AllowFriendlyFire() ) {
if( sourcePlayer != NULL && sourcePlayer != hitPlayer && !gameLocal->GetMatchParms().AllowFriendlyFire() )
{
return true;
}
}
@ -1008,12 +1133,15 @@ qboolean PTR_ShootTraverse (intercept_t* in)
#endif
mobj_t* sourceObject = ::g->shootthing;
if( sourceObject ) {
if( sourceObject )
{
if( ( sourceObject->player) == &(::g->players[DoomLib::GetPlayer()]) ) {
if( ( sourceObject->player ) == &( ::g->players[DoomLib::GetPlayer()] ) )
{
// Fist Punch.
if( ::g->attackrange == MELEERANGE ) {
if( ::g->attackrange == MELEERANGE )
{
}
}
}
@ -1022,12 +1150,18 @@ qboolean PTR_ShootTraverse (intercept_t* in)
// Spawn bullet puffs or blod spots,
// depending on target type.
if( in->d.thing->flags & MF_NOBLOOD )
{
P_SpawnPuff( x, y, z );
}
else
{
P_SpawnBlood( x, y, z, ::g->la_damage );
}
if( ::g->la_damage )
{
P_DamageMobj( th, ::g->shootthing, ::g->shootthing, ::g->la_damage );
}
// don't go any farther
return false;
@ -1067,7 +1201,9 @@ P_AimLineAttack
PTR_AimTraverse );
if( ::g->linetarget )
{
return ::g->aimslope;
}
return 0;
}
@ -1130,7 +1266,9 @@ qboolean PTR_UseTraverse (intercept_t* in)
side = 0;
if( P_PointOnLineSide( ::g->usething->x, ::g->usething->y, in->d.line ) == 1 )
{
side = 1;
}
// return false; // don't use back side
@ -1183,13 +1321,17 @@ qboolean PIT_RadiusAttack (mobj_t* thing)
fixed_t dist;
if( !( thing->flags & MF_SHOOTABLE ) )
{
return true;
}
// Boss spider and cyborg
// take no damage from concussion.
if( thing->type == MT_CYBORG
|| thing->type == MT_SPIDER )
{
return true;
}
dx = abs( thing->x - ::g->bombspot->x );
dy = abs( thing->y - ::g->bombspot->y );
@ -1198,10 +1340,14 @@ qboolean PIT_RadiusAttack (mobj_t* thing)
dist = ( dist - thing->radius ) >> FRACBITS;
if( dist < 0 )
{
dist = 0;
}
if( dist >= ::g->bombdamage )
{
return true; // out of range
}
if( P_CheckSight( thing, ::g->bombspot ) )
{
@ -1244,8 +1390,10 @@ P_RadiusAttack
for( y = yl ; y <= yh ; y++ )
for( x = xl ; x <= xh ; x++ )
{
P_BlockThingsIterator( x, y, PIT_RadiusAttack );
}
}
@ -1344,7 +1492,9 @@ P_ChangeSector
// re-check 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 ::g->nofit;

View file

@ -55,7 +55,9 @@ P_AproxDistance
dx = abs( dx );
dy = abs( dy );
if( dx < dy )
{
return dx + dy - ( dx >> 1 );
}
return dx + dy - ( dy >> 1 );
}
@ -78,14 +80,18 @@ P_PointOnLineSide
if( !line->dx )
{
if( x <= line->v1->x )
{
return line->dy > 0;
}
return line->dy < 0;
}
if( !line->dy )
{
if( y <= line->v1->y )
{
return line->dx < 0;
}
return line->dx > 0;
}
@ -97,7 +103,9 @@ P_PointOnLineSide
right = FixedMul( dy , line->dx >> FRACBITS );
if( right < left )
{
return 0; // front side
}
return 1; // back side
}
@ -150,7 +158,9 @@ P_BoxOnLineSide
}
if( p1 == p2 )
{
return p1;
}
return -1;
}
@ -173,14 +183,18 @@ P_PointOnDivlineSide
if( !line->dx )
{
if( x <= line->x )
{
return line->dy > 0;
}
return line->dy < 0;
}
if( !line->dy )
{
if( y <= line->y )
{
return line->dx < 0;
}
return line->dx > 0;
}
@ -192,7 +206,9 @@ P_PointOnDivlineSide
if( ( line->dy ^ line->dx ^ dx ^ dy ) & 0x80000000 )
{
if( ( line->dy ^ dx ) & 0x80000000 )
{
return 1; // (left is negative)
}
return 0;
}
@ -200,7 +216,9 @@ P_PointOnDivlineSide
right = FixedMul( dy >> 8 , line->dx >> 8 );
if( right < left )
{
return 0; // front side
}
return 1; // back side
}
@ -242,7 +260,9 @@ P_InterceptVector
den = FixedMul( v1->dy >> 8, v2->dx ) - FixedMul( v1->dx >> 8, v2->dy );
if( den == 0 )
{
return 0;
}
// I_Error ("P_InterceptVector: parallel");
num =
@ -277,7 +297,9 @@ P_InterceptVector
den = v1dy * v2dx - v1dx * v2dy;
if( den == 0 )
{
return 0; // parallel
}
num = ( v1x - v2x ) * v1dy + ( v2y - v1y ) * v1dx;
frac = num / den;
@ -311,9 +333,13 @@ void P_LineOpening (line_t* maputil_linedef)
back = maputil_linedef->backsector;
if( front->ceilingheight < back->ceilingheight )
{
::g->opentop = front->ceilingheight;
}
else
{
::g->opentop = back->ceilingheight;
}
if( front->floorheight > back->floorheight )
{
@ -352,23 +378,33 @@ void P_UnsetThingPosition (mobj_t* thing)
// inert things don't need to be in blockmap?
// unlink from subsector
if( thing->snext )
{
thing->snext->sprev = thing->sprev;
}
if( thing->sprev )
{
thing->sprev->snext = thing->snext;
}
else
{
thing->subsector->sector->thinglist = thing->snext;
}
}
if( !( thing->flags & MF_NOBLOCKMAP ) )
{
// inert things don't need to be in ::g->blockmap
// unlink from block map
if( thing->bnext )
{
thing->bnext->bprev = thing->bprev;
}
if( thing->bprev )
{
thing->bprev->bnext = thing->bnext;
}
else
{
blockx = ( thing->x - ::g->bmaporgx ) >> MAPBLOCKSHIFT;
@ -413,7 +449,9 @@ P_SetThingPosition (mobj_t* thing)
thing->snext = sec->thinglist;
if( sec->thinglist )
{
sec->thinglist->sprev = thing;
}
sec->thinglist = thing;
}
@ -435,7 +473,9 @@ P_SetThingPosition (mobj_t* thing)
thing->bprev = NULL;
thing->bnext = *link;
if( *link )
{
( *link )->bprev = thing;
}
*link = thing;
}
@ -493,13 +533,17 @@ P_BlockLinesIterator
ld = &::g->lines[*list];
if( ld->validcount == ::g->validcount )
{
continue; // line has already been checked
}
ld->validcount = ::g->validcount;
if( !func( ld ) )
{
return false;
}
}
return true; // everything was checked
}
@ -529,8 +573,10 @@ P_BlockThingsIterator
mobj = mobj->bnext )
{
if( !func( mobj ) )
{
return false;
}
}
return true;
}
@ -575,14 +621,18 @@ PIT_AddLineIntercepts (line_t* ld)
}
if( s1 == s2 )
{
return true; // line isn't crossed
}
// hit the line
P_MakeDivline( ld, &dl );
frac = P_InterceptVector( &::g->trace, &dl );
if( frac < 0 )
{
return true; // behind source
}
// try to early out the check
if( ::g->earlyout
@ -646,7 +696,9 @@ qboolean PIT_AddThingIntercepts (mobj_t* thing)
s2 = P_PointOnDivlineSide( x2, y2, &::g->trace );
if( s1 == s2 )
{
return true; // line isn't crossed
}
dl.x = x1;
dl.y = y1;
@ -656,7 +708,9 @@ qboolean PIT_AddThingIntercepts (mobj_t* thing)
frac = P_InterceptVector( &::g->trace, &dl );
if( frac < 0 )
{
return true; // behind source
}
::g->intercept_p->frac = frac;
::g->intercept_p->isaline = false;
@ -699,7 +753,9 @@ P_TraverseIntercepts
}
if( dist > maxfrac )
{
return true; // checked everything in range
}
#if 0 // UNUSED
{
@ -707,14 +763,18 @@ P_TraverseIntercepts
in = scan = ::g->intercepts;
for( scan = ::g->intercepts ; scan <::g->intercept_p ; scan++ )
if( scan->frac > maxfrac )
{
*in++ = *scan;
}
::g->intercept_p = in;
return false;
}
#endif
if( !func( in ) )
{
return false; // don't bother going farther
}
in->frac = MAXINT;
}
@ -768,10 +828,14 @@ P_PathTraverse
::g->intercept_p = ::g->intercepts;
if( ( ( x1 -::g->bmaporgx ) & ( MAPBLOCKSIZE - 1 ) ) == 0 )
{
x1 += FRACUNIT; // don't side exactly on a line
}
if( ( ( y1 -::g->bmaporgy ) & ( MAPBLOCKSIZE - 1 ) ) == 0 )
{
y1 += FRACUNIT; // don't side exactly on a line
}
::g->trace.x = x1;
::g->trace.y = y1;
@ -841,14 +905,18 @@ P_PathTraverse
if( flags & PT_ADDLINES )
{
if( !P_BlockLinesIterator( mapx, mapy, PIT_AddLineIntercepts ) )
{
return false; // early out
}
}
if( flags & PT_ADDTHINGS )
{
if( !P_BlockThingsIterator( mapx, mapy, PIT_AddThingIntercepts ) )
{
return false; // early out
}
}
if( mapx == xt2
&& mapy == yt2 )

View file

@ -80,10 +80,13 @@ P_SetMobjState
// Modified handling.
// Call action functions when the state is set
if( st->action )
{
st->action( mobj, NULL );
}
state = st->nextstate;
} while (!mobj->tics);
}
while( !mobj->tics );
return true;
}
@ -101,13 +104,17 @@ void P_ExplodeMissile (mobj_t* mo)
mo->tics -= P_Random() & 3;
if( mo->tics < 1 )
{
mo->tics = 1;
}
mo->flags &= ~MF_MISSILE;
if( mo->info->deathsound )
{
S_StartSound( mo, mo->info->deathsound );
}
}
//
@ -138,14 +145,22 @@ void P_XYMovement (mobj_t* mo)
player = mo->player;
if( mo->momx > MAXMOVE )
{
mo->momx = MAXMOVE;
}
else if( mo->momx < -MAXMOVE )
{
mo->momx = -MAXMOVE;
}
if( mo->momy > MAXMOVE )
{
mo->momy = MAXMOVE;
}
else if( mo->momy < -MAXMOVE )
{
mo->momy = -MAXMOVE;
}
xmove = mo->momx;
ymove = mo->momy;
@ -170,7 +185,8 @@ void P_XYMovement (mobj_t* mo)
{
// blocked move
if( mo->player )
{ // try to slide along it
{
// try to slide along it
P_SlideMove( mo );
}
else if( mo->flags & MF_MISSILE )
@ -189,9 +205,12 @@ void P_XYMovement (mobj_t* mo)
P_ExplodeMissile( mo );
}
else
{
mo->momx = mo->momy = 0;
}
} while (xmove || ymove);
}
}
while( xmove || ymove );
// slow down
if( player && player->cheats & CF_NOMOMENTUM )
@ -202,10 +221,14 @@ void P_XYMovement (mobj_t* mo)
}
if( mo->flags & ( MF_MISSILE | MF_SKULLFLY ) )
{
return; // no friction for missiles ever
}
if( mo->z > mo->floorz )
{
return; // no friction when airborne
}
if( mo->flags & MF_CORPSE )
{
@ -217,9 +240,11 @@ void P_XYMovement (mobj_t* mo)
|| mo->momy < -FRACUNIT / 4 )
{
if( mo->floorz != mo->subsector->sector->floorheight )
{
return;
}
}
}
if( mo->momx > -STOPSPEED
&& mo->momx < STOPSPEED
@ -231,7 +256,9 @@ void P_XYMovement (mobj_t* mo)
{
// if in a walking frame, stop moving
if( player && ( unsigned )( ( player->mo->state - ::g->states ) - S_PLAY_RUN1 ) < 4 )
{
P_SetMobjState( player->mo, S_PLAY );
}
mo->momx = 0;
mo->momy = 0;
@ -276,10 +303,14 @@ void P_ZMovement (mobj_t* mo)
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;
}
}
}
@ -308,8 +339,10 @@ void P_ZMovement (mobj_t* mo)
// and utter appropriate sound.
mo->player->deltaviewheight = mo->momz >> 3;
if( globalNetworking || ( mo->player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( mo, sfx_oof );
}
}
mo->momz = 0;
}
mo->z = mo->floorz;
@ -324,22 +357,29 @@ void P_ZMovement (mobj_t* mo)
else if( !( mo->flags & MF_NOGRAVITY ) )
{
if( mo->momz == 0 )
{
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;
}
if( mo->flags & MF_SKULLFLY )
{ // the skull slammed into something
{
// the skull slammed into something
mo->momz = -mo->momz;
}
@ -372,7 +412,9 @@ P_NightmareRespawn (mobj_t* mobj)
// somthing is occupying it's position?
if( !P_CheckPosition( mobj, x, y ) )
{
return; // no respwan
}
// spawn a teleport fog at old spot
// because of removal of the body?
@ -394,9 +436,13 @@ P_NightmareRespawn (mobj_t* mobj)
// spawn it
if( mobj->info->flags & MF_SPAWNCEILING )
{
z = ONCEILINGZ;
}
else
{
z = ONFLOORZ;
}
// inherit attributes from deceased one
mo = P_SpawnMobj( x, y, z, mobj->type );
@ -404,7 +450,9 @@ P_NightmareRespawn (mobj_t* mobj)
mo->angle = ANG45 * ( mthing->angle / 45 );
if( mthing->options & MTF_AMBUSH )
{
mo->flags |= MF_AMBUSH;
}
mo->reactiontime = 18;
@ -427,8 +475,10 @@ void P_MobjThinker (mobj_t* mobj)
// FIXME: decent NOP/NULL/Nil function pointer please.
if( mobj->thinker.function.acv == ( actionf_v )( -1 ) )
{
return; // mobj was removed
}
}
if( ( mobj->z != mobj->floorz )
|| mobj->momz )
{
@ -436,8 +486,10 @@ void P_MobjThinker (mobj_t* mobj)
// FIXME: decent NOP/NULL/Nil function pointer please.
if( mobj->thinker.function.acv == ( actionf_v )( -1 ) )
{
return; // mobj was removed
}
}
// cycle through states,
@ -449,27 +501,39 @@ void P_MobjThinker (mobj_t* mobj)
// you can cycle through multiple states in a tic
if( !mobj->tics )
if( !P_SetMobjState( mobj, mobj->state->nextstate ) )
{
return; // freed itself
}
}
else
{
// check for nightmare respawn
if( !( mobj->flags & MF_COUNTKILL ) )
{
return;
}
if( !::g->respawnmonsters )
{
return;
}
mobj->movecount++;
if( mobj->movecount < 12 * TICRATE )
{
return;
}
if( ::g->leveltime & 31 )
{
return;
}
if( P_Random() > 4 )
{
return;
}
P_NightmareRespawn( mobj );
}
@ -505,7 +569,9 @@ P_SpawnMobj
mobj->health = info->spawnhealth;
if( ::g->gameskill != sk_nightmare )
{
mobj->reactiontime = info->reactiontime;
}
mobj->lastlook = P_Random() % MAXPLAYERS;
// do not set the state with P_SetMobjState,
@ -524,11 +590,17 @@ P_SpawnMobj
mobj->ceilingz = mobj->subsector->sector->ceilingheight;
if( z == ONFLOORZ )
{
mobj->z = mobj->floorz;
}
else if( z == ONCEILINGZ )
{
mobj->z = mobj->ceilingz - mobj->info->height;
}
else
{
mobj->z = z;
}
mobj->thinker.function.acp1 = ( actionf_p1 )P_MobjThinker;
@ -556,8 +628,10 @@ void P_RemoveMobj (mobj_t* mobj)
// lose one off the end?
if( ::g->iquehead == ::g->iquetail )
{
::g->iquetail = ( ::g->iquetail + 1 ) & ( ITEMQUESIZE - 1 );
}
}
// unlink from sector and block lists
P_UnsetThingPosition( mobj );
@ -589,15 +663,21 @@ void P_RespawnSpecials (void)
// only respawn items in ::g->deathmatch
if( ::g->deathmatch != 2 )
{
return; //
}
// nothing left to respawn?
if( ::g->iquehead == ::g->iquetail )
{
return;
}
// wait at least 30 seconds
if( ::g->leveltime - ::g->itemrespawntime[::g->iquetail] < 30 * TICRATE )
{
return;
}
mthing = &::g->itemrespawnque[::g->iquetail];
@ -613,14 +693,20 @@ void P_RespawnSpecials (void)
for( i = 0 ; i < NUMMOBJTYPES ; i++ )
{
if( mthing->type == mobjinfo[i].doomednum )
{
break;
}
}
// spawn it
if( mobjinfo[i].flags & MF_SPAWNCEILING )
{
z = ONCEILINGZ;
}
else
{
z = ONFLOORZ;
}
mo = ( mobj_t* )P_SpawnMobj( x, y, z, ( mobjtype_t )i );
mo->spawnpoint = *mthing;
@ -652,12 +738,16 @@ void P_SpawnPlayer (mapthing_t* mthing)
// not playing?
if( !::g->playeringame[mthing->type - 1] )
{
return;
}
p = &::g->players[mthing->type - 1];
if( p->playerstate == PST_REBORN )
{
G_PlayerReborn( mthing->type - 1 );
}
x = mthing->x << FRACBITS;
y = mthing->y << FRACBITS;
@ -666,7 +756,9 @@ void P_SpawnPlayer (mapthing_t* mthing)
// set color translations for player ::g->sprites
if( mthing->type > 1 )
{
mobj->flags |= ( mthing->type - 1 ) << MF_TRANSSHIFT;
}
mobj->angle = ANG45 * ( mthing->angle / 45 );
mobj->player = p;
@ -688,7 +780,9 @@ void P_SpawnPlayer (mapthing_t* mthing)
// give all cards in death match mode
if( ::g->deathmatch )
for( i = 0 ; i < NUMCARDS ; i++ )
{
p->cards[i] = true;
}
if( mthing->type - 1 == ::g->consoleplayer )
{
@ -699,20 +793,27 @@ void P_SpawnPlayer (mapthing_t* mthing)
}
// Give him everything is Give All is on.
if( p->cheats & CF_GIVEALL ) {
if( p->cheats & CF_GIVEALL )
{
p->armorpoints = 200;
p->armortype = 2;
int i;
for( i = 0; i < NUMWEAPONS; i++ )
{
p->weaponowned[i] = true;
}
for( i = 0; i < NUMAMMO; i++ )
{
p->ammo[i] = p->maxammo[i];
}
for( i = 0; i < NUMCARDS; i++ )
{
p->cards[i] = true;
}
}
}
@ -748,31 +849,46 @@ void P_SpawnMapThing (mapthing_t* mthing)
// save spots for respawning in network games
::g->playerstarts[mthing->type - 1] = *mthing;
if( !::g->deathmatch )
{
P_SpawnPlayer( mthing );
}
return;
}
// check for apropriate skill level
if( !::g->netgame && ( mthing->options & 16 ) )
{
return;
}
if( ::g->gameskill == sk_baby )
{
bit = 1;
}
else if( ::g->gameskill == sk_nightmare )
{
bit = 4;
}
else
{
bit = 1 << ( ::g->gameskill - 1 );
}
if( !( mthing->options & bit ) )
{
return;
}
// find which type to spawn
for( i = 0 ; i < NUMMOBJTYPES ; i++ )
if( mthing->type == mobjinfo[i].doomednum )
{
break;
}
if ( i==NUMMOBJTYPES ) {
if( i == NUMMOBJTYPES )
{
//printf( "P_SpawnMapThing: Unknown type %i at (%i, %i)", mthing->type, mthing->x, mthing->y);
return;
//I_Error ("P_SpawnMapThing: Unknown type %i at (%i, %i)",
@ -782,7 +898,9 @@ void P_SpawnMapThing (mapthing_t* mthing)
// don't spawn keycards and ::g->players in ::g->deathmatch
if( ::g->deathmatch && mobjinfo[i].flags & MF_NOTDMATCH )
{
return;
}
// don't spawn any monsters if -::g->nomonsters
if( ::g->nomonsters
@ -797,24 +915,36 @@ void P_SpawnMapThing (mapthing_t* mthing)
y = mthing->y << FRACBITS;
if( mobjinfo[i].flags & MF_SPAWNCEILING )
{
z = ONCEILINGZ;
}
else
{
z = ONFLOORZ;
}
mobj = ( mobj_t* )P_SpawnMobj( x, y, z, ( mobjtype_t )i );
mobj->spawnpoint = *mthing;
if( mobj->tics > 0 )
{
mobj->tics = 1 + ( P_Random() % mobj->tics );
}
if( mobj->flags & MF_COUNTKILL )
{
::g->totalkills++;
}
if( mobj->flags & MF_COUNTITEM )
{
::g->totalitems++;
}
mobj->angle = ANG45 * ( mthing->angle / 45 );
if( mthing->options & MTF_AMBUSH )
{
mobj->flags |= MF_AMBUSH;
}
}
@ -842,10 +972,13 @@ P_SpawnPuff
th->tics -= P_Random() & 3;
if( th->tics < 1 )
{
th->tics = 1;
}
// don't make punches spark on the wall
if (::g->attackrange == MELEERANGE) {
if( ::g->attackrange == MELEERANGE )
{
P_SetMobjState( th, S_PUFF3 );
@ -872,13 +1005,19 @@ P_SpawnBlood
th->tics -= P_Random() & 3;
if( th->tics < 1 )
{
th->tics = 1;
}
if( damage <= 12 && damage >= 9 )
{
P_SetMobjState( th, S_BLOOD2 );
}
else if( damage < 9 )
{
P_SetMobjState( th, S_BLOOD3 );
}
}
@ -891,7 +1030,9 @@ void P_CheckMissileSpawn (mobj_t* th)
{
th->tics -= P_Random() & 3;
if( th->tics < 1 )
{
th->tics = 1;
}
// move a little forward so an angle can
// be computed if it immediately explodes
@ -900,8 +1041,10 @@ void P_CheckMissileSpawn (mobj_t* th)
th->z += ( th->momz >> 1 );
if( !P_TryMove( th, th->x, th->y ) )
{
P_ExplodeMissile( th );
}
}
//
@ -922,14 +1065,18 @@ P_SpawnMissile
source->z + 4 * 8 * FRACUNIT, type );
if( th->info->seesound )
{
S_StartSound( th, th->info->seesound );
}
th->target = source; // where it came from
an = R_PointToAngle2( source->x, source->y, dest->x, dest->y );
// fuzzy player
if( dest->flags & MF_SHADOW )
{
an += ( P_Random() - P_Random() ) << 20;
}
th->angle = an;
an >>= ANGLETOFINESHIFT;
@ -940,7 +1087,9 @@ P_SpawnMissile
dist = dist / th->info->speed;
if( dist < 1 )
{
dist = 1;
}
th->momz = ( dest->z - source->z ) / dist;
P_CheckMissileSpawn( th );
@ -994,7 +1143,8 @@ P_SpawnPlayerMissile
th = P_SpawnMobj( x, y, z, type );
if (th->info->seesound && (source->player == &::g->players[::g->consoleplayer]) ) {
if( th->info->seesound && ( source->player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( th, th->info->seesound );
}

View file

@ -124,9 +124,13 @@ void T_PlatRaise(plat_t* plat)
if( !--plat->count )
{
if( plat->sector->floorheight == plat->low )
{
plat->status = up;
}
else
{
plat->status = down;
}
S_StartSound( &plat->sector->soundorg, sfx_pstart );
}
case in_stasis:
@ -170,7 +174,9 @@ EV_DoPlat
sec = &::g->sectors[secnum];
if( sec->specialdata )
{
continue;
}
// Find lowest & highest floors around sector
rtn = 1;
@ -213,7 +219,9 @@ EV_DoPlat
plat->low = P_FindLowestFloorSurrounding( sec );
if( plat->low > sec->floorheight )
{
plat->low = sec->floorheight;
}
plat->high = sec->floorheight;
plat->wait = TICRATE * PLATWAIT;
@ -226,7 +234,9 @@ EV_DoPlat
plat->low = P_FindLowestFloorSurrounding( sec );
if( plat->low > sec->floorheight )
{
plat->low = sec->floorheight;
}
plat->high = sec->floorheight;
plat->wait = TICRATE * PLATWAIT;
@ -239,12 +249,16 @@ EV_DoPlat
plat->low = P_FindLowestFloorSurrounding( sec );
if( plat->low > sec->floorheight )
{
plat->low = sec->floorheight;
}
plat->high = P_FindHighestFloorSurrounding( sec );
if( plat->high < sec->floorheight )
{
plat->high = sec->floorheight;
}
plat->wait = TICRATE * PLATWAIT;
plat->status = ( plat_e )( P_Random() & 1 );

View file

@ -139,12 +139,15 @@ P_SetPsprite
{
state->action( player, psp );
if( !psp->state )
{
break;
}
}
stnum = psp->state->nextstate;
} while (!psp->tics);
}
while( !psp->tics );
// an initial state of 0 could cycle through
}
@ -185,10 +188,14 @@ void P_BringUpWeapon (player_t* player)
statenum_t newstate;
if( player->pendingweapon == wp_nochange )
{
player->pendingweapon = player->readyweapon;
}
if( player->pendingweapon == wp_chainsaw && ( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) )
{
S_StartSound( player->mo, sfx_sawup );
}
newstate = ( statenum_t )( weaponinfo[player->pendingweapon].upstate );
@ -212,16 +219,24 @@ qboolean P_CheckAmmo (player_t* player)
// Minimal amount for one shot varies.
if( player->readyweapon == wp_bfg )
{
count = BFGCELLS;
}
else if( player->readyweapon == wp_supershotgun )
{
count = 2; // Double barrel.
}
else
{
count = 1; // Regular.
}
// Some do not need ammunition anyway.
// Return if current ammunition sufficient.
if( ammo == am_noammo || player->ammo[ammo] >= count )
{
return true;
}
// Out of ammo, pick a weapon to change to.
// Preferences are set here.
@ -274,7 +289,8 @@ qboolean P_CheckAmmo (player_t* player)
player->pendingweapon = wp_fist;
}
} while (player->pendingweapon == wp_nochange);
}
while( player->pendingweapon == wp_nochange );
// Now set appropriate weapon overlay.
P_SetPsprite( player,
@ -293,7 +309,9 @@ void P_FireWeapon (player_t* player)
statenum_t newstate;
if( !P_CheckAmmo( player ) )
{
return;
}
P_SetMobjState( player->mo, S_PLAY_ATK1 );
newstate = ( statenum_t )weaponinfo[player->readyweapon].atkstate;
@ -302,7 +320,8 @@ void P_FireWeapon (player_t* player)
if( player->readyweapon == wp_chainsaw )
{
if( ::g->plyr == player ) {
if( ::g->plyr == player )
{
}
}
@ -350,8 +369,10 @@ A_WeaponReady
&& psp->state == &::g->states[S_SAW] )
{
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_sawidl );
}
}
// check for change
// if player is dead, put the weapon away
@ -378,7 +399,9 @@ A_WeaponReady
}
}
else
{
player->attackdown = false;
}
// bob the weapon based on movement speed
angle = ( 128 *::g->leveltime )&FINEMASK;
@ -424,7 +447,9 @@ A_CheckReload
P_CheckAmmo( player );
#if 0
if( player->ammo[am_shell] < 2 )
{
P_SetPsprite( player, ps_weapon, S_DSNR1 );
}
#endif
}
@ -444,7 +469,9 @@ A_Lower
// Is already down.
if( psp->sy < WEAPONBOTTOM )
{
return;
}
// Player is dead.
if( player->playerstate == PST_DEAD )
@ -483,7 +510,9 @@ A_Raise
psp->sy -= RAISESPEED;
if( psp->sy > WEAPONTOP )
{
return;
}
psp->sy = WEAPONTOP;
@ -530,7 +559,9 @@ A_Punch
damage = ( P_Random() % 10 + 1 ) << 1;
if( player->powers[pw_strength] )
{
damage *= 10;
}
angle = player->mo->angle;
angle += ( P_Random() - P_Random() ) << 18;
@ -572,11 +603,15 @@ A_Saw
if( !::g->linetarget )
{
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_sawful );
}
return;
}
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_sawhit );
}
// turn to face target
angle = R_PointToAngle2( player->mo->x, player->mo->y,
@ -584,17 +619,25 @@ A_Saw
if( angle - player->mo->angle > ANG180 )
{
if( angle - player->mo->angle < -ANG90 / 20 )
{
player->mo->angle = angle + ANG90 / 21;
}
else
{
player->mo->angle -= ANG90 / 20;
}
}
else
{
if( angle - player->mo->angle > ANG90 / 20 )
{
player->mo->angle = angle - ANG90 / 21;
}
else
{
player->mo->angle += ANG90 / 20;
}
}
player->mo->flags |= MF_JUSTATTACKED;
}
@ -608,12 +651,14 @@ A_FireMissile
( player_t* player,
pspdef_t* psp )
{
if( (player->cheats & CF_INFAMMO) == false ) {
if( ( player->cheats & CF_INFAMMO ) == false )
{
player->ammo[weaponinfo[player->readyweapon].ammo]--;
}
P_SpawnPlayerMissile( player->mo, MT_ROCKET );
if( ::g->plyr == player ) {
if( ::g->plyr == player )
{
}
}
@ -627,13 +672,15 @@ A_FireBFG
( player_t* player,
pspdef_t* psp )
{
if( (player->cheats & CF_INFAMMO) == false ) {
if( ( player->cheats & CF_INFAMMO ) == false )
{
player->ammo[weaponinfo[player->readyweapon].ammo] -= BFGCELLS;
}
P_SpawnPlayerMissile( player->mo, MT_BFG );
if( ::g->plyr == player ) {
if( ::g->plyr == player )
{
}
}
@ -647,7 +694,8 @@ A_FirePlasma
( player_t* player,
pspdef_t* psp )
{
if( (player->cheats & CF_INFAMMO) == false ) {
if( ( player->cheats & CF_INFAMMO ) == false )
{
player->ammo[weaponinfo[player->readyweapon].ammo]--;
}
@ -657,7 +705,8 @@ A_FirePlasma
P_SpawnPlayerMissile( player->mo, MT_PLASMA );
if( ::g->plyr == player ) {
if( ::g->plyr == player )
{
}
}
@ -706,7 +755,9 @@ P_GunShot
angle = mo->angle;
if( !accurate )
{
angle += ( P_Random() - P_Random() ) << 18;
}
P_LineAttack( mo, angle, MISSILERANGE, ::g->bulletslope, damage );
}
@ -721,10 +772,13 @@ A_FirePistol
pspdef_t* psp )
{
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_pistol );
}
P_SetMobjState( player->mo, S_PLAY_ATK2 );
if( (player->cheats & CF_INFAMMO ) == false ) {
if( ( player->cheats & CF_INFAMMO ) == false )
{
player->ammo[weaponinfo[player->readyweapon].ammo]--;
}
@ -735,7 +789,8 @@ A_FirePistol
P_BulletSlope( player->mo );
P_GunShot( player->mo, !player->refire );
if( ::g->plyr == player ) {
if( ::g->plyr == player )
{
}
}
@ -751,10 +806,13 @@ A_FireShotgun
int i;
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_shotgn );
}
P_SetMobjState( player->mo, S_PLAY_ATK2 );
if( ( player->cheats & CF_INFAMMO ) == false ) {
if( ( player->cheats & CF_INFAMMO ) == false )
{
player->ammo[weaponinfo[player->readyweapon].ammo]--;
}
@ -765,9 +823,12 @@ A_FireShotgun
P_BulletSlope( player->mo );
for( i = 0 ; i < 7 ; i++ )
{
P_GunShot( player->mo, false );
}
if( ::g->plyr == player ) {
if( ::g->plyr == player )
{
}
}
@ -787,10 +848,13 @@ A_FireShotgun2
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_dshtgn );
}
P_SetMobjState( player->mo, S_PLAY_ATK2 );
if( (player->cheats & CF_INFAMMO) == false ) {
if( ( player->cheats & CF_INFAMMO ) == false )
{
player->ammo[weaponinfo[player->readyweapon].ammo] -= 2;
}
@ -811,7 +875,8 @@ A_FireShotgun2
::g->bulletslope + ( ( P_Random() - P_Random() ) << 5 ), damage );
}
if( ::g->plyr == player ) {
if( ::g->plyr == player )
{
}
}
@ -825,13 +890,18 @@ A_FireCGun
pspdef_t* psp )
{
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_pistol );
}
if( !player->ammo[weaponinfo[player->readyweapon].ammo] )
{
return;
}
P_SetMobjState( player->mo, S_PLAY_ATK2 );
if( (player->cheats & CF_INFAMMO) == false ) {
if( ( player->cheats & CF_INFAMMO ) == false )
{
player->ammo[weaponinfo[player->readyweapon].ammo]--;
}
P_SetPsprite( player,
@ -846,7 +916,8 @@ A_FireCGun
P_GunShot( player->mo, !player->refire );
if( ::g->plyr == player ) {
if( ::g->plyr == player )
{
}
}
@ -892,7 +963,9 @@ void A_BFGSpray (mobj_t* mo, void * )
P_AimLineAttack( mo->target, an, 16 * 64 * FRACUNIT );
if( !::g->linetarget )
{
continue;
}
P_SpawnMobj( ::g->linetarget->x,
::g->linetarget->y,
@ -901,7 +974,9 @@ void A_BFGSpray (mobj_t* mo, void * )
damage = 0;
for( j = 0; j < 15; j++ )
{
damage += ( P_Random() & 7 ) + 1;
}
P_DamageMobj( ::g->linetarget, mo->target, mo->target, damage );
}
@ -932,7 +1007,9 @@ void P_SetupPsprites (player_t* player)
// remove all psprites
for( i = 0 ; i < NUMPSPRITES ; i++ )
{
player->psprites[i].state = NULL;
}
// spawn the gun
player->pendingweapon = player->readyweapon;
@ -965,10 +1042,12 @@ void P_MovePsprites (player_t* player)
{
psp->tics--;
if( !psp->tics )
{
P_SetPsprite( player, i, psp->state->nextstate );
}
}
}
}
player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx;
player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy;

View file

@ -56,7 +56,9 @@ void P_ArchivePlayers (void)
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( !::g->playeringame[i] )
{
continue;
}
PADSAVEP();
@ -87,7 +89,9 @@ void P_UnArchivePlayers (void)
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( !::g->playeringame[i] )
{
continue;
}
PADSAVEP();
@ -147,7 +151,9 @@ void P_ArchiveWorld (void)
for( j = 0 ; j < 2 ; j++ )
{
if( li->sidenum[j] == -1 )
{
continue;
}
si = &::g->sides[li->sidenum[j]];
@ -205,7 +211,9 @@ void P_UnArchiveWorld (void)
for( j = 0 ; j < 2 ; j++ )
{
if( li->sidenum[j] == -1 )
{
continue;
}
si = &::g->sides[li->sidenum[j]];
si->textureoffset = *get++ << FRACBITS;
si->rowoffset = *get++ << FRACBITS;
@ -230,18 +238,21 @@ void P_UnArchiveWorld (void)
// Thinkers
//
int GetMOIndex( mobj_t* findme ) {
int GetMOIndex( mobj_t* findme )
{
thinker_t* th;
mobj_t* mobj;
int index = 0;
for( th = ::g->thinkercap.next ; th != &::g->thinkercap ; th = th->next )
{
if (th->function.acp1 == (actionf_p1)P_MobjThinker) {
if( th->function.acp1 == ( actionf_p1 )P_MobjThinker )
{
index++;
mobj = ( mobj_t* )th;
if ( mobj == findme ) {
if( mobj == findme )
{
return index;
}
}
@ -250,20 +261,24 @@ int GetMOIndex( mobj_t* findme ) {
return 0;
}
mobj_t* GetMO( int index ) {
mobj_t* GetMO( int index )
{
thinker_t* th;
int testindex = 0;
if ( !index ) {
if( !index )
{
return NULL;
}
for( th = ::g->thinkercap.next ; th != &::g->thinkercap ; th = th->next )
{
if (th->function.acp1 == (actionf_p1)P_MobjThinker) {
if( th->function.acp1 == ( actionf_p1 )P_MobjThinker )
{
testindex++;
if ( testindex == index ) {
if( testindex == index )
{
return ( mobj_t* )th;
}
}
@ -309,7 +324,9 @@ void P_ArchiveThinkers (void)
mobj->state = ( state_t* )( mobj->state - ::g->states );
if( mobj->player )
{
mobj->player = ( player_t* )( ( mobj->player -::g->players ) + 1 );
}
// Save out 'target'
int moIndex = GetMOIndex( mobj->target );
@ -330,10 +347,12 @@ void P_ArchiveThinkers (void)
*::g->save_p++ = moIndex;
// Is this the head of a sector list?
if ( mobj->subsector->sector->thinglist == (mobj_t*)th ) {
if( mobj->subsector->sector->thinglist == ( mobj_t* )th )
{
*::g->save_p++ = 1;
}
else {
else
{
*::g->save_p++ = 0;
}
@ -349,11 +368,13 @@ void P_ArchiveThinkers (void)
int blockx = ( mobj->x - ::g->bmaporgx ) >> MAPBLOCKSHIFT;
int blocky = ( mobj->y - ::g->bmaporgy ) >> MAPBLOCKSHIFT;
if( blockx >= 0 && blockx < ::g->bmapwidth && blocky >= 0 && blocky < ::g->bmapheight
&& (mobj_t*)th == ::g->blocklinks[blocky*::g->bmapwidth+blockx] ) {
&& ( mobj_t* )th == ::g->blocklinks[blocky*::g->bmapwidth + blockx] )
{
*::g->save_p++ = 1;
}
else {
else
{
*::g->save_p++ = 0;
}
continue;
@ -363,7 +384,9 @@ void P_ArchiveThinkers (void)
{
for( i = 0; i < MAXCEILINGS; i++ )
if( ::g->activeceilings[i] == ( ceiling_t* )th )
{
break;
}
if( i < MAXCEILINGS )
{
@ -471,7 +494,8 @@ void P_ArchiveThinkers (void)
sector_t* sec;
short* put = ( short* )::g->save_p;
for (i=0, sec = ::g->sectors ; i < ::g->numsectors ; i++,sec++) {
for( i = 0, sec = ::g->sectors ; i < ::g->numsectors ; i++, sec++ )
{
*put++ = ( short )GetMOIndex( sec->soundtarget );
}
@ -523,9 +547,13 @@ void P_UnArchiveThinkers (void)
next = currentthinker->next;
if( currentthinker->function.acp1 == ( actionf_p1 )P_MobjThinker )
{
P_RemoveMobj( ( mobj_t* )currentthinker );
}
else
{
Z_Free( currentthinker );
}
currentthinker = next;
}
@ -542,7 +570,8 @@ void P_UnArchiveThinkers (void)
// clear sector thing lists
ss = ::g->sectors;
for (int i=0 ; i < ::g->numsectors ; i++, ss++) {
for( int i = 0 ; i < ::g->numsectors ; i++, ss++ )
{
ss->thinglist = NULL;
}
@ -555,8 +584,10 @@ void P_UnArchiveThinkers (void)
// fixup mobj_t pointers now that all thinkers have been restored
mo_index = 0;
for (th = ::g->thinkercap.next ; th != &::g->thinkercap ; th=th->next) {
if (th->function.acp1 == (actionf_p1)P_MobjThinker) {
for( th = ::g->thinkercap.next ; th != &::g->thinkercap ; th = th->next )
{
if( th->function.acp1 == ( actionf_p1 )P_MobjThinker )
{
mobj = ( mobj_t* )th;
mobj->target = GetMO( mo_targets[mo_index] );
@ -565,24 +596,28 @@ void P_UnArchiveThinkers (void)
mobj->snext = GetMO( mo_snext[mo_index] );
mobj->sprev = GetMO( mo_sprev[mo_index] );
if ( mo_shead[mo_index] ) {
if( mo_shead[mo_index] )
{
mobj->subsector->sector->thinglist = mobj;
}
mobj->bnext = GetMO( mo_bnext[mo_index] );
mobj->bprev = GetMO( mo_bprev[mo_index] );
if ( mo_bhead[mo_index] ) {
if( mo_bhead[mo_index] )
{
// Is this the head of a block list?
int blockx = ( mobj->x - ::g->bmaporgx ) >> MAPBLOCKSHIFT;
int blocky = ( mobj->y - ::g->bmaporgy ) >> MAPBLOCKSHIFT;
if ( blockx >= 0 && blockx < ::g->bmapwidth && blocky >= 0 && blocky < ::g->bmapheight ) {
if( blockx >= 0 && blockx < ::g->bmapwidth && blocky >= 0 && blocky < ::g->bmapheight )
{
::g->blocklinks[blocky*::g->bmapwidth + blockx] = mobj;
}
}
// Doom 2 level 30 requires some global pointers, wheee!
if ( mobj->type == MT_BOSSTARGET ) {
if( mobj->type == MT_BOSSTARGET )
{
::g->braintargets[::g->numbraintargets] = mobj;
::g->numbraintargets++;
}
@ -603,7 +638,8 @@ void P_UnArchiveThinkers (void)
::g->save_p = ( byte* )get;
tclass = *::g->save_p++;
if ( tclass != tc_end ) {
if( tclass != tc_end )
{
I_Error( "Savegame error after loading sector soundtargets." );
}
@ -697,7 +733,9 @@ void P_UnArchiveThinkers (void)
ceiling->sector->specialdata = ceiling;
if( ceiling->thinker.function.acp1 )
{
ceiling->thinker.function.acp1 = ( actionf_p1 )T_MoveCeiling;
}
P_AddThinker( &ceiling->thinker );
P_AddActiveCeiling( ceiling );
@ -734,7 +772,9 @@ void P_UnArchiveThinkers (void)
plat->sector->specialdata = plat;
if( plat->thinker.function.acp1 )
{
plat->thinker.function.acp1 = ( actionf_p1 )T_PlatRaise;
}
P_AddThinker( &plat->thinker );
P_AddActivePlat( plat );
@ -823,7 +863,9 @@ void P_ArchiveSpecials (void)
{
for( i = 0; i < MAXCEILINGS; i++ )
if( ::g->activeceilings[i] == ( ceiling_t* )th )
{
break;
}
if( i < MAXCEILINGS )
{
@ -953,7 +995,9 @@ void P_UnArchiveSpecials (void)
ceiling->sector->specialdata = ceiling;
if( ceiling->thinker.function.acp1 )
{
ceiling->thinker.function.acp1 = ( actionf_p1 )T_MoveCeiling;
}
P_AddThinker( &ceiling->thinker );
P_AddActiveCeiling( ceiling );
@ -990,7 +1034,9 @@ void P_UnArchiveSpecials (void)
plat->sector->specialdata = plat;
if( plat->thinker.function.acp1 )
{
plat->thinker.function.acp1 = ( actionf_p1 )T_PlatRaise;
}
P_AddThinker( &plat->thinker );
P_AddActivePlat( plat );

View file

@ -170,10 +170,14 @@ void P_LoadSegs (int lump)
li->sidedef = &::g->sides[ldef->sidenum[side]];
li->frontsector = ::g->sides[ldef->sidenum[side]].sector;
if( ldef-> flags & ML_TWOSIDED )
{
li->backsector = ::g->sides[ldef->sidenum[side ^ 1]].sector;
}
else
{
li->backsector = 0;
}
}
Z_Free( data );
}
@ -300,9 +304,11 @@ void P_LoadNodes (int lump)
{
no->children[j] = SHORT( mn->children[j] );
for( k = 0 ; k < 4 ; k++ )
{
no->bbox[j][k] = SHORT( mn->bbox[j][k] ) << FRACBITS;
}
}
}
Z_Free( data );
}
@ -348,7 +354,9 @@ void P_LoadThings (int lump)
}
}
if( spawn == false )
{
break;
}
// Do spawn all other stuff.
mt->x = SHORT( mt->x );
@ -396,16 +404,24 @@ void P_LoadLineDefs (int lump)
ld->dy = v2->y - v1->y;
if( !ld->dx )
{
ld->slopetype = ST_VERTICAL;
}
else if( !ld->dy )
{
ld->slopetype = ST_HORIZONTAL;
}
else
{
if( FixedDiv( ld->dy , ld->dx ) > 0 )
{
ld->slopetype = ST_POSITIVE;
}
else
{
ld->slopetype = ST_NEGATIVE;
}
}
if( v1->x < v2->x )
{
@ -433,15 +449,23 @@ void P_LoadLineDefs (int lump)
ld->sidenum[1] = SHORT( mld->sidenum[1] );
if( ld->sidenum[0] != -1 )
{
ld->frontsector = ::g->sides[ld->sidenum[0]].sector;
}
else
{
ld->frontsector = 0;
}
if( ld->sidenum[1] != -1 )
{
ld->backsector = ::g->sides[ld->sidenum[1]].sector;
}
else
{
ld->backsector = 0;
}
}
Z_Free( data );
}
@ -490,7 +514,8 @@ void P_LoadBlockMap (int lump)
int count;
bool firstTime = false;
if (!lumpcache[lump]) { // SMF - solution for double endian conversion issue
if( !lumpcache[lump] ) // SMF - solution for double endian conversion issue
{
firstTime = true;
}
@ -498,10 +523,13 @@ void P_LoadBlockMap (int lump)
::g->blockmap = ::g->blockmaplump + 4;
count = W_LumpLength( lump ) / 2;
if ( firstTime ) { // SMF
if( firstTime ) // SMF
{
for( i = 0 ; i < count ; i++ )
{
::g->blockmaplump[i] = SHORT( ::g->blockmaplump[i] );
}
}
::g->bmaporgx = ( ::g->blockmaplump[0] ) << FRACBITS;
::g->bmaporgy = ( ::g->blockmaplump[1] ) << FRACBITS;
@ -576,7 +604,9 @@ 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;
@ -656,10 +686,14 @@ P_SetupLevel
if( ::g->gamemode == commercial )
{
if( map < 10 )
{
sprintf( lumpname, "map0%i", map % 100 );
}
else
{
sprintf( lumpname, "map%i", map % 100 );
}
}
else
{
lumpname[0] = 'E';
@ -718,8 +752,10 @@ P_SetupLevel
// preload graphics
if( ::g->precache )
{
R_PrecacheLevel();
}
}

View file

@ -63,10 +63,14 @@ P_DivlineSide
if( !node->dx )
{
if( x == node->x )
{
return 2;
}
if( x <= node->x )
{
return node->dy > 0;
}
return node->dy < 0;
}
@ -74,10 +78,14 @@ P_DivlineSide
if( !node->dy )
{
if( x == node->y )
{
return 2;
}
if( y <= node->y )
{
return node->dx < 0;
}
return node->dx > 0;
}
@ -89,10 +97,14 @@ P_DivlineSide
right = ( dy >> FRACBITS ) * ( node->dx >> FRACBITS );
if( right < left )
{
return 0; // front side
}
if( left == right )
{
return 2;
}
return 1; // back side
}
@ -115,7 +127,9 @@ P_InterceptVector2
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 ) +
@ -167,7 +181,9 @@ qboolean P_CrossSubsector (int num)
// allready checked other side?
if( line->validcount == ::g->validcount )
{
continue;
}
line->validcount = ::g->validcount;
@ -178,7 +194,9 @@ qboolean P_CrossSubsector (int num)
// line isn't crossed?
if( s1 == s2 )
{
continue;
}
divl.x = v1->x;
divl.y = v1->y;
@ -189,12 +207,16 @@ qboolean P_CrossSubsector (int num)
// line isn't crossed?
if( s1 == s2 )
{
continue;
}
// stop because it is not two sided anyway
// might do this after updating validcount?
if( !( line->flags & ML_TWOSIDED ) )
{
return false;
}
// crosses a two sided line
front = seg->frontsector;
@ -203,24 +225,36 @@ qboolean P_CrossSubsector (int num)
// no wall to block sight with?
if( front->floorheight == back->floorheight
&& front->ceilingheight == back->ceilingheight )
{
continue;
}
// possible occluder
// because of ceiling height differences
if( front->ceilingheight < back->ceilingheight )
{
psight_opentop = front->ceilingheight;
}
else
{
psight_opentop = back->ceilingheight;
}
// because of ceiling height differences
if( front->floorheight > back->floorheight )
{
psight_openbottom = front->floorheight;
}
else
{
psight_openbottom = back->floorheight;
}
// quick test for totally closed doors
if( psight_openbottom >= psight_opentop )
{
return false; // stop
}
frac = P_InterceptVector2( &::g->strace, &divl );
@ -228,19 +262,25 @@ qboolean P_CrossSubsector (int num)
{
slope = FixedDiv( psight_openbottom - ::g->sightzstart , frac );
if( slope > ::g->bottomslope )
{
::g->bottomslope = slope;
}
}
if( front->ceilingheight != back->ceilingheight )
{
slope = FixedDiv( psight_opentop - ::g->sightzstart , frac );
if( slope < ::g->topslope )
{
::g->topslope = slope;
}
}
if( ::g->topslope <= ::g->bottomslope )
{
return false; // stop
}
}
// passed the subsector ok
return true;
}
@ -260,21 +300,29 @@ qboolean P_CrossBSPNode (int bspnum)
if( bspnum & NF_SUBSECTOR )
{
if( bspnum == -1 )
{
return P_CrossSubsector( 0 );
}
else
{
return P_CrossSubsector( bspnum & ( ~NF_SUBSECTOR ) );
}
}
bsp = &::g->nodes[bspnum];
// decide which side the start point is on
side = P_DivlineSide( ::g->strace.x, ::g->strace.y, ( divline_t* )bsp );
if( side == 2 )
{
side = 0; // an "on" should cross both ::g->sides
}
// cross the starting side
if( !P_CrossBSPNode( bsp->children[side] ) )
{
return false;
}
// the partition plane is crossed here
if( side == P_DivlineSide( ::g->t2x, ::g->t2y, ( divline_t* )bsp ) )

View file

@ -138,7 +138,9 @@ void P_InitPicAnims (void)
{
// different episode ?
if( R_CheckTextureNumForName( animdefs[i].startname ) == -1 )
{
continue;
}
::g->lastanim->picnum = R_TextureNumForName( animdefs[i].endname );
::g->lastanim->basepic = R_TextureNumForName( animdefs[i].startname );
@ -146,7 +148,9 @@ void P_InitPicAnims (void)
else
{
if( W_CheckNumForName( animdefs[i].startname ) == -1 )
{
continue;
}
::g->lastanim->picnum = R_FlatNumForName( animdefs[i].endname );
::g->lastanim->basepic = R_FlatNumForName( animdefs[i].startname );
@ -233,10 +237,14 @@ getNextSector
sector_t* sec )
{
if( !( line->flags & ML_TWOSIDED ) )
{
return NULL;
}
if( line->frontsector == sec )
{
return line->backsector;
}
return line->frontsector;
}
@ -260,11 +268,15 @@ fixed_t P_FindLowestFloorSurrounding(sector_t* sec)
other = getNextSector( check, sec );
if( !other )
{
continue;
}
if( other->floorheight < floor )
{
floor = other->floorheight;
}
}
return floor;
}
@ -287,11 +299,15 @@ fixed_t P_FindHighestFloorSurrounding(sector_t *sec)
other = getNextSector( check, sec );
if( !other )
{
continue;
}
if( other->floorheight > floor )
{
floor = other->floorheight;
}
}
return floor;
}
@ -325,10 +341,14 @@ P_FindNextHighestFloor
other = getNextSector( check, sec );
if( !other )
{
continue;
}
if( other->floorheight > height )
{
heightlist[h++] = other->floorheight;
}
// Check for overflow. Exit.
if( h >= MAX_ADJOINING_SECTORS )
@ -340,14 +360,18 @@ P_FindNextHighestFloor
// Find lowest height in list
if( !h )
{
return currentheight;
}
min = heightlist[0];
// Range checking?
for( i = 1; i < h; i++ )
if( heightlist[i] < min )
{
min = heightlist[i];
}
return min;
}
@ -370,11 +394,15 @@ P_FindLowestCeilingSurrounding(sector_t* sec)
other = getNextSector( check, sec );
if( !other )
{
continue;
}
if( other->ceilingheight < height )
{
height = other->ceilingheight;
}
}
return height;
}
@ -395,11 +423,15 @@ fixed_t P_FindHighestCeilingSurrounding(sector_t* sec)
other = getNextSector( check, sec );
if( !other )
{
continue;
}
if( other->ceilingheight > height )
{
height = other->ceilingheight;
}
}
return height;
}
@ -417,7 +449,9 @@ P_FindSectorFromLineTag
for( i = start + 1; i < ::g->numsectors; i++ )
if( ::g->sectors[i].tag == line->tag )
{
return i;
}
return -1;
}
@ -445,11 +479,15 @@ P_FindMinSurroundingLight
check = getNextSector( line, sector );
if( !check )
{
continue;
}
if( check->lightlevel < min )
{
min = check->lightlevel;
}
}
return min;
}
@ -492,7 +530,8 @@ P_CrossSpecialLine
return;
break;
default: break;
default:
break;
}
ok = 0;
@ -509,8 +548,10 @@ P_CrossSpecialLine
break;
}
if( !ok )
{
return;
}
}
// Note: could use some const's here.
@ -655,7 +696,8 @@ P_CrossSpecialLine
case 52:
// EXIT!
// DHM - Nerve :: Don't exit level in death match, timelimit and fraglimit only
if ( !::g->deathmatch && ::g->gameaction != ga_completed ) {
if( !::g->deathmatch && ::g->gameaction != ga_completed )
{
G_ExitLevel();
}
break;
@ -740,7 +782,8 @@ P_CrossSpecialLine
case 124:
// Secret EXIT
if ( !::g->deathmatch && ::g->gameaction != ga_completed ) {
if( !::g->deathmatch && ::g->gameaction != ga_completed )
{
G_SecretExitLevel();
}
break;
@ -917,7 +960,9 @@ P_CrossSpecialLine
case 126:
// TELEPORT MonsterONLY.
if( !thing->player )
{
EV_Teleport( line, side, thing );
}
break;
case 128:
@ -957,8 +1002,10 @@ P_ShootSpecialLine
break;
}
if( !ok )
{
return;
}
}
switch( line->special )
{
@ -997,7 +1044,9 @@ void P_PlayerInSpecialSector (player_t* player)
// Falling, not all the way down yet?
if( player->mo->z != sector->floorheight )
{
return;
}
// Has hitten ground.
switch( sector->special )
@ -1006,14 +1055,18 @@ void P_PlayerInSpecialSector (player_t* player)
// HELLSLIME DAMAGE
if( !player->powers[pw_ironfeet] )
if( !( ::g->leveltime & 0x1f ) )
{
P_DamageMobj( player->mo, NULL, NULL, 10 );
}
break;
case 7:
// NUKAGE DAMAGE
if( !player->powers[pw_ironfeet] )
if( !( ::g->leveltime & 0x1f ) )
{
P_DamageMobj( player->mo, NULL, NULL, 5 );
}
break;
case 16:
@ -1024,8 +1077,10 @@ void P_PlayerInSpecialSector (player_t* player)
|| ( P_Random() < 5 ) )
{
if( !( ::g->leveltime & 0x1f ) )
{
P_DamageMobj( player->mo, NULL, NULL, 20 );
}
}
break;
case 9:
@ -1034,26 +1089,33 @@ void P_PlayerInSpecialSector (player_t* player)
sector->special = 0;
if ( !::g->demoplayback && ( ::g->usergame && !::g->netgame ) ) {
if( !::g->demoplayback && ( ::g->usergame && !::g->netgame ) )
{
// DHM - Nerve :: Let's give achievements in real time in Doom 2
if ( !common->IsMultiplayer() ) {
switch( DoomLib::GetGameSKU() ) {
case GAME_SKU_DOOM1_BFG: {
if( !common->IsMultiplayer() )
{
switch( DoomLib::GetGameSKU() )
{
case GAME_SKU_DOOM1_BFG:
{
// Removing trophies for DOOM and DOOM II BFG due to point limit.
//gameLocal->UnlockAchievement( Doom1BFG_Trophies::SCOUT_FIND_ANY_SECRET );
break;
}
case GAME_SKU_DOOM2_BFG: {
case GAME_SKU_DOOM2_BFG:
{
//gameLocal->UnlockAchievement( Doom2BFG_Trophies::IMPORTANT_LOOKING_DOOR_FIND_ANY_SECRET );
idAchievementManager::LocalUser_CompleteAchievement( ACHIEVEMENT_DOOM2_IMPORTANT_LOOKING_DOOR_FIND_ANY_SECRET );
break;
}
case GAME_SKU_DCC: {
case GAME_SKU_DCC:
{
// Not on PC.
//gameLocal->UnlockAchievement( DOOM_ACHIEVEMENT_FIND_SECRET );
break;
}
default: {
default:
{
// No unlocks for other SKUs.
break;
}
@ -1069,10 +1131,14 @@ void P_PlayerInSpecialSector (player_t* player)
player->cheats &= ~CF_GODMODE;
if( !( ::g->leveltime & 0x1f ) )
{
P_DamageMobj( player->mo, NULL, NULL, 20 );
}
if( player->health <= 10 )
{
G_ExitLevel();
}
break;
default:
@ -1090,11 +1156,14 @@ void P_PlayerInSpecialSector (player_t* player)
// P_UpdateSpecials
// Animate planes, scroll walls, etc.
//
int PlayerFrags( int playernum ) {
int PlayerFrags( int playernum )
{
int frags = 0;
for( int i=0 ; i<MAXPLAYERS ; i++) {
if ( i != playernum ) {
for( int i = 0 ; i < MAXPLAYERS ; i++ )
{
if( i != playernum )
{
frags += ::g->players[playernum].frags[i];
}
}
@ -1117,22 +1186,29 @@ void P_UpdateSpecials (void)
{
::g->levelTimeCount--;
if( !::g->levelTimeCount )
{
G_ExitLevel();
}
}
// DHM - Nerve :: FRAG COUNT
if ( ::g->deathmatch && ::g->levelFragCount > 0 ) {
if( ::g->deathmatch && ::g->levelFragCount > 0 )
{
bool fragCountHit = false;
for ( int i=0; i<MAXPLAYERS; i++ ) {
if ( ::g->playeringame[i] ) {
if ( PlayerFrags(i) >= ::g->levelFragCount ) {
for( int i = 0; i < MAXPLAYERS; i++ )
{
if( ::g->playeringame[i] )
{
if( PlayerFrags( i ) >= ::g->levelFragCount )
{
fragCountHit = true;
}
}
}
if ( fragCountHit ) {
if( fragCountHit )
{
G_ExitLevel();
}
}
@ -1144,11 +1220,15 @@ void P_UpdateSpecials (void)
{
pic = anim->basepic + ( ( ::g->leveltime / anim->speed + i ) % anim->numpics );
if( anim->istexture )
{
::g->texturetranslation[i] = pic;
}
else
{
::g->flattranslation[i] = pic;
}
}
}
// ANIMATE LINE SPECIALS
@ -1219,7 +1299,9 @@ int EV_DoDonut(line_t* line)
// ALREADY MOVING? IF SO, KEEP GOING...
if( s1->specialdata )
{
continue;
}
rtn = 1;
s2 = getNextSector( s1->lines[0], s1 );
@ -1227,7 +1309,9 @@ int EV_DoDonut(line_t* line)
{
if( ( !( s2->lines[i]->flags & ML_TWOSIDED ) ) ||
( s2->lines[i]->backsector == s1 ) )
{
continue;
}
s3 = s2->lines[i]->backsector;
// Spawn rising slime
@ -1283,7 +1367,9 @@ void P_SpawnSpecials (void)
episode = 1;
if( W_CheckNumForName( "texture2" ) >= 0 )
{
episode = 2;
}
// See if -TIMER needs to be used.
@ -1323,7 +1409,9 @@ void P_SpawnSpecials (void)
{
//::g->levelFragCount = atoi(::g->myargv[i+1]);
::g->levelFragCount = fragLimit;
} else {
}
else
{
::g->levelFragCount = 0;
}
@ -1332,7 +1420,9 @@ void P_SpawnSpecials (void)
for( i = 0 ; i < ::g->numsectors ; i++, sector++ )
{
if( !sector->special )
{
continue;
}
switch( sector->special )
{
@ -1410,13 +1500,19 @@ void P_SpawnSpecials (void)
// Init other misc stuff
for( i = 0; i < MAXCEILINGS; i++ )
{
::g->activeceilings[i] = NULL;
}
for( i = 0; i < MAXPLATS; i++ )
{
::g->activeplats[i] = NULL;
}
for( i = 0; i < MAXBUTTONS; i++ )
{
memset( &::g->buttonlist[i], 0, sizeof( button_t ) );
}
// UNUSED: no horizonal sliders.
// P_InitSlidingDoorFrames();

View file

@ -234,7 +234,8 @@ typedef struct
bwhere_e where;
int btexture;
int btimer;
union {
union
{
mobj_t* soundorg;
degenmobj_t* degensoundorg;
};

View file

@ -114,9 +114,13 @@ void P_InitSwitchList(void)
episode = 1;
if( ::g->gamemode == registered || ::g->gamemode == retail )
{
episode = 2;
}
else if( ::g->gamemode == commercial )
{
episode = 3;
}
for( index = 0, i = 0; i < MAXSWITCHES; i++ )
{
@ -209,7 +213,9 @@ P_ChangeSwitchTexture
int sound;
if( !useAgain )
{
line->special = 0;
}
texTop = ::g->sides[line->sidenum[0]].toptexture;
texMid = ::g->sides[line->sidenum[0]].midtexture;
@ -219,7 +225,9 @@ P_ChangeSwitchTexture
// EXIT SWITCH?
if( line->special == 11 )
{
sound = sfx_swtchx;
}
for( i = 0; i < ::g->numswitches * 2; i++ )
{
@ -229,7 +237,9 @@ P_ChangeSwitchTexture
::g->sides[line->sidenum[0]].toptexture = ::g->switchlist[i ^ 1];
if( useAgain )
{
P_StartButton( line, top, ::g->switchlist[i], BUTTONTIME );
}
return;
}
@ -241,7 +251,9 @@ P_ChangeSwitchTexture
::g->sides[line->sidenum[0]].midtexture = ::g->switchlist[i ^ 1];
if( useAgain )
{
P_StartButton( line, middle, ::g->switchlist[i], BUTTONTIME );
}
return;
}
@ -253,7 +265,9 @@ P_ChangeSwitchTexture
::g->sides[line->sidenum[0]].bottomtexture = ::g->switchlist[i ^ 1];
if( useAgain )
{
P_StartButton( line, bottom, ::g->switchlist[i], BUTTONTIME );
}
return;
}
@ -302,7 +316,9 @@ P_UseSpecialLine
{
// never open secret doors
if( line->flags & ML_SECRET )
{
return false;
}
switch( line->special )
{
@ -347,19 +363,24 @@ P_UseSpecialLine
case 7:
// Build Stairs
if( EV_BuildStairs( line, build8 ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 9:
// Change Donut
if( EV_DoDonut( line ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 11:
// Exit level
// DHM - Nerve :: Not in deathmatch, stay in level until timelimit or fraglimit
if ( !::g->deathmatch && ::g->gameaction != ga_completed ) {
if( !::g->deathmatch && ::g->gameaction != ga_completed )
{
P_ChangeSwitchTexture( line, 0 );
G_ExitLevel();
}
@ -368,72 +389,95 @@ P_UseSpecialLine
case 14:
// Raise Floor 32 and change texture
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 );
}
break;
case 18:
// Raise Floor to next highest floor
if( EV_DoFloor( line, raiseFloorToNearest ) )
{
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 );
}
break;
case 21:
// PlatDownWaitUpStay
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 );
}
break;
case 29:
// Raise Door
if( EV_DoDoor( line, normal ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 41:
// Lower Ceiling to Floor
if( EV_DoCeiling( line, lowerToFloor ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 71:
// Turbo Lower Floor
if( EV_DoFloor( line, turboLower ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 49:
// Ceiling Crush And Raise
if( EV_DoCeiling( line, crushAndRaise ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 50:
// Close Door
if( EV_DoDoor( line, closed ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 51:
// Secret EXIT
if ( !::g->deathmatch && ::g->gameaction != ga_completed ) {
if( !::g->deathmatch && ::g->gameaction != ga_completed )
{
P_ChangeSwitchTexture( line, 0 );
G_SecretExitLevel();
}
@ -442,61 +486,81 @@ P_UseSpecialLine
case 55:
// Raise Floor Crush
if( EV_DoFloor( line, raiseFloorCrush ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 101:
// Raise Floor
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 );
}
break;
case 103:
// Open Door
if( EV_DoDoor( line, opened ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 111:
// Blazing Door Raise (faster than TURBO!)
if( EV_DoDoor( line, blazeRaise ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 112:
// Blazing Door Open (faster than TURBO!)
if( EV_DoDoor( line, blazeOpen ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 113:
// Blazing Door Close (faster than TURBO!)
if( EV_DoDoor( line, blazeClose ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 122:
// Blazing PlatDownWaitUpStay
if( EV_DoPlat( line, blazeDWUS, 0 ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 127:
// Build Stairs Turbo 16
if( EV_BuildStairs( line, turbo16 ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 131:
// Raise Floor Turbo
if( EV_DoFloor( line, raiseFloorTurbo ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 133:
@ -506,128 +570,170 @@ P_UseSpecialLine
case 137:
// BlzOpenDoor YELLOW
if( EV_DoLockedDoor( line, blazeOpen, thing ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
case 140:
// Raise Floor 512
if( EV_DoFloor( line, raiseFloor512 ) )
{
P_ChangeSwitchTexture( line, 0 );
}
break;
// BUTTONS
case 42:
// Close Door
if( EV_DoDoor( line, closed ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 43:
// Lower Ceiling to Floor
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 );
}
break;
case 60:
// Lower Floor to Lowest
if( EV_DoFloor( line, lowerFloorToLowest ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 61:
// Open Door
if( EV_DoDoor( line, opened ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 62:
// PlatDownWaitUpStay
if( EV_DoPlat( line, downWaitUpStay, 1 ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 63:
// Raise Door
if( EV_DoDoor( line, normal ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 64:
// Raise Floor to ceiling
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 );
}
break;
case 67:
// Raise Floor 32 and change texture
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 );
}
break;
case 68:
// Raise Plat to next highest floor and change texture
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 );
}
break;
case 70:
// Turbo Lower Floor
if( EV_DoFloor( line, turboLower ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 114:
// Blazing Door Raise (faster than TURBO!)
if( EV_DoDoor( line, blazeRaise ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 115:
// Blazing Door Open (faster than TURBO!)
if( EV_DoDoor( line, blazeOpen ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 116:
// Blazing Door Close (faster than TURBO!)
if( EV_DoDoor( line, blazeClose ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 123:
// Blazing PlatDownWaitUpStay
if( EV_DoPlat( line, blazeDWUS, 0 ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 132:
// Raise Floor Turbo
if( EV_DoFloor( line, raiseFloorTurbo ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 99:
@ -637,7 +743,9 @@ P_UseSpecialLine
case 136:
// BlzOpenDoor YELLOW
if( EV_DoLockedDoor( line, blazeOpen, thing ) )
{
P_ChangeSwitchTexture( line, 1 );
}
break;
case 138:

View file

@ -68,12 +68,16 @@ EV_Teleport
// don't teleport missiles
if( thing->flags & MF_MISSILE )
{
return 0;
}
// Don't teleport if hit back of line,
// so you can get out of teleporter.
if( side == 1 )
{
return 0;
}
tag = line->tag;
@ -88,29 +92,39 @@ EV_Teleport
{
// not a mobj
if( thinker->function.acp1 != ( actionf_p1 )P_MobjThinker )
{
continue;
}
m = ( mobj_t* )thinker;
// not a teleportman
if( m->type != MT_TELEPORTMAN )
{
continue;
}
sector = m->subsector->sector;
// wrong sector
if( sector -::g->sectors != i )
{
continue;
}
oldx = thing->x;
oldy = thing->y;
oldz = thing->z;
if( !P_TeleportMove( thing, m->x, m->y ) )
{
return 0;
}
thing->z = thing->floorz; //fixme: not needed?
if( thing->player )
{
thing->player->viewz = thing->z + thing->player->viewheight;
}
// spawn teleport fog at source and destination
fog = P_SpawnMobj( oldx, oldy, oldz, MT_TFOG );
@ -124,7 +138,9 @@ EV_Teleport
// don't move for a bit
if( thing->player )
{
thing->reactiontime = 18;
}
thing->angle = m->angle;
thing->momx = thing->momy = thing->momz = 0;

View file

@ -117,8 +117,10 @@ void P_RunThinkers (void)
else
{
if( currentthinker->function.acp1 )
{
currentthinker->function.acp1( ( mobj_t* )currentthinker );
}
}
currentthinker = currentthinker->next;
}
}
@ -136,10 +138,13 @@ void P_Ticker (void)
// run the tic
if( ::g->paused )
{
return;
}
// don't think during wipe
if ( !::g->netgame && (!::g->demoplayback || demoversion == VERSION ) && ::g->wipe ) {
if( !::g->netgame && ( !::g->demoplayback || demoversion == VERSION ) && ::g->wipe )
{
return;
}
@ -153,8 +158,10 @@ void P_Ticker (void)
}
for (i=0 ; i<MAXPLAYERS ; i++) {
if (::g->playeringame[i]) {
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( ::g->playeringame[i] )
{
P_PlayerThink( &::g->players[i] );
}
}

View file

@ -93,14 +93,18 @@ void P_CalcHeight (player_t* player)
// DHM - NERVE :: player bob reduced by 25%, MAXBOB reduced by 25% as well
player->bob = ( fixed_t )( ( float )( player->bob ) * 0.75f );
if( player->bob > MAXBOB )
{
player->bob = MAXBOB;
}
if( ( player->cheats & CF_NOMOMENTUM ) || !::g->onground )
{
player->viewz = player->mo->z + VIEWHEIGHT;
if( player->viewz > player->mo->ceilingz - 4 * FRACUNIT )
{
player->viewz = player->mo->ceilingz - 4 * FRACUNIT;
}
player->viewz = player->mo->z + player->viewheight;
return;
@ -125,21 +129,27 @@ void P_CalcHeight (player_t* player)
{
player->viewheight = VIEWHEIGHT / 2;
if( player->deltaviewheight <= 0 )
{
player->deltaviewheight = 1;
}
}
if( player->deltaviewheight )
{
player->deltaviewheight += FRACUNIT / 4;
if( !player->deltaviewheight )
{
player->deltaviewheight = 1;
}
}
}
player->viewz = player->mo->z + player->viewheight + bob;
if( player->viewz > player->mo->ceilingz - 4 * FRACUNIT )
{
player->viewz = player->mo->ceilingz - 4 * FRACUNIT;
}
}
@ -159,10 +169,14 @@ void P_MovePlayer (player_t* player)
::g->onground = ( player->mo->z <= player->mo->floorz );
if( cmd->forwardmove && ::g->onground )
{
P_Thrust( player, player->mo->angle, cmd->forwardmove * 2048 );
}
if( cmd->sidemove && ::g->onground )
{
P_Thrust( player, player->mo->angle - ANG90, cmd->sidemove * 2048 );
}
if( ( cmd->forwardmove || cmd->sidemove )
&& player->mo->state == &::g->states[S_PLAY] )
@ -189,10 +203,14 @@ void P_DeathThink (player_t* player)
// fall to the ground
if( player->viewheight > 6 * FRACUNIT )
{
player->viewheight -= FRACUNIT;
}
if( player->viewheight < 6 * FRACUNIT )
{
player->viewheight = 6 * FRACUNIT;
}
player->deltaviewheight = 0;
::g->onground = ( player->mo->z <= player->mo->floorz );
@ -214,20 +232,30 @@ void P_DeathThink (player_t* player)
player->mo->angle = angle;
if( player->damagecount )
{
player->damagecount--;
}
}
else if( delta < ANG180 )
{
player->mo->angle += ANG5;
}
else
{
player->mo->angle -= ANG5;
}
}
else if( player->damagecount )
{
player->damagecount--;
}
if( player->cmd.buttons & BT_USE )
{
player->playerstate = PST_REBORN;
}
}
@ -241,9 +269,13 @@ void P_PlayerThink (player_t* player)
// fixme: do this in the cheat code
if( player->cheats & CF_NOCLIP )
{
player->mo->flags |= MF_NOCLIP;
}
else
{
player->mo->flags &= ~MF_NOCLIP;
}
// chain saw run forward
cmd = &player->cmd;
@ -266,20 +298,28 @@ void P_PlayerThink (player_t* player)
// Reactiontime is used to prevent movement
// for a bit after a teleport.
if( player->mo->reactiontime )
{
player->mo->reactiontime--;
}
else
{
P_MovePlayer( player );
}
P_CalcHeight( player );
if( player->mo->subsector->sector->special )
{
P_PlayerInSpecialSector( player );
}
// Check for weapon change.
// A special event has no other buttons.
if( cmd->buttons & BT_SPECIAL )
{
cmd->buttons = 0;
}
if( ::g->demoplayback && demoversion < VERSION )
{
@ -329,7 +369,8 @@ void P_PlayerThink (player_t* player)
// (read: not in the middle of an attack).
which = ( ( cmd->buttons & BT_WEAPONMASK ) >> BT_WEAPONSHIFT );
if ( cmd->nextPrevWeapon > 0) {
if( cmd->nextPrevWeapon > 0 )
{
newweapon = player->readyweapon;
for( k = 0; k < NUMWEAPONS; ++k )
@ -337,15 +378,21 @@ void P_PlayerThink (player_t* player)
newweapon = ( weapontype_t )( ( cmd->nextPrevWeapon - 1 ) ? ( newweapon + 1 ) : ( newweapon - 1 ) );
if( newweapon == wp_nochange )
{
continue;
}
weapontype_t maxweapon = ( ::g->gamemode == retail ) ? wp_chainsaw : wp_supershotgun;
if( newweapon < 0 )
{
newweapon = maxweapon;
}
if( newweapon > maxweapon )
{
newweapon = wp_fist;
}
if( player->weaponowned[newweapon] && newweapon != player->readyweapon )
@ -355,7 +402,8 @@ void P_PlayerThink (player_t* player)
}
}
}
else {
else
{
newweapon = ( weapontype_t )( ( cmd->buttons & BT_WEAPONMASK ) >> BT_WEAPONSHIFT );
@ -375,7 +423,8 @@ void P_PlayerThink (player_t* player)
newweapon = wp_supershotgun;
}
if ( player->weaponowned[ newweapon ] && newweapon != player->readyweapon ) {
if( player->weaponowned[ newweapon ] && newweapon != player->readyweapon )
{
player->pendingweapon = newweapon;
}
}
@ -391,7 +440,9 @@ void P_PlayerThink (player_t* player)
}
}
else
{
player->usedown = false;
}
// cycle psprites
P_MovePsprites( player );
@ -400,26 +451,40 @@ void P_PlayerThink (player_t* player)
// Strength counts up to diminish fade.
if( player->powers[pw_strength] )
{
player->powers[pw_strength]++;
}
if( player->powers[pw_invulnerability] )
{
player->powers[pw_invulnerability]--;
}
if( player->powers[pw_invisibility] )
if( ! --player->powers[pw_invisibility] )
{
player->mo->flags &= ~MF_SHADOW;
}
if( player->powers[pw_infrared] )
{
player->powers[pw_infrared]--;
}
if( player->powers[pw_ironfeet] )
{
player->powers[pw_ironfeet]--;
}
if( player->damagecount )
{
player->damagecount--;
}
if( player->bonuscount )
{
player->bonuscount--;
}
// Handling ::g->colormaps.
@ -427,10 +492,14 @@ void P_PlayerThink (player_t* player)
{
if( player->powers[pw_invulnerability] > 4 * 32
|| ( player->powers[pw_invulnerability] & 8 ) )
{
player->fixedcolormap = INVERSECOLORMAP;
}
else
{
player->fixedcolormap = 0;
}
}
else if( player->powers[pw_infrared] )
{
if( player->powers[pw_infrared] > 4 * 32
@ -440,11 +509,15 @@ void P_PlayerThink (player_t* player)
player->fixedcolormap = 1;
}
else
{
player->fixedcolormap = 0;
}
}
else
{
player->fixedcolormap = 0;
}
}

View file

@ -100,7 +100,9 @@ R_ClipSolidWallSegment
// (adjacent pixels are touching).
start = ::g->solidsegs;
while( start->last < first - 1 )
{
start++;
}
if( first < start->first )
{
@ -130,7 +132,9 @@ R_ClipSolidWallSegment
// Bottom contained in start?
if( last <= start->last )
{
return;
}
next = start;
while( last >= ( next + 1 )->first - 1 )
@ -192,7 +196,9 @@ R_ClipPassWallSegment
// (adjacent pixels are touching).
start = ::g->solidsegs;
while( start->last < first - 1 )
{
start++;
}
if( first < start->first )
{
@ -209,7 +215,9 @@ R_ClipPassWallSegment
// Bottom contained in start?
if( last <= start->last )
{
return;
}
while( last >= ( start + 1 )->first - 1 )
{
@ -218,8 +226,10 @@ R_ClipPassWallSegment
start++;
if( last <= start->last )
{
return;
}
}
// There is a fragment after *next.
R_StoreWallRange( start->last + 1, last );
@ -265,7 +275,9 @@ void R_AddLine (seg_t* line)
// Back side? I.e. backface culling?
if( span >= ANG180 )
{
return;
}
extern angle_t GetViewAngle();
// Global angle needed by segcalc.
@ -280,7 +292,9 @@ void R_AddLine (seg_t* line)
// Totally off the left edge?
if( tspan >= span )
{
return;
}
angle1 = ::g->clipangle;
}
@ -291,7 +305,9 @@ void R_AddLine (seg_t* line)
// Totally off the left edge?
if( tspan >= span )
{
return;
}
angle2 = -::g->clipangle; // ALANHACK UNSIGNED
}
@ -304,23 +320,31 @@ void R_AddLine (seg_t* line)
// Does not cross a pixel?
if( x1 == x2 )
{
return;
}
::g->backsector = line->backsector;
// Single sided line?
if( !::g->backsector )
{
goto clipsolid;
}
// Closed door.
if( ::g->backsector->ceilingheight <= ::g->frontsector->floorheight
|| ::g->backsector->floorheight >= ::g->frontsector->ceilingheight )
{
goto clipsolid;
}
// Window.
if( ::g->backsector->ceilingheight != ::g->frontsector->ceilingheight
|| ::g->backsector->floorheight != ::g->frontsector->floorheight )
{
goto clippass;
}
// Reject empty ::g->lines used for triggers
// and special ::g->events.
@ -374,26 +398,41 @@ qboolean R_CheckBBox (fixed_t* bspcoord)
int sx1;
int sx2;
extern fixed_t GetViewX(); extern fixed_t GetViewY();
extern fixed_t GetViewX();
extern fixed_t GetViewY();
// Find the corners of the box
// that define the edges from current viewpoint.
if( GetViewX() <= bspcoord[BOXLEFT] )
{
boxx = 0;
}
else if( GetViewX() < bspcoord[BOXRIGHT] )
{
boxx = 1;
}
else
{
boxx = 2;
}
if( GetViewY() >= bspcoord[BOXTOP] )
{
boxy = 0;
}
else if( GetViewY() > bspcoord[BOXBOTTOM] )
{
boxy = 1;
}
else
{
boxy = 2;
}
boxpos = ( boxy << 2 ) + boxx;
if( boxpos == 5 )
{
return true;
}
x1 = bspcoord[::g->checkcoord[boxpos][0]];
y1 = bspcoord[::g->checkcoord[boxpos][1]];
@ -409,7 +448,9 @@ qboolean R_CheckBBox (fixed_t* bspcoord)
// Sitting on a line?
if( span >= ANG180 )
{
return true;
}
tspan = angle1 + ::g->clipangle;
@ -419,7 +460,9 @@ qboolean R_CheckBBox (fixed_t* bspcoord)
// Totally off the left edge?
if( tspan >= span )
{
return false;
}
angle1 = ::g->clipangle;
}
@ -430,7 +473,9 @@ qboolean R_CheckBBox (fixed_t* bspcoord)
// Totally off the left edge?
if( tspan >= span )
{
return false;
}
angle2 = -::g->clipangle;// ALANHACK UNSIGNED
}
@ -446,12 +491,16 @@ qboolean R_CheckBBox (fixed_t* bspcoord)
// Does not cross a pixel.
if( sx1 == sx2 )
{
return false;
}
sx2--;
start = ::g->solidsegs;
while( start->last < sx2 )
{
start++;
}
if( sx1 >= start->first
&& sx2 <= start->last )
@ -497,7 +546,9 @@ void R_Subsector (int num)
::g->frontsector->lightlevel );
}
else
{
::g->floorplane = NULL;
}
if( ::g->frontsector->ceilingheight > ::g->viewz
|| ::g->frontsector->ceilingpic == ::g->skyflatnum )
@ -507,7 +558,9 @@ void R_Subsector (int num)
::g->frontsector->lightlevel );
}
else
{
::g->ceilingplane = NULL;
}
R_AddSprites( ::g->frontsector );
@ -535,15 +588,20 @@ void R_RenderBSPNode (int bspnum)
if( bspnum & NF_SUBSECTOR )
{
if( bspnum == -1 )
{
R_Subsector( 0 );
}
else
{
R_Subsector( bspnum & ( ~NF_SUBSECTOR ) );
}
return;
}
bsp = &::g->nodes[bspnum];
extern fixed_t GetViewX(); extern fixed_t GetViewY();
extern fixed_t GetViewX();
extern fixed_t GetViewY();
// Decide which side the view point is on.
side = R_PointOnSide( GetViewX(), GetViewY(), bsp );
@ -552,8 +610,10 @@ void R_RenderBSPNode (int bspnum)
// Possibly divide back space.
if( R_CheckBBox( bsp->bbox[side ^ 1] ) )
{
R_RenderBSPNode( bsp->children[side ^ 1] );
}
}

View file

@ -145,10 +145,14 @@ R_DrawColumnInCache
}
if( position + count > cacheheight )
{
count = cacheheight - position;
}
if( count > 0 )
{
memcpy( cache + position, source, count );
}
patch = ( postColumn_t* )( ( byte* )patch + patch->length + 4 );
}
@ -197,18 +201,26 @@ void R_GenerateComposite (int texnum)
x2 = x1 + SHORT( realpatch->width );
if( x1 < 0 )
{
x = 0;
}
else
{
x = x1;
}
if( x2 > texture->width )
{
x2 = texture->width;
}
for( ; x < x2 ; x++ )
{
// Column does not have multiple patches?
if( collump[x] >= 0 )
{
continue;
}
patchcol = ( postColumn_t* )( ( byte* )realpatch
+ LONG( realpatch->columnofs[x - x1] ) );
@ -263,12 +275,18 @@ void R_GenerateLookup (int texnum)
x2 = x1 + SHORT( realpatch->width );
if( x1 < 0 )
{
x = 0;
}
else
{
x = x1;
}
if( x2 > texture->width )
{
x2 = texture->width;
}
for( ; x < x2 ; x++ )
{
patchcount[x]++;
@ -323,10 +341,14 @@ R_GetColumn
ofs = ::g->s_texturecolumnofs[tex][col];
if( lump > 0 )
{
return ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ) + ofs;
}
if( !::g->s_texturecomposite[tex] )
{
R_GenerateComposite( tex );
}
return ::g->s_texturecomposite[tex] + ofs;
}
@ -430,16 +452,22 @@ void R_InitTextures (void)
temp3 = ( ( temp2 - temp1 + 63 ) / 64 ) + ( ( ::g->s_numtextures + 63 ) / 64 );
I_Printf( "[" );
for( i = 0; i < temp3; i++ )
{
I_Printf( " " );
}
I_Printf( " ]" );
for( i = 0; i < temp3; i++ )
{
I_Printf( "\x8" );
}
I_Printf( "\x8\x8\x8\x8\x8\x8\x8\x8\x8\x8" );
for( i = 0 ; i < ::g->s_numtextures ; i++, directory++ )
{
if( !( i & 63 ) )
{
I_Printf( "." );
}
if( i == numtextures1 )
{
@ -452,7 +480,9 @@ void R_InitTextures (void)
offset = LONG( *directory );
if( offset > maxoff )
{
I_Error( "R_InitTextures: bad texture directory" );
}
mtexture = ( maptexture_t* )( ( byte* )maptex + offset );
@ -483,7 +513,9 @@ void R_InitTextures (void)
j = 1;
while( j * 2 <= texture->width )
{
j <<= 1;
}
::g->s_texturewidthmask[i] = j - 1;
::g->s_textureheight[i] = texture->height << FRACBITS;
@ -493,21 +525,27 @@ void R_InitTextures (void)
Z_Free( maptex1 );
if( maptex2 )
{
Z_Free( maptex2 );
}
// Precalculate whatever possible.
for( i = 0 ; i < ::g->s_numtextures ; i++ )
{
R_GenerateLookup( i );
}
}
// ALAN: These animations are done globally -- can it be shared?
// Create translation table for global animation.
::g->texturetranslation = ( int* )DoomLib::Z_Malloc( ( ::g->s_numtextures + 1 ) * 4, PU_STATIC, 0 );
for( i = 0 ; i < ::g->s_numtextures ; i++ )
{
::g->texturetranslation[i] = i;
}
}
@ -526,8 +564,10 @@ void R_InitFlats (void)
::g->flattranslation = ( int* )DoomLib::Z_Malloc( ( ::g->numflats + 1 ) * 4, PU_STATIC, 0 );
for( i = 0 ; i < ::g->numflats ; i++ )
{
::g->flattranslation[i] = i;
}
}
//
@ -552,7 +592,9 @@ void R_InitSpriteLumps (void)
for( i = 0 ; i < ::g->numspritelumps ; i++ )
{
if( !( i & 63 ) )
{
I_Printf( "." );
}
patch = ( patch_t* )W_CacheLumpNum( ::g->firstspritelump + i, PU_CACHE_SHARED );
::g->spritewidth[i] = SHORT( patch->width ) << FRACBITS;
@ -635,11 +677,15 @@ int R_CheckTextureNumForName (const char *name)
// "NoTexture" marker.
if( name[0] == '-' )
{
return 0;
}
for( i = 0 ; i < ::g->s_numtextures ; i++ )
if( !idStr::Icmpn( ::g->s_textures[i]->name, name, 8 ) )
{
return i;
}
return -1;
}
@ -685,7 +731,9 @@ void R_PrecacheLevel (void)
spriteframe_t* sf;
if( ::g->demoplayback )
{
return;
}
// Precache flats.
std::vector<char> flatpresent( ::g->numflats, 0 );
@ -730,7 +778,9 @@ void R_PrecacheLevel (void)
for( i = 0 ; i < ::g->s_numtextures ; i++ )
{
if( !texturepresent[i] )
{
continue;
}
texture = ::g->s_textures[i];
@ -748,14 +798,18 @@ void R_PrecacheLevel (void)
for( th = ::g->thinkercap.next ; th != &::g->thinkercap ; th = th->next )
{
if( th->function.acp1 == ( actionf_p1 )P_MobjThinker )
{
spritepresent[( ( mobj_t* )th )->sprite] = 1;
}
}
::g->spritememory = 0;
for( i = 0 ; i < ::g->numsprites ; i++ )
{
if( !spritepresent[i] )
{
continue;
}
for( j = 0 ; j < ::g->sprites[i].numframes ; j++ )
{

View file

@ -94,14 +94,17 @@ void R_DrawColumn ( lighttable_t * dc_colormap,
count = ::g->dc_yh - ::g->dc_yl;
// Zero length, column does not exceed a pixel.
if (count >= 0) {
if( count >= 0 )
{
//return;
#ifdef RANGECHECK
if( ( unsigned )::g->dc_x >= SCREENWIDTH
|| ::g->dc_yl < 0
|| ::g->dc_yh >= SCREENHEIGHT )
{
I_Error( "R_DrawColumn: %i to %i at %i", ::g->dc_yl, ::g->dc_yh, ::g->dc_x );
}
#endif
// Framebuffer destination address.
@ -128,7 +131,8 @@ void R_DrawColumn ( lighttable_t * dc_colormap,
frac += fracstep;
dest += SCREENWIDTH;
} while (count--);
}
while( count-- );
}
}
@ -206,7 +210,9 @@ void R_DrawColumnLow ( lighttable_t * dc_colormap,
// Zero length.
if( count < 0 )
{
return;
}
#ifdef RANGECHECK
if( ( unsigned )::g->dc_x >= SCREENWIDTH
@ -235,7 +241,8 @@ void R_DrawColumnLow ( lighttable_t * dc_colormap,
dest2 += SCREENWIDTH;
frac += fracstep;
} while (count--);
}
while( count-- );
}
@ -265,17 +272,23 @@ void R_DrawFuzzColumn ( lighttable_t * dc_colormap,
// Adjust borders. Low...
if( !::g->dc_yl )
{
::g->dc_yl = 1;
}
// .. and high.
if( ::g->dc_yh == ::g->viewheight - 1 )
{
::g->dc_yh = ::g->viewheight - 2;
}
count = ::g->dc_yh - ::g->dc_yl;
// Zero length.
if( count < 0 )
{
return;
}
#ifdef RANGECHECK
@ -333,12 +346,15 @@ void R_DrawFuzzColumn ( lighttable_t * dc_colormap,
// Clamp table lookup index.
if( ++::g->fuzzpos == FUZZTABLE )
{
::g->fuzzpos = 0;
}
dest += SCREENWIDTH;
frac += fracstep;
} while (count--);
}
while( count-- );
}
@ -364,7 +380,9 @@ void R_DrawTranslatedColumn ( lighttable_t * dc_colormap,
count = ::g->dc_yh - ::g->dc_yl;
if( count < 0 )
{
return;
}
#ifdef RANGECHECK
if( ( unsigned )::g->dc_x >= SCREENWIDTH
@ -416,7 +434,8 @@ void R_DrawTranslatedColumn ( lighttable_t * dc_colormap,
dest += SCREENWIDTH;
frac += fracstep;
} while (count--);
}
while( count-- );
}
@ -511,7 +530,8 @@ void R_DrawSpan ( fixed_t xfrac,
// We do not check for zero spans here?
count = ds_x2 - g->ds_x1;
if ( ds_x2 < ds_x1 ) {
if( ds_x2 < ds_x1 )
{
return; // SMF - think this is the sky
}
@ -528,7 +548,8 @@ void R_DrawSpan ( fixed_t xfrac,
xfrac += ds_xstep;
yfrac += ds_ystep;
} while (count--);
}
while( count-- );
}
@ -654,7 +675,8 @@ void R_DrawSpanLow ( fixed_t xfrac,
xfrac += ::g->ds_xstep;
yfrac += ::g->ds_ystep;
} while (count--);
}
while( count-- );
}
//
@ -678,18 +700,26 @@ R_InitBuffer
// Column offset. For windows.
for( i = 0 ; i < width ; i++ )
{
::g->columnofs[i] = ::g->viewwindowx + i;
}
// Samw with base row offset.
if( width == SCREENWIDTH )
{
::g->viewwindowy = 0;
}
else
{
::g->viewwindowy = ( SCREENHEIGHT - SBARHEIGHT - height ) >> 1;
}
// Preclaculate all row offsets.
for( i = 0 ; i < height ; i++ )
{
::g->ylookup[i] = ::g->screens[0] + ( i +::g->viewwindowy ) * SCREENWIDTH;
}
}
@ -717,18 +747,26 @@ void R_FillBackScreen (void)
char* name;
if( ::g->scaledviewwidth == SCREENWIDTH )
{
return;
}
if( ::g->gamemode == commercial )
{
name = name2;
}
else
{
name = name1;
}
src = ( byte* )W_CacheLumpName( name, PU_CACHE_SHARED );
dest = ::g->screens[1];
for (y=0 ; y<SCREENHEIGHT-SBARHEIGHT ; y++) {
for (x=0 ; x<SCREENWIDTH/64 ; x++) {
for( y = 0 ; y < SCREENHEIGHT - SBARHEIGHT ; y++ )
{
for( x = 0 ; x < SCREENWIDTH / 64 ; x++ )
{
memcpy( dest, src + ( ( y & 63 ) << 6 ), 64 );
dest += 64;
}
@ -745,22 +783,26 @@ void R_FillBackScreen (void)
windowy = ::g->viewwindowy / GLOBAL_IMAGE_SCALER;
patch = ( patch_t* )W_CacheLumpName( "brdr_t", PU_CACHE_SHARED );
for (x=0 ; x<width ; x+=8) {
for( x = 0 ; x < width ; x += 8 )
{
V_DrawPatch( windowx + x, windowy - 8, 1, patch );
}
patch = ( patch_t* )W_CacheLumpName( "brdr_b", PU_CACHE_SHARED );
for (x=0 ; x<width ; x+=8) {
for( x = 0 ; x < width ; x += 8 )
{
V_DrawPatch( windowx + x, windowy + height, 1, patch );
}
patch = ( patch_t* )W_CacheLumpName( "brdr_l", PU_CACHE_SHARED );
for (y=0 ; y<height ; y+=8) {
for( y = 0 ; y < height ; y += 8 )
{
V_DrawPatch( windowx - 8, windowy + y, 1, patch );
}
patch = ( patch_t* )W_CacheLumpName( "brdr_r", PU_CACHE_SHARED );
for (y=0 ; y<height ; y+=8) {
for( y = 0 ; y < height ; y += 8 )
{
V_DrawPatch( windowx + width, windowy + y, 1, patch );
}
@ -809,7 +851,9 @@ void R_DrawViewBorder (void)
int i;
if( ::g->scaledviewwidth == SCREENWIDTH )
{
return;
}
top = ( ( SCREENHEIGHT - SBARHEIGHT ) -::g->viewheight ) / 2;
side = ( SCREENWIDTH -::g->scaledviewwidth ) / 2;

View file

@ -128,14 +128,22 @@ R_AddPointToBox
fixed_t* box )
{
if( x < box[BOXLEFT] )
{
box[BOXLEFT] = x;
}
if( x > box[BOXRIGHT] )
{
box[BOXRIGHT] = x;
}
if( y < box[BOXBOTTOM] )
{
box[BOXBOTTOM] = y;
}
if( y > box[BOXTOP] )
{
box[BOXTOP] = y;
}
}
//
@ -158,14 +166,18 @@ R_PointOnSide
if( !node->dx )
{
if( x <= node->x )
{
return node->dy > 0;
}
return node->dy < 0;
}
if( !node->dy )
{
if( y <= node->y )
{
return node->dx < 0;
}
return node->dx > 0;
}
@ -221,14 +233,18 @@ R_PointOnSegSide
if( !ldx )
{
if( x <= lx )
{
return ldy > 0;
}
return ldy < 0;
}
if( !ldy )
{
if( y <= ly )
{
return ldx < 0;
}
return ldx > 0;
}
@ -279,12 +295,15 @@ R_PointToAngle
( fixed_t x,
fixed_t y )
{
extern fixed_t GetViewX(); extern fixed_t GetViewY();
extern fixed_t GetViewX();
extern fixed_t GetViewY();
x -= GetViewX();
y -= GetViewY();
if( ( !x ) && ( !y ) )
{
return 0;
}
if( x >= 0 )
{
@ -368,7 +387,8 @@ R_PointToAngle2
fixed_t x2,
fixed_t y2 )
{
extern void SetViewX( fixed_t ); extern void SetViewY( fixed_t );
extern void SetViewX( fixed_t );
extern void SetViewY( fixed_t );
SetViewX( x1 );
SetViewY( y1 );
@ -387,7 +407,8 @@ R_PointToDist
fixed_t temp;
fixed_t dist;
extern fixed_t GetViewX(); extern fixed_t GetViewY();
extern fixed_t GetViewX();
extern fixed_t GetViewY();
dx = abs( x - GetViewX() );
dy = abs( y - GetViewY() );
@ -484,12 +505,18 @@ fixed_t R_ScaleFromGlobalAngle (angle_t visangle)
scale = FixedDiv( num, den );
if( scale > 64 * FRACUNIT )
{
scale = 64 * FRACUNIT;
}
else if( scale < 256 )
{
scale = 256;
}
}
else
{
scale = 64 * FRACUNIT;
}
return scale;
}
@ -553,19 +580,27 @@ void R_InitTextureMapping (void)
for( i = 0 ; i < FINEANGLES / 2 ; i++ )
{
if( finetangent[i] > FRACUNIT * 2 )
{
t = -1;
}
else if( finetangent[i] < -FRACUNIT * 2 )
{
t = ::g->viewwidth + 1;
}
else
{
t = FixedMul( finetangent[i], focallength );
t = ( ::g->centerxfrac - t + FRACUNIT - 1 ) >> FRACBITS;
if( t < -1 )
{
t = -1;
}
else if( t >::g->viewwidth + 1 )
{
t = ::g->viewwidth + 1;
}
}
::g->viewangletox[i] = t;
}
@ -576,7 +611,9 @@ void R_InitTextureMapping (void)
{
i = 0;
while( ::g->viewangletox[i] > x )
{
i++;
}
::g->xtoviewangle[x] = ( i << ANGLETOFINESHIFT ) - ANG90;
}
@ -587,10 +624,14 @@ void R_InitTextureMapping (void)
t = ::g->centerx - t;
if( ::g->viewangletox[i] == -1 )
{
::g->viewangletox[i] = 0;
}
else if( ::g->viewangletox[i] == ::g->viewwidth + 1 )
{
::g->viewangletox[i] = ::g->viewwidth;
}
}
::g->clipangle = ::g->xtoviewangle[0];
}
@ -623,10 +664,14 @@ void R_InitLightTables (void)
level = nocollide_startmap - scale / DISTMAP;
if( level < 0 )
{
level = 0;
}
if( level >= NUMCOLORMAPS )
{
level = NUMCOLORMAPS - 1;
}
::g->zlight[i][j] = ::g->colormaps + level * 256;
}
@ -717,7 +762,9 @@ void R_ExecuteSetViewSize (void)
// thing clipping
for( i = 0 ; i < ::g->viewwidth ; i++ )
{
::g->screenheightarray[i] = ::g->viewheight;
}
// planes
for( i = 0 ; i < ::g->viewheight ; i++ )
@ -743,10 +790,14 @@ void R_ExecuteSetViewSize (void)
level = nocollide_startmap - j * SCREENWIDTH / ( ::g->viewwidth << ::g->detailshift ) / DISTMAP;
if( level < 0 )
{
level = 0;
}
if( level >= NUMCOLORMAPS )
{
level = NUMCOLORMAPS - 1;
}
::g->scalelight[i][j] = ::g->colormaps + level * 256;
}
@ -799,7 +850,9 @@ R_PointInSubsector
// single subsector is a special case
if( !::g->numnodes )
{
return ::g->subsectors;
}
nodenum = ::g->numnodes - 1;
@ -823,7 +876,9 @@ void R_SetupFrame (player_t* player)
int i;
::g->viewplayer = player;
extern void SetViewX( fixed_t ); extern void SetViewY( fixed_t ); extern void SetViewAngle( angle_t );
extern void SetViewX( fixed_t );
extern void SetViewY( fixed_t );
extern void SetViewAngle( angle_t );
SetViewX( player->mo->x );
SetViewY( player->mo->y );
SetViewAngle( player->mo->angle + ::g->viewangleoffset );
@ -847,10 +902,14 @@ void R_SetupFrame (player_t* player)
::g->walllights = ::g->scalelightfixed;
for( i = 0 ; i < MAXLIGHTSCALE ; i++ )
{
::g->scalelightfixed[i] = ::g->fixedcolormap;
}
}
else
{
::g->fixedcolormap = 0;
}
::g->framecount++;
::g->validcount++;
@ -863,7 +922,8 @@ void R_SetupFrame (player_t* player)
//
void R_RenderPlayerView( player_t* player )
{
if ( player->mo == NULL ) {
if( player->mo == NULL )
{
return;
}

View file

@ -130,18 +130,23 @@ R_MapPlane
extern angle_t GetViewAngle();
length = FixedMul( distance, ::g->distscale[x1] );
angle = ( GetViewAngle() + ::g->xtoviewangle[x1] ) >> ANGLETOFINESHIFT;
extern fixed_t GetViewX(); extern fixed_t GetViewY();
extern fixed_t GetViewX();
extern fixed_t GetViewY();
::g->ds_xfrac = GetViewX() + FixedMul( finecosine[angle], length );
::g->ds_yfrac = -GetViewY() - FixedMul( finesine[angle], length );
if( ::g->fixedcolormap )
{
::g->ds_colormap = ::g->fixedcolormap;
}
else
{
index = distance >> LIGHTZSHIFT;
if( index >= MAXLIGHTZ )
{
index = MAXLIGHTZ - 1;
}
::g->ds_colormap = ::g->planezlight[index];
}
@ -201,26 +206,33 @@ void R_ClearPlanes (void)
//
// R_FindPlane
//
visplane_t* R_FindPlane( fixed_t height, int picnum, int lightlevel ) {
visplane_t* R_FindPlane( fixed_t height, int picnum, int lightlevel )
{
visplane_t* check;
if (picnum == ::g->skyflatnum) {
if( picnum == ::g->skyflatnum )
{
height = 0; // all skys map together
lightlevel = 0;
}
for (check=::g->visplanes; check < ::g->lastvisplane; check++) {
if (height == check->height && picnum == check->picnum && lightlevel == check->lightlevel) {
for( check =::g->visplanes; check < ::g->lastvisplane; check++ )
{
if( height == check->height && picnum == check->picnum && lightlevel == check->lightlevel )
{
break;
}
}
if( check < ::g->lastvisplane )
{
return check;
}
//if (::g->lastvisplane - ::g->visplanes == MAXVISPLANES)
//I_Error ("R_FindPlane: no more visplanes");
if ( ::g->lastvisplane - ::g->visplanes == MAXVISPLANES ) {
if( ::g->lastvisplane - ::g->visplanes == MAXVISPLANES )
{
check = ::g->visplanes;
return check;
}
@ -278,7 +290,9 @@ R_CheckPlane
for( x = intrl ; x <= intrh ; x++ )
if( pl->top[x] != 0xffff )
{
break;
}
if( x > intrh )
{
@ -289,7 +303,8 @@ R_CheckPlane
return pl;
}
if ( ::g->lastvisplane - ::g->visplanes == MAXVISPLANES ) {
if( ::g->lastvisplane - ::g->visplanes == MAXVISPLANES )
{
return pl;
}
@ -373,7 +388,9 @@ void R_DrawPlanes (void)
for( pl = ::g->visplanes ; pl < ::g->lastvisplane ; pl++ )
{
if( pl->minx > pl->maxx )
{
continue;
}
// sky flat
@ -413,10 +430,14 @@ void R_DrawPlanes (void)
light = ( pl->lightlevel >> LIGHTSEGSHIFT ) +::g->extralight;
if( light >= LIGHTLEVELS )
{
light = LIGHTLEVELS - 1;
}
if( light < 0 )
{
light = 0;
}
::g->planezlight = ::g->zlight[light];

View file

@ -93,16 +93,26 @@ R_RenderMaskedSegRange
lightnum = ( ::g->frontsector->lightlevel >> LIGHTSEGSHIFT ) +::g->extralight;
if( ::g->curline->v1->y == ::g->curline->v2->y )
{
lightnum--;
}
else if( ::g->curline->v1->x == ::g->curline->v2->x )
{
lightnum++;
}
if( lightnum < 0 )
{
::g->walllights = ::g->scalelight[0];
}
else if( lightnum >= LIGHTLEVELS )
{
::g->walllights = ::g->scalelight[LIGHTLEVELS - 1];
}
else
{
::g->walllights = ::g->scalelight[lightnum];
}
::g->maskedtexturecol = ds->maskedtexturecol;
@ -127,7 +137,9 @@ R_RenderMaskedSegRange
::g->dc_texturemid += ::g->curline->sidedef->rowoffset;
if( ::g->fixedcolormap )
{
::g->dc_colormap = ::g->fixedcolormap;
}
// draw the columns
for( ::g->dc_x = x1 ; ::g->dc_x <= x2 ; ::g->dc_x++ )
@ -140,7 +152,9 @@ R_RenderMaskedSegRange
index = ::g->spryscale >> LIGHTSCALESHIFT;
if( index >= MAXLIGHTSCALE )
{
index = MAXLIGHTSCALE - 1;
}
::g->dc_colormap = ::g->walllights[index];
}
@ -192,7 +206,9 @@ void R_RenderSegLoop (void)
// no space above wall?
if( yl < ::g->ceilingclip[::g->rw_x] + 1 )
{
yl = ::g->ceilingclip[::g->rw_x] + 1;
}
if( ::g->markceiling )
{
@ -200,7 +216,9 @@ void R_RenderSegLoop (void)
bottom = yl - 1;
if( bottom >= ::g->floorclip[::g->rw_x] )
{
bottom = ::g->floorclip[::g->rw_x] - 1;
}
if( top <= bottom )
{
@ -212,14 +230,18 @@ void R_RenderSegLoop (void)
yh = ::g->bottomfrac >> HEIGHTBITS;
if( yh >= ::g->floorclip[::g->rw_x] )
{
yh = ::g->floorclip[::g->rw_x] - 1;
}
if( ::g->markfloor )
{
top = yh + 1;
bottom = ::g->floorclip[::g->rw_x] - 1;
if( top <= ::g->ceilingclip[::g->rw_x] )
{
top = ::g->ceilingclip[::g->rw_x] + 1;
}
if( top <= bottom )
{
::g->floorplane->top[::g->rw_x] = top;
@ -238,7 +260,9 @@ void R_RenderSegLoop (void)
index = ::g->rw_scale >> LIGHTSCALESHIFT;
if( index >= MAXLIGHTSCALE )
{
index = MAXLIGHTSCALE - 1;
}
::g->dc_colormap = ::g->walllights[index];
::g->dc_x = ::g->rw_x;
@ -267,7 +291,9 @@ void R_RenderSegLoop (void)
::g->pixhigh += ::g->pixhighstep;
if( mid >= ::g->floorclip[::g->rw_x] )
{
mid = ::g->floorclip[::g->rw_x] - 1;
}
if( mid >= yl )
{
@ -279,14 +305,18 @@ void R_RenderSegLoop (void)
::g->ceilingclip[::g->rw_x] = mid;
}
else
{
::g->ceilingclip[::g->rw_x] = yl - 1;
}
}
else
{
// no top wall
if( ::g->markceiling )
{
::g->ceilingclip[::g->rw_x] = yl - 1;
}
}
if( ::g->bottomtexture )
{
@ -296,7 +326,9 @@ void R_RenderSegLoop (void)
// no space above wall?
if( mid <= ::g->ceilingclip[::g->rw_x] )
{
mid = ::g->ceilingclip[::g->rw_x] + 1;
}
if( mid <= yh )
{
@ -309,14 +341,18 @@ void R_RenderSegLoop (void)
::g->floorclip[::g->rw_x] = mid;
}
else
{
::g->floorclip[::g->rw_x] = yh + 1;
}
}
else
{
// no bottom wall
if( ::g->markfloor )
{
::g->floorclip[::g->rw_x] = yh + 1;
}
}
if( ::g->maskedtexture )
{
@ -353,11 +389,15 @@ R_StoreWallRange
// don't overflow and crash
if( ::g->ds_p == &::g->drawsegs[MAXDRAWSEGS] )
{
return;
}
#ifdef RANGECHECK
if( start >=::g->viewwidth || start > stop )
{
I_Error( "Bad R_RenderWallRange: %i to %i", start , stop );
}
#endif
::g->sidedef = ::g->curline->sidedef;
@ -371,7 +411,9 @@ R_StoreWallRange
offsetangle = abs( ( int )( ::g->rw_normalangle -::g->rw_angle1 ) );
if( offsetangle > ANG90 )
{
offsetangle = ANG90;
}
distangle = ANG90 - offsetangle;
hyp = R_PointToDist( ::g->curline->v1->x, ::g->curline->v1->y );
@ -404,7 +446,8 @@ R_StoreWallRange
fixed_t trx, try;
fixed_t gxt, gyt;
extern fixed_t GetViewX(); extern fixed_t GetViewY();
extern fixed_t GetViewX();
extern fixed_t GetViewY();
trx = ::g->curline->v1->x - GetViewX();
try = ::g->curline->v1->y - GetVewY();
@ -569,8 +612,10 @@ R_StoreWallRange
::g->rw_bottomtexturemid = ::g->worldtop;
}
else // top of texture at top
{
::g->rw_bottomtexturemid = ::g->worldlow;
}
}
::g->rw_toptexturemid += ::g->sidedef->rowoffset;
::g->rw_bottomtexturemid += ::g->sidedef->rowoffset;
@ -592,16 +637,22 @@ R_StoreWallRange
offsetangle = ::g->rw_normalangle -::g->rw_angle1;
if( offsetangle > ANG180 )
{
offsetangle = -offsetangle; // ALANHACK UNSIGNED
}
if( offsetangle > ANG90 )
{
offsetangle = ANG90;
}
sineval = finesine[offsetangle >> ANGLETOFINESHIFT];
::g->rw_offset = FixedMul( hyp, sineval );
if( ::g->rw_normalangle -::g->rw_angle1 < ANG180 )
{
::g->rw_offset = -::g->rw_offset;
}
::g->rw_offset += ::g->sidedef->textureoffset + ::g->curline->offset;
::g->rw_centerangle = ANG90 + GetViewAngle() - ::g->rw_normalangle;
@ -615,18 +666,28 @@ R_StoreWallRange
lightnum = ( ::g->frontsector->lightlevel >> LIGHTSEGSHIFT ) +::g->extralight;
if( ::g->curline->v1->y == ::g->curline->v2->y )
{
lightnum--;
}
else if( ::g->curline->v1->x == ::g->curline->v2->x )
{
lightnum++;
}
if( lightnum < 0 )
{
::g->walllights = ::g->scalelight[0];
}
else if( lightnum >= LIGHTLEVELS )
{
::g->walllights = ::g->scalelight[LIGHTLEVELS - 1];
}
else
{
::g->walllights = ::g->scalelight[lightnum];
}
}
}
// if a floor / ceiling plane is on the wrong side
// of the view plane, it is definitely invisible
@ -677,10 +738,14 @@ R_StoreWallRange
// render it
if( ::g->markceiling )
{
::g->ceilingplane = R_CheckPlane( ::g->ceilingplane, ::g->rw_x, ::g->rw_stopx - 1 );
}
if( ::g->markfloor )
{
::g->floorplane = R_CheckPlane( ::g->floorplane, ::g->rw_x, ::g->rw_stopx - 1 );
}
R_RenderSegLoop();

View file

@ -99,7 +99,9 @@ R_InstallSpriteLump
"Bad frame characters in lump %i", lump );
if( ( int )frame > ::g->maxframe )
{
::g->maxframe = frame;
}
if( rotation == 0 )
{
@ -172,12 +174,16 @@ void R_InitSpriteDefs (const char* const* namelist)
// count the number of sprite names
check = namelist;
while( *check != NULL )
{
check++;
}
::g->numsprites = check - namelist;
if( !::g->numsprites )
{
return;
}
::g->sprites = ( spritedef_t* )DoomLib::Z_Malloc( ::g->numsprites * sizeof( *::g->sprites ), PU_STATIC, NULL );
@ -205,9 +211,13 @@ void R_InitSpriteDefs (const char* const* namelist)
rotation = lumpinfo[l].name[5] - '0';
if( ::g->modifiedgame )
{
patched = W_GetNumForName( lumpinfo[l].name );
}
else
{
patched = l;
}
R_InstallSpriteLump( patched, frame, rotation, false );
@ -307,7 +317,9 @@ void R_ClearSprites (void)
vissprite_t* R_NewVisSprite( void )
{
if( ::g->vissprite_p == &::g->vissprites[MAXVISSPRITES] )
{
return &::g->overflowsprite;
}
::g->vissprite_p++;
return ::g->vissprite_p - 1;
@ -342,9 +354,13 @@ void R_DrawMaskedColumn (postColumn_t* column)
::g->dc_yh = ( bottomscreen - 1 ) >> FRACBITS;
if( ::g->dc_yh >= ::g->mfloorclip[::g->dc_x] )
{
::g->dc_yh = ::g->mfloorclip[::g->dc_x] - 1;
}
if( ::g->dc_yl <= ::g->mceilingclip[::g->dc_x] )
{
::g->dc_yl = ::g->mceilingclip[::g->dc_x] + 1;
}
if( ::g->dc_yl <= ::g->dc_yh )
{
@ -407,7 +423,9 @@ R_DrawVisSprite
texturecolumn = frac >> FRACBITS;
#ifdef RANGECHECK
if( texturecolumn < 0 || texturecolumn >= SHORT( patch->width ) )
{
I_Error( "R_DrawSpriteRange: bad texturecolumn" );
}
#endif
column = ( postColumn_t* )( ( byte* )patch +
LONG( patch->columnofs[texturecolumn] ) );
@ -459,7 +477,8 @@ void R_ProjectSprite (mobj_t* thing)
fixed_t iscale;
// transform the origin point
extern fixed_t GetViewX(); extern fixed_t GetViewY();
extern fixed_t GetViewX();
extern fixed_t GetViewY();
tr_x = thing->x - GetViewX();
tr_y = thing->y - GetViewY();
@ -470,7 +489,9 @@ void R_ProjectSprite (mobj_t* thing)
// thing is behind view plane?
if( tz < MINZ )
{
return;
}
xscale = FixedDiv( ::g->projection, tz );
@ -480,7 +501,9 @@ void R_ProjectSprite (mobj_t* thing)
// too far off the side?
if( abs( tx ) > ( tz << 2 ) )
{
return;
}
// decide which patch to use for sprite relative to player
#ifdef RANGECHECK
@ -517,14 +540,18 @@ void R_ProjectSprite (mobj_t* thing)
// off the right side?
if( x1 > ::g->viewwidth )
{
return;
}
tx += ::g->spritewidth[lump];
x2 = ( ( ::g->centerxfrac + FixedMul( tx, xscale ) ) >> FRACBITS ) - 1;
// off the left side
if( x2 < 0 )
{
return;
}
// store information in a vissprite
vis = R_NewVisSprite();
@ -551,7 +578,9 @@ void R_ProjectSprite (mobj_t* thing)
}
if( vis->x1 > x1 )
{
vis->startfrac += vis->xiscale * ( vis->x1 - x1 );
}
vis->patch = lump;
// get light level
@ -577,7 +606,9 @@ void R_ProjectSprite (mobj_t* thing)
index = xscale >> ( LIGHTSCALESHIFT -::g->detailshift );
if( index >= MAXLIGHTSCALE )
{
index = MAXLIGHTSCALE - 1;
}
vis->colormap = ::g->spritelights[index];
}
@ -600,7 +631,9 @@ void R_AddSprites (sector_t* sec)
// ::g->subsectors during BSP building.
// Thus we check whether its already added.
if( sec->validcount == ::g->validcount )
{
return;
}
// Well, now it will be done.
sec->validcount = ::g->validcount;
@ -608,16 +641,24 @@ void R_AddSprites (sector_t* sec)
lightnum = ( sec->lightlevel >> LIGHTSEGSHIFT ) +::g->extralight;
if( lightnum < 0 )
{
::g->spritelights = ::g->scalelight[0];
}
else if( lightnum >= LIGHTLEVELS )
{
::g->spritelights = ::g->scalelight[LIGHTLEVELS - 1];
}
else
{
::g->spritelights = ::g->scalelight[lightnum];
}
// Handle all things in sector.
for( thing = sec->thinglist ; thing ; thing = thing->snext )
{
R_ProjectSprite( thing );
}
}
//
@ -660,14 +701,18 @@ void R_DrawPSprite (pspdef_t* psp)
// off the right side
if( x1 > ::g->viewwidth )
{
return;
}
tx += ::g->spritewidth[lump];
x2 = ( ( ::g->centerxfrac + FixedMul( tx, ::g->pspritescale ) ) >> FRACBITS ) - 1;
// off the left side
if( x2 < 0 )
{
return;
}
// store information in a vissprite
vis = &avis;
@ -689,7 +734,9 @@ void R_DrawPSprite (pspdef_t* psp)
}
if( vis->x1 > x1 )
{
vis->startfrac += vis->xiscale * ( vis->x1 - x1 );
}
vis->patch = lump;
@ -735,11 +782,17 @@ void R_DrawPlayerSprites (void)
+::g->extralight;
if( lightnum < 0 )
{
::g->spritelights = ::g->scalelight[0];
}
else if( lightnum >= LIGHTLEVELS )
{
::g->spritelights = ::g->scalelight[LIGHTLEVELS - 1];
}
else
{
::g->spritelights = ::g->scalelight[lightnum];
}
// clip to screen bounds
::g->mfloorclip = ::g->screenheightarray;
@ -751,9 +804,11 @@ void R_DrawPlayerSprites (void)
i++, psp++ )
{
if( psp->state )
{
R_DrawPSprite( psp );
}
}
}
@ -777,7 +832,9 @@ void R_SortVisSprites (void)
unsorted.next = unsorted.prev = &unsorted;
if( !count )
{
return;
}
for( ds =::g->vissprites ; ds < ::g->vissprite_p ; ds++ )
{
@ -831,7 +888,9 @@ void R_DrawSprite (vissprite_t* spr)
int silhouette;
for( x = spr->x1 ; x <= spr->x2 ; x++ )
{
clipbot[x] = cliptop[x] = -2;
}
// Scan ::g->drawsegs from end to start for obscuring ::g->segs.
// The first drawseg that has a greater scale
@ -868,7 +927,9 @@ void R_DrawSprite (vissprite_t* spr)
{
// masked mid texture?
if( ds->maskedtexturecol )
{
R_RenderMaskedSegRange( ds, r1, r2 );
}
// seg is behind sprite
continue;
}
@ -878,36 +939,48 @@ void R_DrawSprite (vissprite_t* spr)
silhouette = ds->silhouette;
if( spr->gz >= ds->bsilheight )
{
silhouette &= ~SIL_BOTTOM;
}
if( spr->gzt <= ds->tsilheight )
{
silhouette &= ~SIL_TOP;
}
if( silhouette == 1 )
{
// bottom sil
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++ )
if( cliptop[x] == -2 )
{
cliptop[x] = ds->sprtopclip[x];
}
}
else if( silhouette == 3 )
{
// both
for( x = r1 ; x <= r2 ; x++ )
{
if( clipbot[x] == -2 )
{
clipbot[x] = ds->sprbottomclip[x];
}
if( cliptop[x] == -2 )
{
cliptop[x] = ds->sprtopclip[x];
}
}
}
}
@ -917,11 +990,15 @@ void R_DrawSprite (vissprite_t* spr)
for( x = spr->x1 ; x <= spr->x2 ; x++ )
{
if( clipbot[x] == -2 )
{
clipbot[x] = ::g->viewheight;
}
if( cliptop[x] == -2 )
{
cliptop[x] = -1;
}
}
::g->mfloorclip = clipbot;
::g->mceilingclip = cliptop;
@ -956,13 +1033,17 @@ void R_DrawMasked (void)
// render any remaining masked mid textures
for( ds =::g->ds_p - 1 ; ds >= ::g->drawsegs ; ds-- )
if( ds->maskedtexturecol )
{
R_RenderMaskedSegRange( ds, ds->x1, ds->x2 );
}
// draw the psprites on top of everything
// but does not draw on side views
if( !::g->viewangleoffset )
{
R_DrawPlayerSprites();
}
}

View file

@ -147,7 +147,9 @@ void S_Init
// Free all ::g->channels for use
for( i = 0 ; i < ::g->numChannels ; i++ )
{
::g->channels[i].sfxinfo = 0;
}
// no sounds are playing, and they are not ::g->mus_paused
::g->mus_paused = 0;
@ -155,8 +157,10 @@ void S_Init
// Note that sounds have not been cached (yet).
for( i = 1 ; i < NUMSFX ; i++ )
{
S_sfx[i].lumpnum = S_sfx[i].usefulness = -1;
}
}
@ -173,16 +177,20 @@ void S_Start(void)
// kill all playing sounds at start of level
// (trust me - a good idea)
if( ::g->channels ) {
if( ::g->channels )
{
for( cnum = 0 ; cnum < ::g->numChannels ; cnum++ )
if( ::g->channels[cnum].sfxinfo )
{
S_StopChannel( cnum );
}
}
// start new music for the level
::g->mus_paused = 0;
if (::g->gamemode == commercial) {
if( ::g->gamemode == commercial )
{
mnum = mus_runnin + ::g->gamemap - 1;
@ -199,7 +207,8 @@ void S_Start(void)
}
else
{
int spmus[] = {
int spmus[] =
{
// Song - Who? - Where?
mus_e3m4, // American e4m1
mus_e3m2, // Romero e4m2
@ -213,10 +222,14 @@ void S_Start(void)
};
if( ::g->gameepisode < 4 )
{
mnum = mus_e1m1 + ( ::g->gameepisode - 1 ) * 9 + ::g->gamemap - 1;
}
else
{
mnum = spmus[::g->gamemap - 1];
}
}
S_StopMusic();
S_ChangeMusic( mnum, true );
@ -252,7 +265,9 @@ S_StartSoundAtVolume
// check for bogus sound #
if( sfx_id < 1 || sfx_id > NUMSFX )
{
I_Error( "Bad sfx #: %d", sfx_id );
}
sfx = &S_sfx[sfx_id];
@ -264,21 +279,29 @@ S_StartSoundAtVolume
volume += sfx->volume;
if( volume < 1 )
{
return;
}
if( volume > s_volume_sound.GetInteger() )
{
volume = s_volume_sound.GetInteger();
}
}
else
{
pitch = NORM_PITCH;
priority = NORM_PRIORITY;
if( volume < 1 )
{
return;
}
if( volume > s_volume_sound.GetInteger() )
{
volume = s_volume_sound.GetInteger();
}
}
@ -301,8 +324,10 @@ S_StartSoundAtVolume
}
if( !rc )
{
return;
}
}
else
{
sep = NORM_SEP;
@ -316,10 +341,14 @@ S_StartSoundAtVolume
pitch += 16 - ( M_Random() & 31 );
if( pitch < 0 )
{
pitch = 0;
}
else if( pitch > 255 )
{
pitch = 255;
}
}
// kill old sound
//S_StopSound(origin);
@ -327,18 +356,23 @@ S_StartSoundAtVolume
// try to find a channel
cnum = S_getChannel( origin, sfx );
if (cnum<0) {
if( cnum < 0 )
{
printf( "No sound channels available for sfxid %d.\n", sfx_id );
return;
}
// get lumpnum if necessary
if( sfx->lumpnum < 0 )
{
sfx->lumpnum = I_GetSfxLumpNum( sfx );
}
// increase the usefulness
if( sfx->usefulness++ < 0 )
{
sfx->usefulness = 1;
}
// Assigns the handle to one of the ::g->channels in the
// mix/output buffer.
@ -428,11 +462,14 @@ void S_UpdateSounds(void* listener_p)
pitch = sfx->pitch;
volume += sfx->volume;
if (volume < 1) {
if( volume < 1 )
{
S_StopChannel( cnum );
continue;
} else if ( volume > s_volume_sound.GetInteger() ) {
}
else if( volume > s_volume_sound.GetInteger() )
{
volume = s_volume_sound.GetInteger();
}
}
@ -441,7 +478,8 @@ void S_UpdateSounds(void* listener_p)
if( c->origin && listener_p != c->origin )
{
audible = S_AdjustSoundParams( listener, ( mobj_t* )c->origin, &volume, &sep, &pitch );
if (!audible) {
if( !audible )
{
S_StopChannel( cnum );
}
}
@ -496,10 +534,14 @@ void S_ChangeMusic ( int musicnum, int looping )
I_Error( "Bad music number %d", musicnum );
}
else
{
music = &::g->S_music[musicnum];
}
if( ::g->mus_playing == music )
{
return;
}
//I_Printf("S_ChangeMusic: Playing new track: '%s'\n", music->name);
@ -520,7 +562,9 @@ void S_StopMusic(void)
if( ::g->mus_playing )
{
if( ::g->mus_paused )
{
I_ResumeSong( ::g->mus_playing->handle );
}
I_StopSong( ::g->mus_playing->handle );
I_UnRegisterSong( ::g->mus_playing->handle );
@ -547,7 +591,9 @@ void S_StopChannel(int cnum)
{
#ifdef SAWDEBUG
if( c->sfxinfo == &S_sfx[sfx_sawful] )
{
I_PrintfE( "stopped\n" );
}
#endif
I_StopSound( c->handle );
}
@ -578,13 +624,15 @@ void S_StopChannel(int cnum)
// If the sound is not audible, returns a 0.
// Otherwise, modifies parameters and returns 1.
//
int S_AdjustSoundParams( mobj_t* listener, mobj_t* source, int* vol, int* sep, int* pitch ) {
int S_AdjustSoundParams( mobj_t* listener, mobj_t* source, int* vol, int* sep, int* pitch )
{
fixed_t approx_dist;
fixed_t adx;
fixed_t ady;
// DHM - Nerve :: Could happen in multiplayer if a player exited the level holding the chainsaw
if ( listener == NULL || source == NULL ) {
if( listener == NULL || source == NULL )
{
return 0;
}
@ -596,7 +644,8 @@ int S_AdjustSoundParams( mobj_t* listener, mobj_t* source, int* vol, int* sep, i
// From _GG1_ p.428. Appox. eucledian distance fast.
approx_dist = adx + ady - ( ( adx < ady ? adx : ady ) >> 1 );
if ( approx_dist > S_CLIPPING_DIST) {
if( approx_dist > S_CLIPPING_DIST )
{
return 0;
}
@ -604,10 +653,12 @@ int S_AdjustSoundParams( mobj_t* listener, mobj_t* source, int* vol, int* sep, i
*sep = NORM_SEP;
// volume calculation
if (approx_dist < S_CLOSE_DIST) {
if( approx_dist < S_CLOSE_DIST )
{
*vol = s_volume_sound.GetInteger();
}
else {
else
{
// distance effect
*vol = ( s_volume_sound.GetInteger()
* ( ( S_CLIPPING_DIST - approx_dist ) >> FRACBITS ) )
@ -638,7 +689,9 @@ S_getChannel
for( cnum = 0 ; cnum < ::g->numChannels ; cnum++ )
{
if( !::g->channels[cnum].sfxinfo )
{
break;
}
else if( origin && ::g->channels[cnum].origin == origin &&
( ::g->channels[cnum].handle == sfx_sawidl || ::g->channels[cnum].handle == sfx_sawful ) )
{
@ -652,7 +705,10 @@ S_getChannel
{
// Look for lower priority
for( cnum = 0 ; cnum < ::g->numChannels ; cnum++ )
if (::g->channels[cnum].sfxinfo->priority >= sfxinfo->priority) break;
if( ::g->channels[cnum].sfxinfo->priority >= sfxinfo->priority )
{
break;
}
if( cnum == ::g->numChannels )
{

View file

@ -111,9 +111,13 @@ STlib_drawNum
if( neg )
{
if( numdigits == 2 && num < -9 )
{
num = -9;
}
else if( numdigits == 3 && num < -99 )
{
num = -99;
}
num = -num;
}
@ -122,19 +126,25 @@ STlib_drawNum
x = n->x - numdigits * w;
if( n->y - ST_Y < 0 )
{
I_Error( "drawNum: n->y - ST_Y < 0" );
}
V_CopyRect( x, n->y - ST_Y, BG, w * numdigits, h, x, n->y, FG );
// if non-number, do not draw it
if( num == 1994 )
{
return;
}
x = n->x;
// in the special case of 0, you draw 0
if( !num )
{
V_DrawPatch( x - w, n->y, FG, n->p[ 0 ] );
}
// draw the new number
while( num && numdigits-- )
@ -146,8 +156,10 @@ STlib_drawNum
// draw a minus sign if necessary
if( neg )
{
V_DrawPatch( x - 8, n->y, FG, ::g->sttminus );
}
}
//
@ -156,7 +168,10 @@ STlib_updateNum
( st_number_t* n,
qboolean refresh )
{
if (*n->on) STlib_drawNum(n, refresh);
if( *n->on )
{
STlib_drawNum( n, refresh );
}
}
@ -184,7 +199,9 @@ STlib_updatePercent
int refresh )
{
if( refresh && *per->n.on )
{
V_DrawPatch( per->n.x, per->n.y, FG, per->p );
}
STlib_updateNum( &per->n, refresh );
}
@ -232,7 +249,9 @@ STlib_updateMultIcon
h = SHORT( mi->p[mi->oldinum]->height );
if( y - ST_Y < 0 )
{
I_Error( "updateMultIcon: y - ST_Y < 0" );
}
V_CopyRect( x, y - ST_Y, BG, w, h, x, y, FG );
}
@ -281,12 +300,18 @@ STlib_updateBinIcon
h = SHORT( bi->p->height );
if( y - ST_Y < 0 )
{
I_Error( "updateBinIcon: y - ST_Y < 0" );
}
if( *bi->val )
{
V_DrawPatch( bi->x, bi->y, FG, bi->p );
}
else
{
V_CopyRect( x, y - ST_Y, BG, w, h, x, y, FG );
}
bi->oldval = *bi->val;
}

View file

@ -346,7 +346,9 @@ void ST_refreshBackground(void)
V_DrawPatch( ST_X, 0, BG, ::g->sbar );
if( ::g->netgame )
{
V_DrawPatch( ST_FX, 0, BG, ::g->faceback );
}
V_CopyRect( ST_X, 0, BG, ST_WIDTH, ST_HEIGHT, ST_X, ST_Y, FG );
}
@ -394,14 +396,18 @@ ST_Responder (event_t* ev)
if( ::g->plyr->cheats & CF_GODMODE )
{
if( ::g->plyr->mo )
{
::g->plyr->mo->health = 100;
}
::g->plyr->health = 100;
::g->plyr->message = STSTR_DQDON;
}
else
{
::g->plyr->message = STSTR_DQDOFF;
}
}
// 'fa' cheat for killer fucking arsenal
else if( cht_CheckCheat( &cheat_ammonokey, ev->data1 ) )
{
@ -409,10 +415,14 @@ ST_Responder (event_t* ev)
::g->plyr->armortype = 2;
for( i = 0; i < NUMWEAPONS; i++ )
{
::g->plyr->weaponowned[i] = true;
}
for( i = 0; i < NUMAMMO; i++ )
{
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
}
::g->plyr->message = STSTR_FAADDED;
}
@ -423,13 +433,19 @@ ST_Responder (event_t* ev)
::g->plyr->armortype = 2;
for( i = 0; i < NUMWEAPONS; i++ )
{
::g->plyr->weaponowned[i] = true;
}
for( i = 0; i < NUMAMMO; i++ )
{
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
}
for( i = 0; i < NUMCARDS; i++ )
{
::g->plyr->cards[i] = true;
}
::g->plyr->message = STSTR_KFAADDED;
}
@ -448,20 +464,28 @@ ST_Responder (event_t* ev)
musnum = mus_runnin + ( buf[0] - '0' ) * 10 + buf[1] - '0' - 1;
if( ( ( buf[0] - '0' ) * 10 + buf[1] - '0' ) > 35 )
{
::g->plyr->message = STSTR_NOMUS;
}
else
{
S_ChangeMusic( musnum, 1 );
}
}
else
{
musnum = mus_e1m1 + ( buf[0] - '1' ) * 9 + ( buf[1] - '1' );
if( ( ( buf[0] - '1' ) * 9 + buf[1] - '1' ) > 31 )
{
::g->plyr->message = STSTR_NOMUS;
}
else
{
S_ChangeMusic( musnum, 1 );
}
}
}
// Simplified, accepting both "noclip" and "idspispopd".
// no clipping mode cheat
else if( cht_CheckCheat( &cheat_noclip, ev->data1 )
@ -470,21 +494,31 @@ ST_Responder (event_t* ev)
::g->plyr->cheats ^= CF_NOCLIP;
if( ::g->plyr->cheats & CF_NOCLIP )
{
::g->plyr->message = STSTR_NCON;
}
else
{
::g->plyr->message = STSTR_NCOFF;
}
}
// 'behold?' power-up cheats
for( i = 0; i < 6; i++ )
{
if( cht_CheckCheat( &::g->cheat_powerup[i], ev->data1 ) )
{
if( !::g->plyr->powers[i] )
{
P_GivePower( ::g->plyr, i );
}
else if( i != pw_strength )
{
::g->plyr->powers[i] = 1;
}
else
{
::g->plyr->powers[i] = 0;
}
::g->plyr->message = STSTR_BEHOLDX;
}
@ -537,27 +571,39 @@ ST_Responder (event_t* ev)
// Catch invalid maps.
if( epsd < 1 )
{
return false;
}
if( map < 1 )
{
return false;
}
// Ohmygod - this is not going to work.
if( ( ::g->gamemode == retail )
&& ( ( epsd > 4 ) || ( map > 9 ) ) )
{
return false;
}
if( ( ::g->gamemode == registered )
&& ( ( epsd > 3 ) || ( map > 9 ) ) )
{
return false;
}
if( ( ::g->gamemode == shareware )
&& ( ( epsd > 1 ) || ( map > 9 ) ) )
{
return false;
}
if( ( ::g->gamemode == commercial )
&& ( ( epsd > 1 ) || ( map > 34 ) ) )
{
return false;
}
// So be it.
::g->plyr->message = STSTR_CLEV;
@ -719,7 +765,9 @@ void ST_updateFaceWidget(void)
if( ::g->plyr->attackdown )
{
if( ::g->lastattackdown == -1 )
{
::g->lastattackdown = ST_RAMPAGEDELAY;
}
else if( !--::g->lastattackdown )
{
::g->priority = 5;
@ -729,7 +777,9 @@ void ST_updateFaceWidget(void)
}
}
else
{
::g->lastattackdown = -1;
}
}
@ -768,9 +818,13 @@ void ST_updateWidgets(void)
// if (::g->w_ready.data != ::g->plyr->readyweapon)
// {
if( weaponinfo[::g->plyr->readyweapon].ammo == am_noammo )
{
::g->w_ready.num = &::g->largeammo;
}
else
{
::g->w_ready.num = &::g->plyr->ammo[weaponinfo[::g->plyr->readyweapon].ammo];
}
//{
// static int tic=0;
// static int dir=-1;
@ -793,8 +847,10 @@ void ST_updateWidgets(void)
::g->keyboxes[i] = ::g->plyr->cards[i] ? i : -1;
if( ::g->plyr->cards[i + 3] )
{
::g->keyboxes[i] = i + 3;
}
}
// refresh everything if this is him coming back to life
ST_updateFaceWidget();
@ -812,14 +868,20 @@ void ST_updateWidgets(void)
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( i != ::g->consoleplayer )
{
::g->st_fragscount += ::g->plyr->frags[i];
}
else
{
::g->st_fragscount -= ::g->plyr->frags[i];
}
}
// get rid of chat window if up because of message
if( !--::g->st_msgcounter )
{
::g->st_chat = ::g->st_oldchat;
}
}
@ -850,15 +912,19 @@ void ST_doPaletteStuff(void)
bzc = 12 - ( ::g->plyr->powers[pw_strength] >> 6 );
if( bzc > cnt )
{
cnt = bzc;
}
}
if( cnt )
{
palette = ( cnt + 7 ) >> 3;
if( palette >= NUMREDPALS )
{
palette = NUMREDPALS - 1;
}
palette += STARTREDPALS;
}
@ -868,16 +934,22 @@ void ST_doPaletteStuff(void)
palette = ( ::g->plyr->bonuscount + 7 ) >> 3;
if( palette >= NUMBONUSPALS )
{
palette = NUMBONUSPALS - 1;
}
palette += STARTBONUSPALS;
}
else if( ::g->plyr->powers[pw_ironfeet] > 4 * 32
|| ::g->plyr->powers[pw_ironfeet] & 8 )
{
palette = RADIATIONPAL;
}
else
{
palette = 0;
}
if( palette != ::g->st_palette )
{
@ -914,12 +986,16 @@ void ST_drawWidgets(qboolean refresh)
STlib_updateBinIcon( &::g->w_armsbg, refresh );
for( i = 0; i < 6; i++ )
{
STlib_updateMultIcon( &::g->w_arms[i], refresh );
}
STlib_updateMultIcon( &::g->w_faces, refresh );
for( i = 0; i < 3; i++ )
{
STlib_updateMultIcon( &::g->w_keyboxes[i], refresh );
}
STlib_updateNum( &::g->w_frags, refresh );
@ -951,9 +1027,15 @@ void ST_Drawer (qboolean fullscreen, qboolean refresh)
ST_doPaletteStuff();
// If just after ST_Start(), refresh all
if (::g->st_firsttime) ST_doRefresh();
if( ::g->st_firsttime )
{
ST_doRefresh();
}
// Otherwise, update as little as possible
else ST_diffDraw();
else
{
ST_diffDraw();
}
}
void ST_loadGraphics( void )
@ -1076,10 +1158,14 @@ void ST_initData(void)
::g->st_oldhealth = -1;
for( i = 0; i < NUMWEAPONS; i++ )
{
::g->oldweaponsowned[i] = ::g->plyr->weaponowned[i];
}
for( i = 0; i < 3; i++ )
{
::g->keyboxes[i] = -1;
}
STlib_init();
@ -1252,7 +1338,9 @@ void ST_Start (void)
{
if( !::g->st_stopped )
{
ST_Stop();
}
ST_initData();
ST_createWidgets();
@ -1263,7 +1351,9 @@ void ST_Start (void)
void ST_Stop( void )
{
if( ::g->st_stopped )
{
return;
}
I_SetPalette( ( byte* )W_CacheLumpNum( ( int )::g->lu_palette, PU_CACHE_SHARED ) );
@ -1279,14 +1369,17 @@ void ST_Init (void)
}
CONSOLE_COMMAND_SHIP( idqd, "cheat for toggleable god mode", 0 ) {
CONSOLE_COMMAND_SHIP( idqd, "cheat for toggleable god mode", 0 )
{
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
if ( ::g == NULL ) {
if( ::g == NULL )
{
return;
}
if (::g->gamestate != GS_LEVEL) {
if( ::g->gamestate != GS_LEVEL )
{
return;
}
@ -1294,25 +1387,32 @@ CONSOLE_COMMAND_SHIP( idqd, "cheat for toggleable god mode", 0 ) {
if( ::g->plyr->cheats & CF_GODMODE )
{
if( ::g->plyr->mo )
{
::g->plyr->mo->health = 100;
}
::g->plyr->health = 100;
::g->plyr->message = STSTR_DQDON;
}
else
{
::g->plyr->message = STSTR_DQDOFF;
}
DoomLib::SetPlayer( oldPlayer );
}
CONSOLE_COMMAND_SHIP( idfa, "cheat for killer fucking arsenal", 0 ) {
CONSOLE_COMMAND_SHIP( idfa, "cheat for killer fucking arsenal", 0 )
{
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
if ( ::g == NULL ) {
if( ::g == NULL )
{
return;
}
if (::g->gamestate != GS_LEVEL) {
if( ::g->gamestate != GS_LEVEL )
{
return;
}
@ -1321,24 +1421,31 @@ CONSOLE_COMMAND_SHIP( idfa, "cheat for killer fucking arsenal", 0 ) {
::g->plyr->armortype = 2;
for( i = 0; i < NUMWEAPONS; i++ )
{
::g->plyr->weaponowned[i] = true;
}
for( i = 0; i < NUMAMMO; i++ )
{
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
}
::g->plyr->message = STSTR_FAADDED;
DoomLib::SetPlayer( oldPlayer );
}
CONSOLE_COMMAND_SHIP( idkfa, "cheat for key full ammo", 0 ) {
CONSOLE_COMMAND_SHIP( idkfa, "cheat for key full ammo", 0 )
{
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
if ( ::g == NULL ) {
if( ::g == NULL )
{
return;
}
if (::g->gamestate != GS_LEVEL) {
if( ::g->gamestate != GS_LEVEL )
{
return;
}
@ -1347,13 +1454,19 @@ CONSOLE_COMMAND_SHIP( idkfa, "cheat for key full ammo", 0 ) {
::g->plyr->armortype = 2;
for( i = 0; i < NUMWEAPONS; i++ )
{
::g->plyr->weaponowned[i] = true;
}
for( i = 0; i < NUMAMMO; i++ )
{
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
}
for( i = 0; i < NUMCARDS; i++ )
{
::g->plyr->cards[i] = true;
}
::g->plyr->message = STSTR_KFAADDED;
@ -1361,34 +1474,44 @@ CONSOLE_COMMAND_SHIP( idkfa, "cheat for key full ammo", 0 ) {
}
CONSOLE_COMMAND_SHIP( idclip, "cheat for no clip", 0 ) {
CONSOLE_COMMAND_SHIP( idclip, "cheat for no clip", 0 )
{
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
if ( ::g == NULL ) {
if( ::g == NULL )
{
return;
}
if (::g->gamestate != GS_LEVEL) {
if( ::g->gamestate != GS_LEVEL )
{
return;
}
::g->plyr->cheats ^= CF_NOCLIP;
if( ::g->plyr->cheats & CF_NOCLIP )
{
::g->plyr->message = STSTR_NCON;
}
else
{
::g->plyr->message = STSTR_NCOFF;
}
DoomLib::SetPlayer( oldPlayer );
}
CONSOLE_COMMAND_SHIP( idmypos, "for player position", 0 ) {
CONSOLE_COMMAND_SHIP( idmypos, "for player position", 0 )
{
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
if ( ::g == NULL ) {
if( ::g == NULL )
{
return;
}
if (::g->gamestate != GS_LEVEL) {
if( ::g->gamestate != GS_LEVEL )
{
return;
}
@ -1402,14 +1525,17 @@ CONSOLE_COMMAND_SHIP( idmypos, "for player position", 0 ) {
DoomLib::SetPlayer( oldPlayer );
}
CONSOLE_COMMAND_SHIP( idclev, "warp to next level", 0 ) {
CONSOLE_COMMAND_SHIP( idclev, "warp to next level", 0 )
{
int oldPlayer = DoomLib::GetPlayer();
DoomLib::SetPlayer( 0 );
if ( ::g == NULL ) {
if( ::g == NULL )
{
return;
}
if (::g->gamestate != GS_LEVEL) {
if( ::g->gamestate != GS_LEVEL )
{
return;
}
@ -1419,24 +1545,31 @@ CONSOLE_COMMAND_SHIP( idclev, "warp to next level", 0 ) {
if( ::g->gamemode == commercial )
{
if( args.Argc() > 1 ) {
if( args.Argc() > 1 )
{
epsd = 1;
map = atoi( args.Argv( 1 ) );
} else {
}
else
{
idLib::Printf( "idclev takes map as first argument \n" );
return;
}
if( map > 32 ) {
if( map > 32 )
{
map = 1;
}
}
else
{
if( args.Argc() > 2 ) {
if( args.Argc() > 2 )
{
epsd = atoi( args.Argv( 1 ) );
map = atoi( args.Argv( 2 ) );
} else {
}
else
{
idLib::Printf( "idclev takes episode and map as first two arguments \n" );
return;
}
@ -1444,27 +1577,39 @@ CONSOLE_COMMAND_SHIP( idclev, "warp to next level", 0 ) {
// Catch invalid maps.
if( epsd < 1 )
{
return;
}
if( map < 1 )
{
return;
}
// Ohmygod - this is not going to work.
if( ( ::g->gamemode == retail )
&& ( ( epsd > 4 ) || ( map > 9 ) ) )
{
return;
}
if( ( ::g->gamemode == registered )
&& ( ( epsd > 3 ) || ( map > 9 ) ) )
{
return;
}
if( ( ::g->gamemode == shareware )
&& ( ( epsd > 1 ) || ( map > 9 ) ) )
{
return;
}
if( ( ::g->gamemode == commercial )
&& ( ( epsd > 1 ) || ( map > 34 ) ) )
{
return;
}
// So be it.
::g->plyr->message = STSTR_CLEV;

View file

@ -59,7 +59,8 @@ typedef struct
// f_finale.structs end //
// i_input.structs begin //
enum {
enum
{
J_DELTAX,
J_DELTAY,
};
@ -80,7 +81,8 @@ struct InputEvent
// i_input.structs end //
// mus2midi.structs begin //
typedef struct tagMUSheader_t {
typedef struct tagMUSheader_t
{
char ID[4]; // identifier "MUS" 0x1A
WORD scoreLen;
WORD scoreStart;
@ -90,7 +92,8 @@ typedef struct tagMUSheader_t {
WORD dummy;
//// variable-length part starts here
} MUSheader_t ;
typedef struct tagMidiHeaderChunk_t {
typedef struct tagMidiHeaderChunk_t
{
char name[4];
int length;
@ -98,7 +101,8 @@ typedef struct tagMidiHeaderChunk_t {
short ntracks; // make 1
short division; // 0xe250??
} MidiHeaderChunk_t;
typedef struct tagMidiTrackChunk_t {
typedef struct tagMidiTrackChunk_t
{
char name[4];
int length;
} MidiTrackChunk_t;
@ -213,11 +217,13 @@ typedef enum
struct default_t
{
const char* name;
union {
union
{
int* location;
const char ** charLocation;
};
union {
union
{
int defaultvalue;
const char* charDefault;
};
@ -229,19 +235,22 @@ struct default_t
location( NULL ),
defaultvalue( 0 ),
scantranslate( 0 ),
untranslated( 0 ) {
untranslated( 0 )
{
}
default_t( const char* name_, int* location_, int defaultvalue_ ) :
name( name_ ),
location( location_ ),
defaultvalue( defaultvalue_ ) {
defaultvalue( defaultvalue_ )
{
}
default_t( const char* name_, const char * * charLocation_, const char* charDefault_ ) :
name( name_ ),
charLocation( charLocation_ ),
charDefault( charDefault_ ) {
charDefault( charDefault_ )
{
}
};
typedef struct

View file

@ -44,7 +44,9 @@ SlopeDiv
unsigned ans;
if( den < 512 )
{
return SLOPERANGE;
}
ans = ( num << 3 ) / ( den >> 8 );

View file

@ -50,7 +50,8 @@ If you have questions concerning this license or the applicable additional terms
// Now where did these came from?
const byte gammatable[5][256] =
{
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
{
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
@ -65,9 +66,11 @@ const byte gammatable[5][256] =
192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255},
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
},
{2,4,5,7,8,10,11,12,14,15,16,18,19,20,21,23,24,25,26,27,29,30,31,
{
2, 4, 5, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20, 21, 23, 24, 25, 26, 27, 29, 30, 31,
32, 33, 34, 36, 37, 38, 39, 40, 41, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 55,
56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
@ -81,9 +84,11 @@ const byte gammatable[5][256] =
205, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 214, 215, 216, 217, 218,
219, 220, 221, 222, 222, 223, 224, 225, 226, 227, 228, 229, 230, 230, 231, 232,
233, 234, 235, 236, 237, 237, 238, 239, 240, 241, 242, 243, 244, 245, 245, 246,
247,248,249,250,251,252,252,253,254,255},
247, 248, 249, 250, 251, 252, 252, 253, 254, 255
},
{4,7,9,11,13,15,17,19,21,22,24,26,27,29,30,32,33,35,36,38,39,40,42,
{
4, 7, 9, 11, 13, 15, 17, 19, 21, 22, 24, 26, 27, 29, 30, 32, 33, 35, 36, 38, 39, 40, 42,
43, 45, 46, 47, 48, 50, 51, 52, 54, 55, 56, 57, 59, 60, 61, 62, 63, 65, 66, 67, 68, 69,
70, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
94, 95, 96, 97, 98, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
@ -97,9 +102,11 @@ const byte gammatable[5][256] =
216, 217, 217, 218, 219, 220, 221, 221, 222, 223, 224, 224, 225, 226, 227, 228, 228,
229, 230, 231, 231, 232, 233, 234, 235, 235, 236, 237, 238, 238, 239, 240, 241, 241,
242, 243, 244, 244, 245, 246, 247, 247, 248, 249, 250, 251, 251, 252, 253, 254, 254,
255},
255
},
{8,12,16,19,22,24,27,29,31,34,36,38,40,41,43,45,47,49,50,52,53,55,
{
8, 12, 16, 19, 22, 24, 27, 29, 31, 34, 36, 38, 40, 41, 43, 45, 47, 49, 50, 52, 53, 55,
57, 58, 60, 61, 63, 64, 65, 67, 68, 70, 71, 72, 74, 75, 76, 77, 79, 80, 81, 82, 84, 85,
86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
@ -113,9 +120,11 @@ const byte gammatable[5][256] =
219, 220, 221, 221, 222, 223, 223, 224, 225, 225, 226, 227, 227, 228, 229, 229, 230,
231, 231, 232, 233, 233, 234, 235, 235, 236, 237, 237, 238, 238, 239, 240, 240, 241,
242, 242, 243, 244, 244, 245, 246, 246, 247, 247, 248, 249, 249, 250, 251, 251, 252,
253,253,254,254,255},
253, 253, 254, 254, 255
},
{16,23,28,32,36,39,42,45,48,50,53,55,57,60,62,64,66,68,69,71,73,75,76,
{
16, 23, 28, 32, 36, 39, 42, 45, 48, 50, 53, 55, 57, 60, 62, 64, 66, 68, 69, 71, 73, 75, 76,
78, 80, 81, 83, 84, 86, 87, 89, 90, 92, 93, 94, 96, 97, 98, 100, 101, 102, 103, 105, 106,
107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
125, 126, 128, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141,
@ -129,7 +138,8 @@ const byte gammatable[5][256] =
224, 225, 225, 226, 227, 227, 228, 228, 229, 229, 230, 230, 231, 232, 232, 233, 233,
234, 234, 235, 235, 236, 236, 237, 237, 238, 239, 239, 240, 240, 241, 241, 242, 242,
243, 243, 244, 244, 245, 245, 246, 246, 247, 247, 248, 248, 249, 249, 250, 250, 251,
251,252,252,253,254,254,255,255}
251, 252, 252, 253, 254, 254, 255, 255
}
};
@ -194,7 +204,8 @@ V_CopyRect
src = ::g->screens[srcscrn] + srcy * SCREENWIDTH + srcx;
dest = ::g->screens[destscrn] + desty * SCREENWIDTH + destx;
for ( ; height>0 ; height--) {
for( ; height > 0 ; height-- )
{
memcpy( dest, src, width );
src += SCREENWIDTH;
dest += SCREENWIDTH;
@ -237,7 +248,9 @@ V_DrawPatch
#endif
if( !scrn )
{
V_MarkRect( x, y, SHORT( patch->width ), SHORT( patch->height ) );
}
col = 0;
int destx = x;
@ -246,25 +259,30 @@ V_DrawPatch
w = SHORT( patch->width );
// SMF - rewritten for scaling
for ( ; col < w ; x++, col++ ) {
for( ; col < w ; x++, col++ )
{
column = ( postColumn_t* )( ( byte* )patch + LONG( patch->columnofs[col] ) );
destx = x;
// step through the posts in a column
while (column->topdelta != 0xff ) {
while( column->topdelta != 0xff )
{
source = ( byte* )column + 3;
desty = y + column->topdelta;
count = column->length;
while (count--) {
while( count-- )
{
int scaledx, scaledy;
scaledx = destx * GLOBAL_IMAGE_SCALER;
scaledy = desty * GLOBAL_IMAGE_SCALER;
byte src = *source++;
for ( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ ) {
for ( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ ) {
for( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ )
{
for( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ )
{
::g->screens[scrn][( scaledx + j ) + ( scaledy + i ) * SCREENWIDTH] = src;
}
}
@ -311,7 +329,9 @@ V_DrawPatchFlipped
#endif
if( !scrn )
{
V_MarkRect( x, y, SHORT( patch->width ), SHORT( patch->height ) );
}
col = 0;
int destx = x;
@ -339,8 +359,10 @@ V_DrawPatchFlipped
scaledy = desty * GLOBAL_IMAGE_SCALER;
byte src = *source++;
for ( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ ) {
for ( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ ) {
for( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ )
{
for( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ )
{
::g->screens[scrn][( scaledx + j ) + ( scaledy + i ) * SCREENWIDTH] = src;
}
}
@ -514,6 +536,8 @@ void V_Init (void)
base = ( byte* )DoomLib::Z_Malloc( SCREENWIDTH * SCREENHEIGHT * 4, PU_STATIC, 0 );
for( i = 0 ; i < 4 ; i++ )
{
::g->screens[i] = base + i * SCREENWIDTH * SCREENHEIGHT;
}
}

View file

@ -93,7 +93,9 @@ ExtractFileBase
while( *src && *src != '.' )
{
if( ++length == 9 )
{
I_Error( "Filename base of %s >8 chars", path );
}
*dest++ = toupper( ( int ) * src++ );
}
@ -177,14 +179,19 @@ void W_AddFile ( const char *filename)
// Fill in lumpinfo
if (lumpinfo == NULL) {
if( lumpinfo == NULL )
{
lumpinfo = ( lumpinfo_t* )malloc( numlumps * sizeof( lumpinfo_t ) );
} else {
}
else
{
lumpinfo = ( lumpinfo_t* )realloc( lumpinfo, numlumps * sizeof( lumpinfo_t ) );
}
if( !lumpinfo )
{
I_Error( "Couldn't realloc lumpinfo" );
}
lump_p = &lumpinfo[startlump];
@ -217,10 +224,14 @@ void W_Reload (void)
// W_FreeLumps
// Frees all lump data
//
void W_FreeLumps() {
if ( lumpcache != NULL ) {
for ( int i = 0; i < numlumps; i++ ) {
if ( lumpcache[i] ) {
void W_FreeLumps()
{
if( lumpcache != NULL )
{
for( int i = 0; i < numlumps; i++ )
{
if( lumpcache[i] )
{
Z_Free( lumpcache[i] );
}
}
@ -229,7 +240,8 @@ void W_FreeLumps() {
lumpcache = NULL;
}
if ( lumpinfo != NULL ) {
if( lumpinfo != NULL )
{
free( lumpinfo );
lumpinfo = NULL;
numlumps = 0;
@ -240,10 +252,13 @@ void W_FreeLumps() {
// W_FreeWadFiles
// Free this list of wad files so that a new list can be created
//
void W_FreeWadFiles() {
for (int i = 0 ; i < MAXWADFILES ; i++) {
void W_FreeWadFiles()
{
for( int i = 0 ; i < MAXWADFILES ; i++ )
{
wadfiles[i] = NULL;
if ( ::g->wadFileHandles[i] ) {
if( ::g->wadFileHandles[i] )
{
delete ::g->wadFileHandles[i];
}
::g->wadFileHandles[i] = NULL;
@ -285,30 +300,39 @@ void W_InitMultipleFiles (const char** filenames)
}
if( !numlumps )
{
I_Error( "W_InitMultipleFiles: no files found" );
}
// set up caching
size = numlumps * sizeof( *lumpcache );
lumpcache = ( void** )DoomLib::Z_Malloc( size, PU_STATIC_SHARED, 0 );
if( !lumpcache )
{
I_Error( "Couldn't allocate lumpcache" );
}
memset( lumpcache, 0, size );
} else {
}
else
{
// set up caching
size = numlumps * sizeof( *lumpcache );
lumpcache = ( void** )DoomLib::Z_Malloc( size, PU_STATIC_SHARED, 0 );
if( !lumpcache )
{
I_Error( "Couldn't allocate lumpcache" );
}
memset( lumpcache, 0, size );
}
}
void W_Shutdown() {
void W_Shutdown()
{
/*
for (int i = 0 ; i < MAXWADFILES ; i++) {
if ( ::g->wadFileHandles[i] ) {
@ -344,7 +368,8 @@ int W_CheckNumForName (const char* name)
{
const int NameLength = 9;
union {
union
{
char s[NameLength];
int x[2];
@ -361,7 +386,8 @@ int W_CheckNumForName (const char* name)
name8.s[NameLength - 1] = 0;
// case insensitive
for ( int i = 0; i < NameLength; ++i ) {
for( int i = 0; i < NameLength; ++i )
{
name8.s[i] = toupper( name8.s[i] );
}
@ -399,7 +425,9 @@ int W_GetNumForName ( const char* name)
i = W_CheckNumForName( name );
if( i == -1 )
{
I_Error( "W_GetNumForName: %s not found!", name );
}
return i;
}
@ -412,7 +440,9 @@ int W_GetNumForName ( const char* name)
int W_LumpLength( int lump )
{
if( lump >= numlumps )
{
I_Error( "W_LumpLength: %i >= numlumps", lump );
}
return lumpinfo[lump].size;
}
@ -434,7 +464,9 @@ W_ReadLump
idFile* handle;
if( lump >= numlumps )
{
I_Error( "W_ReadLump: %i >= numlumps", lump );
}
l = lumpinfo + lump;
@ -444,8 +476,10 @@ W_ReadLump
c = handle->Read( dest, l->size );
if( c < l->size )
{
I_Error( "W_ReadLump: only read %i of %i on lump %i", c, l->size, lump );
}
}
@ -460,7 +494,9 @@ W_CacheLumpNum
{
#ifdef RANGECHECK
if( lump >= numlumps )
{
I_Error( "W_CacheLumpNum: %i >= numlumps", lump );
}
#endif
if( !lumpcache[lump] )

View file

@ -253,7 +253,8 @@ const wbplayerstruct_t* plrs; // ::g->wbs->plyr[]
void localCalculateAchievements( bool epComplete )
{
if( !common->IsMultiplayer() ) {
if( !common->IsMultiplayer() )
{
player_t* player = &::g->players[::g->consoleplayer];
@ -348,7 +349,8 @@ WI_drawOnLnode
{
i++;
}
} while (!fits && i!=2);
}
while( !fits && i != 2 );
if( fits && i < 2 )
{
@ -370,10 +372,14 @@ void WI_initAnimatedBack(void)
anim_t* a;
if( ::g->gamemode == commercial )
{
return;
}
if( ::g->wbs->epsd > 2 )
{
return;
}
for( i = 0; i < ::g->NUMANIMS[::g->wbs->epsd]; i++ )
{
@ -384,12 +390,18 @@ void WI_initAnimatedBack(void)
// specify the next time to draw it
if( a->type == ANIM_ALWAYS )
{
a->nexttic = ::g->bcnt + 1 + ( M_Random() % a->period );
}
else if( a->type == ANIM_RANDOM )
{
a->nexttic = ::g->bcnt + 1 + a->data2 + ( M_Random() % a->data1 );
}
else if( a->type == ANIM_LEVEL )
{
a->nexttic = ::g->bcnt + 1;
}
}
}
@ -400,10 +412,14 @@ void WI_updateAnimatedBack(void)
anim_t* a;
if( ::g->gamemode == commercial )
{
return;
}
if( ::g->wbs->epsd > 2 )
{
return;
}
for( i = 0; i < ::g->NUMANIMS[::g->wbs->epsd]; i++ )
{
@ -414,7 +430,10 @@ void WI_updateAnimatedBack(void)
switch( a->type )
{
case ANIM_ALWAYS:
if (++a->ctr >= a->nanims) a->ctr = 0;
if( ++a->ctr >= a->nanims )
{
a->ctr = 0;
}
a->nexttic = ::g->bcnt + a->period;
break;
@ -425,7 +444,10 @@ void WI_updateAnimatedBack(void)
a->ctr = -1;
a->nexttic = ::g->bcnt + a->data2 + ( M_Random() % a->data1 );
}
else a->nexttic = ::g->bcnt + a->period;
else
{
a->nexttic = ::g->bcnt + a->period;
}
break;
case ANIM_LEVEL:
@ -434,7 +456,10 @@ void WI_updateAnimatedBack(void)
&& ::g->wbs->next == a->data1 )
{
a->ctr++;
if (a->ctr == a->nanims) a->ctr--;
if( a->ctr == a->nanims )
{
a->ctr--;
}
a->nexttic = ::g->bcnt + a->period;
}
break;
@ -451,18 +476,24 @@ void WI_drawAnimatedBack(void)
anim_t* a;
if( commercial )
{
return;
}
if( ::g->wbs->epsd > 2 )
{
return;
}
for( i = 0 ; i < ::g->NUMANIMS[::g->wbs->epsd] ; i++ )
{
a = &::g->wi_stuff_anims[::g->wbs->epsd][i];
if( a->ctr >= 0 )
{
V_DrawPatch( a->loc.x, a->loc.y, FB, a->p[a->ctr] );
}
}
}
@ -508,11 +539,15 @@ WI_drawNum
neg = n < 0;
if( neg )
{
n = -n;
}
// if non-number, do not draw it
if( n == 1994 )
{
return 0;
}
// draw the new number
while( digits-- )
@ -524,7 +559,9 @@ WI_drawNum
// draw a minus sign if necessary
if( neg )
{
V_DrawPatch( x -= 8, y, FB, ::g->wiminus );
}
return x;
@ -537,7 +574,9 @@ WI_drawPercent
int p )
{
if( p < 0 )
{
return;
}
V_DrawPatch( x, y, FB, ::g->percent );
WI_drawNum( x, y, p, -1 );
@ -560,7 +599,9 @@ WI_drawTime
int n;
if( t < 0 )
{
return;
}
if( t <= 61 * 59 )
{
@ -574,9 +615,12 @@ WI_drawTime
// draw
if( div == 60 || t / div )
{
V_DrawPatch( x, y, FB, ::g->colon );
}
} while (t / div);
}
while( t / div );
}
else
{
@ -599,11 +643,13 @@ void WI_initNoState(void)
::g->cnt = 10;
}
void WI_updateNoState(void) {
void WI_updateNoState( void )
{
WI_updateAnimatedBack();
if (!--::g->cnt) {
if( !--::g->cnt )
{
// Unload data
WI_End();
G_WorldDone();
@ -629,10 +675,13 @@ void WI_updateShowNextLoc(void)
{
WI_updateAnimatedBack();
if (!--::g->cnt || ::g->acceleratestage) {
if( !--::g->cnt || ::g->acceleratestage )
{
WI_initNoState();
DoomLib::ShowXToContinue( false );
} else {
}
else
{
::g->snl_pointeron = ( ::g->cnt & 31 ) < 20;
}
}
@ -659,8 +708,10 @@ void WI_drawShowNextLoc(void)
last = ( ::g->wbs->last == 8 ) ? ::g->wbs->next - 1 : ::g->wbs->last;
// don't draw any splats for extra secret levels
if( last == 9 ) {
for (i=0 ; i<MAXPLAYERS ; i++) {
if( last == 9 )
{
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
::g->players[i].didsecret = false;
}
::g->wbs->didsecret = false;
@ -669,21 +720,29 @@ void WI_drawShowNextLoc(void)
// draw a splat on taken cities.
for( i = 0 ; i <= last ; i++ )
{
WI_drawOnLnode( i, &::g->splat );
}
// splat the secret level?
if( ::g->wbs->didsecret )
{
WI_drawOnLnode( 8, &::g->splat );
}
// draw flashing ptr
if( ::g->snl_pointeron )
{
WI_drawOnLnode( ::g->wbs->next, ::g->yah );
}
}
// draws which level you are entering..
if( ( ::g->gamemode != commercial )
|| ::g->wbs->next != 30 )
{
WI_drawEL();
}
}
@ -770,7 +829,9 @@ void WI_initDeathmatchStats(void)
{
for( j = 0 ; j < MAXPLAYERS ; j++ )
if( ::g->playeringame[j] )
{
::g->dm_frags[i][j] = 0;
}
::g->dm_totals[i] = 0;
}
@ -778,7 +839,8 @@ void WI_initDeathmatchStats(void)
WI_initAnimatedBack();
if ( common->IsMultiplayer() ) {
if( common->IsMultiplayer() )
{
localCalculateAchievements( false );
/* JAF PS3
@ -817,7 +879,9 @@ void WI_updateDeathmatchStats(void)
{
for( j = 0 ; j < MAXPLAYERS ; j++ )
if( ::g->playeringame[j] )
{
::g->dm_frags[i][j] = plrs[i].frags[j];
}
::g->dm_totals[i] = WI_fragSum( i );
}
@ -832,7 +896,9 @@ void WI_updateDeathmatchStats(void)
if( ::g->dm_state == 2 )
{
if( !( ::g->bcnt & 3 ) )
{
S_StartSound( 0, sfx_pistol );
}
stillticking = false;
@ -846,15 +912,23 @@ void WI_updateDeathmatchStats(void)
&& ::g->dm_frags[i][j] != plrs[i].frags[j] )
{
if( plrs[i].frags[j] < 0 )
{
::g->dm_frags[i][j]--;
}
else
{
::g->dm_frags[i][j]++;
}
if( ::g->dm_frags[i][j] > 99 )
{
::g->dm_frags[i][j] = 99;
}
if( ::g->dm_frags[i][j] < -99 )
{
::g->dm_frags[i][j] = -99;
}
stillticking = true;
}
@ -862,11 +936,15 @@ void WI_updateDeathmatchStats(void)
::g->dm_totals[i] = WI_fragSum( i );
if( ::g->dm_totals[i] > 99 )
{
::g->dm_totals[i] = 99;
}
if( ::g->dm_totals[i] < -99 )
{
::g->dm_totals[i] = -99;
}
}
}
if( !stillticking )
@ -880,7 +958,8 @@ void WI_updateDeathmatchStats(void)
{
if( ::g->acceleratestage )
{
if ( !::g->demoplayback && ( ::g->usergame || ::g->netgame ) ) {
if( !::g->demoplayback && ( ::g->usergame || ::g->netgame ) )
{
// This sound plays repeatedly after a player continues at the end of a deathmatch,
// and sounds bad. Quick fix is to just not play it.
//S_StartSound(0, sfx_slop);
@ -985,7 +1064,9 @@ void WI_drawDeathmatchStats(void)
for( j = 0 ; j < MAXPLAYERS ; j++ )
{
if( ::g->playeringame[j] )
{
WI_drawNum( x + w, y, ::g->dm_frags[i][j], 2 );
}
x += DM_SPACINGX;
}
@ -1010,7 +1091,9 @@ void WI_initNetgameStats(void)
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( !::g->playeringame[i] )
{
continue;
}
::g->cnt_kills[i] = ::g->cnt_items[i] = ::g->cnt_secret[i] = ::g->cnt_frags[i] = 0;
@ -1062,15 +1145,19 @@ void WI_updateNetgameStats(void)
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( !::g->playeringame[i] )
{
continue;
}
::g->cnt_kills[i] = ( plrs[i].skills * 100 ) / ::g->wbs->maxkills;
::g->cnt_items[i] = ( plrs[i].sitems * 100 ) / ::g->wbs->maxitems;
::g->cnt_secret[i] = ( plrs[i].ssecret * 100 ) / ::g->wbs->maxsecret;
if( ::g->dofrags )
{
::g->cnt_frags[i] = WI_fragSum( i );
}
}
S_StartSound( 0, sfx_barexp );
::g->ng_state = 10;
}
@ -1078,22 +1165,30 @@ void WI_updateNetgameStats(void)
if( ::g->ng_state == 2 )
{
if( !( ::g->bcnt & 3 ) )
{
S_StartSound( 0, sfx_pistol );
}
stillticking = false;
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( !::g->playeringame[i] )
{
continue;
}
::g->cnt_kills[i] += 2;
if( ::g->cnt_kills[i] >= ( plrs[i].skills * 100 ) / ::g->wbs->maxkills )
{
::g->cnt_kills[i] = ( plrs[i].skills * 100 ) / ::g->wbs->maxkills;
}
else
{
stillticking = true;
}
}
if( !stillticking )
{
@ -1104,21 +1199,29 @@ void WI_updateNetgameStats(void)
else if( ::g->ng_state == 4 )
{
if( !( ::g->bcnt & 3 ) )
{
S_StartSound( 0, sfx_pistol );
}
stillticking = false;
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( !::g->playeringame[i] )
{
continue;
}
::g->cnt_items[i] += 2;
if( ::g->cnt_items[i] >= ( plrs[i].sitems * 100 ) / ::g->wbs->maxitems )
{
::g->cnt_items[i] = ( plrs[i].sitems * 100 ) / ::g->wbs->maxitems;
}
else
{
stillticking = true;
}
}
if( !stillticking )
{
S_StartSound( 0, sfx_barexp );
@ -1128,22 +1231,30 @@ void WI_updateNetgameStats(void)
else if( ::g->ng_state == 6 )
{
if( !( ::g->bcnt & 3 ) )
{
S_StartSound( 0, sfx_pistol );
}
stillticking = false;
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( !::g->playeringame[i] )
{
continue;
}
::g->cnt_secret[i] += 2;
if( ::g->cnt_secret[i] >= ( plrs[i].ssecret * 100 ) / ::g->wbs->maxsecret )
{
::g->cnt_secret[i] = ( plrs[i].ssecret * 100 ) / ::g->wbs->maxsecret;
}
else
{
stillticking = true;
}
}
if( !stillticking )
{
@ -1154,22 +1265,30 @@ void WI_updateNetgameStats(void)
else if( ::g->ng_state == 8 )
{
if( !( ::g->bcnt & 3 ) )
{
S_StartSound( 0, sfx_pistol );
}
stillticking = false;
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( !::g->playeringame[i] )
{
continue;
}
::g->cnt_frags[i] += 1;
if( ::g->cnt_frags[i] >= ( fsum = WI_fragSum( i ) ) )
{
::g->cnt_frags[i] = fsum;
}
else
{
stillticking = true;
}
}
if( !stillticking )
{
@ -1181,16 +1300,19 @@ void WI_updateNetgameStats(void)
{
if( ::g->acceleratestage )
{
if ( !::g->demoplayback && ( ::g->usergame || ::g->netgame ) ) {
if( !::g->demoplayback && ( ::g->usergame || ::g->netgame ) )
{
S_StartSound( 0, sfx_sgcock );
// need to do this again if they buy it
localCalculateAchievements( false );
if (::g->gamemode == commercial){
if( ::g->gamemode == commercial )
{
WI_initNoState();
DoomLib::ShowXToContinue( false );
}
else{
else
{
WI_initShowNextLoc();
}
}
@ -1242,22 +1364,31 @@ void WI_drawNetgameStats(void)
for( i = 0 ; i < MAXPLAYERS ; i++ )
{
if( !::g->playeringame[i] )
{
continue;
}
x = NG_STATSX;
V_DrawPatch( x - SHORT( ::g->wistuff_p[i]->width ), y, FB, ::g->wistuff_p[i] );
// No splitscreen on PC
if( i == ::g->me /* && !gameLocal->IsSplitscreen() */ )
{
V_DrawPatch( x - SHORT( ::g->wistuff_p[i]->width ), y, FB, ::g->star );
}
x += NG_SPACINGX;
WI_drawPercent(x-pwidth, y+10, ::g->cnt_kills[i]); x += NG_SPACINGX;
WI_drawPercent(x-pwidth, y+10, ::g->cnt_items[i]); x += NG_SPACINGX;
WI_drawPercent(x-pwidth, y+10, ::g->cnt_secret[i]); x += NG_SPACINGX;
WI_drawPercent( x - pwidth, y + 10, ::g->cnt_kills[i] );
x += NG_SPACINGX;
WI_drawPercent( x - pwidth, y + 10, ::g->cnt_items[i] );
x += NG_SPACINGX;
WI_drawPercent( x - pwidth, y + 10, ::g->cnt_secret[i] );
x += NG_SPACINGX;
if( ::g->dofrags )
{
WI_drawNum( x, y + 10, ::g->cnt_frags[i], -1 );
}
y += WI_SPACINGY;
}
@ -1301,7 +1432,9 @@ void WI_updateStats(void)
::g->cnt_kills[0] += 2;
if( !( ::g->bcnt & 3 ) )
{
S_StartSound( 0, sfx_pistol );
}
if( ::g->cnt_kills[0] >= ( plrs[::g->me].skills * 100 ) / ::g->wbs->maxkills )
{
@ -1315,7 +1448,9 @@ void WI_updateStats(void)
::g->cnt_items[0] += 2;
if( !( ::g->bcnt & 3 ) )
{
S_StartSound( 0, sfx_pistol );
}
if( ::g->cnt_items[0] >= ( plrs[::g->me].sitems * 100 ) / ::g->wbs->maxitems )
{
@ -1329,7 +1464,9 @@ void WI_updateStats(void)
::g->cnt_secret[0] += 2;
if( !( ::g->bcnt & 3 ) )
{
S_StartSound( 0, sfx_pistol );
}
if( ::g->cnt_secret[0] >= ( plrs[::g->me].ssecret * 100 ) / ::g->wbs->maxsecret )
{
@ -1342,12 +1479,16 @@ void WI_updateStats(void)
else if( ::g->sp_state == 8 )
{
if( !( ::g->bcnt & 3 ) )
{
S_StartSound( 0, sfx_pistol );
}
::g->cnt_time += 3;
if( ::g->cnt_time >= plrs[::g->me].stime / TICRATE )
{
::g->cnt_time = plrs[::g->me].stime / TICRATE;
}
::g->cnt_par += 3;
@ -1366,17 +1507,20 @@ void WI_updateStats(void)
{
if( ::g->acceleratestage )
{
if ( !::g->demoplayback && ( ::g->usergame || ::g->netgame ) ) {
if( !::g->demoplayback && ( ::g->usergame || ::g->netgame ) )
{
S_StartSound( 0, sfx_sgcock );
// need to do this again if they buy it
localCalculateAchievements( false );
if (::g->gamemode == commercial) {
if( ::g->gamemode == commercial )
{
WI_initNoState();
}
else{
else
{
WI_initShowNextLoc();
}
}
@ -1440,21 +1584,27 @@ void WI_checkForAccelerate(void)
{
if( player->cmd.buttons & BT_ATTACK )
{
if (!player->attackdown) {
if( !player->attackdown )
{
::g->acceleratestage = 1;
}
player->attackdown = true;
} else {
}
else
{
player->attackdown = false;
}
if( player->cmd.buttons & BT_USE )
{
if (!player->usedown) {
if( !player->usedown )
{
::g->acceleratestage = 1;
}
player->usedown = true;
} else {
}
else
{
player->usedown = false;
}
}
@ -1473,19 +1623,32 @@ void WI_Ticker(void)
{
// intermission music
if( ::g->gamemode == commercial )
{
S_ChangeMusic( mus_dm2int, true );
}
else
{
S_ChangeMusic( mus_inter, true );
}
}
WI_checkForAccelerate();
switch( ::g->state )
{
case StatCount:
if (::g->deathmatch) WI_updateDeathmatchStats();
else if (::g->netgame) WI_updateNetgameStats();
else WI_updateStats();
if( ::g->deathmatch )
{
WI_updateDeathmatchStats();
}
else if( ::g->netgame )
{
WI_updateNetgameStats();
}
else
{
WI_updateStats();
}
break;
case ShowNextLoc:
@ -1507,17 +1670,23 @@ void WI_loadData(void)
anim_t* a;
if( ::g->gamemode == commercial )
{
strcpy( name, "INTERPIC" );
}
// DHM - Nerve :: Use our background image
//strcpy(name, "DMENUPIC");
else
{
idStr::snPrintf( name, sizeof( name ), "WIMAP%d", ::g->wbs->epsd );
}
if( ::g->gamemode == retail )
{
if( ::g->wbs->epsd == 3 )
{
strcpy( name, "INTERPIC" );
}
}
// background
::g->bg = ( patch_t* )W_CacheLumpName( name, PU_LEVEL_SHARED );
@ -1681,11 +1850,17 @@ void WI_Drawer (void)
{
case StatCount:
if( ::g->deathmatch )
{
WI_drawDeathmatchStats();
}
else if( ::g->netgame )
{
WI_drawNetgameStats();
}
else
{
WI_drawStats();
}
break;
case ShowNextLoc:
@ -1708,10 +1883,14 @@ void WI_initVariables(wbstartstruct_t* wbstartstruct)
if( ::g->gamemode != commercial )
{
if( ::g->gamemode == retail )
{
RNGCHECK( ::g->wbs->epsd, 0, 3 );
}
else
{
RNGCHECK( ::g->wbs->epsd, 0, 2 );
}
}
else
{
RNGCHECK( ::g->wbs->last, 0, 8 );
@ -1728,18 +1907,26 @@ void WI_initVariables(wbstartstruct_t* wbstartstruct)
plrs = ::g->wbs->plyr;
if( !::g->wbs->maxkills )
{
::g->wbs->maxkills = 1;
}
if( !::g->wbs->maxitems )
{
::g->wbs->maxitems = 1;
}
if( !::g->wbs->maxsecret )
{
::g->wbs->maxsecret = 1;
}
if( ::g->gamemode != retail )
if( ::g->wbs->epsd > 2 )
{
::g->wbs->epsd -= 3;
}
}
void WI_Start( wbstartstruct_t* wbstartstruct )
{
@ -1748,9 +1935,15 @@ void WI_Start(wbstartstruct_t* wbstartstruct)
WI_loadData();
if( ::g->deathmatch )
{
WI_initDeathmatchStats();
}
else if( ::g->netgame )
{
WI_initNetgameStats();
}
else
{
WI_initStats();
}
}

View file

@ -127,7 +127,9 @@ void Z_Free (void* ptr)
NumAlloc -= block->size;
if( block->id != ZONEID )
{
I_Error( "Z_Free: freed a pointer without ZONEID" );
}
if( block->user > ( void** )0x100 )
{
@ -153,7 +155,9 @@ void Z_Free (void* ptr)
other->next->prev = other;
if( block == ::g->mainzone->rover )
{
::g->mainzone->rover = other;
}
block = other;
}
@ -167,9 +171,11 @@ void Z_Free (void* ptr)
block->next->prev = block;
if( other == ::g->mainzone->rover )
{
::g->mainzone->rover = block;
}
}
}
@ -208,7 +214,9 @@ Z_Malloc
base = ::g->mainzone->rover;
if( !base->prev->user )
{
base = base->prev;
}
rover = base;
start = base->prev;
@ -241,8 +249,11 @@ Z_Malloc
}
}
else
{
rover = rover->next;
} while (base->user || base->size < size);
}
}
while( base->user || base->size < size );
// found a block big enough
@ -274,7 +285,9 @@ Z_Malloc
else
{
if( tag >= PU_PURGELEVEL )
{
I_Error( "Z_Malloc: an owner is required for purgable blocks" );
}
// mark as in use, but unowned
base->user = ( void** )2;
@ -311,12 +324,16 @@ Z_FreeTags
// free block?
if( !block->user )
{
continue;
}
if( block->tag >= lowtag && block->tag <= hightag )
{
Z_Free( ( byte* )block + sizeof( memblock_t ) );
}
}
}
@ -350,15 +367,21 @@ Z_DumpHeap
}
if( ( byte* )block + block->size != ( byte* )block->next )
{
I_Printf( "ERROR: block size does not touch the next block\n" );
}
if( block->next->prev != block )
{
I_Printf( "ERROR: next block doesn't have proper back link\n" );
}
if( !block->user && !block->next->user )
{
I_Printf( "ERROR: two consecutive free blocks\n" );
}
}
}
//
@ -382,15 +405,21 @@ void Z_FileDumpHeap (FILE* f)
}
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" );
}
}
}
@ -410,15 +439,21 @@ void Z_CheckHeap (void)
}
if( ( byte* )block + block->size != ( byte* )block->next )
{
I_Error( "Z_CheckHeap: block size does not touch the next block\n" );
}
if( block->next->prev != block )
{
I_Error( "Z_CheckHeap: next block doesn't have proper back link\n" );
}
if( !block->user && !block->next->user )
{
I_Error( "Z_CheckHeap: two consecutive free blocks\n" );
}
}
}
@ -436,15 +471,22 @@ Z_ChangeTag2
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 && ( uintptr_t )block->user < 0x100 )
{
I_Error( "Z_ChangeTag: an owner is required for purgable blocks" );
}
block->tag = tag;
}
void Z_ChangeTag2( void** pp, int tag ) { Z_ChangeTag2( *pp, tag ); }
void Z_ChangeTag2( void** pp, int tag )
{
Z_ChangeTag2( *pp, tag );
}
//
@ -462,8 +504,10 @@ int Z_FreeMemory (void)
block = block->next )
{
if( !block->user || block->tag >= PU_PURGELEVEL )
{
free += block->size;
}
}
return free;
}

View file

@ -78,7 +78,8 @@ int Z_FreeMemory (void);
template< class _type_ >
bool MallocForLump( int lump, size_t size, _type_ * & ptr, int tag ) {
bool MallocForLump( int lump, size_t size, _type_*& ptr, int tag )
{
ptr = static_cast< _type_* >( Z_Malloc( size, tag, 0 ) );
return true;

View file

@ -37,3 +37,4 @@ fi
$ASTYLE_BIN -v --formatted --options=astyle-options.ini --exclude="libs" --exclude="extern" --recursive "*.h"
$ASTYLE_BIN -v --formatted --options=astyle-options.ini --exclude="libs" --exclude="extern" --exclude="d3xp/gamesys/SysCvar.cpp" --exclude="d3xp/gamesys/Callbacks.cpp" \
--exclude="sys/win32/win_cpu.cpp" --exclude="sys/win32/win_main.cpp" --recursive "*.cpp"
$ASTYLE_BIN -v --formatted --options=astyle-options.ini --recursive "../doomclassic/doom/*.h" "../doomclassic/doom/*.cpp"