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 ();
}
// 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];
}

View file

@ -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 ();
}

View file

@ -87,8 +87,6 @@ private:
Dictionary <String, int32> 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;
}
};

View file

@ -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

View file

@ -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);
}
}

View file

@ -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;

View file

@ -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 {

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) {
// 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);

View file

@ -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) {

View file

@ -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;