diff --git a/dep/include/sol/traits.hpp b/dep/include/sol/traits.hpp index ff5056b7..dfc54bd9 100644 --- a/dep/include/sol/traits.hpp +++ b/dep/include/sol/traits.hpp @@ -146,10 +146,11 @@ struct is_function_impl { template struct check_deducible_signature { + struct nat; template static auto test(int) -> decltype(&G::operator(), void()); template - static auto test(...) -> struct nat; + static auto test(...) -> nat; using type = std::is_void(0))>; }; diff --git a/gamed/include/VersionCommon.h b/gamed/include/VersionCommon.h new file mode 100644 index 00000000..e6cd6043 --- /dev/null +++ b/gamed/include/VersionCommon.h @@ -0,0 +1,9 @@ +#ifndef __VERSION_COMMON_H__ +#define __VERSION_COMMON_H__ + + +#define __PATH_BY_LUA // Allows end user to set path to client via config.lua +#define __VS_COMPILE // Allows Compiling in VS2015 + +#endif /* __VERSION_COMMON_H */ + diff --git a/gamed/src/Champion.cpp b/gamed/src/Champion.cpp index 3faec0c4..f3cadf5f 100644 --- a/gamed/src/Champion.cpp +++ b/gamed/src/Champion.cpp @@ -130,7 +130,7 @@ void Champion::update(int64 diff) { const std::map& objects = map->getObjects(); float distanceToTarget = 9000000.f; Unit* nextTarget = 0; - float range = std::max(stats->getRange(), DETECT_RANGE); + float range = max(stats->getRange(), DETECT_RANGE); for (auto& it : objects) { Unit* u = dynamic_cast (it.second); diff --git a/gamed/src/PacketHandler.cpp b/gamed/src/PacketHandler.cpp index aa69f3e7..d10ff6ed 100644 --- a/gamed/src/PacketHandler.cpp +++ b/gamed/src/PacketHandler.cpp @@ -19,6 +19,8 @@ along with this program. If not, see . #include "Packets.h" #include "Logger.h" #include +#include "VersionCommon.h" + //#undef min // No, do NOT do this. //#define min(a, b) ((a) < (b) ? (a) : (b)) @@ -181,11 +183,21 @@ bool Game::broadcastPacketVision(Object* o, const Packet& packet, uint8 channelN bool Game::broadcastPacketVision(Object* o, const uint8 *data, uint32 length, uint8 channelNo, uint32 flag) { +#ifdef __VS_COMPILE + if (o->isVisibleByTeam(0)) { + broadcastPacketTeam(TEAM_BLUE, data, length, channelNo, flag); + } + else { + broadcastPacketTeam(TEAM_PURPLE, data, length, channelNo, flag); + } + return true; +#else for(int i = 0; i < 2; ++i) { if(o->isVisibleByTeam(i)) { broadcastPacketTeam((i == 0) ? TEAM_BLUE : TEAM_PURPLE, data, length, channelNo, flag); } } +#endif // __VS_COMPILE } bool Game::handlePacket(ENetPeer *peer, ENetPacket *packet, uint8 channelID) diff --git a/gamed/src/Pathfinder.cpp b/gamed/src/Pathfinder.cpp index 3cded997..297b9a18 100644 --- a/gamed/src/Pathfinder.cpp +++ b/gamed/src/Pathfinder.cpp @@ -10,9 +10,15 @@ #include "Logger.h" #include "Minion.h" #include "Champion.h" +#include +#include "VersionCommon.h" Map * Pathfinder::chart = 0; +#ifdef __VS_COMPILE +auto g_Clock = clock(); +#else auto g_Clock = std::clock(); +#endif // __VS_COMPILES #define debugOutput() false //((std::clock() - g_Clock) > 4000) @@ -27,7 +33,11 @@ Path Pathfinder::getPath(Vector2 from, Vector2 to, float boxSize) Path path; PathJob job; +#ifdef __VS_COMPILE + if ((clock() - g_Clock) > 4000 && (successes + oot + empties) > 0) +#else if ((std::clock() - g_Clock) > 4000 && (successes + oot + empties) > 0) +#endif { CORE_INFO("Pathfinding successrate: %f", (((float)successes / (float)(successes + oot + empties))*(100.0f))); } @@ -441,11 +451,19 @@ void PathJob::cleanLists() totalDuration = std::chrono::duration_cast(end_time - start_time).count(); durations++; +#ifdef __VS_COMPILE + if ((clock() - g_Clock) > 4000) + { + CORE_INFO("%f milliseconds, %d paths.", (float)totalDuration / (float)durations, durations); + g_Clock = clock(); + } +#else if ((std::clock() - g_Clock) > 4000) { CORE_INFO("%f milliseconds, %d paths.", (float)totalDuration/(float)durations, durations); g_Clock = std::clock(); } +#endif // __VS_COMPILE } void Pathfinder::setMap(Map * map) diff --git a/gamed/src/Unit.cpp b/gamed/src/Unit.cpp index 0448513f..a1dbad3b 100644 --- a/gamed/src/Unit.cpp +++ b/gamed/src/Unit.cpp @@ -159,7 +159,7 @@ void Unit::dealDamageTo(Unit* target, float damage, DamageType type, DamageSourc //Damage dealing. (based on leagueoflegends' wikia) damage = defense >= 0 ? (100 / (100 + defense)) * damage : (2 - (100 / (100 - defense))) * damage; - target->getStats().setCurrentHealth(std::max(0.f, target->getStats().getCurrentHealth() - damage)); + target->getStats().setCurrentHealth(max(0.f, target->getStats().getCurrentHealth() - damage)); if (!target->deathFlag && target->getStats().getCurrentHealth() <= 0) { target->deathFlag = true; target->die(this); diff --git a/gamed/src/main.cpp b/gamed/src/main.cpp index 2d2f22da..924c2f19 100644 --- a/gamed/src/main.cpp +++ b/gamed/src/main.cpp @@ -24,6 +24,12 @@ along with this program. If not, see . #include "Logger.h" #include "Pathfinder.h" +#include "VersionCommon.h" + +#ifdef __PATH_BY_LUA + #include "LuaScript.h" +#endif // __PATH_BY_LUA + #define SERVER_HOST ENET_HOST_ANY #define SERVER_PORT 5119 #define SERVER_KEY "17BLOhi6KZsTtldTsizvHg==" @@ -37,7 +43,17 @@ int main(int argc, char ** argv) Logger::instance().setLogFile("../../log.html", false, true); CORE_INFO("Loading RAF files in filearchives/."); - std::string basePath = RAFManager::getInstance()->findGameBasePath(); + #ifdef __PATH_BY_LUA + LuaScript script(false); + script.loadScript("../../lua/config.lua"); + + sol::table pathList = script.getTable("paths"); + std::string basePath = pathList.get("client"); + std::replace(basePath.begin(), basePath.end(), '\\', '/'); + CORE_INFO(basePath); + #else + std::string basePath = RAFManager::getInstance()->findGameBasePath(); + #endif // __PATH_BY_LUA if(!RAFManager::getInstance()->init(basePath + "filearchives")) { CORE_ERROR("Couldn't load RAF files. Make sure you have a 'filearchives' directory in the server's root directory. This directory is to be taken from RADS/projects/lol_game_client/"); diff --git a/lua/config.lua b/lua/config.lua index ad961d86..67c9fb32 100644 --- a/lua/config.lua +++ b/lua/config.lua @@ -1,3 +1,12 @@ +paths = { +--[[ +Path to your 4.20 compatible client folder +Must point to the lol_game_client folder (and please use TWO \\) +Example: C:\\LOL420\\RADS\\projects\\lol_game_client\\ +--]] + ['client'] = "C:\\Users\\John\\Downloads\\LOLPBE\\LOLPBE\\RADS\\projects\\lol_game_client\\" +} + players = { ["player1"] = { ["rank"] = "DIAMOND",