Skip to content

Commit

Permalink
Merge branch 'master' into multiple_sections
Browse files Browse the repository at this point in the history
  • Loading branch information
Fulgen301 committed Sep 18, 2024
2 parents 6291c9c + fa914d7 commit 618849a
Show file tree
Hide file tree
Showing 38 changed files with 1,068 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
run: |
mkdir deps
cd deps
curl -L https://github.com/legacyclonk/deps/releases/download/2024-07-01/lc_deps-$CONFIG_SUFFIX.tar.gz | tar -xz
curl -L https://github.com/legacyclonk/deps/releases/download/2024-07-24/lc_deps-$CONFIG_SUFFIX.tar.gz | tar -xz
./fix_paths.sh
- name: "Configuration setup: No Sound"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
run: |
mkdir deps
cd deps
curl -L https://github.com/legacyclonk/deps/releases/download/2024-07-01/lc_deps-$CONFIG_SUFFIX.tar.gz | tar -xz
curl -L https://github.com/legacyclonk/deps/releases/download/2024-07-24/lc_deps-$CONFIG_SUFFIX.tar.gz | tar -xz
./fix_paths.sh
- name: Configure
Expand Down
33 changes: 32 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ cmake_policy(SET CMP0072 NEW)
# Enable <PackageName>_ROOT for find_package
cmake_policy(SET CMP0074 NEW)

# Enable option() honoring existing variables
cmake_policy(SET CMP0077 NEW)

if (APPLE)
set(LANGUAGE_OBJCXX OBJCXX)
endif ()
Expand All @@ -47,6 +50,7 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CheckCXXSymbolExists)
include(CheckIncludeFileCXX)
include(CMakeDependentOption)
include(FetchContent)

# Make sure headers of the project are found
include_directories(src)
Expand Down Expand Up @@ -95,6 +99,8 @@ CMAKE_DEPENDENT_OPTION(WITH_DEVELOPER_MODE "Use GTK for the developer mode" OFF
"NOT USE_CONSOLE" OFF)
# USE_LIBNOTIFY
CMAKE_DEPENDENT_OPTION(USE_LIBNOTIFY "Use libnotify for desktop notifications" ON "WITH_DEVELOPER_MODE AND NOT USE_CONSOLE AND NOT WIN32" OFF)
# USE_MINIUPNPC
option(USE_MINIUPNPC "Use miniupnpc for UPnP support" ON)
# USE_WINDOWS_RUNTIME
CMAKE_DEPENDENT_OPTION(USE_WINDOWS_RUNTIME "Use Windows Runtime features" ON "WIN32" OFF)

Expand Down Expand Up @@ -242,6 +248,12 @@ if (USE_LIBNOTIFY)
src/C4ToastLibNotify.cpp src/C4ToastLibNotify.h)
endif ()

if (USE_MINIUPNPC)
list(APPEND CLONK_SOURCES src/C4Network2UPnPMiniUPnPc.cpp)
else ()
list(APPEND CLONK_SOURCES src/C4Network2UPnPDummy.cpp)
endif ()

if (USE_WINDOWS_RUNTIME)
list(APPEND CLONK_SOURCES
src/C4ToastWinRT.cpp src/C4ToastWinRT.h)
Expand Down Expand Up @@ -408,7 +420,20 @@ if (USE_SDL_MIXER)
endif ()

# Link spdlog
find_package(spdlog REQUIRED)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.14.1
)

set(SPDLOG_BUILD_EXAMPLE OFF)
set(SPDLOG_DISABLE_DEFAULT_LOGGER ON)
set(SPDLOG_ENABLE_PCH ${USE_PCH})
set(SPDLOG_USE_STD_FORMAT ON)

FetchContent_MakeAvailable(spdlog)

