Minor fixes.

This commit is contained in:
jeefo 2019-08-12 22:51:26 +03:00
commit 858d247893
10 changed files with 37 additions and 57 deletions

View file

@ -170,13 +170,8 @@ public:
return m_weapons.begin (); 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 // get's the weapons prop
const WeaponProp &getWeaponProp (int id) const { WeaponProp &getWeaponProp (int id) {
return m_weaponProps[id]; return m_weaponProps[id];
} }

View file

@ -180,11 +180,11 @@ public:
public: public:
int32 &next () { int32 &next () {
return at (m_cursor + 1); return at (1);
} }
int32 &first () { int32 &first () {
return at (m_cursor); return at (0);
} }
int32 &last () { int32 &last () {
@ -192,7 +192,7 @@ public:
} }
int32 &at (size_t index) { int32 &at (size_t index) {
return m_storage.at (index); return m_storage.at (m_cursor + index);
} }
void shift () { void shift () {
@ -210,10 +210,6 @@ public:
return m_storage.length () - m_cursor; return m_storage.length () - m_cursor;
} }
size_t cursor () const {
return m_cursor;
}
bool hasNext () const { bool hasNext () const {
return m_cursor < m_storage.length (); return m_cursor < m_storage.length ();
} }

View file

@ -87,8 +87,6 @@ private:
Dictionary <String, int32> m_teamInfoCache; // cache for teaminfo message Dictionary <String, int32> m_teamInfoCache; // cache for teaminfo message
private: private:
bool m_broadcast; // message for all players
Bot *m_bot; // owner of a message Bot *m_bot; // owner of a message
NetMsg m_current; // ongoing message id NetMsg m_current; // ongoing message id
@ -124,7 +122,7 @@ public:
public: public:
void registerMessage (const String &name, int32 id); 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 (); void stop ();
public: public:
@ -147,7 +145,6 @@ private:
void reset () { void reset () {
m_current = NetMsg::None; m_current = NetMsg::None;
m_bot = nullptr; m_bot = nullptr;
m_broadcast = false;
} }
}; };

View file

@ -494,25 +494,23 @@ struct WeaponInfo {
bool primaryFireHold; // hold down primary fire button to use? bool primaryFireHold; // hold down primary fire button to use?
public: public:
WeaponInfo (int id, const char *name, const char *model, int price, int minPriAmmo, int teamStd, WeaponInfo (int id,
int teamAs, int buyGroup, int buySelect, int buySelectT, int buySelectCT, int penetratePower, const char *name,
int maxClip, bool fireHold) { const char *model,
int price,
this->id = id; int minPriAmmo,
this->name = name; int teamStd,
this->model = model; int teamAs,
this->price = price; int buyGroup,
this->minPrimaryAmmo = minPriAmmo; int buySelect,
this->teamStandard = teamStd; int buySelectT,
this->teamAS = teamAs; int buySelectCT,
this->buyGroup = buyGroup; int penetratePower,
this->buySelect = buySelect; int maxClip,
this->buySelectCT = buySelectCT; bool fireHold) : id (id), name (name), model (model), price (price), minPrimaryAmmo (minPriAmmo), teamStandard (teamStd),
this->buySelectT = buySelectT; teamAS (teamAs), buyGroup (buyGroup), buySelect (buySelect), buySelectT (buySelectT), buySelectCT (buySelectCT),
this->penetratePower = penetratePower; penetratePower (penetratePower), maxClip (maxClip), primaryFireHold (fireHold)
this->maxClip = maxClip; { }
this->primaryFireHold = fireHold;
}
}; };
// array of clients struct // array of clients struct

View file

