Skip to content

Commit

Permalink
Merge branch 'ddnet' into chillerbot
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Nov 24, 2023
2 parents b834996 + edee3d5 commit 5e8869d
Show file tree
Hide file tree
Showing 95 changed files with 969 additions and 524 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
brew update || true
brew install pkg-config sdl2 ffmpeg ninja molten-vk vulkan-headers glslang spirv-tools || true
# --overwrite for: Target /usr/local/bin/2to3 already exists.
brew link --overwrite python@3.10
brew link --overwrite python@3.11
brew upgrade freetype
pip3 install dmgbuild
echo /Library/Frameworks/Python.framework/Versions/3.11/bin >> $GITHUB_PATH
Expand Down Expand Up @@ -140,18 +140,16 @@ jobs:
run: |
mkdir headless
cd headless
CFLAGS="$CFLAGS --coverage"
CXXFLAGS="$CXXFLAGS --coverage"
LDFLAGS="$LDFLAGS --coverage"
${{ matrix.cmake-path }}cmake --version
${{ matrix.cmake-path }}cmake -E env ${{ matrix.cmake-init-env }} ${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DHEADLESS_CLIENT=ON -DCMAKE_BUILD_TYPE=Debug -Werror=dev -DDOWNLOAD_GTEST=ON -DDEV=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=. ..
${{ matrix.cmake-path }}cmake --build . --config Debug ${{ matrix.build-args }}
${{ matrix.cmake-path }}cmake -E env CXXFLAGS="--coverage -Werror" ${{ matrix.cmake-path }}cmake -E env LDFLAGS="--coverage -Werror" ${{ matrix.cmake-path }}cmake ${{ matrix.cmake-args }} -DHEADLESS_CLIENT=ON -DCMAKE_BUILD_TYPE=Debug -Werror=dev -DDOWNLOAD_GTEST=ON -DDEV=ON -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG=. ..
${{ matrix.cmake-path }}cmake -E env RUSTFLAGS="-Clink-arg=--coverage" ${{ matrix.cmake-path }}cmake --build . --config Debug ${{ matrix.build-args }}
mv chillerbot-ux DDNet || true
- name: Test headless client (unit tests)
if: contains(matrix.os, 'ubuntu-latest')
run: |
cd headless
${{ matrix.cmake-path }}cmake --build . --config Debug --target run_tests ${{ matrix.build-args }}
${{ matrix.cmake-path }}cmake -E env RUSTFLAGS="-Clink-arg=--coverage" RUSTDOCFLAGS="-Clink-arg=--coverage" ${{ matrix.cmake-path }}cmake --build . --config Debug --target run_tests ${{ matrix.build-args }}
- name: Upload Codecov report (unit tests)
if: contains(matrix.os, 'ubuntu-latest')
Expand Down Expand Up @@ -212,7 +210,7 @@ jobs:
with:
gcov: true
gcov_include: src
flags: intgrationtests
flags: integrationtests

- name: Package
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ chillpw_*
config_retrieve
config_store
crapnet
demo_extract_chat
dilate
dummy_map
fake_server
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ if(NOT MSVC AND NOT HAIKU)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wthread-safety)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wthread-safety-negative)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wsuggest-override)
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wdynamic-class-memaccess) # clang
add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wclass-memaccess) # gcc
add_linker_flag_if_supported(OUR_FLAGS_LINK -Wno-alloc-size-larger-than) # save.cpp with LTO
# add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wdouble-promotion) # Many occurrences
# add_cxx_compiler_flag_if_supported(OUR_FLAGS_OWN -Wnull-dereference) # Many occurrences
Expand Down Expand Up @@ -2623,6 +2625,8 @@ if(SERVER)
gamecontroller.h
gamemodes/DDRace.cpp
gamemodes/DDRace.h
gamemodes/mod.cpp
gamemodes/mod.h
gameworld.cpp
gameworld.h
player.cpp
Expand Down Expand Up @@ -2837,6 +2841,7 @@ if(GTEST_FOUND OR DOWNLOAD_GTEST)
linereader.cpp
mapbugs.cpp
math.cpp
memory.cpp
name_ban.cpp
net.cpp
netaddr.cpp
Expand Down
10 changes: 10 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
comment: false
github_checks:
annotations: false
coverage:
status:
project:
default:
target: 0%
patch:
default:
target: 0%
3 changes: 2 additions & 1 deletion src/antibot/antibot_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