target_compile_definitions(spdlog PUBLIC SPDLOG_EOL=\"\\x0A\")
target_link_libraries(standard spdlog::spdlog)

# Link Windows Imaging Component
Expand All @@ -430,6 +455,12 @@ if (USE_LIBNOTIFY)
target_link_libraries(clonk PkgConfig::libnotify)
endif ()

# Link miniupnpc
if (USE_MINIUPNPC)
find_package(miniupnpc CONFIG REQUIRED)
target_link_libraries(clonk miniupnpc::miniupnpc)
endif ()

# Link Windows libraries
if (WIN32)
target_link_libraries(clonk dbghelp dwmapi iphlpapi winmm ws2_32)
Expand Down
2 changes: 2 additions & 0 deletions cmake/filelists/Engine.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ src/C4Def.h
src/C4DefGraphics.cpp
src/C4DefGraphics.h
src/C4DelegatedIterable.h
src/C4DeletionTrackable.h
src/C4DevmodeDlg.cpp
src/C4DevmodeDlg.h
src/C4DownloadDlg.cpp
Expand Down Expand Up @@ -196,6 +197,7 @@ src/C4Network2Res.h
src/C4Network2ResDlg.cpp
src/C4Network2Stats.cpp
src/C4Network2Stats.h
src/C4Network2UPnP.h
src/C4NumberParsing.h
src/C4Object.cpp
src/C4Object.h
Expand Down
3 changes: 3 additions & 0 deletions planet/System.c4g/LanguageDE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ IDS_CTL_TOTALPLAYINGTIME=Gesamtspielzeit: %02d:%02d:%02d
IDS_CTL_UNREGISTERED=NICHT REGISTRIERT
IDS_CTL_UPDATE=&Update
IDS_CTL_UPJUMP=Rauf / Springen
IDS_CTL_UPNP=UPnP verwenden
IDS_CTL_USEOTHERSERVER=anderen Internetserver verwenden
IDS_CTL_USESHELL=Windows-Shell zum Bearbeiten benutzen
IDS_CTL_VALUE=Wert
Expand Down Expand Up @@ -429,6 +430,7 @@ IDS_DESC_THROW=Werfen:
IDS_DESC_TIMESTAMPS=Zeigt vor Chat- und Log-Nachrichten den Zeitpunkt der Nachricht an.
IDS_DESC_UNASSOCIATEDSAVEGAMEPLAYE=Nicht zugewiesene Spielstand-Spieler.
IDS_DESC_UNKNOWNGAMESTATE=Spiel ist in einem unbekannten Zustand
IDS_DESC_UPNP=Aktiviert automatische Portweiterleitung f�r direkte Verbindungen zwischen Teilnehmern in Netzwerkspielen.
IDS_DESC_VERSION=Engine-Version: %s
IDS_DESC_VOLUMEMUSIC=Lautst�rke der Hintergrundmusik.
IDS_DESC_VOLUMESOUND=Lautst�rke der Ger�uscheffekte.
Expand Down Expand Up @@ -1132,6 +1134,7 @@ IDS_NET_RUNTIMEJOINFREE=Laufzeitbeitritt freigegeben
IDS_NET_RUNTIMEJOIN_DESC=Gibt an, ob weitere Clients nach dem Spielstart beitreten k�nnen.
IDS_NET_SAVE_ERR_ADDDYNDATARES=Netzwerk: Laufzeitdaten konnten nicht zur Ressourcenliste hinzugef�gt werden!
IDS_NET_SAVE_ERR_CREATEDYNFILE=Netzwerk: Datei f�r Laufzeitdaten konnte nicht erstellt werden!
IDS_NET_SAVE_ERR_SAVEDYNFILE=Netzwerk: Datei f�r Laufzeitdaten konnte nicht gespeichert werden!
IDS_NET_SAVING=Netzwerk: Spiel wird gespeichert...
IDS_NET_SERVERREDIRECT=Server-Umleitung
IDS_NET_SERVERREDIRECTDONE=Die Server-Umleitung wurde eingetragen.
Expand Down
3 changes: 3 additions & 0 deletions planet/System.c4g/LanguageUS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ IDS_CTL_TOTALPLAYINGTIME=Total playing time: %02d:%02d:%02d
IDS_CTL_UNREGISTERED=NOT REGISTERED
IDS_CTL_UPDATE=&Update
IDS_CTL_UPJUMP=Up / Jump
UDS_CTL_UPNP=Use UPnP
IDS_CTL_USEOTHERSERVER=Use alternate internet server
IDS_CTL_USESHELL=Use Windows Shell to edit files
IDS_CTL_VALUE=Value
Expand Down Expand Up @@ -429,6 +430,7 @@ IDS_DESC_THROW=Throw:
IDS_DESC_TIMESTAMPS=Shows timestamps for chat and log messages.
IDS_DESC_UNASSOCIATEDSAVEGAMEPLAYE=Unassociated savegame players.
IDS_DESC_UNKNOWNGAMESTATE=Game is in an unknown state
IDS_DESC_UPNP=Enable automatic port forwarding for direct connections between participants in network games.
IDS_DESC_VERSION=Engine version: %s
IDS_DESC_VOLUMEMUSIC=Volume of background music.
IDS_DESC_VOLUMESOUND=Volume of sound effects.
Expand Down Expand Up @@ -1133,6 +1135,7 @@ IDS_NET_RUNTIMEJOINFREE=Runtime join allowed
IDS_NET_RUNTIMEJOIN_DESC=Specifies whether additional computers may connect to the game after start.
IDS_NET_SAVE_ERR_ADDDYNDATARES=Network: could not add dynamic data file to resource list!
IDS_NET_SAVE_ERR_CREATEDYNFILE=Network: could not create dynamic data file!
IDS_NET_SAVE_ERR_SAVEDYNFILE=Network: could not save dynamic data file!
IDS_NET_SAVING=Network: Creating savegame...
IDS_NET_SERVERREDIRECT=Server Redirection
IDS_NET_SERVERREDIRECTDONE=Server redirection has been applied.
Expand Down
2 changes: 1 addition & 1 deletion src/C4Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void C4Application::DoInit()
#ifdef _WIN32
C4ThreadPool::Global = std::make_shared<C4ThreadPool>();
#else
C4ThreadPool::Global = std::make_shared<C4ThreadPool>(Config.General.ThreadPoolMinimumThreadCount, Config.General.ThreadPoolMaximumThreadCount);
C4ThreadPool::Global = std::make_shared<C4ThreadPool>(Config.General.ThreadPoolThreadCount, Config.General.ThreadPoolThreadCount);
#endif

// Initialize curl
Expand Down
5 changes: 3 additions & 2 deletions src/C4Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ void C4ConfigGeneral::CompileFunc(StdCompiler *pComp)
#endif

#ifndef _WIN32
pComp->Value(mkNamingAdapt(ThreadPoolMinimumThreadCount, "ThreadPoolMinimumThreadCount", 5));
pComp->Value(mkNamingAdapt(ThreadPoolMaximumThreadCount, "ThreadPoolMaximumThreadCount", 10));
pComp->Value(mkNamingAdapt(ThreadPoolThreadCount, "ThreadPoolThreadCount", 8));
#endif
}

