fix: code formatting
This commit is contained in:
parent
290681d2d8
commit
2718adbb8f
13 changed files with 206 additions and 208 deletions
|
|
@ -14,7 +14,7 @@ struct BotName {
|
|||
|
||||
public:
|
||||
BotName () = default;
|
||||
BotName (StringRef name, int usedBy) : name (name), usedBy (usedBy) { }
|
||||
BotName (StringRef name, int usedBy) : name (name), usedBy (usedBy) {}
|
||||
};
|
||||
|
||||
// voice config structure definition
|
||||
|
|
@ -24,7 +24,7 @@ struct ChatterItem {
|
|||
float duration;
|
||||
|
||||
public:
|
||||
ChatterItem (StringRef name, float repeat, float duration) : name (name), repeat (repeat), duration (duration) { }
|
||||
ChatterItem (StringRef name, float repeat, float duration) : name (name), repeat (repeat), duration (duration) {}
|
||||
};
|
||||
|
||||
// mostly config stuff, and some stuff dealing with menus
|
||||
|
|
@ -112,7 +112,7 @@ public:
|
|||
void clearUsedName (Bot *bot);
|
||||
|
||||
// set the bot names as used
|
||||
void setBotNameUsed(const int index, StringRef name);
|
||||
void setBotNameUsed (const int index, StringRef name);
|
||||
|
||||
// initialize weapon info
|
||||
void initWeapons ();
|
||||
|
|
|
|||
|
|
@ -946,7 +946,7 @@ void Bot::showChaterIcon (bool show) {
|
|||
return;
|
||||
}
|
||||
|
||||
auto sendBotVoice = [](bool show, edict_t *ent, int ownId) {
|
||||
auto sendBotVoice = [] (bool show, edict_t *ent, int ownId) {
|
||||
MessageWriter (MSG_ONE, msgs.id (NetMsg::BotVoice), nullptr, ent) // begin message
|
||||
.writeByte (show) // switch on/off
|
||||
.writeByte (ownId);
|
||||
|
|
@ -1229,7 +1229,7 @@ bool Bot::isWeaponRestrictedAMX (int weaponIndex) {
|
|||
if (restrictedWeapons.empty ()) {
|
||||
return false;
|
||||
}
|
||||
constexpr int indices[] = {4, 25, 20, -1, 8, -1, 12, 19, -1, 5, 6, 13, 23, 17, 18, 1, 2, 21, 9, 24, 7, 16, 10, 22, -1, 3, 15, 14, 0, 11};
|
||||
constexpr int indices[] = { 4, 25, 20, -1, 8, -1, 12, 19, -1, 5, 6, 13, 23, 17, 18, 1, 2, 21, 9, 24, 7, 16, 10, 22, -1, 3, 15, 14, 0, 11 };
|
||||
|
||||
// find the weapon index
|
||||
int index = indices[weaponIndex - 1];
|
||||
|
|
@ -1248,7 +1248,7 @@ bool Bot::isWeaponRestrictedAMX (int weaponIndex) {
|
|||
if (restrictedEquipment.empty ()) {
|
||||
return false;
|
||||
}
|
||||
constexpr int indices[] = {-1, -1, -1, 3, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, 0, 1, 5};
|
||||
constexpr int indices[] = { -1, -1, -1, 3, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, 0, 1, 5 };
|
||||
|
||||
// find the weapon index
|
||||
int index = indices[weaponIndex - 1];
|
||||
|
|
@ -5196,7 +5196,7 @@ void Bot::showDebugOverlay () {
|
|||
// red = view angles
|
||||
game.drawLine (game.getLocalEntity (), getEyesPos (), m_destOrigin, 10, 0, { 0, 255, 0 }, 250, 5, 1, DrawLine::Arrow);
|
||||
game.drawLine (game.getLocalEntity (), getEyesPos () - Vector (0.0f, 0.0f, 16.0f), getEyesPos () + m_idealAngles.forward () * 300.0f, 10, 0, { 0, 0, 255 }, 250, 5, 1, DrawLine::Arrow);
|
||||
game.drawLine (game.getLocalEntity (), getEyesPos () - Vector (0.0f, 0.0f, 32.0f), getEyesPos () + pev->v_angle.forward () * 300.0f, 10, 0, {255, 0, 0}, 250, 5, 1, DrawLine::Arrow);
|
||||
game.drawLine (game.getLocalEntity (), getEyesPos () - Vector (0.0f, 0.0f, 32.0f), getEyesPos () + pev->v_angle.forward () * 300.0f, 10, 0, { 255, 0, 0 }, 250, 5, 1, DrawLine::Arrow);
|
||||
|
||||
// now draw line from source to destination
|
||||
for (size_t i = 0; i < m_pathWalk.length () && i + 1 < m_pathWalk.length (); ++i) {
|
||||
|
|
|
|||
|
|
@ -1303,7 +1303,7 @@ bool Bot::usesCampGun () {
|
|||
return usesSubmachine () || usesRifle () || usesSniper () || usesHeavy ();
|
||||
}
|
||||
|
||||
bool Bot::usesKnife (){
|
||||
bool Bot::usesKnife () {
|
||||
return m_weaponType == WeaponType::Melee;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ void BotConfig::loadMainConfig (bool isFirstLoad) {
|
|||
}
|
||||
setupMemoryFiles ();
|
||||
|
||||
auto needsToIgnoreVar = [](StringArray &list, const char *needle) {
|
||||
auto needsToIgnoreVar = [] (StringArray &list, const char *needle) {
|
||||
for (const auto &var : list) {
|
||||
if (var == needle) {
|
||||
return true;
|
||||
|
|
@ -136,7 +136,7 @@ void BotConfig::loadNamesConfig () {
|
|||
void BotConfig::loadWeaponsConfig () {
|
||||
setupMemoryFiles ();
|
||||
|
||||
auto addWeaponEntries = [](SmallArray <WeaponInfo> &weapons, bool as, StringRef name, const StringArray &data) {
|
||||
auto addWeaponEntries = [] (SmallArray <WeaponInfo> &weapons, bool as, StringRef name, const StringArray &data) {
|
||||
|
||||
// we're have null terminator element in weapons array...
|
||||
if (data.length () + 1 != weapons.length ()) {
|
||||
|
|
@ -155,7 +155,7 @@ void BotConfig::loadWeaponsConfig () {
|
|||
}
|
||||
};
|
||||
|
||||
auto addIntEntries = [](SmallArray <int32> &to, StringRef name, const StringArray &data) {
|
||||
auto addIntEntries = [] (SmallArray <int32> &to, StringRef name, const StringArray &data) {
|
||||
if (data.length () != to.length ()) {
|
||||
logger.error ("%s entry in weapons config is not valid or malformed (%d/%d).", name, data.length (), to.length ());
|
||||
return;
|
||||
|
|
@ -711,7 +711,7 @@ void BotConfig::clearUsedName (Bot *bot) {
|
|||
}
|
||||
}
|
||||
|
||||
void BotConfig::setBotNameUsed(const int index, StringRef name) {
|
||||
void BotConfig::setBotNameUsed (const int index, StringRef name) {
|
||||
for (auto &bn : m_botNames) {
|
||||
if (bn.name == name) {
|
||||
bn.usedBy = index;
|
||||
|
|
@ -795,7 +795,7 @@ const char *BotConfig::translate (StringRef input) {
|
|||
void BotConfig::showCustomValues () {
|
||||
game.print ("Current values for custom config items:");
|
||||
|
||||
m_custom.foreach ([&](const String &key, const String &val) {
|
||||
m_custom.foreach ([&] (const String &key, const String &val) {
|
||||
game.print (" %s = %s", key, val);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -868,7 +868,7 @@ int BotControl::cmdNodeFileInfo () {
|
|||
return BotCommandResult::Handled;
|
||||
}
|
||||
|
||||
int BotControl::cmdAdjustHeight() {
|
||||
int BotControl::cmdAdjustHeight () {
|
||||
enum args { graph_cmd = 1, cmd, offset };
|
||||
|
||||
if (!hasArg (offset)) {
|
||||
|
|
@ -1852,7 +1852,7 @@ void BotControl::showMenu (int id) {
|
|||
}
|
||||
auto &client = util.getClient (game.indexOfPlayer (m_ent));
|
||||
|
||||
auto sendMenu = [&](int32 slots, bool last, StringRef text) {
|
||||
auto sendMenu = [&] (int32 slots, bool last, StringRef text) {
|
||||
MessageWriter (MSG_ONE, msgs.id (NetMsg::ShowMenu), nullptr, m_ent)
|
||||
.writeShort (slots)
|
||||
.writeChar (-1)
|
||||
|
|
|
|||
|
|
@ -530,7 +530,7 @@ void Game::prepareBotArgs (edict_t *ent, String str) {
|
|||
}
|
||||
|
||||
// helper to parse single (not multi) command
|
||||
auto parsePartArgs = [& ] (String &args) {
|
||||
auto parsePartArgs = [&] (String &args) {
|
||||
args.trim ("\r\n\t\" "); // trim new lines
|
||||
|
||||
// we're have empty commands?
|
||||
|
|
@ -1124,7 +1124,7 @@ void LightMeasure::updateLight (int style, char *value) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (strings.isEmpty (value)){
|
||||
if (strings.isEmpty (value)) {
|
||||
m_lightstyle[style].length = 0u;
|
||||
m_lightstyle[style].map[0] = kNullChar;
|
||||
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ int BotGraph::clearConnections (int index) {
|
|||
|
||||
|
||||
for (int i = 2; i < kMaxNodeLinks; ++i) {
|
||||
while (inspect_p0 (i)) { }
|
||||
while (inspect_p0 (i)) {}
|
||||
}
|
||||
|
||||
// check pass 1
|
||||
|
|
@ -332,7 +332,7 @@ int BotGraph::clearConnections (int index) {
|
|||
};
|
||||
|
||||
for (int i = 1; i < kMaxNodeLinks; ++i) {
|
||||
while (inspect_p2 (i)) { }
|
||||
while (inspect_p2 (i)) {}
|
||||
}
|
||||
|
||||
// check pass 3
|
||||
|
|
@ -1565,11 +1565,11 @@ bool BotGraph::convertOldFormat () {
|
|||
// add to node array
|
||||
m_paths.push (cr::move (path));
|
||||
}
|
||||
fp.close();
|
||||
fp.close ();
|
||||
|
||||
// save new format in case loaded older one
|
||||
if (!m_paths.empty()) {
|
||||
ctrl.msg("Converting old PWF to new format Graph.");
|
||||
if (!m_paths.empty ()) {
|
||||
ctrl.msg ("Converting old PWF to new format Graph.");
|
||||
|
||||
m_graphAuthor = header.author;
|
||||
|
||||
|
|
@ -1577,7 +1577,7 @@ bool BotGraph::convertOldFormat () {
|
|||
auto editor = m_editor;
|
||||
m_editor = nullptr;
|
||||
|
||||
auto result = saveGraphData();
|
||||
auto result = saveGraphData ();
|
||||
m_editor = editor;
|
||||
|
||||
return result;
|
||||
|
|
@ -2695,7 +2695,7 @@ bool BotGraph::checkNodes (bool teleportPlayer) {
|
|||
Array <IntArray> outgoingPaths; // store incoming paths for speedup
|
||||
outgoingPaths.resize (m_paths.length ());
|
||||
|
||||
for (const auto &path: m_paths) {
|
||||
for (const auto &path : m_paths) {
|
||||
outgoingPaths[path.number].resize (m_paths.length () + 1);
|
||||
|
||||
for (const auto &link : path.links) {
|
||||
|
|
@ -3068,7 +3068,7 @@ void BotGraph::updateGlobalPractice () {
|
|||
}
|
||||
|
||||
for (int team = Team::Terrorist; team < kGameTeamNum; ++team) {
|
||||
m_highestDamage[team] = cr::clamp (m_highestDamage [team] - kHalfDamageVal, 1, kMaxPracticeDamageValue);
|
||||
m_highestDamage[team] = cr::clamp (m_highestDamage[team] - kHalfDamageVal, 1, kMaxPracticeDamageValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ plugin_info_t Plugin_info = {
|
|||
PT_ANYTIME, // when unloadable
|
||||
};
|
||||
|
||||
namespace variadic {
|
||||
void clientCommand (edict_t *ent, char const *format, ...) {
|
||||
void hook_ClientCommand (edict_t *ent, char const *format, ...) {
|
||||
// this function forces the client whose player entity is ent to issue a client command.
|
||||
// How it works is that clients all have a argv global string in their client DLL that
|
||||
// stores the command string; if ever that string is filled with characters, the client DLL
|
||||
|
|
@ -79,7 +78,6 @@ namespace variadic {
|
|||
RETURN_META (MRES_IGNORED);
|
||||
}
|
||||
engfuncs.pfnClientCommand (ent, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
|
||||
|
|
@ -509,7 +507,7 @@ CR_LINKAGE_C int GetEngineFunctions (enginefuncs_t *table, int *) {
|
|||
}
|
||||
|
||||
if (ents.needsBypass () && !game.is (GameFlags::Metamod)) {
|
||||
table->pfnCreateNamedEntity = [] (int classname) -> edict_t * {
|
||||
table->pfnCreateNamedEntity = [] (int classname) -> edict_t *{
|
||||
|
||||
if (ents.isPaused ()) {
|
||||
ents.enable ();
|
||||
|
|
@ -779,7 +777,7 @@ CR_LINKAGE_C int GetEngineFunctions (enginefuncs_t *table, int *) {
|
|||
engfuncs.pfnSetClientMaxspeed (ent, newMaxspeed);
|
||||
};
|
||||
|
||||
table->pfnClientCommand = variadic::clientCommand;
|
||||
table->pfnClientCommand = hook_ClientCommand;
|
||||
|
||||
return HLTrue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ BotCreateResult BotManager::create (StringRef name, int difficulty, int personal
|
|||
botName->usedBy = index; // save by who name is used
|
||||
}
|
||||
else {
|
||||
conf.setBotNameUsed(index, resultName);
|
||||
conf.setBotNameUsed (index, resultName);
|
||||
}
|
||||
m_bots.push (cr::move (object));
|
||||
|
||||
|
|
@ -566,7 +566,7 @@ void BotManager::serverFill (int selection, int personality, int difficulty, int
|
|||
else {
|
||||
selection = 5;
|
||||
}
|
||||
char teams[6][12] = {"", {"Terrorists"}, {"CTs"}, "", "", {"Random"}, };
|
||||
char teams[6][12] = { "", {"Terrorists"}, {"CTs"}, "", "", {"Random"}, };
|
||||
auto toAdd = numToAdd == -1 ? maxClients - (getHumansCount () + getBotCount ()) : numToAdd;
|
||||
|
||||
for (int i = 0; i <= toAdd; ++i) {
|
||||
|
|
@ -703,7 +703,7 @@ bool BotManager::kickRandom (bool decQuota, Team fromTeam) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void BotManager::setLastWinner (int winner) {
|
||||
void BotManager::setLastWinner (int winner) {
|
||||
m_lastWinner = winner;
|
||||
m_roundOver = true;
|
||||
|
||||
|
|
@ -748,7 +748,7 @@ void BotManager::setWeaponMode (int selection) {
|
|||
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, -1, 1, -1, -1}, // Snipers only
|
||||
{-1, -1, -1, 2, 2, 0, 1, 1, 1, 1, 1, 1, 0, 2, 0, -1, 1, 0, 1, 1, 0, 0, -1, 1, 1, 1} // Standard
|
||||
};
|
||||
constexpr char modes[7][12] = {{"Knife"}, {"Pistol"}, {"Shotgun"}, {"Machine Gun"}, {"Rifle"}, {"Sniper"}, {"Standard"}};
|
||||
constexpr char modes[7][12] = { {"Knife"}, {"Pistol"}, {"Shotgun"}, {"Machine Gun"}, {"Rifle"}, {"Sniper"}, {"Standard"} };
|
||||
|
||||
// get the raw weapons array
|
||||
auto tab = conf.getRawWeapons ();
|
||||
|
|
@ -768,7 +768,8 @@ void BotManager::listBots () {
|
|||
|
||||
ctrl.msg ("%-3.5s\t%-19.16s\t%-10.12s\t%-3.4s\t%-3.4s\t%-3.4s\t%-3.5s", "index", "name", "personality", "team", "difficulty", "frags", "alive");
|
||||
|
||||
for (const auto &bot : bots) {;
|
||||
for (const auto &bot : bots) {
|
||||
;
|
||||
ctrl.msg ("[%-3.1d]\t%-19.16s\t%-10.12s\t%-3.4s\t%-3.1d\t%-3.1d\t%-3.4s", bot->index (), bot->pev->netname.chars (), bot->m_personality == Personality::Rusher ? "rusher" : bot->m_personality == Personality::Normal ? "normal" : "careful", bot->m_team == Team::CT ? "CT" : "T", bot->m_difficulty, static_cast <int> (bot->pev->frags), bot->m_notKilled ? "yes" : "no");
|
||||
}
|
||||
ctrl.msg ("%d bots", m_bots.length ());
|
||||
|
|
@ -966,7 +967,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int skin) {
|
|||
}
|
||||
}
|
||||
|
||||
char reject[256] = {0, };
|
||||
char reject[256] = { 0, };
|
||||
MDLL_ClientConnect (bot, bot->v.netname.chars (), strings.format ("127.0.0.%d", clientIndex + 100), reject);
|
||||
|
||||
if (!strings.isEmpty (reject)) {
|
||||
|
|
@ -1221,7 +1222,7 @@ void Bot::newRound () {
|
|||
|
||||
m_path = nullptr;
|
||||
m_currentTravelFlags = 0;
|
||||
m_desiredVelocity= nullptr;
|
||||
m_desiredVelocity = nullptr;
|
||||
m_currentNodeIndex = kInvalidNodeIndex;
|
||||
m_prevGoalIndex = kInvalidNodeIndex;
|
||||
m_chosenGoalIndex = kInvalidNodeIndex;
|
||||
|
|
@ -1310,7 +1311,7 @@ void Bot::newRound () {
|
|||
m_aimFlags = 0;
|
||||
m_liftState = 0;
|
||||
|
||||
m_aimLastError= nullptr;
|
||||
m_aimLastError = nullptr;
|
||||
m_position = nullptr;
|
||||
m_liftTravelPos = nullptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -597,8 +597,7 @@ void Bot::checkTerrain (float movedDistance, const Vector &dirNormal) {
|
|||
++i;
|
||||
|
||||
#if 0
|
||||
if (bits & CollisionProbe::Duck)
|
||||
{
|
||||
if (bits & CollisionProbe::Duck) {
|
||||
state[i] = 0;
|
||||
|
||||
if (canDuckUnder (dirNormal)) {
|
||||
|
|
@ -1294,7 +1293,7 @@ bool Bot::updateLiftStates () {
|
|||
void Bot::findShortestPath (int srcIndex, int destIndex) {
|
||||
// this function finds the shortest path from source index to destination index
|
||||
|
||||
if (!graph.exists (srcIndex)){
|
||||
if (!graph.exists (srcIndex)) {
|
||||
logger.error ("%s source path index not valid (%d).", __FUNCTION__, srcIndex);
|
||||
return;
|
||||
}
|
||||
|
|
@ -2036,7 +2035,7 @@ int Bot::findDefendNode (const Vector &origin) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
return nodeIndex[rg.get (0, (index -1) / 2)];
|
||||
return nodeIndex[rg.get (0, (index - 1) / 2)];
|
||||
}
|
||||
|
||||
int Bot::findCoverNode (float maxDistance) {
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ bool BotSupport::isMonster (edict_t *ent) {
|
|||
}
|
||||
|
||||
bool BotSupport::isItem (edict_t *ent) {
|
||||
return !!(strstr (ent->v.classname.chars(), "item_"));
|
||||
return !!(strstr (ent->v.classname.chars (), "item_"));
|
||||
}
|
||||
|
||||
bool BotSupport::isPlayerVIP (edict_t *ent) {
|
||||
|
|
@ -676,7 +676,7 @@ void BotSupport::installSendTo () {
|
|||
}
|
||||
|
||||
bool BotSupport::isObjectInsidePlane (FrustumPlane &plane, const Vector ¢er, float height, float radius) {
|
||||
auto isPointInsidePlane = [&](const Vector &point) -> bool {
|
||||
auto isPointInsidePlane = [&] (const Vector &point) -> bool {
|
||||
return plane.result + (plane.normal | point) >= 0.0f;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue