From f51d3bf13b12b5fc91be4e866a5830af2bd8b296 Mon Sep 17 00:00:00 2001 From: dmitry Date: Wed, 8 Jul 2020 13:03:27 +0300 Subject: [PATCH] fix: do not clean non-cmd buttons on IN_SCORE hook. fix: reset search nodes when receiving team info message. fix: clear bot args on every call to bot client command. add: drone build scenario. --- .drone.jsonnet | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/engine.cpp | 2 ++ src/linkage.cpp | 5 ++--- src/message.cpp | 7 +++++++ src/support.cpp | 2 +- 5 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 .drone.jsonnet diff --git a/.drone.jsonnet b/.drone.jsonnet new file mode 100644 index 0000000..ce6628a --- /dev/null +++ b/.drone.jsonnet @@ -0,0 +1,44 @@ +local mesonBuild (buildName, cxx, ld, mesonOptions) = { + kind: "pipeline", + type: "exec", + name: buildName, + steps: [ + { + environment: { + CXX: cxx, + CXX_LD: ld + }, + name: "setup", + commands: [ + "meson setup build " + mesonOptions, + ] + }, + { + name: "build", + commands: [ + "ninja -C build", + ] + }, + { + name: "upload", + commands: [ + "upload-binary " + buildName + ] + } + ] +}; + +[ + mesonBuild("linux-release-gcc", "gcc", "", ""), + mesonBuild("linux-release-clang", "clang", "lld", ""), + + mesonBuild("linux-release-intel", "/opt/intel/bin/icc", "", ""), + mesonBuild("linux-debug-gcc", "gcc", "", "--buildtype=debug"), + + mesonBuild("macos-release-clang", "", "", "--cross-file=/opt/meson/cross/darwin.ini"), + mesonBuild("macos-debug-clang", "", "", "--cross-file=/opt/meson/cross/darwin.ini --buildtype=debug"), + + mesonBuild("win32-release-msvc", "", "", "--cross-file=/opt/meson/cross/msvc.ini -Db_vscrt=mt"), + mesonBuild("win32-debug-msvc", "", "", "--cross-file=/opt/meson/cross/msvc.ini --buildtype=debug -Db_vscrt=mtd"), + mesonBuild("win32-release-mingw", "", "", "--cross-file=/opt/meson/cross/mingw.ini"), +] diff --git a/src/engine.cpp b/src/engine.cpp index d551fec..c307dc5 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -436,6 +436,8 @@ void Game::prepareBotArgs (edict_t *ent, String str) { // supply directly the whole string as if you were typing it in the bot's "console". It // is supposed to work exactly like the pfnClientCommand (server-sided client command). + m_botArgs.clear (); // always clear args + if (str.empty ()) { return; } diff --git a/src/linkage.cpp b/src/linkage.cpp index 558c796..2475810 100644 --- a/src/linkage.cpp +++ b/src/linkage.cpp @@ -409,10 +409,9 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) { table->pfnCmdStart = [] (const edict_t *player, usercmd_t *cmd, unsigned int random_seed) { auto ent = const_cast (player); - // if we're handle pings for bots and clients, clear IN_SCORE button so SV_ShouldUpdatePing engine function return false - // and SV_EmitPings will not overwrite our results + // if we're handle pings for bots and clients, clear IN_SCORE button so SV_ShouldUpdatePing engine function return false, and SV_EmitPings will not overwrite our results if (game.is (GameFlags::HasFakePings) && cv_show_latency.int_ () == 2) { - if ((cmd->buttons & IN_SCORE) || (ent->v.oldbuttons & IN_SCORE)) { + if (cmd->buttons & IN_SCORE) { cmd->buttons &= ~IN_SCORE; // send our version of pings diff --git a/src/message.cpp b/src/message.cpp index 46138e6..7f4661f 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -329,6 +329,13 @@ void MessageDispatcher::netMsgTeamInfo () { // update player team client.team2 = m_teamInfoCache[m_args[team].chars_]; // update real team client.team = game.is (GameFlags::FreeForAll) ? m_args[index].long_ : client.team2; + + auto bot = bots[client.ent]; + + // clear the routes so we're have no error in pathfinding in case team info update (respawn/change team) + if (bot) { + bot->clearSearchNodes (); + } } void MessageDispatcher::netMsgBarTime () { diff --git a/src/support.cpp b/src/support.cpp index 4dd8d0e..09cfae0 100644 --- a/src/support.cpp +++ b/src/support.cpp @@ -596,7 +596,7 @@ void BotSupport::calculatePings () { } int part = static_cast (average.first * 0.2f); - int botPing = bot->m_basePing + rg.int_ (average.first - part, average.first + part) + rg.int_ (bot->m_difficulty / 2, bot->m_difficulty); + int botPing = bot->index () / 2 + bot->m_basePing + rg.int_ (average.first - part, average.first + part) + rg.int_ (bot->m_difficulty / 2, bot->m_difficulty); int botLoss = rg.int_ (average.second / 2, average.second); client.ping = getPingBitmask (client.ent, botLoss, botPing);