Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix no VR and fix loading games from 32-bit on 64-bit and vice-versa #301

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions doomclassic/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
# Doom 1 coding style

Language: Cpp
Standard: Auto
DisableFormat: false

IndentWidth: 4
TabWidth: 4
UseTab: ForContinuationAndIndentation
IndentCaseLabels: false
AccessModifierOffset: -4
IndentWrappedFunctionNames: false
NamespaceIndentation: All
ContinuationIndentWidth: 4

SpaceBeforeParens: ControlStatements
SpacesInParentheses: false
SpacesInCStyleCastParentheses: false
SpaceInEmptyParentheses: false
SpacesInContainerLiterals: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
#SpaceBeforeCpp11BracedList: false

SpaceBeforeAssignmentOperators: true
#SpaceAfterLogicalNot: false
SpacesBeforeTrailingComments: 1

BreakBeforeBraces: Custom
BraceWrapping:
IndentBraces: false # always
AfterClass: true # always
AfterEnum: true # 6 out of 61 are wrong
AfterUnion: false # 1 out of 6 is wrong
AfterStruct: true # most of the time
AfterFunction: true # most of the time
AfterNamespace: false # 2 out of 6 are wrong
BeforeElse: false # about 50/50 so use the style I prefer
AfterControlStatement: false # a mixture so use the style I prefer
BeforeCatch: true # never used
AfterObjCDeclaration: false # never used

ColumnLimit: 100

AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignTrailingComments: false

#SpaceBeforeInheritanceColon: true
#SpaceBeforeCtorInitializerColon: true
#AllowAllConstructorInitializersOnNextLine: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4

AllowAllParametersOfDeclarationOnNextLine: false
#AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true


AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
#AlwaysBreakTemplateDeclarations: MultiLine
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeTernaryOperators: false

DerivePointerAlignment: true
PointerAlignment: Left

SortIncludes: false
SortUsingDeclarations: false
ReflowComments: false
MaxEmptyLinesToKeep: 3
KeepEmptyLinesAtTheStartOfBlocks: true

CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^\<[^Q][^/.>]*\>'
Priority: -2
- Regex: '^\<'
Priority: -1
- Regex: '^\"'
Priority: 0
MacroBlockBegin: ''
MacroBlockEnd: ''
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 150

# inconsistent
#SpacesInSquareBrackets: false
#SpacesInAngles: false
#AlignConsecutiveDeclarations: false
#AlignEscapedNewlinesLeft: false
#AlignOperands: false
#BreakBeforeBinaryOperators: None
...
113 changes: 113 additions & 0 deletions neo/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
# Doom 3 coding style

Language: Cpp
Standard: Auto
DisableFormat: false

IndentWidth: 4
TabWidth: 4
UseTab: Always
IndentCaseLabels: true
AccessModifierOffset: -4
IndentWrappedFunctionNames: false
NamespaceIndentation: None
ContinuationIndentWidth: 4

SpaceBeforeParens: false
SpacesInParentheses: true
SpacesInCStyleCastParentheses: true
SpaceInEmptyParentheses: false
SpacesInContainerLiterals: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
#SpaceBeforeCpp11BracedList: false

SpaceBeforeAssignmentOperators: true
#SpaceAfterLogicalNot: false
#SpacesBeforeTrailingComments: 1

BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false

ColumnLimit: 160

AlignAfterOpenBracket: Align
AlignTrailingComments: true

#SpaceBeforeInheritanceColon: true
#SpaceBeforeCtorInitializerColon: true
#AllowAllConstructorInitializersOnNextLine: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4

AllowAllParametersOfDeclarationOnNextLine: false
#AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false


AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
#AlwaysBreakTemplateDeclarations: MultiLine
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeTernaryOperators: false

DerivePointerAlignment: false
PointerAlignment: Left

SortIncludes: false
SortUsingDeclarations: false
ReflowComments: false
MaxEmptyLinesToKeep: 3
KeepEmptyLinesAtTheStartOfBlocks: true

BreakConstructorInitializersBeforeComma: false
CommentPragmas: '^ IWYU pragma:'
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeCategories:
- Regex: '^\<[^Q][^/.>]*\>'
Priority: -2
- Regex: '^\<'
Priority: -1
- Regex: '^\"'
Priority: 0
MacroBlockBegin: ''
MacroBlockEnd: ''
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 150

# inconsistent
SpacesInSquareBrackets: true
#SpacesInAngles: false
#AlignConsecutiveAssignments: false
#AlignConsecutiveDeclarations: false
#AlignEscapedNewlinesLeft: false
#AlignOperands: false
#BreakBeforeBinaryOperators: None
...
21 changes: 13 additions & 8 deletions neo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")

elseif(MSVC)

# the warnings are used for every profile anyway, so put them in a variable
# 4267 is for warning about converting size_t to smaller types (eg. int)
# 4467 is for VS2017 spamming: warning C4467: usage of ATL attributes is deprecated
set(my_warn_flags "/wd4267 /wd4467")

# Multiprocessor support for compiling
# /MP

Expand Down Expand Up @@ -152,15 +157,15 @@ elseif(MSVC)
# set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP ${WINRT_OPTIONS}")
# set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /Oi /Oy ${WINRT_OPTIONS}")
# else()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /D _DEBUG /MP /MTd")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MP /Oi /Oy /MT /wd4267")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MP /Oi /MTd /wd4267")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MP /Oi /Oy /MT /wd4267")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /D _DEBUG /MP /MTd ${my_warn_flags}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MP /Oi /Oy /MT ${my_warn_flags}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /MP /Oi /MTd ${my_warn_flags}")
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /MP /Oi /Oy /MT ${my_warn_flags}")

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /Oi /Oy /MT /wd4267")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP /MTd /wd4267")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /Oi /Oy /MT /wd4267")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MP /MTd ${my_warn_flags}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MP /Oi /Oy /MT ${my_warn_flags}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MP /MTd ${my_warn_flags}")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MP /Oi /Oy /MT ${my_warn_flags}")

