From 858d24789359b396ed7bf3d47547ed8f72ee2db3 Mon Sep 17 00:00:00 2001 From: jeefo Date: Mon, 12 Aug 2019 22:51:26 +0300 Subject: [PATCH] Minor fixes. --- include/config.h | 7 +------ include/graph.h | 10 +++------- include/message.h | 5 +---- include/yapb.h | 36 +++++++++++++++++------------------- source/basecode.cpp | 10 +++++----- source/control.cpp | 2 +- source/graph.cpp | 2 +- source/interface.cpp | 2 +- source/message.cpp | 14 ++++---------- source/navigate.cpp | 6 +++--- 10 files changed, 37 insertions(+), 57 deletions(-) diff --git a/include/config.h b/include/config.h index 1682069..2faff1b 100644 --- a/include/config.h +++ b/include/config.h @@ -170,13 +170,8 @@ public: return m_weapons.begin (); } - // set's the weapon properties - void setWeaponProp (WeaponProp prop) { - m_weaponProps[prop.id] = cr::move (prop); - } - // get's the weapons prop - const WeaponProp &getWeaponProp (int id) const { + WeaponProp &getWeaponProp (int id) { return m_weaponProps[id]; } diff --git a/include/graph.h b/include/graph.h index 75ca83c..8085986 100644 --- a/include/graph.h +++ b/include/graph.h @@ -180,11 +180,11 @@ public: public: int32 &next () { - return at (m_cursor + 1); + return at (1); } int32 &first () { - return at (m_cursor); + return at (0); } int32 &last () { @@ -192,7 +192,7 @@ public: } int32 &at (size_t index) { - return m_storage.at (index); + return m_storage.at (m_cursor + index); } void shift () { @@ -210,10 +210,6 @@ public: return m_storage.length () - m_cursor; } - size_t cursor () const { - return m_cursor; - } - bool hasNext () const { return m_cursor < m_storage.length (); } diff --git a/include/message.h b/include/message.h index d5c65e9..a23571e 100644 --- a/include/message.h +++ b/include/message.h @@ -87,8 +87,6 @@ private: Dictionary m_teamInfoCache; // cache for teaminfo message private: - bool m_broadcast; // message for all players - Bot *m_bot; // owner of a message NetMsg m_current; // ongoing message id @@ -124,7 +122,7 @@ public: public: void registerMessage (const String &name, int32 id); - void start (edict_t *ent, int32 dest, int32 type); + void start (edict_t *ent, int32 type); void stop (); public: @@ -147,7 +145,6 @@ private: void reset () { m_current = NetMsg::None; m_bot = nullptr; - m_broadcast = false; } }; diff --git a/include/yapb.h b/include/yapb.h index ff4e80a..60542c5 100644 --- a/include/yapb.h +++ b/include/yapb.h @@ -494,25 +494,23 @@ struct WeaponInfo { bool primaryFireHold; // hold down primary fire button to use? public: - WeaponInfo (int id, const char *name, const char *model, int price, int minPriAmmo, int teamStd, - int teamAs, int buyGroup, int buySelect, int buySelectT, int buySelectCT, int penetratePower, - int maxClip, bool fireHold) { - - this->id = id; - this->name = name; - this->model = model; - this->price = price; - this->minPrimaryAmmo = minPriAmmo; - this->teamStandard = teamStd; - this->teamAS = teamAs; - this->buyGroup = buyGroup; - this->buySelect = buySelect; - this->buySelectCT = buySelectCT; - this->buySelectT = buySelectT; - this->penetratePower = penetratePower; - this->maxClip = maxClip; - this->primaryFireHold = fireHold; - } + WeaponInfo (int id, + const char *name, + const char *model, + int price, + int minPriAmmo, + int teamStd, + int teamAs, + int buyGroup, + int buySelect, + int buySelectT, + int buySelectCT, + int penetratePower, + int maxClip, + bool fireHold) : id (id), name (name), model (model), price (price), minPrimaryAmmo (minPriAmmo), teamStandard (teamStd), + teamAS (teamAs), buyGroup (buyGroup), buySelect (buySelect), buySelectT (buySelectT), buySelectCT (buySelectCT), + penetratePower (penetratePower), maxClip (maxClip), primaryFireHold (fireHold) + { } }; // array of clients struct diff --git a/source/basecode.cpp b/source/basecode.cpp index e53aa93..bf6b655 100644 --- a/source/basecode.cpp +++ b/source/basecode.cpp @@ -644,7 +644,7 @@ void Bot::updatePickups () { m_defendedBomb = true; int index = findDefendNode (origin); - Path &path = graph[index]; + const Path &path = graph[index]; float bombTimer = mp_c4timer.float_ (); float timeMidBlowup = bots.getTimeBombPlanted () + (bombTimer * 0.5f + bombTimer * 0.25f) - graph.calculateTravelTime (pev->maxspeed, pev->origin, path.origin); @@ -717,7 +717,7 @@ void Bot::updatePickups () { m_defendedBomb = true; int index = findDefendNode (origin); - Path &path = graph[index]; + const Path &path = graph[index]; float timeToExplode = bots.getTimeBombPlanted () + mp_c4timer.float_ () - graph.calculateTravelTime (pev->maxspeed, pev->origin, path.origin); @@ -824,7 +824,7 @@ void Bot::getCampDirection (Vector *dest) { float minDistance = kInfiniteDistance; int lookAtWaypoint = kInvalidNodeIndex; - Path &path = graph[tempIndex]; + const Path &path = graph[tempIndex]; for (auto &link : path.links) { if (link.index == kInvalidNodeIndex) { @@ -2472,7 +2472,7 @@ void Bot::checkRadioQueue () { switch (getCurrentTaskId ()) { case Task::Normal: if (getTask ()->data != kInvalidNodeIndex && rg.chance (70)) { - Path &path = graph[getTask ()->data]; + const Path &path = graph[getTask ()->data]; if (path.flags & NodeFlag::Goal) { if (game.mapIs (MapFlags::Demolition) && m_team == Team::Terrorist && m_hasC4) { @@ -5003,7 +5003,7 @@ void Bot::showDebugOverlay () { game.drawLine (game.getLocalEntity (), getEyesPos () - Vector (0.0f, 0.0f, 32.0f), getEyesPos () + pev->v_angle.forward () * 300.0f, 10, 0, Color (255, 0, 0), 250, 5, 1, DrawLine::Arrow); // now draw line from source to destination - for (size_t i = m_pathWalk.cursor (); i < m_pathWalk.length () && i + 1 < m_pathWalk.length (); ++i) { + for (size_t i = 0; i < m_pathWalk.length () && i + 1 < m_pathWalk.length (); ++i) { game.drawLine (game.getLocalEntity (), graph[m_pathWalk.at (i)].origin, graph[m_pathWalk.at (i + 1)].origin, 15, 0, Color (255, 100, 55), 200, 5, 1, DrawLine::Arrow); } } diff --git a/source/control.cpp b/source/control.cpp index 3ecc07b..d4fe7fb 100644 --- a/source/control.cpp +++ b/source/control.cpp @@ -1169,7 +1169,7 @@ int BotControl::menuGraphPage2 (int item) { int noHostagePoints = 0; for (int i = 0; i < graph.length (); ++i) { - Path &path = graph[i]; + const Path &path = graph[i]; if (path.flags & NodeFlag::TerroristOnly) { ++terrPoints; diff --git a/source/graph.cpp b/source/graph.cpp index 1e259c3..c09335b 100644 --- a/source/graph.cpp +++ b/source/graph.cpp @@ -1604,7 +1604,7 @@ bool BotGraph::loadGraphData () { addToBucket (path.origin, path.number); } - if (outOptions & StorageOption::Official) { + if ((outOptions & StorageOption::Official) || memcmp (blob, "official", 8) == 0) { m_tempStrings.assign ("Using Official Graph File"); } else { diff --git a/source/interface.cpp b/source/interface.cpp index 788f3db..c45f1bb 100644 --- a/source/interface.cpp +++ b/source/interface.cpp @@ -612,7 +612,7 @@ CR_EXPORT int GetEngineFunctions (enginefuncs_t *functionTable, int *) { functionTable->pfnMessageBegin = [] (int msgDest, int msgType, const float *origin, edict_t *ed) { // this function called each time a message is about to sent. - msgs.start (ed, msgDest, msgType); + msgs.start (ed, msgType); if (game.is (GameFlags::Metamod)) { RETURN_META (MRES_IGNORED); diff --git a/source/message.cpp b/source/message.cpp index e92fc06..98c22ea 100644 --- a/source/message.cpp +++ b/source/message.cpp @@ -128,8 +128,8 @@ void MessageDispatcher::netMsgWeaponList () { return; } - // register prop - WeaponProp prop { + // store away this weapon with it's ammo information... + conf.getWeaponProp (m_args[id].long_) = { m_args[classname].chars_, m_args[ammo_index_1].long_, m_args[max_ammo_1].long_, @@ -138,7 +138,6 @@ void MessageDispatcher::netMsgWeaponList () { m_args[id].long_, m_args[flags].long_ }; - conf.setWeaponProp (cr::move (prop)); // store away this weapon with it's ammo information... } void MessageDispatcher::netMsgCurWeapon () { @@ -454,7 +453,7 @@ void MessageDispatcher::registerMessage (const String &name, int32 id) { m_maps[m_wanted[name]] = id; // add message from engine RegUserMsg } -void MessageDispatcher::start (edict_t *ent, int32 dest, int32 type) { +void MessageDispatcher::start (edict_t *ent, int32 type) { reset (); // search if we need to handle this message @@ -470,13 +469,8 @@ void MessageDispatcher::start (edict_t *ent, int32 dest, int32 type) { return; } - // broadcast message ? - if (dest == MSG_ALL || dest == MSG_SPEC || dest == MSG_BROADCAST) { - m_broadcast = true; - } - // message for bot bot? - if (ent && (ent->v.flags & FL_FAKECLIENT) && !(ent->v.flags & FL_DORMANT)) { + if (!game.isNullEntity (ent) && !(ent->v.flags & FL_DORMANT)) { m_bot = bots[ent]; if (!m_bot) { diff --git a/source/navigate.cpp b/source/navigate.cpp index 17f2383..caf9e40 100644 --- a/source/navigate.cpp +++ b/source/navigate.cpp @@ -2196,8 +2196,8 @@ bool Bot::advanceMovement () { if (m_pathWalk.hasNext ()) { auto nextIndex = m_pathWalk.next (); - Path &path = graph[destIndex]; - Path &next = graph[nextIndex]; + const Path &path = graph[destIndex]; + const Path &next = graph[nextIndex]; for (const auto &link : path.links) { if (link.index == nextIndex && (link.flags & PathFlag::Jump)) { @@ -2804,7 +2804,7 @@ int Bot::findCampingDirection () { if (currentNode == i || !graph.isVisible (currentNode, i)) { continue; } - Path &path = graph[i]; + const Path &path = graph[i]; if (count < 3) { indices[count] = i;