From 793bbeed727965ce584bfd532d5bbb0703499a12 Mon Sep 17 00:00:00 2001 From: Jonathan Gonzalez Date: Thu, 6 Aug 2015 21:46:59 -0400 Subject: [PATCH 1/3] Change Client Path via LUA Added __PATH_BY_LUA All further commits by me will include __DRESDENJOHN defines to allow for debugging This allows the user to use config.lua in the /lua/ directory to assign the client location. --- gamed/include/VersionCommon.h | 18 ++++++++++++++++++ gamed/src/main.cpp | 22 +++++++++++++++++++++- lua/config.lua | 9 +++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 gamed/include/VersionCommon.h diff --git a/gamed/include/VersionCommon.h b/gamed/include/VersionCommon.h new file mode 100644 index 00000000..1f2f4523 --- /dev/null +++ b/gamed/include/VersionCommon.h @@ -0,0 +1,18 @@ +#ifndef __VERSION_COMMON_H__ +#define __VERSION_COMMON_H__ + +// Split up code by contributor, this allows modules to be disabled if bugs occur. + +#define __DRESDENJOHN + +// Use #ifdef/#else/#endif clauses to allow for easier debugging. + +#ifdef __DRESDENJOHN + + #define __PATH_BY_LUA // Allows end user to set path to client via config.lua + +#endif + + +#endif /* __VERSION_COMMON_H */ + diff --git a/gamed/src/main.cpp b/gamed/src/main.cpp index 2d2f22da..ed5ae029 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 __DRESDENJOHN + #include "LuaScript.h" +#endif + #define SERVER_HOST ENET_HOST_ANY #define SERVER_PORT 5119 #define SERVER_KEY "17BLOhi6KZsTtldTsizvHg==" @@ -37,7 +43,21 @@ 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 __DRESDENJOHN + #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 + #else + std::string basePath = RAFManager::getInstance()->findGameBasePath(); + #endif // __DRESDENJOHN 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", From 5379ea3914c291cec9d2e91d25a8c96fff615659 Mon Sep 17 00:00:00 2001 From: Jonathan Gonzalez Date: Fri, 7 Aug 2015 02:58:23 -0400 Subject: [PATCH 2/3] __PATH_BY_LUA Removed Self Defines --- gamed/include/VersionCommon.h | 11 +---------- gamed/src/main.cpp | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/gamed/include/VersionCommon.h b/gamed/include/VersionCommon.h index 1f2f4523..0a17c34f 100644 --- a/gamed/include/VersionCommon.h +++ b/gamed/include/VersionCommon.h @@ -1,17 +1,8 @@ #ifndef __VERSION_COMMON_H__ #define __VERSION_COMMON_H__ -// Split up code by contributor, this allows modules to be disabled if bugs occur. -#define __DRESDENJOHN - -// Use #ifdef/#else/#endif clauses to allow for easier debugging. - -#ifdef __DRESDENJOHN - - #define __PATH_BY_LUA // Allows end user to set path to client via config.lua - -#endif +#define __PATH_BY_LUA // Allows end user to set path to client via config.lua #endif /* __VERSION_COMMON_H */ diff --git a/gamed/src/main.cpp b/gamed/src/main.cpp index ed5ae029..924c2f19 100644 --- a/gamed/src/main.cpp +++ b/gamed/src/main.cpp @@ -26,9 +26,9 @@ along with this program. If not, see . #include "VersionCommon.h" -#ifdef __DRESDENJOHN +#ifdef __PATH_BY_LUA #include "LuaScript.h" -#endif +#endif // __PATH_BY_LUA #define SERVER_HOST ENET_HOST_ANY #define SERVER_PORT 5119 @@ -43,21 +43,17 @@ int main(int argc, char ** argv) Logger::instance().setLogFile("../../log.html", false, true); CORE_INFO("Loading RAF files in filearchives/."); - #ifdef __DRESDENJOHN - #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 + #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 // __DRESDENJOHN + #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/"); From b8264f99c9be0ee6974cbe97f1ba38026f6bf67d Mon Sep 17 00:00:00 2001 From: Jonathan Gonzalez Date: Sat, 8 Aug 2015 19:12:24 -0400 Subject: [PATCH 3/3] VS Compatibility Fixes (Part One) __VS_COMPILE now active in VersionCommon.h. Still compiles in CMAKE even without VS. Just standardized and cleaned up some parts for VS to compile. SOL Fixing and VS Compatibility coming next --- dep/include/sol/traits.hpp | 3 ++- gamed/include/VersionCommon.h | 2 +- gamed/src/Champion.cpp | 2 +- gamed/src/PacketHandler.cpp | 12 ++++++++++++ gamed/src/Pathfinder.cpp | 18 ++++++++++++++++++ gamed/src/Unit.cpp | 2 +- 6 files changed, 35 insertions(+), 4 deletions(-) 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 index 0a17c34f..e6cd6043 100644 --- a/gamed/include/VersionCommon.h +++ b/gamed/include/VersionCommon.h @@ -3,7 +3,7 @@ #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);