cfg: updated yapb.cfg to reflect changes.

cfg: made yb_quota 9 by default.
linux: fixed bots connection times remains static on linux or osx.
crlib: fix security issues.
This commit is contained in:
ds 2020-10-04 00:54:34 +03:00
commit 30a112fd71
10 changed files with 110 additions and 54 deletions

View file

@ -4,11 +4,11 @@
// @author: YaPB Development Team
// @filename: yapb.cfg
//
// YAPB main configuration file. Can be executed via "exec" command.
// YaPB main configuration file. Can be executed via "exec" command.
//
//
// Enables or disables useful messages about bot states. Not required for end users
// Enables or disables useful messages about bot states. Not required for end users.
// ---
// Default: "0", Min: "0", Max: "4"
//
@ -61,7 +61,7 @@ yb_radio_mode "2"
yb_economics_rounds "1"
//
// Sepcifies whether bots able to use 'shift' if they thinks that enemy is near.
// Specifies whether bots able to use 'shift' if they thinks that enemy is near.
// ---
// Default: "1", Min: "0", Max: "1"
//
@ -82,7 +82,7 @@ yb_camping_allowed "1"
yb_tkpunish "1"
//
// If enables bots think function is disabled, so bots will not move anywhere from their spawn spots.
// If enabled the bots think function is disabled, so bots will not move anywhere from their spawn spots.
// ---
// Default: "0", Min: "0", Max: "1"
//
@ -158,6 +158,20 @@ yb_check_enemy_rendering "0"
//
yb_stab_close_enemies "1"
//
// Bind's specified key for opening bots menu.
// ---
// Default: "="
//
yb_bind_menu_key "="
//
// Specifies comma separated list of bot cvars, that will not be overriten by config on changelevel.
// ---
// Default: "yb_quota,yb_autovacate"
//
yb_ignore_cvars_on_changelevel "yb_quota,yb_autovacate"
//
// Enables or disables display menu text, when players asks for menu. Useful only for Android.
// ---
@ -173,7 +187,7 @@ yb_display_menu_text "1"
yb_password ""
//
// The name of setinfo key used to store password to bot commands and menus
// The name of setinfo key used to store password to bot commands and menus.
// ---
// Default: "_ybpw"
//
@ -199,7 +213,7 @@ yb_csdm_mode "0"
yb_graph_fixcamp "1"
//
// Specifies the URL from bots will be able to download graph in case of missing local one.
// Specifies the URL from bots will be able to download graph in case of missing local one. Set to empty, if no downloads needed.
// ---
// Default: "yapb.ru"
//
@ -212,39 +226,32 @@ yb_graph_url "yapb.ru"
//
yb_autovacate "1"
//
// Bind's specified key for openining bots menu.
// ---
// Default: "="
//
yb_bind_menu_key "="
//
// Specifies the number bots to be added to the game.
// ---
// Default: "0", Min: "0", Max: "32"
// Default: "9", Min: "0", Max: "32"
//
yb_quota "12"
yb_quota "9"
//
// Specifies the type of quota.
// Allowed values: 'normal', 'fill', and 'match'.
// If 'fill', the server will adjust bots to keep N players in the game, where N is cv_quota.
// If 'match', the server will maintain a 1:N ratio of humans to bots, where N is cv_quota_match.
// If 'fill', the server will adjust bots to keep N players in the game, where N is yb_quota.
// If 'match', the server will maintain a 1:N ratio of humans to bots, where N is yb_quota_match.
// ---
// Default: "normal"
//
yb_quota_mode "normal"
//
// Number of players to match if cv_quota_mode set to 'match'
// Number of players to match if yb_quota_mode set to 'match'
// ---
// Default: "0", Min: "0", Max: "32"
//
yb_quota_match "0"
//
// Specifies hou many times per second bot code will run.
// Specifies how many times per second bot code will run.
// ---
// Default: "30.0", Min: "30.0", Max: "90.0"
//
@ -258,7 +265,7 @@ yb_think_fps "30.0"
yb_autokill_delay "0.0"
//
// Sepcifies whether bots should join server, only when at least one human player in game.
// Specifies whether bots should join server, only when at least one human player in game.
// ---
// Default: "0", Min: "0", Max: "1"
//
@ -286,12 +293,33 @@ yb_join_delay "5.0"
yb_name_prefix ""
//
// All bots difficulty level. Chaning at runtime will affect already created bots.
// All bots difficulty level. Changing at runtime will affect already created bots.
// ---
// Default: "4", Min: "0", Max: "4"
//
yb_difficulty "4"
//
// Lower bound of random difficulty on bot creation. Only affects newly created bots. -1 means yb_difficulty only used.
// ---
// Default: "-1", Min: "-1", Max: "4"
//
yb_difficulty_min "-1"
//
// Upper bound of random difficulty on bot creation. Only affects newly created bots. -1 means yb_difficulty only used.
// ---
// Default: "-1", Min: "-1", Max: "4"
//
yb_difficulty_max "-1"
//
// Enables each bot balances own difficulty based kd-ratio of team.
// ---
// Default: "0", Min: "0", Max: "1"
//
yb_difficulty_auto "0"
//
// Enables or disabels displaying bot avatars in front of their names in scoreboard. Note, that is currently you can see only avatars of your steam friends.
// ---
@ -310,6 +338,34 @@ yb_show_avatars "1"
//
yb_show_latency "2"
//
// Specifies the bots wanted skin for Terrorist team.
// ---
// Default: "0", Min: "0", Max: "5"
//
yb_botskin_t "0"
//
// Specifies the bots wanted skin for CT team.
// ---
// Default: "0", Min: "0", Max: "5"
//
yb_botskin_ct "0"
//
// Lower bound for base bot ping shown in scoreboard upon creation.
// ---
// Default: "7", Min: "0", Max: "100"
//
yb_ping_base_min "7"
//
// Upper bound for base bot ping shown in scoreboard upon creation.
// ---
// Default: "34", Min: "0", Max: "100"
//
yb_ping_base_max "34"
//
// Specifies the language for bot messages and menus.
// ---
@ -317,13 +373,6 @@ yb_show_latency "2"
//
yb_language "en"
//
// Specifies comma separated list of bot cvars, that will not be overriten by config on changelevel.
// ---
// Default: "yb_quota,yb_autovacate"
//
yb_ignore_cvars_on_changelevel "yb_quota,yb_autovacate"
//
// Enables or disables extra hard difficulty for bots.
// ---
@ -346,7 +395,7 @@ yb_debug_heuristic_type "0"
yb_display_welcome_text "1"
//
// Enables or disabled fake server queries response, that shows bots as real players in server browser.
// Enables or disables fake server queries response, that shows bots as real players in server browser.
// ---
// Default: "0", Min: "0", Max: "1"
//

