From 8cef9852485db8f98d40ebdd49f510136183fc7b Mon Sep 17 00:00:00 2001 From: Ben Date: Thu, 17 Jul 2014 09:55:08 -0700 Subject: [PATCH 1/4] Making it identical to what I have So it should work on the newest league version --- CONNECT TO LAN.bat | 136 ++++++++++++++++++++++++++ bin/VC120_Debug/error.txt | 0 bin/VC120_Debug/output.txt | 0 common.h | 131 +++++++++++++------------ gamed/Client.cpp | 75 +++++++++++++++ gamed/Client.h | 52 +++------- gamed/GameSession.cpp | 68 +++++++++++++ gamed/GameSession.h | 48 +++++++++ gamed/Handlers.cpp | 166 +++++++++++++++++--------------- gamed/Log.cpp | 2 + gamed/Log.h | 37 ++++--- gamed/Map.cpp | 71 ++++++++++++++ gamed/Map.h | 39 ++++++++ gamed/NetworkListener.cpp | 12 +++ gamed/NetworkListener.h | 1 + gamed/PacketHandler.cpp | 8 +- gamed/PacketHandler.h | 10 +- gamed/Packets.cpp | 1 + gamed/Packets.h | 7 +- gamed/Player.cpp | 41 ++++++++ gamed/Player.h | 44 +++++++++ gamed/main.cpp | 7 +- local.bat | 7 +- localz.bat | 137 ++++++++++++++++++++++++++ map ids.txt | 9 ++ win/VC100/Client.cpp | 75 +++++++++++++++ win/VC100/GameSession.cpp | 68 +++++++++++++ win/VC100/GameSession.h | 48 +++++++++ win/VC100/Map.cpp | 71 ++++++++++++++ win/VC100/Map.h | 39 ++++++++ win/VC100/enet-1.2.5.vcxproj | 4 +- win/VC100/gamed.vcxproj | 9 +- win/VC100/gamed.vcxproj.filters | 18 ++++ win/VC100/intlib.vcxproj | 4 +- 34 files changed, 1236 insertions(+), 209 deletions(-) create mode 100644 CONNECT TO LAN.bat create mode 100644 bin/VC120_Debug/error.txt create mode 100644 bin/VC120_Debug/output.txt create mode 100644 gamed/Client.cpp create mode 100644 gamed/GameSession.cpp create mode 100644 gamed/GameSession.h create mode 100644 gamed/Map.cpp create mode 100644 gamed/Map.h create mode 100644 gamed/Player.cpp create mode 100644 gamed/Player.h create mode 100644 localz.bat create mode 100644 map ids.txt create mode 100644 win/VC100/Client.cpp create mode 100644 win/VC100/GameSession.cpp create mode 100644 win/VC100/GameSession.h create mode 100644 win/VC100/Map.cpp create mode 100644 win/VC100/Map.h diff --git a/CONNECT TO LAN.bat b/CONNECT TO LAN.bat new file mode 100644 index 00000000..adf83941 --- /dev/null +++ b/CONNECT TO LAN.bat @@ -0,0 +1,136 @@ +@echo off +setlocal enabledelayedexpansion +echo ----------------------- +echo IntWars Solo Launcher +echo ----------------------- +set RADS_PATH= +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path again.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +goto cannotFind +:runApp +set RADS_PATH=%RADS_PATH:/=\% +@cd /d "%RADS_PATH%\solutions\lol_game_client_sln\releases" + +set init=0 +set v0=0&set v1=0&set v2=0&set v3=0 +for /f "delims=" %%F in ('dir * /b ^| findstr ^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$') do ( + for /F "tokens=1,2,3,4 delims=." %%i in ("%%F") do ( + if !init! equ 0 ( set init=1&set flag=1 ) else ( + set flag=0 + + if %%i gtr !v0! ( set flag=1 ) else ( + if %%j gtr !v1! ( set flag=1 ) else ( + if %%k gtr !v2! ( set flag=1 ) else ( + if %%l gtr !v3! ( set flag=1 ) + ) + ) + ) + ) + + if !flag! gtr 0 ( + set v0=%%i&set v1=%%j&set v2=%%k&set v3=%%l + ) + ) +) + +if !init! equ 0 goto cannotFind +set lolver=!v0!.!v1!.!v2!.!v3! + +@cd /d "!RADS_PATH!\solutions\lol_game_client_sln\releases\!lolver!\deploy" +if exist "League of Legends.exe" ( + @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "127.0.0.1 5119 17BLOhi6KZsTtldTsizvHg== 47917791" + goto exit +) +:cannotFind +echo =================== +echo Cannot find LoL path automatically :( +echo =================== +@pause +goto exit +:exit diff --git a/bin/VC120_Debug/error.txt b/bin/VC120_Debug/error.txt new file mode 100644 index 00000000..e69de29b diff --git a/bin/VC120_Debug/output.txt b/bin/VC120_Debug/output.txt new file mode 100644 index 00000000..e69de29b diff --git a/common.h b/common.h index cbb1fe87..acf56c75 100644 --- a/common.h +++ b/common.h @@ -20,73 +20,78 @@ along with this program. If not, see . enum GameCmd : uint8 { - PKT_S2C_MoveAns = 0x60, +PKT_S2C_MoveAns = 0x61, }; //Currently attuned to Live 4.5.0.264 + enum PacketCmd : uint8 -{ //Channel //Type - PKT_KeyCheck = 0x00, //0 //UPDATED - - PKT_S2C_EndSpawn = 0x11, //? //UPDATED - PKT_C2S_QueryStatusReq = 0x14, //1 //UPDATED - PKT_S2C_SkillUp = 0x15, //3 //UPDATED - PKT_C2S_Ping_Load_Info = 0x16, //1 //UPDATED - - PKT_S2C_ViewAns = 0x2B, //3 //UPDATED - PKT_C2S_ViewReq = 0x2D, //1 //UPDATED - - PKT_C2S_SkillUp = 0x38, //1 //UPDATED - PKT_S2C_AttentionPing = 0x3F, //3 //UPDATED - - PKT_S2C_Emotion = 0x41, //3 UPDATED - PKT_C2S_Emotion = 0x47, //1 UPDATED - PKT_S2C_HeroSpawn = 0x4B, //3 UPDATED - PKT_S2C_Announce = 0x4C, //3 - - PKT_S2C_GameTimer = 0xC0, - PKT_S2C_GameTimerUpdate = 0xC1, - - PKT_C2S_StartGame = 0x51, //1 //UPDATED - PKT_S2C_SynchVersion = 0x53, //3 //UPDATED - PKT_C2S_ScoreBord = 0x55, //1 //UPDATED - PKT_C2S_AttentionPing = 0x56, //1 //UPDATED - PKT_S2C_StartGame = 0x5B, //? //UPDATED - - PKT_S2C_StartSpawn = 0x61, //? //UPDATED - //PKT_C2S_OpenShop = 0x63, //1 - DEPRECATED - PKT_C2S_ClientReady = 0x64, //6 //UPDATED ? - PKT_S2C_LoadHero = 0x65, //6 //UPDATED - PKT_S2C_LoadName = 0x66, //6 //UPDATED - PKT_S2C_LoadScreenInfo = 0x67, //6 //UPDATED - PKT_ChatBoxMessage = 0x68, //5 //UPDATED - PKT_S2C_BuyItemAns = 0x6E, //3 //UPDATED - - PKT_C2S_MoveReq = 0x71, //1 //UPDATED - PKT_C2S_MoveConfirm = 0x76, //1 //UPDATED - - PKT_C2S_LockCamera = 0x80, //1 //UPDATED - PKT_C2S_BuyItemReq = 0x81, //1 //UPDATED - PKT_S2C_QueryStatusAns = 0x87, //? //UPDATED - PKT_C2S_Exit = 0x8E, //1 //UPDATED - - PKT_World_SendGameNumber = 0x91, //3 //UPDATED - PKT_S2C_Ping_Load_Info = 0x94, //4 //UPDATED - PKT_S2C_TurretSpawn = 0x9C, //3 UPDATED - - PKT_C2S_Surrender = 0xA3, //1 //UPDATED - //PKT_C2S_GameNumberReq = 0xA6, //1 //DEPRECATED - PKT_C2S_StatsConfirm = 0xA7, //1 UPDATED - PKT_C2S_Click = 0xAE, //1 //UPDATED - - PKT_C2S_SynchVersion = 0xBC, //1 //UPDATED - PKT_C2S_CharLoaded = 0xBD, //1 //UPDATED - - PKT_S2C_CharStats = 0xC3, //4 //UPDATED - PKT_S2C_FogUpdate2 = 0x23, //3 //UPDATED? - PKT_S2C_LevelPropSpawn = 0xCF, //3 UPDATED - - PKT_Batch = 0xFF, //3 +{ //Channel //Type +PKT_KeyCheck = 0x00, //0 //UPDATED +PKT_C2S_ClientConnect_NamedPipe = 0x01, + +PKT_S2C_EndSpawn = 0x11, //? //UPDATED +PKT_C2S_QueryStatusReq = 0x14, //1 //UPDATED +PKT_S2C_SkillUp = 0x16, //3 //UPDATED +PKT_C2S_Ping_Load_Info = 0x16, //1 //UPDATED + +PKT_S2C_ViewAns = 0x2C, //3 //UPDATED +PKT_C2S_ViewReq = 0x2E, //1 //UPDATED + +PKT_C2S_SkillUp = 0x39, //1 //UPDATED +PKT_S2C_AttentionPing = 0x3F, //3 //UPDATED + +PKT_S2C_Emotion = 0x42, //3 UPDATED +PKT_C2S_Emotion = 0x48, //1 UPDATED +PKT_S2C_HeroSpawn = 0x4C, //3 UPDATED +PKT_S2C_Announce = 0x4D, //3 + +PKT_S2C_GameTimer = 0xC0, +PKT_S2C_GameTimerUpdate = 0xC1, + +PKT_C2S_StartGame = 0x52, //1 //UPDATED +PKT_S2C_SynchVersion = 0x54, //3 //UPDATED +PKT_C2S_ScoreBord = 0x56, //1 //UPDATED +PKT_C2S_AttentionPing = 0x57, //1 //UPDATED +PKT_S2C_StartGame = 0x5C, //? //UPDATED + +PKT_S2C_StartSpawn = 0x62, //? //UPDATED +//PKT_C2S_OpenShop = 0x63, //1 - DEPRECATED +PKT_C2S_ClientReady = 0x64, //6 //UPDATED ? +PKT_S2C_LoadHero = 0x65, //6 //UPDATED +PKT_S2C_LoadName = 0x66, //6 //UPDATED +PKT_S2C_LoadScreenInfo = 0x67, //6 //UPDATED +PKT_ChatBoxMessage = 0x68, //5 //UPDATED +PKT_S2C_BuyItemAns = 0x6F, //3 //UPDATED + +PKT_C2S_MoveReq = 0x72, //1 //UPDATED +PKT_C2S_MoveConfirm = 0x77, //1 //UPDATED + +PKT_C2S_LockCamera = 0x81, //1 //UPDATED +PKT_C2S_BuyItemReq = 0x82, //1 //UPDATED +PKT_S2C_QueryStatusAns = 0x88, //? //UPDATED +PKT_C2S_Exit = 0x8F, //1 //UPDATED + +PKT_World_SendGameNumber = 0x92, //3 //UPDATED +PKT_S2C_Ping_Load_Info = 0x95, //4 //UPDATED +PKT_S2C_UpdateModel = 0x97, +PKT_S2C_TurretSpawn = 0x9D, //3 UPDATED + +PKT_C2S_Surrender = 0xA4, //1 //UPDATED +//PKT_C2S_GameNumberReq = 0xA6, //1 //DEPRECATED +PKT_C2S_StatsConfirm = 0xA8, //1 UPDATED +PKT_S2C_HeroSpawnUnk3 = 0xAE, +PKT_C2S_Click = 0xAF, //1 //UPDATED + +PKT_S2C_HeroSpawnUnk2 = 0xBA, +PKT_C2S_SynchVersion = 0xBD, //1 //UPDATED +PKT_C2S_CharLoaded = 0xBE, //1 //UPDATED + +PKT_S2C_CharStats = 0xC4, //4 //UPDATED +PKT_S2C_FogUpdate2 = 0x23, //3 //UPDATED? +PKT_S2C_LevelPropSpawn = 0xD0, //3 UPDATED + +PKT_Batch = 0xFF, //3 }; enum MoveType : uint8 diff --git a/gamed/Client.cpp b/gamed/Client.cpp new file mode 100644 index 00000000..7e9da387 --- /dev/null +++ b/gamed/Client.cpp @@ -0,0 +1,75 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "stdafx.h" +#include "Client.h" + +ClientInfo::ClientInfo() +{ + keyChecked = false; + name = type = NULL; + ticks = 0; + skinNo = 0; +} + +ClientInfo::~ClientInfo() +{ + if(name != NULL) + delete[] name; + if(type != NULL) + delete[] type; +} + +void ClientInfo::setName(char *name) +{ + if(this->name != NULL) + delete[] this->name; + + nameLen = strlen(name); + this->name = new int8[nameLen+1]; + memcpy(this->name, name, nameLen+1); +} + +void ClientInfo::setType(char *type) +{ + if(this->type != NULL) + delete[] this->type; + + typeLen = strlen(type); + this->type = new int8[typeLen+1]; + memcpy(this->type, type, typeLen+1); +} + +uint32 ClientInfo::getTicks() +{ + ticks++; + return ticks; +} + +LoadScreenPlayer* ClientInfo::GetLoadScreenPlayerName() +{ + LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadName, name, nameLen); + p->userId = userId; + return p; +} +LoadScreenPlayer* ClientInfo::GetLoadScreenPlayerHero() +{ + LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadHero, type, typeLen); + p->userId = userId; + p->skinId = skinNo; + return p; +} \ No newline at end of file diff --git a/gamed/Client.h b/gamed/Client.h index 2aae0eaa..fed2c0e7 100644 --- a/gamed/Client.h +++ b/gamed/Client.h @@ -19,50 +19,22 @@ along with this program. If not, see . #define _CLIENT_H #include "common.h" +#include "Packets.h" -struct ClientInfo +class ClientInfo { - ClientInfo() - { - keyChecked = false; - name = type = NULL; - ticks = 0; - skinNo = 0; - } +public: + ClientInfo(); + ~ClientInfo(); - ~ClientInfo() - { - if(name != NULL) - delete[] name; - if(type != NULL) - delete[] type; - } + void setName(char *name); + void setType(char *type); - void setName(char *name) - { - if(this->name != NULL) - delete[] this->name; + LoadScreenPlayer* GetLoadScreenPlayerName(); + LoadScreenPlayer* GetLoadScreenPlayerHero(); - nameLen = strlen(name); - this->name = new int8[nameLen+1]; - memcpy(this->name, name, nameLen+1); - } + uint32 getTicks(); - void setType(char *type) - { - if(this->type != NULL) - delete[] this->type; - - typeLen = strlen(type); - this->type = new int8[typeLen+1]; - memcpy(this->type, type, typeLen+1); - } - - uint32 getTicks() - { - ticks++; - return ticks; - } bool keyChecked; uint64 userId; uint32 ticks; @@ -72,8 +44,10 @@ struct ClientInfo uint32 skinNo; int8 *name; int8 *type; - + uint8 team; + ENetPeer *peer; }; + #define peerInfo(p) ((ClientInfo*)p->data) #endif \ No newline at end of file diff --git a/gamed/GameSession.cpp b/gamed/GameSession.cpp new file mode 100644 index 00000000..2769647a --- /dev/null +++ b/gamed/GameSession.cpp @@ -0,0 +1,68 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "stdafx.h" +#include "GameSession.h" +#include "Map.h" +#include "Client.h" +#include "Log.h" + +std::vector GameSession::m_Players; +Map* GameSession::m_Map = 0; + +void GameSession::Init(PacketHandler* packetHandler) +{ + m_Map = new Map(packetHandler); +} + +GameSession::~GameSession() +{ + delete m_Map; + m_Map = 0; + + for(int i=0; i < m_Players.size();i++) + { + delete m_Players[i]; + m_Players[i] = 0; + } + m_Players.clear(); +} + +void GameSession::AddPlayer(ClientInfo* player) +{ + if(std::find(m_Players.begin(), m_Players.end(), player) != m_Players.end()) { + //Logging->writeLine("player %s already in playerlist", player->name); + return; + } + m_Players.push_back(player); +} + +const std::vector& GameSession::GetPlayerList() +{ + return m_Players; +} + +ClientInfo* GameSession::FindPlayer(uint32 netId) +{ + for(int i=0; i < m_Players.size();i++) + { + if(m_Players[i]->netId == netId) + return m_Players[i]; + } + + return NULL; +} \ No newline at end of file diff --git a/gamed/GameSession.h b/gamed/GameSession.h new file mode 100644 index 00000000..f95c614a --- /dev/null +++ b/gamed/GameSession.h @@ -0,0 +1,48 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef _GAME_SESSION_H +#define _GAME_SESSION_H + +#include "stdafx.h" +#include +#include "Map.h" + +class ClientInfo; +class PacketHandler; +class GameSession +{ +public: + ~GameSession(); + + static void Init(PacketHandler* packetHandler); + static void AddPlayer(ClientInfo* player); + static const std::vector& GetPlayerList(); + static ClientInfo* FindPlayer(uint32 netId); + static Map* GetMap(); + +private: + static std::vector m_Players; + static Map* m_Map; +}; + +inline Map* GameSession::GetMap() +{ + return m_Map; +} + +#endif \ No newline at end of file diff --git a/gamed/Handlers.cpp b/gamed/Handlers.cpp index 9630bf3f..9d387e0a 100644 --- a/gamed/Handlers.cpp +++ b/gamed/Handlers.cpp @@ -18,12 +18,15 @@ along with this program. If not, see . #include "stdafx.h" #include "PacketHandler.h" #include "NetworkListener.h" +#include "GameSession.h" +#include "Player.h" bool PacketHandler::handleNull(HANDLE_ARGS) { return true; } -bool PacketHandler::handleKeyCheck(ENetPeer *peer, ENetPacket *packet) { +bool PacketHandler::handleKeyCheck(HANDLE_ARGS) +{ KeyCheck *keyCheck = (KeyCheck *)packet->data; uint64 userId = _blowfish->Decrypt(keyCheck->checkId); /* @@ -37,77 +40,70 @@ bool PacketHandler::handleKeyCheck(ENetPeer *peer, ENetPacket *packet) { PDEBUG_LOG_LINE(Logging," Enc id: %s\n", buffer);*/ if(userId == keyCheck->userId) { PDEBUG_LOG_LINE(Logging, " User got the same key as i do, go on!\n"); - peerInfo(peer)->keyChecked = true; - peerInfo(peer)->userId = userId; + peerInfo(m_CurrPeer)->keyChecked = true; + peerInfo(m_CurrPeer)->userId = userId; + + std::vector players = GameSession::GetPlayerList(); + for(int i=0; i < players.size();i++) + { + if(players[i]->netId == peerInfo(m_CurrPeer)->netId) + { + players[i]->userId = userId; + break; + } + } } else { Logging->errorLine(" WRONG KEY, GTFO!!!\n"); - return false; + return false; } //Send response as this is correct (OFC DO SOME ID CHECKS HERE!!!) KeyCheck response; response.userId = keyCheck->userId; - bool bRet = sendPacket(peer, reinterpret_cast(&response), sizeof(KeyCheck), CHL_HANDSHAKE); - handleGameNumber(peer, NULL);//Send 0x91 Packet? + bool bRet = sendPacket(reinterpret_cast(&response), sizeof(KeyCheck), CHL_HANDSHAKE); + handleGameNumber(NULL);//Send 0x91 Packet? return bRet; } -bool PacketHandler::handleGameNumber(ENetPeer *peer, ENetPacket *packet) { +bool PacketHandler::handleGameNumber(HANDLE_ARGS) { WorldSendGameNumber world; world.gameId = 1; strcpy((char *)world.data1, "EUW1"); - memcpy(world.data, peerInfo(peer)->name, peerInfo(peer)->nameLen); - return sendPacket(peer, reinterpret_cast(&world), sizeof(WorldSendGameNumber), CHL_S2C); + memcpy(world.data, peerInfo(m_CurrPeer)->name, peerInfo(m_CurrPeer)->nameLen); + return sendPacket(reinterpret_cast(&world), sizeof(WorldSendGameNumber), CHL_S2C); } -bool PacketHandler::handleSynch(ENetPeer *peer, ENetPacket *packet) { +bool PacketHandler::handleSynch(HANDLE_ARGS) { SynchVersion *version = reinterpret_cast(packet->data); Logging->writeLine("Client version: %s\n", version->version); SynchVersionAns answer; answer.mapId = 1; - answer.players[0].userId = peerInfo(peer)->userId; + answer.players[0].userId = peerInfo(m_CurrPeer)->userId; answer.players[0].skill1 = SPL_Ignite; answer.players[0].skill2 = SPL_Flash; - return sendPacket(peer, reinterpret_cast(&answer), sizeof(SynchVersionAns), 3); + return sendPacket(reinterpret_cast(&answer), sizeof(SynchVersionAns), 3); } -bool PacketHandler::handleMap(ENetPeer *peer, ENetPacket *packet) { - LoadScreenPlayer *playerName = LoadScreenPlayer::create(PKT_S2C_LoadName, peerInfo(peer)->name, peerInfo(peer)->nameLen); - playerName->userId = peerInfo(peer)->userId; - LoadScreenPlayer *playerHero = LoadScreenPlayer::create(PKT_S2C_LoadHero, peerInfo(peer)->type, peerInfo(peer)->typeLen); - playerHero->userId = peerInfo(peer)->userId; - playerHero->skinId = peerInfo(peer)->skinNo; - //Builds team info - LoadScreenInfo screenInfo; - screenInfo.bluePlayerNo = 1; - screenInfo.redPlayerNo = 0; - screenInfo.bluePlayerIds[0] = peerInfo(peer)->userId; - bool pInfo = sendPacket(peer, reinterpret_cast(&screenInfo), sizeof(LoadScreenInfo), CHL_LOADING_SCREEN); - //For all players send this info - bool pName = sendPacket(peer, reinterpret_cast(playerName), playerName->getPacketLength(), CHL_LOADING_SCREEN); - bool pHero = sendPacket(peer, reinterpret_cast(playerHero), playerHero->getPacketLength(), CHL_LOADING_SCREEN); - //cleanup - LoadScreenPlayer::destroy(playerName); - LoadScreenPlayer::destroy(playerHero); - return (pInfo && pName && pHero); +bool PacketHandler::handleMap(HANDLE_ARGS) { + return GameSession::GetMap()->Init(); } //building the map -bool PacketHandler::handleSpawn(ENetPeer *peer, ENetPacket *packet) { +bool PacketHandler::handleSpawn(HANDLE_ARGS) { StatePacket2 start(PKT_S2C_StartSpawn); - bool p1 = sendPacket(peer, reinterpret_cast(&start), sizeof(StatePacket2), CHL_S2C); + bool p1 = sendPacket(reinterpret_cast(&start), sizeof(StatePacket2), CHL_S2C); printf("Spawning map\r\n"); HeroSpawn spawn; - spawn.netId = peerInfo(peer)->netId; + spawn.netId = peerInfo(m_CurrPeer)->netId; spawn.gameId = 0; - memcpy(spawn.name, peerInfo(peer)->name, peerInfo(peer)->nameLen); - memcpy(spawn.type, peerInfo(peer)->type, peerInfo(peer)->typeLen); - bool p2 = sendPacket(peer, reinterpret_cast(&spawn), sizeof(HeroSpawn), CHL_S2C); + memcpy(spawn.name, peerInfo(m_CurrPeer)->name, peerInfo(m_CurrPeer)->nameLen); + memcpy(spawn.type, peerInfo(m_CurrPeer)->type, peerInfo(m_CurrPeer)->typeLen); + bool p2 = sendPacket(reinterpret_cast(&spawn), sizeof(HeroSpawn), CHL_S2C); HeroSpawn2 h2; - h2.header.netId = peerInfo(peer)->netId; - sendPacket(peer, reinterpret_cast(&h2), sizeof(HeroSpawn2), CHL_S2C); + h2.header.netId = peerInfo(m_CurrPeer)->netId; + sendPacket(reinterpret_cast(&h2), sizeof(HeroSpawn2), CHL_S2C); HeroSpawn3 h3; - h3.header.netId = peerInfo(peer)->netId; - sendPacket(peer, reinterpret_cast(&h3), sizeof(HeroSpawn3), CHL_S2C); + h3.header.netId = peerInfo(m_CurrPeer)->netId; + sendPacket(reinterpret_cast(&h3), sizeof(HeroSpawn3), CHL_S2C); //Spawn Turrets char *szTurrets[24] = { "@@Turret_T1_R_03_A", @@ -139,7 +135,7 @@ bool PacketHandler::handleSpawn(ENetPeer *peer, ENetPacket *packet) { TurretSpawn turretSpawn; turretSpawn.tID = i + 1; strcpy((char *)turretSpawn.name, szTurrets[i]); - sendPacket(peer, reinterpret_cast(&turretSpawn), sizeof(TurretSpawn), CHL_S2C); + sendPacket(reinterpret_cast(&turretSpawn), sizeof(TurretSpawn), CHL_S2C); } //Spawn Props LevelPropSpawn lpSpawn; @@ -148,85 +144,85 @@ bool PacketHandler::handleSpawn(ENetPeer *peer, ENetPacket *packet) { lpSpawn.netId = GetNewNetID(); lpSpawn.x = 12465; lpSpawn.y = 101; - sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); + sendPacket(reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); lpSpawn.SetProp("LevelProp_Yonkey1", "Yonkey"); lpSpawn.header.netId = 0; lpSpawn.netId = GetNewNetID(); lpSpawn.x = -76; lpSpawn.y = 94; - sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); + sendPacket(reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); lpSpawn.SetProp("LevelProp_ShopMale", "ShopMale"); lpSpawn.header.netId = 0; lpSpawn.netId = GetNewNetID(); lpSpawn.x = 13374; lpSpawn.y = 194; - sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); + sendPacket(reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); lpSpawn.SetProp("LevelProp_ShopMale1", "ShopMale"); lpSpawn.header.netId = 0; lpSpawn.netId = GetNewNetID(); lpSpawn.x = -99; lpSpawn.y = 191; - sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); + sendPacket(reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); StatePacket end(PKT_S2C_EndSpawn); - bool p3 = sendPacket(peer, reinterpret_cast(&end), sizeof(StatePacket), CHL_S2C); + bool p3 = sendPacket(reinterpret_cast(&end), sizeof(StatePacket), CHL_S2C); BuyItemAns recall; - recall.header.netId = peerInfo(peer)->netId; + recall.header.netId = peerInfo(m_CurrPeer)->netId; recall.itemId = 2001; recall.slotId = 7; recall.stack = 1; - bool p4 = sendPacket(peer, reinterpret_cast(&recall), sizeof(BuyItemAns), CHL_S2C); //activate recall slot + bool p4 = sendPacket(reinterpret_cast(&recall), sizeof(BuyItemAns), CHL_S2C); //activate recall slot GameTimer timer(0); //0xC0 - sendPacket(peer, reinterpret_cast(&timer), sizeof(GameTimer), CHL_S2C); + sendPacket(reinterpret_cast(&timer), sizeof(GameTimer), CHL_S2C); GameTimer timer2(0.4); //0xC0 - sendPacket(peer, reinterpret_cast(&timer2), sizeof(GameTimer), CHL_S2C); + sendPacket(reinterpret_cast(&timer2), sizeof(GameTimer), CHL_S2C); GameTimerUpdate timer3(0.4); //0xC1 - sendPacket(peer, reinterpret_cast(&timer3), sizeof(GameTimerUpdate), CHL_S2C); + sendPacket(reinterpret_cast(&timer3), sizeof(GameTimerUpdate), CHL_S2C); //lvl 1 R for elise for(int i = 0; i < 4; i++) { - SpellSet spell(peerInfo(peer)->netId, i, 1); - sendPacket(peer, reinterpret_cast(&spell), sizeof(SpellSet), CHL_S2C); + SpellSet spell(peerInfo(m_CurrPeer)->netId, i, 1); + sendPacket(reinterpret_cast(&spell), sizeof(SpellSet), CHL_S2C); } return p1 & p2 & p3; } bool PacketHandler::handleStartGame(HANDLE_ARGS) { StatePacket start(PKT_S2C_StartGame); - sendPacket(peer, reinterpret_cast(&start), sizeof(StatePacket), CHL_S2C); + sendPacket(reinterpret_cast(&start), sizeof(StatePacket), CHL_S2C); FogUpdate2 test; test.x = 0; test.y = 0; test.radius = 1; test.unk1 = 2; //uint8 p[] = {0xC5, 0x19, 0x00, 0x00, 0x40, 0x00, 0x00, 0x50}; - //sendPacket(peer, reinterpret_cast(p), sizeof(p), 3); - sendPacket(peer, reinterpret_cast(&test), sizeof(FogUpdate2), 3); + //sendPacket(reinterpret_cast(p), sizeof(p), 3); + sendPacket(reinterpret_cast(&test), sizeof(FogUpdate2), 3); //playing around 8-) /* CharacterStats movement; - movement.netId = peerInfo(peer)->netId; + movement.netId = peerInfo(m_CurrPeer)->netId; movement.statType = STI_Movement; movement.statValue = 800; sendPacket(peer,reinterpret_cast(&movement),sizeof(movement), 4);*/ return true; } -bool PacketHandler::handleAttentionPing(ENetPeer *peer, ENetPacket *packet) { +bool PacketHandler::handleAttentionPing(HANDLE_ARGS) { AttentionPing *ping = reinterpret_cast(packet->data); AttentionPingAns response(ping); Logging->writeLine("Plong x: %f, y: %f, z: %f, type: %i\n", ping->x, ping->y, ping->z, ping->type); return broadcastPacket(reinterpret_cast(&response), sizeof(AttentionPing), 3); } -bool PacketHandler::handleView(ENetPeer *peer, ENetPacket *packet) { +bool PacketHandler::handleView(HANDLE_ARGS) { ViewReq *request = reinterpret_cast(packet->data); //Logging->writeLine("View (%i), x:%f, y:%f, zoom: %f\n", request->requestNo, request->x, request->y, request->zoom); ViewAns answer; answer.requestNo = request->requestNo; - sendPacket(peer, reinterpret_cast(&answer), sizeof(ViewAns), CHL_S2C, UNRELIABLE); - enet_host_flush(peer->host); + sendPacket(reinterpret_cast(&answer), sizeof(ViewAns), CHL_S2C, UNRELIABLE); + enet_host_flush(m_CurrPeer->host); if(request->requestNo == 0xFE) { answer.requestNo = 0xFF; - sendPacket(peer, reinterpret_cast(&answer), sizeof(ViewAns), CHL_S2C, UNRELIABLE); + sendPacket(reinterpret_cast(&answer), sizeof(ViewAns), CHL_S2C, UNRELIABLE); } return true; } @@ -274,7 +270,7 @@ std::vector readWaypoints(byte *buffer, int coordCount) { #define MAP_WIDTH (13982 / 2) #define MAP_HEIGHT (14446 / 2) -bool PacketHandler::handleMove(ENetPeer *peer, ENetPacket *packet) { +bool PacketHandler::handleMove(HANDLE_ARGS) { MovementReq *request = reinterpret_cast(packet->data); switch(request->type) { //TODO, Implement stop commands @@ -292,7 +288,7 @@ bool PacketHandler::handleMove(ENetPeer *peer, ENetPacket *packet) { MovementAns *answer = MovementAns::create(request->vectorNo); answer->ok = 1; answer->vectorNo = request->vectorNo; - answer->netId = peerInfo(peer)->netId; + answer->netId = peerInfo(m_CurrPeer)->netId; for(int i = 0; i < vMoves.size(); i++) { answer->getVector(i)->x = vMoves[i].x; answer->getVector(i)->y = vMoves[i].y; @@ -302,17 +298,17 @@ bool PacketHandler::handleMove(ENetPeer *peer, ENetPacket *packet) { return bRet; } -bool PacketHandler::handleLoadPing(ENetPeer *peer, ENetPacket *packet) { +bool PacketHandler::handleLoadPing(HANDLE_ARGS) { PingLoadInfo *loadInfo = reinterpret_cast(packet->data); PingLoadInfo response; memcpy(&response, packet->data, sizeof(PingLoadInfo)); response.header.cmd = PKT_S2C_Ping_Load_Info; - response.userId = peerInfo(peer)->userId; + response.userId = peerInfo(m_CurrPeer)->userId; Logging->writeLine("loaded: %f, ping: %f, %f\n", loadInfo->loaded, loadInfo->ping, loadInfo->f3); bool bRet = broadcastPacket(reinterpret_cast(&response), sizeof(PingLoadInfo), CHL_LOW_PRIORITY, UNRELIABLE); static bool bLoad = false; if(!bLoad) { - handleMap(peer, NULL); + handleMap(NULL); bLoad = true; } return bRet; @@ -320,7 +316,7 @@ bool PacketHandler::handleLoadPing(ENetPeer *peer, ENetPacket *packet) { bool PacketHandler::handleQueryStatus(HANDLE_ARGS) { QueryStatus response; - return sendPacket(peer, reinterpret_cast(&response), sizeof(QueryStatus), CHL_S2C); + return sendPacket(reinterpret_cast(&response), sizeof(QueryStatus), CHL_S2C); } bool PacketHandler::handleChatBoxMessage(HANDLE_ARGS) { @@ -335,10 +331,10 @@ bool PacketHandler::handleChatBoxMessage(HANDLE_ARGS) { float value = (float)atoi(&message->getMessage()[strlen(cmd[0]) + 5]); uint32 mask = 1 << abs(((int)fieldNo - 1)); CharacterStats *stats = CharacterStats::create(blockNo, mask); - stats->netId = peerInfo(peer)->netId; + stats->netId = peerInfo(m_CurrPeer)->netId; stats->setValue(blockNo, mask, value); Logging->writeLine("Setting to %f in block: %i, field: %i\n", value, blockNo, fieldNo); - sendPacket(peer, reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); + sendPacket(reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); stats->destroy(); return true; } @@ -346,10 +342,10 @@ bool PacketHandler::handleChatBoxMessage(HANDLE_ARGS) { if(strncmp(message->getMessage(), cmd[1], strlen(cmd[1])) == 0) { float gold = (float)atoi(&message->getMessage()[strlen(cmd[1]) + 1]); CharacterStats *stats = CharacterStats::create(FM1_Gold, 0, 0, 0, 0); - stats->netId = peerInfo(peer)->netId; + stats->netId = peerInfo(m_CurrPeer)->netId; stats->setValue(1, FM1_Gold, gold); Logging->writeLine("Set gold to %f\n", gold); - sendPacket(peer, reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); + sendPacket(reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); stats->destroy(); return true; } @@ -425,25 +421,39 @@ bool PacketHandler::handleChatBoxMessage(HANDLE_ARGS) { //Model if(strncmp(message->getMessage(), cmd[8], strlen(cmd[8])) == 0) { std::string sModel = (char *)&message->getMessage()[strlen(cmd[8]) + 1]; - UpdateModel modelPacket(peerInfo(peer)->netId, (char *)sModel.c_str()); //96 + UpdateModel modelPacket(peerInfo(m_CurrPeer)->netId, (char *)sModel.c_str()); //96 broadcastPacket(reinterpret_cast(&modelPacket), sizeof(UpdateModel), CHL_S2C); return true; } } + std::vector players = GameSession::GetPlayerList(); + ClientInfo* player; + bool res; switch(message->type) { case CMT_ALL: return broadcastPacket(packet->data, packet->dataLength, CHL_COMMUNICATION); break; case CMT_TEAM: //!TODO make a team class and foreach player in the team send the message - return sendPacket(peer, packet->data, packet->dataLength, CHL_COMMUNICATION); + player = GameSession::FindPlayer(peerInfo(m_CurrPeer)->netId); + if(!player) + return false; + + for(int i=0; i < players.size();i++) + { + if(players[i]->team == player->team) + { + if(!sendPacket(packet->data, packet->dataLength, CHL_COMMUNICATION)) + return false; + } + } break; default: Logging->errorLine("Unknown ChatMessageType\n"); - return sendPacket(peer, packet->data, packet->dataLength, CHL_COMMUNICATION); + return sendPacket(packet->data, packet->dataLength, CHL_COMMUNICATION); break; } - return false; + return true; } bool PacketHandler::handleSkillUp(HANDLE_ARGS) { @@ -453,7 +463,7 @@ bool PacketHandler::handleSkillUp(HANDLE_ARGS) { skillUpResponse.skill = skillUpPacket->skill; skillUpResponse.level = 0x01; skillUpResponse.pointsLeft = 5; - return sendPacket(peer, reinterpret_cast(&skillUpResponse), sizeof(skillUpResponse), CHL_GAMEPLAY); + return sendPacket(reinterpret_cast(&skillUpResponse), sizeof(skillUpResponse), CHL_GAMEPLAY); } bool PacketHandler::handleBuyItem(HANDLE_ARGS) { diff --git a/gamed/Log.cpp b/gamed/Log.cpp index 74576ad3..f7b899f4 100644 --- a/gamed/Log.cpp +++ b/gamed/Log.cpp @@ -19,6 +19,8 @@ along with this program. If not, see . #include "Log.h" Log* Log::m_instance; +using namespace std; + Log::Log() { m_stream = &cout; diff --git a/gamed/Log.h b/gamed/Log.h index 358ea17b..58966477 100644 --- a/gamed/Log.h +++ b/gamed/Log.h @@ -18,6 +18,13 @@ along with this program. If not, see . #ifndef _LOG_H #define _LOG_H + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif + +#define byte BYTE + #include #define LOG_BUFFER_SIZE 1024 @@ -35,50 +42,50 @@ along with this program. If not, see . #define VDEBUG_LOG(LogHandler,buffer,...) #endif -using namespace std; /* * This class was made to simplify Logs * As you can see we can make multiple instance of logs (if one day we make multi-party server it can be helpfull) * but anyway we have a also a main instance of logs that can be access by getMainInstance. -* I also made PDEBUG_LOG and VDEBUG_LOG macros to remove some useless message when we'll be in release mode. +* I also made PDEBUG_LOG and VDEBUG_LOG macros to remove some useless message when we'll be in release mode. * SYSTEMTIME is from window's API, , that broke the portability. */ + class Log { public: - enum LogType + enum LogType { LT_NORMAL, LT_DEBUG, LT_ERROR }; - + public: Log(); ~Log(); - void setStream(ostream* stream); + void setStream(std::ostream* stream); void setOutputFile(const char* path); void writeDate(); - void writeLine(const char* buffer,...); - void write(const char* buffer,...); - void errorLine(const char* buffer,...); - void error(const char* buffer,...); - void debugLine(const char* buffer,...); - void debug(const char* buffer,...); + void writeLine(const char* buffer, ...); + void write(const char* buffer, ...); + void errorLine(const char* buffer, ...); + void error(const char* buffer, ...); + void debugLine(const char* buffer, ...); + void debug(const char* buffer, ...); void clear(); void setLogType(LogType type); static Log* getMainInstance(); private: - void vaWriteLine(const char* buffer,va_list l); - void vaWrite(const char* buffer,va_list al); + void vaWriteLine(const char* buffer, va_list l); + void vaWrite(const char* buffer, va_list al); private: static Log* m_instance; LogType m_type; - ostream* m_stream; + std::ostream* m_stream; SYSTEMTIME m_time; - char m_buffer[LOG_BUFFER_SIZE]; + char m_buffer[LOG_BUFFER_SIZE]; }; #endif diff --git a/gamed/Map.cpp b/gamed/Map.cpp new file mode 100644 index 00000000..5b4b0bbe --- /dev/null +++ b/gamed/Map.cpp @@ -0,0 +1,71 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "stdafx.h" +#include "Map.h" +#include "PacketHandler.h" +#include "GameSession.h" + +bool Map::Init() +{ + int blueTeam=0; + int redTeam=0; + LoadScreenInfo screenInfo; + + std::vector m_players = GameSession::GetPlayerList(); + + //Builds team info + for(int i=0; i < m_players.size();i++) + { + if(m_players[i]->team == 0) + { + blueTeam++; + screenInfo.bluePlayerIds[i] = m_players[i]->userId; + } + else + { + redTeam++; + screenInfo.redPlayersIds[i] = m_players[i]->userId; + } + } + + screenInfo.bluePlayerNo = blueTeam; + screenInfo.redPlayerNo = redTeam; + + bool pInfo = m_PacketHandler->sendPacket(reinterpret_cast(&screenInfo), sizeof(LoadScreenInfo), CHL_LOADING_SCREEN); + + bool noerr; + + //For all players send this info + for(int i=0; i < m_players.size();i++) + { + LoadScreenPlayer* playerName = m_players[i]->GetLoadScreenPlayerName(); + LoadScreenPlayer* playerHero = m_players[i]->GetLoadScreenPlayerHero(); + + noerr = m_PacketHandler->sendPacket(reinterpret_cast(playerName), playerName->getPacketLength(), CHL_LOADING_SCREEN); + LoadScreenPlayer::destroy(playerName); + if(!noerr) + break; + noerr = m_PacketHandler->sendPacket(reinterpret_cast(playerHero), playerHero->getPacketLength(), CHL_LOADING_SCREEN); + LoadScreenPlayer::destroy(playerHero); + if(!noerr) + break; + } + + + return (pInfo && noerr); +} diff --git a/gamed/Map.h b/gamed/Map.h new file mode 100644 index 00000000..8bbadd8e --- /dev/null +++ b/gamed/Map.h @@ -0,0 +1,39 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef _MAP_H +#define _MAP_H + +#include "stdafx.h" + +class PacketHandler; +class Map +{ +public: + Map(PacketHandler* packetHandler); + bool Init(); + +private: + PacketHandler* m_PacketHandler; +}; + +inline Map::Map(PacketHandler* _packetHandler) : m_PacketHandler(_packetHandler) +{ + +} + +#endif \ No newline at end of file diff --git a/gamed/NetworkListener.cpp b/gamed/NetworkListener.cpp index 418bfd30..e02764b6 100644 --- a/gamed/NetworkListener.cpp +++ b/gamed/NetworkListener.cpp @@ -18,6 +18,8 @@ along with this program. If not, see . #include "stdafx.h" #include "NetworkListener.h" #include "Log.h" +#include "GameSession.h" +#include "Player.h" uint32 GetNewNetID() { static DWORD dwStart = 0x40000019; @@ -59,9 +61,15 @@ bool NetworkListener::initialize(ENetAddress *address, const char *baseKey) return _isAlive = true; } +PacketHandler* NetworkListener::GetPacketHandler() +{ + return _handler; +} + void NetworkListener::netLoop() { ENetEvent event; + Player* p; while(enet_host_service(_server, & event, 10) >= 0 && _isAlive) { @@ -77,7 +85,11 @@ void NetworkListener::netLoop() peerInfo(event.peer)->setName("Test"); peerInfo(event.peer)->setType("Teemo"); peerInfo(event.peer)->skinNo = 6; + peerInfo(event.peer)->team = 0; peerInfo(event.peer)->netId = GetNewNetID(); + peerInfo(event.peer)->peer = event.peer; + + GameSession::AddPlayer(peerInfo(event.peer)); break; diff --git a/gamed/NetworkListener.h b/gamed/NetworkListener.h index c9522cda..83621934 100644 --- a/gamed/NetworkListener.h +++ b/gamed/NetworkListener.h @@ -34,6 +34,7 @@ class NetworkListener bool initialize(ENetAddress *address, const char *baseKey); void netLoop(); + PacketHandler* GetPacketHandler(); private: bool _isAlive; diff --git a/gamed/PacketHandler.cpp b/gamed/PacketHandler.cpp index d5432594..d8e1d102 100644 --- a/gamed/PacketHandler.cpp +++ b/gamed/PacketHandler.cpp @@ -21,6 +21,7 @@ along with this program. If not, see . PacketHandler::PacketHandler(ENetHost *server, BlowFish *blowfish) { + m_CurrPeer = NULL; _server = server; _blowfish = blowfish; memset(_handlerTable,0,sizeof(_handlerTable)); @@ -77,7 +78,7 @@ void PacketHandler::printLine(uint8 *buf, uint32 len) PDEBUG_LOG(Logging,"\n"); } -bool PacketHandler::sendPacket(ENetPeer *peer, uint8 *data, uint32 length, uint8 channelNo, uint32 flag) +bool PacketHandler::sendPacket(uint8 *data, uint32 length, uint8 channelNo, uint32 flag) { //PDEBUG_LOG_LINE(Logging," Sending packet:\n"); //if(length < 300) @@ -87,7 +88,7 @@ bool PacketHandler::sendPacket(ENetPeer *peer, uint8 *data, uint32 length, uint8 _blowfish->Encrypt(data, length-(length%8)); //Encrypt everything minus the last bytes that overflow the 8 byte boundary ENetPacket *packet = enet_packet_create(data, length, flag); - if(enet_peer_send(peer, channelNo, packet) < 0) + if(enet_peer_send(m_CurrPeer, channelNo, packet) < 0) { PDEBUG_LOG_LINE(Logging,"Warning fail, send!"); return false; @@ -111,6 +112,7 @@ bool PacketHandler::broadcastPacket(uint8 *data, uint32 length, uint8 channelNo, bool PacketHandler::handlePacket(ENetPeer *peer, ENetPacket *packet, uint8 channelID) { + m_CurrPeer = peer; if(packet->dataLength >= 8) { if(peerInfo(peer)->keyChecked) @@ -122,7 +124,7 @@ bool PacketHandler::handlePacket(ENetPeer *peer, ENetPacket *packet, uint8 chann if(handler) { - return (*this.*handler)(peer,packet); + return (*this.*handler)(packet); } else { diff --git a/gamed/PacketHandler.h b/gamed/PacketHandler.h index bcfb6f28..faf68623 100644 --- a/gamed/PacketHandler.h +++ b/gamed/PacketHandler.h @@ -17,9 +17,12 @@ along with this program. If not, see . */ #ifndef _PACKET_HANDLER_H #define _PACKET_HANDLER_H + +#include "Log.h" + #include #include "common.h" -#include "Log.h" + #include "ChatBox.h" #include @@ -32,7 +35,7 @@ along with this program. If not, see . #define RELIABLE ENET_PACKET_FLAG_RELIABLE #define UNRELIABLE 0 -#define HANDLE_ARGS ENetPeer *peer, ENetPacket *packet +#define HANDLE_ARGS ENetPacket *packet class PacketHandler { @@ -64,7 +67,7 @@ class PacketHandler //Tools void printPacket(uint8 *buf, uint32 len); void printLine(uint8 *buf, uint32 len); - bool sendPacket(ENetPeer *peer, uint8 *data, uint32 length, uint8 channelNo, uint32 flag = RELIABLE); + bool sendPacket( uint8 *data, uint32 length, uint8 channelNo, uint32 flag = RELIABLE); bool broadcastPacket(uint8 *data, uint32 length, uint8 channelNo, uint32 flag = RELIABLE); private: void registerHandler(bool (PacketHandler::*handler)(HANDLE_ARGS), PacketCmd pktcmd,Channel c); @@ -72,5 +75,6 @@ class PacketHandler ENetHost *_server; BlowFish *_blowfish; bool (PacketHandler::*_handlerTable[0x100][0x7])(HANDLE_ARGS); + ENetPeer *m_CurrPeer; }; #endif \ No newline at end of file diff --git a/gamed/Packets.cpp b/gamed/Packets.cpp index 3c0afb41..2946f9e6 100644 --- a/gamed/Packets.cpp +++ b/gamed/Packets.cpp @@ -17,3 +17,4 @@ along with this program. If not, see . */ #include "stdafx.h" #include "Packets.h" +#include \ No newline at end of file diff --git a/gamed/Packets.h b/gamed/Packets.h index c770db8d..2ac2cee7 100644 --- a/gamed/Packets.h +++ b/gamed/Packets.h @@ -18,10 +18,11 @@ along with this program. If not, see . #ifndef _PACKETS_H #define _PACKETS_H -#include + #include "common.h" #include #include +#include #if defined( __GNUC__ ) #pragma pack(1) @@ -474,8 +475,8 @@ struct ChatMessage { uint32 unk1; uint8 unk2; - uint32 playerNo; - ChatType type; + ChatType type; + uint32 playerNo; uint32 lenght; uint8 unk3[32]; int8 msg; diff --git a/gamed/Player.cpp b/gamed/Player.cpp new file mode 100644 index 00000000..b1022d8e --- /dev/null +++ b/gamed/Player.cpp @@ -0,0 +1,41 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "stdafx.h" +#include "Player.h" + + +LoadScreenPlayer* Player::GetLoadScreenPlayerName() +{ + + int8 *n = new int8[name.length()+1]; + memcpy(n, name.c_str(), name.length()+1); + LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadName, n, name.length()); + p->userId = userId; + return p; +} +LoadScreenPlayer* Player::GetLoadScreenPlayerHero() +{ + int8 *n = new int8[type.length()+1]; + memcpy(n, type.c_str(), type.length()+1); + LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadHero, n, type.length()); + p->userId = userId; + p->skinId = skinId; + return p; +} + +ClientInfo* \ No newline at end of file diff --git a/gamed/Player.h b/gamed/Player.h new file mode 100644 index 00000000..a5c19486 --- /dev/null +++ b/gamed/Player.h @@ -0,0 +1,44 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef _PLAYER_H +#define _PLAYER_H + +#include "stdafx.h" +#include "Packets.h" + +class ClientInfo; +class Player +{ +public: + uint64 userId; + uint32 netId; + uint32 skinId; + std::string type; + std::string name; + uint8 team; + + Player(uint64 userId, uint32 skinId, std::string name, uint8 team); + LoadScreenPlayer* GetLoadScreenPlayerName(); + LoadScreenPlayer* GetLoadScreenPlayerHero(); + ClientInfo* GetClientInfo(); +}; + +inline Player::Player(uint64 _userId, uint32 _skinId, std::string _name, uint8 _team) : userId(_userId), skinId(_skinId), name(_name), team(_team) +{} + +#endif \ No newline at end of file diff --git a/gamed/main.cpp b/gamed/main.cpp index 20058463..fb1a6a72 100644 --- a/gamed/main.cpp +++ b/gamed/main.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . #include "stdafx.h" #include "NetworkListener.h" #include "Log.h" +#include "GameSession.h" #define SERVER_HOST ENET_HOST_ANY #define SERVER_PORT 5119 @@ -32,8 +33,12 @@ int main(int argc, char ** argv) ENetAddress address; address.host = SERVER_HOST; address.port = SERVER_PORT; - + listener->initialize(&address, SERVER_KEY); + + Logging->writeLine("Initializing GameSession\n"); + GameSession::Init(listener->GetPacketHandler()); + Logging->writeLine("Starting net loop\n"); listener->netLoop(); delete listener; diff --git a/local.bat b/local.bat index adf83941..17f615db 100644 --- a/local.bat +++ b/local.bat @@ -1,4 +1,9 @@ @echo off +set /P id=Enter username: %=% +set /P ch=Enter champion: %=% +set /P ip=Enter IP: %=% + +pause setlocal enabledelayedexpansion echo ----------------------- echo IntWars Solo Launcher @@ -124,7 +129,7 @@ set lolver=!v0!.!v1!.!v2!.!v3! @cd /d "!RADS_PATH!\solutions\lol_game_client_sln\releases\!lolver!\deploy" if exist "League of Legends.exe" ( - @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "127.0.0.1 5119 17BLOhi6KZsTtldTsizvHg== 47917791" + @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "%ip% 5119 17BLOhi6KZsTtldTsizvHg== 47917791" goto exit ) :cannotFind diff --git a/localz.bat b/localz.bat new file mode 100644 index 00000000..0dee6e14 --- /dev/null +++ b/localz.bat @@ -0,0 +1,137 @@ +@echo off + +setlocal enabledelayedexpansion +echo ----------------------- +echo IntWars Solo Launcher +echo ----------------------- +set RADS_PATH= +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path again.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +goto cannotFind +:runApp +set RADS_PATH=%RADS_PATH:/=\% +@cd /d "%RADS_PATH%\solutions\lol_game_client_sln\releases" + +set init=0 +set v0=0&set v1=0&set v2=0&set v3=0 +for /f "delims=" %%F in ('dir * /b ^| findstr ^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$') do ( + for /F "tokens=1,2,3,4 delims=." %%i in ("%%F") do ( + if !init! equ 0 ( set init=1&set flag=1 ) else ( + set flag=0 + + if %%i gtr !v0! ( set flag=1 ) else ( + if %%j gtr !v1! ( set flag=1 ) else ( + if %%k gtr !v2! ( set flag=1 ) else ( + if %%l gtr !v3! ( set flag=1 ) + ) + ) + ) + ) + + if !flag! gtr 0 ( + set v0=%%i&set v1=%%j&set v2=%%k&set v3=%%l + ) + ) +) + +if !init! equ 0 goto cannotFind +set lolver=!v0!.!v1!.!v2!.!v3! + +@cd /d "!RADS_PATH!\solutions\lol_game_client_sln\releases\!lolver!\deploy" +if exist "League of Legends.exe" ( + @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "127.0.0.1 5119 17BLOhi6KZsTtldTsizvHg== 47917791" + goto exit +) +:cannotFind +echo =================== +echo Cannot find LoL path automatically :( +echo =================== +@pause +goto exit +:exit diff --git a/map ids.txt b/map ids.txt new file mode 100644 index 00000000..c1a87ef8 --- /dev/null +++ b/map ids.txt @@ -0,0 +1,9 @@ + maps[1] = createMap(1,"SummonersRift","Summoner\'s Rift","",10); + maps[2] = createMap(2,"SummonersRiftWinter","Summoner\'s Rift (Autumn)","",10); + maps[4] = createMap(4,"OldTwistedTreeline","The Twisted Treeline","",6); + maps[7] = createMap(7,"ProvingGroundsARAM","The Proving Grounds","",10); + maps[8] = createMap(8,"CrystalScar","The Crystal Scar","",10); + maps[10] = createMap(10,"TwistedTreeline","The Twisted Treeline","",6); + maps[11] = createMap(11,"DebugMap1","Debug Map 1","",10); + maps[12] = createMap(12,"HowlingAbyss","The Howling Abyss","",10); + maps[13] = createMap(13,"DebugMap3","Debug Map 3","",10); \ No newline at end of file diff --git a/win/VC100/Client.cpp b/win/VC100/Client.cpp new file mode 100644 index 00000000..303a2897 --- /dev/null +++ b/win/VC100/Client.cpp @@ -0,0 +1,75 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "stdafx.h" +#include "Client.h" + +ClientInfo::ClientInfo() +{ + keyChecked = false; + name = type = NULL; + ticks = 0; + skinNo = 0; +} + +ClientInfo::~ClientInfo() +{ + if (name != NULL) + delete[] name; + if (type != NULL) + delete[] type; +} + +void ClientInfo::setName(char *name) +{ + if (this->name != NULL) + delete[] this->name; + + nameLen = strlen(name); + this->name = new int8[nameLen + 1]; + memcpy(this->name, name, nameLen + 1); +} + +void ClientInfo::setType(char *type) +{ + if (this->type != NULL) + delete[] this->type; + + typeLen = strlen(type); + this->type = new int8[typeLen + 1]; + memcpy(this->type, type, typeLen + 1); +} + +uint32 ClientInfo::getTicks() +{ + ticks++; + return ticks; +} + +LoadScreenPlayer* ClientInfo::GetLoadScreenPlayerName() +{ + LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadName, name, nameLen); + p->userId = userId; + return p; +} +LoadScreenPlayer* ClientInfo::GetLoadScreenPlayerHero() +{ + LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadHero, type, typeLen); + p->userId = userId; + p->skinId = skinNo; + return p; +} \ No newline at end of file diff --git a/win/VC100/GameSession.cpp b/win/VC100/GameSession.cpp new file mode 100644 index 00000000..748a8541 --- /dev/null +++ b/win/VC100/GameSession.cpp @@ -0,0 +1,68 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "stdafx.h" +#include "GameSession.h" +#include "Map.h" +#include "Client.h" +#include "Log.h" + +std::vector GameSession::m_Players; +Map* GameSession::m_Map = 0; + +void GameSession::Init(PacketHandler* packetHandler) +{ + m_Map = new Map(packetHandler); +} + +GameSession::~GameSession() +{ + delete m_Map; + m_Map = 0; + + for (int i = 0; i < m_Players.size(); i++) + { + delete m_Players[i]; + m_Players[i] = 0; + } + m_Players.clear(); +} + +void GameSession::AddPlayer(ClientInfo* player) +{ + if (std::find(m_Players.begin(), m_Players.end(), player) != m_Players.end()) { + //Logging->writeLine("player %s already in playerlist", player->name); + return; + } + m_Players.push_back(player); +} + +const std::vector& GameSession::GetPlayerList() +{ + return m_Players; +} + +ClientInfo* GameSession::FindPlayer(uint32 netId) +{ + for (int i = 0; i < m_Players.size(); i++) + { + if (m_Players[i]->netId == netId) + return m_Players[i]; + } + + return NULL; +} \ No newline at end of file diff --git a/win/VC100/GameSession.h b/win/VC100/GameSession.h new file mode 100644 index 00000000..f95c614a --- /dev/null +++ b/win/VC100/GameSession.h @@ -0,0 +1,48 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef _GAME_SESSION_H +#define _GAME_SESSION_H + +#include "stdafx.h" +#include +#include "Map.h" + +class ClientInfo; +class PacketHandler; +class GameSession +{ +public: + ~GameSession(); + + static void Init(PacketHandler* packetHandler); + static void AddPlayer(ClientInfo* player); + static const std::vector& GetPlayerList(); + static ClientInfo* FindPlayer(uint32 netId); + static Map* GetMap(); + +private: + static std::vector m_Players; + static Map* m_Map; +}; + +inline Map* GameSession::GetMap() +{ + return m_Map; +} + +#endif \ No newline at end of file diff --git a/win/VC100/Map.cpp b/win/VC100/Map.cpp new file mode 100644 index 00000000..5ca8e3ae --- /dev/null +++ b/win/VC100/Map.cpp @@ -0,0 +1,71 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#include "stdafx.h" +#include "Map.h" +#include "PacketHandler.h" +#include "GameSession.h" + +bool Map::Init() +{ + int blueTeam = 0; + int redTeam = 0; + LoadScreenInfo screenInfo; + + std::vector m_players = GameSession::GetPlayerList(); + + //Builds team info + for (int i = 0; i < m_players.size(); i++) + { + if (m_players[i]->team == 0) + { + blueTeam++; + screenInfo.bluePlayersIds[i] = m_players[i]->userId; + } + else + { + redTeam++; + screenInfo.redPlayersIds[i] = m_players[i]->userId; + } + } + + screenInfo.bluePlayerNo = blueTeam; + screenInfo.redPlayerNo = redTeam; + + bool pInfo = m_PacketHandler->sendPacket(reinterpret_cast(&screenInfo), sizeof(LoadScreenInfo), CHL_LOADING_SCREEN); + + bool noerr; + + //For all players send this info + for (int i = 0; i < m_players.size(); i++) + { + LoadScreenPlayer* playerName = m_players[i]->GetLoadScreenPlayerName(); + LoadScreenPlayer* playerHero = m_players[i]->GetLoadScreenPlayerHero(); + + noerr = m_PacketHandler->sendPacket(reinterpret_cast(playerName), playerName->getPacketLength(), CHL_LOADING_SCREEN); + LoadScreenPlayer::destroy(playerName); + if (!noerr) + break; + noerr = m_PacketHandler->sendPacket(reinterpret_cast(playerHero), playerHero->getPacketLength(), CHL_LOADING_SCREEN); + LoadScreenPlayer::destroy(playerHero); + if (!noerr) + break; + } + + + return (pInfo && noerr); +} diff --git a/win/VC100/Map.h b/win/VC100/Map.h new file mode 100644 index 00000000..8bbadd8e --- /dev/null +++ b/win/VC100/Map.h @@ -0,0 +1,39 @@ +/* +IntWars playground server for League of Legends protocol testing +Copyright (C) 2012 Intline9 + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ +#ifndef _MAP_H +#define _MAP_H + +#include "stdafx.h" + +class PacketHandler; +class Map +{ +public: + Map(PacketHandler* packetHandler); + bool Init(); + +private: + PacketHandler* m_PacketHandler; +}; + +inline Map::Map(PacketHandler* _packetHandler) : m_PacketHandler(_packetHandler) +{ + +} + +#endif \ No newline at end of file diff --git a/win/VC100/enet-1.2.5.vcxproj b/win/VC100/enet-1.2.5.vcxproj index 57507616..82c75e9d 100644 --- a/win/VC100/enet-1.2.5.vcxproj +++ b/win/VC100/enet-1.2.5.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,10 +19,12 @@ StaticLibrary Unicode + v120 StaticLibrary Unicode + v120 diff --git a/win/VC100/gamed.vcxproj b/win/VC100/gamed.vcxproj index 971f8623..3ff9510e 100644 --- a/win/VC100/gamed.vcxproj +++ b/win/VC100/gamed.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,10 +19,12 @@ Application Unicode + v120 Application Unicode + v120 @@ -77,7 +79,10 @@ + + + @@ -87,6 +92,8 @@ + + diff --git a/win/VC100/gamed.vcxproj.filters b/win/VC100/gamed.vcxproj.filters index 03a62d34..f0e89bae 100644 --- a/win/VC100/gamed.vcxproj.filters +++ b/win/VC100/gamed.vcxproj.filters @@ -16,6 +16,9 @@ {eeac7bfa-3b4f-4c49-987a-ab1bfa6da602} + + {4d3d70f9-7ac8-4945-a22b-ae0077d5a5b8} + @@ -34,6 +37,15 @@ Protocol + + logic + + + logic + + + Source Files + @@ -60,5 +72,11 @@ Header Files + + logic + + + logic + \ No newline at end of file diff --git a/win/VC100/intlib.vcxproj b/win/VC100/intlib.vcxproj index 4bef66d9..27a2d44a 100644 --- a/win/VC100/intlib.vcxproj +++ b/win/VC100/intlib.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,10 +19,12 @@ StaticLibrary Unicode + v120 StaticLibrary Unicode + v120 From 621c7af42e7e69a6fd6fe1a134168af5515006bd Mon Sep 17 00:00:00 2001 From: noobasaurus Date: Thu, 17 Jul 2014 09:55:32 -0700 Subject: [PATCH 2/4] Revert "Making it identical to what I have" This reverts commit 8cef9852485db8f98d40ebdd49f510136183fc7b. --- CONNECT TO LAN.bat | 136 -------------------------- bin/VC120_Debug/error.txt | 0 bin/VC120_Debug/output.txt | 0 common.h | 131 ++++++++++++------------- gamed/Client.cpp | 75 --------------- gamed/Client.h | 52 +++++++--- gamed/GameSession.cpp | 68 ------------- gamed/GameSession.h | 48 --------- gamed/Handlers.cpp | 166 +++++++++++++++----------------- gamed/Log.cpp | 2 - gamed/Log.h | 37 +++---- gamed/Map.cpp | 71 -------------- gamed/Map.h | 39 -------- gamed/NetworkListener.cpp | 12 --- gamed/NetworkListener.h | 1 - gamed/PacketHandler.cpp | 8 +- gamed/PacketHandler.h | 10 +- gamed/Packets.cpp | 1 - gamed/Packets.h | 7 +- gamed/Player.cpp | 41 -------- gamed/Player.h | 44 --------- gamed/main.cpp | 7 +- local.bat | 7 +- localz.bat | 137 -------------------------- map ids.txt | 9 -- win/VC100/Client.cpp | 75 --------------- win/VC100/GameSession.cpp | 68 ------------- win/VC100/GameSession.h | 48 --------- win/VC100/Map.cpp | 71 -------------- win/VC100/Map.h | 39 -------- win/VC100/enet-1.2.5.vcxproj | 4 +- win/VC100/gamed.vcxproj | 9 +- win/VC100/gamed.vcxproj.filters | 18 ---- win/VC100/intlib.vcxproj | 4 +- 34 files changed, 209 insertions(+), 1236 deletions(-) delete mode 100644 CONNECT TO LAN.bat delete mode 100644 bin/VC120_Debug/error.txt delete mode 100644 bin/VC120_Debug/output.txt delete mode 100644 gamed/Client.cpp delete mode 100644 gamed/GameSession.cpp delete mode 100644 gamed/GameSession.h delete mode 100644 gamed/Map.cpp delete mode 100644 gamed/Map.h delete mode 100644 gamed/Player.cpp delete mode 100644 gamed/Player.h delete mode 100644 localz.bat delete mode 100644 map ids.txt delete mode 100644 win/VC100/Client.cpp delete mode 100644 win/VC100/GameSession.cpp delete mode 100644 win/VC100/GameSession.h delete mode 100644 win/VC100/Map.cpp delete mode 100644 win/VC100/Map.h diff --git a/CONNECT TO LAN.bat b/CONNECT TO LAN.bat deleted file mode 100644 index adf83941..00000000 --- a/CONNECT TO LAN.bat +++ /dev/null @@ -1,136 +0,0 @@ -@echo off -setlocal enabledelayedexpansion -echo ----------------------- -echo IntWars Solo Launcher -echo ----------------------- -set RADS_PATH= -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( - set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m - goto runApp -) -cls -echo =================== -echo Finding another LoL directory path.. -echo =================== -for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( - set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m - goto runApp -) -cls -echo =================== -echo Finding another LoL directory path.. -echo =================== -for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( - set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m - goto runApp -) -cls -echo =================== -echo Finding another LoL directory path again.. -echo =================== -for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( - set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m - goto runApp -) -cls -goto cannotFind -:runApp -set RADS_PATH=%RADS_PATH:/=\% -@cd /d "%RADS_PATH%\solutions\lol_game_client_sln\releases" - -set init=0 -set v0=0&set v1=0&set v2=0&set v3=0 -for /f "delims=" %%F in ('dir * /b ^| findstr ^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$') do ( - for /F "tokens=1,2,3,4 delims=." %%i in ("%%F") do ( - if !init! equ 0 ( set init=1&set flag=1 ) else ( - set flag=0 - - if %%i gtr !v0! ( set flag=1 ) else ( - if %%j gtr !v1! ( set flag=1 ) else ( - if %%k gtr !v2! ( set flag=1 ) else ( - if %%l gtr !v3! ( set flag=1 ) - ) - ) - ) - ) - - if !flag! gtr 0 ( - set v0=%%i&set v1=%%j&set v2=%%k&set v3=%%l - ) - ) -) - -if !init! equ 0 goto cannotFind -set lolver=!v0!.!v1!.!v2!.!v3! - -@cd /d "!RADS_PATH!\solutions\lol_game_client_sln\releases\!lolver!\deploy" -if exist "League of Legends.exe" ( - @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "127.0.0.1 5119 17BLOhi6KZsTtldTsizvHg== 47917791" - goto exit -) -:cannotFind -echo =================== -echo Cannot find LoL path automatically :( -echo =================== -@pause -goto exit -:exit diff --git a/bin/VC120_Debug/error.txt b/bin/VC120_Debug/error.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/bin/VC120_Debug/output.txt b/bin/VC120_Debug/output.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/common.h b/common.h index acf56c75..cbb1fe87 100644 --- a/common.h +++ b/common.h @@ -20,78 +20,73 @@ along with this program. If not, see . enum GameCmd : uint8 { -PKT_S2C_MoveAns = 0x61, + PKT_S2C_MoveAns = 0x60, }; //Currently attuned to Live 4.5.0.264 - enum PacketCmd : uint8 -{ //Channel //Type -PKT_KeyCheck = 0x00, //0 //UPDATED -PKT_C2S_ClientConnect_NamedPipe = 0x01, - -PKT_S2C_EndSpawn = 0x11, //? //UPDATED -PKT_C2S_QueryStatusReq = 0x14, //1 //UPDATED -PKT_S2C_SkillUp = 0x16, //3 //UPDATED -PKT_C2S_Ping_Load_Info = 0x16, //1 //UPDATED - -PKT_S2C_ViewAns = 0x2C, //3 //UPDATED -PKT_C2S_ViewReq = 0x2E, //1 //UPDATED - -PKT_C2S_SkillUp = 0x39, //1 //UPDATED -PKT_S2C_AttentionPing = 0x3F, //3 //UPDATED - -PKT_S2C_Emotion = 0x42, //3 UPDATED -PKT_C2S_Emotion = 0x48, //1 UPDATED -PKT_S2C_HeroSpawn = 0x4C, //3 UPDATED -PKT_S2C_Announce = 0x4D, //3 - -PKT_S2C_GameTimer = 0xC0, -PKT_S2C_GameTimerUpdate = 0xC1, - -PKT_C2S_StartGame = 0x52, //1 //UPDATED -PKT_S2C_SynchVersion = 0x54, //3 //UPDATED -PKT_C2S_ScoreBord = 0x56, //1 //UPDATED -PKT_C2S_AttentionPing = 0x57, //1 //UPDATED -PKT_S2C_StartGame = 0x5C, //? //UPDATED - -PKT_S2C_StartSpawn = 0x62, //? //UPDATED -//PKT_C2S_OpenShop = 0x63, //1 - DEPRECATED -PKT_C2S_ClientReady = 0x64, //6 //UPDATED ? -PKT_S2C_LoadHero = 0x65, //6 //UPDATED -PKT_S2C_LoadName = 0x66, //6 //UPDATED -PKT_S2C_LoadScreenInfo = 0x67, //6 //UPDATED -PKT_ChatBoxMessage = 0x68, //5 //UPDATED -PKT_S2C_BuyItemAns = 0x6F, //3 //UPDATED - -PKT_C2S_MoveReq = 0x72, //1 //UPDATED -PKT_C2S_MoveConfirm = 0x77, //1 //UPDATED - -PKT_C2S_LockCamera = 0x81, //1 //UPDATED -PKT_C2S_BuyItemReq = 0x82, //1 //UPDATED -PKT_S2C_QueryStatusAns = 0x88, //? //UPDATED -PKT_C2S_Exit = 0x8F, //1 //UPDATED - -PKT_World_SendGameNumber = 0x92, //3 //UPDATED -PKT_S2C_Ping_Load_Info = 0x95, //4 //UPDATED -PKT_S2C_UpdateModel = 0x97, -PKT_S2C_TurretSpawn = 0x9D, //3 UPDATED - -PKT_C2S_Surrender = 0xA4, //1 //UPDATED -//PKT_C2S_GameNumberReq = 0xA6, //1 //DEPRECATED -PKT_C2S_StatsConfirm = 0xA8, //1 UPDATED -PKT_S2C_HeroSpawnUnk3 = 0xAE, -PKT_C2S_Click = 0xAF, //1 //UPDATED - -PKT_S2C_HeroSpawnUnk2 = 0xBA, -PKT_C2S_SynchVersion = 0xBD, //1 //UPDATED -PKT_C2S_CharLoaded = 0xBE, //1 //UPDATED - -PKT_S2C_CharStats = 0xC4, //4 //UPDATED -PKT_S2C_FogUpdate2 = 0x23, //3 //UPDATED? -PKT_S2C_LevelPropSpawn = 0xD0, //3 UPDATED - -PKT_Batch = 0xFF, //3 +{ //Channel //Type + PKT_KeyCheck = 0x00, //0 //UPDATED + + PKT_S2C_EndSpawn = 0x11, //? //UPDATED + PKT_C2S_QueryStatusReq = 0x14, //1 //UPDATED + PKT_S2C_SkillUp = 0x15, //3 //UPDATED + PKT_C2S_Ping_Load_Info = 0x16, //1 //UPDATED + + PKT_S2C_ViewAns = 0x2B, //3 //UPDATED + PKT_C2S_ViewReq = 0x2D, //1 //UPDATED + + PKT_C2S_SkillUp = 0x38, //1 //UPDATED + PKT_S2C_AttentionPing = 0x3F, //3 //UPDATED + + PKT_S2C_Emotion = 0x41, //3 UPDATED + PKT_C2S_Emotion = 0x47, //1 UPDATED + PKT_S2C_HeroSpawn = 0x4B, //3 UPDATED + PKT_S2C_Announce = 0x4C, //3 + + PKT_S2C_GameTimer = 0xC0, + PKT_S2C_GameTimerUpdate = 0xC1, + + PKT_C2S_StartGame = 0x51, //1 //UPDATED + PKT_S2C_SynchVersion = 0x53, //3 //UPDATED + PKT_C2S_ScoreBord = 0x55, //1 //UPDATED + PKT_C2S_AttentionPing = 0x56, //1 //UPDATED + PKT_S2C_StartGame = 0x5B, //? //UPDATED + + PKT_S2C_StartSpawn = 0x61, //? //UPDATED + //PKT_C2S_OpenShop = 0x63, //1 - DEPRECATED + PKT_C2S_ClientReady = 0x64, //6 //UPDATED ? + PKT_S2C_LoadHero = 0x65, //6 //UPDATED + PKT_S2C_LoadName = 0x66, //6 //UPDATED + PKT_S2C_LoadScreenInfo = 0x67, //6 //UPDATED + PKT_ChatBoxMessage = 0x68, //5 //UPDATED + PKT_S2C_BuyItemAns = 0x6E, //3 //UPDATED + + PKT_C2S_MoveReq = 0x71, //1 //UPDATED + PKT_C2S_MoveConfirm = 0x76, //1 //UPDATED + + PKT_C2S_LockCamera = 0x80, //1 //UPDATED + PKT_C2S_BuyItemReq = 0x81, //1 //UPDATED + PKT_S2C_QueryStatusAns = 0x87, //? //UPDATED + PKT_C2S_Exit = 0x8E, //1 //UPDATED + + PKT_World_SendGameNumber = 0x91, //3 //UPDATED + PKT_S2C_Ping_Load_Info = 0x94, //4 //UPDATED + PKT_S2C_TurretSpawn = 0x9C, //3 UPDATED + + PKT_C2S_Surrender = 0xA3, //1 //UPDATED + //PKT_C2S_GameNumberReq = 0xA6, //1 //DEPRECATED + PKT_C2S_StatsConfirm = 0xA7, //1 UPDATED + PKT_C2S_Click = 0xAE, //1 //UPDATED + + PKT_C2S_SynchVersion = 0xBC, //1 //UPDATED + PKT_C2S_CharLoaded = 0xBD, //1 //UPDATED + + PKT_S2C_CharStats = 0xC3, //4 //UPDATED + PKT_S2C_FogUpdate2 = 0x23, //3 //UPDATED? + PKT_S2C_LevelPropSpawn = 0xCF, //3 UPDATED + + PKT_Batch = 0xFF, //3 }; enum MoveType : uint8 diff --git a/gamed/Client.cpp b/gamed/Client.cpp deleted file mode 100644 index 7e9da387..00000000 --- a/gamed/Client.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "stdafx.h" -#include "Client.h" - -ClientInfo::ClientInfo() -{ - keyChecked = false; - name = type = NULL; - ticks = 0; - skinNo = 0; -} - -ClientInfo::~ClientInfo() -{ - if(name != NULL) - delete[] name; - if(type != NULL) - delete[] type; -} - -void ClientInfo::setName(char *name) -{ - if(this->name != NULL) - delete[] this->name; - - nameLen = strlen(name); - this->name = new int8[nameLen+1]; - memcpy(this->name, name, nameLen+1); -} - -void ClientInfo::setType(char *type) -{ - if(this->type != NULL) - delete[] this->type; - - typeLen = strlen(type); - this->type = new int8[typeLen+1]; - memcpy(this->type, type, typeLen+1); -} - -uint32 ClientInfo::getTicks() -{ - ticks++; - return ticks; -} - -LoadScreenPlayer* ClientInfo::GetLoadScreenPlayerName() -{ - LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadName, name, nameLen); - p->userId = userId; - return p; -} -LoadScreenPlayer* ClientInfo::GetLoadScreenPlayerHero() -{ - LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadHero, type, typeLen); - p->userId = userId; - p->skinId = skinNo; - return p; -} \ No newline at end of file diff --git a/gamed/Client.h b/gamed/Client.h index fed2c0e7..2aae0eaa 100644 --- a/gamed/Client.h +++ b/gamed/Client.h @@ -19,22 +19,50 @@ along with this program. If not, see . #define _CLIENT_H #include "common.h" -#include "Packets.h" -class ClientInfo +struct ClientInfo { -public: - ClientInfo(); - ~ClientInfo(); + ClientInfo() + { + keyChecked = false; + name = type = NULL; + ticks = 0; + skinNo = 0; + } - void setName(char *name); - void setType(char *type); + ~ClientInfo() + { + if(name != NULL) + delete[] name; + if(type != NULL) + delete[] type; + } - LoadScreenPlayer* GetLoadScreenPlayerName(); - LoadScreenPlayer* GetLoadScreenPlayerHero(); + void setName(char *name) + { + if(this->name != NULL) + delete[] this->name; - uint32 getTicks(); + nameLen = strlen(name); + this->name = new int8[nameLen+1]; + memcpy(this->name, name, nameLen+1); + } + void setType(char *type) + { + if(this->type != NULL) + delete[] this->type; + + typeLen = strlen(type); + this->type = new int8[typeLen+1]; + memcpy(this->type, type, typeLen+1); + } + + uint32 getTicks() + { + ticks++; + return ticks; + } bool keyChecked; uint64 userId; uint32 ticks; @@ -44,10 +72,8 @@ class ClientInfo uint32 skinNo; int8 *name; int8 *type; - uint8 team; - ENetPeer *peer; -}; +}; #define peerInfo(p) ((ClientInfo*)p->data) #endif \ No newline at end of file diff --git a/gamed/GameSession.cpp b/gamed/GameSession.cpp deleted file mode 100644 index 2769647a..00000000 --- a/gamed/GameSession.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "stdafx.h" -#include "GameSession.h" -#include "Map.h" -#include "Client.h" -#include "Log.h" - -std::vector GameSession::m_Players; -Map* GameSession::m_Map = 0; - -void GameSession::Init(PacketHandler* packetHandler) -{ - m_Map = new Map(packetHandler); -} - -GameSession::~GameSession() -{ - delete m_Map; - m_Map = 0; - - for(int i=0; i < m_Players.size();i++) - { - delete m_Players[i]; - m_Players[i] = 0; - } - m_Players.clear(); -} - -void GameSession::AddPlayer(ClientInfo* player) -{ - if(std::find(m_Players.begin(), m_Players.end(), player) != m_Players.end()) { - //Logging->writeLine("player %s already in playerlist", player->name); - return; - } - m_Players.push_back(player); -} - -const std::vector& GameSession::GetPlayerList() -{ - return m_Players; -} - -ClientInfo* GameSession::FindPlayer(uint32 netId) -{ - for(int i=0; i < m_Players.size();i++) - { - if(m_Players[i]->netId == netId) - return m_Players[i]; - } - - return NULL; -} \ No newline at end of file diff --git a/gamed/GameSession.h b/gamed/GameSession.h deleted file mode 100644 index f95c614a..00000000 --- a/gamed/GameSession.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#ifndef _GAME_SESSION_H -#define _GAME_SESSION_H - -#include "stdafx.h" -#include -#include "Map.h" - -class ClientInfo; -class PacketHandler; -class GameSession -{ -public: - ~GameSession(); - - static void Init(PacketHandler* packetHandler); - static void AddPlayer(ClientInfo* player); - static const std::vector& GetPlayerList(); - static ClientInfo* FindPlayer(uint32 netId); - static Map* GetMap(); - -private: - static std::vector m_Players; - static Map* m_Map; -}; - -inline Map* GameSession::GetMap() -{ - return m_Map; -} - -#endif \ No newline at end of file diff --git a/gamed/Handlers.cpp b/gamed/Handlers.cpp index 9d387e0a..9630bf3f 100644 --- a/gamed/Handlers.cpp +++ b/gamed/Handlers.cpp @@ -18,15 +18,12 @@ along with this program. If not, see . #include "stdafx.h" #include "PacketHandler.h" #include "NetworkListener.h" -#include "GameSession.h" -#include "Player.h" bool PacketHandler::handleNull(HANDLE_ARGS) { return true; } -bool PacketHandler::handleKeyCheck(HANDLE_ARGS) -{ +bool PacketHandler::handleKeyCheck(ENetPeer *peer, ENetPacket *packet) { KeyCheck *keyCheck = (KeyCheck *)packet->data; uint64 userId = _blowfish->Decrypt(keyCheck->checkId); /* @@ -40,70 +37,77 @@ bool PacketHandler::handleKeyCheck(HANDLE_ARGS) PDEBUG_LOG_LINE(Logging," Enc id: %s\n", buffer);*/ if(userId == keyCheck->userId) { PDEBUG_LOG_LINE(Logging, " User got the same key as i do, go on!\n"); - peerInfo(m_CurrPeer)->keyChecked = true; - peerInfo(m_CurrPeer)->userId = userId; - - std::vector players = GameSession::GetPlayerList(); - for(int i=0; i < players.size();i++) - { - if(players[i]->netId == peerInfo(m_CurrPeer)->netId) - { - players[i]->userId = userId; - break; - } - } + peerInfo(peer)->keyChecked = true; + peerInfo(peer)->userId = userId; } else { Logging->errorLine(" WRONG KEY, GTFO!!!\n"); - return false; + return false; } //Send response as this is correct (OFC DO SOME ID CHECKS HERE!!!) KeyCheck response; response.userId = keyCheck->userId; - bool bRet = sendPacket(reinterpret_cast(&response), sizeof(KeyCheck), CHL_HANDSHAKE); - handleGameNumber(NULL);//Send 0x91 Packet? + bool bRet = sendPacket(peer, reinterpret_cast(&response), sizeof(KeyCheck), CHL_HANDSHAKE); + handleGameNumber(peer, NULL);//Send 0x91 Packet? return bRet; } -bool PacketHandler::handleGameNumber(HANDLE_ARGS) { +bool PacketHandler::handleGameNumber(ENetPeer *peer, ENetPacket *packet) { WorldSendGameNumber world; world.gameId = 1; strcpy((char *)world.data1, "EUW1"); - memcpy(world.data, peerInfo(m_CurrPeer)->name, peerInfo(m_CurrPeer)->nameLen); - return sendPacket(reinterpret_cast(&world), sizeof(WorldSendGameNumber), CHL_S2C); + memcpy(world.data, peerInfo(peer)->name, peerInfo(peer)->nameLen); + return sendPacket(peer, reinterpret_cast(&world), sizeof(WorldSendGameNumber), CHL_S2C); } -bool PacketHandler::handleSynch(HANDLE_ARGS) { +bool PacketHandler::handleSynch(ENetPeer *peer, ENetPacket *packet) { SynchVersion *version = reinterpret_cast(packet->data); Logging->writeLine("Client version: %s\n", version->version); SynchVersionAns answer; answer.mapId = 1; - answer.players[0].userId = peerInfo(m_CurrPeer)->userId; + answer.players[0].userId = peerInfo(peer)->userId; answer.players[0].skill1 = SPL_Ignite; answer.players[0].skill2 = SPL_Flash; - return sendPacket(reinterpret_cast(&answer), sizeof(SynchVersionAns), 3); + return sendPacket(peer, reinterpret_cast(&answer), sizeof(SynchVersionAns), 3); } -bool PacketHandler::handleMap(HANDLE_ARGS) { - return GameSession::GetMap()->Init(); +bool PacketHandler::handleMap(ENetPeer *peer, ENetPacket *packet) { + LoadScreenPlayer *playerName = LoadScreenPlayer::create(PKT_S2C_LoadName, peerInfo(peer)->name, peerInfo(peer)->nameLen); + playerName->userId = peerInfo(peer)->userId; + LoadScreenPlayer *playerHero = LoadScreenPlayer::create(PKT_S2C_LoadHero, peerInfo(peer)->type, peerInfo(peer)->typeLen); + playerHero->userId = peerInfo(peer)->userId; + playerHero->skinId = peerInfo(peer)->skinNo; + //Builds team info + LoadScreenInfo screenInfo; + screenInfo.bluePlayerNo = 1; + screenInfo.redPlayerNo = 0; + screenInfo.bluePlayerIds[0] = peerInfo(peer)->userId; + bool pInfo = sendPacket(peer, reinterpret_cast(&screenInfo), sizeof(LoadScreenInfo), CHL_LOADING_SCREEN); + //For all players send this info + bool pName = sendPacket(peer, reinterpret_cast(playerName), playerName->getPacketLength(), CHL_LOADING_SCREEN); + bool pHero = sendPacket(peer, reinterpret_cast(playerHero), playerHero->getPacketLength(), CHL_LOADING_SCREEN); + //cleanup + LoadScreenPlayer::destroy(playerName); + LoadScreenPlayer::destroy(playerHero); + return (pInfo && pName && pHero); } //building the map -bool PacketHandler::handleSpawn(HANDLE_ARGS) { +bool PacketHandler::handleSpawn(ENetPeer *peer, ENetPacket *packet) { StatePacket2 start(PKT_S2C_StartSpawn); - bool p1 = sendPacket(reinterpret_cast(&start), sizeof(StatePacket2), CHL_S2C); + bool p1 = sendPacket(peer, reinterpret_cast(&start), sizeof(StatePacket2), CHL_S2C); printf("Spawning map\r\n"); HeroSpawn spawn; - spawn.netId = peerInfo(m_CurrPeer)->netId; + spawn.netId = peerInfo(peer)->netId; spawn.gameId = 0; - memcpy(spawn.name, peerInfo(m_CurrPeer)->name, peerInfo(m_CurrPeer)->nameLen); - memcpy(spawn.type, peerInfo(m_CurrPeer)->type, peerInfo(m_CurrPeer)->typeLen); - bool p2 = sendPacket(reinterpret_cast(&spawn), sizeof(HeroSpawn), CHL_S2C); + memcpy(spawn.name, peerInfo(peer)->name, peerInfo(peer)->nameLen); + memcpy(spawn.type, peerInfo(peer)->type, peerInfo(peer)->typeLen); + bool p2 = sendPacket(peer, reinterpret_cast(&spawn), sizeof(HeroSpawn), CHL_S2C); HeroSpawn2 h2; - h2.header.netId = peerInfo(m_CurrPeer)->netId; - sendPacket(reinterpret_cast(&h2), sizeof(HeroSpawn2), CHL_S2C); + h2.header.netId = peerInfo(peer)->netId; + sendPacket(peer, reinterpret_cast(&h2), sizeof(HeroSpawn2), CHL_S2C); HeroSpawn3 h3; - h3.header.netId = peerInfo(m_CurrPeer)->netId; - sendPacket(reinterpret_cast(&h3), sizeof(HeroSpawn3), CHL_S2C); + h3.header.netId = peerInfo(peer)->netId; + sendPacket(peer, reinterpret_cast(&h3), sizeof(HeroSpawn3), CHL_S2C); //Spawn Turrets char *szTurrets[24] = { "@@Turret_T1_R_03_A", @@ -135,7 +139,7 @@ bool PacketHandler::handleSpawn(HANDLE_ARGS) { TurretSpawn turretSpawn; turretSpawn.tID = i + 1; strcpy((char *)turretSpawn.name, szTurrets[i]); - sendPacket(reinterpret_cast(&turretSpawn), sizeof(TurretSpawn), CHL_S2C); + sendPacket(peer, reinterpret_cast(&turretSpawn), sizeof(TurretSpawn), CHL_S2C); } //Spawn Props LevelPropSpawn lpSpawn; @@ -144,85 +148,85 @@ bool PacketHandler::handleSpawn(HANDLE_ARGS) { lpSpawn.netId = GetNewNetID(); lpSpawn.x = 12465; lpSpawn.y = 101; - sendPacket(reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); + sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); lpSpawn.SetProp("LevelProp_Yonkey1", "Yonkey"); lpSpawn.header.netId = 0; lpSpawn.netId = GetNewNetID(); lpSpawn.x = -76; lpSpawn.y = 94; - sendPacket(reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); + sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); lpSpawn.SetProp("LevelProp_ShopMale", "ShopMale"); lpSpawn.header.netId = 0; lpSpawn.netId = GetNewNetID(); lpSpawn.x = 13374; lpSpawn.y = 194; - sendPacket(reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); + sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); lpSpawn.SetProp("LevelProp_ShopMale1", "ShopMale"); lpSpawn.header.netId = 0; lpSpawn.netId = GetNewNetID(); lpSpawn.x = -99; lpSpawn.y = 191; - sendPacket(reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); + sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); StatePacket end(PKT_S2C_EndSpawn); - bool p3 = sendPacket(reinterpret_cast(&end), sizeof(StatePacket), CHL_S2C); + bool p3 = sendPacket(peer, reinterpret_cast(&end), sizeof(StatePacket), CHL_S2C); BuyItemAns recall; - recall.header.netId = peerInfo(m_CurrPeer)->netId; + recall.header.netId = peerInfo(peer)->netId; recall.itemId = 2001; recall.slotId = 7; recall.stack = 1; - bool p4 = sendPacket(reinterpret_cast(&recall), sizeof(BuyItemAns), CHL_S2C); //activate recall slot + bool p4 = sendPacket(peer, reinterpret_cast(&recall), sizeof(BuyItemAns), CHL_S2C); //activate recall slot GameTimer timer(0); //0xC0 - sendPacket(reinterpret_cast(&timer), sizeof(GameTimer), CHL_S2C); + sendPacket(peer, reinterpret_cast(&timer), sizeof(GameTimer), CHL_S2C); GameTimer timer2(0.4); //0xC0 - sendPacket(reinterpret_cast(&timer2), sizeof(GameTimer), CHL_S2C); + sendPacket(peer, reinterpret_cast(&timer2), sizeof(GameTimer), CHL_S2C); GameTimerUpdate timer3(0.4); //0xC1 - sendPacket(reinterpret_cast(&timer3), sizeof(GameTimerUpdate), CHL_S2C); + sendPacket(peer, reinterpret_cast(&timer3), sizeof(GameTimerUpdate), CHL_S2C); //lvl 1 R for elise for(int i = 0; i < 4; i++) { - SpellSet spell(peerInfo(m_CurrPeer)->netId, i, 1); - sendPacket(reinterpret_cast(&spell), sizeof(SpellSet), CHL_S2C); + SpellSet spell(peerInfo(peer)->netId, i, 1); + sendPacket(peer, reinterpret_cast(&spell), sizeof(SpellSet), CHL_S2C); } return p1 & p2 & p3; } bool PacketHandler::handleStartGame(HANDLE_ARGS) { StatePacket start(PKT_S2C_StartGame); - sendPacket(reinterpret_cast(&start), sizeof(StatePacket), CHL_S2C); + sendPacket(peer, reinterpret_cast(&start), sizeof(StatePacket), CHL_S2C); FogUpdate2 test; test.x = 0; test.y = 0; test.radius = 1; test.unk1 = 2; //uint8 p[] = {0xC5, 0x19, 0x00, 0x00, 0x40, 0x00, 0x00, 0x50}; - //sendPacket(reinterpret_cast(p), sizeof(p), 3); - sendPacket(reinterpret_cast(&test), sizeof(FogUpdate2), 3); + //sendPacket(peer, reinterpret_cast(p), sizeof(p), 3); + sendPacket(peer, reinterpret_cast(&test), sizeof(FogUpdate2), 3); //playing around 8-) /* CharacterStats movement; - movement.netId = peerInfo(m_CurrPeer)->netId; + movement.netId = peerInfo(peer)->netId; movement.statType = STI_Movement; movement.statValue = 800; sendPacket(peer,reinterpret_cast(&movement),sizeof(movement), 4);*/ return true; } -bool PacketHandler::handleAttentionPing(HANDLE_ARGS) { +bool PacketHandler::handleAttentionPing(ENetPeer *peer, ENetPacket *packet) { AttentionPing *ping = reinterpret_cast(packet->data); AttentionPingAns response(ping); Logging->writeLine("Plong x: %f, y: %f, z: %f, type: %i\n", ping->x, ping->y, ping->z, ping->type); return broadcastPacket(reinterpret_cast(&response), sizeof(AttentionPing), 3); } -bool PacketHandler::handleView(HANDLE_ARGS) { +bool PacketHandler::handleView(ENetPeer *peer, ENetPacket *packet) { ViewReq *request = reinterpret_cast(packet->data); //Logging->writeLine("View (%i), x:%f, y:%f, zoom: %f\n", request->requestNo, request->x, request->y, request->zoom); ViewAns answer; answer.requestNo = request->requestNo; - sendPacket(reinterpret_cast(&answer), sizeof(ViewAns), CHL_S2C, UNRELIABLE); - enet_host_flush(m_CurrPeer->host); + sendPacket(peer, reinterpret_cast(&answer), sizeof(ViewAns), CHL_S2C, UNRELIABLE); + enet_host_flush(peer->host); if(request->requestNo == 0xFE) { answer.requestNo = 0xFF; - sendPacket(reinterpret_cast(&answer), sizeof(ViewAns), CHL_S2C, UNRELIABLE); + sendPacket(peer, reinterpret_cast(&answer), sizeof(ViewAns), CHL_S2C, UNRELIABLE); } return true; } @@ -270,7 +274,7 @@ std::vector readWaypoints(byte *buffer, int coordCount) { #define MAP_WIDTH (13982 / 2) #define MAP_HEIGHT (14446 / 2) -bool PacketHandler::handleMove(HANDLE_ARGS) { +bool PacketHandler::handleMove(ENetPeer *peer, ENetPacket *packet) { MovementReq *request = reinterpret_cast(packet->data); switch(request->type) { //TODO, Implement stop commands @@ -288,7 +292,7 @@ bool PacketHandler::handleMove(HANDLE_ARGS) { MovementAns *answer = MovementAns::create(request->vectorNo); answer->ok = 1; answer->vectorNo = request->vectorNo; - answer->netId = peerInfo(m_CurrPeer)->netId; + answer->netId = peerInfo(peer)->netId; for(int i = 0; i < vMoves.size(); i++) { answer->getVector(i)->x = vMoves[i].x; answer->getVector(i)->y = vMoves[i].y; @@ -298,17 +302,17 @@ bool PacketHandler::handleMove(HANDLE_ARGS) { return bRet; } -bool PacketHandler::handleLoadPing(HANDLE_ARGS) { +bool PacketHandler::handleLoadPing(ENetPeer *peer, ENetPacket *packet) { PingLoadInfo *loadInfo = reinterpret_cast(packet->data); PingLoadInfo response; memcpy(&response, packet->data, sizeof(PingLoadInfo)); response.header.cmd = PKT_S2C_Ping_Load_Info; - response.userId = peerInfo(m_CurrPeer)->userId; + response.userId = peerInfo(peer)->userId; Logging->writeLine("loaded: %f, ping: %f, %f\n", loadInfo->loaded, loadInfo->ping, loadInfo->f3); bool bRet = broadcastPacket(reinterpret_cast(&response), sizeof(PingLoadInfo), CHL_LOW_PRIORITY, UNRELIABLE); static bool bLoad = false; if(!bLoad) { - handleMap(NULL); + handleMap(peer, NULL); bLoad = true; } return bRet; @@ -316,7 +320,7 @@ bool PacketHandler::handleLoadPing(HANDLE_ARGS) { bool PacketHandler::handleQueryStatus(HANDLE_ARGS) { QueryStatus response; - return sendPacket(reinterpret_cast(&response), sizeof(QueryStatus), CHL_S2C); + return sendPacket(peer, reinterpret_cast(&response), sizeof(QueryStatus), CHL_S2C); } bool PacketHandler::handleChatBoxMessage(HANDLE_ARGS) { @@ -331,10 +335,10 @@ bool PacketHandler::handleChatBoxMessage(HANDLE_ARGS) { float value = (float)atoi(&message->getMessage()[strlen(cmd[0]) + 5]); uint32 mask = 1 << abs(((int)fieldNo - 1)); CharacterStats *stats = CharacterStats::create(blockNo, mask); - stats->netId = peerInfo(m_CurrPeer)->netId; + stats->netId = peerInfo(peer)->netId; stats->setValue(blockNo, mask, value); Logging->writeLine("Setting to %f in block: %i, field: %i\n", value, blockNo, fieldNo); - sendPacket(reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); + sendPacket(peer, reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); stats->destroy(); return true; } @@ -342,10 +346,10 @@ bool PacketHandler::handleChatBoxMessage(HANDLE_ARGS) { if(strncmp(message->getMessage(), cmd[1], strlen(cmd[1])) == 0) { float gold = (float)atoi(&message->getMessage()[strlen(cmd[1]) + 1]); CharacterStats *stats = CharacterStats::create(FM1_Gold, 0, 0, 0, 0); - stats->netId = peerInfo(m_CurrPeer)->netId; + stats->netId = peerInfo(peer)->netId; stats->setValue(1, FM1_Gold, gold); Logging->writeLine("Set gold to %f\n", gold); - sendPacket(reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); + sendPacket(peer, reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); stats->destroy(); return true; } @@ -421,39 +425,25 @@ bool PacketHandler::handleChatBoxMessage(HANDLE_ARGS) { //Model if(strncmp(message->getMessage(), cmd[8], strlen(cmd[8])) == 0) { std::string sModel = (char *)&message->getMessage()[strlen(cmd[8]) + 1]; - UpdateModel modelPacket(peerInfo(m_CurrPeer)->netId, (char *)sModel.c_str()); //96 + UpdateModel modelPacket(peerInfo(peer)->netId, (char *)sModel.c_str()); //96 broadcastPacket(reinterpret_cast(&modelPacket), sizeof(UpdateModel), CHL_S2C); return true; } } - std::vector players = GameSession::GetPlayerList(); - ClientInfo* player; - bool res; switch(message->type) { case CMT_ALL: return broadcastPacket(packet->data, packet->dataLength, CHL_COMMUNICATION); break; case CMT_TEAM: //!TODO make a team class and foreach player in the team send the message - player = GameSession::FindPlayer(peerInfo(m_CurrPeer)->netId); - if(!player) - return false; - - for(int i=0; i < players.size();i++) - { - if(players[i]->team == player->team) - { - if(!sendPacket(packet->data, packet->dataLength, CHL_COMMUNICATION)) - return false; - } - } + return sendPacket(peer, packet->data, packet->dataLength, CHL_COMMUNICATION); break; default: Logging->errorLine("Unknown ChatMessageType\n"); - return sendPacket(packet->data, packet->dataLength, CHL_COMMUNICATION); + return sendPacket(peer, packet->data, packet->dataLength, CHL_COMMUNICATION); break; } - return true; + return false; } bool PacketHandler::handleSkillUp(HANDLE_ARGS) { @@ -463,7 +453,7 @@ bool PacketHandler::handleSkillUp(HANDLE_ARGS) { skillUpResponse.skill = skillUpPacket->skill; skillUpResponse.level = 0x01; skillUpResponse.pointsLeft = 5; - return sendPacket(reinterpret_cast(&skillUpResponse), sizeof(skillUpResponse), CHL_GAMEPLAY); + return sendPacket(peer, reinterpret_cast(&skillUpResponse), sizeof(skillUpResponse), CHL_GAMEPLAY); } bool PacketHandler::handleBuyItem(HANDLE_ARGS) { diff --git a/gamed/Log.cpp b/gamed/Log.cpp index f7b899f4..74576ad3 100644 --- a/gamed/Log.cpp +++ b/gamed/Log.cpp @@ -19,8 +19,6 @@ along with this program. If not, see . #include "Log.h" Log* Log::m_instance; -using namespace std; - Log::Log() { m_stream = &cout; diff --git a/gamed/Log.h b/gamed/Log.h index 58966477..358ea17b 100644 --- a/gamed/Log.h +++ b/gamed/Log.h @@ -18,13 +18,6 @@ along with this program. If not, see . #ifndef _LOG_H #define _LOG_H - -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#define byte BYTE - #include #define LOG_BUFFER_SIZE 1024 @@ -42,50 +35,50 @@ along with this program. If not, see . #define VDEBUG_LOG(LogHandler,buffer,...) #endif +using namespace std; /* * This class was made to simplify Logs * As you can see we can make multiple instance of logs (if one day we make multi-party server it can be helpfull) * but anyway we have a also a main instance of logs that can be access by getMainInstance. -* I also made PDEBUG_LOG and VDEBUG_LOG macros to remove some useless message when we'll be in release mode. +* I also made PDEBUG_LOG and VDEBUG_LOG macros to remove some useless message when we'll be in release mode. * SYSTEMTIME is from window's API, , that broke the portability. */ - class Log { public: - enum LogType + enum LogType { LT_NORMAL, LT_DEBUG, LT_ERROR }; - + public: Log(); ~Log(); - void setStream(std::ostream* stream); + void setStream(ostream* stream); void setOutputFile(const char* path); void writeDate(); - void writeLine(const char* buffer, ...); - void write(const char* buffer, ...); - void errorLine(const char* buffer, ...); - void error(const char* buffer, ...); - void debugLine(const char* buffer, ...); - void debug(const char* buffer, ...); + void writeLine(const char* buffer,...); + void write(const char* buffer,...); + void errorLine(const char* buffer,...); + void error(const char* buffer,...); + void debugLine(const char* buffer,...); + void debug(const char* buffer,...); void clear(); void setLogType(LogType type); static Log* getMainInstance(); private: - void vaWriteLine(const char* buffer, va_list l); - void vaWrite(const char* buffer, va_list al); + void vaWriteLine(const char* buffer,va_list l); + void vaWrite(const char* buffer,va_list al); private: static Log* m_instance; LogType m_type; - std::ostream* m_stream; + ostream* m_stream; SYSTEMTIME m_time; - char m_buffer[LOG_BUFFER_SIZE]; + char m_buffer[LOG_BUFFER_SIZE]; }; #endif diff --git a/gamed/Map.cpp b/gamed/Map.cpp deleted file mode 100644 index 5b4b0bbe..00000000 --- a/gamed/Map.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "stdafx.h" -#include "Map.h" -#include "PacketHandler.h" -#include "GameSession.h" - -bool Map::Init() -{ - int blueTeam=0; - int redTeam=0; - LoadScreenInfo screenInfo; - - std::vector m_players = GameSession::GetPlayerList(); - - //Builds team info - for(int i=0; i < m_players.size();i++) - { - if(m_players[i]->team == 0) - { - blueTeam++; - screenInfo.bluePlayerIds[i] = m_players[i]->userId; - } - else - { - redTeam++; - screenInfo.redPlayersIds[i] = m_players[i]->userId; - } - } - - screenInfo.bluePlayerNo = blueTeam; - screenInfo.redPlayerNo = redTeam; - - bool pInfo = m_PacketHandler->sendPacket(reinterpret_cast(&screenInfo), sizeof(LoadScreenInfo), CHL_LOADING_SCREEN); - - bool noerr; - - //For all players send this info - for(int i=0; i < m_players.size();i++) - { - LoadScreenPlayer* playerName = m_players[i]->GetLoadScreenPlayerName(); - LoadScreenPlayer* playerHero = m_players[i]->GetLoadScreenPlayerHero(); - - noerr = m_PacketHandler->sendPacket(reinterpret_cast(playerName), playerName->getPacketLength(), CHL_LOADING_SCREEN); - LoadScreenPlayer::destroy(playerName); - if(!noerr) - break; - noerr = m_PacketHandler->sendPacket(reinterpret_cast(playerHero), playerHero->getPacketLength(), CHL_LOADING_SCREEN); - LoadScreenPlayer::destroy(playerHero); - if(!noerr) - break; - } - - - return (pInfo && noerr); -} diff --git a/gamed/Map.h b/gamed/Map.h deleted file mode 100644 index 8bbadd8e..00000000 --- a/gamed/Map.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#ifndef _MAP_H -#define _MAP_H - -#include "stdafx.h" - -class PacketHandler; -class Map -{ -public: - Map(PacketHandler* packetHandler); - bool Init(); - -private: - PacketHandler* m_PacketHandler; -}; - -inline Map::Map(PacketHandler* _packetHandler) : m_PacketHandler(_packetHandler) -{ - -} - -#endif \ No newline at end of file diff --git a/gamed/NetworkListener.cpp b/gamed/NetworkListener.cpp index e02764b6..418bfd30 100644 --- a/gamed/NetworkListener.cpp +++ b/gamed/NetworkListener.cpp @@ -18,8 +18,6 @@ along with this program. If not, see . #include "stdafx.h" #include "NetworkListener.h" #include "Log.h" -#include "GameSession.h" -#include "Player.h" uint32 GetNewNetID() { static DWORD dwStart = 0x40000019; @@ -61,15 +59,9 @@ bool NetworkListener::initialize(ENetAddress *address, const char *baseKey) return _isAlive = true; } -PacketHandler* NetworkListener::GetPacketHandler() -{ - return _handler; -} - void NetworkListener::netLoop() { ENetEvent event; - Player* p; while(enet_host_service(_server, & event, 10) >= 0 && _isAlive) { @@ -85,11 +77,7 @@ void NetworkListener::netLoop() peerInfo(event.peer)->setName("Test"); peerInfo(event.peer)->setType("Teemo"); peerInfo(event.peer)->skinNo = 6; - peerInfo(event.peer)->team = 0; peerInfo(event.peer)->netId = GetNewNetID(); - peerInfo(event.peer)->peer = event.peer; - - GameSession::AddPlayer(peerInfo(event.peer)); break; diff --git a/gamed/NetworkListener.h b/gamed/NetworkListener.h index 83621934..c9522cda 100644 --- a/gamed/NetworkListener.h +++ b/gamed/NetworkListener.h @@ -34,7 +34,6 @@ class NetworkListener bool initialize(ENetAddress *address, const char *baseKey); void netLoop(); - PacketHandler* GetPacketHandler(); private: bool _isAlive; diff --git a/gamed/PacketHandler.cpp b/gamed/PacketHandler.cpp index d8e1d102..d5432594 100644 --- a/gamed/PacketHandler.cpp +++ b/gamed/PacketHandler.cpp @@ -21,7 +21,6 @@ along with this program. If not, see . PacketHandler::PacketHandler(ENetHost *server, BlowFish *blowfish) { - m_CurrPeer = NULL; _server = server; _blowfish = blowfish; memset(_handlerTable,0,sizeof(_handlerTable)); @@ -78,7 +77,7 @@ void PacketHandler::printLine(uint8 *buf, uint32 len) PDEBUG_LOG(Logging,"\n"); } -bool PacketHandler::sendPacket(uint8 *data, uint32 length, uint8 channelNo, uint32 flag) +bool PacketHandler::sendPacket(ENetPeer *peer, uint8 *data, uint32 length, uint8 channelNo, uint32 flag) { //PDEBUG_LOG_LINE(Logging," Sending packet:\n"); //if(length < 300) @@ -88,7 +87,7 @@ bool PacketHandler::sendPacket(uint8 *data, uint32 length, uint8 channelNo, uint _blowfish->Encrypt(data, length-(length%8)); //Encrypt everything minus the last bytes that overflow the 8 byte boundary ENetPacket *packet = enet_packet_create(data, length, flag); - if(enet_peer_send(m_CurrPeer, channelNo, packet) < 0) + if(enet_peer_send(peer, channelNo, packet) < 0) { PDEBUG_LOG_LINE(Logging,"Warning fail, send!"); return false; @@ -112,7 +111,6 @@ bool PacketHandler::broadcastPacket(uint8 *data, uint32 length, uint8 channelNo, bool PacketHandler::handlePacket(ENetPeer *peer, ENetPacket *packet, uint8 channelID) { - m_CurrPeer = peer; if(packet->dataLength >= 8) { if(peerInfo(peer)->keyChecked) @@ -124,7 +122,7 @@ bool PacketHandler::handlePacket(ENetPeer *peer, ENetPacket *packet, uint8 chann if(handler) { - return (*this.*handler)(packet); + return (*this.*handler)(peer,packet); } else { diff --git a/gamed/PacketHandler.h b/gamed/PacketHandler.h index faf68623..bcfb6f28 100644 --- a/gamed/PacketHandler.h +++ b/gamed/PacketHandler.h @@ -17,12 +17,9 @@ along with this program. If not, see . */ #ifndef _PACKET_HANDLER_H #define _PACKET_HANDLER_H - -#include "Log.h" - #include #include "common.h" - +#include "Log.h" #include "ChatBox.h" #include @@ -35,7 +32,7 @@ along with this program. If not, see . #define RELIABLE ENET_PACKET_FLAG_RELIABLE #define UNRELIABLE 0 -#define HANDLE_ARGS ENetPacket *packet +#define HANDLE_ARGS ENetPeer *peer, ENetPacket *packet class PacketHandler { @@ -67,7 +64,7 @@ class PacketHandler //Tools void printPacket(uint8 *buf, uint32 len); void printLine(uint8 *buf, uint32 len); - bool sendPacket( uint8 *data, uint32 length, uint8 channelNo, uint32 flag = RELIABLE); + bool sendPacket(ENetPeer *peer, uint8 *data, uint32 length, uint8 channelNo, uint32 flag = RELIABLE); bool broadcastPacket(uint8 *data, uint32 length, uint8 channelNo, uint32 flag = RELIABLE); private: void registerHandler(bool (PacketHandler::*handler)(HANDLE_ARGS), PacketCmd pktcmd,Channel c); @@ -75,6 +72,5 @@ class PacketHandler ENetHost *_server; BlowFish *_blowfish; bool (PacketHandler::*_handlerTable[0x100][0x7])(HANDLE_ARGS); - ENetPeer *m_CurrPeer; }; #endif \ No newline at end of file diff --git a/gamed/Packets.cpp b/gamed/Packets.cpp index 2946f9e6..3c0afb41 100644 --- a/gamed/Packets.cpp +++ b/gamed/Packets.cpp @@ -17,4 +17,3 @@ along with this program. If not, see . */ #include "stdafx.h" #include "Packets.h" -#include \ No newline at end of file diff --git a/gamed/Packets.h b/gamed/Packets.h index 2ac2cee7..c770db8d 100644 --- a/gamed/Packets.h +++ b/gamed/Packets.h @@ -18,11 +18,10 @@ along with this program. If not, see . #ifndef _PACKETS_H #define _PACKETS_H - +#include #include "common.h" #include #include -#include #if defined( __GNUC__ ) #pragma pack(1) @@ -475,8 +474,8 @@ struct ChatMessage { uint32 unk1; uint8 unk2; - ChatType type; - uint32 playerNo; + uint32 playerNo; + ChatType type; uint32 lenght; uint8 unk3[32]; int8 msg; diff --git a/gamed/Player.cpp b/gamed/Player.cpp deleted file mode 100644 index b1022d8e..00000000 --- a/gamed/Player.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "stdafx.h" -#include "Player.h" - - -LoadScreenPlayer* Player::GetLoadScreenPlayerName() -{ - - int8 *n = new int8[name.length()+1]; - memcpy(n, name.c_str(), name.length()+1); - LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadName, n, name.length()); - p->userId = userId; - return p; -} -LoadScreenPlayer* Player::GetLoadScreenPlayerHero() -{ - int8 *n = new int8[type.length()+1]; - memcpy(n, type.c_str(), type.length()+1); - LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadHero, n, type.length()); - p->userId = userId; - p->skinId = skinId; - return p; -} - -ClientInfo* \ No newline at end of file diff --git a/gamed/Player.h b/gamed/Player.h deleted file mode 100644 index a5c19486..00000000 --- a/gamed/Player.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#ifndef _PLAYER_H -#define _PLAYER_H - -#include "stdafx.h" -#include "Packets.h" - -class ClientInfo; -class Player -{ -public: - uint64 userId; - uint32 netId; - uint32 skinId; - std::string type; - std::string name; - uint8 team; - - Player(uint64 userId, uint32 skinId, std::string name, uint8 team); - LoadScreenPlayer* GetLoadScreenPlayerName(); - LoadScreenPlayer* GetLoadScreenPlayerHero(); - ClientInfo* GetClientInfo(); -}; - -inline Player::Player(uint64 _userId, uint32 _skinId, std::string _name, uint8 _team) : userId(_userId), skinId(_skinId), name(_name), team(_team) -{} - -#endif \ No newline at end of file diff --git a/gamed/main.cpp b/gamed/main.cpp index fb1a6a72..20058463 100644 --- a/gamed/main.cpp +++ b/gamed/main.cpp @@ -18,7 +18,6 @@ along with this program. If not, see . #include "stdafx.h" #include "NetworkListener.h" #include "Log.h" -#include "GameSession.h" #define SERVER_HOST ENET_HOST_ANY #define SERVER_PORT 5119 @@ -33,12 +32,8 @@ int main(int argc, char ** argv) ENetAddress address; address.host = SERVER_HOST; address.port = SERVER_PORT; - - listener->initialize(&address, SERVER_KEY); - - Logging->writeLine("Initializing GameSession\n"); - GameSession::Init(listener->GetPacketHandler()); + listener->initialize(&address, SERVER_KEY); Logging->writeLine("Starting net loop\n"); listener->netLoop(); delete listener; diff --git a/local.bat b/local.bat index 17f615db..adf83941 100644 --- a/local.bat +++ b/local.bat @@ -1,9 +1,4 @@ @echo off -set /P id=Enter username: %=% -set /P ch=Enter champion: %=% -set /P ip=Enter IP: %=% - -pause setlocal enabledelayedexpansion echo ----------------------- echo IntWars Solo Launcher @@ -129,7 +124,7 @@ set lolver=!v0!.!v1!.!v2!.!v3! @cd /d "!RADS_PATH!\solutions\lol_game_client_sln\releases\!lolver!\deploy" if exist "League of Legends.exe" ( - @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "%ip% 5119 17BLOhi6KZsTtldTsizvHg== 47917791" + @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "127.0.0.1 5119 17BLOhi6KZsTtldTsizvHg== 47917791" goto exit ) :cannotFind diff --git a/localz.bat b/localz.bat deleted file mode 100644 index 0dee6e14..00000000 --- a/localz.bat +++ /dev/null @@ -1,137 +0,0 @@ -@echo off - -setlocal enabledelayedexpansion -echo ----------------------- -echo IntWars Solo Launcher -echo ----------------------- -set RADS_PATH= -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( - SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o - goto runApp -) -cls -echo =================== -echo Finding other LoL directory path.. -echo =================== -for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( - set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m - goto runApp -) -cls -echo =================== -echo Finding another LoL directory path.. -echo =================== -for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( - set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m - goto runApp -) -cls -echo =================== -echo Finding another LoL directory path.. -echo =================== -for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( - set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m - goto runApp -) -cls -echo =================== -echo Finding another LoL directory path again.. -echo =================== -for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( - set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m - goto runApp -) -cls -goto cannotFind -:runApp -set RADS_PATH=%RADS_PATH:/=\% -@cd /d "%RADS_PATH%\solutions\lol_game_client_sln\releases" - -set init=0 -set v0=0&set v1=0&set v2=0&set v3=0 -for /f "delims=" %%F in ('dir * /b ^| findstr ^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$') do ( - for /F "tokens=1,2,3,4 delims=." %%i in ("%%F") do ( - if !init! equ 0 ( set init=1&set flag=1 ) else ( - set flag=0 - - if %%i gtr !v0! ( set flag=1 ) else ( - if %%j gtr !v1! ( set flag=1 ) else ( - if %%k gtr !v2! ( set flag=1 ) else ( - if %%l gtr !v3! ( set flag=1 ) - ) - ) - ) - ) - - if !flag! gtr 0 ( - set v0=%%i&set v1=%%j&set v2=%%k&set v3=%%l - ) - ) -) - -if !init! equ 0 goto cannotFind -set lolver=!v0!.!v1!.!v2!.!v3! - -@cd /d "!RADS_PATH!\solutions\lol_game_client_sln\releases\!lolver!\deploy" -if exist "League of Legends.exe" ( - @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "127.0.0.1 5119 17BLOhi6KZsTtldTsizvHg== 47917791" - goto exit -) -:cannotFind -echo =================== -echo Cannot find LoL path automatically :( -echo =================== -@pause -goto exit -:exit diff --git a/map ids.txt b/map ids.txt deleted file mode 100644 index c1a87ef8..00000000 --- a/map ids.txt +++ /dev/null @@ -1,9 +0,0 @@ - maps[1] = createMap(1,"SummonersRift","Summoner\'s Rift","",10); - maps[2] = createMap(2,"SummonersRiftWinter","Summoner\'s Rift (Autumn)","",10); - maps[4] = createMap(4,"OldTwistedTreeline","The Twisted Treeline","",6); - maps[7] = createMap(7,"ProvingGroundsARAM","The Proving Grounds","",10); - maps[8] = createMap(8,"CrystalScar","The Crystal Scar","",10); - maps[10] = createMap(10,"TwistedTreeline","The Twisted Treeline","",6); - maps[11] = createMap(11,"DebugMap1","Debug Map 1","",10); - maps[12] = createMap(12,"HowlingAbyss","The Howling Abyss","",10); - maps[13] = createMap(13,"DebugMap3","Debug Map 3","",10); \ No newline at end of file diff --git a/win/VC100/Client.cpp b/win/VC100/Client.cpp deleted file mode 100644 index 303a2897..00000000 --- a/win/VC100/Client.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "stdafx.h" -#include "Client.h" - -ClientInfo::ClientInfo() -{ - keyChecked = false; - name = type = NULL; - ticks = 0; - skinNo = 0; -} - -ClientInfo::~ClientInfo() -{ - if (name != NULL) - delete[] name; - if (type != NULL) - delete[] type; -} - -void ClientInfo::setName(char *name) -{ - if (this->name != NULL) - delete[] this->name; - - nameLen = strlen(name); - this->name = new int8[nameLen + 1]; - memcpy(this->name, name, nameLen + 1); -} - -void ClientInfo::setType(char *type) -{ - if (this->type != NULL) - delete[] this->type; - - typeLen = strlen(type); - this->type = new int8[typeLen + 1]; - memcpy(this->type, type, typeLen + 1); -} - -uint32 ClientInfo::getTicks() -{ - ticks++; - return ticks; -} - -LoadScreenPlayer* ClientInfo::GetLoadScreenPlayerName() -{ - LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadName, name, nameLen); - p->userId = userId; - return p; -} -LoadScreenPlayer* ClientInfo::GetLoadScreenPlayerHero() -{ - LoadScreenPlayer* p = LoadScreenPlayer::create(PKT_S2C_LoadHero, type, typeLen); - p->userId = userId; - p->skinId = skinNo; - return p; -} \ No newline at end of file diff --git a/win/VC100/GameSession.cpp b/win/VC100/GameSession.cpp deleted file mode 100644 index 748a8541..00000000 --- a/win/VC100/GameSession.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "stdafx.h" -#include "GameSession.h" -#include "Map.h" -#include "Client.h" -#include "Log.h" - -std::vector GameSession::m_Players; -Map* GameSession::m_Map = 0; - -void GameSession::Init(PacketHandler* packetHandler) -{ - m_Map = new Map(packetHandler); -} - -GameSession::~GameSession() -{ - delete m_Map; - m_Map = 0; - - for (int i = 0; i < m_Players.size(); i++) - { - delete m_Players[i]; - m_Players[i] = 0; - } - m_Players.clear(); -} - -void GameSession::AddPlayer(ClientInfo* player) -{ - if (std::find(m_Players.begin(), m_Players.end(), player) != m_Players.end()) { - //Logging->writeLine("player %s already in playerlist", player->name); - return; - } - m_Players.push_back(player); -} - -const std::vector& GameSession::GetPlayerList() -{ - return m_Players; -} - -ClientInfo* GameSession::FindPlayer(uint32 netId) -{ - for (int i = 0; i < m_Players.size(); i++) - { - if (m_Players[i]->netId == netId) - return m_Players[i]; - } - - return NULL; -} \ No newline at end of file diff --git a/win/VC100/GameSession.h b/win/VC100/GameSession.h deleted file mode 100644 index f95c614a..00000000 --- a/win/VC100/GameSession.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#ifndef _GAME_SESSION_H -#define _GAME_SESSION_H - -#include "stdafx.h" -#include -#include "Map.h" - -class ClientInfo; -class PacketHandler; -class GameSession -{ -public: - ~GameSession(); - - static void Init(PacketHandler* packetHandler); - static void AddPlayer(ClientInfo* player); - static const std::vector& GetPlayerList(); - static ClientInfo* FindPlayer(uint32 netId); - static Map* GetMap(); - -private: - static std::vector m_Players; - static Map* m_Map; -}; - -inline Map* GameSession::GetMap() -{ - return m_Map; -} - -#endif \ No newline at end of file diff --git a/win/VC100/Map.cpp b/win/VC100/Map.cpp deleted file mode 100644 index 5ca8e3ae..00000000 --- a/win/VC100/Map.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#include "stdafx.h" -#include "Map.h" -#include "PacketHandler.h" -#include "GameSession.h" - -bool Map::Init() -{ - int blueTeam = 0; - int redTeam = 0; - LoadScreenInfo screenInfo; - - std::vector m_players = GameSession::GetPlayerList(); - - //Builds team info - for (int i = 0; i < m_players.size(); i++) - { - if (m_players[i]->team == 0) - { - blueTeam++; - screenInfo.bluePlayersIds[i] = m_players[i]->userId; - } - else - { - redTeam++; - screenInfo.redPlayersIds[i] = m_players[i]->userId; - } - } - - screenInfo.bluePlayerNo = blueTeam; - screenInfo.redPlayerNo = redTeam; - - bool pInfo = m_PacketHandler->sendPacket(reinterpret_cast(&screenInfo), sizeof(LoadScreenInfo), CHL_LOADING_SCREEN); - - bool noerr; - - //For all players send this info - for (int i = 0; i < m_players.size(); i++) - { - LoadScreenPlayer* playerName = m_players[i]->GetLoadScreenPlayerName(); - LoadScreenPlayer* playerHero = m_players[i]->GetLoadScreenPlayerHero(); - - noerr = m_PacketHandler->sendPacket(reinterpret_cast(playerName), playerName->getPacketLength(), CHL_LOADING_SCREEN); - LoadScreenPlayer::destroy(playerName); - if (!noerr) - break; - noerr = m_PacketHandler->sendPacket(reinterpret_cast(playerHero), playerHero->getPacketLength(), CHL_LOADING_SCREEN); - LoadScreenPlayer::destroy(playerHero); - if (!noerr) - break; - } - - - return (pInfo && noerr); -} diff --git a/win/VC100/Map.h b/win/VC100/Map.h deleted file mode 100644 index 8bbadd8e..00000000 --- a/win/VC100/Map.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -IntWars playground server for League of Legends protocol testing -Copyright (C) 2012 Intline9 - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ -#ifndef _MAP_H -#define _MAP_H - -#include "stdafx.h" - -class PacketHandler; -class Map -{ -public: - Map(PacketHandler* packetHandler); - bool Init(); - -private: - PacketHandler* m_PacketHandler; -}; - -inline Map::Map(PacketHandler* _packetHandler) : m_PacketHandler(_packetHandler) -{ - -} - -#endif \ No newline at end of file diff --git a/win/VC100/enet-1.2.5.vcxproj b/win/VC100/enet-1.2.5.vcxproj index 82c75e9d..57507616 100644 --- a/win/VC100/enet-1.2.5.vcxproj +++ b/win/VC100/enet-1.2.5.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,12 +19,10 @@ StaticLibrary Unicode - v120 StaticLibrary Unicode - v120 diff --git a/win/VC100/gamed.vcxproj b/win/VC100/gamed.vcxproj index 3ff9510e..971f8623 100644 --- a/win/VC100/gamed.vcxproj +++ b/win/VC100/gamed.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,12 +19,10 @@ Application Unicode - v120 Application Unicode - v120 @@ -79,10 +77,7 @@ - - - @@ -92,8 +87,6 @@ - - diff --git a/win/VC100/gamed.vcxproj.filters b/win/VC100/gamed.vcxproj.filters index f0e89bae..03a62d34 100644 --- a/win/VC100/gamed.vcxproj.filters +++ b/win/VC100/gamed.vcxproj.filters @@ -16,9 +16,6 @@ {eeac7bfa-3b4f-4c49-987a-ab1bfa6da602} - - {4d3d70f9-7ac8-4945-a22b-ae0077d5a5b8} - @@ -37,15 +34,6 @@ Protocol - - logic - - - logic - - - Source Files - @@ -72,11 +60,5 @@ Header Files - - logic - - - logic - \ No newline at end of file diff --git a/win/VC100/intlib.vcxproj b/win/VC100/intlib.vcxproj index 27a2d44a..4bef66d9 100644 --- a/win/VC100/intlib.vcxproj +++ b/win/VC100/intlib.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,12 +19,10 @@ StaticLibrary Unicode - v120 StaticLibrary Unicode - v120 From 28f3efb57866ad6d1f6c7861d3a7d747f3cc64bd Mon Sep 17 00:00:00 2001 From: noobasaurus Date: Thu, 17 Jul 2014 10:04:45 -0700 Subject: [PATCH 3/4] Updated packets, etc Updated packets, works on 4.12, weird name tag but whatever. You can move, use .model to change your model. --- CONNECT TO LAN.bat | 136 +++++++++++++ bin/VC120_Debug/error.txt | 0 bin/VC120_Debug/output.txt | 0 common.h | 130 ++++++------ gamed/Client.h | 2 +- gamed/Handlers.cpp | 381 ++++++++++++++++++++--------------- gamed/NetworkListener.cpp | 35 ++-- gamed/Packets.h | 38 ++-- gamed/main.cpp | 2 +- local.bat | 7 +- localz.bat | 137 +++++++++++++ win/VC100/enet-1.2.5.vcxproj | 4 +- win/VC100/gamed.vcxproj | 4 +- win/VC100/intlib.vcxproj | 4 +- 14 files changed, 616 insertions(+), 264 deletions(-) create mode 100644 CONNECT TO LAN.bat create mode 100644 bin/VC120_Debug/error.txt create mode 100644 bin/VC120_Debug/output.txt create mode 100644 localz.bat diff --git a/CONNECT TO LAN.bat b/CONNECT TO LAN.bat new file mode 100644 index 00000000..adf83941 --- /dev/null +++ b/CONNECT TO LAN.bat @@ -0,0 +1,136 @@ +@echo off +setlocal enabledelayedexpansion +echo ----------------------- +echo IntWars Solo Launcher +echo ----------------------- +set RADS_PATH= +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path again.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +goto cannotFind +:runApp +set RADS_PATH=%RADS_PATH:/=\% +@cd /d "%RADS_PATH%\solutions\lol_game_client_sln\releases" + +set init=0 +set v0=0&set v1=0&set v2=0&set v3=0 +for /f "delims=" %%F in ('dir * /b ^| findstr ^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$') do ( + for /F "tokens=1,2,3,4 delims=." %%i in ("%%F") do ( + if !init! equ 0 ( set init=1&set flag=1 ) else ( + set flag=0 + + if %%i gtr !v0! ( set flag=1 ) else ( + if %%j gtr !v1! ( set flag=1 ) else ( + if %%k gtr !v2! ( set flag=1 ) else ( + if %%l gtr !v3! ( set flag=1 ) + ) + ) + ) + ) + + if !flag! gtr 0 ( + set v0=%%i&set v1=%%j&set v2=%%k&set v3=%%l + ) + ) +) + +if !init! equ 0 goto cannotFind +set lolver=!v0!.!v1!.!v2!.!v3! + +@cd /d "!RADS_PATH!\solutions\lol_game_client_sln\releases\!lolver!\deploy" +if exist "League of Legends.exe" ( + @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "127.0.0.1 5119 17BLOhi6KZsTtldTsizvHg== 47917791" + goto exit +) +:cannotFind +echo =================== +echo Cannot find LoL path automatically :( +echo =================== +@pause +goto exit +:exit diff --git a/bin/VC120_Debug/error.txt b/bin/VC120_Debug/error.txt new file mode 100644 index 00000000..e69de29b diff --git a/bin/VC120_Debug/output.txt b/bin/VC120_Debug/output.txt new file mode 100644 index 00000000..e69de29b diff --git a/common.h b/common.h index cbb1fe87..3b8194d4 100644 --- a/common.h +++ b/common.h @@ -20,73 +20,77 @@ along with this program. If not, see . enum GameCmd : uint8 { - PKT_S2C_MoveAns = 0x60, +PKT_S2C_MoveAns = 0x61, }; //Currently attuned to Live 4.5.0.264 enum PacketCmd : uint8 -{ //Channel //Type - PKT_KeyCheck = 0x00, //0 //UPDATED - - PKT_S2C_EndSpawn = 0x11, //? //UPDATED - PKT_C2S_QueryStatusReq = 0x14, //1 //UPDATED - PKT_S2C_SkillUp = 0x15, //3 //UPDATED - PKT_C2S_Ping_Load_Info = 0x16, //1 //UPDATED - - PKT_S2C_ViewAns = 0x2B, //3 //UPDATED - PKT_C2S_ViewReq = 0x2D, //1 //UPDATED - - PKT_C2S_SkillUp = 0x38, //1 //UPDATED - PKT_S2C_AttentionPing = 0x3F, //3 //UPDATED - - PKT_S2C_Emotion = 0x41, //3 UPDATED - PKT_C2S_Emotion = 0x47, //1 UPDATED - PKT_S2C_HeroSpawn = 0x4B, //3 UPDATED - PKT_S2C_Announce = 0x4C, //3 - - PKT_S2C_GameTimer = 0xC0, - PKT_S2C_GameTimerUpdate = 0xC1, - - PKT_C2S_StartGame = 0x51, //1 //UPDATED - PKT_S2C_SynchVersion = 0x53, //3 //UPDATED - PKT_C2S_ScoreBord = 0x55, //1 //UPDATED - PKT_C2S_AttentionPing = 0x56, //1 //UPDATED - PKT_S2C_StartGame = 0x5B, //? //UPDATED - - PKT_S2C_StartSpawn = 0x61, //? //UPDATED - //PKT_C2S_OpenShop = 0x63, //1 - DEPRECATED - PKT_C2S_ClientReady = 0x64, //6 //UPDATED ? - PKT_S2C_LoadHero = 0x65, //6 //UPDATED - PKT_S2C_LoadName = 0x66, //6 //UPDATED - PKT_S2C_LoadScreenInfo = 0x67, //6 //UPDATED - PKT_ChatBoxMessage = 0x68, //5 //UPDATED - PKT_S2C_BuyItemAns = 0x6E, //3 //UPDATED - - PKT_C2S_MoveReq = 0x71, //1 //UPDATED - PKT_C2S_MoveConfirm = 0x76, //1 //UPDATED - - PKT_C2S_LockCamera = 0x80, //1 //UPDATED - PKT_C2S_BuyItemReq = 0x81, //1 //UPDATED - PKT_S2C_QueryStatusAns = 0x87, //? //UPDATED - PKT_C2S_Exit = 0x8E, //1 //UPDATED - - PKT_World_SendGameNumber = 0x91, //3 //UPDATED - PKT_S2C_Ping_Load_Info = 0x94, //4 //UPDATED - PKT_S2C_TurretSpawn = 0x9C, //3 UPDATED - - PKT_C2S_Surrender = 0xA3, //1 //UPDATED - //PKT_C2S_GameNumberReq = 0xA6, //1 //DEPRECATED - PKT_C2S_StatsConfirm = 0xA7, //1 UPDATED - PKT_C2S_Click = 0xAE, //1 //UPDATED - - PKT_C2S_SynchVersion = 0xBC, //1 //UPDATED - PKT_C2S_CharLoaded = 0xBD, //1 //UPDATED - - PKT_S2C_CharStats = 0xC3, //4 //UPDATED - PKT_S2C_FogUpdate2 = 0x23, //3 //UPDATED? - PKT_S2C_LevelPropSpawn = 0xCF, //3 UPDATED - - PKT_Batch = 0xFF, //3 +{ //Channel //Type +PKT_KeyCheck = 0x00, //0 //UPDATED +PKT_C2S_ClientConnect_NamedPipe = 0x01, + +PKT_S2C_EndSpawn = 0x11, //? //UPDATED +PKT_C2S_QueryStatusReq = 0x14, //1 //UPDATED +PKT_S2C_SkillUp = 0x16, //3 //UPDATED +PKT_C2S_Ping_Load_Info = 0x16, //1 //UPDATED + +PKT_S2C_ViewAns = 0x2C, //3 //UPDATED +PKT_C2S_ViewReq = 0x2E, //1 //UPDATED + +PKT_C2S_SkillUp = 0x39, //1 //UPDATED +PKT_S2C_AttentionPing = 0x3F, //3 //UPDATED + +PKT_S2C_Emotion = 0x42, //3 UPDATED +PKT_C2S_Emotion = 0x47, //1 UPDATED +PKT_S2C_HeroSpawn = 0x4C, //3 UPDATED +PKT_S2C_Announce = 0x4D, //3 + +PKT_S2C_GameTimer = 0xC0, +PKT_S2C_GameTimerUpdate = 0xC1, + +PKT_C2S_StartGame = 0x52, //1 //UPDATED +PKT_S2C_SynchVersion = 0x54, //3 //UPDATED +PKT_C2S_ScoreBord = 0x56, //1 //UPDATED +PKT_C2S_AttentionPing = 0x57, //1 //UPDATED +PKT_S2C_StartGame = 0x5C, //? //UPDATED + +PKT_S2C_StartSpawn = 0x62, //? //UPDATED +//PKT_C2S_OpenShop = 0x63, //1 - DEPRECATED +PKT_C2S_ClientReady = 0x64, //6 //UPDATED ? +PKT_S2C_LoadHero = 0x65, //6 //UPDATED +PKT_S2C_LoadName = 0x66, //6 //UPDATED +PKT_S2C_LoadScreenInfo = 0x67, //6 //UPDATED +PKT_ChatBoxMessage = 0x68, //5 //UPDATED +PKT_S2C_BuyItemAns = 0x6F, //3 //UPDATED + +PKT_C2S_MoveReq = 0x72, //1 //UPDATED +PKT_C2S_MoveConfirm = 0x77, //1 //UPDATED + +PKT_C2S_LockCamera = 0x81, //1 //UPDATED +PKT_C2S_BuyItemReq = 0x82, //1 //UPDATED +PKT_S2C_QueryStatusAns = 0x88, //? //UPDATED +PKT_C2S_Exit = 0x8F, //1 //UPDATED + +PKT_World_SendGameNumber = 0x92, //3 //UPDATED +PKT_S2C_Ping_Load_Info = 0x95, //4 //UPDATED +PKT_S2C_UpdateModel = 0x97, +PKT_S2C_TurretSpawn = 0x9D, //3 UPDATED + +PKT_C2S_Surrender = 0xA4, //1 //UPDATED +//PKT_C2S_GameNumberReq = 0xA6, //1 //DEPRECATED +PKT_C2S_StatsConfirm = 0xA8, //1 UPDATED +PKT_S2C_HeroSpawnUnk3 = 0xAE, +PKT_C2S_Click = 0xAF, //1 //UPDATED + +PKT_S2C_HeroSpawnUnk2 = 0xBA, +PKT_C2S_SynchVersion = 0xBD, //1 //UPDATED +PKT_C2S_CharLoaded = 0xBE, //1 //UPDATED + +PKT_S2C_CharStats = 0xC4, //4 //UPDATED +PKT_S2C_FogUpdate2 = 0x23, //3 //UPDATED? +PKT_S2C_LevelPropSpawn = 0xD0, //3 UPDATED + +PKT_Batch = 0xFF, //3 }; enum MoveType : uint8 diff --git a/gamed/Client.h b/gamed/Client.h index 2aae0eaa..de4453de 100644 --- a/gamed/Client.h +++ b/gamed/Client.h @@ -27,7 +27,7 @@ struct ClientInfo keyChecked = false; name = type = NULL; ticks = 0; - skinNo = 0; + skinNo = 1; } ~ClientInfo() diff --git a/gamed/Handlers.cpp b/gamed/Handlers.cpp index 9630bf3f..0bab8e2a 100644 --- a/gamed/Handlers.cpp +++ b/gamed/Handlers.cpp @@ -18,6 +18,17 @@ along with this program. If not, see . #include "stdafx.h" #include "PacketHandler.h" #include "NetworkListener.h" +#include +#include + +int log(int argc, char* argv[]) +{ + using namespace std; + freopen("output.txt", "w", stdout); + freopen("error.txt", "w", stderr); + return true; + +} bool PacketHandler::handleNull(HANDLE_ARGS) { return true; @@ -37,8 +48,9 @@ bool PacketHandler::handleKeyCheck(ENetPeer *peer, ENetPacket *packet) { PDEBUG_LOG_LINE(Logging," Enc id: %s\n", buffer);*/ if(userId == keyCheck->userId) { PDEBUG_LOG_LINE(Logging, " User got the same key as i do, go on!\n"); - peerInfo(peer)->keyChecked = true; - peerInfo(peer)->userId = userId; + peerInfo(peer)->keyChecked = true; + peerInfo(peer)->userId = userId; + peerInfo(peer)->userId = userId; } else { Logging->errorLine(" WRONG KEY, GTFO!!!\n"); return false; @@ -54,7 +66,7 @@ bool PacketHandler::handleKeyCheck(ENetPeer *peer, ENetPacket *packet) { bool PacketHandler::handleGameNumber(ENetPeer *peer, ENetPacket *packet) { WorldSendGameNumber world; world.gameId = 1; - strcpy((char *)world.data1, "EUW1"); + strcpy((char *)world.data1, "NA1"); memcpy(world.data, peerInfo(peer)->name, peerInfo(peer)->nameLen); return sendPacket(peer, reinterpret_cast(&world), sizeof(WorldSendGameNumber), CHL_S2C); } @@ -63,10 +75,10 @@ bool PacketHandler::handleSynch(ENetPeer *peer, ENetPacket *packet) { SynchVersion *version = reinterpret_cast(packet->data); Logging->writeLine("Client version: %s\n", version->version); SynchVersionAns answer; - answer.mapId = 1; + answer.mapId = 1; answer.players[0].userId = peerInfo(peer)->userId; - answer.players[0].skill1 = SPL_Ignite; - answer.players[0].skill2 = SPL_Flash; + answer.players[0].skill1 = SPL_Teleport; + answer.players[0].skill2 = SPL_Flash; return sendPacket(peer, reinterpret_cast(&answer), sizeof(SynchVersionAns), 3); } @@ -78,9 +90,30 @@ bool PacketHandler::handleMap(ENetPeer *peer, ENetPacket *packet) { playerHero->skinId = peerInfo(peer)->skinNo; //Builds team info LoadScreenInfo screenInfo; - screenInfo.bluePlayerNo = 1; - screenInfo.redPlayerNo = 0; - screenInfo.bluePlayerIds[0] = peerInfo(peer)->userId; + screenInfo.bluePlayerNo = 10; + screenInfo.redPlayerNo = 10; + int z = 0; + int blueid = 0; + int redid = 0; + if (z%2 == 0) + { + screenInfo.bluePlayerIds[blueid] = peerInfo(peer)->userId; + printf("New blue player connected, team ID is %i\n", blueid); + z = z++; + blueid = blueid++; + } + if (z % 2 != 0) + { + if (z > 0) + { + screenInfo.redPlayerIds[redid] = peerInfo(peer)->userId; + printf("New red player connected, team ID is %i\n", redid); + z = z++; + redid = redid++; + } + } + screenInfo.redPlayerIds[0] = peerInfo(peer)->userId; + printf("Info: %i\n", peerInfo(peer)->userId); bool pInfo = sendPacket(peer, reinterpret_cast(&screenInfo), sizeof(LoadScreenInfo), CHL_LOADING_SCREEN); //For all players send this info bool pName = sendPacket(peer, reinterpret_cast(playerName), playerName->getPacketLength(), CHL_LOADING_SCREEN); @@ -96,9 +129,9 @@ bool PacketHandler::handleSpawn(ENetPeer *peer, ENetPacket *packet) { StatePacket2 start(PKT_S2C_StartSpawn); bool p1 = sendPacket(peer, reinterpret_cast(&start), sizeof(StatePacket2), CHL_S2C); printf("Spawning map\r\n"); - HeroSpawn spawn; + HeroSpawn spawn; spawn.netId = peerInfo(peer)->netId; - spawn.gameId = 0; + spawn.gameId = 0; // 0 memcpy(spawn.name, peerInfo(peer)->name, peerInfo(peer)->nameLen); memcpy(spawn.type, peerInfo(peer)->type, peerInfo(peer)->typeLen); bool p2 = sendPacket(peer, reinterpret_cast(&spawn), sizeof(HeroSpawn), CHL_S2C); @@ -142,6 +175,7 @@ bool PacketHandler::handleSpawn(ENetPeer *peer, ENetPacket *packet) { sendPacket(peer, reinterpret_cast(&turretSpawn), sizeof(TurretSpawn), CHL_S2C); } //Spawn Props + LevelPropSpawn lpSpawn; lpSpawn.SetProp("LevelProp_Yonkey", "Yonkey"); lpSpawn.header.netId = 0; @@ -160,18 +194,17 @@ bool PacketHandler::handleSpawn(ENetPeer *peer, ENetPacket *packet) { lpSpawn.netId = GetNewNetID(); lpSpawn.x = 13374; lpSpawn.y = 194; - sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); - lpSpawn.SetProp("LevelProp_ShopMale1", "ShopMale"); - lpSpawn.header.netId = 0; - lpSpawn.netId = GetNewNetID(); - lpSpawn.x = -99; - lpSpawn.y = 191; - sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); + sendPacket(peer, reinterpret_cast(&lpSpawn), sizeof(LevelPropSpawn), CHL_S2C); + lpSpawn.SetProp("LevelProp_ShopMale1", "ShopMale"); + lpSpawn.header.netId = 0; + lpSpawn.netId = GetNewNetID(); + lpSpawn.x = -99; + lpSpawn.y = 191; StatePacket end(PKT_S2C_EndSpawn); bool p3 = sendPacket(peer, reinterpret_cast(&end), sizeof(StatePacket), CHL_S2C); BuyItemAns recall; recall.header.netId = peerInfo(peer)->netId; - recall.itemId = 2001; + recall.itemId = 2001; //2001 recall.slotId = 7; recall.stack = 1; bool p4 = sendPacket(peer, reinterpret_cast(&recall), sizeof(BuyItemAns), CHL_S2C); //activate recall slot @@ -182,10 +215,16 @@ bool PacketHandler::handleSpawn(ENetPeer *peer, ENetPacket *packet) { GameTimerUpdate timer3(0.4); //0xC1 sendPacket(peer, reinterpret_cast(&timer3), sizeof(GameTimerUpdate), CHL_S2C); //lvl 1 R for elise - for(int i = 0; i < 4; i++) { - SpellSet spell(peerInfo(peer)->netId, i, 1); - sendPacket(peer, reinterpret_cast(&spell), sizeof(SpellSet), CHL_S2C); - } +// for(int i = 0; i < 4; i++) { + int i; + i = 1; + if (i > 0) + { + i = i++; + SpellSet spell(peerInfo(peer)->netId, 1, 1); + sendPacket(peer, reinterpret_cast(&spell), sizeof(SpellSet), CHL_S2C); + } +// } return p1 & p2 & p3; } @@ -199,13 +238,13 @@ bool PacketHandler::handleStartGame(HANDLE_ARGS) { test.unk1 = 2; //uint8 p[] = {0xC5, 0x19, 0x00, 0x00, 0x40, 0x00, 0x00, 0x50}; //sendPacket(peer, reinterpret_cast(p), sizeof(p), 3); - sendPacket(peer, reinterpret_cast(&test), sizeof(FogUpdate2), 3); +// sendPacket(peer, reinterpret_cast(&test), sizeof(FogUpdate2), 3); //playing around 8-) - /* - CharacterStats movement; - movement.netId = peerInfo(peer)->netId; - movement.statType = STI_Movement; - movement.statValue = 800; + /* + CharacterStats movement; + CharacterStats *stats = CharacterStats::create(STI_Movement, 0, 0, 0, 0); + stats->netId = peerInfo(peer)->netId; + stats->setValue(1, STI_Movement, 800); sendPacket(peer,reinterpret_cast(&movement),sizeof(movement), 4);*/ return true; } @@ -276,19 +315,40 @@ std::vector readWaypoints(byte *buffer, int coordCount) { bool PacketHandler::handleMove(ENetPeer *peer, ENetPacket *packet) { MovementReq *request = reinterpret_cast(packet->data); + std::vector vMoves = readWaypoints(&request->moveData, request->vectorNo); switch(request->type) { //TODO, Implement stop commands - case STOP: - Logging->writeLine("Move stop\n"); - return true; + case STOP: + { + MovementAns *answer = MovementAns::create(request->vectorNo); + answer->ok = 1; + answer->vectorNo = request->vectorNo; + answer->netId = peerInfo(peer)->netId; + + float x = ((request->x) - MAP_WIDTH) / 2; + + float y = ((request->y) - MAP_HEIGHT) / 2; + + for (int i = 0; i < vMoves.size(); i++){ + answer->getVector(i)->x = x; + answer->getVector(i)->y = y; + + } + + + bool bRet = broadcastPacket(reinterpret_cast(answer), answer->size(), 4); + MovementAns::destroy(answer); + return bRet; + } case EMOTE: Logging->writeLine("Emotion\n"); return true; } - std::vector vMoves = readWaypoints(&request->moveData, request->vectorNo); Logging->writeLine("Move to(normal): x:%f, y:%f, type: %i, vectorNo: %i\n", request->x, request->y, request->type, vMoves.size()); for(int i = 0; i < vMoves.size(); i++) - { printf(" Vector %i, x: %f, y: %f\n", i, 2.0 * vMoves[i].x + MAP_WIDTH, 2.0 * vMoves[i].y + MAP_HEIGHT); } + { + printf(" Vector %i, x: %f, y: %f\n", i, 2.0 * vMoves[i].x + MAP_WIDTH, 2.0 * vMoves[i].y + MAP_HEIGHT); + } MovementAns *answer = MovementAns::create(request->vectorNo); answer->ok = 1; answer->vectorNo = request->vectorNo; @@ -324,128 +384,131 @@ bool PacketHandler::handleQueryStatus(HANDLE_ARGS) { } bool PacketHandler::handleChatBoxMessage(HANDLE_ARGS) { - ChatMessage *message = reinterpret_cast(packet->data); - //Lets do commands - if(message->msg == '.') { - const char *cmd[] = { ".set", ".gold", ".speed", ".health", ".xp", ".ap", ".ad", ".mana", ".model", ".help" }; - //Set field - if(strncmp(message->getMessage(), cmd[0], strlen(cmd[0])) == 0) { - uint32 blockNo = atoi(&message->getMessage()[strlen(cmd[0]) + 1]); - uint32 fieldNo = atoi(&message->getMessage()[strlen(cmd[0]) + 3]); - float value = (float)atoi(&message->getMessage()[strlen(cmd[0]) + 5]); - uint32 mask = 1 << abs(((int)fieldNo - 1)); - CharacterStats *stats = CharacterStats::create(blockNo, mask); - stats->netId = peerInfo(peer)->netId; - stats->setValue(blockNo, mask, value); - Logging->writeLine("Setting to %f in block: %i, field: %i\n", value, blockNo, fieldNo); - sendPacket(peer, reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); - stats->destroy(); - return true; - } - // Set Gold - if(strncmp(message->getMessage(), cmd[1], strlen(cmd[1])) == 0) { - float gold = (float)atoi(&message->getMessage()[strlen(cmd[1]) + 1]); - CharacterStats *stats = CharacterStats::create(FM1_Gold, 0, 0, 0, 0); - stats->netId = peerInfo(peer)->netId; - stats->setValue(1, FM1_Gold, gold); - Logging->writeLine("Set gold to %f\n", gold); - sendPacket(peer, reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); - stats->destroy(); - return true; - } - /* - - //movement - if(strncmp(message->getMessage(), cmd[2], strlen(cmd[2])) == 0) - { - float data = (float)atoi(&message->getMessage()[strlen(cmd[2])+1]); - - charStats.statType = STI_Movement; - charStats.statValue = data; - Logging->writeLine("set champ speed to %f\n", data); - sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); - return true; - } - //health - if(strncmp(message->getMessage(), cmd[3], strlen(cmd[3])) == 0) - { - float data = (float)atoi(&message->getMessage()[strlen(cmd[3])+1]); - - charStats.statType = STI_Health; - charStats.statValue = data; - Logging->writeLine("set champ health to %f\n", data); - sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); - return true; - } - //experience - if(strncmp(message->getMessage(), cmd[4], strlen(cmd[4])) == 0) - { - float data = (float)atoi(&message->getMessage()[strlen(cmd[4])+1]); - - charStats.statType = STI_Exp; - charStats.statValue = data; - Logging->writeLine("set champ exp to %f\n", data); - sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); - return true; - } - //AbilityPower - if(strncmp(message->getMessage(), cmd[5], strlen(cmd[5])) == 0) - { - float data = (float)atoi(&message->getMessage()[strlen(cmd[5])+1]); - - charStats.statType = STI_AbilityPower; - charStats.statValue = data; - Logging->writeLine("set champ abilityPower to %f\n", data); - sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); - return true; - } - //Attack damage - if(strncmp(message->getMessage(), cmd[6], strlen(cmd[6])) == 0) - { - float data = (float)atoi(&message->getMessage()[strlen(cmd[6])+1]); - - charStats.statType = STI_AttackDamage; - charStats.statValue = data; - Logging->writeLine("set champ attack damage to %f\n", data); - sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); - return true; - } - //Mana - if(strncmp(message->getMessage(), cmd[7], strlen(cmd[7])) == 0) - { - float data = (float)atoi(&message->getMessage()[strlen(cmd[7])+1]); - - charStats.statType = STI_Mana; - charStats.statValue = data; - Logging->writeLine("set champ mana to %f\n", data); - sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); - return true; - } - */ - //Model - if(strncmp(message->getMessage(), cmd[8], strlen(cmd[8])) == 0) { - std::string sModel = (char *)&message->getMessage()[strlen(cmd[8]) + 1]; - UpdateModel modelPacket(peerInfo(peer)->netId, (char *)sModel.c_str()); //96 - broadcastPacket(reinterpret_cast(&modelPacket), sizeof(UpdateModel), CHL_S2C); - return true; - } - } - switch(message->type) { - case CMT_ALL: - return broadcastPacket(packet->data, packet->dataLength, CHL_COMMUNICATION); - break; - case CMT_TEAM: - //!TODO make a team class and foreach player in the team send the message - return sendPacket(peer, packet->data, packet->dataLength, CHL_COMMUNICATION); - break; - default: - Logging->errorLine("Unknown ChatMessageType\n"); - return sendPacket(peer, packet->data, packet->dataLength, CHL_COMMUNICATION); - break; - } - return false; -} + ChatMessage *message = reinterpret_cast(packet->data); + //Lets do commands + + if (message->msg == '.') { + const char *cmd[] = { ".set", ".gold", ".speed", ".health", ".xp", ".ap", ".ad", ".mana", ".model", ".help" }; + //Set field + + if (strncmp(message->getMessage(), cmd[0], strlen(cmd[0])) == 0) { + uint32 blockNo = atoi(&message->getMessage()[strlen(cmd[0]) + 1]); + uint32 fieldNo = atoi(&message->getMessage()[strlen(cmd[0]) + 3]); + float value = (float)atoi(&message->getMessage()[strlen(cmd[0]) + 5]); + uint32 mask = 1 << abs(((int)fieldNo - 1)); + CharacterStats *stats = CharacterStats::create(blockNo, mask); + stats->netId = peerInfo(peer)->netId; + stats->setValue(blockNo, mask, value); + Logging->writeLine("Setting to %f in block: %i, field: %i\n", value, blockNo, fieldNo); + sendPacket(peer, reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); + stats->destroy(); + return true; + } + // Set Gold + if (strncmp(message->getMessage(), cmd[1], strlen(cmd[1])) == 0) { + float gold = (float)atoi(&message->getMessage()[strlen(cmd[1]) + 1]); + CharacterStats *stats = CharacterStats::create(FM1_Gold, 0, 0, 0, 0); + stats->netId = peerInfo(peer)->netId; + stats->setValue(1, FM1_Gold, gold); + Logging->writeLine("Set gold to %f\n", gold); + sendPacket(peer, reinterpret_cast(stats), stats->getSize(), CHL_LOW_PRIORITY, 2); + stats->destroy(); + return true; + } + /* + //movement + if(strncmp(message->getMessage(), cmd[2], strlen(cmd[2])) == 0) + { + float data = (float)atoi(&message->getMessage()[strlen(cmd[2])+1]); + + CharacterStats.statType = STI_Movement; + CharacterStats.statValue = data; + Logging->writeLine("set champ speed to %f\n", data); + sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); + return true; + } + + //health + if(strncmp(message->getMessage(), cmd[3], strlen(cmd[3])) == 0) + { + float data = (float)atoi(&message->getMessage()[strlen(cmd[3])+1]); + + CharacterStats.statType = STI_Health; + CharacterStats.statValue = data; + Logging->writeLine("set champ health to %f\n", data); + sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); + return true; + } + //experience + if(strncmp(message->getMessage(), cmd[4], strlen(cmd[4])) == 0) + { + float data = (float)atoi(&message->getMessage()[strlen(cmd[4])+1]); + + CharacterStats.statType = STI_Exp; + CharacterStats.statValue = data; + Logging->writeLine("set champ exp to %f\n", data); + sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); + return true; + } + + //AbilityPower + if(strncmp(message->getMessage(), cmd[5], strlen(cmd[5])) == 0) + { + float data = (float)atoi(&message->getMessage()[strlen(cmd[5])+1]); + + charStats.statType = STI_AbilityPower; + charStats.statValue = data; + Logging->writeLine("set champ abilityPower to %f\n", data); + sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); + return true; + } + //Attack damage + if(strncmp(message->getMessage(), cmd[6], strlen(cmd[6])) == 0) + { + float data = (float)atoi(&message->getMessage()[strlen(cmd[6])+1]); + + charStats.statType = STI_AttackDamage; + charStats.statValue = data; + Logging->writeLine("set champ attack damage to %f\n", data); + sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); + return true; + } + //Mana + if(strncmp(message->getMessage(), cmd[7], strlen(cmd[7])) == 0) + { + float data = (float)atoi(&message->getMessage()[strlen(cmd[7])+1]); + + charStats.statType = STI_Mana; + charStats.statValue = data; + Logging->writeLine("set champ mana to %f\n", data); + sendPacket(peer,reinterpret_cast(&charStats),sizeof(charStats), CHL_LOW_PRIORITY, 2); + return true; + } + */ + //Model + if (strncmp(message->getMessage(), cmd[8], strlen(cmd[8])) == 0) { + std::string sModel = (char *)&message->getMessage()[strlen(cmd[8]) + 1]; + UpdateModel modelPacket(peerInfo(peer)->netId, (char *)sModel.c_str()); //96 + broadcastPacket(reinterpret_cast(&modelPacket), sizeof(UpdateModel), CHL_S2C); + return true; + } + } + switch (message->type) { + case CMT_ALL: + return broadcastPacket(packet->data, packet->dataLength, CHL_COMMUNICATION); + break; + case CMT_TEAM: + //!TODO make a team class and foreach player in the team send the message + return sendPacket(peer, packet->data, packet->dataLength, CHL_COMMUNICATION); + break; + default: + Logging->errorLine("Unknown ChatMessageType\n"); + return sendPacket(peer, packet->data, packet->dataLength, CHL_COMMUNICATION); + break; + } + return false; +} bool PacketHandler::handleSkillUp(HANDLE_ARGS) { SkillUpPacket *skillUpPacket = reinterpret_cast(packet->data); //!TODO Check if can up skill? :) @@ -473,19 +536,19 @@ bool PacketHandler::handleEmotion(HANDLE_ARGS) { switch(emotion->id) { case 0: //dance - Logging->writeLine("dance"); + Logging->writeLine("dance\n"); break; case 1: //taunt - Logging->writeLine("taunt"); + Logging->writeLine("taunt\n"); break; case 2: //laugh - Logging->writeLine("laugh"); + Logging->writeLine("laugh\n"); break; case 3: //joke - Logging->writeLine("joke"); + Logging->writeLine("joke\n"); break; } EmotionResponse response; diff --git a/gamed/NetworkListener.cpp b/gamed/NetworkListener.cpp index 418bfd30..5381cd33 100644 --- a/gamed/NetworkListener.cpp +++ b/gamed/NetworkListener.cpp @@ -18,6 +18,9 @@ along with this program. If not, see . #include "stdafx.h" #include "NetworkListener.h" #include "Log.h" +#include +#define NAME "%id%" +#define CHAMP "%ch%" uint32 GetNewNetID() { static DWORD dwStart = 0x40000019; @@ -63,40 +66,38 @@ void NetworkListener::netLoop() { ENetEvent event; - while(enet_host_service(_server, & event, 10) >= 0 && _isAlive) + while (enet_host_service(_server, &event, 10) >= 0 && _isAlive) { switch (event.type) { - case ENET_EVENT_TYPE_CONNECT: - Logging->writeLine("A new client connected: %i.%i.%i.%i:%i \n", event.peer->address.host & 0xFF, (event.peer->address.host >> 8) & 0xFF, (event.peer->address.host >> 16) & 0xFF, (event.peer->address.host >> 24) & 0xFF, event.peer->address.port); - - /* Set some defaults */ - event.peer->mtu = PEER_MTU; - - event.peer->data = new ClientInfo(); - peerInfo(event.peer)->setName("Test"); - peerInfo(event.peer)->setType("Teemo"); - peerInfo(event.peer)->skinNo = 6; - peerInfo(event.peer)->netId = GetNewNetID(); - + case ENET_EVENT_TYPE_CONNECT: + + Logging->writeLine("A new client connected: %i.%i.%i.%i:%i \n", event.peer->address.host & 0xFF, (event.peer->address.host >> 8) & 0xFF, (event.peer->address.host >> 16) & 0xFF, (event.peer->address.host >> 24) & 0xFF, event.peer->address.port); + /* Set some defaults */ + event.peer->mtu = PEER_MTU; + event.peer->data = new ClientInfo(); + peerInfo(event.peer)->setName("coolman"); + peerInfo(event.peer)->setType("Braum"); + peerInfo(event.peer)->skinNo = 0; + peerInfo(event.peer)->netId = GetNewNetID(); break; case ENET_EVENT_TYPE_RECEIVE: - if(!_handler->handlePacket(event.peer, event.packet,event.channelID)) + if (!_handler->handlePacket(event.peer, event.packet, event.channelID)) { //enet_peer_disconnect(event.peer, 0); } /* Clean up the packet now that we're done using it. */ - enet_packet_destroy (event.packet); - break; + enet_packet_destroy(event.packet); + break; case ENET_EVENT_TYPE_DISCONNECT: Logging->writeLine("Client disconnected: %i.%i.%i.%i:%i \n", event.peer->address.host & 0xFF, (event.peer->address.host >> 8) & 0xFF, (event.peer->address.host >> 16) & 0xFF, (event.peer->address.host >> 24) & 0xFF, event.peer->address.port); /* Cleanup */ delete (ClientInfo*)event.peer->data; - break; + break; } } } \ No newline at end of file diff --git a/gamed/Packets.h b/gamed/Packets.h index c770db8d..05dd47a6 100644 --- a/gamed/Packets.h +++ b/gamed/Packets.h @@ -81,8 +81,8 @@ typedef struct _SynchVersionAns { _SynchVersionAns() { header.cmd = PKT_S2C_SynchVersion; ok = ok2 = 1; - memcpy(version, "Version 4.5.0.264 [PUBLIC]", 27); - memcpy(gameMode, "CLASSIC", 8); + memcpy(version, "SANDBOX WOO", 27); + memcpy(gameMode, "COOLMAN", 8); //8 memset(zero, 0, 2232); end1 = 0xE2E0; end2 = 0xA0; @@ -91,11 +91,11 @@ typedef struct _SynchVersionAns { PacketHeader header; uint8 ok; uint32 mapId; - SynchBlock players[12]; + SynchBlock players[20]; uint8 version[27]; //Ending zero so size 26+0x00 uint8 ok2; //1 uint8 unknown[228]; //Really strange shit - uint8 gameMode[8]; + uint8 gameMode[1]; // 8 uint8 zero[2232]; uint16 end1; //0xE2E0 uint8 end2; //0xA0 || 0x08 @@ -117,16 +117,16 @@ typedef struct _LoadScreenInfo { //Zero this complete buffer memset(this, 0, sizeof(_LoadScreenInfo)); cmd = PKT_S2C_LoadScreenInfo; - blueMax = redMax = 6; + blueMax = redMax = 10; } uint8 cmd; uint32 blueMax; uint32 redMax; - uint64 bluePlayerIds[6]; //Team 1, 6 players max - uint8 blueData[144]; - uint64 redPlayersIds[6]; //Team 2, 6 players max - uint8 redData[144]; + uint64 bluePlayerIds[10]; //Team 1, 10 players max + uint8 blueData[400]; + uint64 redPlayerIds[10]; //Team 2, 10 players max + uint8 redData[400]; uint32 bluePlayerNo; uint32 redPlayerNo; } LoadScreenInfo; @@ -141,8 +141,8 @@ typedef struct _LoadScreenPlayer { _LoadScreenPlayer *packet = (_LoadScreenPlayer *)buf; packet->cmd = cmd; packet->length = size; - packet->userId = 0; - packet->skinId = 0; + packet->userId = 1; + packet->skinId = 0; memcpy(packet->getDescription(), str, packet->length); return packet; } @@ -488,7 +488,7 @@ struct ChatMessage { typedef struct _UpdateModel { _UpdateModel(DWORD netID, const char *szModel) { ZeroMemory(this, sizeof(_UpdateModel)); - header.cmd = (PacketCmd)0x96; + header.cmd = (PacketCmd)0x97; header.netId = netID; id = netID & ~0x40000000; bOk = 1; @@ -548,7 +548,7 @@ struct HeroSpawn { } ; struct HeroSpawn2 { HeroSpawn2() { - header.cmd = (PacketCmd)0xB9; + header.cmd = (PacketCmd)0xBA; ZeroMemory(unk, 30); unk[15] = 0x80; unk[16] = 0x3F; @@ -571,10 +571,10 @@ struct HeroSpawn2 { }; struct HeroSpawn3 { HeroSpawn3() { - header.cmd = (PacketCmd)0xAD; + header.cmd = (PacketCmd)0xAE; unk = 0; - health = 1337; - maxHealth = 666; + health = 1000; + maxHealth = 1000; } PacketHeader header; @@ -671,9 +671,9 @@ typedef struct _SkillUpPacket { typedef struct _SkillUpResponse { _SkillUpResponse() { header.cmd = PKT_S2C_SkillUp; - skill = 0; - level = 0; - pointsLeft = 0; + skill = 1; + level = 1; + pointsLeft = 1; } PacketHeader header; uint8 skill; diff --git a/gamed/main.cpp b/gamed/main.cpp index 20058463..fc9844c2 100644 --- a/gamed/main.cpp +++ b/gamed/main.cpp @@ -4,7 +4,7 @@ Copyright (C) 2012 Intline9 This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or +the Free Software Foundation, either version 3 of the License, orlth (at your option) any later version. This program is distributed in the hope that it will be useful, diff --git a/local.bat b/local.bat index adf83941..17f615db 100644 --- a/local.bat +++ b/local.bat @@ -1,4 +1,9 @@ @echo off +set /P id=Enter username: %=% +set /P ch=Enter champion: %=% +set /P ip=Enter IP: %=% + +pause setlocal enabledelayedexpansion echo ----------------------- echo IntWars Solo Launcher @@ -124,7 +129,7 @@ set lolver=!v0!.!v1!.!v2!.!v3! @cd /d "!RADS_PATH!\solutions\lol_game_client_sln\releases\!lolver!\deploy" if exist "League of Legends.exe" ( - @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "127.0.0.1 5119 17BLOhi6KZsTtldTsizvHg== 47917791" + @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "%ip% 5119 17BLOhi6KZsTtldTsizvHg== 47917791" goto exit ) :cannotFind diff --git a/localz.bat b/localz.bat new file mode 100644 index 00000000..0dee6e14 --- /dev/null +++ b/localz.bat @@ -0,0 +1,137 @@ +@echo off + +setlocal enabledelayedexpansion +echo ----------------------- +echo IntWars Solo Launcher +echo ----------------------- +set RADS_PATH= +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\Classes\VirtualStore\MACHINE\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\Software\Wow6432Node\Riot Games\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKCU\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +FOR /f "usebackq skip=2 tokens=3,4,5,6,7,8,9" %%i in (`%systemroot%\system32\REG.EXE QUERY "HKLM\SOFTWARE\RIOT GAMES\RADS" /v "LOCALROOTFOLDER"`) DO ( + SET RADS_PATH=%%i %%j %%k %%l %%m %%n %%o + goto runApp +) +cls +echo =================== +echo Finding other LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKLM\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /V /F "LocalRootFolder" /S /E ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +echo =================== +echo Finding another LoL directory path again.. +echo =================== +for /f "Tokens=3,4,5,6,7,8,9,10,11,12,13,14,15" %%a in ('%systemroot%\system32\REG.EXE Query HKCU\Software /s ^| %systemroot%\system32\find.exe "LocalRootFolder" ^| %systemroot%\system32\find.exe "RADS"') do ( + set RADS_PATH=%%a %%b %%c %%d %%e %%f %%g %%h %%i %%j %%k %%l %%m + goto runApp +) +cls +goto cannotFind +:runApp +set RADS_PATH=%RADS_PATH:/=\% +@cd /d "%RADS_PATH%\solutions\lol_game_client_sln\releases" + +set init=0 +set v0=0&set v1=0&set v2=0&set v3=0 +for /f "delims=" %%F in ('dir * /b ^| findstr ^[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*$') do ( + for /F "tokens=1,2,3,4 delims=." %%i in ("%%F") do ( + if !init! equ 0 ( set init=1&set flag=1 ) else ( + set flag=0 + + if %%i gtr !v0! ( set flag=1 ) else ( + if %%j gtr !v1! ( set flag=1 ) else ( + if %%k gtr !v2! ( set flag=1 ) else ( + if %%l gtr !v3! ( set flag=1 ) + ) + ) + ) + ) + + if !flag! gtr 0 ( + set v0=%%i&set v1=%%j&set v2=%%k&set v3=%%l + ) + ) +) + +if !init! equ 0 goto cannotFind +set lolver=!v0!.!v1!.!v2!.!v3! + +@cd /d "!RADS_PATH!\solutions\lol_game_client_sln\releases\!lolver!\deploy" +if exist "League of Legends.exe" ( + @start "" "League of Legends.exe" "8394" "LoLLauncher.exe" "" "127.0.0.1 5119 17BLOhi6KZsTtldTsizvHg== 47917791" + goto exit +) +:cannotFind +echo =================== +echo Cannot find LoL path automatically :( +echo =================== +@pause +goto exit +:exit diff --git a/win/VC100/enet-1.2.5.vcxproj b/win/VC100/enet-1.2.5.vcxproj index 57507616..82c75e9d 100644 --- a/win/VC100/enet-1.2.5.vcxproj +++ b/win/VC100/enet-1.2.5.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,10 +19,12 @@ StaticLibrary Unicode + v120 StaticLibrary Unicode + v120 diff --git a/win/VC100/gamed.vcxproj b/win/VC100/gamed.vcxproj index 971f8623..3e433fec 100644 --- a/win/VC100/gamed.vcxproj +++ b/win/VC100/gamed.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,10 +19,12 @@ Application Unicode + v120 Application Unicode + v120 diff --git a/win/VC100/intlib.vcxproj b/win/VC100/intlib.vcxproj index 4bef66d9..27a2d44a 100644 --- a/win/VC100/intlib.vcxproj +++ b/win/VC100/intlib.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -19,10 +19,12 @@ StaticLibrary Unicode + v120 StaticLibrary Unicode + v120 From b8b09e489a2b32b41c4934fb537e218ee1a6683a Mon Sep 17 00:00:00 2001 From: noobasaurus Date: Thu, 17 Jul 2014 10:09:34 -0700 Subject: [PATCH 4/4] Fixed emoticons Screwed them up last one --- common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.h b/common.h index 3b8194d4..96a46f7c 100644 --- a/common.h +++ b/common.h @@ -41,7 +41,7 @@ PKT_C2S_SkillUp = 0x39, //1 //UPDATED PKT_S2C_AttentionPing = 0x3F, //3 //UPDATED PKT_S2C_Emotion = 0x42, //3 UPDATED -PKT_C2S_Emotion = 0x47, //1 UPDATED +PKT_C2S_Emotion = 0x48, //1 UPDATED PKT_S2C_HeroSpawn = 0x4C, //3 UPDATED PKT_S2C_Announce = 0x4D, //3