Expand Down Expand Up @@ -205,6 +204,7 @@ void C4ConfigGraphics::CompileFunc(StdCompiler *pComp)
#endif

pComp->Value(mkNamingAdapt(ShowFolderMaps, "ShowFolderMaps", true));
pComp->Value(mkNamingAdapt(UseShaderGamma, "UseShaderGamma", true));
}

void C4ConfigSound::CompileFunc(StdCompiler *pComp)
Expand Down Expand Up @@ -262,6 +262,7 @@ void C4ConfigNetwork::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(LeagueAccount, "LeagueNick", "", false, false));
pComp->Value(mkNamingAdapt(LeagueAutoLogin, "LeagueAutoLogin", true, false, false));
pComp->Value(mkNamingAdapt(UseCurl, "UseCurl", true));
pComp->Value(mkNamingAdapt(EnableUPnP, "EnableUPnP", true));
}

void C4ConfigLobby::CompileFunc(StdCompiler *pComp)
Expand Down
7 changes: 5 additions & 2 deletions src/C4Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ class C4ConfigGeneral
bool UseWhiteLobbyChat;
bool ShowLogTimestamps;
bool Preloading;
std::uint32_t ThreadPoolMinimumThreadCount;
std::uint32_t ThreadPoolMaximumThreadCount;
#ifndef _WIN32
std::uint32_t ThreadPoolThreadCount;
#endif

public:
static int GetLanguageSequence(const char *strSource, char *strTarget);
Expand Down Expand Up @@ -169,6 +170,7 @@ class C4ConfigGraphics
int PositionY;
#endif
bool ShowFolderMaps; // if true, folder maps are shown
bool UseShaderGamma; // whether to use shader-based gamma correction

void CompileFunc(StdCompiler *pComp);
};
Expand Down Expand Up @@ -219,6 +221,7 @@ class C4ConfigNetwork
uint64_t LastUpdateTime;
int32_t AsyncMaxWait;
bool UseCurl;
bool EnableUPnP;

static constexpr auto DefaultPuncherServer = "netpuncher.openclonk.org:11115";

