fix: startup on hlds_l 3111e (still needs nosmid)

build: add option to build bot without any smid instructions
refactor: fix static analyzer warnings
crlib: update submodule (fix double anglevectors call)
This commit is contained in:
jeefo 2024-10-27 20:51:37 +03:00
commit c7c5e0eaf9
No known key found for this signature in database
GPG key ID: D696786B81B667C8
14 changed files with 92 additions and 70 deletions

View file

@ -74,7 +74,7 @@ if((CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
target_compile_options(${PROJECT_NAME} PRIVATE -funroll-loops -fomit-frame-pointer -fno-stack-protector -fvisibility=hidden -fvisibility-inlines-hidden) target_compile_options(${PROJECT_NAME} PRIVATE -funroll-loops -fomit-frame-pointer -fno-stack-protector -fvisibility=hidden -fvisibility-inlines-hidden)
if(NOT WIN32 AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "arm" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc") if(NOT WIN32 AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" AND NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "arm" AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc")
target_compile_options(${PROJECT_NAME} PRIVATE -fdata-sections -ffunction-sections -fcf-protection=none) target_compile_options(${PROJECT_NAME} PRIVATE -fdata-sections -ffunction-sections -fcf-protection=none -fno-plt)
target_link_options(${PROJECT_NAME} PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/ext/ldscripts/version.lds -Wl,--gc-sections) target_link_options(${PROJECT_NAME} PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/ext/ldscripts/version.lds -Wl,--gc-sections)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")

@ -1 +1 @@
Subproject commit c0d1357bcd6b638368f345489c1a0dc70b4a9b38 Subproject commit 63cfde122f6479ec94af5c16caf9fbda885f814a

View file

@ -100,19 +100,19 @@ struct PODGraphHeader {
// defines linked nodes // defines linked nodes
struct PathLink { struct PathLink {
Vector velocity; Vector velocity {};
int32_t distance; int32_t distance {};
uint16_t flags; uint16_t flags {};
int16_t index; int16_t index {};
}; };
// define graph path structure for yapb // define graph path structure for yapb
struct Path { struct Path {
int32_t number, flags; int32_t number {}, flags {};
Vector origin, start, end; Vector origin {}, start {}, end {};
float radius, light, display; float radius {}, light {}, display {};
PathLink links[kMaxNodeLinks]; PathLink links[kMaxNodeLinks] {};
PathVis vis; PathVis vis {};
}; };
// define waypoint structure for podbot (will convert on load) // define waypoint structure for podbot (will convert on load)

View file

@ -39,13 +39,13 @@ public:
// weapon properties structure // weapon properties structure
struct WeaponProp { struct WeaponProp {
String classname; String classname {};
int ammo1; // ammo index for primary ammo int ammo1 {}; // ammo index for primary ammo
int ammo1Max; // max primary ammo int ammo1Max {}; // max primary ammo
int slot; // HUD slot (0 based) int slot {}; // HUD slot (0 based)
int pos; // slot position int pos {}; // slot position
int id; // weapon ID int id {}; // weapon ID
int flags; // flags??? int flags {}; // flags???
}; };
// weapon info structure // weapon info structure
@ -89,23 +89,23 @@ public:
// clients noise // clients noise
struct ClientNoise { struct ClientNoise {
Vector pos; Vector pos {};
float dist; float dist {};
float last; float last {};
}; };
// array of clients struct // array of clients struct
struct Client { struct Client {
edict_t *ent; // pointer to actual edict edict_t *ent {}; // pointer to actual edict
Vector origin; // position in the world Vector origin {}; // position in the world
int team; // bot team int team {}; // bot team
int team2; // real bot team in free for all mode (csdm) int team2 {}; // real bot team in free for all mode (csdm)
int flags; // client flags int flags {}; // client flags
int radio; // radio orders int radio {}; // radio orders
int menu; // identifier to opened menu int menu {}; // identifier to opened menu
int iconFlags[kGameMaxPlayers]; // flag holding chatter icons int iconFlags[kGameMaxPlayers] {}; // flag holding chatter icons
float iconTimestamp[kGameMaxPlayers]; // timers for chatter icons float iconTimestamp[kGameMaxPlayers] {}; // timers for chatter icons
ClientNoise noise; ClientNoise noise {};
}; };
// think delay mapping // think delay mapping

View file

@ -41,6 +41,7 @@ build_type = get_option ('buildtype')
opt_64bit = get_option('64bit') opt_64bit = get_option('64bit')
opt_native = get_option('native') opt_native = get_option('native')
opt_winxp = get_option('winxp') opt_winxp = get_option('winxp')
opt_nosimd = get_option('nosimd')
# cpp and ldflags from scratch # cpp and ldflags from scratch
cxxflags = [] cxxflags = []
@ -96,6 +97,11 @@ if opt_native
cxxflags += ['-DCR_NATIVE_BUILD'] cxxflags += ['-DCR_NATIVE_BUILD']
endif endif
# globally disables all simd optimizations
if opt_nosimd
cxxflags += ['-DCR_DISABLE_SIMD']
endif
# configure flags gcc and clang # configure flags gcc and clang
if cxx == 'clang' or cxx == 'gcc' if cxx == 'clang' or cxx == 'gcc'
cxxflags += [ cxxflags += [
@ -111,14 +117,18 @@ if cxx == 'clang' or cxx == 'gcc'
'-march=armv8-a+fp+simd', '-march=armv8-a+fp+simd',
] ]
elif cpu != 'arm' and not cpu.startswith('ppc') elif cpu != 'arm' and not cpu.startswith('ppc')
if not opt_nosimd
cxxflags += [ cxxflags += [
'-mmmx', '-msse', '-msse2', '-msse3', '-mfpmath=sse' '-msse', '-msse2', '-mfpmath=sse'
] ]
endif
if opt_native if opt_native
cxxflags += '-march=native' cxxflags += '-march=native'
else elif opt_64bit
cxxflags += '-march=x86-64' cxxflags += '-march=x86-64'
else
cxxflags += '-march=i686'
endif endif
endif endif
@ -132,7 +142,8 @@ if cxx == 'clang' or cxx == 'gcc'
cxxflags += [ cxxflags += [
'-fdata-sections', '-fdata-sections',
'-ffunction-sections', '-ffunction-sections',
'-fcf-protection=none' '-fcf-protection=none',
'-fno-plt'
] ]
ldflags += [ ldflags += [

View file

@ -13,3 +13,7 @@ option('native', type : 'boolean', value : false,
option('winxp', type : 'boolean', value : false, option('winxp', type : 'boolean', value : false,
description: 'Configure MSVC build to output Windows XP compatible binary.') description: 'Configure MSVC build to output Windows XP compatible binary.')
option('nosimd', type : 'boolean', value : false,
description: 'Disables all SIMD or NEON optimizations.')

View file

@ -4057,7 +4057,7 @@ void Bot::updateHearing () {
} }
m_lastEnemyOrigin = getHeardOriginWithError (); m_lastEnemyOrigin = getHeardOriginWithError ();
} }
else { else if (m_hearedEnemy != nullptr) {
// if bot had an enemy but the heard one is nearer, take it instead // if bot had an enemy but the heard one is nearer, take it instead
const float distanceSq = m_lastEnemyOrigin.distanceSq (pev->origin); const float distanceSq = m_lastEnemyOrigin.distanceSq (pev->origin);

View file

@ -1992,7 +1992,7 @@ void BotControl::showMenu (int id) {
parsed.text = translated; parsed.text = translated;
// make menu looks best // make menu looks best
if (!(game.is (GameFlags::Legacy))) { if (!game.is (GameFlags::Legacy)) {
for (int j = 0; j < 10; ++j) { for (int j = 0; j < 10; ++j) {
parsed.text.replace (strings.format ("%d.", j), strings.format ("\\r%d.\\w", j)); parsed.text.replace (strings.format ("%d.", j), strings.format ("\\r%d.\\w", j));
} }

View file

@ -662,7 +662,7 @@ void ConVar::setPrefix (StringRef name, int32_t type) {
void Game::checkCvarsBounds () { void Game::checkCvarsBounds () {
for (const auto &var : m_cvars) { for (const auto &var : m_cvars) {
if (!var.self->ptr) { if (!var.self || !var.self->ptr) {
continue; continue;
} }
@ -1143,8 +1143,12 @@ void Game::printBotVersion () {
botRuntimeFlags.push ("HL25"); botRuntimeFlags.push ("HL25");
} }
if (botRuntimeFlags.empty ()) {
botRuntimeFlags.push ("None");
}
// print if we're using sse 4.x instructions // print if we're using sse 4.x instructions
if (cpuflags.sse41 || cpuflags.sse42 || cpuflags.neon) { if (plat.simd && (cpuflags.sse41 || cpuflags.sse42 || cpuflags.neon)) {
Array <String> simdLevels {}; Array <String> simdLevels {};
if (cpuflags.sse41) { if (cpuflags.sse41) {

View file

@ -2835,8 +2835,6 @@ void BotGraph::unassignPath (int from, int to) {
} }
void BotGraph::convertFromPOD (Path &path, const PODPath &pod) { void BotGraph::convertFromPOD (Path &path, const PODPath &pod) {
path = {};
path.number = pod.number; path.number = pod.number;
path.flags = pod.flags; path.flags = pod.flags;
path.origin = pod.origin; path.origin = pod.origin;
@ -2861,8 +2859,6 @@ void BotGraph::convertFromPOD (Path &path, const PODPath &pod) {
} }
void BotGraph::convertToPOD (const Path &path, PODPath &pod) { void BotGraph::convertToPOD (const Path &path, PODPath &pod) {
pod = {};
pod.number = path.number; pod.number = path.number;
pod.flags = path.flags; pod.flags = path.flags;
pod.origin = path.origin; pod.origin = path.origin;

View file

@ -530,17 +530,6 @@ CR_LINKAGE_C int GetEngineFunctions (enginefuncs_t *table, int *) {
}; };
} }
table->pfnLightStyle = [] (int style, char *val) {
// this function update lightstyle for the bots
illum.updateLight (style, val);
if (game.is (GameFlags::Metamod)) {
RETURN_META (MRES_IGNORED);
}
engfuncs.pfnLightStyle (style, val);
};
if (game.is (GameFlags::Legacy)) { if (game.is (GameFlags::Legacy)) {
table->pfnFindEntityByString = [] (edict_t *edictStartSearchAfter, const char *field, const char *value) { table->pfnFindEntityByString = [] (edict_t *edictStartSearchAfter, const char *field, const char *value) {
// round starts in counter-strike 1.5 // round starts in counter-strike 1.5
@ -555,6 +544,18 @@ CR_LINKAGE_C int GetEngineFunctions (enginefuncs_t *table, int *) {
}; };
} }
if (!game.is (GameFlags::Legacy)) {
table->pfnLightStyle = [] (int style, char *val) {
// this function update lightstyle for the bots
illum.updateLight (style, val);
if (game.is (GameFlags::Metamod)) {
RETURN_META (MRES_IGNORED);
}
engfuncs.pfnLightStyle (style, val);
};
table->pfnGetPlayerAuthId = [] (edict_t *e) -> const char * { table->pfnGetPlayerAuthId = [] (edict_t *e) -> const char * {
if (bots[e]) { if (bots[e]) {
auto authid = util.getFakeSteamId (e); auto authid = util.getFakeSteamId (e);
@ -570,6 +571,7 @@ CR_LINKAGE_C int GetEngineFunctions (enginefuncs_t *table, int *) {
} }
return engfuncs.pfnGetPlayerAuthId (e); return engfuncs.pfnGetPlayerAuthId (e);
}; };
}
table->pfnEmitSound = [] (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch) { table->pfnEmitSound = [] (edict_t *entity, int channel, const char *sample, float volume, float attenuation, int flags, int pitch) {
// this function tells the engine that the entity pointed to by "entity", is emitting a sound // this function tells the engine that the entity pointed to by "entity", is emitting a sound

View file

@ -57,7 +57,7 @@ float Heuristic::gfunctionKills (int team, int currentIndex, int) {
if (current.flags & NodeFlag::Crouch) { if (current.flags & NodeFlag::Crouch) {
cost *= 1.5f; cost *= 1.5f;
} }
return cost; return cost + 0.5f;
} }
auto Heuristic::gfunctionKillsCTWithHostage (int team, int currentIndex, int parentIndex) -> float { auto Heuristic::gfunctionKillsCTWithHostage (int team, int currentIndex, int parentIndex) -> float {

View file

@ -430,6 +430,11 @@ StringRef BotStorage::getRunningPath () {
if (path.startsWith ("<unk")) { if (path.startsWith ("<unk")) {
logger.fatal ("Unable to detect library path. Giving up..."); logger.fatal ("Unable to detect library path. Giving up...");
} }
// remove dot prefix
if (path.startsWith (".")) {
path.ltrim (".\\/");
}
auto parts = path.substr (1).split (kPathSeparator); auto parts = path.substr (1).split (kPathSeparator);
parts.pop (); // remove library name parts.pop (); // remove library name