Cosmetic changes.

This commit is contained in:
Dmitry 2019-07-28 15:47:46 +03:00 committed by jeefo
commit bbaac860dd
7 changed files with 78 additions and 54 deletions

View file

@ -93,8 +93,13 @@ public:
};
auto timeouts = getTimeouts ();
setsockopt (m_socket, SOL_SOCKET, SO_RCVTIMEO, timeouts.first, timeouts.second);
setsockopt (m_socket, SOL_SOCKET, SO_SNDTIMEO, timeouts.first, timeouts.second);
if (setsockopt (m_socket, SOL_SOCKET, SO_RCVTIMEO, timeouts.first, timeouts.second) < 1) {
logger.error ("Unable to set SO_RCVTIMEO.");
}
if (setsockopt (m_socket, SOL_SOCKET, SO_SNDTIMEO, timeouts.first, timeouts.second) < 1) {
logger.error ("Unable to set SO_SNDTIMEO.");
}
sockaddr_in dest;
memset (&dest, 0, sizeof (dest));

View file

@ -784,11 +784,11 @@ private:
int m_reloadState; // current reload state
int m_voicePitch; // bot voice pitch
int m_rechoiceGoalCount; // multiple failed goals?
int m_loosedBombWptIndex; // nearest to loosed bomb node
int m_plantedBombWptIndex; // nearest to planted bomb node
int m_loosedBombNodeIndex; // nearest to loosed bomb node
int m_plantedBombNodeIndex; // nearest to planted bomb node
int m_currentNodeIndex; // current node index
int m_travelStartIndex; // travel start index to double jump action
int m_prevWptIndex[5]; // previous node indices from node find
int m_previousNodes[5]; // previous node indices from node find
int m_pathFlags; // current node flags
int m_needAvoidGrenade; // which direction to strafe away
int m_campDirection; // camp Facing direction
@ -1450,12 +1450,17 @@ public:
}
void setLastRadioTimestamp (const int team, const float timestamp) {
if (team == Team::CT || team == Team::Terrorist) {
m_lastRadioTime[team] = timestamp;
}
}
float getLastRadioTimestamp (const int team) const {
if (team == Team::CT || team == Team::Terrorist) {
return m_lastRadioTime[team];
}
return 0.0f;
}
void setLastRadio (const int team, const int radio) {
m_lastRadio[team] = radio;

View file

@ -1762,9 +1762,9 @@ void Bot::setConditions () {
// if no more enemies found AND bomb planted, switch to knife to get to bombplace faster
if (m_team == Team::CT && m_currentWeapon != Weapon::Knife && m_numEnemiesLeft == 0 && bots.isBombPlanted ()) {
selectWeaponByName ("weapon_knife");
m_plantedBombWptIndex = getNearestToPlantedBomb ();
m_plantedBombNodeIndex = getNearestToPlantedBomb ();
if (isOccupiedPoint (m_plantedBombWptIndex)) {
if (isOccupiedPoint (m_plantedBombNodeIndex)) {
pushChatterMessage (Chatter::BombsiteSecured);
}
}
@ -3304,7 +3304,7 @@ void Bot::seekCover_ () {
// chosen waypoint is a camp waypoint?
if (m_path->flags & NodeFlag::Camp) {
// use the existing camp wpt prefs
// use the existing camp node prefs
if (m_path->flags & NodeFlag::Crouch) {
m_campButtons = IN_DUCK;
}

View file

@ -21,7 +21,7 @@ int BotControl::cmdAddBot () {
// this is duplicate error as in main bot creation code, but not to be silent
if (!graph.length () || graph.hasChanged ()) {
ctrl.msg ("There is not graph found or graph is changed. Cannot create bot.");
ctrl.msg ("There is no graph found or graph is changed. Cannot create bot.");
return BotCommandResult::Handled;
}

View file

@ -870,6 +870,10 @@ void BotGraph::setRadius (int index, float radius) {
bool BotGraph::isConnected (int a, int b) {
// this function checks if node A has a connection to node B
if (!exists (a) || !exists (b)) {
return false;
}
for (const auto &link : m_paths[a].links) {
if (link.index == b) {
return true;
@ -1541,7 +1545,7 @@ template <typename U> bool BotGraph::loadStorage (const String &ext, const Strin
if (tryReload ()) {
return true;
}
return bailout ("Damaged %s (filename: '%s'). Version number differs (got: '%d', need: '%d').", name.chars (), filename.chars (), hdr.length, hdr.version, version);
return bailout ("Damaged %s (filename: '%s'). Version number differs (got: '%d', need: '%d').", name.chars (), filename.chars (), hdr.version, version);
}
// check the storage type

View file

@ -40,6 +40,15 @@ BotManager::BotManager () {
m_lastDifficulty = 0;
m_lastWinner = -1;
m_timeRoundStart = 0.0f;
m_timeRoundMid = 0.0f;
m_timeRoundEnd = 0.0f;
m_bombPlanted = false;
m_botsCanPause = false;
m_bombSayStatus = BombPlantedSay::ChatSay | BombPlantedSay::Chatter;
for (int i = 0; i < kGameTeamNum; ++i) {
m_leaderChoosen[i] = false;
m_economicsGood[i] = true;
@ -305,7 +314,7 @@ void BotManager::maintainQuota () {
if (graph.length () < 1 || graph.hasChanged ()) {
if (yb_quota.int_ () > 0) {
ctrl.msg ("There is not graph found. Cannot create bot");
ctrl.msg ("There is no graph found. Cannot create bot.");
}
yb_quota.set (0);
return;
@ -414,6 +423,7 @@ void BotManager::reset () {
m_plantSearchUpdateTime = 0.0f;
m_lastChatTime = 0.0f;
m_timeBombPlanted = 0.0f;
m_bombSayStatus = BombPlantedSay::ChatSay | BombPlantedSay::Chatter;
m_intrestingEntities.clear ();
m_activeGrenades.clear ();
@ -956,8 +966,8 @@ void Bot::newRound () {
m_currentNodeIndex = kInvalidNodeIndex;
m_prevGoalIndex = kInvalidNodeIndex;
m_chosenGoalIndex = kInvalidNodeIndex;
m_loosedBombWptIndex = kInvalidNodeIndex;
m_plantedBombWptIndex = kInvalidNodeIndex;
m_loosedBombNodeIndex = kInvalidNodeIndex;
m_plantedBombNodeIndex = kInvalidNodeIndex;
m_grenadeRequested = false;
m_moveToC4 = false;
@ -973,7 +983,7 @@ void Bot::newRound () {
m_avoidTime = 0.0f;
for (i = 0; i < 5; ++i) {
m_prevWptIndex[i] = kInvalidNodeIndex;
m_previousNodes[i] = kInvalidNodeIndex;
}
m_navTimeset = game.timebase ();
m_team = game.getTeam (ent ());

View file

@ -23,7 +23,7 @@ int Bot::findBestGoal () {
int index = graph.getNearest (game.getAbsPos (pent));
if (graph.exists (index)) {
return m_loosedBombWptIndex = index;
return m_loosedBombNodeIndex = index;
}
break;
}
@ -46,32 +46,32 @@ int Bot::findBestGoal () {
float backoffDesire = 0.0f;
float tacticChoice = 0.0f;
IntArray *offensiveWpts = nullptr;
IntArray *defensiveWpts = nullptr;
IntArray *offensiveNodes = nullptr;
IntArray *defensiveNodes = nullptr;
switch (m_team) {
case Team::Terrorist:
offensiveWpts = &graph.m_ctPoints;
defensiveWpts = &graph.m_terrorPoints;
offensiveNodes = &graph.m_ctPoints;
defensiveNodes = &graph.m_terrorPoints;
break;
case Team::CT:
default:
offensiveWpts = &graph.m_terrorPoints;
defensiveWpts = &graph.m_ctPoints;
offensiveNodes = &graph.m_terrorPoints;
defensiveNodes = &graph.m_ctPoints;
break;
}
// terrorist carrying the C4?
if (m_hasC4 || m_isVIP) {
tactic = 3;
return findGoalPost (tactic, defensiveWpts, offensiveWpts);
return findGoalPost (tactic, defensiveNodes, offensiveNodes);
}
else if (m_team == Team::CT && hasHostage ()) {
tactic = 2;
offensiveWpts = &graph.m_rescuePoints;
offensiveNodes = &graph.m_rescuePoints;
return findGoalPost (tactic, defensiveWpts, offensiveWpts);
return findGoalPost (tactic, defensiveNodes, offensiveNodes);
}
offensive = m_agressionLevel * 100.0f;
@ -142,7 +142,7 @@ int Bot::findBestGoal () {
if (goalDesire > tacticChoice) {
tactic = 3;
}
return findGoalPost (tactic, defensiveWpts, offensiveWpts);
return findGoalPost (tactic, defensiveNodes, offensiveNodes);
}
int Bot::findGoalPost (int tactic, IntArray *defensive, IntArray *offsensive) {
@ -837,7 +837,7 @@ bool Bot::updateNavigation () {
// is lift activated and bot is standing on it and lift is moving ?
if (m_liftState == LiftState::LookingButtonInside || m_liftState == LiftState::EnteringIn || m_liftState == LiftState::WaitingForTeammates || m_liftState == LiftState::WaitingFor) {
if (pev->groundentity == m_liftEntity && m_liftEntity->v.velocity.z != 0.0f && isOnFloor () && ((graph[m_prevWptIndex[0]].flags & NodeFlag::Lift) || !game.isNullEntity (m_targetEntity))) {
if (pev->groundentity == m_liftEntity && m_liftEntity->v.velocity.z != 0.0f && isOnFloor () && ((graph[m_previousNodes[0]].flags & NodeFlag::Lift) || !game.isNullEntity (m_targetEntity))) {
m_liftState = LiftState::TravelingBy;
m_liftUsageTime = game.timebase () + 14.0f;
@ -873,8 +873,8 @@ bool Bot::updateNavigation () {
// button has been pressed, lift should come
if (m_buttonPushTime + 8.0f >= game.timebase ()) {
if (graph.exists (m_prevWptIndex[0])) {
m_destOrigin = graph[m_prevWptIndex[0]].origin;
if (graph.exists (m_previousNodes[0])) {
m_destOrigin = graph[m_previousNodes[0]].origin;
}
else {
m_destOrigin = pev->origin;
@ -912,8 +912,8 @@ bool Bot::updateNavigation () {
// lift is currently used
if (liftUsed) {
if (graph.exists (m_prevWptIndex[0])) {
m_destOrigin = graph[m_prevWptIndex[0]].origin;
if (graph.exists (m_previousNodes[0])) {
m_destOrigin = graph[m_previousNodes[0]].origin;
}
else {
m_destOrigin = button->v.origin;
@ -942,12 +942,12 @@ bool Bot::updateNavigation () {
// bot is waiting for lift
if (m_liftState == LiftState::WaitingFor) {
if (graph.exists (m_prevWptIndex[0])) {
if (!(graph[m_prevWptIndex[0]].flags & NodeFlag::Lift)) {
m_destOrigin = graph[m_prevWptIndex[0]].origin;
if (graph.exists (m_previousNodes[0])) {
if (!(graph[m_previousNodes[0]].flags & NodeFlag::Lift)) {
m_destOrigin = graph[m_previousNodes[0]].origin;
}
else if (graph.exists (m_prevWptIndex[1])) {
m_destOrigin = graph[m_prevWptIndex[1]].origin;
else if (graph.exists (m_previousNodes[1])) {
m_destOrigin = graph[m_previousNodes[1]].origin;
}
}
@ -965,8 +965,8 @@ bool Bot::updateNavigation () {
// if bot is waiting for lift, or going to it
if (m_liftState == LiftState::WaitingFor || m_liftState == LiftState::EnteringIn) {
// bot fall down somewhere inside the lift's groove :)
if (pev->groundentity != m_liftEntity && graph.exists (m_prevWptIndex[0])) {
if ((graph[m_prevWptIndex[0]].flags & NodeFlag::Lift) && (m_path->origin.z - pev->origin.z) > 50.0f && (graph[m_prevWptIndex[0]].origin.z - pev->origin.z) > 50.0f) {
if (pev->groundentity != m_liftEntity && graph.exists (m_previousNodes[0])) {
if ((graph[m_previousNodes[0]].flags & NodeFlag::Lift) && (m_path->origin.z - pev->origin.z) > 50.0f && (graph[m_previousNodes[0]].origin.z - pev->origin.z) > 50.0f) {
m_liftState = LiftState::None;
m_liftEntity = nullptr;
m_liftUsageTime = 0.0f;
@ -974,8 +974,8 @@ bool Bot::updateNavigation () {
clearSearchNodes ();
findBestNearestNode ();
if (graph.exists (m_prevWptIndex[2])) {
findPath (m_currentNodeIndex, m_prevWptIndex[2], FindPath::Fast);
if (graph.exists (m_previousNodes[2])) {
findPath (m_currentNodeIndex, m_previousNodes[2], FindPath::Fast);
}
return false;
}
@ -1003,9 +1003,9 @@ bool Bot::updateNavigation () {
clearSearchNodes ();
if (graph.exists (m_prevWptIndex[0])) {
if (!(graph[m_prevWptIndex[0]].flags & NodeFlag::Lift)) {
changePointIndex (m_prevWptIndex[0]);
if (graph.exists (m_previousNodes[0])) {
if (!(graph[m_previousNodes[0]].flags & NodeFlag::Lift)) {
changePointIndex (m_previousNodes[0]);
}
else {
findBestNearestNode ();
@ -1078,7 +1078,7 @@ bool Bot::updateNavigation () {
}
float desiredDistance = 0.0f;
// initialize the radius for a special node type, where the wpt is considered to be reached
// initialize the radius for a special node type, where the node is considered to be reached
if (m_path->flags & NodeFlag::Lift) {
desiredDistance = 50.0f;
}
@ -1552,7 +1552,7 @@ bool Bot::findBestNearestNode () {
// skip current and recent previous nodes
for (int j = 0; j < numToSkip; ++j) {
if (at == m_prevWptIndex[j]) {
if (at == m_previousNodes[j]) {
skip = true;
break;
}
@ -1650,8 +1650,8 @@ float Bot::getReachTime () {
}
// calculate 'real' time that we need to get from one node to another
if (graph.exists (m_currentNodeIndex) && graph.exists (m_prevWptIndex[0])) {
float distance = (graph[m_prevWptIndex[0]].origin - graph[m_currentNodeIndex].origin).length ();
if (graph.exists (m_currentNodeIndex) && graph.exists (m_previousNodes[0])) {
float distance = (graph[m_previousNodes[0]].origin - graph[m_currentNodeIndex].origin).length ();
// caclulate estimated time
if (pev->maxspeed <= 0.0f) {
@ -1732,10 +1732,10 @@ int Bot::changePointIndex (int index) {
if (index == kInvalidNodeIndex) {
return 0;
}
m_prevWptIndex[4] = m_prevWptIndex[3];
m_prevWptIndex[3] = m_prevWptIndex[2];
m_prevWptIndex[2] = m_prevWptIndex[1];
m_prevWptIndex[0] = m_currentNodeIndex;
m_previousNodes[4] = m_previousNodes[3];
m_previousNodes[3] = m_previousNodes[2];
m_previousNodes[2] = m_previousNodes[1];
m_previousNodes[0] = m_currentNodeIndex;
m_currentNodeIndex = index;
m_navTimeset = game.timebase ();
@ -2105,7 +2105,7 @@ bool Bot::advanceMovement () {
Task taskID = getCurrentTaskId ();
// only if we in normal task and bomb is not planted
if (taskID == Task::Normal && bots.getRoundMidTime () + 5.0f < game.timebase () && m_timeCamping + 5.0f < game.timebase () && !bots.isBombPlanted () && m_personality != Personality::Rusher && !m_hasC4 && !m_isVIP && m_loosedBombWptIndex == kInvalidNodeIndex && !hasHostage ()) {
if (taskID == Task::Normal && bots.getRoundMidTime () + 5.0f < game.timebase () && m_timeCamping + 5.0f < game.timebase () && !bots.isBombPlanted () && m_personality != Personality::Rusher && !m_hasC4 && !m_isVIP && m_loosedBombNodeIndex == kInvalidNodeIndex && !hasHostage ()) {
m_campButtons = 0;
const int nextIndex = m_pathWalk.next ();
@ -3031,7 +3031,7 @@ bool Bot::isOccupiedPoint (int index) {
}
if (bot != nullptr) {
int occupyId = util.getShootingCone (bot->ent (), pev->origin) >= 0.7f ? bot->m_prevWptIndex[0] : bot->m_currentNodeIndex;
int occupyId = util.getShootingCone (bot->ent (), pev->origin) >= 0.7f ? bot->m_previousNodes[0] : bot->m_currentNodeIndex;
if (bot != nullptr) {
if (index == occupyId) {