Expand Down
104 changes: 104 additions & 0 deletions src/C4DeletionTrackable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* LegacyClonk
*
* Copyright (c) 2023, The LegacyClonk Team and contributors
*
* Distributed under the terms of the ISC license; see accompanying file
* "COPYING" for details.
*
* "Clonk" is a registered trademark of Matthes Bender, used with permission.
* See accompanying file "TRADEMARK" for details.
*
* To redistribute this file separately, substitute the full license texts
* for the above references.
*/

#pragma once

#include <cassert>
#include <utility>

class C4DeletionTrackable
{
class Tracker
{
public:
constexpr Tracker(C4DeletionTrackable *const tracked) noexcept : tracked{tracked}
{
assert(!tracked->tracker);
tracked->tracker = this;
}

Tracker(const Tracker &) = delete;

constexpr Tracker(Tracker &&other) noexcept : tracked{std::exchange(other.tracked, nullptr)}, isDeleted{other.isDeleted}
{
if (!tracked)
{
return;
}

assert(tracked->tracker == &other);
tracked->tracker = this;
}

Tracker &operator=(const Tracker &) = delete;

constexpr Tracker &operator=(Tracker &&other) noexcept
{
Clear();
tracked = std::exchange(other.tracked, nullptr);
isDeleted = other.isDeleted;

if (tracked)
{
assert(tracked->tracker == &other);
tracked->tracker = this;
}

return *this;
}

constexpr ~Tracker() noexcept
{
Clear();
}

constexpr bool IsDeleted() const noexcept
{
return isDeleted;
}

private:
constexpr void Clear() noexcept
{
if (tracked && !isDeleted)
{
assert(tracked->tracker == this);
tracked->tracker = nullptr;
}
}

C4DeletionTrackable *tracked{nullptr};
bool isDeleted{false};

friend C4DeletionTrackable;
};

public:
constexpr ~C4DeletionTrackable() noexcept
{
if (tracker)
{
tracker->isDeleted = true;
}
}

[[nodiscard]] constexpr Tracker TrackDeletion() noexcept
{
return {this};
}

private:
Tracker *tracker{nullptr};
};
23 changes: 22 additions & 1 deletion src/C4Effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,42 @@ void C4Effect::Execute(C4Object *pObj)

void C4Effect::Kill(C4Object *pObj)
{
const auto deletionTracker = TrackDeletion();
// active?
C4Effect *pLastRemovedEffect = nullptr;
if (IsActive())
{
// then temp remove all higher priority effects
TempRemoveUpperEffects(pObj, false, &pLastRemovedEffect);
}
else
{
// otherwise: temp reactivate before real removal
// this happens only if a lower priority effect removes an upper priority effect in its add- or removal-call
if (pFnStart && iPriority != 1) pFnStart->Exec(**section, pCommandTarget, {C4VObj(pObj), C4VInt(iNumber), C4VInt(C4FxCall_TempAddForRemoval)}, false, true);
if (pFnStart && iPriority != 1)
{
pFnStart->Exec(**section, pCommandTarget, {C4VObj(pObj), C4VInt(iNumber), C4VInt(C4FxCall_TempAddForRemoval)}, false, true);
if (deletionTracker.IsDeleted())
{
return;
}
}
}
// remove this effect
int32_t iPrevPrio = iPriority; SetDead();
if (pFnStop)
{
if (pFnStop->Exec(**section, pCommandTarget, {C4VObj(pObj), C4VInt(iNumber)}, false, true).getInt() == C4Fx_Stop_Deny)
{
// effect denied to be removed: recover
iPriority = iPrevPrio;
}

if (deletionTracker.IsDeleted())
{
return;
}
}
// reactivate other effects
TempReaddUpperEffects(pObj, pLastRemovedEffect);
}
Expand Down
3 changes: 2 additions & 1 deletion src/C4Effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "C4Aul.h"
#include "C4Constants.h"
#include "C4DeletionTrackable.h"
#include "C4EnumeratedObjectPtr.h"
#include "C4Section.h"
#include "C4ValueList.h"
Expand Down Expand Up @@ -74,7 +75,7 @@ typedef unsigned long C4ID;
#define C4Fx_FireMode_Last 3 // largest valid fire mode

// generic object effect
class C4Effect
class C4Effect : private C4DeletionTrackable
{
public:
char Name[C4MaxDefString + 1]; // name of effect
Expand Down
Loading

0 comments on commit 618849a

Please sign in to comment.