Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion dep/include/sol/traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ struct is_function_impl<T, true> {

template<class F>
struct check_deducible_signature {
struct nat;
template<class G>
static auto test(int) -> decltype(&G::operator(), void());
template<class>
static auto test(...) -> struct nat;
static auto test(...) -> nat;

using type = std::is_void<decltype(test<F>(0))>;
};
Expand Down
9 changes: 9 additions & 0 deletions gamed/include/VersionCommon.h
Original file line number Diff line number Diff line change
@@ -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 */

2 changes: 1 addition & 1 deletion gamed/src/Champion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void Champion::update(int64 diff) {
const std::map<uint32, Object*>& 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<Unit*> (it.second);
Expand Down
12 changes: 12 additions & 0 deletions gamed/src/PacketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "Packets.h"
#include "Logger.h"
#include <stdio.h>
#include "VersionCommon.h"

//#undef min // No, do NOT do this.
//#define min(a, b) ((a) < (b) ? (a) : (b))

Expand Down Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions gamed/src/Pathfinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
#include "Logger.h"
#include "Minion.h"
#include "Champion.h"
#include <time.h>
#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)

Expand All @@ -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)));
}
Expand Down Expand Up @@ -441,11 +451,19 @@ void PathJob::cleanLists()
totalDuration = std::chrono::duration_cast<std::chrono::milliseconds>(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)
Expand Down
2 changes: 1 addition & 1 deletion gamed/src/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 17 additions & 1 deletion gamed/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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=="
Expand All @@ -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<std::string>("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/");
Expand Down
9 changes: 9 additions & 0 deletions lua/config.lua
Original file line number Diff line number Diff line change
@@ -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",
Expand Down