View file

@ -43,19 +43,16 @@ private:
return;
}
time_t ticks = time (&ticks);
tm *timeinfo = nullptr;
tm timeinfo {};
#if defined (CR_WINDOWS)
tm get;
localtime_s (&get, &ticks);
timeinfo = &get;
localtime_s (&timeinfo, &ticks);
#else
timeinfo = localtime (&ticks);
localtime_r (&ticks, &timeinfo);
#endif
auto timebuf = strings.chars ();
strftime (timebuf, StringBuffer::StaticBufferSize, "%Y-%m-%d %H:%M:%S", timeinfo);
strftime (timebuf, StringBuffer::StaticBufferSize, "%Y-%m-%d %H:%M:%S", &timeinfo);
handle_.puts ("%s (%s): %s\n", timebuf, level, msg);
}

View file

@ -139,6 +139,8 @@ CR_NAMESPACE_END
# include <android/log.h>
#endif
#include <time.h>
CR_NAMESPACE_BEGIN
// helper struct for platform detection
@ -151,6 +153,8 @@ struct Platform : public Singleton <Platform> {
bool x64 = false;
bool arm = false;
char appName[64] = {};
Platform () {
#if defined(CR_WINDOWS)
win32 = true;
@ -182,6 +186,11 @@ struct Platform : public Singleton <Platform> {
#endif
}
// set the app name
void setAppName (const char *name) {
snprintf (appName, cr::bufsize (appName), "%s", name);
}
// helper platform-dependant functions
template <typename U> bool checkPointer (U *ptr) {
#if defined(CR_WINDOWS)
@ -232,12 +241,14 @@ struct Platform : public Singleton <Platform> {
QueryPerformanceFrequency (&freq);
QueryPerformanceCounter (&count);
return static_cast <float> (count.QuadPart) / static_cast <float> (freq.QuadPart);
return static_cast <float> (count.QuadPart / freq.QuadPart);
#else
timeval tv;
gettimeofday (&tv, NULL);
gettimeofday (&tv, nullptr);
return static_cast <float> (tv.tv_sec) + (static_cast <float> (tv.tv_usec)) / 1000000.0;
static auto startTime = tv.tv_sec;
return static_cast <float> (tv.tv_sec - startTime);
#endif
}
@ -245,12 +256,12 @@ struct Platform : public Singleton <Platform> {
fprintf (stderr, "%s\n", msg);
#if defined (CR_ANDROID)
__android_log_write (ANDROID_LOG_ERROR, "crlib.fatal", msg);
__android_log_write (ANDROID_LOG_ERROR, appName, msg);
#endif
#if defined(CR_WINDOWS)
DestroyWindow (GetForegroundWindow ());
MessageBoxA (GetActiveWindow (), msg, "crlib.fatal", MB_ICONSTOP);
MessageBoxA (GetActiveWindow (), msg, appName, MB_ICONSTOP);
#endif
::abort ();
}

View file

@ -15,7 +15,6 @@
#pragma once
#include <time.h>
#include <crlib/cr-basic.h>
CR_NAMESPACE_BEGIN

View file

@ -77,7 +77,7 @@ public:
void loadConfigs ();
// loads main config file
void loadMainConfig ();
void loadMainConfig (bool isFirstLoad = false);
// loads bot names
void loadNamesConfig ();

View file

@ -38,14 +38,12 @@ void BotConfig::loadConfigs () {
loadDifficultyConfig ();
}
void BotConfig::loadMainConfig () {
void BotConfig::loadMainConfig (bool isFirstLoad) {
if (game.is (GameFlags::Legacy) && !game.is (GameFlags::Xash3D)) {
util.setNeedForWelcome (true);
}
setupMemoryFiles ();
static bool firstLoad = true;
auto needsToIgnoreVar = [](StringArray &list, const char *needle) {
for (const auto &var : list) {
if (var == needle) {
@ -66,7 +64,7 @@ void BotConfig::loadMainConfig () {
continue;
}
if (firstLoad) {
if (isFirstLoad) {
game.serverCommand (line.chars ());
continue;
}
@ -104,7 +102,6 @@ void BotConfig::loadMainConfig () {
}
file.close ();
}
firstLoad = false;
// android is abit hard to play, lower the difficulty by default
if (plat.android && cv_difficulty.int_ () > 3) {

View file

@ -17,7 +17,7 @@
ConVar cv_display_menu_text ("yb_display_menu_text", "1", "Enables or disables display menu text, when players asks for menu. Useful only for Android.");
ConVar cv_password ("yb_password", "", "The value (password) for the setinfo key, if user set's correct password, he's gains access to bot commands and menus.", false, 0.0f, 0.0f, Var::Password);
ConVar cv_password_key ("yb_password_key", "_ubpw", "The name of setinfo key used to store password to bot commands and menus.", false);
ConVar cv_password_key ("yb_password_key", "_ybpw", "The name of setinfo key used to store password to bot commands and menus.", false);
int BotControl::cmdAddBot () {
enum args { alias = 1, difficulty, personality, team, model, name, max };

View file

@ -745,6 +745,9 @@ bool Game::postload () {
// set out user agent for http stuff
http.setUserAgent (strings.format ("%s/%s", product.name, product.version));
// set the app name
plat.setAppName (product.name.chars ());
// register bot cvars
game.registerCvars ();

View file

@ -118,7 +118,7 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
// to register by the engine side the server commands we need to administrate our bots.
// execute main config
conf.loadMainConfig ();
conf.loadMainConfig (true);
conf.adjustWeaponPrices ();
if (game.is (GameFlags::Metamod)) {
@ -448,7 +448,7 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
}
CR_LINKAGE_C int GetEntityAPI_Post (gamefuncs_t *table, int) {
// this function is called right after GiveFnptrsToDll() by the engine in the game DLL (or
// this function is called right after ssToDll() by the engine in the game DLL (or
// what it BELIEVES to be the game DLL), in order to copy the list of MOD functions that can
// be called by the engine, into a memory block pointed to by the functionTable pointer
// that is passed into this function (explanation comes straight from botman). This allows

View file

@ -17,7 +17,7 @@
ConVar cv_autovacate ("yb_autovacate", "1", "Kick bots to automatically make room for human players.");
ConVar cv_quota ("yb_quota", "0", "Specifies the number bots to be added to the game.", true, 0.0f, static_cast <float> (kGameMaxPlayers));
ConVar cv_quota ("yb_quota", "9", "Specifies the number bots to be added to the game.", true, 0.0f, static_cast <float> (kGameMaxPlayers));
ConVar cv_quota_mode ("yb_quota_mode", "normal", "Specifies the type of quota.\nAllowed values: 'normal', 'fill', and 'match'.\nIf 'fill', the server will adjust bots to keep N players in the game, where N is yb_quota.\nIf 'match', the server will maintain a 1:N ratio of humans to bots, where N is yb_quota_match.", false);
ConVar cv_quota_match ("yb_quota_match", "0", "Number of players to match if yb_quota_mode set to 'match'", true, 0.0f, static_cast <float> (kGameMaxPlayers));
ConVar cv_think_fps ("yb_think_fps", "30.0", "Specifies how many times per second bot code will run.", true, 30.0f, 90.0f);
@ -37,8 +37,8 @@ ConVar cv_difficulty_auto ("yb_difficulty_auto", "0", "Enables each bot balances
ConVar cv_show_avatars ("yb_show_avatars", "1", "Enables or disabels displaying bot avatars in front of their names in scoreboard. Note, that is currently you can see only avatars of your steam friends.");
ConVar cv_show_latency ("yb_show_latency", "2", "Enables latency display in scoreboard.\nAllowed values: '0', '1', '2'.\nIf '0', there is nothing displayed.\nIf '1', there is a 'BOT' is displayed.\nIf '2' fake ping is displayed.", true, 0.0f, 2.0f);
ConVar cv_botskin_t ("yb_botskin_t", "0", "Specifies the bots wanted skin for Terrorist team", true, 0.0f, 5.0f);
ConVar cv_botskin_ct ("yb_botskin_ct", "0", "Specifies the bots wanted skin for CT team", true, 0.0f, 5.0f);
ConVar cv_botskin_t ("yb_botskin_t", "0", "Specifies the bots wanted skin for Terrorist team.", true, 0.0f, 5.0f);
ConVar cv_botskin_ct ("yb_botskin_ct", "0", "Specifies the bots wanted skin for CT team.", true, 0.0f, 5.0f);
ConVar cv_ping_base_min ("yb_ping_base_min", "7", "Lower bound for base bot ping shown in scoreboard upon creation.", true, 0.0f, 100.0f);
ConVar cv_ping_base_max ("yb_ping_base_max", "34", "Upper bound for base bot ping shown in scoreboard upon creation.", true, 0.0f, 100.0f);