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

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -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;
@ -55,7 +56,7 @@ struct SplitscreenData {
int globalFragLimit; int globalFragLimit;
}; };
void DL_InitNetworking( DoomInterface *pdi ); void DL_InitNetworking( DoomInterface* pdi );
extern int PLAYERCOUNT; extern int PLAYERCOUNT;
extern bool globalNetworking; extern bool globalNetworking;
@ -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,10 +92,11 @@ enum MenuStates{
MENU_COUNT MENU_COUNT
}; };
typedef struct { typedef struct
{
int maxPing; int maxPing;
const wchar_t * image; const wchar_t* image;
} PingImage_t; } PingImage_t;
extern PingImage_t pingsImages[]; extern PingImage_t pingsImages[];

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -71,10 +71,10 @@ typedef unsigned int dword;
// DG: provide MAXINT seems to be available on MSVC but not MinGW, // DG: provide MAXINT seems to be available on MSVC but not MinGW,
// so use the standard defines from limits.h // so use the standard defines from limits.h
#ifndef MAXINT #ifndef MAXINT
#define MAXINT INT_MAX #define MAXINT INT_MAX
#endif #endif
#ifndef MININT #ifndef MININT
#define MININT INT_MIN #define MININT INT_MIN
#endif #endif
// DG end // DG end

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -36,18 +36,18 @@ If you have questions concerning this license or the applicable additional terms
// Called by main loop. // Called by main loop.
qboolean AM_Responder (event_t* ev); qboolean AM_Responder( event_t* ev );
// Called by main loop. // Called by main loop.
void AM_Ticker (void); void AM_Ticker( void );
// Called by main loop, // Called by main loop,
// called instead of view drawer if automap active. // called instead of view drawer if automap active.
void AM_Drawer (void); void AM_Drawer( void );
// Called to force the automap to quit // Called to force the automap to quit
// if the level is completed while it is up. // if the level is completed while it is up.
void AM_Stop (void); void AM_Stop( void );

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -26,515 +26,545 @@ If you have questions concerning this license or the applicable additional terms
=========================================================================== ===========================================================================
*/ */
memset(::g, 0, sizeof(*::g)); memset( ::g, 0, sizeof( *::g ) );
// am_map.constructs begin // // am_map.constructs begin //
::g->cheating = 0; ::g->cheating = 0;
::g->grid = 0; ::g->grid = 0;
::g->leveljuststarted = 1; // kluge until AM_LevelInit() is called ::g->leveljuststarted = 1; // kluge until AM_LevelInit() is called
::g->automapactive = false; ::g->automapactive = false;
::g->finit_width = SCREENWIDTH; ::g->finit_width = SCREENWIDTH;
::g->finit_height = SCREENHEIGHT - (32 * GLOBAL_IMAGE_SCALER); ::g->finit_height = SCREENHEIGHT - ( 32 * GLOBAL_IMAGE_SCALER );
::g->scale_mtof = (fixed_t)INITSCALEMTOF; ::g->scale_mtof = ( fixed_t )INITSCALEMTOF;
::g->markpointnum = 0; // next point to be assigned ::g->markpointnum = 0; // next point to be assigned
::g->followplayer = 1; // specifies whether to follow the player around ::g->followplayer = 1; // specifies whether to follow the player around
::g->stopped = true; ::g->stopped = true;
::g->lastlevel = -1; ::g->lastlevel = -1;
::g->lastepisode = -1; ::g->lastepisode = -1;
::g->cheatstate=0; ::g->cheatstate = 0;
::g->bigstate=0; ::g->bigstate = 0;
::g->nexttic = 0; ::g->nexttic = 0;
::g->litelevelscnt = 0; ::g->litelevelscnt = 0;
// am_map.constructs end // // am_map.constructs end //
// doomstat.constructs begin // // doomstat.constructs begin //
::g->gamemode = indetermined; ::g->gamemode = indetermined;
::g->gamemission = doom; ::g->gamemission = doom;
::g->language = english; ::g->language = english;
// doomstat.constructs end // // doomstat.constructs end //
// d_main.constructs begin // // d_main.constructs begin //
::g->singletics = false; // debug flag to cancel adaptiveness ::g->singletics = false; // debug flag to cancel adaptiveness
::g->oldgamestate = (gamestate_t)-1; ::g->oldgamestate = ( gamestate_t ) - 1;
::g->wipegamestate = GS_DEMOSCREEN; ::g->wipegamestate = GS_DEMOSCREEN;
::g->viewactivestate = false; ::g->viewactivestate = false;
::g->menuactivestate = false; ::g->menuactivestate = false;
::g->inhelpscreensstate = false; ::g->inhelpscreensstate = false;
::g->fullscreen = false; ::g->fullscreen = false;
::g->wipe = false; ::g->wipe = false;
::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 ) );
// d_net.constructs end // // d_net.constructs end //
// f_wipe.constructs begin // // f_wipe.constructs begin //
::g->go = 0; ::g->go = 0;
// 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) );
fixed_t temp_sidemove[2] = {
0x18, 0x28
};
memcpy( ::g->sidemove, temp_sidemove, sizeof(temp_sidemove) );
fixed_t temp_angleturn[3] = {
640, 1280, 320 // + slow turn
};
memcpy( ::g->angleturn, temp_angleturn, sizeof(temp_angleturn) );
::g->mousebuttons = &::g->mousearray[1]; // allow [-1]
::g->joybuttons = &::g->joyarray[1]; // allow [-1]
// g_game.constructs end //
// hu_lib.constructs begin //
::g->lastautomapactive = true;
// hu_lib.constructs end //
// hu_stuff.constructs begin //
::g->always_off = false;
::g->headsupactive = false;
::g->head = 0;
::g->tail = 0;
::g->shiftdown = false;
::g->altdown = false;
::g->num_nobrainers = 0;
// hu_stuff.constructs end //
// i_input.constructs begin //
// i_input.constructs end //
// i_system.constructs begin //
::g->mb_used = 2;
::g->current_time = 0;
// i_system.constructs end //
// m_cheat.constructs begin //
::g->firsttime = 1;
::g->usedcheatbuffer = 0;
// m_cheat.constructs end //
// m_menu.constructs begin //
menuitem_t temp_QuitMenu[3] = {
{1,"M_ACPT", M_ExitGame,'a'},
{1,"M_CAN", M_CancelExit,'c'},
{1,"M_CHG", M_GameSelection,'g'}
}; };
memcpy( ::g->QuitMenu, temp_QuitMenu, sizeof(temp_QuitMenu) ); memcpy( ::g->forwardmove, temp_forwardmove, sizeof( temp_forwardmove ) );
menu_t temp_QuitDef = { fixed_t temp_sidemove[2] =
{
0x18, 0x28
};
memcpy( ::g->sidemove, temp_sidemove, sizeof( temp_sidemove ) );
fixed_t temp_angleturn[3] =
{
640, 1280, 320 // + slow turn
};
memcpy( ::g->angleturn, temp_angleturn, sizeof( temp_angleturn ) );
::g->mousebuttons = &::g->mousearray[1]; // allow [-1]
::g->joybuttons = &::g->joyarray[1]; // allow [-1]
// g_game.constructs end //
// hu_lib.constructs begin //
::g->lastautomapactive = true;
// hu_lib.constructs end //
// hu_stuff.constructs begin //
::g->always_off = false;
::g->headsupactive = false;
::g->head = 0;
::g->tail = 0;
::g->shiftdown = false;
::g->altdown = false;
::g->num_nobrainers = 0;
// hu_stuff.constructs end //
// i_input.constructs begin //
// i_input.constructs end //
// i_system.constructs begin //
::g->mb_used = 2;
::g->current_time = 0;
// i_system.constructs end //
// m_cheat.constructs begin //
::g->firsttime = 1;
::g->usedcheatbuffer = 0;
// m_cheat.constructs end //
// m_menu.constructs begin //
menuitem_t temp_QuitMenu[3] =
{
{1, "M_ACPT", M_ExitGame, 'a'},
{1, "M_CAN", M_CancelExit, 'c'},
{1, "M_CHG", M_GameSelection, 'g'}
};
memcpy( ::g->QuitMenu, temp_QuitMenu, sizeof( temp_QuitMenu ) );
menu_t temp_QuitDef =
{
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 ->
M_DrawQuit, // drawing routine -> M_DrawQuit, // drawing routine ->
48,63, // x,y 48, 63, // x,y
g_accept // lastOn g_accept // lastOn
}; };
memcpy( &::g->QuitDef, &temp_QuitDef, sizeof(temp_QuitDef) ); memcpy( &::g->QuitDef, &temp_QuitDef, sizeof( temp_QuitDef ) );
menuitem_t temp_MainMenu[5]= menuitem_t temp_MainMenu[5] =
{ {
{1,"M_NGAME",M_NewGame,'n'}, {1, "M_NGAME", M_NewGame, 'n'},
{1,"M_OPTION",M_Options,'o'}, {1, "M_OPTION", M_Options, 'o'},
{1,"M_LOADG",M_LoadGame,'l'}, {1, "M_LOADG", M_LoadGame, 'l'},
{1,"M_SAVEG",M_SaveGame,'m'}, {1, "M_SAVEG", M_SaveGame, 'm'},
// Another hickup with Special edition. // Another hickup with Special edition.
//{1,"M_RDTHIS",M_ReadThis,'r'}, //{1,"M_RDTHIS",M_ReadThis,'r'},
{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,
M_DrawMainMenu, M_DrawMainMenu,
97,64, 97, 64,
0 0
}; };
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_EPI2", M_Episode,'t'}, {1, "M_EPI1", M_Episode, 'k'},
{1,"M_EPI3", M_Episode,'i'}, {1, "M_EPI2", M_Episode, 't'},
{1,"M_EPI4", M_Episode,'t'} {1, "M_EPI3", M_Episode, 'i'},
{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 ->
M_DrawEpisode, // drawing routine -> M_DrawEpisode, // drawing routine ->
48,63, // x,y 48, 63, // x,y
ep1 // lastOn ep1 // lastOn
}; };
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_EPI2", M_Expansion,'n'}, {1, "M_EPI1", M_Expansion, 'h'},
{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 ->
M_DrawEpisode, // drawing routine -> M_DrawEpisode, // drawing routine ->
48,63, // x,y 48, 63, // x,y
ex1 // lastOn ex1 // lastOn
}; };
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_EPI2", M_LoadExpansion,'n'}, {1, "M_EPI1", M_LoadExpansion, 'h'},
{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 ->
M_DrawEpisode, // drawing routine -> M_DrawEpisode, // drawing routine ->
48,63, // x,y 48, 63, // x,y
ex1 // lastOn ex1 // lastOn
}; };
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_ROUGH", M_ChooseSkill, 'h'}, {1, "M_JKILL", M_ChooseSkill, 'i'},
{1,"M_HURT", M_ChooseSkill, 'h'}, {1, "M_ROUGH", M_ChooseSkill, 'h'},
{1,"M_ULTRA", M_ChooseSkill, 'u'}, {1, "M_HURT", M_ChooseSkill, 'h'},
{1,"M_NMARE", M_ChooseSkill, 'n'} {1, "M_ULTRA", M_ChooseSkill, 'u'},
{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 ->
M_DrawNewGame, // drawing routine -> M_DrawNewGame, // drawing routine ->
48,63, // x,y 48, 63, // x,y
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_SCRNSZ", M_ChangeGPad,'m'}, {1, "M_GDHIGH", M_FullScreen, 'f'},
{1,"M_MESSG", M_ChangeMessages,'m'}, {1, "M_SCRNSZ", M_ChangeGPad, 'm'},
{1, "M_MESSG", M_ChangeMessages, 'm'},
//{1,"M_DETAIL", M_ChangeDetail,'g'}, //{1,"M_DETAIL", M_ChangeDetail,'g'},
//{2,"M_SCRNSZ", M_SizeDisplay,'s'}, //{2,"M_SCRNSZ", M_SizeDisplay,'s'},
{-1,"",0}, { -1, "", 0},
{2,"M_MSENS", M_ChangeSensitivity,'m'}, {2, "M_MSENS", M_ChangeSensitivity, 'm'},
{-1,"",0}, { -1, "", 0},
{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,
M_DrawOptions, M_DrawOptions,
60,37, 60, 37,
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'}, {
{-1,"",0}, {2, "M_SFXVOL", M_SfxVol, 's'},
{2,"M_MUSVOL",M_MusicVol,'m'}, { -1, "", 0},
{-1,"",0} {2, "M_MUSVOL", M_MusicVol, 'm'},
{ -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,
M_DrawSound, M_DrawSound,
80,64, 80, 64,
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,'2'}, {1, "", M_LoadSelect, '1'},
{1,"", M_LoadSelect,'3'}, {1, "", M_LoadSelect, '2'},
{1,"", M_LoadSelect,'4'}, {1, "", M_LoadSelect, '3'},
{1,"", M_LoadSelect,'5'}, {1, "", M_LoadSelect, '4'},
{1,"", M_LoadSelect,'6'} {1, "", M_LoadSelect, '5'},
{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,
M_DrawLoad, M_DrawLoad,
80,54, 80, 54,
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,'2'}, {1, "", M_SaveSelect, '1'},
{1,"", M_SaveSelect,'3'}, {1, "", M_SaveSelect, '2'},
{1,"", M_SaveSelect,'4'}, {1, "", M_SaveSelect, '3'},
{1,"", M_SaveSelect,'5'}, {1, "", M_SaveSelect, '4'},
{1,"", M_SaveSelect,'6'} {1, "", M_SaveSelect, '5'},
{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,
M_DrawSave, M_DrawSave,
80,54, 80, 54,
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,
sfx_slop, sfx_slop,
sfx_telept, sfx_telept,
sfx_posit1, sfx_posit1,
sfx_posit3, sfx_posit3,
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,
sfx_slop, sfx_slop,
sfx_skeswg, sfx_skeswg,
sfx_kntdth, sfx_kntdth,
sfx_bspact, sfx_bspact,
sfx_sgtatk sfx_sgtatk
}; };
memcpy( ::g->quitsounds2, temp_quitsounds2, sizeof(temp_quitsounds2) ); memcpy( ::g->quitsounds2, temp_quitsounds2, sizeof( temp_quitsounds2 ) );
::g->joywait = 0; ::g->joywait = 0;
::g->mousewait = 0; ::g->mousewait = 0;
::g->mmenu_mousey = 0; ::g->mmenu_mousey = 0;
::g->lasty = 0; ::g->lasty = 0;
::g->mmenu_mousex = 0; ::g->mmenu_mousex = 0;
::g->lastx = 0; ::g->lastx = 0;
// m_menu.constructs end // // m_menu.constructs end //
// m_misc.constructs begin // // m_misc.constructs begin //
::g->g_pszSaveFile = "\\save.dat"; ::g->g_pszSaveFile = "\\save.dat";
::g->g_pszImagePath = "d:\\saveimage.xbx"; ::g->g_pszImagePath = "d:\\saveimage.xbx";
::g->g_pszImageMeta = "saveimage.xbx"; ::g->g_pszImageMeta = "saveimage.xbx";
extern const char* const temp_chat_macros[]; extern const char* const temp_chat_macros[];
for (int i = 0; i < 10; i++) for( int i = 0; i < 10; i++ )
{ {
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( "key_right",&::g->key_right, KEY_RIGHTARROW ),
default_t( "key_left",&::g->key_left, KEY_LEFTARROW ),
default_t( "key_up",&::g->key_up, KEY_UPARROW ),
default_t( "key_down",&::g->key_down, KEY_DOWNARROW ),
default_t( "key_strafeleft",&::g->key_strafeleft, ',' ),
default_t( "key_straferight",&::g->key_straferight, '.' ),
default_t( "key_fire",&::g->key_fire, KEY_RCTRL ), default_t( "show_messages", &::g->showMessages, 1 ),
default_t( "key_use",&::g->key_use, ' ' ),
default_t( "key_strafe",&::g->key_strafe, KEY_RALT ),
default_t( "key_speed",&::g->key_speed, KEY_RSHIFT ),
default_t( "use_mouse",&::g->usemouse, 1 ), default_t( "key_right", &::g->key_right, KEY_RIGHTARROW ),
default_t( "mouseb_fire",&::g->mousebfire,0 ), default_t( "key_left", &::g->key_left, KEY_LEFTARROW ),
default_t( "mouseb_strafe",&::g->mousebstrafe,1 ), default_t( "key_up", &::g->key_up, KEY_UPARROW ),
default_t( "mouseb_forward",&::g->mousebforward,2 ), default_t( "key_down", &::g->key_down, KEY_DOWNARROW ),
default_t( "key_strafeleft", &::g->key_strafeleft, ',' ),
default_t( "key_straferight", &::g->key_straferight, '.' ),
default_t( "use_joystick",&::g->usejoystick, 0 ), default_t( "key_fire", &::g->key_fire, KEY_RCTRL ),
default_t( "joyb_fire",&::g->joybfire,0 ), default_t( "key_use", &::g->key_use, ' ' ),
default_t( "joyb_strafe",&::g->joybstrafe,1 ), default_t( "key_strafe", &::g->key_strafe, KEY_RALT ),
default_t( "joyb_use",&::g->joybuse,3 ), default_t( "key_speed", &::g->key_speed, KEY_RSHIFT ),
default_t( "joyb_speed",&::g->joybspeed,2 ),
default_t( "screenblocks",&::g->screenblocks, 10 ), default_t( "use_mouse", &::g->usemouse, 1 ),
default_t( "detaillevel",&::g->detailLevel, 0 ), default_t( "mouseb_fire", &::g->mousebfire, 0 ),
default_t( "mouseb_strafe", &::g->mousebstrafe, 1 ),
default_t( "mouseb_forward", &::g->mousebforward, 2 ),
default_t( "snd_channels",&::g->numChannels, S_NUMCHANNELS ), default_t( "use_joystick", &::g->usejoystick, 0 ),
default_t( "joyb_fire", &::g->joybfire, 0 ),
default_t( "joyb_strafe", &::g->joybstrafe, 1 ),
default_t( "joyb_use", &::g->joybuse, 3 ),
default_t( "joyb_speed", &::g->joybspeed, 2 ),
default_t( "screenblocks", &::g->screenblocks, 10 ),
default_t( "detaillevel", &::g->detailLevel, 0 ),
default_t( "snd_channels", &::g->numChannels, S_NUMCHANNELS ),
default_t( "usegamma",&::g->usegamma, 0 ), default_t( "usegamma", &::g->usegamma, 0 ),
default_t( "chatmacro0", &::g->chat_macros[0], HUSTR_CHATMACRO0 ), default_t( "chatmacro0", &::g->chat_macros[0], HUSTR_CHATMACRO0 ),
default_t( "chatmacro1", &::g->chat_macros[1], HUSTR_CHATMACRO1 ), default_t( "chatmacro1", &::g->chat_macros[1], HUSTR_CHATMACRO1 ),
default_t( "chatmacro2", &::g->chat_macros[2], HUSTR_CHATMACRO2 ), default_t( "chatmacro2", &::g->chat_macros[2], HUSTR_CHATMACRO2 ),
default_t( "chatmacro3", &::g->chat_macros[3], HUSTR_CHATMACRO3 ), default_t( "chatmacro3", &::g->chat_macros[3], HUSTR_CHATMACRO3 ),
default_t( "chatmacro4", &::g->chat_macros[4], HUSTR_CHATMACRO4 ), default_t( "chatmacro4", &::g->chat_macros[4], HUSTR_CHATMACRO4 ),
default_t( "chatmacro5", &::g->chat_macros[5], HUSTR_CHATMACRO5 ), default_t( "chatmacro5", &::g->chat_macros[5], HUSTR_CHATMACRO5 ),
default_t( "chatmacro6", &::g->chat_macros[6], HUSTR_CHATMACRO6 ), default_t( "chatmacro6", &::g->chat_macros[6], HUSTR_CHATMACRO6 ),
default_t( "chatmacro7", &::g->chat_macros[7], HUSTR_CHATMACRO7 ), default_t( "chatmacro7", &::g->chat_macros[7], HUSTR_CHATMACRO7 ),
default_t( "chatmacro8", &::g->chat_macros[8], HUSTR_CHATMACRO8 ), default_t( "chatmacro8", &::g->chat_macros[8], HUSTR_CHATMACRO8 ),
default_t( "chatmacro9", &::g->chat_macros[9], HUSTR_CHATMACRO9 ) default_t( "chatmacro9", &::g->chat_macros[9], HUSTR_CHATMACRO9 )
}; };
memcpy( ::g->defaults, temp_defaults, sizeof(temp_defaults) ); memcpy( ::g->defaults, temp_defaults, sizeof( temp_defaults ) );
// m_misc.constructs end // // m_misc.constructs end //
// m_random.constructs begin // // m_random.constructs begin //
::g->rndindex = 0; ::g->rndindex = 0;
::g->prndindex = 0; ::g->prndindex = 0;
// m_random.constructs end // // m_random.constructs end //
// p_enemy.constructs begin // // p_enemy.constructs begin //
::g->TRACEANGLE = 0xc000000; ::g->TRACEANGLE = 0xc000000;
::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,0}, {3, 0, 2, 1},
{3,1,2,0}, {3, 0, 2, 0},
{0}, {3, 1, 2, 0},
{2,0,2,1}, {0},
{0,0,0,0}, {2, 0, 2, 1},
{3,1,3,0}, {0, 0, 0, 0},
{0}, {3, 1, 3, 0},
{2,0,3,1}, {0},
{2,1,3,1}, {2, 0, 3, 1},
{2,1,3,0} {2, 1, 3, 1},
{2, 1, 3, 0}
}; };
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,-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,-FUZZOFF,FUZZOFF FUZZOFF, -FUZZOFF, -FUZZOFF, -FUZZOFF, -FUZZOFF, FUZZOFF, FUZZOFF,
}; FUZZOFF, FUZZOFF, -FUZZOFF, FUZZOFF, FUZZOFF, -FUZZOFF, FUZZOFF
memcpy( ::g->fuzzoffset, temp_fuzzoffset, sizeof(temp_fuzzoffset) );
::g->fuzzpos = 0;
// r_draw.constructs end //
// r_main.constructs begin //
::g->validcount = 1;
// r_main.constructs end //
// sounds.constructs begin //
musicinfo_t temp_S_music[80] = {
{ 0 },
{ "e1m1", 0 },
{ "e1m2", 0 },
{ "e1m3", 0 },
{ "e1m4", 0 },
{ "e1m5", 0 },
{ "e1m6", 0 },
{ "e1m7", 0 },
{ "e1m8", 0 },
{ "e1m9", 0 },
{ "e2m1", 0 },
{ "e2m2", 0 },
{ "e2m3", 0 },
{ "e2m4", 0 },
{ "e2m5", 0 },
{ "e2m6", 0 },
{ "e2m7", 0 },
{ "e2m8", 0 },
{ "e2m9", 0 },
{ "e3m1", 0 },
{ "e3m2", 0 },
{ "e3m3", 0 },
{ "e3m4", 0 },
{ "e3m5", 0 },
{ "e3m6", 0 },
{ "e3m7", 0 },
{ "e3m8", 0 },
{ "e3m9", 0 },
{ "inter", 0 },
{ "intro", 0 },
{ "bunny", 0 },
{ "victor", 0 },
{ "introa", 0 },
{ "runnin", 0 },
{ "stalks", 0 },
{ "countd", 0 },
{ "betwee", 0 },
{ "doom", 0 },
{ "the_da", 0 },
{ "shawn", 0 },
{ "ddtblu", 0 },
{ "in_cit", 0 },
{ "dead", 0 },
{ "stlks2", 0 },
{ "theda2", 0 },
{ "doom2", 0 },
{ "ddtbl2", 0 },
{ "runni2", 0 },
{ "dead2", 0 },
{ "stlks3", 0 },
{ "romero", 0 },
{ "shawn2", 0 },
{ "messag", 0 },
{ "count2", 0 },
{ "ddtbl3", 0 },
{ "ampie", 0 },
{ "theda3", 0 },
{ "adrian", 0 },
{ "messg2", 0 },
{ "romer2", 0 },
{ "tense", 0 },
{ "shawn3", 0 },
{ "openin", 0 },
{ "evil", 0 },
{ "ultima", 0 },
{ "read_m", 0 },
{ "dm2ttl", 0 },
{ "dm2int", 0 }
}; };
memcpy( ::g->S_music, temp_S_music, sizeof(temp_S_music) ); memcpy( ::g->fuzzoffset, temp_fuzzoffset, sizeof( temp_fuzzoffset ) );
// sounds.constructs end // ::g->fuzzpos = 0;
// st_stuff.constructs begin // // r_draw.constructs end //
::g->veryfirsttime = 1; // r_main.constructs begin //
::g->st_msgcounter=0; ::g->validcount = 1;
::g->st_oldhealth = -1; // r_main.constructs end //
::g->st_facecount = 0; // sounds.constructs begin //
::g->st_faceindex = 0; musicinfo_t temp_S_music[80] =
::g->oldhealth = -1; {
::g->lastattackdown = -1; { 0 },
::g->priority = 0; { "e1m1", 0 },
::g->largeammo = 1994; // means "n/a" { "e1m2", 0 },
::g->st_palette = 0; { "e1m3", 0 },
::g->st_stopped = true; { "e1m4", 0 },
// st_stuff.constructs end // { "e1m5", 0 },
{ "e1m6", 0 },
{ "e1m7", 0 },
{ "e1m8", 0 },
{ "e1m9", 0 },
{ "e2m1", 0 },
{ "e2m2", 0 },
{ "e2m3", 0 },
{ "e2m4", 0 },
{ "e2m5", 0 },
{ "e2m6", 0 },
{ "e2m7", 0 },
{ "e2m8", 0 },
{ "e2m9", 0 },
{ "e3m1", 0 },
{ "e3m2", 0 },
{ "e3m3", 0 },
{ "e3m4", 0 },
{ "e3m5", 0 },
{ "e3m6", 0 },
{ "e3m7", 0 },
{ "e3m8", 0 },
{ "e3m9", 0 },
{ "inter", 0 },
{ "intro", 0 },
{ "bunny", 0 },
{ "victor", 0 },
{ "introa", 0 },
{ "runnin", 0 },
{ "stalks", 0 },
{ "countd", 0 },
{ "betwee", 0 },
{ "doom", 0 },
{ "the_da", 0 },
{ "shawn", 0 },
{ "ddtblu", 0 },
{ "in_cit", 0 },
{ "dead", 0 },
{ "stlks2", 0 },
{ "theda2", 0 },
{ "doom2", 0 },
{ "ddtbl2", 0 },
{ "runni2", 0 },
{ "dead2", 0 },
{ "stlks3", 0 },
{ "romero", 0 },
{ "shawn2", 0 },
{ "messag", 0 },
{ "count2", 0 },
{ "ddtbl3", 0 },
{ "ampie", 0 },
{ "theda3", 0 },
{ "adrian", 0 },
{ "messg2", 0 },
{ "romer2", 0 },
{ "tense", 0 },
{ "shawn3", 0 },
{ "openin", 0 },
{ "evil", 0 },
{ "ultima", 0 },
{ "read_m", 0 },
{ "dm2ttl", 0 },
{ "dm2int", 0 }
};
memcpy( ::g->S_music, temp_S_music, sizeof( temp_S_music ) );
// sounds.constructs end //
// st_stuff.constructs begin //
::g->veryfirsttime = 1;
::g->st_msgcounter = 0;
::g->st_oldhealth = -1;
::g->st_facecount = 0;
::g->st_faceindex = 0;
::g->oldhealth = -1;
::g->lastattackdown = -1;
::g->priority = 0;
::g->largeammo = 1994; // means "n/a"
::g->st_palette = 0;
::g->st_stopped = true;
// st_stuff.constructs end //
// s_sound.constructs begin // // s_sound.constructs begin //
::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(epsd1animinfo)/sizeof(anim_t), sizeof( epsd0animinfo ) / sizeof( anim_t ),
sizeof(epsd2animinfo)/sizeof(anim_t) sizeof( epsd1animinfo ) / sizeof( anim_t ),
sizeof( epsd2animinfo ) / sizeof( anim_t )
}; };
memcpy( ::g->NUMANIMS, temp_NUMANIMS, sizeof(temp_NUMANIMS) ); memcpy( ::g->NUMANIMS, temp_NUMANIMS, sizeof( temp_NUMANIMS ) );
::g->snl_pointeron = false; ::g->snl_pointeron = false;
extern const anim_t temp_epsd0animinfo[10]; extern const anim_t temp_epsd0animinfo[10];
extern const anim_t temp_epsd1animinfo[9]; extern const anim_t temp_epsd1animinfo[9];
extern const anim_t temp_epsd2animinfo[6]; extern const anim_t temp_epsd2animinfo[6];
memcpy(::g->epsd0animinfo, temp_epsd0animinfo, sizeof(temp_epsd0animinfo)); memcpy( ::g->epsd0animinfo, temp_epsd0animinfo, sizeof( temp_epsd0animinfo ) );
memcpy(::g->epsd1animinfo, temp_epsd1animinfo, sizeof(temp_epsd1animinfo)); memcpy( ::g->epsd1animinfo, temp_epsd1animinfo, sizeof( temp_epsd1animinfo ) );
memcpy(::g->epsd2animinfo, temp_epsd2animinfo, sizeof(temp_epsd2animinfo)); memcpy( ::g->epsd2animinfo, temp_epsd2animinfo, sizeof( temp_epsd2animinfo ) );
wi_stuff_anims[0] = ::g->epsd0animinfo; wi_stuff_anims[0] = ::g->epsd0animinfo;
wi_stuff_anims[1] = ::g->epsd1animinfo; wi_stuff_anims[1] = ::g->epsd1animinfo;
wi_stuff_anims[2] = ::g->epsd2animinfo; wi_stuff_anims[2] = ::g->epsd2animinfo;
// wi_stuff.constructs end // // wi_stuff.constructs end //
// z_zone.constructs begin // // z_zone.constructs begin //
::g->zones[NUM_ZONES] = NULL; ::g->zones[NUM_ZONES] = NULL;
::g->NumAlloc = 0; ::g->NumAlloc = 0;
// z_zone.constructs end // // z_zone.constructs end //
// info constructs begin // // info constructs begin //
extern const state_t tempStates[NUMSTATES]; extern const state_t tempStates[NUMSTATES];
memcpy(::g->states, tempStates, sizeof(tempStates)); memcpy( ::g->states, tempStates, sizeof( tempStates ) );
// info constructs end // // info constructs end //
// p_local begin // // p_local begin //
::g->rejectmatrix = NULL; ::g->rejectmatrix = NULL;
// p_local end // // p_local end //
// r_data begin //] // r_data begin //]
::g->s_numtextures = 0; ::g->s_numtextures = 0;
// r_data end // // r_data end //

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -552,7 +552,7 @@ If you have questions concerning this license or the applicable additional terms
"CONGRATULATIONS YOU HAVE FINISHED... \n\n"\ "CONGRATULATIONS YOU HAVE FINISHED... \n\n"\
"THE MASTER LEVELS\n" "THE MASTER LEVELS\n"
// after map 06 // after map 06
#define P1TEXT \ #define P1TEXT \
"You gloat over the steaming carcass of the\n"\ "You gloat over the steaming carcass of the\n"\

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -40,35 +40,35 @@ If you have questions concerning this license or the applicable additional terms
// Input event types. // Input event types.
typedef enum typedef enum
{ {
ev_keydown, ev_keydown,
ev_keyup, ev_keyup,
ev_mouse, ev_mouse,
ev_joystick, ev_joystick,
ev_none, ev_none,
} evtype_t; } evtype_t;
// Event structure. // Event structure.
typedef struct typedef struct
{ {
evtype_t type; evtype_t type;
int data1; // keys / mouse/joystick buttons int data1; // keys / mouse/joystick buttons
int data2; // mouse/joystick x move int data2; // mouse/joystick x move
int data3; // mouse/joystick y move int data3; // mouse/joystick y move
} event_t; } event_t;
typedef enum typedef enum
{ {
ga_nothing, ga_nothing,
ga_loadlevel, ga_loadlevel,
ga_newgame, ga_newgame,
ga_loadgame, ga_loadgame,
ga_savegame, ga_savegame,
ga_playdemo, ga_playdemo,
ga_completed, ga_completed,
ga_victory, ga_victory,
ga_worlddone, ga_worlddone,
ga_screenshot ga_screenshot
} gameaction_t; } gameaction_t;
@ -78,32 +78,32 @@ typedef enum
// //
typedef enum typedef enum
{ {
// Press "Fire". // Press "Fire".
BT_ATTACK = 1, BT_ATTACK = 1,
// Use button, to open doors, activate switches. // Use button, to open doors, activate switches.
BT_USE = 2, BT_USE = 2,
// Flag: game events, not really buttons. // Flag: game events, not really buttons.
BT_SPECIAL = 128, BT_SPECIAL = 128,
BT_SPECIALMASK = 3, BT_SPECIALMASK = 3,
// Flag, weapon change pending.
// If true, the next 3 bits hold weapon num.
BT_CHANGE = 4,
// The 3bit weapon mask and shift, convenience.
BT_WEAPONMASK = (8+16+32),
BT_WEAPONSHIFT = 3,
// Pause the game. // Flag, weapon change pending.
BTS_PAUSE = 1, // If true, the next 3 bits hold weapon num.
// Save the game at each console. BT_CHANGE = 4,
BTS_SAVEGAME = 2, // The 3bit weapon mask and shift, convenience.
BT_WEAPONMASK = ( 8 + 16 + 32 ),
BT_WEAPONSHIFT = 3,
// Pause the game.
BTS_PAUSE = 1,
// Save the game at each console.
BTS_SAVEGAME = 2,
// Savegame slot numbers
// occupy the second byte of buttons.
BTS_SAVEMASK = ( 4 + 8 + 16 ),
BTS_SAVESHIFT = 2,
// Savegame slot numbers
// occupy the second byte of buttons.
BTS_SAVEMASK = (4+8+16),
BTS_SAVESHIFT = 2,
} buttoncode_t; } buttoncode_t;

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -29,7 +29,7 @@ If you have questions concerning this license or the applicable additional terms
#include "Precompiled.h" #include "Precompiled.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "d_items.h" #pragma implementation "d_items.h"
#endif #endif
#include "d_items.h" #include "d_items.h"
@ -53,87 +53,87 @@ If you have questions concerning this license or the applicable additional terms
// //
const weaponinfo_t weaponinfo[NUMWEAPONS] = const weaponinfo_t weaponinfo[NUMWEAPONS] =
{ {
{ {
// fist // fist
am_noammo, am_noammo,
S_PUNCHUP, S_PUNCHUP,
S_PUNCHDOWN, S_PUNCHDOWN,
S_PUNCH, S_PUNCH,
S_PUNCH1, S_PUNCH1,
S_NULL S_NULL
}, },
{ {
// pistol // pistol
am_clip, am_clip,
S_PISTOLUP, S_PISTOLUP,
S_PISTOLDOWN, S_PISTOLDOWN,
S_PISTOL, S_PISTOL,
S_PISTOL1, S_PISTOL1,
S_PISTOLFLASH S_PISTOLFLASH
}, },
{ {
// shotgun // shotgun
am_shell, am_shell,
S_SGUNUP, S_SGUNUP,
S_SGUNDOWN, S_SGUNDOWN,
S_SGUN, S_SGUN,
S_SGUN1, S_SGUN1,
S_SGUNFLASH1 S_SGUNFLASH1
}, },
{ {
// chaingun // chaingun
am_clip, am_clip,
S_CHAINUP, S_CHAINUP,
S_CHAINDOWN, S_CHAINDOWN,
S_CHAIN, S_CHAIN,
S_CHAIN1, S_CHAIN1,
S_CHAINFLASH1 S_CHAINFLASH1
}, },
{ {
// missile launcher // missile launcher
am_misl, am_misl,
S_MISSILEUP, S_MISSILEUP,
S_MISSILEDOWN, S_MISSILEDOWN,
S_MISSILE, S_MISSILE,
S_MISSILE1, S_MISSILE1,
S_MISSILEFLASH1 S_MISSILEFLASH1
}, },
{ {
// plasma rifle // plasma rifle
am_cell, am_cell,
S_PLASMAUP, S_PLASMAUP,
S_PLASMADOWN, S_PLASMADOWN,
S_PLASMA, S_PLASMA,
S_PLASMA1, S_PLASMA1,
S_PLASMAFLASH1 S_PLASMAFLASH1
}, },
{ {
// bfg 9000 // bfg 9000
am_cell, am_cell,
S_BFGUP, S_BFGUP,
S_BFGDOWN, S_BFGDOWN,
S_BFG, S_BFG,
S_BFG1, S_BFG1,
S_BFGFLASH1 S_BFGFLASH1
}, },
{ {
// chainsaw // chainsaw
am_noammo, am_noammo,
S_SAWUP, S_SAWUP,
S_SAWDOWN, S_SAWDOWN,
S_SAW, S_SAW,
S_SAW1, S_SAW1,
S_NULL S_NULL
}, },
{ {
// super shotgun // super shotgun
am_shell, am_shell,
S_DSGUNUP, S_DSGUNUP,
S_DSGUNDOWN, S_DSGUNDOWN,
S_DSGUN, S_DSGUN,
S_DSGUN1, S_DSGUN1,
S_DSGUNFLASH1 S_DSGUNFLASH1
}, },
}; };

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -32,19 +32,19 @@ If you have questions concerning this license or the applicable additional terms
#include "doomdef.h" #include "doomdef.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
// Weapon info: sprite frames, ammunition use. // Weapon info: sprite frames, ammunition use.
typedef struct typedef struct
{ {
ammotype_t ammo; ammotype_t ammo;
int upstate; int upstate;
int downstate; int downstate;
int readystate; int readystate;
int atkstate; int atkstate;
int flashstate; int flashstate;
} weaponinfo_t; } weaponinfo_t;

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -32,7 +32,7 @@ If you have questions concerning this license or the applicable additional terms
#include "d_event.h" #include "d_event.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
extern const char* extraWad; extern const char* extraWad;
@ -40,8 +40,8 @@ extern const char* extraWad;
#define MAXWADFILES 20 #define MAXWADFILES 20
extern const char* wadfiles[MAXWADFILES]; extern const char* wadfiles[MAXWADFILES];
void D_AddExtraWadFile( const char *file ); void D_AddExtraWadFile( const char* file );
void D_AddFile ( const char *file); void D_AddFile( const char* file );
@ -51,25 +51,25 @@ void D_AddFile ( const char *file);
// calls all startup code, parses command line options. // calls all startup code, parses command line options.
// If not overrided by user input, calls N_AdvanceDemo. // If not overrided by user input, calls N_AdvanceDemo.
// //
void D_DoomMain (void); void D_DoomMain( void );
// Called by IO functions when input is detected. // Called by IO functions when input is detected.
void D_PostEvent (event_t* ev); void D_PostEvent( event_t* ev );
// //
// BASE LEVEL // BASE LEVEL
// //
void D_PageTicker (void); void D_PageTicker( void );
void D_PageDrawer (void); void D_PageDrawer( void );
void D_AdvanceDemo (void); void D_AdvanceDemo( void );
void D_StartTitle (void); void D_StartTitle( void );
//#define R_OK 0x01 //#define R_OK 0x01
//#define X_OK 0x02 //#define X_OK 0x02
//#define W_OK 0x04 //#define W_OK 0x04
int access(char* name, int val); int access( char* name, int val );
#endif #endif

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -33,7 +33,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
@ -56,8 +56,8 @@ If you have questions concerning this license or the applicable additional terms
typedef enum typedef enum
{ {
CMD_SEND = 1, CMD_SEND = 1,
CMD_GET = 2 CMD_GET = 2
} command_t; } command_t;
@ -67,17 +67,17 @@ typedef enum
// //
typedef struct typedef struct
{ {
// High bit is retransmit request. // High bit is retransmit request.
unsigned checksum; unsigned checksum;
// Only valid if NCMD_RETRANSMIT. // Only valid if NCMD_RETRANSMIT.
byte retransmitfrom; byte retransmitfrom;
byte sourceDest; byte sourceDest;
byte starttic; byte starttic;
byte player; byte player;
byte numtics; byte numtics;
ticcmd_t cmds[BACKUPTICS]; ticcmd_t cmds[BACKUPTICS];
} doomdata_t; } doomdata_t;
@ -86,66 +86,66 @@ typedef struct
struct doomcom_t struct doomcom_t
{ {
// Supposed to be DOOMCOM_ID? // Supposed to be DOOMCOM_ID?
long id; long id;
// DOOM executes an int to execute commands.
short intnum;
// Communication between DOOM and the driver.
// Is CMD_SEND or CMD_GET.
short command;
// Is dest for send, set by get (-1 = no packet).
short remotenode;
// Number of bytes in doomdata to be sent
short datalength;
// Info common to all nodes. // DOOM executes an int to execute commands.
// Console is allways node 0. short intnum;
short numnodes; // Communication between DOOM and the driver.
// Flag: 1 = no duplication, 2-5 = dup for slow nets. // Is CMD_SEND or CMD_GET.
short ticdup; short command;
// Flag: 1 = send a backup tic in every packet. // Is dest for send, set by get (-1 = no packet).
short extratics; short remotenode;
// Flag: 1 = deathmatch.
short deathmatch;
// Flag: -1 = new game, 0-5 = load savegame
short savegame;
short episode; // 1-3
short map; // 1-9
short skill; // 1-5
// Info specific to this node. // Number of bytes in doomdata to be sent
short consoleplayer; short datalength;
short numplayers;
// Info common to all nodes.
// These are related to the 3-display mode, // Console is allways node 0.
// in which two drones looking left and right short numnodes;
// were used to render two additional views // Flag: 1 = no duplication, 2-5 = dup for slow nets.
// on two additional computers. short ticdup;
// Probably not operational anymore. // Flag: 1 = send a backup tic in every packet.
// 1 = left, 0 = center, -1 = right short extratics;
short angleoffset; // Flag: 1 = deathmatch.
// 1 = drone short deathmatch;
short drone; // Flag: -1 = new game, 0-5 = load savegame
short savegame;
short episode; // 1-3
short map; // 1-9
short skill; // 1-5
// Info specific to this node.
short consoleplayer;
short numplayers;
// These are related to the 3-display mode,
// in which two drones looking left and right
// were used to render two additional views
// on two additional computers.
// Probably not operational anymore.
// 1 = left, 0 = center, -1 = right
short angleoffset;
// 1 = drone
short drone;
// The packet data to be sent.
doomdata_t data;
// The packet data to be sent.
doomdata_t data;
} ; } ;
class idUserCmdMgr; class idUserCmdMgr;
// Create any new ticcmds and broadcast to other players. // Create any new ticcmds and broadcast to other players.
void NetUpdate ( idUserCmdMgr * userCmdMgr ); void NetUpdate( idUserCmdMgr* userCmdMgr );
// Broadcasts special packets to other players // Broadcasts special packets to other players
// to notify of game exit // to notify of game exit
void D_QuitNetGame (void); void D_QuitNetGame( void );
//? how many ticks to run? //? how many ticks to run?
bool TryRunTics (void); bool TryRunTics( void );
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -47,7 +47,7 @@ If you have questions concerning this license or the applicable additional terms
#include "d_ticcmd.h" #include "d_ticcmd.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
@ -58,12 +58,12 @@ If you have questions concerning this license or the applicable additional terms
// //
typedef enum typedef enum
{ {
// Playing or camping. // Playing or camping.
PST_LIVE, PST_LIVE,
// Dead on the ground, view follows killer. // Dead on the ground, view follows killer.
PST_DEAD, PST_DEAD,
// Ready to restart/respawn??? // Ready to restart/respawn???
PST_REBORN PST_REBORN
} playerstate_t; } playerstate_t;
@ -73,12 +73,12 @@ typedef enum
// //
typedef enum typedef enum
{ {
// No clipping, walk through barriers. // No clipping, walk through barriers.
CF_NOCLIP = 1, CF_NOCLIP = 1,
// No damage, no health loss. // No damage, no health loss.
CF_GODMODE = 2, CF_GODMODE = 2,
// Not really a cheat, just a debug aid. // Not really a cheat, just a debug aid.
CF_NOMOMENTUM = 4, CF_NOMOMENTUM = 4,
// Gives kfa at the beginning of the level. // Gives kfa at the beginning of the level.
CF_GIVEALL = 8, CF_GIVEALL = 8,
@ -92,89 +92,89 @@ typedef enum
// //
typedef struct player_s typedef struct player_s
{ {
mobj_t* mo; mobj_t* mo;
playerstate_t playerstate; playerstate_t playerstate;
ticcmd_t cmd; ticcmd_t cmd;
// Determine POV, // Determine POV,
// including viewpoint bobbing during movement. // including viewpoint bobbing during movement.
// Focal origin above r.z // Focal origin above r.z
fixed_t viewz; fixed_t viewz;
// Base height above floor for viewz. // Base height above floor for viewz.
fixed_t viewheight; fixed_t viewheight;
// Bob/squat speed. // Bob/squat speed.
fixed_t deltaviewheight; fixed_t deltaviewheight;
// bounded/scaled total momentum. // bounded/scaled total momentum.
fixed_t bob; fixed_t bob;
// This is only used between levels, // This is only used between levels,
// mo->health is used during levels. // mo->health is used during levels.
int health; int health;
int armorpoints; int armorpoints;
// Armor type is 0-2. // Armor type is 0-2.
int armortype; int armortype;
// Power ups. invinc and invis are tic counters. // Power ups. invinc and invis are tic counters.
int powers[NUMPOWERS]; int powers[NUMPOWERS];
qboolean cards[NUMCARDS]; qboolean cards[NUMCARDS];
qboolean backpack; qboolean backpack;
// Frags, kills of other players.
int frags[MAXPLAYERS];
weapontype_t readyweapon;
// Is wp_nochange if not changing.
weapontype_t pendingweapon;
int weaponowned[NUMWEAPONS]; // Frags, kills of other players.
int ammo[NUMAMMO]; int frags[MAXPLAYERS];
int maxammo[NUMAMMO]; weapontype_t readyweapon;
// True if button down last tic. // Is wp_nochange if not changing.
int attackdown; weapontype_t pendingweapon;
int usedown;
// Bit flags, for cheats and debug. int weaponowned[NUMWEAPONS];
// See cheat_t, above. int ammo[NUMAMMO];
int cheats; int maxammo[NUMAMMO];
// Refired shots are less accurate. // True if button down last tic.
int refire; int attackdown;
int usedown;
// For intermission stats. // Bit flags, for cheats and debug.
int killcount; // See cheat_t, above.
int itemcount; int cheats;
int secretcount;
// Refired shots are less accurate.
int refire;
// For intermission stats.
int killcount;
int itemcount;
int secretcount;
int chainsawKills; int chainsawKills;
int berserkKills; int berserkKills;
// Hint messages. // Hint messages.
const char* message; const char* message;
// For screen flashing (red or bright).
int damagecount;
int bonuscount;
// Who did damage (NULL for floors/ceilings). // For screen flashing (red or bright).
mobj_t* attacker; int damagecount;
int bonuscount;
// So gun flashes light up areas.
int extralight;
// Current PLAYPAL, ??? // Who did damage (NULL for floors/ceilings).
// can be set to REDCOLORMAP for pain, etc. mobj_t* attacker;
int fixedcolormap;
// Player skin colorshift, // So gun flashes light up areas.
// 0-3 for which color to draw player. int extralight;
int colormap;
// Overlay view sprites (gun, etc). // Current PLAYPAL, ???
pspdef_t psprites[NUMPSPRITES]; // can be set to REDCOLORMAP for pain, etc.
int fixedcolormap;
// True if secret level has been done. // Player skin colorshift,
qboolean didsecret; // 0-3 for which color to draw player.
int colormap;
// Overlay view sprites (gun, etc).
pspdef_t psprites[NUMPSPRITES];
// True if secret level has been done.
qboolean didsecret;
} player_t; } player_t;
@ -185,41 +185,41 @@ typedef struct player_s
// //
typedef struct typedef struct
{ {
qboolean in; // whether the player is in game qboolean in; // whether the player is in game
// Player stats, kills, collected items etc. // Player stats, kills, collected items etc.
int skills; int skills;
int sitems; int sitems;
int ssecret; int ssecret;
int stime; int stime;
int frags[4]; int frags[4];
int score; // current score on entry, modified on return int score; // current score on entry, modified on return
} wbplayerstruct_t; } wbplayerstruct_t;
typedef struct typedef struct
{ {
int epsd; // episode # (0-2) int epsd; // episode # (0-2)
// if true, splash the secret level // if true, splash the secret level
qboolean didsecret; qboolean didsecret;
// previous and next levels, origin 0
int last;
int next;
int maxkills;
int maxitems;
int maxsecret;
int maxfrags;
// the par time // previous and next levels, origin 0
int partime; int last;
int next;
// index of this player in game
int pnum;
wbplayerstruct_t plyr[MAXPLAYERS]; int maxkills;
int maxitems;
int maxsecret;
int maxfrags;
// the par time
int partime;
// index of this player in game
int pnum;
wbplayerstruct_t plyr[MAXPLAYERS];
} wbstartstruct_t; } wbstartstruct_t;

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -40,9 +40,9 @@ If you have questions concerning this license or the applicable additional terms
// a pic is an unmasked block of pixels // a pic is an unmasked block of pixels
typedef struct typedef struct
{ {
byte width; byte width;
byte height; byte height;
byte data; byte data;
} pic_t; } pic_t;

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
// //
@ -41,15 +41,15 @@ If you have questions concerning this license or the applicable additional terms
// action functions cleanly. // action functions cleanly.
// //
struct mobj_t; struct mobj_t;
typedef void (*actionf_v)(); typedef void ( *actionf_v )();
typedef void (*actionf_p1)( mobj_t* ); typedef void ( *actionf_p1 )( mobj_t* );
typedef void (*actionf_p2)( void*, void* ); typedef void ( *actionf_p2 )( void*, void* );
typedef union typedef union
{ {
actionf_p1 acp1; actionf_p1 acp1;
actionf_v acv; actionf_v acv;
actionf_p2 acp2; actionf_p2 acp2;
} actionf_t; } actionf_t;
@ -66,10 +66,10 @@ typedef actionf_t think_t;
// Doubly linked list of actors. // Doubly linked list of actors.
typedef struct thinker_s typedef struct thinker_s
{ {
struct thinker_s* prev; struct thinker_s* prev;
struct thinker_s* next; struct thinker_s* next;
think_t function; think_t function;
} thinker_t; } thinker_t;

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -32,7 +32,7 @@ If you have questions concerning this license or the applicable additional terms
#include "doomtype.h" #include "doomtype.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
// The data sampled per tick (single player) // The data sampled per tick (single player)
@ -41,11 +41,11 @@ If you have questions concerning this license or the applicable additional terms
// plus a checksum for internal state consistency. // plus a checksum for internal state consistency.
typedef struct typedef struct
{ {
char forwardmove; // *2048 for move char forwardmove; // *2048 for move
char sidemove; // *2048 for move char sidemove; // *2048 for move
short angleturn; // <<16 for angle delta short angleturn; // <<16 for angle delta
short consistancy; // checks for net game short consistancy; // checks for net game
byte buttons; byte buttons;
byte nextPrevWeapon; byte nextPrevWeapon;
} ticcmd_t; } ticcmd_t;

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -26,7 +26,7 @@ If you have questions concerning this license or the applicable additional terms
=========================================================================== ===========================================================================
*/ */
// am_map.defs begin // // am_map.defs begin //
#define REDS (256-5*16) #define REDS (256-5*16)
#define REDRANGE 16 #define REDRANGE 16
#define BLUES (256-4*16+8) #define BLUES (256-4*16+8)
@ -94,13 +94,13 @@ If you have questions concerning this license or the applicable additional terms
if ((mx) < 0) (oc) |= LEFT; \ if ((mx) < 0) (oc) |= LEFT; \
else if ((mx) >= ::g->f_w) (oc) |= RIGHT; else if ((mx) >= ::g->f_w) (oc) |= RIGHT;
#define PUTDOT(xx,yy,cc) ::g->fb[(yy)*::g->f_w+(xx)]=(cc) #define PUTDOT(xx,yy,cc) ::g->fb[(yy)*::g->f_w+(xx)]=(cc)
// am_map.defs end // // am_map.defs end //
// d_main.defs begin // // d_main.defs begin //
#define BGCOLOR 7 #define BGCOLOR 7
#define FGCOLOR 8 #define FGCOLOR 8
#define DOOMWADDIR "wads/" #define DOOMWADDIR "wads/"
// d_main.defs end // // d_main.defs end //
// d_net.defs begin // // d_net.defs begin //
#define NCMD_EXIT 0x80000000 #define NCMD_EXIT 0x80000000
#define NCMD_RETRANSMIT 0x40000000 #define NCMD_RETRANSMIT 0x40000000
#define NCMD_SETUP 0x20000000 #define NCMD_SETUP 0x20000000
@ -108,25 +108,25 @@ If you have questions concerning this license or the applicable additional terms
#define NCMD_CHECKSUM 0x0fffffff #define NCMD_CHECKSUM 0x0fffffff
#define RESENDCOUNT 10 #define RESENDCOUNT 10
#define PL_DRONE 0x80 // bit flag in doomdata->player #define PL_DRONE 0x80 // bit flag in doomdata->player
// d_net.defs end // // d_net.defs end //
// f_finale.defs begin // // f_finale.defs begin //
#define TEXTSPEED 3 #define TEXTSPEED 3
#define TEXTWAIT 250 #define TEXTWAIT 250
// f_finale.defs end // // f_finale.defs end //
// g_game.defs begin // // g_game.defs begin //
#define SAVESTRINGSIZE 64 #define SAVESTRINGSIZE 64
#define MAXPLMOVE (::g->forwardmove[1]) #define MAXPLMOVE (::g->forwardmove[1])
#define TURBOTHRESHOLD 0x32 #define TURBOTHRESHOLD 0x32
#define SLOWTURNTICS 6 #define SLOWTURNTICS 6
#define NUMKEYS 256 #define NUMKEYS 256
#define BODYQUESIZE 32 #define BODYQUESIZE 32
#define VERSIONSIZE 16 #define VERSIONSIZE 16
#define DEMOMARKER 0x80 #define DEMOMARKER 0x80
// g_game.defs end // // g_game.defs end //
// hu_lib.defs begin // // hu_lib.defs begin //
#define noterased ::g->viewwindowx #define noterased ::g->viewwindowx
// hu_lib.defs end // // hu_lib.defs end //
// hu_stuff.defs begin // // hu_stuff.defs begin //
#define HU_TITLE (mapnames[(::g->gameepisode-1)*9+::g->gamemap-1]) #define HU_TITLE (mapnames[(::g->gameepisode-1)*9+::g->gamemap-1])
#define HU_TITLE2 (mapnames2[::g->gamemap-1]) #define HU_TITLE2 (mapnames2[::g->gamemap-1])
#define HU_TITLEP (mapnamesp[::g->gamemap-1]) #define HU_TITLEP (mapnamesp[::g->gamemap-1])
@ -140,8 +140,8 @@ If you have questions concerning this license or the applicable additional terms
#define HU_INPUTWIDTH 64 #define HU_INPUTWIDTH 64
#define HU_INPUTHEIGHT 1 #define HU_INPUTHEIGHT 1
#define QUEUESIZE 128 #define QUEUESIZE 128
// hu_stuff.defs end // // hu_stuff.defs end //
// i_net.defs begin // // i_net.defs begin //
// SMF // SMF
/* /*
#define ntohl(x) \ #define ntohl(x) \
@ -154,8 +154,8 @@ If you have questions concerning this license or the applicable additional terms
(((unsigned short int)(x) & 0xff00) >> 8))) \ (((unsigned short int)(x) & 0xff00) >> 8))) \
#define htonl(x) ntohl(x) #define htonl(x) ntohl(x)
#define htons(x) ntohs(x) #define htons(x) ntohs(x)
// i_net.defs end // // i_net.defs end //
// i_net_xbox.defs begin // // i_net_xbox.defs begin //
#define ntohl(x) \ #define ntohl(x) \
((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \ ((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
(((unsigned long int)(x) & 0x0000ff00U) << 8) | \ (((unsigned long int)(x) & 0x0000ff00U) << 8) | \
@ -167,21 +167,21 @@ If you have questions concerning this license or the applicable additional terms
#define htonl(x) ntohl(x) #define htonl(x) ntohl(x)
#define htons(x) ntohs(x) #define htons(x) ntohs(x)
*/ */
#define IPPORT_USERRESERVED 5000 #define IPPORT_USERRESERVED 5000
// i_net_xbox.defs end // // i_net_xbox.defs end //
// i_sound_xbox.defs begin // // i_sound_xbox.defs begin //
#define SAMPLECOUNT 512 #define SAMPLECOUNT 512
#define NUM_SOUNDBUFFERS 64 #define NUM_SOUNDBUFFERS 64
#define BUFMUL 4 #define BUFMUL 4
#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL) #define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL)
// i_sound_xbox.defs end // // i_sound_xbox.defs end //
// i_video_xbox.defs begin // // i_video_xbox.defs begin //
//#define TEXTUREWIDTH 512 //#define TEXTUREWIDTH 512
//#define TEXTUREHEIGHT 256 //#define TEXTUREHEIGHT 256
// i_video_xbox.defs end // // i_video_xbox.defs end //
// mus2midi.defs begin // // mus2midi.defs begin //
#define MUSEVENT_KEYOFF 0 #define MUSEVENT_KEYOFF 0
#define MUSEVENT_KEYON 1 #define MUSEVENT_KEYON 1
#define MUSEVENT_PITCHWHEEL 2 #define MUSEVENT_PITCHWHEEL 2
@ -190,46 +190,46 @@ If you have questions concerning this license or the applicable additional terms
#define MUSEVENT_END 6 #define MUSEVENT_END 6
#define MIDI_MAXCHANNELS 16 #define MIDI_MAXCHANNELS 16
#define MIDIHEADERSIZE 14 #define MIDIHEADERSIZE 14
// mus2midi.defs end // // mus2midi.defs end //
// m_menu.defs begin // // m_menu.defs begin //
#define SAVESTRINGSIZE 64 #define SAVESTRINGSIZE 64
#define SKULLXOFF -32 #define SKULLXOFF -32
#define LINEHEIGHT 16 #define LINEHEIGHT 16
// m_menu.defs end // // m_menu.defs end //
// p_enemy.defs begin // // p_enemy.defs begin //
#define MAXSPECIALCROSS 8 #define MAXSPECIALCROSS 8
#define FATSPREAD (ANG90/8) #define FATSPREAD (ANG90/8)
#define SKULLSPEED (20*FRACUNIT) #define SKULLSPEED (20*FRACUNIT)
// p_enemy.defs end // // p_enemy.defs end //
// p_inter.defs begin // // p_inter.defs begin //
#define BONUSADD 6 #define BONUSADD 6
// p_inter.defs end // // p_inter.defs end //
// p_map.defs begin // // p_map.defs begin //
#define MAXSPECIALCROSS 8 #define MAXSPECIALCROSS 8
// p_map.defs end // // p_map.defs end //
// p_mobj.defs begin // // p_mobj.defs begin //
#define STOPSPEED 0x1000 #define STOPSPEED 0x1000
#define FRICTION 0xe800 #define FRICTION 0xe800
// p_mobj.defs end // // p_mobj.defs end //
// p_pspr.defs begin // // p_pspr.defs begin //
#define LOWERSPEED FRACUNIT*6 #define LOWERSPEED FRACUNIT*6
#define RAISESPEED FRACUNIT*6 #define RAISESPEED FRACUNIT*6
#define WEAPONBOTTOM 128*FRACUNIT #define WEAPONBOTTOM 128*FRACUNIT
#define WEAPONTOP 32*FRACUNIT #define WEAPONTOP 32*FRACUNIT
#define BFGCELLS 40 #define BFGCELLS 40
// p_pspr.defs end // // p_pspr.defs end //
// p_saveg.defs begin // // p_saveg.defs begin //
#define PADSAVEP() ::g->save_p += (4 - ((intptr_t) ::g->save_p & 3)) & 3 #define PADSAVEP() ::g->save_p += (4 - ((intptr_t) ::g->save_p & 3)) & 3
// p_saveg.defs end // // p_saveg.defs end //
// p_setup.defs begin // // p_setup.defs begin //
#define MAX_DEATHMATCH_STARTS 10 #define MAX_DEATHMATCH_STARTS 10
// p_setup.defs end // // p_setup.defs end //
// p_spec.defs begin // // p_spec.defs begin //
#define MAXANIMS 32 #define MAXANIMS 32
#define MAXLINEANIMS 64 #define MAXLINEANIMS 64
#define MAX_ADJOINING_SECTORS 20 #define MAX_ADJOINING_SECTORS 20
// p_spec.defs end // // p_spec.defs end //
// p_user.defs begin // // p_user.defs begin //
#define INVERSECOLORMAP 32 #define INVERSECOLORMAP 32
// DHM - NERVE :: MAXBOB reduced 25% // DHM - NERVE :: MAXBOB reduced 25%
@ -237,35 +237,35 @@ If you have questions concerning this license or the applicable additional terms
#define MAXBOB 0xC0000 #define MAXBOB 0xC0000
#define ANG5 (ANG90/18) #define ANG5 (ANG90/18)
// p_user.defs end // // p_user.defs end //
// r_bsp.defs begin // // r_bsp.defs begin //
#define MAXSEGS 32 #define MAXSEGS 32
// r_bsp.defs end // // r_bsp.defs end //
// r_draw.defs begin // // r_draw.defs begin //
//#define MAXWIDTH 1120 //#define MAXWIDTH 1120
//#define MAXHEIGHT 832 //#define MAXHEIGHT 832
#define SBARHEIGHT 32 * GLOBAL_IMAGE_SCALER #define SBARHEIGHT 32 * GLOBAL_IMAGE_SCALER
#define FUZZTABLE 50 #define FUZZTABLE 50
#define FUZZOFF (SCREENWIDTH) #define FUZZOFF (SCREENWIDTH)
// r_draw.defs end // // r_draw.defs end //
// r_main.defs begin // // r_main.defs begin //
#define FIELDOFVIEW 2048 #define FIELDOFVIEW 2048
#define DISTMAP 2 #define DISTMAP 2
// r_main.defs end // // r_main.defs end //
// r_plane.defs begin // // r_plane.defs begin //
//#define MAXVISPLANES 128 //#define MAXVISPLANES 128
#define MAXVISPLANES 384 #define MAXVISPLANES 384
#define MAXOPENINGS SCREENWIDTH*64 #define MAXOPENINGS SCREENWIDTH*64
// r_plane.defs end // // r_plane.defs end //
// r_segs.defs begin // // r_segs.defs begin //
#define HEIGHTBITS 12 #define HEIGHTBITS 12
#define HEIGHTUNIT (1<<HEIGHTBITS) #define HEIGHTUNIT (1<<HEIGHTBITS)
// r_segs.defs end // // r_segs.defs end //
// r_things.defs begin // // r_things.defs begin //
#define MINZ (FRACUNIT*4) #define MINZ (FRACUNIT*4)
#define BASEYCENTER 100 #define BASEYCENTER 100
// r_things.defs end // // r_things.defs end //
// st_stuff.defs begin // // st_stuff.defs begin //
#define STARTREDPALS 1 #define STARTREDPALS 1
#define STARTBONUSPALS 9 #define STARTBONUSPALS 9
#define NUMREDPALS 8 #define NUMREDPALS 8
@ -301,10 +301,10 @@ If you have questions concerning this license or the applicable additional terms
#define ST_OUCHCOUNT (1*TICRATE) #define ST_OUCHCOUNT (1*TICRATE)
#define ST_RAMPAGEDELAY (2*TICRATE) #define ST_RAMPAGEDELAY (2*TICRATE)
#define ST_MUCHPAIN 20 #define ST_MUCHPAIN 20
#define ST_AMMOWIDTH 3 #define ST_AMMOWIDTH 3
#define ST_AMMOX 44 #define ST_AMMOX 44
#define ST_AMMOY 171 #define ST_AMMOY 171
#define ST_HEALTHWIDTH 3 #define ST_HEALTHWIDTH 3
#define ST_HEALTHX 90 #define ST_HEALTHX 90
#define ST_HEALTHY 171 #define ST_HEALTHY 171
#define ST_ARMSX 111 #define ST_ARMSX 111
@ -314,7 +314,7 @@ If you have questions concerning this license or the applicable additional terms
#define ST_ARMSXSPACE 12 #define ST_ARMSXSPACE 12
#define ST_ARMSYSPACE 10 #define ST_ARMSYSPACE 10
#define ST_FRAGSX 138 #define ST_FRAGSX 138
#define ST_FRAGSY 171 #define ST_FRAGSY 171
#define ST_FRAGSWIDTH 2 #define ST_FRAGSWIDTH 2
#define ST_ARMORWIDTH 3 #define ST_ARMORWIDTH 3
#define ST_ARMORX 221 #define ST_ARMORX 221
@ -355,19 +355,19 @@ If you have questions concerning this license or the applicable additional terms
#define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH #define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH
#define ST_MAXAMMO3X 314 #define ST_MAXAMMO3X 314
#define ST_MAXAMMO3Y 185 #define ST_MAXAMMO3Y 185
#define ST_WEAPON0X 110 #define ST_WEAPON0X 110
#define ST_WEAPON0Y 172 #define ST_WEAPON0Y 172
#define ST_WEAPON1X 122 #define ST_WEAPON1X 122
#define ST_WEAPON1Y 172 #define ST_WEAPON1Y 172
#define ST_WEAPON2X 134 #define ST_WEAPON2X 134
#define ST_WEAPON2Y 172 #define ST_WEAPON2Y 172
#define ST_WEAPON3X 110 #define ST_WEAPON3X 110
#define ST_WEAPON3Y 181 #define ST_WEAPON3Y 181
#define ST_WEAPON4X 122 #define ST_WEAPON4X 122
#define ST_WEAPON4Y 181 #define ST_WEAPON4Y 181
#define ST_WEAPON5X 134 #define ST_WEAPON5X 134
#define ST_WEAPON5Y 181 #define ST_WEAPON5Y 181
#define ST_WPNSX 109 #define ST_WPNSX 109
#define ST_WPNSY 191 #define ST_WPNSY 191
#define ST_DETHX 109 #define ST_DETHX 109
#define ST_DETHY 191 #define ST_DETHY 191
@ -377,7 +377,7 @@ If you have questions concerning this license or the applicable additional terms
#define ST_MSGHEIGHT 1 #define ST_MSGHEIGHT 1
#define ST_OUTTEXTX 0 #define ST_OUTTEXTX 0
#define ST_OUTTEXTY 6 #define ST_OUTTEXTY 6
#define ST_OUTWIDTH 52 #define ST_OUTWIDTH 52
#define ST_OUTHEIGHT 1 #define ST_OUTHEIGHT 1
#define ST_MAPWIDTH \ #define ST_MAPWIDTH \
(strlen(mapnames[(::g->gameepisode-1)*9+(::g->gamemap-1)])) (strlen(mapnames[(::g->gameepisode-1)*9+(::g->gamemap-1)]))
@ -385,8 +385,8 @@ If you have questions concerning this license or the applicable additional terms
(SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH) (SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH)
#define ST_MAPTITLEY 0 #define ST_MAPTITLEY 0
#define ST_MAPHEIGHT 1 #define ST_MAPHEIGHT 1
// st_stuff.defs end // // st_stuff.defs end //
// s_sound.defs begin // // s_sound.defs begin //
#define S_MAX_VOLUME 127 #define S_MAX_VOLUME 127
#define S_CLIPPING_DIST (1200*0x10000) #define S_CLIPPING_DIST (1200*0x10000)
#define S_CLOSE_DIST (160*0x10000) #define S_CLOSE_DIST (160*0x10000)
@ -400,8 +400,8 @@ If you have questions concerning this license or the applicable additional terms
#define S_IFRACVOL 30 #define S_IFRACVOL 30
#define NA 0 #define NA 0
#define S_NUMCHANNELS 256 #define S_NUMCHANNELS 256
// s_sound.defs end // // s_sound.defs end //
// wi_stuff.defs begin // // wi_stuff.defs begin //
#define NUMEPISODES 4 #define NUMEPISODES 4
#define NUMMAPS 9 #define NUMMAPS 9
#define WI_TITLEY 2 #define WI_TITLEY 2
@ -425,18 +425,18 @@ If you have questions concerning this license or the applicable additional terms
#define SP_KILLS 0 #define SP_KILLS 0
#define SP_ITEMS 2 #define SP_ITEMS 2
#define SP_SECRET 4 #define SP_SECRET 4
#define SP_FRAGS 6 #define SP_FRAGS 6
#define SP_TIME 8 #define SP_TIME 8
#define SP_PAR ST_TIME #define SP_PAR ST_TIME
#define SP_PAUSE 1 #define SP_PAUSE 1
#define SHOWNEXTLOCDELAY 4 #define SHOWNEXTLOCDELAY 4
// wi_stuff.defs end // // wi_stuff.defs end //
// w_wad.defs begin // // w_wad.defs begin //
// w_wad.defs end // // w_wad.defs end //
// z_zone.defs begin // // z_zone.defs begin //
#define ZONEID 0x1d4a11 #define ZONEID 0x1d4a11
#define NUM_ZONES 11 #define NUM_ZONES 11
#define MINFRAGMENT 64 #define MINFRAGMENT 64
#define NO_SHARE_LUMPS #define NO_SHARE_LUMPS
// z_zone.defs end // // z_zone.defs end //

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -47,25 +47,25 @@ If you have questions concerning this license or the applicable additional terms
// to provide a complete scene geometry description. // to provide a complete scene geometry description.
enum enum
{ {
ML_LABEL, // A separator, name, ExMx or MAPxx ML_LABEL, // A separator, name, ExMx or MAPxx
ML_THINGS, // Monsters, items.. ML_THINGS, // Monsters, items..
ML_LINEDEFS, // LineDefs, from editing ML_LINEDEFS, // LineDefs, from editing
ML_SIDEDEFS, // SideDefs, from editing ML_SIDEDEFS, // SideDefs, from editing
ML_VERTEXES, // Vertices, edited and BSP splits generated ML_VERTEXES, // Vertices, edited and BSP splits generated
ML_SEGS, // LineSegs, from LineDefs split by BSP ML_SEGS, // LineSegs, from LineDefs split by BSP
ML_SSECTORS, // SubSectors, list of LineSegs ML_SSECTORS, // SubSectors, list of LineSegs
ML_NODES, // BSP nodes ML_NODES, // BSP nodes
ML_SECTORS, // Sectors, from editing ML_SECTORS, // Sectors, from editing
ML_REJECT, // LUT, sector-sector visibility ML_REJECT, // LUT, sector-sector visibility
ML_BLOCKMAP // LUT, motion clipping, walls/grid element ML_BLOCKMAP // LUT, motion clipping, walls/grid element
}; };
// A single Vertex. // A single Vertex.
typedef struct typedef struct
{ {
short x; short x;
short y; short y;
} mapvertex_t; } mapvertex_t;
@ -73,13 +73,13 @@ typedef struct
// by setting textures and offsets. // by setting textures and offsets.
typedef struct typedef struct
{ {
short textureoffset; short textureoffset;
short rowoffset; short rowoffset;
char toptexture[8]; char toptexture[8];
char bottomtexture[8]; char bottomtexture[8];
char midtexture[8]; char midtexture[8];
// Front sector, towards viewer. // Front sector, towards viewer.
short sector; short sector;
} mapsidedef_t; } mapsidedef_t;
@ -88,13 +88,13 @@ typedef struct
// to the BSP builder. // to the BSP builder.
typedef struct typedef struct
{ {
short v1; short v1;
short v2; short v2;
short flags; short flags;
short special; short special;
short tag; short tag;
// sidenum[1] will be -1 if one sided // sidenum[1] will be -1 if one sided
short sidenum[2]; short sidenum[2];
} maplinedef_t; } maplinedef_t;
@ -125,7 +125,7 @@ typedef struct
#define ML_DONTPEGTOP 8 #define ML_DONTPEGTOP 8
// lower texture unpegged // lower texture unpegged
#define ML_DONTPEGBOTTOM 16 #define ML_DONTPEGBOTTOM 16
// In AutoMap: don't map as two sided: IT'S A SECRET! // In AutoMap: don't map as two sided: IT'S A SECRET!
#define ML_SECRET 32 #define ML_SECRET 32
@ -145,21 +145,21 @@ typedef struct
// Sector definition, from editing. // Sector definition, from editing.
typedef struct typedef struct
{ {
short floorheight; short floorheight;
short ceilingheight; short ceilingheight;
char floorpic[8]; char floorpic[8];
char ceilingpic[8]; char ceilingpic[8];
short lightlevel; short lightlevel;
short special; short special;
short tag; short tag;
} mapsector_t; } mapsector_t;
// SubSector, as generated by BSP. // SubSector, as generated by BSP.
typedef struct typedef struct
{ {
short numsegs; short numsegs;
// Index of first one, segs are stored sequentially. // Index of first one, segs are stored sequentially.
short firstseg; short firstseg;
} mapsubsector_t; } mapsubsector_t;
@ -167,12 +167,12 @@ typedef struct
// using partition lines selected by BSP builder. // using partition lines selected by BSP builder.
typedef struct typedef struct
{ {
short v1; short v1;
short v2; short v2;
short angle; short angle;
short linedef; short linedef;
short side; short side;
short offset; short offset;
} mapseg_t; } mapseg_t;
@ -184,19 +184,19 @@ typedef struct
typedef struct typedef struct
{ {
// Partition line from (x,y) to x+dx,y+dy) // Partition line from (x,y) to x+dx,y+dy)
short x; short x;
short y; short y;
short dx; short dx;
short dy; short dy;
// Bounding box for each child, // Bounding box for each child,
// clip against view frustum. // clip against view frustum.
short bbox[2][4]; short bbox[2][4];
// If NF_SUBSECTOR its a subsector, // If NF_SUBSECTOR its a subsector,
// else it's a node of another subtree. // else it's a node of another subtree.
unsigned short children[2]; unsigned short children[2];
} mapnode_t; } mapnode_t;
@ -207,11 +207,11 @@ typedef struct
// plus skill/visibility flags and attributes. // plus skill/visibility flags and attributes.
typedef struct typedef struct
{ {
short x; short x;
short y; short y;
short angle; short angle;
short type; short type;
short options; short options;
} mapthing_t; } mapthing_t;

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -29,7 +29,7 @@ If you have questions concerning this license or the applicable additional terms
#include "Precompiled.h" #include "Precompiled.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "doomdef.h" #pragma implementation "doomdef.h"
#endif #endif
#include "doomdef.h" #include "doomdef.h"

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -45,27 +45,27 @@ enum { VERSION = 111 };
// to handle IWAD dependend animations etc. // to handle IWAD dependend animations etc.
typedef enum typedef enum
{ {
shareware, // DOOM 1 shareware, E1, M9 shareware, // DOOM 1 shareware, E1, M9
registered, // DOOM 1 registered, E3, M27 registered, // DOOM 1 registered, E3, M27
commercial, // DOOM 2 retail, E1 M34 commercial, // DOOM 2 retail, E1 M34
// DOOM 2 german edition not handled // DOOM 2 german edition not handled
retail, // DOOM 1 retail, E4, M36 retail, // DOOM 1 retail, E4, M36
indetermined // Well, no IWAD found. indetermined // Well, no IWAD found.
} GameMode_t; } GameMode_t;
// Mission packs - might be useful for TC stuff? // Mission packs - might be useful for TC stuff?
typedef enum typedef enum
{ {
doom, // DOOM 1 doom, // DOOM 1
doom2, // DOOM 2 doom2, // DOOM 2
pack_tnt, // TNT mission pack pack_tnt, // TNT mission pack
pack_plut, // Plutonia pack pack_plut, // Plutonia pack
pack_master, // Master levels pack_master, // Master levels
pack_nerve, // Nerve levels pack_nerve, // Nerve levels
none none
} GameMission_t; } GameMission_t;
@ -73,9 +73,9 @@ typedef enum
// Identify language to use, software localization. // Identify language to use, software localization.
typedef enum typedef enum
{ {
english, english,
german, german,
unknown unknown
} Language_t; } Language_t;
@ -83,7 +83,7 @@ typedef enum
// If rangecheck is undefined, // If rangecheck is undefined,
// most parameter validation debugging code will not be compiled // most parameter validation debugging code will not be compiled
#ifdef _DEBUG #ifdef _DEBUG
#define RANGECHECK #define RANGECHECK
#endif #endif
// Do or do not use external soundserver. // Do or do not use external soundserver.
@ -92,7 +92,7 @@ typedef enum
// The integrated sound support is experimental, // The integrated sound support is experimental,
// and unfinished. Default is synchronous. // and unfinished. Default is synchronous.
// Experimental asynchronous timer based is // Experimental asynchronous timer based is
// handled by SNDINTR. // handled by SNDINTR.
#define SNDSERV 1 #define SNDSERV 1
//#define SNDINTR 1 //#define SNDINTR 1
@ -135,13 +135,13 @@ typedef enum
// The current state of the game: whether we are // The current state of the game: whether we are
// playing, gazing at the intermission screen, // playing, gazing at the intermission screen,
// the game final animation, or a demo. // the game final animation, or a demo.
typedef enum typedef enum
{ {
GS_LEVEL, GS_LEVEL,
GS_INTERMISSION, GS_INTERMISSION,
GS_FINALE, GS_FINALE,
GS_DEMOSCREEN GS_DEMOSCREEN
} gamestate_t; } gamestate_t;
// //
@ -158,11 +158,11 @@ typedef enum
typedef enum typedef enum
{ {
sk_baby, sk_baby,
sk_easy, sk_easy,
sk_medium, sk_medium,
sk_hard, sk_hard,
sk_nightmare sk_nightmare
} skill_t; } skill_t;
@ -173,15 +173,15 @@ typedef enum
// //
typedef enum typedef enum
{ {
it_bluecard, it_bluecard,
it_yellowcard, it_yellowcard,
it_redcard, it_redcard,
it_blueskull, it_blueskull,
it_yellowskull, it_yellowskull,
it_redskull, it_redskull,
NUMCARDS NUMCARDS
} card_t; } card_t;
@ -191,20 +191,20 @@ typedef enum
// user has not changed weapon. // user has not changed weapon.
typedef enum typedef enum
{ {
wp_fist, wp_fist,
wp_pistol, wp_pistol,
wp_shotgun, wp_shotgun,
wp_chaingun, wp_chaingun,
wp_missile, wp_missile,
wp_plasma, wp_plasma,
wp_bfg, wp_bfg,
wp_chainsaw, wp_chainsaw,
wp_supershotgun, wp_supershotgun,
NUMWEAPONS, NUMWEAPONS,
// No pending weapon change. // No pending weapon change.
wp_nochange wp_nochange
} weapontype_t; } weapontype_t;
@ -212,12 +212,12 @@ typedef enum
// Ammunition types defined. // Ammunition types defined.
typedef enum typedef enum
{ {
am_clip, // Pistol / chaingun ammo. am_clip, // Pistol / chaingun ammo.
am_shell, // Shotgun / double barreled shotgun. am_shell, // Shotgun / double barreled shotgun.
am_cell, // Plasma rifle, BFG. am_cell, // Plasma rifle, BFG.
am_misl, // Missile launcher. am_misl, // Missile launcher.
NUMAMMO, NUMAMMO,
am_noammo // Unlimited for chainsaw / fist. am_noammo // Unlimited for chainsaw / fist.
} ammotype_t; } ammotype_t;
@ -225,14 +225,14 @@ typedef enum
// Power up artifacts. // Power up artifacts.
typedef enum typedef enum
{ {
pw_invulnerability, pw_invulnerability,
pw_strength, pw_strength,
pw_invisibility, pw_invisibility,
pw_ironfeet, pw_ironfeet,
pw_allmap, pw_allmap,
pw_infrared, pw_infrared,
NUMPOWERS NUMPOWERS
} powertype_t; } powertype_t;
@ -244,11 +244,11 @@ typedef enum
// //
typedef enum typedef enum
{ {
INVULNTICS = (30*TICRATE), INVULNTICS = ( 30 * TICRATE ),
INVISTICS = (60*TICRATE), INVISTICS = ( 60 * TICRATE ),
INFRATICS = (120*TICRATE), INFRATICS = ( 120 * TICRATE ),
IRONTICS = (60*TICRATE) IRONTICS = ( 60 * TICRATE )
} powerduration_t; } powerduration_t;
@ -338,7 +338,7 @@ typedef enum
#ifndef _WIN32 #ifndef _WIN32
#define MAX_PATH 260 #define MAX_PATH 260
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -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,105 +76,123 @@ 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;
} }
// Start up DooM Classic // Start up DooM Classic
for ( i = 0; i < numplayers; ++i) for( i = 0; i < numplayers; ++i )
{ {
DoomLib::SetPlayer(i); DoomLib::SetPlayer( i );
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 { }
DoomLib::InitGame(localdargc, (char **)dargv[i] ); else
{
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;
::g->menuactive = 0; ::g->menuactive = 0;
} }
DoomLib::SetPlayer(-1); DoomLib::SetPlayer( -1 );
} }
} }
bool DoomInterface::Frame( int iTime, idUserCmdMgr * userCmdMgr ) 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;
DoomLib::SetPlayer( 0 ); DoomLib::SetPlayer( 0 );
DoomLib::PollNetwork(); DoomLib::PollNetwork();
for (i = 0; i < numplayers; ++i) for( i = 0; i < numplayers; ++i )
{ {
DoomLib::SetPlayer( i ); DoomLib::SetPlayer( i );
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.
Sys_Yield(); Sys_Yield();
} }
} }
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;
} }
} }
DoomLib::SetPlayer(-1); DoomLib::SetPlayer( -1 );
} }
DoomLib::SetPlayer( 0 ); DoomLib::SetPlayer( 0 );
@ -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();
} }
@ -232,8 +260,8 @@ void DoomInterface::QuitCurrentGame() {
lastTicRun = 0; lastTicRun = 0;
//if ( !gameLocal->IsSplitscreen() ) { //if ( !gameLocal->IsSplitscreen() ) {
// Start background demos // Start background demos
D_StartTitle(); D_StartTitle();
//} //}
} }
@ -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();
} }
@ -263,41 +294,48 @@ 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];
} }
mpArgc[localPlayerIndex] = playerCount+5;
strcpy(mpArgV[localPlayerIndex][0], "doomlauncher"); mpArgc[localPlayerIndex] = playerCount + 5;
strcpy(mpArgV[localPlayerIndex][1], "-dup");
strcpy(mpArgV[localPlayerIndex][2], "1"); strcpy( mpArgV[localPlayerIndex][0], "doomlauncher" );
strcpy(mpArgV[localPlayerIndex][3], "-net"); strcpy( mpArgV[localPlayerIndex][1], "-dup" );
strcpy( mpArgV[localPlayerIndex][2], "1" );
sprintf(mpArgV[localPlayerIndex][4], "%d", localPlayer); strcpy( mpArgV[localPlayerIndex][3], "-net" );
strcpy(mpArgV[localPlayerIndex][5], playerAddresses[localPlayer].c_str());
sprintf( mpArgV[localPlayerIndex][4], "%d", localPlayer );
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) { {
strcpy(mpArgV[localPlayerIndex][currentArg], playerAddresses[i].c_str()); if( i != localPlayer )
{
strcpy( mpArgV[localPlayerIndex][currentArg], playerAddresses[i].c_str() );
currentArg++; currentArg++;
} }
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -39,13 +39,13 @@ class idUserCmdMgr;
class DoomInterface class DoomInterface
{ {
public: public:
DoomInterface(); DoomInterface();
virtual ~DoomInterface(); virtual ~DoomInterface();
typedef int ( *NoParamCallback)(); typedef int ( *NoParamCallback )();
void Startup( int players, bool multiplayer = false ); void Startup( int players, bool multiplayer = false );
bool Frame( int time, idUserCmdMgr * userCmdMgr ); bool Frame( int time, idUserCmdMgr* userCmdMgr );
void Shutdown(); void Shutdown();
void QuitCurrentGame(); void QuitCurrentGame();
void EndDMGame(); void EndDMGame();
@ -60,7 +60,7 @@ public:
static int CurrentPlayer(); static int CurrentPlayer();
void SetMultiplayerPlayers(int localPlayerIndex, int playerCount, int localPlayer, std::vector<std::string> playerAddresses ); void SetMultiplayerPlayers( int localPlayerIndex, int playerCount, int localPlayer, std::vector<std::string> playerAddresses );
protected: protected:
int numplayers; int numplayers;
@ -71,4 +71,4 @@ protected:
}; };
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -50,184 +50,219 @@ bool globalPauseTime = false;
int PLAYERCOUNT = 1; int PLAYERCOUNT = 1;
#ifdef _DEBUG #ifdef _DEBUG
bool debugOutput = true; bool debugOutput = true;
#else #else
bool debugOutput = false; bool debugOutput = false;
#endif #endif
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", {
"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", "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",
"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", "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",
"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" "E3M1: Hell Keep", "E3M2: Slough of Despair", "E3M3: Pandemonium", "E3M4: House of Pain", "E3M5: Unholy Cathedral", "E3M6: MT. Erebus", "E3M7: Gate to Limbo", "E3M8: DIS", "E3M9: Warrens",
}; "E4M1: Hell Beneath", "E4M2: Perfect Hatred", "E4M3: Sever The Wicked", "E4M4: Unruly Evil", "E4M5: They Will Repent", "E4M6: Against Thee Wickedly", "E4M7: And Hell Followed", "E4M8: Unto The Cruel", "E4M9: Fear"
};
static const char * Doom2_MapNames[] = { static const char* Doom2_MapNames[] =
"1: Entryway", "2: Underhalls", "3: The Gantlet", "4: The Focus", "5: The Waste Tunnels", "6: The Crusher", "7: Dead Simple", "8: Tricks and Traps", "9: The Pit", "10: Refueling Base", {
"11: Circle of Death", "12: The Factory", "13: Downtown", "14: The Inmost Dens", "15: Industrial Zone", "16: Suburbs", "17: Tenements", "18: The Courtyard", "19: The Citadel", "20: Gotcha!", "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",
"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", "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!",
"30: Icon of Sin", "31: IDKFA", "32: Keen" "21: Nirvana", "22: The Catacombs", "23: Barrels O' Fun", "24: The Chasm", "25: Bloodfalls", "26: The Abandoned Mines", "27: Monster Condo", "28: The Spirit World", "29: The Living End",
}; "30: Icon of Sin", "31: IDKFA", "32: Keen"
};
static const char * TNT_MapNames[] = { static const char* TNT_MapNames[] =
"1: System Control", "2: Human BBQ", "3: Power Control", "4: Wormhole", "5: Hangar", "6: Open Season", "7: Prison", "8: Metal", "9: Stronghold", "10: Redemption", "11: Storage Facility", {
"12: Crater", "13: Nukage Processing", "14: Steel Works", "15: Dead Zone", "16: Deepest Reaches", "17: Processing Area", "18: Mill", "19: Shipping & Respawning", "20: Central Processing", "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",
"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" "12: Crater", "13: Nukage Processing", "14: Steel Works", "15: Dead Zone", "16: Deepest Reaches", "17: Processing Area", "18: Mill", "19: Shipping & Respawning", "20: Central Processing",
}; "21: Administration Center", "22: Habitat", "23: Lunar Mining Project", "24: Quarry", "25: Baron's Den", "26: Ballistyx", "27: Mount Pain", "28: Heck", "29: River Styx", "30: Last Call", "31: Pharaoh", "32: Caribbean"
};
static const char * Plut_MapNames[] = { static const char* Plut_MapNames[] =
"1: Congo", "2: Well of Souls", "3: Aztec", "4: Caged", "5: Ghost Town", "6: Baron's Lair", "7: Caughtyard", "8: Realm", "9: Abattoire", "10: Onslaught", "11: Hunted", "12: Speed", "13: The Crypt", "14: Genesis", {
"15: The Twilight", "16: The Omen", "17: Compound", "18: Neurosphere", "19: NME", "20: The Death Domain", "21: Slayer", "22: Impossible Mission", "23: Tombstone", "24: The Final Frontier", "25: The Temple of Darkness", "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",
"26: Bunker", "27: Anti-Christ", "28: The Sewers", "29: Odyssey of Noises", "30: The Gateway of Hell", "31: Cyberden", "32: Go 2 It" "15: The Twilight", "16: The Omen", "17: Compound", "18: Neurosphere", "19: NME", "20: The Death Domain", "21: Slayer", "22: Impossible Mission", "23: Tombstone", "24: The Final Frontier", "25: The Temple of Darkness",
}; "26: Bunker", "27: Anti-Christ", "28: The Sewers", "29: Odyssey of Noises", "30: The Gateway of Hell", "31: Cyberden", "32: Go 2 It"
};
static const char * Mast_MapNames[] = { static const char* Mast_MapNames[] =
"1: Attack", "2: Canyon","3: The Catwalk", "4: The Combine", "5: The Fistula", "6: The Garrison", "7: Titan Manor", "8: Paradox", "9: Subspace", "10: Subterra", "11: Trapped On Titan", "12: Virgil's Lead", "13: Minos' Judgement", {
"14: Bloodsea Keep", "15: Mephisto's Maosoleum", "16: Nessus", "17: Geryon", "18: Vesperas", "19: Black Tower", "20: The Express Elevator To Hell", "21: Bad Dream" "1: Attack", "2: Canyon", "3: The Catwalk", "4: The Combine", "5: The Fistula", "6: The Garrison", "7: Titan Manor", "8: Paradox", "9: Subspace", "10: Subterra", "11: Trapped On Titan", "12: Virgil's Lead", "13: Minos' Judgement",
}; "14: Bloodsea Keep", "15: Mephisto's Maosoleum", "16: Nessus", "17: Geryon", "18: Vesperas", "19: Black Tower", "20: The Express Elevator To Hell", "21: Bad Dream"
};
static const char * Nerve_MapNames[] = { static const char* Nerve_MapNames[] =
"1: The Earth Base", "2: The Pain Labs", "3: Canyon of the Dead", "4: Hell Mountain", "5: Vivisection", "6: Inferno of Blood", "7: Baron's Banquet", "8: Tomb of Malevolence", "9: March of Demons" {
}; "1: The Earth Base", "2: The Pain Labs", "3: Canyon of the Dead", "4: Hell Mountain", "5: Vivisection", "6: Inferno of Blood", "7: Baron's Banquet", "8: Tomb of Malevolence", "9: March of Demons"
};
const ExpansionData App_Expansion_Data_Local[] = { const ExpansionData App_Expansion_Data_Local[] =
{ ExpansionData::IWAD, retail, doom, "DOOM", DOOMWADDIR"DOOM.WAD", NULL, "base/textures/DOOMICON.PNG" , Doom_MapNames }, {
{ ExpansionData::IWAD, commercial, doom2, "DOOM 2", DOOMWADDIR"DOOM2.WAD", NULL, "base/textures/DOOM2ICON.PNG" , Doom2_MapNames }, { ExpansionData::IWAD, retail, doom, "DOOM", DOOMWADDIR"DOOM.WAD", NULL, "base/textures/DOOMICON.PNG" , Doom_MapNames },
{ ExpansionData::IWAD, commercial, pack_tnt, "FINAL DOOM: TNT EVILUTION", DOOMWADDIR"TNT.WAD", NULL, "base/textures/TNTICON.PNG" , TNT_MapNames }, { ExpansionData::IWAD, commercial, doom2, "DOOM 2", DOOMWADDIR"DOOM2.WAD", NULL, "base/textures/DOOM2ICON.PNG" , Doom2_MapNames },
{ ExpansionData::IWAD, commercial, pack_plut, "FINAL DOOM: PLUTONIA EXPERIMENT", DOOMWADDIR"PLUTONIA.WAD", NULL, "base/textures/PLUTICON.PNG" , Plut_MapNames }, { ExpansionData::IWAD, commercial, pack_tnt, "FINAL DOOM: TNT EVILUTION", DOOMWADDIR"TNT.WAD", NULL, "base/textures/TNTICON.PNG" , TNT_MapNames },
{ ExpansionData::PWAD, commercial, pack_master, "DOOM 2: MASTER LEVELS", DOOMWADDIR"DOOM2.WAD", DOOMWADDIR"MASTERLEVELS.WAD", "base/textures/MASTICON.PNG" , Mast_MapNames }, { ExpansionData::IWAD, commercial, pack_plut, "FINAL DOOM: PLUTONIA EXPERIMENT", DOOMWADDIR"PLUTONIA.WAD", NULL, "base/textures/PLUTICON.PNG" , Plut_MapNames },
{ ExpansionData::PWAD, commercial, pack_nerve, "DOOM 2: NO REST FOR THE LIVING", DOOMWADDIR"DOOM2.WAD", DOOMWADDIR"NERVE.WAD", "base/textures/NERVEICON.PNG" , Nerve_MapNames }, { ExpansionData::PWAD, commercial, pack_master, "DOOM 2: MASTER LEVELS", DOOMWADDIR"DOOM2.WAD", DOOMWADDIR"MASTERLEVELS.WAD", "base/textures/MASTICON.PNG" , Mast_MapNames },
}; { ExpansionData::PWAD, commercial, pack_nerve, "DOOM 2: NO REST FOR THE LIVING", DOOMWADDIR"DOOM2.WAD", DOOMWADDIR"NERVE.WAD", "base/textures/NERVEICON.PNG" , Nerve_MapNames },
};
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 )
{
expansionDirty = true;
expansionSelected = expansion;
}
void SetIdealExpansion( int expansion )
{
idealExpansion = expansion;
}
idStr currentMapName;
idStr currentDifficulty;
void SetCurrentMapName( idStr name )
{
currentMapName = name;
}
const idStr& GetCurrentMapName()
{
return currentMapName;
}
void SetCurrentDifficulty( idStr name )
{
currentDifficulty = name;
}
const idStr& GetCurrentDifficulty()
{
return currentDifficulty;
}
int currentplayer = -1;
Globals* globaldata[4];
//RecvFunc Recv;
//SendFunc Send;
//SendRemoteFunc SendRemote;
bool Active = true;
DoomInterface Interface;
int idealExpansion = 0;
int expansionSelected = 0;
bool expansionDirty = true;
bool skipToLoad = false;
char loadGamePath[MAX_PATH];
bool skipToNew = false;
int chosenSkill = 0;
int chosenEpisode = 1;
idMatchParameters matchParms;
void* ( *Z_Malloc )( int size, int tag, void* user ) = NULL;
void ( *Z_FreeTag )( int lowtag );
idArray< idSysMutex, 4 > playerScreenMutexes;
void ExitGame()
{
// TODO: If we ever support splitscreen and online,
// we'll have to call D_QuitNetGame for all local players.
DoomLib::SetPlayer( 0 );
D_QuitNetGame();
session->QuitMatch();
}
void ShowXToContinue( bool activate )
{
}
/*
========================
DoomLib::GetGameSKU
========================
*/
gameSKU_t GetGameSKU()
{
if( common->GetCurrentGame() == DOOM_CLASSIC )
{
return GAME_SKU_DOOM1_BFG;
}
else if( common->GetCurrentGame() == DOOM2_CLASSIC )
{
return GAME_SKU_DOOM2_BFG;
} }
void SetCurrentExpansion( int expansion ) { assert( false && "Invalid basepath" );
expansionDirty = true; return GAME_SKU_DCC;
expansionSelected = expansion; }
/*
========================
DoomLib::ActivateGame
========================
*/
void ActivateGame()
{
Active = true;
// Turn off menu toggler
int originalPlayer = DoomLib::GetPlayer();
for( int i = 0; i < Interface.GetNumPlayers(); i++ )
{
DoomLib::SetPlayer( i );
::g->menuactive = false;
} }
void SetIdealExpansion( int expansion ) { globalPauseTime = false;
idealExpansion = expansion;
} DoomLib::SetPlayer( originalPlayer );
}
idStr currentMapName;
idStr currentDifficulty; /*
========================
void SetCurrentMapName( idStr name ) { currentMapName = name; } DoomLib::HandleEndMatch
const idStr & GetCurrentMapName() { return currentMapName; } ========================
void SetCurrentDifficulty( idStr name ) { currentDifficulty = name; } */
const idStr & GetCurrentDifficulty() { return currentDifficulty; } void HandleEndMatch()
{
int currentplayer = -1; if( session->GetGameLobbyBase().IsHost() )
{
Globals *globaldata[4]; ShowXToContinue( false );
session->EndMatch();
//RecvFunc Recv;
//SendFunc Send;
//SendRemoteFunc SendRemote;
bool Active = true;
DoomInterface Interface;
int idealExpansion = 0;
int expansionSelected = 0;
bool expansionDirty = true;
bool skipToLoad = false;
char loadGamePath[MAX_PATH];
bool skipToNew = false;
int chosenSkill = 0;
int chosenEpisode = 1;
idMatchParameters matchParms;
void * (*Z_Malloc)( int size, int tag, void* user ) = NULL;
void (*Z_FreeTag)(int lowtag );
idArray< idSysMutex, 4 > playerScreenMutexes;
void ExitGame() {
// TODO: If we ever support splitscreen and online,
// we'll have to call D_QuitNetGame for all local players.
DoomLib::SetPlayer( 0 );
D_QuitNetGame();
session->QuitMatch();
}
void ShowXToContinue( bool activate ) {
}
/*
========================
DoomLib::GetGameSKU
========================
*/
gameSKU_t GetGameSKU() {
if ( common->GetCurrentGame() == DOOM_CLASSIC ) {
return GAME_SKU_DOOM1_BFG;
} else if ( common->GetCurrentGame() == DOOM2_CLASSIC ) {
return GAME_SKU_DOOM2_BFG;
}
assert( false && "Invalid basepath" );
return GAME_SKU_DCC;
}
/*
========================
DoomLib::ActivateGame
========================
*/
void ActivateGame() {
Active = true;
// Turn off menu toggler
int originalPlayer = DoomLib::GetPlayer();
for ( int i = 0; i < Interface.GetNumPlayers(); i++ ) {
DoomLib::SetPlayer(i);
::g->menuactive = false;
}
globalPauseTime = false;
DoomLib::SetPlayer( originalPlayer );
}
/*
========================
DoomLib::HandleEndMatch
========================
*/
void HandleEndMatch() {
if ( session->GetGameLobbyBase().IsHost() ) {
ShowXToContinue( false );
session->EndMatch();
}
} }
}
}; };
@ -242,28 +277,32 @@ extern void I_ShutdownGraphics();
extern void I_ProcessSoundEvents(); 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 );
memset( globaldata[currentplayer], 0, sizeof(Globals) ); memset( globaldata[currentplayer], 0, sizeof( Globals ) );
g = globaldata[currentplayer]; g = globaldata[currentplayer];
g->InitGlobals(); g->InitGlobals();
} }
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 ) );
classicRemap[K_JOY3] = KEY_TAB ; classicRemap[K_JOY3] = KEY_TAB ;
classicRemap[K_JOY4] = K_MINUS; classicRemap[K_JOY4] = K_MINUS;
classicRemap[K_JOY2] = K_EQUALS; classicRemap[K_JOY2] = K_EQUALS;
classicRemap[K_JOY9] = K_ESCAPE ; classicRemap[K_JOY9] = K_ESCAPE ;
@ -274,23 +313,28 @@ void DoomLib::InitControlRemap() {
classicRemap[K_JOY_STICK1_LEFT] = K_LEFTARROW ; classicRemap[K_JOY_STICK1_LEFT] = K_LEFTARROW ;
classicRemap[K_JOY_DPAD_LEFT] = K_LEFTARROW ; classicRemap[K_JOY_DPAD_LEFT] = K_LEFTARROW ;
classicRemap[K_JOY_STICK1_RIGHT] = K_RIGHTARROW ; classicRemap[K_JOY_STICK1_RIGHT] = K_RIGHTARROW ;
classicRemap[K_JOY_DPAD_RIGHT] = K_RIGHTARROW ; classicRemap[K_JOY_DPAD_RIGHT] = K_RIGHTARROW ;
classicRemap[K_JOY1] = K_ENTER; classicRemap[K_JOY1] = K_ENTER;
} }
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;
} }
return (keyNum_t)classicRemap[ key ]; return ( keyNum_t )classicRemap[ key ];
} }
} }
@ -301,7 +345,7 @@ void DoomLib::InitGame( int argc, char** argv )
::g->myargv = argv; ::g->myargv = argv;
InitControlRemap(); InitControlRemap();
D_DoomMain(); D_DoomMain();
@ -312,8 +356,8 @@ bool DoomLib::Poll()
return D_DoomMainPoll(); return D_DoomMainPoll();
} }
bool TryRunTics( idUserCmdMgr * userCmdMgr ); bool TryRunTics( idUserCmdMgr* userCmdMgr );
bool DoomLib::Tic( idUserCmdMgr * userCmdMgr ) bool DoomLib::Tic( idUserCmdMgr* userCmdMgr )
{ {
return TryRunTics( userCmdMgr ); return TryRunTics( userCmdMgr );
} }
@ -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 );
@ -343,7 +388,7 @@ void DoomLib::Frame( int realoffset, int buffer )
void DoomLib::Draw() void DoomLib::Draw()
{ {
R_RenderPlayerView (&::g->players[::g->displayplayer]); R_RenderPlayerView( &::g->players[::g->displayplayer] );
} }
angle_t GetViewAngle() angle_t GetViewAngle()
@ -354,9 +399,9 @@ angle_t GetViewAngle()
void SetViewAngle( angle_t ang ) void SetViewAngle( angle_t ang )
{ {
g->viewangle = ang; g->viewangle = ang;
::g->viewxoffset = (finesine[g->viewangle>>ANGLETOFINESHIFT]*::g->realoffset) >> 8; ::g->viewxoffset = ( finesine[g->viewangle >> ANGLETOFINESHIFT]*::g->realoffset ) >> 8;
::g->viewyoffset = (finecosine[g->viewangle>>ANGLETOFINESHIFT]*::g->realoffset) >> 8; ::g->viewyoffset = ( finecosine[g->viewangle >> ANGLETOFINESHIFT]*::g->realoffset ) >> 8;
} }
@ -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,16 +453,19 @@ 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;
} }
g = globaldata[currentplayer]; g = globaldata[currentplayer];
} }
} }
@ -428,23 +479,25 @@ void DoomLib::SetNetworking( RecvFunc rf, SendFunc sf, SendRemoteFunc sendRemote
} }
#endif #endif
int DoomLib::GetPlayer() 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 );
return sourceDest; return sourceDest;
} }
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;
*source = PlayerIndexToRemoteNode( src ); *source = PlayerIndexToRemoteNode( src );
@ -453,16 +506,18 @@ 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
/* /*
int player = ::g->consoleplayer; int player = ::g->consoleplayer;
if (player == 2 && node == 2 ) { if (player == 2 && node == 2 ) {
@ -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;
@ -498,14 +555,17 @@ int DoomLib::PlayerIndexToRemoteNode( int index ) {
return indexMap[::g->consoleplayer][index]; return indexMap[::g->consoleplayer][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,15 +574,17 @@ 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));
} }
return; return;
@ -535,21 +597,24 @@ void DoomLib::PollNetwork() {
GetSourceDest( sw.sourceDest, &source, &dest ); GetSourceDest( sw.sourceDest, &source, &dest );
//Push the packet onto the network stack to be processed. //Push the packet onto the network stack to be processed.
DoomLib::Send( (char*)&sw, receivedSize, NULL, dest ); DoomLib::Send( ( char* )&sw, receivedSize, NULL, dest );
} }
} }
#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

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -60,10 +60,11 @@ struct rumble_t
bool waiting; bool waiting;
int left; int left;
int right; int right;
}; };
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,16 +76,17 @@ 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;
GameMission_t pack_type; GameMission_t pack_type;
const char * expansionName; const char* expansionName;
const char * iWadFilename; const char* iWadFilename;
const char * pWadFilename; const char* pWadFilename;
const char * saveImageFile; const char* saveImageFile;
const char ** mapNames; const char** mapNames;
}; };
@ -93,76 +95,76 @@ struct ExpansionData {
namespace DoomLib namespace DoomLib
{ {
//typedef int ( *RecvFunc)( char* buff, DWORD *numRecv ); //typedef int ( *RecvFunc)( char* buff, DWORD *numRecv );
//typedef int ( *SendFunc)( const char* buff, DWORD size, sockaddr_in *target, int toNode ); //typedef int ( *SendFunc)( const char* buff, DWORD size, sockaddr_in *target, int toNode );
//typedef int ( *SendRemoteFunc)(); //typedef int ( *SendRemoteFunc)();
void InitGlobals( void *ptr = NULL ); void InitGlobals( void* ptr = NULL );
void InitGame( int argc, char ** argv ); void InitGame( int argc, char** argv );
void InitControlRemap(); void InitControlRemap();
keyNum_t RemapControl( keyNum_t key ); keyNum_t RemapControl( keyNum_t key );
bool Poll(); bool Poll();
bool Tic( idUserCmdMgr * userCmdMgr ); bool Tic( idUserCmdMgr* userCmdMgr );
void Wipe(); void Wipe();
void Frame( int realoffset = 0, int buffer = 0 ); void Frame( int realoffset = 0, int buffer = 0 );
void Draw(); void Draw();
void Shutdown(); void Shutdown();
//void SetNetworking( RecvFunc rf, SendFunc sf, SendRemoteFunc sendRemote ); //void SetNetworking( RecvFunc rf, SendFunc sf, SendRemoteFunc sendRemote );
void SetPlayer( int id );
int GetPlayer();
byte BuildSourceDest( int toNode ); void SetPlayer( int id );
void GetSourceDest( byte sourceDest, int* source, int* dest ); int GetPlayer();
int RemoteNodeToPlayerIndex( int node ); byte BuildSourceDest( int toNode );
int PlayerIndexToRemoteNode( int index ); void GetSourceDest( byte sourceDest, int* source, int* dest );
void PollNetwork(); int RemoteNodeToPlayerIndex( int node );
void SendNetwork(); int PlayerIndexToRemoteNode( int index );
void *GetGlobalData( int player ); void PollNetwork();
void SendNetwork();
void RunSound(); void* GetGlobalData( int player );
//extern RecvFunc Recv; void RunSound();
//extern SendFunc Send;
//extern SendRemoteFunc SendRemote;
extern void* (*Z_Malloc)( int size, int tag, void* user ); //extern RecvFunc Recv;
extern void (*Z_FreeTag)(int lowtag ); //extern SendFunc Send;
//extern SendRemoteFunc SendRemote;
extern DoomInterface Interface; extern void* ( *Z_Malloc )( int size, int tag, void* user );
extern int idealExpansion; extern void ( *Z_FreeTag )( int lowtag );
extern int expansionSelected;
extern bool expansionDirty;
extern bool skipToLoad; extern DoomInterface Interface;
extern char loadGamePath[MAX_PATH]; extern int idealExpansion;
extern int expansionSelected;
extern bool expansionDirty;
extern bool skipToNew; extern bool skipToLoad;
extern int chosenSkill; extern char loadGamePath[MAX_PATH];
extern int chosenEpisode;
extern idMatchParameters matchParms; extern bool skipToNew;
extern int chosenSkill;
extern int chosenEpisode;
const ExpansionData * GetCurrentExpansion(); extern idMatchParameters matchParms;
void SetCurrentExpansion( int expansion );
void SetIdealExpansion( int expansion ); const ExpansionData* GetCurrentExpansion();
void SetCurrentExpansion( int expansion );
void SetCurrentMapName( idStr name ); void SetIdealExpansion( int expansion );
const idStr & GetCurrentMapName();
void SetCurrentDifficulty( idStr name ); void SetCurrentMapName( idStr name );
const idStr & GetCurrentDifficulty(); const idStr& GetCurrentMapName();
void SetCurrentDifficulty( idStr name );
const idStr& GetCurrentDifficulty();
void ActivateGame();
void ExitGame();
void ShowXToContinue( bool activate );
gameSKU_t GetGameSKU();
void HandleEndMatch();
void ActivateGame();
void ExitGame();
void ShowXToContinue( bool activate );
gameSKU_t GetGameSKU();
void HandleEndMatch();
}; };

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "doomstat.h" #pragma implementation "doomstat.h"
#endif #endif
#include "doomstat.h" #include "doomstat.h"

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -39,7 +39,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
@ -81,7 +81,7 @@ extern int startmap;
extern qboolean autostart; extern qboolean autostart;
// Selected by user. // Selected by user.
extern skill_t gameskill; extern skill_t gameskill;
extern int gameepisode; extern int gameepisode;
extern int gamemap; extern int gamemap;
@ -94,8 +94,8 @@ extern qboolean netgame;
// Flag: true only if started as net deathmatch. // Flag: true only if started as net deathmatch.
// An enum might handle altdeath/cooperative better. // An enum might handle altdeath/cooperative better.
extern qboolean deathmatch; extern qboolean deathmatch;
// ------------------------- // -------------------------
// Internal parameters for sound rendering. // Internal parameters for sound rendering.
// These have been taken from the DOS version, // These have been taken from the DOS version,
@ -149,7 +149,7 @@ extern int scaledviewwidth;
extern int viewangleoffset; extern int viewangleoffset;
// Player taking events, and displaying. // Player taking events, and displaying.
extern int consoleplayer; extern int consoleplayer;
extern int displayplayer; extern int displayplayer;
@ -177,7 +177,7 @@ extern qboolean usergame;
extern qboolean demoplayback; extern qboolean demoplayback;
// Quit after playing a demo from cmdline. // Quit after playing a demo from cmdline.
extern qboolean singledemo; extern qboolean singledemo;
@ -218,7 +218,7 @@ extern mapthing_t playerstarts[MAXPLAYERS];
// Intermission stats. // Intermission stats.
// Parameters for world map / intermission. // Parameters for world map / intermission.
extern wbstartstruct_t wminfo; extern wbstartstruct_t wminfo;
// LUT of ammunition limits for each kind. // LUT of ammunition limits for each kind.
@ -248,7 +248,7 @@ extern gamestate_t wipegamestate;
extern int mouseSensitivity; extern int mouseSensitivity;
//? //?
// debug flag to cancel adaptiveness // debug flag to cancel adaptiveness
extern qboolean singletics; extern qboolean singletics;
extern int bodyqueslot; extern int bodyqueslot;
@ -267,7 +267,7 @@ extern int skyflatnum;
extern doomcom_t doomcom; extern doomcom_t doomcom;
// This points inside doomcom. // This points inside doomcom.
extern doomdata_t* netbuffer; extern doomdata_t* netbuffer;
extern ticcmd_t localcmds[BACKUPTICS]; extern ticcmd_t localcmds[BACKUPTICS];

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -29,49 +29,49 @@ If you have questions concerning this license or the applicable additional terms
#include "Precompiled.h" #include "Precompiled.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "dstrings.h" #pragma implementation "dstrings.h"
#endif #endif
#include "dstrings.h" #include "dstrings.h"
#include "globaldata.h" #include "globaldata.h"
const char* endmsg[NUM_QUITMESSAGES+1]= const char* endmsg[NUM_QUITMESSAGES + 1] =
{ {
// DOOM1 // DOOM1
QUITMSG, QUITMSG,
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?" "are you sure you want to quit?"
// QuitDOOM II messages // QuitDOOM II messages
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?" "are you sure you want to quit?"
// FinalDOOM? // FinalDOOM?
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
"are you sure you want to quit?", "are you sure you want to quit?",
// Internal debug. Different style, too. // Internal debug. Different style, too.
"are you sure you want to quit?" "are you sure you want to quit?"
}; };

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -37,16 +37,16 @@ If you have questions concerning this license or the applicable additional terms
// //
// Called by main loop. // Called by main loop.
qboolean F_Responder (event_t* ev); qboolean F_Responder( event_t* ev );
// Called by main loop. // Called by main loop.
void F_Ticker (void); void F_Ticker( void );
// Called by main loop. // Called by main loop.
void F_Drawer (void); void F_Drawer( void );
void F_StartFinale (void); void F_StartFinale( void );

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -50,20 +50,22 @@ wipe_shittyColMajorXform
int width, int width,
int height ) int height )
{ {
int x; int x;
int y; int y;
short* dest; short* dest;
//dest = (short*) DoomLib::Z_Malloc(width*height*2, PU_STATIC, 0 ); //dest = (short*) DoomLib::Z_Malloc(width*height*2, PU_STATIC, 0 );
dest = new short[ width * height ]; dest = new short[ width * height ];
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 );
//Z_Free(dest); //Z_Free(dest);
delete[] dest; delete[] dest;
} }
@ -74,38 +76,43 @@ wipe_initMelt
int height, int height,
int ticks ) int ticks )
{ {
int i, r; int i, r;
// copy start screen to main screen
memcpy(::g->wipe_scr, ::g->wipe_scr_start, width*height);
// makes this wipe faster (in theory)
// to have stuff in column-major format
wipe_shittyColMajorXform((short*)::g->wipe_scr_start, width/2, height);
wipe_shittyColMajorXform((short*)::g->wipe_scr_end, width/2, height);
// setup initial column positions
// (::g->wipe_y<0 => not ready to scroll yet)
::g->wipe_y = (int *) DoomLib::Z_Malloc(width*sizeof(int), PU_STATIC, 0);
::g->wipe_y[0] = -(M_Random()%16); // copy start screen to main screen
memcpy( ::g->wipe_scr, ::g->wipe_scr_start, width * height );
for (i=1;i<width;i++) // makes this wipe faster (in theory)
// to have stuff in column-major format
wipe_shittyColMajorXform( ( short* )::g->wipe_scr_start, width / 2, height );
wipe_shittyColMajorXform( ( short* )::g->wipe_scr_end, width / 2, height );
// setup initial column positions
// (::g->wipe_y<0 => not ready to scroll yet)
::g->wipe_y = ( int* ) DoomLib::Z_Malloc( width * sizeof( int ), PU_STATIC, 0 );
::g->wipe_y[0] = -( M_Random() % 16 );
for( i = 1; i < width; i++ )
{ {
r = (M_Random()%3) - 1; r = ( M_Random() % 3 ) - 1;
::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;
@ -115,43 +122,47 @@ int wipe_doMelt( int width, int height, int ticks ) {
short* d; short* d;
qboolean done = true; qboolean done = true;
width/=2; width /= 2;
while (ticks--) while( 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];
idx = 0; idx = 0;
for (j=dy;j;j--) for( j = dy; j; j-- )
{ {
d[idx] = *(s++); d[idx] = *( s++ );
idx += width; idx += width;
} }
::g->wipe_y[i] += dy; ::g->wipe_y[i] += dy;
s = &((short *)::g->wipe_scr_start)[i*height]; s = &( ( short* )::g->wipe_scr_start )[i * height];
d = &((short *)::g->wipe_scr)[::g->wipe_y[i]*width+i]; d = &( ( short* )::g->wipe_scr )[::g->wipe_y[i] * width + i];
idx = 0; idx = 0;
for (j=height-::g->wipe_y[i];j;j--) for( j = height -::g->wipe_y[i]; j; j-- )
{ {
d[idx] = *(s++); d[idx] = *( s++ );
idx += width; idx += width;
} }
@ -169,9 +180,9 @@ wipe_exitMelt
int height, int height,
int ticks ) int ticks )
{ {
Z_Free(::g->wipe_y); Z_Free( ::g->wipe_y );
::g->wipe_y = NULL; ::g->wipe_y = NULL;
return 0; return 0;
} }
int int
@ -181,9 +192,9 @@ wipe_StartScreen
int width, int width,
int height ) int height )
{ {
::g->wipe_scr_start = ::g->screens[2]; ::g->wipe_scr_start = ::g->screens[2];
I_ReadScreen(::g->wipe_scr_start); I_ReadScreen( ::g->wipe_scr_start );
return 0; return 0;
} }
int int
@ -193,10 +204,10 @@ wipe_EndScreen
int width, int width,
int height ) int height )
{ {
::g->wipe_scr_end = ::g->screens[3]; ::g->wipe_scr_end = ::g->screens[3];
I_ReadScreen(::g->wipe_scr_end); I_ReadScreen( ::g->wipe_scr_end );
V_DrawBlock(x, y, 0, width, height, ::g->wipe_scr_start); // restore start scr. V_DrawBlock( x, y, 0, width, height, ::g->wipe_scr_start ); // restore start scr.
return 0; return 0;
} }
int int
@ -210,24 +221,24 @@ wipe_ScreenWipe
int rc; int rc;
// initial stuff // initial stuff
if (!::g->go) if( !::g->go )
{ {
::g->go = 1; ::g->go = 1;
::g->wipe_scr = ::g->screens[0]; ::g->wipe_scr = ::g->screens[0];
wipe_initMelt(width, height, ticks); wipe_initMelt( width, height, ticks );
} }
// do a piece of wipe-in // do a piece of wipe-in
V_MarkRect(0, 0, width, height); V_MarkRect( 0, 0, width, height );
rc = wipe_doMelt(width, height, ticks); rc = wipe_doMelt( width, height, ticks );
// final stuff // final stuff
if (rc) if( rc )
{ {
::g->go = 0; ::g->go = 0;
wipe_exitMelt(width, height, ticks); wipe_exitMelt( width, height, ticks );
} }
return !::g->go; return !::g->go;

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -37,44 +37,44 @@ If you have questions concerning this license or the applicable additional terms
// //
// GAME // GAME
// //
void G_DeathMatchSpawnPlayer (int playernum); void G_DeathMatchSpawnPlayer( int playernum );
void G_InitNew ( skill_t skill, int episode, int map ); void G_InitNew( skill_t skill, int episode, int map );
// Can be called by the startup code or M_Responder. // Can be called by the startup code or M_Responder.
// A normal game starts at map 1, // A normal game starts at map 1,
// but a warp test can start elsewhere // but a warp test can start elsewhere
void G_DeferedInitNew (skill_t skill, int episode, int map); void G_DeferedInitNew( skill_t skill, int episode, int map );
void G_DeferedPlayDemo (const char* demo); void G_DeferedPlayDemo( const char* demo );
// Can be called by the startup code or M_Responder, // Can be called by the startup code or M_Responder,
// calls P_SetupLevel or W_EnterWorld. // calls P_SetupLevel or W_EnterWorld.
void G_LoadGame (char* name); void G_LoadGame( char* name );
qboolean G_DoLoadGame (); qboolean G_DoLoadGame();
// Called by M_Responder. // Called by M_Responder.
void G_SaveGame (int slot, char* description); void G_SaveGame( int slot, char* description );
// Only called by startup code. // Only called by startup code.
void G_RecordDemo (char* name); void G_RecordDemo( char* name );
void G_BeginRecording (void); void G_BeginRecording( void );
void G_PlayDemo (char* name); void G_PlayDemo( char* name );
void G_TimeDemo (const char* name); void G_TimeDemo( const char* name );
qboolean G_CheckDemoStatus (void); qboolean G_CheckDemoStatus( void );
void G_ExitLevel (void); void G_ExitLevel( void );
void G_SecretExitLevel (void); void G_SecretExitLevel( void );
void G_WorldDone (void); void G_WorldDone( void );
void G_Ticker (void); void G_Ticker( void );
qboolean G_Responder (event_t* ev); qboolean G_Responder( event_t* ev );
void G_ScreenShot (void); void G_ScreenShot( void );
#define MAXDEMOSIZE 512 * 1024 #define MAXDEMOSIZE 512 * 1024
#define SAVEGAMESIZE 256 * 1024 + MAXDEMOSIZE #define SAVEGAMESIZE 256 * 1024 + MAXDEMOSIZE

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -34,63 +34,63 @@ If you have questions concerning this license or the applicable additional terms
// //
// PROTOTYPES // PROTOTYPES
// //
void M_NewGame(int choice); void M_NewGame( int choice );
void M_Episode(int choice); void M_Episode( int choice );
void M_Expansion(int choice); void M_Expansion( int choice );
void M_ChooseSkill(int choice); void M_ChooseSkill( int choice );
void M_LoadGame(int choice); void M_LoadGame( int choice );
void M_LoadExpansion(int choice); void M_LoadExpansion( int choice );
void M_SaveGame(int choice); void M_SaveGame( int choice );
void M_Options(int choice); void M_Options( int choice );
void M_EndGame(int choice); void M_EndGame( int choice );
void M_ReadThis(int choice); void M_ReadThis( int choice );
void M_ReadThis2(int choice); void M_ReadThis2( int choice );
void M_QuitDOOM(int choice); void M_QuitDOOM( int choice );
void M_ExitGame(int choice); void M_ExitGame( int choice );
void M_GameSelection(int choice); void M_GameSelection( int choice );
void M_CancelExit(int choice); void M_CancelExit( int choice );
void M_ChangeMessages(int choice); void M_ChangeMessages( int choice );
void M_ChangeGPad(int choice); void M_ChangeGPad( int choice );
void M_FullScreen(int choice); void M_FullScreen( int choice );
void M_ChangeSensitivity(int choice); void M_ChangeSensitivity( int choice );
void M_SfxVol(int choice); void M_SfxVol( int choice );
void M_MusicVol(int choice); void M_MusicVol( int choice );
void M_ChangeDetail(int choice); void M_ChangeDetail( int choice );
void M_SizeDisplay(int choice); void M_SizeDisplay( int choice );
void M_StartGame(int choice); void M_StartGame( int choice );
void M_Sound(int choice); void M_Sound( int choice );
void M_FinishReadThis(int choice); void M_FinishReadThis( int choice );
void M_LoadSelect(int choice); void M_LoadSelect( int choice );
void M_SaveSelect(int choice); void M_SaveSelect( int choice );
void M_ReadSaveStrings(void); void M_ReadSaveStrings( void );
void M_QuickSave(void); void M_QuickSave( void );
void M_QuickLoad(void); void M_QuickLoad( void );
void M_DrawMainMenu(void); void M_DrawMainMenu( void );
void M_DrawQuit(void); void M_DrawQuit( void );
void M_DrawReadThis1(void); void M_DrawReadThis1( void );
void M_DrawReadThis2(void); void M_DrawReadThis2( void );
void M_DrawNewGame(void); void M_DrawNewGame( void );
void M_DrawEpisode(void); void M_DrawEpisode( void );
void M_DrawOptions(void); void M_DrawOptions( void );
void M_DrawSound(void); void M_DrawSound( void );
void M_DrawLoad(void); void M_DrawLoad( void );
void M_DrawSave(void); void M_DrawSave( void );
void M_DrawSaveLoadBorder(int x,int y); void M_DrawSaveLoadBorder( int x, int y );
void M_SetupNextMenu(menu_t *menudef); void M_SetupNextMenu( menu_t* menudef );
void M_DrawThermo(int x,int y,int thermWidth,int thermDot); void M_DrawThermo( int x, int y, int thermWidth, int thermDot );
void M_DrawEmptyCell(menu_t *menu,int item); void M_DrawEmptyCell( menu_t* menu, int item );
void M_DrawSelCell(menu_t *menu,int item); void M_DrawSelCell( menu_t* menu, int item );
void M_WriteText(int x, int y, const char *string); void M_WriteText( int x, int y, const char* string );
int M_StringWidth(const char *string); int M_StringWidth( const char* string );
int M_StringHeight(const char *string); int M_StringHeight( const char* string );
void M_StartControlPanel(void); void M_StartControlPanel( void );
void M_StartMessage(const char *string,messageRoutine_t routine,qboolean input); void M_StartMessage( const char* string, messageRoutine_t routine, qboolean input );
void M_StopMessage(void); void M_StopMessage( void );
void M_ClearMenus (void); void M_ClearMenus( void );
extern const anim_t temp_epsd0animinfo[10]; extern const anim_t temp_epsd0animinfo[10];
extern const anim_t temp_epsd1animinfo[9]; extern const anim_t temp_epsd1animinfo[9];
@ -102,5 +102,5 @@ void Globals::InitGlobals()
#include "constructs.h" #include "constructs.h"
} }
Globals *g; Globals* g;

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -35,7 +35,7 @@ If you have questions concerning this license or the applicable additional terms
#include "m_fixed.h" #include "m_fixed.h"
#include "info.h" #include "info.h"
#include "sounds.h" #include "sounds.h"
#include "r_defs.h" #include "r_defs.h"
#include "z_zone.h" #include "z_zone.h"
#include "d_player.h" #include "d_player.h"
#include "m_cheat.h" #include "m_cheat.h"
@ -55,17 +55,18 @@ 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"
}; };
extern Globals *g; extern Globals* g;
#define GLOBAL( type, name ) type name #define GLOBAL( type, name ) type name
#define GLOBAL_ARRAY( type, name, count ) type name[count] #define GLOBAL_ARRAY( type, name, count ) type name[count]
extern void localCalculateAchievements(bool epComplete); extern void localCalculateAchievements( bool epComplete );
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -43,15 +43,15 @@ If you have questions concerning this license or the applicable additional terms
// qboolean : whether the screen is always erased // qboolean : whether the screen is always erased
void HUlib_init(void) void HUlib_init( void )
{ {
} }
void HUlib_clearTextLine(hu_textline_t* t) void HUlib_clearTextLine( hu_textline_t* t )
{ {
t->len = 0; t->len = 0;
t->l[0] = 0; t->l[0] = 0;
t->needsupdate = true; t->needsupdate = true;
} }
void void
@ -62,11 +62,11 @@ HUlib_initTextLine
patch_t** f, patch_t** f,
int sc ) int sc )
{ {
t->x = x; t->x = x;
t->y = y; t->y = y;
t->f = f; t->f = f;
t->sc = sc; t->sc = sc;
HUlib_clearTextLine(t); HUlib_clearTextLine( t );
} }
qboolean qboolean
@ -75,28 +75,33 @@ HUlib_addCharToTextLine
char ch ) char ch )
{ {
if (t->len == HU_MAXLINELENGTH) if( t->len == HU_MAXLINELENGTH )
return false; {
else return false;
{ }
t->l[t->len++] = ch; else
t->l[t->len] = 0; {
t->needsupdate = 4; t->l[t->len++] = ch;
return true; t->l[t->len] = 0;
} t->needsupdate = 4;
return true;
}
} }
qboolean HUlib_delCharFromTextLine(hu_textline_t* t) qboolean HUlib_delCharFromTextLine( hu_textline_t* t )
{ {
if (!t->len) return false; if( !t->len )
else {
{ return false;
t->l[--t->len] = 0; }
t->needsupdate = 4; else
return true; {
} t->l[--t->len] = 0;
t->needsupdate = 4;
return true;
}
} }
@ -106,73 +111,82 @@ HUlib_drawTextLine
qboolean drawcursor ) qboolean drawcursor )
{ {
int i; int i;
int w; int w;
int x; int x;
unsigned char c; unsigned char c;
// draw the new stuff // draw the new stuff
x = l->x; x = l->x;
for (i=0;i<l->len;i++) for( i = 0; i < l->len; i++ )
{
c = toupper(l->l[i]);
if (c != ' '
&& c >= l->sc
&& c <= '_')
{ {
w = SHORT(l->f[c - l->sc]->width); c = toupper( l->l[i] );
if (x+w > SCREENWIDTH) if( c != ' '
break; && c >= l->sc
V_DrawPatchDirect(x, l->y, FG, l->f[c - l->sc]); && c <= '_' )
x += w; {
w = SHORT( l->f[c - l->sc]->width );
if( x + w > SCREENWIDTH )
{
break;
}
V_DrawPatchDirect( x, l->y, FG, l->f[c - l->sc] );
x += w;
}
else
{
x += 4;
if( x >= SCREENWIDTH )
{
break;
}
}
} }
else
{
x += 4;
if (x >= SCREENWIDTH)
break;
}
}
// draw the cursor if requested // draw the cursor if requested
if (drawcursor if( drawcursor
&& x + SHORT(l->f['_' - l->sc]->width) <= SCREENWIDTH) && x + SHORT( l->f['_' - l->sc]->width ) <= SCREENWIDTH )
{ {
V_DrawPatchDirect(x, l->y, FG, l->f['_' - l->sc]); V_DrawPatchDirect( x, l->y, FG, l->f['_' - l->sc] );
} }
} }
// sorta called by HU_Erase and just better darn get things straight // sorta called by HU_Erase and just better darn get things straight
void HUlib_eraseTextLine(hu_textline_t* l) void HUlib_eraseTextLine( hu_textline_t* l )
{ {
int lh; int lh;
int y; int y;
int yoffset; int yoffset;
// Only erases when NOT in automap and the screen is reduced, // Only erases when NOT in automap and the screen is reduced,
// and the text must either need updating or refreshing // and the text must either need updating or refreshing
// (because of a recent change back from the automap) // (because of a recent change back from the automap)
if (!::g->automapactive && if( !::g->automapactive &&
::g->viewwindowx && l->needsupdate) ::g->viewwindowx && l->needsupdate )
{
lh = SHORT(l->f[0]->height) + 1;
for (y=l->y,yoffset=y*SCREENWIDTH ; y<l->y+lh ; y++,yoffset+=SCREENWIDTH)
{ {
if (y < ::g->viewwindowy || y >= ::g->viewwindowy + ::g->viewheight) lh = SHORT( l->f[0]->height ) + 1;
R_VideoErase(yoffset, SCREENWIDTH); // erase entire line for( y = l->y, yoffset = y * SCREENWIDTH ; y < l->y + lh ; y++, yoffset += SCREENWIDTH )
else {
{ if( y < ::g->viewwindowy || y >= ::g->viewwindowy + ::g->viewheight )
R_VideoErase(yoffset, ::g->viewwindowx); // erase left border {
R_VideoErase(yoffset + ::g->viewwindowx + ::g->viewwidth, ::g->viewwindowx); R_VideoErase( yoffset, SCREENWIDTH ); // erase entire line
// erase right border }
} else
{
R_VideoErase( yoffset, ::g->viewwindowx ); // erase left border
R_VideoErase( yoffset + ::g->viewwindowx + ::g->viewwidth, ::g->viewwindowx );
// erase right border
}
}
} }
}
::g->lastautomapactive = ::g->automapactive; ::g->lastautomapactive = ::g->automapactive;
if (l->needsupdate) l->needsupdate--; if( l->needsupdate )
{
l->needsupdate--;
}
} }
@ -187,32 +201,36 @@ HUlib_initSText
qboolean* on ) qboolean* on )
{ {
int i; int i;
s->h = h; s->h = h;
s->on = on; s->on = on;
s->laston = true; s->laston = true;
s->cl = 0; s->cl = 0;
for (i=0;i<h;i++) for( i = 0; i < h; i++ )
HUlib_initTextLine(&s->l[i], HUlib_initTextLine( &s->l[i],
x, y - i*(SHORT(font[0]->height)+1), x, y - i * ( SHORT( font[0]->height ) + 1 ),
font, startchar); font, startchar );
} }
void HUlib_addLineToSText(hu_stext_t* s) void HUlib_addLineToSText( hu_stext_t* s )
{ {
int i; int i;
// add a clear line // add a clear line
if (++s->cl == s->h) if( ++s->cl == s->h )
s->cl = 0; {
HUlib_clearTextLine(&s->l[s->cl]); s->cl = 0;
}
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;
}
} }
@ -222,50 +240,60 @@ HUlib_addMessageToSText
const char* prefix, const char* prefix,
const char* msg ) const char* msg )
{ {
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 )
{ {
int i, idx; int i, idx;
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]; }
// need a decision made here on whether to skip the draw l = &s->l[idx];
HUlib_drawTextLine(l, false); // no cursor, please
} // need a decision made here on whether to skip the draw
HUlib_drawTextLine( l, false ); // no cursor, please
}
} }
void HUlib_eraseSText(hu_stext_t* s) void HUlib_eraseSText( hu_stext_t* s )
{ {
int i; int i;
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; {
HUlib_eraseTextLine(&s->l[i]); s->l[i].needsupdate = 4;
} }
s->laston = *s->on; HUlib_eraseTextLine( &s->l[i] );
}
s->laston = *s->on;
} }
@ -278,31 +306,35 @@ HUlib_initIText
int startchar, int startchar,
qboolean* on ) qboolean* on )
{ {
it->lm = 0; // default left margin is start of text it->lm = 0; // default left margin is start of text
it->on = on; it->on = on;
it->laston = true; it->laston = true;
HUlib_initTextLine(&it->l, x, y, font, startchar); HUlib_initTextLine( &it->l, x, y, font, startchar );
} }
// The following deletion routines adhere to the left margin restriction // The following deletion routines adhere to the left margin restriction
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 )
{ {
it->lm = 0; it->lm = 0;
HUlib_clearTextLine(&it->l); HUlib_clearTextLine( &it->l );
} }
void void
@ -310,9 +342,11 @@ HUlib_addPrefixToIText
( hu_itext_t* it, ( hu_itext_t* it,
char* str ) char* str )
{ {
while (*str) while( *str )
HUlib_addCharToTextLine(&it->l, *(str++)); {
it->lm = it->l.len; HUlib_addCharToTextLine( &it->l, *( str++ ) );
}
it->lm = it->l.len;
} }
// wrapper function for handling general keyed input. // wrapper function for handling general keyed input.
@ -323,36 +357,44 @@ HUlib_keyInIText
unsigned char ch ) unsigned char ch )
{ {
if (ch >= ' ' && ch <= '_') if( ch >= ' ' && ch <= '_' )
HUlib_addCharToTextLine(&it->l, (char) ch); {
else HUlib_addCharToTextLine( &it->l, ( char ) ch );
if (ch == KEY_BACKSPACE) }
HUlib_delCharFromIText(it); else if( ch == KEY_BACKSPACE )
else {
if (ch != KEY_ENTER) HUlib_delCharFromIText( it );
return false; // did not eat key }
else if( ch != KEY_ENTER )
{
return false; // did not eat key
}
return true; // ate the key return true; // ate the key
} }
void HUlib_drawIText(hu_itext_t* it) 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; {
HUlib_drawTextLine(l, true); // draw the line w/ cursor return;
}
HUlib_drawTextLine( l, true ); // draw the line w/ cursor
} }
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; {
HUlib_eraseTextLine(&it->l); it->l.needsupdate = 4;
it->laston = *it->on; }
HUlib_eraseTextLine( &it->l );
it->laston = *it->on;
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -46,17 +46,17 @@ If you have questions concerning this license or the applicable additional terms
// (parent of Scrolling Text and Input Text widgets) // (parent of Scrolling Text and Input Text widgets)
typedef struct typedef struct
{ {
// left-justified position of scrolling text window // left-justified position of scrolling text window
int x; int x;
int y; int y;
patch_t** f; // font
int sc; // start character
char l[HU_MAXLINELENGTH+1]; // line of text
int len; // current line length
// whether this line needs to be udpated patch_t** f; // font
int needsupdate; int sc; // start character
char l[HU_MAXLINELENGTH + 1]; // line of text
int len; // current line length
// whether this line needs to be udpated
int needsupdate;
} hu_textline_t; } hu_textline_t;
@ -66,13 +66,13 @@ typedef struct
// (child of Text Line widget) // (child of Text Line widget)
typedef struct typedef struct
{ {
hu_textline_t l[HU_MAXLINES]; // text lines to draw hu_textline_t l[HU_MAXLINES]; // text lines to draw
int h; // height in lines int h; // height in lines
int cl; // current line number int cl; // current line number
// pointer to qboolean stating whether to update window // pointer to qboolean stating whether to update window
qboolean* on; qboolean* on;
qboolean laston; // last value of *->on. qboolean laston; // last value of *->on.
} hu_stext_t; } hu_stext_t;
@ -82,14 +82,14 @@ typedef struct
// (child of Text Line widget) // (child of Text Line widget)
typedef struct typedef struct
{ {
hu_textline_t l; // text line to input on hu_textline_t l; // text line to input on
// left margin past which I am not to delete characters // left margin past which I am not to delete characters
int lm; int lm;
// pointer to qboolean stating whether to update window // pointer to qboolean stating whether to update window
qboolean* on; qboolean* on;
qboolean laston; // last value of *->on; qboolean laston; // last value of *->on;
} hu_itext_t; } hu_itext_t;
@ -99,28 +99,28 @@ typedef struct
// //
// initializes heads-up widget library // initializes heads-up widget library
void HUlib_init(void); void HUlib_init( void );
// //
// textline code // textline code
// //
// clear a line of text // clear a line of text
void HUlib_clearTextLine(hu_textline_t *t); void HUlib_clearTextLine( hu_textline_t* t );
void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc); void HUlib_initTextLine( hu_textline_t* t, int x, int y, patch_t** f, int sc );
// returns success // returns success
qboolean HUlib_addCharToTextLine(hu_textline_t *t, char ch); qboolean HUlib_addCharToTextLine( hu_textline_t* t, char ch );
// returns success // returns success
qboolean HUlib_delCharFromTextLine(hu_textline_t *t); qboolean HUlib_delCharFromTextLine( hu_textline_t* t );
// draws tline // draws tline
void HUlib_drawTextLine(hu_textline_t *l, qboolean drawcursor); void HUlib_drawTextLine( hu_textline_t* l, qboolean drawcursor );
// erases text line // erases text line
void HUlib_eraseTextLine(hu_textline_t *l); void HUlib_eraseTextLine( hu_textline_t* l );
// //
@ -139,7 +139,7 @@ HUlib_initSText
qboolean* on ); qboolean* on );
// add a new line // add a new line
void HUlib_addLineToSText(hu_stext_t* s); void HUlib_addLineToSText( hu_stext_t* s );
// ? // ?
void void
@ -149,10 +149,10 @@ HUlib_addMessageToSText
const char* msg ); const char* msg );
// draws stext // draws stext
void HUlib_drawSText(hu_stext_t* s); void HUlib_drawSText( hu_stext_t* s );
// erases all stext lines // erases all stext lines
void HUlib_eraseSText(hu_stext_t* s); void HUlib_eraseSText( hu_stext_t* s );
// Input Text Line widget routines // Input Text Line widget routines
void void
@ -165,13 +165,13 @@ HUlib_initIText
qboolean* on ); qboolean* on );
// enforces left margin // enforces left margin
void HUlib_delCharFromIText(hu_itext_t* it); void HUlib_delCharFromIText( hu_itext_t* it );
// enforces left margin // enforces left margin
void HUlib_eraseLineFromIText(hu_itext_t* it); void HUlib_eraseLineFromIText( hu_itext_t* it );
// resets line and left margin // resets line and left margin
void HUlib_resetIText(hu_itext_t* it); void HUlib_resetIText( hu_itext_t* it );
// left of left-margin // left of left-margin
void void
@ -185,10 +185,10 @@ HUlib_keyInIText
( hu_itext_t* it, ( hu_itext_t* it,
unsigned char ch ); unsigned char ch );
void HUlib_drawIText(hu_itext_t* it); void HUlib_drawIText( hu_itext_t* it );
// erases all itext lines // erases all itext lines
void HUlib_eraseIText(hu_itext_t* it); void HUlib_eraseIText( hu_itext_t* it );
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -96,93 +96,93 @@ const char* mapnames[] =
{ {
HUSTR_E1M1, HUSTR_E1M1,
HUSTR_E1M2, HUSTR_E1M2,
HUSTR_E1M3, HUSTR_E1M3,
HUSTR_E1M4, HUSTR_E1M4,
HUSTR_E1M5, HUSTR_E1M5,
HUSTR_E1M6, HUSTR_E1M6,
HUSTR_E1M7, HUSTR_E1M7,
HUSTR_E1M8, HUSTR_E1M8,
HUSTR_E1M9, HUSTR_E1M9,
HUSTR_E2M1, HUSTR_E2M1,
HUSTR_E2M2, HUSTR_E2M2,
HUSTR_E2M3, HUSTR_E2M3,
HUSTR_E2M4, HUSTR_E2M4,
HUSTR_E2M5, HUSTR_E2M5,
HUSTR_E2M6, HUSTR_E2M6,
HUSTR_E2M7, HUSTR_E2M7,
HUSTR_E2M8, HUSTR_E2M8,
HUSTR_E2M9, HUSTR_E2M9,
HUSTR_E3M1, HUSTR_E3M1,
HUSTR_E3M2, HUSTR_E3M2,
HUSTR_E3M3, HUSTR_E3M3,
HUSTR_E3M4, HUSTR_E3M4,
HUSTR_E3M5, HUSTR_E3M5,
HUSTR_E3M6, HUSTR_E3M6,
HUSTR_E3M7, HUSTR_E3M7,
HUSTR_E3M8, HUSTR_E3M8,
HUSTR_E3M9, HUSTR_E3M9,
HUSTR_E4M1, HUSTR_E4M1,
HUSTR_E4M2, HUSTR_E4M2,
HUSTR_E4M3, HUSTR_E4M3,
HUSTR_E4M4, HUSTR_E4M4,
HUSTR_E4M5, HUSTR_E4M5,
HUSTR_E4M6, HUSTR_E4M6,
HUSTR_E4M7, HUSTR_E4M7,
HUSTR_E4M8, HUSTR_E4M8,
HUSTR_E4M9, HUSTR_E4M9,
"NEWLEVEL", "NEWLEVEL",
"NEWLEVEL", "NEWLEVEL",
"NEWLEVEL", "NEWLEVEL",
"NEWLEVEL", "NEWLEVEL",
"NEWLEVEL", "NEWLEVEL",
"NEWLEVEL", "NEWLEVEL",
"NEWLEVEL", "NEWLEVEL",
"NEWLEVEL", "NEWLEVEL",
"NEWLEVEL" "NEWLEVEL"
}; };
const char* mapnames2[] = const char* mapnames2[] =
{ {
HUSTR_1, HUSTR_1,
HUSTR_2, HUSTR_2,
HUSTR_3, HUSTR_3,
HUSTR_4, HUSTR_4,
HUSTR_5, HUSTR_5,
HUSTR_6, HUSTR_6,
HUSTR_7, HUSTR_7,
HUSTR_8, HUSTR_8,
HUSTR_9, HUSTR_9,
HUSTR_10, HUSTR_10,
HUSTR_11, HUSTR_11,
HUSTR_12, HUSTR_12,
HUSTR_13, HUSTR_13,
HUSTR_14, HUSTR_14,
HUSTR_15, HUSTR_15,
HUSTR_16, HUSTR_16,
HUSTR_17, HUSTR_17,
HUSTR_18, HUSTR_18,
HUSTR_19, HUSTR_19,
HUSTR_20, HUSTR_20,
HUSTR_21, HUSTR_21,
HUSTR_22, HUSTR_22,
HUSTR_23, HUSTR_23,
HUSTR_24, HUSTR_24,
HUSTR_25, HUSTR_25,
HUSTR_26, HUSTR_26,
HUSTR_27, HUSTR_27,
HUSTR_28, HUSTR_28,
HUSTR_29, HUSTR_29,
HUSTR_30, HUSTR_30,
HUSTR_31, HUSTR_31,
HUSTR_32, HUSTR_32,
HUSTR_33 HUSTR_33
}; };
@ -190,78 +190,78 @@ const char* mapnames2[] =
const char* mapnamesp[] = const char* mapnamesp[] =
{ {
PHUSTR_1, PHUSTR_1,
PHUSTR_2, PHUSTR_2,
PHUSTR_3, PHUSTR_3,
PHUSTR_4, PHUSTR_4,
PHUSTR_5, PHUSTR_5,
PHUSTR_6, PHUSTR_6,
PHUSTR_7, PHUSTR_7,
PHUSTR_8, PHUSTR_8,
PHUSTR_9, PHUSTR_9,
PHUSTR_10, PHUSTR_10,
PHUSTR_11, PHUSTR_11,
PHUSTR_12, PHUSTR_12,
PHUSTR_13, PHUSTR_13,
PHUSTR_14, PHUSTR_14,
PHUSTR_15, PHUSTR_15,
PHUSTR_16, PHUSTR_16,
PHUSTR_17, PHUSTR_17,
PHUSTR_18, PHUSTR_18,
PHUSTR_19, PHUSTR_19,
PHUSTR_20, PHUSTR_20,
PHUSTR_21, PHUSTR_21,
PHUSTR_22, PHUSTR_22,
PHUSTR_23, PHUSTR_23,
PHUSTR_24, PHUSTR_24,
PHUSTR_25, PHUSTR_25,
PHUSTR_26, PHUSTR_26,
PHUSTR_27, PHUSTR_27,
PHUSTR_28, PHUSTR_28,
PHUSTR_29, PHUSTR_29,
PHUSTR_30, PHUSTR_30,
PHUSTR_31, PHUSTR_31,
PHUSTR_32 PHUSTR_32
}; };
// TNT WAD map names. // TNT WAD map names.
const char *mapnamest[] = const char* mapnamest[] =
{ {
THUSTR_1, THUSTR_1,
THUSTR_2, THUSTR_2,
THUSTR_3, THUSTR_3,
THUSTR_4, THUSTR_4,
THUSTR_5, THUSTR_5,
THUSTR_6, THUSTR_6,
THUSTR_7, THUSTR_7,
THUSTR_8, THUSTR_8,
THUSTR_9, THUSTR_9,
THUSTR_10, THUSTR_10,
THUSTR_11, THUSTR_11,
THUSTR_12, THUSTR_12,
THUSTR_13, THUSTR_13,
THUSTR_14, THUSTR_14,
THUSTR_15, THUSTR_15,
THUSTR_16, THUSTR_16,
THUSTR_17, THUSTR_17,
THUSTR_18, THUSTR_18,
THUSTR_19, THUSTR_19,
THUSTR_20, THUSTR_20,
THUSTR_21, THUSTR_21,
THUSTR_22, THUSTR_22,
THUSTR_23, THUSTR_23,
THUSTR_24, THUSTR_24,
THUSTR_25, THUSTR_25,
THUSTR_26, THUSTR_26,
THUSTR_27, THUSTR_27,
THUSTR_28, THUSTR_28,
THUSTR_29, THUSTR_29,
THUSTR_30, THUSTR_30,
THUSTR_31, THUSTR_31,
THUSTR_32 THUSTR_32
}; };
@ -271,50 +271,50 @@ const char english_shiftxform[] =
{ {
0, 0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31, 31,
' ', '!', '"', '#', '$', '%', '&', ' ', '!', '"', '#', '$', '%', '&',
'"', // shift-' '"', // shift-'
'(', ')', '*', '+', '(', ')', '*', '+',
'<', // shift-, '<', // shift-,
'_', // shift-- '_', // shift--
'>', // shift-. '>', // shift-.
'?', // shift-/ '?', // shift-/
')', // shift-0 ')', // shift-0
'!', // shift-1 '!', // shift-1
'@', // shift-2 '@', // shift-2
'#', // shift-3 '#', // shift-3
'$', // shift-4 '$', // shift-4
'%', // shift-5 '%', // shift-5
'^', // shift-6 '^', // shift-6
'&', // shift-7 '&', // shift-7
'*', // shift-8 '*', // shift-8
'(', // shift-9 '(', // shift-9
':', ':',
':', // shift-; ':', // shift-;
'<', '<',
'+', // shift-= '+', // shift-=
'>', '?', '@', '>', '?', '@',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'[', // shift-[ '[', // shift-[
'!', // shift-backslash - OH MY GOD DOES WATCOM SUCK '!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
']', // shift-] ']', // shift-]
'"', '_', '"', '_',
'\'', // shift-` '\'', // shift-`
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'{', '|', '}', '~', 127 '{', '|', '}', '~', 127
}; };
char ForeignTranslation(unsigned char ch) char ForeignTranslation( unsigned char ch )
{ {
return ch; return ch;
} }
void HU_Init(void) void HU_Init( void )
{ {
int i; int i;
@ -326,27 +326,29 @@ void HU_Init(void)
// load the heads-up font // load the heads-up font
j = HU_FONTSTART; j = HU_FONTSTART;
for (i=0;i<HU_FONTSIZE;i++) for( i = 0; i < HU_FONTSIZE; i++ )
{ {
snprintf(buffer, buffer_len, "STCFN%03d", j++); snprintf( buffer, buffer_len, "STCFN%03d", j++ );
::g->hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC_SHARED); ::g->hu_font[i] = ( patch_t* ) W_CacheLumpName( buffer, PU_STATIC_SHARED );
} }
} }
void HU_Stop(void) void HU_Stop( void )
{ {
::g->headsupactive = false; ::g->headsupactive = false;
} }
void HU_Start(void) void HU_Start( void )
{ {
int i; int i;
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;
@ -355,94 +357,104 @@ void HU_Start(void)
::g->chat_on = false; ::g->chat_on = false;
// create the message widget // create the message widget
HUlib_initSText(&::g->w_message, HUlib_initSText( &::g->w_message,
HU_MSGX, HU_MSGY, HU_MSGHEIGHT, HU_MSGX, HU_MSGY, HU_MSGHEIGHT,
::g->hu_font, ::g->hu_font,
HU_FONTSTART, &::g->message_on); HU_FONTSTART, &::g->message_on );
// create the map title widget // create the map title widget
HUlib_initTextLine(&::g->w_title, HUlib_initTextLine( &::g->w_title,
HU_TITLEX, HU_TITLEY, HU_TITLEX, HU_TITLEY,
::g->hu_font, ::g->hu_font,
HU_FONTSTART); HU_FONTSTART );
switch ( ::g->gamemode ) switch( ::g->gamemode )
{ {
case shareware: case shareware:
case registered: case registered:
case retail: case retail:
s = HU_TITLE; s = HU_TITLE;
break; break;
case commercial: case commercial:
default: default:
if( DoomLib::expansionSelected == 5 ) { if( DoomLib::expansionSelected == 5 )
int map = ::g->gamemap; {
if( ::g->gamemap > 9 ) { int map = ::g->gamemap;
map = 0; if( ::g->gamemap > 9 )
} {
map = 0;
}
s = DoomLib::GetCurrentExpansion()->mapNames[ map - 1 ]; s = DoomLib::GetCurrentExpansion()->mapNames[ map - 1 ];
} else { }
s = DoomLib::GetCurrentExpansion()->mapNames[ ::g->gamemap - 1 ]; else
} {
s = DoomLib::GetCurrentExpansion()->mapNames[ ::g->gamemap - 1 ];
}
break; break;
} }
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,
HU_INPUTX, HU_INPUTY, HU_INPUTX, HU_INPUTY,
::g->hu_font, ::g->hu_font,
HU_FONTSTART, &::g->chat_on); HU_FONTSTART, &::g->chat_on );
// 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;
} }
void HU_Drawer(void) 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 );
}
} }
void HU_Erase(void) void HU_Erase( void )
{ {
HUlib_eraseSText(&::g->w_message); HUlib_eraseSText( &::g->w_message );
HUlib_eraseIText(&::g->w_chat); HUlib_eraseIText( &::g->w_chat );
HUlib_eraseTextLine(&::g->w_title); HUlib_eraseTextLine( &::g->w_title );
} }
void HU_Ticker(void) void HU_Ticker( void )
{ {
// tick down message counter if message is up // tick down message counter if message is up
if (::g->message_counter && !--::g->message_counter) if( ::g->message_counter && !--::g->message_counter )
{ {
::g->message_on = false; ::g->message_on = false;
::g->message_nottobefuckedwith = false; ::g->message_nottobefuckedwith = false;
} }
if ( ( m_inDemoMode.GetBool() == false && m_show_messages.GetBool() ) || ::g->message_dontfuckwithme) if( ( m_inDemoMode.GetBool() == false && m_show_messages.GetBool() ) || ::g->message_dontfuckwithme )
{ {
// display message if necessary // display message if necessary
if ((::g->plr->message && !::g->message_nottobefuckedwith) if( ( ::g->plr->message && !::g->message_nottobefuckedwith )
|| (::g->plr->message && ::g->message_dontfuckwithme)) || ( ::g->plr->message && ::g->message_dontfuckwithme ) )
{ {
HUlib_addMessageToSText(&::g->w_message, 0, ::g->plr->message); HUlib_addMessageToSText( &::g->w_message, 0, ::g->plr->message );
::g->plr->message = 0; ::g->plr->message = 0;
::g->message_on = true; ::g->message_on = true;
::g->message_counter = HU_MSGTIMEOUT; ::g->message_counter = HU_MSGTIMEOUT;
@ -456,27 +468,27 @@ void HU_Ticker(void)
void HU_queueChatChar(char c) void HU_queueChatChar( char c )
{ {
if (((::g->head + 1) & (QUEUESIZE-1)) == ::g->tail) if( ( ( ::g->head + 1 ) & ( QUEUESIZE - 1 ) ) == ::g->tail )
{ {
::g->plr->message = HUSTR_MSGU; ::g->plr->message = HUSTR_MSGU;
} }
else else
{ {
::g->chatchars[::g->head] = c; ::g->chatchars[::g->head] = c;
::g->head = (::g->head + 1) & (QUEUESIZE-1); ::g->head = ( ::g->head + 1 ) & ( QUEUESIZE - 1 );
} }
} }
char HU_dequeueChatChar(void) char HU_dequeueChatChar( void )
{ {
char c; char c;
if (::g->head != ::g->tail) if( ::g->head != ::g->tail )
{ {
c = ::g->chatchars[::g->tail]; c = ::g->chatchars[::g->tail];
::g->tail = (::g->tail + 1) & (QUEUESIZE-1); ::g->tail = ( ::g->tail + 1 ) & ( QUEUESIZE - 1 );
} }
else else
{ {
@ -486,7 +498,7 @@ char HU_dequeueChatChar(void)
return c; return c;
} }
qboolean HU_Responder(event_t *ev) qboolean HU_Responder( event_t* ev )
{ {
const char* macromessage; const char* macromessage;
@ -498,70 +510,84 @@ qboolean HU_Responder(event_t *ev)
const static char destination_keys[MAXPLAYERS] = const static char destination_keys[MAXPLAYERS] =
{ {
HUSTR_KEYGREEN, HUSTR_KEYGREEN,
HUSTR_KEYINDIGO, HUSTR_KEYINDIGO,
HUSTR_KEYBROWN, HUSTR_KEYBROWN,
HUSTR_KEYRED HUSTR_KEYRED
}; };
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 )
{ {
::g->shiftdown = ev->type == ev_keydown; ::g->shiftdown = ev->type == ev_keydown;
return false; return false;
} }
else if (ev->data1 == KEY_RALT || ev->data1 == KEY_LALT) else if( ev->data1 == KEY_RALT || ev->data1 == KEY_LALT )
{ {
::g->altdown = ev->type == ev_keydown; ::g->altdown = ev->type == ev_keydown;
return false; return false;
} }
if (ev->type != ev_keydown) if( ev->type != ev_keydown )
return false;
if (!::g->chat_on)
{ {
if (ev->data1 == HU_MSGREFRESH) return false;
}
if( !::g->chat_on )
{
if( ev->data1 == HU_MSGREFRESH )
{ {
::g->message_on = true; ::g->message_on = true;
::g->message_counter = HU_MSGTIMEOUT; ::g->message_counter = HU_MSGTIMEOUT;
eatkey = true; eatkey = true;
} }
else if (::g->netgame && ev->data1 == HU_INPUTTOGGLE) else if( ::g->netgame && ev->data1 == HU_INPUTTOGGLE )
{ {
eatkey = ::g->chat_on = true; eatkey = ::g->chat_on = true;
HUlib_resetIText(&::g->w_chat); HUlib_resetIText( &::g->w_chat );
HU_queueChatChar(HU_BROADCAST); HU_queueChatChar( HU_BROADCAST );
} }
else if (::g->netgame && numplayers > 2) else if( ::g->netgame && numplayers > 2 )
{ {
for (i=0; i<MAXPLAYERS ; i++) for( i = 0; i < MAXPLAYERS ; i++ )
{ {
if (ev->data1 == destination_keys[i]) if( ev->data1 == destination_keys[i] )
{ {
if (::g->playeringame[i] && i!=::g->consoleplayer) if( ::g->playeringame[i] && i !=::g->consoleplayer )
{ {
eatkey = ::g->chat_on = true; eatkey = ::g->chat_on = true;
HUlib_resetIText(&::g->w_chat); HUlib_resetIText( &::g->w_chat );
HU_queueChatChar(i+1); HU_queueChatChar( i + 1 );
break; break;
} }
else if (i == ::g->consoleplayer) else if( i == ::g->consoleplayer )
{ {
::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;
}
} }
} }
} }
@ -571,52 +597,60 @@ qboolean HU_Responder(event_t *ev)
{ {
c = ev->data1; c = ev->data1;
// send a macro // send a macro
if (::g->altdown) if( ::g->altdown )
{ {
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];
// kill last message with a '\n' // kill last message with a '\n'
HU_queueChatChar(KEY_ENTER); // DEBUG!!! HU_queueChatChar( KEY_ENTER ); // DEBUG!!!
// send the macro message // send the macro message
while (*macromessage) while( *macromessage )
HU_queueChatChar(*macromessage++); {
HU_queueChatChar(KEY_ENTER); HU_queueChatChar( *macromessage++ );
}
HU_queueChatChar( KEY_ENTER );
// leave chat mode and notify that it was sent // leave chat mode and notify that it was sent
::g->chat_on = false; ::g->chat_on = false;
strcpy(::g->lastmessage, temp_chat_macros[c]); strcpy( ::g->lastmessage, temp_chat_macros[c] );
::g->plr->message = ::g->lastmessage; ::g->plr->message = ::g->lastmessage;
eatkey = true; eatkey = true;
} }
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); }
if (eatkey) eatkey = HUlib_keyInIText( &::g->w_chat, c );
if( eatkey )
{ {
// static unsigned char buf[20]; // DEBUG // static unsigned char buf[20]; // DEBUG
HU_queueChatChar(c); HU_queueChatChar( c );
// sprintf(buf, "KEY: %d => %d", ev->data1, c); // sprintf(buf, "KEY: %d => %d", ev->data1, c);
// ::g->plr->message = buf; // ::g->plr->message = buf;
} }
if (c == KEY_ENTER) if( c == KEY_ENTER )
{ {
::g->chat_on = false; ::g->chat_on = false;
if (::g->w_chat.l.len) if( ::g->w_chat.l.len )
{ {
strcpy(::g->lastmessage, ::g->w_chat.l.l); strcpy( ::g->lastmessage, ::g->w_chat.l.l );
::g->plr->message = ::g->lastmessage; ::g->plr->message = ::g->lastmessage;
} }
} }
else if (c == KEY_ESCAPE) else if( c == KEY_ESCAPE )
{
::g->chat_on = false; ::g->chat_on = false;
}
} }
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -39,7 +39,7 @@ If you have questions concerning this license or the applicable additional terms
#define HU_FONTEND '_' // the last font characters #define HU_FONTEND '_' // the last font characters
// Calculate # of glyphs in font. // Calculate # of glyphs in font.
#define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1)
#define HU_BROADCAST 5 #define HU_BROADCAST 5
@ -55,15 +55,15 @@ If you have questions concerning this license or the applicable additional terms
// HEADS UP TEXT // HEADS UP TEXT
// //
void HU_Init(void); void HU_Init( void );
void HU_Start(void); void HU_Start( void );
qboolean HU_Responder(event_t* ev); qboolean HU_Responder( event_t* ev );
void HU_Ticker(void); void HU_Ticker( void );
void HU_Drawer(void); void HU_Drawer( void );
char HU_dequeueChatChar(void); char HU_dequeueChatChar( void );
void HU_Erase(void); void HU_Erase( void );
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -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;
} }
@ -90,39 +100,53 @@ static bool Cheat_GiveAll() {
::g->plyr->armortype = 2; ::g->plyr->armortype = 2;
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;
::g->plyr->armortype = 2; ::g->plyr->armortype = 2;
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;
@ -130,21 +154,30 @@ static bool Cheat_Choppers() {
return true; return true;
} }
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]) {
P_GivePower( ::g->plyr, i); if( !::g->plyr->powers[i] )
else if (i!=pw_strength) {
P_GivePower( ::g->plyr, i );
}
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;
} }
@ -201,20 +244,21 @@ static bool Cheat_GiveLight() {
#ifndef __PS3__ #ifndef __PS3__
static bool tracking = false; static bool tracking = false;
static int currentCode[NUM_BUTTONS]; static int currentCode[NUM_BUTTONS];
static int currentCheatLength; static int currentCheatLength;
#endif #endif
typedef bool(*cheat_command)(void); typedef bool( *cheat_command )( void );
struct cheatcode_t struct cheatcode_t
{ {
int code[NUM_BUTTONS]; int code[NUM_BUTTONS];
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
@ -228,10 +272,11 @@ static cheatcode_t codes[] = {
{ {3, 3, 3, 2}, Cheat_GiveLight}, // y y y x { {3, 3, 3, 2}, Cheat_GiveLight}, // y y y x
}; };
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,25 +284,32 @@ void BeginTrackingCheat() {
#endif #endif
} }
void EndTrackingCheat() { void EndTrackingCheat()
{
#if ALLOW_CHEATS #if ALLOW_CHEATS
tracking = false; tracking = false;
#endif #endif
} }
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()) { {
S_StartSound(0, sfx_cybsit); if( memcmp( &codes[i].code[0], &currentCode[0], sizeof( currentCode ) ) == 0 )
{
if( codes[i].function() )
{
S_StartSound( 0, sfx_cybsit );
} }
} }
} }
@ -278,55 +330,58 @@ float xbox_deadzone = 0.28f;
void I_InitInput(void) void I_InitInput( void )
{ {
} }
void I_ShutdownInput() void I_ShutdownInput()
{ {
} }
static float _joyAxisConvert(short x, float xbxScale, float dScale, float deadZone) static float _joyAxisConvert( short x, float xbxScale, float dScale, float deadZone )
{ {
//const float signConverted = x - 127; //const float signConverted = x - 127;
float y = x - 127; float y = x - 127;
y = y / xbxScale; y = y / xbxScale;
return (fabs(y) < deadZone) ? 0.f : (y * dScale); return ( fabs( y ) < deadZone ) ? 0.f : ( y * dScale );
} }
int I_PollMouseInputEvents( controller_t *con) int I_PollMouseInputEvents( controller_t* con )
{ {
int numEvents = 0; int numEvents = 0;
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: {
switch (::g->mouseEvents[n].action) case IETAxis:
{ switch( ::g->mouseEvents[n].action )
case M_DELTAX: {
e->data2 = ::g->mouseEvents[n].data; case M_DELTAX:
break; e->data2 = ::g->mouseEvents[n].data;
case M_DELTAY: break;
e->data3 = ::g->mouseEvents[n].data; case M_DELTAY:
break; e->data3 = ::g->mouseEvents[n].data;
} break;
return 1; }
return 1;
default: default:
break; break;
} }
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;
@ -335,137 +390,153 @@ int I_PollJoystickInputEvents( controller_t *con ) {
// //
// Translates the key currently in X_event // Translates the key currently in X_event
// //
static int xlatekey(int key) static int xlatekey( int key )
{ {
int rc = KEY_F1; int rc = KEY_F1;
switch (key) switch( key )
{ {
case 0: // A case 0: // A
//rc = KEY_ENTER;
rc = ' ';
break;
case 3: // Y
rc = '1';
break;
case 1: // B
if( ::g->menuactive ) {
rc = KEY_BACKSPACE;
}
else {
rc = '2';
}
break;
case 2: // X
//rc = ' ';
rc = KEY_TAB;
break;
case 4: // White
rc = KEY_MINUS;
break;
case 5: // Black
rc = KEY_EQUALS;
break;
case 6: // Left triggers
rc = KEY_RSHIFT;
break;
case 7: // Right
rc = KEY_RCTRL;
break;
case 8: // Up
if( ::g->menuactive ) {
rc = KEY_UPARROW;
}
else {
//rc = KEY_ENTER; //rc = KEY_ENTER;
rc = '3'; rc = ' ';
} break;
break; case 3: // Y
case 9: rc = '1';
if( ::g->menuactive ) { break;
rc = KEY_DOWNARROW; case 1: // B
} if( ::g->menuactive )
else { {
//rc = KEY_TAB; rc = KEY_BACKSPACE;
rc = '5'; }
} else
break; {
case 10: rc = '2';
if( ::g->menuactive ) { }
rc = KEY_UPARROW; break;
} case 2: // X
else { //rc = ' ';
//rc = '1'; rc = KEY_TAB;
rc = '6'; break;
} case 4: // White
break; rc = KEY_MINUS;
case 11: break;
if( ::g->menuactive ) { case 5: // Black
rc = KEY_DOWNARROW; rc = KEY_EQUALS;
} break;
else { case 6: // Left triggers
//rc = '2'; rc = KEY_RSHIFT;
rc = '4'; break;
} case 7: // Right
break; rc = KEY_RCTRL;
case 12: // start break;
rc = KEY_ESCAPE; case 8: // Up
break; if( ::g->menuactive )
case 13: //select {
//rc = KEY_ESCAPE; rc = KEY_UPARROW;
break; }
case 14: // lclick else
case 15: // rclick {
//rc = ' '; //rc = KEY_ENTER;
break; rc = '3';
}
break;
case 9:
if( ::g->menuactive )
{
rc = KEY_DOWNARROW;
}
else
{
//rc = KEY_TAB;
rc = '5';
}
break;
case 10:
if( ::g->menuactive )
{
rc = KEY_UPARROW;
}
else
{
//rc = '1';
rc = '6';
}
break;
case 11:
if( ::g->menuactive )
{
rc = KEY_DOWNARROW;
}
else
{
//rc = '2';
rc = '4';
}
break;
case 12: // start
rc = KEY_ESCAPE;
break;
case 13: //select
//rc = KEY_ESCAPE;
break;
case 14: // lclick
case 15: // rclick
//rc = ' ';
break;
} }
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;
switch(::g->joyEvents[n].type) switch( ::g->joyEvents[n].type )
{ {
case IETAxis: case IETAxis:
e->type = ev_joystick;//ev_mouse; e->type = ev_joystick;//ev_mouse;
switch (::g->joyEvents[n].action) switch( ::g->joyEvents[n].action )
{ {
case J_DELTAX: case J_DELTAX:
/* /*
if (::g->joyEvents[n].data < 0) if (::g->joyEvents[n].data < 0)
e->data2 = -1; e->data2 = -1;
else if (::g->joyEvents[n].data > 0) else if (::g->joyEvents[n].data > 0)
e->data2 = 1; e->data2 = 1;
*/ */
e->data2 = ::g->joyEvents[n].data; e->data2 = ::g->joyEvents[n].data;
break; break;
case J_DELTAY: case J_DELTAY:
e->type = ev_mouse; e->type = ev_mouse;
e->data3 = ::g->joyEvents[n].data; e->data3 = ::g->joyEvents[n].data;
break; break;
} }
return 1; return 1;
case IETButtonAnalog: case IETButtonAnalog:
case IETButtonDigital: case IETButtonDigital:
if (::g->joyEvents[n].data) if( ::g->joyEvents[n].data )
e->type = ev_keydown; {
else e->type = ev_keydown;
e->type = ev_keyup; }
e->data1 = xlatekey(::g->joyEvents[n].action); else
return 1; {
e->type = ev_keyup;
}
e->data1 = xlatekey( ::g->joyEvents[n].action );
return 1;
case IETNone: case IETNone:
break; break;
} }
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++ )
{ {
::g->joyEvents[i].type = IETNone; ::g->joyEvents[i].type = IETNone;
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -43,7 +43,7 @@ If you have questions concerning this license or the applicable additional terms
#include "doomstat.h" #include "doomstat.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "i_net.h" #pragma implementation "i_net.h"
#endif #endif
#include "i_net.h" #include "i_net.h"
@ -54,6 +54,6 @@ If you have questions concerning this license or the applicable additional terms
// For some odd reason... // For some odd reason...
void NetSend (void); void NetSend( void );
qboolean NetListen (void); qboolean NetListen( void );

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
@ -39,8 +39,8 @@ If you have questions concerning this license or the applicable additional terms
// Called by D_DoomMain. // Called by D_DoomMain.
void I_InitNetwork (void); void I_InitNetwork( void );
void I_NetCmd (void); void I_NetCmd( void );
// DHM - Nerve // DHM - Nerve
void I_ShutdownNetwork(); void I_ShutdownNetwork();

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -48,33 +48,36 @@ If you have questions concerning this license or the applicable additional terms
#include "doomlib.h" #include "doomlib.h"
void NetSend (void); void NetSend( void );
qboolean NetListen (void); qboolean NetListen( void );
namespace { namespace
bool IsValidSocket( int socketDescriptor ); {
int GetLastSocketError(); bool IsValidSocket( int socketDescriptor );
int GetLastSocketError();
/* /*
======================== ========================
Returns true if the socket is valid. I made this function to help abstract the differences Returns true if the socket is valid. I made this function to help abstract the differences
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;
}
/* /*
======================== ========================
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,19 +86,20 @@ 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;
} }
void (*netget) (void); void ( *netget )( void );
void (*netsend) (void); void ( *netsend )( void );
// //
// UDPsocket // UDPsocket
// //
int UDPsocket (void) int UDPsocket( void )
{ {
//int s; //int s;
@ -122,7 +126,7 @@ void BindToLocalPort( int s, int port )
// //
// PacketSend // PacketSend
// //
void PacketSend (void) void PacketSend( void )
{ {
} }
@ -131,12 +135,12 @@ void PacketSend (void)
// //
// PacketGet // PacketGet
// //
void PacketGet (void) void PacketGet( void )
{ {
} }
static int I_TrySetupNetwork(void) static int I_TrySetupNetwork( void )
{ {
// DHM - Moved to Session // DHM - Moved to Session
return 1; return 1;
@ -145,7 +149,7 @@ static int I_TrySetupNetwork(void)
// //
// I_InitNetwork // I_InitNetwork
// //
void I_InitNetwork (void) void I_InitNetwork( void )
{ {
//qboolean trueval = true; //qboolean trueval = true;
int i; int i;
@ -153,37 +157,47 @@ void I_InitNetwork (void)
//int a = 0; //int a = 0;
// struct hostent* hostentry; // host information entry // struct hostent* hostentry; // host information entry
memset (&::g->doomcom, 0, sizeof(::g->doomcom) ); memset( &::g->doomcom, 0, sizeof( ::g->doomcom ) );
// set up for network // set up for network
i = M_CheckParm ("-dup"); i = M_CheckParm( "-dup" );
if (i && i< ::g->myargc-1) if( i && i < ::g->myargc - 1 )
{ {
::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;
if (M_CheckParm ("-extratic"))
::g->doomcom.extratics = 1;
else
::g->doomcom.extratics = 0;
p = M_CheckParm ("-port");
if (p && p < ::g->myargc-1)
{ {
DOOMPORT = atoi (::g->myargv[p+1]); ::g->doomcom.ticdup = 1;
I_Printf ("using alternate port %i\n",DOOMPORT); }
if( M_CheckParm( "-extratic" ) )
{
::g->doomcom.extratics = 1;
}
else
{
::g->doomcom.extratics = 0;
}
p = M_CheckParm( "-port" );
if( p && p < ::g->myargc - 1 )
{
DOOMPORT = atoi( ::g->myargv[p + 1] );
I_Printf( "using alternate port %i\n", DOOMPORT );
} }
// parse network game options, // parse network game options,
// -net <::g->consoleplayer> <host> <host> ... // -net <::g->consoleplayer> <host> <host> ...
i = M_CheckParm ("-net"); i = M_CheckParm( "-net" );
if (!i || !I_TrySetupNetwork()) if( !i || !I_TrySetupNetwork() )
{ {
// single player game // single player game
::g->netgame = false; ::g->netgame = false;
@ -207,30 +221,34 @@ void I_InitNetwork (void)
// skip the console number // skip the console number
++i; ++i;
::g->doomcom.numnodes = 0; ::g->doomcom.numnodes = 0;
for (; i < ::g->myargc; ++i) for( ; i < ::g->myargc; ++i )
{ {
::g->sendaddress[::g->doomcom.numnodes].sin_family = AF_INET; ::g->sendaddress[::g->doomcom.numnodes].sin_family = AF_INET;
::g->sendaddress[::g->doomcom.numnodes].sin_port = htons(DOOMPORT); ::g->sendaddress[::g->doomcom.numnodes].sin_port = htons( DOOMPORT );
// Pull out the port number. // Pull out the port number.
const std::string ipAddressWithPort( ::g->myargv[i] ); const std::string ipAddressWithPort( ::g->myargv[i] );
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 );
@ -238,21 +256,22 @@ void I_InitNetwork (void)
::g->sendaddress[::g->doomcom.numnodes].sin_addr.s_addr = ipAddress; ::g->sendaddress[::g->doomcom.numnodes].sin_addr.s_addr = ipAddress;
::g->doomcom.numnodes++; ::g->doomcom.numnodes++;
} }
::g->doomcom.id = DOOMCOM_ID; ::g->doomcom.id = DOOMCOM_ID;
::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 ) );
// PS3 call to enable non-blocking mode // PS3 call to enable non-blocking mode
int nonblocking = 1; // Non-zero is nonblocking mode. int nonblocking = 1; // Non-zero is nonblocking mode.
setsockopt( ::g->insocket, SOL_SOCKET, SO_NBIO, &nonblocking, sizeof(nonblocking)); setsockopt( ::g->insocket, SOL_SOCKET, SO_NBIO, &nonblocking, sizeof( nonblocking ) );
::g->sendsocket = UDPsocket (); ::g->sendsocket = UDPsocket();
I_Printf( "[+] Setting up sockets for player %d\n", DoomLib::GetPlayer() ); I_Printf( "[+] Setting up sockets for player %d\n", DoomLib::GetPlayer() );
} }
@ -260,11 +279,12 @@ void I_InitNetwork (void)
} }
// DHM - Nerve // DHM - Nerve
void I_ShutdownNetwork() { void I_ShutdownNetwork()
{
} }
void I_NetCmd (void) void I_NetCmd( void )
{ {
//if (::g->doomcom.command == CMD_SEND) //if (::g->doomcom.command == CMD_SEND)
//{ //{

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -33,9 +33,9 @@ If you have questions concerning this license or the applicable additional terms
// UNIX hack, to be removed. // UNIX hack, to be removed.
#ifdef SNDSERV #ifdef SNDSERV
#include <stdio.h> #include <stdio.h>
extern FILE* sndserver; extern FILE* sndserver;
extern char* sndserver_filename; extern char* sndserver_filename;
#endif #endif
#include "doomstat.h" #include "doomstat.h"
@ -48,11 +48,11 @@ void I_InitSound();
void I_InitSoundHardware( int numOutputChannels_, int channelMask ); void I_InitSoundHardware( int numOutputChannels_, int channelMask );
// ... update sound buffer and audio device at runtime... // ... update sound buffer and audio device at runtime...
void I_UpdateSound(void); void I_UpdateSound( void );
void I_SubmitSound(void); void I_SubmitSound( void );
// ... shut down and relase at program termination. // ... shut down and relase at program termination.
void I_ShutdownSound(void); void I_ShutdownSound( void );
void I_ShutdownSoundHardware(); void I_ShutdownSoundHardware();
// //
@ -63,20 +63,20 @@ void I_ShutdownSoundHardware();
void I_SetChannels(); void I_SetChannels();
// Get raw data lump index for sound descriptor. // Get raw data lump index for sound descriptor.
int I_GetSfxLumpNum (sfxinfo_t* sfxinfo ); int I_GetSfxLumpNum( sfxinfo_t* sfxinfo );
// 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 );
// Stops a sound channel. // Stops a sound channel.
void I_StopSound(int handle, int player = -1); void I_StopSound( int handle, int player = -1 );
// Called by S_*() functions // Called by S_*() functions
// 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 );
// Updates the volume, separation, // Updates the volume, separation,
// and pitch of a sound channel. // and pitch of a sound channel.
@ -86,28 +86,28 @@ void I_SetSfxVolume( int );
// //
// MUSIC I/O // MUSIC I/O
// //
void I_InitMusic(void); void I_InitMusic( void );
void I_ShutdownMusic(void); void I_ShutdownMusic( void );
// Volume. // Volume.
void I_SetMusicVolume(int volume); void I_SetMusicVolume( int volume );
// PAUSE game handling. // PAUSE game handling.
void I_PauseSong(int handle); void I_PauseSong( int handle );
void I_ResumeSong(int handle); 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 );
// 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,
// starts playing it again in an endless loop. // starts playing it again in an endless loop.
// Horrible thing to do, considering. // Horrible thing to do, considering.
void I_PlaySong( const char *songname, int looping ); void I_PlaySong( const char* songname, int looping );
// Stops a song over 3 seconds. // Stops a song over 3 seconds.
void I_StopSong(int handle); void I_StopSong( int handle );
// See above (register), then think backwards // See above (register), then think backwards
void I_UnRegisterSong(int handle); void I_UnRegisterSong( int handle );
// Update Music (XMP), check for notifications // Update Music (XMP), check for notifications
void I_UpdateMusic(void); void I_UpdateMusic( void );
int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len); int Mus2Midi( unsigned char* bytes, unsigned char* out, int* len );
#endif #endif

View file

@ -79,36 +79,40 @@ 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;
int start; int start;
int player; int player;
bool localSound; bool localSound;
mobj_t *originator; mobj_t* originator;
} 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;
int priority; int priority;
mobj_t *originator; mobj_t* originator;
mobj_t *listener; mobj_t* listener;
} soundEvent_t; } soundEvent_t;
// array of all the possible sounds // array of all the possible sounds
@ -149,7 +153,7 @@ getsfx
// This function loads the sound data from the WAD lump, // This function loads the sound data from the WAD lump,
// for single sound. // for single sound.
// //
void* getsfx ( const char* sfxname, int* len ) void* getsfx( const char* sfxname, int* len )
{ {
unsigned char* sfx; unsigned char* sfx;
unsigned char* sfxmem; unsigned char* sfxmem;
@ -157,10 +161,10 @@ void* getsfx ( const char* sfxname, int* len )
char name[20]; char name[20];
int sfxlump; int sfxlump;
//float scale = 1.0f; //float scale = 1.0f;
// Get the sound data from the WAD // Get the sound data from the WAD
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;
@ -168,38 +172,43 @@ void* getsfx ( const char* sfxname, int* len )
//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;
size = W_LumpLength( sfxlump ) - SOUND_LUMP_HEADER_SIZE_IN_BYTES; size = W_LumpLength( sfxlump ) - SOUND_LUMP_HEADER_SIZE_IN_BYTES;
sfx = (unsigned char*)W_CacheLumpNum( sfxlump, PU_CACHE_SHARED ); sfx = ( unsigned char* )W_CacheLumpNum( sfxlump, PU_CACHE_SHARED );
const unsigned char * sfxSampleStart = sfx + SOUND_LUMP_HEADER_SIZE_IN_BYTES; const unsigned char* sfxSampleStart = sfx + SOUND_LUMP_HEADER_SIZE_IN_BYTES;
// Allocate from zone memory. // Allocate from zone memory.
//sfxmem = (float*)DoomLib::Z_Malloc( size*(sizeof(float)), PU_SOUND_SHARED, 0 ); //sfxmem = (float*)DoomLib::Z_Malloc( size*(sizeof(float)), PU_SOUND_SHARED, 0 );
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;
} }
// Remove the cached lump. // Remove the cached lump.
Z_Free( sfx ); Z_Free( sfx );
// Set length. // Set length.
*len = size; *len = size;
// Return allocated padded data. // Return allocated padded data.
return (void *) (sfxmem); return ( void* )( sfxmem );
} }
/* /*
@ -219,7 +228,7 @@ 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;
} }
/* /*
@ -253,99 +262,116 @@ 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 || id == 0 ) { if( !soundHardwareInitialized || id == 0 )
{
return id; return id;
} }
int i; int i;
activeSound_t* sound = 0; activeSound_t* sound = 0;
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;
} }
} }
} }
// 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];
} }
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] );
} }
// Set the source voice volume // Set the source voice volume
alSourcef( sound->alSourceVoice, AL_GAIN, x_SoundVolume ); alSourcef( sound->alSourceVoice, AL_GAIN, x_SoundVolume );
// Set the source voice pitch // Set the source voice pitch
alSourcef( sound->alSourceVoice, AL_PITCH, 1 + ((float)pitch-128.f)/95.f ); alSourcef( sound->alSourceVoice, AL_PITCH, 1 + ( ( float )pitch - 128.f ) / 95.f );
// Set the source voice position // Set the source voice position
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 {
sound->localSound = false;
x = (ALfloat)(origin->x >> FRACBITS);
z = (ALfloat)(origin->y >> FRACBITS);
} }
} else { else
{
sound->localSound = false;
x = ( ALfloat )( origin->x >> FRACBITS );
z = ( ALfloat )( origin->y >> FRACBITS );
}
}
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;
} }
alSource3f( sound->alSourceVoice, AL_POSITION, x, y, z ); alSource3f( sound->alSourceVoice, AL_POSITION, x, y, z );
alSourcePlay( sound->alSourceVoice ); alSourcePlay( sound->alSourceVoice );
// Set id, and start time // Set id, and start time
sound->id = id; sound->id = id;
sound->start = ::g->gametic; sound->start = ::g->gametic;
sound->valid = 1; sound->valid = 1;
sound->player = player; sound->player = player;
sound->originator = origin; sound->originator = origin;
return id; return id;
} }
@ -356,10 +382,12 @@ 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 );
} }
} }
memset( soundEvents, 0, sizeof( soundEvents ) ); memset( soundEvents, 0, sizeof( soundEvents ) );
@ -370,19 +398,24 @@ void I_ProcessSoundEvents( void )
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 { }
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;
@ -399,7 +432,7 @@ int I_StartSound ( int id, mobj_t *origin, mobj_t *listener_origin, int vol, int
I_StopSound I_StopSound
====================== ======================
*/ */
void I_StopSound ( int handle, int player ) void I_StopSound( int handle, int player )
{ {
// You need the handle returned by StartSound. // You need the handle returned by StartSound.
// Would be looping all channels, // Would be looping all channels,
@ -407,20 +440,25 @@ void I_StopSound ( int handle, int player )
// and setting the channel to zero. // and setting the channel to zero.
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 );
sound->valid = 0; sound->valid = 0;
sound->player = -1; sound->player = -1;
} }
@ -432,25 +470,30 @@ 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;
} }
} }
return 0; return 0;
} }
@ -463,64 +506,75 @@ 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;
pAngle >>= ANGLETOFINESHIFT; pAngle >>= ANGLETOFINESHIFT;
fx = finecosine[pAngle]; fx = finecosine[pAngle];
fz = finesine[pAngle]; fz = finesine[pAngle];
doom_Listener.OrientFront.x = (float)(fx) / 65535.f; doom_Listener.OrientFront.x = ( float )( fx ) / 65535.f;
doom_Listener.OrientFront.y = 0.f; doom_Listener.OrientFront.y = 0.f;
doom_Listener.OrientFront.z = (float)(fz) / 65535.f; doom_Listener.OrientFront.z = ( float )( fz ) / 65535.f;
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;
doom_Listener.Position.x = 0.f; doom_Listener.Position.x = 0.f;
doom_Listener.Position.y = 0.f; doom_Listener.Position.y = 0.f;
doom_Listener.Position.z = 0.f; doom_Listener.Position.z = 0.f;
} }
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 { }
ALfloat x = (ALfloat)(sound->originator->x >> FRACBITS); else
{
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 );
alSource3f( sound->alSourceVoice, AL_POSITION, x, y, z ); alSource3f( sound->alSourceVoice, AL_POSITION, x, y, z );
} }
} }
@ -545,29 +599,34 @@ 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;
} }
I_StopSound( sound->id, 0 ); I_StopSound( sound->id, 0 );
} }
// 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 );
} }
} }
} }
I_StopSong( 0 ); I_StopSong( 0 );
S_initialized = 0; S_initialized = 0;
} }
@ -582,19 +641,21 @@ sound channels.
void I_InitSoundHardware( int numOutputChannels_, int channelMask ) 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] );
} }
I_InitMusic(); I_InitMusic();
soundHardwareInitialized = true; soundHardwareInitialized = true;
} }
@ -609,18 +670,21 @@ sound channels.
void I_ShutdownSoundHardware() void I_ShutdownSoundHardware()
{ {
soundHardwareInitialized = false; soundHardwareInitialized = false;
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] );
} }
} }
@ -640,10 +705,10 @@ 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 ];
alGenSources( (ALuint)1, &soundchannel->alSourceVoice ); alGenSources( ( ALuint )1, &soundchannel->alSourceVoice );
alSource3f( soundchannel->alSourceVoice, AL_VELOCITY, 0.f, 0.f, 0.f ); alSource3f( soundchannel->alSourceVoice, AL_VELOCITY, 0.f, 0.f, 0.f );
alSourcef( soundchannel->alSourceVoice, AL_LOOPING, AL_FALSE ); alSourcef( soundchannel->alSourceVoice, AL_LOOPING, AL_FALSE );
alSourcef( soundchannel->alSourceVoice, AL_MAX_DISTANCE, SFX_MAX_DISTANCE ); alSourcef( soundchannel->alSourceVoice, AL_MAX_DISTANCE, SFX_MAX_DISTANCE );
@ -658,35 +723,41 @@ 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;
doom_Listener.OrientFront.z = 1.f; doom_Listener.OrientFront.z = 1.f;
doom_Listener.OrientTop.x = 0.f; doom_Listener.OrientTop.x = 0.f;
doom_Listener.OrientTop.y = -1.f; doom_Listener.OrientTop.y = -1.f;
doom_Listener.OrientTop.z = 0.f; doom_Listener.OrientTop.z = 0.f;
doom_Listener.Position.x = 0.f; doom_Listener.Position.x = 0.f;
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 );
} }
} }
S_initialized = 1; S_initialized = 1;
} }
} }
@ -701,10 +772,11 @@ 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();
// Change music if required // Change music if required
I_UpdateMusic(); I_UpdateMusic();
} }
@ -724,7 +796,7 @@ I_SetMusicVolume
*/ */
void I_SetMusicVolume( int volume ) void I_SetMusicVolume( int volume )
{ {
x_MusicVolume = (float)volume / 15.f; x_MusicVolume = ( float )volume / 15.f;
} }
/* /*
@ -734,22 +806,23 @@ 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" );
musicBuffer = NULL; musicBuffer = NULL;
totalBufferSize = 0; totalBufferSize = 0;
waitingForMusic = false; waitingForMusic = false;
musicReady = false; musicReady = false;
alGenSources( (ALuint)1, &alMusicSourceVoice ); alGenSources( ( ALuint )1, &alMusicSourceVoice );
alSourcef( alMusicSourceVoice, AL_PITCH, 1.f ); alSourcef( alMusicSourceVoice, AL_PITCH, 1.f );
alSourcef( alMusicSourceVoice, AL_LOOPING, AL_TRUE ); alSourcef( alMusicSourceVoice, AL_LOOPING, AL_TRUE );
alGenBuffers( (ALuint)1, &alMusicBuffer ); alGenBuffers( ( ALuint )1, &alMusicBuffer );
Music_initialized = true; Music_initialized = true;
} }
} }
@ -761,37 +834,42 @@ 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;
} }
Timidity_Shutdown(); Timidity_Shutdown();
} }
totalBufferSize = 0; totalBufferSize = 0;
waitingForMusic = false; waitingForMusic = false;
musicReady = false; musicReady = false;
Music_initialized = false; Music_initialized = false;
} }
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; {
unsigned char midiConversionBuffer[MaxMidiConversionSize]; const int MaxMidiConversionSize = 1024 * 1024;
unsigned char midiConversionBuffer[MaxMidiConversionSize];
} }
/* /*
@ -799,36 +877,39 @@ namespace {
I_LoadSong I_LoadSong
====================== ======================
*/ */
void I_LoadSong( const char * songname ) void I_LoadSong( const char* songname )
{ {
idStr lumpName = "d_"; idStr lumpName = "d_";
lumpName += static_cast< const char * >( songname ); lumpName += static_cast< const char* >( songname );
unsigned char * musFile = static_cast< unsigned char * >( W_CacheLumpName( lumpName.c_str(), PU_STATIC_SHARED ) ); unsigned char* musFile = static_cast< unsigned char* >( W_CacheLumpName( lumpName.c_str(), PU_STATIC_SHARED ) );
int length = 0; int length = 0;
Mus2Midi( musFile, midiConversionBuffer, &length ); Mus2Midi( musFile, midiConversionBuffer, &length );
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 );
int rc = RC_NO_RETURN_VALUE; int rc = RC_NO_RETURN_VALUE;
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 );
} }
musicReady = true; musicReady = true;
} }
@ -837,25 +918,28 @@ void I_LoadSong( const char * songname )
I_PlaySong 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;
} }
musicReady = false; musicReady = false;
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,24 +951,29 @@ 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 );
alSourcePlay( alMusicSourceVoice ); alSourcePlay( alMusicSourceVoice );
} }
waitingForMusic = false; waitingForMusic = false;
} }
} }
@ -895,12 +984,13 @@ void I_UpdateMusic( void )
I_PauseSong I_PauseSong
====================== ======================
*/ */
void I_PauseSong ( int handle ) void I_PauseSong( int handle )
{ {
if ( !Music_initialized || !alMusicSourceVoice ) { if( !Music_initialized || !alMusicSourceVoice )
{
return; return;
} }
alSourcePause( alMusicSourceVoice ); alSourcePause( alMusicSourceVoice );
} }
@ -909,12 +999,13 @@ void I_PauseSong ( int handle )
I_ResumeSong I_ResumeSong
====================== ======================
*/ */
void I_ResumeSong ( int handle ) void I_ResumeSong( int handle )
{ {
if ( !Music_initialized || !alMusicSourceVoice ) { if( !Music_initialized || !alMusicSourceVoice )
{
return; return;
} }
alSourcePlay( alMusicSourceVoice ); alSourcePlay( alMusicSourceVoice );
} }
@ -925,10 +1016,11 @@ I_StopSong
*/ */
void I_StopSong( int handle ) void I_StopSong( int handle )
{ {
if ( !Music_initialized || !alMusicSourceVoice ) { if( !Music_initialized || !alMusicSourceVoice )
{
return; return;
} }
alSourceStop( alMusicSourceVoice ); alSourceStop( alMusicSourceVoice );
} }

View file

@ -35,83 +35,89 @@ If you have questions concerning this license or the applicable additional terms
#include "w_wad.h" #include "w_wad.h"
// Init at program start... // Init at program start...
void I_InitSound(){} void I_InitSound() {}
void I_InitSoundHardware( int numOutputChannels_, int channelMask ){} void I_InitSoundHardware( int numOutputChannels_, int channelMask ) {}
// ... update sound buffer and audio device at runtime... // ... update sound buffer and audio device at runtime...
void I_UpdateSound(void){} void I_UpdateSound( void ) {}
void I_SubmitSound(void){} void I_SubmitSound( void ) {}
// ... shut down and relase at program termination. // ... shut down and relase at program termination.
void I_ShutdownSound(void){} void I_ShutdownSound( void ) {}
void I_ShutdownSoundHardware(){} void I_ShutdownSoundHardware() {}
// //
// SFX I/O // SFX I/O
// //
// Initialize channels? // Initialize channels?
void I_SetChannels(){} void I_SetChannels() {}
// Get raw data lump index for sound descriptor. // Get raw data lump index for sound descriptor.
int I_GetSfxLumpNum (sfxinfo_t* sfxinfo ) int I_GetSfxLumpNum( sfxinfo_t* sfxinfo )
{ {
char namebuf[9]; char namebuf[9];
sprintf(namebuf, "ds%s", sfxinfo->name); sprintf( namebuf, "ds%s", sfxinfo->name );
return W_GetNumForName(namebuf); return W_GetNumForName( namebuf );
} }
void I_ProcessSoundEvents( void ){} 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.
void I_StopSound(int handle, int player){} void I_StopSound( int handle, int player ) {}
// Called by S_*() functions // Called by S_*() functions
// 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.
void I_UpdateSoundParams( int handle, int vol, int sep, int pitch ){} void I_UpdateSoundParams( int handle, int vol, int sep, int pitch ) {}
void I_SetSfxVolume( int ){} void I_SetSfxVolume( int ) {}
// //
// MUSIC I/O // MUSIC I/O
// //
void I_InitMusic(void){} void I_InitMusic( void ) {}
void I_ShutdownMusic(void){} void I_ShutdownMusic( void ) {}
// Volume. // Volume.
void I_SetMusicVolume(int volume){} void I_SetMusicVolume( int volume ) {}
// PAUSE game handling. // PAUSE game handling.
void I_PauseSong(int handle){} void I_PauseSong( int handle ) {}
void I_ResumeSong(int handle){} 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,
// starts playing it again in an endless loop. // starts playing it again in an endless loop.
// Horrible thing to do, considering. // Horrible thing to do, considering.
void I_PlaySong( const char *songname, int looping ){} void I_PlaySong( const char* songname, int looping ) {}
// Stops a song over 3 seconds. // Stops a song over 3 seconds.
void I_StopSong(int handle){} void I_StopSong( int handle ) {}
// See above (register), then think backwards // See above (register), then think backwards
void I_UnRegisterSong(int handle){} void I_UnRegisterSong( int handle ) {}
// Update Music (XMP), check for notifications // Update Music (XMP), check for notifications
void I_UpdateMusic(void){} void I_UpdateMusic( void ) {}

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -45,7 +45,7 @@ If you have questions concerning this license or the applicable additional terms
#include "g_game.h" #include "g_game.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "i_system.h" #pragma implementation "i_system.h"
#endif #endif
#include "i_system.h" #include "i_system.h"
@ -55,15 +55,15 @@ If you have questions concerning this license or the applicable additional terms
ticcmd_t* I_BaseTiccmd(void) ticcmd_t* I_BaseTiccmd( void )
{ {
return &::g->emptycmd; return &::g->emptycmd;
} }
int I_GetHeapSize (void) int I_GetHeapSize( void )
{ {
return ::g->mb_used*1024*1024; return ::g->mb_used * 1024 * 1024;
} }
@ -71,7 +71,7 @@ int I_GetHeapSize (void)
// I_GetTime // I_GetTime
// returns time in 1/70th second tics // returns time in 1/70th second tics
// //
int I_GetTime (void) int I_GetTime( void )
{ {
return ::g->current_time; return ::g->current_time;
} }
@ -86,39 +86,39 @@ void I_SetTime( int time_in )
// //
// I_Init // I_Init
// //
void I_Init (void) void I_Init( void )
{ {
I_InitSound(); I_InitSound();
// I_InitGraphics(); // I_InitGraphics();
} }
// //
// I_Quit // I_Quit
// //
void I_Quit (void) void I_Quit( void )
{ {
D_QuitNetGame (); D_QuitNetGame();
I_ShutdownSound(); I_ShutdownSound();
I_ShutdownMusic(); I_ShutdownMusic();
M_SaveDefaults (); M_SaveDefaults();
I_ShutdownGraphics(); I_ShutdownGraphics();
// exit(0); // exit(0);
// Exceptions disabled by default on PS3 // Exceptions disabled by default on PS3
// throw; // throw;
} }
void I_WaitVBL(int count) void I_WaitVBL( int count )
{ {
// PS3 fixme // PS3 fixme
//Sleep(0); //Sleep(0);
} }
void I_BeginRead(void) void I_BeginRead( void )
{ {
} }
void I_EndRead(void) void I_EndRead( void )
{ {
} }
@ -126,56 +126,59 @@ void I_EndRead(void)
// I_Error // I_Error
// //
extern bool debugOutput; extern bool debugOutput;
void I_Printf(const char* msg, ...) void I_Printf( const char* msg, ... )
{ {
char pmsg[1024]; char pmsg[1024];
va_list argptr; va_list argptr;
// Message first. // Message first.
if( debugOutput ) { if( debugOutput )
va_start (argptr,msg); {
vsprintf (pmsg, msg, argptr); va_start( argptr, msg );
vsprintf( pmsg, msg, argptr );
safeOutputDebug(pmsg); safeOutputDebug( pmsg );
va_end (argptr); va_end( argptr );
} }
} }
void I_PrintfE(const char* msg, ...) void I_PrintfE( const char* msg, ... )
{ {
char pmsg[1024]; char pmsg[1024];
va_list argptr; va_list argptr;
// Message first. // Message first.
if( debugOutput ) { if( debugOutput )
va_start (argptr,msg); {
vsprintf (pmsg, msg, argptr); va_start( argptr, msg );
vsprintf( pmsg, msg, argptr );
safeOutputDebug("ERROR: "); safeOutputDebug( "ERROR: " );
safeOutputDebug(pmsg); safeOutputDebug( pmsg );
va_end (argptr); va_end( argptr );
} }
} }
void I_Error(const char *error, ...) void I_Error( const char* error, ... )
{ {
const int ERROR_MSG_SIZE = 1024; const int ERROR_MSG_SIZE = 1024;
char error_msg[ERROR_MSG_SIZE]; char error_msg[ERROR_MSG_SIZE];
va_list argptr; va_list argptr;
// Message first. // Message first.
if( debugOutput ) { if( debugOutput )
va_start (argptr,error); {
idStr::vsnPrintf (error_msg, ERROR_MSG_SIZE, error, argptr); va_start( argptr, error );
idStr::vsnPrintf( error_msg, ERROR_MSG_SIZE, error, argptr );
safeOutputDebug("Error: "); safeOutputDebug( "Error: " );
safeOutputDebug(error_msg); safeOutputDebug( error_msg );
safeOutputDebug("\n"); safeOutputDebug( "\n" );
va_end (argptr); va_end( argptr );
} }
// CRASH DUMP - enable this to get extra info on error from crash dumps // CRASH DUMP - enable this to get extra info on error from crash dumps

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -33,16 +33,16 @@ If you have questions concerning this license or the applicable additional terms
#include "d_event.h" #include "d_event.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
// Called by DoomMain. // Called by DoomMain.
void I_Init (void); void I_Init( void );
// Called by D_DoomLoop, // Called by D_DoomLoop,
// returns current time in tics. // returns current time in tics.
int I_GetTime (void); int I_GetTime( void );
// //
@ -53,7 +53,7 @@ int I_GetTime (void);
// are performed here (joystick reading). // are performed here (joystick reading).
// Can call D_PostEvent. // Can call D_PostEvent.
// //
void I_StartFrame (void); void I_StartFrame( void );
// //
@ -71,17 +71,17 @@ void I_StartFrame (void);
// or calls a loadable driver to build it. // or calls a loadable driver to build it.
// This ticcmd will then be modified by the gameloop // This ticcmd will then be modified by the gameloop
// for normal input. // for normal input.
ticcmd_t* I_BaseTiccmd (void); ticcmd_t* I_BaseTiccmd( void );
// Called by M_Responder when quit is selected. // Called by M_Responder when quit is selected.
// Clean exit, displays sell blurb. // Clean exit, displays sell blurb.
void I_Quit (void); void I_Quit( void );
void I_Error (const char *error, ...); void I_Error( const char* error, ... );
void I_Printf(const char *error, ...); void I_Printf( const char* error, ... );
void I_PrintfE(const char *error, ...); void I_PrintfE( const char* error, ... );
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -34,42 +34,42 @@ If you have questions concerning this license or the applicable additional terms
#include "d_event.h" #include "d_event.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
// Called by D_DoomMain, // Called by D_DoomMain,
// determines the hardware configuration // determines the hardware configuration
// and sets up the video mode // and sets up the video mode
void I_InitGraphics (void); void I_InitGraphics( void );
void I_ShutdownGraphics(void); void I_ShutdownGraphics( void );
// Takes full 8 bit values. // Takes full 8 bit values.
void I_SetPalette (byte* palette); void I_SetPalette( byte* palette );
void I_UpdateNoBlit (void); void I_UpdateNoBlit( void );
void I_FinishUpdate (void); void I_FinishUpdate( void );
// Wait for vertical retrace or pause a bit. // Wait for vertical retrace or pause a bit.
void I_WaitVBL(int count); void I_WaitVBL( int count );
void I_ReadScreen (byte* scr); void I_ReadScreen( byte* scr );
void I_BeginRead (void); void I_BeginRead( void );
void I_EndRead (void); void I_EndRead( void );
void I_InitInput (void); void I_InitInput( void );
void I_ShutdownInput() ; void I_ShutdownInput() ;
void I_InputFrame(); void I_InputFrame();
void I_UpdateControllerState(void); void I_UpdateControllerState( void );
struct controller_t; struct controller_t;
int I_PollMouseInputEvents( controller_t * ) ; int I_PollMouseInputEvents( controller_t* ) ;
int I_ReturnMouseInputEvent( const int n, event_t* e); int I_ReturnMouseInputEvent( const int n, event_t* e );
int I_PollJoystickInputEvents( controller_t * ) ; int I_PollJoystickInputEvents( controller_t* ) ;
int I_ReturnJoystickInputEvent( const int n, event_t* e); int I_ReturnJoystickInputEvent( const int n, event_t* e );
void I_EndJoystickInputEvents(); void I_EndJoystickInputEvents();
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -50,9 +50,9 @@ If you have questions concerning this license or the applicable additional terms
void I_ShutdownGraphics(void) void I_ShutdownGraphics( void )
{ {
// VVTODO: Shutdown Graphics // VVTODO: Shutdown Graphics
} }
@ -60,22 +60,28 @@ void I_ShutdownGraphics(void)
// //
// I_StartFrame // I_StartFrame
// //
void I_StartFrame (void) void I_StartFrame( void )
{ {
// er? // er?
} }
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 )
{ {
event_t e_mouse, e_joystick; event_t e_mouse, e_joystick;
int numEvents; int numEvents;
@ -86,56 +92,65 @@ void I_GetEvents( controller_t *controller )
e_joystick.data1 = e_joystick.data2 = e_joystick.data3 = 0; e_joystick.data1 = e_joystick.data2 = e_joystick.data3 = 0;
numEvents = I_PollMouseInputEvents( controller ); numEvents = I_PollMouseInputEvents( controller );
if (numEvents) if( numEvents )
{ {
int i; int i;
event_t e; event_t e;
// right thumb stick
for (i = 0; i < numEvents; ++i)
{
I_ReturnMouseInputEvent(i, &e);
if (e.type == ev_mouse)
I_CombineMouseEvent(&e, &e_mouse);
else if (e.type == ev_joystick)
I_CombineMouseEvent(&e, &e_joystick);
}
}
numEvents = I_PollJoystickInputEvents( controller ); // right thumb stick
if (numEvents) for( i = 0; i < numEvents; ++i )
{
int i;
event_t e;
for (i = 0; i < numEvents; ++i)
{ {
I_ReturnJoystickInputEvent(i, &e); I_ReturnMouseInputEvent( i, &e );
if (e.type == ev_keydown || e.type == ev_keyup) { if( e.type == ev_mouse )
D_PostEvent(&e); {
} else if (e.type == ev_joystick) { I_CombineMouseEvent( &e, &e_mouse );
I_CombineMouseEvent(&e, &e_joystick); }
} else if (e.type == ev_mouse) { else if( e.type == ev_joystick )
I_CombineMouseEvent(&e, &e_mouse); {
I_CombineMouseEvent( &e, &e_joystick );
} }
} }
} }
D_PostEvent(&e_mouse); numEvents = I_PollJoystickInputEvents( controller );
D_PostEvent(&e_joystick); if( numEvents )
{
int i;
event_t e;
for( i = 0; i < numEvents; ++i )
{
I_ReturnJoystickInputEvent( i, &e );
if( e.type == ev_keydown || e.type == ev_keyup )
{
D_PostEvent( &e );
}
else if( e.type == ev_joystick )
{
I_CombineMouseEvent( &e, &e_joystick );
}
else if( e.type == ev_mouse )
{
I_CombineMouseEvent( &e, &e_mouse );
}
}
}
D_PostEvent( &e_mouse );
D_PostEvent( &e_joystick );
} }
// //
// I_UpdateNoBlit // I_UpdateNoBlit
// //
void I_UpdateNoBlit (void) void I_UpdateNoBlit( void )
{ {
// what is this? // what is this?
} }
// //
// I_FinishUpdate // I_FinishUpdate
// //
void I_FinishUpdate (void) void I_FinishUpdate( void )
{ {
// DHM - These buffers are not used // DHM - These buffers are not used
} }
@ -144,18 +159,19 @@ void I_FinishUpdate (void)
// //
// I_ReadScreen // I_ReadScreen
// //
void I_ReadScreen (byte* scr) 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;
color |= (g & 255) << 16; color |= ( g & 255 ) << 16;
color |= (b & 255) << 8; color |= ( b & 255 ) << 8;
color |= (a & 255); color |= ( a & 255 );
return color; return color;
} }
@ -163,19 +179,19 @@ inline unsigned int I_PackColor( unsigned int a, unsigned int r, unsigned int g,
// //
// I_SetPalette // I_SetPalette
// //
void I_SetPalette (byte* palette) void I_SetPalette( byte* palette )
{ {
int i; int i;
// set the X colormap entries // set the X colormap entries
for (i=0 ; i<256 ; i++) for( i = 0 ; i < 256 ; i++ )
{ {
int r,b,g; int r, b, g;
r = gammatable[::g->usegamma][*palette++]; r = gammatable[::g->usegamma][*palette++];
g = gammatable[::g->usegamma][*palette++]; g = gammatable[::g->usegamma][*palette++];
b = gammatable[::g->usegamma][*palette++]; b = gammatable[::g->usegamma][*palette++];
::g->XColorMap[i] = I_PackColor(0xff, r, g, b); ::g->XColorMap[i] = I_PackColor( 0xff, r, g, b );
} }
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -42,17 +42,19 @@ If you have questions concerning this license or the applicable additional terms
// in the program's command line arguments. // in the program's command line arguments.
// Returns the argument number (1 to argc-1) // Returns the argument number (1 to argc-1)
// or 0 if not present // or 0 if not present
int M_CheckParm (const char *check) int M_CheckParm( const char* check )
{ {
int i; int i;
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

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -37,7 +37,7 @@ extern char** myargv;
// Returns the position of the given parameter // Returns the position of the given parameter
// in the arg list (0 if not found). // in the arg list (0 if not found).
int M_CheckParm (const char* check); int M_CheckParm( const char* check );
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "m_bbox.h" #pragma implementation "m_bbox.h"
#endif #endif
#include "m_bbox.h" #include "m_bbox.h"
@ -39,10 +39,10 @@ If you have questions concerning this license or the applicable additional terms
void M_ClearBox (fixed_t *box) void M_ClearBox( fixed_t* box )
{ {
box[BOXTOP] = box[BOXRIGHT] = MININT; box[BOXTOP] = box[BOXRIGHT] = MININT;
box[BOXBOTTOM] = box[BOXLEFT] = MAXINT; box[BOXBOTTOM] = box[BOXLEFT] = MAXINT;
} }
void void
@ -51,14 +51,22 @@ M_AddToBox
fixed_t x, fixed_t x,
fixed_t y ) fixed_t y )
{ {
if (x<box[BOXLEFT]) if( x < box[BOXLEFT] )
box[BOXLEFT] = x; {
else if (x>box[BOXRIGHT]) box[BOXLEFT] = x;
box[BOXRIGHT] = x; }
if (y<box[BOXBOTTOM]) else if( x > box[BOXRIGHT] )
box[BOXBOTTOM] = y; {
else if (y>box[BOXTOP]) box[BOXRIGHT] = x;
box[BOXTOP] = y; }
if( y < box[BOXBOTTOM] )
{
box[BOXBOTTOM] = y;
}
else if( y > box[BOXTOP] )
{
box[BOXTOP] = y;
}
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -35,14 +35,14 @@ If you have questions concerning this license or the applicable additional terms
// Bounding box coordinate storage. // Bounding box coordinate storage.
enum enum
{ {
BOXTOP, BOXTOP,
BOXBOTTOM, BOXBOTTOM,
BOXLEFT, BOXLEFT,
BOXRIGHT BOXRIGHT
}; // bbox coordinates }; // bbox coordinates
// Bounding box functions. // Bounding box functions.
void M_ClearBox (fixed_t* box); void M_ClearBox( fixed_t* box );
void void
M_AddToBox M_AddToBox

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -47,47 +47,66 @@ cht_CheckCheat
char key ) char key )
{ {
return 0; // ALAN : Checking the cheats CRASHES?? return 0; // ALAN : Checking the cheats CRASHES??
int i; int i;
int rc = 0; int rc = 0;
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] = 0xff; {
::g->usedcheatbuffer += isize; cht->p[isize] = cht->sequence[isize];
::g->usedcheatbuffer ++; }
} cht->p[isize] = 0xff;
::g->usedcheatbuffer += isize;
::g->usedcheatbuffer ++;
}
if (*cht->p == 0) if( *cht->p == 0 )
*(cht->p++) = key; {
else if *( cht->p++ ) = key;
(::g->cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++; }
else else if
{ ( ::g->cheat_xlate_table[( unsigned char )key] == *cht->p )
int isize = 0; {
while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize]; cht->p++;
cht->p[isize] = 0xff; }
} else
{
int isize = 0;
while( cht->sequence[isize] != 0xff )
{
cht->p[isize] = cht->sequence[isize];
}
cht->p[isize] = 0xff;
}
if (*cht->p == 1) if( *cht->p == 1 )
cht->p++; {
else if (*cht->p == 0xff) // end of sequence character cht->p++;
{ }
int isize = 0; else if( *cht->p == 0xff ) // end of sequence character
while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize]; {
cht->p[isize] = 0xff; int isize = 0;
rc = 1; while( cht->sequence[isize] != 0xff )
} {
cht->p[isize] = cht->sequence[isize];
}
cht->p[isize] = 0xff;
rc = 1;
}
return rc; return rc;
} }
void void
@ -97,28 +116,33 @@ cht_GetParam
{ {
unsigned char pb[16]; unsigned char pb[16];
unsigned char *p; unsigned char* p;
unsigned char c; unsigned char c;
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];
while (*(p++) != 1); while( *( p++ ) != 1 );
do
{
c = *p;
*(buffer++) = c;
*(p++) = 0;
}
while (c && *p!=0xff );
if (*p==0xff) do
*buffer = 0; {
c = *p;
*( buffer++ ) = c;
*( p++ ) = 0;
}
while( c && *p != 0xff );
if( *p == 0xff )
{
*buffer = 0;
}
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -40,10 +40,10 @@ If you have questions concerning this license or the applicable additional terms
struct cheatseq_t struct cheatseq_t
{ {
cheatseq_t() {} cheatseq_t() {}
cheatseq_t( const unsigned char *seq, unsigned char *pin ) : sequence( seq ), p( pin ) {} cheatseq_t( const unsigned char* seq, unsigned char* pin ) : sequence( seq ), p( pin ) {}
const unsigned char* sequence; const unsigned char* sequence;
unsigned char* p; unsigned char* p;
}; };
int int

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -29,7 +29,7 @@ If you have questions concerning this license or the applicable additional terms
#include "Precompiled.h" #include "Precompiled.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "m_fixed.h" #pragma implementation "m_fixed.h"
#endif #endif
#include "m_fixed.h" #include "m_fixed.h"
@ -48,7 +48,7 @@ FixedMul
( fixed_t a, ( fixed_t a,
fixed_t b ) fixed_t b )
{ {
return fixed_t( ((long long) a * (long long) b) >> FRACBITS ); return fixed_t( ( ( long long ) a * ( long long ) b ) >> FRACBITS );
} }
@ -62,9 +62,11 @@ FixedDiv
( fixed_t a, ( fixed_t a,
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 FixedDiv2 (a,b); return ( a ^ b ) < 0 ? MININT : MAXINT;
}
return FixedDiv2( a, b );
} }
@ -75,17 +77,19 @@ FixedDiv2
fixed_t b ) fixed_t b )
{ {
#if 0 #if 0
long long c; long long c;
c = ((long long)a<<16) / ((long long)b); c = ( ( long long )a << 16 ) / ( ( long long )b );
return (fixed_t) c; return ( fixed_t ) c;
#endif #endif
double c; double c;
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"); {
return (fixed_t) c; I_Error( "FixedDiv: divide by zero" );
}
return ( fixed_t ) c;
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
@ -43,9 +43,9 @@ If you have questions concerning this license or the applicable additional terms
typedef int fixed_t; typedef int fixed_t;
fixed_t FixedMul (fixed_t a, fixed_t b); fixed_t FixedMul( fixed_t a, fixed_t b );
fixed_t FixedDiv (fixed_t a, fixed_t b); fixed_t FixedDiv( fixed_t a, fixed_t b );
fixed_t FixedDiv2 (fixed_t a, fixed_t b); fixed_t FixedDiv2( fixed_t a, fixed_t b );

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -41,29 +41,29 @@ If you have questions concerning this license or the applicable additional terms
// Even when the menu is not displayed, // Even when the menu is not displayed,
// this can resize the view and change game parameters. // this can resize the view and change game parameters.
// Does all the real work of the menu interaction. // Does all the real work of the menu interaction.
qboolean M_Responder (event_t *ev); qboolean M_Responder( event_t* ev );
// Called by main loop, // Called by main loop,
// only used for menu (skull cursor) animation. // only used for menu (skull cursor) animation.
void M_Ticker (void); void M_Ticker( void );
// Called by main loop, // Called by main loop,
// draws the menus directly into the screen buffer. // draws the menus directly into the screen buffer.
void M_Drawer (void); void M_Drawer( void );
// Called by D_DoomMain, // Called by D_DoomMain,
// loads the config file. // loads the config file.
void M_Init (void); void M_Init( void );
// Called by intro code to force menu up upon a keypress, // Called by intro code to force menu up upon a keypress,
// does nothing if menu is already up. // does nothing if menu is already up.
void M_StartControlPanel (void); void M_StartControlPanel( void );
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -75,51 +75,62 @@ M_DrawText
qboolean direct, qboolean direct,
char* string ) char* string )
{ {
int c; int c;
int w; int w;
while (*string) while( *string )
{
c = toupper(*string) - HU_FONTSTART;
string++;
if (c < 0 || c> HU_FONTSIZE)
{ {
x += 4; c = toupper( *string ) - HU_FONTSTART;
continue; string++;
} if( c < 0 || c > HU_FONTSIZE )
{
w = SHORT (::g->hu_font[c]->width); x += 4;
if (x+w > SCREENWIDTH) continue;
break; }
if (direct)
V_DrawPatchDirect(x, y, 0, ::g->hu_font[c]);
else
V_DrawPatch(x, y, 0, ::g->hu_font[c]);
x+=w;
}
return x; w = SHORT( ::g->hu_font[c]->width );
if( x + w > SCREENWIDTH )
{
break;
}
if( direct )
{
V_DrawPatchDirect( x, y, 0, ::g->hu_font[c] );
}
else
{
V_DrawPatch( x, y, 0, ::g->hu_font[c] );
}
x += w;
}
return x;
} }
// //
// 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;
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,24 +139,27 @@ 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 );
} }
length = handle->Length(); length = handle->Length();
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 );
} }
fileSystem->CloseFile( handle ); fileSystem->CloseFile( handle );
@ -209,32 +223,32 @@ extern const char* const temp_chat_macros[];
// //
// M_SaveDefaults // M_SaveDefaults
// //
void M_SaveDefaults (void) void M_SaveDefaults( void )
{ {
/* /*
int i; int i;
int v; int v;
FILE* f; FILE* f;
f = f o pen (::g->defaultfile, "w"); f = f o pen (::g->defaultfile, "w");
if (!f) if (!f)
return; // can't write the file, but don't complain return; // can't write the file, but don't complain
for (i=0 ; i<::g->numdefaults ; i++) for (i=0 ; i<::g->numdefaults ; i++)
{ {
if (::g->defaults[i].defaultvalue > -0xfff if (::g->defaults[i].defaultvalue > -0xfff
&& ::g->defaults[i].defaultvalue < 0xfff) && ::g->defaults[i].defaultvalue < 0xfff)
{ {
v = *::g->defaults[i].location; v = *::g->defaults[i].location;
fprintf (f,"%s\t\t%i\n",::g->defaults[i].name,v); fprintf (f,"%s\t\t%i\n",::g->defaults[i].name,v);
} else { } else {
fprintf (f,"%s\t\t\"%s\"\n",::g->defaults[i].name, fprintf (f,"%s\t\t\"%s\"\n",::g->defaults[i].name,
* (char **) (::g->defaults[i].location)); * (char **) (::g->defaults[i].location));
} }
} }
fclose (f); fclose (f);
*/ */
} }
@ -242,71 +256,75 @@ void M_SaveDefaults (void)
// M_LoadDefaults // M_LoadDefaults
// //
void M_LoadDefaults (void) void M_LoadDefaults( void )
{ {
int i; int i;
//int len; //int len;
//FILE* f; //FILE* f;
//char def[80]; //char def[80];
//char strparm[100]; //char strparm[100];
//char* newstring; //char* newstring;
//int parm; //int parm;
//qboolean isstring; //qboolean isstring;
// set everything to base values
::g->numdefaults = sizeof(::g->defaults)/sizeof(::g->defaults[0]);
for (i=0 ; i < ::g->numdefaults ; i++)
*::g->defaults[i].location = ::g->defaults[i].defaultvalue;
// check for a custom default file
i = M_CheckParm ("-config");
if (i && i < ::g->myargc-1)
{
::g->defaultfile = ::g->myargv[i+1];
I_Printf (" default file: %s\n",::g->defaultfile);
}
else
::g->defaultfile = ::g->basedefault;
/* // set everything to base values
// read the file in, overriding any set ::g->defaults ::g->numdefaults = sizeof( ::g->defaults ) / sizeof( ::g->defaults[0] );
f = f o pen (::g->defaultfile, "r"); for( i = 0 ; i < ::g->numdefaults ; i++ )
if (f) {
{ *::g->defaults[i].location = ::g->defaults[i].defaultvalue;
while (!feof(f)) }
{
isstring = false; // check for a custom default file
if (fscanf (f, "%79s %[^\n]\n", def, strparm) == 2) i = M_CheckParm( "-config" );
if( i && i < ::g->myargc - 1 )
{
::g->defaultfile = ::g->myargv[i + 1];
I_Printf( " default file: %s\n", ::g->defaultfile );
}
else
{
::g->defaultfile = ::g->basedefault;
}
/*
// read the file in, overriding any set ::g->defaults
f = f o pen (::g->defaultfile, "r");
if (f)
{
while (!feof(f))
{ {
if (strparm[0] == '"') isstring = false;
if (fscanf (f, "%79s %[^\n]\n", def, strparm) == 2)
{ {
// get a string default if (strparm[0] == '"')
isstring = true;
len = strlen(strparm);
newstring = (char *)DoomLib::Z_Malloc(len, PU_STATIC, 0);
strparm[len-1] = 0;
strcpy(newstring, strparm+1);
}
else if (strparm[0] == '0' && strparm[1] == 'x')
sscanf(strparm+2, "%x", &parm);
else
sscanf(strparm, "%i", &parm);
for (i=0 ; i<::g->numdefaults ; i++)
if (!strcmp(def, ::g->defaults[i].name))
{ {
if (!isstring) // get a string default
*::g->defaults[i].location = parm; isstring = true;
else len = strlen(strparm);
*::g->defaults[i].location = (int) newstring; newstring = (char *)DoomLib::Z_Malloc(len, PU_STATIC, 0);
break; strparm[len-1] = 0;
strcpy(newstring, strparm+1);
} }
else if (strparm[0] == '0' && strparm[1] == 'x')
sscanf(strparm+2, "%x", &parm);
else
sscanf(strparm, "%i", &parm);
for (i=0 ; i<::g->numdefaults ; i++)
if (!strcmp(def, ::g->defaults[i].name))
{
if (!isstring)
*::g->defaults[i].location = parm;
else
*::g->defaults[i].location = (int) newstring;
break;
}
}
} }
}
fclose (f);
fclose (f); }
} */
*/
} }
@ -335,37 +353,37 @@ WritePCXfile
// //
// M_ScreenShot // M_ScreenShot
// //
void M_ScreenShot (void) void M_ScreenShot( void )
{ {
/* /*
int i; int i;
byte* linear; byte* linear;
char lbmname[12]; char lbmname[12];
// munge planar buffer to linear // munge planar buffer to linear
linear = ::g->screens[2]; linear = ::g->screens[2];
I_ReadScreen (linear); I_ReadScreen (linear);
// find a file name to save it to // find a file name to save it to
strcpy(lbmname,"DOOM00.pcx"); strcpy(lbmname,"DOOM00.pcx");
for (i=0 ; i<=99 ; i++) for (i=0 ; i<=99 ; i++)
{ {
lbmname[4] = i/10 + '0'; lbmname[4] = i/10 + '0';
lbmname[5] = i%10 + '0'; lbmname[5] = i%10 + '0';
if (_access(lbmname,0) == -1) if (_access(lbmname,0) == -1)
break; // file doesn't exist break; // file doesn't exist
} }
if (i==100) if (i==100)
I_Error ("M_ScreenShot: Couldn't create a PCX"); I_Error ("M_ScreenShot: Couldn't create a PCX");
// save the pcx file // save the pcx file
WritePCXfile (lbmname, linear, WritePCXfile (lbmname, linear,
SCREENWIDTH, SCREENHEIGHT, SCREENWIDTH, SCREENHEIGHT,
(byte*)W_CacheLumpName ("PLAYPAL",PU_CACHE_SHARED)); (byte*)W_CacheLumpName ("PLAYPAL",PU_CACHE_SHARED));
::g->players[::g->consoleplayer].message = "screen shot"; ::g->players[::g->consoleplayer].message = "screen shot";
*/ */
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -41,17 +41,17 @@ M_WriteFile
int length ); int length );
int int
M_ReadFile M_ReadFile
( char const* name, ( char const* name,
byte** buffer ); byte** buffer );
qboolean M_WriteSaveGame( void* source, int length ); qboolean M_WriteSaveGame( void* source, int length );
int M_ReadSaveGame ( byte** buffer ); int M_ReadSaveGame( byte** buffer );
void M_ScreenShot (void); void M_ScreenShot( void );
void M_LoadDefaults (void); void M_LoadDefaults( void );
void M_SaveDefaults (void); void M_SaveDefaults( void );
int int

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -34,45 +34,46 @@ 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 , {
74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36 , 0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66 ,
95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188 , 74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36 ,
52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224 , 95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188 ,
149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242 , 52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224 ,
145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0 , 149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242 ,
175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235 , 145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0 ,
25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113 , 175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235 ,
94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75 , 25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113 ,
136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196 , 94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75 ,
135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113 , 136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196 ,
80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241 , 135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113 ,
24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224 , 80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241 ,
145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95 , 24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224 ,
28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226 , 145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95 ,
71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36 , 28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226 ,
17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106 , 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36 ,
197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136 , 17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106 ,
120, 163, 236, 249 197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136 ,
120, 163, 236, 249
}; };
// Which one is deterministic? // Which one is deterministic?
int P_Random (void) int P_Random( void )
{ {
::g->prndindex = (::g->prndindex+1)&0xff; ::g->prndindex = ( ::g->prndindex + 1 ) & 0xff;
return rndtable[::g->prndindex]; return rndtable[::g->prndindex];
} }
int M_Random (void) int M_Random( void )
{ {
::g->rndindex = (::g->rndindex+1)&0xff; ::g->rndindex = ( ::g->rndindex + 1 ) & 0xff;
return rndtable[::g->rndindex]; return rndtable[::g->rndindex];
} }
void M_ClearRandom (void) void M_ClearRandom( void )
{ {
::g->rndindex = ::g->prndindex = 0; ::g->rndindex = ::g->prndindex = 0;
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -36,13 +36,13 @@ If you have questions concerning this license or the applicable additional terms
// Returns a number from 0 to 255, // Returns a number from 0 to 255,
// from a lookup table. // from a lookup table.
int M_Random (void); int M_Random( void );
// As M_Random, but used only by the play simulation. // As M_Random, but used only by the play simulation.
int P_Random (void); int P_Random( void );
// Fix randoms for demos. // Fix randoms for demos.
void M_ClearRandom (void); void M_ClearRandom( void );
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "m_swap.h" #pragma implementation "m_swap.h"
#endif #endif
#include "m_swap.h" #include "m_swap.h"

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
@ -42,20 +42,20 @@ If you have questions concerning this license or the applicable additional terms
//long SwapLONG(long); //long SwapLONG(long);
// Swap 16bit, that is, MSB and LSB byte. // Swap 16bit, that is, MSB and LSB byte.
inline unsigned short SwapSHORT(unsigned short x) inline unsigned short SwapSHORT( unsigned short x )
{ {
// No masking with 0xFF should be necessary. // No masking with 0xFF should be necessary.
return (x>>8) | (x<<8); return ( x >> 8 ) | ( x << 8 );
} }
// Swapping 32bit. // Swapping 32bit.
inline unsigned long SwapLONG( unsigned long x) inline unsigned long SwapLONG( unsigned long x )
{ {
return return
(x>>24) ( x >> 24 )
| ((x>>8) & 0xff00) | ( ( x >> 8 ) & 0xff00 )
| ((x<<8) & 0xff0000) | ( ( x << 8 ) & 0xff0000 )
| (x<<24); | ( x << 24 );
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -35,104 +35,114 @@ 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); {
} while (c & 0x80); value = ( value << 7 ) + ( ( c = *buffer++ ) & 0x7f );
}
while( c & 0x80 );
} }
return value; return value;
} }
// Writes a variable length integer to a buffer, and returns bytes written // Writes a variable length integer to a buffer, and returns bytes written
int WriteVarLen( long value, byte* out ) 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;
} }
// writes a byte, and returns the buffer // writes a byte, and returns the buffer
unsigned char* WriteByte(void* buf, byte b) unsigned char* WriteByte( void* buf, byte b )
{ {
unsigned char* buffer = (unsigned char*)buf; unsigned char* buffer = ( unsigned char* )buf;
*buffer++ = b; *buffer++ = b;
return buffer; return buffer;
} }
unsigned char* WriteShort(void* b, unsigned short s) unsigned char* WriteShort( void* b, unsigned short s )
{ {
unsigned char* buffer = (unsigned char*)b; unsigned char* buffer = ( unsigned char* )b;
*buffer++ = (s >> 8); *buffer++ = ( s >> 8 );
*buffer++ = (s & 0x00FF); *buffer++ = ( s & 0x00FF );
return buffer; return buffer;
} }
unsigned char* WriteInt(void* b, unsigned int i) unsigned char* WriteInt( void* b, unsigned int i )
{ {
unsigned char* buffer = (unsigned char*)b; unsigned char* buffer = ( unsigned char* )b;
*buffer++ = (i & 0xff000000) >> 24; *buffer++ = ( i & 0xff000000 ) >> 24;
*buffer++ = (i & 0x00ff0000) >> 16; *buffer++ = ( i & 0x00ff0000 ) >> 16;
*buffer++ = (i & 0x0000ff00) >> 8; *buffer++ = ( i & 0x0000ff00 ) >> 8;
*buffer++ = (i & 0x000000ff); *buffer++ = ( i & 0x000000ff );
return buffer; return buffer;
} }
// Format - 0(1 track only), 1(1 or more tracks, each play same time), 2(1 or more, each play seperatly) // Format - 0(1 track only), 1(1 or more tracks, each play same time), 2(1 or more, each play seperatly)
void Midi_CreateHeader(MidiHeaderChunk_t* header, short format, short track_count, short division) void Midi_CreateHeader( MidiHeaderChunk_t* header, short format, short track_count, short division )
{ {
WriteInt(header->name, 'MThd'); WriteInt( header->name, 'MThd' );
WriteInt(&header->length, 6); WriteInt( &header->length, 6 );
WriteShort(&header->format, format); WriteShort( &header->format, format );
WriteShort(&header->ntracks, track_count); WriteShort( &header->ntracks, track_count );
WriteShort(&header->division, division); WriteShort( &header->division, division );
} }
unsigned char* Midi_WriteTempo(unsigned char* buffer, int tempo) unsigned char* Midi_WriteTempo( unsigned char* buffer, int tempo )
{ {
buffer = WriteByte(buffer, 0x00); // delta time buffer = WriteByte( buffer, 0x00 ); // delta time
buffer = WriteByte(buffer, 0xff); // sys command buffer = WriteByte( buffer, 0xff ); // sys command
buffer = WriteShort(buffer, 0x5103); // command - set tempo buffer = WriteShort( buffer, 0x5103 ); // command - set tempo
buffer = WriteByte(buffer, tempo & 0x000000ff); buffer = WriteByte( buffer, tempo & 0x000000ff );
buffer = WriteByte(buffer, (tempo & 0x0000ff00) >> 8); buffer = WriteByte( buffer, ( tempo & 0x0000ff00 ) >> 8 );
buffer = WriteByte(buffer, (tempo & 0x00ff0000) >> 16); buffer = WriteByte( buffer, ( tempo & 0x00ff0000 ) >> 16 );
return buffer; return buffer;
} }
int Midi_UpdateBytesWritten(int* bytes_written, int to_add, int max) int Midi_UpdateBytesWritten( int* bytes_written, int to_add, int max )
{ {
*bytes_written += to_add; *bytes_written += to_add;
if (max && *bytes_written > max) if( max && *bytes_written > max )
{ {
assert(0); assert( 0 );
return 0; return 0;
} }
return 1; return 1;
} }
unsigned char MidiMap[] = unsigned char MidiMap[] =
{ {
0, // prog change 0, // prog change
0, // bank sel 0, // bank sel
@ -152,19 +162,21 @@ 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 ) { {
return value; unsigned short LittleToNative( const unsigned short value )
} {
return value;
}
} }
int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len) int Mus2Midi( unsigned char* bytes, unsigned char* out, int* len )
{ {
// mus header and instruments // mus header and instruments
MUSheader_t header; MUSheader_t header;
// current position in read buffer // current position in read buffer
unsigned char* cur = bytes,* end; unsigned char* cur = bytes, * end;
if( cur[0] != 'M' || cur[1] != 'U' || cur[2] != 'S' ) if( cur[0] != 'M' || cur[1] != 'U' || cur[2] != 'S' )
{ {
return 0; return 0;
@ -176,7 +188,7 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
MidiTrackChunk_t midiTrackHeader; MidiTrackChunk_t midiTrackHeader;
// Stores the position of the midi track header(to change the size) // Stores the position of the midi track header(to change the size)
byte* midiTrackHeaderOut; byte* midiTrackHeaderOut;
// Delta time for midi event // Delta time for midi event
int delta_time = 0; int delta_time = 0;
int temp; int temp;
@ -186,8 +198,8 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
byte last_status = 0; byte last_status = 0;
// read the mus header // read the mus header
memcpy(&header, cur, sizeof(header)); memcpy( &header, cur, sizeof( header ) );
cur += sizeof(header); cur += sizeof( header );
header.scoreLen = LittleToNative( header.scoreLen ); header.scoreLen = LittleToNative( header.scoreLen );
header.scoreStart = LittleToNative( header.scoreStart ); header.scoreStart = LittleToNative( header.scoreStart );
@ -195,13 +207,16 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
header.sec_channels = LittleToNative( header.sec_channels ); header.sec_channels = LittleToNative( header.sec_channels );
header.instrCnt = LittleToNative( header.instrCnt ); header.instrCnt = LittleToNative( header.instrCnt );
header.dummy = LittleToNative( header.dummy ); header.dummy = LittleToNative( header.dummy );
// 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;
} }
@ -212,143 +227,159 @@ int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
end = cur + header.scoreLen; end = cur + header.scoreLen;
// Write out midi header // Write out midi header
Midi_CreateHeader(&midiHeader, 0, 1, 0x0059); Midi_CreateHeader( &midiHeader, 0, 1, 0x0059 );
Midi_UpdateBytesWritten(&bytes_written, MIDIHEADERSIZE, *len); Midi_UpdateBytesWritten( &bytes_written, MIDIHEADERSIZE, *len );
memcpy(out, &midiHeader, MIDIHEADERSIZE); // cannot use sizeof(packs it to 16 bytes) memcpy( out, &midiHeader, MIDIHEADERSIZE ); // cannot use sizeof(packs it to 16 bytes)
out += MIDIHEADERSIZE; out += MIDIHEADERSIZE;
// Store this position, for later filling in the midiTrackHeader // Store this position, for later filling in the midiTrackHeader
Midi_UpdateBytesWritten(&bytes_written, sizeof(midiTrackHeader), *len); Midi_UpdateBytesWritten( &bytes_written, sizeof( midiTrackHeader ), *len );
midiTrackHeaderOut = out; midiTrackHeaderOut = out;
out += sizeof(midiTrackHeader); out += sizeof( midiTrackHeader );
// microseconds per quarter note(yikes) // microseconds per quarter note(yikes)
Midi_UpdateBytesWritten(&bytes_written, 7, *len); Midi_UpdateBytesWritten( &bytes_written, 7, *len );
out = Midi_WriteTempo(out, 0x001aa309); out = Midi_WriteTempo( out, 0x001aa309 );
// Percussions channel starts out at full volume // Percussions channel starts out at full volume
Midi_UpdateBytesWritten(&bytes_written, 4, *len); Midi_UpdateBytesWritten( &bytes_written, 4, *len );
out = WriteByte(out, 0x00); out = WriteByte( out, 0x00 );
out = WriteByte(out, 0xB9); out = WriteByte( out, 0xB9 );
out = WriteByte(out, 0x07); out = WriteByte( out, 0x07 );
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
byte *out_local = temp_buffer; byte* out_local = temp_buffer;
byte status, bit1, bit2, bitc = 2; byte status, bit1, bit2, bitc = 2;
// Read in current bit // Read in current bit
event = *cur++; event = *cur++;
channel = (event & 15); // current channel channel = ( event & 15 ); // current channel
// 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 );
out_local = WriteByte(out_local, 127); out_local = WriteByte( out_local, 127 );
out_local = WriteByte(out_local, 0x00); out_local = WriteByte( out_local, 0x00 );
channelMap[channel] = currentChannel++; channelMap[channel] = currentChannel++;
if (currentChannel == 9) if( currentChannel == 9 )
{
++currentChannel; ++currentChannel;
}
} }
status = channelMap[channel]; status = channelMap[channel];
// Handle ::g->events // Handle ::g->events
switch ((event & 122) >> 4) switch( ( event & 122 ) >> 4 )
{ {
default: default:
assert(0); assert( 0 );
break; break;
case MUSEVENT_KEYOFF: case MUSEVENT_KEYOFF:
status |= 0x80; status |= 0x80;
bit1 = *cur++;
bit2 = 0x40;
break;
case MUSEVENT_KEYON:
status |= 0x90;
bit1 = *cur & 127;
if (*cur++ & 128) // volume bit?
channel_volume[channelMap[channel]] = *cur++;
bit2 = channel_volume[channelMap[channel]];
break;
case MUSEVENT_PITCHWHEEL:
status |= 0xE0;
bit1 = (*cur & 1) >> 6;
bit2 = (*cur++ >> 1) & 127;
break;
case MUSEVENT_CHANNELMODE:
status |= 0xB0;
assert(*cur < sizeof(MidiMap) / sizeof(MidiMap[0]));
bit1 = MidiMap[*cur++];
bit2 = (*cur++ == 12) ? header.channels + 1 : 0x00;
break;
case MUSEVENT_CONTROLLERCHANGE:
if (*cur == 0) {
cur++;
status |= 0xC0;
bit1 = *cur++; bit1 = *cur++;
bitc = 1; bit2 = 0x40;
} else { break;
case MUSEVENT_KEYON:
status |= 0x90;
bit1 = *cur & 127;
if( *cur++ & 128 ) // volume bit?
{
channel_volume[channelMap[channel]] = *cur++;
}
bit2 = channel_volume[channelMap[channel]];
break;
case MUSEVENT_PITCHWHEEL:
status |= 0xE0;
bit1 = ( *cur & 1 ) >> 6;
bit2 = ( *cur++ >> 1 ) & 127;
break;
case MUSEVENT_CHANNELMODE:
status |= 0xB0; status |= 0xB0;
assert(*cur < sizeof(MidiMap) / sizeof(MidiMap[0])); assert( *cur < sizeof( MidiMap ) / sizeof( MidiMap[0] ) );
bit1 = MidiMap[*cur++]; bit1 = MidiMap[*cur++];
bit2 = *cur++; bit2 = ( *cur++ == 12 ) ? header.channels + 1 : 0x00;
} break;
break; case MUSEVENT_CONTROLLERCHANGE:
case 5: // Unknown if( *cur == 0 )
assert(0); {
break; cur++;
case MUSEVENT_END: // End status |= 0xC0;
status = 0xff; bit1 = *cur++;
bit1 = 0x2f; bitc = 1;
bit2 = 0x00; }
assert(cur == end); else
break; {
case 7: // Unknown status |= 0xB0;
assert(0); assert( *cur < sizeof( MidiMap ) / sizeof( MidiMap[0] ) );
break; bit1 = MidiMap[*cur++];
bit2 = *cur++;
}
break;
case 5: // Unknown
assert( 0 );
break;
case MUSEVENT_END: // End
status = 0xff;
bit1 = 0x2f;
bit2 = 0x00;
assert( cur == end );
break;
case 7: // Unknown
assert( 0 );
break;
} }
// Write it out // Write it out
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
if (out_local != temp_buffer) if( out_local != temp_buffer )
{ {
Midi_UpdateBytesWritten(&bytes_written, out_local - temp_buffer, *len); Midi_UpdateBytesWritten( &bytes_written, out_local - temp_buffer, *len );
memcpy(out, temp_buffer, out_local - temp_buffer); memcpy( out, temp_buffer, out_local - temp_buffer );
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); {
} while ((*cur++ & 128)); delta_time = delta_time * 128 + ( *cur & 127 );
} else { }
while( ( *cur++ & 128 ) );
}
else
{
delta_time = 0; delta_time = 0;
} }
} }
// Write out track header // Write out track header
WriteInt(midiTrackHeader.name, 'MTrk'); WriteInt( midiTrackHeader.name, 'MTrk' );
WriteInt(&midiTrackHeader.length, out - midiTrackHeaderOut - sizeof(midiTrackHeader)); WriteInt( &midiTrackHeader.length, out - midiTrackHeaderOut - sizeof( midiTrackHeader ) );
memcpy(midiTrackHeaderOut, &midiTrackHeader, sizeof(midiTrackHeader)); memcpy( midiTrackHeaderOut, &midiTrackHeader, sizeof( midiTrackHeader ) );
// Store length written // Store length written
*len = bytes_written; *len = bytes_written;
/*{ /*{

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -54,118 +54,119 @@ If you have questions concerning this license or the applicable additional terms
// T_MoveCeiling // T_MoveCeiling
// //
void T_MoveCeiling (ceiling_t* ceiling) void T_MoveCeiling( ceiling_t* ceiling )
{ {
result_e res; result_e res;
switch(ceiling->direction)
{
case 0:
// IN STASIS
break;
case 1:
// UP
res = T_MovePlane(ceiling->sector,
ceiling->speed,
ceiling->topheight,
false,1,ceiling->direction);
if (!(::g->leveltime&7))
{
switch(ceiling->type)
{
case silentCrushAndRaise:
break;
default:
S_StartSound( &ceiling->sector->soundorg,
sfx_stnmov);
// ?
break;
}
}
if (res == pastdest)
{
switch(ceiling->type)
{
case raiseToHighest:
P_RemoveActiveCeiling(ceiling);
break;
case silentCrushAndRaise:
S_StartSound( &ceiling->sector->soundorg,
sfx_pstop);
case fastCrushAndRaise:
case crushAndRaise:
ceiling->direction = -1;
break;
default:
break;
}
}
break;
case -1:
// DOWN
res = T_MovePlane(ceiling->sector,
ceiling->speed,
ceiling->bottomheight,
ceiling->crush,1,ceiling->direction);
if (!(::g->leveltime&7))
{
switch(ceiling->type)
{
case silentCrushAndRaise: break;
default:
S_StartSound( &ceiling->sector->soundorg,
sfx_stnmov);
}
}
if (res == pastdest)
{
switch(ceiling->type)
{
case silentCrushAndRaise:
S_StartSound( &ceiling->sector->soundorg,
sfx_pstop);
case crushAndRaise:
ceiling->speed = CEILSPEED;
case fastCrushAndRaise:
ceiling->direction = 1;
break;
case lowerAndCrush: switch( ceiling->direction )
case lowerToFloor:
P_RemoveActiveCeiling(ceiling);
break;
default:
break;
}
}
else // ( res != pastdest )
{ {
if (res == crushed) case 0:
{ // IN STASIS
switch(ceiling->type) break;
{ case 1:
case silentCrushAndRaise: // UP
case crushAndRaise: res = T_MovePlane( ceiling->sector,
case lowerAndCrush: ceiling->speed,
ceiling->speed = CEILSPEED / 8; ceiling->topheight,
break; false, 1, ceiling->direction );
default: if( !( ::g->leveltime & 7 ) )
break; {
} switch( ceiling->type )
} {
case silentCrushAndRaise:
break;
default:
S_StartSound( &ceiling->sector->soundorg,
sfx_stnmov );
// ?
break;
}
}
if( res == pastdest )
{
switch( ceiling->type )
{
case raiseToHighest:
P_RemoveActiveCeiling( ceiling );
break;
case silentCrushAndRaise:
S_StartSound( &ceiling->sector->soundorg,
sfx_pstop );
case fastCrushAndRaise:
case crushAndRaise:
ceiling->direction = -1;
break;
default:
break;
}
}
break;
case -1:
// DOWN
res = T_MovePlane( ceiling->sector,
ceiling->speed,
ceiling->bottomheight,
ceiling->crush, 1, ceiling->direction );
if( !( ::g->leveltime & 7 ) )
{
switch( ceiling->type )
{
case silentCrushAndRaise:
break;
default:
S_StartSound( &ceiling->sector->soundorg,
sfx_stnmov );
}
}
if( res == pastdest )
{
switch( ceiling->type )
{
case silentCrushAndRaise:
S_StartSound( &ceiling->sector->soundorg,
sfx_pstop );
case crushAndRaise:
ceiling->speed = CEILSPEED;
case fastCrushAndRaise:
ceiling->direction = 1;
break;
case lowerAndCrush:
case lowerToFloor:
P_RemoveActiveCeiling( ceiling );
break;
default:
break;
}
}
else // ( res != pastdest )
{
if( res == crushed )
{
switch( ceiling->type )
{
case silentCrushAndRaise:
case crushAndRaise:
case lowerAndCrush:
ceiling->speed = CEILSPEED / 8;
break;
default:
break;
}
}
}
break;
} }
break;
}
} }
@ -178,93 +179,97 @@ EV_DoCeiling
( line_t* line, ( line_t* line,
ceiling_e type ) ceiling_e type )
{ {
int secnum; int secnum;
int rtn; int rtn;
sector_t* sec; sector_t* sec;
ceiling_t* ceiling; ceiling_t* ceiling;
secnum = -1; secnum = -1;
rtn = 0; rtn = 0;
// Reactivate in-stasis ceilings...for certain types. // Reactivate in-stasis ceilings...for certain types.
switch(type) switch( type )
{
case fastCrushAndRaise:
case silentCrushAndRaise:
case crushAndRaise:
P_ActivateInStasisCeiling(line);
default:
break;
}
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
{
sec = &::g->sectors[secnum];
if (sec->specialdata)
continue;
// new door thinker
rtn = 1;
ceiling = (ceiling_t*)DoomLib::Z_Malloc(sizeof(*ceiling), PU_LEVEL, 0);
P_AddThinker (&ceiling->thinker);
sec->specialdata = ceiling;
ceiling->thinker.function.acp1 = (actionf_p1)T_MoveCeiling;
ceiling->sector = sec;
ceiling->crush = false;
switch(type)
{ {
case fastCrushAndRaise: case fastCrushAndRaise:
ceiling->crush = true; case silentCrushAndRaise:
ceiling->topheight = sec->ceilingheight; case crushAndRaise:
ceiling->bottomheight = sec->floorheight + (8*FRACUNIT); P_ActivateInStasisCeiling( line );
ceiling->direction = -1; default:
ceiling->speed = CEILSPEED * 2; break;
break;
case silentCrushAndRaise:
case crushAndRaise:
ceiling->crush = true;
ceiling->topheight = sec->ceilingheight;
case lowerAndCrush:
case lowerToFloor:
ceiling->bottomheight = sec->floorheight;
if (type != lowerToFloor)
ceiling->bottomheight += 8*FRACUNIT;
ceiling->direction = -1;
ceiling->speed = CEILSPEED;
break;
case raiseToHighest:
ceiling->topheight = P_FindHighestCeilingSurrounding(sec);
ceiling->direction = 1;
ceiling->speed = CEILSPEED;
break;
} }
ceiling->tag = sec->tag; while( ( secnum = P_FindSectorFromLineTag( line, secnum ) ) >= 0 )
ceiling->type = type; {
P_AddActiveCeiling(ceiling); sec = &::g->sectors[secnum];
} if( sec->specialdata )
return rtn; {
continue;
}
// new door thinker
rtn = 1;
ceiling = ( ceiling_t* )DoomLib::Z_Malloc( sizeof( *ceiling ), PU_LEVEL, 0 );
P_AddThinker( &ceiling->thinker );
sec->specialdata = ceiling;
ceiling->thinker.function.acp1 = ( actionf_p1 )T_MoveCeiling;
ceiling->sector = sec;
ceiling->crush = false;
switch( type )
{
case fastCrushAndRaise:
ceiling->crush = true;
ceiling->topheight = sec->ceilingheight;
ceiling->bottomheight = sec->floorheight + ( 8 * FRACUNIT );
ceiling->direction = -1;
ceiling->speed = CEILSPEED * 2;
break;
case silentCrushAndRaise:
case crushAndRaise:
ceiling->crush = true;
ceiling->topheight = sec->ceilingheight;
case lowerAndCrush:
case lowerToFloor:
ceiling->bottomheight = sec->floorheight;
if( type != lowerToFloor )
{
ceiling->bottomheight += 8 * FRACUNIT;
}
ceiling->direction = -1;
ceiling->speed = CEILSPEED;
break;
case raiseToHighest:
ceiling->topheight = P_FindHighestCeilingSurrounding( sec );
ceiling->direction = 1;
ceiling->speed = CEILSPEED;
break;
}
ceiling->tag = sec->tag;
ceiling->type = type;
P_AddActiveCeiling( ceiling );
}
return rtn;
} }
// //
// Add an active ceiling // Add an active ceiling
// //
void P_AddActiveCeiling(ceiling_t* c) void P_AddActiveCeiling( ceiling_t* c )
{ {
int i; int i;
for (i = 0; i < MAXCEILINGS;i++) for( i = 0; i < MAXCEILINGS; i++ )
{
if (::g->activeceilings[i] == NULL)
{ {
::g->activeceilings[i] = c; if( ::g->activeceilings[i] == NULL )
return; {
::g->activeceilings[i] = c;
return;
}
} }
}
} }
@ -272,20 +277,20 @@ void P_AddActiveCeiling(ceiling_t* c)
// //
// Remove a ceiling's thinker // Remove a ceiling's thinker
// //
void P_RemoveActiveCeiling(ceiling_t* c) void P_RemoveActiveCeiling( ceiling_t* c )
{ {
int i; int i;
for (i = 0;i < MAXCEILINGS;i++) for( i = 0; i < MAXCEILINGS; i++ )
{
if (::g->activeceilings[i] == c)
{ {
::g->activeceilings[i]->sector->specialdata = NULL; if( ::g->activeceilings[i] == c )
P_RemoveThinker (&::g->activeceilings[i]->thinker); {
::g->activeceilings[i] = NULL; ::g->activeceilings[i]->sector->specialdata = NULL;
break; P_RemoveThinker( &::g->activeceilings[i]->thinker );
::g->activeceilings[i] = NULL;
break;
}
} }
}
} }
@ -293,21 +298,21 @@ void P_RemoveActiveCeiling(ceiling_t* c)
// //
// Restart a ceiling that's in-stasis // Restart a ceiling that's in-stasis
// //
void P_ActivateInStasisCeiling(line_t* line) void P_ActivateInStasisCeiling( line_t* line )
{ {
int i; int i;
for (i = 0;i < MAXCEILINGS;i++) for( i = 0; i < MAXCEILINGS; i++ )
{
if (::g->activeceilings[i]
&& (::g->activeceilings[i]->tag == line->tag)
&& (::g->activeceilings[i]->direction == 0))
{ {
::g->activeceilings[i]->direction = ::g->activeceilings[i]->olddirection; if( ::g->activeceilings[i]
::g->activeceilings[i]->thinker.function.acp1 && ( ::g->activeceilings[i]->tag == line->tag )
= (actionf_p1)T_MoveCeiling; && ( ::g->activeceilings[i]->direction == 0 ) )
{
::g->activeceilings[i]->direction = ::g->activeceilings[i]->olddirection;
::g->activeceilings[i]->thinker.function.acp1
= ( actionf_p1 )T_MoveCeiling;
}
} }
}
} }
@ -316,26 +321,26 @@ void P_ActivateInStasisCeiling(line_t* line)
// EV_CeilingCrushStop // EV_CeilingCrushStop
// Stop a ceiling from crushing! // Stop a ceiling from crushing!
// //
int EV_CeilingCrushStop(line_t *line) int EV_CeilingCrushStop( line_t* line )
{ {
int i; int i;
int rtn; int rtn;
rtn = 0;
for (i = 0;i < MAXCEILINGS;i++)
{
if (::g->activeceilings[i]
&& (::g->activeceilings[i]->tag == line->tag)
&& (::g->activeceilings[i]->direction != 0))
{
::g->activeceilings[i]->olddirection = ::g->activeceilings[i]->direction;
::g->activeceilings[i]->thinker.function.acv = (actionf_v)NULL;
::g->activeceilings[i]->direction = 0; // in-stasis
rtn = 1;
}
}
return rtn; rtn = 0;
for( i = 0; i < MAXCEILINGS; i++ )
{
if( ::g->activeceilings[i]
&& ( ::g->activeceilings[i]->tag == line->tag )
&& ( ::g->activeceilings[i]->direction != 0 ) )
{
::g->activeceilings[i]->olddirection = ::g->activeceilings[i]->direction;
::g->activeceilings[i]->thinker.function.acv = ( actionf_v )NULL;
::g->activeceilings[i]->direction = 0; // in-stasis
rtn = 1;
}
}
return rtn;
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -55,141 +55,141 @@ extern bool globalNetworking;
// //
// T_VerticalDoor // T_VerticalDoor
// //
void T_VerticalDoor (vldoor_t* door) void T_VerticalDoor( vldoor_t* door )
{ {
result_e res; result_e res;
switch(door->direction) switch( door->direction )
{
case 0:
// WAITING
if (!--door->topcountdown)
{ {
switch(door->type) case 0:
{ // WAITING
case blazeRaise: if( !--door->topcountdown )
door->direction = -1; // time to go back down {
S_StartSound( &door->sector->soundorg, switch( door->type )
sfx_bdcls); {
break; case blazeRaise:
door->direction = -1; // time to go back down
case normal: S_StartSound( &door->sector->soundorg,
door->direction = -1; // time to go back down sfx_bdcls );
S_StartSound( &door->sector->soundorg, break;
sfx_dorcls);
break; case normal:
door->direction = -1; // time to go back down
case close30ThenOpen: S_StartSound( &door->sector->soundorg,
door->direction = 1; sfx_dorcls );
S_StartSound( &door->sector->soundorg, break;
sfx_doropn);
break; case close30ThenOpen:
door->direction = 1;
default: S_StartSound( &door->sector->soundorg,
break; sfx_doropn );
} break;
default:
break;
}
}
break;
case 2:
// INITIAL WAIT
if( !--door->topcountdown )
{
switch( door->type )
{
case raiseIn5Mins:
door->direction = 1;
door->type = normal;
S_StartSound( &door->sector->soundorg,
sfx_doropn );
break;
default:
break;
}
}
break;
case -1:
// DOWN
res = T_MovePlane( door->sector,
door->speed,
door->sector->floorheight,
false, 1, door->direction );
if( res == pastdest )
{
switch( door->type )
{
case blazeRaise:
case blazeClose:
door->sector->specialdata = NULL;
P_RemoveThinker( &door->thinker ); // unlink and free
S_StartSound( &door->sector->soundorg,
sfx_bdcls );
break;
case normal:
case closed:
door->sector->specialdata = NULL;
P_RemoveThinker( &door->thinker ); // unlink and free
break;
case close30ThenOpen:
door->direction = 0;
door->topcountdown = TICRATE * 30;
break;
default:
break;
}
}
else if( res == crushed )
{
switch( door->type )
{
case blazeClose:
case closed: // DO NOT GO BACK UP!
break;
default:
door->direction = 1;
S_StartSound( &door->sector->soundorg,
sfx_doropn );
break;
}
}
break;
case 1:
// UP
res = T_MovePlane( door->sector,
door->speed,
door->topheight,
false, 1, door->direction );
if( res == pastdest )
{
switch( door->type )
{
case blazeRaise:
case normal:
door->direction = 0; // wait at top
door->topcountdown = door->topwait;
break;
case close30ThenOpen:
case blazeOpen:
case opened:
door->sector->specialdata = NULL;
P_RemoveThinker( &door->thinker ); // unlink and free
break;
default:
break;
}
}
break;
} }
break;
case 2:
// INITIAL WAIT
if (!--door->topcountdown)
{
switch(door->type)
{
case raiseIn5Mins:
door->direction = 1;
door->type = normal;
S_StartSound( &door->sector->soundorg,
sfx_doropn);
break;
default:
break;
}
}
break;
case -1:
// DOWN
res = T_MovePlane(door->sector,
door->speed,
door->sector->floorheight,
false,1,door->direction);
if (res == pastdest)
{
switch(door->type)
{
case blazeRaise:
case blazeClose:
door->sector->specialdata = NULL;
P_RemoveThinker (&door->thinker); // unlink and free
S_StartSound( &door->sector->soundorg,
sfx_bdcls);
break;
case normal:
case closed:
door->sector->specialdata = NULL;
P_RemoveThinker (&door->thinker); // unlink and free
break;
case close30ThenOpen:
door->direction = 0;
door->topcountdown = TICRATE*30;
break;
default:
break;
}
}
else if (res == crushed)
{
switch(door->type)
{
case blazeClose:
case closed: // DO NOT GO BACK UP!
break;
default:
door->direction = 1;
S_StartSound( &door->sector->soundorg,
sfx_doropn);
break;
}
}
break;
case 1:
// UP
res = T_MovePlane(door->sector,
door->speed,
door->topheight,
false,1,door->direction);
if (res == pastdest)
{
switch(door->type)
{
case blazeRaise:
case normal:
door->direction = 0; // wait at top
door->topcountdown = door->topwait;
break;
case close30ThenOpen:
case blazeOpen:
case opened:
door->sector->specialdata = NULL;
P_RemoveThinker (&door->thinker); // unlink and free
break;
default:
break;
}
}
break;
}
} }
@ -204,57 +204,71 @@ EV_DoLockedDoor
vldoor_e type, vldoor_e type,
mobj_t* thing ) mobj_t* thing )
{ {
player_t* p; player_t* p;
p = thing->player;
if (!p)
return 0;
switch(line->special)
{
case 99: // Blue Lock
case 133:
if ( !p )
return 0;
if (!p->cards[it_bluecard] && !p->cards[it_blueskull])
{
p->message = PD_BLUEO;
if (p == &::g->players[::g->consoleplayer])
S_StartSound(NULL,sfx_oof);
return 0;
}
break;
case 134: // Red Lock
case 135:
if ( !p )
return 0;
if (!p->cards[it_redcard] && !p->cards[it_redskull])
{
p->message = PD_REDO;
if (p == &::g->players[::g->consoleplayer])
S_StartSound(NULL,sfx_oof);
return 0;
}
break;
case 136: // Yellow Lock
case 137:
if ( !p )
return 0;
if (!p->cards[it_yellowcard] &&
!p->cards[it_yellowskull])
{
p->message = PD_YELLOWO;
if (p == &::g->players[::g->consoleplayer])
S_StartSound(NULL,sfx_oof);
return 0;
}
break;
}
return EV_DoDoor(line,type); p = thing->player;
if( !p )
{
return 0;
}
switch( line->special )
{
case 99: // Blue Lock
case 133:
if( !p )
{
return 0;
}
if( !p->cards[it_bluecard] && !p->cards[it_blueskull] )
{
p->message = PD_BLUEO;
if( p == &::g->players[::g->consoleplayer] )
{
S_StartSound( NULL, sfx_oof );
}
return 0;
}
break;
case 134: // Red Lock
case 135:
if( !p )
{
return 0;
}
if( !p->cards[it_redcard] && !p->cards[it_redskull] )
{
p->message = PD_REDO;
if( p == &::g->players[::g->consoleplayer] )
{
S_StartSound( NULL, sfx_oof );
}
return 0;
}
break;
case 136: // Yellow Lock
case 137:
if( !p )
{
return 0;
}
if( !p->cards[it_yellowcard] &&
!p->cards[it_yellowskull] )
{
p->message = PD_YELLOWO;
if( p == &::g->players[::g->consoleplayer] )
{
S_StartSound( NULL, sfx_oof );
}
return 0;
}
break;
}
return EV_DoDoor( line, type );
} }
@ -263,85 +277,87 @@ EV_DoDoor
( line_t* line, ( line_t* line,
vldoor_e type ) vldoor_e type )
{ {
int secnum,rtn; int secnum, rtn;
sector_t* sec; sector_t* sec;
vldoor_t* door; vldoor_t* door;
secnum = -1;
rtn = 0;
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
{
sec = &::g->sectors[secnum];
if (sec->specialdata)
continue;
// new door thinker
rtn = 1;
door = (vldoor_t*)DoomLib::Z_Malloc(sizeof(*door), PU_LEVEL, 0);
P_AddThinker (&door->thinker);
sec->specialdata = door;
door->thinker.function.acp1 = (actionf_p1) T_VerticalDoor; secnum = -1;
door->sector = sec; rtn = 0;
door->type = type;
door->topwait = VDOORWAIT; while( ( secnum = P_FindSectorFromLineTag( line, secnum ) ) >= 0 )
door->speed = VDOORSPEED;
switch(type)
{ {
case blazeClose: sec = &::g->sectors[secnum];
door->topheight = P_FindLowestCeilingSurrounding(sec); if( sec->specialdata )
door->topheight -= 4*FRACUNIT; {
door->direction = -1; continue;
door->speed = VDOORSPEED * 4; }
S_StartSound( &door->sector->soundorg,
sfx_bdcls);
break; // new door thinker
rtn = 1;
case closed: door = ( vldoor_t* )DoomLib::Z_Malloc( sizeof( *door ), PU_LEVEL, 0 );
door->topheight = P_FindLowestCeilingSurrounding(sec); P_AddThinker( &door->thinker );
door->topheight -= 4*FRACUNIT; sec->specialdata = door;
door->direction = -1;
S_StartSound( &door->sector->soundorg, door->thinker.function.acp1 = ( actionf_p1 ) T_VerticalDoor;
sfx_dorcls); door->sector = sec;
break; door->type = type;
door->topwait = VDOORWAIT;
case close30ThenOpen: door->speed = VDOORSPEED;
door->topheight = sec->ceilingheight;
door->direction = -1; switch( type )
S_StartSound( &door->sector->soundorg, {
sfx_dorcls); case blazeClose:
break; door->topheight = P_FindLowestCeilingSurrounding( sec );
door->topheight -= 4 * FRACUNIT;
case blazeRaise: door->direction = -1;
case blazeOpen: door->speed = VDOORSPEED * 4;
door->direction = 1; S_StartSound( &door->sector->soundorg,
door->topheight = P_FindLowestCeilingSurrounding(sec); sfx_bdcls );
door->topheight -= 4*FRACUNIT; break;
door->speed = VDOORSPEED * 4;
if (door->topheight != sec->ceilingheight) case closed:
S_StartSound( &door->sector->soundorg, door->topheight = P_FindLowestCeilingSurrounding( sec );
sfx_bdopn); door->topheight -= 4 * FRACUNIT;
break; door->direction = -1;
S_StartSound( &door->sector->soundorg,
case normal: sfx_dorcls );
case opened: break;
door->direction = 1;
door->topheight = P_FindLowestCeilingSurrounding(sec); case close30ThenOpen:
door->topheight -= 4*FRACUNIT; door->topheight = sec->ceilingheight;
if (door->topheight != sec->ceilingheight) door->direction = -1;
S_StartSound( &door->sector->soundorg, S_StartSound( &door->sector->soundorg,
sfx_doropn); sfx_dorcls );
break; break;
default: case blazeRaise:
break; case blazeOpen:
door->direction = 1;
door->topheight = P_FindLowestCeilingSurrounding( sec );
door->topheight -= 4 * FRACUNIT;
door->speed = VDOORSPEED * 4;
if( door->topheight != sec->ceilingheight )
S_StartSound( &door->sector->soundorg,
sfx_bdopn );
break;
case normal:
case opened:
door->direction = 1;
door->topheight = P_FindLowestCeilingSurrounding( sec );
door->topheight -= 4 * FRACUNIT;
if( door->topheight != sec->ceilingheight )
S_StartSound( &door->sector->soundorg,
sfx_doropn );
break;
default:
break;
}
} }
return rtn;
}
return rtn;
} }
@ -353,175 +369,192 @@ EV_VerticalDoor
( line_t* line, ( line_t* line,
mobj_t* thing ) mobj_t* thing )
{ {
player_t* player; player_t* player;
int secnum; int secnum;
sector_t* sec; sector_t* sec;
vldoor_t* door; vldoor_t* door;
int side; int side;
side = 0; // only front ::g->sides can be used
// Check for locks side = 0; // only front ::g->sides can be used
player = thing->player;
switch(line->special)
{
case 26: // Blue Lock
case 32:
if ( !player )
return;
if (!player->cards[it_bluecard] && !player->cards[it_blueskull])
{
player->message = PD_BLUEK;
if (globalNetworking || (player == &::g->players[::g->consoleplayer]))
S_StartSound(player->mo,sfx_oof);
return;
}
break;
case 27: // Yellow Lock
case 34:
if ( !player )
return;
if (!player->cards[it_yellowcard] &&
!player->cards[it_yellowskull])
{
player->message = PD_YELLOWK;
if (globalNetworking || (player == &::g->players[::g->consoleplayer]))
S_StartSound(player->mo,sfx_oof);
return;
}
break;
case 28: // Red Lock
case 33:
if ( !player )
return;
if (!player->cards[it_redcard] && !player->cards[it_redskull])
{
player->message = PD_REDK;
if (globalNetworking || (player == &::g->players[::g->consoleplayer]))
S_StartSound(player->mo,sfx_oof);
return;
}
break;
}
// if the sector has an active thinker, use it
sec = ::g->sides[ line->sidenum[side^1]] .sector;
secnum = sec-::g->sectors;
if (sec->specialdata) // Check for locks
{ player = thing->player;
door = (vldoor_t*)sec->specialdata;
switch(line->special) switch( line->special )
{ {
case 1: // ONLY FOR "RAISE" DOORS, NOT "OPEN"s case 26: // Blue Lock
case 26: case 32:
case 27: if( !player )
case 28: {
case 117: return;
if (door->direction == -1) }
door->direction = 1; // go back up
else if( !player->cards[it_bluecard] && !player->cards[it_blueskull] )
{ {
if (!thing->player) player->message = PD_BLUEK;
return; // JDC: bad guys never close doors if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
door->direction = -1; // start going down immediately S_StartSound( player->mo, sfx_oof );
} }
return; return;
}
break;
case 27: // Yellow Lock
case 34:
if( !player )
{
return;
}
if( !player->cards[it_yellowcard] &&
!player->cards[it_yellowskull] )
{
player->message = PD_YELLOWK;
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_oof );
}
return;
}
break;
case 28: // Red Lock
case 33:
if( !player )
{
return;
}
if( !player->cards[it_redcard] && !player->cards[it_redskull] )
{
player->message = PD_REDK;
if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
{
S_StartSound( player->mo, sfx_oof );
}
return;
}
break;
} }
}
// if the sector has an active thinker, use it
// for proper sound sec = ::g->sides[ line->sidenum[side ^ 1]] .sector;
if (globalNetworking || (player == &::g->players[::g->consoleplayer])) { secnum = sec -::g->sectors;
switch(line->special)
if( sec->specialdata )
{
door = ( vldoor_t* )sec->specialdata;
switch( line->special )
{ {
case 117: // BLAZING DOOR RAISE case 1: // ONLY FOR "RAISE" DOORS, NOT "OPEN"s
case 118: // BLAZING DOOR OPEN case 26:
S_StartSound( &sec->soundorg,sfx_bdopn); case 27:
break; case 28:
case 117:
if( door->direction == -1 )
{
door->direction = 1; // go back up
}
else
{
if( !thing->player )
{
return; // JDC: bad guys never close doors
}
case 1: // NORMAL DOOR SOUND door->direction = -1; // start going down immediately
case 31: }
S_StartSound( &sec->soundorg,sfx_doropn); return;
break;
default: // LOCKED DOOR SOUND
S_StartSound( &sec->soundorg,sfx_doropn);
break;
} }
} }
// new door thinker
door = (vldoor_t*)DoomLib::Z_Malloc(sizeof(*door), PU_LEVEL, 0);
P_AddThinker (&door->thinker);
sec->specialdata = door;
door->thinker.function.acp1 = (actionf_p1) T_VerticalDoor;
door->sector = sec;
door->direction = 1;
door->speed = VDOORSPEED;
door->topwait = VDOORWAIT;
switch(line->special) // for proper sound
{ if( globalNetworking || ( player == &::g->players[::g->consoleplayer] ) )
case 1: {
case 26: switch( line->special )
case 27: {
case 28: case 117: // BLAZING DOOR RAISE
door->type = normal; case 118: // BLAZING DOOR OPEN
break; S_StartSound( &sec->soundorg, sfx_bdopn );
break;
case 31:
case 32: case 1: // NORMAL DOOR SOUND
case 33: case 31:
case 34: S_StartSound( &sec->soundorg, sfx_doropn );
door->type = opened; break;
line->special = 0;
break; default: // LOCKED DOOR SOUND
S_StartSound( &sec->soundorg, sfx_doropn );
case 117: // blazing door raise break;
door->type = blazeRaise; }
door->speed = VDOORSPEED*4; }
break;
case 118: // blazing door open
door->type = blazeOpen; // new door thinker
line->special = 0; door = ( vldoor_t* )DoomLib::Z_Malloc( sizeof( *door ), PU_LEVEL, 0 );
door->speed = VDOORSPEED*4; P_AddThinker( &door->thinker );
break; sec->specialdata = door;
} door->thinker.function.acp1 = ( actionf_p1 ) T_VerticalDoor;
door->sector = sec;
// find the top and bottom of the movement range door->direction = 1;
door->topheight = P_FindLowestCeilingSurrounding(sec); door->speed = VDOORSPEED;
door->topheight -= 4*FRACUNIT; door->topwait = VDOORWAIT;
switch( line->special )
{
case 1:
case 26:
case 27:
case 28:
door->type = normal;
break;
case 31:
case 32:
case 33:
case 34:
door->type = opened;
line->special = 0;
break;
case 117: // blazing door raise
door->type = blazeRaise;
door->speed = VDOORSPEED * 4;
break;
case 118: // blazing door open
door->type = blazeOpen;
line->special = 0;
door->speed = VDOORSPEED * 4;
break;
}
// find the top and bottom of the movement range
door->topheight = P_FindLowestCeilingSurrounding( sec );
door->topheight -= 4 * FRACUNIT;
} }
// //
// Spawn a door that closes after 30 seconds // Spawn a door that closes after 30 seconds
// //
void P_SpawnDoorCloseIn30 (sector_t* sec) void P_SpawnDoorCloseIn30( sector_t* sec )
{ {
vldoor_t* door; vldoor_t* door;
door = (vldoor_t*)DoomLib::Z_Malloc( sizeof(*door), PU_LEVEL, 0);
P_AddThinker (&door->thinker); door = ( vldoor_t* )DoomLib::Z_Malloc( sizeof( *door ), PU_LEVEL, 0 );
sec->specialdata = door; P_AddThinker( &door->thinker );
sec->special = 0;
door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor; sec->specialdata = door;
door->sector = sec; sec->special = 0;
door->direction = 0;
door->type = normal; door->thinker.function.acp1 = ( actionf_p1 )T_VerticalDoor;
door->speed = VDOORSPEED; door->sector = sec;
door->topcountdown = 30 * TICRATE; door->direction = 0;
door->type = normal;
door->speed = VDOORSPEED;
door->topcountdown = 30 * TICRATE;
} }
// //
@ -532,24 +565,24 @@ P_SpawnDoorRaiseIn5Mins
( sector_t* sec, ( sector_t* sec,
int secnum ) int secnum )
{ {
vldoor_t* door; vldoor_t* door;
door = (vldoor_t*)DoomLib::Z_Malloc( sizeof(*door), PU_LEVEL, 0);
P_AddThinker (&door->thinker);
sec->specialdata = door; door = ( vldoor_t* )DoomLib::Z_Malloc( sizeof( *door ), PU_LEVEL, 0 );
sec->special = 0;
door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor; P_AddThinker( &door->thinker );
door->sector = sec;
door->direction = 2; sec->specialdata = door;
door->type = raiseIn5Mins; sec->special = 0;
door->speed = VDOORSPEED;
door->topheight = P_FindLowestCeilingSurrounding(sec); door->thinker.function.acp1 = ( actionf_p1 )T_VerticalDoor;
door->topheight -= 4*FRACUNIT; door->sector = sec;
door->topwait = VDOORWAIT; door->direction = 2;
door->topcountdown = 5 * 60 * TICRATE; door->type = raiseIn5Mins;
door->speed = VDOORSPEED;
door->topheight = P_FindLowestCeilingSurrounding( sec );
door->topheight -= 4 * FRACUNIT;
door->topwait = VDOORWAIT;
door->topcountdown = 5 * 60 * TICRATE;
} }

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -59,202 +59,206 @@ T_MovePlane
int floorOrCeiling, int floorOrCeiling,
int direction ) int direction )
{ {
qboolean flag; qboolean flag;
fixed_t lastpos; fixed_t lastpos;
switch(floorOrCeiling)
{
case 0:
// FLOOR
switch(direction)
{
case -1:
// DOWN
if (sector->floorheight - speed < dest)
{
lastpos = sector->floorheight;
sector->floorheight = dest;
flag = P_ChangeSector(sector,crush);
if (flag == true)
{
sector->floorheight =lastpos;
P_ChangeSector(sector,crush);
//return crushed;
}
return pastdest;
}
else
{
lastpos = sector->floorheight;
sector->floorheight -= speed;
flag = P_ChangeSector(sector,crush);
if (flag == true)
{
sector->floorheight = lastpos;
P_ChangeSector(sector,crush);
return crushed;
}
}
break;
case 1:
// UP
if (sector->floorheight + speed > dest)
{
lastpos = sector->floorheight;
sector->floorheight = dest;
flag = P_ChangeSector(sector,crush);
if (flag == true)
{
sector->floorheight = lastpos;
P_ChangeSector(sector,crush);
//return crushed;
}
return pastdest;
}
else
{
// COULD GET CRUSHED
lastpos = sector->floorheight;
sector->floorheight += speed;
flag = P_ChangeSector(sector,crush);
if (flag == true)
{
if (crush == true)
return crushed;
sector->floorheight = lastpos;
P_ChangeSector(sector,crush);
return crushed;
}
}
break;
}
break;
case 1:
// CEILING
switch(direction)
{
case -1:
// DOWN
if (sector->ceilingheight - speed < dest)
{
lastpos = sector->ceilingheight;
sector->ceilingheight = dest;
flag = P_ChangeSector(sector,crush);
if (flag == true) switch( floorOrCeiling )
{ {
sector->ceilingheight = lastpos; case 0:
P_ChangeSector(sector,crush); // FLOOR
//return crushed; switch( direction )
} {
return pastdest; case -1:
} // DOWN
else if( sector->floorheight - speed < dest )
{ {
// COULD GET CRUSHED lastpos = sector->floorheight;
lastpos = sector->ceilingheight; sector->floorheight = dest;
sector->ceilingheight -= speed; flag = P_ChangeSector( sector, crush );
flag = P_ChangeSector(sector,crush); if( flag == true )
{
sector->floorheight = lastpos;
P_ChangeSector( sector, crush );
//return crushed;
}
return pastdest;
}
else
{
lastpos = sector->floorheight;
sector->floorheight -= speed;
flag = P_ChangeSector( sector, crush );
if( flag == true )
{
sector->floorheight = lastpos;
P_ChangeSector( sector, crush );
return crushed;
}
}
break;
if (flag == true) case 1:
{ // UP
if (crush == true) if( sector->floorheight + speed > dest )
return crushed; {
sector->ceilingheight = lastpos; lastpos = sector->floorheight;
P_ChangeSector(sector,crush); sector->floorheight = dest;
return crushed; flag = P_ChangeSector( sector, crush );
} if( flag == true )
} {
break; sector->floorheight = lastpos;
P_ChangeSector( sector, crush );
case 1: //return crushed;
// UP }
if (sector->ceilingheight + speed > dest) return pastdest;
{ }
lastpos = sector->ceilingheight; else
sector->ceilingheight = dest; {
flag = P_ChangeSector(sector,crush); // COULD GET CRUSHED
if (flag == true) lastpos = sector->floorheight;
{ sector->floorheight += speed;
sector->ceilingheight = lastpos; flag = P_ChangeSector( sector, crush );
P_ChangeSector(sector,crush); if( flag == true )
//return crushed; {
} if( crush == true )
return pastdest; {
} return crushed;
else }
{ sector->floorheight = lastpos;
lastpos = sector->ceilingheight; P_ChangeSector( sector, crush );
sector->ceilingheight += speed; return crushed;
flag = P_ChangeSector(sector,crush); }
}
break;
}
break;
case 1:
// CEILING
switch( direction )
{
case -1:
// DOWN
if( sector->ceilingheight - speed < dest )
{
lastpos = sector->ceilingheight;
sector->ceilingheight = dest;
flag = P_ChangeSector( sector, crush );
if( flag == true )
{
sector->ceilingheight = lastpos;
P_ChangeSector( sector, crush );
//return crushed;
}
return pastdest;
}
else
{
// COULD GET CRUSHED
lastpos = sector->ceilingheight;
sector->ceilingheight -= speed;
flag = P_ChangeSector( sector, crush );
if( flag == true )
{
if( crush == true )
{
return crushed;
}
sector->ceilingheight = lastpos;
P_ChangeSector( sector, crush );
return crushed;
}
}
break;
case 1:
// UP
if( sector->ceilingheight + speed > dest )
{
lastpos = sector->ceilingheight;
sector->ceilingheight = dest;
flag = P_ChangeSector( sector, crush );
if( flag == true )
{
sector->ceilingheight = lastpos;
P_ChangeSector( sector, crush );
//return crushed;
}
return pastdest;
}
else
{
lastpos = sector->ceilingheight;
sector->ceilingheight += speed;
flag = P_ChangeSector( sector, crush );
// UNUSED // UNUSED
#if 0 #if 0
if (flag == true) if( flag == true )
{ {
sector->ceilingheight = lastpos; sector->ceilingheight = lastpos;
P_ChangeSector(sector,crush); P_ChangeSector( sector, crush );
return crushed; return crushed;
} }
#endif #endif
} }
break; break;
}
break;
} }
break; return ok;
}
return ok;
} }
// //
// MOVE A FLOOR TO IT'S DESTINATION (UP OR DOWN) // MOVE A FLOOR TO IT'S DESTINATION (UP OR DOWN)
// //
void T_MoveFloor(floormove_t* floor) void T_MoveFloor( floormove_t* floor )
{ {
result_e res; result_e res;
res = T_MovePlane(floor->sector,
floor->speed,
floor->floordestheight,
floor->crush,0,floor->direction);
if (!(::g->leveltime&7))
S_StartSound( &floor->sector->soundorg,
sfx_stnmov);
if (res == pastdest)
{
floor->sector->specialdata = NULL;
if (floor->direction == 1) res = T_MovePlane( floor->sector,
{ floor->speed,
switch(floor->type) floor->floordestheight,
{ floor->crush, 0, floor->direction );
case donutRaise:
floor->sector->special = floor->newspecial;
floor->sector->floorpic = floor->texture;
default:
break;
}
}
else if (floor->direction == -1)
{
switch(floor->type)
{
case lowerAndChange:
floor->sector->special = floor->newspecial;
floor->sector->floorpic = floor->texture;
default:
break;
}
}
P_RemoveThinker(&floor->thinker);
S_StartSound( &floor->sector->soundorg, if( !( ::g->leveltime & 7 ) )
sfx_pstop); S_StartSound( &floor->sector->soundorg,
} sfx_stnmov );
if( res == pastdest )
{
floor->sector->specialdata = NULL;
if( floor->direction == 1 )
{
switch( floor->type )
{
case donutRaise:
floor->sector->special = floor->newspecial;
floor->sector->floorpic = floor->texture;
default:
break;
}
}
else if( floor->direction == -1 )
{
switch( floor->type )
{
case lowerAndChange:
floor->sector->special = floor->newspecial;
floor->sector->floorpic = floor->texture;
default:
break;
}
}
P_RemoveThinker( &floor->thinker );
S_StartSound( &floor->sector->soundorg,
sfx_pstop );
}
} }
@ -266,186 +270,192 @@ EV_DoFloor
( line_t* line, ( line_t* line,
floor_e floortype ) floor_e floortype )
{ {
int secnum; int secnum;
int rtn; int rtn;
int i; int i;
sector_t* sec; sector_t* sec;
floormove_t* floor; floormove_t* floor;
secnum = -1; secnum = -1;
rtn = 0; rtn = 0;
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) while( ( secnum = P_FindSectorFromLineTag( line, secnum ) ) >= 0 )
{
sec = &::g->sectors[secnum];
// ALREADY MOVING? IF SO, KEEP GOING...
if (sec->specialdata)
continue;
// new floor thinker
rtn = 1;
floor = (floormove_t*)DoomLib::Z_Malloc(sizeof(*floor), PU_LEVEL, 0);
P_AddThinker (&floor->thinker);
sec->specialdata = floor;
floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;
floor->type = floortype;
floor->crush = false;
switch(floortype)
{ {
case lowerFloor: sec = &::g->sectors[secnum];
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindHighestFloorSurrounding(sec);
break;
case lowerFloorToLowest: // ALREADY MOVING? IF SO, KEEP GOING...
floor->direction = -1; if( sec->specialdata )
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindLowestFloorSurrounding(sec);
break;
case turboLower:
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED * 4;
floor->floordestheight =
P_FindHighestFloorSurrounding(sec);
if (floor->floordestheight != sec->floorheight)
floor->floordestheight += 8*FRACUNIT;
break;
case raiseFloorCrush:
floor->crush = true;
case raiseFloor:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindLowestCeilingSurrounding(sec);
if (floor->floordestheight > sec->ceilingheight)
floor->floordestheight = sec->ceilingheight;
floor->floordestheight -= (8*FRACUNIT)*
(floortype == raiseFloorCrush);
break;
case raiseFloorTurbo:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED*4;
floor->floordestheight =
P_FindNextHighestFloor(sec,sec->floorheight);
break;
case raiseFloorToNearest:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindNextHighestFloor(sec,sec->floorheight);
break;
case raiseFloor24:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight = floor->sector->floorheight +
24 * FRACUNIT;
break;
case raiseFloor512:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight = floor->sector->floorheight +
512 * FRACUNIT;
break;
case raiseFloor24AndChange:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight = floor->sector->floorheight +
24 * FRACUNIT;
sec->floorpic = line->frontsector->floorpic;
sec->special = line->frontsector->special;
break;
case raiseToTexture:
{
int minsize = MAXINT;
side_t* side;
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
for (i = 0; i < sec->linecount; i++)
{
if (twoSided (secnum, i) )
{
side = getSide(secnum,i,0);
if (side->bottomtexture >= 0)
if (::g->s_textureheight[side->bottomtexture] <
minsize)
minsize =
::g->s_textureheight[side->bottomtexture];
side = getSide(secnum,i,1);
if (side->bottomtexture >= 0)
if (::g->s_textureheight[side->bottomtexture] <
minsize)
minsize =
::g->s_textureheight[side->bottomtexture];
}
}
floor->floordestheight =
floor->sector->floorheight + minsize;
}
break;
case lowerAndChange:
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindLowestFloorSurrounding(sec);
floor->texture = sec->floorpic;
for (i = 0; i < sec->linecount; i++)
{
if ( twoSided(secnum, i) )
{ {
if (getSide(secnum,i,0)->sector-::g->sectors == secnum) continue;
{ }
sec = getSector(secnum,i,1);
// new floor thinker
if (sec->floorheight == floor->floordestheight) rtn = 1;
{ floor = ( floormove_t* )DoomLib::Z_Malloc( sizeof( *floor ), PU_LEVEL, 0 );
floor->texture = sec->floorpic; P_AddThinker( &floor->thinker );
floor->newspecial = sec->special; sec->specialdata = floor;
break; floor->thinker.function.acp1 = ( actionf_p1 ) T_MoveFloor;
} floor->type = floortype;
} floor->crush = false;
else
{ switch( floortype )
sec = getSector(secnum,i,0); {
case lowerFloor:
if (sec->floorheight == floor->floordestheight) floor->direction = -1;
{ floor->sector = sec;
floor->texture = sec->floorpic; floor->speed = FLOORSPEED;
floor->newspecial = sec->special; floor->floordestheight =
break; P_FindHighestFloorSurrounding( sec );
} break;
}
case lowerFloorToLowest:
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindLowestFloorSurrounding( sec );
break;
case turboLower:
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED * 4;
floor->floordestheight =
P_FindHighestFloorSurrounding( sec );
if( floor->floordestheight != sec->floorheight )
{
floor->floordestheight += 8 * FRACUNIT;
}
break;
case raiseFloorCrush:
floor->crush = true;
case raiseFloor:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindLowestCeilingSurrounding( sec );
if( floor->floordestheight > sec->ceilingheight )
{
floor->floordestheight = sec->ceilingheight;
}
floor->floordestheight -= ( 8 * FRACUNIT ) *
( floortype == raiseFloorCrush );
break;
case raiseFloorTurbo:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED * 4;
floor->floordestheight =
P_FindNextHighestFloor( sec, sec->floorheight );
break;
case raiseFloorToNearest:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindNextHighestFloor( sec, sec->floorheight );
break;
case raiseFloor24:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight = floor->sector->floorheight +
24 * FRACUNIT;
break;
case raiseFloor512:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight = floor->sector->floorheight +
512 * FRACUNIT;
break;
case raiseFloor24AndChange:
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight = floor->sector->floorheight +
24 * FRACUNIT;
sec->floorpic = line->frontsector->floorpic;
sec->special = line->frontsector->special;
break;
case raiseToTexture:
{
int minsize = MAXINT;
side_t* side;
floor->direction = 1;
floor->sector = sec;
floor->speed = FLOORSPEED;
for( i = 0; i < sec->linecount; i++ )
{
if( twoSided( secnum, i ) )
{
side = getSide( secnum, i, 0 );
if( side->bottomtexture >= 0 )
if( ::g->s_textureheight[side->bottomtexture] <
minsize )
minsize =
::g->s_textureheight[side->bottomtexture];
side = getSide( secnum, i, 1 );
if( side->bottomtexture >= 0 )
if( ::g->s_textureheight[side->bottomtexture] <
minsize )
minsize =
::g->s_textureheight[side->bottomtexture];
}
}
floor->floordestheight =
floor->sector->floorheight + minsize;
}
break;
case lowerAndChange:
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
P_FindLowestFloorSurrounding( sec );
floor->texture = sec->floorpic;
for( i = 0; i < sec->linecount; i++ )
{
if( twoSided( secnum, i ) )
{
if( getSide( secnum, i, 0 )->sector -::g->sectors == secnum )
{
sec = getSector( secnum, i, 1 );
if( sec->floorheight == floor->floordestheight )
{
floor->texture = sec->floorpic;
floor->newspecial = sec->special;
break;
}
}
else
{
sec = getSector( secnum, i, 0 );
if( sec->floorheight == floor->floordestheight )
{
floor->texture = sec->floorpic;
floor->newspecial = sec->special;
break;
}
}
}
}
default:
break;
} }
}
default:
break;
} }
} return rtn;
return rtn;
} }
@ -459,103 +469,114 @@ EV_BuildStairs
( line_t* line, ( line_t* line,
stair_e type ) stair_e type )
{ {
int secnum; int secnum;
int height; int height;
int i; int i;
int newsecnum; int newsecnum;
int texture; int texture;
int ok; int ok;
int rtn; int rtn;
sector_t* sec;
sector_t* tsec;
floormove_t* floor; sector_t* sec;
sector_t* tsec;
fixed_t stairsize = 0;
fixed_t speed = 0;
secnum = -1; floormove_t* floor;
rtn = 0;
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) fixed_t stairsize = 0;
{ fixed_t speed = 0;
sec = &::g->sectors[secnum];
secnum = -1;
// ALREADY MOVING? IF SO, KEEP GOING... rtn = 0;
if (sec->specialdata) while( ( secnum = P_FindSectorFromLineTag( line, secnum ) ) >= 0 )
continue;
// new floor thinker
rtn = 1;
floor = (floormove_t*)DoomLib::Z_Malloc(sizeof(*floor), PU_LEVEL, 0);
P_AddThinker (&floor->thinker);
sec->specialdata = floor;
floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor;
floor->direction = 1;
floor->sector = sec;
switch(type)
{ {
case build8: sec = &::g->sectors[secnum];
speed = FLOORSPEED/4;
stairsize = 8*FRACUNIT;
break;
case turbo16:
speed = FLOORSPEED*4;
stairsize = 16*FRACUNIT;
break;
}
floor->speed = speed;
height = sec->floorheight + stairsize;
floor->floordestheight = height;
texture = sec->floorpic;
// Find next sector to raise
// 1. Find 2-sided line with same sector side[0]
// 2. Other side is the next sector to raise
do
{
ok = 0;
for (i = 0;i < sec->linecount;i++)
{
if ( !((sec->lines[i])->flags & ML_TWOSIDED) )
continue;
tsec = (sec->lines[i])->frontsector;
newsecnum = tsec-::g->sectors;
if (secnum != newsecnum)
continue;
tsec = (sec->lines[i])->backsector; // ALREADY MOVING? IF SO, KEEP GOING...
newsecnum = tsec - ::g->sectors; if( sec->specialdata )
{
if (tsec->floorpic != texture) continue;
continue; }
height += stairsize;
if (tsec->specialdata)
continue;
sec = tsec;
secnum = newsecnum;
floor = (floormove_t*)DoomLib::Z_Malloc(sizeof(*floor), PU_LEVEL, 0);
P_AddThinker (&floor->thinker);
// new floor thinker
rtn = 1;
floor = ( floormove_t* )DoomLib::Z_Malloc( sizeof( *floor ), PU_LEVEL, 0 );
P_AddThinker( &floor->thinker );
sec->specialdata = floor; sec->specialdata = floor;
floor->thinker.function.acp1 = (actionf_p1) T_MoveFloor; floor->thinker.function.acp1 = ( actionf_p1 ) T_MoveFloor;
floor->direction = 1; floor->direction = 1;
floor->sector = sec; floor->sector = sec;
switch( type )
{
case build8:
speed = FLOORSPEED / 4;
stairsize = 8 * FRACUNIT;
break;
case turbo16:
speed = FLOORSPEED * 4;
stairsize = 16 * FRACUNIT;
break;
}
floor->speed = speed; floor->speed = speed;
height = sec->floorheight + stairsize;
floor->floordestheight = height; floor->floordestheight = height;
ok = 1;
break; texture = sec->floorpic;
}
} while(ok); // Find next sector to raise
} // 1. Find 2-sided line with same sector side[0]
return rtn; // 2. Other side is the next sector to raise
do
{
ok = 0;
for( i = 0; i < sec->linecount; i++ )
{
if( !( ( sec->lines[i] )->flags & ML_TWOSIDED ) )
{
continue;
}
tsec = ( sec->lines[i] )->frontsector;
newsecnum = tsec -::g->sectors;
if( secnum != newsecnum )
{
continue;
}
tsec = ( sec->lines[i] )->backsector;
newsecnum = tsec - ::g->sectors;
if( tsec->floorpic != texture )
{
continue;
}
height += stairsize;
if( tsec->specialdata )
{
continue;
}
sec = tsec;
secnum = newsecnum;
floor = ( floormove_t* )DoomLib::Z_Malloc( sizeof( *floor ), PU_LEVEL, 0 );
P_AddThinker( &floor->thinker );
sec->specialdata = floor;
floor->thinker.function.acp1 = ( actionf_p1 ) T_MoveFloor;
floor->direction = 1;
floor->sector = sec;
floor->speed = speed;
floor->floordestheight = height;
ok = 1;
break;
}
}
while( ok );
}
return rtn;
} }

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,11 +31,11 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
qboolean P_GivePower(player_t*, int); qboolean P_GivePower( player_t*, int );

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -47,21 +47,27 @@ If you have questions concerning this license or the applicable additional terms
// //
// T_FireFlicker // T_FireFlicker
// //
void T_FireFlicker (fireflicker_t* flick) void T_FireFlicker( fireflicker_t* flick )
{ {
int amount; int amount;
if (--flick->count)
return;
amount = (P_Random()&3)*16;
if (flick->sector->lightlevel - amount < flick->minlight)
flick->sector->lightlevel = flick->minlight;
else
flick->sector->lightlevel = flick->maxlight - amount;
flick->count = 4; if( --flick->count )
{
return;
}
amount = ( P_Random() & 3 ) * 16;
if( flick->sector->lightlevel - amount < flick->minlight )
{
flick->sector->lightlevel = flick->minlight;
}
else
{
flick->sector->lightlevel = flick->maxlight - amount;
}
flick->count = 4;
} }
@ -69,23 +75,23 @@ void T_FireFlicker (fireflicker_t* flick)
// //
// P_SpawnFireFlicker // P_SpawnFireFlicker
// //
void P_SpawnFireFlicker (sector_t* sector) void P_SpawnFireFlicker( sector_t* sector )
{ {
fireflicker_t* flick; fireflicker_t* flick;
// Note that we are resetting sector attributes.
// Nothing special about it during gameplay.
sector->special = 0;
flick = (fireflicker_t*)DoomLib::Z_Malloc( sizeof(*flick), PU_LEVEL, 0);
P_AddThinker (&flick->thinker); // Note that we are resetting sector attributes.
// Nothing special about it during gameplay.
sector->special = 0;
flick->thinker.function.acp1 = (actionf_p1) T_FireFlicker; flick = ( fireflicker_t* )DoomLib::Z_Malloc( sizeof( *flick ), PU_LEVEL, 0 );
flick->sector = sector;
flick->maxlight = sector->lightlevel; P_AddThinker( &flick->thinker );
flick->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel)+16;
flick->count = 4; flick->thinker.function.acp1 = ( actionf_p1 ) T_FireFlicker;
flick->sector = sector;
flick->maxlight = sector->lightlevel;
flick->minlight = P_FindMinSurroundingLight( sector, sector->lightlevel ) + 16;
flick->count = 4;
} }
@ -99,21 +105,23 @@ void P_SpawnFireFlicker (sector_t* sector)
// T_LightFlash // T_LightFlash
// Do flashing lights. // Do flashing lights.
// //
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) }
{
flash-> sector->lightlevel = flash->minlight; if( flash->sector->lightlevel == flash->maxlight )
flash->count = (P_Random()&flash->mintime)+1; {
} flash-> sector->lightlevel = flash->minlight;
else flash->count = ( P_Random()&flash->mintime ) + 1;
{ }
flash-> sector->lightlevel = flash->maxlight; else
flash->count = (P_Random()&flash->maxtime)+1; {
} flash-> sector->lightlevel = flash->maxlight;
flash->count = ( P_Random()&flash->maxtime ) + 1;
}
} }
@ -125,25 +133,25 @@ void T_LightFlash (lightflash_t* flash)
// After the map has been loaded, scan each sector // After the map has been loaded, scan each sector
// for specials that spawn thinkers // for specials that spawn thinkers
// //
void P_SpawnLightFlash (sector_t* sector) void P_SpawnLightFlash( sector_t* sector )
{ {
lightflash_t* flash; lightflash_t* flash;
// nothing special about it during gameplay // nothing special about it during gameplay
sector->special = 0; sector->special = 0;
flash = (lightflash_t*)DoomLib::Z_Malloc( sizeof(*flash), PU_LEVEL, 0);
P_AddThinker (&flash->thinker); flash = ( lightflash_t* )DoomLib::Z_Malloc( sizeof( *flash ), PU_LEVEL, 0 );
flash->thinker.function.acp1 = (actionf_p1) T_LightFlash; P_AddThinker( &flash->thinker );
flash->sector = sector;
flash->maxlight = sector->lightlevel;
flash->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel); flash->thinker.function.acp1 = ( actionf_p1 ) T_LightFlash;
flash->maxtime = 64; flash->sector = sector;
flash->mintime = 7; flash->maxlight = sector->lightlevel;
flash->count = (P_Random()&flash->maxtime)+1;
flash->minlight = P_FindMinSurroundingLight( sector, sector->lightlevel );
flash->maxtime = 64;
flash->mintime = 7;
flash->count = ( P_Random()&flash->maxtime ) + 1;
} }
@ -156,21 +164,23 @@ void P_SpawnLightFlash (sector_t* sector)
// //
// T_StrobeFlash // T_StrobeFlash
// //
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) }
{
flash-> sector->lightlevel = flash->maxlight; if( flash->sector->lightlevel == flash->minlight )
flash->count = flash->brighttime; {
} flash-> sector->lightlevel = flash->maxlight;
else flash->count = flash->brighttime;
{ }
flash-> sector->lightlevel = flash->minlight; else
flash->count =flash->darktime; {
} flash-> sector->lightlevel = flash->minlight;
flash->count = flash->darktime;
}
} }
@ -187,49 +197,57 @@ P_SpawnStrobeFlash
int fastOrSlow, int fastOrSlow,
int inSync ) int inSync )
{ {
strobe_t* flash; strobe_t* flash;
flash = (strobe_t*)DoomLib::Z_Malloc( sizeof(*flash), PU_LEVEL, 0);
P_AddThinker (&flash->thinker); flash = ( strobe_t* )DoomLib::Z_Malloc( sizeof( *flash ), PU_LEVEL, 0 );
flash->sector = sector; P_AddThinker( &flash->thinker );
flash->darktime = fastOrSlow;
flash->brighttime = STROBEBRIGHT;
flash->thinker.function.acp1 = (actionf_p1) T_StrobeFlash;
flash->maxlight = sector->lightlevel;
flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel);
if (flash->minlight == flash->maxlight)
flash->minlight = 0;
// nothing special about it during gameplay flash->sector = sector;
sector->special = 0; flash->darktime = fastOrSlow;
flash->brighttime = STROBEBRIGHT;
flash->thinker.function.acp1 = ( actionf_p1 ) T_StrobeFlash;
flash->maxlight = sector->lightlevel;
flash->minlight = P_FindMinSurroundingLight( sector, sector->lightlevel );
if (!inSync) if( flash->minlight == flash->maxlight )
flash->count = (P_Random()&7)+1; {
else flash->minlight = 0;
flash->count = 1; }
// nothing special about it during gameplay
sector->special = 0;
if( !inSync )
{
flash->count = ( P_Random() & 7 ) + 1;
}
else
{
flash->count = 1;
}
} }
// //
// Start strobing lights (usually from a trigger) // Start strobing lights (usually from a trigger)
// //
void EV_StartLightStrobing(line_t* line) void EV_StartLightStrobing( line_t* line )
{ {
int secnum; int secnum;
sector_t* sec; sector_t* sec;
secnum = -1; secnum = -1;
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0) while( ( secnum = P_FindSectorFromLineTag( line, secnum ) ) >= 0 )
{ {
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 );
}
} }
@ -237,34 +255,38 @@ void EV_StartLightStrobing(line_t* line)
// //
// TURN LINE'S TAG LIGHTS OFF // TURN LINE'S TAG LIGHTS OFF
// //
void EV_TurnTagLightsOff(line_t* line) void EV_TurnTagLightsOff( line_t* line )
{ {
int i; int i;
int j; int j;
int min; int min;
sector_t* sector; sector_t* sector;
sector_t* tsec; sector_t* tsec;
line_t* templine; line_t* templine;
sector = ::g->sectors; sector = ::g->sectors;
for (j = 0;j < ::g->numsectors; j++, sector++) for( j = 0; j < ::g->numsectors; j++, sector++ )
{
if (sector->tag == line->tag)
{ {
min = sector->lightlevel; if( sector->tag == line->tag )
for (i = 0;i < sector->linecount; i++) {
{ min = sector->lightlevel;
templine = sector->lines[i]; for( i = 0; i < sector->linecount; i++ )
tsec = getNextSector(templine,sector); {
if (!tsec) templine = sector->lines[i];
continue; tsec = getNextSector( templine, sector );
if (tsec->lightlevel < min) if( !tsec )
min = tsec->lightlevel; {
} continue;
sector->lightlevel = min; }
if( tsec->lightlevel < min )
{
min = tsec->lightlevel;
}
}
sector->lightlevel = min;
}
} }
}
} }
@ -276,87 +298,91 @@ EV_LightTurnOn
( line_t* line, ( line_t* line,
int bright ) int bright )
{ {
int i; int i;
int j; int j;
sector_t* sector; sector_t* sector;
sector_t* temp; sector_t* temp;
line_t* templine; line_t* templine;
sector = ::g->sectors; sector = ::g->sectors;
for (i = 0; i < ::g->numsectors; i++, sector++) for( i = 0; i < ::g->numsectors; i++, sector++ )
{
if (sector->tag == line->tag)
{ {
// bright = 0 means to search if( sector->tag == line->tag )
// for highest light level
// surrounding sector
if (!bright)
{
for (j = 0;j < sector->linecount; j++)
{ {
templine = sector->lines[j]; // bright = 0 means to search
temp = getNextSector(templine,sector); // for highest light level
// surrounding sector
if( !bright )
{
for( j = 0; j < sector->linecount; j++ )
{
templine = sector->lines[j];
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;
} }
}
} }
// //
// Spawn glowing light // Spawn glowing light
// //
void T_Glow(glow_t* g) void T_Glow( glow_t* g )
{ {
switch(g->direction) switch( g->direction )
{
case -1:
// DOWN
g->sector->lightlevel -= GLOWSPEED;
if (g->sector->lightlevel <= g->minlight)
{ {
g->sector->lightlevel += GLOWSPEED; case -1:
g->direction = 1; // DOWN
g->sector->lightlevel -= GLOWSPEED;
if( g->sector->lightlevel <= g->minlight )
{
g->sector->lightlevel += GLOWSPEED;
g->direction = 1;
}
break;
case 1:
// UP
g->sector->lightlevel += GLOWSPEED;
if( g->sector->lightlevel >= g->maxlight )
{
g->sector->lightlevel -= GLOWSPEED;
g->direction = -1;
}
break;
} }
break;
case 1:
// UP
g->sector->lightlevel += GLOWSPEED;
if (g->sector->lightlevel >= g->maxlight)
{
g->sector->lightlevel -= GLOWSPEED;
g->direction = -1;
}
break;
}
} }
void P_SpawnGlowingLight(sector_t* sector) void P_SpawnGlowingLight( sector_t* sector )
{ {
glow_t* g; glow_t* g;
g = (glow_t*)DoomLib::Z_Malloc( sizeof(*g), PU_LEVEL, 0);
P_AddThinker(&g->thinker); g = ( glow_t* )DoomLib::Z_Malloc( sizeof( *g ), PU_LEVEL, 0 );
g->sector = sector; P_AddThinker( &g->thinker );
g->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel);
g->maxlight = sector->lightlevel;
g->thinker.function.acp1 = (actionf_p1) T_Glow;
g->direction = -1;
sector->special = 0; g->sector = sector;
g->minlight = P_FindMinSurroundingLight( sector, sector->lightlevel );
g->maxlight = sector->lightlevel;
g->thinker.function.acp1 = ( actionf_p1 ) T_Glow;
g->direction = -1;
sector->special = 0;
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -30,7 +30,7 @@ If you have questions concerning this license or the applicable additional terms
#define __P_LOCAL__ #define __P_LOCAL__
#ifndef __R_LOCAL__ #ifndef __R_LOCAL__
#include "r_local.h" #include "r_local.h"
#endif #endif
#define FLOATSPEED (FRACUNIT*4) #define FLOATSPEED (FRACUNIT*4)
@ -73,26 +73,26 @@ If you have questions concerning this license or the applicable additional terms
// //
// both the head and tail of the thinker list // both the head and tail of the thinker list
extern thinker_t thinkercap; extern thinker_t thinkercap;
void P_InitThinkers (void); void P_InitThinkers( void );
void P_AddThinker (thinker_t* thinker); void P_AddThinker( thinker_t* thinker );
void P_RemoveThinker (thinker_t* thinker); void P_RemoveThinker( thinker_t* thinker );
// //
// P_PSPR // P_PSPR
// //
void P_SetupPsprites (player_t* curplayer); void P_SetupPsprites( player_t* curplayer );
void P_MovePsprites (player_t* curplayer); void P_MovePsprites( player_t* curplayer );
void P_DropWeapon (player_t* player); void P_DropWeapon( player_t* player );
// //
// P_USER // P_USER
// //
void P_PlayerThink (player_t* player); void P_PlayerThink( player_t* player );
// //
@ -110,7 +110,7 @@ extern int iquehead;
extern int iquetail; extern int iquetail;
void P_RespawnSpecials (void); void P_RespawnSpecials( void );
mobj_t* mobj_t*
P_SpawnMobj P_SpawnMobj
@ -119,20 +119,20 @@ P_SpawnMobj
fixed_t z, fixed_t z,
mobjtype_t type ); mobjtype_t type );
void P_RemoveMobj (mobj_t* th); void P_RemoveMobj( mobj_t* th );
qboolean P_SetMobjState (mobj_t* mobj, statenum_t state); qboolean P_SetMobjState( mobj_t* mobj, statenum_t state );
void P_MobjThinker (mobj_t* mobj); void P_MobjThinker( mobj_t* mobj );
void P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z); void P_SpawnPuff( fixed_t x, fixed_t y, fixed_t z );
void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage); void P_SpawnBlood( fixed_t x, fixed_t y, fixed_t z, int damage );
mobj_t* P_SpawnMissile (mobj_t* source, mobj_t* dest, mobjtype_t type); mobj_t* P_SpawnMissile( mobj_t* source, mobj_t* dest, mobjtype_t type );
void P_SpawnPlayerMissile (mobj_t* source, mobjtype_t type); void P_SpawnPlayerMissile( mobj_t* source, mobjtype_t type );
// //
// P_ENEMY // P_ENEMY
// //
void P_NoiseAlert (mobj_t* target, mobj_t* emmiter); void P_NoiseAlert( mobj_t* target, mobj_t* emmiter );
// //
@ -140,21 +140,22 @@ void P_NoiseAlert (mobj_t* target, mobj_t* emmiter);
// //
typedef struct typedef struct
{ {
fixed_t x; fixed_t x;
fixed_t y; fixed_t y;
fixed_t dx; fixed_t dx;
fixed_t dy; fixed_t dy;
} divline_t; } divline_t;
typedef struct typedef struct
{ {
fixed_t frac; // along trace line fixed_t frac; // along trace line
qboolean isaline; qboolean isaline;
union { union
mobj_t* thing; {
line_t* line; mobj_t* thing;
} d; line_t* line;
} d;
} intercept_t; } intercept_t;
#define MAXINTERCEPTS 128 #define MAXINTERCEPTS 128
@ -162,24 +163,24 @@ typedef struct
extern intercept_t intercepts[MAXINTERCEPTS]; extern intercept_t intercepts[MAXINTERCEPTS];
extern intercept_t* intercept_p; extern intercept_t* intercept_p;
typedef qboolean (*traverser_t) (intercept_t *in); typedef qboolean( *traverser_t )( intercept_t* in );
fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); fixed_t P_AproxDistance( fixed_t dx, fixed_t dy );
int P_PointOnLineSide (fixed_t x, fixed_t y, line_t* line); int P_PointOnLineSide( fixed_t x, fixed_t y, line_t* line );
int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t* line); int P_PointOnDivlineSide( fixed_t x, fixed_t y, divline_t* line );
void P_MakeDivline (line_t* li, divline_t* dl); void P_MakeDivline( line_t* li, divline_t* dl );
fixed_t P_InterceptVector (divline_t* v2, divline_t* v1); fixed_t P_InterceptVector( divline_t* v2, divline_t* v1 );
int P_BoxOnLineSide (fixed_t* tmbox, line_t* ld); int P_BoxOnLineSide( fixed_t* tmbox, line_t* ld );
extern fixed_t opentop; extern fixed_t opentop;
extern fixed_t openbottom; extern fixed_t openbottom;
extern fixed_t openrange; extern fixed_t openrange;
extern fixed_t lowfloor; extern fixed_t lowfloor;
void P_LineOpening (line_t* linedef); void P_LineOpening( line_t* linedef );
qboolean P_BlockLinesIterator (int x, int y, qboolean(*func)(line_t*) ); qboolean P_BlockLinesIterator( int x, int y, qboolean( *func )( line_t* ) );
qboolean P_BlockThingsIterator (int x, int y, qboolean(*func)(mobj_t*) ); qboolean P_BlockThingsIterator( int x, int y, qboolean( *func )( mobj_t* ) );
#define PT_ADDLINES 1 #define PT_ADDLINES 1
#define PT_ADDTHINGS 2 #define PT_ADDTHINGS 2
@ -194,10 +195,10 @@ P_PathTraverse
fixed_t x2, fixed_t x2,
fixed_t y2, fixed_t y2,
int flags, int flags,
qboolean (*trav) (intercept_t *)); qboolean( *trav )( intercept_t* ) );
void P_UnsetThingPosition (mobj_t* thing); void P_UnsetThingPosition( mobj_t* thing );
void P_SetThingPosition (mobj_t* thing); void P_SetThingPosition( mobj_t* thing );
// //
@ -213,14 +214,14 @@ extern fixed_t tmceilingz;
extern line_t* ceilingline; extern line_t* ceilingline;
qboolean P_CheckPosition (mobj_t *thing, fixed_t x, fixed_t y); qboolean P_CheckPosition( mobj_t* thing, fixed_t x, fixed_t y );
qboolean P_TryMove (mobj_t* thing, fixed_t x, fixed_t y); qboolean P_TryMove( mobj_t* thing, fixed_t x, fixed_t y );
qboolean P_TeleportMove (mobj_t* thing, fixed_t x, fixed_t y); qboolean P_TeleportMove( mobj_t* thing, fixed_t x, fixed_t y );
void P_SlideMove (mobj_t* mo); void P_SlideMove( mobj_t* mo );
qboolean P_CheckSight (mobj_t* t1, mobj_t* t2); qboolean P_CheckSight( mobj_t* t1, mobj_t* t2 );
void P_UseLines (player_t* player); void P_UseLines( player_t* player );
qboolean P_ChangeSector (sector_t* sector, qboolean crunch); qboolean P_ChangeSector( sector_t* sector, qboolean crunch );
extern mobj_t* linetarget; // who got hit (or NULL) extern mobj_t* linetarget; // who got hit (or NULL)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -48,7 +48,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
@ -102,7 +102,7 @@ If you have questions concerning this license or the applicable additional terms
// things, but nothing can run into a missile). // things, but nothing can run into a missile).
// Each block in the grid is 128*128 units, and knows about // Each block in the grid is 128*128 units, and knows about
// every line_t that it contains a piece of, and every // every line_t that it contains a piece of, and every
// interactable mobj_t that has its origin contained. // interactable mobj_t that has its origin contained.
// //
// A valid mobj_t is a mobj_t that has the proper subsector_t // A valid mobj_t is a mobj_t that has the proper subsector_t
// filled in for its xy coordinates and is linked into the // filled in for its xy coordinates and is linked into the
@ -122,89 +122,89 @@ If you have questions concerning this license or the applicable additional terms
// //
typedef enum typedef enum
{ {
// Call P_SpecialThing when touched. // Call P_SpecialThing when touched.
MF_SPECIAL = 1, MF_SPECIAL = 1,
// Blocks. // Blocks.
MF_SOLID = 2, MF_SOLID = 2,
// Can be hit. // Can be hit.
MF_SHOOTABLE = 4, MF_SHOOTABLE = 4,
// Don't use the sector links (invisible but touchable). // Don't use the sector links (invisible but touchable).
MF_NOSECTOR = 8, MF_NOSECTOR = 8,
// Don't use the blocklinks (inert but displayable) // Don't use the blocklinks (inert but displayable)
MF_NOBLOCKMAP = 16, MF_NOBLOCKMAP = 16,
// Not to be activated by sound, deaf monster. // Not to be activated by sound, deaf monster.
MF_AMBUSH = 32, MF_AMBUSH = 32,
// Will try to attack right back. // Will try to attack right back.
MF_JUSTHIT = 64, MF_JUSTHIT = 64,
// Will take at least one step before attacking. // Will take at least one step before attacking.
MF_JUSTATTACKED = 128, MF_JUSTATTACKED = 128,
// On level spawning (initial position), // On level spawning (initial position),
// hang from ceiling instead of stand on floor. // hang from ceiling instead of stand on floor.
MF_SPAWNCEILING = 256, MF_SPAWNCEILING = 256,
// Don't apply gravity (every tic), // Don't apply gravity (every tic),
// that is, object will float, keeping current height // that is, object will float, keeping current height
// or changing it actively. // or changing it actively.
MF_NOGRAVITY = 512, MF_NOGRAVITY = 512,
// Movement flags. // Movement flags.
// This allows jumps from high places. // This allows jumps from high places.
MF_DROPOFF = 0x400, MF_DROPOFF = 0x400,
// For players, will pick up items. // For players, will pick up items.
MF_PICKUP = 0x800, MF_PICKUP = 0x800,
// Player cheat. ??? // Player cheat. ???
MF_NOCLIP = 0x1000, MF_NOCLIP = 0x1000,
// Player: keep info about sliding along walls. // Player: keep info about sliding along walls.
MF_SLIDE = 0x2000, MF_SLIDE = 0x2000,
// Allow moves to any height, no gravity. // Allow moves to any height, no gravity.
// For active floaters, e.g. cacodemons, pain elementals. // For active floaters, e.g. cacodemons, pain elementals.
MF_FLOAT = 0x4000, MF_FLOAT = 0x4000,
// Don't cross lines // Don't cross lines
// ??? or look at heights on teleport. // ??? or look at heights on teleport.
MF_TELEPORT = 0x8000, MF_TELEPORT = 0x8000,
// Don't hit same species, explode on block. // Don't hit same species, explode on block.
// Player missiles as well as fireballs of various kinds. // Player missiles as well as fireballs of various kinds.
MF_MISSILE = 0x10000, MF_MISSILE = 0x10000,
// Dropped by a demon, not level spawned. // Dropped by a demon, not level spawned.
// E.g. ammo clips dropped by dying former humans. // E.g. ammo clips dropped by dying former humans.
MF_DROPPED = 0x20000, MF_DROPPED = 0x20000,
// Use fuzzy draw (shadow demons or spectres), // Use fuzzy draw (shadow demons or spectres),
// temporary player invisibility powerup. // temporary player invisibility powerup.
MF_SHADOW = 0x40000, MF_SHADOW = 0x40000,
// Flag: don't bleed when shot (use puff), // Flag: don't bleed when shot (use puff),
// barrels and shootable furniture shall not bleed. // barrels and shootable furniture shall not bleed.
MF_NOBLOOD = 0x80000, MF_NOBLOOD = 0x80000,
// Don't stop moving halfway off a step, // Don't stop moving halfway off a step,
// that is, have dead bodies slide down all the way. // that is, have dead bodies slide down all the way.
MF_CORPSE = 0x100000, MF_CORPSE = 0x100000,
// Floating to a height for a move, ??? // Floating to a height for a move, ???
// don't auto float to target's height. // don't auto float to target's height.
MF_INFLOAT = 0x200000, MF_INFLOAT = 0x200000,
// On kill, count this enemy object // On kill, count this enemy object
// towards intermission kill total. // towards intermission kill total.
// Happy gathering. // Happy gathering.
MF_COUNTKILL = 0x400000, MF_COUNTKILL = 0x400000,
// On picking up, count this item object
// towards intermission item total.
MF_COUNTITEM = 0x800000,
// Special handling: skull in flight. // On picking up, count this item object
// Neither a cacodemon nor a missile. // towards intermission item total.
MF_SKULLFLY = 0x1000000, MF_COUNTITEM = 0x800000,
// Don't spawn this object // Special handling: skull in flight.
// in death match mode (e.g. key cards). // Neither a cacodemon nor a missile.
MF_NOTDMATCH = 0x2000000, MF_SKULLFLY = 0x1000000,
// Player sprites in multiplayer modes are modified // Don't spawn this object
// using an internal color lookup table for re-indexing. // in death match mode (e.g. key cards).
// If 0x4 0x8 or 0xc, MF_NOTDMATCH = 0x2000000,
// use a translation table for player colormaps
MF_TRANSLATION = 0xc000000, // Player sprites in multiplayer modes are modified
// Hmm ???. // using an internal color lookup table for re-indexing.
MF_TRANSSHIFT = 26 // If 0x4 0x8 or 0xc,
// use a translation table for player colormaps
MF_TRANSLATION = 0xc000000,
// Hmm ???.
MF_TRANSSHIFT = 26
} mobjflag_t; } mobjflag_t;
@ -212,83 +212,83 @@ typedef enum
// Map Object definition. // Map Object definition.
struct mobj_t struct mobj_t
{ {
// List: thinker links. // List: thinker links.
thinker_t thinker; thinker_t thinker;
// Info for drawing: position. // Info for drawing: position.
fixed_t x; fixed_t x;
fixed_t y; fixed_t y;
fixed_t z; fixed_t z;
// More list: links in sector (if needed) // More list: links in sector (if needed)
mobj_t* snext; mobj_t* snext;
mobj_t* sprev; mobj_t* sprev;
//More drawing info: to determine current sprite. //More drawing info: to determine current sprite.
angle_t angle; // orientation angle_t angle; // orientation
spritenum_t sprite; // used to find patch_t and flip value spritenum_t sprite; // used to find patch_t and flip value
int frame; // might be ORed with FF_FULLBRIGHT int frame; // might be ORed with FF_FULLBRIGHT
// Interaction info, by BLOCKMAP. // Interaction info, by BLOCKMAP.
// Links in blocks (if needed). // Links in blocks (if needed).
mobj_t* bnext; mobj_t* bnext;
mobj_t* bprev; mobj_t* bprev;
struct subsector_s* subsector;
// The closest interval over all contacted Sectors. struct subsector_s* subsector;
fixed_t floorz;
fixed_t ceilingz;
// For movement checking. // The closest interval over all contacted Sectors.
fixed_t radius; fixed_t floorz;
fixed_t height; fixed_t ceilingz;
// Momentums, used to update position. // For movement checking.
fixed_t momx; fixed_t radius;
fixed_t momy; fixed_t height;
fixed_t momz;
// If == validcount, already checked. // Momentums, used to update position.
int validcount; fixed_t momx;
fixed_t momy;
fixed_t momz;
mobjtype_t type; // If == validcount, already checked.
const mobjinfo_t* info; // &mobjinfo[mobj->type] int validcount;
int tics; // state tic counter
const state_t* state;
int flags;
int health;
// Movement direction, movement generation (zig-zagging). mobjtype_t type;
int movedir; // 0-7 const mobjinfo_t* info; // &mobjinfo[mobj->type]
int movecount; // when 0, select a new dir
// Thing being chased/attacked (or NULL), int tics; // state tic counter
// also the originator for missiles. const state_t* state;
mobj_t* target; int flags;
int health;
// Reaction time: if non 0, don't attack yet. // Movement direction, movement generation (zig-zagging).
// Used by player to freeze a bit after teleporting. int movedir; // 0-7
int reactiontime; int movecount; // when 0, select a new dir
// If >0, the target will be chased // Thing being chased/attacked (or NULL),
// no matter what (even if shot) // also the originator for missiles.
int threshold; mobj_t* target;
// Additional info record for player avatars only. // Reaction time: if non 0, don't attack yet.
// Only valid if type == MT_PLAYER // Used by player to freeze a bit after teleporting.
struct player_s* player; int reactiontime;
// Player number last looked for. // If >0, the target will be chased
int lastlook; // no matter what (even if shot)
int threshold;
// For nightmare respawn. // Additional info record for player avatars only.
mapthing_t spawnpoint; // Only valid if type == MT_PLAYER
struct player_s* player;
// Player number last looked for.
int lastlook;
// For nightmare respawn.
mapthing_t spawnpoint;
// Thing being chased/attacked for tracers.
mobj_t* tracer;
// Thing being chased/attacked for tracers.
mobj_t* tracer;
}; };

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -53,85 +53,89 @@ If you have questions concerning this license or the applicable additional terms
// //
// Move a plat up and down // Move a plat up and down
// //
void T_PlatRaise(plat_t* plat) void T_PlatRaise( plat_t* plat )
{ {
result_e res; result_e res;
switch(plat->status)
{
case up:
res = T_MovePlane(plat->sector,
plat->speed,
plat->high,
plat->crush,0,1);
if (plat->type == raiseAndChange
|| plat->type == raiseToNearestAndChange)
{
if (!(::g->leveltime&7))
S_StartSound( &plat->sector->soundorg,
sfx_stnmov);
}
if (res == crushed && (!plat->crush))
{
plat->count = plat->wait;
plat->status = down;
S_StartSound( &plat->sector->soundorg,
sfx_pstart);
}
else
{
if (res == pastdest)
{
plat->count = plat->wait;
plat->status = waiting;
S_StartSound( &plat->sector->soundorg,
sfx_pstop);
switch(plat->type) switch( plat->status )
{ {
case blazeDWUS: case up:
case downWaitUpStay: res = T_MovePlane( plat->sector,
P_RemoveActivePlat(plat); plat->speed,
break; plat->high,
plat->crush, 0, 1 );
case raiseAndChange:
case raiseToNearestAndChange:
P_RemoveActivePlat(plat);
break;
default:
break;
}
}
}
break;
case down:
res = T_MovePlane(plat->sector,plat->speed,plat->low,false,0,-1);
if (res == pastdest) if( plat->type == raiseAndChange
{ || plat->type == raiseToNearestAndChange )
plat->count = plat->wait; {
plat->status = waiting; if( !( ::g->leveltime & 7 ) )
S_StartSound( &plat->sector->soundorg,sfx_pstop); S_StartSound( &plat->sector->soundorg,
sfx_stnmov );
}
if( res == crushed && ( !plat->crush ) )
{
plat->count = plat->wait;
plat->status = down;
S_StartSound( &plat->sector->soundorg,
sfx_pstart );
}
else
{
if( res == pastdest )
{
plat->count = plat->wait;
plat->status = waiting;
S_StartSound( &plat->sector->soundorg,
sfx_pstop );
switch( plat->type )
{
case blazeDWUS:
case downWaitUpStay:
P_RemoveActivePlat( plat );
break;
case raiseAndChange:
case raiseToNearestAndChange:
P_RemoveActivePlat( plat );
break;
default:
break;
}
}
}
break;
case down:
res = T_MovePlane( plat->sector, plat->speed, plat->low, false, 0, -1 );
if( res == pastdest )
{
plat->count = plat->wait;
plat->status = waiting;
S_StartSound( &plat->sector->soundorg, sfx_pstop );
}
break;
case waiting:
if( !--plat->count )
{
if( plat->sector->floorheight == plat->low )
{
plat->status = up;
}
else
{
plat->status = down;
}
S_StartSound( &plat->sector->soundorg, sfx_pstart );
}
case in_stasis:
break;
} }
break;
case waiting:
if (!--plat->count)
{
if (plat->sector->floorheight == plat->low)
plat->status = up;
else
plat->status = down;
S_StartSound( &plat->sector->soundorg,sfx_pstart);
}
case in_stasis:
break;
}
} }
@ -145,175 +149,185 @@ EV_DoPlat
plattype_e type, plattype_e type,
int amount ) int amount )
{ {
plat_t* plat; plat_t* plat;
int secnum; int secnum;
int rtn; int rtn;
sector_t* sec; sector_t* sec;
secnum = -1;
rtn = 0;
secnum = -1;
// Activate all <type> plats that are in_stasis rtn = 0;
switch(type)
{
case perpetualRaise:
P_ActivateInStasis(line->tag);
break;
default:
break;
}
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
{
sec = &::g->sectors[secnum];
if (sec->specialdata)
continue; // Activate all <type> plats that are in_stasis
switch( type )
// Find lowest & highest floors around sector
rtn = 1;
plat = (plat_t*)DoomLib::Z_Malloc( sizeof(*plat), PU_LEVEL, 0);
P_AddThinker(&plat->thinker);
plat->type = type;
plat->sector = sec;
plat->sector->specialdata = plat;
plat->thinker.function.acp1 = (actionf_p1) T_PlatRaise;
plat->crush = false;
plat->tag = line->tag;
switch(type)
{ {
case raiseToNearestAndChange: case perpetualRaise:
plat->speed = PLATSPEED/2; P_ActivateInStasis( line->tag );
sec->floorpic = ::g->sides[line->sidenum[0]].sector->floorpic; break;
plat->high = P_FindNextHighestFloor(sec,sec->floorheight);
plat->wait = 0;
plat->status = up;
// NO MORE DAMAGE, IF APPLICABLE
sec->special = 0;
S_StartSound( &sec->soundorg,sfx_stnmov); default:
break; break;
case raiseAndChange:
plat->speed = PLATSPEED/2;
sec->floorpic = ::g->sides[line->sidenum[0]].sector->floorpic;
plat->high = sec->floorheight + amount*FRACUNIT;
plat->wait = 0;
plat->status = up;
S_StartSound( &sec->soundorg,sfx_stnmov);
break;
case downWaitUpStay:
plat->speed = PLATSPEED * 4;
plat->low = P_FindLowestFloorSurrounding(sec);
if (plat->low > sec->floorheight)
plat->low = sec->floorheight;
plat->high = sec->floorheight;
plat->wait = TICRATE*PLATWAIT;
plat->status = down;
S_StartSound( &sec->soundorg,sfx_pstart);
break;
case blazeDWUS:
plat->speed = PLATSPEED * 8;
plat->low = P_FindLowestFloorSurrounding(sec);
if (plat->low > sec->floorheight)
plat->low = sec->floorheight;
plat->high = sec->floorheight;
plat->wait = TICRATE*PLATWAIT;
plat->status = down;
S_StartSound( &sec->soundorg,sfx_pstart);
break;
case perpetualRaise:
plat->speed = PLATSPEED;
plat->low = P_FindLowestFloorSurrounding(sec);
if (plat->low > sec->floorheight)
plat->low = sec->floorheight;
plat->high = P_FindHighestFloorSurrounding(sec);
if (plat->high < sec->floorheight)
plat->high = sec->floorheight;
plat->wait = TICRATE*PLATWAIT;
plat->status = (plat_e)(P_Random()&1);
S_StartSound( &sec->soundorg,sfx_pstart);
break;
} }
P_AddActivePlat(plat);
} while( ( secnum = P_FindSectorFromLineTag( line, secnum ) ) >= 0 )
return rtn; {
sec = &::g->sectors[secnum];
if( sec->specialdata )
{
continue;
}
// Find lowest & highest floors around sector
rtn = 1;
plat = ( plat_t* )DoomLib::Z_Malloc( sizeof( *plat ), PU_LEVEL, 0 );
P_AddThinker( &plat->thinker );
plat->type = type;
plat->sector = sec;
plat->sector->specialdata = plat;
plat->thinker.function.acp1 = ( actionf_p1 ) T_PlatRaise;
plat->crush = false;
plat->tag = line->tag;
switch( type )
{
case raiseToNearestAndChange:
plat->speed = PLATSPEED / 2;
sec->floorpic = ::g->sides[line->sidenum[0]].sector->floorpic;
plat->high = P_FindNextHighestFloor( sec, sec->floorheight );
plat->wait = 0;
plat->status = up;
// NO MORE DAMAGE, IF APPLICABLE
sec->special = 0;
S_StartSound( &sec->soundorg, sfx_stnmov );
break;
case raiseAndChange:
plat->speed = PLATSPEED / 2;
sec->floorpic = ::g->sides[line->sidenum[0]].sector->floorpic;
plat->high = sec->floorheight + amount * FRACUNIT;
plat->wait = 0;
plat->status = up;
S_StartSound( &sec->soundorg, sfx_stnmov );
break;
case downWaitUpStay:
plat->speed = PLATSPEED * 4;
plat->low = P_FindLowestFloorSurrounding( sec );
if( plat->low > sec->floorheight )
{
plat->low = sec->floorheight;
}
plat->high = sec->floorheight;
plat->wait = TICRATE * PLATWAIT;
plat->status = down;
S_StartSound( &sec->soundorg, sfx_pstart );
break;
case blazeDWUS:
plat->speed = PLATSPEED * 8;
plat->low = P_FindLowestFloorSurrounding( sec );
if( plat->low > sec->floorheight )
{
plat->low = sec->floorheight;
}
plat->high = sec->floorheight;
plat->wait = TICRATE * PLATWAIT;
plat->status = down;
S_StartSound( &sec->soundorg, sfx_pstart );
break;
case perpetualRaise:
plat->speed = PLATSPEED;
plat->low = P_FindLowestFloorSurrounding( sec );
if( plat->low > sec->floorheight )
{
plat->low = sec->floorheight;
}
plat->high = P_FindHighestFloorSurrounding( sec );
if( plat->high < sec->floorheight )
{
plat->high = sec->floorheight;
}
plat->wait = TICRATE * PLATWAIT;
plat->status = ( plat_e )( P_Random() & 1 );
S_StartSound( &sec->soundorg, sfx_pstart );
break;
}
P_AddActivePlat( plat );
}
return rtn;
} }
void P_ActivateInStasis(int tag) void P_ActivateInStasis( int tag )
{ {
int i; int i;
for (i = 0;i < MAXPLATS;i++) for( i = 0; i < MAXPLATS; i++ )
if (::g->activeplats[i] if( ::g->activeplats[i]
&& (::g->activeplats[i])->tag == tag && ( ::g->activeplats[i] )->tag == tag
&& (::g->activeplats[i])->status == in_stasis) && ( ::g->activeplats[i] )->status == in_stasis )
{ {
(::g->activeplats[i])->status = (::g->activeplats[i])->oldstatus; ( ::g->activeplats[i] )->status = ( ::g->activeplats[i] )->oldstatus;
(::g->activeplats[i])->thinker.function.acp1 ( ::g->activeplats[i] )->thinker.function.acp1
= (actionf_p1) T_PlatRaise; = ( actionf_p1 ) T_PlatRaise;
} }
} }
void EV_StopPlat(line_t* line) void EV_StopPlat( line_t* line )
{ {
int j; int j;
for (j = 0;j < MAXPLATS;j++) for( j = 0; j < MAXPLATS; j++ )
if (::g->activeplats[j] if( ::g->activeplats[j]
&& ((::g->activeplats[j])->status != in_stasis) && ( ( ::g->activeplats[j] )->status != in_stasis )
&& ((::g->activeplats[j])->tag == line->tag)) && ( ( ::g->activeplats[j] )->tag == line->tag ) )
{ {
(::g->activeplats[j])->oldstatus = (::g->activeplats[j])->status; ( ::g->activeplats[j] )->oldstatus = ( ::g->activeplats[j] )->status;
(::g->activeplats[j])->status = in_stasis; ( ::g->activeplats[j] )->status = in_stasis;
(::g->activeplats[j])->thinker.function.acv = (actionf_v)NULL; ( ::g->activeplats[j] )->thinker.function.acv = ( actionf_v )NULL;
} }
} }
void P_AddActivePlat(plat_t* plat) void P_AddActivePlat( plat_t* plat )
{ {
int i; int i;
for (i = 0;i < MAXPLATS;i++) for( i = 0; i < MAXPLATS; i++ )
if (::g->activeplats[i] == NULL) if( ::g->activeplats[i] == NULL )
{ {
::g->activeplats[i] = plat; ::g->activeplats[i] = plat;
return; return;
} }
I_Error ("P_AddActivePlat: no more plats!"); I_Error( "P_AddActivePlat: no more plats!" );
} }
void P_RemoveActivePlat(plat_t* plat) void P_RemoveActivePlat( plat_t* plat )
{ {
int i; int i;
for (i = 0;i < MAXPLATS;i++) for( i = 0; i < MAXPLATS; i++ )
if (plat == ::g->activeplats[i]) if( plat == ::g->activeplats[i] )
{ {
(::g->activeplats[i])->sector->specialdata = NULL; ( ::g->activeplats[i] )->sector->specialdata = NULL;
P_RemoveThinker(&(::g->activeplats[i])->thinker); P_RemoveThinker( &( ::g->activeplats[i] )->thinker );
::g->activeplats[i] = NULL; ::g->activeplats[i] = NULL;
return; return;
} }
I_Error ("P_RemoveActivePlat: can't find plat!"); I_Error( "P_RemoveActivePlat: can't find plat!" );
} }

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -45,7 +45,7 @@ If you have questions concerning this license or the applicable additional terms
#include "info.h" #include "info.h"
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
@ -65,18 +65,18 @@ If you have questions concerning this license or the applicable additional terms
// //
typedef enum typedef enum
{ {
ps_weapon, ps_weapon,
ps_flash, ps_flash,
NUMPSPRITES NUMPSPRITES
} psprnum_t; } psprnum_t;
typedef struct typedef struct
{ {
const state_t* state; // a NULL state means not active const state_t* state; // a NULL state means not active
int tics; int tics;
fixed_t sx; fixed_t sx;
fixed_t sy; fixed_t sy;
} pspdef_t; } pspdef_t;

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,22 +31,22 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
// Persistent storage/archiving. // Persistent storage/archiving.
// These are the load / save game routines. // These are the load / save game routines.
void P_ArchivePlayers (void); void P_ArchivePlayers( void );
void P_UnArchivePlayers (void); void P_UnArchivePlayers( void );
void P_ArchiveWorld (void); void P_ArchiveWorld( void );
void P_UnArchiveWorld (void); void P_UnArchiveWorld( void );
void P_ArchiveThinkers (void); void P_ArchiveThinkers( void );
void P_UnArchiveThinkers (void); void P_UnArchiveThinkers( void );
void P_ArchiveSpecials (void); void P_ArchiveSpecials( void );
void P_UnArchiveSpecials (void); void P_UnArchiveSpecials( void );
extern byte* save_p; extern byte* save_p;
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -50,7 +50,7 @@ If you have questions concerning this license or the applicable additional terms
#include "doomstat.h" #include "doomstat.h"
void P_SpawnMapThing (mapthing_t* mthing); void P_SpawnMapThing( mapthing_t* mthing );
// //
@ -97,7 +97,7 @@ void P_SpawnMapThing (mapthing_t* mthing);
// //
// P_LoadVertexes // P_LoadVertexes
// //
void P_LoadVertexes (int lump) void P_LoadVertexes( int lump )
{ {
byte* data; byte* data;
int i; int i;
@ -106,28 +106,28 @@ void P_LoadVertexes (int lump)
// Determine number of lumps: // Determine number of lumps:
// total lump length / vertex record length. // total lump length / vertex record length.
::g->numvertexes = W_LumpLength (lump) / sizeof(mapvertex_t); ::g->numvertexes = W_LumpLength( lump ) / sizeof( mapvertex_t );
// Allocate zone memory for buffer. // Allocate zone memory for buffer.
// ::g->vertexes = (vertex_t*)Z_Malloc (::g->numvertexes*sizeof(vertex_t),PU_LEVEL,0); // ::g->vertexes = (vertex_t*)Z_Malloc (::g->numvertexes*sizeof(vertex_t),PU_LEVEL,0);
if (MallocForLump( lump, ::g->numvertexes*sizeof(vertex_t ), ::g->vertexes, PU_LEVEL_SHARED )) if( MallocForLump( lump, ::g->numvertexes * sizeof( vertex_t ), ::g->vertexes, PU_LEVEL_SHARED ) )
{ {
// Load data into cache. // Load data into cache.
data = (byte*)W_CacheLumpNum (lump,PU_CACHE_SHARED); // ALAN: LOADTIME data = ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ); // ALAN: LOADTIME
ml = (mapvertex_t *)data; ml = ( mapvertex_t* )data;
li = ::g->vertexes; li = ::g->vertexes;
// Copy and convert vertex coordinates, // Copy and convert vertex coordinates,
// internal representation as fixed. // internal representation as fixed.
for (i=0 ; i < ::g->numvertexes ; i++, li++, ml++) for( i = 0 ; i < ::g->numvertexes ; i++, li++, ml++ )
{ {
li->x = SHORT(ml->x)<<FRACBITS; li->x = SHORT( ml->x ) << FRACBITS;
li->y = SHORT(ml->y)<<FRACBITS; li->y = SHORT( ml->y ) << FRACBITS;
} }
// Free buffer memory. // Free buffer memory.
Z_Free(data); Z_Free( data );
} }
} }
@ -136,7 +136,7 @@ void P_LoadVertexes (int lump)
// //
// P_LoadSegs // P_LoadSegs
// //
void P_LoadSegs (int lump) void P_LoadSegs( int lump )
{ {
byte* data; byte* data;
int i; int i;
@ -146,36 +146,40 @@ void P_LoadSegs (int lump)
int psetup_linedef; int psetup_linedef;
int side; int side;
::g->numsegs = W_LumpLength (lump) / sizeof(mapseg_t); ::g->numsegs = W_LumpLength( lump ) / sizeof( mapseg_t );
// ::g->segs = (seg_t*)Z_Malloc (::g->numsegs*sizeof(seg_t),PU_LEVEL,0); // ::g->segs = (seg_t*)Z_Malloc (::g->numsegs*sizeof(seg_t),PU_LEVEL,0);
if (MallocForLump( lump, ::g->numsegs*sizeof(seg_t), ::g->segs, PU_LEVEL_SHARED )) if( MallocForLump( lump, ::g->numsegs * sizeof( seg_t ), ::g->segs, PU_LEVEL_SHARED ) )
{ {
memset (::g->segs, 0, ::g->numsegs*sizeof(seg_t)); memset( ::g->segs, 0, ::g->numsegs * sizeof( seg_t ) );
data = (byte*)W_CacheLumpNum (lump,PU_CACHE_SHARED); // ALAN: LOADTIME data = ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ); // ALAN: LOADTIME
ml = (mapseg_t *)data; ml = ( mapseg_t* )data;
li = ::g->segs; li = ::g->segs;
for (i=0 ; i < ::g->numsegs ; i++, li++, ml++) for( i = 0 ; i < ::g->numsegs ; i++, li++, ml++ )
{ {
li->v1 = &::g->vertexes[SHORT(ml->v1)]; li->v1 = &::g->vertexes[SHORT( ml->v1 )];
li->v2 = &::g->vertexes[SHORT(ml->v2)]; li->v2 = &::g->vertexes[SHORT( ml->v2 )];
li->angle = (SHORT(ml->angle))<<16; li->angle = ( SHORT( ml->angle ) ) << 16;
li->offset = (SHORT(ml->offset))<<16; li->offset = ( SHORT( ml->offset ) ) << 16;
psetup_linedef = SHORT(ml->linedef); psetup_linedef = SHORT( ml->linedef );
ldef = &::g->lines[psetup_linedef]; ldef = &::g->lines[psetup_linedef];
li->linedef = ldef; li->linedef = ldef;
side = SHORT(ml->side); side = SHORT( ml->side );
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 );
} }
} }
@ -183,30 +187,30 @@ void P_LoadSegs (int lump)
// //
// P_LoadSubsectors // P_LoadSubsectors
// //
void P_LoadSubsectors (int lump) void P_LoadSubsectors( int lump )
{ {
byte* data; byte* data;
int i; int i;
mapsubsector_t* ms; mapsubsector_t* ms;
subsector_t* ss; subsector_t* ss;
::g->numsubsectors = W_LumpLength (lump) / sizeof(mapsubsector_t); ::g->numsubsectors = W_LumpLength( lump ) / sizeof( mapsubsector_t );
if (MallocForLump( lump, ::g->numsubsectors*sizeof(subsector_t), ::g->subsectors, PU_LEVEL_SHARED )) if( MallocForLump( lump, ::g->numsubsectors * sizeof( subsector_t ), ::g->subsectors, PU_LEVEL_SHARED ) )
{ {
data = (byte*)W_CacheLumpNum (lump,PU_CACHE_SHARED); // ALAN: LOADTIME data = ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ); // ALAN: LOADTIME
ms = (mapsubsector_t *)data; ms = ( mapsubsector_t* )data;
memset (::g->subsectors,0, ::g->numsubsectors*sizeof(subsector_t)); memset( ::g->subsectors, 0, ::g->numsubsectors * sizeof( subsector_t ) );
ss = ::g->subsectors; ss = ::g->subsectors;
for (i=0 ; i < ::g->numsubsectors ; i++, ss++, ms++) for( i = 0 ; i < ::g->numsubsectors ; i++, ss++, ms++ )
{ {
ss->numlines = SHORT(ms->numsegs); ss->numlines = SHORT( ms->numsegs );
ss->firstline = SHORT(ms->firstseg); ss->firstline = SHORT( ms->firstseg );
} }
Z_Free(data); Z_Free( data );
} }
} }
@ -215,65 +219,65 @@ void P_LoadSubsectors (int lump)
// //
// P_LoadSectors // P_LoadSectors
// //
void P_LoadSectors (int lump) void P_LoadSectors( int lump )
{ {
byte* data; byte* data;
int i; int i;
mapsector_t* ms; mapsector_t* ms;
sector_t* ss; sector_t* ss;
::g->numsectors = W_LumpLength (lump) / sizeof(mapsector_t); ::g->numsectors = W_LumpLength( lump ) / sizeof( mapsector_t );
::g->sectors = (sector_t*)Z_Malloc( ::g->numsectors*sizeof(sector_t), PU_LEVEL, NULL );
memset (::g->sectors, 0, ::g->numsectors*sizeof(sector_t));
data = (byte*)W_CacheLumpNum (lump,PU_CACHE_SHARED); // ALAN: LOADTIME
ms = (mapsector_t *)data; ::g->sectors = ( sector_t* )Z_Malloc( ::g->numsectors * sizeof( sector_t ), PU_LEVEL, NULL );
memset( ::g->sectors, 0, ::g->numsectors * sizeof( sector_t ) );
data = ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ); // ALAN: LOADTIME
ms = ( mapsector_t* )data;
ss = ::g->sectors; ss = ::g->sectors;
for (i=0 ; i < ::g->numsectors ; i++, ss++, ms++) for( i = 0 ; i < ::g->numsectors ; i++, ss++, ms++ )
{ {
ss->floorheight = SHORT(ms->floorheight)<<FRACBITS; ss->floorheight = SHORT( ms->floorheight ) << FRACBITS;
ss->ceilingheight = SHORT(ms->ceilingheight)<<FRACBITS; ss->ceilingheight = SHORT( ms->ceilingheight ) << FRACBITS;
ss->floorpic = R_FlatNumForName(ms->floorpic); ss->floorpic = R_FlatNumForName( ms->floorpic );
ss->ceilingpic = R_FlatNumForName(ms->ceilingpic); ss->ceilingpic = R_FlatNumForName( ms->ceilingpic );
ss->lightlevel = SHORT(ms->lightlevel); ss->lightlevel = SHORT( ms->lightlevel );
ss->special = SHORT(ms->special); ss->special = SHORT( ms->special );
ss->tag = SHORT(ms->tag); ss->tag = SHORT( ms->tag );
ss->thinglist = NULL; ss->thinglist = NULL;
} }
Z_Free(data); Z_Free( data );
/* /*
if (MallocForLump( lump, ::g->numsectors*sizeof(sector_t), (void**)&::g->sectors, PU_LEVEL_SHARED )) if (MallocForLump( lump, ::g->numsectors*sizeof(sector_t), (void**)&::g->sectors, PU_LEVEL_SHARED ))
{
memset (::g->sectors, 0, ::g->numsectors*sizeof(sector_t));
data = (byte*)W_CacheLumpNum (lump,PU_CACHE_SHARED); // ALAN: LOADTIME
ms = (mapsector_t *)data;
ss = ::g->sectors;
for (i=0 ; i < ::g->numsectors ; i++, ss++, ms++)
{ {
ss->floorheight = SHORT(ms->floorheight)<<FRACBITS; memset (::g->sectors, 0, ::g->numsectors*sizeof(sector_t));
ss->ceilingheight = SHORT(ms->ceilingheight)<<FRACBITS; data = (byte*)W_CacheLumpNum (lump,PU_CACHE_SHARED); // ALAN: LOADTIME
ss->floorpic = R_FlatNumForName(ms->floorpic);
ss->ceilingpic = R_FlatNumForName(ms->ceilingpic);
ss->lightlevel = SHORT(ms->lightlevel);
ss->special = SHORT(ms->special);
ss->tag = SHORT(ms->tag);
ss->thinglist = NULL;
}
DoomLib::Z_Free(data); ms = (mapsector_t *)data;
} ss = ::g->sectors;
*/ for (i=0 ; i < ::g->numsectors ; i++, ss++, ms++)
{
ss->floorheight = SHORT(ms->floorheight)<<FRACBITS;
ss->ceilingheight = SHORT(ms->ceilingheight)<<FRACBITS;
ss->floorpic = R_FlatNumForName(ms->floorpic);
ss->ceilingpic = R_FlatNumForName(ms->ceilingpic);
ss->lightlevel = SHORT(ms->lightlevel);
ss->special = SHORT(ms->special);
ss->tag = SHORT(ms->tag);
ss->thinglist = NULL;
}
DoomLib::Z_Free(data);
}
*/
} }
// //
// P_LoadNodes // P_LoadNodes
// //
void P_LoadNodes (int lump) void P_LoadNodes( int lump )
{ {
byte* data; byte* data;
int i; int i;
@ -282,29 +286,31 @@ void P_LoadNodes (int lump)
mapnode_t* mn; mapnode_t* mn;
node_t* no; node_t* no;
::g->numnodes = W_LumpLength (lump) / sizeof(mapnode_t); ::g->numnodes = W_LumpLength( lump ) / sizeof( mapnode_t );
if (MallocForLump( lump, ::g->numnodes*sizeof(node_t), ::g->nodes, PU_LEVEL_SHARED )) if( MallocForLump( lump, ::g->numnodes * sizeof( node_t ), ::g->nodes, PU_LEVEL_SHARED ) )
{ {
data = (byte*)W_CacheLumpNum (lump,PU_CACHE_SHARED); // ALAN: LOADTIME data = ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ); // ALAN: LOADTIME
mn = (mapnode_t *)data; mn = ( mapnode_t* )data;
no = ::g->nodes; no = ::g->nodes;
for (i=0 ; i < ::g->numnodes ; i++, no++, mn++) for( i = 0 ; i < ::g->numnodes ; i++, no++, mn++ )
{ {
no->x = SHORT(mn->x)<<FRACBITS; no->x = SHORT( mn->x ) << FRACBITS;
no->y = SHORT(mn->y)<<FRACBITS; no->y = SHORT( mn->y ) << FRACBITS;
no->dx = SHORT(mn->dx)<<FRACBITS; no->dx = SHORT( mn->dx ) << FRACBITS;
no->dy = SHORT(mn->dy)<<FRACBITS; no->dy = SHORT( mn->dy ) << FRACBITS;
for (j=0 ; j<2 ; j++) for( j = 0 ; j < 2 ; j++ )
{ {
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 );
} }
} }
@ -312,7 +318,7 @@ void P_LoadNodes (int lump)
// //
// P_LoadThings // P_LoadThings
// //
void P_LoadThings (int lump) void P_LoadThings( int lump )
{ {
byte* data; byte* data;
int i; int i;
@ -320,47 +326,49 @@ void P_LoadThings (int lump)
int numthings; int numthings;
qboolean spawn; qboolean spawn;
data = (byte*)W_CacheLumpNum (lump,PU_CACHE_SHARED); // ALAN: LOADTIME data = ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ); // ALAN: LOADTIME
numthings = (W_LumpLength (lump) / sizeof(mapthing_t)); numthings = ( W_LumpLength( lump ) / sizeof( mapthing_t ) );
mt = (mapthing_t *)data; mt = ( mapthing_t* )data;
for (i=0 ; i<numthings ; i++, mt++) for( i = 0 ; i < numthings ; i++, mt++ )
{ {
spawn = true; spawn = true;
// Do not spawn cool, new monsters if !commercial // Do not spawn cool, new monsters if !commercial
if ( ::g->gamemode != commercial) if( ::g->gamemode != commercial )
{ {
switch(mt->type) switch( mt->type )
{ {
case 68: // Arachnotron case 68: // Arachnotron
case 64: // Archvile case 64: // Archvile
case 88: // Boss Brain case 88: // Boss Brain
case 89: // Boss Shooter case 89: // Boss Shooter
case 69: // Hell Knight case 69: // Hell Knight
case 67: // Mancubus case 67: // Mancubus
case 71: // Pain Elemental case 71: // Pain Elemental
case 65: // Former Human Commando case 65: // Former Human Commando
case 66: // Revenant case 66: // Revenant
case 84: // Wolf SS case 84: // Wolf SS
spawn = false; spawn = false;
break; break;
} }
} }
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 );
mt->y = SHORT(mt->y); mt->y = SHORT( mt->y );
mt->angle = SHORT(mt->angle); mt->angle = SHORT( mt->angle );
mt->type = SHORT(mt->type); mt->type = SHORT( mt->type );
mt->options = SHORT(mt->options); mt->options = SHORT( mt->options );
P_SpawnMapThing (mt); P_SpawnMapThing( mt );
} }
Z_Free(data); Z_Free( data );
} }
@ -368,7 +376,7 @@ void P_LoadThings (int lump)
// P_LoadLineDefs // P_LoadLineDefs
// Also counts secret ::g->lines for intermissions. // Also counts secret ::g->lines for intermissions.
// //
void P_LoadLineDefs (int lump) void P_LoadLineDefs( int lump )
{ {
byte* data; byte* data;
int i; int i;
@ -377,37 +385,45 @@ void P_LoadLineDefs (int lump)
vertex_t* v1; vertex_t* v1;
vertex_t* v2; vertex_t* v2;
::g->numlines = W_LumpLength (lump) / sizeof(maplinedef_t); ::g->numlines = W_LumpLength( lump ) / sizeof( maplinedef_t );
if (MallocForLump( lump, ::g->numlines*sizeof(line_t), ::g->lines, PU_LEVEL_SHARED )) if( MallocForLump( lump, ::g->numlines * sizeof( line_t ), ::g->lines, PU_LEVEL_SHARED ) )
{ {
memset (::g->lines, 0, ::g->numlines*sizeof(line_t)); memset( ::g->lines, 0, ::g->numlines * sizeof( line_t ) );
data = (byte*)W_CacheLumpNum (lump,PU_CACHE_SHARED); // ALAN: LOADTIME data = ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ); // ALAN: LOADTIME
mld = (maplinedef_t *)data; mld = ( maplinedef_t* )data;
ld = ::g->lines; ld = ::g->lines;
for (i=0 ; i < ::g->numlines ; i++, mld++, ld++) for( i = 0 ; i < ::g->numlines ; i++, mld++, ld++ )
{ {
ld->flags = SHORT(mld->flags); ld->flags = SHORT( mld->flags );
ld->special = SHORT(mld->special); ld->special = SHORT( mld->special );
ld->tag = SHORT(mld->tag); ld->tag = SHORT( mld->tag );
v1 = ld->v1 = &::g->vertexes[SHORT(mld->v1)]; v1 = ld->v1 = &::g->vertexes[SHORT( mld->v1 )];
v2 = ld->v2 = &::g->vertexes[SHORT(mld->v2)]; v2 = ld->v2 = &::g->vertexes[SHORT( mld->v2 )];
ld->dx = v2->x - v1->x; ld->dx = v2->x - v1->x;
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 )
{ {
ld->bbox[BOXLEFT] = v1->x; ld->bbox[BOXLEFT] = v1->x;
ld->bbox[BOXRIGHT] = v2->x; ld->bbox[BOXRIGHT] = v2->x;
@ -418,7 +434,7 @@ void P_LoadLineDefs (int lump)
ld->bbox[BOXRIGHT] = v1->x; ld->bbox[BOXRIGHT] = v1->x;
} }
if (v1->y < v2->y) if( v1->y < v2->y )
{ {
ld->bbox[BOXBOTTOM] = v1->y; ld->bbox[BOXBOTTOM] = v1->y;
ld->bbox[BOXTOP] = v2->y; ld->bbox[BOXTOP] = v2->y;
@ -429,21 +445,29 @@ void P_LoadLineDefs (int lump)
ld->bbox[BOXTOP] = v1->y; ld->bbox[BOXTOP] = v1->y;
} }
ld->sidenum[0] = SHORT(mld->sidenum[0]); ld->sidenum[0] = SHORT( mld->sidenum[0] );
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 );
} }
} }
@ -451,32 +475,32 @@ void P_LoadLineDefs (int lump)
// //
// P_LoadSideDefs // P_LoadSideDefs
// //
void P_LoadSideDefs (int lump) void P_LoadSideDefs( int lump )
{ {
byte* data; byte* data;
int i; int i;
mapsidedef_t* msd; mapsidedef_t* msd;
side_t* sd; side_t* sd;
::g->numsides = W_LumpLength (lump) / sizeof(mapsidedef_t); ::g->numsides = W_LumpLength( lump ) / sizeof( mapsidedef_t );
if (MallocForLump( lump, ::g->numsides*sizeof(side_t), ::g->sides, PU_LEVEL_SHARED)) if( MallocForLump( lump, ::g->numsides * sizeof( side_t ), ::g->sides, PU_LEVEL_SHARED ) )
{ {
memset (::g->sides, 0, ::g->numsides*sizeof(side_t)); memset( ::g->sides, 0, ::g->numsides * sizeof( side_t ) );
data = (byte*)W_CacheLumpNum (lump,PU_CACHE_SHARED); // ALAN: LOADTIME data = ( byte* )W_CacheLumpNum( lump, PU_CACHE_SHARED ); // ALAN: LOADTIME
msd = (mapsidedef_t *)data; msd = ( mapsidedef_t* )data;
sd = ::g->sides; sd = ::g->sides;
for (i=0 ; i < ::g->numsides ; i++, msd++, sd++) for( i = 0 ; i < ::g->numsides ; i++, msd++, sd++ )
{ {
sd->textureoffset = SHORT(msd->textureoffset)<<FRACBITS; sd->textureoffset = SHORT( msd->textureoffset ) << FRACBITS;
sd->rowoffset = SHORT(msd->rowoffset)<<FRACBITS; sd->rowoffset = SHORT( msd->rowoffset ) << FRACBITS;
sd->toptexture = R_TextureNumForName(msd->toptexture); sd->toptexture = R_TextureNumForName( msd->toptexture );
sd->bottomtexture = R_TextureNumForName(msd->bottomtexture); sd->bottomtexture = R_TextureNumForName( msd->bottomtexture );
sd->midtexture = R_TextureNumForName(msd->midtexture); sd->midtexture = R_TextureNumForName( msd->midtexture );
sd->sector = &::g->sectors[SHORT(msd->sector)]; sd->sector = &::g->sectors[SHORT( msd->sector )];
} }
Z_Free(data); Z_Free( data );
} }
} }
@ -484,34 +508,38 @@ void P_LoadSideDefs (int lump)
// //
// P_LoadBlockMap // P_LoadBlockMap
// //
void P_LoadBlockMap (int lump) void P_LoadBlockMap( int lump )
{ {
int i; int i;
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;
} }
::g->blockmaplump = (short*)W_CacheLumpNum (lump,PU_LEVEL_SHARED); // ALAN: This is initialized somewhere else as shared... ::g->blockmaplump = ( short* )W_CacheLumpNum( lump, PU_LEVEL_SHARED ); // ALAN: This is initialized somewhere else as shared...
::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++) {
::g->blockmaplump[i] = SHORT(::g->blockmaplump[i]); for( i = 0 ; i < count ; 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;
::g->bmapwidth = ( ::g->blockmaplump[2] ); ::g->bmapwidth = ( ::g->blockmaplump[2] );
::g->bmapheight = ( ::g->blockmaplump[3] ); ::g->bmapheight = ( ::g->blockmaplump[3] );
// clear out mobj chains // clear out mobj chains
count = sizeof(*::g->blocklinks)* ::g->bmapwidth*::g->bmapheight; count = sizeof( *::g->blocklinks )* ::g->bmapwidth*::g->bmapheight;
::g->blocklinks = (mobj_t**)Z_Malloc (count,PU_LEVEL, 0); ::g->blocklinks = ( mobj_t** )Z_Malloc( count, PU_LEVEL, 0 );
memset (::g->blocklinks, 0, count); memset( ::g->blocklinks, 0, count );
} }
@ -521,7 +549,7 @@ void P_LoadBlockMap (int lump)
// Builds sector line lists and subsector sector numbers. // Builds sector line lists and subsector sector numbers.
// Finds block bounding boxes for ::g->sectors. // Finds block bounding boxes for ::g->sectors.
// //
void P_GroupLines (void) void P_GroupLines( void )
{ {
line_t** linebuffer; line_t** linebuffer;
int i; int i;
@ -534,10 +562,10 @@ void P_GroupLines (void)
fixed_t bbox[4]; fixed_t bbox[4];
int block; int block;
// look up sector number for each subsector // look up sector number for each subsector
ss = ::g->subsectors; ss = ::g->subsectors;
for (i=0 ; i < ::g->numsubsectors ; i++, ss++) for( i = 0 ; i < ::g->numsubsectors ; i++, ss++ )
{ {
seg = &::g->segs[ss->firstline]; seg = &::g->segs[ss->firstline];
ss->sector = seg->sidedef->sector; ss->sector = seg->sidedef->sector;
@ -546,58 +574,60 @@ void P_GroupLines (void)
// count number of ::g->lines in each sector // count number of ::g->lines in each sector
li = ::g->lines; li = ::g->lines;
total = 0; total = 0;
for (i=0 ; i < ::g->numlines ; i++, li++) for( i = 0 ; i < ::g->numlines ; i++, li++ )
{ {
total++; total++;
li->frontsector->linecount++; li->frontsector->linecount++;
if (li->backsector && li->backsector != li->frontsector) if( li->backsector && li->backsector != li->frontsector )
{ {
li->backsector->linecount++; li->backsector->linecount++;
total++; total++;
} }
} }
// build line tables for each sector // build line tables for each sector
linebuffer = (line_t**)Z_Malloc (total*sizeof(line_t*), PU_LEVEL, 0); linebuffer = ( line_t** )Z_Malloc( total * sizeof( line_t* ), PU_LEVEL, 0 );
sector = ::g->sectors; sector = ::g->sectors;
for (i=0 ; i < ::g->numsectors ; i++, sector++) for( i = 0 ; i < ::g->numsectors ; i++, sector++ )
{ {
M_ClearBox (bbox); M_ClearBox( bbox );
sector->lines = linebuffer; sector->lines = linebuffer;
li = ::g->lines; li = ::g->lines;
for (j=0 ; j < ::g->numlines ; j++, li++) for( j = 0 ; j < ::g->numlines ; j++, li++ )
{ {
if (li->frontsector == sector || li->backsector == sector) if( li->frontsector == sector || li->backsector == sector )
{ {
*linebuffer++ = li; *linebuffer++ = li;
M_AddToBox (bbox, li->v1->x, li->v1->y); M_AddToBox( bbox, li->v1->x, li->v1->y );
M_AddToBox (bbox, li->v2->x, li->v2->y); M_AddToBox( bbox, li->v2->x, li->v2->y );
} }
} }
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;
sector->soundorg.y = (bbox[BOXTOP]+bbox[BOXBOTTOM])/2; sector->soundorg.y = ( bbox[BOXTOP] + bbox[BOXBOTTOM] ) / 2;
// adjust bounding box to map blocks // adjust bounding box to map blocks
block = (bbox[BOXTOP]-::g->bmaporgy+MAXRADIUS)>>MAPBLOCKSHIFT; block = ( bbox[BOXTOP] -::g->bmaporgy + MAXRADIUS ) >> MAPBLOCKSHIFT;
block = block >= ::g->bmapheight ? ::g->bmapheight-1 : block; block = block >= ::g->bmapheight ? ::g->bmapheight - 1 : block;
sector->blockbox[BOXTOP]=block; sector->blockbox[BOXTOP] = block;
block = (bbox[BOXBOTTOM]-::g->bmaporgy-MAXRADIUS)>>MAPBLOCKSHIFT; block = ( bbox[BOXBOTTOM] -::g->bmaporgy - MAXRADIUS ) >> MAPBLOCKSHIFT;
block = block < 0 ? 0 : block; block = block < 0 ? 0 : block;
sector->blockbox[BOXBOTTOM]=block; sector->blockbox[BOXBOTTOM] = block;
block = (bbox[BOXRIGHT]-::g->bmaporgx+MAXRADIUS)>>MAPBLOCKSHIFT; block = ( bbox[BOXRIGHT] -::g->bmaporgx + MAXRADIUS ) >> MAPBLOCKSHIFT;
block = block >= ::g->bmapwidth ? ::g->bmapwidth-1 : block; block = block >= ::g->bmapwidth ? ::g->bmapwidth - 1 : block;
sector->blockbox[BOXRIGHT]=block; sector->blockbox[BOXRIGHT] = block;
block = (bbox[BOXLEFT]-::g->bmaporgx-MAXRADIUS)>>MAPBLOCKSHIFT; block = ( bbox[BOXLEFT] -::g->bmaporgx - MAXRADIUS ) >> MAPBLOCKSHIFT;
block = block < 0 ? 0 : block; block = block < 0 ? 0 : block;
sector->blockbox[BOXLEFT]=block; sector->blockbox[BOXLEFT] = block;
} }
} }
@ -609,9 +639,9 @@ void P_GroupLines (void)
void void
P_SetupLevel P_SetupLevel
( int episode, ( int episode,
int map, int map,
int playermask, int playermask,
skill_t skill) skill_t skill )
{ {
int i; int i;
char lumpname[9]; char lumpname[9];
@ -619,10 +649,10 @@ P_SetupLevel
::g->totalkills = ::g->totalitems = ::g->totalsecret = ::g->wminfo.maxfrags = 0; ::g->totalkills = ::g->totalitems = ::g->totalsecret = ::g->wminfo.maxfrags = 0;
::g->wminfo.partime = 180; ::g->wminfo.partime = 180;
for (i=0 ; i<MAXPLAYERS ; i++) for( i = 0 ; i < MAXPLAYERS ; i++ )
{ {
::g->players[i].killcount = ::g->players[i].secretcount ::g->players[i].killcount = ::g->players[i].secretcount
= ::g->players[i].itemcount = 0; = ::g->players[i].itemcount = 0;
::g->players[i].chainsawKills = 0; ::g->players[i].chainsawKills = 0;
::g->players[i].berserkKills = 0; ::g->players[i].berserkKills = 0;
@ -630,35 +660,39 @@ P_SetupLevel
// Initial height of PointOfView // Initial height of PointOfView
// will be set by player think. // will be set by player think.
::g->players[::g->consoleplayer].viewz = 1; ::g->players[::g->consoleplayer].viewz = 1;
// Make sure all sounds are stopped before Z_FreeTags. // Make sure all sounds are stopped before Z_FreeTags.
S_Start (); S_Start();
Z_FreeTags( PU_LEVEL, PU_PURGELEVEL-1 ); Z_FreeTags( PU_LEVEL, PU_PURGELEVEL - 1 );
// UNUSED W_Profile (); // UNUSED W_Profile ();
P_InitThinkers (); P_InitThinkers();
// if working with a devlopment map, reload it // if working with a devlopment map, reload it
// W_Reload (); // W_Reload ();
// DHM - NERVE :: Update the cached asset pointers in case the wad files were reloaded // DHM - NERVE :: Update the cached asset pointers in case the wad files were reloaded
{ {
void ST_loadData(void); void ST_loadData( void );
ST_loadData(); ST_loadData();
void HU_Init(void); void HU_Init( void );
HU_Init(); HU_Init();
} }
// find map name // find map name
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
{ {
@ -669,56 +703,58 @@ P_SetupLevel
lumpname[4] = 0; lumpname[4] = 0;
} }
lumpnum = W_GetNumForName (lumpname); lumpnum = W_GetNumForName( lumpname );
::g->leveltime = 0; ::g->leveltime = 0;
// note: most of this ordering is important // note: most of this ordering is important
P_LoadBlockMap (lumpnum+ML_BLOCKMAP); P_LoadBlockMap( lumpnum + ML_BLOCKMAP );
P_LoadVertexes (lumpnum+ML_VERTEXES); P_LoadVertexes( lumpnum + ML_VERTEXES );
P_LoadSectors (lumpnum+ML_SECTORS); P_LoadSectors( lumpnum + ML_SECTORS );
P_LoadSideDefs (lumpnum+ML_SIDEDEFS); P_LoadSideDefs( lumpnum + ML_SIDEDEFS );
P_LoadLineDefs (lumpnum+ML_LINEDEFS); P_LoadLineDefs( lumpnum + ML_LINEDEFS );
P_LoadSubsectors (lumpnum+ML_SSECTORS); P_LoadSubsectors( lumpnum + ML_SSECTORS );
P_LoadNodes (lumpnum+ML_NODES); P_LoadNodes( lumpnum + ML_NODES );
P_LoadSegs (lumpnum+ML_SEGS); P_LoadSegs( lumpnum + ML_SEGS );
::g->rejectmatrix = (byte*)W_CacheLumpNum (lumpnum+ML_REJECT,PU_LEVEL); ::g->rejectmatrix = ( byte* )W_CacheLumpNum( lumpnum + ML_REJECT, PU_LEVEL );
P_GroupLines (); P_GroupLines();
::g->bodyqueslot = 0; ::g->bodyqueslot = 0;
::g->deathmatch_p = ::g->deathmatchstarts; ::g->deathmatch_p = ::g->deathmatchstarts;
P_LoadThings (lumpnum+ML_THINGS); P_LoadThings( lumpnum + ML_THINGS );
// if ::g->deathmatch, randomly spawn the active ::g->players // if ::g->deathmatch, randomly spawn the active ::g->players
if (::g->deathmatch) if( ::g->deathmatch )
{ {
for (i=0 ; i<MAXPLAYERS ; i++) for( i = 0 ; i < MAXPLAYERS ; i++ )
if (::g->playeringame[i]) if( ::g->playeringame[i] )
{ {
// DHM - Nerve :: In deathmatch, reset every player at match start // DHM - Nerve :: In deathmatch, reset every player at match start
::g->players[i].playerstate = PST_REBORN; ::g->players[i].playerstate = PST_REBORN;
::g->players[i].mo = NULL; ::g->players[i].mo = NULL;
G_DeathMatchSpawnPlayer (i); G_DeathMatchSpawnPlayer( i );
} }
} }
// clear special respawning que // clear special respawning que
::g->iquehead = ::g->iquetail = 0; ::g->iquehead = ::g->iquetail = 0;
// set up world state // set up world state
P_SpawnSpecials (); P_SpawnSpecials();
// build subsector connect matrix // build subsector connect matrix
// UNUSED P_ConnectSubsectors (); // UNUSED P_ConnectSubsectors ();
// preload graphics // preload graphics
if (::g->precache) if( ::g->precache )
R_PrecacheLevel (); {
R_PrecacheLevel();
}
} }
@ -726,11 +762,11 @@ P_SetupLevel
// //
// P_Init // P_Init
// //
void P_Init (void) void P_Init( void )
{ {
P_InitSwitchList (); P_InitSwitchList();
P_InitPicAnims (); P_InitPicAnims();
R_InitSprites (sprnames); R_InitSprites( sprnames );
} }

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,7 +31,7 @@ If you have questions concerning this license or the applicable additional terms
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface #pragma interface
#endif #endif
@ -41,10 +41,10 @@ P_SetupLevel
( int episode, ( int episode,
int map, int map,
int playermask, int playermask,
skill_t skill); skill_t skill );
// Called by startup code. // Called by startup code.
void P_Init (void); void P_Init( void );
#endif #endif

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -55,45 +55,57 @@ P_DivlineSide
fixed_t y, fixed_t y,
divline_t* node ) divline_t* node )
{ {
fixed_t dx; fixed_t dx;
fixed_t dy; fixed_t dy;
fixed_t left; fixed_t left;
fixed_t right; fixed_t right;
if (!node->dx) if( !node->dx )
{ {
if (x==node->x) if( x == node->x )
return 2; {
return 2;
if (x <= node->x) }
return node->dy > 0;
return node->dy < 0; if( x <= node->x )
} {
return node->dy > 0;
if (!node->dy) }
{
if (x==node->y)
return 2;
if (y <= node->y) return node->dy < 0;
return node->dx < 0; }
return node->dx > 0; if( !node->dy )
} {
if( x == node->y )
dx = (x - node->x); {
dy = (y - node->y); return 2;
}
left = (node->dy>>FRACBITS) * (dx>>FRACBITS); if( y <= node->y )
right = (dy>>FRACBITS) * (node->dx>>FRACBITS); {
return node->dx < 0;
if (right < left) }
return 0; // front side
return node->dx > 0;
if (left == right) }
return 2;
return 1; // back side dx = ( x - node->x );
dy = ( y - node->y );
left = ( node->dy >> FRACBITS ) * ( dx >> FRACBITS );
right = ( dy >> FRACBITS ) * ( node->dx >> FRACBITS );
if( right < left )
{
return 0; // front side
}
if( left == right )
{
return 2;
}
return 1; // back side
} }
@ -108,21 +120,23 @@ P_InterceptVector2
( divline_t* v2, ( divline_t* v2,
divline_t* v1 ) divline_t* v1 )
{ {
fixed_t frac; fixed_t frac;
fixed_t num; fixed_t num;
fixed_t den; fixed_t den;
den = FixedMul (v1->dy>>8,v2->dx) - FixedMul(v1->dx>>8,v2->dy);
if (den == 0) den = FixedMul( v1->dy >> 8, v2->dx ) - FixedMul( v1->dx >> 8, v2->dy );
return 0;
// I_Error ("P_InterceptVector: parallel");
num = FixedMul ( (v1->x - v2->x)>>8 ,v1->dy) +
FixedMul ( (v2->y - v1->y)>>8 , v1->dx);
frac = FixedDiv (num , den);
return frac; if( den == 0 )
{
return 0;
}
// I_Error ("P_InterceptVector: parallel");
num = FixedMul( ( v1->x - v2->x ) >> 8 , v1->dy ) +
FixedMul( ( v2->y - v1->y ) >> 8 , v1->dx );
frac = FixedDiv( num , den );
return frac;
} }
// //
@ -130,119 +144,145 @@ P_InterceptVector2
// Returns true // Returns true
// if ::g->strace crosses the given subsector successfully. // if ::g->strace crosses the given subsector successfully.
// //
qboolean P_CrossSubsector (int num) qboolean P_CrossSubsector( int num )
{ {
seg_t* seg; seg_t* seg;
line_t* line; line_t* line;
int s1; int s1;
int s2; int s2;
int count; int count;
subsector_t* sub; subsector_t* sub;
sector_t* front; sector_t* front;
sector_t* back; sector_t* back;
fixed_t psight_opentop; fixed_t psight_opentop;
fixed_t psight_openbottom; fixed_t psight_openbottom;
divline_t divl; divline_t divl;
vertex_t* v1; vertex_t* v1;
vertex_t* v2; vertex_t* v2;
fixed_t frac; fixed_t frac;
fixed_t slope; fixed_t slope;
#ifdef RANGECHECK #ifdef RANGECHECK
if (num>=::g->numsubsectors) if( num >=::g->numsubsectors )
I_Error ("P_CrossSubsector: ss %i with numss = %i", I_Error( "P_CrossSubsector: ss %i with numss = %i",
num, num,
::g->numsubsectors); ::g->numsubsectors );
#endif #endif
sub = &::g->subsectors[num]; sub = &::g->subsectors[num];
// check ::g->lines
count = sub->numlines;
seg = &::g->segs[sub->firstline];
for ( ; count ; seg++, count--) // check ::g->lines
{ count = sub->numlines;
line = seg->linedef; seg = &::g->segs[sub->firstline];
// allready checked other side? for( ; count ; seg++, count-- )
if (line->validcount == ::g->validcount)
continue;
line->validcount = ::g->validcount;
v1 = line->v1;
v2 = line->v2;
s1 = P_DivlineSide (v1->x,v1->y, &::g->strace);
s2 = P_DivlineSide (v2->x, v2->y, &::g->strace);
// line isn't crossed?
if (s1 == s2)
continue;
divl.x = v1->x;
divl.y = v1->y;
divl.dx = v2->x - v1->x;
divl.dy = v2->y - v1->y;
s1 = P_DivlineSide (::g->strace.x, ::g->strace.y, &divl);
s2 = P_DivlineSide (::g->t2x, ::g->t2y, &divl);
// line isn't crossed?
if (s1 == s2)
continue;
// stop because it is not two sided anyway
// might do this after updating validcount?
if ( !(line->flags & ML_TWOSIDED) )
return false;
// crosses a two sided line
front = seg->frontsector;
back = seg->backsector;
// no wall to block sight with?
if (front->floorheight == back->floorheight
&& front->ceilingheight == back->ceilingheight)
continue;
// possible occluder
// because of ceiling height differences
if (front->ceilingheight < back->ceilingheight)
psight_opentop = front->ceilingheight;
else
psight_opentop = back->ceilingheight;
// because of ceiling height differences
if (front->floorheight > back->floorheight)
psight_openbottom = front->floorheight;
else
psight_openbottom = back->floorheight;
// quick test for totally closed doors
if (psight_openbottom >= psight_opentop)
return false; // stop
frac = P_InterceptVector2 (&::g->strace, &divl);
if (front->floorheight != back->floorheight)
{ {
slope = FixedDiv (psight_openbottom - ::g->sightzstart , frac); line = seg->linedef;
if (slope > ::g->bottomslope)
::g->bottomslope = slope; // allready checked other side?
if( line->validcount == ::g->validcount )
{
continue;
}
line->validcount = ::g->validcount;
v1 = line->v1;
v2 = line->v2;
s1 = P_DivlineSide( v1->x, v1->y, &::g->strace );
s2 = P_DivlineSide( v2->x, v2->y, &::g->strace );
// line isn't crossed?
if( s1 == s2 )
{
continue;
}
divl.x = v1->x;
divl.y = v1->y;
divl.dx = v2->x - v1->x;
divl.dy = v2->y - v1->y;
s1 = P_DivlineSide( ::g->strace.x, ::g->strace.y, &divl );
s2 = P_DivlineSide( ::g->t2x, ::g->t2y, &divl );
// line isn't crossed?
if( s1 == s2 )
{
continue;
}
// stop because it is not two sided anyway
// might do this after updating validcount?
if( !( line->flags & ML_TWOSIDED ) )
{
return false;
}
// crosses a two sided line
front = seg->frontsector;
back = seg->backsector;
// no wall to block sight with?
if( front->floorheight == back->floorheight
&& front->ceilingheight == back->ceilingheight )
{
continue;
}
// possible occluder
// because of ceiling height differences
if( front->ceilingheight < back->ceilingheight )
{
psight_opentop = front->ceilingheight;
}
else
{
psight_opentop = back->ceilingheight;
}
// because of ceiling height differences
if( front->floorheight > back->floorheight )
{
psight_openbottom = front->floorheight;
}
else
{
psight_openbottom = back->floorheight;
}
// quick test for totally closed doors
if( psight_openbottom >= psight_opentop )
{
return false; // stop
}
frac = P_InterceptVector2( &::g->strace, &divl );
if( front->floorheight != back->floorheight )
{
slope = FixedDiv( psight_openbottom - ::g->sightzstart , frac );
if( slope > ::g->bottomslope )
{
::g->bottomslope = slope;
}
}
if( front->ceilingheight != back->ceilingheight )
{
slope = FixedDiv( psight_opentop - ::g->sightzstart , frac );
if( slope < ::g->topslope )
{
::g->topslope = slope;
}
}
if( ::g->topslope <= ::g->bottomslope )
{
return false; // stop
}
} }
// passed the subsector ok
if (front->ceilingheight != back->ceilingheight) return true;
{
slope = FixedDiv (psight_opentop - ::g->sightzstart , frac);
if (slope < ::g->topslope)
::g->topslope = slope;
}
if (::g->topslope <= ::g->bottomslope)
return false; // stop
}
// passed the subsector ok
return true;
} }
@ -252,39 +292,47 @@ qboolean P_CrossSubsector (int num)
// Returns true // Returns true
// if ::g->strace crosses the given node successfully. // if ::g->strace crosses the given node successfully.
// //
qboolean P_CrossBSPNode (int bspnum) qboolean P_CrossBSPNode( int bspnum )
{ {
node_t* bsp; node_t* bsp;
int side; int side;
if (bspnum & NF_SUBSECTOR) if( bspnum & NF_SUBSECTOR )
{ {
if (bspnum == -1) if( bspnum == -1 )
return P_CrossSubsector (0); {
else return P_CrossSubsector( 0 );
return P_CrossSubsector (bspnum&(~NF_SUBSECTOR)); }
} else
{
bsp = &::g->nodes[bspnum]; return P_CrossSubsector( bspnum & ( ~NF_SUBSECTOR ) );
}
// decide which side the start point is on }
side = P_DivlineSide (::g->strace.x, ::g->strace.y, (divline_t *)bsp);
if (side == 2)
side = 0; // an "on" should cross both ::g->sides
// cross the starting side bsp = &::g->nodes[bspnum];
if (!P_CrossBSPNode (bsp->children[side]) )
return false; // decide which side the start point is on
side = P_DivlineSide( ::g->strace.x, ::g->strace.y, ( divline_t* )bsp );
// the partition plane is crossed here if( side == 2 )
if (side == P_DivlineSide (::g->t2x, ::g->t2y,(divline_t *)bsp)) {
{ side = 0; // an "on" should cross both ::g->sides
// the line doesn't touch the other side }
return true;
} // cross the starting side
if( !P_CrossBSPNode( bsp->children[side] ) )
// cross the ending side {
return P_CrossBSPNode (bsp->children[side^1]); return false;
}
// the partition plane is crossed here
if( side == P_DivlineSide( ::g->t2x, ::g->t2y, ( divline_t* )bsp ) )
{
// the line doesn't touch the other side
return true;
}
// cross the ending side
return P_CrossBSPNode( bsp->children[side ^ 1] );
} }
@ -299,49 +347,49 @@ P_CheckSight
( mobj_t* t1, ( mobj_t* t1,
mobj_t* t2 ) mobj_t* t2 )
{ {
int s1; int s1;
int s2; int s2;
int pnum; int pnum;
int bytenum; int bytenum;
int bitnum; int bitnum;
// First check for trivial rejection.
// Determine subsector entries in REJECT table. // First check for trivial rejection.
s1 = (t1->subsector->sector - ::g->sectors);
s2 = (t2->subsector->sector - ::g->sectors);
pnum = s1*::g->numsectors + s2;
bytenum = pnum>>3;
bitnum = 1 << (pnum&7);
// Check in REJECT table. // Determine subsector entries in REJECT table.
if (::g->rejectmatrix[bytenum]&bitnum) s1 = ( t1->subsector->sector - ::g->sectors );
{ s2 = ( t2->subsector->sector - ::g->sectors );
::g->sightcounts[0]++; pnum = s1*::g->numsectors + s2;
bytenum = pnum >> 3;
bitnum = 1 << ( pnum & 7 );
// can't possibly be connected // Check in REJECT table.
return false; if( ::g->rejectmatrix[bytenum]&bitnum )
} {
::g->sightcounts[0]++;
// An unobstructed LOS is possible. // can't possibly be connected
// Now look from eyes of t1 to any part of t2. return false;
::g->sightcounts[1]++; }
::g->validcount++; // An unobstructed LOS is possible.
// Now look from eyes of t1 to any part of t2.
::g->sightzstart = t1->z + t1->height - (t1->height>>2); ::g->sightcounts[1]++;
::g->topslope = (t2->z+t2->height) - ::g->sightzstart;
::g->bottomslope = (t2->z) - ::g->sightzstart;
::g->strace.x = t1->x;
::g->strace.y = t1->y;
::g->t2x = t2->x;
::g->t2y = t2->y;
::g->strace.dx = t2->x - t1->x;
::g->strace.dy = t2->y - t1->y;
// the head node is the last node output ::g->validcount++;
return P_CrossBSPNode (::g->numnodes-1);
::g->sightzstart = t1->z + t1->height - ( t1->height >> 2 );
::g->topslope = ( t2->z + t2->height ) - ::g->sightzstart;
::g->bottomslope = ( t2->z ) - ::g->sightzstart;
::g->strace.x = t1->x;
::g->strace.y = t1->y;
::g->t2x = t2->x;
::g->t2y = t2->y;
::g->strace.dx = t2->x - t1->x;
::g->strace.dy = t2->y - t1->y;
// the head node is the last node output
return P_CrossBSPNode( ::g->numnodes - 1 );
} }

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -42,13 +42,13 @@ extern int levelTimeCount;
// at game start // at game start
void P_InitPicAnims (void); void P_InitPicAnims( void );
// at map load // at map load
void P_SpawnSpecials (void); void P_SpawnSpecials( void );
// every tic // every tic
void P_UpdateSpecials (void); void P_UpdateSpecials( void );
// when needed // when needed
qboolean qboolean
@ -68,7 +68,7 @@ P_CrossSpecialLine
int side, int side,
mobj_t* thing ); mobj_t* thing );
void P_PlayerInSpecialSector (player_t* player); void P_PlayerInSpecialSector( player_t* player );
int int
twoSided twoSided
@ -87,16 +87,16 @@ getSide
int line, int line,
int side ); int side );
fixed_t P_FindLowestFloorSurrounding(sector_t* sec); fixed_t P_FindLowestFloorSurrounding( sector_t* sec );
fixed_t P_FindHighestFloorSurrounding(sector_t* sec); fixed_t P_FindHighestFloorSurrounding( sector_t* sec );
fixed_t fixed_t
P_FindNextHighestFloor P_FindNextHighestFloor
( sector_t* sec, ( sector_t* sec,
int currentheight ); int currentheight );
fixed_t P_FindLowestCeilingSurrounding(sector_t* sec); fixed_t P_FindLowestCeilingSurrounding( sector_t* sec );
fixed_t P_FindHighestCeilingSurrounding(sector_t* sec); fixed_t P_FindHighestCeilingSurrounding( sector_t* sec );
int int
P_FindSectorFromLineTag P_FindSectorFromLineTag
@ -117,7 +117,7 @@ getNextSector
// //
// SPECIAL // SPECIAL
// //
int EV_DoDonut(line_t* line); int EV_DoDonut( line_t* line );
@ -126,40 +126,40 @@ int EV_DoDonut(line_t* line);
// //
typedef struct typedef struct
{ {
thinker_t thinker; thinker_t thinker;
sector_t* sector; sector_t* sector;
int count; int count;
int maxlight; int maxlight;
int minlight; int minlight;
} fireflicker_t; } fireflicker_t;
typedef struct typedef struct
{ {
thinker_t thinker; thinker_t thinker;
sector_t* sector; sector_t* sector;
int count; int count;
int maxlight; int maxlight;
int minlight; int minlight;
int maxtime; int maxtime;
int mintime; int mintime;
} lightflash_t; } lightflash_t;
typedef struct typedef struct
{ {
thinker_t thinker; thinker_t thinker;
sector_t* sector; sector_t* sector;
int count; int count;
int minlight; int minlight;
int maxlight; int maxlight;
int darktime; int darktime;
int brighttime; int brighttime;
} strobe_t; } strobe_t;
@ -167,11 +167,11 @@ typedef struct
typedef struct typedef struct
{ {
thinker_t thinker; thinker_t thinker;
sector_t* sector; sector_t* sector;
int minlight; int minlight;
int maxlight; int maxlight;
int direction; int direction;
} glow_t; } glow_t;
@ -181,11 +181,11 @@ typedef struct
#define FASTDARK 15 #define FASTDARK 15
#define SLOWDARK 35 #define SLOWDARK 35
void T_FireFlicker (fireflicker_t* flick); void T_FireFlicker( fireflicker_t* flick );
void P_SpawnFireFlicker (sector_t* sector); void P_SpawnFireFlicker( sector_t* sector );
void T_LightFlash (lightflash_t* flash); void T_LightFlash( lightflash_t* flash );
void P_SpawnLightFlash (sector_t* sector); void P_SpawnLightFlash( sector_t* sector );
void T_StrobeFlash (strobe_t* flash); void T_StrobeFlash( strobe_t* flash );
void void
P_SpawnStrobeFlash P_SpawnStrobeFlash
@ -193,16 +193,16 @@ P_SpawnStrobeFlash
int fastOrSlow, int fastOrSlow,
int inSync ); int inSync );
void EV_StartLightStrobing(line_t* line); void EV_StartLightStrobing( line_t* line );
void EV_TurnTagLightsOff(line_t* line); void EV_TurnTagLightsOff( line_t* line );
void void
EV_LightTurnOn EV_LightTurnOn
( line_t* line, ( line_t* line,
int bright ); int bright );
void T_Glow(glow_t* g); void T_Glow( glow_t* g );
void P_SpawnGlowingLight(sector_t* sector); void P_SpawnGlowingLight( sector_t* sector );
@ -212,54 +212,55 @@ void P_SpawnGlowingLight(sector_t* sector);
// //
typedef struct typedef struct
{ {
char name1[9]; char name1[9];
char name2[9]; char name2[9];
short episode; short episode;
} switchlist_t; } switchlist_t;
typedef enum typedef enum
{ {
top, top,
middle, middle,
bottom bottom
} bwhere_e; } bwhere_e;
typedef struct typedef struct
{ {
line_t* line; line_t* line;
bwhere_e where; bwhere_e where;
int btexture; int btexture;
int btimer; int btimer;
union { union
mobj_t * soundorg; {
degenmobj_t * degensoundorg; mobj_t* soundorg;
degenmobj_t* degensoundorg;
}; };
} button_t; } button_t;
// max # of wall switches in a level // max # of wall switches in a level
#define MAXSWITCHES 50 #define MAXSWITCHES 50
// 4 players, 4 buttons each at once, max. // 4 players, 4 buttons each at once, max.
#define MAXBUTTONS 16 #define MAXBUTTONS 16
// 1 second, in ticks. // 1 second, in ticks.
#define BUTTONTIME TICRATE #define BUTTONTIME TICRATE
extern button_t buttonlist[MAXBUTTONS]; extern button_t buttonlist[MAXBUTTONS];
void void
P_ChangeSwitchTexture P_ChangeSwitchTexture
( line_t* line, ( line_t* line,
int useAgain ); int useAgain );
void P_InitSwitchList(void); void P_InitSwitchList( void );
// //
@ -267,10 +268,10 @@ void P_InitSwitchList(void);
// //
typedef enum typedef enum
{ {
up, up,
down, down,
waiting, waiting,
in_stasis in_stasis
} plat_e; } plat_e;
@ -278,11 +279,11 @@ typedef enum
typedef enum typedef enum
{ {
perpetualRaise, perpetualRaise,
downWaitUpStay, downWaitUpStay,
raiseAndChange, raiseAndChange,
raiseToNearestAndChange, raiseToNearestAndChange,
blazeDWUS blazeDWUS
} plattype_e; } plattype_e;
@ -290,19 +291,19 @@ typedef enum
typedef struct typedef struct
{ {
thinker_t thinker; thinker_t thinker;
sector_t* sector; sector_t* sector;
fixed_t speed; fixed_t speed;
fixed_t low; fixed_t low;
fixed_t high; fixed_t high;
int wait; int wait;
int count; int count;
plat_e status; plat_e status;
plat_e oldstatus; plat_e oldstatus;
qboolean crush; qboolean crush;
int tag; int tag;
plattype_e type; plattype_e type;
} plat_t; } plat_t;
@ -314,7 +315,7 @@ typedef struct
extern plat_t* activeplats[MAXPLATS]; extern plat_t* activeplats[MAXPLATS];
void T_PlatRaise(plat_t* plat); void T_PlatRaise( plat_t* plat );
int int
EV_DoPlat EV_DoPlat
@ -322,10 +323,10 @@ EV_DoPlat
plattype_e type, plattype_e type,
int amount ); int amount );
void P_AddActivePlat(plat_t* plat); void P_AddActivePlat( plat_t* plat );
void P_RemoveActivePlat(plat_t* plat); void P_RemoveActivePlat( plat_t* plat );
void EV_StopPlat(line_t* line); void EV_StopPlat( line_t* line );
void P_ActivateInStasis(int tag); void P_ActivateInStasis( int tag );
// //
@ -333,14 +334,14 @@ void P_ActivateInStasis(int tag);
// //
typedef enum typedef enum
{ {
normal, normal,
close30ThenOpen, close30ThenOpen,
closed, closed,
opened, opened,
raiseIn5Mins, raiseIn5Mins,
blazeRaise, blazeRaise,
blazeOpen, blazeOpen,
blazeClose blazeClose
} vldoor_e; } vldoor_e;
@ -348,21 +349,21 @@ typedef enum
typedef struct typedef struct
{ {
thinker_t thinker; thinker_t thinker;
vldoor_e type; vldoor_e type;
sector_t* sector; sector_t* sector;
fixed_t topheight; fixed_t topheight;
fixed_t speed; fixed_t speed;
// 1 = up, 0 = waiting at top, -1 = down
int direction;
// tics to wait at the top
int topwait;
// (keep in case a door going down is reset)
// when it reaches 0, start going down
int topcountdown;
// 1 = up, 0 = waiting at top, -1 = down
int direction;
// tics to wait at the top
int topwait;
// (keep in case a door going down is reset)
// when it reaches 0, start going down
int topcountdown;
} vldoor_t; } vldoor_t;
@ -386,8 +387,8 @@ EV_DoLockedDoor
vldoor_e type, vldoor_e type,
mobj_t* thing ); mobj_t* thing );
void T_VerticalDoor (vldoor_t* door); void T_VerticalDoor( vldoor_t* door );
void P_SpawnDoorCloseIn30 (sector_t* sec); void P_SpawnDoorCloseIn30( sector_t* sec );
void void
P_SpawnDoorRaiseIn5Mins P_SpawnDoorRaiseIn5Mins
@ -402,9 +403,9 @@ P_SpawnDoorRaiseIn5Mins
// //
typedef enum typedef enum
{ {
sd_opening, sd_opening,
sd_waiting, sd_waiting,
sd_closing sd_closing
} sd_e; } sd_e;
@ -412,9 +413,9 @@ typedef enum
typedef enum typedef enum
{ {
sdt_openOnly, sdt_openOnly,
sdt_closeOnly, sdt_closeOnly,
sdt_openAndClose sdt_openAndClose
} sdt_e; } sdt_e;
@ -423,15 +424,15 @@ typedef enum
typedef struct typedef struct
{ {
thinker_t thinker; thinker_t thinker;
sdt_e type; sdt_e type;
line_t* line; line_t* line;
int frame; int frame;
int whichDoorIndex; int whichDoorIndex;
int timer; int timer;
sector_t* frontsector; sector_t* frontsector;
sector_t* backsector; sector_t* backsector;
sd_e status; sd_e status;
} slidedoor_t; } slidedoor_t;
@ -439,23 +440,23 @@ typedef struct
typedef struct typedef struct
{ {
char frontFrame1[9]; char frontFrame1[9];
char frontFrame2[9]; char frontFrame2[9];
char frontFrame3[9]; char frontFrame3[9];
char frontFrame4[9]; char frontFrame4[9];
char backFrame1[9]; char backFrame1[9];
char backFrame2[9]; char backFrame2[9];
char backFrame3[9]; char backFrame3[9];
char backFrame4[9]; char backFrame4[9];
} slidename_t; } slidename_t;
typedef struct typedef struct
{ {
int frontFrames[4]; int frontFrames[4];
int backFrames[4]; int backFrames[4];
} slideframe_t; } slideframe_t;
@ -468,9 +469,9 @@ typedef struct
#define SWAITTICS 4 #define SWAITTICS 4
// how many diff. types of anims // how many diff. types of anims
#define MAXSLIDEDOORS 5 #define MAXSLIDEDOORS 5
void P_InitSlidingDoorFrames(void); void P_InitSlidingDoorFrames( void );
void void
EV_SlidingDoor EV_SlidingDoor
@ -485,12 +486,12 @@ EV_SlidingDoor
// //
typedef enum typedef enum
{ {
lowerToFloor, lowerToFloor,
raiseToHighest, raiseToHighest,
lowerAndCrush, lowerAndCrush,
crushAndRaise, crushAndRaise,
fastCrushAndRaise, fastCrushAndRaise,
silentCrushAndRaise silentCrushAndRaise
} ceiling_e; } ceiling_e;
@ -498,21 +499,21 @@ typedef enum
typedef struct typedef struct
{ {
thinker_t thinker; thinker_t thinker;
ceiling_e type; ceiling_e type;
sector_t* sector; sector_t* sector;
fixed_t bottomheight; fixed_t bottomheight;
fixed_t topheight; fixed_t topheight;
fixed_t speed; fixed_t speed;
qboolean crush; qboolean crush;
// 1 = up, 0 = waiting, -1 = down // 1 = up, 0 = waiting, -1 = down
int direction; int direction;
// ID
int tag;
int olddirection;
// ID
int tag;
int olddirection;
} ceiling_t; } ceiling_t;
@ -530,11 +531,11 @@ EV_DoCeiling
( line_t* line, ( line_t* line,
ceiling_e type ); ceiling_e type );
void T_MoveCeiling (ceiling_t* ceiling); void T_MoveCeiling( ceiling_t* ceiling );
void P_AddActiveCeiling(ceiling_t* c); void P_AddActiveCeiling( ceiling_t* c );
void P_RemoveActiveCeiling(ceiling_t* c); void P_RemoveActiveCeiling( ceiling_t* c );
int EV_CeilingCrushStop(line_t* line); int EV_CeilingCrushStop( line_t* line );
void P_ActivateInStasisCeiling(line_t* line); void P_ActivateInStasisCeiling( line_t* line );
// //
@ -542,37 +543,37 @@ void P_ActivateInStasisCeiling(line_t* line);
// //
typedef enum typedef enum
{ {
// lower floor to highest surrounding floor // lower floor to highest surrounding floor
lowerFloor, lowerFloor,
// lower floor to lowest surrounding floor
lowerFloorToLowest,
// lower floor to highest surrounding floor VERY FAST
turboLower,
// raise floor to lowest surrounding CEILING
raiseFloor,
// raise floor to next highest surrounding floor
raiseFloorToNearest,
// raise floor to shortest height texture around it // lower floor to lowest surrounding floor
raiseToTexture, lowerFloorToLowest,
// lower floor to lowest surrounding floor // lower floor to highest surrounding floor VERY FAST
// and change floorpic turboLower,
lowerAndChange,
// raise floor to lowest surrounding CEILING
raiseFloor24, raiseFloor,
raiseFloor24AndChange,
raiseFloorCrush, // raise floor to next highest surrounding floor
raiseFloorToNearest,
// raise floor to shortest height texture around it
raiseToTexture,
// lower floor to lowest surrounding floor
// and change floorpic
lowerAndChange,
raiseFloor24,
raiseFloor24AndChange,
raiseFloorCrush,
// raise to next highest floor, turbo-speed
raiseFloorTurbo,
donutRaise,
raiseFloor512
// raise to next highest floor, turbo-speed
raiseFloorTurbo,
donutRaise,
raiseFloor512
} floor_e; } floor_e;
@ -580,24 +581,24 @@ typedef enum
typedef enum typedef enum
{ {
build8, // slowly build by 8 build8, // slowly build by 8
turbo16 // quickly build by 16 turbo16 // quickly build by 16
} stair_e; } stair_e;
typedef struct typedef struct
{ {
thinker_t thinker; thinker_t thinker;
floor_e type; floor_e type;
qboolean crush; qboolean crush;
sector_t* sector; sector_t* sector;
int direction; int direction;
int newspecial; int newspecial;
short texture; short texture;
fixed_t floordestheight; fixed_t floordestheight;
fixed_t speed; fixed_t speed;
} floormove_t; } floormove_t;
@ -607,10 +608,10 @@ typedef struct
typedef enum typedef enum
{ {
ok, ok,
crushed, crushed,
pastdest pastdest
} result_e; } result_e;
result_e result_e
@ -632,7 +633,7 @@ EV_DoFloor
( line_t* line, ( line_t* line,
floor_e floortype ); floor_e floortype );
void T_MoveFloor( floormove_t* floor); void T_MoveFloor( floormove_t* floor );
// //
// P_TELEPT // P_TELEPT

File diff suppressed because it is too large Load diff

View file

@ -2,9 +2,9 @@
=========================================================================== ===========================================================================
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -55,84 +55,100 @@ EV_Teleport
int side, int side,
mobj_t* thing ) mobj_t* thing )
{ {
int i; int i;
int tag; int tag;
mobj_t* m; mobj_t* m;
mobj_t* fog; mobj_t* fog;
unsigned an; unsigned an;
thinker_t* thinker; thinker_t* thinker;
sector_t* sector; sector_t* sector;
fixed_t oldx; fixed_t oldx;
fixed_t oldy; fixed_t oldy;
fixed_t oldz; fixed_t oldz;
// don't teleport missiles // don't teleport missiles
if (thing->flags & MF_MISSILE) if( thing->flags & MF_MISSILE )
return 0;
// Don't teleport if hit back of line,
// so you can get out of teleporter.
if (side == 1)
return 0;
tag = line->tag;
for (i = 0; i < ::g->numsectors; i++)
{
if (::g->sectors[ i ].tag == tag )
{ {
thinker = ::g->thinkercap.next; return 0;
for (thinker = ::g->thinkercap.next;
thinker != &::g->thinkercap;
thinker = thinker->next)
{
// not a mobj
if (thinker->function.acp1 != (actionf_p1)P_MobjThinker)
continue;
m = (mobj_t *)thinker;
// not a teleportman
if (m->type != MT_TELEPORTMAN )
continue;
sector = m->subsector->sector;
// wrong sector
if (sector-::g->sectors != i )
continue;
oldx = thing->x;
oldy = thing->y;
oldz = thing->z;
if (!P_TeleportMove (thing, m->x, m->y))
return 0;
thing->z = thing->floorz; //fixme: not needed?
if (thing->player)
thing->player->viewz = thing->z+thing->player->viewheight;
// spawn teleport fog at source and destination
fog = P_SpawnMobj (oldx, oldy, oldz, MT_TFOG);
S_StartSound (fog, sfx_telept);
an = m->angle >> ANGLETOFINESHIFT;
fog = P_SpawnMobj (m->x+20*finecosine[an], m->y+20*finesine[an]
, thing->z, MT_TFOG);
// emit sound, where?
S_StartSound (fog, sfx_telept);
// don't move for a bit
if (thing->player)
thing->reactiontime = 18;
thing->angle = m->angle;
thing->momx = thing->momy = thing->momz = 0;
return 1;
}
} }
}
return 0; // Don't teleport if hit back of line,
// so you can get out of teleporter.
if( side == 1 )
{
return 0;
}
tag = line->tag;
for( i = 0; i < ::g->numsectors; i++ )
{
if( ::g->sectors[ i ].tag == tag )
{
thinker = ::g->thinkercap.next;
for( thinker = ::g->thinkercap.next;
thinker != &::g->thinkercap;
thinker = thinker->next )
{
// not a mobj
if( thinker->function.acp1 != ( actionf_p1 )P_MobjThinker )
{
continue;
}
m = ( mobj_t* )thinker;
// not a teleportman
if( m->type != MT_TELEPORTMAN )
{
continue;
}
sector = m->subsector->sector;
// wrong sector
if( sector -::g->sectors != i )
{
continue;
}
oldx = thing->x;
oldy = thing->y;
oldz = thing->z;
if( !P_TeleportMove( thing, m->x, m->y ) )
{
return 0;
}
thing->z = thing->floorz; //fixme: not needed?
if( thing->player )
{
thing->player->viewz = thing->z + thing->player->viewheight;
}
// spawn teleport fog at source and destination
fog = P_SpawnMobj( oldx, oldy, oldz, MT_TFOG );
S_StartSound( fog, sfx_telept );
an = m->angle >> ANGLETOFINESHIFT;
fog = P_SpawnMobj( m->x + 20 * finecosine[an], m->y + 20 * finesine[an]
, thing->z, MT_TFOG );
// emit sound, where?
S_StartSound( fog, sfx_telept );
// don't move for a bit
if( thing->player )
{
thing->reactiontime = 18;
}
thing->angle = m->angle;
thing->momx = thing->momy = thing->momz = 0;
return 1;
}
}
}
return 0;
} }

Some files were not shown because too many files have changed in this diff Show more