Initial commit

This commit is contained in:
Brian Harris
2012-11-26 12:58:24 -06:00
parent a5214f79ef
commit 5016f605b8
1115 changed files with 587266 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir>$(SolutionDir)..\build\$(PlatformName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)..\build\$(PlatformName)\$(Configuration)\intermediate\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)Main;$(SolutionDir);$(DXSDK_DIR)\Include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild>
<PreprocessorDefinitions>_D3XP;CTF;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@@ -0,0 +1,147 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "DoomLeaderboards.h"
#include "tech5/engine/framework/precompiled.h"
#include "tech5\engine\sys\sys_stats.h"
#include "../doomengine/source/doomdef.h"
#include <map>
static columnDef_t columnDefTime[] = {
{ "Time", 64, AGGREGATE_MIN, STATS_COLUMN_DISPLAY_TIME_MILLISECONDS }
};
const static int NUMLEVELS_ULTIMATE_DOOM = 36;
const static int NUMLEVELS_DOOM2_HELL_ON_EARTH = 32;
const static int NUMLEVELS_FINALDOOM_TNT = 32;
const static int NUMLEVELS_FINALDOOM_PLUTONIA = 32;
const static int NUMLEVELS_DOOM2_MASTER_LEVELS = 21;
const static int NUMLEVELS_DOOM2_NERVE = 9;
const static int NUM_LEVEL_LIST[] = {
NUMLEVELS_ULTIMATE_DOOM,
NUMLEVELS_DOOM2_HELL_ON_EARTH,
NUMLEVELS_FINALDOOM_TNT,
NUMLEVELS_FINALDOOM_PLUTONIA,
NUMLEVELS_DOOM2_MASTER_LEVELS,
NUMLEVELS_DOOM2_NERVE
};
/*
========================
GenerateLeaderboard ID
Generates a Leaderboard ID based on current Expansion + episode + map + skill + Type
Expansion is the base value that the leaderboard ID comes from
========================
*/
const int GenerateLeaderboardID( int expansion, int episode, int map, int skill ) {
int realMapNumber = ( episode * map - 1 );
if( common->GetGameSKU() == GAME_SKU_DOOM1_BFG ) {
// Doom levels start at 620 .. yeah.. hack.
int block = 615;
int mapAndSkill = ( realMapNumber * ( (int)sk_nightmare + 1 ) ) + skill ;
return block + mapAndSkill;
} else if( common->GetGameSKU() == GAME_SKU_DOOM2_BFG ) {
if( expansion == 1 ) {
// Doom 2 Levels start at 800.. Yep.. another hack.
int block = 795;
int mapAndSkill = ( realMapNumber * ( (int)sk_nightmare + 1 ) ) + skill ;
return block + mapAndSkill;
} else {
// Nerve Levels start at 960... another hack!
int block = 955;
int mapAndSkill = ( realMapNumber * ( (int)sk_nightmare + 1 ) ) + skill ;
return block + mapAndSkill;
}
} else {
// DCC Content
int block = 0;
if( expansion > 0 ){
for( int expi = 0; expi < expansion; expi++ ) {
block += NUM_LEVEL_LIST[ expi ] * ( (int)sk_nightmare + 1);
}
}
int mapAndSkill = ( realMapNumber * ( (int)sk_nightmare + 1 ) ) + skill ;
return block + mapAndSkill;
}
}
/*
========================
InitLeaderboards
Generates all the possible leaderboard definitions
and stores into an STL Map, with leaderboard ID as the Hash/key value.
========================
*/
void InitLeaderboards() {
for( int expi = 0; expi < ARRAY_COUNT( NUM_LEVEL_LIST ); expi++ ) {
for( int udi = 1; udi <= NUM_LEVEL_LIST[expi] ; udi++ ) {
for( int skilli = 0; skilli <= sk_nightmare; skilli++ ) {
// Create the Time Trial leaderboard for each level.
int timeTrial_leaderboardID = GenerateLeaderboardID( expi, 1, udi, skilli );
leaderboardDefinition_t * timeTrial_Leaderboard = new leaderboardDefinition_t( timeTrial_leaderboardID, ARRAY_COUNT( columnDefTime ), columnDefTime, RANK_LEAST_FIRST, false, true );
}
}
}
}
/*
========================
GenerateLeaderboard
Generates a Leaderboard based on current Expansion + episode + map + skill + Type
Expansion is the base value that the leaderboard ID comes from
========================
*/
const leaderboardDefinition_t * GetLeaderboard( int expansion, int episode, int map, int skill ) {
int leaderboardID = GenerateLeaderboardID( expansion, episode, map, skill );
return Sys_FindLeaderboardDef( leaderboardID );;
}

View File

@@ -0,0 +1,45 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __DOOM_LEADERBOARDS_H__
#define __DOOM_LEADERBOARDS_H__
#include "sys\sys_stats_misc.h"
enum Leaderboard_type_t {
LEADERBOARD_TYPE_TIME_TRIAL,
LEADERBOARD_TYPE_FRAGS,
LEADERBOARD_MAX_TYPES
};
void InitLeaderboards();
const leaderboardDefinition_t * GetLeaderboard( int expansion, int episode, int map, int skill );
#endif // __DOOM_LEADERBOARDS_H__

102
doomclassic/doom/Main.h Normal file
View File

@@ -0,0 +1,102 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef _MAIN_H_
#define _MAIN_H_
#include "idlib/precompiled.h"
#include "../doom/doomlib.h"
#include "../doom/doominterface.h"
#include "../doom/globaldata.h"
// DHM - Nerve :: Enable demo recording for game clips
#define _DEMO_RECORDING
#ifdef _DEBUG
#define safeOutputDebug(x) printf( "%s", x );
#else
#define safeOutputDebug(x)
#endif
struct SplitscreenData {
int PLAYERCOUNT;
int globalSkill;
int globalEpisode;
int globalLevel;
int globalTimeLimit;
int globalFragLimit;
};
void DL_InitNetworking( DoomInterface *pdi );
extern int PLAYERCOUNT;
extern bool globalNetworking;
extern bool debugOutput;
extern BOOL globalLicenseFullGame;
extern int globalRichPresenceState; // values from spa.h X_CONTEXT_PRESENCE
extern int globalNeedUpsell;
// PS3
//extern HXUISTRINGTABLE globalStrings; // gStrings for short
extern bool globalPauseTime;
enum MenuStates{
MENU_NONE,
MENU_XBOX_SYSTEM,
MENU_PAUSE,
MENU_UPSELL,
MENU_UPSELL_INVITE,
MENU_ENDLEVEL_UPSELL,
MENU_ERROR_MESSAGE,
MENU_ERROR_MESSAGE_FATAL,
MENU_END_LEVEL,
MENU_END_EPISODE,
MENU_END_CAST,
MENU_END_LEVEL_COOP,
MENU_END_LEVEL_DM,
MENU_END_GAME_LOBBY,
MENU_END_GAME_LOBBY_PLAYER,
MENU_LOBBY,
MENU_LOBBY_PLAYER,
MENU_INVITE,
MENU_COUNT
};
typedef struct {
int maxPing;
const wchar_t * image;
} PingImage_t;
extern PingImage_t pingsImages[];
#endif

View File

@@ -0,0 +1,166 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "../Main/Main.h"
#include <sys/types.h>
#include <sys/socket.h>
#include "tech5/engine/sys/sys_lobby.h"
bool useTech5Packets = true;
#if 1
struct networkitem
{
int source;
int size;
char buffer[256*64];
};
std::queue< networkitem > networkstacks[4];
//sockaddr_in sockaddrs[4];
int DoomLibRecv( char* buff, DWORD *numRecv )
{
//int player = DoomInterface::CurrentPlayer();
int player = ::g->consoleplayer;
if (networkstacks[player].empty())
return -1;
networkitem item = networkstacks[player].front();
memcpy( buff, item.buffer, item.size );
*numRecv = item.size;
//*source = sockaddrs[item.source];
networkstacks[player].pop();
return 1;
}
void I_Printf(char *error, ...);
int DoomLibSend( const char* buff, DWORD size, sockaddr_in *target, int toNode )
{
int i;
i = DoomLib::RemoteNodeToPlayerIndex( toNode );
//I_Printf( "DoomLibSend %d --> %d: %d\n", ::g->consoleplayer, i, size );
networkitem item;
item.source = DoomInterface::CurrentPlayer();
item.size = size;
memcpy( item.buffer, buff, size );
networkstacks[i].push( item );
return 1;
}
int DoomLibSendRemote()
{
if ( gameLocal == NULL ) {
return 0;
}
int curPlayer = DoomLib::GetPlayer();
for (int player = 0; player < gameLocal->Interface.GetNumPlayers(); ++player)
{
DoomLib::SetPlayer( player );
for( int i = 0; i < 4; i++ ) {
//Check if it is remote
int node = DoomLib::PlayerIndexToRemoteNode( i );
if ( ::g->sendaddress[node].sin_addr.s_addr == ::g->sendaddress[0].sin_addr.s_addr ) {
continue;
}
while(!networkstacks[i].empty()) {
networkitem item = networkstacks[i].front();
int c;
//WSABUF buffer;
//DWORD num_sent;
//buffer.buf = (char*)&item.buffer;
//buffer.len = item.size;
if ( useTech5Packets ) {
idLobby & lobby = static_cast< idLobby & >( session->GetGameLobbyBase() );
lobbyUser_t * user = lobby.GetLobbyUser( i );
if ( user != NULL ) {
lobby.SendConnectionLess( user->address, idLobby::OOB_GENERIC_GAME_DATA, (const byte *)(&item.buffer[0] ), item.size );
}
} else {
c = sendto( ::g->sendsocket, &item.buffer, item.size, MSG_DONTWAIT, (sockaddr*)&::g->sendaddress[node], sizeof(::g->sendaddress[node]) );
//c = WSASendTo(::g->sendsocket, &buffer, 1, &num_sent, 0, (sockaddr*)&::g->sendaddress[node], sizeof(::g->sendaddress[node]), 0, 0);
}
networkstacks[i].pop();
}
}
}
DoomLib::SetPlayer(curPlayer);
return 1;
}
void DL_InitNetworking( DoomInterface *pdi )
{
// DHM - Nerve :: Clear out any old splitscreen packets that may be lingering.
for ( int i = 0; i<4; i++ ) {
while ( !networkstacks[i].empty() ) {
networkstacks[i].pop();
}
}
/*sockaddrs[0].sin_addr.s_addr = inet_addr("0.0.0.1" );
sockaddrs[1].sin_addr.s_addr = inet_addr("0.0.0.2" );
sockaddrs[2].sin_addr.s_addr = inet_addr("0.0.0.3" );
sockaddrs[3].sin_addr.s_addr = inet_addr("0.0.0.4" );*/
pdi->SetNetworking( DoomLibRecv, DoomLibSend, DoomLibSendRemote );
}
#else
void DL_InitNetworking( DoomInterface *pdi ) {
}
#endif

View File

@@ -0,0 +1,649 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "PlayerProfile.h"
#include "PS3_Includes.h"
#include "PSN/PS3_Session.h"
const int32 FRAMEWORK_PROFILE_VER = 1;
// Store master volume settings in archived cvars, becausue we want them to apply
// even if a user isn't signed in.
// The range is from 0 to 15, which matches the setting in vanilla DOOM.
idCVar s_volume_sound( "s_volume_sound", "8", CVAR_ARCHIVE | CVAR_INTEGER, "sound volume", 0, 15 );
idCVar s_volume_midi( "s_volume_midi", "8", CVAR_ARCHIVE | CVAR_INTEGER, "music volume", 0, 15 );
/*
================================================
idProfileMgr
================================================
*/
/*
========================
idProfileMgr
========================
*/
idProfileMgr::idProfileMgr() :
profileSaveProcessor( new (TAG_SAVEGAMES) idSaveGameProcessorSaveProfile ),
profileLoadProcessor( new (TAG_SAVEGAMES) idSaveGameProcessorLoadProfile ),
profile( NULL ),
handle( 0 ) {
}
/*
================================================
~idProfileMgr
================================================
*/
idProfileMgr::~idProfileMgr() {
delete profileSaveProcessor;
profileSaveProcessor = NULL;
delete profileLoadProcessor;
profileLoadProcessor = NULL;
}
/*
========================
idProfileMgr::Init
========================
*/
void idProfileMgr::Init( idPlayerProfile * profile_ ) {
profile = profile_;
handle = 0;
}
/*
========================
idProfileMgr::Pump
========================
*/
void idProfileMgr::Pump() {
// profile can be NULL if we forced the user to register as in the case of map-ing into a level from the press start screen
if ( profile == NULL ) {
return;
}
// See if we are done with saving/loading the profile
bool saving = profile->GetState() == idPlayerProfile::SAVING;
bool loading = profile->GetState() == idPlayerProfile::LOADING;
if ( ( saving || loading ) && psn_session->GetSaveGameManager()->IsSaveGameCompletedFromHandle( handle ) ) {
profile->SetState( idPlayerProfile::IDLE );
if ( saving ) {
// Done saving
} else if ( loading ) {
// Done loading
const idSaveLoadParms & parms = profileLoadProcessor->GetParms();
if ( parms.GetError() == SAVEGAME_E_FOLDER_NOT_FOUND || parms.GetError() == SAVEGAME_E_FILE_NOT_FOUND ) {
profile->SaveSettings();
} else if ( parms.GetError() != SAVEGAME_E_NONE ) {
profile->SetState( idPlayerProfile::ERR );
}
}
}
// See if we need to save/load the profile
if ( profile->GetRequestedState() == idPlayerProfile::SAVE_REQUESTED ) {
SaveSettings();
profile->SetRequestedState( idPlayerProfile::IDLE );
} else if ( profile->GetRequestedState() == idPlayerProfile::LOAD_REQUESTED ) {
LoadSettings();
profile->SetRequestedState( idPlayerProfile::IDLE );
}
}
/*
========================
idProfileMgr::GetProfile
========================
*/
idPlayerProfile * idProfileMgr::GetProfile() {
if ( profile == NULL ) {
return NULL;
}
bool loading = ( profile->GetState() == idPlayerProfile::LOADING ) || ( profile->GetRequestedState() == idPlayerProfile::LOAD_REQUESTED );
if ( loading ) {
return NULL;
}
return profile;
}
/*
========================
idProfileMgr::SaveSettings
========================
*/
void idProfileMgr::SaveSettings() {
if ( profile != NULL && saveGame_enable.GetBool() ) {
// Issue the async save...
if ( profileSaveProcessor->InitSaveProfile( profile, "" ) ) {
handle = psn_session->GetSaveGameManager()->ExecuteProcessor( profileSaveProcessor );
profile->SetState( idPlayerProfile::SAVING );
}
} else {
// If not able to save the profile, just change the state and leave
if ( profile == NULL ) {
idLib::Warning( "Not saving profile, profile is NULL." );
}
if ( !saveGame_enable.GetBool() ) {
idLib::Warning( "Skipping profile save because saveGame_enable = 0" );
}
}
}
/*
========================
idProfileMgr::LoadSettings
========================
*/
void idProfileMgr::LoadSettings() {
if ( profile != NULL && saveGame_enable.GetBool() ) {
if ( profileLoadProcessor->InitLoadProfile( profile, "" ) ) {
// Skip the not found error because this might be the first time to play the game!
profileLoadProcessor->SetSkipSystemErrorDialogMask( SAVEGAME_E_FOLDER_NOT_FOUND | SAVEGAME_E_FILE_NOT_FOUND );
handle = psn_session->GetSaveGameManager()->ExecuteProcessor( profileLoadProcessor );
profile->SetState( idPlayerProfile::LOADING );
}
} else {
// If not able to save the profile, just change the state and leave
if ( profile == NULL ) {
idLib::Warning( "Not loading profile, profile is NULL." );
}
if ( !saveGame_enable.GetBool() ) {
idLib::Warning( "Skipping profile load because saveGame_enable = 0" );
}
}
}
/*
================================================
idSaveGameProcessorSaveProfile
================================================
*/
/*
========================
idSaveGameProcessorSaveProfile::idSaveGameProcessorSaveProfile
========================
*/
idSaveGameProcessorSaveProfile::idSaveGameProcessorSaveProfile() {
profileFile = NULL;
profile = NULL;
}
/*
========================
idSaveGameProcessorSaveProfile::InitSaveProfile
========================
*/
bool idSaveGameProcessorSaveProfile::InitSaveProfile( idPlayerProfile * profile_, const char * folder ) {
// Serialize the profile and pass a file to the processor
profileFile = new (TAG_SAVEGAMES) idFile_Memory( SAVEGAME_PROFILE_FILENAME );
profileFile->MakeWritable();
profileFile->SetMaxLength( MAX_PROFILE_SIZE );
idTempArray< byte > buffer( MAX_PROFILE_SIZE );
idBitMsg msg;
msg.InitWrite( buffer.Ptr(), MAX_PROFILE_SIZE );
idSerializer ser( msg, true );
profile_->SerializeSettings( ser );
profileFile->Write( msg.GetReadData(), msg.GetSize() );
profileFile->MakeReadOnly();
idList< idSaveFileEntry > files;
files.Append( idSaveFileEntry( profileFile, SAVEGAMEFILE_BINARY | SAVEGAMEFILE_AUTO_DELETE, SAVEGAME_PROFILE_FILENAME ) );
idSaveGameDetails description;
if ( !idSaveGameProcessor::Init() ) {
return false;
}
if ( files.Num() == 0 ) {
idLib::Warning( "No files to save." );
return false;
}
// Setup save system
parms.directory = AddSaveFolderPrefix( folder, idSaveGameManager::PACKAGE_PROFILE );
parms.mode = SAVEGAME_MBF_SAVE | SAVEGAME_MBF_HIDDEN; // do NOT delete the existing files
parms.saveFileType = SAVEFILE_TYPE_AUTO;
for ( int i = 0; i < files.Num(); ++i ) {
parms.files.Append( files[i] );
}
description.title = idLocalization::GetString( "#str_savegame_title" );
description.subTitle = idLocalization::GetString( "#str_savegame_profile_heading" );
description.summary = idLocalization::GetString( "#str_savegame_profile_desc" );
// Add static image as the thumbnail
staticScreenshotFile = new (TAG_SAVEGAMES) idFile_Memory( "image" );
// Open up the Image file and Make it a memory file.
void* thumbImage = NULL;
int imagesize = fileSystem->ReadFile( "base/textures/PROFILE.PNG", &thumbImage ); // This file lives at USRData.. i think.
staticScreenshotFile->MakeWritable();
staticScreenshotFile->Write( thumbImage, imagesize );
staticScreenshotFile->MakeReadOnly();
parms.files.Append( idSaveFileEntry( staticScreenshotFile, SAVEGAMEFILE_THUMB, "image" ) );
fileSystem->FreeFile( thumbImage );
this->parms.description = description;
parms.description.slotName = folder;
// TODO:KC - what was the purpose of this?
// JAF idKeyInput::SetUserDeviceNumForBind( profile_->GetDeviceNumForProfile() );
profile = profile_;
return true;
}
/*
========================
idSaveGameProcessorSaveProfile::Process
========================
*/
bool idSaveGameProcessorSaveProfile::Process() {
// Files already setup for save, just execute as normal files
// Platform-specific implementation
// This will start a worker thread for async operation.
// It will always signal when it's completed.
Sys_ExecuteSavegameCommandAsync( &parms );
return false;
}
/*
================================================
idSaveGameProcessorLoadProfile
================================================
*/
/*
========================
idSaveGameProcessorLoadProfile::idSaveGameProcessorLoadProfile
========================
*/
idSaveGameProcessorLoadProfile::idSaveGameProcessorLoadProfile() {
profileFile = NULL;
profile = NULL;
}
/*
========================
idSaveGameProcessorLoadProfile::~idSaveGameProcessorLoadProfile
========================
*/
idSaveGameProcessorLoadProfile::~idSaveGameProcessorLoadProfile() {
}
/*
========================
idSaveGameProcessorLoadProfile::InitLoadFiles
========================
*/
bool idSaveGameProcessorLoadProfile::InitLoadProfile( idPlayerProfile * profile_, const char * folder_ ) {
if ( !idSaveGameProcessor::Init() ) {
return false;
}
parms.directory = AddSaveFolderPrefix( folder_, idSaveGameManager::PACKAGE_PROFILE );
parms.description.slotName = folder_;
parms.mode = SAVEGAME_MBF_LOAD | SAVEGAME_MBF_HIDDEN;
parms.saveFileType = SAVEFILE_TYPE_AUTO;
profileFile = new (TAG_SAVEGAMES) idFile_Memory( SAVEGAME_PROFILE_FILENAME );
parms.files.Append( idSaveFileEntry( profileFile, SAVEGAMEFILE_BINARY, SAVEGAME_PROFILE_FILENAME ) );
profile = profile_;
return true;
}
/*
========================
idSaveGameProcessorLoadProfile::Process
========================
*/
bool idSaveGameProcessorLoadProfile::Process() {
Sys_ExecuteSavegameCommandAsync( &parms );
return false;
}
/*
========================
idSaveGameProcessorLoadProfile::PostProcess
========================
*/
void idSaveGameProcessorLoadProfile::PostProcess() {
// Serialize the loaded profile
bool foundProfile = profileFile->Length() > 0;
if ( foundProfile ) {
idTempArray< byte> buffer( MAX_PROFILE_SIZE );
// Serialize settings from this buffer
profileFile->MakeReadOnly();
profileFile->ReadBigArray( buffer.Ptr(), profileFile->Length() );
idBitMsg msg;
msg.InitRead( buffer.Ptr(), (int)buffer.Size() );
idSerializer ser( msg, false );
profile->SerializeSettings( ser );
// JAF idKeyInput::SetUserDeviceNumForBind( profile->GetDeviceNumForProfile() );
} else {
parms.errorCode = SAVEGAME_E_FILE_NOT_FOUND;
}
delete profileFile;
}
/*
========================
Contains data that needs to be saved out on a per player profile basis, global for the lifetime of the player so
the data can be shared across computers.
- HUD tint colors
- key bindings
- etc...
========================
*/
/*
========================
idPlayerProfile::idPlayerProfile
========================
*/
idPlayerProfile::idPlayerProfile() {
SetDefaults();
// Don't have these in SetDefaults because they're used for state management and SetDefaults is called when
// loading the profile
state = IDLE;
requestedState = IDLE;
}
/*
========================
idPlayerProfile::SetDefaults
========================
*/
void idPlayerProfile::SetDefaults() {
achievementBits = 0;
seenInstallMessage = false;
stats.SetNum( MAX_PLAYER_PROFILE_STATS );
for ( int i = 0; i < MAX_PLAYER_PROFILE_STATS; ++i ) {
stats[i].i = 0;
}
deviceNum = 0;
state = IDLE;
requestedState = IDLE;
frameScaleX = 0.85f;
frameScaleY = 0.85f;
}
/*
========================
idPlayerProfile::Init
========================
*/
void idPlayerProfile::Init() {
SetDefaults();
}
/*
========================
idPlayerProfile::~idPlayerProfile
========================
*/
idPlayerProfile::~idPlayerProfile() {
}
/*
========================
idPlayerProfile::SerializeSettings
========================
*/
bool idPlayerProfile::SerializeSettings( idSerializer & ser ) {
int flags = cvarSystem->GetModifiedFlags();
// Default to current tag/version
int32 tag = GetProfileTag();
int32 version = FRAMEWORK_PROFILE_VER;
// Serialize tag/version
ser.SerializePacked( tag );
if ( tag != GetProfileTag() ) {
idLib::Warning( "Profile tag did not match, profile will be re-initialized" );
SetDefaults();
SaveSettings(); // Flag the profile to save so we have the latest version stored
return false;
}
ser.SerializePacked( version );
if ( version != FRAMEWORK_PROFILE_VER ) {
// For now, don't allow profiles with invalid versions load
// We could easily support old version by doing a few version checks below to pick and choose what we load as well.
idLib::Warning( "Profile version did not match. Profile will be replaced" );
SetDefaults();
SaveSettings(); // Flag the profile to save so we have the latest version stored
return false;
}
// Serialize audio settings
SERIALIZE_BOOL( ser, seenInstallMessage );
// New setting to save to make sure that we have or haven't seen this achievement before used to pass TRC R149d
ser.Serialize( achievementBits );
ser.Serialize( frameScaleX );
ser.Serialize( frameScaleY );
SERIALIZE_BOOL( ser, alwaysRun );
// we save all the cvar-based settings in the profile even though some cvars are archived
// so that we are consistent and don't miss any or get affected when the archive flag is changed
SERIALIZE_CVAR_INT( ser, s_volume_sound );
SERIALIZE_CVAR_INT( ser, s_volume_midi );
// Don't trigger profile save due to modified archived cvars during profile load
cvarSystem->ClearModifiedFlags( CVAR_ARCHIVE ); // must clear because set() is an OR operation, not assignment...
cvarSystem->SetModifiedFlags( flags );
return true;
}
/*
========================
idPlayerProfile::GetLevel
========================
*/
int idPlayerProfile::GetLevel() const {
return 1;
}
/*
========================
idPlayerProfile::StatSetInt
========================
*/
void idPlayerProfile::StatSetInt( int s, int v ) {
stats[s].i = v;
}
/*
========================
idPlayerProfile::StatSetFloat
========================
*/
void idPlayerProfile::StatSetFloat( int s, float v ) {
stats[s].f = v;
}
/*
========================
idPlayerProfile::StatGetInt
========================
*/
int idPlayerProfile::StatGetInt( int s ) const {
return stats[s].i;
}
/*
========================
idPlayerProfile::StatGetFloat
========================
*/
float idPlayerProfile::StatGetFloat( int s ) const {
return stats[s].f;
}
/*
========================
idPlayerProfile::SaveSettings
========================
*/
void idPlayerProfile::SaveSettings() {
if ( state != SAVING ) {
if ( GetRequestedState() == IDLE ) {
SetRequestedState( SAVE_REQUESTED );
}
}
}
/*
========================
idPlayerProfile::SaveSettings
========================
*/
void idPlayerProfile::LoadSettings() {
if ( state != LOADING ) {
if ( verify( GetRequestedState() == IDLE ) ) {
SetRequestedState( LOAD_REQUESTED );
}
}
}
/*
========================
idPlayerProfile::SetAchievementBit
========================
*/
void idPlayerProfile::SetAchievementBit( const int id ) {
if ( id > 63 ) {
assert( false ); // FIXME: add another set of achievement bit flags
return;
}
achievementBits |= (int64)1 << id;
}
/*
========================
idPlayerProfile::ClearAchievementBit
========================
*/
void idPlayerProfile::ClearAchievementBit( const int id ) {
if ( id > 63 ) {
assert( false ); // FIXME: add another set of achievement bit flags
return;
}
achievementBits &= ~( (int64)1 << id );
}
/*
========================
idPlayerProfile::GetAchievementBit
========================
*/
bool idPlayerProfile::GetAchievementBit( const int id ) const {
if ( id > 63 ) {
assert( false ); // FIXME: add another set of achievement bit flags
return false;
}
return ( achievementBits & (int64)1 << id ) != 0;
}
/*
========================
Returns the value stored in the music volume cvar.
========================
*/
int idPlayerProfile::GetMusicVolume() const {
return s_volume_midi.GetInteger();
}
/*
========================
Returns the value stored in the sound volume cvar.
========================
*/
int idPlayerProfile::GetSoundVolume() const {
return s_volume_sound.GetInteger();
}
/*
========================
Sets the music volume cvar.
========================
*/
void idPlayerProfile::SetMusicVolume( int volume ) {
s_volume_midi.SetInteger( volume );
}
/*
========================
Sets the sound volume cvar.
========================
*/
void idPlayerProfile::SetSoundVolume( int volume ) {
s_volume_sound.SetInteger( volume );
}

View File

@@ -0,0 +1,267 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __PLAYERPROFILE_H__
#define __PLAYERPROFILE_H__
#include "Precompiled.h"
#include "Serializer.h"
//#include "SaveGameManager.h"
#define MAX_PROFILE_SIZE ( 1024 * 1000 ) // High number for the key bindings
#define SAVEGAME_PROFILE_FILENAME "_PROF"
extern idCVar s_volume_sound;
extern idCVar s_volume_midi;
class idSaveGameProcessorSaveProfile;
class idSaveGameProcessorLoadProfile;
class idPlayerProfile;
/*
================================================
idProfileMgr
================================================
*/
class idProfileMgr {
public:
idProfileMgr();
~idProfileMgr();
// Called the first time it's asked to load
void Init( idPlayerProfile * profile );
void Pump();
idPlayerProfile * GetProfile();
private:
void LoadSettings();
void SaveSettings();
private:
idSaveGameProcessorSaveProfile * profileSaveProcessor;
idSaveGameProcessorLoadProfile * profileLoadProcessor;
idPlayerProfile * profile;
saveGameHandle_t handle;
};
/*
================================================
idSaveGameProcessorSaveProfile
================================================
*/
class idSaveGameProcessorSaveProfile : public idSaveGameProcessor {
public:
DEFINE_CLASS( idSaveGameProcessorSaveProfile );
idSaveGameProcessorSaveProfile();
bool InitSaveProfile( idPlayerProfile * profile, const char * folder );
virtual bool Process();
private:
idFile_Memory * profileFile;
idFile_Memory * staticScreenshotFile;
idPlayerProfile * profile;
};
/*
================================================
idSaveGameProcessorLoadProfile
================================================
*/
class idSaveGameProcessorLoadProfile: public idSaveGameProcessor {
public:
DEFINE_CLASS( idSaveGameProcessorLoadProfile );
idSaveGameProcessorLoadProfile();
~idSaveGameProcessorLoadProfile();
bool InitLoadProfile( idPlayerProfile * profile, const char * folder );
virtual bool Process();
virtual void PostProcess();
private:
idFile_Memory * profileFile;
idPlayerProfile * profile;
};
/*
================================================
profileStatValue_t
================================================
*/
union profileStatValue_t {
int i;
float f;
};
/*
================================================
idPlayerProfile
The general rule for using cvars for settings is that if you want the player's profile settings to affect the startup
of the game before there is a player associated with the game, use cvars. Example: video & volume settings.
================================================
*/
class idPlayerProfile {
public:
static const int MAX_PLAYER_PROFILE_STATS = 500;
enum state_t {
IDLE = 0,
SAVING,
LOADING,
SAVE_REQUESTED,
LOAD_REQUESTED,
ERR
};
enum displayMode_t {
DISPLAY_INVALID = -1,
DISPLAY_WINDOWED,
DISPLAY_FULLSCREEN,
MAX_DISPLAY_MODES
};
enum syncTypes_t {
SYNC_INVALID = -1,
SYNC_TEAR,
SYNC_ON,
SYNC_SMART,
MAX_SYNC_COUNT,
};
public:
idPlayerProfile(); // don't instantiate. we static_cast the child all over the place
virtual ~idPlayerProfile();
//------------------------
// each game can override but call the parent serialize first
//------------------------
virtual void SetDefaults();
virtual void Init();
virtual bool SerializeSettings( idSerializer & ser );
//------------------------
// each game must override, not an abstract method because we have a static object as a hack... ugh.
//------------------------
virtual int32 GetProfileTag() { return -1; }
int GetDeviceNumForProfile() { return deviceNum; }
void SetDeviceNumForProfile( int num ) { deviceNum = num; }
//------------------------
void SaveSettings();
void LoadSettings();
state_t GetState() const { return state; }
state_t GetRequestedState() const { return requestedState; }
//------------------------
// settings
//------------------------
float GetFrameScaleX() const { return frameScaleX; }
float GetFrameScaleY() const { return frameScaleY; }
void SetFrameScaleX( float scale ) { frameScaleX = scale; }
void SetFrameScaleY( float scale ) { frameScaleY = scale; }
int GetMusicVolume() const;
int GetSoundVolume() const;
void SetMusicVolume( int volume );
void SetSoundVolume( int volume );
bool GetAlwaysRun() const { return alwaysRun; }
void SetAlwaysRun( bool set ) { alwaysRun = set; }
//------------------------
// misc
//------------------------
virtual int GetLevel() const;
void ClearAchievementBit( const int id ); // Should only be called by idLocalUser
bool GetAchievementBit( const int id ) const;
void SetAchievementBit( const int id ); // Should only be called by idLocalUser
bool GetSeenInstallMessage() const { return seenInstallMessage; }
void SetSeenInstallMessage( bool seen ) { seenInstallMessage = seen; }
bool HasSavedGame() const { return hasSavedGame; }
void SetHasSavedGame() { hasSavedGame = true; }
protected:
friend class idLocalUser;
friend class idProfileMgr;
// used by idLocalUser and internally
void StatSetInt( int s, int v );
void StatSetFloat( int s, float v );
int StatGetInt( int s ) const;
float StatGetFloat( int s ) const;
private:
void SetState( state_t value ) { state = value; }
void SetRequestedState( state_t value ) { requestedState = value; }
protected:
//------------------------
// settings
//------------------------
bool alwaysRun;
int musicVolume;
int soundVolume;
//------------------------
// video settings
//------------------------
float frameScaleX;
float frameScaleY;
//------------------------
// state management
//------------------------
state_t state;
state_t requestedState;
//------------------------
// stats are stored in the profile
//------------------------
idStaticList< profileStatValue_t, MAX_PLAYER_PROFILE_STATS > stats;
//------------------------
// misc
//------------------------
int deviceNum;
bool seenInstallMessage;
uint64 achievementBits;
bool hasSavedGame;
};
#endif

View File

@@ -0,0 +1,29 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"

View File

@@ -0,0 +1,69 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#pragma once
#include "idlib/precompiled.h"
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#define ID_INLINE inline
typedef unsigned char byte;
typedef unsigned int dword;
#include <Math.h>
#include <Assert.h>
#define ACTUALTEXTUREWIDTH 1024 // should always be equal to or larger
#define ACTUALTEXTUREHEIGHT 1024
#define GLOBAL_IMAGE_SCALER 3
#define ORIGINAL_WIDTH 320
#define ORIGINAL_HEIGHT 200
#define WIDTH ( ORIGINAL_WIDTH * GLOBAL_IMAGE_SCALER )
#define HEIGHT ( ORIGINAL_HEIGHT * GLOBAL_IMAGE_SCALER )
#define TEXTUREWIDTH WIDTH
#define TEXTUREHEIGHT HEIGHT
#define BASE_WIDTH WIDTH
#define SCREENWIDTH WIDTH
#define SCREENHEIGHT HEIGHT
#define MAXWIDTH 1120
#define MAXHEIGHT 832

1224
doomclassic/doom/am_map.cpp Normal file

File diff suppressed because it is too large Load Diff

55
doomclassic/doom/am_map.h Normal file
View File

@@ -0,0 +1,55 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __AMMAP_H__
#define __AMMAP_H__
// Used by ST StatusBar stuff.
#define AM_MSGHEADER (('a'<<24)+('m'<<16))
#define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8))
#define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8))
// Called by main loop.
qboolean AM_Responder (event_t* ev);
// Called by main loop.
void AM_Ticker (void);
// Called by main loop,
// called instead of view drawer if automap active.
void AM_Drawer (void);
// Called to force the automap to quit
// if the level is completed while it is up.
void AM_Stop (void);
#endif

View File

@@ -0,0 +1,540 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
memset(::g, 0, sizeof(*::g));
// am_map.constructs begin //
::g->cheating = 0;
::g->grid = 0;
::g->leveljuststarted = 1; // kluge until AM_LevelInit() is called
::g->automapactive = false;
::g->finit_width = SCREENWIDTH;
::g->finit_height = SCREENHEIGHT - (32 * GLOBAL_IMAGE_SCALER);
::g->scale_mtof = (fixed_t)INITSCALEMTOF;
::g->markpointnum = 0; // next point to be assigned
::g->followplayer = 1; // specifies whether to follow the player around
::g->stopped = true;
::g->lastlevel = -1;
::g->lastepisode = -1;
::g->cheatstate=0;
::g->bigstate=0;
::g->nexttic = 0;
::g->litelevelscnt = 0;
// am_map.constructs end //
// doomstat.constructs begin //
::g->gamemode = indetermined;
::g->gamemission = doom;
::g->language = english;
// doomstat.constructs end //
// d_main.constructs begin //
::g->singletics = false; // debug flag to cancel adaptiveness
::g->oldgamestate = (gamestate_t)-1;
::g->wipegamestate = GS_DEMOSCREEN;
::g->viewactivestate = false;
::g->menuactivestate = false;
::g->inhelpscreensstate = false;
::g->fullscreen = false;
::g->wipe = false;
::g->wipedone = true;
// d_main.constructs end //
// d_net.constructs begin //
doomcom_t temp_doomcom = {
0
};
memcpy( &::g->doomcom, &temp_doomcom, sizeof(temp_doomcom) );
// d_net.constructs end //
// f_wipe.constructs begin //
::g->go = 0;
// f_wipe.constructs end //
// g_game.constructs begin //
::g->precache = true; // if true, load all graphics at start
fixed_t temp_forwardmove[2] = {
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) );
menu_t temp_QuitDef = {
qut_end, // # of menu items
&::g->MainDef, // previous menu
::g->QuitMenu, // menuitem_t ->
M_DrawQuit, // drawing routine ->
48,63, // x,y
g_accept // lastOn
};
memcpy( &::g->QuitDef, &temp_QuitDef, sizeof(temp_QuitDef) );
menuitem_t temp_MainMenu[5]=
{
{1,"M_NGAME",M_NewGame,'n'},
{1,"M_OPTION",M_Options,'o'},
{1,"M_LOADG",M_LoadGame,'l'},
{1,"M_SAVEG",M_SaveGame,'m'},
// Another hickup with Special edition.
//{1,"M_RDTHIS",M_ReadThis,'r'},
{1,"M_QUITG",M_QuitDOOM,'q'}
};
memcpy( &::g->MainMenu, temp_MainMenu, sizeof(temp_MainMenu) );
menu_t temp_MainDef = {
main_end,
NULL,
::g->MainMenu,
M_DrawMainMenu,
97,64,
0
};
memcpy( &::g->MainDef, &temp_MainDef, sizeof(temp_MainDef) );
menuitem_t temp_EpisodeMenu[4] = {
{1,"M_EPI1", M_Episode,'k'},
{1,"M_EPI2", M_Episode,'t'},
{1,"M_EPI3", M_Episode,'i'},
{1,"M_EPI4", M_Episode,'t'}
};
memcpy( ::g->EpisodeMenu, temp_EpisodeMenu, sizeof(temp_EpisodeMenu) );
menu_t temp_EpiDef = {
ep_end, // # of menu items
&::g->MainDef, // previous menu
::g->EpisodeMenu, // menuitem_t ->
M_DrawEpisode, // drawing routine ->
48,63, // x,y
ep1 // lastOn
};
memcpy( &::g->EpiDef, &temp_EpiDef, sizeof(temp_EpiDef) );
menuitem_t temp_ExpansionMenu[2] = {
{1,"M_EPI1", M_Expansion,'h'},
{1,"M_EPI2", M_Expansion,'n'},
};
memcpy( ::g->ExpansionMenu, temp_ExpansionMenu, sizeof(temp_ExpansionMenu) );
menu_t temp_ExpDef = {
ex_end, // # of menu items
&::g->MainDef, // previous menu
::g->ExpansionMenu, // menuitem_t ->
M_DrawEpisode, // drawing routine ->
48,63, // x,y
ex1 // lastOn
};
memcpy( &::g->ExpDef, &temp_ExpDef, sizeof(temp_ExpDef) );
menuitem_t temp_LoadExpMenu[2] = {
{1,"M_EPI1", M_LoadExpansion,'h'},
{1,"M_EPI2", M_LoadExpansion,'n'},
};
memcpy( ::g->LoadExpMenu, temp_LoadExpMenu, sizeof(temp_LoadExpMenu) );
menu_t temp_LoadExpDef = {
ex_end, // # of menu items
&::g->MainDef, // previous menu
::g->LoadExpMenu, // menuitem_t ->
M_DrawEpisode, // drawing routine ->
48,63, // x,y
ex1 // lastOn
};
memcpy( &::g->LoadExpDef, &temp_LoadExpDef, sizeof(temp_LoadExpDef) );
menuitem_t temp_NewGameMenu[5] = {
{1,"M_JKILL", M_ChooseSkill, 'i'},
{1,"M_ROUGH", M_ChooseSkill, 'h'},
{1,"M_HURT", M_ChooseSkill, 'h'},
{1,"M_ULTRA", M_ChooseSkill, 'u'},
{1,"M_NMARE", M_ChooseSkill, 'n'}
};
memcpy( ::g->NewGameMenu, temp_NewGameMenu, sizeof(temp_NewGameMenu) );
menu_t temp_NewDef = {
newg_end, // # of menu items
&::g->EpiDef, // previous menu
::g->NewGameMenu, // menuitem_t ->
M_DrawNewGame, // drawing routine ->
48,63, // x,y
hurtme // lastOn
};
memcpy( &::g->NewDef, &temp_NewDef, sizeof(temp_NewDef) );
menuitem_t temp_OptionsMenu[8] = {
{1,"M_GDHIGH", M_FullScreen,'f'},
{1,"M_SCRNSZ", M_ChangeGPad,'m'},
{1,"M_MESSG", M_ChangeMessages,'m'},
//{1,"M_DETAIL", M_ChangeDetail,'g'},
//{2,"M_SCRNSZ", M_SizeDisplay,'s'},
{-1,"",0},
{2,"M_MSENS", M_ChangeSensitivity,'m'},
{-1,"",0},
{1,"M_SVOL", M_Sound,'s'}
};
memcpy( ::g->OptionsMenu, temp_OptionsMenu, sizeof(temp_OptionsMenu) );
menu_t temp_OptionsDef = {
opt_end,
&::g->MainDef,
::g->OptionsMenu,
M_DrawOptions,
60,37,
0
};
memcpy( &::g->OptionsDef, &temp_OptionsDef, sizeof(temp_OptionsDef) );
menuitem_t temp_SoundMenu[4] = {
{2,"M_SFXVOL",M_SfxVol,'s'},
{-1,"",0},
{2,"M_MUSVOL",M_MusicVol,'m'},
{-1,"",0}
};
memcpy( ::g->SoundMenu, temp_SoundMenu, sizeof(temp_SoundMenu) );
menu_t temp_SoundDef = {
sound_end,
&::g->OptionsDef,
::g->SoundMenu,
M_DrawSound,
80,64,
0
};
memcpy( &::g->SoundDef, &temp_SoundDef, sizeof(temp_SoundDef) );
menuitem_t temp_LoadMenu[6] = {
{1,"", M_LoadSelect,'1'},
{1,"", M_LoadSelect,'2'},
{1,"", M_LoadSelect,'3'},
{1,"", M_LoadSelect,'4'},
{1,"", M_LoadSelect,'5'},
{1,"", M_LoadSelect,'6'}
};
memcpy( ::g->LoadMenu, temp_LoadMenu, sizeof(temp_LoadMenu) );
menu_t temp_LoadDef = {
load_end,
&::g->MainDef,
::g->LoadMenu,
M_DrawLoad,
80,54,
0
};
memcpy( &::g->LoadDef, &temp_LoadDef, sizeof(temp_LoadDef) );
menuitem_t temp_SaveMenu[6] = {
{1,"", M_SaveSelect,'1'},
{1,"", M_SaveSelect,'2'},
{1,"", M_SaveSelect,'3'},
{1,"", M_SaveSelect,'4'},
{1,"", M_SaveSelect,'5'},
{1,"", M_SaveSelect,'6'}
};
memcpy( ::g->SaveMenu, temp_SaveMenu, sizeof(temp_SaveMenu) );
menu_t temp_SaveDef = {
load_end,
&::g->MainDef,
::g->SaveMenu,
M_DrawSave,
80,54,
0
};
memcpy( &::g->SaveDef, &temp_SaveDef, sizeof(temp_SaveDef) );
int temp_quitsounds[8] = {
sfx_pldeth,
sfx_dmpain,
sfx_popain,
sfx_slop,
sfx_telept,
sfx_posit1,
sfx_posit3,
sfx_sgtatk
};
memcpy( ::g->quitsounds, temp_quitsounds, sizeof(temp_quitsounds) );
int temp_quitsounds2[8] = {
sfx_vilact,
sfx_getpow,
sfx_boscub,
sfx_slop,
sfx_skeswg,
sfx_kntdth,
sfx_bspact,
sfx_sgtatk
};
memcpy( ::g->quitsounds2, temp_quitsounds2, sizeof(temp_quitsounds2) );
::g->joywait = 0;
::g->mousewait = 0;
::g->mmenu_mousey = 0;
::g->lasty = 0;
::g->mmenu_mousex = 0;
::g->lastx = 0;
// m_menu.constructs end //
// m_misc.constructs begin //
::g->g_pszSaveFile = "\\save.dat";
::g->g_pszImagePath = "d:\\saveimage.xbx";
::g->g_pszImageMeta = "saveimage.xbx";
extern const char* const temp_chat_macros[];
for (int i = 0; i < 10; i++)
{
chat_macros[i] = temp_chat_macros[i];
}
default_t temp_defaults[35] = {
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( "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( "mouseb_fire",&::g->mousebfire,0 ),
default_t( "mouseb_strafe",&::g->mousebstrafe,1 ),
default_t( "mouseb_forward",&::g->mousebforward,2 ),
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( "chatmacro0", &::g->chat_macros[0], HUSTR_CHATMACRO0 ),
default_t( "chatmacro1", &::g->chat_macros[1], HUSTR_CHATMACRO1 ),
default_t( "chatmacro2", &::g->chat_macros[2], HUSTR_CHATMACRO2 ),
default_t( "chatmacro3", &::g->chat_macros[3], HUSTR_CHATMACRO3 ),
default_t( "chatmacro4", &::g->chat_macros[4], HUSTR_CHATMACRO4 ),
default_t( "chatmacro5", &::g->chat_macros[5], HUSTR_CHATMACRO5 ),
default_t( "chatmacro6", &::g->chat_macros[6], HUSTR_CHATMACRO6 ),
default_t( "chatmacro7", &::g->chat_macros[7], HUSTR_CHATMACRO7 ),
default_t( "chatmacro8", &::g->chat_macros[8], HUSTR_CHATMACRO8 ),
default_t( "chatmacro9", &::g->chat_macros[9], HUSTR_CHATMACRO9 )
};
memcpy( ::g->defaults, temp_defaults, sizeof(temp_defaults) );
// m_misc.constructs end //
// m_random.constructs begin //
::g->rndindex = 0;
::g->prndindex = 0;
// m_random.constructs end //
// p_enemy.constructs begin //
::g->TRACEANGLE = 0xc000000;
::g->easy = 0;
// p_enemy.constructs end //
// r_bsp.constructs begin //
int temp_checkcoord[12][4] = {
{3,0,2,1},
{3,0,2,0},
{3,1,2,0},
{0},
{2,0,2,1},
{0,0,0,0},
{3,1,3,0},
{0},
{2,0,3,1},
{2,1,3,1},
{2,1,3,0}
};
memcpy( ::g->checkcoord, temp_checkcoord, sizeof(temp_checkcoord) );
// r_bsp.constructs end //
// r_draw.constructs begin //
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
};
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) );
// 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 //
::g->mus_playing=0;
// s_sound.constructs end //
// wi_stuff.constructs begin //
int temp_NUMANIMS[NUMEPISODES] = {
sizeof(epsd0animinfo)/sizeof(anim_t),
sizeof(epsd1animinfo)/sizeof(anim_t),
sizeof(epsd2animinfo)/sizeof(anim_t)
};
memcpy( ::g->NUMANIMS, temp_NUMANIMS, sizeof(temp_NUMANIMS) );
::g->snl_pointeron = false;
extern const anim_t temp_epsd0animinfo[10];
extern const anim_t temp_epsd1animinfo[9];
extern const anim_t temp_epsd2animinfo[6];
memcpy(::g->epsd0animinfo, temp_epsd0animinfo, sizeof(temp_epsd0animinfo));
memcpy(::g->epsd1animinfo, temp_epsd1animinfo, sizeof(temp_epsd1animinfo));
memcpy(::g->epsd2animinfo, temp_epsd2animinfo, sizeof(temp_epsd2animinfo));
wi_stuff_anims[0] = ::g->epsd0animinfo;
wi_stuff_anims[1] = ::g->epsd1animinfo;
wi_stuff_anims[2] = ::g->epsd2animinfo;
// wi_stuff.constructs end //
// z_zone.constructs begin //
::g->zones[NUM_ZONES] = NULL;
::g->NumAlloc = 0;
// z_zone.constructs end //
// info constructs begin //
extern const state_t tempStates[NUMSTATES];
memcpy(::g->states, tempStates, sizeof(tempStates));
// info constructs end //
// p_local begin //
::g->rejectmatrix = NULL;
// p_local end //
// r_data begin //]
::g->s_numtextures = 0;
// r_data end //

725
doomclassic/doom/d_englsh.h Normal file
View File

@@ -0,0 +1,725 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __D_ENGLSH__
#define __D_ENGLSH__
//
// Printed strings for translation
//
//
// D_Main.C
//
#define D_DEVSTR "Development mode ON.\n"
#define D_CDROM "CD-ROM Version: default.cfg from c:\\doomdata\n"
//
// M_Menu.C
//
#define PRESSKEY "press any button."
#define PRESSYN "press y or n."
#define QUITMSG "are you sure you want to\nquit this great game?"
#define LOADNET "you can't do load while in a net game!\n\n"PRESSKEY
#define QLOADNET "you can't quickload during a netgame!\n\n"PRESSKEY
#define QSAVESPOT "you haven't picked a quicksave slot yet!\n\n"PRESSKEY
#define SAVEDEAD "you can't save if you aren't playing!\n\n"PRESSKEY
#define QSPROMPT "quicksave over your game named\n\n'%s'?\n\n"PRESSYN
#define QLPROMPT "do you want to quickload the game named\n\n'%s'?\n\n"PRESSYN
#define NEWGAME \
"you can't start a new game\n"\
"while in a network game.\n\n"PRESSKEY
#define NIGHTMARE \
"are you sure? this skill level\n"\
"isn't even remotely fair.\n\n"PRESSYN
#define SWSTRING \
"this is the shareware version of doom.\n\n"\
"you need to order the entire trilogy.\n\n"PRESSKEY
#define MSGOFF "Messages OFF"
#define MSGON "Messages ON"
#define NETEND "you can't end a netgame!\n\n"PRESSKEY
#define ENDGAME "are you sure you want to end the game?\n\n"PRESSYN
#define DOSY "(press A to quit)"
#define DETAILHI "High detail"
#define DETAILLO "Low detail"
#define GAMMALVL0 "Gamma correction OFF"
#define GAMMALVL1 "Gamma correction level 1"
#define GAMMALVL2 "Gamma correction level 2"
#define GAMMALVL3 "Gamma correction level 3"
#define GAMMALVL4 "Gamma correction level 4"
//#define EMPTYSTRING "empty slot"
#define EMPTYSTRING "---"
//
// P_inter.C
//
#define GOTARMOR "Picked up the armor."
#define GOTMEGA "Picked up the MegaArmor!"
#define GOTHTHBONUS "Picked up a health bonus."
#define GOTARMBONUS "Picked up an armor bonus."
#define GOTSTIM "Picked up a stimpack."
#define GOTMEDINEED "Picked up a medikit that you REALLY need!"
#define GOTMEDIKIT "Picked up a medikit."
#define GOTSUPER "Supercharge!"
#define GOTBLUECARD "Picked up a blue keycard."
#define GOTYELWCARD "Picked up a yellow keycard."
#define GOTREDCARD "Picked up a red keycard."
#define GOTBLUESKUL "Picked up a blue skull key."
#define GOTYELWSKUL "Picked up a yellow skull key."
#define GOTREDSKULL "Picked up a red skull key."
#define GOTINVUL "Invulnerability!"
#define GOTBERSERK "Berserk!"
#define GOTINVIS "Partial Invisibility"
#define GOTSUIT "Radiation Shielding Suit"
#define GOTMAP "Computer Area Map"
#define GOTVISOR "Light Amplification Visor"
#define GOTMSPHERE "MegaSphere!"
#define GOTCLIP "Picked up a clip."
#define GOTCLIPBOX "Picked up a box of bullets."
#define GOTROCKET "Picked up a rocket."
#define GOTROCKBOX "Picked up a box of rockets."
#define GOTCELL "Picked up an energy cell."
#define GOTCELLBOX "Picked up an energy cell pack."
#define GOTSHELLS "Picked up 4 shotgun shells."
#define GOTSHELLBOX "Picked up a box of shotgun shells."
#define GOTBACKPACK "Picked up a backpack full of ammo!"
#define GOTBFG9000 "You got the BFG9000! Oh, yes."
#define GOTCHAINGUN "You got the chaingun!"
#define GOTCHAINSAW "A chainsaw! Find some meat!"
#define GOTLAUNCHER "You got the rocket launcher!"
#define GOTPLASMA "You got the plasma gun!"
#define GOTSHOTGUN "You got the shotgun!"
#define GOTSHOTGUN2 "You got the super shotgun!"
//
// P_Doors.C
//
#define PD_BLUEO "You need a blue key to activate this object"
#define PD_REDO "You need a red key to activate this object"
#define PD_YELLOWO "You need a yellow key to activate this object"
#define PD_BLUEK "You need a blue key to open this door"
#define PD_REDK "You need a red key to open this door"
#define PD_YELLOWK "You need a yellow key to open this door"
//
// G_game.C
//
#define GGSAVED "game saved."
//
// HU_stuff.C
//
#define HUSTR_MSGU "[Message unsent]"
#define HUSTR_E1M1 "E1M1: Hangar"
#define HUSTR_E1M2 "E1M2: Nuclear Plant"
#define HUSTR_E1M3 "E1M3: Toxin Refinery"
#define HUSTR_E1M4 "E1M4: Command Control"
#define HUSTR_E1M5 "E1M5: Phobos Lab"
#define HUSTR_E1M6 "E1M6: Central Processing"
#define HUSTR_E1M7 "E1M7: Computer Station"
#define HUSTR_E1M8 "E1M8: Phobos Anomaly"
#define HUSTR_E1M9 "E1M9: Military Base"
#define HUSTR_E2M1 "E2M1: Deimos Anomaly"
#define HUSTR_E2M2 "E2M2: Containment Area"
#define HUSTR_E2M3 "E2M3: Refinery"
#define HUSTR_E2M4 "E2M4: Deimos Lab"
#define HUSTR_E2M5 "E2M5: Command Center"
#define HUSTR_E2M6 "E2M6: Halls of the Damned"
#define HUSTR_E2M7 "E2M7: Spawning Vats"
#define HUSTR_E2M8 "E2M8: Tower of Babel"
#define HUSTR_E2M9 "E2M9: Fortress of Mystery"
#define HUSTR_E3M1 "E3M1: Hell Keep"
#define HUSTR_E3M2 "E3M2: Slough of Despair"
#define HUSTR_E3M3 "E3M3: Pandemonium"
#define HUSTR_E3M4 "E3M4: House of Pain"
#define HUSTR_E3M5 "E3M5: Unholy Cathedral"
#define HUSTR_E3M6 "E3M6: Mt. Erebus"
#define HUSTR_E3M7 "E3M7: Limbo"
#define HUSTR_E3M8 "E3M8: Dis"
#define HUSTR_E3M9 "E3M9: Warrens"
#define HUSTR_E4M1 "E4M1: Hell Beneath"
#define HUSTR_E4M2 "E4M2: Perfect Hatred"
#define HUSTR_E4M3 "E4M3: Sever The Wicked"
#define HUSTR_E4M4 "E4M4: Unruly Evil"
#define HUSTR_E4M5 "E4M5: They Will Repent"
#define HUSTR_E4M6 "E4M6: Against Thee Wickedly"
#define HUSTR_E4M7 "E4M7: And Hell Followed"
#define HUSTR_E4M8 "E4M8: Unto The Cruel"
#define HUSTR_E4M9 "E4M9: Fear"
#define HUSTR_1 "level 1: entryway"
#define HUSTR_2 "level 2: underhalls"
#define HUSTR_3 "level 3: the gantlet"
#define HUSTR_4 "level 4: the focus"
#define HUSTR_5 "level 5: the waste tunnels"
#define HUSTR_6 "level 6: the crusher"
#define HUSTR_7 "level 7: dead simple"
#define HUSTR_8 "level 8: tricks and traps"
#define HUSTR_9 "level 9: the pit"
#define HUSTR_10 "level 10: refueling base"
#define HUSTR_11 "level 11: circle of death"
#define HUSTR_12 "level 12: the factory"
#define HUSTR_13 "level 13: downtown"
#define HUSTR_14 "level 14: the inmost dens"
#define HUSTR_15 "level 15: industrial zone"
#define HUSTR_16 "level 16: suburbs"
#define HUSTR_17 "level 17: tenements"
#define HUSTR_18 "level 18: the courtyard"
#define HUSTR_19 "level 19: the citadel"
#define HUSTR_20 "level 20: gotcha!"
#define HUSTR_21 "level 21: nirvana"
#define HUSTR_22 "level 22: the catacombs"
#define HUSTR_23 "level 23: barrels o' fun"
#define HUSTR_24 "level 24: the chasm"
#define HUSTR_25 "level 25: bloodfalls"
#define HUSTR_26 "level 26: the abandoned mines"
#define HUSTR_27 "level 27: monster condo"
#define HUSTR_28 "level 28: the spirit world"
#define HUSTR_29 "level 29: the living end"
#define HUSTR_30 "level 30: icon of sin"
#define HUSTR_31 "level 31: idkfa"
#define HUSTR_32 "level 32: keen"
#define HUSTR_33 "level 33: betray"
#define PHUSTR_1 "level 1: congo"
#define PHUSTR_2 "level 2: well of souls"
#define PHUSTR_3 "level 3: aztec"
#define PHUSTR_4 "level 4: caged"
#define PHUSTR_5 "level 5: ghost town"
#define PHUSTR_6 "level 6: baron's lair"
#define PHUSTR_7 "level 7: caughtyard"
#define PHUSTR_8 "level 8: realm"
#define PHUSTR_9 "level 9: abattoire"
#define PHUSTR_10 "level 10: onslaught"
#define PHUSTR_11 "level 11: hunted"
#define PHUSTR_12 "level 12: speed"
#define PHUSTR_13 "level 13: the crypt"
#define PHUSTR_14 "level 14: genesis"
#define PHUSTR_15 "level 15: the twilight"
#define PHUSTR_16 "level 16: the omen"
#define PHUSTR_17 "level 17: compound"
#define PHUSTR_18 "level 18: neurosphere"
#define PHUSTR_19 "level 19: nme"
#define PHUSTR_20 "level 20: the death domain"
#define PHUSTR_21 "level 21: slayer"
#define PHUSTR_22 "level 22: impossible mission"
#define PHUSTR_23 "level 23: tombstone"
#define PHUSTR_24 "level 24: the final frontier"
#define PHUSTR_25 "level 25: the temple of darkness"
#define PHUSTR_26 "level 26: bunker"
#define PHUSTR_27 "level 27: anti-christ"
#define PHUSTR_28 "level 28: the sewers"
#define PHUSTR_29 "level 29: odyssey of noises"
#define PHUSTR_30 "level 30: the gateway of hell"
#define PHUSTR_31 "level 31: cyberden"
#define PHUSTR_32 "level 32: go 2 it"
#define THUSTR_1 "level 1: system control"
#define THUSTR_2 "level 2: human bbq"
#define THUSTR_3 "level 3: power control"
#define THUSTR_4 "level 4: wormhole"
#define THUSTR_5 "level 5: hanger"
#define THUSTR_6 "level 6: open season"
#define THUSTR_7 "level 7: prison"
#define THUSTR_8 "level 8: metal"
#define THUSTR_9 "level 9: stronghold"
#define THUSTR_10 "level 10: redemption"
#define THUSTR_11 "level 11: storage facility"
#define THUSTR_12 "level 12: crater"
#define THUSTR_13 "level 13: nukage processing"
#define THUSTR_14 "level 14: steel works"
#define THUSTR_15 "level 15: dead zone"
#define THUSTR_16 "level 16: deepest reaches"
#define THUSTR_17 "level 17: processing area"
#define THUSTR_18 "level 18: mill"
#define THUSTR_19 "level 19: shipping/respawning"
#define THUSTR_20 "level 20: central processing"
#define THUSTR_21 "level 21: administration center"
#define THUSTR_22 "level 22: habitat"
#define THUSTR_23 "level 23: lunar mining project"
#define THUSTR_24 "level 24: quarry"
#define THUSTR_25 "level 25: baron's den"
#define THUSTR_26 "level 26: ballistyx"
#define THUSTR_27 "level 27: mount pain"
#define THUSTR_28 "level 28: heck"
#define THUSTR_29 "level 29: river styx"
#define THUSTR_30 "level 30: last call"
#define THUSTR_31 "level 31: pharaoh"
#define THUSTR_32 "level 32: caribbean"
#define HUSTR_CHATMACRO1 "I'm ready to kick butt!"
#define HUSTR_CHATMACRO2 "I'm OK."
#define HUSTR_CHATMACRO3 "I'm not looking too good!"
#define HUSTR_CHATMACRO4 "Help!"
#define HUSTR_CHATMACRO5 "You suck!"
#define HUSTR_CHATMACRO6 "Next time, scumbag..."
#define HUSTR_CHATMACRO7 "Come here!"
#define HUSTR_CHATMACRO8 "I'll take care of it."
#define HUSTR_CHATMACRO9 "Yes"
#define HUSTR_CHATMACRO0 "No"
#define HUSTR_TALKTOSELF1 "You mumble to yourself"
#define HUSTR_TALKTOSELF2 "Who's there?"
#define HUSTR_TALKTOSELF3 "You scare yourself"
#define HUSTR_TALKTOSELF4 "You start to rave"
#define HUSTR_TALKTOSELF5 "You've lost it..."
#define HUSTR_MESSAGESENT "[Message Sent]"
// The following should NOT be changed unless it seems
// just AWFULLY necessary
#define HUSTR_PLRGREEN "Green: "
#define HUSTR_PLRINDIGO "Indigo: "
#define HUSTR_PLRBROWN "Brown: "
#define HUSTR_PLRRED "Red: "
#define HUSTR_KEYGREEN 'g'
#define HUSTR_KEYINDIGO 'i'
#define HUSTR_KEYBROWN 'b'
#define HUSTR_KEYRED 'r'
//
// AM_map.C
//
#define AMSTR_FOLLOWON "Follow Mode ON"
#define AMSTR_FOLLOWOFF "Follow Mode OFF"
#define AMSTR_GRIDON "Grid ON"
#define AMSTR_GRIDOFF "Grid OFF"
#define AMSTR_MARKEDSPOT "Marked Spot"
#define AMSTR_MARKSCLEARED "All Marks Cleared"
//
// ST_stuff.C
//
#define STSTR_MUS "Music Change"
#define STSTR_NOMUS "IMPOSSIBLE SELECTION"
#define STSTR_DQDON "Degreelessness Mode On"
#define STSTR_DQDOFF "Degreelessness Mode Off"
#define STSTR_KFAADDED "Very Happy Ammo Added"
#define STSTR_FAADDED "Ammo (no keys) Added"
#define STSTR_NCON "No Clipping Mode ON"
#define STSTR_NCOFF "No Clipping Mode OFF"
#define STSTR_BEHOLD "inVuln, Str, Inviso, Rad, Allmap, or Lite-amp"
#define STSTR_BEHOLDX "Power-up Toggled"
#define STSTR_CHOPPERS "... doesn't suck - GM"
#define STSTR_CLEV "Changing Level..."
//
// F_Finale.C
//
#define E1TEXT \
"Once you beat the big badasses and\n"\
"clean out the moon base you're supposed\n"\
"to win, aren't you? Aren't you? Where's\n"\
"your fat reward and ticket home? What\n"\
"the hell is this? It's not supposed to\n"\
"end this way!\n"\
"\n" \
"It stinks like rotten meat, but looks\n"\
"like the lost Deimos base. Looks like\n"\
"you're stuck on The Shores of Hell.\n"\
"The only way out is through.\n"\
"\n"\
"To continue the DOOM experience, play\n"\
"The Shores of Hell and its amazing\n"\
"sequel, Inferno!\n"
#define E2TEXT \
"You've done it! The hideous cyber-\n"\
"demon lord that ruled the lost Deimos\n"\
"moon base has been slain and you\n"\
"are triumphant! But ... where are\n"\
"you? You clamber to the edge of the\n"\
"moon and look down to see the awful\n"\
"truth.\n" \
"\n"\
"Deimos floats above Hell itself!\n"\
"You've never heard of anyone escaping\n"\
"from Hell, but you'll make the bastards\n"\
"sorry they ever heard of you! Quickly,\n"\
"you rappel down to the surface of\n"\
"Hell.\n"\
"\n" \
"Now, it's on to the final chapter of\n"\
"DOOM! -- Inferno."
#define E3TEXT \
"The loathsome spiderdemon that\n"\
"masterminded the invasion of the moon\n"\
"bases and caused so much death has had\n"\
"its ass kicked for all time.\n"\
"\n"\
"A hidden doorway opens and you enter.\n"\
"You've proven too tough for Hell to\n"\
"contain, and now Hell at last plays\n"\
"fair -- for you emerge from the door\n"\
"to see the green fields of Earth!\n"\
"Home at last.\n" \
"\n"\
"You wonder what's been happening on\n"\
"Earth while you were battling evil\n"\
"unleashed. It's good that no Hell-\n"\
"spawn could have come through that\n"\
"door with you ..."
#define E4TEXT \
"the spider mastermind must have sent forth\n"\
"its legions of hellspawn before your\n"\
"final confrontation with that terrible\n"\
"beast from hell. but you stepped forward\n"\
"and brought forth eternal damnation and\n"\
"suffering upon the horde as a true hero\n"\
"would in the face of something so evil.\n"\
"\n"\
"besides, someone was gonna pay for what\n"\
"happened to daisy, your pet rabbit.\n"\
"\n"\
"but now, you see spread before you more\n"\
"potential pain and gibbitude as a nation\n"\
"of demons run amok among our cities.\n"\
"\n"\
"next stop, hell on earth!"
// after level 6, put this:
#define C1TEXT \
"YOU HAVE ENTERED DEEPLY INTO THE INFESTED\n" \
"STARPORT. BUT SOMETHING IS WRONG. THE\n" \
"MONSTERS HAVE BROUGHT THEIR OWN REALITY\n" \
"WITH THEM, AND THE STARPORT'S TECHNOLOGY\n" \
"IS BEING SUBVERTED BY THEIR PRESENCE.\n" \
"\n"\
"AHEAD, YOU SEE AN OUTPOST OF HELL, A\n" \
"FORTIFIED ZONE. IF YOU CAN GET PAST IT,\n" \
"YOU CAN PENETRATE INTO THE HAUNTED HEART\n" \
"OF THE STARBASE AND FIND THE CONTROLLING\n" \
"SWITCH WHICH HOLDS EARTH'S POPULATION\n" \
"HOSTAGE."
// After level 11, put this:
#define C2TEXT \
"YOU HAVE WON! YOUR VICTORY HAS ENABLED\n" \
"HUMANKIND TO EVACUATE EARTH AND ESCAPE\n"\
"THE NIGHTMARE. NOW YOU ARE THE ONLY\n"\
"HUMAN LEFT ON THE FACE OF THE PLANET.\n"\
"CANNIBAL MUTATIONS, CARNIVOROUS ALIENS,\n"\
"AND EVIL SPIRITS ARE YOUR ONLY NEIGHBORS.\n"\
"YOU SIT BACK AND WAIT FOR DEATH, CONTENT\n"\
"THAT YOU HAVE SAVED YOUR SPECIES.\n"\
"\n"\
"BUT THEN, EARTH CONTROL BEAMS DOWN A\n"\
"MESSAGE FROM SPACE: \"SENSORS HAVE LOCATED\n"\
"THE SOURCE OF THE ALIEN INVASION. IF YOU\n"\
"GO THERE, YOU MAY BE ABLE TO BLOCK THEIR\n"\
"ENTRY. THE ALIEN BASE IS IN THE HEART OF\n"\
"YOUR OWN HOME CITY, NOT FAR FROM THE\n"\
"STARPORT.\" SLOWLY AND PAINFULLY YOU GET\n"\
"UP AND RETURN TO THE FRAY."
// After level 20, put this:
#define C3TEXT \
"YOU ARE AT THE CORRUPT HEART OF THE CITY,\n"\
"SURROUNDED BY THE CORPSES OF YOUR ENEMIES.\n"\
"YOU SEE NO WAY TO DESTROY THE CREATURES'\n"\
"ENTRYWAY ON THIS SIDE, SO YOU CLENCH YOUR\n"\
"TEETH AND PLUNGE THROUGH IT.\n"\
"\n"\
"THERE MUST BE A WAY TO CLOSE IT ON THE\n"\
"OTHER SIDE. WHAT DO YOU CARE IF YOU'VE\n"\
"GOT TO GO THROUGH HELL TO GET TO IT?"
// After level 29, put this:
#define C4TEXT \
"THE HORRENDOUS VISAGE OF THE BIGGEST\n"\
"DEMON YOU'VE EVER SEEN CRUMBLES BEFORE\n"\
"YOU, AFTER YOU PUMP YOUR ROCKETS INTO\n"\
"HIS EXPOSED BRAIN. THE MONSTER SHRIVELS\n"\
"UP AND DIES, ITS THRASHING LIMBS\n"\
"DEVASTATING UNTOLD MILES OF HELL'S\n"\
"SURFACE.\n"\
"\n"\
"YOU'VE DONE IT. THE INVASION IS OVER.\n"\
"EARTH IS SAVED. HELL IS A WRECK. YOU\n"\
"WONDER WHERE BAD FOLKS WILL GO WHEN THEY\n"\
"DIE, NOW. WIPING THE SWEAT FROM YOUR\n"\
"FOREHEAD YOU BEGIN THE LONG TREK BACK\n"\
"HOME. REBUILDING EARTH OUGHT TO BE A\n"\
"LOT MORE FUN THAN RUINING IT WAS.\n"
// Before level 31, put this:
#define C5TEXT \
"CONGRATULATIONS, YOU'VE FOUND THE SECRET\n"\
"LEVEL! LOOKS LIKE IT'S BEEN BUILT BY\n"\
"HUMANS, RATHER THAN DEMONS. YOU WONDER\n"\
"WHO THE INMATES OF THIS CORNER OF HELL\n"\
"WILL BE."
// Before level 32, put this:
#define C6TEXT \
"CONGRATULATIONS, YOU'VE FOUND THE\n"\
"SUPER SECRET LEVEL! YOU'D BETTER\n"\
"BLAZE THROUGH THIS ONE!\n"
#define C7TEXT \
"TROUBLE WAS BREWING AGAIN IN YOUR FAVORITE\n"\
"VACATION SPOT... HELL. SOME CYBERDEMON\n"\
"PUNK THOUGHT HE COULD TURN HELL INTO A\n"\
"PERSONAL AMUSEMENT PARK, AND MAKE EARTH\nTHE TICKET BOOTH.\n\n"\
"WELL THAT HALF-ROBOT FREAK SHOW DIDN'T\n"\
"KNOW WHO WAS COMING TO THE FAIR. THERE'S\n"\
"NOTHING LIKE A SHOOTING GALLERY FULL OF\n"\
"HELLSPAWN TO GET THE BLOOD PUMPING...\n\n"\
"NOW THE WALLS OF THE DEMON'S LABYRINTH\n"\
"ECHO WITH THE SOUND OF HIS METALLIC LIMBS\n"\
"HITTING THE FLOOR. HIS DEATH MOAN GURGLES\n" \
"OUT THROUGH THE MESS YOU LEFT OF HIS FACE.\n\n" \
"THIS RIDE IS CLOSED."
#define C8TEXT \
"CONGRATULATIONS YOU HAVE FINISHED... \n\n"\
"THE MASTER LEVELS\n"
// after map 06
#define P1TEXT \
"You gloat over the steaming carcass of the\n"\
"Guardian. With its death, you've wrested\n"\
"the Accelerator from the stinking claws\n"\
"of Hell. You relax and glance around the\n"\
"room. Damn! There was supposed to be at\n"\
"least one working prototype, but you can't\n"\
"see it. The demons must have taken it.\n"\
"\n"\
"You must find the prototype, or all your\n"\
"struggles will have been wasted. Keep\n"\
"moving, keep fighting, keep killing.\n"\
"Oh yes, keep living, too."
// after map 11
#define P2TEXT \
"Even the deadly Arch-Vile labyrinth could\n"\
"not stop you, and you've gotten to the\n"\
"prototype Accelerator which is soon\n"\
"efficiently and permanently deactivated.\n"\
"\n"\
"You're good at that kind of thing."
// after map 20
#define P3TEXT \
"You've bashed and battered your way into\n"\
"the heart of the devil-hive. Time for a\n"\
"Search-and-Destroy mission, aimed at the\n"\
"Gatekeeper, whose foul offspring is\n"\
"cascading to Earth. Yeah, he's bad. But\n"\
"you know who's worse!\n"\
"\n"\
"Grinning evilly, you check your gear, and\n"\
"get ready to give the bastard a little Hell\n"\
"of your own making!"
// after map 30
#define P4TEXT \
"The Gatekeeper's evil face is splattered\n"\
"all over the place. As its tattered corpse\n"\
"collapses, an inverted Gate forms and\n"\
"sucks down the shards of the last\n"\
"prototype Accelerator, not to mention the\n"\
"few remaining demons. You're done. Hell\n"\
"has gone back to pounding bad dead folks \n"\
"instead of good live ones. Remember to\n"\
"tell your grandkids to put a rocket\n"\
"launcher in your coffin. If you go to Hell\n"\
"when you die, you'll need it for some\n"\
"final cleaning-up ..."
// before map 31
#define P5TEXT \
"You've found the second-hardest level we\n"\
"got. Hope you have a saved game a level or\n"\
"two previous. If not, be prepared to die\n"\
"aplenty. For master marines only."
// before map 32
#define P6TEXT \
"Betcha wondered just what WAS the hardest\n"\
"level we had ready for ya? Now you know.\n"\
"No one gets out alive."
#define T1TEXT \
"You've fought your way out of the infested\n"\
"experimental labs. It seems that UAC has\n"\
"once again gulped it down. With their\n"\
"high turnover, it must be hard for poor\n"\
"old UAC to buy corporate health insurance\n"\
"nowadays..\n"\
"\n"\
"Ahead lies the military complex, now\n"\
"swarming with diseased horrors hot to get\n"\
"their teeth into you. With luck, the\n"\
"complex still has some warlike ordnance\n"\
"laying around."
#define T2TEXT \
"You hear the grinding of heavy machinery\n"\
"ahead. You sure hope they're not stamping\n"\
"out new hellspawn, but you're ready to\n"\
"ream out a whole herd if you have to.\n"\
"They might be planning a blood feast, but\n"\
"you feel about as mean as two thousand\n"\
"maniacs packed into one mad killer.\n"\
"\n"\
"You don't plan to go down easy."
#define T3TEXT \
"The vista opening ahead looks real damn\n"\
"familiar. Smells familiar, too -- like\n"\
"fried excrement. You didn't like this\n"\
"place before, and you sure as hell ain't\n"\
"planning to like it now. The more you\n"\
"brood on it, the madder you get.\n"\
"Hefting your gun, an evil grin trickles\n"\
"onto your face. Time to take some names."
#define T4TEXT \
"Suddenly, all is silent, from one horizon\n"\
"to the other. The agonizing echo of Hell\n"\
"fades away, the nightmare sky turns to\n"\
"blue, the heaps of monster corpses start \n"\
"to evaporate along with the evil stench \n"\
"that filled the air. Jeeze, maybe you've\n"\
"done it. Have you really won?\n"\
"\n"\
"Something rumbles in the distance.\n"\
"A blue light begins to glow inside the\n"\
"ruined skull of the demon-spitter."
#define T5TEXT \
"What now? Looks totally different. Kind\n"\
"of like King Tut's condo. Well,\n"\
"whatever's here can't be any worse\n"\
"than usual. Can it? Or maybe it's best\n"\
"to let sleeping gods lie.."
#define T6TEXT \
"Time for a vacation. You've burst the\n"\
"bowels of hell and by golly you're ready\n"\
"for a break. You mutter to yourself,\n"\
"Maybe someone else can kick Hell's ass\n"\
"next time around. Ahead lies a quiet town,\n"\
"with peaceful flowing water, quaint\n"\
"buildings, and presumably no Hellspawn.\n"\
"\n"\
"As you step off the transport, you hear\n"\
"the stomp of a cyberdemon's iron shoe."
//
// Character cast strings F_FINALE.C
//
#define CC_ZOMBIE "ZOMBIEMAN"
#define CC_SHOTGUN "SHOTGUN GUY"
#define CC_HEAVY "HEAVY WEAPON DUDE"
#define CC_IMP "IMP"
#define CC_DEMON "DEMON"
#define CC_LOST "LOST SOUL"
#define CC_CACO "CACODEMON"
#define CC_HELL "HELL KNIGHT"
#define CC_BARON "BARON OF HELL"
#define CC_ARACH "ARACHNOTRON"
#define CC_PAIN "PAIN ELEMENTAL"
#define CC_REVEN "REVENANT"
#define CC_MANCU "MANCUBUS"
#define CC_ARCH "ARCH-VILE"
#define CC_SPIDER "THE SPIDER MASTERMIND"
#define CC_CYBER "THE CYBERDEMON"
#define CC_HERO "OUR HERO"
#endif

125
doomclassic/doom/d_event.h Normal file
View File

@@ -0,0 +1,125 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __D_EVENT__
#define __D_EVENT__
#include "doomtype.h"
//
// Event handling.
//
// Input event types.
typedef enum
{
ev_keydown,
ev_keyup,
ev_mouse,
ev_joystick,
ev_none,
} evtype_t;
// Event structure.
typedef struct
{
evtype_t type;
int data1; // keys / mouse/joystick buttons
int data2; // mouse/joystick x move
int data3; // mouse/joystick y move
} event_t;
typedef enum
{
ga_nothing,
ga_loadlevel,
ga_newgame,
ga_loadgame,
ga_savegame,
ga_playdemo,
ga_completed,
ga_victory,
ga_worlddone,
ga_screenshot
} gameaction_t;
//
// Button/action code definitions.
//
typedef enum
{
// Press "Fire".
BT_ATTACK = 1,
// Use button, to open doors, activate switches.
BT_USE = 2,
// Flag: game events, not really buttons.
BT_SPECIAL = 128,
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.
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,
} buttoncode_t;
//
// GLOBAL VARIABLES
//
#define MAXEVENTS 64
extern event_t events[MAXEVENTS];
extern int eventhead;
extern int eventtail;
extern gameaction_t gameaction;
#endif

View File

@@ -0,0 +1,29 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/

View File

@@ -0,0 +1,145 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
// We are referring to sprite numbers.
#include "info.h"
#ifdef __GNUG__
#pragma implementation "d_items.h"
#endif
#include "d_items.h"
//
// PSPRITE ACTIONS for waepons.
// This struct controls the weapon animations.
//
// Each entry is:
// ammo/amunition type
// upstate
// downstate
// readystate
// atkstate, i.e. attack/fire/hit frame
// flashstate, muzzle flash
//
const weaponinfo_t weaponinfo[NUMWEAPONS] =
{
{
// fist
am_noammo,
S_PUNCHUP,
S_PUNCHDOWN,
S_PUNCH,
S_PUNCH1,
S_NULL
},
{
// pistol
am_clip,
S_PISTOLUP,
S_PISTOLDOWN,
S_PISTOL,
S_PISTOL1,
S_PISTOLFLASH
},
{
// shotgun
am_shell,
S_SGUNUP,
S_SGUNDOWN,
S_SGUN,
S_SGUN1,
S_SGUNFLASH1
},
{
// chaingun
am_clip,
S_CHAINUP,
S_CHAINDOWN,
S_CHAIN,
S_CHAIN1,
S_CHAINFLASH1
},
{
// missile launcher
am_misl,
S_MISSILEUP,
S_MISSILEDOWN,
S_MISSILE,
S_MISSILE1,
S_MISSILEFLASH1
},
{
// plasma rifle
am_cell,
S_PLASMAUP,
S_PLASMADOWN,
S_PLASMA,
S_PLASMA1,
S_PLASMAFLASH1
},
{
// bfg 9000
am_cell,
S_BFGUP,
S_BFGDOWN,
S_BFG,
S_BFG1,
S_BFGFLASH1
},
{
// chainsaw
am_noammo,
S_SAWUP,
S_SAWDOWN,
S_SAW,
S_SAW1,
S_NULL
},
{
// super shotgun
am_shell,
S_DSGUNUP,
S_DSGUNDOWN,
S_DSGUN,
S_DSGUN1,
S_DSGUNFLASH1
},
};

View File

@@ -0,0 +1,54 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __D_ITEMS__
#define __D_ITEMS__
#include "doomdef.h"
#ifdef __GNUG__
#pragma interface
#endif
// Weapon info: sprite frames, ammunition use.
typedef struct
{
ammotype_t ammo;
int upstate;
int downstate;
int readystate;
int atkstate;
int flashstate;
} weaponinfo_t;
extern const weaponinfo_t weaponinfo[NUMWEAPONS];
#endif

866
doomclassic/doom/d_main.cpp Normal file
View File

@@ -0,0 +1,866 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "doomdef.h"
#include "doomstat.h"
#include "dstrings.h"
#include "sounds.h"
#include "z_zone.h"
#include "w_wad.h"
#include "s_sound.h"
#include "v_video.h"
#include "f_finale.h"
#include "f_wipe.h"
#include "m_argv.h"
#include "m_misc.h"
#include "m_menu.h"
#include "i_system.h"
#include "i_sound.h"
#include "i_video.h"
#include "g_game.h"
#include "hu_stuff.h"
#include "wi_stuff.h"
#include "st_stuff.h"
#include "am_map.h"
#include "p_setup.h"
#include "r_local.h"
#include "d_main.h"
//#include "../idLib/precompiled.h"
//#include "../Main/PlayerProfile.h"
//#include "../Main/PSN/PS3_Session.h"
#include "d3xp/Game_local.h"
//
// D-DoomLoop()
// Not a globally visible function,
// just included for source reference,
// called by D_DoomMain, never exits.
// Manages timing and IO,
// calls all ?_Responder, ?_Ticker, and ?_Drawer,
// calls I_GetTime, I_StartFrame, and I_StartTic
//
void D_DoomLoop (void);
void R_ExecuteSetViewSize (void);
void D_CheckNetGame (void);
bool D_PollNetworkStart();
void D_ProcessEvents (void);
void D_DoAdvanceDemo (void);
const char* wadfiles[MAXWADFILES] =
{
0
};
const char* extraWad = 0;
//
// EVENT HANDLING
//
// Events are asynchronous inputs generally generated by the game user.
// Events can be discarded if no responder claims them
//
//
// D_PostEvent
// Called by the I/O functions when input is detected
//
void D_PostEvent (event_t* ev)
{
::g->events[::g->eventhead] = *ev;
::g->eventhead = (++::g->eventhead)&(MAXEVENTS-1);
}
//
// D_ProcessEvents
// Send all the ::g->events of the given timestamp down the responder chain
//
void D_ProcessEvents (void)
{
event_t* ev;
// IF STORE DEMO, DO NOT ACCEPT INPUT
if ( ( ::g->gamemode == commercial )
&& (W_CheckNumForName("map01")<0) )
return;
for ( ; ::g->eventtail != ::g->eventhead ; ::g->eventtail = (++::g->eventtail)&(MAXEVENTS-1) )
{
ev = &::g->events[::g->eventtail];
if (M_Responder (ev))
continue; // menu ate the event
G_Responder (ev);
}
}
//
// D_Display
// draw current display, possibly wiping it from the previous
//
// ::g->wipegamestate can be set to -1 to force a ::g->wipe on the next draw
extern bool waitingForWipe;
void D_Wipe()
{
int nowtime, tics;
nowtime = I_GetTime();
tics = nowtime - ::g->wipestart;
if (tics != 0)
{
::g->wipestart = nowtime;
::g->wipedone = wipe_ScreenWipe( 0, 0, SCREENWIDTH, SCREENHEIGHT, tics );
// DHM - Nerve :: Demo recording :: Stop large hitch on first frame after the wipe
if ( ::g->wipedone ) {
::g->oldtrt_entertics = nowtime / ::g->ticdup;
::g->gametime = nowtime;
::g->wipe = false;
waitingForWipe = false;
}
}
}
void D_Display (void)
{
qboolean redrawsbar;
if (::g->nodrawers)
return; // for comparative timing / profiling
redrawsbar = false;
// change the view size if needed
if (::g->setsizeneeded)
{
R_ExecuteSetViewSize();
::g->oldgamestate = (gamestate_t)-1; // force background redraw
::g->borderdrawcount = 3;
}
// save the current screen if about to ::g->wipe
if (::g->gamestate != ::g->wipegamestate)
{
::g->wipe = true;
wipe_StartScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
}
else
::g->wipe = false;
if (::g->gamestate == GS_LEVEL && ::g->gametic)
HU_Erase();
// do buffered drawing
switch (::g->gamestate)
{
case GS_LEVEL:
if (!::g->gametic)
break;
if (::g->automapactive)
AM_Drawer ();
if (::g->wipe || (::g->viewheight != 200 * GLOBAL_IMAGE_SCALER && ::g->fullscreen) )
redrawsbar = true;
if (::g->inhelpscreensstate && !::g->inhelpscreens)
redrawsbar = true; // just put away the help screen
ST_Drawer ( ::g->viewheight == 200 * GLOBAL_IMAGE_SCALER, redrawsbar );
::g->fullscreen = ::g->viewheight == 200 * GLOBAL_IMAGE_SCALER;
break;
case GS_INTERMISSION:
WI_Drawer ();
break;
case GS_FINALE:
F_Drawer ();
break;
case GS_DEMOSCREEN:
D_PageDrawer ();
break;
}
// draw buffered stuff to screen
I_UpdateNoBlit ();
// draw the view directly
if (::g->gamestate == GS_LEVEL && !::g->automapactive && ::g->gametic)
R_RenderPlayerView (&::g->players[::g->displayplayer]);
if (::g->gamestate == GS_LEVEL && ::g->gametic)
HU_Drawer ();
// clean up border stuff
if (::g->gamestate != ::g->oldgamestate && ::g->gamestate != GS_LEVEL)
I_SetPalette ((byte*)W_CacheLumpName ("PLAYPAL",PU_CACHE_SHARED));
// see if the border needs to be initially drawn
if (::g->gamestate == GS_LEVEL && ::g->oldgamestate != GS_LEVEL)
{
::g->viewactivestate = false; // view was not active
R_FillBackScreen (); // draw the pattern into the back screen
}
// see if the border needs to be updated to the screen
if (::g->gamestate == GS_LEVEL && !::g->automapactive && ::g->scaledviewwidth != (320 * GLOBAL_IMAGE_SCALER) )
{
if (::g->menuactive || ::g->menuactivestate || !::g->viewactivestate)
::g->borderdrawcount = 3;
if (::g->borderdrawcount)
{
R_DrawViewBorder (); // erase old menu stuff
::g->borderdrawcount--;
}
}
::g->menuactivestate = ::g->menuactive;
::g->viewactivestate = ::g->viewactive;
::g->inhelpscreensstate = ::g->inhelpscreens;
::g->oldgamestate = ::g->wipegamestate = ::g->gamestate;
// draw pause pic
/*
if (::g->paused)
{
if (::g->automapactive)
y = 4;
else
y = ::g->viewwindowy+4;
V_DrawPatchDirect(::g->viewwindowx+(ORIGINAL_WIDTH-68)/2,
y,0,(patch_t*)W_CacheLumpName ("M_PAUSE", PU_CACHE_SHARED));
}
*/
// menus go directly to the screen
M_Drawer (); // menu is drawn even on top of everything
NetUpdate ( NULL ); // send out any new accumulation
// normal update
if (!::g->wipe)
{
I_FinishUpdate (); // page flip or blit buffer
return;
}
// \ update
wipe_EndScreen(0, 0, SCREENWIDTH, SCREENHEIGHT);
::g->wipestart = I_GetTime () - 1;
D_Wipe(); // initialize g->wipedone
}
void D_RunFrame( bool Sounds )
{
if (Sounds) {
// move positional sounds
S_UpdateSounds (::g->players[::g->consoleplayer].mo);
}
// Update display, next frame, with current state.
D_Display ();
if (Sounds) {
// Update sound output.
I_SubmitSound();
}
}
//
// D_DoomLoop
//
void D_DoomLoop (void)
{
// DHM - Not used
/*
if (M_CheckParm ("-debugfile"))
{
char filename[20];
sprintf (filename,"debug%i.txt",::g->consoleplayer);
I_Printf ("debug output to: %s\n",filename);
::g->debugfile = f o p e n(filename,"w");
}
I_InitGraphics ();
while (1)
{
TryRunTics();
D_RunFrame( true );
}
*/
}
//
// DEMO LOOP
//
//
// D_PageTicker
// Handles timing for warped ::g->projection
//
void D_PageTicker (void)
{
if (--::g->pagetic < 0)
D_AdvanceDemo ();
}
//
// D_PageDrawer
//
void D_PageDrawer (void)
{
V_DrawPatch (0,0, 0, (patch_t*)W_CacheLumpName(::g->pagename, PU_CACHE_SHARED));
}
//
// D_AdvanceDemo
// Called after each demo or intro ::g->demosequence finishes
//
void D_AdvanceDemo (void)
{
::g->advancedemo = true;
}
//
// This cycles through the demo sequences.
// FIXME - version dependend demo numbers?
//
void D_DoAdvanceDemo (void)
{
::g->players[::g->consoleplayer].playerstate = PST_LIVE; // not reborn
::g->advancedemo = false;
::g->usergame = false; // no save / end game here
::g->paused = false;
::g->gameaction = ga_nothing;
if ( ::g->gamemode == retail )
::g->demosequence = (::g->demosequence+1)%8;
else
::g->demosequence = (::g->demosequence+1)%6;
switch (::g->demosequence)
{
case 0:
if ( ::g->gamemode == commercial )
::g->pagetic = 35 * 11;
else
::g->pagetic = 8 * TICRATE;
::g->gamestate = GS_DEMOSCREEN;
::g->pagename = "INTERPIC";
if ( ::g->gamemode == commercial )
S_StartMusic(mus_dm2ttl);
else
S_StartMusic (mus_intro);
break;
case 1:
G_DeferedPlayDemo ("demo1");
break;
case 2:
::g->pagetic = 3 * TICRATE;
::g->gamestate = GS_DEMOSCREEN;
::g->pagename = "INTERPIC";
break;
case 3:
G_DeferedPlayDemo ("demo2");
break;
case 4:
::g->pagetic = 3 * TICRATE;
::g->gamestate = GS_DEMOSCREEN;
::g->pagename = "INTERPIC";
break;
case 5:
G_DeferedPlayDemo ("demo3");
break;
// THE DEFINITIVE DOOM Special Edition demo
case 6:
::g->pagetic = 3 * TICRATE;
::g->gamestate = GS_DEMOSCREEN;
::g->pagename = "INTERPIC";
break;
case 7:
G_DeferedPlayDemo ("demo4");
break;
}
}
//
// D_StartTitle
//
void D_StartTitle (void)
{
::g->gameaction = ga_nothing;
::g->demosequence = -1;
D_AdvanceDemo ();
}
// print ::g->title for every printed line
//
// D_AddExtraWadFile
//
void D_SetExtraWadFile( const char *file ) {
extraWad = file;
}
//
// D_AddFile
//
void D_AddFile (const char *file)
{
int numwadfiles;
for (numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++)
if (file == wadfiles[numwadfiles])
return;
;
wadfiles[numwadfiles] = file;
}
//
// IdentifyVersion
// Checks availability of IWAD files by name,
// to determine whether registered/commercial features
// should be executed (notably loading PWAD's).
//
void IdentifyVersion (void)
{
W_FreeWadFiles();
const ExpansionData * expansion = DoomLib::GetCurrentExpansion();
::g->gamemode = expansion->gameMode;
::g->gamemission = expansion->pack_type;
if( expansion->type == ExpansionData::PWAD ) {
D_AddFile( expansion->iWadFilename );
D_AddFile( expansion->pWadFilename );
} else {
D_AddFile( expansion->iWadFilename );
}
}
//
// Find a Response File
//
void FindResponseFile (void)
{
}
//
// D_DoomMain
//
void D_DoomMain (void)
{
int p;
char file[256];
FindResponseFile ();
IdentifyVersion ();
setbuf (stdout, NULL);
::g->modifiedgame = false;
// TODO: Networking
//const bool isDeathmatch = gameLocal->GetMatchParms().GetGameType() == GAME_TYPE_PVP;
const bool isDeathmatch = false;
::g->nomonsters = M_CheckParm ("-nomonsters") || isDeathmatch;
::g->respawnparm = M_CheckParm ("-respawn");
::g->fastparm = M_CheckParm ("-fast");
::g->devparm = M_CheckParm ("-devparm");
if (M_CheckParm ("-altdeath") || isDeathmatch)
::g->deathmatch = 2;
else if (M_CheckParm ("-deathmatch"))
::g->deathmatch = 1;
switch ( ::g->gamemode )
{
case retail:
sprintf (::g->title,
" "
"The Ultimate DOOM Startup v%i.%i"
" ",
VERSION/100,VERSION%100);
break;
case shareware:
sprintf (::g->title,
" "
"DOOM Shareware Startup v%i.%i"
" ",
VERSION/100,VERSION%100);
break;
case registered:
sprintf (::g->title,
" "
"DOOM Registered Startup v%i.%i"
" ",
VERSION/100,VERSION%100);
break;
case commercial:
sprintf (::g->title,
" "
"DOOM 2: Hell on Earth v%i.%i"
" ",
VERSION/100,VERSION%100);
break;
default:
sprintf (::g->title,
" "
"Public DOOM - v%i.%i"
" ",
VERSION/100,VERSION%100);
break;
}
I_Printf ("%s\n",::g->title);
if (::g->devparm)
I_Printf(D_DEVSTR);
if (M_CheckParm("-cdrom"))
{
I_Printf(D_CDROM);
//c++ mkdir("c:\\doomdata",0);
strcpy (::g->basedefault,"c:/doomdata/default.cfg");
}
// add any files specified on the command line with -file ::g->wadfile
// to the wad list
//
p = M_CheckParm ("-file");
if (p)
{
// the parms after p are ::g->wadfile/lump names,
// until end of parms or another - preceded parm
::g->modifiedgame = true; // homebrew levels
while (++p != ::g->myargc && ::g->myargv[p][0] != '-')
D_AddFile (::g->myargv[p]);
}
p = M_CheckParm ("-playdemo");
if (!p)
p = M_CheckParm ("-timedemo");
if (p && p < ::g->myargc-1)
{
sprintf (file,"d:\\%s.lmp", ::g->myargv[p+1]);
D_AddFile (file);
I_Printf("Playing demo %s.lmp.\n",::g->myargv[p+1]);
}
// get skill / episode / map from defaults
::g->startskill = sk_medium;
::g->startepisode = 1;
::g->startmap = 1;
::g->autostart = false;
if ( DoomLib::matchParms.gameEpisode != GAME_EPISODE_UNKNOWN ) {
::g->startepisode = DoomLib::matchParms.gameEpisode;
::g->autostart = 1;
}
if ( DoomLib::matchParms.gameMap != -1 ) {
::g->startmap = DoomLib::matchParms.gameMap;
::g->autostart = 1;
}
if ( DoomLib::matchParms.gameSkill != -1) {
::g->startskill = (skill_t)DoomLib::matchParms.gameSkill;
}
// get skill / episode / map from cmdline
p = M_CheckParm ("-skill");
if (p && p < ::g->myargc-1)
{
::g->startskill = (skill_t)(::g->myargv[p+1][0]-'1');
::g->autostart = true;
}
p = M_CheckParm ("-episode");
if (p && p < ::g->myargc-1)
{
::g->startepisode = ::g->myargv[p+1][0]-'0';
::g->startmap = 1;
::g->autostart = true;
}
/*p = M_CheckParm ("-timer");
if (p && p < ::g->myargc-1 && ::g->deathmatch)
{*/
// TODO: Networking
//const int timeLimit = gameLocal->GetMatchParms().GetTimeLimit();
const int timeLimit = 0;
if (timeLimit != 0 && ::g->deathmatch)
{
int time;
//time = atoi(::g->myargv[p+1]);
time = timeLimit;
I_Printf("Levels will end after %d minute",time);
if (time>1)
I_Printf("s");
I_Printf(".\n");
}
p = M_CheckParm ("-avg");
if (p && p < ::g->myargc-1 && ::g->deathmatch)
I_Printf("Austin Virtual Gaming: Levels will end after 20 minutes\n");
p = M_CheckParm ("-warp");
if (p && p < ::g->myargc-1)
{
if (::g->gamemode == commercial)
::g->startmap = atoi (::g->myargv[p+1]);
else
{
::g->startepisode = ::g->myargv[p+1][0]-'0';
::g->startmap = ::g->myargv[p+2][0]-'0';
}
::g->autostart = true;
}
I_Printf ("Z_Init: Init zone memory allocation daemon. \n");
Z_Init ();
// init subsystems
I_Printf ("V_Init: allocate ::g->screens.\n");
V_Init ();
I_Printf ("M_LoadDefaults: Load system defaults.\n");
M_LoadDefaults (); // load before initing other systems
I_Printf ("W_Init: Init WADfiles.\n");
W_InitMultipleFiles (wadfiles);
// Check for -file in shareware
if (::g->modifiedgame)
{
// These are the lumps that will be checked in IWAD,
// if any one is not present, execution will be aborted.
char name[23][16]=
{
"e2m1","e2m2","e2m3","e2m4","e2m5","e2m6","e2m7","e2m8","e2m9",
"e3m1","e3m3","e3m3","e3m4","e3m5","e3m6","e3m7","e3m8","e3m9",
"dphoof","bfgga0","heada1","cybra1","spida1d1"
};
int i;
if ( ::g->gamemode == shareware)
I_Error("\nYou cannot -file with the shareware "
"version. Register!");
// Check for fake IWAD with right name,
// but w/o all the lumps of the registered version.
if (::g->gamemode == registered)
for (i = 0;i < 23; i++)
if (W_CheckNumForName(name[i])<0)
I_Error("\nThis is not the registered version.");
}
// Iff additonal PWAD files are used, print modified banner
if (::g->modifiedgame)
{
/*m*/I_Printf (
"===========================================================================\n"
"ATTENTION: This version of DOOM has been modified. If you would like to\n"
"get a copy of the original game, call 1-800-IDGAMES or see the readme file.\n"
" You will not receive technical support for modified games.\n"
" press enter to continue\n"
"===========================================================================\n"
);
getchar ();
}
// Check and print which version is executed.
switch ( ::g->gamemode )
{
case shareware:
case indetermined:
I_Printf (
"===========================================================================\n"
" Shareware!\n"
"===========================================================================\n"
);
break;
case registered:
case retail:
case commercial:
I_Printf (
"===========================================================================\n"
" Commercial product - do not distribute!\n"
" Please report software piracy to the SPA: 1-800-388-PIR8\n"
"===========================================================================\n"
);
break;
default:
// Ouch.
break;
}
I_Printf ("M_Init: Init miscellaneous info.\n");
M_Init ();
I_Printf ("R_Init: Init DOOM refresh daemon - ");
R_Init ();
I_Printf ("\nP_Init: Init Playloop state.\n");
P_Init ();
I_Printf ("I_Init: Setting up machine state.\n");
I_Init ();
I_Printf ("D_CheckNetGame: Checking network game status.\n");
D_CheckNetGame ();
}
bool D_DoomMainPoll(void)
{
int p;
char file[256];
if (D_PollNetworkStart() == false)
return false;
I_Printf( "S_Init: Setting up sound.\n" );
S_Init( s_volume_sound.GetInteger(), s_volume_midi.GetInteger() );
I_Printf ("HU_Init: Setting up heads up display.\n");
HU_Init ();
I_Printf ("ST_Init: Init status bar.\n");
ST_Init ();
// start the apropriate game based on parms
p = M_CheckParm ("-record");
if (p && p < ::g->myargc-1)
{
G_RecordDemo (::g->myargv[p+1]);
::g->autostart = true;
}
p = M_CheckParm ("-playdemo");
if (p && p < ::g->myargc-1)
{
//::g->singledemo = true; // quit after one demo
G_DeferedPlayDemo (::g->myargv[p+1]);
//D_DoomLoop (); // never returns
}
p = M_CheckParm ("-timedemo");
if (p && p < ::g->myargc-1)
{
G_TimeDemo ("nukage1");//::g->myargv[p+1]);
D_DoomLoop (); // never returns
}
p = M_CheckParm ("-loadgame");
if (p && p < ::g->myargc-1)
{
if (M_CheckParm("-cdrom"))
sprintf(file, "c:\\doomdata\\"SAVEGAMENAME"%c.dsg",::g->myargv[p+1][0]);
else
sprintf(file, SAVEGAMENAME"%c.dsg",::g->myargv[p+1][0]);
G_LoadGame (file);
}
if ( ::g->gameaction != ga_loadgame && ::g->gameaction != ga_playdemo )
{
if (::g->autostart || ::g->netgame ) {
G_InitNew (::g->startskill, ::g->startepisode, ::g->startmap );
} else if( ::g->gameaction != ga_newgame) {
D_StartTitle (); // start up intro loop
}
}
return true;
}

75
doomclassic/doom/d_main.h Normal file
View File

@@ -0,0 +1,75 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __D_MAIN__
#define __D_MAIN__
#include "d_event.h"
#ifdef __GNUG__
#pragma interface
#endif
extern const char* extraWad;
#define MAXWADFILES 20
extern const char* wadfiles[MAXWADFILES];
void D_AddExtraWadFile( const char *file );
void D_AddFile ( const char *file);
//
// D_DoomMain()
// Not a globally visible function, just included for source reference,
// calls all startup code, parses command line options.
// If not overrided by user input, calls N_AdvanceDemo.
//
void D_DoomMain (void);
// Called by IO functions when input is detected.
void D_PostEvent (event_t* ev);
//
// BASE LEVEL
//
void D_PageTicker (void);
void D_PageDrawer (void);
void D_AdvanceDemo (void);
void D_StartTitle (void);
#define R_OK 0x01
#define X_OK 0x02
#define W_OK 0x04
int access(char* name, int val);
#endif

831
doomclassic/doom/d_net.cpp Normal file
View File

@@ -0,0 +1,831 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "m_menu.h"
#include "i_system.h"
#include "i_video.h"
#include "i_net.h"
#include "g_game.h"
#include "doomdef.h"
#include "doomstat.h"
#include "doomlib.h"
#include "Main.h"
#include "d3xp/Game_local.h"
void I_GetEvents( controller_t * );
void D_ProcessEvents (void);
void G_BuildTiccmd (ticcmd_t *cmd, idUserCmdMgr *, int newTics );
void D_DoAdvanceDemo (void);
extern bool globalNetworking;
//
// NETWORKING
//
// ::g->gametic is the tic about to (or currently being) run
// ::g->maketic is the tick that hasn't had control made for it yet
// ::g->nettics[] has the maketics for all ::g->players
//
// a ::g->gametic cannot be run until ::g->nettics[] > ::g->gametic for all ::g->players
//
#define NET_TIMEOUT 1 * TICRATE
//
//
//
int NetbufferSize (void)
{
int size = (int)&(((doomdata_t *)0)->cmds[::g->netbuffer->numtics]);
return size;
}
//
// Checksum
//
unsigned NetbufferChecksum (void)
{
unsigned c;
int i,l;
c = 0x1234567;
if ( globalNetworking ) {
l = (NetbufferSize () - (int)&(((doomdata_t *)0)->retransmitfrom))/4;
for (i=0 ; i<l ; i++)
c += ((unsigned *)&::g->netbuffer->retransmitfrom)[i] * (i+1);
}
return c & NCMD_CHECKSUM;
}
//
//
//
int ExpandTics (int low)
{
int delta;
delta = low - (::g->maketic&0xff);
if (delta >= -64 && delta <= 64)
return (::g->maketic&~0xff) + low;
if (delta > 64)
return (::g->maketic&~0xff) - 256 + low;
if (delta < -64)
return (::g->maketic&~0xff) + 256 + low;
I_Error ("ExpandTics: strange value %i at ::g->maketic %i",low,::g->maketic);
return 0;
}
//
// HSendPacket
//
void
HSendPacket
(int node,
int flags )
{
::g->netbuffer->checksum = NetbufferChecksum () | flags;
if (!node)
{
::g->reboundstore = *::g->netbuffer;
::g->reboundpacket = true;
return;
}
if (::g->demoplayback)
return;
if (!::g->netgame)
I_Error ("Tried to transmit to another node");
::g->doomcom.command = CMD_SEND;
::g->doomcom.remotenode = node;
::g->doomcom.datalength = NetbufferSize ();
if (::g->debugfile)
{
int i;
int realretrans;
if (::g->netbuffer->checksum & NCMD_RETRANSMIT)
realretrans = ExpandTics (::g->netbuffer->retransmitfrom);
else
realretrans = -1;
fprintf (::g->debugfile,"send (%i + %i, R %i) [%i] ",
ExpandTics(::g->netbuffer->starttic),
::g->netbuffer->numtics, realretrans, ::g->doomcom.datalength);
for (i=0 ; i < ::g->doomcom.datalength ; i++)
fprintf (::g->debugfile,"%i ",((byte *)::g->netbuffer)[i]);
fprintf (::g->debugfile,"\n");
}
I_NetCmd ();
}
//
// HGetPacket
// Returns false if no packet is waiting
//
qboolean HGetPacket (void)
{
if (::g->reboundpacket)
{
*::g->netbuffer = ::g->reboundstore;
::g->doomcom.remotenode = 0;
::g->reboundpacket = false;
return true;
}
if (!::g->netgame)
return false;
if (::g->demoplayback)
return false;
::g->doomcom.command = CMD_GET;
I_NetCmd ();
if (::g->doomcom.remotenode == -1)
return false;
if (::g->doomcom.datalength != NetbufferSize ())
{
if (::g->debugfile)
fprintf (::g->debugfile,"bad packet length %i\n",::g->doomcom.datalength);
return false;
}
// ALAN NETWORKING -- this fails a lot on 4 player split debug!!
// TODO: Networking
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
if ( !gameLocal->IsSplitscreen() && NetbufferChecksum() != (::g->netbuffer->checksum&NCMD_CHECKSUM) )
{
if (::g->debugfile) {
fprintf (::g->debugfile,"bad packet checksum\n");
}
return false;
}
#endif
if (::g->debugfile)
{
int realretrans;
int i;
if (::g->netbuffer->checksum & NCMD_SETUP)
fprintf (::g->debugfile,"setup packet\n");
else
{
if (::g->netbuffer->checksum & NCMD_RETRANSMIT)
realretrans = ExpandTics (::g->netbuffer->retransmitfrom);
else
realretrans = -1;
fprintf (::g->debugfile,"get %i = (%i + %i, R %i)[%i] ",
::g->doomcom.remotenode,
ExpandTics(::g->netbuffer->starttic),
::g->netbuffer->numtics, realretrans, ::g->doomcom.datalength);
for (i=0 ; i < ::g->doomcom.datalength ; i++)
fprintf (::g->debugfile,"%i ",((byte *)::g->netbuffer)[i]);
fprintf (::g->debugfile,"\n");
}
}
return true;
}
//
// GetPackets
//
void GetPackets (void)
{
int netconsole;
int netnode;
ticcmd_t *src, *dest;
int realend;
int realstart;
while ( HGetPacket() )
{
if (::g->netbuffer->checksum & NCMD_SETUP)
continue; // extra setup packet
netconsole = ::g->netbuffer->player & ~PL_DRONE;
netnode = ::g->doomcom.remotenode;
// to save bytes, only the low byte of tic numbers are sent
// Figure out what the rest of the bytes are
realstart = ExpandTics (::g->netbuffer->starttic);
realend = (realstart+::g->netbuffer->numtics);
// check for exiting the game
if (::g->netbuffer->checksum & NCMD_EXIT)
{
if (!::g->nodeingame[netnode])
continue;
::g->nodeingame[netnode] = false;
::g->playeringame[netconsole] = false;
strcpy (::g->exitmsg, "Player 1 left the game");
::g->exitmsg[7] += netconsole;
::g->players[::g->consoleplayer].message = ::g->exitmsg;
if( ::g->demorecording ) {
G_CheckDemoStatus();
}
continue;
}
// check for a remote game kill
/*
if (::g->netbuffer->checksum & NCMD_KILL)
I_Error ("Killed by network driver");
*/
::g->nodeforplayer[netconsole] = netnode;
// check for retransmit request
if ( ::g->resendcount[netnode] <= 0
&& (::g->netbuffer->checksum & NCMD_RETRANSMIT) )
{
::g->resendto[netnode] = ExpandTics(::g->netbuffer->retransmitfrom);
if (::g->debugfile)
fprintf (::g->debugfile,"retransmit from %i\n", ::g->resendto[netnode]);
::g->resendcount[netnode] = RESENDCOUNT;
}
else
::g->resendcount[netnode]--;
// check for out of order / duplicated packet
if (realend == ::g->nettics[netnode])
continue;
if (realend < ::g->nettics[netnode])
{
if (::g->debugfile)
fprintf (::g->debugfile,
"out of order packet (%i + %i)\n" ,
realstart,::g->netbuffer->numtics);
continue;
}
// check for a missed packet
if (realstart > ::g->nettics[netnode])
{
// stop processing until the other system resends the missed tics
if (::g->debugfile)
fprintf (::g->debugfile,
"missed tics from %i (%i - %i)\n",
netnode, realstart, ::g->nettics[netnode]);
::g->remoteresend[netnode] = true;
continue;
}
// update command store from the packet
{
int start;
::g->remoteresend[netnode] = false;
start = ::g->nettics[netnode] - realstart;
src = &::g->netbuffer->cmds[start];
while (::g->nettics[netnode] < realend)
{
dest = &::g->netcmds[netconsole][::g->nettics[netnode]%BACKUPTICS];
::g->nettics[netnode]++;
*dest = *src;
src++;
}
}
}
}
//
// NetUpdate
// Builds ticcmds for console player,
// sends out a packet
//
void NetUpdate ( idUserCmdMgr * userCmdMgr )
{
int nowtime;
int newtics;
int i,j;
int realstart;
int gameticdiv;
// check time
nowtime = I_GetTime ()/::g->ticdup;
newtics = nowtime - ::g->gametime;
::g->gametime = nowtime;
if (newtics <= 0) // nothing new to update
goto listen;
if (::g->skiptics <= newtics)
{
newtics -= ::g->skiptics;
::g->skiptics = 0;
}
else
{
::g->skiptics -= newtics;
newtics = 0;
}
::g->netbuffer->player = ::g->consoleplayer;
// build new ticcmds for console player
gameticdiv = ::g->gametic/::g->ticdup;
for (i=0 ; i<newtics ; i++)
{
//I_GetEvents( ::g->I_StartTicCallback () );
D_ProcessEvents ();
if (::g->maketic - gameticdiv >= BACKUPTICS/2-1) {
printf( "Out of room for ticcmds: maketic = %d, gameticdiv = %d\n", ::g->maketic, gameticdiv );
break; // can't hold any more
}
//I_Printf ("mk:%i ",::g->maketic);
// Grab the latest tech5 command
G_BuildTiccmd (&::g->localcmds[::g->maketic%BACKUPTICS], userCmdMgr, newtics );
::g->maketic++;
}
if (::g->singletics)
return; // singletic update is syncronous
// send the packet to the other ::g->nodes
for (i=0 ; i < ::g->doomcom.numnodes ; i++) {
if (::g->nodeingame[i]) {
::g->netbuffer->starttic = realstart = ::g->resendto[i];
::g->netbuffer->numtics = ::g->maketic - realstart;
if (::g->netbuffer->numtics > BACKUPTICS)
I_Error ("NetUpdate: ::g->netbuffer->numtics > BACKUPTICS");
::g->resendto[i] = ::g->maketic - ::g->doomcom.extratics;
for (j=0 ; j< ::g->netbuffer->numtics ; j++)
::g->netbuffer->cmds[j] =
::g->localcmds[(realstart+j)%BACKUPTICS];
if (::g->remoteresend[i])
{
::g->netbuffer->retransmitfrom = ::g->nettics[i];
HSendPacket (i, NCMD_RETRANSMIT);
}
else
{
::g->netbuffer->retransmitfrom = 0;
HSendPacket (i, 0);
}
}
}
// listen for other packets
listen:
GetPackets ();
}
//
// CheckAbort
//
void CheckAbort (void)
{
// DHM - Time starts at 0 tics when starting a multiplayer game, so we can
// check for timeouts easily. If we're still waiting after N seconds, abort.
if ( I_GetTime() > NET_TIMEOUT ) {
// TOOD: Show error & leave net game.
printf( "NET GAME TIMED OUT!\n" );
//gameLocal->showFatalErrorMessage( XuiLookupStringTable(globalStrings,L"Timed out waiting for match start.") );
D_QuitNetGame();
session->QuitMatch();
common->Dialog().AddDialog( GDM_OPPONENT_CONNECTION_LOST, DIALOG_ACCEPT, NULL, NULL, false );
}
}
//
// D_ArbitrateNetStart
//
bool D_ArbitrateNetStart (void)
{
int i;
::g->autostart = true;
if (::g->doomcom.consoleplayer)
{
// listen for setup info from key player
CheckAbort ();
if (!HGetPacket ())
return false;
if (::g->netbuffer->checksum & NCMD_SETUP)
{
printf( "Received setup info\n" );
if (::g->netbuffer->player != VERSION)
I_Error ("Different DOOM versions cannot play a net game!");
::g->startskill = (skill_t)(::g->netbuffer->retransmitfrom & 15);
::g->deathmatch = (::g->netbuffer->retransmitfrom & 0xc0) >> 6;
::g->nomonsters = (::g->netbuffer->retransmitfrom & 0x20) > 0;
::g->respawnparm = (::g->netbuffer->retransmitfrom & 0x10) > 0;
// VV original xbox doom :: don't do this.. it will be setup from the launcher
//::g->startmap = ::g->netbuffer->starttic & 0x3f;
//::g->startepisode = ::g->netbuffer->starttic >> 6;
return true;
}
return false;
}
else
{
// key player, send the setup info
CheckAbort ();
for (i=0 ; i < ::g->doomcom.numnodes ; i++)
{
printf( "Sending setup info to node %d\n", i );
::g->netbuffer->retransmitfrom = ::g->startskill;
if (::g->deathmatch)
::g->netbuffer->retransmitfrom |= (::g->deathmatch<<6);
if (::g->nomonsters)
::g->netbuffer->retransmitfrom |= 0x20;
if (::g->respawnparm)
::g->netbuffer->retransmitfrom |= 0x10;
::g->netbuffer->starttic = ::g->startepisode * 64 + ::g->startmap;
::g->netbuffer->player = VERSION;
::g->netbuffer->numtics = 0;
HSendPacket (i, NCMD_SETUP);
}
while (HGetPacket ())
{
::g->gotinfo[::g->netbuffer->player&0x7f] = true;
}
for (i=1 ; i < ::g->doomcom.numnodes ; i++) {
if (!::g->gotinfo[i])
break;
}
if (i >= ::g->doomcom.numnodes)
return true;
return false;
}
}
//
// D_CheckNetGame
// Works out player numbers among the net participants
//
void D_CheckNetGame (void)
{
int i;
for (i=0 ; i<MAXNETNODES ; i++)
{
::g->nodeingame[i] = false;
::g->nettics[i] = 0;
::g->remoteresend[i] = false; // set when local needs tics
::g->resendto[i] = 0; // which tic to start sending
}
// I_InitNetwork sets ::g->doomcom and ::g->netgame
I_InitNetwork ();
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
if (::g->doomcom.id != DOOMCOM_ID)
I_Error ("Doomcom buffer invalid!");
#endif
::g->netbuffer = &::g->doomcom.data;
::g->consoleplayer = ::g->displayplayer = ::g->doomcom.consoleplayer;
}
bool D_PollNetworkStart()
{
int i;
if (::g->netgame)
{
if (D_ArbitrateNetStart () == false)
return false;
}
I_Printf ("startskill %i deathmatch: %i startmap: %i startepisode: %i\n",
::g->startskill, ::g->deathmatch, ::g->startmap, ::g->startepisode);
// read values out of ::g->doomcom
::g->ticdup = ::g->doomcom.ticdup;
::g->maxsend = BACKUPTICS/(2*::g->ticdup)-1;
if (::g->maxsend<1)
::g->maxsend = 1;
for (i=0 ; i < ::g->doomcom.numplayers ; i++)
::g->playeringame[i] = true;
for (i=0 ; i < ::g->doomcom.numnodes ; i++)
::g->nodeingame[i] = true;
I_Printf ("player %i of %i (%i ::g->nodes)\n",
::g->consoleplayer+1, ::g->doomcom.numplayers, ::g->doomcom.numnodes);
return true;
}
//
// D_QuitNetGame
// Called before quitting to leave a net game
// without hanging the other ::g->players
//
void D_QuitNetGame (void)
{
int i;
if ( (!::g->netgame && !::g->usergame) || ::g->consoleplayer == -1 || ::g->demoplayback || ::g->netbuffer == NULL )
return;
// send a quit packet to the other nodes
::g->netbuffer->player = ::g->consoleplayer;
::g->netbuffer->numtics = 0;
for ( i=1; i < ::g->doomcom.numnodes; i++ ) {
if ( ::g->nodeingame[i] ) {
HSendPacket( i, NCMD_EXIT );
}
}
DoomLib::SendNetwork();
for (i=1 ; i<MAXNETNODES ; i++)
{
::g->nodeingame[i] = false;
::g->nettics[i] = 0;
::g->remoteresend[i] = false; // set when local needs tics
::g->resendto[i] = 0; // which tic to start sending
}
//memset (&::g->doomcom, 0, sizeof(::g->doomcom) );
// Reset singleplayer state
::g->doomcom.id = DOOMCOM_ID;
::g->doomcom.ticdup = 1;
::g->doomcom.extratics = 0;
::g->doomcom.numplayers = ::g->doomcom.numnodes = 1;
::g->doomcom.deathmatch = false;
::g->doomcom.consoleplayer = 0;
::g->netgame = false;
::g->netbuffer = &::g->doomcom.data;
::g->consoleplayer = ::g->displayplayer = ::g->doomcom.consoleplayer;
::g->ticdup = ::g->doomcom.ticdup;
::g->maxsend = BACKUPTICS/(2*::g->ticdup)-1;
if (::g->maxsend<1)
::g->maxsend = 1;
for (i=0 ; i < ::g->doomcom.numplayers ; i++)
::g->playeringame[i] = true;
for (i=0 ; i < ::g->doomcom.numnodes ; i++)
::g->nodeingame[i] = true;
}
//
// TryRunTics
//
bool TryRunTics ( idUserCmdMgr * userCmdMgr )
{
int i;
int lowtic_node = -1;
// get real tics
::g->trt_entertic = I_GetTime ()/::g->ticdup;
::g->trt_realtics = ::g->trt_entertic - ::g->oldtrt_entertics;
::g->oldtrt_entertics = ::g->trt_entertic;
// get available tics
NetUpdate ( userCmdMgr );
::g->trt_lowtic = MAXINT;
::g->trt_numplaying = 0;
for (i=0 ; i < ::g->doomcom.numnodes ; i++) {
if (::g->nodeingame[i]) {
::g->trt_numplaying++;
if (::g->nettics[i] < ::g->trt_lowtic) {
::g->trt_lowtic = ::g->nettics[i];
lowtic_node = i;
}
}
}
::g->trt_availabletics = ::g->trt_lowtic - ::g->gametic/::g->ticdup;
// decide how many tics to run
if (::g->trt_realtics < ::g->trt_availabletics-1) {
::g->trt_counts = ::g->trt_realtics+1;
} else if (::g->trt_realtics < ::g->trt_availabletics) {
::g->trt_counts = ::g->trt_realtics;
} else {
::g->trt_counts = ::g->trt_availabletics;
}
if (::g->trt_counts < 1) {
::g->trt_counts = 1;
}
::g->frameon++;
if (::g->debugfile) {
fprintf (::g->debugfile, "=======real: %i avail: %i game: %i\n", ::g->trt_realtics, ::g->trt_availabletics,::g->trt_counts);
}
if ( !::g->demoplayback )
{
// ideally ::g->nettics[0] should be 1 - 3 tics above ::g->trt_lowtic
// if we are consistantly slower, speed up time
for (i=0 ; i<MAXPLAYERS ; i++) {
if (::g->playeringame[i]) {
break;
}
}
if (::g->consoleplayer == i) {
// the key player does not adapt
}
else {
if (::g->nettics[0] <= ::g->nettics[::g->nodeforplayer[i]]) {
::g->gametime--;
//OutputDebugString("-");
}
::g->frameskip[::g->frameon&3] = (::g->oldnettics > ::g->nettics[::g->nodeforplayer[i]]);
::g->oldnettics = ::g->nettics[0];
if (::g->frameskip[0] && ::g->frameskip[1] && ::g->frameskip[2] && ::g->frameskip[3]) {
::g->skiptics = 1;
//OutputDebugString("+");
}
}
}
// wait for new tics if needed
if (::g->trt_lowtic < ::g->gametic/::g->ticdup + ::g->trt_counts)
{
int lagtime = 0;
if (::g->trt_lowtic < ::g->gametic/::g->ticdup) {
I_Error ("TryRunTics: ::g->trt_lowtic < gametic");
}
if ( ::g->lastnettic == 0 ) {
::g->lastnettic = ::g->trt_entertic;
}
lagtime = ::g->trt_entertic - ::g->lastnettic;
// Detect if a client has stopped sending updates, remove them from the game after 5 secs.
if ( common->IsMultiplayer() && (!::g->demoplayback && ::g->netgame) && lagtime >= TICRATE ) {
if ( lagtime > NET_TIMEOUT ) {
if ( lowtic_node == ::g->nodeforplayer[::g->consoleplayer] ) {
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
#ifndef __PS3__
gameLocal->showFatalErrorMessage( XuiLookupStringTable(globalStrings,L"You have been disconnected from the match.") );
gameLocal->Interface.QuitCurrentGame();
#endif
#endif
} else {
if (::g->nodeingame[lowtic_node]) {
int i, consoleNum = lowtic_node;
for ( i=0; i < ::g->doomcom.numnodes; i++ ) {
if ( ::g->nodeforplayer[i] == lowtic_node ) {
consoleNum = i;
break;
}
}
::g->nodeingame[lowtic_node] = false;
::g->playeringame[consoleNum] = false;
strcpy (::g->exitmsg, "Player 1 left the game");
::g->exitmsg[7] += consoleNum;
::g->players[::g->consoleplayer].message = ::g->exitmsg;
// Stop a demo record now, as playback doesn't support losing players
G_CheckDemoStatus();
}
}
}
}
return false;
}
::g->lastnettic = 0;
// run the count * ::g->ticdup dics
while (::g->trt_counts--)
{
for (i=0 ; i < ::g->ticdup ; i++)
{
if (::g->gametic/::g->ticdup > ::g->trt_lowtic) {
I_Error ("gametic(%d) greater than trt_lowtic(%d), trt_counts(%d)", ::g->gametic, ::g->trt_lowtic, ::g->trt_counts );
return false;
}
if (::g->advancedemo) {
D_DoAdvanceDemo ();
}
M_Ticker ();
G_Ticker ();
::g->gametic++;
// modify command for duplicated tics
if (i != ::g->ticdup-1)
{
ticcmd_t *cmd;
int buf;
int j;
buf = (::g->gametic/::g->ticdup)%BACKUPTICS;
for (j=0 ; j<MAXPLAYERS ; j++)
{
cmd = &::g->netcmds[j][buf];
if (cmd->buttons & BT_SPECIAL)
cmd->buttons = 0;
}
}
}
NetUpdate ( userCmdMgr ); // check for new console commands
}
return true;
}

154
doomclassic/doom/d_net.h Normal file
View File

@@ -0,0 +1,154 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __D_NET__
#define __D_NET__
#include "d_player.h"
#ifdef __GNUG__
#pragma interface
#endif
//
// Network play related stuff.
// There is a data struct that stores network
// communication related stuff, and another
// one that defines the actual packets to
// be transmitted.
//
#define DOOMCOM_ID 0x12345678l
// Max computers/players in a game.
#define MAXNETNODES 8
// Networking and tick handling related.
#define BACKUPTICS 64
typedef enum
{
CMD_SEND = 1,
CMD_GET = 2
} command_t;
//
// Network packet data.
//
typedef struct
{
// High bit is retransmit request.
unsigned checksum;
// Only valid if NCMD_RETRANSMIT.
byte retransmitfrom;
byte sourceDest;
byte starttic;
byte player;
byte numtics;
ticcmd_t cmds[BACKUPTICS];
} doomdata_t;
struct doomcom_t
{
// Supposed to be DOOMCOM_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.
// Console is allways node 0.
short numnodes;
// Flag: 1 = no duplication, 2-5 = dup for slow nets.
short ticdup;
// Flag: 1 = send a backup tic in every packet.
short extratics;
// 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.
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;
} ;
class idUserCmdMgr;
// Create any new ticcmds and broadcast to other players.
void NetUpdate ( idUserCmdMgr * userCmdMgr );
// Broadcasts special packets to other players
// to notify of game exit
void D_QuitNetGame (void);
//? how many ticks to run?
bool TryRunTics (void);
#endif

228
doomclassic/doom/d_player.h Normal file
View File

@@ -0,0 +1,228 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __D_PLAYER__
#define __D_PLAYER__
// The player data structure depends on a number
// of other structs: items (internal inventory),
// animation states (closely tied to the sprites
// used to represent them, unfortunately).
#include "d_items.h"
#include "p_pspr.h"
// In addition, the player is just a special
// case of the generic moving object/actor.
#include "p_mobj.h"
// Finally, for odd reasons, the player input
// is buffered within the player data struct,
// as commands per game tick.
#include "d_ticcmd.h"
#ifdef __GNUG__
#pragma interface
#endif
//
// Player states.
//
typedef enum
{
// Playing or camping.
PST_LIVE,
// Dead on the ground, view follows killer.
PST_DEAD,
// Ready to restart/respawn???
PST_REBORN
} playerstate_t;
//
// Player internal flags, for cheats and debug.
//
typedef enum
{
// No clipping, walk through barriers.
CF_NOCLIP = 1,
// No damage, no health loss.
CF_GODMODE = 2,
// Not really a cheat, just a debug aid.
CF_NOMOMENTUM = 4,
// Gives kfa at the beginning of the level.
CF_GIVEALL = 8,
CF_INFAMMO = 16,
} cheat_t;
//
// Extended player object info: player_t
//
typedef struct player_s
{
mobj_t* mo;
playerstate_t playerstate;
ticcmd_t cmd;
// Determine POV,
// including viewpoint bobbing during movement.
// Focal origin above r.z
fixed_t viewz;
// Base height above floor for viewz.
fixed_t viewheight;
// Bob/squat speed.
fixed_t deltaviewheight;
// bounded/scaled total momentum.
fixed_t bob;
// This is only used between levels,
// mo->health is used during levels.
int health;
int armorpoints;
// Armor type is 0-2.
int armortype;
// Power ups. invinc and invis are tic counters.
int powers[NUMPOWERS];
qboolean cards[NUMCARDS];
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];
int ammo[NUMAMMO];
int maxammo[NUMAMMO];
// True if button down last tic.
int attackdown;
int usedown;
// Bit flags, for cheats and debug.
// See cheat_t, above.
int cheats;
// Refired shots are less accurate.
int refire;
// For intermission stats.
int killcount;
int itemcount;
int secretcount;
int chainsawKills;
int berserkKills;
// Hint messages.
const char* message;
// For screen flashing (red or bright).
int damagecount;
int bonuscount;
// Who did damage (NULL for floors/ceilings).
mobj_t* attacker;
// So gun flashes light up areas.
int extralight;
// Current PLAYPAL, ???
// can be set to REDCOLORMAP for pain, etc.
int fixedcolormap;
// Player skin colorshift,
// 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;
//
// INTERMISSION
// Structure passed e.g. to WI_Start(wb)
//
typedef struct
{
qboolean in; // whether the player is in game
// Player stats, kills, collected items etc.
int skills;
int sitems;
int ssecret;
int stime;
int frags[4];
int score; // current score on entry, modified on return
} wbplayerstruct_t;
typedef struct
{
int epsd; // episode # (0-2)
// if true, splash the secret level
qboolean didsecret;
// previous and next levels, origin 0
int last;
int next;
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;
#endif

View File

@@ -0,0 +1,52 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __D_TEXTUR__
#define __D_TEXTUR__
#include "doomtype.h"
//
// Flats?
//
// a pic is an unmasked block of pixels
typedef struct
{
byte width;
byte height;
byte data;
} pic_t;
#endif

View File

@@ -0,0 +1,78 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __D_THINK__
#define __D_THINK__
#ifdef __GNUG__
#pragma interface
#endif
//
// Experimental stuff.
// To compile this as "ANSI C with classes"
// we will need to handle the various
// action functions cleanly.
//
struct mobj_t;
typedef void (*actionf_v)();
typedef void (*actionf_p1)( mobj_t* );
typedef void (*actionf_p2)( void*, void* );
typedef union
{
actionf_p1 acp1;
actionf_v acv;
actionf_p2 acp2;
} actionf_t;
// Historically, "think_t" is yet another
// function pointer to a routine to handle
// an actor.
typedef actionf_t think_t;
// Doubly linked list of actors.
typedef struct thinker_s
{
struct thinker_s* prev;
struct thinker_s* next;
think_t function;
} thinker_t;
#endif

View File

@@ -0,0 +1,55 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __D_TICCMD__
#define __D_TICCMD__
#include "doomtype.h"
#ifdef __GNUG__
#pragma interface
#endif
// The data sampled per tick (single player)
// and transmitted to other peers (multiplayer).
// Mainly movements/button commands per game tick,
// plus a checksum for internal state consistency.
typedef struct
{
char forwardmove; // *2048 for move
char sidemove; // *2048 for move
short angleturn; // <<16 for angle delta
short consistancy; // checks for net game
byte buttons;
byte nextPrevWeapon;
} ticcmd_t;
#endif

442
doomclassic/doom/defs.h Normal file
View File

@@ -0,0 +1,442 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
// am_map.defs begin //
#define REDS (256-5*16)
#define REDRANGE 16
#define BLUES (256-4*16+8)
#define BLUERANGE 8
#define GREENS (7*16)
#define GREENRANGE 16
#define GRAYS (6*16)
#define GRAYSRANGE 16
#define BROWNS (4*16)
#define BROWNRANGE 16
#define YELLOWS (256-32+7)
#define YELLOWRANGE 1
#define BLACK 0
#define WHITE (256-47)
#define BACKGROUND BLACK
#define YOURCOLORS WHITE
#define YOURRANGE 0
#define WALLCOLORS REDS
#define WALLRANGE REDRANGE
#define TSWALLCOLORS GRAYS
#define TSWALLRANGE GRAYSRANGE
#define FDWALLCOLORS BROWNS
#define FDWALLRANGE BROWNRANGE
#define CDWALLCOLORS YELLOWS
#define CDWALLRANGE YELLOWRANGE
#define THINGCOLORS GREENS
#define THINGRANGE GREENRANGE
#define SECRETWALLCOLORS WALLCOLORS
#define SECRETWALLRANGE WALLRANGE
#define GRIDCOLORS (GRAYS + GRAYSRANGE/2)
#define GRIDRANGE 0
#define XHAIRCOLORS GRAYS
#define FB 0
#define AM_PANDOWNKEY KEY_DOWNARROW
#define AM_PANUPKEY KEY_UPARROW
#define AM_PANRIGHTKEY KEY_RIGHTARROW
#define AM_PANLEFTKEY KEY_LEFTARROW
#define AM_ZOOMINKEY K_EQUALS
#define AM_ZOOMOUTKEY K_MINUS
#define AM_STARTKEY KEY_TAB
#define AM_ENDKEY KEY_TAB
#define AM_GOBIGKEY K_0
#define AM_FOLLOWKEY K_F
#define AM_GRIDKEY K_G
#define AM_MARKKEY K_M
#define AM_CLEARMARKKEY K_C
#define AM_NUMMARKPOINTS 10
#define INITSCALEMTOF (.2*FRACUNIT)
#define F_PANINC 4
#define M_ZOOMIN ((int) (1.02*FRACUNIT))
#define M_ZOOMOUT ((int) (FRACUNIT/1.02))
#define FTOM(x) FixedMul(((x)<<16),::g->scale_ftom)
#define MTOF(x) (FixedMul((x),::g->scale_mtof)>>16)
#define CXMTOF(x) (::g->f_x + MTOF((x)-::g->m_x))
#define CYMTOF(y) (::g->f_y + (::g->f_h - MTOF((y)-::g->m_y)))
#define LINE_NEVERSEE ML_DONTDRAW
#define NUMPLYRLINES (sizeof(player_arrow)/sizeof(mline_t))
#define NUMCHEATPLYRLINES (sizeof(cheat_player_arrow)/sizeof(mline_t))
#define NUMTRIANGLEGUYLINES (sizeof(triangle_guy)/sizeof(mline_t))
#define NUMTHINTRIANGLEGUYLINES (sizeof(thintriangle_guy)/sizeof(mline_t))
#define DOOUTCODE(oc, mx, my) \
(oc) = 0; \
if ((my) < 0) (oc) |= TOP; \
else if ((my) >= ::g->f_h) (oc) |= BOTTOM; \
if ((mx) < 0) (oc) |= LEFT; \
else if ((mx) >= ::g->f_w) (oc) |= RIGHT;
#define PUTDOT(xx,yy,cc) ::g->fb[(yy)*::g->f_w+(xx)]=(cc)
// am_map.defs end //
// d_main.defs begin //
#define BGCOLOR 7
#define FGCOLOR 8
#define DOOMWADDIR "wads/"
// d_main.defs end //
// d_net.defs begin //
#define NCMD_EXIT 0x80000000
#define NCMD_RETRANSMIT 0x40000000
#define NCMD_SETUP 0x20000000
#define NCMD_KILL 0x10000000 // kill game
#define NCMD_CHECKSUM 0x0fffffff
#define RESENDCOUNT 10
#define PL_DRONE 0x80 // bit flag in doomdata->player
// d_net.defs end //
// f_finale.defs begin //
#define TEXTSPEED 3
#define TEXTWAIT 250
// f_finale.defs end //
// g_game.defs begin //
#define SAVESTRINGSIZE 64
#define MAXPLMOVE (::g->forwardmove[1])
#define TURBOTHRESHOLD 0x32
#define SLOWTURNTICS 6
#define NUMKEYS 256
#define BODYQUESIZE 32
#define VERSIONSIZE 16
#define DEMOMARKER 0x80
// g_game.defs end //
// hu_lib.defs begin //
#define noterased ::g->viewwindowx
// hu_lib.defs end //
// hu_stuff.defs begin //
#define HU_TITLE (mapnames[(::g->gameepisode-1)*9+::g->gamemap-1])
#define HU_TITLE2 (mapnames2[::g->gamemap-1])
#define HU_TITLEP (mapnamesp[::g->gamemap-1])
#define HU_TITLET (mapnamest[::g->gamemap-1])
#define HU_TITLEHEIGHT 1
#define HU_TITLEX 0
#define HU_TITLEY (167 - SHORT(::g->hu_font[0]->height))
#define HU_INPUTTOGGLE K_T
#define HU_INPUTX HU_MSGX
#define HU_INPUTY (HU_MSGY + HU_MSGHEIGHT*(SHORT(::g->hu_font[0]->height) +1))
#define HU_INPUTWIDTH 64
#define HU_INPUTHEIGHT 1
#define QUEUESIZE 128
// hu_stuff.defs end //
// i_net.defs begin //
// SMF
/*
#define ntohl(x) \
((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
(((unsigned long int)(x) & 0x0000ff00U) << 8) | \
(((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
(((unsigned long int)(x) & 0xff000000U) >> 24)))
#define ntohs(x) \
((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
(((unsigned short int)(x) & 0xff00) >> 8))) \
#define htonl(x) ntohl(x)
#define htons(x) ntohs(x)
// i_net.defs end //
// i_net_xbox.defs begin //
#define ntohl(x) \
((unsigned long int)((((unsigned long int)(x) & 0x000000ffU) << 24) | \
(((unsigned long int)(x) & 0x0000ff00U) << 8) | \
(((unsigned long int)(x) & 0x00ff0000U) >> 8) | \
(((unsigned long int)(x) & 0xff000000U) >> 24)))
#define ntohs(x) \
((unsigned short int)((((unsigned short int)(x) & 0x00ff) << 8) | \
(((unsigned short int)(x) & 0xff00) >> 8))) \
#define htonl(x) ntohl(x)
#define htons(x) ntohs(x)
*/
#define IPPORT_USERRESERVED 5000
// i_net_xbox.defs end //
// i_sound_xbox.defs begin //
#define SAMPLECOUNT 512
#define NUM_SOUNDBUFFERS 64
#define BUFMUL 4
#define MIXBUFFERSIZE (SAMPLECOUNT*BUFMUL)
// i_sound_xbox.defs end //
// i_video_xbox.defs begin //
//#define TEXTUREWIDTH 512
//#define TEXTUREHEIGHT 256
// i_video_xbox.defs end //
// mus2midi.defs begin //
#define MUSEVENT_KEYOFF 0
#define MUSEVENT_KEYON 1
#define MUSEVENT_PITCHWHEEL 2
#define MUSEVENT_CHANNELMODE 3
#define MUSEVENT_CONTROLLERCHANGE 4
#define MUSEVENT_END 6
#define MIDI_MAXCHANNELS 16
#define MIDIHEADERSIZE 14
// mus2midi.defs end //
// m_menu.defs begin //
#define SAVESTRINGSIZE 64
#define SKULLXOFF -32
#define LINEHEIGHT 16
// m_menu.defs end //
// p_enemy.defs begin //
#define MAXSPECIALCROSS 8
#define FATSPREAD (ANG90/8)
#define SKULLSPEED (20*FRACUNIT)
// p_enemy.defs end //
// p_inter.defs begin //
#define BONUSADD 6
// p_inter.defs end //
// p_map.defs begin //
#define MAXSPECIALCROSS 8
// p_map.defs end //
// p_mobj.defs begin //
#define STOPSPEED 0x1000
#define FRICTION 0xe800
// p_mobj.defs end //
// p_pspr.defs begin //
#define LOWERSPEED FRACUNIT*6
#define RAISESPEED FRACUNIT*6
#define WEAPONBOTTOM 128*FRACUNIT
#define WEAPONTOP 32*FRACUNIT
#define BFGCELLS 40
// p_pspr.defs end //
// p_saveg.defs begin //
#define PADSAVEP() ::g->save_p += (4 - ((int) ::g->save_p & 3)) & 3
// p_saveg.defs end //
// p_setup.defs begin //
#define MAX_DEATHMATCH_STARTS 10
// p_setup.defs end //
// p_spec.defs begin //
#define MAXANIMS 32
#define MAXLINEANIMS 64
#define MAX_ADJOINING_SECTORS 20
// p_spec.defs end //
// p_user.defs begin //
#define INVERSECOLORMAP 32
// DHM - NERVE :: MAXBOB reduced 25%
//#define MAXBOB 0x100000
#define MAXBOB 0xC0000
#define ANG5 (ANG90/18)
// p_user.defs end //
// r_bsp.defs begin //
#define MAXSEGS 32
// r_bsp.defs end //
// r_draw.defs begin //
//#define MAXWIDTH 1120
//#define MAXHEIGHT 832
#define SBARHEIGHT 32 * GLOBAL_IMAGE_SCALER
#define FUZZTABLE 50
#define FUZZOFF (SCREENWIDTH)
// r_draw.defs end //
// r_main.defs begin //
#define FIELDOFVIEW 2048
#define DISTMAP 2
// r_main.defs end //
// r_plane.defs begin //
//#define MAXVISPLANES 128
#define MAXVISPLANES 384
#define MAXOPENINGS SCREENWIDTH*64
// r_plane.defs end //
// r_segs.defs begin //
#define HEIGHTBITS 12
#define HEIGHTUNIT (1<<HEIGHTBITS)
// r_segs.defs end //
// r_things.defs begin //
#define MINZ (FRACUNIT*4)
#define BASEYCENTER 100
// r_things.defs end //
// st_stuff.defs begin //
#define STARTREDPALS 1
#define STARTBONUSPALS 9
#define NUMREDPALS 8
#define NUMBONUSPALS 4
#define RADIATIONPAL 13
#define ST_FACEPROBABILITY 96
#define ST_TOGGLECHAT KEY_ENTER
#define ST_X 0
#define ST_X2 104
#define ST_FX 143
#define ST_FY 169
#define ST_TALLNUMWIDTH (::g->tallnum[0]->width)
#define ST_NUMPAINFACES 5
#define ST_NUMSTRAIGHTFACES 3
#define ST_NUMTURNFACES 2
#define ST_NUMSPECIALFACES 3
#define ST_FACESTRIDE \
(ST_NUMSTRAIGHTFACES+ST_NUMTURNFACES+ST_NUMSPECIALFACES)
#define ST_NUMEXTRAFACES 2
#define ST_NUMFACES \
(ST_FACESTRIDE*ST_NUMPAINFACES+ST_NUMEXTRAFACES)
#define ST_TURNOFFSET (ST_NUMSTRAIGHTFACES)
#define ST_OUCHOFFSET (ST_TURNOFFSET + ST_NUMTURNFACES)
#define ST_EVILGRINOFFSET (ST_OUCHOFFSET + 1)
#define ST_RAMPAGEOFFSET (ST_EVILGRINOFFSET + 1)
#define ST_GODFACE (ST_NUMPAINFACES*ST_FACESTRIDE)
#define ST_DEADFACE (ST_GODFACE+1)
#define ST_FACESX 143
#define ST_FACESY 168
#define ST_EVILGRINCOUNT (2*TICRATE)
#define ST_STRAIGHTFACECOUNT (TICRATE/2)
#define ST_TURNCOUNT (1*TICRATE)
#define ST_OUCHCOUNT (1*TICRATE)
#define ST_RAMPAGEDELAY (2*TICRATE)
#define ST_MUCHPAIN 20
#define ST_AMMOWIDTH 3
#define ST_AMMOX 44
#define ST_AMMOY 171
#define ST_HEALTHWIDTH 3
#define ST_HEALTHX 90
#define ST_HEALTHY 171
#define ST_ARMSX 111
#define ST_ARMSY 172
#define ST_ARMSBGX 104
#define ST_ARMSBGY 168
#define ST_ARMSXSPACE 12
#define ST_ARMSYSPACE 10
#define ST_FRAGSX 138
#define ST_FRAGSY 171
#define ST_FRAGSWIDTH 2
#define ST_ARMORWIDTH 3
#define ST_ARMORX 221
#define ST_ARMORY 171
#define ST_KEY0WIDTH 8
#define ST_KEY0HEIGHT 5
#define ST_KEY0X 239
#define ST_KEY0Y 171
#define ST_KEY1WIDTH ST_KEY0WIDTH
#define ST_KEY1X 239
#define ST_KEY1Y 181
#define ST_KEY2WIDTH ST_KEY0WIDTH
#define ST_KEY2X 239
#define ST_KEY2Y 191
#define ST_AMMO0WIDTH 3
#define ST_AMMO0HEIGHT 6
#define ST_AMMO0X 288
#define ST_AMMO0Y 173
#define ST_AMMO1WIDTH ST_AMMO0WIDTH
#define ST_AMMO1X 288
#define ST_AMMO1Y 179
#define ST_AMMO2WIDTH ST_AMMO0WIDTH
#define ST_AMMO2X 288
#define ST_AMMO2Y 191
#define ST_AMMO3WIDTH ST_AMMO0WIDTH
#define ST_AMMO3X 288
#define ST_AMMO3Y 185
#define ST_MAXAMMO0WIDTH 3
#define ST_MAXAMMO0HEIGHT 5
#define ST_MAXAMMO0X 314
#define ST_MAXAMMO0Y 173
#define ST_MAXAMMO1WIDTH ST_MAXAMMO0WIDTH
#define ST_MAXAMMO1X 314
#define ST_MAXAMMO1Y 179
#define ST_MAXAMMO2WIDTH ST_MAXAMMO0WIDTH
#define ST_MAXAMMO2X 314
#define ST_MAXAMMO2Y 191
#define ST_MAXAMMO3WIDTH ST_MAXAMMO0WIDTH
#define ST_MAXAMMO3X 314
#define ST_MAXAMMO3Y 185
#define ST_WEAPON0X 110
#define ST_WEAPON0Y 172
#define ST_WEAPON1X 122
#define ST_WEAPON1Y 172
#define ST_WEAPON2X 134
#define ST_WEAPON2Y 172
#define ST_WEAPON3X 110
#define ST_WEAPON3Y 181
#define ST_WEAPON4X 122
#define ST_WEAPON4Y 181
#define ST_WEAPON5X 134
#define ST_WEAPON5Y 181
#define ST_WPNSX 109
#define ST_WPNSY 191
#define ST_DETHX 109
#define ST_DETHY 191
#define ST_MSGTEXTX 0
#define ST_MSGTEXTY 0
#define ST_MSGWIDTH 52
#define ST_MSGHEIGHT 1
#define ST_OUTTEXTX 0
#define ST_OUTTEXTY 6
#define ST_OUTWIDTH 52
#define ST_OUTHEIGHT 1
#define ST_MAPWIDTH \
(strlen(mapnames[(::g->gameepisode-1)*9+(::g->gamemap-1)]))
#define ST_MAPTITLEX \
(SCREENWIDTH - ST_MAPWIDTH * ST_CHATFONTWIDTH)
#define ST_MAPTITLEY 0
#define ST_MAPHEIGHT 1
// st_stuff.defs end //
// s_sound.defs begin //
#define S_MAX_VOLUME 127
#define S_CLIPPING_DIST (1200*0x10000)
#define S_CLOSE_DIST (160*0x10000)
#define S_ATTENUATOR ((S_CLIPPING_DIST-S_CLOSE_DIST)>>FRACBITS)
#define NORM_VOLUME snd_MaxVolume
#define NORM_PITCH 128
#define NORM_PRIORITY 64
#define NORM_SEP 128
#define S_PITCH_PERTURB 1
#define S_STEREO_SWING (96*0x10000)
#define S_IFRACVOL 30
#define NA 0
#define S_NUMCHANNELS 256
// s_sound.defs end //
// wi_stuff.defs begin //
#define NUMEPISODES 4
#define NUMMAPS 9
#define WI_TITLEY 2
#define WI_SPACINGY 33
#define SP_STATSX 50
#define SP_STATSY 50
#define SP_TIMEX 16
#define SP_TIMEY (ORIGINAL_HEIGHT-32)
#define NG_STATSY 50
#define NG_STATSX (32 + SHORT(::g->star->width)/2 + 32*!::g->dofrags)
#define NG_SPACINGX 64
#define DM_MATRIXX 42
#define DM_MATRIXY 68
#define DM_SPACINGX 40
#define DM_TOTALSX 269
#define DM_KILLERSX 10
#define DM_KILLERSY 100
#define DM_VICTIMSX 5
#define DM_VICTIMSY 50
#define FB 0
#define SP_KILLS 0
#define SP_ITEMS 2
#define SP_SECRET 4
#define SP_FRAGS 6
#define SP_TIME 8
#define SP_PAR ST_TIME
#define SP_PAUSE 1
#define SHOWNEXTLOCDELAY 4
// wi_stuff.defs end //
// w_wad.defs begin //
// w_wad.defs end //
// z_zone.defs begin //
#define ZONEID 0x1d4a11
#define NUM_ZONES 11
#define MINFRAGMENT 64
#define NO_SHARE_LUMPS
// z_zone.defs end //

223
doomclassic/doom/doomdata.h Normal file
View File

@@ -0,0 +1,223 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __DOOMDATA__
#define __DOOMDATA__
// The most basic types we use, portability.
#include "doomtype.h"
// Some global defines, that configure the game.
#include "doomdef.h"
//
// Map level types.
// The following data structures define the persistent format
// used in the lumps of the WAD files.
//
// Lump order in a map WAD: each map needs a couple of lumps
// to provide a complete scene geometry description.
enum
{
ML_LABEL, // A separator, name, ExMx or MAPxx
ML_THINGS, // Monsters, items..
ML_LINEDEFS, // LineDefs, from editing
ML_SIDEDEFS, // SideDefs, from editing
ML_VERTEXES, // Vertices, edited and BSP splits generated
ML_SEGS, // LineSegs, from LineDefs split by BSP
ML_SSECTORS, // SubSectors, list of LineSegs
ML_NODES, // BSP nodes
ML_SECTORS, // Sectors, from editing
ML_REJECT, // LUT, sector-sector visibility
ML_BLOCKMAP // LUT, motion clipping, walls/grid element
};
// A single Vertex.
typedef struct
{
short x;
short y;
} mapvertex_t;
// A SideDef, defining the visual appearance of a wall,
// by setting textures and offsets.
typedef struct
{
short textureoffset;
short rowoffset;
char toptexture[8];
char bottomtexture[8];
char midtexture[8];
// Front sector, towards viewer.
short sector;
} mapsidedef_t;
// A LineDef, as used for editing, and as input
// to the BSP builder.
typedef struct
{
short v1;
short v2;
short flags;
short special;
short tag;
// sidenum[1] will be -1 if one sided
short sidenum[2];
} maplinedef_t;
//
// LineDef attributes.
//
// Solid, is an obstacle.
#define ML_BLOCKING 1
// Blocks monsters only.
#define ML_BLOCKMONSTERS 2
// Backside will not be present at all
// if not two sided.
#define ML_TWOSIDED 4
// If a texture is pegged, the texture will have
// the end exposed to air held constant at the
// top or bottom of the texture (stairs or pulled
// down things) and will move with a height change
// of one of the neighbor sectors.
// Unpegged textures allways have the first row of
// the texture at the top pixel of the line for both
// top and bottom textures (use next to windows).
// upper texture unpegged
#define ML_DONTPEGTOP 8
// lower texture unpegged
#define ML_DONTPEGBOTTOM 16
// In AutoMap: don't map as two sided: IT'S A SECRET!
#define ML_SECRET 32
// Sound rendering: don't let sound cross two of these.
#define ML_SOUNDBLOCK 64
// Don't draw on the automap at all.
#define ML_DONTDRAW 128
// Set if already seen, thus drawn in automap.
#define ML_MAPPED 256
// Sector definition, from editing.
typedef struct
{
short floorheight;
short ceilingheight;
char floorpic[8];
char ceilingpic[8];
short lightlevel;
short special;
short tag;
} mapsector_t;
// SubSector, as generated by BSP.
typedef struct
{
short numsegs;
// Index of first one, segs are stored sequentially.
short firstseg;
} mapsubsector_t;
// LineSeg, generated by splitting LineDefs
// using partition lines selected by BSP builder.
typedef struct
{
short v1;
short v2;
short angle;
short linedef;
short side;
short offset;
} mapseg_t;
// BSP node structure.
// Indicate a leaf.
#define NF_SUBSECTOR 0x8000
typedef struct
{
// Partition line from (x,y) to x+dx,y+dy)
short x;
short y;
short dx;
short dy;
// Bounding box for each child,
// clip against view frustum.
short bbox[2][4];
// If NF_SUBSECTOR its a subsector,
// else it's a node of another subtree.
unsigned short children[2];
} mapnode_t;
// Thing definition, position, orientation and type,
// plus skill/visibility flags and attributes.
typedef struct
{
short x;
short y;
short angle;
short type;
short options;
} mapthing_t;
#endif // __DOOMDATA__

View File

@@ -0,0 +1,43 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#ifdef __GNUG__
#pragma implementation "doomdef.h"
#endif
#include "doomdef.h"
// Location for any defines turned variables.
// None.

343
doomclassic/doom/doomdef.h Normal file
View File

@@ -0,0 +1,343 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __DOOMDEF__
#define __DOOMDEF__
#include <stdio.h>
#include <string.h>
#include "../../neo/sys/sys_public.h"
//
// Global parameters/defines.
//
// DOOM version
enum { VERSION = 111 };
// Game mode handling - identify IWAD version
// to handle IWAD dependend animations etc.
typedef enum
{
shareware, // DOOM 1 shareware, E1, M9
registered, // DOOM 1 registered, E3, M27
commercial, // DOOM 2 retail, E1 M34
// DOOM 2 german edition not handled
retail, // DOOM 1 retail, E4, M36
indetermined // Well, no IWAD found.
} GameMode_t;
// Mission packs - might be useful for TC stuff?
typedef enum
{
doom, // DOOM 1
doom2, // DOOM 2
pack_tnt, // TNT mission pack
pack_plut, // Plutonia pack
pack_master, // Master levels
pack_nerve, // Nerve levels
none
} GameMission_t;
// Identify language to use, software localization.
typedef enum
{
english,
german,
unknown
} Language_t;
// If rangecheck is undefined,
// most parameter validation debugging code will not be compiled
#ifdef _DEBUG
#define RANGECHECK
#endif
// Do or do not use external soundserver.
// The sndserver binary to be run separately
// has been introduced by Dave Taylor.
// The integrated sound support is experimental,
// and unfinished. Default is synchronous.
// Experimental asynchronous timer based is
// handled by SNDINTR.
#define SNDSERV 1
//#define SNDINTR 1
// This one switches between MIT SHM (no proper mouse)
// and XFree86 DGA (mickey sampling). The original
// linuxdoom used SHM, which is default.
//#define X11_DGA 1
//
// For resize of screen, at start of game.
// It will not work dynamically, see visplanes.
//
//#define BASE_WIDTH 320
// It is educational but futile to change this
// scaling e.g. to 2. Drawing of status bar,
// menues etc. is tied to the scale implied
// by the graphics.
#define SCREEN_MUL 1
#define INV_ASPECT_RATIO 0.625 // 0.75, ideally
// Defines suck. C sucks.
// C++ might sucks for OOP, but it sure is a better C.
// So there.
//#define SCREENWIDTH 320//320
//SCREEN_MUL*BASE_WIDTH //320
//#define SCREENHEIGHT 200//200
//(int)(SCREEN_MUL*BASE_WIDTH*INV_ASPECT_RATIO) //200
// The maximum number of players, multiplayer/networking.
#define MAXPLAYERS 4
// State updates, number of tics / second.
#define TICRATE 35
// The current state of the game: whether we are
// playing, gazing at the intermission screen,
// the game final animation, or a demo.
typedef enum
{
GS_LEVEL,
GS_INTERMISSION,
GS_FINALE,
GS_DEMOSCREEN
} gamestate_t;
//
// Difficulty/skill settings/filters.
//
// Skill flags.
#define MTF_EASY 1
#define MTF_NORMAL 2
#define MTF_HARD 4
// Deaf monsters/do not react to sound.
#define MTF_AMBUSH 8
typedef enum
{
sk_baby,
sk_easy,
sk_medium,
sk_hard,
sk_nightmare
} skill_t;
//
// Key cards.
//
typedef enum
{
it_bluecard,
it_yellowcard,
it_redcard,
it_blueskull,
it_yellowskull,
it_redskull,
NUMCARDS
} card_t;
// The defined weapons,
// including a marker indicating
// user has not changed weapon.
typedef enum
{
wp_fist,
wp_pistol,
wp_shotgun,
wp_chaingun,
wp_missile,
wp_plasma,
wp_bfg,
wp_chainsaw,
wp_supershotgun,
NUMWEAPONS,
// No pending weapon change.
wp_nochange
} weapontype_t;
// Ammunition types defined.
typedef enum
{
am_clip, // Pistol / chaingun ammo.
am_shell, // Shotgun / double barreled shotgun.
am_cell, // Plasma rifle, BFG.
am_misl, // Missile launcher.
NUMAMMO,
am_noammo // Unlimited for chainsaw / fist.
} ammotype_t;
// Power up artifacts.
typedef enum
{
pw_invulnerability,
pw_strength,
pw_invisibility,
pw_ironfeet,
pw_allmap,
pw_infrared,
NUMPOWERS
} powertype_t;
//
// Power up durations,
// how many seconds till expiration,
// assuming TICRATE is 35 ticks/second.
//
typedef enum
{
INVULNTICS = (30*TICRATE),
INVISTICS = (60*TICRATE),
INFRATICS = (120*TICRATE),
IRONTICS = (60*TICRATE)
} powerduration_t;
//
// DOOM keyboard definition.
// This is the stuff configured by Setup.Exe.
// Most key data are simple ascii (uppercased).
//
#define KEY_RIGHTARROW K_RIGHTARROW
#define KEY_LEFTARROW K_LEFTARROW
#define KEY_UPARROW K_UPARROW
#define KEY_DOWNARROW K_DOWNARROW
#define KEY_ESCAPE K_ESCAPE
#define KEY_ENTER K_ENTER
#define KEY_TAB K_TAB
#define KEY_F1 K_F1
#define KEY_F2 K_F2
#define KEY_F3 K_F3
#define KEY_F4 K_F4
#define KEY_F5 K_F5
#define KEY_F6 K_F6
#define KEY_F7 K_F7
#define KEY_F8 K_F8
#define KEY_F9 K_F9
#define KEY_F10 K_F10
#define KEY_F11 K_F11
#define KEY_F12 K_F12
#define KEY_BACKSPACE K_BACKSPACE
#define KEY_PAUSE 0xff
#define KEY_EQUALS K_EQUALS
#define KEY_MINUS K_MINUS
#define KEY_RSHIFT K_RSHIFT
#define KEY_RCTRL K_RCTRL
#define KEY_RALT K_RALT
#define KEY_LALT K_LALT
// DOOM basic types (qboolean),
// and max/min values.
//#include "doomtype.h"
// Fixed point.
//#include "m_fixed.h"
// Endianess handling.
//#include "m_swap.h"
// Binary Angles, sine/cosine/atan lookups.
//#include "tables.h"
// Event type.
//#include "d_event.h"
// Game function, skills.
//#include "g_game.h"
// All external data is defined here.
//#include "doomdata.h"
// All important printed strings.
// Language selection (message strings).
//#include "dstrings.h"
// Player is a special actor.
//struct player_s;
//#include "d_items.h"
//#include "d_player.h"
//#include "p_mobj.h"
//#include "d_net.h"
// PLAY
//#include "p_tick.h"
// Header, generated by sound utility.
// The utility was written by Dave Taylor.
//#include "sounds.h"
#endif // __DOOMDEF__

View File

@@ -0,0 +1,305 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include <stdio.h>
#include "globaldata.h"
#include "doominterface.h"
#include "Main.h"
#include "m_menu.h"
#include "g_game.h"
extern void I_SetTime( int );
bool waitingForWipe;
static const int dargc = 7;
static char* dargv[4][7] =
{
{ "doomlauncher", "-net", "0", "127.0.0.1", "127.0.0.1", "127.0.0.1", "127.0.0.1" },
{ "doomlauncher", "-net", "1", "127.0.0.1", "127.0.0.1", "127.0.0.1", "127.0.0.1" },
{ "doomlauncher", "-net", "2", "127.0.0.1", "127.0.0.1", "127.0.0.1", "127.0.0.1" },
{ "doomlauncher", "-net", "3", "127.0.0.1", "127.0.0.1", "127.0.0.1", "127.0.0.1" },
};
static int mpArgc[4];
static char mpArgV[4][10][32];
static char* mpArgVPtr[4][10];
static bool drawFullScreen = false;
DoomInterface::DoomInterface() {
numplayers = 0;
bFinished[0] = bFinished[1] = bFinished[2] = bFinished[3] = false;
lastTicRun = 0;
}
DoomInterface::~DoomInterface() {
}
void DoomInterface::Startup( int playerscount, bool multiplayer )
{
int i;
int localdargc = 1; // for the commandline
numplayers = playerscount;
globalNetworking = multiplayer;
lastTicRun = 0;
if (DoomLib::Z_Malloc == NULL) {
DoomLib::Z_Malloc = Z_Malloc;
}
// Splitscreen
if ( !multiplayer && playerscount > 1 ) {
localdargc += 2; // for the '-net' and the console number
localdargc += playerscount;
}
if ( multiplayer ) {
// Force online games to 1 local player for now.
// TODO: We should support local splitscreen and online.
numplayers = 1;
}
// Start up DooM Classic
for ( i = 0; i < numplayers; ++i)
{
DoomLib::SetPlayer(i);
bFinished[i] = false;
DoomLib::InitGlobals( NULL );
if ( globalNetworking ) {
printf( "Starting mulitplayer game, argv = " );
for ( int j = 0; j < mpArgc[0]; ++j ) {
printf( " %s", mpArgVPtr[0][j] );
}
printf( "\n" );
DoomLib::InitGame(mpArgc[i], mpArgVPtr[i] );
} else {
DoomLib::InitGame(localdargc, dargv[i] );
}
if( DoomLib::skipToLoad ) {
G_LoadGame( DoomLib::loadGamePath );
DoomLib::skipToLoad = false;
::g->menuactive = 0;
}
if( DoomLib::skipToNew ) {
static int startLevel = 1;
G_DeferedInitNew((skill_t)DoomLib::chosenSkill,DoomLib::chosenEpisode+1, startLevel);
DoomLib::skipToNew = false;
::g->menuactive = 0;
}
DoomLib::SetPlayer(-1);
}
}
bool DoomInterface::Frame( int iTime, idUserCmdMgr * userCmdMgr )
{
int i;
bool bAllFinished = true;
if ( !globalNetworking || ( lastTicRun < iTime ) ) {
drawFullScreen = false;
DoomLib::SetPlayer( 0 );
DoomLib::PollNetwork();
for (i = 0; i < numplayers; ++i)
{
DoomLib::SetPlayer( i );
I_SetTime( iTime );
if (bFinished[i] == false) {
bAllFinished = false;
bFinished[i] = DoomLib::Poll();
} else {
if (::g->wipedone) {
if ( !waitingForWipe ) {
const bool didRunTic = DoomLib::Tic( userCmdMgr );
if ( didRunTic == false ) {
//printf( "Skipping tic and yielding because not enough time has passed.\n" );
// Give lower priority threads a chance to run.
Sys_Yield();
}
}
DoomLib::Frame();
}
if (::g->wipe) {
DoomLib::Wipe();
// Draw the menus over the wipe.
M_Drawer();
}
if( ::g->gamestate != GS_LEVEL && GetNumPlayers() > 2 ) {
drawFullScreen = true;
}
}
DoomLib::SetPlayer(-1);
}
DoomLib::SetPlayer( 0 );
DoomLib::SendNetwork();
DoomLib::RunSound();
DoomLib::SetPlayer( -1 );
lastTicRun = iTime;
} else {
printf( "Skipping this frame becase it's not time to run a tic yet.\n" );
}
return bAllFinished;
}
void I_ShutdownNetwork();
void DoomInterface::Shutdown() {
int i;
for ( i=0; i < numplayers; i++ ) {
DoomLib::SetPlayer( i );
D_QuitNetGame();
}
// Shutdown local network state
I_ShutdownNetwork();
for ( i=0; i < numplayers; i++ ) {
DoomLib::SetPlayer( i );
DoomLib::Shutdown();
}
DoomLib::SetPlayer( -1 );
numplayers = 0;
lastTicRun = 0;
}
qboolean G_CheckDemoStatus( void );
void DoomInterface::QuitCurrentGame() {
for ( int i = 0; i < numplayers; i++ ) {
DoomLib::SetPlayer( i );
if(::g->netgame) {
// Shut down networking
D_QuitNetGame();
}
G_CheckDemoStatus();
globalPauseTime = false;
::g->menuactive = false;
::g->usergame = false;
::g->netgame = false;
lastTicRun = 0;
//if ( !gameLocal->IsSplitscreen() ) {
// Start background demos
D_StartTitle();
//}
}
// Shutdown local network state
I_ShutdownNetwork();
}
void DoomInterface::EndDMGame() {
for ( int i = 0; i < numplayers; i++ ) {
DoomLib::SetPlayer( i );
if(::g->netgame) {
D_QuitNetGame();
}
G_CheckDemoStatus();
globalPauseTime = false;
::g->menuactive = false;
::g->usergame = false;
::g->netgame = false;
lastTicRun = 0;
D_StartTitle();
}
}
//static
int DoomInterface::CurrentPlayer() {
return DoomLib::GetPlayer();
}
int DoomInterface::GetNumPlayers() const {
return numplayers;
}
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
void DoomInterface::SetNetworking( DoomLib::RecvFunc recv, DoomLib::SendFunc send, DoomLib::SendRemoteFunc sendRemote ) {
DoomLib::SetNetworking( recv, send, sendRemote );
}
#endif
void DoomInterface::SetMultiplayerPlayers(int localPlayerIndex, int playerCount, int localPlayer, std::vector<std::string> playerAddresses) {
for(int i = 0; i < 10; i++) {
mpArgVPtr[localPlayerIndex][i] = mpArgV[localPlayerIndex][i];
}
mpArgc[localPlayerIndex] = playerCount+5;
strcpy(mpArgV[localPlayerIndex][0], "doomlauncher");
strcpy(mpArgV[localPlayerIndex][1], "-dup");
strcpy(mpArgV[localPlayerIndex][2], "1");
strcpy(mpArgV[localPlayerIndex][3], "-net");
sprintf(mpArgV[localPlayerIndex][4], "%d", localPlayer);
strcpy(mpArgV[localPlayerIndex][5], playerAddresses[localPlayer].c_str());
int currentArg = 6;
for(int i = 0; i < playerCount; i++) {
if(i != localPlayer) {
strcpy(mpArgV[localPlayerIndex][currentArg], playerAddresses[i].c_str());
currentArg++;
}
}
}

View File

@@ -0,0 +1,74 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef DOOM_INTERFACE_H
#define DOOM_INTERFACE_H
//#include "doomlib.h"
#include <vector>
#include <string>
class idUserCmdMgr;
class DoomInterface
{
public:
DoomInterface();
virtual ~DoomInterface();
typedef int ( *NoParamCallback)();
void Startup( int players, bool multiplayer = false );
bool Frame( int time, idUserCmdMgr * userCmdMgr );
void Shutdown();
void QuitCurrentGame();
void EndDMGame();
// PS3
//void InitGraphics( int player = -1, int width = TEXTUREWIDTH, int height = TEXTUREHEIGHT, D3DCOLOR *pBuffer = NULL, D3DCOLOR *pBuffer2 = NULL );
void SetPostGlobalsCallback( NoParamCallback cb );
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
void SetNetworking( DoomLib::RecvFunc recv, DoomLib::SendFunc send, DoomLib::SendRemoteFunc sendRemote );
#endif
int GetNumPlayers() const;
static int CurrentPlayer();
void SetMultiplayerPlayers(int localPlayerIndex, int playerCount, int localPlayer, std::vector<std::string> playerAddresses );
protected:
int numplayers;
bool bFinished[4];
int lastTicRun;
};
#endif

View File

@@ -0,0 +1,554 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "doomlib.h"
#include <assert.h>
#include "Main.h"
#include "sys/sys_session.h"
#include "idlib/Thread.h"
#include <sys/types.h>
// Store master volume settings in archived cvars, becausue we want them to apply
// even if a user isn't signed in.
// The range is from 0 to 15, which matches the setting in vanilla DOOM.
idCVar s_volume_sound( "s_volume_sound", "8", CVAR_ARCHIVE | CVAR_INTEGER, "sound volume", 0, 15 );
idCVar s_volume_midi( "s_volume_midi", "8", CVAR_ARCHIVE | CVAR_INTEGER, "music volume", 0, 15 );
idCVar m_show_messages( "m_show_messages", "1", CVAR_ARCHIVE | CVAR_INTEGER, "show messages", 0, 1 );
idCVar m_inDemoMode( "m_inDemoMode", "1", CVAR_INTEGER, "in demo mode", 0, 1 );
bool globalNetworking = false;
bool globalPauseTime = false;
int PLAYERCOUNT = 1;
#ifdef _DEBUG
bool debugOutput = true;
#else
bool debugOutput = false;
#endif
namespace DoomLib
{
static const char * Expansion_Names[] = {
"Ultimate DOOM", "DOOM II: Hell On Earth", "Final DOOM: TNT Evilution", "Final DOOM: Plutonia Experiment", "DOOM II: Master Levels", "DOOM II: No Rest For The Living"
};
static const char* Skill_Names[] = {
"I'm Too Young To Die!", "Hey, Not Too Rough!", "Hurt Me Plenty!", "Ultra-Violence", "Nightmare"
};
static const char* Filter_Names[] = {
"#str_friends", "#str_around", "#str_top15"
};
// Game-specific setup values.
static const char * Doom_MapNames[] = {
"E1M1: Hangar", "E1M2: Nuclear Plant", "E1M3: Toxin Refinery", "E1M4: Command Control", "E1M5: Phobos Lab", "E1M6: Central Processing", "E1M7: Computer Station", "E1M8: Phobos Anomaly", "E1M9: Military Base",
"E2M1: Deimos Anomaly", "E2M2: Containment Area", "E2M3: Refinery", "E2M4: Deimos Lab", "E2M5: Command Center", "E2M6: Halls of the Damned", "E2M7: Spawning Vats", "E2M8: Tower of Babel", "E2M9: Fortress of Mystery",
"E3M1: Hell Keep", "E3M2: Slough of Despair", "E3M3: Pandemonium", "E3M4: House of Pain", "E3M5: Unholy Cathedral", "E3M6: MT. Erebus", "E3M7: Gate to Limbo", "E3M8: DIS", "E3M9: Warrens",
"E4M1: Hell Beneath", "E4M2: Perfect Hatred", "E4M3: Sever The Wicked", "E4M4: Unruly Evil", "E4M5: They Will Repent", "E4M6: Against Thee Wickedly", "E4M7: And Hell Followed", "E4M8: Unto The Cruel", "E4M9: Fear"
};
static const char * Doom2_MapNames[] = {
"1: Entryway", "2: Underhalls", "3: The Gantlet", "4: The Focus", "5: The Waste Tunnels", "6: The Crusher", "7: Dead Simple", "8: Tricks and Traps", "9: The Pit", "10: Refueling Base",
"11: Circle of Death", "12: The Factory", "13: Downtown", "14: The Inmost Dens", "15: Industrial Zone", "16: Suburbs", "17: Tenements", "18: The Courtyard", "19: The Citadel", "20: Gotcha!",
"21: Nirvana", "22: The Catacombs", "23: Barrels O' Fun", "24: The Chasm", "25: Bloodfalls", "26: The Abandoned Mines", "27: Monster Condo", "28: The Spirit World", "29: The Living End",
"30: Icon of Sin", "31: IDKFA", "32: Keen"
};
static const char * TNT_MapNames[] = {
"1: System Control", "2: Human BBQ", "3: Power Control", "4: Wormhole", "5: Hangar", "6: Open Season", "7: Prison", "8: Metal", "9: Stronghold", "10: Redemption", "11: Storage Facility",
"12: Crater", "13: Nukage Processing", "14: Steel Works", "15: Dead Zone", "16: Deepest Reaches", "17: Processing Area", "18: Mill", "19: Shipping & Respawning", "20: Central Processing",
"21: Administration Center", "22: Habitat", "23: Lunar Mining Project", "24: Quarry", "25: Baron's Den", "26: Ballistyx", "27: Mount Pain", "28: Heck", "29: River Styx", "30: Last Call", "31: Pharaoh", "32: Caribbean"
};
static const char * Plut_MapNames[] = {
"1: Congo", "2: Well of Souls", "3: Aztec", "4: Caged", "5: Ghost Town", "6: Baron's Lair", "7: Caughtyard", "8: Realm", "9: Abattoire", "10: Onslaught", "11: Hunted", "12: Speed", "13: The Crypt", "14: Genesis",
"15: The Twilight", "16: The Omen", "17: Compound", "18: Neurosphere", "19: NME", "20: The Death Domain", "21: Slayer", "22: Impossible Mission", "23: Tombstone", "24: The Final Frontier", "25: The Temple of Darkness",
"26: Bunker", "27: Anti-Christ", "28: The Sewers", "29: Odyssey of Noises", "30: The Gateway of Hell", "31: Cyberden", "32: Go 2 It"
};
static const char * Mast_MapNames[] = {
"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[] = {
"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[] = {
{ ExpansionData::IWAD, retail, doom, "DOOM", DOOMWADDIR"DOOM.WAD", NULL, "base/textures/DOOMICON.PNG" , Doom_MapNames },
{ ExpansionData::IWAD, commercial, doom2, "DOOM 2", DOOMWADDIR"DOOM2.WAD", NULL, "base/textures/DOOM2ICON.PNG" , Doom2_MapNames },
{ ExpansionData::IWAD, commercial, pack_tnt, "FINAL DOOM: TNT EVILUTION", DOOMWADDIR"TNT.WAD", NULL, "base/textures/TNTICON.PNG" , TNT_MapNames },
{ ExpansionData::IWAD, commercial, pack_plut, "FINAL DOOM: PLUTONIA EXPERIMENT", DOOMWADDIR"PLUTONIA.WAD", NULL, "base/textures/PLUTICON.PNG" , Plut_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];
const ExpansionData * GetCurrentExpansion() {
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;
}
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();
}
}
};
extern void I_InitGraphics();
extern void D_DoomMain();
extern bool D_DoomMainPoll();
extern void I_InitInput();
extern void D_RunFrame( bool );
extern void I_ShutdownSound();
extern void I_ShutdownMusic();
extern void I_ShutdownGraphics();
extern void I_ProcessSoundEvents( void );
void DoomLib::InitGlobals( void *ptr /* = NULL */ )
{
if (ptr == NULL)
ptr = new Globals;
globaldata[currentplayer] = static_cast<Globals*>(ptr);
memset( globaldata[currentplayer], 0, sizeof(Globals) );
g = globaldata[currentplayer];
g->InitGlobals();
}
void *DoomLib::GetGlobalData( int player ) {
return globaldata[player];
}
void DoomLib::InitControlRemap() {
memset( classicRemap, K_NONE, sizeof( classicRemap ) );
classicRemap[K_JOY3] = KEY_TAB ;
classicRemap[K_JOY4] = K_MINUS;
classicRemap[K_JOY2] = K_EQUALS;
classicRemap[K_JOY9] = K_ESCAPE ;
classicRemap[K_JOY_STICK1_UP] = K_UPARROW ;
classicRemap[K_JOY_DPAD_UP] = K_UPARROW ;
classicRemap[K_JOY_STICK1_DOWN] = K_DOWNARROW ;
classicRemap[K_JOY_DPAD_DOWN] = K_DOWNARROW ;
classicRemap[K_JOY_STICK1_LEFT] = K_LEFTARROW ;
classicRemap[K_JOY_DPAD_LEFT] = K_LEFTARROW ;
classicRemap[K_JOY_STICK1_RIGHT] = K_RIGHTARROW ;
classicRemap[K_JOY_DPAD_RIGHT] = K_RIGHTARROW ;
classicRemap[K_JOY1] = K_ENTER;
}
keyNum_t DoomLib::RemapControl( keyNum_t key ) {
if( classicRemap[ key ] == K_NONE ) {
return key;
} else {
if( ::g->menuactive && key == K_JOY2 ) {
return K_BACKSPACE;
}
return (keyNum_t)classicRemap[ key ];
}
}
void DoomLib::InitGame( int argc, char** argv )
{
::g->myargc = argc;
::g->myargv = argv;
InitControlRemap();
D_DoomMain();
}
bool DoomLib::Poll()
{
return D_DoomMainPoll();
}
bool TryRunTics( idUserCmdMgr * userCmdMgr );
bool DoomLib::Tic( idUserCmdMgr * userCmdMgr )
{
return TryRunTics( userCmdMgr );
}
void D_Wipe();
void DoomLib::Wipe()
{
D_Wipe();
}
void DoomLib::Frame( int realoffset, int buffer )
{
::g->realoffset = realoffset;
// The render thread needs to read the player's screens[0] array,
// so updating it needs to be in a critical section.
// This may seem like a really broad mutex (which it is), and if performance
// suffers too much, we can try to narrow the scope.
// Just be careful, because the player's screen data is updated in many different
// places.
if ( 0 <= currentplayer && currentplayer <= 4 ) {
idScopedCriticalSection crit( playerScreenMutexes[currentplayer] );
D_RunFrame( true );
}
}
void DoomLib::Draw()
{
R_RenderPlayerView (&::g->players[::g->displayplayer]);
}
angle_t GetViewAngle()
{
return g->viewangle;
}
void SetViewAngle( angle_t ang )
{
g->viewangle = ang;
::g->viewxoffset = (finesine[g->viewangle>>ANGLETOFINESHIFT]*::g->realoffset) >> 8;
::g->viewyoffset = (finecosine[g->viewangle>>ANGLETOFINESHIFT]*::g->realoffset) >> 8;
}
void SetViewX( fixed_t x )
{
::g->viewx = x;
}
void SetViewY( fixed_t y )
{
::g->viewy = y;
}
fixed_t GetViewX()
{
return ::g->viewx + ::g->viewxoffset;
}
fixed_t GetViewY()
{
return ::g->viewy + ::g->viewyoffset;
}
void DoomLib::Shutdown() {
//D_QuitNetGame ();
I_ShutdownSound();
I_ShutdownGraphics();
W_Shutdown();
// De-allocate the zone memory (never happened in original doom, until quit)
if ( ::g->mainzone ) {
free( ::g->mainzone );
}
// Delete the globals
if ( globaldata[currentplayer] ) {
delete globaldata[currentplayer];
globaldata[currentplayer] = NULL;
}
}
// static
void DoomLib::SetPlayer( int id )
{
currentplayer = id;
if ( id < 0 || id >= MAX_PLAYERS ) {
g = NULL;
}
else {
// Big Fucking hack.
if( globalNetworking && session->GetGameLobbyBase().GetMatchParms().matchFlags | MATCH_ONLINE ) {
currentplayer = 0;
}
g = globaldata[currentplayer];
}
}
void DoomLib::SetNetworking( RecvFunc rf, SendFunc sf, SendRemoteFunc sendRemote )
{
Recv = rf;
Send = sf;
SendRemote = sendRemote;
}
int DoomLib::GetPlayer()
{
return currentplayer;
}
byte DoomLib::BuildSourceDest( int toNode ) {
byte sourceDest = 0;
sourceDest |= ::g->consoleplayer << 2;
sourceDest |= RemoteNodeToPlayerIndex( toNode );
return sourceDest;
}
void I_Printf(char *error, ...);
void DoomLib::GetSourceDest( byte sourceDest, int* source, int* dest ) {
int src = (sourceDest & 12) >> 2;
int dst = sourceDest & 3;
*source = PlayerIndexToRemoteNode( src );
//I_Printf( "GetSourceDest Current Player(%d) %d --> %d\n", GetPlayer(), src, *source );
*dest = PlayerIndexToRemoteNode( dst );
}
int nodeMap[4][4] = {
{0, 1, 2, 3}, //Player 0
{1, 0, 2, 3}, //Player 1
{2, 0, 1, 3}, //Player 2
{3, 0, 1, 2} //Player 3
};
int DoomLib::RemoteNodeToPlayerIndex( int node ) {
//This needs to be called with the proper doom globals set so this calculation will work properly
/*
int player = ::g->consoleplayer;
if (player == 2 && node == 2 ) {
int suck = 0;
}
if( node == player ) {
return 0;
}
if( node - player <= 0 ) {
return node+1;
}
return node;*/
return nodeMap[::g->consoleplayer][node];
}
int indexMap[4][4] = {
{0, 1, 2, 3}, //Player 0
{1, 0, 2, 3}, //Player 1
{1, 2, 0, 3}, //Player 2
{1, 2, 3, 0} //Player 3
};
int DoomLib::PlayerIndexToRemoteNode( int index ) {
/*int player = ::g->consoleplayer;
if( index == 0 ) {
return player;
}
if( index <= player ) {
return index-1;
}
return index;*/
return indexMap[::g->consoleplayer][index];
}
void I_Error (char *error, ...);
extern bool useTech5Packets;
void DoomLib::PollNetwork() {
#if 0
if ( !useTech5Packets ) {
if ( !globalNetworking ) {
return;
}
int c;
struct sockaddr fromaddress;
socklen_t fromlen;
doomdata_t sw;
while(1) {
int receivedSize = recvfrom( ::g->insocket, &sw, sizeof( doomdata_t ), MSG_DONTWAIT, &fromaddress, &fromlen );
//c = WSARecvFrom(::g->insocket, &buffer, 1, &num_recieved, &flags, (struct sockaddr*)&fromaddress, &fromlen, 0, 0);
if ( receivedSize < 0 )
{
int err = sys_net_errno;
if (err != SYS_NET_EWOULDBLOCK ) {
I_Error ("GetPacket: %d", err );
//I_Printf ("GetPacket: %s",strerror(errno));
}
return;
}
printf( "RECEIVED PACKET!!\n" );
int source;
int dest;
GetSourceDest( sw.sourceDest, &source, &dest );
//Push the packet onto the network stack to be processed.
DoomLib::Send( (char*)&sw, receivedSize, NULL, dest );
}
}
#endif
}
void DoomLib::SendNetwork() {
if ( !globalNetworking ) {
return;
}
DoomLib::SendRemote();
}
void DoomLib::RunSound() {
I_ProcessSoundEvents();
}

169
doomclassic/doom/doomlib.h Normal file
View File

@@ -0,0 +1,169 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef _DOOM_LIB_H
#define _DOOM_LIB_H
#include "doomtype.h"
#include "doomdef.h"
#include "doominterface.h"
#include "idlib/containers/Array.h"
class idSysMutex;
class idUserCmdMgr;
#define IN_NUM_DIGITAL_BUTTONS 8
#define IN_NUM_ANALOG_BUTTONS 8
// Cutoff where the analog buttons are considered to be "pressed"
// This should be smarter.
#define IN_ANALOG_BUTTON_THRESHOLD 64
extern idCVar s_volume_sound;
extern idCVar s_volume_midi;
extern idCVar m_show_messages;
extern idCVar m_inDemoMode;
struct rumble_t
{
int feedback; // SMF // XINPUT_FEEDBACK feedback;
int endTime;
// The following values are needed, becuase a rumble
// can fail, if it hasn't processed the previous one yet,
// so, it must be stored
bool waiting;
int left;
int right;
};
enum gameSKU_t {
GAME_SKU_DCC = 0, // Doom Classic Complete
GAME_SKU_DOOM1_BFG, // Doom 1 Ran from BFG
GAME_SKU_DOOM2_BFG, // Doom 2 Ran from BFG
};
/*
================================================================================================
ExpansionData
================================================================================================
*/
struct ExpansionData {
enum { IWAD = 0, PWAD = 1 } type;
GameMode_t gameMode;
GameMission_t pack_type;
const char * expansionName;
const char * iWadFilename;
const char * pWadFilename;
const char * saveImageFile;
const char ** mapNames;
};
namespace DoomLib
{
typedef int ( *RecvFunc)( char* buff, DWORD *numRecv );
typedef int ( *SendFunc)( const char* buff, DWORD size, sockaddr_in *target, int toNode );
typedef int ( *SendRemoteFunc)();
void InitGlobals( void *ptr = NULL );
void InitGame( int argc, char ** argv );
void InitControlRemap();
keyNum_t RemapControl( keyNum_t key );
bool Poll();
bool Tic( idUserCmdMgr * userCmdMgr );
void Wipe();
void Frame( int realoffset = 0, int buffer = 0 );
void Draw();
void Shutdown();
void SetNetworking( RecvFunc rf, SendFunc sf, SendRemoteFunc sendRemote );
void SetPlayer( int id );
int GetPlayer();
byte BuildSourceDest( int toNode );
void GetSourceDest( byte sourceDest, int* source, int* dest );
int RemoteNodeToPlayerIndex( int node );
int PlayerIndexToRemoteNode( int index );
void PollNetwork();
void SendNetwork();
void *GetGlobalData( int player );
void RunSound();
extern RecvFunc Recv;
extern SendFunc Send;
extern SendRemoteFunc SendRemote;
extern void* (*Z_Malloc)( int size, int tag, void* user );
extern void (*Z_FreeTag)(int lowtag );
extern DoomInterface Interface;
extern int idealExpansion;
extern int expansionSelected;
extern bool expansionDirty;
extern bool skipToLoad;
extern char loadGamePath[MAX_PATH];
extern bool skipToNew;
extern int chosenSkill;
extern int chosenEpisode;
extern idMatchParameters matchParms;
const ExpansionData * GetCurrentExpansion();
void SetCurrentExpansion( int expansion );
void SetIdealExpansion( int expansion );
void SetCurrentMapName( idStr name );
const idStr & GetCurrentMapName();
void SetCurrentDifficulty( idStr name );
const idStr & GetCurrentDifficulty();
void ActivateGame();
void ExitGame();
void ShowXToContinue( bool activate );
gameSKU_t GetGameSKU();
void HandleEndMatch();
};
#endif

View File

@@ -0,0 +1,48 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#ifdef __GNUG__
#pragma implementation "doomstat.h"
#endif
#include "doomstat.h"
// Game Mode - identify IWAD as shareware, retail etc.
// Language.
// Set if homebrew PWAD stuff has been added.

285
doomclassic/doom/doomstat.h Normal file
View File

@@ -0,0 +1,285 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __D_STATE__
#define __D_STATE__
// We need globally shared data structures,
// for defining the global state variables.
#include "doomdata.h"
#include "d_net.h"
// We need the playr data structure as well.
#include "d_player.h"
#ifdef __GNUG__
#pragma interface
#endif
// ------------------------
// Command line parameters.
//
extern qboolean nomonsters; // checkparm of -nomonsters
extern qboolean respawnparm; // checkparm of -respawn
extern qboolean fastparm; // checkparm of -fast
extern qboolean devparm; // DEBUG: launched with -devparm
// -----------------------------------------------------
// Game Mode - identify IWAD as shareware, retail etc.
//
extern GameMode_t gamemode;
extern int gamemission;
// Set if homebrew PWAD stuff has been added.
extern qboolean modifiedgame;
// -------------------------------------------
// Language.
extern Language_t language;
// -------------------------------------------
// Selected skill type, map etc.
//
// Defaults for menu, methinks.
extern skill_t startskill;
extern int startepisode;
extern int startmap;
extern qboolean autostart;
// Selected by user.
extern skill_t gameskill;
extern int gameepisode;
extern int gamemap;
// Nightmare mode flag, single player.
extern qboolean respawnmonsters;
// Netgame? Only true if >1 player.
extern qboolean netgame;
// Flag: true only if started as net deathmatch.
// An enum might handle altdeath/cooperative better.
extern qboolean deathmatch;
// -------------------------
// Internal parameters for sound rendering.
// These have been taken from the DOS version,
// but are not (yet) supported with Linux
// (e.g. no sound volume adjustment with menu.
// Current music/sfx card - index useless
// w/o a reference LUT in a sound module.
// Ideally, this would use indices found
// in: /usr/include/linux/soundcard.h
extern int snd_MusicDevice;
extern int snd_SfxDevice;
// Config file? Same disclaimer as above.
extern int snd_DesiredMusicDevice;
extern int snd_DesiredSfxDevice;
// -------------------------
// Status flags for refresh.
//
// Depending on view size - no status bar?
// Note that there is no way to disable the
// status bar explicitely.
extern qboolean statusbaractive;
extern qboolean automapactive; // In AutoMap mode?
extern qboolean menuactive; // Menu overlayed?
extern qboolean paused; // Game Pause?
extern qboolean viewactive;
extern qboolean nodrawers;
extern qboolean noblit;
extern int viewwindowx;
extern int viewwindowy;
extern int viewheight;
extern int viewwidth;
extern int scaledviewwidth;
// This one is related to the 3-screen display mode.
// ANG90 = left side, ANG270 = right
extern int viewangleoffset;
// Player taking events, and displaying.
extern int consoleplayer;
extern int displayplayer;
// -------------------------------------
// Scores, rating.
// Statistics on a given map, for intermission.
//
extern int totalkills;
extern int totalitems;
extern int totalsecret;
// Timer, for scores.
extern int levelstarttic; // gametic at level start
extern int leveltime; // tics in game play for par
// --------------------------------------
// DEMO playback/recording related stuff.
// No demo, there is a human player in charge?
// Disable save/end game?
extern qboolean usergame;
//?
extern qboolean demoplayback;
// Quit after playing a demo from cmdline.
extern qboolean singledemo;
//?
extern gamestate_t gamestate;
//-----------------------------
// Internal parameters, fixed.
// These are set by the engine, and not changed
// according to user inputs. Partly load from
// WAD, partly set at startup time.
extern int gametic;
// Bookkeeping on players - state.
extern player_t players[MAXPLAYERS];
// Alive? Disconnected?
extern qboolean playeringame[MAXPLAYERS];
// Player spawn spots for deathmatch.
#define MAX_DM_STARTS 10
extern mapthing_t deathmatchstarts[MAX_DM_STARTS];
extern mapthing_t* deathmatch_p;
// Player spawn spots.
extern mapthing_t playerstarts[MAXPLAYERS];
// Intermission stats.
// Parameters for world map / intermission.
extern wbstartstruct_t wminfo;
// LUT of ammunition limits for each kind.
// This doubles with BackPack powerup item.
const extern int maxammo[NUMAMMO];
//-----------------------------------------
// Internal parameters, used for engine.
//
// File handling stuff.
extern char basedefault[1024];
extern FILE* debugfile;
// if true, load all graphics at level load
extern qboolean precache;
// wipegamestate can be set to -1
// to force a wipe on the next draw
extern gamestate_t wipegamestate;
extern int mouseSensitivity;
//?
// debug flag to cancel adaptiveness
extern qboolean singletics;
extern int bodyqueslot;
// Needed to store the number of the dummy sky flat.
// Used for rendering,
// as well as tracking projectiles etc.
extern int skyflatnum;
// Netgame stuff (buffers and pointers, i.e. indices).
// This is ???
extern doomcom_t doomcom;
// This points inside doomcom.
extern doomdata_t* netbuffer;
extern ticcmd_t localcmds[BACKUPTICS];
extern int rndindex;
extern int maketic;
extern int nettics[MAXNETNODES];
extern ticcmd_t netcmds[MAXPLAYERS][BACKUPTICS];
extern int ticdup;
#endif

View File

@@ -0,0 +1,45 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __DOOMTYPE__
#define __DOOMTYPE__
#include <limits>
#define false 0
#define true 1
typedef int qboolean;
typedef float FLOAT;
#endif

View File

@@ -0,0 +1,78 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#ifdef __GNUG__
#pragma implementation "dstrings.h"
#endif
#include "dstrings.h"
const char* endmsg[NUM_QUITMESSAGES+1]=
{
// DOOM1
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?"
// 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?"
// 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?",
// Internal debug. Different style, too.
"are you sure you want to quit?"
};

View File

@@ -0,0 +1,59 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __DSTRINGS__
#define __DSTRINGS__
// All important printed strings.
// Language selection (message strings).
// Use -DFRENCH etc.
#include "d_englsh.h"
// Misc. other strings.
#define SAVEGAMENAME "doomsav"
//
// File locations,
// relative to current position.
// Path names are OS-sensitive.
//
#define DEVMAPS "devmaps"
#define DEVDATA "devdata"
// QuitDOOM messages
#define NUM_QUITMESSAGES 22
extern const char* endmsg[];
#endif

View File

@@ -0,0 +1,816 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <ctype.h>
// Functions.
#include "i_system.h"
#include "m_swap.h"
#include "z_zone.h"
#include "v_video.h"
#include "w_wad.h"
#include "s_sound.h"
// Data.
#include "dstrings.h"
#include "sounds.h"
#include "doomstat.h"
#include "r_state.h"
#include "Main.h"
#include "d3xp/Game_local.h"
// ?
//#include "doomstat.h"
//#include "r_local.h"
//#include "f_finale.h"
// Stage of animation:
// 0 = text, 1 = art screen, 2 = character cast
const char* e1text = E1TEXT;
const char* e2text = E2TEXT;
const char* e3text = E3TEXT;
const char* e4text = E4TEXT;
const char* c1text = C1TEXT;
const char* c2text = C2TEXT;
const char* c3text = C3TEXT;
const char* c4text = C4TEXT;
const char* c5text = C5TEXT;
const char* c6text = C6TEXT;
const char* c7text = C7TEXT;
const char* c8Text = C8TEXT;
const char* p1text = P1TEXT;
const char* p2text = P2TEXT;
const char* p3text = P3TEXT;
const char* p4text = P4TEXT;
const char* p5text = P5TEXT;
const char* p6text = P6TEXT;
const char* t1text = T1TEXT;
const char* t2text = T2TEXT;
const char* t3text = T3TEXT;
const char* t4text = T4TEXT;
const char* t5text = T5TEXT;
const char* t6text = T6TEXT;
const char* finaletext;
const char* finaleflat;
void F_StartCast (void);
void F_CastTicker (void);
qboolean F_CastResponder (event_t *ev);
void F_CastDrawer (void);
//
// F_StartFinale
//
void F_StartFinale (void)
{
::g->gameaction = ga_nothing;
::g->gamestate = GS_FINALE;
::g->viewactive = false;
::g->automapactive = false;
// Check for end of episode/mission
bool endOfMission = false;
if ( ( ::g->gamemission == doom || ::g->gamemission == doom2 || ::g->gamemission == pack_tnt || ::g->gamemission == pack_plut ) && ::g->gamemap == 30 ) {
endOfMission = true;
}
else if ( ::g->gamemission == pack_nerve && ::g->gamemap == 8 ) {
endOfMission = true;
}
else if ( ::g->gamemission == pack_master && ::g->gamemap == 21 ) {
endOfMission = true;
}
localCalculateAchievements( endOfMission );
// Okay - IWAD dependend stuff.
// This has been changed severly, and
// some stuff might have changed in the process.
switch ( ::g->gamemode )
{
// DOOM 1 - E1, E3 or E4, but each nine missions
case shareware:
case registered:
case retail:
{
S_ChangeMusic(mus_victor, true);
switch (::g->gameepisode)
{
case 1:
finaleflat = "FLOOR4_8";
finaletext = e1text;
break;
case 2:
finaleflat = "SFLR6_1";
finaletext = e2text;
break;
case 3:
finaleflat = "MFLR8_4";
finaletext = e3text;
break;
case 4:
finaleflat = "MFLR8_3";
finaletext = e4text;
break;
default:
// Ouch.
break;
}
break;
}
// DOOM II and missions packs with E1, M34
case commercial:
{
S_ChangeMusic(mus_read_m, true);
if ( ::g->gamemission == doom2 || ::g->gamemission == pack_tnt || ::g->gamemission == pack_plut ) {
switch (::g->gamemap)
{
case 6:
finaleflat = "SLIME16";
finaletext = c1text;
break;
case 11:
finaleflat = "RROCK14";
finaletext = c2text;
break;
case 20:
finaleflat = "RROCK07";
finaletext = c3text;
break;
case 30:
finaleflat = "RROCK17";
finaletext = c4text;
break;
case 15:
finaleflat = "RROCK13";
finaletext = c5text;
break;
case 31:
finaleflat = "RROCK19";
finaletext = c6text;
break;
default:
// Ouch.
break;
}
} else if( ::g->gamemission == pack_master ) {
switch (::g->gamemap)
{
case 21:
finaleflat = "SLIME16";
finaletext = c8Text;
break;
}
} else if ( ::g->gamemission == pack_nerve ) {
switch( ::g->gamemap ){
case 8:
finaleflat = "SLIME16";
finaletext = c7text;
break;
}
}
break;
}
// Indeterminate.
default:
S_ChangeMusic(mus_read_m, true);
finaleflat = "F_SKY1"; // Not used anywhere else.
finaletext = c1text; // FIXME - other text, music?
break;
}
::g->finalestage = 0;
::g->finalecount = 0;
}
bool finaleButtonPressed = false;
bool startButtonPressed = false;
qboolean F_Responder (event_t *event)
{
if( !common->IsMultiplayer() && event->type == ev_keydown && event->data1 == KEY_ESCAPE ) {
startButtonPressed = true;
return true;
}
if (::g->finalestage == 2)
return F_CastResponder (event);
return false;
}
//
// F_Ticker
//
void F_Ticker (void)
{
int i;
// check for skipping
if ( (::g->gamemode == commercial) && ( ::g->finalecount > 50) )
{
// go on to the next level
for (i=0 ; i<MAXPLAYERS ; i++)
if (::g->players[i].cmd.buttons)
break;
if ( finaleButtonPressed || i < MAXPLAYERS)
{
bool castStarted = false;
if( ::g->gamemission == doom2 || ::g->gamemission == pack_plut || ::g->gamemission == pack_tnt ) {
if (::g->gamemap == 30) {
F_StartCast ();
castStarted = true;
}
} else if( ::g->gamemission == pack_master ) {
if( :: g->gamemap == 21 ) {
F_StartCast ();
castStarted = true;
}
} else if( ::g->gamemission == pack_nerve ) {
if( :: g->gamemap == 8 ) {
F_StartCast ();
castStarted = true;
}
}
if( castStarted == false ) {
::g->gameaction = ga_worlddone;
}
}
}
bool SkipTheText = finaleButtonPressed;
// advance animation
::g->finalecount++;
finaleButtonPressed = false;
if (::g->finalestage == 2)
{
F_CastTicker ();
return;
}
if ( ::g->gamemode == commercial) {
startButtonPressed = false;
return;
}
if( SkipTheText && ( ::g->finalecount > 50) ) {
::g->finalecount = static_cast<int>(strlen(finaletext)) * TEXTSPEED + TEXTWAIT;
}
if (!::g->finalestage && ::g->finalecount > static_cast<int>(strlen(finaletext)) * TEXTSPEED + TEXTWAIT)
{
::g->finalecount = 0;
::g->finalestage = 1;
::g->wipegamestate = (gamestate_t)-1; // force a wipe
if (::g->gameepisode == 3)
S_StartMusic (mus_bunny);
}
startButtonPressed = false;
}
//
// F_TextWrite
//
#include "hu_stuff.h"
void F_TextWrite (void)
{
byte* src;
byte* dest;
int x,y,w;
int count;
const char* ch;
int c;
int cx;
int cy;
if(::g->finalecount == 60 ) {
DoomLib::ShowXToContinue( true );
}
// erase the entire screen to a tiled background
src = (byte*)W_CacheLumpName ( finaleflat , PU_CACHE_SHARED);
dest = ::g->screens[0];
for (y=0 ; y<SCREENHEIGHT ; y++)
{
for (x=0 ; x<SCREENWIDTH/64 ; x++)
{
memcpy (dest, src+((y&63)<<6), 64);
dest += 64;
}
if (SCREENWIDTH&63)
{
memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63);
dest += (SCREENWIDTH&63);
}
}
V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);
// draw some of the text onto the screen
cx = 10;
cy = 10;
ch = finaletext;
count = (::g->finalecount - 10)/TEXTSPEED;
if (count < 0)
count = 0;
for ( ; count ; count-- )
{
c = *ch++;
if (!c)
break;
if (c == '\n')
{
cx = 10;
cy += 11;
continue;
}
c = toupper(c) - HU_FONTSTART;
if (c < 0 || c> HU_FONTSIZE)
{
cx += 4;
continue;
}
w = SHORT (::g->hu_font[c]->width);
if (cx+w > SCREENWIDTH)
break;
V_DrawPatch(cx, cy, 0, ::g->hu_font[c]);
cx+=w;
}
}
//
// Final DOOM 2 animation
// Casting by id Software.
// in order of appearance
//
castinfo_t castorder[] =
{
{CC_ZOMBIE, MT_POSSESSED},
{CC_SHOTGUN, MT_SHOTGUY},
{CC_HEAVY, MT_CHAINGUY},
{CC_IMP, MT_TROOP},
{CC_DEMON, MT_SERGEANT},
{CC_LOST, MT_SKULL},
{CC_CACO, MT_HEAD},
{CC_HELL, MT_KNIGHT},
{CC_BARON, MT_BRUISER},
{CC_ARACH, MT_BABY},
{CC_PAIN, MT_PAIN},
{CC_REVEN, MT_UNDEAD},
{CC_MANCU, MT_FATSO},
{CC_ARCH, MT_VILE},
{CC_SPIDER, MT_SPIDER},
{CC_CYBER, MT_CYBORG},
{CC_HERO, MT_PLAYER},
{NULL,(mobjtype_t)0}
};
//
// F_StartCast
//
void F_StartCast (void)
{
if ( ::g->finalestage != 2 ) {
::g->wipegamestate = (gamestate_t)-1; // force a screen wipe
::g->castnum = 0;
::g->caststate = &::g->states[mobjinfo[castorder[::g->castnum].type].seestate];
::g->casttics = ::g->caststate->tics;
::g->castdeath = false;
::g->finalestage = 2;
::g->castframes = 0;
::g->castonmelee = 0;
::g->castattacking = false;
S_ChangeMusic(mus_evil, true);
::g->caststartmenu = ::g->finalecount + 50;
}
}
//
// F_CastTicker
//
void F_CastTicker (void)
{
int st;
int sfx;
if( ::g->finalecount == ::g->caststartmenu ) {
DoomLib::ShowXToContinue( true );
}
if (--::g->casttics > 0)
return; // not time to change state yet
if (::g->caststate->tics == -1 || ::g->caststate->nextstate == S_NULL)
{
// switch from deathstate to next monster
::g->castnum++;
::g->castdeath = false;
if (castorder[::g->castnum].name == NULL)
::g->castnum = 0;
if (mobjinfo[castorder[::g->castnum].type].seesound)
S_StartSound (NULL, mobjinfo[castorder[::g->castnum].type].seesound);
::g->caststate = &::g->states[mobjinfo[castorder[::g->castnum].type].seestate];
::g->castframes = 0;
}
else
{
// just advance to next state in animation
if (::g->caststate == &::g->states[S_PLAY_ATK1])
goto stopattack; // Oh, gross hack!
st = ::g->caststate->nextstate;
::g->caststate = &::g->states[st];
::g->castframes++;
// sound hacks....
switch (st)
{
case S_PLAY_ATK1: sfx = sfx_dshtgn; break;
case S_POSS_ATK2: sfx = sfx_pistol; break;
case S_SPOS_ATK2: sfx = sfx_shotgn; break;
case S_VILE_ATK2: sfx = sfx_vilatk; break;
case S_SKEL_FIST2: sfx = sfx_skeswg; break;
case S_SKEL_FIST4: sfx = sfx_skepch; break;
case S_SKEL_MISS2: sfx = sfx_skeatk; break;
case S_FATT_ATK8:
case S_FATT_ATK5:
case S_FATT_ATK2: sfx = sfx_firsht; break;
case S_CPOS_ATK2:
case S_CPOS_ATK3:
case S_CPOS_ATK4: sfx = sfx_shotgn; break;
case S_TROO_ATK3: sfx = sfx_claw; break;
case S_SARG_ATK2: sfx = sfx_sgtatk; break;
case S_BOSS_ATK2:
case S_BOS2_ATK2:
case S_HEAD_ATK2: sfx = sfx_firsht; break;
case S_SKULL_ATK2: sfx = sfx_sklatk; break;
case S_SPID_ATK2:
case S_SPID_ATK3: sfx = sfx_shotgn; break;
case S_BSPI_ATK2: sfx = sfx_plasma; break;
case S_CYBER_ATK2:
case S_CYBER_ATK4:
case S_CYBER_ATK6: sfx = sfx_rlaunc; break;
case S_PAIN_ATK3: sfx = sfx_sklatk; break;
default: sfx = 0; break;
}
if (sfx)
S_StartSound (NULL, sfx);
}
if (::g->castframes == 12)
{
// go into attack frame
::g->castattacking = true;
if (::g->castonmelee)
::g->caststate=&::g->states[mobjinfo[castorder[::g->castnum].type].meleestate];
else
::g->caststate=&::g->states[mobjinfo[castorder[::g->castnum].type].missilestate];
::g->castonmelee ^= 1;
if (::g->caststate == &::g->states[S_NULL])
{
if (::g->castonmelee)
::g->caststate=
&::g->states[mobjinfo[castorder[::g->castnum].type].meleestate];
else
::g->caststate=
&::g->states[mobjinfo[castorder[::g->castnum].type].missilestate];
}
}
if (::g->castattacking)
{
if (::g->castframes == 24
|| ::g->caststate == &::g->states[mobjinfo[castorder[::g->castnum].type].seestate] )
{
stopattack:
::g->castattacking = false;
::g->castframes = 0;
::g->caststate = &::g->states[mobjinfo[castorder[::g->castnum].type].seestate];
}
}
::g->casttics = ::g->caststate->tics;
if (::g->casttics == -1)
::g->casttics = 15;
}
//
// F_CastResponder
//
qboolean F_CastResponder (event_t* ev)
{
if (ev->type != ev_keydown)
return false;
if (::g->castdeath)
return true; // already in dying frames
// go into death frame
::g->castdeath = true;
::g->caststate = &::g->states[mobjinfo[castorder[::g->castnum].type].deathstate];
::g->casttics = ::g->caststate->tics;
::g->castframes = 0;
::g->castattacking = false;
if (mobjinfo[castorder[::g->castnum].type].deathsound)
S_StartSound (NULL, mobjinfo[castorder[::g->castnum].type].deathsound);
return true;
}
void F_CastPrint (char* text)
{
char* ch;
int c;
int cx;
int w;
int width;
// find width
ch = text;
width = 0;
while (ch)
{
c = *ch++;
if (!c)
break;
c = toupper(c) - HU_FONTSTART;
if (c < 0 || c> HU_FONTSIZE)
{
width += 4;
continue;
}
w = SHORT (::g->hu_font[c]->width);
width += w;
}
// draw it
cx = 160-width/2;
ch = text;
while (ch)
{
c = *ch++;
if (!c)
break;
c = toupper(c) - HU_FONTSTART;
if (c < 0 || c> HU_FONTSIZE)
{
cx += 4;
continue;
}
w = SHORT (::g->hu_font[c]->width);
V_DrawPatch(cx, 180, 0, ::g->hu_font[c]);
cx+=w;
}
}
//
// F_CastDrawer
//
void V_DrawPatchFlipped (int x, int y, int scrn, patch_t *patch);
void F_CastDrawer (void)
{
spritedef_t* sprdef;
spriteframe_t* sprframe;
int lump;
qboolean flip;
patch_t* patch;
// erase the entire screen to a background
V_DrawPatch (0,0,0, (patch_t*)W_CacheLumpName ("BOSSBACK", PU_CACHE_SHARED));
F_CastPrint (castorder[::g->castnum].name);
// draw the current frame in the middle of the screen
sprdef = &::g->sprites[::g->caststate->sprite];
sprframe = &sprdef->spriteframes[ ::g->caststate->frame & FF_FRAMEMASK];
lump = sprframe->lump[0];
flip = (qboolean)sprframe->flip[0];
patch = (patch_t*)W_CacheLumpNum (lump+::g->firstspritelump, PU_CACHE_SHARED);
if (flip)
V_DrawPatchFlipped (160,170,0,patch);
else
V_DrawPatch (160,170,0,patch);
}
//
// F_DrawPatchCol
//
void
F_DrawPatchCol( int x, patch_t* patch, int col ) {
postColumn_t* column;
byte* source;
int count;
column = (postColumn_t *)((byte *)patch + LONG(patch->columnofs[col]));
int destx = x;
int desty = 0;
// step through the posts in a column
while (column->topdelta != 0xff )
{
source = (byte *)column + 3;
desty = column->topdelta;
count = column->length;
while (count--)
{
int scaledx, scaledy;
scaledx = destx * GLOBAL_IMAGE_SCALER;
scaledy = desty * GLOBAL_IMAGE_SCALER;
byte src = *source++;
for ( int i = 0; i < GLOBAL_IMAGE_SCALER; i++ ) {
for ( int j = 0; j < GLOBAL_IMAGE_SCALER; j++ ) {
::g->screens[0][( scaledx + j ) + ( scaledy + i ) * SCREENWIDTH] = src;
}
}
desty++;
}
column = (postColumn_t *)( (byte *)column + column->length + 4 );
}
}
//
// F_BunnyScroll
//
void F_BunnyScroll (void)
{
int scrolled;
int x;
patch_t* p1;
patch_t* p2;
char name[10];
int stage;
p1 = (patch_t*)W_CacheLumpName ("PFUB2", PU_LEVEL_SHARED);
p2 = (patch_t*)W_CacheLumpName ("PFUB1", PU_LEVEL_SHARED);
V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);
scrolled = 320 - (::g->finalecount-230)/2;
if (scrolled > 320)
scrolled = 320;
if (scrolled < 0)
scrolled = 0;
for ( x=0 ; x<ORIGINAL_WIDTH ; x++)
{
if (x+scrolled < 320)
F_DrawPatchCol (x, p1, x+scrolled);
else
F_DrawPatchCol (x, p2, x+scrolled - 320);
}
if (::g->finalecount < 1130)
return;
if (::g->finalecount < 1180)
{
V_DrawPatch ((ORIGINAL_WIDTH-13*8)/2,
(ORIGINAL_HEIGHT-8*8)/2,0, (patch_t*)W_CacheLumpName ("END0",PU_CACHE_SHARED));
::g->laststage = 0;
return;
}
stage = (::g->finalecount-1180) / 5;
if (stage > 6)
stage = 6;
if (stage > ::g->laststage)
{
S_StartSound (NULL, sfx_pistol);
::g->laststage = stage;
}
sprintf (name,"END%i",stage);
V_DrawPatch ((ORIGINAL_WIDTH-13*8)/2, (ORIGINAL_HEIGHT-8*8)/2,0, (patch_t*)W_CacheLumpName (name,PU_CACHE_SHARED));
}
//
// F_Drawer
//
void F_Drawer (void)
{
if (::g->finalestage == 2)
{
F_CastDrawer ();
return;
}
if (!::g->finalestage)
F_TextWrite ();
else
{
switch (::g->gameepisode)
{
case 1:
if ( ::g->gamemode == retail )
V_DrawPatch (0,0,0,
(patch_t*)W_CacheLumpName("CREDIT",PU_CACHE_SHARED));
else
V_DrawPatch (0,0,0,
(patch_t*)W_CacheLumpName("HELP2",PU_CACHE_SHARED));
break;
case 2:
V_DrawPatch(0,0,0,
(patch_t*)W_CacheLumpName("VICTORY2",PU_CACHE_SHARED));
break;
case 3:
F_BunnyScroll ();
break;
case 4:
V_DrawPatch (0,0,0,
(patch_t*)W_CacheLumpName("ENDPIC",PU_CACHE_SHARED));
break;
}
}
}

View File

@@ -0,0 +1,55 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __F_FINALE__
#define __F_FINALE__
#include "doomtype.h"
#include "d_event.h"
//
// FINALE
//
// Called by main loop.
qboolean F_Responder (event_t* ev);
// Called by main loop.
void F_Ticker (void);
// Called by main loop.
void F_Drawer (void);
void F_StartFinale (void);
#endif

235
doomclassic/doom/f_wipe.cpp Normal file
View File

@@ -0,0 +1,235 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "z_zone.h"
#include "i_video.h"
#include "i_system.h"
#include "v_video.h"
#include "m_random.h"
#include "doomdef.h"
#include "f_wipe.h"
//
// SCREEN WIPE PACKAGE
//
// when zero, stop the wipe
void
wipe_shittyColMajorXform
( short* array,
int width,
int height )
{
int x;
int y;
short* dest;
//dest = (short*) DoomLib::Z_Malloc(width*height*2, PU_STATIC, 0 );
dest = new short[ width * height ];
for(y=0;y<height;y++)
for(x=0;x<width;x++)
dest[x*height+y] = array[y*width+x];
memcpy(array, dest, width*height*2);
//Z_Free(dest);
delete[] dest;
}
int
wipe_initMelt
( int width,
int height,
int ticks )
{
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);
for (i=1;i<width;i++)
{
r = (M_Random()%3) - 1;
::g->wipe_y[i] = ::g->wipe_y[i-1] + r;
if (::g->wipe_y[i] > 0)
::g->wipe_y[i] = 0;
else if (::g->wipe_y[i] == -16)
::g->wipe_y[i] = -15;
}
return 0;
}
int wipe_doMelt( int width, int height, int ticks ) {
int i;
int j;
int dy;
int idx;
short* s;
short* d;
qboolean done = true;
width/=2;
while (ticks--)
{
for (i=0;i<width;i++)
{
if (::g->wipe_y[i]<0) {
::g->wipe_y[i]++;
done = false;
}
else if (::g->wipe_y[i] < height) {
dy = (::g->wipe_y[i] < 16 * GLOBAL_IMAGE_SCALER) ? ::g->wipe_y[i]+1 : 8 * GLOBAL_IMAGE_SCALER;
if (::g->wipe_y[i]+dy >= height)
dy = height - ::g->wipe_y[i];
s = &((short *)::g->wipe_scr_end)[i*height+::g->wipe_y[i]];
d = &((short *)::g->wipe_scr)[::g->wipe_y[i]*width+i];
idx = 0;
for (j=dy;j;j--)
{
d[idx] = *(s++);
idx += width;
}
::g->wipe_y[i] += dy;
s = &((short *)::g->wipe_scr_start)[i*height];
d = &((short *)::g->wipe_scr)[::g->wipe_y[i]*width+i];
idx = 0;
for (j=height-::g->wipe_y[i];j;j--)
{
d[idx] = *(s++);
idx += width;
}
done = false;
}
}
}
return done;
}
int
wipe_exitMelt
( int width,
int height,
int ticks )
{
Z_Free(::g->wipe_y);
::g->wipe_y = NULL;
return 0;
}
int
wipe_StartScreen
( int x,
int y,
int width,
int height )
{
::g->wipe_scr_start = ::g->screens[2];
I_ReadScreen(::g->wipe_scr_start);
return 0;
}
int
wipe_EndScreen
( int x,
int y,
int width,
int height )
{
::g->wipe_scr_end = ::g->screens[3];
I_ReadScreen(::g->wipe_scr_end);
V_DrawBlock(x, y, 0, width, height, ::g->wipe_scr_start); // restore start scr.
return 0;
}
int
wipe_ScreenWipe
( int x,
int y,
int width,
int height,
int ticks )
{
int rc;
// initial stuff
if (!::g->go)
{
::g->go = 1;
::g->wipe_scr = ::g->screens[0];
wipe_initMelt(width, height, ticks);
}
// do a piece of wipe-in
V_MarkRect(0, 0, width, height);
rc = wipe_doMelt(width, height, ticks);
// final stuff
if (rc)
{
::g->go = 0;
wipe_exitMelt(width, height, ticks);
}
return !::g->go;
}

61
doomclassic/doom/f_wipe.h Normal file
View File

@@ -0,0 +1,61 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __F_WIPE_H__
#define __F_WIPE_H__
//
// SCREEN WIPE PACKAGE
//
int
wipe_StartScreen
( int x,
int y,
int width,
int height );
int
wipe_EndScreen
( int x,
int y,
int width,
int height );
int
wipe_ScreenWipe
( int x,
int y,
int width,
int height,
int ticks );
#endif

2015
doomclassic/doom/g_game.cpp Normal file

File diff suppressed because it is too large Load Diff

84
doomclassic/doom/g_game.h Normal file
View File

@@ -0,0 +1,84 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __G_GAME__
#define __G_GAME__
#include "doomdef.h"
#include "d_event.h"
//
// GAME
//
void G_DeathMatchSpawnPlayer (int playernum);
void G_InitNew ( skill_t skill, int episode, int map );
// Can be called by the startup code or M_Responder.
// A normal game starts at map 1,
// but a warp test can start elsewhere
void G_DeferedInitNew (skill_t skill, int episode, int map);
void G_DeferedPlayDemo (char* demo);
// Can be called by the startup code or M_Responder,
// calls P_SetupLevel or W_EnterWorld.
void G_LoadGame (char* name);
qboolean G_DoLoadGame ();
// Called by M_Responder.
void G_SaveGame (int slot, char* description);
// Only called by startup code.
void G_RecordDemo (char* name);
void G_BeginRecording (void);
void G_PlayDemo (char* name);
void G_TimeDemo (char* name);
qboolean G_CheckDemoStatus (void);
void G_ExitLevel (void);
void G_SecretExitLevel (void);
void G_WorldDone (void);
void G_Ticker (void);
qboolean G_Responder (event_t* ev);
void G_ScreenShot (void);
#define MAXDEMOSIZE 512 * 1024
#define SAVEGAMESIZE 256 * 1024 + MAXDEMOSIZE
#endif

View File

@@ -0,0 +1,106 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "globaldata.h"
#include "Main.h"
//
// PROTOTYPES
//
void M_NewGame(int choice);
void M_Episode(int choice);
void M_Expansion(int choice);
void M_ChooseSkill(int choice);
void M_LoadGame(int choice);
void M_LoadExpansion(int choice);
void M_SaveGame(int choice);
void M_Options(int choice);
void M_EndGame(int choice);
void M_ReadThis(int choice);
void M_ReadThis2(int choice);
void M_QuitDOOM(int choice);
void M_ExitGame(int choice);
void M_GameSelection(int choice);
void M_CancelExit(int choice);
void M_ChangeMessages(int choice);
void M_ChangeGPad(int choice);
void M_FullScreen(int choice);
void M_ChangeSensitivity(int choice);
void M_SfxVol(int choice);
void M_MusicVol(int choice);
void M_ChangeDetail(int choice);
void M_SizeDisplay(int choice);
void M_StartGame(int choice);
void M_Sound(int choice);
void M_FinishReadThis(int choice);
void M_LoadSelect(int choice);
void M_SaveSelect(int choice);
void M_ReadSaveStrings(void);
void M_QuickSave(void);
void M_QuickLoad(void);
void M_DrawMainMenu(void);
void M_DrawQuit(void);
void M_DrawReadThis1(void);
void M_DrawReadThis2(void);
void M_DrawNewGame(void);
void M_DrawEpisode(void);
void M_DrawOptions(void);
void M_DrawSound(void);
void M_DrawLoad(void);
void M_DrawSave(void);
void M_DrawSaveLoadBorder(int x,int y);
void M_SetupNextMenu(menu_t *menudef);
void M_DrawThermo(int x,int y,int thermWidth,int thermDot);
void M_DrawEmptyCell(menu_t *menu,int item);
void M_DrawSelCell(menu_t *menu,int item);
void M_WriteText(int x, int y, char *string);
int M_StringWidth(char *string);
int M_StringHeight(char *string);
void M_StartControlPanel(void);
void M_StartMessage(char *string,messageRoutine_t routine,qboolean input);
void M_StopMessage(void);
void M_ClearMenus (void);
extern const anim_t temp_epsd0animinfo[10];
extern const anim_t temp_epsd1animinfo[9];
extern const anim_t temp_epsd2animinfo[6];
extern const char* const temp_chat_macros[];
void Globals::InitGlobals()
{
#include "constructs.h"
}
Globals *g;

View File

@@ -0,0 +1,71 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef _GLOBAL_DATA_H
#define _GLOBAL_DATA_H
#include "doomtype.h"
#include "d_net.h"
#include "m_fixed.h"
#include "info.h"
#include "sounds.h"
#include "r_defs.h"
#include "z_zone.h"
#include "d_player.h"
#include "m_cheat.h"
#include "doomlib.h"
#include "d_main.h"
#include "hu_lib.h"
#include "hu_stuff.h"
#include "p_spec.h"
#include "p_local.h"
#include "r_bsp.h"
#include "st_stuff.h"
#include "st_lib.h"
#include "w_wad.h"
#include "dstrings.h"
#include "typedefs.h"
#include "defs.h"
#include "structs.h"
struct Globals {
void InitGlobals();
#include "vars.h"
};
extern Globals *g;
#define GLOBAL( type, name ) type name
#define GLOBAL_ARRAY( type, name, count ) type name[count]
extern void localCalculateAchievements(bool epComplete);
#endif

358
doomclassic/doom/hu_lib.cpp Normal file
View File

@@ -0,0 +1,358 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <ctype.h>
#include "doomdef.h"
#include "v_video.h"
#include "m_swap.h"
#include "hu_lib.h"
#include "r_local.h"
#include "r_draw.h"
// qboolean : whether the screen is always erased
void HUlib_init(void)
{
}
void HUlib_clearTextLine(hu_textline_t* t)
{
t->len = 0;
t->l[0] = 0;
t->needsupdate = true;
}
void
HUlib_initTextLine
( hu_textline_t* t,
int x,
int y,
patch_t** f,
int sc )
{
t->x = x;
t->y = y;
t->f = f;
t->sc = sc;
HUlib_clearTextLine(t);
}
qboolean
HUlib_addCharToTextLine
( hu_textline_t* t,
char ch )
{
if (t->len == HU_MAXLINELENGTH)
return false;
else
{
t->l[t->len++] = ch;
t->l[t->len] = 0;
t->needsupdate = 4;
return true;
}
}
qboolean HUlib_delCharFromTextLine(hu_textline_t* t)
{
if (!t->len) return false;
else
{
t->l[--t->len] = 0;
t->needsupdate = 4;
return true;
}
}
void
HUlib_drawTextLine
( hu_textline_t* l,
qboolean drawcursor )
{
int i;
int w;
int x;
unsigned char c;
// draw the new stuff
x = l->x;
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);
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;
}
}
// draw the cursor if requested
if (drawcursor
&& x + SHORT(l->f['_' - l->sc]->width) <= SCREENWIDTH)
{
V_DrawPatchDirect(x, l->y, FG, l->f['_' - l->sc]);
}
}
// sorta called by HU_Erase and just better darn get things straight
void HUlib_eraseTextLine(hu_textline_t* l)
{
int lh;
int y;
int yoffset;
// Only erases when NOT in automap and the screen is reduced,
// and the text must either need updating or refreshing
// (because of a recent change back from the automap)
if (!::g->automapactive &&
::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)
R_VideoErase(yoffset, SCREENWIDTH); // erase entire line
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;
if (l->needsupdate) l->needsupdate--;
}
void
HUlib_initSText
( hu_stext_t* s,
int x,
int y,
int h,
patch_t** font,
int startchar,
qboolean* on )
{
int i;
s->h = h;
s->on = on;
s->laston = true;
s->cl = 0;
for (i=0;i<h;i++)
HUlib_initTextLine(&s->l[i],
x, y - i*(SHORT(font[0]->height)+1),
font, startchar);
}
void HUlib_addLineToSText(hu_stext_t* s)
{
int i;
// add a clear line
if (++s->cl == s->h)
s->cl = 0;
HUlib_clearTextLine(&s->l[s->cl]);
// everything needs updating
for (i=0 ; i<s->h ; i++)
s->l[i].needsupdate = 4;
}
void
HUlib_addMessageToSText
( hu_stext_t* s,
const char* prefix,
const char* msg )
{
HUlib_addLineToSText(s);
if (prefix)
while (*prefix)
HUlib_addCharToTextLine(&s->l[s->cl], *(prefix++));
while (*msg)
HUlib_addCharToTextLine(&s->l[s->cl], *(msg++));
}
void HUlib_drawSText(hu_stext_t* s)
{
int i, idx;
hu_textline_t *l;
if (!*s->on)
return; // if not on, don't draw
// draw everything
for (i=0 ; i<s->h ; i++)
{
idx = s->cl - i;
if (idx < 0)
idx += s->h; // handle queue of ::g->lines
l = &s->l[idx];
// 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)
{
int i;
for (i=0 ; i<s->h ; i++)
{
if (s->laston && !*s->on)
s->l[i].needsupdate = 4;
HUlib_eraseTextLine(&s->l[i]);
}
s->laston = *s->on;
}
void
HUlib_initIText
( hu_itext_t* it,
int x,
int y,
patch_t** font,
int startchar,
qboolean* on )
{
it->lm = 0; // default left margin is start of text
it->on = on;
it->laston = true;
HUlib_initTextLine(&it->l, x, y, font, startchar);
}
// The following deletion routines adhere to the left margin restriction
void HUlib_delCharFromIText(hu_itext_t* it)
{
if (it->l.len != it->lm)
HUlib_delCharFromTextLine(&it->l);
}
void HUlib_eraseLineFromIText(hu_itext_t* it)
{
while (it->lm != it->l.len)
HUlib_delCharFromTextLine(&it->l);
}
// Resets left margin as well
void HUlib_resetIText(hu_itext_t* it)
{
it->lm = 0;
HUlib_clearTextLine(&it->l);
}
void
HUlib_addPrefixToIText
( hu_itext_t* it,
char* str )
{
while (*str)
HUlib_addCharToTextLine(&it->l, *(str++));
it->lm = it->l.len;
}
// wrapper function for handling general keyed input.
// returns true if it ate the key
qboolean
HUlib_keyInIText
( hu_itext_t* it,
unsigned char ch )
{
if (ch >= ' ' && ch <= '_')
HUlib_addCharToTextLine(&it->l, (char) ch);
else
if (ch == KEY_BACKSPACE)
HUlib_delCharFromIText(it);
else
if (ch != KEY_ENTER)
return false; // did not eat key
return true; // ate the key
}
void HUlib_drawIText(hu_itext_t* it)
{
hu_textline_t *l = &it->l;
if (!*it->on)
return;
HUlib_drawTextLine(l, true); // draw the line w/ cursor
}
void HUlib_eraseIText(hu_itext_t* it)
{
if (it->laston && !*it->on)
it->l.needsupdate = 4;
HUlib_eraseTextLine(&it->l);
it->laston = *it->on;
}

194
doomclassic/doom/hu_lib.h Normal file
View File

@@ -0,0 +1,194 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __HULIB__
#define __HULIB__
// We are referring to patches.
#include "r_defs.h"
// font stuff
#define HU_CHARERASE KEY_BACKSPACE
#define HU_MAXLINES 4
#define HU_MAXLINELENGTH 80
//
// Typedefs of widgets
//
// Text Line widget
// (parent of Scrolling Text and Input Text widgets)
typedef struct
{
// left-justified position of scrolling text window
int x;
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
int needsupdate;
} hu_textline_t;
// Scrolling Text window widget
// (child of Text Line widget)
typedef struct
{
hu_textline_t l[HU_MAXLINES]; // text lines to draw
int h; // height in lines
int cl; // current line number
// pointer to qboolean stating whether to update window
qboolean* on;
qboolean laston; // last value of *->on.
} hu_stext_t;
// Input Text Line widget
// (child of Text Line widget)
typedef struct
{
hu_textline_t l; // text line to input on
// left margin past which I am not to delete characters
int lm;
// pointer to qboolean stating whether to update window
qboolean* on;
qboolean laston; // last value of *->on;
} hu_itext_t;
//
// Widget creation, access, and update routines
//
// initializes heads-up widget library
void HUlib_init(void);
//
// textline code
//
// clear a line of text
void HUlib_clearTextLine(hu_textline_t *t);
void HUlib_initTextLine(hu_textline_t *t, int x, int y, patch_t **f, int sc);
// returns success
qboolean HUlib_addCharToTextLine(hu_textline_t *t, char ch);
// returns success
qboolean HUlib_delCharFromTextLine(hu_textline_t *t);
// draws tline
void HUlib_drawTextLine(hu_textline_t *l, qboolean drawcursor);
// erases text line
void HUlib_eraseTextLine(hu_textline_t *l);
//
// Scrolling Text window widget routines
//
// ?
void
HUlib_initSText
( hu_stext_t* s,
int x,
int y,
int h,
patch_t** font,
int startchar,
qboolean* on );
// add a new line
void HUlib_addLineToSText(hu_stext_t* s);
// ?
void
HUlib_addMessageToSText
( hu_stext_t* s,
const char* prefix,
const char* msg );
// draws stext
void HUlib_drawSText(hu_stext_t* s);
// erases all stext lines
void HUlib_eraseSText(hu_stext_t* s);
// Input Text Line widget routines
void
HUlib_initIText
( hu_itext_t* it,
int x,
int y,
patch_t** font,
int startchar,
qboolean* on );
// enforces left margin
void HUlib_delCharFromIText(hu_itext_t* it);
// enforces left margin
void HUlib_eraseLineFromIText(hu_itext_t* it);
// resets line and left margin
void HUlib_resetIText(hu_itext_t* it);
// left of left-margin
void
HUlib_addPrefixToIText
( hu_itext_t* it,
char* str );
// whether eaten
qboolean
HUlib_keyInIText
( hu_itext_t* it,
unsigned char ch );
void HUlib_drawIText(hu_itext_t* it);
// erases all itext lines
void HUlib_eraseIText(hu_itext_t* it);
#endif

View File

@@ -0,0 +1,625 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <ctype.h>
#include "doomdef.h"
#include "z_zone.h"
#include "m_swap.h"
#include "hu_stuff.h"
#include "hu_lib.h"
#include "w_wad.h"
#include "s_sound.h"
#include "doomstat.h"
// Data.
#include "dstrings.h"
#include "sounds.h"
#include "Main.h"
//
// Locally used constants, shortcuts.
//
extern const char* const temp_chat_macros[];
const char* const temp_chat_macros[] =
{
HUSTR_CHATMACRO0,
HUSTR_CHATMACRO1,
HUSTR_CHATMACRO2,
HUSTR_CHATMACRO3,
HUSTR_CHATMACRO4,
HUSTR_CHATMACRO5,
HUSTR_CHATMACRO6,
HUSTR_CHATMACRO7,
HUSTR_CHATMACRO8,
HUSTR_CHATMACRO9
};
extern const char* const player_names[];
const char* const player_names[] =
{
HUSTR_PLRGREEN,
HUSTR_PLRINDIGO,
HUSTR_PLRBROWN,
HUSTR_PLRRED
};
//
// Builtin map names.
// The actual names can be found in DStrings.h.
//
const char* mapnames[] =
{
HUSTR_E1M1,
HUSTR_E1M2,
HUSTR_E1M3,
HUSTR_E1M4,
HUSTR_E1M5,
HUSTR_E1M6,
HUSTR_E1M7,
HUSTR_E1M8,
HUSTR_E1M9,
HUSTR_E2M1,
HUSTR_E2M2,
HUSTR_E2M3,
HUSTR_E2M4,
HUSTR_E2M5,
HUSTR_E2M6,
HUSTR_E2M7,
HUSTR_E2M8,
HUSTR_E2M9,
HUSTR_E3M1,
HUSTR_E3M2,
HUSTR_E3M3,
HUSTR_E3M4,
HUSTR_E3M5,
HUSTR_E3M6,
HUSTR_E3M7,
HUSTR_E3M8,
HUSTR_E3M9,
HUSTR_E4M1,
HUSTR_E4M2,
HUSTR_E4M3,
HUSTR_E4M4,
HUSTR_E4M5,
HUSTR_E4M6,
HUSTR_E4M7,
HUSTR_E4M8,
HUSTR_E4M9,
"NEWLEVEL",
"NEWLEVEL",
"NEWLEVEL",
"NEWLEVEL",
"NEWLEVEL",
"NEWLEVEL",
"NEWLEVEL",
"NEWLEVEL",
"NEWLEVEL"
};
const char* mapnames2[] =
{
HUSTR_1,
HUSTR_2,
HUSTR_3,
HUSTR_4,
HUSTR_5,
HUSTR_6,
HUSTR_7,
HUSTR_8,
HUSTR_9,
HUSTR_10,
HUSTR_11,
HUSTR_12,
HUSTR_13,
HUSTR_14,
HUSTR_15,
HUSTR_16,
HUSTR_17,
HUSTR_18,
HUSTR_19,
HUSTR_20,
HUSTR_21,
HUSTR_22,
HUSTR_23,
HUSTR_24,
HUSTR_25,
HUSTR_26,
HUSTR_27,
HUSTR_28,
HUSTR_29,
HUSTR_30,
HUSTR_31,
HUSTR_32,
HUSTR_33
};
const char* mapnamesp[] =
{
PHUSTR_1,
PHUSTR_2,
PHUSTR_3,
PHUSTR_4,
PHUSTR_5,
PHUSTR_6,
PHUSTR_7,
PHUSTR_8,
PHUSTR_9,
PHUSTR_10,
PHUSTR_11,
PHUSTR_12,
PHUSTR_13,
PHUSTR_14,
PHUSTR_15,
PHUSTR_16,
PHUSTR_17,
PHUSTR_18,
PHUSTR_19,
PHUSTR_20,
PHUSTR_21,
PHUSTR_22,
PHUSTR_23,
PHUSTR_24,
PHUSTR_25,
PHUSTR_26,
PHUSTR_27,
PHUSTR_28,
PHUSTR_29,
PHUSTR_30,
PHUSTR_31,
PHUSTR_32
};
// TNT WAD map names.
const char *mapnamest[] =
{
THUSTR_1,
THUSTR_2,
THUSTR_3,
THUSTR_4,
THUSTR_5,
THUSTR_6,
THUSTR_7,
THUSTR_8,
THUSTR_9,
THUSTR_10,
THUSTR_11,
THUSTR_12,
THUSTR_13,
THUSTR_14,
THUSTR_15,
THUSTR_16,
THUSTR_17,
THUSTR_18,
THUSTR_19,
THUSTR_20,
THUSTR_21,
THUSTR_22,
THUSTR_23,
THUSTR_24,
THUSTR_25,
THUSTR_26,
THUSTR_27,
THUSTR_28,
THUSTR_29,
THUSTR_30,
THUSTR_31,
THUSTR_32
};
const char* shiftxform;
const char english_shiftxform[] =
{
0,
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
31,
' ', '!', '"', '#', '$', '%', '&',
'"', // shift-'
'(', ')', '*', '+',
'<', // shift-,
'_', // shift--
'>', // shift-.
'?', // shift-/
')', // shift-0
'!', // shift-1
'@', // shift-2
'#', // shift-3
'$', // shift-4
'%', // shift-5
'^', // shift-6
'&', // shift-7
'*', // shift-8
'(', // shift-9
':',
':', // shift-;
'<',
'+', // shift-=
'>', '?', '@',
'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',
'[', // shift-[
'!', // shift-backslash - OH MY GOD DOES WATCOM SUCK
']', // shift-]
'"', '_',
'\'', // shift-`
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'{', '|', '}', '~', 127
};
char ForeignTranslation(unsigned char ch)
{
return ch;
}
void HU_Init(void)
{
int i;
int j;
char buffer[9];
shiftxform = english_shiftxform;
// load the heads-up font
j = HU_FONTSTART;
for (i=0;i<HU_FONTSIZE;i++)
{
sprintf(buffer, "STCFN%.3d", j++);
::g->hu_font[i] = (patch_t *) W_CacheLumpName(buffer, PU_STATIC_SHARED);
}
}
void HU_Stop(void)
{
::g->headsupactive = false;
}
void HU_Start(void)
{
int i;
const char* s;
if (::g->headsupactive)
HU_Stop();
::g->plr = &::g->players[::g->consoleplayer];
::g->message_on = false;
::g->message_dontfuckwithme = false;
::g->message_nottobefuckedwith = false;
::g->chat_on = false;
// create the message widget
HUlib_initSText(&::g->w_message,
HU_MSGX, HU_MSGY, HU_MSGHEIGHT,
::g->hu_font,
HU_FONTSTART, &::g->message_on);
// create the map title widget
HUlib_initTextLine(&::g->w_title,
HU_TITLEX, HU_TITLEY,
::g->hu_font,
HU_FONTSTART);
switch ( ::g->gamemode )
{
case shareware:
case registered:
case retail:
s = HU_TITLE;
break;
case commercial:
default:
if( DoomLib::expansionSelected == 5 ) {
int map = ::g->gamemap;
if( ::g->gamemap > 9 ) {
map = 0;
}
s = DoomLib::GetCurrentExpansion()->mapNames[ map - 1 ];
} else {
s = DoomLib::GetCurrentExpansion()->mapNames[ ::g->gamemap - 1 ];
}
break;
}
while (*s)
HUlib_addCharToTextLine(&::g->w_title, *(s++));
// create the chat widget
HUlib_initIText(&::g->w_chat,
HU_INPUTX, HU_INPUTY,
::g->hu_font,
HU_FONTSTART, &::g->chat_on);
// create the inputbuffer widgets
for (i=0 ; i<MAXPLAYERS ; i++)
HUlib_initIText(&::g->w_inputbuffer[i], 0, 0, 0, 0, &::g->always_off);
::g->headsupactive = true;
}
void HU_Drawer(void)
{
HUlib_drawSText(&::g->w_message);
HUlib_drawIText(&::g->w_chat);
if (::g->automapactive)
HUlib_drawTextLine(&::g->w_title, false);
}
void HU_Erase(void)
{
HUlib_eraseSText(&::g->w_message);
HUlib_eraseIText(&::g->w_chat);
HUlib_eraseTextLine(&::g->w_title);
}
void HU_Ticker(void)
{
// tick down message counter if message is up
if (::g->message_counter && !--::g->message_counter)
{
::g->message_on = false;
::g->message_nottobefuckedwith = false;
}
if ( ( m_inDemoMode.GetBool() == false && m_show_messages.GetBool() ) || ::g->message_dontfuckwithme)
{
// display message if necessary
if ((::g->plr->message && !::g->message_nottobefuckedwith)
|| (::g->plr->message && ::g->message_dontfuckwithme))
{
HUlib_addMessageToSText(&::g->w_message, 0, ::g->plr->message);
::g->plr->message = 0;
::g->message_on = true;
::g->message_counter = HU_MSGTIMEOUT;
::g->message_nottobefuckedwith = ::g->message_dontfuckwithme;
::g->message_dontfuckwithme = 0;
}
} // else ::g->message_on = false;
}
void HU_queueChatChar(char c)
{
if (((::g->head + 1) & (QUEUESIZE-1)) == ::g->tail)
{
::g->plr->message = HUSTR_MSGU;
}
else
{
::g->chatchars[::g->head] = c;
::g->head = (::g->head + 1) & (QUEUESIZE-1);
}
}
char HU_dequeueChatChar(void)
{
char c;
if (::g->head != ::g->tail)
{
c = ::g->chatchars[::g->tail];
::g->tail = (::g->tail + 1) & (QUEUESIZE-1);
}
else
{
c = 0;
}
return c;
}
qboolean HU_Responder(event_t *ev)
{
const char* macromessage;
qboolean eatkey = false;
unsigned char c;
int i;
int numplayers;
const static char destination_keys[MAXPLAYERS] =
{
HUSTR_KEYGREEN,
HUSTR_KEYINDIGO,
HUSTR_KEYBROWN,
HUSTR_KEYRED
};
numplayers = 0;
for (i=0 ; i<MAXPLAYERS ; i++)
numplayers += ::g->playeringame[i];
if (ev->data1 == KEY_RSHIFT)
{
::g->shiftdown = ev->type == ev_keydown;
return false;
}
else if (ev->data1 == KEY_RALT || ev->data1 == KEY_LALT)
{
::g->altdown = ev->type == ev_keydown;
return false;
}
if (ev->type != ev_keydown)
return false;
if (!::g->chat_on)
{
if (ev->data1 == HU_MSGREFRESH)
{
::g->message_on = true;
::g->message_counter = HU_MSGTIMEOUT;
eatkey = true;
}
else if (::g->netgame && ev->data1 == HU_INPUTTOGGLE)
{
eatkey = ::g->chat_on = true;
HUlib_resetIText(&::g->w_chat);
HU_queueChatChar(HU_BROADCAST);
}
else if (::g->netgame && numplayers > 2)
{
for (i=0; i<MAXPLAYERS ; i++)
{
if (ev->data1 == destination_keys[i])
{
if (::g->playeringame[i] && i!=::g->consoleplayer)
{
eatkey = ::g->chat_on = true;
HUlib_resetIText(&::g->w_chat);
HU_queueChatChar(i+1);
break;
}
else if (i == ::g->consoleplayer)
{
::g->num_nobrainers++;
if (::g->num_nobrainers < 3)
::g->plr->message = HUSTR_TALKTOSELF1;
else if (::g->num_nobrainers < 6)
::g->plr->message = HUSTR_TALKTOSELF2;
else if (::g->num_nobrainers < 9)
::g->plr->message = HUSTR_TALKTOSELF3;
else if (::g->num_nobrainers < 32)
::g->plr->message = HUSTR_TALKTOSELF4;
else
::g->plr->message = HUSTR_TALKTOSELF5;
}
}
}
}
}
else
{
c = ev->data1;
// send a macro
if (::g->altdown)
{
c = c - '0';
if (c > 9)
return false;
// I_PrintfE( "got here\n");
macromessage = temp_chat_macros[c];
// kill last message with a '\n'
HU_queueChatChar(KEY_ENTER); // DEBUG!!!
// send the macro message
while (*macromessage)
HU_queueChatChar(*macromessage++);
HU_queueChatChar(KEY_ENTER);
// leave chat mode and notify that it was sent
::g->chat_on = false;
strcpy(::g->lastmessage, temp_chat_macros[c]);
::g->plr->message = ::g->lastmessage;
eatkey = true;
}
else
{
if (::g->shiftdown || (c >= 'a' && c <= 'z'))
c = shiftxform[c];
eatkey = HUlib_keyInIText(&::g->w_chat, c);
if (eatkey)
{
// static unsigned char buf[20]; // DEBUG
HU_queueChatChar(c);
// sprintf(buf, "KEY: %d => %d", ev->data1, c);
// ::g->plr->message = buf;
}
if (c == KEY_ENTER)
{
::g->chat_on = false;
if (::g->w_chat.l.len)
{
strcpy(::g->lastmessage, ::g->w_chat.l.l);
::g->plr->message = ::g->lastmessage;
}
}
else if (c == KEY_ESCAPE)
::g->chat_on = false;
}
}
return eatkey;
}

View File

@@ -0,0 +1,70 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __HU_STUFF_H__
#define __HU_STUFF_H__
#include "d_event.h"
//
// Globally visible constants.
//
#define HU_FONTSTART '!' // the first font characters
#define HU_FONTEND '_' // the last font characters
// Calculate # of glyphs in font.
#define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1)
#define HU_BROADCAST 5
#define HU_MSGREFRESH KEY_ENTER
#define HU_MSGX 0
#define HU_MSGY 0
#define HU_MSGWIDTH 64 // in characters
#define HU_MSGHEIGHT 1 // in lines
#define HU_MSGTIMEOUT (4*TICRATE)
//
// HEADS UP TEXT
//
void HU_Init(void);
void HU_Start(void);
qboolean HU_Responder(event_t* ev);
void HU_Ticker(void);
void HU_Drawer(void);
char HU_dequeueChatChar(void);
void HU_Erase(void);
#endif

View File

@@ -0,0 +1,474 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
#include "i_video.h"
#include "i_system.h"
#include "doomstat.h"
#include "v_video.h"
#include "m_argv.h"
#include "d_main.h"
#include "doomdef.h"
#include "sys/sys_public.h"
#define ALLOW_CHEATS 1
extern int PLAYERCOUNT;
#define NUM_BUTTONS 4
static bool Cheat_God( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
::g->plyr->cheats ^= CF_GODMODE;
if (::g->plyr->cheats & CF_GODMODE)
{
if (::g->plyr->mo)
::g->plyr->mo->health = 100;
::g->plyr->health = 100;
::g->plyr->message = STSTR_DQDON;
}
else
::g->plyr->message = STSTR_DQDOFF;
return true;
}
#include "g_game.h"
static bool Cheat_NextLevel( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
G_ExitLevel();
return true;
}
static bool Cheat_GiveAll( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
::g->plyr->armorpoints = 200;
::g->plyr->armortype = 2;
int i;
for (i=0;i<NUMWEAPONS;i++)
::g->plyr->weaponowned[i] = true;
for (i=0;i<NUMAMMO;i++)
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
for (i=0;i<NUMCARDS;i++)
::g->plyr->cards[i] = true;
::g->plyr->message = STSTR_KFAADDED;
return true;
}
static bool Cheat_GiveAmmo( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
::g->plyr->armorpoints = 200;
::g->plyr->armortype = 2;
int i;
for (i=0;i<NUMWEAPONS;i++)
::g->plyr->weaponowned[i] = true;
for (i=0;i<NUMAMMO;i++)
::g->plyr->ammo[i] = ::g->plyr->maxammo[i];
::g->plyr->message = STSTR_KFAADDED;
return true;
}
static bool Cheat_Choppers( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
::g->plyr->weaponowned[wp_chainsaw] = true;
::g->plyr->message = "Chainsaw!";
return true;
}
extern qboolean P_GivePower ( player_t* player, int /*powertype_t*/ power );
static void TogglePowerUp( int i ) {
if (!::g->plyr->powers[i])
P_GivePower( ::g->plyr, i);
else if (i!=pw_strength)
::g->plyr->powers[i] = 1;
else
::g->plyr->powers[i] = 0;
::g->plyr->message = STSTR_BEHOLDX;
}
static bool Cheat_GiveInvul( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
TogglePowerUp( 0 );
return true;
}
static bool Cheat_GiveBerserk( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
TogglePowerUp( 1 );
return true;
}
static bool Cheat_GiveBlur( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
TogglePowerUp( 2 );
return true;
}
static bool Cheat_GiveRad( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
TogglePowerUp( 3 );
return true;
}
static bool Cheat_GiveMap( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
TogglePowerUp( 4 );
return true;
}
static bool Cheat_GiveLight( void ) {
if( PLAYERCOUNT != 1 || ::g->netgame ) {
return false;
}
TogglePowerUp( 5 );
return true;
}
#ifndef __PS3__
static bool tracking = false;
static int currentCode[NUM_BUTTONS];
static int currentCheatLength;
#endif
typedef bool(*cheat_command)(void);
struct cheatcode_t
{
int code[NUM_BUTTONS];
cheat_command function;
};
static cheatcode_t codes[] = {
{ {0, 1, 1, 0}, Cheat_God }, // a b b a
{ {0, 0, 1, 1}, Cheat_NextLevel }, // a a b b
{ {1, 0, 1, 0}, Cheat_GiveAmmo }, // b a b a
{ {1, 1, 0, 0}, Cheat_Choppers}, // b b a a
{ {0, 1, 0, 1}, Cheat_GiveAll }, // a b a b
{ {2, 3, 3, 2}, Cheat_GiveInvul }, // x y y x
{ {2, 2, 2, 3}, Cheat_GiveBerserk }, // x x x y
{ {2, 2, 3, 3}, Cheat_GiveBlur }, // x x y y
{ {2, 3, 3, 3}, Cheat_GiveRad }, // x y y y
{ {3, 2, 3, 2}, Cheat_GiveMap }, // y x y x
{ {3, 3, 3, 2}, Cheat_GiveLight}, // y y y x
};
const static int numberOfCodes = sizeof(codes) / sizeof(codes[0]);
void BeginTrackingCheat( void ) {
#if ALLOW_CHEATS
tracking = true;
currentCheatLength = 0;
memset( currentCode, 0, sizeof( currentCode ) );
#endif
}
void EndTrackingCheat( void ) {
#if ALLOW_CHEATS
tracking = false;
#endif
}
extern void S_StartSound ( void* origin, int sfx_id );
void CheckCheat( int button ) {
#if ALLOW_CHEATS
if( tracking && !::g->netgame ) {
currentCode[ currentCheatLength++ ] = button;
if( currentCheatLength == NUM_BUTTONS ) {
for( int i = 0; i < numberOfCodes; ++i) {
if( memcmp( &codes[i].code[0], &currentCode[0], sizeof(currentCode) ) == 0 ) {
if(codes[i].function()) {
S_StartSound(0, sfx_cybsit);
}
}
}
// reset the code
memset( currentCode, 0, sizeof( currentCode ) );
currentCheatLength = 0;
}
}
#endif
}
float xbox_deadzone = 0.28f;
// input event storage
//PRIVATE TO THE INPUT THREAD!
void I_InitInput(void)
{
}
void I_ShutdownInput( void )
{
}
static float _joyAxisConvert(short x, float xbxScale, float dScale, float deadZone)
{
//const float signConverted = x - 127;
float y = x - 127;
y = y / xbxScale;
return (fabs(y) < deadZone) ? 0.f : (y * dScale);
}
int I_PollMouseInputEvents( controller_t *con)
{
int numEvents = 0;
return numEvents;
}
int I_ReturnMouseInputEvent( const int n, event_t* e) {
e->type = ev_mouse;
e->data1 = e->data2 = e->data3 = 0;
switch(::g->mouseEvents[n].type) {
case IETAxis:
switch (::g->mouseEvents[n].action)
{
case M_DELTAX:
e->data2 = ::g->mouseEvents[n].data;
break;
case M_DELTAY:
e->data3 = ::g->mouseEvents[n].data;
break;
}
return 1;
default:
break;
}
return 0;
}
int I_PollJoystickInputEvents( controller_t *con ) {
int numEvents = 0;
return numEvents;
}
//
// Translates the key currently in X_event
//
static int xlatekey(int key)
{
int rc = KEY_F1;
switch (key)
{
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 = '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;
}
int I_ReturnJoystickInputEvent( const int n, event_t* e) {
e->data1 = e->data2 = e->data3 = 0;
switch(::g->joyEvents[n].type)
{
case IETAxis:
e->type = ev_joystick;//ev_mouse;
switch (::g->joyEvents[n].action)
{
case J_DELTAX:
/*
if (::g->joyEvents[n].data < 0)
e->data2 = -1;
else if (::g->joyEvents[n].data > 0)
e->data2 = 1;
*/
e->data2 = ::g->joyEvents[n].data;
break;
case J_DELTAY:
e->type = ev_mouse;
e->data3 = ::g->joyEvents[n].data;
break;
}
return 1;
case IETButtonAnalog:
case IETButtonDigital:
if (::g->joyEvents[n].data)
e->type = ev_keydown;
else
e->type = ev_keyup;
e->data1 = xlatekey(::g->joyEvents[n].action);
return 1;
case IETNone:
break;
}
return 0;
}
void I_EndJoystickInputEvents( void ) {
int i;
for(i = 0; i < 18; i++)
{
::g->joyEvents[i].type = IETNone;
}
}

View File

@@ -0,0 +1,31 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"

View File

@@ -0,0 +1,59 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "i_system.h"
#include "d_event.h"
#include "d_net.h"
#include "m_argv.h"
#include "doomstat.h"
#ifdef __GNUG__
#pragma implementation "i_net.h"
#endif
#include "i_net.h"
// For some odd reason...
void NetSend (void);
qboolean NetListen (void);

49
doomclassic/doom/i_net.h Normal file
View File

@@ -0,0 +1,49 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __I_NET__
#define __I_NET__
#ifdef __GNUG__
#pragma interface
#endif
// Called by D_DoomMain.
void I_InitNetwork (void);
void I_NetCmd (void);
// DHM - Nerve
void I_ShutdownNetwork( void );
#endif

View File

@@ -0,0 +1,423 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <string>
#include <errno.h>
// Sockets
#include <sys/socket.h>
#include <sys/types.h>
#include <netex/errno.h>
#include <netex/net.h>
#include <arpa/inet.h>
#include "i_system.h"
#include "d_event.h"
#include "d_net.h"
#include "m_argv.h"
#include "doomstat.h"
#include "i_net.h"
#include "doomlib.h"
#include "../Main/Main.h"
void NetSend (void);
qboolean NetListen (void);
namespace {
bool IsValidSocket( int socketDescriptor );
int GetLastSocketError();
/*
========================
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.
========================
*/
bool IsValidSocket( int socketDescriptor ) {
return socketDescriptor >= 0;
}
/*
========================
Returns the last error reported by the platform's socket library.
========================
*/
int GetLastSocketError() {
return sys_net_errno;
}
}
//
// NETWORKING
//
int DOOMPORT = 1002; // DHM - Nerve :: On original XBox, ports 1000 - 1255 saved you a byte on every packet. 360 too?
unsigned long GetServerIP() {
return ::g->sendaddress[::g->doomcom.consoleplayer].sin_addr.s_addr;
}
void (*netget) (void);
void (*netsend) (void);
//
// UDPsocket
//
int UDPsocket (void)
{
int s;
// allocate a socket
s = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if ( !IsValidSocket( s ) ) {
int err = GetLastSocketError();
I_Error( "can't create socket, error %d", err );
}
return s;
}
//
// BindToLocalPort
//
void BindToLocalPort( int s, int port )
{
int v;
struct sockaddr_in address;
memset (&address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = port;
v = bind (s, (sockaddr*)&address, sizeof(address));
//if (v == -1)
//I_Error ("BindToPort: bind: %s", strerror(errno));
}
//
// PacketSend
//
void PacketSend (void)
{
int c;
doomdata_t sw;
// byte swap
sw.checksum = htonl(::g->netbuffer->checksum);
sw.sourceDest = DoomLib::BuildSourceDest(::g->doomcom.remotenode);
sw.player = ::g->netbuffer->player;
sw.retransmitfrom = ::g->netbuffer->retransmitfrom;
sw.starttic = ::g->netbuffer->starttic;
sw.numtics = ::g->netbuffer->numtics;
for (c=0 ; c< ::g->netbuffer->numtics ; c++)
{
sw.cmds[c].forwardmove = ::g->netbuffer->cmds[c].forwardmove;
sw.cmds[c].sidemove = ::g->netbuffer->cmds[c].sidemove;
sw.cmds[c].angleturn = htons(::g->netbuffer->cmds[c].angleturn);
sw.cmds[c].consistancy = htons(::g->netbuffer->cmds[c].consistancy);
sw.cmds[c].buttons = ::g->netbuffer->cmds[c].buttons;
}
// Send Socket
{
//DWORD num_sent;
//if ( globalNetworking ) {
// c = WSASendTo(::g->sendsocket, &buffer, 1, &num_sent, 0, (sockaddr*)&::g->sendaddress[::g->doomcom.remotenode],
// sizeof(::g->sendaddress[::g->doomcom.remotenode]), 0, 0);
//} else {
c = DoomLib::Send( (char*)&sw, ::g->doomcom.datalength, (sockaddr_in*)&::g->sendaddress[::g->doomcom.remotenode], ::g->doomcom.remotenode );
//}
}
}
//
// PacketGet
//
void PacketGet (void)
{
int i;
int c;
struct sockaddr_in fromaddress;
int fromlen;
doomdata_t sw;
DWORD num_recieved; //, flags = 0;
// Try and read a socket
//buffer.buf = (char*)&sw;
//buffer.len = sizeof(sw);
fromlen = sizeof(fromaddress);
//if ( globalNetworking ) {
// c = WSARecvFrom(::g->insocket, &buffer, 1, &num_recieved, &flags, (struct sockaddr*)&fromaddress, &fromlen, 0, 0);
//} else {
c = DoomLib::Recv( (char*)&sw, &num_recieved );
//}
if ( c < 0 )
{
/*if ( globalNetworking ) {
int err = WSAGetLastError();
if (err != WSAEWOULDBLOCK)
I_Error ("GetPacket: %s",strerror(errno));
}*/
::g->doomcom.remotenode = -1; // no packet
return;
}
// find remote node number
/*for (i=0 ; i<::g->doomcom.numnodes ; i++)
if ( fromaddress.sin_addr.s_addr == ::g->sendaddress[i].sin_addr.s_addr )
break;
if (i == ::g->doomcom.numnodes)
{
// packet is not from one of the ::g->players (new game broadcast)
::g->doomcom.remotenode = -1; // no packet
return;
}*/
//if ( ::g->consoleplayer == 1 ) {
//int x = 0;
//}
int source;
int dest;
DoomLib::GetSourceDest( sw.sourceDest, &source, &dest );
i = source;
//if ( ::g->consoleplayer == 1 ) {
//if ( i == 2 ) {
//int suck = 0;
//}
//}
::g->doomcom.remotenode = i; // good packet from a game player
::g->doomcom.datalength = (short)num_recieved;
// byte swap
::g->netbuffer->checksum = ntohl(sw.checksum);
::g->netbuffer->player = sw.player;
::g->netbuffer->retransmitfrom = sw.retransmitfrom;
::g->netbuffer->starttic = sw.starttic;
::g->netbuffer->numtics = sw.numtics;
for ( c = 0; c < ::g->netbuffer->numtics; c++ )
{
::g->netbuffer->cmds[c].forwardmove = sw.cmds[c].forwardmove;
::g->netbuffer->cmds[c].sidemove = sw.cmds[c].sidemove;
::g->netbuffer->cmds[c].angleturn = ntohs(sw.cmds[c].angleturn);
::g->netbuffer->cmds[c].consistancy = ntohs(sw.cmds[c].consistancy);
::g->netbuffer->cmds[c].buttons = sw.cmds[c].buttons;
}
}
static int I_TrySetupNetwork(void)
{
// DHM - Moved to Session
return 1;
}
//
// I_InitNetwork
//
void I_InitNetwork (void)
{
//qboolean trueval = true;
int i;
int p;
//int a = 0;
// struct hostent* hostentry; // host information entry
memset (&::g->doomcom, 0, sizeof(::g->doomcom) );
// set up for network
i = M_CheckParm ("-dup");
if (i && i< ::g->myargc-1)
{
::g->doomcom.ticdup = ::g->myargv[i+1][0]-'0';
if (::g->doomcom.ticdup < 1)
::g->doomcom.ticdup = 1;
if (::g->doomcom.ticdup > 9)
::g->doomcom.ticdup = 9;
}
else
::g->doomcom.ticdup = 1;
if (M_CheckParm ("-extratic"))
::g->doomcom.extratics = 1;
else
::g->doomcom.extratics = 0;
p = M_CheckParm ("-port");
if (p && p < ::g->myargc-1)
{
DOOMPORT = atoi (::g->myargv[p+1]);
I_Printf ("using alternate port %i\n",DOOMPORT);
}
// parse network game options,
// -net <::g->consoleplayer> <host> <host> ...
i = M_CheckParm ("-net");
if (!i || !I_TrySetupNetwork())
{
// single player game
::g->netgame = false;
::g->doomcom.id = DOOMCOM_ID;
::g->doomcom.numplayers = ::g->doomcom.numnodes = 1;
::g->doomcom.deathmatch = false;
::g->doomcom.consoleplayer = 0;
return;
}
netsend = PacketSend;
netget = PacketGet;
::g->netgame = true;
{
++i; // skip the '-net'
::g->doomcom.numnodes = 0;
::g->doomcom.consoleplayer = atoi( ::g->myargv[i] );
// skip the console number
++i;
::g->doomcom.numnodes = 0;
for (; i < ::g->myargc; ++i)
{
::g->sendaddress[::g->doomcom.numnodes].sin_family = AF_INET;
::g->sendaddress[::g->doomcom.numnodes].sin_port = htons(DOOMPORT);
// Pull out the port number.
const std::string ipAddressWithPort( ::g->myargv[i] );
const std::size_t colonPosition = ipAddressWithPort.find_last_of(':');
std::string ipOnly;
if( colonPosition != std::string::npos && colonPosition + 1 < ipAddressWithPort.size() ) {
const std::string portOnly( ipAddressWithPort.substr( colonPosition + 1 ) );
::g->sendaddress[::g->doomcom.numnodes].sin_port = htons( atoi( portOnly.c_str() ) );
ipOnly = ipAddressWithPort.substr( 0, colonPosition );
} else {
// Assume the address doesn't include a port.
ipOnly = ipAddressWithPort;
}
in_addr_t ipAddress = inet_addr( ipOnly.c_str() );
if ( ipAddress == INADDR_NONE ) {
I_Error( "Invalid IP Address: %s\n", ipOnly.c_str() );
session->QuitMatch();
common->AddDialog( GDM_OPPONENT_CONNECTION_LOST, DIALOG_ACCEPT, NULL, NULL, false );
}
::g->sendaddress[::g->doomcom.numnodes].sin_addr.s_addr = ipAddress;
::g->doomcom.numnodes++;
}
::g->doomcom.id = DOOMCOM_ID;
::g->doomcom.numplayers = ::g->doomcom.numnodes;
}
if ( globalNetworking ) {
// Setup sockets
::g->insocket = UDPsocket ();
BindToLocalPort (::g->insocket,htons(DOOMPORT));
// PS3 call to enable non-blocking mode
int nonblocking = 1; // Non-zero is nonblocking mode.
setsockopt( ::g->insocket, SOL_SOCKET, SO_NBIO, &nonblocking, sizeof(nonblocking));
::g->sendsocket = UDPsocket ();
I_Printf( "[+] Setting up sockets for player %d\n", DoomLib::GetPlayer() );
}
}
// DHM - Nerve
void I_ShutdownNetwork( void ) {
if ( globalNetworking && gameLocal != NULL ) {
int curPlayer = DoomLib::GetPlayer();
for (int player = 0; player < gameLocal->Interface.GetNumPlayers(); ++player)
{
DoomLib::SetPlayer( player );
if ( IsValidSocket( ::g->insocket ) ) {
I_Printf( "[-] Shut down insocket for player %d\n", DoomLib::GetPlayer() );
shutdown( ::g->insocket, SHUT_RDWR );
socketclose( ::g->insocket );
}
if ( IsValidSocket( ::g->sendsocket ) ) {
I_Printf( "[-] Shut down sendsocket for player %d\n", DoomLib::GetPlayer() );
shutdown( ::g->sendsocket, SHUT_RDWR );
socketclose( ::g->sendsocket );
}
}
DoomLib::SetPlayer(curPlayer);
globalNetworking = false;
}
}
void I_NetCmd (void)
{
if (::g->doomcom.command == CMD_SEND)
{
netsend ();
}
else if (::g->doomcom.command == CMD_GET)
{
netget ();
}
else
I_Error ("Bad net cmd: %i\n",::g->doomcom.command);
}

View File

@@ -0,0 +1,278 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <string>
#include <errno.h>
#include "i_system.h"
#include "d_event.h"
#include "d_net.h"
#include "m_argv.h"
#include "doomstat.h"
#include "i_net.h"
#include "doomlib.h"
void NetSend (void);
qboolean NetListen (void);
namespace {
bool IsValidSocket( int socketDescriptor );
int GetLastSocketError();
/*
========================
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.
========================
*/
bool IsValidSocket( int socketDescriptor ) {
return false;
}
/*
========================
Returns the last error reported by the platform's socket library.
========================
*/
int GetLastSocketError() {
return 0;
}
}
//
// NETWORKING
//
int DOOMPORT = 1002; // DHM - Nerve :: On original XBox, ports 1000 - 1255 saved you a byte on every packet. 360 too?
unsigned long GetServerIP() {
return ::g->sendaddress[::g->doomcom.consoleplayer].sin_addr.s_addr;
}
void (*netget) (void);
void (*netsend) (void);
//
// UDPsocket
//
int UDPsocket (void)
{
int s;
// allocate a socket
s = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if ( !IsValidSocket( s ) ) {
int err = GetLastSocketError();
I_Error( "can't create socket, error %d", err );
}
return s;
}
//
// BindToLocalPort
//
void BindToLocalPort( int s, int port )
{
}
//
// PacketSend
//
void PacketSend (void)
{
}
//
// PacketGet
//
void PacketGet (void)
{
}
static int I_TrySetupNetwork(void)
{
// DHM - Moved to Session
return 1;
}
//
// I_InitNetwork
//
void I_InitNetwork (void)
{
//qboolean trueval = true;
int i;
int p;
//int a = 0;
// struct hostent* hostentry; // host information entry
memset (&::g->doomcom, 0, sizeof(::g->doomcom) );
// set up for network
i = M_CheckParm ("-dup");
if (i && i< ::g->myargc-1)
{
::g->doomcom.ticdup = ::g->myargv[i+1][0]-'0';
if (::g->doomcom.ticdup < 1)
::g->doomcom.ticdup = 1;
if (::g->doomcom.ticdup > 9)
::g->doomcom.ticdup = 9;
}
else
::g->doomcom.ticdup = 1;
if (M_CheckParm ("-extratic"))
::g->doomcom.extratics = 1;
else
::g->doomcom.extratics = 0;
p = M_CheckParm ("-port");
if (p && p < ::g->myargc-1)
{
DOOMPORT = atoi (::g->myargv[p+1]);
I_Printf ("using alternate port %i\n",DOOMPORT);
}
// parse network game options,
// -net <::g->consoleplayer> <host> <host> ...
i = M_CheckParm ("-net");
if (!i || !I_TrySetupNetwork())
{
// single player game
::g->netgame = false;
::g->doomcom.id = DOOMCOM_ID;
::g->doomcom.numplayers = ::g->doomcom.numnodes = 1;
::g->doomcom.deathmatch = false;
::g->doomcom.consoleplayer = 0;
return;
}
netsend = PacketSend;
netget = PacketGet;
#ifdef ID_ENABLE_DOOM_CLASSIC_NETWORKING
::g->netgame = true;
{
++i; // skip the '-net'
::g->doomcom.numnodes = 0;
::g->doomcom.consoleplayer = atoi( ::g->myargv[i] );
// skip the console number
++i;
::g->doomcom.numnodes = 0;
for (; i < ::g->myargc; ++i)
{
::g->sendaddress[::g->doomcom.numnodes].sin_family = AF_INET;
::g->sendaddress[::g->doomcom.numnodes].sin_port = htons(DOOMPORT);
// Pull out the port number.
const std::string ipAddressWithPort( ::g->myargv[i] );
const std::size_t colonPosition = ipAddressWithPort.find_last_of(':');
std::string ipOnly;
if( colonPosition != std::string::npos && colonPosition + 1 < ipAddressWithPort.size() ) {
const std::string portOnly( ipAddressWithPort.substr( colonPosition + 1 ) );
::g->sendaddress[::g->doomcom.numnodes].sin_port = htons( atoi( portOnly.c_str() ) );
ipOnly = ipAddressWithPort.substr( 0, colonPosition );
} else {
// Assume the address doesn't include a port.
ipOnly = ipAddressWithPort;
}
in_addr_t ipAddress = inet_addr( ipOnly.c_str() );
if ( ipAddress == INADDR_NONE ) {
I_Error( "Invalid IP Address: %s\n", ipOnly.c_str() );
session->QuitMatch();
common->AddDialog( GDM_OPPONENT_CONNECTION_LOST, DIALOG_ACCEPT, NULL, NULL, false );
}
::g->sendaddress[::g->doomcom.numnodes].sin_addr.s_addr = ipAddress;
::g->doomcom.numnodes++;
}
::g->doomcom.id = DOOMCOM_ID;
::g->doomcom.numplayers = ::g->doomcom.numnodes;
}
if ( globalNetworking ) {
// Setup sockets
::g->insocket = UDPsocket ();
BindToLocalPort (::g->insocket,htons(DOOMPORT));
// PS3 call to enable non-blocking mode
int nonblocking = 1; // Non-zero is nonblocking mode.
setsockopt( ::g->insocket, SOL_SOCKET, SO_NBIO, &nonblocking, sizeof(nonblocking));
::g->sendsocket = UDPsocket ();
I_Printf( "[+] Setting up sockets for player %d\n", DoomLib::GetPlayer() );
}
#endif
}
// DHM - Nerve
void I_ShutdownNetwork( void ) {
}
void I_NetCmd (void)
{
if (::g->doomcom.command == CMD_SEND)
{
netsend ();
}
else if (::g->doomcom.command == CMD_GET)
{
netget ();
}
else
I_Error ("Bad net cmd: %i\n",::g->doomcom.command);
}

View File

@@ -0,0 +1,365 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "i_system.h"
#include "d_event.h"
#include "d_net.h"
#include "m_argv.h"
#include "doomstat.h"
#include "i_net.h"
#include "doomlib.h"
#include "../Main/Main.h"
void NetSend (void);
qboolean NetListen (void);
//
// NETWORKING
//
int DOOMPORT = 1002; // DHM - Nerve :: On original XBox, ports 1000 - 1255 saved you a byte on every packet. 360 too?
unsigned long GetServerIP() { return ::g->sendaddress[::g->doomcom.consoleplayer].sin_addr.s_addr; }
void (*netget) (void);
void (*netsend) (void);
//
// UDPsocket
//
int UDPsocket (void)
{
int s;
// allocate a socket
s = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (s == INVALID_SOCKET) {
int err = WSAGetLastError ();
I_Error ("can't create socket: %s",strerror(errno));
}
return s;
}
//
// BindToLocalPort
//
void BindToLocalPort( int s, int port )
{
int v;
struct sockaddr_in address;
memset (&address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_addr.s_addr = INADDR_ANY;
address.sin_port = port;
v = bind (s, (sockaddr*)&address, sizeof(address));
//if (v == -1)
//I_Error ("BindToPort: bind: %s", strerror(errno));
}
//
// PacketSend
//
void PacketSend (void)
{
int c;
doomdata_t sw;
// byte swap
sw.checksum = htonl(::g->netbuffer->checksum);
sw.sourceDest = DoomLib::BuildSourceDest(::g->doomcom.remotenode);
sw.player = ::g->netbuffer->player;
sw.retransmitfrom = ::g->netbuffer->retransmitfrom;
sw.starttic = ::g->netbuffer->starttic;
sw.numtics = ::g->netbuffer->numtics;
for (c=0 ; c< ::g->netbuffer->numtics ; c++)
{
sw.cmds[c].forwardmove = ::g->netbuffer->cmds[c].forwardmove;
sw.cmds[c].sidemove = ::g->netbuffer->cmds[c].sidemove;
sw.cmds[c].angleturn = htons(::g->netbuffer->cmds[c].angleturn);
//sw.cmds[c].consistancy = htons(::g->netbuffer->cmds[c].consistancy);
sw.cmds[c].buttons = ::g->netbuffer->cmds[c].buttons;
}
// Send Socket
{
//DWORD num_sent;
WSABUF buffer;
buffer.buf = (char*)&sw;
buffer.len = ::g->doomcom.datalength;
//if ( globalNetworking ) {
// c = WSASendTo(::g->sendsocket, &buffer, 1, &num_sent, 0, (sockaddr*)&::g->sendaddress[::g->doomcom.remotenode],
// sizeof(::g->sendaddress[::g->doomcom.remotenode]), 0, 0);
//} else {
c = DoomLib::Send( buffer.buf, buffer.len, (sockaddr_in*)&::g->sendaddress[::g->doomcom.remotenode], ::g->doomcom.remotenode );
//}
}
}
//
// PacketGet
//
void PacketGet (void)
{
int i;
int c;
struct sockaddr_in fromaddress;
int fromlen;
doomdata_t sw;
WSABUF buffer;
DWORD num_recieved, flags = 0;
// Try and read a socket
buffer.buf = (char*)&sw;
buffer.len = sizeof(sw);
fromlen = sizeof(fromaddress);
//if ( globalNetworking ) {
// c = WSARecvFrom(::g->insocket, &buffer, 1, &num_recieved, &flags, (struct sockaddr*)&fromaddress, &fromlen, 0, 0);
//} else {
c = DoomLib::Recv( (char*)&sw, &num_recieved );
//}
if (c == SOCKET_ERROR )
{
/*if ( globalNetworking ) {
int err = WSAGetLastError();
if (err != WSAEWOULDBLOCK)
I_Error ("GetPacket: %s",strerror(errno));
}*/
::g->doomcom.remotenode = -1; // no packet
return;
}
// find remote node number
/*for (i=0 ; i<::g->doomcom.numnodes ; i++)
if ( fromaddress.sin_addr.s_addr == ::g->sendaddress[i].sin_addr.s_addr )
break;
if (i == ::g->doomcom.numnodes)
{
// packet is not from one of the ::g->players (new game broadcast)
::g->doomcom.remotenode = -1; // no packet
return;
}*/
//if ( ::g->consoleplayer == 1 ) {
//int x = 0;
//}
int source;
int dest;
DoomLib::GetSourceDest( sw.sourceDest, &source, &dest );
i = source;
//if ( ::g->consoleplayer == 1 ) {
//if ( i == 2 ) {
//int suck = 0;
//}
//}
::g->doomcom.remotenode = i; // good packet from a game player
::g->doomcom.datalength = (short)num_recieved;
// byte swap
::g->netbuffer->checksum = ntohl(sw.checksum);
::g->netbuffer->player = sw.player;
::g->netbuffer->retransmitfrom = sw.retransmitfrom;
::g->netbuffer->starttic = sw.starttic;
::g->netbuffer->numtics = sw.numtics;
for (c=0 ; c< ::g->netbuffer->numtics ; c++)
{
::g->netbuffer->cmds[c].forwardmove = sw.cmds[c].forwardmove;
::g->netbuffer->cmds[c].sidemove = sw.cmds[c].sidemove;
::g->netbuffer->cmds[c].angleturn = ntohs(sw.cmds[c].angleturn);
//::g->netbuffer->cmds[c].consistancy = ntohs(sw.cmds[c].consistancy);
::g->netbuffer->cmds[c].buttons = sw.cmds[c].buttons;
}
}
static int I_TrySetupNetwork(void)
{
// DHM - Moved to Session
return 1;
}
//
// I_InitNetwork
//
void I_InitNetwork (void)
{
qboolean trueval = true;
int i;
int p;
int a = 0;
// struct hostent* hostentry; // host information entry
memset (&::g->doomcom, 0, sizeof(::g->doomcom) );
// set up for network
i = M_CheckParm ("-dup");
if (i && i< ::g->myargc-1)
{
::g->doomcom.ticdup = ::g->myargv[i+1][0]-'0';
if (::g->doomcom.ticdup < 1)
::g->doomcom.ticdup = 1;
if (::g->doomcom.ticdup > 9)
::g->doomcom.ticdup = 9;
}
else
::g->doomcom.ticdup = 1;
if (M_CheckParm ("-extratic"))
::g->doomcom.extratics = 1;
else
::g->doomcom.extratics = 0;
p = M_CheckParm ("-port");
if (p && p<::g->myargc-1)
{
DOOMPORT = atoi (::g->myargv[p+1]);
I_Printf ("using alternate port %i\n",DOOMPORT);
}
// parse network game options,
// -net <::g->consoleplayer> <host> <host> ...
i = M_CheckParm ("-net");
if (!i || !I_TrySetupNetwork())
{
// single player game
::g->netgame = false;
::g->doomcom.id = DOOMCOM_ID;
::g->doomcom.numplayers = ::g->doomcom.numnodes = 1;
::g->doomcom.deathmatch = false;
::g->doomcom.consoleplayer = 0;
return;
}
netsend = PacketSend;
netget = PacketGet;
::g->netgame = true;
{
++i; // skip the '-net'
::g->doomcom.numnodes = 0;
::g->doomcom.consoleplayer = atoi( ::g->myargv[i] );
// skip the console number
++i;
::g->doomcom.numnodes = 0;
for (; i < ::g->myargc; ++i)
{
::g->sendaddress[::g->doomcom.numnodes].sin_family = AF_INET;
::g->sendaddress[::g->doomcom.numnodes].sin_port = htons(DOOMPORT);
::g->sendaddress[::g->doomcom.numnodes].sin_addr.s_addr = inet_addr (::g->myargv[i]);//39, 17
::g->doomcom.numnodes++;
}
::g->doomcom.id = DOOMCOM_ID;
::g->doomcom.numplayers = ::g->doomcom.numnodes;
}
if ( globalNetworking ) {
// Setup sockets
::g->insocket = UDPsocket ();
BindToLocalPort (::g->insocket,htons(DOOMPORT));
ioctlsocket (::g->insocket, FIONBIO, (u_long*)&trueval);
::g->sendsocket = UDPsocket ();
I_Printf( "[+] Setting up sockets for player %d\n", DoomLib::GetPlayer() );
}
}
// DHM - Nerve
void I_ShutdownNetwork( void ) {
if ( globalNetworking ) {
int curPlayer = DoomLib::GetPlayer();
for (int player = 0; player < App->Game->Interface.GetNumPlayers(); ++player)
{
DoomLib::SetPlayer( player );
if ( ::g->insocket != INVALID_SOCKET ) {
I_Printf( "[-] Shut down insocket for player %d\n", DoomLib::GetPlayer() );
shutdown( ::g->insocket, SD_BOTH );
closesocket( ::g->insocket );
}
if ( ::g->sendsocket != INVALID_SOCKET ) {
I_Printf( "[-] Shut down sendsocket for player %d\n", DoomLib::GetPlayer() );
shutdown( ::g->sendsocket, SD_BOTH );
closesocket( ::g->sendsocket );
}
}
DoomLib::SetPlayer(curPlayer);
globalNetworking = false;
}
}
void I_NetCmd (void)
{
if (::g->doomcom.command == CMD_SEND)
{
netsend ();
}
else if (::g->doomcom.command == CMD_GET)
{
netget ();
}
else
I_Error ("Bad net cmd: %i\n",::g->doomcom.command);
}

113
doomclassic/doom/i_sound.h Normal file
View File

@@ -0,0 +1,113 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __I_SOUND__
#define __I_SOUND__
#include "doomdef.h"
// UNIX hack, to be removed.
#ifdef SNDSERV
#include <stdio.h>
extern FILE* sndserver;
extern char* sndserver_filename;
#endif
#include "doomstat.h"
#include "sounds.h"
// Init at program start...
void I_InitSound();
void I_InitSoundHardware( int numOutputChannels_, int channelMask );
// ... update sound buffer and audio device at runtime...
void I_UpdateSound(void);
void I_SubmitSound(void);
// ... shut down and relase at program termination.
void I_ShutdownSound(void);
void I_ShutdownSoundHardware();
//
// SFX I/O
//
// Initialize channels?
void I_SetChannels();
// Get raw data lump index for sound descriptor.
int I_GetSfxLumpNum (sfxinfo_t* sfxinfo );
// 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 );
// Stops a sound channel.
void I_StopSound(int handle, int player = -1);
// Called by S_*() functions
// to see if a channel is still playing.
// Returns 0 if no longer playing, 1 if playing.
int I_SoundIsPlaying(int handle);
// Updates the volume, separation,
// and pitch of a sound channel.
void I_UpdateSoundParams( int handle, int vol, int sep, int pitch );
void I_SetSfxVolume( int );
//
// MUSIC I/O
//
void I_InitMusic(void);
void I_ShutdownMusic(void);
// Volume.
void I_SetMusicVolume(int volume);
// PAUSE game handling.
void I_PauseSong(int handle);
void I_ResumeSong(int handle);
// Registers a song handle to song data.
int I_RegisterSong(void *data, int length);
// Called by anything that wishes to start music.
// plays a song, and when the song is done,
// starts playing it again in an endless loop.
// Horrible thing to do, considering.
void I_PlaySong( const char *songname, int looping );
// Stops a song over 3 seconds.
void I_StopSong(int handle);
// See above (register), then think backwards
void I_UnRegisterSong(int handle);
// Update Music (XMP), check for notifications
void I_UpdateMusic(void);
int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,189 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "doomdef.h"
#include "m_misc.h"
#include "i_video.h"
#include "i_sound.h"
#include "d_net.h"
#include "g_game.h"
#ifdef __GNUG__
#pragma implementation "i_system.h"
#endif
#include "i_system.h"
#include "Main.h"
#if 1
ticcmd_t* I_BaseTiccmd(void)
{
return &::g->emptycmd;
}
int I_GetHeapSize (void)
{
return ::g->mb_used*1024*1024;
}
//
// I_GetTime
// returns time in 1/70th second tics
//
int I_GetTime (void)
{
return ::g->current_time;
}
void I_SetTime( int time_in )
{
::g->current_time = time_in;
}
//
// I_Init
//
void I_Init (void)
{
I_InitSound();
// I_InitGraphics();
}
//
// I_Quit
//
void I_Quit (void)
{
D_QuitNetGame ();
I_ShutdownSound();
I_ShutdownMusic();
M_SaveDefaults ();
I_ShutdownGraphics();
// exit(0);
// Exceptions disabled by default on PS3
// throw;
}
void I_WaitVBL(int count)
{
// PS3 fixme
//Sleep(0);
}
void I_BeginRead(void)
{
}
void I_EndRead(void)
{
}
//
// I_Error
//
extern bool debugOutput;
void I_Printf(char* msg, ...)
{
char pmsg[1024];
va_list argptr;
// Message first.
if( debugOutput ) {
va_start (argptr,msg);
vsprintf (pmsg, msg, argptr);
safeOutputDebug(pmsg);
va_end (argptr);
}
}
void I_PrintfE(char* msg, ...)
{
char pmsg[1024];
va_list argptr;
// Message first.
if( debugOutput ) {
va_start (argptr,msg);
vsprintf (pmsg, msg, argptr);
safeOutputDebug("ERROR: ");
safeOutputDebug(pmsg);
va_end (argptr);
}
}
void I_Error(char *error, ...)
{
const int ERROR_MSG_SIZE = 1024;
char error_msg[ERROR_MSG_SIZE];
va_list argptr;
// Message first.
if( debugOutput ) {
va_start (argptr,error);
idStr::vsnPrintf (error_msg, ERROR_MSG_SIZE, error, argptr);
safeOutputDebug("Error: ");
safeOutputDebug(error_msg);
safeOutputDebug("\n");
va_end (argptr);
}
// CRASH DUMP - enable this to get extra info on error from crash dumps
//*(int*)0x0 = 21;
DoomLib::Interface.QuitCurrentGame();
idLib::Printf( "DOOM Classic error: %s", error_msg );
common->SwitchToGame( DOOM3_BFG );
}
#endif

View File

@@ -0,0 +1,88 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __I_SYSTEM__
#define __I_SYSTEM__
#include "d_ticcmd.h"
#include "d_event.h"
#ifdef __GNUG__
#pragma interface
#endif
// Called by DoomMain.
void I_Init (void);
// Called by D_DoomLoop,
// returns current time in tics.
int I_GetTime (void);
//
// Called by D_DoomLoop,
// called before processing any tics in a frame
// (just after displaying a frame).
// Time consuming syncronous operations
// are performed here (joystick reading).
// Can call D_PostEvent.
//
void I_StartFrame (void);
//
// Called by D_DoomLoop,
// called before processing each tic in a frame.
// Quick syncronous operations are performed here.
// Can call D_PostEvent.
#include "doomlib.h"
// Asynchronous interrupt functions should maintain private queues
// that are read by the synchronous functions
// to be converted into events.
// Either returns a null ticcmd,
// or calls a loadable driver to build it.
// This ticcmd will then be modified by the gameloop
// for normal input.
ticcmd_t* I_BaseTiccmd (void);
// Called by M_Responder when quit is selected.
// Clean exit, displays sell blurb.
void I_Quit (void);
void I_Error (char *error, ...);
void I_Printf(char *error, ...);
void I_PrintfE(char *error, ...);
#endif

View File

@@ -0,0 +1,76 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __I_VIDEO__
#define __I_VIDEO__
#include "doomtype.h"
#include "d_event.h"
#ifdef __GNUG__
#pragma interface
#endif
// Called by D_DoomMain,
// determines the hardware configuration
// and sets up the video mode
void I_InitGraphics (void);
void I_ShutdownGraphics(void);
// Takes full 8 bit values.
void I_SetPalette (byte* palette);
void I_UpdateNoBlit (void);
void I_FinishUpdate (void);
// Wait for vertical retrace or pause a bit.
void I_WaitVBL(int count);
void I_ReadScreen (byte* scr);
void I_BeginRead (void);
void I_EndRead (void);
void I_InitInput (void);
void I_ShutdownInput( void ) ;
void I_InputFrame( void );
void I_UpdateControllerState(void);
struct controller_t;
int I_PollMouseInputEvents( controller_t * ) ;
int I_ReturnMouseInputEvent( const int n, event_t* e);
int I_PollJoystickInputEvents( controller_t * ) ;
int I_ReturnJoystickInputEvent( const int n, event_t* e);
void I_EndJoystickInputEvents( void );
#endif

View File

@@ -0,0 +1,186 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
#include "i_video.h"
#include "i_system.h"
#include "doomstat.h"
#include "v_video.h"
#include "m_argv.h"
#include "d_main.h"
#include "doomdef.h"
//#include <d3d8.h> // SMF
//#include <xgraphics.h> // SMF
void I_ShutdownGraphics(void)
{
// VVTODO: Shutdown Graphics
}
//
// I_StartFrame
//
void I_StartFrame (void)
{
// er?
}
static void I_CombineMouseEvent(const event_t* in, event_t* out)
{
if (fabs((float)in->data1) > fabs((float)out->data1))
out->data1 = in->data1;
if (fabs((float)in->data2) > fabs((float)out->data2))
out->data2 = in->data2;
if (fabs((float)in->data3) > fabs((float)out->data3))
out->data3 = in->data3;
}
void I_GetEvents( controller_t *controller )
{
event_t e_mouse, e_joystick;
int numEvents;
e_mouse.type = ev_mouse;
e_mouse.data1 = e_mouse.data2 = e_mouse.data3 = 0;
e_joystick.type = ev_joystick;
e_joystick.data1 = e_joystick.data2 = e_joystick.data3 = 0;
numEvents = I_PollMouseInputEvents( controller );
if (numEvents)
{
int i;
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 );
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
//
void I_UpdateNoBlit (void)
{
// what is this?
}
//
// I_FinishUpdate
//
void I_FinishUpdate (void)
{
// DHM - These buffers are not used
}
//
// I_ReadScreen
//
void I_ReadScreen (byte* scr)
{
memcpy(scr, ::g->screens[0], SCREENWIDTH*SCREENHEIGHT);
}
inline unsigned int I_PackColor( unsigned int a, unsigned int r, unsigned int g, unsigned int b ) {
unsigned int color = 0;
color |= (r & 255) << 24;
color |= (g & 255) << 16;
color |= (b & 255) << 8;
color |= (a & 255);
return color;
}
//
// I_SetPalette
//
void I_SetPalette (byte* palette)
{
int i;
// set the X colormap entries
for (i=0 ; i<256 ; i++)
{
int r,b,g;
r = gammatable[::g->usegamma][*palette++];
g = gammatable[::g->usegamma][*palette++];
b = gammatable[::g->usegamma][*palette++];
::g->XColorMap[i] = I_PackColor(0xff, r, g, b);
}
}
void I_InitGraphics()
{
}

View File

@@ -0,0 +1,174 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
#include <signal.h>
#include "i_video.h"
#include "i_system.h"
#include "doomstat.h"
#include "v_video.h"
#include "m_argv.h"
#include "d_main.h"
#include "doomdef.h"
//#include <d3d8.h> // SMF
//#include <xgraphics.h> // SMF
void I_ShutdownGraphics(void)
{
// VVTODO: Shutdown Graphics
}
//
// I_StartFrame
//
void I_StartFrame (void)
{
// er?
}
static void I_CombineMouseEvent(const event_t* in, event_t* out)
{
if (fabs((float)in->data1) > fabs((float)out->data1))
out->data1 = in->data1;
if (fabs((float)in->data2) > fabs((float)out->data2))
out->data2 = in->data2;
if (fabs((float)in->data3) > fabs((float)out->data3))
out->data3 = in->data3;
}
void I_GetEvents( controller_t *controller )
{
event_t e_mouse, e_joystick;
int numEvents;
e_mouse.type = ev_mouse;
e_mouse.data1 = e_mouse.data2 = e_mouse.data3 = 0;
e_joystick.type = ev_joystick;
e_joystick.data1 = e_joystick.data2 = e_joystick.data3 = 0;
numEvents = I_PollMouseInputEvents( controller );
if (numEvents)
{
int i;
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 );
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
//
void I_UpdateNoBlit (void)
{
// what is this?
}
//
// I_FinishUpdate
//
void I_FinishUpdate (void)
{
// DHM - These buffers are not used
}
//
// I_ReadScreen
//
void I_ReadScreen (byte* scr)
{
XMemCpy(scr, ::g->screens[0], SCREENWIDTH*SCREENHEIGHT);
}
//
// I_SetPalette
//
void I_SetPalette (byte* palette)
{
int i;
// set the X colormap entries
for (i=0 ; i<256 ; i++)
{
int r,b,g;
r = gammatable[::g->usegamma][*palette++];
g = gammatable[::g->usegamma][*palette++];
b = gammatable[::g->usegamma][*palette++];
::g->XColorMap[i] = D3DCOLOR_ARGB(0xff, r, g, b);
}
}
void I_InitGraphics()
{
}

4675
doomclassic/doom/info.cpp Normal file

File diff suppressed because it is too large Load Diff

1347
doomclassic/doom/info.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,61 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <string.h>
//
// M_CheckParm
// Checks for the given parameter
// in the program's command line arguments.
// Returns the argument number (1 to argc-1)
// or 0 if not present
int M_CheckParm (char *check)
{
int i;
for (i = 1; i < ::g->myargc; i++)
{
if ( !idStr::Icmp(check, ::g->myargv[i]) )
return i;
}
return 0;
}

44
doomclassic/doom/m_argv.h Normal file
View File

@@ -0,0 +1,44 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __M_ARGV__
#define __M_ARGV__
//
// MISC
//
extern int myargc;
extern char** myargv;
// Returns the position of the given parameter
// in the arg list (0 if not found).
int M_CheckParm (char* check);
#endif

View File

@@ -0,0 +1,68 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#ifdef __GNUG__
#pragma implementation "m_bbox.h"
#endif
#include "m_bbox.h"
#include "doomtype.h"
void M_ClearBox (fixed_t *box)
{
box[BOXTOP] = box[BOXRIGHT] = MININT;
box[BOXBOTTOM] = box[BOXLEFT] = MAXINT;
}
void
M_AddToBox
( fixed_t* box,
fixed_t x,
fixed_t y )
{
if (x<box[BOXLEFT])
box[BOXLEFT] = x;
else if (x>box[BOXRIGHT])
box[BOXRIGHT] = x;
if (y<box[BOXBOTTOM])
box[BOXBOTTOM] = y;
else if (y>box[BOXTOP])
box[BOXTOP] = y;
}

55
doomclassic/doom/m_bbox.h Normal file
View File

@@ -0,0 +1,55 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __M_BBOX__
#define __M_BBOX__
#include "m_fixed.h"
// Bounding box coordinate storage.
enum
{
BOXTOP,
BOXBOTTOM,
BOXLEFT,
BOXRIGHT
}; // bbox coordinates
// Bounding box functions.
void M_ClearBox (fixed_t* box);
void
M_AddToBox
( fixed_t* box,
fixed_t x,
fixed_t y );
#endif

View File

@@ -0,0 +1,127 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "m_cheat.h"
//
// CHEAT SEQUENCE PACKAGE
//
//
// Called in st_stuff module, which handles the input.
// Returns a 1 if the cheat was successful, 0 if failed.
//
int
cht_CheckCheat
( cheatseq_t* cht,
char key )
{
return 0; // ALAN : Checking the cheats CRASHES??
int i;
int rc = 0;
if (::g->firsttime)
{
::g->firsttime = 0;
for (i=0;i<256;i++) ::g->cheat_xlate_table[i] = SCRAMBLE(i);
}
if (!cht->p)
{
cht->p = ::g->cheatbuffer + ::g->usedcheatbuffer;
int isize = 0;
while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize];
cht->p[isize] = 0xff;
::g->usedcheatbuffer += isize;
::g->usedcheatbuffer ++;
}
if (*cht->p == 0)
*(cht->p++) = key;
else if
(::g->cheat_xlate_table[(unsigned char)key] == *cht->p) cht->p++;
else
{
int isize = 0;
while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize];
cht->p[isize] = 0xff;
}
if (*cht->p == 1)
cht->p++;
else if (*cht->p == 0xff) // end of sequence character
{
int isize = 0;
while(cht->sequence[isize] != 0xff) cht->p[isize] = cht->sequence[isize];
cht->p[isize] = 0xff;
rc = 1;
}
return rc;
}
void
cht_GetParam
( cheatseq_t* cht,
char* buffer )
{
unsigned char pb[16];
unsigned char *p;
unsigned char c;
int isize = 0;
while(cht->sequence[isize] != 0xff) pb[isize] = cht->sequence[isize];
pb[isize] = 0xff;
p = &pb[0];
while (*(p++) != 1);
do
{
c = *p;
*(buffer++) = c;
*(p++) = 0;
}
while (c && *p!=0xff );
if (*p==0xff)
*buffer = 0;
}

View File

@@ -0,0 +1,62 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __M_CHEAT__
#define __M_CHEAT__
//
// CHEAT SEQUENCE PACKAGE
//
#define SCRAMBLE(a) \
((((a)&1)<<7) + (((a)&2)<<5) + ((a)&4) + (((a)&8)<<1) \
+ (((a)&16)>>1) + ((a)&32) + (((a)&64)>>5) + (((a)&128)>>7))
struct cheatseq_t
{
cheatseq_t() {}
cheatseq_t( const unsigned char *seq, unsigned char *pin ) : sequence( seq ), p( pin ) {}
const unsigned char* sequence;
unsigned char* p;
};
int
cht_CheckCheat
( cheatseq_t* cht,
char key );
void
cht_GetParam
( cheatseq_t* cht,
char* buffer );
#endif

View File

@@ -0,0 +1,92 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "stdlib.h"
#include "doomtype.h"
#include "i_system.h"
#ifdef __GNUG__
#pragma implementation "m_fixed.h"
#endif
#include "m_fixed.h"
// Fixme. __USE_C_FIXED__ or something.
fixed_t
FixedMul
( fixed_t a,
fixed_t b )
{
return fixed_t( ((long long) a * (long long) b) >> FRACBITS );
}
//
// FixedDiv, C version.
//
fixed_t
FixedDiv
( fixed_t a,
fixed_t b )
{
if ( (abs(a)>>14) >= abs(b))
return (a^b)<0 ? MININT : MAXINT;
return FixedDiv2 (a,b);
}
fixed_t
FixedDiv2
( fixed_t a,
fixed_t b )
{
#if 0
long long c;
c = ((long long)a<<16) / ((long long)b);
return (fixed_t) c;
#endif
double c;
c = ((double)a) / ((double)b) * FRACUNIT;
if (c >= 2147483648.0 || c < -2147483648.0)
I_Error("FixedDiv: divide by zero");
return (fixed_t) c;
}

View File

@@ -0,0 +1,53 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __M_FIXED__
#define __M_FIXED__
#ifdef __GNUG__
#pragma interface
#endif
//
// Fixed point, 32bit as 16.16.
//
#define FRACBITS 16
#define FRACUNIT (1<<FRACBITS)
typedef int fixed_t;
fixed_t FixedMul (fixed_t a, fixed_t b);
fixed_t FixedDiv (fixed_t a, fixed_t b);
fixed_t FixedDiv2 (fixed_t a, fixed_t b);
#endif

1707
doomclassic/doom/m_menu.cpp Normal file

File diff suppressed because it is too large Load Diff

69
doomclassic/doom/m_menu.h Normal file
View File

@@ -0,0 +1,69 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __M_MENU__
#define __M_MENU__
#include "d_event.h"
//
// MENUS
//
// Called by main loop,
// saves config file and calls I_Quit when user exits.
// Even when the menu is not displayed,
// this can resize the view and change game parameters.
// Does all the real work of the menu interaction.
qboolean M_Responder (event_t *ev);
// Called by main loop,
// only used for menu (skull cursor) animation.
void M_Ticker (void);
// Called by main loop,
// draws the menus directly into the screen buffer.
void M_Drawer (void);
// Called by D_DoomMain,
// loads the config file.
void M_Init (void);
// Called by intro code to force menu up upon a keypress,
// does nothing if menu is already up.
void M_StartControlPanel (void);
#endif

372
doomclassic/doom/m_misc.cpp Normal file
View File

@@ -0,0 +1,372 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdlib.h>
#include <ctype.h>
#include "doomdef.h"
#include "g_game.h"
#include "z_zone.h"
#include "m_swap.h"
#include "m_argv.h"
#include "w_wad.h"
#include "i_system.h"
#include "i_video.h"
#include "v_video.h"
#include "hu_stuff.h"
// State.
#include "doomstat.h"
// Data.
#include "dstrings.h"
#include "m_misc.h"
#include "d3xp/Game_local.h"
//
// M_DrawText
// Returns the final X coordinate
// HU_Init must have been called to init the font
//
int
M_DrawText
( int x,
int y,
qboolean direct,
char* string )
{
int c;
int w;
while (*string)
{
c = toupper(*string) - HU_FONTSTART;
string++;
if (c < 0 || c> HU_FONTSIZE)
{
x += 4;
continue;
}
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
//
boolean M_WriteFile ( char const* name, void* source, int length ) {
idFile * handle = NULL;
int count;
handle = fileSystem->OpenFileWrite( name, "fs_savepath" );
if (handle == NULL )
return false;
count = handle->Write( source, length );
fileSystem->CloseFile( handle );
if (count < length)
return false;
return true;
}
//
// M_ReadFile
//
int M_ReadFile ( char const* name, byte** buffer ) {
int count, length;
idFile * handle = NULL;
byte *buf;
handle = fileSystem->OpenFileRead( name, false );
if (handle == NULL ) {
I_Error ("Couldn't read file %s", name);
}
length = handle->Length();
buf = ( byte* )Z_Malloc ( handle->Length(), PU_STATIC, NULL);
count = handle->Read( buf, length );
if (count < length ) {
I_Error ("Couldn't read file %s", name);
}
fileSystem->CloseFile( handle );
*buffer = buf;
return length;
}
//
// Write a save game to the specified device using the specified game name.
//
static qboolean SaveGame( void* source, DWORD length )
{
return false;
}
qboolean M_WriteSaveGame( void* source, int length )
{
return SaveGame( source, length );
}
int M_ReadSaveGame( byte** buffer )
{
return 0;
}
//
// DEFAULTS
//
// machine-independent sound params
// UNIX hack, to be removed.
#ifdef SNDSERV
#endif
#ifdef LINUX
#endif
extern const char* const temp_chat_macros[];
//
// M_SaveDefaults
//
void M_SaveDefaults (void)
{
/*
int i;
int v;
FILE* f;
f = f o pen (::g->defaultfile, "w");
if (!f)
return; // can't write the file, but don't complain
for (i=0 ; i<::g->numdefaults ; i++)
{
if (::g->defaults[i].defaultvalue > -0xfff
&& ::g->defaults[i].defaultvalue < 0xfff)
{
v = *::g->defaults[i].location;
fprintf (f,"%s\t\t%i\n",::g->defaults[i].name,v);
} else {
fprintf (f,"%s\t\t\"%s\"\n",::g->defaults[i].name,
* (char **) (::g->defaults[i].location));
}
}
fclose (f);
*/
}
//
// M_LoadDefaults
//
void M_LoadDefaults (void)
{
int i;
//int len;
//FILE* f;
//char def[80];
//char strparm[100];
//char* newstring;
//int parm;
//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;
/*
// read the file in, overriding any set ::g->defaults
f = f o pen (::g->defaultfile, "r");
if (f)
{
while (!feof(f))
{
isstring = false;
if (fscanf (f, "%79s %[^\n]\n", def, strparm) == 2)
{
if (strparm[0] == '"')
{
// get a string default
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)
*::g->defaults[i].location = parm;
else
*::g->defaults[i].location = (int) newstring;
break;
}
}
}
fclose (f);
}
*/
}
//
// SCREEN SHOTS
//
//
// WritePCXfile
//
void
WritePCXfile
( char* filename,
byte* data,
int width,
int height,
byte* palette )
{
I_Error( "depreciated" );
}
//
// M_ScreenShot
//
void M_ScreenShot (void)
{
/*
int i;
byte* linear;
char lbmname[12];
// munge planar buffer to linear
linear = ::g->screens[2];
I_ReadScreen (linear);
// find a file name to save it to
strcpy(lbmname,"DOOM00.pcx");
for (i=0 ; i<=99 ; i++)
{
lbmname[4] = i/10 + '0';
lbmname[5] = i%10 + '0';
if (_access(lbmname,0) == -1)
break; // file doesn't exist
}
if (i==100)
I_Error ("M_ScreenShot: Couldn't create a PCX");
// save the pcx file
WritePCXfile (lbmname, linear,
SCREENWIDTH, SCREENHEIGHT,
(byte*)W_CacheLumpName ("PLAYPAL",PU_CACHE_SHARED));
::g->players[::g->consoleplayer].message = "screen shot";
*/
}

66
doomclassic/doom/m_misc.h Normal file
View File

@@ -0,0 +1,66 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __M_MISC__
#define __M_MISC__
#include "doomtype.h"
//
// MISC
//
boolean
M_WriteFile
( char const* name,
void* source,
int length );
int
M_ReadFile
( char const* name,
byte** buffer );
qboolean M_WriteSaveGame( void* source, int length );
int M_ReadSaveGame ( byte** buffer );
void M_ScreenShot (void);
void M_LoadDefaults (void);
void M_SaveDefaults (void);
int
M_DrawText
( int x,
int y,
qboolean direct,
char* string );
#endif

View File

@@ -0,0 +1,81 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
//
// M_Random
// Returns a 0-255 number
//
const unsigned char rndtable[256] = {
0, 8, 109, 220, 222, 241, 149, 107, 75, 248, 254, 140, 16, 66 ,
74, 21, 211, 47, 80, 242, 154, 27, 205, 128, 161, 89, 77, 36 ,
95, 110, 85, 48, 212, 140, 211, 249, 22, 79, 200, 50, 28, 188 ,
52, 140, 202, 120, 68, 145, 62, 70, 184, 190, 91, 197, 152, 224 ,
149, 104, 25, 178, 252, 182, 202, 182, 141, 197, 4, 81, 181, 242 ,
145, 42, 39, 227, 156, 198, 225, 193, 219, 93, 122, 175, 249, 0 ,
175, 143, 70, 239, 46, 246, 163, 53, 163, 109, 168, 135, 2, 235 ,
25, 92, 20, 145, 138, 77, 69, 166, 78, 176, 173, 212, 166, 113 ,
94, 161, 41, 50, 239, 49, 111, 164, 70, 60, 2, 37, 171, 75 ,
136, 156, 11, 56, 42, 146, 138, 229, 73, 146, 77, 61, 98, 196 ,
135, 106, 63, 197, 195, 86, 96, 203, 113, 101, 170, 247, 181, 113 ,
80, 250, 108, 7, 255, 237, 129, 226, 79, 107, 112, 166, 103, 241 ,
24, 223, 239, 120, 198, 58, 60, 82, 128, 3, 184, 66, 143, 224 ,
145, 224, 81, 206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95 ,
28, 139, 123, 98, 125, 196, 15, 70, 194, 253, 54, 14, 109, 226 ,
71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36 ,
17, 46, 52, 231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106 ,
197, 242, 98, 43, 39, 175, 254, 145, 190, 84, 118, 222, 187, 136 ,
120, 163, 236, 249
};
// Which one is deterministic?
int P_Random (void)
{
::g->prndindex = (::g->prndindex+1)&0xff;
return rndtable[::g->prndindex];
}
int M_Random (void)
{
::g->rndindex = (::g->rndindex+1)&0xff;
return rndtable[::g->rndindex];
}
void M_ClearRandom (void)
{
::g->rndindex = ::g->prndindex = 0;
}

View File

@@ -0,0 +1,49 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __M_RANDOM__
#define __M_RANDOM__
#include "doomtype.h"
// Returns a number from 0 to 255,
// from a lookup table.
int M_Random (void);
// As M_Random, but used only by the play simulation.
int P_Random (void);
// Fix randoms for demos.
void M_ClearRandom (void);
#endif

View File

@@ -0,0 +1,45 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#ifdef __GNUG__
#pragma implementation "m_swap.h"
#endif
#include "m_swap.h"
// Not needed with big endian.
#ifdef __BIG_ENDIAN__
#endif

73
doomclassic/doom/m_swap.h Normal file
View File

@@ -0,0 +1,73 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __M_SWAP__
#define __M_SWAP__
#ifdef __GNUG__
#pragma interface
#endif
// Endianess handling.
// WAD files are stored little endian.
#ifdef __BIG_ENDIAN__
//short SwapSHORT(short);
//long SwapLONG(long);
// Swap 16bit, that is, MSB and LSB byte.
inline unsigned short SwapSHORT(unsigned short x)
{
// No masking with 0xFF should be necessary.
return (x>>8) | (x<<8);
}
// Swapping 32bit.
inline unsigned long SwapLONG( unsigned long x)
{
return
(x>>24)
| ((x>>8) & 0xff00)
| ((x<<8) & 0xff0000)
| (x<<24);
}
#define SHORT(x) ((short)SwapSHORT((unsigned short) (x)))
#define LONG(x) ((long)SwapLONG((unsigned long) (x)))
#else
#define SHORT(x) (x)
#define LONG(x) (x)
#endif
#endif

View File

@@ -0,0 +1,358 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include "idlib/sys/sys_defines.h"
// mus header
// reads a variable length integer
unsigned long ReadVarLen( char* buffer ) {
unsigned long value;
byte c;
if ((value = *buffer++) & 0x80) {
value &= 0x7f;
do {
value = (value << 7) + ((c = *buffer++) & 0x7f);
} while (c & 0x80);
}
return value;
}
// Writes a variable length integer to a buffer, and returns bytes written
int WriteVarLen( long value, byte* out )
{
long buffer, count = 0;
buffer = value & 0x7f;
while ((value >>= 7) > 0) {
buffer <<= 8;
buffer += 0x80;
buffer += (value & 0x7f);
}
while (1) {
++count;
*out = (byte)buffer;
++out;
if (buffer & 0x80)
buffer >>= 8;
else
break;
}
return count;
}
// writes a byte, and returns the buffer
unsigned char* WriteByte(void* buf, byte b)
{
unsigned char* buffer = (unsigned char*)buf;
*buffer++ = b;
return buffer;
}
unsigned char* WriteShort(void* b, unsigned short s)
{
unsigned char* buffer = (unsigned char*)b;
*buffer++ = (s >> 8);
*buffer++ = (s & 0x00FF);
return buffer;
}
unsigned char* WriteInt(void* b, unsigned int i)
{
unsigned char* buffer = (unsigned char*)b;
*buffer++ = (i & 0xff000000) >> 24;
*buffer++ = (i & 0x00ff0000) >> 16;
*buffer++ = (i & 0x0000ff00) >> 8;
*buffer++ = (i & 0x000000ff);
return buffer;
}
// 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)
{
WriteInt(header->name, 'MThd');
WriteInt(&header->length, 6);
WriteShort(&header->format, format);
WriteShort(&header->ntracks, track_count);
WriteShort(&header->division, division);
}
unsigned char* Midi_WriteTempo(unsigned char* buffer, int tempo)
{
buffer = WriteByte(buffer, 0x00); // delta time
buffer = WriteByte(buffer, 0xff); // sys command
buffer = WriteShort(buffer, 0x5103); // command - set tempo
buffer = WriteByte(buffer, tempo & 0x000000ff);
buffer = WriteByte(buffer, (tempo & 0x0000ff00) >> 8);
buffer = WriteByte(buffer, (tempo & 0x00ff0000) >> 16);
return buffer;
}
int Midi_UpdateBytesWritten(int* bytes_written, int to_add, int max)
{
*bytes_written += to_add;
if (max && *bytes_written > max)
{
assert(0);
return 0;
}
return 1;
}
unsigned char MidiMap[] =
{
0, // prog change
0, // bank sel
1, //2 // mod pot
0x07, //3 // volume
0x0A, //4 // pan pot
0x0B, //5 // expression pot
0x5B, //6 // reverb depth
0x5D, //7 // chorus depth
0x40, //8 // sustain pedal
0x43, //9 // soft pedal
0x78, //10 // all sounds off
0x7B, //11 // all notes off
0x7E, //12 // mono(use numchannels + 1)
0x7F, //13 // poly
0x79, //14 // reset all controllers
};
// The MUS data is stored in little-endian.
namespace {
unsigned short LittleToNative( const unsigned short value ) {
return value;
}
}
int Mus2Midi(unsigned char* bytes, unsigned char* out, int* len)
{
// mus header and instruments
MUSheader_t header;
// current position in read buffer
unsigned char* cur = bytes,* end;
// Midi header(format 0)
MidiHeaderChunk_t midiHeader;
// Midi track header, only 1 needed(format 0)
MidiTrackChunk_t midiTrackHeader;
// Stores the position of the midi track header(to change the size)
byte* midiTrackHeaderOut;
// Delta time for midi event
int delta_time = 0;
int temp;
int channel_volume[MIDI_MAXCHANNELS] = {0};
int bytes_written = 0;
int channelMap[MIDI_MAXCHANNELS], currentChannel = 0;
byte last_status = 0;
// read the mus header
memcpy(&header, cur, sizeof(header));
cur += sizeof(header);
header.scoreLen = LittleToNative( header.scoreLen );
header.scoreStart = LittleToNative( header.scoreStart );
header.channels = LittleToNative( header.channels );
header.sec_channels = LittleToNative( header.sec_channels );
header.instrCnt = LittleToNative( header.instrCnt );
header.dummy = LittleToNative( header.dummy );
// only 15 supported
if (header.channels > MIDI_MAXCHANNELS - 1)
return 0;
// Map channel 15 to 9(percussions)
for (temp = 0; temp < MIDI_MAXCHANNELS; ++temp) {
channelMap[temp] = -1;
channel_volume[temp] = 0x40;
}
channelMap[15] = 9;
// Get current position, and end of position
cur = bytes + header.scoreStart;
end = cur + header.scoreLen;
// Write out midi header
Midi_CreateHeader(&midiHeader, 0, 1, 0x0059);
Midi_UpdateBytesWritten(&bytes_written, MIDIHEADERSIZE, *len);
memcpy(out, &midiHeader, MIDIHEADERSIZE); // cannot use sizeof(packs it to 16 bytes)
out += MIDIHEADERSIZE;
// Store this position, for later filling in the midiTrackHeader
Midi_UpdateBytesWritten(&bytes_written, sizeof(midiTrackHeader), *len);
midiTrackHeaderOut = out;
out += sizeof(midiTrackHeader);
// microseconds per quarter note(yikes)
Midi_UpdateBytesWritten(&bytes_written, 7, *len);
out = Midi_WriteTempo(out, 0x001aa309);
// Percussions channel starts out at full volume
Midi_UpdateBytesWritten(&bytes_written, 4, *len);
out = WriteByte(out, 0x00);
out = WriteByte(out, 0xB9);
out = WriteByte(out, 0x07);
out = WriteByte(out, 127);
// Main Loop
while (cur < end) {
byte channel;
byte event;
byte temp_buffer[32]; // temp buffer for current iterator
byte *out_local = temp_buffer;
byte status, bit1, bit2, bitc = 2;
// Read in current bit
event = *cur++;
channel = (event & 15); // current channel
// Write variable length delta time
out_local += WriteVarLen(delta_time, out_local);
if (channelMap[channel] < 0) {
// Set all channels to 127 volume
out_local = WriteByte(out_local, 0xB0 + currentChannel);
out_local = WriteByte(out_local, 0x07);
out_local = WriteByte(out_local, 127);
out_local = WriteByte(out_local, 0x00);
channelMap[channel] = currentChannel++;
if (currentChannel == 9)
++currentChannel;
}
status = channelMap[channel];
// Handle ::g->events
switch ((event & 122) >> 4)
{
default:
assert(0);
break;
case MUSEVENT_KEYOFF:
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++;
bitc = 1;
} else {
status |= 0xB0;
assert(*cur < sizeof(MidiMap) / sizeof(MidiMap[0]));
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
out_local = WriteByte(out_local, status);
out_local = WriteByte(out_local, bit1);
if (bitc == 2)
out_local = WriteByte(out_local, bit2);
// Write out temp stuff
if (out_local != temp_buffer)
{
Midi_UpdateBytesWritten(&bytes_written, out_local - temp_buffer, *len);
memcpy(out, temp_buffer, out_local - temp_buffer);
out += out_local - temp_buffer;
}
if (event & 128) {
delta_time = 0;
do {
delta_time = delta_time * 128 + (*cur & 127);
} while ((*cur++ & 128));
} else {
delta_time = 0;
}
}
// Write out track header
WriteInt(midiTrackHeader.name, 'MTrk');
WriteInt(&midiTrackHeader.length, out - midiTrackHeaderOut - sizeof(midiTrackHeader));
memcpy(midiTrackHeaderOut, &midiTrackHeader, sizeof(midiTrackHeader));
// Store length written
*len = bytes_written;
/*{
FILE* file = f o pen("d:\\test.midi", "wb");
fwrite(midiTrackHeaderOut - sizeof(MidiHeaderChunk_t), bytes_written, 1, file);
fclose(file);
}*/
return 1;
}

View File

@@ -0,0 +1,341 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "z_zone.h"
#include "doomdef.h"
#include "p_local.h"
#include "s_sound.h"
// State.
#include "doomstat.h"
#include "r_state.h"
// Data.
#include "sounds.h"
//
// CEILINGS
//
//
// T_MoveCeiling
//
void T_MoveCeiling (ceiling_t* ceiling)
{
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:
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;
}
}
//
// EV_DoCeiling
// Move a ceiling up/down and all around!
//
int
EV_DoCeiling
( line_t* line,
ceiling_e type )
{
int secnum;
int rtn;
sector_t* sec;
ceiling_t* ceiling;
secnum = -1;
rtn = 0;
// Reactivate in-stasis ceilings...for certain types.
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:
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
//
void P_AddActiveCeiling(ceiling_t* c)
{
int i;
for (i = 0; i < MAXCEILINGS;i++)
{
if (::g->activeceilings[i] == NULL)
{
::g->activeceilings[i] = c;
return;
}
}
}
//
// Remove a ceiling's thinker
//
void P_RemoveActiveCeiling(ceiling_t* c)
{
int i;
for (i = 0;i < MAXCEILINGS;i++)
{
if (::g->activeceilings[i] == c)
{
::g->activeceilings[i]->sector->specialdata = NULL;
P_RemoveThinker (&::g->activeceilings[i]->thinker);
::g->activeceilings[i] = NULL;
break;
}
}
}
//
// Restart a ceiling that's in-stasis
//
void P_ActivateInStasisCeiling(line_t* line)
{
int 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;
::g->activeceilings[i]->thinker.function.acp1
= (actionf_p1)T_MoveCeiling;
}
}
}
//
// EV_CeilingCrushStop
// Stop a ceiling from crushing!
//
int EV_CeilingCrushStop(line_t *line)
{
int i;
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;
}

View File

@@ -0,0 +1,560 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "z_zone.h"
#include "doomdef.h"
#include "p_local.h"
#include "s_sound.h"
// State.
#include "doomstat.h"
#include "r_state.h"
// Data.
#include "dstrings.h"
#include "sounds.h"
extern bool globalNetworking;
//
// VERTICAL DOORS
//
//
// T_VerticalDoor
//
void T_VerticalDoor (vldoor_t* door)
{
result_e res;
switch(door->direction)
{
case 0:
// WAITING
if (!--door->topcountdown)
{
switch(door->type)
{
case blazeRaise:
door->direction = -1; // time to go back down
S_StartSound( &door->sector->soundorg,
sfx_bdcls);
break;
case normal:
door->direction = -1; // time to go back down
S_StartSound( &door->sector->soundorg,
sfx_dorcls);
break;
case close30ThenOpen:
door->direction = 1;
S_StartSound( &door->sector->soundorg,
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;
}
}
//
// EV_DoLockedDoor
// Move a locked door up/down
//
int
EV_DoLockedDoor
( line_t* line,
vldoor_e type,
mobj_t* thing )
{
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);
}
int
EV_DoDoor
( line_t* line,
vldoor_e type )
{
int secnum,rtn;
sector_t* sec;
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;
door->sector = sec;
door->type = type;
door->topwait = VDOORWAIT;
door->speed = VDOORSPEED;
switch(type)
{
case blazeClose:
door->topheight = P_FindLowestCeilingSurrounding(sec);
door->topheight -= 4*FRACUNIT;
door->direction = -1;
door->speed = VDOORSPEED * 4;
S_StartSound( &door->sector->soundorg,
sfx_bdcls);
break;
case closed:
door->topheight = P_FindLowestCeilingSurrounding(sec);
door->topheight -= 4*FRACUNIT;
door->direction = -1;
S_StartSound( &door->sector->soundorg,
sfx_dorcls);
break;
case close30ThenOpen:
door->topheight = sec->ceilingheight;
door->direction = -1;
S_StartSound( &door->sector->soundorg,
sfx_dorcls);
break;
case blazeRaise:
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;
}
//
// EV_VerticalDoor : open a door manually, no tag value
//
void
EV_VerticalDoor
( line_t* line,
mobj_t* thing )
{
player_t* player;
int secnum;
sector_t* sec;
vldoor_t* door;
int side;
side = 0; // only front ::g->sides can be used
// Check for locks
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)
{
door = (vldoor_t*)sec->specialdata;
switch(line->special)
{
case 1: // ONLY FOR "RAISE" DOORS, NOT "OPEN"s
case 26:
case 27:
case 28:
case 117:
if (door->direction == -1)
door->direction = 1; // go back up
else
{
if (!thing->player)
return; // JDC: bad guys never close doors
door->direction = -1; // start going down immediately
}
return;
}
}
// for proper sound
if (globalNetworking || (player == &::g->players[::g->consoleplayer])) {
switch(line->special)
{
case 117: // BLAZING DOOR RAISE
case 118: // BLAZING DOOR OPEN
S_StartSound( &sec->soundorg,sfx_bdopn);
break;
case 1: // NORMAL DOOR SOUND
case 31:
S_StartSound( &sec->soundorg,sfx_doropn);
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)
{
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
//
void P_SpawnDoorCloseIn30 (sector_t* sec)
{
vldoor_t* door;
door = (vldoor_t*)DoomLib::Z_Malloc( sizeof(*door), PU_LEVEL, 0);
P_AddThinker (&door->thinker);
sec->specialdata = door;
sec->special = 0;
door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor;
door->sector = sec;
door->direction = 0;
door->type = normal;
door->speed = VDOORSPEED;
door->topcountdown = 30 * TICRATE;
}
//
// Spawn a door that opens after 5 minutes
//
void
P_SpawnDoorRaiseIn5Mins
( sector_t* sec,
int secnum )
{
vldoor_t* door;
door = (vldoor_t*)DoomLib::Z_Malloc( sizeof(*door), PU_LEVEL, 0);
P_AddThinker (&door->thinker);
sec->specialdata = door;
sec->special = 0;
door->thinker.function.acp1 = (actionf_p1)T_VerticalDoor;
door->sector = sec;
door->direction = 2;
door->type = raiseIn5Mins;
door->speed = VDOORSPEED;
door->topheight = P_FindLowestCeilingSurrounding(sec);
door->topheight -= 4*FRACUNIT;
door->topwait = VDOORWAIT;
door->topcountdown = 5 * 60 * TICRATE;
}
// UNUSED
// Separate into p_slidoor.c?

2028
doomclassic/doom/p_enemy.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,561 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "z_zone.h"
#include "doomdef.h"
#include "p_local.h"
#include "s_sound.h"
// State.
#include "doomstat.h"
#include "r_state.h"
// Data.
#include "sounds.h"
//
// FLOORS
//
//
// Move a plane (floor or ceiling) and check for crushing
//
result_e
T_MovePlane
( sector_t* sector,
fixed_t speed,
fixed_t dest,
qboolean crush,
int floorOrCeiling,
int direction )
{
qboolean flag;
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)
{
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
#if 0
if (flag == true)
{
sector->ceilingheight = lastpos;
P_ChangeSector(sector,crush);
return crushed;
}
#endif
}
break;
}
break;
}
return ok;
}
//
// MOVE A FLOOR TO IT'S DESTINATION (UP OR DOWN)
//
void T_MoveFloor(floormove_t* floor)
{
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)
{
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);
}
}
//
// HANDLE FLOOR TYPES
//
int
EV_DoFloor
( line_t* line,
floor_e floortype )
{
int secnum;
int rtn;
int i;
sector_t* sec;
floormove_t* floor;
secnum = -1;
rtn = 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:
floor->direction = -1;
floor->sector = sec;
floor->speed = FLOORSPEED;
floor->floordestheight =
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;
}
}
return rtn;
}
//
// BUILD A STAIRCASE!
//
int
EV_BuildStairs
( line_t* line,
stair_e type )
{
int secnum;
int height;
int i;
int newsecnum;
int texture;
int ok;
int rtn;
sector_t* sec;
sector_t* tsec;
floormove_t* floor;
fixed_t stairsize = 0;
fixed_t speed = 0;
secnum = -1;
rtn = 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->direction = 1;
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;
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;
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;
}

1073
doomclassic/doom/p_inter.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,43 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __P_INTER__
#define __P_INTER__
#ifdef __GNUG__
#pragma interface
#endif
qboolean P_GivePower(player_t*, int);
#endif

View File

@@ -0,0 +1,362 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "z_zone.h"
#include "m_random.h"
#include "doomdef.h"
#include "p_local.h"
// State.
#include "r_state.h"
//
// FIRELIGHT FLICKER
//
//
// T_FireFlicker
//
void T_FireFlicker (fireflicker_t* flick)
{
int amount;
if (--flick->count)
return;
amount = (P_Random()&3)*16;
if (flick->sector->lightlevel - amount < flick->minlight)
flick->sector->lightlevel = flick->minlight;
else
flick->sector->lightlevel = flick->maxlight - amount;
flick->count = 4;
}
//
// P_SpawnFireFlicker
//
void P_SpawnFireFlicker (sector_t* sector)
{
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);
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;
}
//
// BROKEN LIGHT FLASHING
//
//
// T_LightFlash
// Do flashing lights.
//
void T_LightFlash (lightflash_t* flash)
{
if (--flash->count)
return;
if (flash->sector->lightlevel == flash->maxlight)
{
flash-> sector->lightlevel = flash->minlight;
flash->count = (P_Random()&flash->mintime)+1;
}
else
{
flash-> sector->lightlevel = flash->maxlight;
flash->count = (P_Random()&flash->maxtime)+1;
}
}
//
// P_SpawnLightFlash
// After the map has been loaded, scan each sector
// for specials that spawn thinkers
//
void P_SpawnLightFlash (sector_t* sector)
{
lightflash_t* flash;
// nothing special about it during gameplay
sector->special = 0;
flash = (lightflash_t*)DoomLib::Z_Malloc( sizeof(*flash), PU_LEVEL, 0);
P_AddThinker (&flash->thinker);
flash->thinker.function.acp1 = (actionf_p1) T_LightFlash;
flash->sector = sector;
flash->maxlight = sector->lightlevel;
flash->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel);
flash->maxtime = 64;
flash->mintime = 7;
flash->count = (P_Random()&flash->maxtime)+1;
}
//
// STROBE LIGHT FLASHING
//
//
// T_StrobeFlash
//
void T_StrobeFlash (strobe_t* flash)
{
if (--flash->count)
return;
if (flash->sector->lightlevel == flash->minlight)
{
flash-> sector->lightlevel = flash->maxlight;
flash->count = flash->brighttime;
}
else
{
flash-> sector->lightlevel = flash->minlight;
flash->count =flash->darktime;
}
}
//
// P_SpawnStrobeFlash
// After the map has been loaded, scan each sector
// for specials that spawn thinkers
//
void
P_SpawnStrobeFlash
( sector_t* sector,
int fastOrSlow,
int inSync )
{
strobe_t* flash;
flash = (strobe_t*)DoomLib::Z_Malloc( sizeof(*flash), PU_LEVEL, 0);
P_AddThinker (&flash->thinker);
flash->sector = sector;
flash->darktime = fastOrSlow;
flash->brighttime = STROBEBRIGHT;
flash->thinker.function.acp1 = (actionf_p1) T_StrobeFlash;
flash->maxlight = sector->lightlevel;
flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel);
if (flash->minlight == flash->maxlight)
flash->minlight = 0;
// 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)
//
void EV_StartLightStrobing(line_t* line)
{
int secnum;
sector_t* sec;
secnum = -1;
while ((secnum = P_FindSectorFromLineTag(line,secnum)) >= 0)
{
sec = &::g->sectors[secnum];
if (sec->specialdata)
continue;
P_SpawnStrobeFlash (sec,SLOWDARK, 0);
}
}
//
// TURN LINE'S TAG LIGHTS OFF
//
void EV_TurnTagLightsOff(line_t* line)
{
int i;
int j;
int min;
sector_t* sector;
sector_t* tsec;
line_t* templine;
sector = ::g->sectors;
for (j = 0;j < ::g->numsectors; j++, sector++)
{
if (sector->tag == line->tag)
{
min = sector->lightlevel;
for (i = 0;i < sector->linecount; i++)
{
templine = sector->lines[i];
tsec = getNextSector(templine,sector);
if (!tsec)
continue;
if (tsec->lightlevel < min)
min = tsec->lightlevel;
}
sector->lightlevel = min;
}
}
}
//
// TURN LINE'S TAG LIGHTS ON
//
void
EV_LightTurnOn
( line_t* line,
int bright )
{
int i;
int j;
sector_t* sector;
sector_t* temp;
line_t* templine;
sector = ::g->sectors;
for (i = 0; i < ::g->numsectors; i++, sector++)
{
if (sector->tag == line->tag)
{
// bright = 0 means to search
// 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)
continue;
if (temp->lightlevel > bright)
bright = temp->lightlevel;
}
}
sector-> lightlevel = bright;
}
}
}
//
// Spawn glowing light
//
void T_Glow(glow_t* g)
{
switch(g->direction)
{
case -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;
}
}
void P_SpawnGlowingLight(sector_t* sector)
{
glow_t* g;
g = (glow_t*)DoomLib::Z_Malloc( sizeof(*g), PU_LEVEL, 0);
P_AddThinker(&g->thinker);
g->sector = sector;
g->minlight = P_FindMinSurroundingLight(sector,sector->lightlevel);
g->maxlight = sector->lightlevel;
g->thinker.function.acp1 = (actionf_p1) T_Glow;
g->direction = -1;
sector->special = 0;
}

282
doomclassic/doom/p_local.h Normal file
View File

@@ -0,0 +1,282 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __P_LOCAL__
#define __P_LOCAL__
#ifndef __R_LOCAL__
#include "r_local.h"
#endif
#define FLOATSPEED (FRACUNIT*4)
#define MAXHEALTH 100
#define VIEWHEIGHT (41*FRACUNIT)
// mapblocks are used to check movement
// against lines and things
#define MAPBLOCKUNITS 128
#define MAPBLOCKSIZE (MAPBLOCKUNITS*FRACUNIT)
#define MAPBLOCKSHIFT (FRACBITS+7)
#define MAPBMASK (MAPBLOCKSIZE-1)
#define MAPBTOFRAC (MAPBLOCKSHIFT-FRACBITS)
// player radius for movement checking
#define PLAYERRADIUS 16*FRACUNIT
// MAXRADIUS is for precalculated sector block boxes
// the spider demon is larger,
// but we do not have any moving sectors nearby
#define MAXRADIUS 32*FRACUNIT
#define GRAVITY FRACUNIT
#define MAXMOVE (30*FRACUNIT)
#define USERANGE (64*FRACUNIT)
#define MELEERANGE (64*FRACUNIT)
#define MISSILERANGE (32*64*FRACUNIT)
// follow a player exlusively for 3 seconds
#define BASETHRESHOLD 100
//
// P_TICK
//
// both the head and tail of the thinker list
extern thinker_t thinkercap;
void P_InitThinkers (void);
void P_AddThinker (thinker_t* thinker);
void P_RemoveThinker (thinker_t* thinker);
//
// P_PSPR
//
void P_SetupPsprites (player_t* curplayer);
void P_MovePsprites (player_t* curplayer);
void P_DropWeapon (player_t* player);
//
// P_USER
//
void P_PlayerThink (player_t* player);
//
// P_MOBJ
//
#define ONFLOORZ MININT
#define ONCEILINGZ MAXINT
// Time interval for item respawning.
#define ITEMQUESIZE 128
extern mapthing_t itemrespawnque[ITEMQUESIZE];
extern int itemrespawntime[ITEMQUESIZE];
extern int iquehead;
extern int iquetail;
void P_RespawnSpecials (void);
mobj_t*
P_SpawnMobj
( fixed_t x,
fixed_t y,
fixed_t z,
mobjtype_t type );
void P_RemoveMobj (mobj_t* th);
qboolean P_SetMobjState (mobj_t* mobj, statenum_t state);
void P_MobjThinker (mobj_t* mobj);
void P_SpawnPuff (fixed_t x, fixed_t y, fixed_t z);
void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, int damage);
mobj_t* P_SpawnMissile (mobj_t* source, mobj_t* dest, mobjtype_t type);
void P_SpawnPlayerMissile (mobj_t* source, mobjtype_t type);
//
// P_ENEMY
//
void P_NoiseAlert (mobj_t* target, mobj_t* emmiter);
//
// P_MAPUTL
//
typedef struct
{
fixed_t x;
fixed_t y;
fixed_t dx;
fixed_t dy;
} divline_t;
typedef struct
{
fixed_t frac; // along trace line
qboolean isaline;
union {
mobj_t* thing;
line_t* line;
} d;
} intercept_t;
#define MAXINTERCEPTS 128
extern intercept_t intercepts[MAXINTERCEPTS];
extern intercept_t* intercept_p;
typedef qboolean (*traverser_t) (intercept_t *in);
fixed_t P_AproxDistance (fixed_t dx, fixed_t dy);
int P_PointOnLineSide (fixed_t x, fixed_t y, line_t* line);
int P_PointOnDivlineSide (fixed_t x, fixed_t y, divline_t* line);
void P_MakeDivline (line_t* li, divline_t* dl);
fixed_t P_InterceptVector (divline_t* v2, divline_t* v1);
int P_BoxOnLineSide (fixed_t* tmbox, line_t* ld);
extern fixed_t opentop;
extern fixed_t openbottom;
extern fixed_t openrange;
extern fixed_t lowfloor;
void P_LineOpening (line_t* linedef);
qboolean P_BlockLinesIterator (int x, int y, qboolean(*func)(line_t*) );
qboolean P_BlockThingsIterator (int x, int y, qboolean(*func)(mobj_t*) );
#define PT_ADDLINES 1
#define PT_ADDTHINGS 2
#define PT_EARLYOUT 4
extern divline_t trace;
qboolean
P_PathTraverse
( fixed_t x1,
fixed_t y1,
fixed_t x2,
fixed_t y2,
int flags,
qboolean (*trav) (intercept_t *));
void P_UnsetThingPosition (mobj_t* thing);
void P_SetThingPosition (mobj_t* thing);
//
// P_MAP
//
// If "floatok" true, move would be ok
// if within "tmfloorz - tmceilingz".
extern qboolean floatok;
extern fixed_t tmfloorz;
extern fixed_t tmceilingz;
extern line_t* ceilingline;
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_TeleportMove (mobj_t* thing, fixed_t x, fixed_t y);
void P_SlideMove (mobj_t* mo);
qboolean P_CheckSight (mobj_t* t1, mobj_t* t2);
void P_UseLines (player_t* player);
qboolean P_ChangeSector (sector_t* sector, qboolean crunch);
extern mobj_t* linetarget; // who got hit (or NULL)
fixed_t
P_AimLineAttack
( mobj_t* t1,
angle_t angle,
fixed_t distance );
void
P_LineAttack
( mobj_t* t1,
angle_t angle,
fixed_t distance,
fixed_t slope,
int damage );
void
P_RadiusAttack
( mobj_t* spot,
mobj_t* source,
int damage );
//
// P_SETUP
//
//
// P_INTER
//
extern const int maxammo[NUMAMMO];
extern const int clipammo[NUMAMMO];
void
P_TouchSpecialThing
( mobj_t* special,
mobj_t* toucher );
void
P_DamageMobj
( mobj_t* target,
mobj_t* inflictor,
mobj_t* source,
int damage );
//
// P_SPEC
//
#include "p_spec.h"
#endif // __P_LOCAL__

1353
doomclassic/doom/p_map.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,877 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include <stdlib.h>
#include "m_bbox.h"
#include "doomdef.h"
#include "p_local.h"
// State.
#include "r_state.h"
//
// P_AproxDistance
// Gives an estimation of distance (not exact)
//
fixed_t
P_AproxDistance
( fixed_t dx,
fixed_t dy )
{
dx = abs(dx);
dy = abs(dy);
if (dx < dy)
return dx+dy-(dx>>1);
return dx+dy-(dy>>1);
}
//
// P_PointOnLineSide
// Returns 0 or 1
//
int
P_PointOnLineSide
( fixed_t x,
fixed_t y,
line_t* line )
{
fixed_t dx;
fixed_t dy;
fixed_t left;
fixed_t right;
if (!line->dx)
{
if (x <= line->v1->x)
return line->dy > 0;
return line->dy < 0;
}
if (!line->dy)
{
if (y <= line->v1->y)
return line->dx < 0;
return line->dx > 0;
}
dx = (x - line->v1->x);
dy = (y - line->v1->y);
left = FixedMul ( line->dy>>FRACBITS , dx );
right = FixedMul ( dy , line->dx>>FRACBITS );
if (right < left)
return 0; // front side
return 1; // back side
}
//
// P_BoxOnLineSide
// Considers the line to be infinite
// Returns side 0 or 1, -1 if box crosses the line.
//
int
P_BoxOnLineSide
( fixed_t* tmbox,
line_t* ld )
{
int p1 = 0;
int p2 = 0;
switch (ld->slopetype)
{
case ST_HORIZONTAL:
p1 = tmbox[BOXTOP] > ld->v1->y;
p2 = tmbox[BOXBOTTOM] > ld->v1->y;
if (ld->dx < 0)
{
p1 ^= 1;
p2 ^= 1;
}
break;
case ST_VERTICAL:
p1 = tmbox[BOXRIGHT] < ld->v1->x;
p2 = tmbox[BOXLEFT] < ld->v1->x;
if (ld->dy < 0)
{
p1 ^= 1;
p2 ^= 1;
}
break;
case ST_POSITIVE:
p1 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXTOP], ld);
p2 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXBOTTOM], ld);
break;
case ST_NEGATIVE:
p1 = P_PointOnLineSide (tmbox[BOXRIGHT], tmbox[BOXTOP], ld);
p2 = P_PointOnLineSide (tmbox[BOXLEFT], tmbox[BOXBOTTOM], ld);
break;
}
if (p1 == p2)
return p1;
return -1;
}
//
// P_PointOnDivlineSide
// Returns 0 or 1.
//
int
P_PointOnDivlineSide
( fixed_t x,
fixed_t y,
divline_t* line )
{
fixed_t dx;
fixed_t dy;
fixed_t left;
fixed_t right;
if (!line->dx)
{
if (x <= line->x)
return line->dy > 0;
return line->dy < 0;
}
if (!line->dy)
{
if (y <= line->y)
return line->dx < 0;
return line->dx > 0;
}
dx = (x - line->x);
dy = (y - line->y);
// try to quickly decide by looking at sign bits
if ( (line->dy ^ line->dx ^ dx ^ dy)&0x80000000 )
{
if ( (line->dy ^ dx) & 0x80000000 )
return 1; // (left is negative)
return 0;
}
left = FixedMul ( line->dy>>8, dx>>8 );
right = FixedMul ( dy>>8 , line->dx>>8 );
if (right < left)
return 0; // front side
return 1; // back side
}
//
// P_MakeDivline
//
void
P_MakeDivline
( line_t* li,
divline_t* dl )
{
dl->x = li->v1->x;
dl->y = li->v1->y;
dl->dx = li->dx;
dl->dy = li->dy;
}
//
// P_InterceptVector
// Returns the fractional intercept point
// along the first divline.
// This is only called by the addthings
// and addlines traversers.
//
fixed_t
P_InterceptVector
( divline_t* v2,
divline_t* v1 )
{
#if 1
fixed_t frac;
fixed_t num;
fixed_t den;
den = FixedMul (v1->dy>>8,v2->dx) - FixedMul(v1->dx>>8,v2->dy);
if (den == 0)
return 0;
// I_Error ("P_InterceptVector: parallel");
num =
FixedMul ( (v1->x - v2->x)>>8 ,v1->dy )
+FixedMul ( (v2->y - v1->y)>>8, v1->dx );
frac = FixedDiv (num , den);
return frac;
#else // UNUSED, float debug.
float frac;
float num;
float den;
float v1x;
float v1y;
float v1dx;
float v1dy;
float v2x;
float v2y;
float v2dx;
float v2dy;
v1x = (float)v1->x/FRACUNIT;
v1y = (float)v1->y/FRACUNIT;
v1dx = (float)v1->dx/FRACUNIT;
v1dy = (float)v1->dy/FRACUNIT;
v2x = (float)v2->x/FRACUNIT;
v2y = (float)v2->y/FRACUNIT;
v2dx = (float)v2->dx/FRACUNIT;
v2dy = (float)v2->dy/FRACUNIT;
den = v1dy*v2dx - v1dx*v2dy;
if (den == 0)
return 0; // parallel
num = (v1x - v2x)*v1dy + (v2y - v1y)*v1dx;
frac = num / den;
return frac*FRACUNIT;
#endif
}
//
// P_LineOpening
// Sets ::g->opentop and ::g->openbottom to the window
// through a two sided line.
// OPTIMIZE: keep this precalculated
//
void P_LineOpening (line_t* maputil_linedef)
{
sector_t* front;
sector_t* back;
if (maputil_linedef->sidenum[1] == -1)
{
// single sided line
::g->openrange = 0;
return;
}
front = maputil_linedef->frontsector;
back = maputil_linedef->backsector;
if (front->ceilingheight < back->ceilingheight)
::g->opentop = front->ceilingheight;
else
::g->opentop = back->ceilingheight;
if (front->floorheight > back->floorheight)
{
::g->openbottom = front->floorheight;
::g->lowfloor = back->floorheight;
}
else
{
::g->openbottom = back->floorheight;
::g->lowfloor = front->floorheight;
}
::g->openrange = ::g->opentop - ::g->openbottom;
}
//
// THING POSITION SETTING
//
//
// P_UnsetThingPosition
// Unlinks a thing from block map and ::g->sectors.
// On each position change, BLOCKMAP and other
// lookups maintaining lists ot things inside
// these structures need to be updated.
//
void P_UnsetThingPosition (mobj_t* thing)
{
int blockx;
int blocky;
if ( ! (thing->flags & MF_NOSECTOR) )
{
// inert things don't need to be in blockmap?
// unlink from subsector
if (thing->snext)
thing->snext->sprev = thing->sprev;
if (thing->sprev)
thing->sprev->snext = thing->snext;
else
thing->subsector->sector->thinglist = thing->snext;
}
if ( ! (thing->flags & MF_NOBLOCKMAP) )
{
// inert things don't need to be in ::g->blockmap
// unlink from block map
if (thing->bnext)
thing->bnext->bprev = thing->bprev;
if (thing->bprev)
thing->bprev->bnext = thing->bnext;
else
{
blockx = (thing->x - ::g->bmaporgx)>>MAPBLOCKSHIFT;
blocky = (thing->y - ::g->bmaporgy)>>MAPBLOCKSHIFT;
if (blockx>=0 && blockx < ::g->bmapwidth
&& blocky>=0 && blocky < ::g->bmapheight)
{
::g->blocklinks[blocky*::g->bmapwidth+blockx] = thing->bnext;
}
}
}
}
//
// P_SetThingPosition
// Links a thing into both a block and a subsector
// based on it's x y.
// Sets thing->subsector properly
//
void
P_SetThingPosition (mobj_t* thing)
{
subsector_t* ss;
sector_t* sec;
int blockx;
int blocky;
mobj_t** link;
// link into subsector
ss = R_PointInSubsector (thing->x,thing->y);
thing->subsector = ss;
if ( ! (thing->flags & MF_NOSECTOR) )
{
// invisible things don't go into the sector links
sec = ss->sector;
thing->sprev = NULL;
thing->snext = sec->thinglist;
if (sec->thinglist)
sec->thinglist->sprev = thing;
sec->thinglist = thing;
}
// link into ::g->blockmap
if ( ! (thing->flags & MF_NOBLOCKMAP) )
{
// inert things don't need to be in ::g->blockmap
blockx = (thing->x - ::g->bmaporgx)>>MAPBLOCKSHIFT;
blocky = (thing->y - ::g->bmaporgy)>>MAPBLOCKSHIFT;
if (blockx>=0
&& blockx < ::g->bmapwidth
&& blocky>=0
&& blocky < ::g->bmapheight)
{
link = &::g->blocklinks[blocky*::g->bmapwidth+blockx];
thing->bprev = NULL;
thing->bnext = *link;
if (*link)
(*link)->bprev = thing;
*link = thing;
}
else
{
// thing is off the map
thing->bnext = thing->bprev = NULL;
}
}
}
//
// BLOCK MAP ITERATORS
// For each line/thing in the given mapblock,
// call the passed PIT_* function.
// If the function returns false,
// exit with false without checking anything else.
//
//
// P_BlockLinesIterator
// The ::g->validcount flags are used to avoid checking ::g->lines
// that are marked in multiple mapblocks,
// so increment ::g->validcount before the first call
// to P_BlockLinesIterator, then make one or more calls
// to it.
//
qboolean
P_BlockLinesIterator
( int x,
int y,
qboolean(*func)(line_t*) )
{
int offset;
short* list;
line_t* ld;
if (x<0
|| y<0
|| x>=::g->bmapwidth
|| y>=::g->bmapheight)
{
return true;
}
offset = y*::g->bmapwidth+x;
offset = *(::g->blockmap+offset);
for ( list = ::g->blockmaplump+offset ; *list != -1 ; list++)
{
ld = &::g->lines[*list];
if (ld->validcount == ::g->validcount)
continue; // line has already been checked
ld->validcount = ::g->validcount;
if ( !func(ld) )
return false;
}
return true; // everything was checked
}
//
// P_BlockThingsIterator
//
qboolean
P_BlockThingsIterator
( int x,
int y,
qboolean(*func)(mobj_t*) )
{
mobj_t* mobj;
if ( x<0
|| y<0
|| x>=::g->bmapwidth
|| y>=::g->bmapheight)
{
return true;
}
for (mobj = ::g->blocklinks[y*::g->bmapwidth+x] ;
mobj ;
mobj = mobj->bnext)
{
if (!func( mobj ) )
return false;
}
return true;
}
//
// INTERCEPT ROUTINES
//
//
// PIT_AddLineIntercepts.
// Looks for ::g->lines in the given block
// that intercept the given ::g->trace
// to add to the ::g->intercepts list.
//
// A line is crossed if its endpoints
// are on opposite ::g->sides of the ::g->trace.
// Returns true if ::g->earlyout and a solid line hit.
//
qboolean
PIT_AddLineIntercepts (line_t* ld)
{
int s1;
int s2;
fixed_t frac;
divline_t dl;
// avoid precision problems with two routines
if ( ::g->trace.dx > FRACUNIT*16
|| ::g->trace.dy > FRACUNIT*16
|| ::g->trace.dx < -FRACUNIT*16
|| ::g->trace.dy < -FRACUNIT*16)
{
s1 = P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &::g->trace);
s2 = P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &::g->trace);
}
else
{
s1 = P_PointOnLineSide (::g->trace.x, ::g->trace.y, ld);
s2 = P_PointOnLineSide (::g->trace.x+::g->trace.dx, ::g->trace.y+::g->trace.dy, ld);
}
if (s1 == s2)
return true; // line isn't crossed
// hit the line
P_MakeDivline (ld, &dl);
frac = P_InterceptVector (&::g->trace, &dl);
if (frac < 0)
return true; // behind source
// try to early out the check
if (::g->earlyout
&& frac < FRACUNIT
&& !ld->backsector)
{
return false; // stop checking
}
::g->intercept_p->frac = frac;
::g->intercept_p->isaline = true;
::g->intercept_p->d.line = ld;
::g->intercept_p++;
return true; // continue
}
//
// PIT_AddThingIntercepts
//
qboolean PIT_AddThingIntercepts (mobj_t* thing)
{
fixed_t x1;
fixed_t y1;
fixed_t x2;
fixed_t y2;
int s1;
int s2;
qboolean tracepositive;
divline_t dl;
fixed_t frac;
tracepositive = (::g->trace.dx ^ ::g->trace.dy)>0;
// check a corner to corner crossection for hit
if (tracepositive)
{
x1 = thing->x - thing->radius;
y1 = thing->y + thing->radius;
x2 = thing->x + thing->radius;
y2 = thing->y - thing->radius;
}
else
{
x1 = thing->x - thing->radius;
y1 = thing->y - thing->radius;
x2 = thing->x + thing->radius;
y2 = thing->y + thing->radius;
}
s1 = P_PointOnDivlineSide (x1, y1, &::g->trace);
s2 = P_PointOnDivlineSide (x2, y2, &::g->trace);
if (s1 == s2)
return true; // line isn't crossed
dl.x = x1;
dl.y = y1;
dl.dx = x2-x1;
dl.dy = y2-y1;
frac = P_InterceptVector (&::g->trace, &dl);
if (frac < 0)
return true; // behind source
::g->intercept_p->frac = frac;
::g->intercept_p->isaline = false;
::g->intercept_p->d.thing = thing;
::g->intercept_p++;
return true; // keep going
}
//
// P_TraverseIntercepts
// Returns true if the traverser function returns true
// for all ::g->lines.
//
qboolean
P_TraverseIntercepts
( traverser_t func,
fixed_t maxfrac )
{
int count;
fixed_t dist;
intercept_t* scan;
intercept_t* in;
count = ::g->intercept_p - ::g->intercepts;
in = 0; // shut up compiler warning
while (count--)
{
dist = MAXINT;
for (scan = ::g->intercepts ; scan < ::g->intercept_p ; scan++)
{
if (scan->frac < dist)
{
dist = scan->frac;
in = scan;
}
}
if (dist > maxfrac)
return true; // checked everything in range
#if 0 // UNUSED
{
// don't check these yet, there may be others inserted
in = scan = ::g->intercepts;
for ( scan = ::g->intercepts ; scan<::g->intercept_p ; scan++)
if (scan->frac > maxfrac)
*in++ = *scan;
::g->intercept_p = in;
return false;
}
#endif
if ( !func (in) )
return false; // don't bother going farther
in->frac = MAXINT;
}
return true; // everything was traversed
}
//
// P_PathTraverse
// Traces a line from x1,y1 to x2,y2,
// calling the traverser function for each.
// Returns true if the traverser function returns true
// for all ::g->lines.
//
qboolean
P_PathTraverse
( fixed_t x1,
fixed_t y1,
fixed_t x2,
fixed_t y2,
int flags,
qboolean (*trav) (intercept_t *))
{
fixed_t xt1;
fixed_t yt1;
fixed_t xt2;
fixed_t yt2;
fixed_t xstep;
fixed_t ystep;
fixed_t partial;
fixed_t xintercept;
fixed_t yintercept;
int mapx;
int mapy;
int mapxstep;
int mapystep;
int count;
::g->earlyout = flags & PT_EARLYOUT;
::g->validcount++;
::g->intercept_p = ::g->intercepts;
if ( ((x1-::g->bmaporgx)&(MAPBLOCKSIZE-1)) == 0)
x1 += FRACUNIT; // don't side exactly on a line
if ( ((y1-::g->bmaporgy)&(MAPBLOCKSIZE-1)) == 0)
y1 += FRACUNIT; // don't side exactly on a line
::g->trace.x = x1;
::g->trace.y = y1;
::g->trace.dx = x2 - x1;
::g->trace.dy = y2 - y1;
x1 -= ::g->bmaporgx;
y1 -= ::g->bmaporgy;
xt1 = x1>>MAPBLOCKSHIFT;
yt1 = y1>>MAPBLOCKSHIFT;
x2 -= ::g->bmaporgx;
y2 -= ::g->bmaporgy;
xt2 = x2>>MAPBLOCKSHIFT;
yt2 = y2>>MAPBLOCKSHIFT;
if (xt2 > xt1)
{
mapxstep = 1;
partial = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1));
ystep = FixedDiv (y2-y1,abs(x2-x1));
}
else if (xt2 < xt1)
{
mapxstep = -1;
partial = (x1>>MAPBTOFRAC)&(FRACUNIT-1);
ystep = FixedDiv (y2-y1,abs(x2-x1));
}
else
{
mapxstep = 0;
partial = FRACUNIT;
ystep = 256*FRACUNIT;
}
yintercept = (y1>>MAPBTOFRAC) + FixedMul (partial, ystep);
if (yt2 > yt1)
{
mapystep = 1;
partial = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1));
xstep = FixedDiv (x2-x1,abs(y2-y1));
}
else if (yt2 < yt1)
{
mapystep = -1;
partial = (y1>>MAPBTOFRAC)&(FRACUNIT-1);
xstep = FixedDiv (x2-x1,abs(y2-y1));
}
else
{
mapystep = 0;
partial = FRACUNIT;
xstep = 256*FRACUNIT;
}
xintercept = (x1>>MAPBTOFRAC) + FixedMul (partial, xstep);
// Step through map blocks.
// Count is present to prevent a round off error
// from skipping the break.
mapx = xt1;
mapy = yt1;
for (count = 0 ; count < 64 ; count++)
{
if (flags & PT_ADDLINES)
{
if (!P_BlockLinesIterator (mapx, mapy,PIT_AddLineIntercepts))
return false; // early out
}
if (flags & PT_ADDTHINGS)
{
if (!P_BlockThingsIterator (mapx, mapy,PIT_AddThingIntercepts))
return false; // early out
}
if (mapx == xt2
&& mapy == yt2)
{
break;
}
if ( (yintercept >> FRACBITS) == mapy)
{
yintercept += ystep;
mapx += mapxstep;
}
else if ( (xintercept >> FRACBITS) == mapx)
{
xintercept += xstep;
mapy += mapystep;
}
}
// go through the sorted list
return P_TraverseIntercepts ( trav, FRACUNIT );
}

1012
doomclassic/doom/p_mobj.cpp Normal file

File diff suppressed because it is too large Load Diff

297
doomclassic/doom/p_mobj.h Normal file
View File

@@ -0,0 +1,297 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __P_MOBJ__
#define __P_MOBJ__
// Basics.
#include "tables.h"
#include "m_fixed.h"
// We need the thinker_t stuff.
#include "d_think.h"
// We need the WAD data structure for Map things,
// from the THINGS lump.
#include "doomdata.h"
// States are tied to finite states are
// tied to animation frames.
// Needs precompiled tables/data structures.
#include "info.h"
#ifdef __GNUG__
#pragma interface
#endif
//
// NOTES: mobj_t
//
// mobj_ts are used to tell the refresh where to draw an image,
// tell the world simulation when objects are contacted,
// and tell the sound driver how to position a sound.
//
// The refresh uses the next and prev links to follow
// lists of things in sectors as they are being drawn.
// The sprite, frame, and angle elements determine which patch_t
// is used to draw the sprite if it is visible.
// The sprite and frame values are allmost allways set
// from state_t structures.
// The statescr.exe utility generates the states.h and states.c
// files that contain the sprite/frame numbers from the
// statescr.txt source file.
// The xyz origin point represents a point at the bottom middle
// of the sprite (between the feet of a biped).
// This is the default origin position for patch_ts grabbed
// with lumpy.exe.
// A walking creature will have its z equal to the floor
// it is standing on.
//
// The sound code uses the x,y, and subsector fields
// to do stereo positioning of any sound effited by the mobj_t.
//
// The play simulation uses the blocklinks, x,y,z, radius, height
// to determine when mobj_ts are touching each other,
// touching lines in the map, or hit by trace lines (gunshots,
// lines of sight, etc).
// The mobj_t->flags element has various bit flags
// used by the simulation.
//
// Every mobj_t is linked into a single sector
// based on its origin coordinates.
// The subsector_t is found with R_PointInSubsector(x,y),
// and the sector_t can be found with subsector->sector.
// The sector links are only used by the rendering code,
// the play simulation does not care about them at all.
//
// Any mobj_t that needs to be acted upon by something else
// in the play world (block movement, be shot, etc) will also
// need to be linked into the blockmap.
// If the thing has the MF_NOBLOCK flag set, it will not use
// the block links. It can still interact with other things,
// but only as the instigator (missiles will run into other
// things, but nothing can run into a missile).
// Each block in the grid is 128*128 units, and knows about
// every line_t that it contains a piece of, and every
// interactable mobj_t that has its origin contained.
//
// 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
// sector from which the subsector was made, or has the
// MF_NOSECTOR flag set (the subsector_t needs to be valid
// even if MF_NOSECTOR is set), and is linked into a blockmap
// block or has the MF_NOBLOCKMAP flag set.
// Links should only be modified by the P_[Un]SetThingPosition()
// functions.
// Do not change the MF_NO? flags while a thing is valid.
//
// Any questions?
//
//
// Misc. mobj flags
//
typedef enum
{
// Call P_SpecialThing when touched.
MF_SPECIAL = 1,
// Blocks.
MF_SOLID = 2,
// Can be hit.
MF_SHOOTABLE = 4,
// Don't use the sector links (invisible but touchable).
MF_NOSECTOR = 8,
// Don't use the blocklinks (inert but displayable)
MF_NOBLOCKMAP = 16,
// Not to be activated by sound, deaf monster.
MF_AMBUSH = 32,
// Will try to attack right back.
MF_JUSTHIT = 64,
// Will take at least one step before attacking.
MF_JUSTATTACKED = 128,
// On level spawning (initial position),
// hang from ceiling instead of stand on floor.
MF_SPAWNCEILING = 256,
// Don't apply gravity (every tic),
// that is, object will float, keeping current height
// or changing it actively.
MF_NOGRAVITY = 512,
// Movement flags.
// This allows jumps from high places.
MF_DROPOFF = 0x400,
// For players, will pick up items.
MF_PICKUP = 0x800,
// Player cheat. ???
MF_NOCLIP = 0x1000,
// Player: keep info about sliding along walls.
MF_SLIDE = 0x2000,
// Allow moves to any height, no gravity.
// For active floaters, e.g. cacodemons, pain elementals.
MF_FLOAT = 0x4000,
// Don't cross lines
// ??? or look at heights on teleport.
MF_TELEPORT = 0x8000,
// Don't hit same species, explode on block.
// Player missiles as well as fireballs of various kinds.
MF_MISSILE = 0x10000,
// Dropped by a demon, not level spawned.
// E.g. ammo clips dropped by dying former humans.
MF_DROPPED = 0x20000,
// Use fuzzy draw (shadow demons or spectres),
// temporary player invisibility powerup.
MF_SHADOW = 0x40000,
// Flag: don't bleed when shot (use puff),
// barrels and shootable furniture shall not bleed.
MF_NOBLOOD = 0x80000,
// Don't stop moving halfway off a step,
// that is, have dead bodies slide down all the way.
MF_CORPSE = 0x100000,
// Floating to a height for a move, ???
// don't auto float to target's height.
MF_INFLOAT = 0x200000,
// On kill, count this enemy object
// towards intermission kill total.
// Happy gathering.
MF_COUNTKILL = 0x400000,
// On picking up, count this item object
// towards intermission item total.
MF_COUNTITEM = 0x800000,
// Special handling: skull in flight.
// Neither a cacodemon nor a missile.
MF_SKULLFLY = 0x1000000,
// Don't spawn this object
// in death match mode (e.g. key cards).
MF_NOTDMATCH = 0x2000000,
// Player sprites in multiplayer modes are modified
// using an internal color lookup table for re-indexing.
// If 0x4 0x8 or 0xc,
// use a translation table for player colormaps
MF_TRANSLATION = 0xc000000,
// Hmm ???.
MF_TRANSSHIFT = 26
} mobjflag_t;
// Map Object definition.
struct mobj_t
{
// List: thinker links.
thinker_t thinker;
// Info for drawing: position.
fixed_t x;
fixed_t y;
fixed_t z;
// More list: links in sector (if needed)
mobj_t* snext;
mobj_t* sprev;
//More drawing info: to determine current sprite.
angle_t angle; // orientation
spritenum_t sprite; // used to find patch_t and flip value
int frame; // might be ORed with FF_FULLBRIGHT
// Interaction info, by BLOCKMAP.
// Links in blocks (if needed).
mobj_t* bnext;
mobj_t* bprev;
struct subsector_s* subsector;
// The closest interval over all contacted Sectors.
fixed_t floorz;
fixed_t ceilingz;
// For movement checking.
fixed_t radius;
fixed_t height;
// Momentums, used to update position.
fixed_t momx;
fixed_t momy;
fixed_t momz;
// If == validcount, already checked.
int validcount;
mobjtype_t type;
const mobjinfo_t* info; // &mobjinfo[mobj->type]
int tics; // state tic counter
const state_t* state;
int flags;
int health;
// Movement direction, movement generation (zig-zagging).
int movedir; // 0-7
int movecount; // when 0, select a new dir
// Thing being chased/attacked (or NULL),
// also the originator for missiles.
mobj_t* target;
// Reaction time: if non 0, don't attack yet.
// Used by player to freeze a bit after teleporting.
int reactiontime;
// If >0, the target will be chased
// no matter what (even if shot)
int threshold;
// Additional info record for player avatars only.
// 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;
};
#endif

View File

@@ -0,0 +1,319 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "i_system.h"
#include "z_zone.h"
#include "m_random.h"
#include "doomdef.h"
#include "p_local.h"
#include "s_sound.h"
// State.
#include "doomstat.h"
#include "r_state.h"
// Data.
#include "sounds.h"
//
// Move a plat up and down
//
void T_PlatRaise(plat_t* plat)
{
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)
{
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;
}
}
//
// Do Platforms
// "amount" is only used for SOME platforms.
//
int
EV_DoPlat
( line_t* line,
plattype_e type,
int amount )
{
plat_t* plat;
int secnum;
int rtn;
sector_t* sec;
secnum = -1;
rtn = 0;
// Activate all <type> plats that are in_stasis
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;
// 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)
{
int i;
for (i = 0;i < MAXPLATS;i++)
if (::g->activeplats[i]
&& (::g->activeplats[i])->tag == tag
&& (::g->activeplats[i])->status == in_stasis)
{
(::g->activeplats[i])->status = (::g->activeplats[i])->oldstatus;
(::g->activeplats[i])->thinker.function.acp1
= (actionf_p1) T_PlatRaise;
}
}
void EV_StopPlat(line_t* line)
{
int j;
for (j = 0;j < MAXPLATS;j++)
if (::g->activeplats[j]
&& ((::g->activeplats[j])->status != in_stasis)
&& ((::g->activeplats[j])->tag == line->tag))
{
(::g->activeplats[j])->oldstatus = (::g->activeplats[j])->status;
(::g->activeplats[j])->status = in_stasis;
(::g->activeplats[j])->thinker.function.acv = (actionf_v)NULL;
}
}
void P_AddActivePlat(plat_t* plat)
{
int i;
for (i = 0;i < MAXPLATS;i++)
if (::g->activeplats[i] == NULL)
{
::g->activeplats[i] = plat;
return;
}
I_Error ("P_AddActivePlat: no more plats!");
}
void P_RemoveActivePlat(plat_t* plat)
{
int i;
for (i = 0;i < MAXPLATS;i++)
if (plat == ::g->activeplats[i])
{
(::g->activeplats[i])->sector->specialdata = NULL;
P_RemoveThinker(&(::g->activeplats[i])->thinker);
::g->activeplats[i] = NULL;
return;
}
I_Error ("P_RemoveActivePlat: can't find plat!");
}

976
doomclassic/doom/p_pspr.cpp Normal file
View File

@@ -0,0 +1,976 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#include "Precompiled.h"
#include "globaldata.h"
#include "doomdef.h"
#include "d_event.h"
#include "m_random.h"
#include "p_local.h"
#include "s_sound.h"
// State.
#include "doomstat.h"
// Data.
#include "sounds.h"
#include "p_pspr.h"
#include "d3xp/Game_local.h"
extern bool globalNetworking;
static const float PISTOL_MAGNITUDE_HIGH = 0.5f;
static const int PISTOL_DURATION_HIGH = 250;
static const float PISTOL_MAGNITUDE_LOW = 1.0f;
static const int PISTOL_DURATION_LOW = 150;
static const float SHOTGUN_MAGNITUDE_HIGH = 0.5f;
static const int SHOTGUN_DURATION_HIGH = 250;
static const float SHOTGUN_MAGNITUDE_LOW = 1.0f;
static const int SHOTGUN_DURATION_LOW = 350;
static const float CHAINGUN_MAGNITUDE_HIGH = 0.5f;
static const int CHAINGUN_DURATION_HIGH = 250;
static const float CHAINGUN_MAGNITUDE_LOW = 1.0f;
static const int CHAINGUN_DURATION_LOW = 150;
static const float PLASMAGUN_MAGNITUDE_HIGH = 0.5f;
static const int PLASMAGUN_DURATION_HIGH = 250;
static const float PLASMAGUN_MAGNITUDE_LOW = 1.0f;
static const int PLASMAGUN_DURATION_LOW = 150;
static const float SUPERSHOTGUN_MAGNITUDE_HIGH = 1.0f;
static const int SUPERSHOTGUN_DURATION_HIGH = 250;
static const float SUPERSHOTGUN_MAGNITUDE_LOW = 1.0f;
static const int SUPERSHOTGUN_DURATION_LOW = 350;
static const float ROCKET_MAGNITUDE_HIGH = 1.5f;
static const int ROCKET_DURATION_HIGH = 250;
static const float ROCKET_MAGNITUDE_LOW = 1.0f;
static const int ROCKET_DURATION_LOW = 350;
static const float BFG_MAGNITUDE_HIGH = 1.5f;
static const int BFG_DURATION_HIGH = 250;
static const float BFG_MAGNITUDE_LOW = 1.0f;
static const int BFG_DURATION_LOW = 400;
static const float SAW_IDL_MAGNITUDE_HIGH = 0.0f;
static const int SAW_IDL_DURATION_HIGH = 0;
static const float SAW_IDL_MAGNITUDE_LOW = 0.4f;
static const int SAW_IDL_DURATION_LOW = 150;
static const float SAW_ATK_MAGNITUDE_HIGH = 1.0f;
static const int SAW_ATK_DURATION_HIGH = 250;
static const float SAW_ATK_MAGNITUDE_LOW = 0.0f;
static const int SAW_ATK_DURATION_LOW = 0;
// plasma cells for a bfg attack
//
// P_SetPsprite
//
void
P_SetPsprite
( player_t* player,
int position,
statenum_t stnum )
{
pspdef_t* psp;
const state_t* state;
psp = &player->psprites[position];
do
{
if (!stnum)
{
// object removed itself
psp->state = NULL;
break;
}
state = &::g->states[stnum];
psp->state = state;
psp->tics = state->tics; // could be 0
if (state->misc1)
{
// coordinate set
psp->sx = state->misc1 << FRACBITS;
psp->sy = state->misc2 << FRACBITS;
}
// Call action routine.
// Modified handling.
if (state->action)
{
state->action(player, psp);
if (!psp->state)
break;
}
stnum = psp->state->nextstate;
} while (!psp->tics);
// an initial state of 0 could cycle through
}
//
// P_CalcSwing
//
void P_CalcSwing (player_t* player)
{
fixed_t swing;
int angle;
// OPTIMIZE: tablify this.
// A LUT would allow for different modes,
// and add flexibility.
swing = player->bob;
angle = (FINEANGLES/70*::g->leveltime)&FINEMASK;
::g->swingx = FixedMul ( swing, finesine[angle]);
angle = (FINEANGLES/70*::g->leveltime+FINEANGLES/2)&FINEMASK;
::g->swingy = -FixedMul ( ::g->swingx, finesine[angle]);
}
//
// P_BringUpWeapon
// Starts bringing the pending weapon up
// from the bottom of the screen.
// Uses player
//
void P_BringUpWeapon (player_t* player)
{
statenum_t newstate;
if (player->pendingweapon == wp_nochange)
player->pendingweapon = player->readyweapon;
if (player->pendingweapon == wp_chainsaw && (globalNetworking || (player == &::g->players[::g->consoleplayer])) )
S_StartSound (player->mo, sfx_sawup);
newstate = (statenum_t)(weaponinfo[player->pendingweapon].upstate);
player->pendingweapon = wp_nochange;
player->psprites[ps_weapon].sy = WEAPONBOTTOM;
P_SetPsprite (player, ps_weapon, newstate);
}
//
// P_CheckAmmo
// Returns true if there is enough ammo to shoot.
// If not, selects the next weapon to use.
//
qboolean P_CheckAmmo (player_t* player)
{
ammotype_t ammo;
int count;
ammo = weaponinfo[player->readyweapon].ammo;
// Minimal amount for one shot varies.
if (player->readyweapon == wp_bfg)
count = BFGCELLS;
else if (player->readyweapon == wp_supershotgun)
count = 2; // Double barrel.
else
count = 1; // Regular.
// Some do not need ammunition anyway.
// Return if current ammunition sufficient.
if (ammo == am_noammo || player->ammo[ammo] >= count)
return true;
// Out of ammo, pick a weapon to change to.
// Preferences are set here.
do
{
if (player->weaponowned[wp_plasma]
&& player->ammo[am_cell]
&& (::g->gamemode != shareware) )
{
player->pendingweapon = wp_plasma;
}
else if (player->weaponowned[wp_supershotgun]
&& player->ammo[am_shell]>2
&& (::g->gamemode == commercial) )
{
player->pendingweapon = wp_supershotgun;
}
else if (player->weaponowned[wp_chaingun]
&& player->ammo[am_clip])
{
player->pendingweapon = wp_chaingun;
}
else if (player->weaponowned[wp_shotgun]
&& player->ammo[am_shell])
{
player->pendingweapon = wp_shotgun;
}
else if (player->ammo[am_clip])
{
player->pendingweapon = wp_pistol;
}
else if (player->weaponowned[wp_chainsaw])
{
player->pendingweapon = wp_chainsaw;
}
else if (player->weaponowned[wp_missile]
&& player->ammo[am_misl])
{
player->pendingweapon = wp_missile;
}
else if (player->weaponowned[wp_bfg]
&& player->ammo[am_cell]>40
&& (::g->gamemode != shareware) )
{
player->pendingweapon = wp_bfg;
}
else
{
// If everything fails.
player->pendingweapon = wp_fist;
}
} while (player->pendingweapon == wp_nochange);
// Now set appropriate weapon overlay.
P_SetPsprite (player,
ps_weapon,
(statenum_t)(weaponinfo[player->readyweapon].downstate));
return false;
}
//
// P_FireWeapon.
//
void P_FireWeapon (player_t* player)
{
statenum_t newstate;
if (!P_CheckAmmo (player))
return;
P_SetMobjState (player->mo, S_PLAY_ATK1);
newstate = (statenum_t)weaponinfo[player->readyweapon].atkstate;
P_SetPsprite (player, ps_weapon, newstate);
P_NoiseAlert (player->mo, player->mo);
if (player->readyweapon == wp_chainsaw )
{
if( ::g->plyr == player ) {
}
}
}
//
// P_DropWeapon
// Player died, so put the weapon away.
//
void P_DropWeapon (player_t* player)
{
P_SetPsprite (player,
ps_weapon,
(statenum_t)weaponinfo[player->readyweapon].downstate);
}
extern "C" {
//
// A_WeaponReady
// The player can fire the weapon
// or change to another weapon at this time.
// Follows after getting weapon up,
// or after previous attack/fire sequence.
//
void
A_WeaponReady
( player_t* player,
pspdef_t* psp )
{
statenum_t newstate;
int angle;
// get out of attack state
if (player->mo->state == &::g->states[S_PLAY_ATK1]
|| player->mo->state == &::g->states[S_PLAY_ATK2] )
{
P_SetMobjState (player->mo, S_PLAY);
}
if (player->readyweapon == wp_chainsaw
&& psp->state == &::g->states[S_SAW])
{
if (globalNetworking || (player == &::g->players[::g->consoleplayer]))
S_StartSound (player->mo, sfx_sawidl);
}
// check for change
// if player is dead, put the weapon away
if (player->pendingweapon != wp_nochange || !player->health)
{
// change weapon
// (pending weapon should allready be validated)
newstate = (statenum_t)weaponinfo[player->readyweapon].downstate;
P_SetPsprite (player, ps_weapon, newstate);
return;
}
// check for fire
// the missile launcher and bfg do not auto fire
if (player->cmd.buttons & BT_ATTACK)
{
if ( !player->attackdown
|| (player->readyweapon != wp_missile
&& player->readyweapon != wp_bfg) )
{
player->attackdown = true;
P_FireWeapon (player);
return;
}
}
else
player->attackdown = false;
// bob the weapon based on movement speed
angle = (128*::g->leveltime)&FINEMASK;
psp->sx = FRACUNIT + FixedMul (player->bob, finecosine[angle]);
angle &= FINEANGLES/2-1;
psp->sy = WEAPONTOP + FixedMul (player->bob, finesine[angle]);
}
//
// A_ReFire
// The player can re-fire the weapon
// without lowering it entirely.
//
void A_ReFire
( player_t* player,
pspdef_t* psp )
{
// check for fire
// (if a weaponchange is pending, let it go through instead)
if ( (player->cmd.buttons & BT_ATTACK)
&& player->pendingweapon == wp_nochange
&& player->health)
{
player->refire++;
P_FireWeapon (player);
}
else
{
player->refire = 0;
P_CheckAmmo (player);
}
}
void
A_CheckReload
( player_t* player,
pspdef_t* psp )
{
P_CheckAmmo (player);
#if 0
if (player->ammo[am_shell]<2)
P_SetPsprite (player, ps_weapon, S_DSNR1);
#endif
}
//
// A_Lower
// Lowers current weapon,
// and changes weapon at bottom.
//
void
A_Lower
( player_t* player,
pspdef_t* psp )
{
psp->sy += LOWERSPEED;
// Is already down.
if (psp->sy < WEAPONBOTTOM )
return;
// Player is dead.
if (player->playerstate == PST_DEAD)
{
psp->sy = WEAPONBOTTOM;
// don't bring weapon back up
return;
}
// The old weapon has been lowered off the screen,
// so change the weapon and start raising it
if (!player->health)
{
// Player is dead, so keep the weapon off screen.
P_SetPsprite (player, ps_weapon, S_NULL);
return;
}
player->readyweapon = player->pendingweapon;
P_BringUpWeapon (player);
}
//
// A_Raise
//
void
A_Raise
( player_t* player,
pspdef_t* psp )
{
statenum_t newstate;
psp->sy -= RAISESPEED;
if (psp->sy > WEAPONTOP )
return;
psp->sy = WEAPONTOP;
// The weapon has been raised all the way,
// so change to the ready state.
newstate = (statenum_t)weaponinfo[player->readyweapon].readystate;
P_SetPsprite (player, ps_weapon, newstate);
}
//
// A_GunFlash
//
void
A_GunFlash
( player_t* player,
pspdef_t* psp )
{
P_SetMobjState (player->mo, S_PLAY_ATK2);
P_SetPsprite (player,ps_flash,(statenum_t)weaponinfo[player->readyweapon].flashstate);
}
//
// WEAPON ATTACKS
//
//
// A_Punch
//
void
A_Punch
( player_t* player,
pspdef_t* psp )
{
angle_t angle;
int damage;
int slope;
damage = (P_Random ()%10+1)<<1;
if (player->powers[pw_strength])
damage *= 10;
angle = player->mo->angle;
angle += (P_Random()-P_Random())<<18;
slope = P_AimLineAttack (player->mo, angle, MELEERANGE);
P_LineAttack (player->mo, angle, MELEERANGE, slope, damage);
// turn to face target
if (::g->linetarget)
{
S_StartSound (player->mo, sfx_punch);
player->mo->angle = R_PointToAngle2 (player->mo->x,
player->mo->y,
::g->linetarget->x,
::g->linetarget->y);
}
}
//
// A_Saw
//
void
A_Saw
( player_t* player,
pspdef_t* psp )
{
angle_t angle;
int damage;
int slope;
damage = 2*(P_Random ()%10+1);
angle = player->mo->angle;
angle += (P_Random()-P_Random())<<18;
// use meleerange + 1 se the puff doesn't skip the flash
slope = P_AimLineAttack (player->mo, angle, MELEERANGE+1);
P_LineAttack (player->mo, angle, MELEERANGE+1, slope, damage);
if (!::g->linetarget)
{
if (globalNetworking || (player == &::g->players[::g->consoleplayer]))
S_StartSound (player->mo, sfx_sawful);
return;
}
if (globalNetworking || (player == &::g->players[::g->consoleplayer]))
S_StartSound (player->mo, sfx_sawhit);
// turn to face target
angle = R_PointToAngle2 (player->mo->x, player->mo->y,
::g->linetarget->x, ::g->linetarget->y);
if (angle - player->mo->angle > ANG180)
{
if (angle - player->mo->angle < -ANG90/20)
player->mo->angle = angle + ANG90/21;
else
player->mo->angle -= ANG90/20;
}
else
{
if (angle - player->mo->angle > ANG90/20)
player->mo->angle = angle - ANG90/21;
else
player->mo->angle += ANG90/20;
}
player->mo->flags |= MF_JUSTATTACKED;
}
//
// A_FireMissile
//
void
A_FireMissile
( player_t* player,
pspdef_t* psp )
{
if( (player->cheats & CF_INFAMMO) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]--;
}
P_SpawnPlayerMissile (player->mo, MT_ROCKET);
if( ::g->plyr == player ) {
}
}
//
// A_FireBFG
//
void
A_FireBFG
( player_t* player,
pspdef_t* psp )
{
if( (player->cheats & CF_INFAMMO) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo] -= BFGCELLS;
}
P_SpawnPlayerMissile (player->mo, MT_BFG);
if( ::g->plyr == player ) {
}
}
//
// A_FirePlasma
//
void
A_FirePlasma
( player_t* player,
pspdef_t* psp )
{
if( (player->cheats & CF_INFAMMO) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]--;
}
P_SetPsprite (player,
ps_flash,
(statenum_t)(weaponinfo[player->readyweapon].flashstate+(P_Random ()&1)) );
P_SpawnPlayerMissile (player->mo, MT_PLASMA);
if( ::g->plyr == player ) {
}
}
//
// P_BulletSlope
// Sets a slope so a near miss is at aproximately
// the height of the intended target
//
void P_BulletSlope (mobj_t* mo)
{
angle_t an;
// see which target is to be aimed at
an = mo->angle;
::g->bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);
if (!::g->linetarget)
{
an += 1<<26;
::g->bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);
if (!::g->linetarget)
{
an -= 2<<26;
::g->bulletslope = P_AimLineAttack (mo, an, 16*64*FRACUNIT);
}
}
}
//
// P_GunShot
//
void
P_GunShot
( mobj_t* mo,
qboolean accurate )
{
angle_t angle;
int damage;
damage = 5*(P_Random ()%3+1);
angle = mo->angle;
if (!accurate)
angle += (P_Random()-P_Random())<<18;
P_LineAttack (mo, angle, MISSILERANGE, ::g->bulletslope, damage);
}
//
// A_FirePistol
//
void
A_FirePistol
( player_t* player,
pspdef_t* psp )
{
if (globalNetworking || (player == &::g->players[::g->consoleplayer]))
S_StartSound (player->mo, sfx_pistol);
P_SetMobjState (player->mo, S_PLAY_ATK2);
if( (player->cheats & CF_INFAMMO ) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]--;
}
P_SetPsprite (player,
ps_flash,
(statenum_t)weaponinfo[player->readyweapon].flashstate);
P_BulletSlope (player->mo);
P_GunShot (player->mo, !player->refire);
if( ::g->plyr == player ) {
}
}
//
// A_FireShotgun
//
void
A_FireShotgun
( player_t* player,
pspdef_t* psp )
{
int i;
if (globalNetworking || (player == &::g->players[::g->consoleplayer]))
S_StartSound (player->mo, sfx_shotgn);
P_SetMobjState (player->mo, S_PLAY_ATK2);
if( ( player->cheats & CF_INFAMMO ) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]--;
}
P_SetPsprite (player,
ps_flash,
(statenum_t)weaponinfo[player->readyweapon].flashstate);
P_BulletSlope (player->mo);
for (i=0 ; i<7 ; i++)
P_GunShot (player->mo, false);
if( ::g->plyr == player ) {
}
}
//
// A_FireShotgun2
//
void
A_FireShotgun2
( player_t* player,
pspdef_t* psp )
{
int i;
angle_t angle;
int damage;
if (globalNetworking || (player == &::g->players[::g->consoleplayer]))
S_StartSound (player->mo, sfx_dshtgn);
P_SetMobjState (player->mo, S_PLAY_ATK2);
if( (player->cheats & CF_INFAMMO) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]-=2;
}
P_SetPsprite (player,
ps_flash,
(statenum_t)weaponinfo[player->readyweapon].flashstate);
P_BulletSlope (player->mo);
for (i=0 ; i<20 ; i++)
{
damage = 5*(P_Random ()%3+1);
angle = player->mo->angle;
angle += (P_Random()-P_Random())<<19;
P_LineAttack (player->mo,
angle,
MISSILERANGE,
::g->bulletslope + ((P_Random()-P_Random())<<5), damage);
}
if( ::g->plyr == player ) {
}
}
//
// A_FireCGun
//
void
A_FireCGun
( player_t* player,
pspdef_t* psp )
{
if (globalNetworking || (player == &::g->players[::g->consoleplayer]))
S_StartSound (player->mo, sfx_pistol);
if (!player->ammo[weaponinfo[player->readyweapon].ammo])
return;
P_SetMobjState (player->mo, S_PLAY_ATK2);
if( (player->cheats & CF_INFAMMO) == false ) {
player->ammo[weaponinfo[player->readyweapon].ammo]--;
}
P_SetPsprite (player,
ps_flash,
(statenum_t)(
weaponinfo[player->readyweapon].flashstate
+ psp->state
- &::g->states[S_CHAIN1] ));
P_BulletSlope (player->mo);
P_GunShot (player->mo, !player->refire);
if( ::g->plyr == player ) {
}
}
//
// ?
//
void A_Light0 (player_t *player, pspdef_t *psp)
{
player->extralight = 0;
}
void A_Light1 (player_t *player, pspdef_t *psp)
{
player->extralight = 1;
}
void A_Light2 (player_t *player, pspdef_t *psp)
{
player->extralight = 2;
}
//
// A_BFGSpray
// Spawn a BFG explosion on every monster in view
//
void A_BFGSpray (mobj_t* mo, void * )
{
int i;
int j;
int damage;
angle_t an;
// offset angles from its attack angle
for (i=0 ; i<40 ; i++)
{
an = mo->angle - ANG90/2 + ANG90/40*i;
// mo->target is the originator (player)
// of the missile
P_AimLineAttack (mo->target, an, 16*64*FRACUNIT);
if (!::g->linetarget)
continue;
P_SpawnMobj (::g->linetarget->x,
::g->linetarget->y,
::g->linetarget->z + (::g->linetarget->height>>2),
MT_EXTRABFG);
damage = 0;
for (j=0;j<15;j++)
damage += (P_Random()&7) + 1;
P_DamageMobj (::g->linetarget, mo->target,mo->target, damage);
}
}
//
// A_BFGsound
//
void
A_BFGsound
( player_t* player,
pspdef_t* psp )
{
S_StartSound (player->mo, sfx_bfg);
}
}; // extern "C"
//
// P_SetupPsprites
// Called at start of level for each player.
//
void P_SetupPsprites (player_t* player)
{
int i;
// remove all psprites
for (i=0 ; i<NUMPSPRITES ; i++)
player->psprites[i].state = NULL;
// spawn the gun
player->pendingweapon = player->readyweapon;
P_BringUpWeapon (player);
}
//
// P_MovePsprites
// Called every tic by player thinking routine.
//
void P_MovePsprites (player_t* player)
{
int i;
pspdef_t* psp;
const state_t* state;
psp = &player->psprites[0];
for (i=0 ; i<NUMPSPRITES ; i++, psp++)
{
// a null state means not active
if ( (state = psp->state) )
{
// drop tic count and possibly change state
// a -1 tic count never changes
if (psp->tics != -1)
{
psp->tics--;
if (!psp->tics)
P_SetPsprite (player, i, psp->state->nextstate);
}
}
}
player->psprites[ps_flash].sx = player->psprites[ps_weapon].sx;
player->psprites[ps_flash].sy = player->psprites[ps_weapon].sy;
}

84
doomclassic/doom/p_pspr.h Normal file
View File

@@ -0,0 +1,84 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __P_PSPR__
#define __P_PSPR__
// Basic data types.
// Needs fixed point, and BAM angles.
#include "m_fixed.h"
#include "tables.h"
//
// Needs to include the precompiled
// sprite animation tables.
// Header generated by multigen utility.
// This includes all the data for thing animation,
// i.e. the Thing Atrributes table
// and the Frame Sequence table.
#include "info.h"
#ifdef __GNUG__
#pragma interface
#endif
//
// Frame flags:
// handles maximum brightness (torches, muzzle flare, light sources)
//
#define FF_FULLBRIGHT 0x8000 // flag in thing->frame
#define FF_FRAMEMASK 0x7fff
//
// Overlay psprites are scaled shapes
// drawn directly on the view screen,
// coordinates are given for a 320*200 view screen.
//
typedef enum
{
ps_weapon,
ps_flash,
NUMPSPRITES
} psprnum_t;
typedef struct
{
const state_t* state; // a NULL state means not active
int tics;
fixed_t sx;
fixed_t sy;
} pspdef_t;
#endif

1038
doomclassic/doom/p_saveg.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,53 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
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").
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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __P_SAVEG__
#define __P_SAVEG__
#ifdef __GNUG__
#pragma interface
#endif
// Persistent storage/archiving.
// These are the load / save game routines.
void P_ArchivePlayers (void);
void P_UnArchivePlayers (void);
void P_ArchiveWorld (void);
void P_UnArchiveWorld (void);
void P_ArchiveThinkers (void);
void P_UnArchiveThinkers (void);
void P_ArchiveSpecials (void);
void P_UnArchiveSpecials (void);
extern byte* save_p;
#endif

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