This commit is contained in:
Christoph Oelckers 2016-10-01 18:22:00 +02:00
commit 3a3d538a45
7 changed files with 169 additions and 18 deletions

View file

@ -30,8 +30,27 @@ if(CMAKE_CROSSCOMPILING)
include(${IMPORT_EXECUTABLES})
endif()
# Recursive function to place PK3 archive source files into a hierarchy of source file in the IDE
function( assort_pk3_source_folder FOLDER_NAME PK3_DIR )
# Assort source files into folders in the IDE
file(GLOB PK3_SRCS ${PK3_DIR}/*) # Create list of all files in this folder
foreach(PK3_SRC ${PK3_SRCS})
# If there are subfolders, recurse into them
if(IS_DIRECTORY ${PK3_SRC})
get_filename_component(DIRNAME ${PK3_SRC} NAME)
# Exclude folder from list of source files
list(REMOVE_ITEM PK3_SRCS ${PK3_SRC})
# Recurse deeper into the filesystem folder tree
assort_pk3_source_folder( ${FOLDER_NAME}\\${DIRNAME} ${PK3_SRC} )
endif()
# Assign IDE group for current top-level source files
source_group(${FOLDER_NAME} FILES ${PK3_SRCS})
endforeach()
endfunction()
# Simplify pk3 building, add_pk3(filename srcdirectory)
function( add_pk3 PK3_NAME PK3_DIR )
# message(STATUS "Creating build rule for PK3 ${PK3_NAME} ${PK3_DIR}")
# Generate target name. Just use "pk3" for main pk3 target.
string( REPLACE "." "_" PK3_TARGET ${PK3_NAME} )
if( ${PK3_TARGET} STREQUAL "zdoom_pk3" )
@ -48,14 +67,33 @@ function( add_pk3 PK3_NAME PK3_DIR )
COMMAND zipdir -udf ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR}
DEPENDS zipdir )
endif()
# Grab a list of top-level PK3 folder files, so we can conveniently see them in the IDE
file(GLOB PK3_SRCS ${PK3_DIR}/*)
# Create a list of source files for this PK3, for use in the IDE
# Phase 1: Create a list of all source files for this PK3 archive, except
# for a couple of strife image file names that confuse CMake.
file(GLOB_RECURSE PK3_SRCS ${PK3_DIR}/*)
# Exclude from the source list some gzdoom .png files with brackets in the
# file names here, because they confuse CMake.
# This only affects the list of source files shown in the IDE.
# It does not actually remove the files from the PK3 archive.
# First replace that toxic bracket character with something we can handle
string(REPLACE "[" confusing_bracket PK3_SRCS "${PK3_SRCS}")
string(REPLACE "]" confusing_bracket PK3_SRCS "${PK3_SRCS}")
foreach(PK3_SRC ${PK3_SRCS}) # All source files at all levels
# Exclude those quarantined source file source file names that once had a bracket
if(${PK3_SRC} MATCHES confusing_bracket)
# message(STATUS "Ignoring PK3 file name containing brackets "${PK3_SRC})
list(REMOVE_ITEM PK3_SRCS ${PK3_SRC})
endif()
endforeach()
# Phase 2: Create the PK3 build rule, including the source file list for the IDE
# Touch the zipdir executable here so that the pk3s are forced to
# rebuild each time since their dependecy has "changed."
# rebuild each time since their dependency has "changed."
add_custom_target( ${PK3_TARGET} ALL
COMMAND ${CMAKE_COMMAND} -E touch $<TARGET_FILE:zipdir>
DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME}
SOURCES ${PK3_SRCS})
# Phase 3: Assign source files to a nice folder structure in the IDE
assort_pk3_source_folder("Source Files" ${PK3_DIR})
endfunction()
# Macro for building libraries without debugging information

View file

@ -1323,6 +1323,9 @@ bool AActor::Massacre ()
if (health > 0)
{
auto f = flags;
auto f2 = flags2;
flags |= MF_SHOOTABLE;
flags2 &= ~(MF2_DORMANT|MF2_INVULNERABLE);
do
@ -1331,6 +1334,12 @@ bool AActor::Massacre ()
P_DamageMobj (this, NULL, NULL, TELEFRAG_DAMAGE, NAME_Massacre);
}
while (health != prevhealth && health > 0); //abort if the actor wasn't hurt.
if (health > 0)
{
// restore flags if this did not kill the monster.
flags = f;
flags2 = f2;
}
return health <= 0;
}
return false;

View file

@ -259,6 +259,7 @@ DScroller::DScroller (EScroll type, double dx, double dy,
m_Accel = accel;
m_Parts = scrollpos;
m_vdx = m_vdy = 0;
m_LastHeight = 0;
if ((m_Control = control) != -1)
m_LastHeight =
sectors[control].CenterFloor () + sectors[control].CenterCeiling ();
@ -342,6 +343,7 @@ DScroller::DScroller (double dx, double dy, const line_t *l,
m_vdx = m_vdy = 0;
m_Accel = accel;
m_Parts = scrollpos;
m_LastHeight = 0;
if ((m_Control = control) != -1)
m_LastHeight = sectors[control].CenterFloor() + sectors[control].CenterCeiling();
m_Affectee = int(l->sidedef[0] - sides);

View file

@ -51,6 +51,7 @@
#include "i_system.h"
#include "d_player.h"
#include "serializer.h"
#include "v_text.h"
// MACROS ------------------------------------------------------------------
@ -326,6 +327,99 @@ void S_HashSounds ()
}
}
//==========================================================================
//
// S_CheckIntegrity
//
// Scans the entire sound list and looks for recursive definitions.
//==========================================================================
static bool S_CheckSound(sfxinfo_t *startsfx, sfxinfo_t *sfx, TArray<sfxinfo_t *> &chain)
{
sfxinfo_t *me = sfx;
bool success = true;
unsigned siz = chain.Size();
if (sfx->bPlayerReserve)
{
return true;
}
// There is a bad link in here, but let's report it only for the sound that contains the broken definition.
// Once that sound has been disabled this one will work again.
if (chain.Find(sfx) < chain.Size())
{
return true;
}
chain.Push(sfx);
if (me->bRandomHeader)
{
const FRandomSoundList *list = &S_rnd[me->link];
for (int i = 0; i < list->NumSounds; ++i)
{
auto rsfx = &S_sfx[list->Sounds[i]];
if (rsfx == startsfx)
{
Printf(TEXTCOLOR_RED "recursive sound $random found for %s:\n", startsfx->name.GetChars());
success = false;
for (unsigned i = 1; i<chain.Size(); i++)
{
Printf(TEXTCOLOR_ORANGE " -> %s\n", chain[i]->name.GetChars());
}
}
else
{
success &= S_CheckSound(startsfx, rsfx, chain);
}
}
}
else if (me->link != sfxinfo_t::NO_LINK)
{
me = &S_sfx[me->link];
if (me == startsfx)
{
Printf(TEXTCOLOR_RED "recursive sound $alias found for %s:\n", startsfx->name.GetChars());
success = false;
for (unsigned i = 1; i<chain.Size(); i++)
{
Printf(TEXTCOLOR_ORANGE " -> %s\n", chain[i]->name.GetChars());
}
chain.Resize(siz);
}
else
{
success &= S_CheckSound(startsfx, me, chain);
}
}
chain.Pop();
return success;
}
void S_CheckIntegrity()
{
TArray<sfxinfo_t *> chain;
TArray<bool> broken;
broken.Resize(S_sfx.Size());
memset(&broken[0], 0, sizeof(bool)*S_sfx.Size());
for (unsigned i = 0; i < S_sfx.Size(); i++)
{
auto &sfx = S_sfx[i];
broken[i] = !S_CheckSound(&sfx, &sfx, chain);
}
for (unsigned i = 0; i < S_sfx.Size(); i++)
{
if (broken[i])
{
auto &sfx = S_sfx[i];
Printf(TEXTCOLOR_RED "Sound %s has been disabled\n", sfx.name.GetChars());
sfx.bRandomHeader = false;
sfx.link = 0; // link to the empty sound.
}
}
}
//==========================================================================
//
// S_PickReplacement
@ -334,13 +428,12 @@ void S_HashSounds ()
// is not the head of a random list, then the sound passed is returned.
//==========================================================================
int S_PickReplacement (int refid)
int S_PickReplacement(int refid)
{
if (S_sfx[refid].bRandomHeader)
while (S_sfx[refid].bRandomHeader)
{
const FRandomSoundList *list = &S_rnd[S_sfx[refid].link];
return list->Sounds[pr_randsound() % list->NumSounds];
refid = list->Sounds[pr_randsound() % list->NumSounds];
}
return refid;
}
@ -941,6 +1034,7 @@ void S_ParseSndInfo (bool redefine)
S_ShrinkPlayerSoundLists ();
sfx_empty = Wads.CheckNumForName ("dsempty", ns_sounds);
S_CheckIntegrity();
}
//==========================================================================
@ -961,6 +1055,7 @@ void S_AddLocalSndInfo(int lump)
}
S_ShrinkPlayerSoundLists ();
S_CheckIntegrity();
}
//==========================================================================

View file

@ -522,18 +522,19 @@ void S_CacheSound (sfxinfo_t *sfx)
{
return;
}
else if (sfx->bRandomHeader)
sfxinfo_t *orig = sfx;
while (!sfx->bRandomHeader && sfx->link != sfxinfo_t::NO_LINK)
{
S_CacheRandomSound (sfx);
sfx = &S_sfx[sfx->link];
}
if (sfx->bRandomHeader)
{
S_CacheRandomSound(sfx);
}
else
{
while (sfx->link != sfxinfo_t::NO_LINK)
{
sfx = &S_sfx[sfx->link];
}
S_LoadSound(sfx);
sfx->bUsed = true;
S_LoadSound (sfx);
}
}
}

View file

@ -215,8 +215,14 @@ struct FWriter
void Double(double k)
{
if (mWriter1) mWriter1->Double(k);
else if (mWriter2) mWriter2->Double(k);
if (mWriter1)
{
if (!mWriter1->Double(k)) mWriter1->Double(0);
}
else if (mWriter2)
{
if (!mWriter2->Double(k)) mWriter2->Double(0);
}
}
};

View file

@ -211,11 +211,11 @@ bool MUSSong2::CheckDone()
void MUSSong2::Precache()
{
TArray<WORD> work(MusHeader->NumInstruments);
TArray<WORD> work(LittleShort(MusHeader->NumInstruments));
const BYTE *used = (BYTE *)MusHeader + sizeof(MUSHeader) / sizeof(BYTE);
int i, k;
for (i = k = 0; i < MusHeader->NumInstruments; ++i)
for (i = k = 0; i < LittleShort(MusHeader->NumInstruments); ++i)
{
BYTE instr = used[k++];
WORD val;