build: add arm64 build to linux release package
add: yb_ignore_objectives, that makes bots to ignore map target (hostage rescue, bomb plant/defuse) (fixes #237) fix: possible buffer overrun in message functions build: cleanup package.py
This commit is contained in:
parent
e0f3317b1a
commit
6e83258c7d
6 changed files with 49 additions and 25 deletions
11
.github/workflows/build.yml
vendored
11
.github/workflows/build.yml
vendored
|
|
@ -52,7 +52,7 @@ jobs:
|
|||
|
||||
windows:
|
||||
name: windows-x86
|
||||
runs-on: windows-latest
|
||||
runs-on: windows-2022
|
||||
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
|
|
@ -60,6 +60,7 @@ jobs:
|
|||
with:
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
|
||||
- name: Setup MSBuild
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
|
|
@ -103,12 +104,16 @@ jobs:
|
|||
- name: Compile Source
|
||||
run: |
|
||||
meson compile -v -C build
|
||||
|
||||
- name: Rename Binary
|
||||
run: |
|
||||
mv build/yapb.so build/yapb.arm64.so
|
||||
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: yapb.aarch64.so
|
||||
path: build/yapb.so
|
||||
name: yapb.arm64.so
|
||||
path: build/yapb.arm64.so
|
||||
|
||||
publish:
|
||||
if: |
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ template <typename ...Args> inline void BotControl::msg (const char *fmt, Args &
|
|||
return;
|
||||
}
|
||||
|
||||
if (m_isFromConsole || strlen (result) > 56 || m_rapidOutput) {
|
||||
if (m_isFromConsole || strnlen (result, StringBuffer::StaticBufferSize) > 56 || m_rapidOutput) {
|
||||
if (m_rapidOutput) {
|
||||
m_printQueue.emplaceLast (PrintQueueDestination::ClientConsole, result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1160,6 +1160,7 @@ public:
|
|||
extern ConVar cv_jasonmode;
|
||||
extern ConVar cv_radio_mode;
|
||||
extern ConVar cv_ignore_enemies;
|
||||
extern ConVar cv_ignore_objectives;
|
||||
extern ConVar cv_chat;
|
||||
extern ConVar cv_language;
|
||||
extern ConVar cv_show_latency;
|
||||
|
|
|
|||
44
package.py
44
package.py
|
|
@ -6,9 +6,8 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
from genericpath import isdir
|
||||
import os, sys, subprocess, base64
|
||||
import locale, urllib3
|
||||
import urllib3
|
||||
import pathlib, shutil
|
||||
import zipfile, tarfile
|
||||
import datetime, calendar
|
||||
|
|
@ -132,7 +131,7 @@ class BotRelease (object):
|
|||
|
||||
def make_directories (self):
|
||||
dirs = [
|
||||
"bin",
|
||||
"bin",
|
||||
os.path.join ("data", "pwf"),
|
||||
os.path.join ("data", "train"),
|
||||
os.path.join ("data", "graph"),
|
||||
|
|
@ -173,7 +172,7 @@ class BotRelease (object):
|
|||
self.get_graph_file (file)
|
||||
|
||||
def unlink_binaries (self):
|
||||
libs = ["yapb.so", "yapb.dll", "yapb.dylib"]
|
||||
libs = ["yapb.so", "yapb.arm64.so", "yapb.dll", "yapb.dylib"]
|
||||
|
||||
for lib in libs:
|
||||
path = os.path.join (self.bot_dir, "bin", lib)
|
||||
|
|
@ -194,34 +193,34 @@ class BotRelease (object):
|
|||
|
||||
def compress_directory (self, path, handle):
|
||||
length = len (path) + 1
|
||||
empty_dirs = []
|
||||
empty_dirs = []
|
||||
|
||||
for root, dirs, files in os.walk (path):
|
||||
empty_dirs.extend ([dir for dir in dirs if os.listdir (os.path.join (root, dir)) == []])
|
||||
empty_dirs.extend ([dir for dir in dirs if os.listdir (os.path.join (root, dir)) == []])
|
||||
|
||||
for file in files:
|
||||
file_path = os.path.join (root, file)
|
||||
handle.write (file_path, file_path[length:])
|
||||
|
||||
for dir in empty_dirs:
|
||||
for dir in empty_dirs:
|
||||
dir_path = os.path.join (root, dir)
|
||||
|
||||
zif = zipfile.ZipInfo (dir_path[length:] + "/")
|
||||
handle.writestr (zif, "")
|
||||
zif = zipfile.ZipInfo (dir_path[length:] + "/")
|
||||
handle.writestr (zif, "")
|
||||
|
||||
empty_dirs = []
|
||||
|
||||
def create_zip (self, dir):
|
||||
def create_zip (self, dir):
|
||||
zf = zipfile.ZipFile (dir, "w", zipfile.ZIP_DEFLATED, compresslevel=9)
|
||||
zf.comment = bytes (self.version, encoding = "ascii")
|
||||
|
||||
self.compress_directory (self.work_dir, zf)
|
||||
zf.close ()
|
||||
|
||||
def convert_zip_txz (self, zip, txz):
|
||||
def convert_zip_txz (self, zfn, txz):
|
||||
timeshift = int ((datetime.datetime.now () - datetime.datetime.utcnow ()).total_seconds ())
|
||||
|
||||
with zipfile.ZipFile (zip) as zipf:
|
||||
with zipfile.ZipFile (zfn) as zipf:
|
||||
with tarfile.open (txz, "w:xz") as tarf:
|
||||
for zif in zipf.infolist ():
|
||||
tif = tarfile.TarInfo (name = zif.filename)
|
||||
|
|
@ -230,9 +229,9 @@ class BotRelease (object):
|
|||
|
||||
tarf.addfile (tarinfo = tif, fileobj = zipf.open (zif.filename))
|
||||
|
||||
os.remove (zip)
|
||||
os.remove (zfn)
|
||||
|
||||
def install_binary (self, ext):
|
||||
def install_binary (self, ext, unlink_existing = True):
|
||||
lib = "yapb.{}".format (ext)
|
||||
binary = os.path.join (self.artifacts, lib)
|
||||
|
||||
|
|
@ -240,10 +239,12 @@ class BotRelease (object):
|
|||
binary = os.path.join (binary, lib)
|
||||
|
||||
if not os.path.exists (binary):
|
||||
print ("Packaging failed for {}. Skipping...", lib)
|
||||
print ("Packaging failed for {}. Skipping...".format (lib))
|
||||
return False
|
||||
|
||||
self.unlink_binaries ()
|
||||
if unlink_existing:
|
||||
self.unlink_binaries ()
|
||||
|
||||
self.copy_binary (binary)
|
||||
|
||||
return True
|
||||
|
|
@ -259,16 +260,19 @@ class BotRelease (object):
|
|||
|
||||
print ("Generating Win32 EXE")
|
||||
|
||||
with open ("botsetup.exe", "rb") as sfx, open (self.pkg_win32, "rb") as zip, open (self.pkg_win32_sfx, "wb") as exe:
|
||||
with open ("botsetup.exe", "rb") as sfx, open (self.pkg_win32, "rb") as zfn, open (self.pkg_win32_sfx, "wb") as exe:
|
||||
exe.write (sfx.read ())
|
||||
exe.write (zip.read ())
|
||||
exe.write (zfn.read ())
|
||||
|
||||
self.sign_binary (self.pkg_win32_sfx)
|
||||
|
||||
def create_pkg_linux (self):
|
||||
print ("Generating Linux TXZ")
|
||||
|
||||
if not self.install_binary ("so"):
|
||||
|
||||
self.unlink_binaries ()
|
||||
self.install_binary ("arm64.so")
|
||||
|
||||
if not self.install_binary ("so", False):
|
||||
return
|
||||
|
||||
tmp_file = "tmp.zip"
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ ConVar cv_restricted_weapons ("yb_restricted_weapons", "", "Specifies semicolon
|
|||
|
||||
ConVar cv_attack_monsters ("yb_attack_monsters", "0", "Allows or disallows bots to attack monsters.");
|
||||
ConVar cv_pickup_custom_items ("yb_pickup_custom_items", "0", "Allows or disallows bots to pickup custom items.");
|
||||
ConVar cv_ignore_objectives ("yb_ignore_objectives", "0", "Allows or disallows bots to do map objectives, i.e. plant/defuse bombs, and saves hostages");
|
||||
|
||||
// game console variables
|
||||
ConVar mp_c4timer ("mp_c4timer", nullptr, Var::GameRef);
|
||||
|
|
@ -2951,6 +2952,10 @@ void Bot::update () {
|
|||
|
||||
if (m_team == Team::Terrorist && game.mapIs (MapFlags::Demolition)) {
|
||||
m_hasC4 = !!(pev->weapons & cr::bit (Weapon::C4));
|
||||
|
||||
if (m_hasC4 && cv_ignore_objectives.bool_ ()) {
|
||||
m_hasC4 = false;
|
||||
}
|
||||
}
|
||||
|
||||
// is bot movement enabled
|
||||
|
|
@ -3153,7 +3158,7 @@ void Bot::normal_ () {
|
|||
if (game.mapIs (MapFlags::HostageRescue)) {
|
||||
// CT Bot has some hostages following?
|
||||
if (m_team == Team::CT && hasHostage ()) {
|
||||
// and reached a Rescue Point?
|
||||
// and reached a rescue point?
|
||||
if (m_path->flags & NodeFlag::Rescue) {
|
||||
m_hostages.clear ();
|
||||
}
|
||||
|
|
@ -5061,6 +5066,10 @@ void Bot::showDebugOverlay () {
|
|||
}
|
||||
|
||||
bool Bot::hasHostage () {
|
||||
if (cv_ignore_objectives.bool_ ()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto hostage : m_hostages) {
|
||||
if (!game.isNullEntity (hostage)) {
|
||||
|
||||
|
|
|
|||
|
|
@ -1829,6 +1829,11 @@ void BotManager::initRound () {
|
|||
}
|
||||
|
||||
void BotManager::setBombPlanted (bool isPlanted) {
|
||||
if (cv_ignore_objectives.bool_ ()) {
|
||||
m_bombPlanted = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (isPlanted) {
|
||||
m_timeBombPlanted = game.time ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue