mirror of
https://github.com/edubart/otclient.git
synced 2025-04-29 17:19:20 +02:00
Fix the use of deprecated C++ functions (#1138)
This commit is contained in:
parent
67b7dbfcfe
commit
b37623cd86
@ -72,7 +72,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
stdext::dynamic_storage<uint8> m_attribs;
|
stdext::dynamic_storage<uint8> m_attribs;
|
||||||
std::unordered_map<Position, CreatureTypePtr, PositionHasher> m_creatures;
|
std::unordered_map<Position, CreatureTypePtr, Position::Hasher> m_creatures;
|
||||||
friend class CreatureManager;
|
friend class CreatureManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<CreatureTypePtr> m_creatures;
|
std::vector<CreatureTypePtr> m_creatures;
|
||||||
std::unordered_map<Position, SpawnPtr, PositionHasher> m_spawns;
|
std::unordered_map<Position, SpawnPtr, Position::Hasher> m_spawns;
|
||||||
stdext::boolean<false> m_loaded, m_spawnLoaded;
|
stdext::boolean<false> m_loaded, m_spawnLoaded;
|
||||||
CreatureTypePtr m_nullCreature;
|
CreatureTypePtr m_nullCreature;
|
||||||
};
|
};
|
||||||
|
@ -85,9 +85,9 @@ typedef std::list<TownPtr> TownList;
|
|||||||
typedef std::list<ItemPtr> ItemList;
|
typedef std::list<ItemPtr> ItemList;
|
||||||
typedef std::list<TilePtr> TileList;
|
typedef std::list<TilePtr> TileList;
|
||||||
typedef std::vector<ItemPtr> ItemVector;
|
typedef std::vector<ItemPtr> ItemVector;
|
||||||
typedef std::unordered_map<Position, TilePtr, PositionHasher> TileMap;
|
typedef std::unordered_map<Position, TilePtr, Position::Hasher> TileMap;
|
||||||
typedef std::unordered_map<Position, CreatureTypePtr, PositionHasher> CreatureMap;
|
typedef std::unordered_map<Position, CreatureTypePtr, Position::Hasher> CreatureMap;
|
||||||
typedef std::unordered_map<Position, SpawnPtr, PositionHasher> SpawnMap;
|
typedef std::unordered_map<Position, SpawnPtr, Position::Hasher> SpawnMap;
|
||||||
|
|
||||||
// net
|
// net
|
||||||
class ProtocolLogin;
|
class ProtocolLogin;
|
||||||
|
@ -718,18 +718,20 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
|
|||||||
// as described in http://en.wikipedia.org/wiki/A*_search_algorithm
|
// as described in http://en.wikipedia.org/wiki/A*_search_algorithm
|
||||||
|
|
||||||
struct Node {
|
struct Node {
|
||||||
|
using Pair = std::pair<Node *, float>;
|
||||||
|
|
||||||
Node(const Position& pos) : cost(0), totalCost(0), pos(pos), prev(nullptr), dir(Otc::InvalidDirection) { }
|
Node(const Position& pos) : cost(0), totalCost(0), pos(pos), prev(nullptr), dir(Otc::InvalidDirection) { }
|
||||||
float cost;
|
float cost;
|
||||||
float totalCost;
|
float totalCost;
|
||||||
Position pos;
|
Position pos;
|
||||||
Node *prev;
|
Node *prev;
|
||||||
Otc::Direction dir;
|
Otc::Direction dir;
|
||||||
};
|
|
||||||
|
|
||||||
struct LessNode : std::binary_function<std::pair<Node*, float>, std::pair<Node*, float>, bool> {
|
struct Compare {
|
||||||
bool operator()(std::pair<Node*, float> a, std::pair<Node*, float> b) const {
|
bool operator() (const Pair &a, const Pair &b) const {
|
||||||
return b.second < a.second;
|
return b.second < a.second;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> ret;
|
std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> ret;
|
||||||
@ -762,8 +764,8 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<Position, Node*, PositionHasher> nodes;
|
std::unordered_map<Position, Node*, Position::Hasher> nodes;
|
||||||
std::priority_queue<std::pair<Node*, float>, std::deque<std::pair<Node*, float>>, LessNode> searchList;
|
std::priority_queue<Node::Pair, std::deque<Node::Pair>, Node::Compare> searchList;
|
||||||
|
|
||||||
Node *currentNode = new Node(startPos);
|
Node *currentNode = new Node(startPos);
|
||||||
currentNode->pos = startPos;
|
currentNode->pos = startPos;
|
||||||
@ -856,7 +858,7 @@ std::tuple<std::vector<Otc::Direction>, Otc::PathFindResult> Map::findPath(const
|
|||||||
neighborNode->cost = cost;
|
neighborNode->cost = cost;
|
||||||
neighborNode->totalCost = neighborNode->cost + neighborPos.distance(goalPos);
|
neighborNode->totalCost = neighborNode->cost + neighborPos.distance(goalPos);
|
||||||
neighborNode->dir = walkDir;
|
neighborNode->dir = walkDir;
|
||||||
searchList.push(std::make_pair(neighborNode, neighborNode->totalCost));
|
searchList.emplace(neighborNode, neighborNode->totalCost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ private:
|
|||||||
std::vector<AnimatedTextPtr> m_animatedTexts;
|
std::vector<AnimatedTextPtr> m_animatedTexts;
|
||||||
std::vector<StaticTextPtr> m_staticTexts;
|
std::vector<StaticTextPtr> m_staticTexts;
|
||||||
std::vector<MapViewPtr> m_mapViews;
|
std::vector<MapViewPtr> m_mapViews;
|
||||||
std::unordered_map<Position, std::string, PositionHasher> m_waypoints;
|
std::unordered_map<Position, std::string, Position::Hasher> m_waypoints;
|
||||||
|
|
||||||
uint8 m_animationFlags;
|
uint8 m_animationFlags;
|
||||||
uint32 m_zoneFlags;
|
uint32 m_zoneFlags;
|
||||||
|
@ -243,12 +243,14 @@ public:
|
|||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
short z;
|
short z;
|
||||||
};
|
|
||||||
|
|
||||||
struct PositionHasher : std::unary_function<Position, std::size_t> {
|
// NOTE: This does not increase the size of the struct.
|
||||||
std::size_t operator()(const Position& pos) const {
|
struct Hasher
|
||||||
return (((pos.x * 8192) + pos.y) * 16) + pos.z;
|
{
|
||||||
}
|
std::size_t operator() (const Position& pos) const {
|
||||||
|
return (((pos.x * 8192) + pos.y) * 16) + pos.z;
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::ostream& operator<<(std::ostream& out, const Position& pos)
|
inline std::ostream& operator<<(std::ostream& out, const Position& pos)
|
||||||
|
@ -43,7 +43,7 @@ private:
|
|||||||
std::deque<EventPtr> m_eventList;
|
std::deque<EventPtr> m_eventList;
|
||||||
int m_pollEventsSize;
|
int m_pollEventsSize;
|
||||||
stdext::boolean<false> m_disabled;
|
stdext::boolean<false> m_disabled;
|
||||||
std::priority_queue<ScheduledEventPtr, std::deque<ScheduledEventPtr>, lessScheduledEvent> m_scheduledEventList;
|
std::priority_queue<ScheduledEventPtr, std::deque<ScheduledEventPtr>, ScheduledEvent::Compare> m_scheduledEventList;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EventDispatcher g_dispatcher;
|
extern EventDispatcher g_dispatcher;
|
||||||
|
@ -40,6 +40,12 @@ public:
|
|||||||
int cyclesExecuted() { return m_cyclesExecuted; }
|
int cyclesExecuted() { return m_cyclesExecuted; }
|
||||||
int maxCycles() { return m_maxCycles; }
|
int maxCycles() { return m_maxCycles; }
|
||||||
|
|
||||||
|
struct Compare {
|
||||||
|
bool operator() (const ScheduledEventPtr &a, const ScheduledEventPtr &b) const {
|
||||||
|
return b->ticks() < a->ticks();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ticks_t m_ticks;
|
ticks_t m_ticks;
|
||||||
int m_delay;
|
int m_delay;
|
||||||
@ -47,10 +53,4 @@ private:
|
|||||||
int m_cyclesExecuted;
|
int m_cyclesExecuted;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lessScheduledEvent : std::binary_function<ScheduledEventPtr, ScheduledEventPtr&, bool> {
|
|
||||||
bool operator()(const ScheduledEventPtr& a, const ScheduledEventPtr& b) {
|
|
||||||
return b->ticks() < a->ticks();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user