Custom.cfg (#213)

Added custom configs.

These are used for replacing some hardcoded strings inside bot code, currently custom cvar for parachute detection is available, as well as custom c4 model names.

Added editorconfig, and fixed CRLF for files (was a mix between LF & CRLF).
Fixed use-after-free sanitizer error with chatlib.
Fixed configs files loaded with memory-loader does not process last line in config files.
This commit is contained in:
jeefo 2020-12-15 15:28:58 +03:00 committed by GitHub
commit 075bff2988
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 533 additions and 404 deletions

View file

@ -51,6 +51,7 @@ private:
HashMap <uint32, String, Hash <int32>> m_language;
HashMap <int32, DifficultyData> m_difficulty;
HashMap <String, String> m_custom;
// default tables for personality weapon preferences, overridden by weapon.cfg
SmallArray <int32> m_normalWeaponPrefs = { 0, 2, 1, 4, 5, 6, 3, 12, 10, 24, 25, 13, 11, 8, 7, 22, 23, 18, 21, 17, 19, 15, 17, 9, 14, 16 };
@ -98,6 +99,9 @@ public:
// loads bots map-specific config
void loadMapSpecificConfig ();
// loads custom config
void loadCustomConfig ();
// sets memfile to use engine functions
void setupMemoryFiles ();
@ -119,6 +123,9 @@ public:
// translates bot message into needed language
const char *translate (StringRef input);
// display current custom values
void showCustomValues ();
private:
bool isCommentLine (StringRef line) const {
if (line.empty ()) {
@ -237,6 +244,21 @@ public:
StringRef getRandomLogoName (int index) {
return m_logos[index];
}
// get custom value
StringRef fetchCustom (StringRef name) {
if (m_custom.has (name)) {
return m_custom[name];
}
SimpleLogger::instance ().error ("Trying to fetch uknonwn custom variable: %s", name);
return "";
}
// simple accessor to c4 model name
StringRef getBombModelName () {
return fetchCustom ("C4ModelName");
}
};
// explose global

View file

@ -99,6 +99,7 @@ private:
int cmdMenu ();
int cmdList ();
int cmdCvars ();
int cmdShowCustom ();
int cmdNode ();
int cmdNodeOn ();
int cmdNodeOff ();

View file

@ -108,6 +108,10 @@ public:
// check if object inside frustum plane
bool isObjectInsidePlane (FrustumPlane &plane, const Vector &center, float height, float radius);
// checks if same model ommiting the models directory
bool isModel (const edict_t *ent, StringRef model);
public:
// re-show welcome after changelevel ?

View file

@ -14,6 +14,6 @@
#define MODULE_BUILD_MACHINE "localhost"
#define MODULE_BUILD_COMPILER "unknown"
#define MODULE_BOT_VERSION "4.1"
#define MODULE_BOT_VERSION_FILE 4,0,0,000
#define MODULE_BOT_VERSION "4.2"
#define MODULE_BOT_VERSION_FILE 4,2,0,000
#define MODULE_BOT_BUILD_ID "0:0"