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) #define safeOutputDebug(x)
#endif #endif
struct SplitscreenData { struct SplitscreenData
{
int PLAYERCOUNT; int PLAYERCOUNT;
int globalSkill; int globalSkill;
int globalEpisode; int globalEpisode;
@ -68,7 +69,8 @@ extern int globalNeedUpsell;
extern bool globalPauseTime; extern bool globalPauseTime;
enum MenuStates{ enum MenuStates
{
MENU_NONE, MENU_NONE,
MENU_XBOX_SYSTEM, MENU_XBOX_SYSTEM,
MENU_PAUSE, MENU_PAUSE,
@ -90,7 +92,8 @@ enum MenuStates{
MENU_COUNT MENU_COUNT
}; };
typedef struct { typedef struct
{
int maxPing; int maxPing;
const wchar_t* image; const wchar_t* image;

View file

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

View file

@ -62,7 +62,8 @@ If you have questions concerning this license or the applicable additional terms
::g->wipedone = true; ::g->wipedone = true;
// d_main.constructs end // // d_main.constructs end //
// d_net.constructs begin // // d_net.constructs begin //
doomcom_t temp_doomcom = { doomcom_t temp_doomcom =
{
0 0
}; };
memcpy( &::g->doomcom, &temp_doomcom, sizeof( temp_doomcom ) ); memcpy( &::g->doomcom, &temp_doomcom, sizeof( temp_doomcom ) );
@ -72,15 +73,18 @@ memcpy( &::g->doomcom, &temp_doomcom, sizeof(temp_doomcom) );
// f_wipe.constructs end // // f_wipe.constructs end //
// g_game.constructs begin // // g_game.constructs begin //
::g->precache = true; // if true, load all graphics at start ::g->precache = true; // if true, load all graphics at start
fixed_t temp_forwardmove[2] = { fixed_t temp_forwardmove[2] =
{
0x19, 0x32 0x19, 0x32
}; };
memcpy( ::g->forwardmove, temp_forwardmove, sizeof( temp_forwardmove ) ); memcpy( ::g->forwardmove, temp_forwardmove, sizeof( temp_forwardmove ) );
fixed_t temp_sidemove[2] = { fixed_t temp_sidemove[2] =
{
0x18, 0x28 0x18, 0x28
}; };
memcpy( ::g->sidemove, temp_sidemove, sizeof( temp_sidemove ) ); memcpy( ::g->sidemove, temp_sidemove, sizeof( temp_sidemove ) );
fixed_t temp_angleturn[3] = { fixed_t temp_angleturn[3] =
{
640, 1280, 320 // + slow turn 640, 1280, 320 // + slow turn
}; };
memcpy( ::g->angleturn, temp_angleturn, sizeof( temp_angleturn ) ); 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_cheat.constructs end //
// m_menu.constructs begin // // m_menu.constructs begin //
menuitem_t temp_QuitMenu[3] = { menuitem_t temp_QuitMenu[3] =
{
{1, "M_ACPT", M_ExitGame, 'a'}, {1, "M_ACPT", M_ExitGame, 'a'},
{1, "M_CAN", M_CancelExit, 'c'}, {1, "M_CAN", M_CancelExit, 'c'},
{1, "M_CHG", M_GameSelection, 'g'} {1, "M_CHG", M_GameSelection, 'g'}
}; };
memcpy( ::g->QuitMenu, temp_QuitMenu, sizeof( temp_QuitMenu ) ); memcpy( ::g->QuitMenu, temp_QuitMenu, sizeof( temp_QuitMenu ) );
menu_t temp_QuitDef = { menu_t temp_QuitDef =
{
qut_end, // # of menu items qut_end, // # of menu items
&::g->MainDef, // previous menu &::g->MainDef, // previous menu
::g->QuitMenu, // menuitem_t -> ::g->QuitMenu, // menuitem_t ->
@ -138,7 +144,8 @@ menuitem_t temp_MainMenu[5]=
{1, "M_QUITG", M_QuitDOOM, 'q'} {1, "M_QUITG", M_QuitDOOM, 'q'}
}; };
memcpy( &::g->MainMenu, temp_MainMenu, sizeof( temp_MainMenu ) ); memcpy( &::g->MainMenu, temp_MainMenu, sizeof( temp_MainMenu ) );
menu_t temp_MainDef = { menu_t temp_MainDef =
{
main_end, main_end,
NULL, NULL,
::g->MainMenu, ::g->MainMenu,
@ -149,14 +156,16 @@ menu_t temp_MainDef = {
memcpy( &::g->MainDef, &temp_MainDef, sizeof( 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_EPI1", M_Episode, 'k'},
{1, "M_EPI2", M_Episode, 't'}, {1, "M_EPI2", M_Episode, 't'},
{1, "M_EPI3", M_Episode, 'i'}, {1, "M_EPI3", M_Episode, 'i'},
{1, "M_EPI4", M_Episode, 't'} {1, "M_EPI4", M_Episode, 't'}
}; };
memcpy( ::g->EpisodeMenu, temp_EpisodeMenu, sizeof( temp_EpisodeMenu ) ); memcpy( ::g->EpisodeMenu, temp_EpisodeMenu, sizeof( temp_EpisodeMenu ) );
menu_t temp_EpiDef = { menu_t temp_EpiDef =
{
ep_end, // # of menu items ep_end, // # of menu items
&::g->MainDef, // previous menu &::g->MainDef, // previous menu
::g->EpisodeMenu, // menuitem_t -> ::g->EpisodeMenu, // menuitem_t ->
@ -166,12 +175,14 @@ menu_t temp_EpiDef = {
}; };
memcpy( &::g->EpiDef, &temp_EpiDef, sizeof( 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_EPI1", M_Expansion, 'h'},
{1, "M_EPI2", M_Expansion, 'n'}, {1, "M_EPI2", M_Expansion, 'n'},
}; };
memcpy( ::g->ExpansionMenu, temp_ExpansionMenu, sizeof( temp_ExpansionMenu ) ); memcpy( ::g->ExpansionMenu, temp_ExpansionMenu, sizeof( temp_ExpansionMenu ) );
menu_t temp_ExpDef = { menu_t temp_ExpDef =
{
ex_end, // # of menu items ex_end, // # of menu items
&::g->MainDef, // previous menu &::g->MainDef, // previous menu
::g->ExpansionMenu, // menuitem_t -> ::g->ExpansionMenu, // menuitem_t ->
@ -181,12 +192,14 @@ menu_t temp_ExpDef = {
}; };
memcpy( &::g->ExpDef, &temp_ExpDef, sizeof( 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_EPI1", M_LoadExpansion, 'h'},
{1, "M_EPI2", M_LoadExpansion, 'n'}, {1, "M_EPI2", M_LoadExpansion, 'n'},
}; };
memcpy( ::g->LoadExpMenu, temp_LoadExpMenu, sizeof( temp_LoadExpMenu ) ); memcpy( ::g->LoadExpMenu, temp_LoadExpMenu, sizeof( temp_LoadExpMenu ) );
menu_t temp_LoadExpDef = { menu_t temp_LoadExpDef =
{
ex_end, // # of menu items ex_end, // # of menu items
&::g->MainDef, // previous menu &::g->MainDef, // previous menu
::g->LoadExpMenu, // menuitem_t -> ::g->LoadExpMenu, // menuitem_t ->
@ -196,7 +209,8 @@ menu_t temp_LoadExpDef = {
}; };
memcpy( &::g->LoadExpDef, &temp_LoadExpDef, sizeof( 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_JKILL", M_ChooseSkill, 'i'},
{1, "M_ROUGH", M_ChooseSkill, 'h'}, {1, "M_ROUGH", M_ChooseSkill, 'h'},
{1, "M_HURT", M_ChooseSkill, 'h'}, {1, "M_HURT", M_ChooseSkill, 'h'},
@ -204,7 +218,8 @@ menuitem_t temp_NewGameMenu[5] = {
{1, "M_NMARE", M_ChooseSkill, 'n'} {1, "M_NMARE", M_ChooseSkill, 'n'}
}; };
memcpy( ::g->NewGameMenu, temp_NewGameMenu, sizeof( temp_NewGameMenu ) ); memcpy( ::g->NewGameMenu, temp_NewGameMenu, sizeof( temp_NewGameMenu ) );
menu_t temp_NewDef = { menu_t temp_NewDef =
{
newg_end, // # of menu items newg_end, // # of menu items
&::g->EpiDef, // previous menu &::g->EpiDef, // previous menu
::g->NewGameMenu, // menuitem_t -> ::g->NewGameMenu, // menuitem_t ->
@ -213,7 +228,8 @@ menu_t temp_NewDef = {
hurtme // lastOn hurtme // lastOn
}; };
memcpy( &::g->NewDef, &temp_NewDef, sizeof( temp_NewDef ) ); 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_GDHIGH", M_FullScreen, 'f'},
{1, "M_SCRNSZ", M_ChangeGPad, 'm'}, {1, "M_SCRNSZ", M_ChangeGPad, 'm'},
{1, "M_MESSG", M_ChangeMessages, 'm'}, {1, "M_MESSG", M_ChangeMessages, 'm'},
@ -225,7 +241,8 @@ menuitem_t temp_OptionsMenu[8] = {
{1, "M_SVOL", M_Sound, 's'} {1, "M_SVOL", M_Sound, 's'}
}; };
memcpy( ::g->OptionsMenu, temp_OptionsMenu, sizeof( temp_OptionsMenu ) ); memcpy( ::g->OptionsMenu, temp_OptionsMenu, sizeof( temp_OptionsMenu ) );
menu_t temp_OptionsDef = { menu_t temp_OptionsDef =
{
opt_end, opt_end,
&::g->MainDef, &::g->MainDef,
::g->OptionsMenu, ::g->OptionsMenu,
@ -234,14 +251,16 @@ menu_t temp_OptionsDef = {
0 0
}; };
memcpy( &::g->OptionsDef, &temp_OptionsDef, sizeof( temp_OptionsDef ) ); memcpy( &::g->OptionsDef, &temp_OptionsDef, sizeof( temp_OptionsDef ) );
menuitem_t temp_SoundMenu[4] = { menuitem_t temp_SoundMenu[4] =
{
{2, "M_SFXVOL", M_SfxVol, 's'}, {2, "M_SFXVOL", M_SfxVol, 's'},
{ -1, "", 0}, { -1, "", 0},
{2, "M_MUSVOL", M_MusicVol, 'm'}, {2, "M_MUSVOL", M_MusicVol, 'm'},
{ -1, "", 0} { -1, "", 0}
}; };
memcpy( ::g->SoundMenu, temp_SoundMenu, sizeof( temp_SoundMenu ) ); memcpy( ::g->SoundMenu, temp_SoundMenu, sizeof( temp_SoundMenu ) );
menu_t temp_SoundDef = { menu_t temp_SoundDef =
{
sound_end, sound_end,
&::g->OptionsDef, &::g->OptionsDef,
::g->SoundMenu, ::g->SoundMenu,
@ -250,7 +269,8 @@ menu_t temp_SoundDef = {
0 0
}; };
memcpy( &::g->SoundDef, &temp_SoundDef, sizeof( temp_SoundDef ) ); 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, '1'},
{1, "", M_LoadSelect, '2'}, {1, "", M_LoadSelect, '2'},
{1, "", M_LoadSelect, '3'}, {1, "", M_LoadSelect, '3'},
@ -259,7 +279,8 @@ menuitem_t temp_LoadMenu[6] = {
{1, "", M_LoadSelect, '6'} {1, "", M_LoadSelect, '6'}
}; };
memcpy( ::g->LoadMenu, temp_LoadMenu, sizeof( temp_LoadMenu ) ); memcpy( ::g->LoadMenu, temp_LoadMenu, sizeof( temp_LoadMenu ) );
menu_t temp_LoadDef = { menu_t temp_LoadDef =
{
load_end, load_end,
&::g->MainDef, &::g->MainDef,
::g->LoadMenu, ::g->LoadMenu,
@ -268,7 +289,8 @@ menu_t temp_LoadDef = {
0 0
}; };
memcpy( &::g->LoadDef, &temp_LoadDef, sizeof( temp_LoadDef ) ); 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, '1'},
{1, "", M_SaveSelect, '2'}, {1, "", M_SaveSelect, '2'},
{1, "", M_SaveSelect, '3'}, {1, "", M_SaveSelect, '3'},
@ -277,7 +299,8 @@ menuitem_t temp_SaveMenu[6] = {
{1, "", M_SaveSelect, '6'} {1, "", M_SaveSelect, '6'}
}; };
memcpy( ::g->SaveMenu, temp_SaveMenu, sizeof( temp_SaveMenu ) ); memcpy( ::g->SaveMenu, temp_SaveMenu, sizeof( temp_SaveMenu ) );
menu_t temp_SaveDef = { menu_t temp_SaveDef =
{
load_end, load_end,
&::g->MainDef, &::g->MainDef,
::g->SaveMenu, ::g->SaveMenu,
@ -286,7 +309,8 @@ menu_t temp_SaveDef = {
0 0
}; };
memcpy( &::g->SaveDef, &temp_SaveDef, sizeof( temp_SaveDef ) ); memcpy( &::g->SaveDef, &temp_SaveDef, sizeof( temp_SaveDef ) );
int temp_quitsounds[8] = { int temp_quitsounds[8] =
{
sfx_pldeth, sfx_pldeth,
sfx_dmpain, sfx_dmpain,
sfx_popain, sfx_popain,
@ -297,7 +321,8 @@ int temp_quitsounds[8] = {
sfx_sgtatk sfx_sgtatk
}; };
memcpy( ::g->quitsounds, temp_quitsounds, sizeof( temp_quitsounds ) ); memcpy( ::g->quitsounds, temp_quitsounds, sizeof( temp_quitsounds ) );
int temp_quitsounds2[8] = { int temp_quitsounds2[8] =
{
sfx_vilact, sfx_vilact,
sfx_getpow, sfx_getpow,
sfx_boscub, sfx_boscub,
@ -324,7 +349,8 @@ memcpy( ::g->quitsounds2, temp_quitsounds2, sizeof(temp_quitsounds2) );
{ {
chat_macros[i] = temp_chat_macros[i]; 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( "mouse_sensitivity", &::g->mouseSensitivity, 7 ),
default_t( "show_messages", &::g->showMessages, 1 ), default_t( "show_messages", &::g->showMessages, 1 ),
@ -384,7 +410,8 @@ memcpy( ::g->defaults, temp_defaults, sizeof(temp_defaults) );
::g->easy = 0; ::g->easy = 0;
// p_enemy.constructs end // // p_enemy.constructs end //
// r_bsp.constructs begin // // r_bsp.constructs begin //
int temp_checkcoord[12][4] = { int temp_checkcoord[12][4] =
{
{3, 0, 2, 1}, {3, 0, 2, 1},
{3, 0, 2, 0}, {3, 0, 2, 0},
{3, 1, 2, 0}, {3, 1, 2, 0},
@ -400,7 +427,8 @@ int temp_checkcoord[12][4] = {
memcpy( ::g->checkcoord, temp_checkcoord, sizeof( temp_checkcoord ) ); memcpy( ::g->checkcoord, temp_checkcoord, sizeof( temp_checkcoord ) );
// r_bsp.constructs end // // r_bsp.constructs end //
// r_draw.constructs begin // // 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, 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; ::g->validcount = 1;
// r_main.constructs end // // r_main.constructs end //
// sounds.constructs begin // // sounds.constructs begin //
musicinfo_t temp_S_music[80] = { musicinfo_t temp_S_music[80] =
{
{ 0 }, { 0 },
{ "e1m1", 0 }, { "e1m1", 0 },
{ "e1m2", 0 }, { "e1m2", 0 },
@ -505,7 +534,8 @@ memcpy( ::g->S_music, temp_S_music, sizeof(temp_S_music) );
::g->mus_playing = 0; ::g->mus_playing = 0;
// s_sound.constructs end // // s_sound.constructs end //
// wi_stuff.constructs begin // // wi_stuff.constructs begin //
int temp_NUMANIMS[NUMEPISODES] = { int temp_NUMANIMS[NUMEPISODES] =
{
sizeof( epsd0animinfo ) / sizeof( anim_t ), sizeof( epsd0animinfo ) / sizeof( anim_t ),
sizeof( epsd1animinfo ) / sizeof( anim_t ), sizeof( epsd1animinfo ) / sizeof( anim_t ),
sizeof( epsd2animinfo ) / 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 STORE DEMO, DO NOT ACCEPT INPUT
if( ( ::g->gamemode == commercial ) if( ( ::g->gamemode == commercial )
&& ( W_CheckNumForName( "map01" ) < 0 ) ) && ( W_CheckNumForName( "map01" ) < 0 ) )
{
return; return;
}
for( ; ::g->eventtail != ::g->eventhead ; ::g->eventtail = ( ++::g->eventtail ) & ( MAXEVENTS - 1 ) ) for( ; ::g->eventtail != ::g->eventhead ; ::g->eventtail = ( ++::g->eventtail ) & ( MAXEVENTS - 1 ) )
{ {
ev = &::g->events[::g->eventtail]; ev = &::g->events[::g->eventtail];
if( M_Responder( ev ) ) if( M_Responder( ev ) )
{
continue; // menu ate the event continue; // menu ate the event
}
G_Responder( ev ); G_Responder( ev );
} }
} }
@ -166,7 +170,8 @@ void D_Wipe()
::g->wipedone = wipe_ScreenWipe( 0, 0, SCREENWIDTH, SCREENHEIGHT, tics ); ::g->wipedone = wipe_ScreenWipe( 0, 0, SCREENWIDTH, SCREENHEIGHT, tics );
// DHM - Nerve :: Demo recording :: Stop large hitch on first frame after the wipe // 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->oldtrt_entertics = nowtime / ::g->ticdup;
::g->gametime = nowtime; ::g->gametime = nowtime;
::g->wipe = false; ::g->wipe = false;
@ -181,7 +186,9 @@ void D_Display (void)
qboolean redrawsbar; qboolean redrawsbar;
if( ::g->nodrawers ) if( ::g->nodrawers )
{
return; // for comparative timing / profiling return; // for comparative timing / profiling
}
redrawsbar = false; redrawsbar = false;
@ -200,23 +207,35 @@ void D_Display (void)
wipe_StartScreen( 0, 0, SCREENWIDTH, SCREENHEIGHT ); wipe_StartScreen( 0, 0, SCREENWIDTH, SCREENHEIGHT );
} }
else else
{
::g->wipe = false; ::g->wipe = false;
}
if( ::g->gamestate == GS_LEVEL && ::g->gametic ) if( ::g->gamestate == GS_LEVEL && ::g->gametic )
{
HU_Erase(); HU_Erase();
}
// do buffered drawing // do buffered drawing
switch( ::g->gamestate ) switch( ::g->gamestate )
{ {
case GS_LEVEL: case GS_LEVEL:
if( !::g->gametic ) if( !::g->gametic )
{
break; break;
}
if( ::g->automapactive ) if( ::g->automapactive )
{
AM_Drawer(); AM_Drawer();
}
if( ::g->wipe || ( ::g->viewheight != 200 * GLOBAL_IMAGE_SCALER && ::g->fullscreen ) ) if( ::g->wipe || ( ::g->viewheight != 200 * GLOBAL_IMAGE_SCALER && ::g->fullscreen ) )
{
redrawsbar = true; redrawsbar = true;
}
if( ::g->inhelpscreensstate && !::g->inhelpscreens ) if( ::g->inhelpscreensstate && !::g->inhelpscreens )
{
redrawsbar = true; // just put away the help screen redrawsbar = true; // just put away the help screen
}
ST_Drawer( ::g->viewheight == 200 * GLOBAL_IMAGE_SCALER, redrawsbar ); ST_Drawer( ::g->viewheight == 200 * GLOBAL_IMAGE_SCALER, redrawsbar );
::g->fullscreen = ::g->viewheight == 200 * GLOBAL_IMAGE_SCALER; ::g->fullscreen = ::g->viewheight == 200 * GLOBAL_IMAGE_SCALER;
break; break;
@ -239,14 +258,20 @@ void D_Display (void)
// draw the view directly // draw the view directly
if( ::g->gamestate == GS_LEVEL && !::g->automapactive && ::g->gametic ) if( ::g->gamestate == GS_LEVEL && !::g->automapactive && ::g->gametic )
{
R_RenderPlayerView( &::g->players[::g->displayplayer] ); R_RenderPlayerView( &::g->players[::g->displayplayer] );
}
if( ::g->gamestate == GS_LEVEL && ::g->gametic ) if( ::g->gamestate == GS_LEVEL && ::g->gametic )
{
HU_Drawer(); HU_Drawer();
}
// clean up border stuff // clean up border stuff
if( ::g->gamestate != ::g->oldgamestate && ::g->gamestate != GS_LEVEL ) if( ::g->gamestate != ::g->oldgamestate && ::g->gamestate != GS_LEVEL )
{
I_SetPalette( ( byte* )W_CacheLumpName( "PLAYPAL", PU_CACHE_SHARED ) ); I_SetPalette( ( byte* )W_CacheLumpName( "PLAYPAL", PU_CACHE_SHARED ) );
}
// see if the border needs to be initially drawn // see if the border needs to be initially drawn
if( ::g->gamestate == GS_LEVEL && ::g->oldgamestate != GS_LEVEL ) 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->gamestate == GS_LEVEL && !::g->automapactive && ::g->scaledviewwidth != ( 320 * GLOBAL_IMAGE_SCALER ) )
{ {
if( ::g->menuactive || ::g->menuactivestate || !::g->viewactivestate ) if( ::g->menuactive || ::g->menuactivestate || !::g->viewactivestate )
{
::g->borderdrawcount = 3; ::g->borderdrawcount = 3;
}
if( ::g->borderdrawcount ) if( ::g->borderdrawcount )
{ {
R_DrawViewBorder(); // erase old menu stuff R_DrawViewBorder(); // erase old menu stuff
@ -309,7 +336,8 @@ void D_Display (void)
void D_RunFrame( bool Sounds ) void D_RunFrame( bool Sounds )
{ {
if (Sounds) { if( Sounds )
{
// move positional sounds // move positional sounds
S_UpdateSounds( ::g->players[::g->consoleplayer].mo ); S_UpdateSounds( ::g->players[::g->consoleplayer].mo );
} }
@ -317,7 +345,8 @@ void D_RunFrame( bool Sounds )
// Update display, next frame, with current state. // Update display, next frame, with current state.
D_Display(); D_Display();
if (Sounds) { if( Sounds )
{
// Update sound output. // Update sound output.
I_SubmitSound(); I_SubmitSound();
} }
@ -364,8 +393,10 @@ void D_DoomLoop (void)
void D_PageTicker( void ) void D_PageTicker( void )
{ {
if( --::g->pagetic < 0 ) if( --::g->pagetic < 0 )
{
D_AdvanceDemo(); D_AdvanceDemo();
} }
}
@ -401,25 +432,37 @@ void D_DoAdvanceDemo (void)
::g->gameaction = ga_nothing; ::g->gameaction = ga_nothing;
if( ::g->gamemode == retail ) if( ::g->gamemode == retail )
{
::g->demosequence = ( ::g->demosequence + 1 ) % 8; ::g->demosequence = ( ::g->demosequence + 1 ) % 8;
}
else else
{
::g->demosequence = ( ::g->demosequence + 1 ) % 6; ::g->demosequence = ( ::g->demosequence + 1 ) % 6;
}
switch( ::g->demosequence ) switch( ::g->demosequence )
{ {
case 0: case 0:
if( ::g->gamemode == commercial ) if( ::g->gamemode == commercial )
{
::g->pagetic = 35 * 11; ::g->pagetic = 35 * 11;
}
else else
{
::g->pagetic = 8 * TICRATE; ::g->pagetic = 8 * TICRATE;
}
::g->gamestate = GS_DEMOSCREEN; ::g->gamestate = GS_DEMOSCREEN;
::g->pagename = ( char* )"INTERPIC"; ::g->pagename = ( char* )"INTERPIC";
if( ::g->gamemode == commercial ) if( ::g->gamemode == commercial )
{
S_StartMusic( mus_dm2ttl ); S_StartMusic( mus_dm2ttl );
}
else else
{
S_StartMusic( mus_intro ); S_StartMusic( mus_intro );
}
break; break;
case 1: case 1:
@ -473,7 +516,8 @@ void D_StartTitle (void)
// //
// D_AddExtraWadFile // D_AddExtraWadFile
// //
void D_SetExtraWadFile( const char *file ) { void D_SetExtraWadFile( const char* file )
{
extraWad = file; extraWad = file;
} }
@ -486,7 +530,9 @@ void D_AddFile (const char *file)
for( numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++ ) for( numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++ )
if( file == wadfiles[numwadfiles] ) if( file == wadfiles[numwadfiles] )
{
return; return;
}
; ;
wadfiles[numwadfiles] = file; wadfiles[numwadfiles] = file;
} }
@ -507,11 +553,14 @@ void IdentifyVersion (void)
::g->gamemission = expansion->pack_type; ::g->gamemission = expansion->pack_type;
if( expansion->type == ExpansionData::PWAD ) { if( expansion->type == ExpansionData::PWAD )
{
D_AddFile( expansion->iWadFilename ); D_AddFile( expansion->iWadFilename );
D_AddFile( expansion->pWadFilename ); D_AddFile( expansion->pWadFilename );
} else { }
else
{
D_AddFile( expansion->iWadFilename ); D_AddFile( expansion->iWadFilename );
} }
@ -552,9 +601,13 @@ void D_DoomMain (void)
::g->fastparm = M_CheckParm( "-fast" ); ::g->fastparm = M_CheckParm( "-fast" );
::g->devparm = M_CheckParm( "-devparm" ); ::g->devparm = M_CheckParm( "-devparm" );
if( M_CheckParm( "-altdeath" ) || isDeathmatch ) if( M_CheckParm( "-altdeath" ) || isDeathmatch )
{
::g->deathmatch = 2; ::g->deathmatch = 2;
}
else if( M_CheckParm( "-deathmatch" ) ) else if( M_CheckParm( "-deathmatch" ) )
{
::g->deathmatch = 1; ::g->deathmatch = 1;
}
switch( ::g->gamemode ) switch( ::g->gamemode )
{ {
@ -598,7 +651,9 @@ void D_DoomMain (void)
I_Printf( "%s\n", ::g->title ); I_Printf( "%s\n", ::g->title );
if( ::g->devparm ) if( ::g->devparm )
{
I_Printf( D_DEVSTR ); I_Printf( D_DEVSTR );
}
if( M_CheckParm( "-cdrom" ) ) if( M_CheckParm( "-cdrom" ) )
{ {
@ -617,13 +672,17 @@ void D_DoomMain (void)
// until end of parms or another - preceded parm // until end of parms or another - preceded parm
::g->modifiedgame = true; // homebrew levels ::g->modifiedgame = true; // homebrew levels
while( ++p != ::g->myargc && ::g->myargv[p][0] != '-' ) while( ++p != ::g->myargc && ::g->myargv[p][0] != '-' )
{
D_AddFile( ::g->myargv[p] ); D_AddFile( ::g->myargv[p] );
} }
}
p = M_CheckParm( "-playdemo" ); p = M_CheckParm( "-playdemo" );
if( !p ) if( !p )
{
p = M_CheckParm( "-timedemo" ); p = M_CheckParm( "-timedemo" );
}
if( p && p < ::g->myargc - 1 ) if( p && p < ::g->myargc - 1 )
{ {
@ -638,17 +697,20 @@ void D_DoomMain (void)
::g->startmap = 1; ::g->startmap = 1;
::g->autostart = false; ::g->autostart = false;
if ( DoomLib::matchParms.gameEpisode != GAME_EPISODE_UNKNOWN ) { if( DoomLib::matchParms.gameEpisode != GAME_EPISODE_UNKNOWN )
{
::g->startepisode = DoomLib::matchParms.gameEpisode; ::g->startepisode = DoomLib::matchParms.gameEpisode;
::g->autostart = 1; ::g->autostart = 1;
} }
if ( DoomLib::matchParms.gameMap != -1 ) { if( DoomLib::matchParms.gameMap != -1 )
{
::g->startmap = DoomLib::matchParms.gameMap; ::g->startmap = DoomLib::matchParms.gameMap;
::g->autostart = 1; ::g->autostart = 1;
} }
if ( DoomLib::matchParms.gameSkill != -1) { if( DoomLib::matchParms.gameSkill != -1 )
{
::g->startskill = ( skill_t )DoomLib::matchParms.gameSkill; ::g->startskill = ( skill_t )DoomLib::matchParms.gameSkill;
} }
@ -681,19 +743,25 @@ void D_DoomMain (void)
time = timeLimit; time = timeLimit;
I_Printf( "Levels will end after %d minute", time ); I_Printf( "Levels will end after %d minute", time );
if( time > 1 ) if( time > 1 )
{
I_Printf( "s" ); I_Printf( "s" );
}
I_Printf( ".\n" ); I_Printf( ".\n" );
} }
p = M_CheckParm( "-avg" ); p = M_CheckParm( "-avg" );
if( p && p < ::g->myargc - 1 && ::g->deathmatch ) if( p && p < ::g->myargc - 1 && ::g->deathmatch )
{
I_Printf( "Austin Virtual Gaming: Levels will end after 20 minutes\n" ); I_Printf( "Austin Virtual Gaming: Levels will end after 20 minutes\n" );
}
p = M_CheckParm( "-warp" ); p = M_CheckParm( "-warp" );
if( p && p < ::g->myargc - 1 ) if( p && p < ::g->myargc - 1 )
{ {
if( ::g->gamemode == commercial ) if( ::g->gamemode == commercial )
{
::g->startmap = atoi( ::g->myargv[p + 1] ); ::g->startmap = atoi( ::g->myargv[p + 1] );
}
else else
{ {
::g->startepisode = ::g->myargv[p + 1][0] - '0'; ::g->startepisode = ::g->myargv[p + 1][0] - '0';
@ -738,8 +806,10 @@ void D_DoomMain (void)
if( ::g->gamemode == registered ) if( ::g->gamemode == registered )
for( i = 0; i < 23; i++ ) for( i = 0; i < 23; i++ )
if( W_CheckNumForName( name[i] ) < 0 ) if( W_CheckNumForName( name[i] ) < 0 )
{
I_Error( "\nThis is not the registered version." ); I_Error( "\nThis is not the registered version." );
} }
}
// Iff additonal PWAD files are used, print modified banner // Iff additonal PWAD files are used, print modified banner
if( ::g->modifiedgame ) if( ::g->modifiedgame )
@ -805,7 +875,9 @@ bool D_DoomMainPoll(void)
char file[256]; char file[256];
if( D_PollNetworkStart() == false ) if( D_PollNetworkStart() == false )
{
return false; return false;
}
I_Printf( "S_Init: Setting up sound.\n" ); I_Printf( "S_Init: Setting up sound.\n" );
@ -845,18 +917,25 @@ bool D_DoomMainPoll(void)
if( p && p < ::g->myargc - 1 ) if( p && p < ::g->myargc - 1 )
{ {
if( M_CheckParm( "-cdrom" ) ) if( M_CheckParm( "-cdrom" ) )
{
sprintf( file, "c:\\doomdata\\" SAVEGAMENAME "%c.dsg", ::g->myargv[p + 1][0] ); sprintf( file, "c:\\doomdata\\" SAVEGAMENAME "%c.dsg", ::g->myargv[p + 1][0] );
}
else else
{
sprintf( file, SAVEGAMENAME "%c.dsg", ::g->myargv[p + 1][0] ); sprintf( file, SAVEGAMENAME "%c.dsg", ::g->myargv[p + 1][0] );
}
G_LoadGame( file ); G_LoadGame( file );
} }
if( ::g->gameaction != ga_loadgame && ::g->gameaction != ga_playdemo ) 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 ); 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 D_StartTitle(); // start up intro loop
} }
} }

View file

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

View file

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

View file

@ -57,55 +57,65 @@ bool debugOutput = false;
namespace DoomLib 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" "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" "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" "#str_friends", "#str_around", "#str_top15"
}; };
// Game-specific setup values. // 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", "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", "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", "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" "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", "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!", "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", "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" "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", "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", "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" "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", "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", "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" "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", "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" "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" "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, 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, 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 }, { 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]; int classicRemap[K_LAST_KEY];
const ExpansionData * GetCurrentExpansion() { const ExpansionData* GetCurrentExpansion()
{
return &App_Expansion_Data_Local[ DoomLib::expansionSelected ]; return &App_Expansion_Data_Local[ DoomLib::expansionSelected ];
} }
void SetCurrentExpansion( int expansion ) { void SetCurrentExpansion( int expansion )
{
expansionDirty = true; expansionDirty = true;
expansionSelected = expansion; expansionSelected = expansion;
} }
void SetIdealExpansion( int expansion ) { void SetIdealExpansion( int expansion )
{
idealExpansion = expansion; idealExpansion = expansion;
} }
idStr currentMapName; idStr currentMapName;
idStr currentDifficulty; idStr currentDifficulty;
void SetCurrentMapName( idStr name ) { currentMapName = name; } void SetCurrentMapName( idStr name )
const idStr & GetCurrentMapName() { return currentMapName; } {
void SetCurrentDifficulty( idStr name ) { currentDifficulty = name; } currentMapName = name;
const idStr & GetCurrentDifficulty() { return currentDifficulty; } }
const idStr& GetCurrentMapName()
{
return currentMapName;
}
void SetCurrentDifficulty( idStr name )
{
currentDifficulty = name;
}
const idStr& GetCurrentDifficulty()
{
return currentDifficulty;
}
int currentplayer = -1; int currentplayer = -1;
@ -167,7 +192,8 @@ namespace DoomLib
idArray< idSysMutex, 4 > playerScreenMutexes; idArray< idSysMutex, 4 > playerScreenMutexes;
void ExitGame() { void ExitGame()
{
// TODO: If we ever support splitscreen and online, // TODO: If we ever support splitscreen and online,
// we'll have to call D_QuitNetGame for all local players. // we'll have to call D_QuitNetGame for all local players.
DoomLib::SetPlayer( 0 ); DoomLib::SetPlayer( 0 );
@ -176,7 +202,8 @@ namespace DoomLib
session->QuitMatch(); session->QuitMatch();
} }
void ShowXToContinue( bool activate ) { void ShowXToContinue( bool activate )
{
} }
/* /*
@ -184,11 +211,15 @@ namespace DoomLib
DoomLib::GetGameSKU DoomLib::GetGameSKU
======================== ========================
*/ */
gameSKU_t GetGameSKU() { gameSKU_t GetGameSKU()
{
if ( common->GetCurrentGame() == DOOM_CLASSIC ) { if( common->GetCurrentGame() == DOOM_CLASSIC )
{
return GAME_SKU_DOOM1_BFG; return GAME_SKU_DOOM1_BFG;
} else if ( common->GetCurrentGame() == DOOM2_CLASSIC ) { }
else if( common->GetCurrentGame() == DOOM2_CLASSIC )
{
return GAME_SKU_DOOM2_BFG; return GAME_SKU_DOOM2_BFG;
} }
@ -201,13 +232,15 @@ namespace DoomLib
DoomLib::ActivateGame DoomLib::ActivateGame
======================== ========================
*/ */
void ActivateGame() { void ActivateGame()
{
Active = true; Active = true;
// Turn off menu toggler // Turn off menu toggler
int originalPlayer = DoomLib::GetPlayer(); int originalPlayer = DoomLib::GetPlayer();
for ( int i = 0; i < Interface.GetNumPlayers(); i++ ) { for( int i = 0; i < Interface.GetNumPlayers(); i++ )
{
DoomLib::SetPlayer( i ); DoomLib::SetPlayer( i );
::g->menuactive = false; ::g->menuactive = false;
} }
@ -222,8 +255,10 @@ namespace DoomLib
DoomLib::HandleEndMatch DoomLib::HandleEndMatch
======================== ========================
*/ */
void HandleEndMatch() { void HandleEndMatch()
if ( session->GetGameLobbyBase().IsHost() ) { {
if( session->GetGameLobbyBase().IsHost() )
{
ShowXToContinue( false ); ShowXToContinue( false );
session->EndMatch(); session->EndMatch();
} }
@ -245,7 +280,9 @@ extern void I_ProcessSoundEvents();
void DoomLib::InitGlobals( void* ptr /* = NULL */ ) void DoomLib::InitGlobals( void* ptr /* = NULL */ )
{ {
if( ptr == NULL ) if( ptr == NULL )
{
ptr = new Globals; ptr = new Globals;
}
globaldata[currentplayer] = static_cast<Globals*>( ptr ); 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]; return globaldata[player];
} }
void DoomLib::InitControlRemap() { void DoomLib::InitControlRemap()
{
memset( classicRemap, K_NONE, sizeof( classicRemap ) ); 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; return key;
} else { }
else
{
if( ::g->menuactive && key == K_JOY2 ) { if( ::g->menuactive && key == K_JOY2 )
{
return K_BACKSPACE; return K_BACKSPACE;
} }
@ -334,7 +378,8 @@ void DoomLib::Frame( int realoffset, int buffer )
// suffers too much, we can try to narrow the scope. // suffers too much, we can try to narrow the scope.
// Just be careful, because the player's screen data is updated in many different // Just be careful, because the player's screen data is updated in many different
// places. // places.
if ( 0 <= currentplayer && currentplayer <= 4 ) { if( 0 <= currentplayer && currentplayer <= 4 )
{
idScopedCriticalSection crit( playerScreenMutexes[currentplayer] ); idScopedCriticalSection crit( playerScreenMutexes[currentplayer] );
D_RunFrame( true ); D_RunFrame( true );
@ -381,7 +426,8 @@ fixed_t GetViewY()
return ::g->viewy + ::g->viewyoffset; return ::g->viewy + ::g->viewyoffset;
} }
void DoomLib::Shutdown() { void DoomLib::Shutdown()
{
//D_QuitNetGame (); //D_QuitNetGame ();
I_ShutdownSound(); I_ShutdownSound();
I_ShutdownGraphics(); I_ShutdownGraphics();
@ -389,12 +435,14 @@ void DoomLib::Shutdown() {
W_Shutdown(); W_Shutdown();
// De-allocate the zone memory (never happened in original doom, until quit) // De-allocate the zone memory (never happened in original doom, until quit)
if ( ::g->mainzone ) { if( ::g->mainzone )
{
free( ::g->mainzone ); free( ::g->mainzone );
} }
// Delete the globals // Delete the globals
if ( globaldata[currentplayer] ) { if( globaldata[currentplayer] )
{
delete globaldata[currentplayer]; delete globaldata[currentplayer];
globaldata[currentplayer] = NULL; globaldata[currentplayer] = NULL;
} }
@ -405,13 +453,16 @@ void DoomLib::SetPlayer( int id )
{ {
currentplayer = id; currentplayer = id;
if ( id < 0 || id >= MAX_PLAYERS ) { if( id < 0 || id >= MAX_PLAYERS )
{
g = NULL; g = NULL;
} }
else { else
{
// Big Fucking hack. // Big Fucking hack.
if( globalNetworking && session->GetGameLobbyBase().GetMatchParms().matchFlags | MATCH_ONLINE ) { if( globalNetworking && session->GetGameLobbyBase().GetMatchParms().matchFlags | MATCH_ONLINE )
{
currentplayer = 0; currentplayer = 0;
} }
@ -433,7 +484,8 @@ int DoomLib::GetPlayer()
return currentplayer; return currentplayer;
} }
byte DoomLib::BuildSourceDest( int toNode ) { byte DoomLib::BuildSourceDest( int toNode )
{
byte sourceDest = 0; byte sourceDest = 0;
sourceDest |= ::g->consoleplayer << 2; sourceDest |= ::g->consoleplayer << 2;
sourceDest |= RemoteNodeToPlayerIndex( toNode ); sourceDest |= RemoteNodeToPlayerIndex( toNode );
@ -442,7 +494,8 @@ byte DoomLib::BuildSourceDest( int toNode ) {
void I_Printf( char* error, ... ); 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 src = ( sourceDest & 12 ) >> 2;
int dst = sourceDest & 3; int dst = sourceDest & 3;
@ -453,14 +506,16 @@ void DoomLib::GetSourceDest( byte sourceDest, int* source, int* dest ) {
*dest = PlayerIndexToRemoteNode( dst ); *dest = PlayerIndexToRemoteNode( dst );
} }
int nodeMap[4][4] = { int nodeMap[4][4] =
{
{0, 1, 2, 3}, //Player 0 {0, 1, 2, 3}, //Player 0
{1, 0, 2, 3}, //Player 1 {1, 0, 2, 3}, //Player 1
{2, 0, 1, 3}, //Player 2 {2, 0, 1, 3}, //Player 2
{3, 0, 1, 2} //Player 3 {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 //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 {0, 1, 2, 3}, //Player 0
{1, 0, 2, 3}, //Player 1 {1, 0, 2, 3}, //Player 1
{1, 2, 0, 3}, //Player 2 {1, 2, 0, 3}, //Player 2
{1, 2, 3, 0} //Player 3 {1, 2, 3, 0} //Player 3
}; };
int DoomLib::PlayerIndexToRemoteNode( int index ) { int DoomLib::PlayerIndexToRemoteNode( int index )
{
/*int player = ::g->consoleplayer; /*int player = ::g->consoleplayer;
if( index == 0 ) { if( index == 0 ) {
return player; return player;
@ -501,11 +558,14 @@ int DoomLib::PlayerIndexToRemoteNode( int index ) {
void I_Error( const char* error, ... ); void I_Error( const char* error, ... );
extern bool useTech5Packets; extern bool useTech5Packets;
void DoomLib::PollNetwork() { void DoomLib::PollNetwork()
{
#if 0 #if 0
if ( !useTech5Packets ) { if( !useTech5Packets )
{
if ( !globalNetworking ) { if( !globalNetworking )
{
return; return;
} }
@ -514,14 +574,16 @@ void DoomLib::PollNetwork() {
socklen_t fromlen; socklen_t fromlen;
doomdata_t sw; doomdata_t sw;
while(1) { while( 1 )
{
int receivedSize = recvfrom( ::g->insocket, &sw, sizeof( doomdata_t ), MSG_DONTWAIT, &fromaddress, &fromlen ); 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); //c = WSARecvFrom(::g->insocket, &buffer, 1, &num_recieved, &flags, (struct sockaddr*)&fromaddress, &fromlen, 0, 0);
if( receivedSize < 0 ) if( receivedSize < 0 )
{ {
int err = sys_net_errno; int err = sys_net_errno;
if (err != SYS_NET_EWOULDBLOCK ) { if( err != SYS_NET_EWOULDBLOCK )
{
I_Error( "GetPacket: %d", err ); I_Error( "GetPacket: %d", err );
//I_Printf ("GetPacket: %s",strerror(errno)); //I_Printf ("GetPacket: %s",strerror(errno));
} }
@ -541,15 +603,18 @@ void DoomLib::PollNetwork() {
#endif #endif
} }
void DoomLib::SendNetwork() { void DoomLib::SendNetwork()
{
if ( !globalNetworking ) { if( !globalNetworking )
{
return; return;
} }
//DoomLib::SendRemote(); //DoomLib::SendRemote();
} }
void DoomLib::RunSound() { void DoomLib::RunSound()
{
I_ProcessSoundEvents(); 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_DCC = 0, // Doom Classic Complete
GAME_SKU_DOOM1_BFG, // Doom 1 Ran from BFG GAME_SKU_DOOM1_BFG, // Doom 1 Ran from BFG
GAME_SKU_DOOM2_BFG, // Doom 2 Ran from BFG GAME_SKU_DOOM2_BFG, // Doom 2 Ran from BFG
@ -75,7 +76,8 @@ enum gameSKU_t {
ExpansionData ExpansionData
================================================================================================ ================================================================================================
*/ */
struct ExpansionData { struct ExpansionData
{
enum { IWAD = 0, PWAD = 1 } type; enum { IWAD = 0, PWAD = 1 } type;
GameMode_t gameMode; GameMode_t gameMode;

View file

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

View file

@ -59,7 +59,9 @@ wipe_shittyColMajorXform
for( y = 0; y < height; y++ ) for( y = 0; y < height; y++ )
for( x = 0; x < width; x++ ) for( x = 0; x < width; x++ )
{
dest[x * height + y] = array[y * width + x]; dest[x * height + y] = array[y * width + x];
}
memcpy( array, dest, width * height * 2 ); memcpy( array, dest, width * height * 2 );
@ -97,15 +99,20 @@ wipe_initMelt
::g->wipe_y[i] = ::g->wipe_y[i - 1] + r; ::g->wipe_y[i] = ::g->wipe_y[i - 1] + r;
if( ::g->wipe_y[i] > 0 ) if( ::g->wipe_y[i] > 0 )
{
::g->wipe_y[i] = 0; ::g->wipe_y[i] = 0;
}
else if( ::g->wipe_y[i] == -16 ) else if( ::g->wipe_y[i] == -16 )
{
::g->wipe_y[i] = -15; ::g->wipe_y[i] = -15;
} }
}
return 0; return 0;
} }
int wipe_doMelt( int width, int height, int ticks ) { int wipe_doMelt( int width, int height, int ticks )
{
int i; int i;
int j; int j;
int dy; int dy;
@ -121,17 +128,21 @@ int wipe_doMelt( int width, int height, int ticks ) {
{ {
for( i = 0; i < width; i++ ) for( i = 0; i < width; i++ )
{ {
if (::g->wipe_y[i]<0) { if( ::g->wipe_y[i] < 0 )
{
::g->wipe_y[i]++; ::g->wipe_y[i]++;
done = false; 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; 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 ) if( ::g->wipe_y[i] + dy >= height )
{
dy = height - ::g->wipe_y[i]; dy = height - ::g->wipe_y[i];
}
s = &( ( short* )::g->wipe_scr_end )[i * 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]; 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 "defs.h"
#include "structs.h" #include "structs.h"
struct Globals { struct Globals
{
void InitGlobals(); void InitGlobals();
#include "vars.h" #include "vars.h"
}; };

View file

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

View file

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

View file

@ -53,27 +53,35 @@ extern int PLAYERCOUNT;
#define NUM_BUTTONS 4 #define NUM_BUTTONS 4
static bool Cheat_God() { static bool Cheat_God()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
::g->plyr->cheats ^= CF_GODMODE; ::g->plyr->cheats ^= CF_GODMODE;
if( ::g->plyr->cheats & CF_GODMODE ) if( ::g->plyr->cheats & CF_GODMODE )
{ {
if( ::g->plyr->mo ) if( ::g->plyr->mo )
{
::g->plyr->mo->health = 100; ::g->plyr->mo->health = 100;
}
::g->plyr->health = 100; ::g->plyr->health = 100;
::g->plyr->message = STSTR_DQDON; ::g->plyr->message = STSTR_DQDON;
} }
else else
{
::g->plyr->message = STSTR_DQDOFF; ::g->plyr->message = STSTR_DQDOFF;
}
return true; return true;
} }
#include "g_game.h" #include "g_game.h"
static bool Cheat_NextLevel() { static bool Cheat_NextLevel()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
G_ExitLevel(); G_ExitLevel();
@ -81,8 +89,10 @@ static bool Cheat_NextLevel() {
return true; return true;
} }
static bool Cheat_GiveAll() { static bool Cheat_GiveAll()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
@ -91,20 +101,28 @@ static bool Cheat_GiveAll() {
int i; int i;
for( i = 0; i < NUMWEAPONS; i++ ) for( i = 0; i < NUMWEAPONS; i++ )
{
::g->plyr->weaponowned[i] = true; ::g->plyr->weaponowned[i] = true;
}
for( i = 0; i < NUMAMMO; i++ ) for( i = 0; i < NUMAMMO; i++ )
{
::g->plyr->ammo[i] = ::g->plyr->maxammo[i]; ::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
}
for( i = 0; i < NUMCARDS; i++ ) for( i = 0; i < NUMCARDS; i++ )
{
::g->plyr->cards[i] = true; ::g->plyr->cards[i] = true;
}
::g->plyr->message = STSTR_KFAADDED; ::g->plyr->message = STSTR_KFAADDED;
return true; return true;
} }
static bool Cheat_GiveAmmo() { static bool Cheat_GiveAmmo()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
::g->plyr->armorpoints = 200; ::g->plyr->armorpoints = 200;
@ -112,17 +130,23 @@ static bool Cheat_GiveAmmo() {
int i; int i;
for( i = 0; i < NUMWEAPONS; i++ ) for( i = 0; i < NUMWEAPONS; i++ )
{
::g->plyr->weaponowned[i] = true; ::g->plyr->weaponowned[i] = true;
}
for( i = 0; i < NUMAMMO; i++ ) for( i = 0; i < NUMAMMO; i++ )
{
::g->plyr->ammo[i] = ::g->plyr->maxammo[i]; ::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
}
::g->plyr->message = STSTR_KFAADDED; ::g->plyr->message = STSTR_KFAADDED;
return true; return true;
} }
static bool Cheat_Choppers() { static bool Cheat_Choppers()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
::g->plyr->weaponowned[wp_chainsaw] = true; ::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 ); 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] ) if( !::g->plyr->powers[i] )
{
P_GivePower( ::g->plyr, i ); P_GivePower( ::g->plyr, i );
}
else if( i != pw_strength ) else if( i != pw_strength )
{
::g->plyr->powers[i] = 1; ::g->plyr->powers[i] = 1;
}
else else
{
::g->plyr->powers[i] = 0; ::g->plyr->powers[i] = 0;
}
::g->plyr->message = STSTR_BEHOLDX; ::g->plyr->message = STSTR_BEHOLDX;
} }
static bool Cheat_GiveInvul() { static bool Cheat_GiveInvul()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
@ -152,8 +185,10 @@ static bool Cheat_GiveInvul() {
return true; return true;
} }
static bool Cheat_GiveBerserk() { static bool Cheat_GiveBerserk()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
@ -161,8 +196,10 @@ static bool Cheat_GiveBerserk() {
return true; return true;
} }
static bool Cheat_GiveBlur() { static bool Cheat_GiveBlur()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
@ -170,8 +207,10 @@ static bool Cheat_GiveBlur() {
return true; return true;
} }
static bool Cheat_GiveRad() { static bool Cheat_GiveRad()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
@ -179,8 +218,10 @@ static bool Cheat_GiveRad() {
return true; return true;
} }
static bool Cheat_GiveMap() { static bool Cheat_GiveMap()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
@ -188,8 +229,10 @@ static bool Cheat_GiveMap() {
return true; return true;
} }
static bool Cheat_GiveLight() { static bool Cheat_GiveLight()
if( PLAYERCOUNT != 1 || ::g->netgame ) { {
if( PLAYERCOUNT != 1 || ::g->netgame )
{
return false; return false;
} }
@ -214,7 +257,8 @@ struct cheatcode_t
cheat_command function; cheat_command function;
}; };
static cheatcode_t codes[] = { static cheatcode_t codes[] =
{
{ {0, 1, 1, 0}, Cheat_God }, // a b b a { {0, 1, 1, 0}, Cheat_God }, // a b b a
{ {0, 0, 1, 1}, Cheat_NextLevel }, // a a b b { {0, 0, 1, 1}, Cheat_NextLevel }, // a a b b
{ {1, 0, 1, 0}, Cheat_GiveAmmo }, // b a b a { {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] ); const static int numberOfCodes = sizeof( codes ) / sizeof( codes[0] );
void BeginTrackingCheat() { void BeginTrackingCheat()
{
#if ALLOW_CHEATS #if ALLOW_CHEATS
tracking = true; tracking = true;
currentCheatLength = 0; currentCheatLength = 0;
@ -239,7 +284,8 @@ void BeginTrackingCheat() {
#endif #endif
} }
void EndTrackingCheat() { void EndTrackingCheat()
{
#if ALLOW_CHEATS #if ALLOW_CHEATS
tracking = false; tracking = false;
#endif #endif
@ -247,16 +293,22 @@ void EndTrackingCheat() {
extern void S_StartSound( void* origin, int sfx_id ); extern void S_StartSound( void* origin, int sfx_id );
void CheckCheat( int button ) { void CheckCheat( int button )
{
#if ALLOW_CHEATS #if ALLOW_CHEATS
if( tracking && !::g->netgame ) { if( tracking && !::g->netgame )
{
currentCode[ currentCheatLength++ ] = button; currentCode[ currentCheatLength++ ] = button;
if( currentCheatLength == NUM_BUTTONS ) { if( currentCheatLength == NUM_BUTTONS )
for( int i = 0; i < numberOfCodes; ++i) { {
if( memcmp( &codes[i].code[0], &currentCode[0], sizeof(currentCode) ) == 0 ) { for( int i = 0; i < numberOfCodes; ++i )
if(codes[i].function()) { {
if( memcmp( &codes[i].code[0], &currentCode[0], sizeof( currentCode ) ) == 0 )
{
if( codes[i].function() )
{
S_StartSound( 0, sfx_cybsit ); S_StartSound( 0, sfx_cybsit );
} }
} }
@ -303,11 +355,13 @@ int I_PollMouseInputEvents( controller_t *con)
return numEvents; 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->type = ev_mouse;
e->data1 = e->data2 = e->data3 = 0; e->data1 = e->data2 = e->data3 = 0;
switch(::g->mouseEvents[n].type) { switch( ::g->mouseEvents[n].type )
{
case IETAxis: case IETAxis:
switch( ::g->mouseEvents[n].action ) switch( ::g->mouseEvents[n].action )
{ {
@ -326,7 +380,8 @@ int I_ReturnMouseInputEvent( const int n, event_t* e) {
return 0; return 0;
} }
int I_PollJoystickInputEvents( controller_t *con ) { int I_PollJoystickInputEvents( controller_t* con )
{
int numEvents = 0; int numEvents = 0;
return numEvents; return numEvents;
@ -349,10 +404,12 @@ static int xlatekey(int key)
rc = '1'; rc = '1';
break; break;
case 1: // B case 1: // B
if( ::g->menuactive ) { if( ::g->menuactive )
{
rc = KEY_BACKSPACE; rc = KEY_BACKSPACE;
} }
else { else
{
rc = '2'; rc = '2';
} }
break; break;
@ -373,37 +430,45 @@ static int xlatekey(int key)
rc = KEY_RCTRL; rc = KEY_RCTRL;
break; break;
case 8: // Up case 8: // Up
if( ::g->menuactive ) { if( ::g->menuactive )
{
rc = KEY_UPARROW; rc = KEY_UPARROW;
} }
else { else
{
//rc = KEY_ENTER; //rc = KEY_ENTER;
rc = '3'; rc = '3';
} }
break; break;
case 9: case 9:
if( ::g->menuactive ) { if( ::g->menuactive )
{
rc = KEY_DOWNARROW; rc = KEY_DOWNARROW;
} }
else { else
{
//rc = KEY_TAB; //rc = KEY_TAB;
rc = '5'; rc = '5';
} }
break; break;
case 10: case 10:
if( ::g->menuactive ) { if( ::g->menuactive )
{
rc = KEY_UPARROW; rc = KEY_UPARROW;
} }
else { else
{
//rc = '1'; //rc = '1';
rc = '6'; rc = '6';
} }
break; break;
case 11: case 11:
if( ::g->menuactive ) { if( ::g->menuactive )
{
rc = KEY_DOWNARROW; rc = KEY_DOWNARROW;
} }
else { else
{
//rc = '2'; //rc = '2';
rc = '4'; rc = '4';
} }
@ -422,7 +487,8 @@ static int xlatekey(int key)
return rc; 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; e->data1 = e->data2 = e->data3 = 0;
@ -450,9 +516,13 @@ int I_ReturnJoystickInputEvent( const int n, event_t* e) {
case IETButtonAnalog: case IETButtonAnalog:
case IETButtonDigital: case IETButtonDigital:
if( ::g->joyEvents[n].data ) if( ::g->joyEvents[n].data )
{
e->type = ev_keydown; e->type = ev_keydown;
}
else else
{
e->type = ev_keyup; e->type = ev_keyup;
}
e->data1 = xlatekey( ::g->joyEvents[n].action ); e->data1 = xlatekey( ::g->joyEvents[n].action );
return 1; return 1;
@ -463,7 +533,8 @@ int I_ReturnJoystickInputEvent( const int n, event_t* e) {
return 0; return 0;
} }
void I_EndJoystickInputEvents() { void I_EndJoystickInputEvents()
{
int i; int i;
for( i = 0; i < 18; 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 ); void NetSend( void );
qboolean NetListen( void ); qboolean NetListen( void );
namespace { namespace
{
bool IsValidSocket( int socketDescriptor ); bool IsValidSocket( int socketDescriptor );
int GetLastSocketError(); int GetLastSocketError();
@ -63,7 +64,8 @@ namespace {
between WinSock (used on Xbox) and BSD sockets, which the PS3 follows more closely. between WinSock (used on Xbox) and BSD sockets, which the PS3 follows more closely.
======================== ========================
*/ */
bool IsValidSocket( int socketDescriptor ) { bool IsValidSocket( int socketDescriptor )
{
return false; return false;
} }
@ -72,7 +74,8 @@ namespace {
Returns the last error reported by the platform's socket library. Returns the last error reported by the platform's socket library.
======================== ========================
*/ */
int GetLastSocketError() { int GetLastSocketError()
{
return 0; 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? 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 ::g->sendaddress[::g->doomcom.consoleplayer].sin_addr.s_addr;
return 0; return 0;
} }
@ -161,17 +165,27 @@ void I_InitNetwork (void)
{ {
::g->doomcom.ticdup = ::g->myargv[i + 1][0] - '0'; ::g->doomcom.ticdup = ::g->myargv[i + 1][0] - '0';
if( ::g->doomcom.ticdup < 1 ) if( ::g->doomcom.ticdup < 1 )
{
::g->doomcom.ticdup = 1; ::g->doomcom.ticdup = 1;
}
if( ::g->doomcom.ticdup > 9 ) if( ::g->doomcom.ticdup > 9 )
{
::g->doomcom.ticdup = 9; ::g->doomcom.ticdup = 9;
} }
}
else else
{
::g->doomcom.ticdup = 1; ::g->doomcom.ticdup = 1;
}
if( M_CheckParm( "-extratic" ) ) if( M_CheckParm( "-extratic" ) )
{
::g->doomcom.extratics = 1; ::g->doomcom.extratics = 1;
}
else else
{
::g->doomcom.extratics = 0; ::g->doomcom.extratics = 0;
}
p = M_CheckParm( "-port" ); p = M_CheckParm( "-port" );
if( p && p < ::g->myargc - 1 ) if( p && p < ::g->myargc - 1 )
@ -217,20 +231,24 @@ void I_InitNetwork (void)
const std::size_t colonPosition = ipAddressWithPort.find_last_of( ':' ); const std::size_t colonPosition = ipAddressWithPort.find_last_of( ':' );
std::string ipOnly; 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 ) ); const std::string portOnly( ipAddressWithPort.substr( colonPosition + 1 ) );
::g->sendaddress[::g->doomcom.numnodes].sin_port = htons( atoi( portOnly.c_str() ) ); ::g->sendaddress[::g->doomcom.numnodes].sin_port = htons( atoi( portOnly.c_str() ) );
ipOnly = ipAddressWithPort.substr( 0, colonPosition ); ipOnly = ipAddressWithPort.substr( 0, colonPosition );
} else { }
else
{
// Assume the address doesn't include a port. // Assume the address doesn't include a port.
ipOnly = ipAddressWithPort; ipOnly = ipAddressWithPort;
} }
in_addr_t ipAddress = inet_addr( ipOnly.c_str() ); 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() ); I_Error( "Invalid IP Address: %s\n", ipOnly.c_str() );
session->QuitMatch(); session->QuitMatch();
common->AddDialog( GDM_OPPONENT_CONNECTION_LOST, DIALOG_ACCEPT, NULL, NULL, false ); 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; ::g->doomcom.numplayers = ::g->doomcom.numnodes;
} }
if ( globalNetworking ) { if( globalNetworking )
{
// Setup sockets // Setup sockets
::g->insocket = UDPsocket(); ::g->insocket = UDPsocket();
BindToLocalPort( ::g->insocket, htons( DOOMPORT ) ); BindToLocalPort( ::g->insocket, htons( DOOMPORT ) );
@ -260,7 +279,8 @@ void I_InitNetwork (void)
} }
// DHM - Nerve // DHM - Nerve
void I_ShutdownNetwork() { void I_ShutdownNetwork()
{
} }

View file

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

View file

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

View file

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

View file

@ -132,7 +132,8 @@ void I_Printf(const char* msg, ...)
va_list argptr; va_list argptr;
// Message first. // Message first.
if( debugOutput ) { if( debugOutput )
{
va_start( argptr, msg ); va_start( argptr, msg );
vsprintf( pmsg, msg, argptr ); vsprintf( pmsg, msg, argptr );
@ -149,7 +150,8 @@ void I_PrintfE(const char* msg, ...)
va_list argptr; va_list argptr;
// Message first. // Message first.
if( debugOutput ) { if( debugOutput )
{
va_start( argptr, msg ); va_start( argptr, msg );
vsprintf( pmsg, msg, argptr ); vsprintf( pmsg, msg, argptr );
@ -167,7 +169,8 @@ void I_Error(const char *error, ...)
va_list argptr; va_list argptr;
// Message first. // Message first.
if( debugOutput ) { if( debugOutput )
{
va_start( argptr, error ); va_start( argptr, error );
idStr::vsnPrintf( error_msg, ERROR_MSG_SIZE, error, argptr ); 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 ) static void I_CombineMouseEvent( const event_t* in, event_t* out )
{ {
if( fabs( ( float )in->data1 ) > fabs( ( float )out->data1 ) ) if( fabs( ( float )in->data1 ) > fabs( ( float )out->data1 ) )
{
out->data1 = in->data1; out->data1 = in->data1;
}
if( fabs( ( float )in->data2 ) > fabs( ( float )out->data2 ) ) if( fabs( ( float )in->data2 ) > fabs( ( float )out->data2 ) )
{
out->data2 = in->data2; out->data2 = in->data2;
}
if( fabs( ( float )in->data3 ) > fabs( ( float )out->data3 ) ) if( fabs( ( float )in->data3 ) > fabs( ( float )out->data3 ) )
{
out->data3 = in->data3; out->data3 = in->data3;
} }
}
void I_GetEvents( controller_t* controller ) void I_GetEvents( controller_t* controller )
{ {
@ -96,11 +102,15 @@ void I_GetEvents( controller_t *controller )
{ {
I_ReturnMouseInputEvent( i, &e ); I_ReturnMouseInputEvent( i, &e );
if( e.type == ev_mouse ) if( e.type == ev_mouse )
{
I_CombineMouseEvent( &e, &e_mouse ); I_CombineMouseEvent( &e, &e_mouse );
}
else if( e.type == ev_joystick ) else if( e.type == ev_joystick )
{
I_CombineMouseEvent( &e, &e_joystick ); I_CombineMouseEvent( &e, &e_joystick );
} }
} }
}
numEvents = I_PollJoystickInputEvents( controller ); numEvents = I_PollJoystickInputEvents( controller );
if( numEvents ) if( numEvents )
@ -110,11 +120,16 @@ void I_GetEvents( controller_t *controller )
for( i = 0; i < numEvents; ++i ) for( i = 0; i < numEvents; ++i )
{ {
I_ReturnJoystickInputEvent( i, &e ); 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 ); D_PostEvent( &e );
} else if (e.type == ev_joystick) { }
else if( e.type == ev_joystick )
{
I_CombineMouseEvent( &e, &e_joystick ); I_CombineMouseEvent( &e, &e_joystick );
} else if (e.type == ev_mouse) { }
else if( e.type == ev_mouse )
{
I_CombineMouseEvent( &e, &e_mouse ); I_CombineMouseEvent( &e, &e_mouse );
} }
} }
@ -149,7 +164,8 @@ void I_ReadScreen (byte* scr)
memcpy( scr, ::g->screens[0], SCREENWIDTH * SCREENHEIGHT ); 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; unsigned int color = 0;
color |= ( r & 255 ) << 24; 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 #ifdef _MSC_VER
actionf_p2 action; actionf_p2 action;
#else #else
struct { struct
{
actionf_p2 action; actionf_p2 action;
// int filler; // int filler;
}; };
@ -1181,7 +1182,8 @@ extern const state_t tempStates[NUMSTATES];
extern const char* const sprnames[NUMSPRITES + 1]; extern const char* const sprnames[NUMSPRITES + 1];
// RB end // RB end
typedef enum { typedef enum
{
MT_PLAYER, MT_PLAYER,
MT_POSSESSED, MT_POSSESSED,
MT_SHOTGUY, MT_SHOTGUY,

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -90,11 +90,17 @@ M_DrawText
w = SHORT( ::g->hu_font[c]->width ); w = SHORT( ::g->hu_font[c]->width );
if( x + w > SCREENWIDTH ) if( x + w > SCREENWIDTH )
{
break; break;
}
if( direct ) if( direct )
{
V_DrawPatchDirect( x, y, 0, ::g->hu_font[c] ); V_DrawPatchDirect( x, y, 0, ::g->hu_font[c] );
}
else else
{
V_DrawPatch( x, y, 0, ::g->hu_font[c] ); V_DrawPatch( x, y, 0, ::g->hu_font[c] );
}
x += w; x += w;
} }
@ -105,7 +111,8 @@ M_DrawText
// //
// M_WriteFile // 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; idFile* handle = NULL;
int count; int count;
@ -113,13 +120,17 @@ bool M_WriteFile ( char const* name, void* source, int length ) {
handle = fileSystem->OpenFileWrite( name, "fs_savepath" ); handle = fileSystem->OpenFileWrite( name, "fs_savepath" );
if( handle == NULL ) if( handle == NULL )
{
return false; return false;
}
count = handle->Write( source, length ); count = handle->Write( source, length );
fileSystem->CloseFile( handle ); fileSystem->CloseFile( handle );
if( count < length ) if( count < length )
{
return false; return false;
}
return true; return true;
} }
@ -128,14 +139,16 @@ bool M_WriteFile ( char const* name, void* source, int length ) {
// //
// M_ReadFile // M_ReadFile
// //
int M_ReadFile ( char const* name, byte** buffer ) { int M_ReadFile( char const* name, byte** buffer )
{
int count, length; int count, length;
idFile* handle = NULL; idFile* handle = NULL;
byte* buf; byte* buf;
handle = fileSystem->OpenFileRead( name, false ); handle = fileSystem->OpenFileRead( name, false );
if (handle == NULL ) { if( handle == NULL )
{
I_Error( "Couldn't read file %s", name ); 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 ); buf = ( byte* )Z_Malloc( handle->Length(), PU_STATIC, NULL );
count = handle->Read( buf, length ); count = handle->Read( buf, length );
if (count < length ) { if( count < length )
{
I_Error( "Couldn't read file %s", name ); I_Error( "Couldn't read file %s", name );
} }
@ -256,7 +270,9 @@ void M_LoadDefaults (void)
// set everything to base values // set everything to base values
::g->numdefaults = sizeof( ::g->defaults ) / sizeof( ::g->defaults[0] ); ::g->numdefaults = sizeof( ::g->defaults ) / sizeof( ::g->defaults[0] );
for( i = 0 ; i < ::g->numdefaults ; i++ ) for( i = 0 ; i < ::g->numdefaults ; i++ )
{
*::g->defaults[i].location = ::g->defaults[i].defaultvalue; *::g->defaults[i].location = ::g->defaults[i].defaultvalue;
}
// check for a custom default file // check for a custom default file
i = M_CheckParm( "-config" ); i = M_CheckParm( "-config" );
@ -266,7 +282,9 @@ void M_LoadDefaults (void)
I_Printf( " default file: %s\n", ::g->defaultfile ); I_Printf( " default file: %s\n", ::g->defaultfile );
} }
else else
{
::g->defaultfile = ::g->basedefault; ::g->defaultfile = ::g->basedefault;
}
/* /*
// read the file in, overriding any set ::g->defaults // 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 // M_Random
// Returns a 0-255 number // 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 , 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 , 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 , 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 // reads a variable length integer
unsigned long ReadVarLen( char* buffer ) { unsigned long ReadVarLen( char* buffer )
{
unsigned long value; unsigned long value;
byte c; byte c;
if ((value = *buffer++) & 0x80) { if( ( value = *buffer++ ) & 0x80 )
{
value &= 0x7f; value &= 0x7f;
do { do
{
value = ( value << 7 ) + ( ( c = *buffer++ ) & 0x7f ); value = ( value << 7 ) + ( ( c = *buffer++ ) & 0x7f );
} while (c & 0x80); }
while( c & 0x80 );
} }
return value; return value;
} }
@ -54,21 +58,27 @@ int WriteVarLen( long value, byte* out )
long buffer, count = 0; long buffer, count = 0;
buffer = value & 0x7f; buffer = value & 0x7f;
while ((value >>= 7) > 0) { while( ( value >>= 7 ) > 0 )
{
buffer <<= 8; buffer <<= 8;
buffer += 0x80; buffer += 0x80;
buffer += ( value & 0x7f ); buffer += ( value & 0x7f );
} }
while (1) { while( 1 )
{
++count; ++count;
*out = ( byte )buffer; *out = ( byte )buffer;
++out; ++out;
if( buffer & 0x80 ) if( buffer & 0x80 )
{
buffer >>= 8; buffer >>= 8;
}
else else
{
break; break;
} }
}
return count; return count;
} }
@ -152,8 +162,10 @@ unsigned char MidiMap[] =
}; };
// The MUS data is stored in little-endian. // The MUS data is stored in little-endian.
namespace { namespace
unsigned short LittleToNative( const unsigned short value ) { {
unsigned short LittleToNative( const unsigned short value )
{
return value; return value;
} }
} }
@ -198,10 +210,13 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
// only 15 supported // only 15 supported
if( header.channels > MIDI_MAXCHANNELS - 1 ) if( header.channels > MIDI_MAXCHANNELS - 1 )
{
return 0; return 0;
}
// Map channel 15 to 9(percussions) // Map channel 15 to 9(percussions)
for (temp = 0; temp < MIDI_MAXCHANNELS; ++temp) { for( temp = 0; temp < MIDI_MAXCHANNELS; ++temp )
{
channelMap[temp] = -1; channelMap[temp] = -1;
channel_volume[temp] = 0x40; channel_volume[temp] = 0x40;
} }
@ -235,7 +250,8 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
out = WriteByte( out, 127 ); out = WriteByte( out, 127 );
// Main Loop // Main Loop
while (cur < end) { while( cur < end )
{
byte channel; byte channel;
byte event; byte event;
byte temp_buffer[32]; // temp buffer for current iterator 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 // Write variable length delta time
out_local += WriteVarLen( delta_time, out_local ); out_local += WriteVarLen( delta_time, out_local );
if (channelMap[channel] < 0) { if( channelMap[channel] < 0 )
{
// Set all channels to 127 volume // Set all channels to 127 volume
out_local = WriteByte( out_local, 0xB0 + currentChannel ); out_local = WriteByte( out_local, 0xB0 + currentChannel );
out_local = WriteByte( out_local, 0x07 ); out_local = WriteByte( out_local, 0x07 );
@ -258,8 +275,10 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
channelMap[channel] = currentChannel++; channelMap[channel] = currentChannel++;
if( currentChannel == 9 ) if( currentChannel == 9 )
{
++currentChannel; ++currentChannel;
} }
}
status = channelMap[channel]; status = channelMap[channel];
@ -278,7 +297,9 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
status |= 0x90; status |= 0x90;
bit1 = *cur & 127; bit1 = *cur & 127;
if( *cur++ & 128 ) // volume bit? if( *cur++ & 128 ) // volume bit?
{
channel_volume[channelMap[channel]] = *cur++; channel_volume[channelMap[channel]] = *cur++;
}
bit2 = channel_volume[channelMap[channel]]; bit2 = channel_volume[channelMap[channel]];
break; break;
case MUSEVENT_PITCHWHEEL: case MUSEVENT_PITCHWHEEL:
@ -293,12 +314,15 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
bit2 = ( *cur++ == 12 ) ? header.channels + 1 : 0x00; bit2 = ( *cur++ == 12 ) ? header.channels + 1 : 0x00;
break; break;
case MUSEVENT_CONTROLLERCHANGE: case MUSEVENT_CONTROLLERCHANGE:
if (*cur == 0) { if( *cur == 0 )
{
cur++; cur++;
status |= 0xC0; status |= 0xC0;
bit1 = *cur++; bit1 = *cur++;
bitc = 1; bitc = 1;
} else { }
else
{
status |= 0xB0; status |= 0xB0;
assert( *cur < sizeof( MidiMap ) / sizeof( MidiMap[0] ) ); assert( *cur < sizeof( MidiMap ) / sizeof( MidiMap[0] ) );
bit1 = MidiMap[*cur++]; 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, status );
out_local = WriteByte( out_local, bit1 ); out_local = WriteByte( out_local, bit1 );
if( bitc == 2 ) if( bitc == 2 )
{
out_local = WriteByte( out_local, bit2 ); out_local = WriteByte( out_local, bit2 );
}
// Write out temp stuff // Write out temp stuff
@ -334,12 +360,17 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
out += out_local - temp_buffer; out += out_local - temp_buffer;
} }
if (event & 128) { if( event & 128 )
{
delta_time = 0; delta_time = 0;
do { do
{
delta_time = delta_time * 128 + ( *cur & 127 ); delta_time = delta_time * 128 + ( *cur & 127 );
} while ((*cur++ & 128)); }
} else { while( ( *cur++ & 128 ) );
}
else
{
delta_time = 0; delta_time = 0;
} }
} }

View file

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

View file

@ -209,19 +209,25 @@ EV_DoLockedDoor
p = thing->player; p = thing->player;
if( !p ) if( !p )
{
return 0; return 0;
}
switch( line->special ) switch( line->special )
{ {
case 99: // Blue Lock case 99: // Blue Lock
case 133: case 133:
if( !p ) if( !p )
{
return 0; return 0;
}
if( !p->cards[it_bluecard] && !p->cards[it_blueskull] ) if( !p->cards[it_bluecard] && !p->cards[it_blueskull] )
{ {
p->message = PD_BLUEO; p->message = PD_BLUEO;
if( p == &::g->players[::g->consoleplayer] ) if( p == &::g->players[::g->consoleplayer] )
{
S_StartSound( NULL, sfx_oof ); S_StartSound( NULL, sfx_oof );
}
return 0; return 0;
} }
break; break;
@ -229,12 +235,16 @@ EV_DoLockedDoor
case 134: // Red Lock case 134: // Red Lock
case 135: case 135:
if( !p ) if( !p )
{
return 0; return 0;
}
if( !p->cards[it_redcard] && !p->cards[it_redskull] ) if( !p->cards[it_redcard] && !p->cards[it_redskull] )
{ {
p->message = PD_REDO; p->message = PD_REDO;
if( p == &::g->players[::g->consoleplayer] ) if( p == &::g->players[::g->consoleplayer] )
{
S_StartSound( NULL, sfx_oof ); S_StartSound( NULL, sfx_oof );
}
return 0; return 0;
} }
break; break;
@ -242,13 +252,17 @@ EV_DoLockedDoor
case 136: // Yellow Lock case 136: // Yellow Lock
case 137: case 137:
if( !p ) if( !p )
{
return 0; return 0;
}
if( !p->cards[it_yellowcard] && if( !p->cards[it_yellowcard] &&
!p->cards[it_yellowskull] ) !p->cards[it_yellowskull] )
{ {
p->message = PD_YELLOWO; p->message = PD_YELLOWO;
if( p == &::g->players[::g->consoleplayer] ) if( p == &::g->players[::g->consoleplayer] )
{
S_StartSound( NULL, sfx_oof ); S_StartSound( NULL, sfx_oof );
}
return 0; return 0;
} }
break; break;
@ -274,7 +288,9 @@ EV_DoDoor
{ {
sec = &::g->sectors[secnum]; sec = &::g->sectors[secnum];
if( sec->specialdata ) if( sec->specialdata )
{
continue; continue;
}
// new door thinker // new door thinker
@ -369,13 +385,17 @@ EV_VerticalDoor
case 26: // Blue Lock case 26: // Blue Lock
case 32: case 32:
if( !player ) if( !player )
{
return; return;
}
if( !player->cards[it_bluecard] && !player->cards[it_blueskull] ) if( !player->cards[it_bluecard] && !player->cards[it_blueskull] )
{ {
player->message = PD_BLUEK; player->message = PD_BLUEK;
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_oof ); S_StartSound( player->mo, sfx_oof );
}
return; return;
} }
break; break;
@ -383,14 +403,18 @@ EV_VerticalDoor
case 27: // Yellow Lock case 27: // Yellow Lock
case 34: case 34:
if( !player ) if( !player )
{
return; return;
}
if( !player->cards[it_yellowcard] && if( !player->cards[it_yellowcard] &&
!player->cards[it_yellowskull] ) !player->cards[it_yellowskull] )
{ {
player->message = PD_YELLOWK; player->message = PD_YELLOWK;
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_oof ); S_StartSound( player->mo, sfx_oof );
}
return; return;
} }
break; break;
@ -398,13 +422,17 @@ EV_VerticalDoor
case 28: // Red Lock case 28: // Red Lock
case 33: case 33:
if( !player ) if( !player )
{
return; return;
}
if( !player->cards[it_redcard] && !player->cards[it_redskull] ) if( !player->cards[it_redcard] && !player->cards[it_redskull] )
{ {
player->message = PD_REDK; player->message = PD_REDK;
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_oof ); S_StartSound( player->mo, sfx_oof );
}
return; return;
} }
break; break;
@ -425,11 +453,15 @@ EV_VerticalDoor
case 28: case 28:
case 117: case 117:
if( door->direction == -1 ) if( door->direction == -1 )
{
door->direction = 1; // go back up door->direction = 1; // go back up
}
else else
{ {
if( !thing->player ) if( !thing->player )
{
return; // JDC: bad guys never close doors return; // JDC: bad guys never close doors
}
door->direction = -1; // start going down immediately door->direction = -1; // start going down immediately
} }
@ -438,7 +470,8 @@ EV_VerticalDoor
} }
// for proper sound // for proper sound
if (globalNetworking || (player == &::g->players[::g->consoleplayer])) { if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
switch( line->special ) switch( line->special )
{ {
case 117: // BLAZING DOOR RAISE 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( flag == true )
{ {
if( crush == true ) if( crush == true )
{
return crushed; return crushed;
}
sector->floorheight = lastpos; sector->floorheight = lastpos;
P_ChangeSector( sector, crush ); P_ChangeSector( sector, crush );
return crushed; return crushed;
@ -161,7 +163,9 @@ T_MovePlane
if( flag == true ) if( flag == true )
{ {
if( crush == true ) if( crush == true )
{
return crushed; return crushed;
}
sector->ceilingheight = lastpos; sector->ceilingheight = lastpos;
P_ChangeSector( sector, crush ); P_ChangeSector( sector, crush );
return crushed; return crushed;
@ -280,7 +284,9 @@ EV_DoFloor
// ALREADY MOVING? IF SO, KEEP GOING... // ALREADY MOVING? IF SO, KEEP GOING...
if( sec->specialdata ) if( sec->specialdata )
{
continue; continue;
}
// new floor thinker // new floor thinker
rtn = 1; rtn = 1;
@ -316,7 +322,9 @@ EV_DoFloor
floor->floordestheight = floor->floordestheight =
P_FindHighestFloorSurrounding( sec ); P_FindHighestFloorSurrounding( sec );
if( floor->floordestheight != sec->floorheight ) if( floor->floordestheight != sec->floorheight )
{
floor->floordestheight += 8 * FRACUNIT; floor->floordestheight += 8 * FRACUNIT;
}
break; break;
case raiseFloorCrush: case raiseFloorCrush:
@ -328,7 +336,9 @@ EV_DoFloor
floor->floordestheight = floor->floordestheight =
P_FindLowestCeilingSurrounding( sec ); P_FindLowestCeilingSurrounding( sec );
if( floor->floordestheight > sec->ceilingheight ) if( floor->floordestheight > sec->ceilingheight )
{
floor->floordestheight = sec->ceilingheight; floor->floordestheight = sec->ceilingheight;
}
floor->floordestheight -= ( 8 * FRACUNIT ) * floor->floordestheight -= ( 8 * FRACUNIT ) *
( floortype == raiseFloorCrush ); ( floortype == raiseFloorCrush );
break; break;
@ -483,7 +493,9 @@ EV_BuildStairs
// ALREADY MOVING? IF SO, KEEP GOING... // ALREADY MOVING? IF SO, KEEP GOING...
if( sec->specialdata ) if( sec->specialdata )
{
continue; continue;
}
// new floor thinker // new floor thinker
rtn = 1; rtn = 1;
@ -519,24 +531,32 @@ EV_BuildStairs
for( i = 0; i < sec->linecount; i++ ) for( i = 0; i < sec->linecount; i++ )
{ {
if( !( ( sec->lines[i] )->flags & ML_TWOSIDED ) ) if( !( ( sec->lines[i] )->flags & ML_TWOSIDED ) )
{
continue; continue;
}
tsec = ( sec->lines[i] )->frontsector; tsec = ( sec->lines[i] )->frontsector;
newsecnum = tsec -::g->sectors; newsecnum = tsec -::g->sectors;
if( secnum != newsecnum ) if( secnum != newsecnum )
{
continue; continue;
}
tsec = ( sec->lines[i] )->backsector; tsec = ( sec->lines[i] )->backsector;
newsecnum = tsec - ::g->sectors; newsecnum = tsec - ::g->sectors;
if( tsec->floorpic != texture ) if( tsec->floorpic != texture )
{
continue; continue;
}
height += stairsize; height += stairsize;
if( tsec->specialdata ) if( tsec->specialdata )
{
continue; continue;
}
sec = tsec; sec = tsec;
secnum = newsecnum; secnum = newsecnum;
@ -553,7 +573,8 @@ EV_BuildStairs
ok = 1; ok = 1;
break; break;
} }
} while(ok); }
while( ok );
} }
return rtn; return rtn;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -139,12 +139,15 @@ P_SetPsprite
{ {
state->action( player, psp ); state->action( player, psp );
if( !psp->state ) if( !psp->state )
{
break; break;
} }
}
stnum = psp->state->nextstate; stnum = psp->state->nextstate;
} while (!psp->tics); }
while( !psp->tics );
// an initial state of 0 could cycle through // an initial state of 0 could cycle through
} }
@ -185,10 +188,14 @@ void P_BringUpWeapon (player_t* player)
statenum_t newstate; statenum_t newstate;
if( player->pendingweapon == wp_nochange ) if( player->pendingweapon == wp_nochange )
{
player->pendingweapon = player->readyweapon; player->pendingweapon = player->readyweapon;
}
if( player->pendingweapon == wp_chainsaw && ( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) ) if( player->pendingweapon == wp_chainsaw && ( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) )
{
S_StartSound( player->mo, sfx_sawup ); S_StartSound( player->mo, sfx_sawup );
}
newstate = ( statenum_t )( weaponinfo[player->pendingweapon].upstate ); newstate = ( statenum_t )( weaponinfo[player->pendingweapon].upstate );
@ -212,16 +219,24 @@ qboolean P_CheckAmmo (player_t* player)
// Minimal amount for one shot varies. // Minimal amount for one shot varies.
if( player->readyweapon == wp_bfg ) if( player->readyweapon == wp_bfg )
{
count = BFGCELLS; count = BFGCELLS;
}
else if( player->readyweapon == wp_supershotgun ) else if( player->readyweapon == wp_supershotgun )
{
count = 2; // Double barrel. count = 2; // Double barrel.
}
else else
{
count = 1; // Regular. count = 1; // Regular.
}
// Some do not need ammunition anyway. // Some do not need ammunition anyway.
// Return if current ammunition sufficient. // Return if current ammunition sufficient.
if( ammo == am_noammo || player->ammo[ammo] >= count ) if( ammo == am_noammo || player->ammo[ammo] >= count )
{
return true; return true;
}
// Out of ammo, pick a weapon to change to. // Out of ammo, pick a weapon to change to.
// Preferences are set here. // Preferences are set here.
@ -274,7 +289,8 @@ qboolean P_CheckAmmo (player_t* player)
player->pendingweapon = wp_fist; player->pendingweapon = wp_fist;
} }
} while (player->pendingweapon == wp_nochange); }
while( player->pendingweapon == wp_nochange );
// Now set appropriate weapon overlay. // Now set appropriate weapon overlay.
P_SetPsprite( player, P_SetPsprite( player,
@ -293,7 +309,9 @@ void P_FireWeapon (player_t* player)
statenum_t newstate; statenum_t newstate;
if( !P_CheckAmmo( player ) ) if( !P_CheckAmmo( player ) )
{
return; return;
}
P_SetMobjState( player->mo, S_PLAY_ATK1 ); P_SetMobjState( player->mo, S_PLAY_ATK1 );
newstate = ( statenum_t )weaponinfo[player->readyweapon].atkstate; newstate = ( statenum_t )weaponinfo[player->readyweapon].atkstate;
@ -302,7 +320,8 @@ void P_FireWeapon (player_t* player)
if( player->readyweapon == wp_chainsaw ) 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] ) && psp->state == &::g->states[S_SAW] )
{ {
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_sawidl ); S_StartSound( player->mo, sfx_sawidl );
} }
}
// check for change // check for change
// if player is dead, put the weapon away // if player is dead, put the weapon away
@ -378,7 +399,9 @@ A_WeaponReady
} }
} }
else else
{
player->attackdown = false; player->attackdown = false;
}
// bob the weapon based on movement speed // bob the weapon based on movement speed
angle = ( 128 *::g->leveltime )&FINEMASK; angle = ( 128 *::g->leveltime )&FINEMASK;
@ -424,7 +447,9 @@ A_CheckReload
P_CheckAmmo( player ); P_CheckAmmo( player );
#if 0 #if 0
if( player->ammo[am_shell] < 2 ) if( player->ammo[am_shell] < 2 )
{
P_SetPsprite( player, ps_weapon, S_DSNR1 ); P_SetPsprite( player, ps_weapon, S_DSNR1 );
}
#endif #endif
} }
@ -444,7 +469,9 @@ A_Lower
// Is already down. // Is already down.
if( psp->sy < WEAPONBOTTOM ) if( psp->sy < WEAPONBOTTOM )
{
return; return;
}
// Player is dead. // Player is dead.
if( player->playerstate == PST_DEAD ) if( player->playerstate == PST_DEAD )
@ -483,7 +510,9 @@ A_Raise
psp->sy -= RAISESPEED; psp->sy -= RAISESPEED;
if( psp->sy > WEAPONTOP ) if( psp->sy > WEAPONTOP )
{
return; return;
}
psp->sy = WEAPONTOP; psp->sy = WEAPONTOP;
@ -530,7 +559,9 @@ A_Punch
damage = ( P_Random() % 10 + 1 ) << 1; damage = ( P_Random() % 10 + 1 ) << 1;
if( player->powers[pw_strength] ) if( player->powers[pw_strength] )
{
damage *= 10; damage *= 10;
}
angle = player->mo->angle; angle = player->mo->angle;
angle += ( P_Random() - P_Random() ) << 18; angle += ( P_Random() - P_Random() ) << 18;
@ -572,11 +603,15 @@ A_Saw
if( !::g->linetarget ) if( !::g->linetarget )
{ {
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_sawful ); S_StartSound( player->mo, sfx_sawful );
}
return; return;
} }
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_sawhit ); S_StartSound( player->mo, sfx_sawhit );
}
// turn to face target // turn to face target
angle = R_PointToAngle2( player->mo->x, player->mo->y, 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 > ANG180 )
{ {
if( angle - player->mo->angle < -ANG90 / 20 ) if( angle - player->mo->angle < -ANG90 / 20 )
{
player->mo->angle = angle + ANG90 / 21; player->mo->angle = angle + ANG90 / 21;
}
else else
{
player->mo->angle -= ANG90 / 20; player->mo->angle -= ANG90 / 20;
} }
}
else else
{ {
if( angle - player->mo->angle > ANG90 / 20 ) if( angle - player->mo->angle > ANG90 / 20 )
{
player->mo->angle = angle - ANG90 / 21; player->mo->angle = angle - ANG90 / 21;
}
else else
{
player->mo->angle += ANG90 / 20; player->mo->angle += ANG90 / 20;
} }
}
player->mo->flags |= MF_JUSTATTACKED; player->mo->flags |= MF_JUSTATTACKED;
} }
@ -608,12 +651,14 @@ A_FireMissile
( player_t* player, ( player_t* player,
pspdef_t* psp ) pspdef_t* psp )
{ {
if( (player->cheats & CF_INFAMMO) == false ) { if( ( player->cheats & CF_INFAMMO ) == false )
{
player->ammo[weaponinfo[player->readyweapon].ammo]--; player->ammo[weaponinfo[player->readyweapon].ammo]--;
} }
P_SpawnPlayerMissile( player->mo, MT_ROCKET ); P_SpawnPlayerMissile( player->mo, MT_ROCKET );
if( ::g->plyr == player ) { if( ::g->plyr == player )
{
} }
} }
@ -627,13 +672,15 @@ A_FireBFG
( player_t* player, ( player_t* player,
pspdef_t* psp ) pspdef_t* psp )
{ {
if( (player->cheats & CF_INFAMMO) == false ) { if( ( player->cheats & CF_INFAMMO ) == false )
{
player->ammo[weaponinfo[player->readyweapon].ammo] -= BFGCELLS; player->ammo[weaponinfo[player->readyweapon].ammo] -= BFGCELLS;
} }
P_SpawnPlayerMissile( player->mo, MT_BFG ); P_SpawnPlayerMissile( player->mo, MT_BFG );
if( ::g->plyr == player ) { if( ::g->plyr == player )
{
} }
} }
@ -647,7 +694,8 @@ A_FirePlasma
( player_t* player, ( player_t* player,
pspdef_t* psp ) pspdef_t* psp )
{ {
if( (player->cheats & CF_INFAMMO) == false ) { if( ( player->cheats & CF_INFAMMO ) == false )
{
player->ammo[weaponinfo[player->readyweapon].ammo]--; player->ammo[weaponinfo[player->readyweapon].ammo]--;
} }
@ -657,7 +705,8 @@ A_FirePlasma
P_SpawnPlayerMissile( player->mo, MT_PLASMA ); P_SpawnPlayerMissile( player->mo, MT_PLASMA );
if( ::g->plyr == player ) { if( ::g->plyr == player )
{
} }
} }
@ -706,7 +755,9 @@ P_GunShot
angle = mo->angle; angle = mo->angle;
if( !accurate ) if( !accurate )
{
angle += ( P_Random() - P_Random() ) << 18; angle += ( P_Random() - P_Random() ) << 18;
}
P_LineAttack( mo, angle, MISSILERANGE, ::g->bulletslope, damage ); P_LineAttack( mo, angle, MISSILERANGE, ::g->bulletslope, damage );
} }
@ -721,10 +772,13 @@ A_FirePistol
pspdef_t* psp ) pspdef_t* psp )
{ {
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_pistol ); S_StartSound( player->mo, sfx_pistol );
}
P_SetMobjState( player->mo, S_PLAY_ATK2 ); 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]--; player->ammo[weaponinfo[player->readyweapon].ammo]--;
} }
@ -735,7 +789,8 @@ A_FirePistol
P_BulletSlope( player->mo ); P_BulletSlope( player->mo );
P_GunShot( player->mo, !player->refire ); P_GunShot( player->mo, !player->refire );
if( ::g->plyr == player ) { if( ::g->plyr == player )
{
} }
} }
@ -751,10 +806,13 @@ A_FireShotgun
int i; int i;
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_shotgn ); S_StartSound( player->mo, sfx_shotgn );
}
P_SetMobjState( player->mo, S_PLAY_ATK2 ); 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]--; player->ammo[weaponinfo[player->readyweapon].ammo]--;
} }
@ -765,9 +823,12 @@ A_FireShotgun
P_BulletSlope( player->mo ); P_BulletSlope( player->mo );
for( i = 0 ; i < 7 ; i++ ) for( i = 0 ; i < 7 ; i++ )
{
P_GunShot( player->mo, false ); 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] ) ) if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_dshtgn ); S_StartSound( player->mo, sfx_dshtgn );
}
P_SetMobjState( player->mo, S_PLAY_ATK2 ); 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; player->ammo[weaponinfo[player->readyweapon].ammo] -= 2;
} }
@ -811,7 +875,8 @@ A_FireShotgun2
::g->bulletslope + ( ( P_Random() - P_Random() ) << 5 ), damage ); ::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 ) pspdef_t* psp )
{ {
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) ) if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_pistol ); S_StartSound( player->mo, sfx_pistol );
}
if( !player->ammo[weaponinfo[player->readyweapon].ammo] ) if( !player->ammo[weaponinfo[player->readyweapon].ammo] )
{
return; return;
}
P_SetMobjState( player->mo, S_PLAY_ATK2 ); 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]--; player->ammo[weaponinfo[player->readyweapon].ammo]--;
} }
P_SetPsprite( player, P_SetPsprite( player,
@ -846,7 +916,8 @@ A_FireCGun
P_GunShot( player->mo, !player->refire ); 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 ); P_AimLineAttack( mo->target, an, 16 * 64 * FRACUNIT );
if( !::g->linetarget ) if( !::g->linetarget )
{
continue; continue;
}
P_SpawnMobj( ::g->linetarget->x, P_SpawnMobj( ::g->linetarget->x,
::g->linetarget->y, ::g->linetarget->y,
@ -901,7 +974,9 @@ void A_BFGSpray (mobj_t* mo, void * )
damage = 0; damage = 0;
for( j = 0; j < 15; j++ ) for( j = 0; j < 15; j++ )
{
damage += ( P_Random() & 7 ) + 1; damage += ( P_Random() & 7 ) + 1;
}
P_DamageMobj( ::g->linetarget, mo->target, mo->target, damage ); P_DamageMobj( ::g->linetarget, mo->target, mo->target, damage );
} }
@ -932,7 +1007,9 @@ void P_SetupPsprites (player_t* player)
// remove all psprites // remove all psprites
for( i = 0 ; i < NUMPSPRITES ; i++ ) for( i = 0 ; i < NUMPSPRITES ; i++ )
{
player->psprites[i].state = NULL; player->psprites[i].state = NULL;
}
// spawn the gun // spawn the gun
player->pendingweapon = player->readyweapon; player->pendingweapon = player->readyweapon;
@ -965,10 +1042,12 @@ void P_MovePsprites (player_t* player)
{ {
psp->tics--; psp->tics--;
if( !psp->tics ) if( !psp->tics )
{
P_SetPsprite( player, i, psp->state->nextstate ); P_SetPsprite( player, i, psp->state->nextstate );
} }
} }
} }
}
player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx; player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx;
player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy; 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++ ) for( i = 0 ; i < MAXPLAYERS ; i++ )
{ {
if( !::g->playeringame[i] ) if( !::g->playeringame[i] )
{
continue; continue;
}
PADSAVEP(); PADSAVEP();
@ -87,7 +89,9 @@ void P_UnArchivePlayers (void)
for( i = 0 ; i < MAXPLAYERS ; i++ ) for( i = 0 ; i < MAXPLAYERS ; i++ )
{ {
if( !::g->playeringame[i] ) if( !::g->playeringame[i] )
{
continue; continue;
}
PADSAVEP(); PADSAVEP();
@ -147,7 +151,9 @@ void P_ArchiveWorld (void)
for( j = 0 ; j < 2 ; j++ ) for( j = 0 ; j < 2 ; j++ )
{ {
if( li->sidenum[j] == -1 ) if( li->sidenum[j] == -1 )
{
continue; continue;
}
si = &::g->sides[li->sidenum[j]]; si = &::g->sides[li->sidenum[j]];
@ -205,7 +211,9 @@ void P_UnArchiveWorld (void)
for( j = 0 ; j < 2 ; j++ ) for( j = 0 ; j < 2 ; j++ )
{ {
if( li->sidenum[j] == -1 ) if( li->sidenum[j] == -1 )
{
continue; continue;
}
si = &::g->sides[li->sidenum[j]]; si = &::g->sides[li->sidenum[j]];
si->textureoffset = *get++ << FRACBITS; si->textureoffset = *get++ << FRACBITS;
si->rowoffset = *get++ << FRACBITS; si->rowoffset = *get++ << FRACBITS;
@ -230,18 +238,21 @@ void P_UnArchiveWorld (void)
// Thinkers // Thinkers
// //
int GetMOIndex( mobj_t* findme ) { int GetMOIndex( mobj_t* findme )
{
thinker_t* th; thinker_t* th;
mobj_t* mobj; mobj_t* mobj;
int index = 0; int index = 0;
for( th = ::g->thinkercap.next ; th != &::g->thinkercap ; th = th->next ) 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++; index++;
mobj = ( mobj_t* )th; mobj = ( mobj_t* )th;
if ( mobj == findme ) { if( mobj == findme )
{
return index; return index;
} }
} }
@ -250,20 +261,24 @@ int GetMOIndex( mobj_t* findme ) {
return 0; return 0;
} }
mobj_t* GetMO( int index ) { mobj_t* GetMO( int index )
{
thinker_t* th; thinker_t* th;
int testindex = 0; int testindex = 0;
if ( !index ) { if( !index )
{
return NULL; return NULL;
} }
for( th = ::g->thinkercap.next ; th != &::g->thinkercap ; th = th->next ) 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++; testindex++;
if ( testindex == index ) { if( testindex == index )
{
return ( mobj_t* )th; return ( mobj_t* )th;
} }
} }
@ -309,7 +324,9 @@ void P_ArchiveThinkers (void)
mobj->state = ( state_t* )( mobj->state - ::g->states ); mobj->state = ( state_t* )( mobj->state - ::g->states );
if( mobj->player ) if( mobj->player )
{
mobj->player = ( player_t* )( ( mobj->player -::g->players ) + 1 ); mobj->player = ( player_t* )( ( mobj->player -::g->players ) + 1 );
}
// Save out 'target' // Save out 'target'
int moIndex = GetMOIndex( mobj->target ); int moIndex = GetMOIndex( mobj->target );
@ -330,10 +347,12 @@ void P_ArchiveThinkers (void)
*::g->save_p++ = moIndex; *::g->save_p++ = moIndex;
// Is this the head of a sector list? // 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; *::g->save_p++ = 1;
} }
else { else
{
*::g->save_p++ = 0; *::g->save_p++ = 0;
} }
@ -349,11 +368,13 @@ void P_ArchiveThinkers (void)
int blockx = ( mobj->x - ::g->bmaporgx ) >> MAPBLOCKSHIFT; int blockx = ( mobj->x - ::g->bmaporgx ) >> MAPBLOCKSHIFT;
int blocky = ( mobj->y - ::g->bmaporgy ) >> 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
&& (mobj_t*)th == ::g->blocklinks[blocky*::g->bmapwidth+blockx] ) { && ( mobj_t* )th == ::g->blocklinks[blocky*::g->bmapwidth + blockx] )
{
*::g->save_p++ = 1; *::g->save_p++ = 1;
} }
else { else
{
*::g->save_p++ = 0; *::g->save_p++ = 0;
} }
continue; continue;
@ -363,7 +384,9 @@ void P_ArchiveThinkers (void)
{ {
for( i = 0; i < MAXCEILINGS; i++ ) for( i = 0; i < MAXCEILINGS; i++ )
if( ::g->activeceilings[i] == ( ceiling_t* )th ) if( ::g->activeceilings[i] == ( ceiling_t* )th )
{
break; break;
}
if( i < MAXCEILINGS ) if( i < MAXCEILINGS )
{ {
@ -471,7 +494,8 @@ void P_ArchiveThinkers (void)
sector_t* sec; sector_t* sec;
short* put = ( short* )::g->save_p; 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 ); *put++ = ( short )GetMOIndex( sec->soundtarget );
} }
@ -523,9 +547,13 @@ void P_UnArchiveThinkers (void)
next = currentthinker->next; next = currentthinker->next;
if( currentthinker->function.acp1 == ( actionf_p1 )P_MobjThinker ) if( currentthinker->function.acp1 == ( actionf_p1 )P_MobjThinker )
{
P_RemoveMobj( ( mobj_t* )currentthinker ); P_RemoveMobj( ( mobj_t* )currentthinker );
}
else else
{
Z_Free( currentthinker ); Z_Free( currentthinker );
}
currentthinker = next; currentthinker = next;
} }
@ -542,7 +570,8 @@ void P_UnArchiveThinkers (void)
// clear sector thing lists // clear sector thing lists
ss = ::g->sectors; ss = ::g->sectors;
for (int i=0 ; i < ::g->numsectors ; i++, ss++) { for( int i = 0 ; i < ::g->numsectors ; i++, ss++ )
{
ss->thinglist = NULL; ss->thinglist = NULL;
} }
@ -555,8 +584,10 @@ void P_UnArchiveThinkers (void)
// fixup mobj_t pointers now that all thinkers have been restored // fixup mobj_t pointers now that all thinkers have been restored
mo_index = 0; mo_index = 0;
for (th = ::g->thinkercap.next ; th != &::g->thinkercap ; th=th->next) { 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 )
{
mobj = ( mobj_t* )th; mobj = ( mobj_t* )th;
mobj->target = GetMO( mo_targets[mo_index] ); mobj->target = GetMO( mo_targets[mo_index] );
@ -565,24 +596,28 @@ void P_UnArchiveThinkers (void)
mobj->snext = GetMO( mo_snext[mo_index] ); mobj->snext = GetMO( mo_snext[mo_index] );
mobj->sprev = GetMO( mo_sprev[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->subsector->sector->thinglist = mobj;
} }
mobj->bnext = GetMO( mo_bnext[mo_index] ); mobj->bnext = GetMO( mo_bnext[mo_index] );
mobj->bprev = GetMO( mo_bprev[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? // Is this the head of a block list?
int blockx = ( mobj->x - ::g->bmaporgx ) >> MAPBLOCKSHIFT; int blockx = ( mobj->x - ::g->bmaporgx ) >> MAPBLOCKSHIFT;
int blocky = ( mobj->y - ::g->bmaporgy ) >> 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; ::g->blocklinks[blocky*::g->bmapwidth + blockx] = mobj;
} }
} }
// Doom 2 level 30 requires some global pointers, wheee! // 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->braintargets[::g->numbraintargets] = mobj;
::g->numbraintargets++; ::g->numbraintargets++;
} }
@ -603,7 +638,8 @@ void P_UnArchiveThinkers (void)
::g->save_p = ( byte* )get; ::g->save_p = ( byte* )get;
tclass = *::g->save_p++; tclass = *::g->save_p++;
if ( tclass != tc_end ) { if( tclass != tc_end )
{
I_Error( "Savegame error after loading sector soundtargets." ); I_Error( "Savegame error after loading sector soundtargets." );
} }
@ -697,7 +733,9 @@ void P_UnArchiveThinkers (void)
ceiling->sector->specialdata = ceiling; ceiling->sector->specialdata = ceiling;
if( ceiling->thinker.function.acp1 ) if( ceiling->thinker.function.acp1 )
{
ceiling->thinker.function.acp1 = ( actionf_p1 )T_MoveCeiling; ceiling->thinker.function.acp1 = ( actionf_p1 )T_MoveCeiling;
}
P_AddThinker( &ceiling->thinker ); P_AddThinker( &ceiling->thinker );
P_AddActiveCeiling( ceiling ); P_AddActiveCeiling( ceiling );
@ -734,7 +772,9 @@ void P_UnArchiveThinkers (void)
plat->sector->specialdata = plat; plat->sector->specialdata = plat;
if( plat->thinker.function.acp1 ) if( plat->thinker.function.acp1 )
{
plat->thinker.function.acp1 = ( actionf_p1 )T_PlatRaise; plat->thinker.function.acp1 = ( actionf_p1 )T_PlatRaise;
}
P_AddThinker( &plat->thinker ); P_AddThinker( &plat->thinker );
P_AddActivePlat( plat ); P_AddActivePlat( plat );
@ -823,7 +863,9 @@ void P_ArchiveSpecials (void)
{ {
for( i = 0; i < MAXCEILINGS; i++ ) for( i = 0; i < MAXCEILINGS; i++ )
if( ::g->activeceilings[i] == ( ceiling_t* )th ) if( ::g->activeceilings[i] == ( ceiling_t* )th )
{
break; break;
}
if( i < MAXCEILINGS ) if( i < MAXCEILINGS )
{ {
@ -953,7 +995,9 @@ void P_UnArchiveSpecials (void)
ceiling->sector->specialdata = ceiling; ceiling->sector->specialdata = ceiling;
if( ceiling->thinker.function.acp1 ) if( ceiling->thinker.function.acp1 )
{
ceiling->thinker.function.acp1 = ( actionf_p1 )T_MoveCeiling; ceiling->thinker.function.acp1 = ( actionf_p1 )T_MoveCeiling;
}
P_AddThinker( &ceiling->thinker ); P_AddThinker( &ceiling->thinker );
P_AddActiveCeiling( ceiling ); P_AddActiveCeiling( ceiling );
@ -990,7 +1034,9 @@ void P_UnArchiveSpecials (void)
plat->sector->specialdata = plat; plat->sector->specialdata = plat;
if( plat->thinker.function.acp1 ) if( plat->thinker.function.acp1 )
{
plat->thinker.function.acp1 = ( actionf_p1 )T_PlatRaise; plat->thinker.function.acp1 = ( actionf_p1 )T_PlatRaise;
}
P_AddThinker( &plat->thinker ); P_AddThinker( &plat->thinker );
P_AddActivePlat( plat ); P_AddActivePlat( plat );

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -145,10 +145,14 @@ R_DrawColumnInCache
} }
if( position + count > cacheheight ) if( position + count > cacheheight )
{
count = cacheheight - position; count = cacheheight - position;
}
if( count > 0 ) if( count > 0 )
{
memcpy( cache + position, source, count ); memcpy( cache + position, source, count );
}
patch = ( postColumn_t* )( ( byte* )patch + patch->length + 4 ); patch = ( postColumn_t* )( ( byte* )patch + patch->length + 4 );
} }
@ -197,18 +201,26 @@ void R_GenerateComposite (int texnum)
x2 = x1 + SHORT( realpatch->width ); x2 = x1 + SHORT( realpatch->width );
if( x1 < 0 ) if( x1 < 0 )
{
x = 0; x = 0;
}
else else
{
x = x1; x = x1;
}
if( x2 > texture->width ) if( x2 > texture->width )
{
x2 = texture->width; x2 = texture->width;
}
for( ; x < x2 ; x++ ) for( ; x < x2 ; x++ )
{ {
// Column does not have multiple patches? // Column does not have multiple patches?
if( collump[x] >= 0 ) if( collump[x] >= 0 )
{
continue; continue;
}
patchcol = ( postColumn_t* )( ( byte* )realpatch patchcol = ( postColumn_t* )( ( byte* )realpatch
+ LONG( realpatch->columnofs[x - x1] ) ); + LONG( realpatch->columnofs[x - x1] ) );
@ -263,12 +275,18 @@ void R_GenerateLookup (int texnum)
x2 = x1 + SHORT( realpatch->width ); x2 = x1 + SHORT( realpatch->width );
if( x1 < 0 ) if( x1 < 0 )
{
x = 0; x = 0;
}
else else
{
x = x1; x = x1;
}
if( x2 > texture->width ) if( x2 > texture->width )
{
x2 = texture->width; x2 = texture->width;
}
for( ; x < x2 ; x++ ) for( ; x < x2 ; x++ )
{ {
patchcount[x]++; patchcount[x]++;
@ -323,10 +341,14 @@ R_GetColumn
ofs = ::g->s_texturecolumnofs[tex][col]; ofs = ::g->s_texturecolumnofs[tex][col];
if( lump > 0 ) if( lump > 0 )
{
return ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ) + ofs; return ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ) + ofs;
}
if( !::g->s_texturecomposite[tex] ) if( !::g->s_texturecomposite[tex] )
{
R_GenerateComposite( tex ); R_GenerateComposite( tex );
}
return ::g->s_texturecomposite[tex] + ofs; return ::g->s_texturecomposite[tex] + ofs;
} }
@ -430,16 +452,22 @@ void R_InitTextures (void)
temp3 = ( ( temp2 - temp1 + 63 ) / 64 ) + ( ( ::g->s_numtextures + 63 ) / 64 ); temp3 = ( ( temp2 - temp1 + 63 ) / 64 ) + ( ( ::g->s_numtextures + 63 ) / 64 );
I_Printf( "[" ); I_Printf( "[" );
for( i = 0; i < temp3; i++ ) for( i = 0; i < temp3; i++ )
{
I_Printf( " " ); I_Printf( " " );
}
I_Printf( " ]" ); I_Printf( " ]" );
for( i = 0; i < temp3; i++ ) for( i = 0; i < temp3; i++ )
{
I_Printf( "\x8" ); I_Printf( "\x8" );
}
I_Printf( "\x8\x8\x8\x8\x8\x8\x8\x8\x8\x8" ); I_Printf( "\x8\x8\x8\x8\x8\x8\x8\x8\x8\x8" );
for( i = 0 ; i < ::g->s_numtextures ; i++, directory++ ) for( i = 0 ; i < ::g->s_numtextures ; i++, directory++ )
{ {
if( !( i & 63 ) ) if( !( i & 63 ) )
{
I_Printf( "." ); I_Printf( "." );
}
if( i == numtextures1 ) if( i == numtextures1 )
{ {
@ -452,7 +480,9 @@ void R_InitTextures (void)
offset = LONG( *directory ); offset = LONG( *directory );
if( offset > maxoff ) if( offset > maxoff )
{
I_Error( "R_InitTextures: bad texture directory" ); I_Error( "R_InitTextures: bad texture directory" );
}
mtexture = ( maptexture_t* )( ( byte* )maptex + offset ); mtexture = ( maptexture_t* )( ( byte* )maptex + offset );
@ -483,7 +513,9 @@ void R_InitTextures (void)
j = 1; j = 1;
while( j * 2 <= texture->width ) while( j * 2 <= texture->width )
{
j <<= 1; j <<= 1;
}
::g->s_texturewidthmask[i] = j - 1; ::g->s_texturewidthmask[i] = j - 1;
::g->s_textureheight[i] = texture->height << FRACBITS; ::g->s_textureheight[i] = texture->height << FRACBITS;
@ -493,21 +525,27 @@ void R_InitTextures (void)
Z_Free( maptex1 ); Z_Free( maptex1 );
if( maptex2 ) if( maptex2 )
{
Z_Free( maptex2 ); Z_Free( maptex2 );
}
// Precalculate whatever possible. // Precalculate whatever possible.
for( i = 0 ; i < ::g->s_numtextures ; i++ ) for( i = 0 ; i < ::g->s_numtextures ; i++ )
{
R_GenerateLookup( i ); R_GenerateLookup( i );
} }
}
// ALAN: These animations are done globally -- can it be shared? // ALAN: These animations are done globally -- can it be shared?
// Create translation table for global animation. // Create translation table for global animation.
::g->texturetranslation = ( int* )DoomLib::Z_Malloc( ( ::g->s_numtextures + 1 ) * 4, PU_STATIC, 0 ); ::g->texturetranslation = ( int* )DoomLib::Z_Malloc( ( ::g->s_numtextures + 1 ) * 4, PU_STATIC, 0 );
for( i = 0 ; i < ::g->s_numtextures ; i++ ) for( i = 0 ; i < ::g->s_numtextures ; i++ )
{
::g->texturetranslation[i] = 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 ); ::g->flattranslation = ( int* )DoomLib::Z_Malloc( ( ::g->numflats + 1 ) * 4, PU_STATIC, 0 );
for( i = 0 ; i < ::g->numflats ; i++ ) for( i = 0 ; i < ::g->numflats ; i++ )
{
::g->flattranslation[i] = i; ::g->flattranslation[i] = i;
} }
}
// //
@ -552,7 +592,9 @@ void R_InitSpriteLumps (void)
for( i = 0 ; i < ::g->numspritelumps ; i++ ) for( i = 0 ; i < ::g->numspritelumps ; i++ )
{ {
if( !( i & 63 ) ) if( !( i & 63 ) )
{
I_Printf( "." ); I_Printf( "." );
}
patch = ( patch_t* )W_CacheLumpNum( ::g->firstspritelump + i, PU_CACHE_SHARED ); patch = ( patch_t* )W_CacheLumpNum( ::g->firstspritelump + i, PU_CACHE_SHARED );
::g->spritewidth[i] = SHORT( patch->width ) << FRACBITS; ::g->spritewidth[i] = SHORT( patch->width ) << FRACBITS;
@ -635,11 +677,15 @@ int R_CheckTextureNumForName (const char *name)
// "NoTexture" marker. // "NoTexture" marker.
if( name[0] == '-' ) if( name[0] == '-' )
{
return 0; return 0;
}
for( i = 0 ; i < ::g->s_numtextures ; i++ ) for( i = 0 ; i < ::g->s_numtextures ; i++ )
if( !idStr::Icmpn( ::g->s_textures[i]->name, name, 8 ) ) if( !idStr::Icmpn( ::g->s_textures[i]->name, name, 8 ) )
{
return i; return i;
}
return -1; return -1;
} }
@ -685,7 +731,9 @@ void R_PrecacheLevel (void)
spriteframe_t* sf; spriteframe_t* sf;
if( ::g->demoplayback ) if( ::g->demoplayback )
{
return; return;
}
// Precache flats. // Precache flats.
std::vector<char> flatpresent( ::g->numflats, 0 ); std::vector<char> flatpresent( ::g->numflats, 0 );
@ -730,7 +778,9 @@ void R_PrecacheLevel (void)
for( i = 0 ; i < ::g->s_numtextures ; i++ ) for( i = 0 ; i < ::g->s_numtextures ; i++ )
{ {
if( !texturepresent[i] ) if( !texturepresent[i] )
{
continue; continue;
}
texture = ::g->s_textures[i]; texture = ::g->s_textures[i];
@ -748,14 +798,18 @@ void R_PrecacheLevel (void)
for( th = ::g->thinkercap.next ; th != &::g->thinkercap ; th = th->next ) 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 )
{
spritepresent[( ( mobj_t* )th )->sprite] = 1; spritepresent[( ( mobj_t* )th )->sprite] = 1;
} }
}
::g->spritememory = 0; ::g->spritememory = 0;
for( i = 0 ; i < ::g->numsprites ; i++ ) for( i = 0 ; i < ::g->numsprites ; i++ )
{ {
if( !spritepresent[i] ) if( !spritepresent[i] )
{
continue; continue;
}
for( j = 0 ; j < ::g->sprites[i].numframes ; j++ ) 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; count = ::g->dc_yh - ::g->dc_yl;
// Zero length, column does not exceed a pixel. // Zero length, column does not exceed a pixel.
if (count >= 0) { if( count >= 0 )
{
//return; //return;
#ifdef RANGECHECK #ifdef RANGECHECK
if( ( unsigned )::g->dc_x >= SCREENWIDTH if( ( unsigned )::g->dc_x >= SCREENWIDTH
|| ::g->dc_yl < 0 || ::g->dc_yl < 0
|| ::g->dc_yh >= SCREENHEIGHT ) || ::g->dc_yh >= SCREENHEIGHT )
{
I_Error( "R_DrawColumn: %i to %i at %i", ::g->dc_yl, ::g->dc_yh, ::g->dc_x ); I_Error( "R_DrawColumn: %i to %i at %i", ::g->dc_yl, ::g->dc_yh, ::g->dc_x );
}
#endif #endif
// Framebuffer destination address. // Framebuffer destination address.
@ -128,7 +131,8 @@ void R_DrawColumn ( lighttable_t * dc_colormap,
frac += fracstep; frac += fracstep;
dest += SCREENWIDTH; dest += SCREENWIDTH;
} while (count--); }
while( count-- );
} }
} }
@ -206,7 +210,9 @@ void R_DrawColumnLow ( lighttable_t * dc_colormap,
// Zero length. // Zero length.
if( count < 0 ) if( count < 0 )
{
return; return;
}
#ifdef RANGECHECK #ifdef RANGECHECK
if( ( unsigned )::g->dc_x >= SCREENWIDTH if( ( unsigned )::g->dc_x >= SCREENWIDTH
@ -235,7 +241,8 @@ void R_DrawColumnLow ( lighttable_t * dc_colormap,
dest2 += SCREENWIDTH; dest2 += SCREENWIDTH;
frac += fracstep; frac += fracstep;
} while (count--); }
while( count-- );
} }
@ -265,17 +272,23 @@ void R_DrawFuzzColumn ( lighttable_t * dc_colormap,
// Adjust borders. Low... // Adjust borders. Low...
if( !::g->dc_yl ) if( !::g->dc_yl )
{
::g->dc_yl = 1; ::g->dc_yl = 1;
}
// .. and high. // .. and high.
if( ::g->dc_yh == ::g->viewheight - 1 ) if( ::g->dc_yh == ::g->viewheight - 1 )
{
::g->dc_yh = ::g->viewheight - 2; ::g->dc_yh = ::g->viewheight - 2;
}
count = ::g->dc_yh - ::g->dc_yl; count = ::g->dc_yh - ::g->dc_yl;
// Zero length. // Zero length.
if( count < 0 ) if( count < 0 )
{
return; return;
}
#ifdef RANGECHECK #ifdef RANGECHECK
@ -333,12 +346,15 @@ void R_DrawFuzzColumn ( lighttable_t * dc_colormap,
// Clamp table lookup index. // Clamp table lookup index.
if( ++::g->fuzzpos == FUZZTABLE ) if( ++::g->fuzzpos == FUZZTABLE )
{
::g->fuzzpos = 0; ::g->fuzzpos = 0;
}
dest += SCREENWIDTH; dest += SCREENWIDTH;
frac += fracstep; frac += fracstep;
} while (count--); }
while( count-- );
} }
@ -364,7 +380,9 @@ void R_DrawTranslatedColumn ( lighttable_t * dc_colormap,
count = ::g->dc_yh - ::g->dc_yl; count = ::g->dc_yh - ::g->dc_yl;
if( count < 0 ) if( count < 0 )
{
return; return;
}
#ifdef RANGECHECK #ifdef RANGECHECK
if( ( unsigned )::g->dc_x >= SCREENWIDTH if( ( unsigned )::g->dc_x >= SCREENWIDTH
@ -416,7 +434,8 @@ void R_DrawTranslatedColumn ( lighttable_t * dc_colormap,
dest += SCREENWIDTH; dest += SCREENWIDTH;
frac += fracstep; frac += fracstep;
} while (count--); }
while( count-- );
} }
@ -511,7 +530,8 @@ void R_DrawSpan ( fixed_t xfrac,
// We do not check for zero spans here? // We do not check for zero spans here?
count = ds_x2 - g->ds_x1; count = ds_x2 - g->ds_x1;
if ( ds_x2 < ds_x1 ) { if( ds_x2 < ds_x1 )
{
return; // SMF - think this is the sky return; // SMF - think this is the sky
} }
@ -528,7 +548,8 @@ void R_DrawSpan ( fixed_t xfrac,
xfrac += ds_xstep; xfrac += ds_xstep;
yfrac += ds_ystep; yfrac += ds_ystep;
} while (count--); }
while( count-- );
} }
@ -654,7 +675,8 @@ void R_DrawSpanLow ( fixed_t xfrac,
xfrac += ::g->ds_xstep; xfrac += ::g->ds_xstep;
yfrac += ::g->ds_ystep; yfrac += ::g->ds_ystep;
} while (count--); }
while( count-- );
} }
// //
@ -678,18 +700,26 @@ R_InitBuffer
// Column offset. For windows. // Column offset. For windows.
for( i = 0 ; i < width ; i++ ) for( i = 0 ; i < width ; i++ )
{
::g->columnofs[i] = ::g->viewwindowx + i; ::g->columnofs[i] = ::g->viewwindowx + i;
}
// Samw with base row offset. // Samw with base row offset.
if( width == SCREENWIDTH ) if( width == SCREENWIDTH )
{
::g->viewwindowy = 0; ::g->viewwindowy = 0;
}
else else
{
::g->viewwindowy = ( SCREENHEIGHT - SBARHEIGHT - height ) >> 1; ::g->viewwindowy = ( SCREENHEIGHT - SBARHEIGHT - height ) >> 1;
}
// Preclaculate all row offsets. // Preclaculate all row offsets.
for( i = 0 ; i < height ; i++ ) for( i = 0 ; i < height ; i++ )
{
::g->ylookup[i] = ::g->screens[0] + ( i +::g->viewwindowy ) * SCREENWIDTH; ::g->ylookup[i] = ::g->screens[0] + ( i +::g->viewwindowy ) * SCREENWIDTH;
} }
}
@ -717,18 +747,26 @@ void R_FillBackScreen (void)
char* name; char* name;
if( ::g->scaledviewwidth == SCREENWIDTH ) if( ::g->scaledviewwidth == SCREENWIDTH )
{
return; return;
}
if( ::g->gamemode == commercial ) if( ::g->gamemode == commercial )
{
name = name2; name = name2;
}
else else
{
name = name1; name = name1;
}
src = ( byte* )W_CacheLumpName( name, PU_CACHE_SHARED ); src = ( byte* )W_CacheLumpName( name, PU_CACHE_SHARED );
dest = ::g->screens[1]; dest = ::g->screens[1];
for (y=0 ; y<SCREENHEIGHT-SBARHEIGHT ; y++) { for( y = 0 ; y < SCREENHEIGHT - SBARHEIGHT ; y++ )
for (x=0 ; x<SCREENWIDTH/64 ; x++) { {
for( x = 0 ; x < SCREENWIDTH / 64 ; x++ )
{
memcpy( dest, src + ( ( y & 63 ) << 6 ), 64 ); memcpy( dest, src + ( ( y & 63 ) << 6 ), 64 );
dest += 64; dest += 64;
} }
@ -745,22 +783,26 @@ void R_FillBackScreen (void)
windowy = ::g->viewwindowy / GLOBAL_IMAGE_SCALER; windowy = ::g->viewwindowy / GLOBAL_IMAGE_SCALER;
patch = ( patch_t* )W_CacheLumpName( "brdr_t", PU_CACHE_SHARED ); 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 ); V_DrawPatch( windowx + x, windowy - 8, 1, patch );
} }
patch = ( patch_t* )W_CacheLumpName( "brdr_b", PU_CACHE_SHARED ); 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 ); V_DrawPatch( windowx + x, windowy + height, 1, patch );
} }
patch = ( patch_t* )W_CacheLumpName( "brdr_l", PU_CACHE_SHARED ); 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 ); V_DrawPatch( windowx - 8, windowy + y, 1, patch );
} }
patch = ( patch_t* )W_CacheLumpName( "brdr_r", PU_CACHE_SHARED ); 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 ); V_DrawPatch( windowx + width, windowy + y, 1, patch );
} }
@ -809,7 +851,9 @@ void R_DrawViewBorder (void)
int i; int i;
if( ::g->scaledviewwidth == SCREENWIDTH ) if( ::g->scaledviewwidth == SCREENWIDTH )
{
return; return;
}
top = ( ( SCREENHEIGHT - SBARHEIGHT ) -::g->viewheight ) / 2; top = ( ( SCREENHEIGHT - SBARHEIGHT ) -::g->viewheight ) / 2;
side = ( SCREENWIDTH -::g->scaledviewwidth ) / 2; side = ( SCREENWIDTH -::g->scaledviewwidth ) / 2;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -44,7 +44,9 @@ SlopeDiv
unsigned ans; unsigned ans;
if( den < 512 ) if( den < 512 )
{
return SLOPERANGE; return SLOPERANGE;
}
ans = ( num << 3 ) / ( den >> 8 ); 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? // Now where did these came from?
const byte gammatable[5][256] = 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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; src = ::g->screens[srcscrn] + srcy * SCREENWIDTH + srcx;
dest = ::g->screens[destscrn] + desty * SCREENWIDTH + destx; dest = ::g->screens[destscrn] + desty * SCREENWIDTH + destx;
for ( ; height>0 ; height--) { for( ; height > 0 ; height-- )
{
memcpy( dest, src, width ); memcpy( dest, src, width );
src += SCREENWIDTH; src += SCREENWIDTH;
dest += SCREENWIDTH; dest += SCREENWIDTH;
@ -237,7 +248,9 @@ V_DrawPatch
#endif #endif
if( !scrn ) if( !scrn )
{
V_MarkRect( x, y, SHORT( patch->width ), SHORT( patch->height ) ); V_MarkRect( x, y, SHORT( patch->width ), SHORT( patch->height ) );
}
col = 0; col = 0;
int destx = x; int destx = x;
@ -246,25 +259,30 @@ V_DrawPatch
w = SHORT( patch->width ); w = SHORT( patch->width );
// SMF - rewritten for scaling // SMF - rewritten for scaling
for ( ; col < w ; x++, col++ ) { for( ; col < w ; x++, col++ )
{
column = ( postColumn_t* )( ( byte* )patch + LONG( patch->columnofs[col] ) ); column = ( postColumn_t* )( ( byte* )patch + LONG( patch->columnofs[col] ) );
destx = x; destx = x;
// step through the posts in a column // step through the posts in a column
while (column->topdelta != 0xff ) { while( column->topdelta != 0xff )
{
source = ( byte* )column + 3; source = ( byte* )column + 3;
desty = y + column->topdelta; desty = y + column->topdelta;
count = column->length; count = column->length;
while (count--) { while( count-- )
{
int scaledx, scaledy; int scaledx, scaledy;
scaledx = destx * GLOBAL_IMAGE_SCALER; scaledx = destx * GLOBAL_IMAGE_SCALER;
scaledy = desty * GLOBAL_IMAGE_SCALER; scaledy = desty * GLOBAL_IMAGE_SCALER;
byte src = *source++; byte src = *source++;
for ( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ ) { for( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ )
for ( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ ) { {
for( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ )
{
::g->screens[scrn][( scaledx + j ) + ( scaledy + i ) * SCREENWIDTH] = src; ::g->screens[scrn][( scaledx + j ) + ( scaledy + i ) * SCREENWIDTH] = src;
} }
} }
@ -311,7 +329,9 @@ V_DrawPatchFlipped
#endif #endif
if( !scrn ) if( !scrn )
{
V_MarkRect( x, y, SHORT( patch->width ), SHORT( patch->height ) ); V_MarkRect( x, y, SHORT( patch->width ), SHORT( patch->height ) );
}
col = 0; col = 0;
int destx = x; int destx = x;
@ -339,8 +359,10 @@ V_DrawPatchFlipped
scaledy = desty * GLOBAL_IMAGE_SCALER; scaledy = desty * GLOBAL_IMAGE_SCALER;
byte src = *source++; byte src = *source++;
for ( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ ) { for( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ )
for ( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ ) { {
for( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ )
{
::g->screens[scrn][( scaledx + j ) + ( scaledy + i ) * SCREENWIDTH] = src; ::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 ); base = ( byte* )DoomLib::Z_Malloc( SCREENWIDTH * SCREENHEIGHT * 4, PU_STATIC, 0 );
for( i = 0 ; i < 4 ; i++ ) for( i = 0 ; i < 4 ; i++ )
{
::g->screens[i] = base + i * SCREENWIDTH * SCREENHEIGHT; ::g->screens[i] = base + i * SCREENWIDTH * SCREENHEIGHT;
} }
}

View file

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

View file

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

View file

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

View file

@ -78,7 +78,8 @@ int Z_FreeMemory (void);
template< class _type_ > 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 ) ); ptr = static_cast< _type_* >( Z_Malloc( size, tag, 0 ) );
return true; 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" --recursive "*.h"
$ASTYLE_BIN -v --formatted --options=astyle-options.ini --exclude="libs" --exclude="extern" --exclude="d3xp/gamesys/SysCvar.cpp" --exclude="d3xp/gamesys/Callbacks.cpp" \ $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" --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"