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

Simplify settings loading/saving #32

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
54 changes: 27 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ else()
set(TARGET_BITS "64")
endif()

if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm"
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm"
OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64"
OR "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "ARM64")
if(TARGET_BITS STREQUAL "32")
Expand Down Expand Up @@ -74,7 +74,7 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
include(CheckLinkerFlag)
endif()
include(CheckSymbolExists)
if(NOT (CMAKE_SYSTEM_NAME STREQUAL "Emscripten"))
if(NOT(CMAKE_SYSTEM_NAME STREQUAL "Emscripten"))
include(CheckAtomic)
endif()

Expand Down Expand Up @@ -346,7 +346,7 @@ endif()

if(MSVC)
if(EXCEPTION_HANDLING)
add_cxx_compiler_flag_if_supported(OUR_FLAGS /DCONF_EXCEPTION_HANDLING)
add_cxx_compiler_flag_if_supported(OUR_FLAGS /DCONF_EXCEPTION_HANDLING)
endif()
endif()

Expand Down Expand Up @@ -463,7 +463,7 @@ function(set_extra_dirs_include VARIABLE NAME LIBRARY)
if(IS_BUNDLED)
set(TMP_TARGET_OS ${TARGET_OS})
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(TMP_TARGET_OS webasm)
set(TMP_TARGET_OS webasm)
endif()
set("HINTS_${VARIABLE}_INCLUDEDIR" "ddnet-libs/${NAME}/include" "ddnet-libs/${NAME}/include/${TMP_TARGET_OS}" PARENT_SCOPE)
endif()
Expand Down Expand Up @@ -731,18 +731,18 @@ elseif(TARGET_OS STREQUAL "mac")
set(PLATFORM_CLIENT_LIBS ${COCOA} ${OPENGL})
set(PLATFORM_LIBS ${CARBON} ${SECURITY})
elseif(TARGET_OS STREQUAL "haiku")
set(PLATFORM_CLIENT)
find_package(OpenGL)
set(PLATFORM_LIBS GL network)
set(PLATFORM_CLIENT_LIBS ${OPENGL_gl_LIBRARY})
set(PLATFORM_CLIENT_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
set(PLATFORM_CLIENT)
find_package(OpenGL)
set(PLATFORM_LIBS GL network)
set(PLATFORM_CLIENT_LIBS ${OPENGL_gl_LIBRARY})
set(PLATFORM_CLIENT_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
elseif(TARGET_OS STREQUAL "android")
set(PLATFORM_CLIENT
src/android/android_main.cpp
)
set(PLATFORM_LIBS ${TW_ANDROID_LIBS})
set(PLATFORM_CLIENT_LIBS ${PLATFORM_LIBS})
set(PLATFORM_CLIENT_INCLUDE_DIRS)
set(PLATFORM_CLIENT
src/android/android_main.cpp
)
set(PLATFORM_LIBS ${TW_ANDROID_LIBS})
set(PLATFORM_CLIENT_LIBS ${PLATFORM_LIBS})
set(PLATFORM_CLIENT_INCLUDE_DIRS)
else()
find_package(Notify)
find_package(OpenGL)
Expand Down Expand Up @@ -928,11 +928,11 @@ if(CMAKE_OSX_ARCHITECTURES)
endif()

set(RUST_SRC
${RUST_BASE}
${RUST_ENGINE_INTERFACE}
${RUST_ENGINE_SHARED}
Cargo.toml
Cargo.lock
${RUST_BASE}
${RUST_ENGINE_INTERFACE}
${RUST_ENGINE_SHARED}
Cargo.toml
Cargo.lock
)
set(RUST_TARGETS engine_shared)
if(NOT CMAKE_OSX_ARCHITECTURES)
Expand Down Expand Up @@ -2063,6 +2063,7 @@ set_src(ENGINE_SHARED GLOB_RECURSE src/engine/shared
config.cpp
config.h
config_variables.h
config_variables_tclient.h
console.cpp
console.h
csv.cpp
Expand Down Expand Up @@ -2130,7 +2131,6 @@ set_src(ENGINE_SHARED GLOB_RECURSE src/engine/shared
storage.cpp
stun.cpp
stun.h
tater_variables.h
teehistorian_ex.cpp
teehistorian_ex.h
teehistorian_ex_chunks.h
Expand Down Expand Up @@ -2619,7 +2619,7 @@ if(CLIENT)
)
endif()
set_property(TARGET game-client
PROPERTY OUTPUT_NAME ${CLIENT_EXECUTABLE}
PROPERTY OUTPUT_NAME ${CLIENT_EXECUTABLE}
)
target_link_libraries(game-client ${LIBS_CLIENT})

Expand Down Expand Up @@ -2812,7 +2812,7 @@ if(SERVER)
$<TARGET_OBJECTS:rust-bridge-shared>
)
set_property(TARGET game-server
PROPERTY OUTPUT_NAME ${SERVER_EXECUTABLE}
PROPERTY OUTPUT_NAME ${SERVER_EXECUTABLE}
)
target_link_libraries(game-server ${LIBS_SERVER})
target_include_directories(game-server PRIVATE ${PNG_INCLUDE_DIRS})
Expand All @@ -2823,7 +2823,7 @@ if(SERVER)
set(SERVER_LAUNCHER_SRC src/macos/server.mm)
add_executable(game-server-launcher ${SERVER_LAUNCHER_SRC})
set_property(TARGET game-server-launcher
PROPERTY OUTPUT_NAME ${SERVER_EXECUTABLE}-Launcher
PROPERTY OUTPUT_NAME ${SERVER_EXECUTABLE}-Launcher
)
target_link_libraries(game-server-launcher ${COCOA})
list(APPEND TARGETS_OWN game-server-launcher)
Expand Down Expand Up @@ -3162,7 +3162,7 @@ set(CPACK_SYSTEM_NAME ${CMAKE_SYSTEM_NAME})

if(TARGET_OS AND TARGET_BITS)
if(TARGET_OS STREQUAL "windows")
if (TARGET_CPU_ARCHITECTURE STREQUAL "arm64")
if(TARGET_CPU_ARCHITECTURE STREQUAL "arm64")
set(CPACK_SYSTEM_NAME "win-arm64")
else()
set(CPACK_SYSTEM_NAME "win${TARGET_BITS}")
Expand Down Expand Up @@ -3427,7 +3427,7 @@ foreach(ext zip tar.gz tar.xz)
endforeach()
foreach(target ${CPACK_TARGETS})
list(APPEND COPY_TARGET_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${target}> ${TMPDIR}/)
if(NOT TARGET_OS STREQUAL "mac" AND NOT (TARGET_OS STREQUAL "windows" AND TARGET_CPU_ARCHITECTURE STREQUAL "arm64"))
if(NOT TARGET_OS STREQUAL "mac" AND NOT(TARGET_OS STREQUAL "windows" AND TARGET_CPU_ARCHITECTURE STREQUAL "arm64"))
list(APPEND STRIP_TARGET_COMMANDS COMMAND strip -s ${TMPDIR}/$<TARGET_FILE_NAME:${target}>)
endif()
endforeach()
Expand Down Expand Up @@ -3619,7 +3619,7 @@ foreach(target ${TARGETS_OWN})
target_compile_definitions(${target} PRIVATE GAME_RELEASE_VERSION="${VERSION}")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
target_compile_definitions(${target} PRIVATE CONF_WEBASM)
target_compile_definitions(${target} PRIVATE CONF_WEBASM)
endif()
endforeach()

Expand Down
6 changes: 2 additions & 4 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4803,11 +4803,9 @@ int main(int argc, const char **argv)
}

// execute tclient config file
IOHANDLE File = pStorage->OpenFile(TCONFIG_FILE, IOFLAG_READ, IStorage::TYPE_ALL);
if(File)
if(pStorage->FileExists(CONFIG_FILE_TCLIENT, IStorage::TYPE_ALL))
{
io_close(File);
pConsole->ExecuteFile(TCONFIG_FILE);
pConsole->ExecuteFile(CONFIG_FILE_TCLIENT);
}

// execute autoexec file
Expand Down
13 changes: 9 additions & 4 deletions src/engine/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

#include "kernel.h"

enum EConfigDomain
{
CFGDOMAIN_NONE = 0,
CFGDOMAIN_TCLIENT,
CFGDOMAIN_MAX,
};

class IConfigManager : public IInterface
{
MACRO_INTERFACE("config")
Expand All @@ -17,13 +24,11 @@ class IConfigManager : public IInterface
virtual void ResetGameSettings() = 0;
virtual void SetReadOnly(const char *pScriptName, bool ReadOnly) = 0;
virtual bool Save() = 0;
virtual bool TSave() = 0;
virtual class CConfig *Values() = 0;

virtual void RegisterCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData) = 0;
virtual void RegisterTCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData) = 0;
virtual void RegisterCallback(SAVECALLBACKFUNC pfnFunc, void *pUserData, EConfigDomain pClient = EConfigDomain::CFGDOMAIN_NONE) = 0;

virtual void WriteLine(const char *pLine) = 0;
virtual void WriteLine(const char *pLine, EConfigDomain pClient = EConfigDomain::CFGDOMAIN_NONE) = 0;

virtual void StoreUnknownCommand(const char *pCommand) = 0;

Expand Down
Loading
Loading