mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-27 21:22:28 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9dd4002337 | |||
| ccdebf0116 | |||
| 1a4aa1692a |
+2
-7
@@ -259,7 +259,6 @@ ENDIF(EQEMU_ENABLE_BOTS)
|
||||
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
|
||||
OPTION(EQEMU_BUILD_LOGIN "Build the login server." OFF)
|
||||
OPTION(EQEMU_BUILD_HC "Build the headless client." OFF)
|
||||
OPTION(EQEMU_BUILD_LP "Build the login lookup proxy." OFF)
|
||||
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
||||
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
||||
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
|
||||
@@ -361,10 +360,10 @@ INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/libs/format")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/libs/recast/detour/include")
|
||||
INCLUDE_DIRECTORIES(SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/libs/recast/recast/include")
|
||||
|
||||
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC OR EQEMU_BUILD_LP)
|
||||
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
||||
ADD_SUBDIRECTORY(common)
|
||||
ADD_SUBDIRECTORY(libs)
|
||||
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC OR EQEMU_BUILD_LP)
|
||||
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS OR EQEMU_BUILD_HC)
|
||||
IF(EQEMU_BUILD_SERVER)
|
||||
ADD_SUBDIRECTORY(shared_memory)
|
||||
ADD_SUBDIRECTORY(world)
|
||||
@@ -381,10 +380,6 @@ IF(EQEMU_BUILD_HC)
|
||||
ADD_SUBDIRECTORY(hc)
|
||||
ENDIF(EQEMU_BUILD_HC)
|
||||
|
||||
IF(EQEMU_BUILD_LP)
|
||||
ADD_SUBDIRECTORY(lp)
|
||||
ENDIF(EQEMU_BUILD_LP)
|
||||
|
||||
IF(EQEMU_BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ENDIF(EQEMU_BUILD_TESTS)
|
||||
|
||||
@@ -151,6 +151,7 @@ RULE_BOOL(Character, UseOldBindWound, false) // Uses the original bind wound beh
|
||||
RULE_BOOL(Character, GrantHoTTOnCreate, false) // Grant Health of Target's Target leadership AA on character creation
|
||||
RULE_BOOL(Character, UseOldConSystem, false) // Grant Health of Target's Target leadership AA on character creation
|
||||
RULE_BOOL(Character, OPClientUpdateVisualDebug, false) // Shows a pulse and forward directional particle each time the client sends its position to server
|
||||
RULE_BOOL(Character, AllowCrossClassTrainers, false)
|
||||
RULE_CATEGORY_END()
|
||||
|
||||
RULE_CATEGORY(Mercs)
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
SET(lp_sources
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(hc_headers
|
||||
)
|
||||
|
||||
FIND_PACKAGE(OpenSSL REQUIRED)
|
||||
|
||||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
|
||||
|
||||
ADD_EXECUTABLE(lp ${lp_sources} ${lp_headers})
|
||||
|
||||
INSTALL(TARGETS lp RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
|
||||
|
||||
TARGET_LINK_LIBRARIES(lp ${SERVER_LIBS} ${OPENSSL_LIBRARIES})
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
-176
@@ -1,176 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <openssl/des.h>
|
||||
#include <memory>
|
||||
|
||||
#include "../common/eqemu_logsys.h"
|
||||
#include "../common/json_config.h"
|
||||
#include "../common/net/daybreak_connection.h"
|
||||
#include "../common/net/dns.h"
|
||||
#include "../common/event/event_loop.h"
|
||||
#include "../common/event/timer.h"
|
||||
|
||||
EQEmuLogSys LogSys;
|
||||
|
||||
const char* eqcrypt_block(const char *buffer_in, size_t buffer_in_sz, char* buffer_out, bool enc) {
|
||||
DES_key_schedule k;
|
||||
DES_cblock v;
|
||||
|
||||
memset(&k, 0, sizeof(DES_key_schedule));
|
||||
memset(&v, 0, sizeof(DES_cblock));
|
||||
|
||||
if (!enc && buffer_in_sz && buffer_in_sz % 8 != 0) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DES_ncbc_encrypt((const unsigned char*)buffer_in, (unsigned char*)buffer_out, (long)buffer_in_sz, &k, &v, enc);
|
||||
return buffer_out;
|
||||
}
|
||||
|
||||
bool connected = false;
|
||||
bool running = true;
|
||||
std::unique_ptr<EQ::Net::DaybreakConnectionManager> m_login_connection_manager;
|
||||
std::shared_ptr<EQ::Net::DaybreakConnection> m_login_connection;
|
||||
std::string m_user;
|
||||
std::string m_pass;
|
||||
|
||||
void LoginSendSessionReady()
|
||||
{
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.PutUInt16(0, 1); //OP_SessionReady
|
||||
p.PutUInt32(2, 2);
|
||||
|
||||
m_login_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void LoginSendLogin()
|
||||
{
|
||||
size_t buffer_len = m_user.length() + m_pass.length() + 2;
|
||||
std::unique_ptr<char[]> buffer(new char[buffer_len]);
|
||||
|
||||
strcpy(&buffer[0], m_user.c_str());
|
||||
strcpy(&buffer[m_user.length() + 1], m_pass.c_str());
|
||||
|
||||
size_t encrypted_len = buffer_len;
|
||||
|
||||
if (encrypted_len % 8 > 0) {
|
||||
encrypted_len = ((encrypted_len / 8) + 1) * 8;
|
||||
}
|
||||
|
||||
EQ::Net::DynamicPacket p;
|
||||
p.Resize(12 + encrypted_len);
|
||||
p.PutUInt16(0, 2); //OP_Login
|
||||
p.PutUInt32(2, 3);
|
||||
|
||||
eqcrypt_block(&buffer[0], buffer_len, (char*)p.Data() + 12, true);
|
||||
|
||||
m_login_connection->QueuePacket(p);
|
||||
}
|
||||
|
||||
void LoginProcessLoginResponse(const EQ::Net::Packet & p)
|
||||
{
|
||||
auto encrypt_size = p.Length() - 12;
|
||||
if (encrypt_size % 8 > 0) {
|
||||
encrypt_size = (encrypt_size / 8) * 8;
|
||||
}
|
||||
|
||||
std::unique_ptr<char[]> decrypted(new char[encrypt_size]);
|
||||
|
||||
eqcrypt_block((char*)p.Data() + 12, encrypt_size, &decrypted[0], false);
|
||||
|
||||
EQ::Net::StaticPacket sp(&decrypted[0], encrypt_size);
|
||||
auto response_error = sp.GetUInt16(1);
|
||||
|
||||
if (response_error > 101) {
|
||||
printf("Error logging in response code: %u\n", response_error);
|
||||
m_login_connection->Close();
|
||||
}
|
||||
else {
|
||||
auto m_dbid = sp.GetUInt32(8);
|
||||
|
||||
printf("Logged in successfully with dbid %u", m_dbid);
|
||||
m_login_connection->Close();
|
||||
}
|
||||
}
|
||||
|
||||
void LoginOnNewConnection(std::shared_ptr<EQ::Net::DaybreakConnection> connection)
|
||||
{
|
||||
m_login_connection = connection;
|
||||
}
|
||||
|
||||
void LoginOnStatusChange(std::shared_ptr<EQ::Net::DaybreakConnection> conn, EQ::Net::DbProtocolStatus from, EQ::Net::DbProtocolStatus to)
|
||||
{
|
||||
if (to == EQ::Net::StatusConnected) {
|
||||
connected = true;
|
||||
LoginSendSessionReady();
|
||||
}
|
||||
|
||||
if (to == EQ::Net::StatusDisconnected) {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
void LoginOnPacketRecv(std::shared_ptr<EQ::Net::DaybreakConnection> conn, const EQ::Net::Packet &p) {
|
||||
auto opcode = p.GetUInt16(0);
|
||||
switch (opcode) {
|
||||
case 0x0017: //OP_ChatMessage
|
||||
LoginSendLogin();
|
||||
break;
|
||||
case 0x0018:
|
||||
LoginProcessLoginResponse(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
LogSys.LoadLogSettingsDefaults();
|
||||
|
||||
if (argc != 3) {
|
||||
printf("Usage: lp [username] [password]\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
m_user = argv[1];
|
||||
m_pass = argv[2];
|
||||
|
||||
std::string address;
|
||||
int port;
|
||||
EQ::Timer t(5000U, false, [&](EQ::Timer *timer) {
|
||||
if (!connected) {
|
||||
printf("Connection failure.\n");
|
||||
running = false;
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
auto config = EQ::JsonConfigFile::Load("eqhost.json");
|
||||
address = config.GetVariableString("login", "address", "login.eqemulator.net");
|
||||
port = config.GetVariableInt("login", "port", 5999);
|
||||
}
|
||||
catch (std::exception) {
|
||||
printf("Unable to parse eqhost.json\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
EQ::Net::DNSLookup(address, port, false, [&](const std::string &addr) {
|
||||
if (addr.empty()) {
|
||||
printf("DNS Error for %s\n", address.c_str());
|
||||
running = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_login_connection_manager.reset(new EQ::Net::DaybreakConnectionManager());
|
||||
|
||||
m_login_connection_manager->OnNewConnection(std::bind(&LoginOnNewConnection, std::placeholders::_1));
|
||||
m_login_connection_manager->OnConnectionStateChange(std::bind(&LoginOnStatusChange, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
m_login_connection_manager->OnPacketRecv(std::bind(&LoginOnPacketRecv, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
m_login_connection_manager->Connect(addr, port);
|
||||
});
|
||||
|
||||
while (running) {
|
||||
EQ::EventLoop::Get().Process();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5750,10 +5750,10 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app)
|
||||
glm::vec3 End(target->GetX(), target->GetY(), target->GetZ() + (target->GetSize() < 6.0 ? 6 : target->GetSize()) * HEAD_POSITION);
|
||||
|
||||
bool partial = false;
|
||||
bool error = false;
|
||||
auto pathlist = zone->pathing->FindRoute(Start, End, partial, error);
|
||||
bool stuck = false;
|
||||
auto pathlist = zone->pathing->FindRoute(Start, End, partial, stuck);
|
||||
|
||||
if (pathlist.empty() || error || partial)
|
||||
if (pathlist.empty() || partial)
|
||||
{
|
||||
EQApplicationPacket outapp(OP_FindPersonReply, 0);
|
||||
QueuePacket(&outapp);
|
||||
|
||||
+15
-9
@@ -1527,9 +1527,11 @@ void Client::OPGMTraining(const EQApplicationPacket *app)
|
||||
return;
|
||||
|
||||
//you can only use your own trainer, client enforces this, but why trust it
|
||||
int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR);
|
||||
if(GetClass() != trains_class)
|
||||
return;
|
||||
if (!RuleB(Character, AllowCrossClassTrainers)) {
|
||||
int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR);
|
||||
if (GetClass() != trains_class)
|
||||
return;
|
||||
}
|
||||
|
||||
//you have to be somewhat close to a trainer to be properly using them
|
||||
if(DistanceSquared(m_Position,pTrainer->GetPosition()) > USE_NPC_RANGE2)
|
||||
@@ -1580,9 +1582,11 @@ void Client::OPGMEndTraining(const EQApplicationPacket *app)
|
||||
return;
|
||||
|
||||
//you can only use your own trainer, client enforces this, but why trust it
|
||||
int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR);
|
||||
if(GetClass() != trains_class)
|
||||
return;
|
||||
if (!RuleB(Character, AllowCrossClassTrainers)) {
|
||||
int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR);
|
||||
if (GetClass() != trains_class)
|
||||
return;
|
||||
}
|
||||
|
||||
//you have to be somewhat close to a trainer to be properly using them
|
||||
if(DistanceSquared(m_Position, pTrainer->GetPosition()) > USE_NPC_RANGE2)
|
||||
@@ -1609,9 +1613,11 @@ void Client::OPGMTrainSkill(const EQApplicationPacket *app)
|
||||
return;
|
||||
|
||||
//you can only use your own trainer, client enforces this, but why trust it
|
||||
int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR);
|
||||
if(GetClass() != trains_class)
|
||||
return;
|
||||
if (!RuleB(Character, AllowCrossClassTrainers)) {
|
||||
int trains_class = pTrainer->GetClass() - (WARRIORGM - WARRIOR);
|
||||
if (GetClass() != trains_class)
|
||||
return;
|
||||
}
|
||||
|
||||
//you have to be somewhat close to a trainer to be properly using them
|
||||
if(DistanceSquared(m_Position, pTrainer->GetPosition()) > USE_NPC_RANGE2)
|
||||
|
||||
+8
-1
@@ -445,7 +445,7 @@ Mob::Mob(const char* in_name,
|
||||
AssistAggro = false;
|
||||
npc_assist_cap = 0;
|
||||
|
||||
PathRecalcTimer.reset(new Timer(1500));
|
||||
PathRecalcTimer.reset(new Timer(500));
|
||||
PathingLoopCount = 0;
|
||||
}
|
||||
|
||||
@@ -1240,6 +1240,13 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
|
||||
|
||||
ns->spawn.flymode = 0;
|
||||
}
|
||||
|
||||
if (RuleB(Character, AllowCrossClassTrainers) && ForWho) {
|
||||
if (ns->spawn.class_ >= WARRIORGM && ns->spawn.class_ <= BERSERKERGM) {
|
||||
int trainer_class = WARRIORGM + (ForWho->GetClass() - 1);
|
||||
ns->spawn.class_ = trainer_class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Mob::CreateDespawnPacket(EQApplicationPacket* app, bool Decay)
|
||||
|
||||
@@ -1264,6 +1264,7 @@ protected:
|
||||
void CalculateNewFearpoint();
|
||||
float FindGroundZ(float new_x, float new_y, float z_offset=0.0);
|
||||
glm::vec3 UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &WaypointChange, bool &NodeReached);
|
||||
glm::vec3 HandleStuckPath(const glm::vec3 &To, const glm::vec3 &From);
|
||||
|
||||
virtual float GetSympatheticProcChances(uint16 spell_id, int16 ProcRateMod, int32 ItemProcRate = 0);
|
||||
int16 GetSympatheticSpellProcRate(uint16 spell_id);
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
IPathfinder() { }
|
||||
virtual ~IPathfinder() { }
|
||||
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error) = 0;
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck) = 0;
|
||||
virtual glm::vec3 GetRandomLocation() = 0;
|
||||
virtual void DebugCommand(Client *c, const Seperator *sep) = 0;
|
||||
|
||||
|
||||
@@ -33,16 +33,12 @@ PathfinderNavmesh::~PathfinderNavmesh()
|
||||
Clear();
|
||||
}
|
||||
|
||||
IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error)
|
||||
IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck)
|
||||
{
|
||||
partial = false;
|
||||
error = false;
|
||||
|
||||
if (!m_impl->nav_mesh) {
|
||||
error = true;
|
||||
IPath Route;
|
||||
Route.push_back(end);
|
||||
return Route;
|
||||
return IPath();
|
||||
}
|
||||
|
||||
if (!m_impl->query) {
|
||||
@@ -74,10 +70,7 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl
|
||||
m_impl->query->findNearestPoly(&dest_location[0], &ext[0], &filter, &end_ref, 0);
|
||||
|
||||
if (!start_ref || !end_ref) {
|
||||
error = true;
|
||||
IPath Route;
|
||||
Route.push_back(end);
|
||||
return Route;
|
||||
return IPath();
|
||||
}
|
||||
|
||||
int npoly = 0;
|
||||
@@ -89,6 +82,11 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl
|
||||
if (path[npoly - 1] != end_ref) {
|
||||
m_impl->query->closestPointOnPoly(path[npoly - 1], &dest_location[0], &epos[0], 0);
|
||||
partial = true;
|
||||
|
||||
auto dist = DistanceSquared(epos, current_location);
|
||||
if (dist < 10.0f) {
|
||||
stuck = true;
|
||||
}
|
||||
}
|
||||
|
||||
float straight_path[2048 * 3];
|
||||
@@ -102,10 +100,7 @@ IPathfinder::IPath PathfinderNavmesh::FindRoute(const glm::vec3 &start, const gl
|
||||
straight_path_polys, &n_straight_polys, 2048, DT_STRAIGHTPATH_AREA_CROSSINGS);
|
||||
|
||||
if (dtStatusFailed(status)) {
|
||||
error = true;
|
||||
IPath Route;
|
||||
Route.push_back(end);
|
||||
return Route;
|
||||
return IPath();
|
||||
}
|
||||
|
||||
if (n_straight_polys) {
|
||||
@@ -292,11 +287,11 @@ void PathfinderNavmesh::Load(const std::string &path)
|
||||
void PathfinderNavmesh::ShowPath(Client * c, const glm::vec3 &start, const glm::vec3 &end)
|
||||
{
|
||||
bool partial = false;
|
||||
bool error = false;
|
||||
auto path = FindRoute(start, end, partial, error);
|
||||
bool stuck = false;
|
||||
auto path = FindRoute(start, end, partial, stuck);
|
||||
std::vector<FindPerson_Point> points;
|
||||
|
||||
if (!partial && !error) {
|
||||
if (!partial) {
|
||||
FindPerson_Point p;
|
||||
for (auto &node : path)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ public:
|
||||
PathfinderNavmesh(const std::string &path);
|
||||
virtual ~PathfinderNavmesh();
|
||||
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error);
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck);
|
||||
virtual glm::vec3 GetRandomLocation();
|
||||
virtual void DebugCommand(Client *c, const Seperator *sep);
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "pathfinder_null.h"
|
||||
|
||||
IPathfinder::IPath PathfinderNull::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error)
|
||||
IPathfinder::IPath PathfinderNull::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck)
|
||||
{
|
||||
error = false;
|
||||
partial = false;
|
||||
stuck = false;
|
||||
IPath ret;
|
||||
ret.push_back(start);
|
||||
ret.push_back(end);
|
||||
|
||||
@@ -8,7 +8,7 @@ public:
|
||||
PathfinderNull() { }
|
||||
virtual ~PathfinderNull() { }
|
||||
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error);
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck);
|
||||
virtual glm::vec3 GetRandomLocation();
|
||||
virtual void DebugCommand(Client *c, const Seperator *sep) { }
|
||||
};
|
||||
@@ -114,21 +114,19 @@ PathfinderWaypoint::~PathfinderWaypoint()
|
||||
{
|
||||
}
|
||||
|
||||
IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error)
|
||||
IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck)
|
||||
{
|
||||
stuck = false;
|
||||
partial = false;
|
||||
error = false;
|
||||
std::vector<RTreeValue> result_start_n;
|
||||
m_impl->Tree.query(boost::geometry::index::nearest(Point(start.x, start.y, start.z), 1), std::back_inserter(result_start_n));
|
||||
if (result_start_n.size() == 0) {
|
||||
error = true;
|
||||
return IPath();
|
||||
}
|
||||
|
||||
std::vector<RTreeValue> result_end_n;
|
||||
m_impl->Tree.query(boost::geometry::index::nearest(Point(end.x, end.y, end.z), 1), std::back_inserter(result_end_n));
|
||||
if (result_end_n.size() == 0) {
|
||||
error = true;
|
||||
return IPath();
|
||||
}
|
||||
|
||||
@@ -183,11 +181,7 @@ IPathfinder::IPath PathfinderWaypoint::FindRoute(const glm::vec3 &start, const g
|
||||
return Route;
|
||||
}
|
||||
|
||||
error = true;
|
||||
IPath Route;
|
||||
Route.push_front(start);
|
||||
Route.push_back(glm::vec3(nearest_start.first.get<0>(), nearest_start.first.get<1>(), nearest_start.first.get<2>()));
|
||||
return Route;
|
||||
return IPath();
|
||||
}
|
||||
|
||||
glm::vec3 PathfinderWaypoint::GetRandomLocation()
|
||||
@@ -401,8 +395,8 @@ void PathfinderWaypoint::ShowNodes()
|
||||
void PathfinderWaypoint::ShowPath(Client *c, const glm::vec3 &start, const glm::vec3 &end)
|
||||
{
|
||||
bool partial = false;
|
||||
bool error = false;
|
||||
auto path = FindRoute(start, end, partial, error);
|
||||
bool stuck = false;
|
||||
auto path = FindRoute(start, end, partial, stuck);
|
||||
std::vector<FindPerson_Point> points;
|
||||
|
||||
FindPerson_Point p;
|
||||
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
PathfinderWaypoint(const std::string &path);
|
||||
virtual ~PathfinderWaypoint();
|
||||
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &error);
|
||||
virtual IPath FindRoute(const glm::vec3 &start, const glm::vec3 &end, bool &partial, bool &stuck);
|
||||
virtual glm::vec3 GetRandomLocation();
|
||||
virtual void DebugCommand(Client *c, const Seperator *sep);
|
||||
|
||||
|
||||
+33
-24
@@ -40,20 +40,18 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
|
||||
|
||||
if (Route.empty()) {
|
||||
bool partial = false;
|
||||
bool error = false;
|
||||
Route = zone->pathing->FindRoute(From, To, partial, error);
|
||||
bool stuck = false;
|
||||
Route = zone->pathing->FindRoute(From, To, partial, stuck);
|
||||
AdjustRoute(Route, flymode, GetModelOffset());
|
||||
|
||||
PathingDestination = To;
|
||||
WaypointChanged = true;
|
||||
NodeReached = false;
|
||||
if (partial && Route.size() <= 2) {
|
||||
//We are stuck
|
||||
Route.clear();
|
||||
Teleport(To);
|
||||
return To;
|
||||
if (stuck) {
|
||||
return HandleStuckPath(To, From);
|
||||
}
|
||||
else if (error || Route.empty()) {
|
||||
|
||||
if (Route.empty()) {
|
||||
return To;
|
||||
}
|
||||
else {
|
||||
@@ -66,19 +64,19 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
|
||||
if (!SameDestination) {
|
||||
//We had a route but our target position moved too much
|
||||
bool partial = false;
|
||||
bool error = false;
|
||||
Route = zone->pathing->FindRoute(From, To, partial, error);
|
||||
bool stuck = false;
|
||||
Route = zone->pathing->FindRoute(From, To, partial, stuck);
|
||||
AdjustRoute(Route, flymode, GetModelOffset());
|
||||
|
||||
PathingDestination = To;
|
||||
WaypointChanged = true;
|
||||
NodeReached = false;
|
||||
|
||||
if (partial && Route.size() <= 2) {
|
||||
Route.clear();
|
||||
Teleport(To);
|
||||
return To;
|
||||
} else if (error || Route.empty()) {
|
||||
if (stuck) {
|
||||
return HandleStuckPath(To, From);
|
||||
}
|
||||
|
||||
if (Route.empty()) {
|
||||
return To;
|
||||
}
|
||||
else {
|
||||
@@ -133,19 +131,17 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
|
||||
|
||||
if (Route.empty()) {
|
||||
bool partial = false;
|
||||
bool error = false;
|
||||
Route = zone->pathing->FindRoute(From, To, partial, error);
|
||||
bool stuck = false;
|
||||
Route = zone->pathing->FindRoute(From, To, partial, stuck);
|
||||
AdjustRoute(Route, flymode, GetModelOffset());
|
||||
PathingDestination = To;
|
||||
WaypointChanged = true;
|
||||
|
||||
if (partial && Route.size() <= 2) {
|
||||
//We are stuck
|
||||
Route.clear();
|
||||
Teleport(To);
|
||||
return To;
|
||||
}
|
||||
else if (error || Route.empty()) {
|
||||
if (stuck) {
|
||||
return HandleStuckPath(To, From);
|
||||
}
|
||||
|
||||
if(Route.empty()) {
|
||||
return To;
|
||||
}
|
||||
else {
|
||||
@@ -187,6 +183,19 @@ glm::vec3 Mob::UpdatePath(float ToX, float ToY, float ToZ, float Speed, bool &Wa
|
||||
return To;
|
||||
}
|
||||
|
||||
glm::vec3 Mob::HandleStuckPath(const glm::vec3 &To, const glm::vec3 &From)
|
||||
{
|
||||
bool partial = false;
|
||||
bool stuck = false;
|
||||
auto r = zone->pathing->FindRoute(To, From, partial, stuck);
|
||||
Route.clear();
|
||||
|
||||
auto final_node = r.back();
|
||||
Route.push_back(final_node);
|
||||
AdjustRoute(Route, flymode, GetModelOffset());
|
||||
return (*Route.begin()).pos;
|
||||
}
|
||||
|
||||
void CullPoints(std::vector<FindPerson_Point> &points) {
|
||||
if (!zone->HasMap()) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user