# RB: without /SAFESEH:NO we can't link against ffmpeg libs and VS2013 or we have to build our own
# libs for newer compilers
Expand Down
2 changes: 1 addition & 1 deletion neo/cmake-vs2013-32bit-openal.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ cd ..
del /s /q build
mkdir build
cd build
cmake -G "Visual Studio 12" -DCMAKE_INSTALL_PREFIX=../bin/win8-32 -DOPENAL=ON ../neo
cmake -G "Visual Studio 12 2013" -DCMAKE_INSTALL_PREFIX=../bin/win8-32 -DOPENAL=ON ../neo
pause
2 changes: 1 addition & 1 deletion neo/cmake-vs2013-32bit.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ cd ..
del /s /q build
mkdir build
cd build
cmake -G "Visual Studio 12" -DCMAKE_INSTALL_PREFIX=../bin/win8-32 ../neo
cmake -G "Visual Studio 12 2013" -DCMAKE_INSTALL_PREFIX=../bin/win8-32 ../neo
pause
2 changes: 1 addition & 1 deletion neo/cmake-vs2013-64bit.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ cd ..
del /s /q build
mkdir build
cd build
cmake -G "Visual Studio 12 Win64" -DCMAKE_INSTALL_PREFIX=../bin/win8-64 ../neo
cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=../bin/win8-64 ../neo
pause
4 changes: 2 additions & 2 deletions neo/d3xp/Actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ class idActor : public idAFEntity_Gibbable

idLinkList<idActor> enemyNode; // node linked into an entity's enemy list for quick lookups of who is attacking him
idLinkList<idActor> enemyList; // list of characters that have targeted the player as their enemy

friend class idConsoleLocal;

public:
idActor();
virtual ~idActor();
Expand Down Expand Up @@ -302,7 +303,6 @@ class idActor : public idAFEntity_Gibbable
void SetupHead();
public:
void PlayFootStepSound();

private:
void Event_EnableEyeFocus();
void Event_DisableEyeFocus();
Expand Down
17 changes: 14 additions & 3 deletions neo/d3xp/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -805,8 +805,15 @@ void idEntity::Restore( idRestoreGame* savefile )
// spawnNode and activeNode are restored by gameLocal
savefile->ReadDict( &spawnArgs );
savefile->ReadString( name );
if ( name == "vrTeleportTarget" && gameLocal.FindEntity("vrTeleportTarget") )
SetName( "vrTeleportTarget2" );
char* duplicate_names[5] = { "vrTeleportTarget", "player1_weapon_left", "player1_weapon_right", "player1_weapon_left_worldmodel", "player1_weapon_right_worldmodel" };
bool isDuplicate = false;
for( int i = 0; i < 5; i++ )
{
if( name == duplicate_names[i] && gameLocal.FindEntity( name.c_str() ) )
isDuplicate = true;
}
if( isDuplicate )
SetName( name + "2" );
else
SetName( name );

Expand Down Expand Up @@ -3607,7 +3614,11 @@ idEntity::RemoveContactEntity
*/
void idEntity::RemoveContactEntity( idEntity* ent )
{
GetPhysics()->RemoveContactEntity( ent );
idPhysics* physicsPtr = GetPhysics();
if( physicsPtr ) // prevent crash when physics is NULL
{
physicsPtr->RemoveContactEntity( ent );
}
}


Expand Down
32 changes: 30 additions & 2 deletions neo/d3xp/Game_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1661,6 +1661,17 @@ bool idGameLocal::InitFromSaveGame( const char* mapName, idRenderWorld* renderWo
{
idPlayer *player = GetLocalPlayer();
player->InitTeleportTarget();
idEntity *duplicate;
char* duplicate_names[4] = { "player1_weapon_left2", "player1_weapon_right2", "player1_weapon_left_worldmodel2", "player1_weapon_right_worldmodel2" };
for( int i = 0; i < 4; i++ )
{
if ( duplicate = gameLocal.FindEntity( duplicate_names[i] ) )
{
common->Warning( "Loading game which had a duplicate player1_weapon_left/right (this is normal)." );
duplicate->PostEventMS( &EV_Remove, 0 );
}
}

// if we autosaved while teleporting QuakeCon style, stop the QuakeCon style effect
if (player->noclip)// && player->playerView.bfgVision)
{
Expand Down Expand Up @@ -4142,9 +4153,26 @@ void idGameLocal::AddEntityToHash( const char* name, idEntity* ent )
{
if( FindEntity( name ) )
{
Error( "Multiple entities named '%s'", name );
// Carl: When loading saved games from other mods, we sometimes need to reset scripts.
// The reset scripts for some monsters end up creating a _light entity that was already created.
// For now, handle that by renaming the duplicate then deleting it.
// This mostly happens with Erebus levels.
idStr n( name );
if( n.Right( 6 ) == "_light" )
{
n = n + '2';
entityHash.Add( entityHash.GenerateKey( n.c_str(), true ), ent->entityNumber );
ent->PostEventMS( &EV_Remove, 0 );
}
else
{
Error( "Multiple entities named '%s'", name );
}
}
else
{
entityHash.Add( entityHash.GenerateKey( name, true ), ent->entityNumber );
}
entityHash.Add( entityHash.GenerateKey( name, true ), ent->entityNumber );
}

/*
Expand Down
Loading