@ -644,7 +644,7 @@ void Bot::updatePickups () {
m_defendedBomb = true; m_defendedBomb = true;
int index = findDefendNode (origin); int index = findDefendNode (origin);
Path &path = graph[index]; const Path &path = graph[index];
float bombTimer = mp_c4timer.float_ (); float bombTimer = mp_c4timer.float_ ();
float timeMidBlowup = bots.getTimeBombPlanted () + (bombTimer * 0.5f + bombTimer * 0.25f) - graph.calculateTravelTime (pev->maxspeed, pev->origin, path.origin); 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; m_defendedBomb = true;
int index = findDefendNode (origin); 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); 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; float minDistance = kInfiniteDistance;
int lookAtWaypoint = kInvalidNodeIndex; int lookAtWaypoint = kInvalidNodeIndex;
Path &path = graph[tempIndex]; const Path &path = graph[tempIndex];
for (auto &link : path.links) { for (auto &link : path.links) {
if (link.index == kInvalidNodeIndex) { if (link.index == kInvalidNodeIndex) {
@ -2472,7 +2472,7 @@ void Bot::checkRadioQueue () {
switch (getCurrentTaskId ()) { switch (getCurrentTaskId ()) {
case Task::Normal: case Task::Normal:
if (getTask ()->data != kInvalidNodeIndex && rg.chance (70)) { if (getTask ()->data != kInvalidNodeIndex && rg.chance (70)) {
Path &path = graph[getTask ()->data]; const Path &path = graph[getTask ()->data];
if (path.flags & NodeFlag::Goal) { if (path.flags & NodeFlag::Goal) {
if (game.mapIs (MapFlags::Demolition) && m_team == Team::Terrorist && m_hasC4) { 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); 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 // 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); 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);
} }
} }

View file

@ -1169,7 +1169,7 @@ int BotControl::menuGraphPage2 (int item) {
int noHostagePoints = 0; int noHostagePoints = 0;
for (int i = 0; i < graph.length (); ++i) { for (int i = 0; i < graph.length (); ++i) {
Path &path = graph[i]; const Path &path = graph[i];
if (path.flags & NodeFlag::TerroristOnly) { if (path.flags & NodeFlag::TerroristOnly) {
++terrPoints; ++terrPoints;

View file

@ -1604,7 +1604,7 @@ bool BotGraph::loadGraphData () {
addToBucket (path.origin, path.number); 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"); m_tempStrings.assign ("Using Official Graph File");
} }
else { else {

View file

@ -612,7 +612,7 @@ CR_EXPORT int GetEngineFunctions (enginefuncs_t *functionTable, int *) {
functionTable->pfnMessageBegin = [] (int msgDest, int msgType, const float *origin, edict_t *ed) { functionTable->pfnMessageBegin = [] (int msgDest, int msgType, const float *origin, edict_t *ed) {
// this function called each time a message is about to sent. // 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)) { if (game.is (GameFlags::Metamod)) {
RETURN_META (MRES_IGNORED); RETURN_META (MRES_IGNORED);

View file

@ -128,8 +128,8 @@ void MessageDispatcher::netMsgWeaponList () {
return; return;
} }
// register prop // store away this weapon with it's ammo information...
WeaponProp prop { conf.getWeaponProp (m_args[id].long_) = {
m_args[classname].chars_, m_args[classname].chars_,
m_args[ammo_index_1].long_, m_args[ammo_index_1].long_,
m_args[max_ammo_1].long_, m_args[max_ammo_1].long_,
@ -138,7 +138,6 @@ void MessageDispatcher::netMsgWeaponList () {
m_args[id].long_, m_args[id].long_,
m_args[flags].long_ m_args[flags].long_
}; };
conf.setWeaponProp (cr::move (prop)); // store away this weapon with it's ammo information...
} }
void MessageDispatcher::netMsgCurWeapon () { 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 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 (); reset ();
// search if we need to handle this message // search if we need to handle this message
@ -470,13 +469,8 @@ void MessageDispatcher::start (edict_t *ent, int32 dest, int32 type) {
return; return;
} }
// broadcast message ?
if (dest == MSG_ALL || dest == MSG_SPEC || dest == MSG_BROADCAST) {
m_broadcast = true;
}
// message for bot bot? // 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]; m_bot = bots[ent];
if (!m_bot) { if (!m_bot) {

View file

@ -2196,8 +2196,8 @@ bool Bot::advanceMovement () {
if (m_pathWalk.hasNext ()) { if (m_pathWalk.hasNext ()) {
auto nextIndex = m_pathWalk.next (); auto nextIndex = m_pathWalk.next ();
Path &path = graph[destIndex]; const Path &path = graph[destIndex];
Path &next = graph[nextIndex]; const Path &next = graph[nextIndex];
for (const auto &link : path.links) { for (const auto &link : path.links) {
if (link.index == nextIndex && (link.flags & PathFlag::Jump)) { if (link.index == nextIndex && (link.flags & PathFlag::Jump)) {
@ -2804,7 +2804,7 @@ int Bot::findCampingDirection () {
if (currentNode == i || !graph.isVisible (currentNode, i)) { if (currentNode == i || !graph.isVisible (currentNode, i)) {
continue; continue;
} }
Path &path = graph[i]; const Path &path = graph[i];
if (count < 3) { if (count < 3) {
indices[count] = i; indices[count] = i;