enum
{
ANTIBOT_ABI_VERSION = 7,
ANTIBOT_ABI_VERSION = 9,

ANTIBOT_MSGFLAG_NONVITAL = 1,
ANTIBOT_MSGFLAG_FLUSH = 2,
Expand Down Expand Up @@ -88,6 +88,7 @@ struct CAntibotData

int64_t m_Now;
int64_t m_Freq;
void (*m_pfnKick)(int ClientID, const char *pMessage, void *pUser);
void (*m_pfnLog)(const char *pMessage, void *pUser);
void (*m_pfnReport)(int ClientID, const char *pMessage, void *pUser);
void (*m_pfnSend)(int ClientID, const void *pData, int DataSize, int Flags, void *pUser);
Expand Down
2 changes: 1 addition & 1 deletion src/antibot/antibot_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ANTIBOTAPI void AntibotRoundStart(CAntibotRoundData *pRoundData);
ANTIBOTAPI void AntibotRoundEnd(void);
ANTIBOTAPI void AntibotUpdateData(void);
ANTIBOTAPI void AntibotDestroy(void);
ANTIBOTAPI void AntibotDump(void);
ANTIBOTAPI void AntibotConsoleCommand(const char *pCommand);
ANTIBOTAPI void AntibotOnPlayerInit(int ClientID);
ANTIBOTAPI void AntibotOnPlayerDestroy(int ClientID);
ANTIBOTAPI void AntibotOnSpawn(int ClientID);
Expand Down
13 changes: 11 additions & 2 deletions src/antibot/antibot_null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include "antibot_interface.h"

#include <cstring>

static CAntibotData *g_pData;

extern "C" {
Expand All @@ -19,9 +21,16 @@ void AntibotRoundStart(CAntibotRoundData *pRoundData){};
void AntibotRoundEnd(void){};
void AntibotUpdateData(void) {}
void AntibotDestroy(void) { g_pData = 0; }
void AntibotDump(void)
void AntibotConsoleCommand(const char *pCommand)
{
g_pData->m_pfnLog("null antibot", g_pData->m_pUser);
if(strcmp(pCommand, "dump") == 0)
{
g_pData->m_pfnLog("null antibot", g_pData->m_pUser);
}
else
{
g_pData->m_pfnLog("unknown command", g_pData->m_pUser);
}
}
void AntibotOnPlayerInit(int /*ClientID*/) {}
void AntibotOnPlayerDestroy(int /*ClientID*/) {}
Expand Down
5 changes: 0 additions & 5 deletions src/base/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,6 @@ void mem_move(void *dest, const void *source, size_t size)
memmove(dest, source, size);
}

void mem_zero(void *block, size_t size)
{
memset(block, 0, size);
}

int mem_comp(const void *a, const void *b, size_t size)
{
return memcmp(a, b, size);
Expand Down
10 changes: 8 additions & 2 deletions src/base/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <cinttypes>
#include <cstdarg>
#include <cstdint>
#include <cstring>
#include <ctime>
#include <functional>
#include <mutex>
Expand Down Expand Up @@ -171,7 +172,12 @@ void mem_move(void *dest, const void *source, size_t size);
* @param block Pointer to the block to zero out.
* @param size Size of the block.
*/
void mem_zero(void *block, size_t size);
template<typename T>
inline void mem_zero(T *block, size_t size)
{
static_assert((std::is_trivially_constructible<T>::value && std::is_trivially_destructible<T>::value) || std::is_fundamental<T>::value);
memset(block, 0, size);
}

/**
* Compares two blocks of memory
Expand Down Expand Up @@ -2835,7 +2841,7 @@ bool shell_unregister_application(const char *executable, bool *updated);
* Notifies the system that a protocol or file extension has been changed and the shell needs to be updated.
*
* @ingroup Shell
*
*
* @remark This is a potentially expensive operation, so it should only be called when necessary.
*/
void shell_update();
Expand Down
18 changes: 3 additions & 15 deletions src/base/vmath.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ class vector2_base
T y, v;
};

constexpr vector2_base() :
x(T()), y(T())
{
}

constexpr vector2_base() = default;
constexpr vector2_base(T nx, T ny) :
x(nx), y(ny)
{
Expand Down Expand Up @@ -198,11 +194,7 @@ class vector3_base
T z, b, l, w;
};

constexpr vector3_base() :
x(T()), y(T()), z(T())
{
}

constexpr vector3_base() = default;
constexpr vector3_base(T nx, T ny, T nz) :
x(nx), y(ny), z(nz)
{
Expand Down Expand Up @@ -326,11 +318,7 @@ class vector4_base
T w, a;
};

constexpr vector4_base() :
x(T()), y(T()), z(T()), w(T())
{
}

constexpr vector4_base() = default;
constexpr vector4_base(T nx, T ny, T nz, T nw) :
x(nx), y(ny), z(nz), w(nw)
{
Expand Down
2 changes: 1 addition & 1 deletion src/engine/antibot.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class IAntibot : public IInterface
virtual void OnHookAttach(int ClientID, bool Player) = 0;

// Commands
virtual void Dump() = 0;
virtual void ConsoleCommand(const char *pCommand) = 0;

virtual ~IAntibot(){};
};
Expand Down
6 changes: 1 addition & 5 deletions src/engine/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,11 @@ class IClient : public IInterface
float m_GlobalTime;
float m_RenderFrameTime;

int m_GameTickSpeed;

float m_FrameTimeAvg;

TMapLoadingCallbackFunc m_MapLoadingCBFunc;

char m_aNews[3000];
char m_aCommunityIconsDownloadUrl[256];
int m_Points;
int64_t m_ReconnectTime;

Expand Down Expand Up @@ -142,7 +139,7 @@ class IClient : public IInterface
inline float PredIntraGameTick(int Conn) const { return m_aPredIntraTick[Conn]; }
inline float IntraGameTickSincePrev(int Conn) const { return m_aGameIntraTickSincePrev[Conn]; }
inline float GameTickTime(int Conn) const { return m_aGameTickTime[Conn]; }
inline int GameTickSpeed() const { return m_GameTickSpeed; }
inline int GameTickSpeed() const { return SERVER_TICK_SPEED; }

// other time access
inline float RenderFrameTime() const { return m_RenderFrameTime; }
Expand Down Expand Up @@ -258,7 +255,6 @@ class IClient : public IInterface
virtual unsigned GetCurrentMapCrc() const = 0;

const char *News() const { return m_aNews; }
const char *CommunityIconsDownloadUrl() const { return m_aCommunityIconsDownloadUrl; }
int Points() const { return m_Points; }
int64_t ReconnectTime() const { return m_ReconnectTime; }
void SetReconnectTime(int64_t ReconnectTime) { m_ReconnectTime = ReconnectTime; }
Expand Down
Loading

0 comments on commit 5e8869d

Please sign in to comment.