Add project files.
This commit is contained in:
parent
0f6fb75cff
commit
3c20df7683
94
Client/Client.cpp
Normal file
94
Client/Client.cpp
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
// Client.cpp : This file contains the 'main' function. Program execution begins and ends there.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
HANDLE hPipe;
|
||||||
|
DWORD dwWritten;
|
||||||
|
BOOL fSuccess = FALSE;
|
||||||
|
DWORD cbRead, cbToWrite, cbWritten, dwMode;
|
||||||
|
|
||||||
|
int CreatePipe(std::string name)
|
||||||
|
{
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
hPipe = CreateFileA(
|
||||||
|
name.c_str(), // pipe name
|
||||||
|
GENERIC_READ | // read and write access
|
||||||
|
GENERIC_WRITE,
|
||||||
|
0, // no sharing
|
||||||
|
NULL, // default security attributes
|
||||||
|
OPEN_EXISTING, // opens existing pipe
|
||||||
|
0, // default attributes
|
||||||
|
NULL); // no template file
|
||||||
|
|
||||||
|
// Break if the pipe handle is valid.
|
||||||
|
|
||||||
|
if (hPipe != INVALID_HANDLE_VALUE)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Exit if an error other than ERROR_PIPE_BUSY occurs.
|
||||||
|
|
||||||
|
if (GetLastError() != ERROR_PIPE_BUSY)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dwMode = PIPE_READMODE_MESSAGE;
|
||||||
|
fSuccess = SetNamedPipeHandleState(
|
||||||
|
hPipe, // pipe handle
|
||||||
|
&dwMode, // new pipe mode
|
||||||
|
NULL, // don't set maximum bytes
|
||||||
|
NULL); // don't set maximum time
|
||||||
|
if (!fSuccess)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ReadMessage()
|
||||||
|
{
|
||||||
|
char chBuf[10240];
|
||||||
|
do
|
||||||
|
{
|
||||||
|
// Read from the pipe.
|
||||||
|
|
||||||
|
fSuccess = ReadFile(
|
||||||
|
hPipe, // pipe handle
|
||||||
|
chBuf, // buffer to receive reply
|
||||||
|
10240 * sizeof(char), // size of buffer
|
||||||
|
&cbRead, // number of bytes read
|
||||||
|
NULL); // not overlapped
|
||||||
|
|
||||||
|
if (!fSuccess && GetLastError() != ERROR_MORE_DATA)
|
||||||
|
break;
|
||||||
|
} while (!fSuccess);
|
||||||
|
|
||||||
|
return std::string(chBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
CreatePipe("\\\\.\\pipe\\PipeL2Bot");
|
||||||
|
std::cout << "Connected to the connection pipe" << std::endl;
|
||||||
|
|
||||||
|
auto name = ReadMessage();
|
||||||
|
CloseHandle(hPipe);
|
||||||
|
std::cout << "Received main pipe name: " << name << std::endl;
|
||||||
|
|
||||||
|
std::cin.get();
|
||||||
|
CreatePipe(name);
|
||||||
|
|
||||||
|
const std::string message = "invalidate";
|
||||||
|
DWORD written;
|
||||||
|
WriteFile(hPipe, message.c_str(), message.size() + 1, &written, NULL);
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
std::cout << ReadMessage() << std::endl;
|
||||||
|
}
|
||||||
|
std::cin.get();
|
||||||
|
}
|
151
Client/Client.vcxproj
Normal file
151
Client/Client.vcxproj
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{d5e220d4-cba9-465c-8d1a-b97cc5e5e825}</ProjectGuid>
|
||||||
|
<RootNamespace>Client</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\bin\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\bin\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Client.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
22
Client/Client.vcxproj.filters
Normal file
22
Client/Client.vcxproj.filters
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Client.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
182
InjectionLibrary/InjectionLibrary.vcxproj
Normal file
182
InjectionLibrary/InjectionLibrary.vcxproj
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{54fbe631-3f9b-458c-9db2-43a868cdb806}</ProjectGuid>
|
||||||
|
<RootNamespace>InjectionLibrary</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\bin\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\bin\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="framework.h" />
|
||||||
|
<ClInclude Include="Injector.h" />
|
||||||
|
<ClInclude Include="pch.h" />
|
||||||
|
<ClInclude Include="ProcessManipulation.h" />
|
||||||
|
<ClInclude Include="Trampoline.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Injector.cpp" />
|
||||||
|
<ClCompile Include="pch.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ProcessManipulation.cpp" />
|
||||||
|
<ClCompile Include="Trampoline.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
48
InjectionLibrary/InjectionLibrary.vcxproj.filters
Normal file
48
InjectionLibrary/InjectionLibrary.vcxproj.filters
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="framework.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="pch.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Injector.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="ProcessManipulation.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Trampoline.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="pch.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Injector.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="ProcessManipulation.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Trampoline.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
35
InjectionLibrary/Injector.cpp
Normal file
35
InjectionLibrary/Injector.cpp
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "Injector.h"
|
||||||
|
|
||||||
|
namespace InjectLibrary
|
||||||
|
{
|
||||||
|
HHOOK Injector::_hookHandle = nullptr;
|
||||||
|
|
||||||
|
Injector::Injector(const std::string& mutexName, int windowsMessage) : _mutexName(mutexName), _windowsMessage(windowsMessage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Injector::SetHook(const HINSTANCE moduleHandle)
|
||||||
|
{
|
||||||
|
if (moduleHandle) {
|
||||||
|
// Ñ ïîìîùüþ ìþòåêñà ïðîâåðÿåì, ÷òî åùå íå áûëî õóêà
|
||||||
|
HANDLE mutexHandle = CreateMutexA(nullptr, false, _mutexName.c_str());
|
||||||
|
if (GetLastError() != ERROR_ALREADY_EXISTS) {
|
||||||
|
_hookHandle = SetWindowsHookExA(_windowsMessage, (HOOKPROC)HookMessageProcedure, moduleHandle, 0);
|
||||||
|
_mutexHandle = mutexHandle;
|
||||||
|
}
|
||||||
|
else if (mutexHandle) {
|
||||||
|
CloseHandle(mutexHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UnhookWindowsHookEx(_hookHandle);
|
||||||
|
CloseHandle(_mutexHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const LRESULT Injector::HookMessageProcedure(const DWORD code, const DWORD wParam, const DWORD lParam)
|
||||||
|
{
|
||||||
|
return CallNextHookEx(_hookHandle, code, wParam, lParam);
|
||||||
|
}
|
||||||
|
}
|
23
InjectionLibrary/Injector.h
Normal file
23
InjectionLibrary/Injector.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace InjectLibrary
|
||||||
|
{
|
||||||
|
class Injector
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Injector(const std::string& mutexName, int windowsMessage);
|
||||||
|
virtual ~Injector() = default;
|
||||||
|
void CALLBACK SetHook(const HINSTANCE moduleHandle = nullptr);
|
||||||
|
private:
|
||||||
|
static const LRESULT CALLBACK HookMessageProcedure(const DWORD code, const DWORD wParam, const DWORD lParam);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static HHOOK _hookHandle;
|
||||||
|
HANDLE _mutexHandle = nullptr;
|
||||||
|
int _windowsMessage = 0;
|
||||||
|
const std::string _mutexName;
|
||||||
|
};
|
||||||
|
};
|
89
InjectionLibrary/ProcessManipulation.cpp
Normal file
89
InjectionLibrary/ProcessManipulation.cpp
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include <algorithm>
|
||||||
|
#include "ProcessManipulation.h"
|
||||||
|
|
||||||
|
namespace InjectLibrary
|
||||||
|
{
|
||||||
|
const std::string GetProcessName(const DWORD processId)
|
||||||
|
{
|
||||||
|
HANDLE handle = OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, FALSE, processId);
|
||||||
|
if (handle) {
|
||||||
|
char path[MAX_PATH];
|
||||||
|
char drive[_MAX_DRIVE];
|
||||||
|
char dir[_MAX_DIR];
|
||||||
|
char fname[_MAX_FNAME];
|
||||||
|
char ext[_MAX_EXT];
|
||||||
|
GetModuleFileNameExA(handle, 0, path, sizeof(path));
|
||||||
|
_splitpath_s(path, drive, dir, fname, ext);
|
||||||
|
CloseHandle(handle);
|
||||||
|
|
||||||
|
std::string result = std::string(fname) + std::string(ext);
|
||||||
|
std::transform(result.begin(), result.end(), result.begin(), ::towlower);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string GetCurrentProcessName()
|
||||||
|
{
|
||||||
|
return GetProcessName(GetCurrentProcessId());
|
||||||
|
}
|
||||||
|
|
||||||
|
void StartProcess(const DWORD processId)
|
||||||
|
{
|
||||||
|
DWORD currThread = GetCurrentThreadId();
|
||||||
|
HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
||||||
|
THREADENTRY32 thread;
|
||||||
|
HANDLE threadHandle;
|
||||||
|
if (snap != INVALID_HANDLE_VALUE) {
|
||||||
|
thread.dwSize = sizeof(LPTHREADENTRY32);
|
||||||
|
if (Thread32First(snap, &thread)) {
|
||||||
|
do {
|
||||||
|
if (thread.th32ThreadID != currThread && thread.th32OwnerProcessID != processId) {
|
||||||
|
threadHandle = OpenThread(THREAD_SUSPEND_RESUME, FALSE, thread.th32ThreadID);
|
||||||
|
if (threadHandle == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ResumeThread(threadHandle);
|
||||||
|
CloseHandle(threadHandle);
|
||||||
|
}
|
||||||
|
} while (Thread32Next(snap, &thread));
|
||||||
|
}
|
||||||
|
CloseHandle(snap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StartCurrentProcess()
|
||||||
|
{
|
||||||
|
StartProcess(GetCurrentProcessId());
|
||||||
|
}
|
||||||
|
|
||||||
|
void StopProcess(const DWORD processId)
|
||||||
|
{
|
||||||
|
DWORD currThread = GetCurrentThreadId();
|
||||||
|
HANDLE snap = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
|
||||||
|
THREADENTRY32 thread;
|
||||||
|
HANDLE threadHandle;
|
||||||
|
if (snap != INVALID_HANDLE_VALUE) {
|
||||||
|
thread.dwSize = sizeof(LPTHREADENTRY32);
|
||||||
|
if (Thread32First(snap, &thread)) {
|
||||||
|
do {
|
||||||
|
if (thread.th32ThreadID != currThread && thread.th32OwnerProcessID != processId) {
|
||||||
|
threadHandle = OpenThread(THREAD_SUSPEND_RESUME, FALSE, thread.th32ThreadID);
|
||||||
|
if (threadHandle == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
SuspendThread(threadHandle);
|
||||||
|
CloseHandle(threadHandle);
|
||||||
|
}
|
||||||
|
} while (Thread32Next(snap, &thread));
|
||||||
|
}
|
||||||
|
CloseHandle(snap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StopCurrentProcess()
|
||||||
|
{
|
||||||
|
StopProcess(GetCurrentProcessId());
|
||||||
|
}
|
||||||
|
}
|
14
InjectionLibrary/ProcessManipulation.h
Normal file
14
InjectionLibrary/ProcessManipulation.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace InjectLibrary
|
||||||
|
{
|
||||||
|
void StartProcess(const DWORD processId);
|
||||||
|
void StartCurrentProcess();
|
||||||
|
void StopProcess(const DWORD processId);
|
||||||
|
void StopCurrentProcess();
|
||||||
|
const std::string GetProcessName(const DWORD processId);
|
||||||
|
const std::string GetCurrentProcessName();
|
||||||
|
};
|
66
InjectionLibrary/Trampoline.cpp
Normal file
66
InjectionLibrary/Trampoline.cpp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "Trampoline.h"
|
||||||
|
|
||||||
|
namespace InjectLibrary
|
||||||
|
{
|
||||||
|
Trampoline::Trampoline(void* hookedFunctionAddress, void* hookPayloadFunctionAddress, const BYTE oldCodeSize) :
|
||||||
|
_hookedFunctionAddress(hookedFunctionAddress), _hookPayloadFunctionAddress(hookPayloadFunctionAddress)
|
||||||
|
{
|
||||||
|
auto size = oldCodeSize;
|
||||||
|
if (size <= 0) {
|
||||||
|
size = SIZE_OF_JUMP;
|
||||||
|
}
|
||||||
|
_trampolineLayout = new TrampolineLayout(size);
|
||||||
|
// Êîä, êîòîðûé áóäåò ñãåíåðèðîâàí â áóäóùåì äîëæåí èìåòü ðàçðåøåíèå íà âûïîëíåíèå
|
||||||
|
VirtualProtect(_trampolineLayout->code, _trampolineLayout->GetFullSize(), PAGE_EXECUTE_READWRITE, &_protect);
|
||||||
|
}
|
||||||
|
|
||||||
|
Trampoline::~Trampoline()
|
||||||
|
{
|
||||||
|
VirtualProtect(_trampolineLayout->code, _trampolineLayout->GetFullSize(), _protect, &_protect);
|
||||||
|
delete _trampolineLayout;
|
||||||
|
}
|
||||||
|
|
||||||
|
const FARPROC Trampoline::Install()
|
||||||
|
{
|
||||||
|
FillLayout();
|
||||||
|
InstallHook();
|
||||||
|
return GetAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Trampoline::Uninstall()
|
||||||
|
{
|
||||||
|
DWORD oldProtect;
|
||||||
|
VirtualProtect(_hookedFunctionAddress, SIZE_OF_JUMP, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||||
|
// Ïðè óäàëåíèè õóêà âåðíåì íà ìåñòî çàòåðòûå èíñòðóêöèè â ïåðåõâàòûâàåìîé ôóêíöèè
|
||||||
|
CopyMemory(_hookedFunctionAddress, _trampolineLayout->code, SIZE_OF_JUMP);
|
||||||
|
VirtualProtect(_hookedFunctionAddress, SIZE_OF_JUMP, oldProtect, &oldProtect);
|
||||||
|
}
|
||||||
|
|
||||||
|
const FARPROC Trampoline::GetAddress() const
|
||||||
|
{
|
||||||
|
return (FARPROC)(void*)_trampolineLayout->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Trampoline::FillLayout()
|
||||||
|
{
|
||||||
|
const auto oldCodeSize = _trampolineLayout->GetOldCodeSize();
|
||||||
|
// Ñêîïèðóåì ïåðâûå oldCodeSize áàéò êîäà èç ïåðåõâàòûâàåìîé ôóíêöèè â íàø òðàìïëèí
|
||||||
|
CopyMemory(_trampolineLayout->code, _hookedFunctionAddress, oldCodeSize);
|
||||||
|
// Ïîäñ÷èòàåì 32áèòíîå ñìåùåíèå àäðåñà è çàïèøåì â íàø òðàìïëèí ïîñëå êîäà ôóêíöèè, ñêîïèðîâííîãî âûøå
|
||||||
|
_trampolineLayout->jumpInstruction->rel32 = (DWORD)_hookedFunctionAddress - ((DWORD)_trampolineLayout->code + oldCodeSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Trampoline::InstallHook() const
|
||||||
|
{
|
||||||
|
DWORD oldProtect;
|
||||||
|
// ×òî áû èçìåíèòü êîä ïåðåõâàòûâàåìîé ôóíêöèè, îáëàñòü ïàìÿòè äîëæíà èìåòü ðàçðåøåíèå íà çàïèñü
|
||||||
|
VirtualProtect(_hookedFunctionAddress, SIZE_OF_JUMP, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||||
|
RelativeJumpLayout* instr = (RelativeJumpLayout*)((BYTE*)_hookedFunctionAddress);
|
||||||
|
// Ïîäñ÷èòàåì 32áèòíîå ñìåùåíèå àäðåñà è çàïèøåì åãî âìåñòå ñ îïêîäîì èíñòðóêöèè äæàìïà â íà÷àëî ïåðåõâàòûâàåìîé ôóíêöèè
|
||||||
|
// Äæàìï áóäåò âûïîëíåí â íàøó ôóíêöèþ, ãäå âûïîëíÿåòñÿ ðåàëüíàÿ ðàáîòà ïîñëå ïåðåõâàòà è îñóùåñòâëÿåòñÿ ïåðåõîä íà èíñòðóêöèþ òðàìïëèíà
|
||||||
|
instr->opcode = 0xe9;
|
||||||
|
instr->rel32 = (DWORD)_hookPayloadFunctionAddress - ((DWORD)_hookedFunctionAddress + SIZE_OF_JUMP);
|
||||||
|
VirtualProtect(_hookedFunctionAddress, SIZE_OF_JUMP, oldProtect, &oldProtect);
|
||||||
|
}
|
||||||
|
}
|
78
InjectionLibrary/Trampoline.h
Normal file
78
InjectionLibrary/Trampoline.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
|
namespace InjectLibrary
|
||||||
|
{
|
||||||
|
// Âûíåñåì èíñòðóêöèþ äæàìïà â îòäåëüíóþ ñòðóêòóðó, è çàïðåòèì êîìïèëÿòîðó âûðâàíèâàíèå àäðåñîâ
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct RelativeJumpLayout
|
||||||
|
{
|
||||||
|
BYTE opcode = 0;
|
||||||
|
DWORD rel32 = 0;
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
const BYTE SIZE_OF_JUMP = sizeof(RelativeJumpLayout);
|
||||||
|
|
||||||
|
struct TrampolineLayout
|
||||||
|
{
|
||||||
|
static const BYTE CODE_MAX_SIZE = 100;
|
||||||
|
// Â ýòîé ñòðóêòóðå çàïðåò íà âûðàâíèâàíèå àäðåñîâ âàæåí òîëüêî äëÿ ãåíåðèðóåìîãî êîäà
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
BYTE code[CODE_MAX_SIZE] = { 0 };
|
||||||
|
#pragma pack(pop)
|
||||||
|
RelativeJumpLayout* jumpInstruction = nullptr;
|
||||||
|
|
||||||
|
TrampolineLayout(const BYTE oldCodeSize) : _oldCodeSize(oldCodeSize)
|
||||||
|
{
|
||||||
|
if (oldCodeSize < SIZE_OF_JUMP) {
|
||||||
|
throw std::overflow_error("oldCodeSize lesser than SIZE_OF_JUMP");
|
||||||
|
}
|
||||||
|
if (oldCodeSize > CODE_MAX_SIZE - SIZE_OF_JUMP) {
|
||||||
|
throw std::overflow_error("oldCodeSize greater than CODE_MAX_SIZE - SIZE_OF_JUMP");
|
||||||
|
}
|
||||||
|
// Íàñòðîèì àäðåñ èíñòðóêöèè äæàìïà íà àäðåñ, íàõîäÿùèéñÿ ñðàçó ïîñëå ðåàëüíûõ èíñòðóêöèé, êîòîðûå áóäóò ñêîïèðîâàíû èç ïåðåõâàòûâàåìîé ôóíêöèè
|
||||||
|
jumpInstruction = (RelativeJumpLayout*)((BYTE*)code + _oldCodeSize);
|
||||||
|
jumpInstruction->opcode = 0xe9;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BYTE GetFullSize() const
|
||||||
|
{
|
||||||
|
return GetOldCodeSize() + SIZE_OF_JUMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
const BYTE GetOldCodeSize() const
|
||||||
|
{
|
||||||
|
return _oldCodeSize;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
const BYTE _oldCodeSize = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Trampoline
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Trampoline(void* hookedFunctionAddress, void* hookPayloadFunctionAddress, const BYTE oldCodeSize = 0);
|
||||||
|
virtual ~Trampoline();
|
||||||
|
const FARPROC Install();
|
||||||
|
void Uninstall();
|
||||||
|
const FARPROC GetAddress() const;
|
||||||
|
|
||||||
|
Trampoline(const Trampoline&) = delete;
|
||||||
|
Trampoline& operator=(const Trampoline&) = delete;
|
||||||
|
Trampoline(const Trampoline&&) = delete;
|
||||||
|
Trampoline& operator=(const Trampoline&&) = delete;
|
||||||
|
private:
|
||||||
|
void FillLayout();
|
||||||
|
void InstallHook() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
TrampolineLayout* _trampolineLayout = nullptr;
|
||||||
|
void* _hookedFunctionAddress = nullptr;
|
||||||
|
void* _hookPayloadFunctionAddress = nullptr;
|
||||||
|
DWORD _protect = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
9
InjectionLibrary/framework.h
Normal file
9
InjectionLibrary/framework.h
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
#include <windows.h>
|
||||||
|
#include <string>
|
||||||
|
#include <Psapi.h>
|
||||||
|
#include <tlhelp32.h>
|
||||||
|
#include <map>
|
||||||
|
#include <stdexcept>
|
5
InjectionLibrary/pch.cpp
Normal file
5
InjectionLibrary/pch.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// pch.cpp: source file corresponding to the pre-compiled header
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
|
13
InjectionLibrary/pch.h
Normal file
13
InjectionLibrary/pch.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// pch.h: This is a precompiled header file.
|
||||||
|
// Files listed below are compiled only once, improving build performance for future builds.
|
||||||
|
// This also affects IntelliSense performance, including code completion and many code browsing features.
|
||||||
|
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
|
||||||
|
// Do not add files here that you will be updating frequently as this negates the performance advantage.
|
||||||
|
|
||||||
|
#ifndef PCH_H
|
||||||
|
#define PCH_H
|
||||||
|
|
||||||
|
// add headers that you want to pre-compile here
|
||||||
|
#include "framework.h"
|
||||||
|
|
||||||
|
#endif //PCH_H
|
77
L2Bot.sln
Normal file
77
L2Bot.sln
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.0.32126.317
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "L2BotCore", "L2BotCore\L2BotCore.vcxproj", "{504A5403-BA08-46DF-AA8A-B79993B56BCA}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Sandbox", "Sandbox\Sandbox.vcxproj", "{28B1B2BC-BB6C-483E-B18D-E532A29ED8EA}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{504A5403-BA08-46DF-AA8A-B79993B56BCA} = {504A5403-BA08-46DF-AA8A-B79993B56BCA}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "L2BotDll", "L2BotDll\L2BotDll.vcxproj", "{F077B130-780F-4C72-AF56-E98B104A2A7D}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{54FBE631-3F9B-458C-9DB2-43A868CDB806} = {54FBE631-3F9B-458C-9DB2-43A868CDB806}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Client", "Client\Client.vcxproj", "{D5E220D4-CBA9-465C-8D1A-B97CC5E5E825}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InjectionLibrary", "InjectionLibrary\InjectionLibrary.vcxproj", "{54FBE631-3F9B-458C-9DB2-43A868CDB806}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{504A5403-BA08-46DF-AA8A-B79993B56BCA}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{504A5403-BA08-46DF-AA8A-B79993B56BCA}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{504A5403-BA08-46DF-AA8A-B79993B56BCA}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{504A5403-BA08-46DF-AA8A-B79993B56BCA}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{504A5403-BA08-46DF-AA8A-B79993B56BCA}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{504A5403-BA08-46DF-AA8A-B79993B56BCA}.Release|x64.Build.0 = Release|x64
|
||||||
|
{504A5403-BA08-46DF-AA8A-B79993B56BCA}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{504A5403-BA08-46DF-AA8A-B79993B56BCA}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{28B1B2BC-BB6C-483E-B18D-E532A29ED8EA}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{28B1B2BC-BB6C-483E-B18D-E532A29ED8EA}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{28B1B2BC-BB6C-483E-B18D-E532A29ED8EA}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{28B1B2BC-BB6C-483E-B18D-E532A29ED8EA}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{28B1B2BC-BB6C-483E-B18D-E532A29ED8EA}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{28B1B2BC-BB6C-483E-B18D-E532A29ED8EA}.Release|x64.Build.0 = Release|x64
|
||||||
|
{28B1B2BC-BB6C-483E-B18D-E532A29ED8EA}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{28B1B2BC-BB6C-483E-B18D-E532A29ED8EA}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{F077B130-780F-4C72-AF56-E98B104A2A7D}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{F077B130-780F-4C72-AF56-E98B104A2A7D}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{F077B130-780F-4C72-AF56-E98B104A2A7D}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{F077B130-780F-4C72-AF56-E98B104A2A7D}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{F077B130-780F-4C72-AF56-E98B104A2A7D}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{F077B130-780F-4C72-AF56-E98B104A2A7D}.Release|x64.Build.0 = Release|x64
|
||||||
|
{F077B130-780F-4C72-AF56-E98B104A2A7D}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{F077B130-780F-4C72-AF56-E98B104A2A7D}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{D5E220D4-CBA9-465C-8D1A-B97CC5E5E825}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{D5E220D4-CBA9-465C-8D1A-B97CC5E5E825}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{D5E220D4-CBA9-465C-8D1A-B97CC5E5E825}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{D5E220D4-CBA9-465C-8D1A-B97CC5E5E825}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{D5E220D4-CBA9-465C-8D1A-B97CC5E5E825}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{D5E220D4-CBA9-465C-8D1A-B97CC5E5E825}.Release|x64.Build.0 = Release|x64
|
||||||
|
{D5E220D4-CBA9-465C-8D1A-B97CC5E5E825}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{D5E220D4-CBA9-465C-8D1A-B97CC5E5E825}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{54FBE631-3F9B-458C-9DB2-43A868CDB806}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{54FBE631-3F9B-458C-9DB2-43A868CDB806}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{54FBE631-3F9B-458C-9DB2-43A868CDB806}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{54FBE631-3F9B-458C-9DB2-43A868CDB806}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{54FBE631-3F9B-458C-9DB2-43A868CDB806}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{54FBE631-3F9B-458C-9DB2-43A868CDB806}.Release|x64.Build.0 = Release|x64
|
||||||
|
{54FBE631-3F9B-458C-9DB2-43A868CDB806}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{54FBE631-3F9B-458C-9DB2-43A868CDB806}.Release|x86.Build.0 = Release|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {F47CE936-74D5-4FF2-AABA-0AA02AB71BA4}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
21
L2BotCore/Domain/DTO/BaseItem.h
Normal file
21
L2BotCore/Domain/DTO/BaseItem.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include "WorldObject.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::DTO
|
||||||
|
{
|
||||||
|
struct BaseItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint32_t itemId = 0;
|
||||||
|
const uint32_t amount = 0;
|
||||||
|
const bool isEquipped = 0;
|
||||||
|
const uint16_t enchantLevel = 0;
|
||||||
|
const int32_t mana = -1;
|
||||||
|
const std::string name = "";
|
||||||
|
const std::string iconName = "";
|
||||||
|
const std::string description = "";
|
||||||
|
const uint16_t weight = 0;
|
||||||
|
};
|
||||||
|
}
|
16
L2BotCore/Domain/DTO/Drop.h
Normal file
16
L2BotCore/Domain/DTO/Drop.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include "WorldObject.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::DTO
|
||||||
|
{
|
||||||
|
struct Drop : public WorldObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint32_t itemId = 0;
|
||||||
|
const uint32_t amount = 0;
|
||||||
|
const std::string name = "";
|
||||||
|
const std::string iconName = "";
|
||||||
|
};
|
||||||
|
}
|
29
L2BotCore/Domain/DTO/Hero.h
Normal file
29
L2BotCore/Domain/DTO/Hero.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "WorldObject.h"
|
||||||
|
#include "../ValueObjects/FullName.h"
|
||||||
|
#include "../ValueObjects/VitalStats.h"
|
||||||
|
#include "../ValueObjects/Phenotype.h"
|
||||||
|
#include "../ValueObjects/ExperienceInfo.h"
|
||||||
|
#include "../ValueObjects/PermanentStats.h"
|
||||||
|
#include "../ValueObjects/VariableStats.h"
|
||||||
|
#include "../ValueObjects/Reputation.h"
|
||||||
|
#include "../ValueObjects/InventoryInfo.h"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::DTO
|
||||||
|
{
|
||||||
|
struct Hero : public WorldObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const ValueObjects::FullName fullName = ValueObjects::FullName();
|
||||||
|
const ValueObjects::VitalStats vitalStats = ValueObjects::VitalStats();
|
||||||
|
const ValueObjects::Phenotype phenotype = ValueObjects::Phenotype();
|
||||||
|
const ValueObjects::ExperienceInfo experienceInfo = ValueObjects::ExperienceInfo();
|
||||||
|
const ValueObjects::PermanentStats permanentStats = ValueObjects::PermanentStats();
|
||||||
|
const ValueObjects::VariableStats variableStats = ValueObjects::VariableStats();
|
||||||
|
const ValueObjects::Reputation reputation = ValueObjects::Reputation();
|
||||||
|
const ValueObjects::InventoryInfo inventoryInfo = ValueObjects::InventoryInfo();
|
||||||
|
const uint32_t targetId = 0;
|
||||||
|
const bool isStanding = true;
|
||||||
|
};
|
||||||
|
}
|
19
L2BotCore/Domain/DTO/NPC.h
Normal file
19
L2BotCore/Domain/DTO/NPC.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "WorldObject.h"
|
||||||
|
#include "../ValueObjects/FullName.h"
|
||||||
|
#include "../ValueObjects/VitalStats.h"
|
||||||
|
#include "../Enums/SpoilStateEnum.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::DTO
|
||||||
|
{
|
||||||
|
struct NPC : public WorldObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const bool isHostile = false;
|
||||||
|
const uint32_t npcId = 0;
|
||||||
|
const Enums::SpoilStateEnum spoilState = Enums::SpoilStateEnum::none;
|
||||||
|
const ValueObjects::FullName fullName = ValueObjects::FullName();
|
||||||
|
const ValueObjects::VitalStats vitalStats = ValueObjects::VitalStats();
|
||||||
|
};
|
||||||
|
}
|
13
L2BotCore/Domain/DTO/ObjectState.h
Normal file
13
L2BotCore/Domain/DTO/ObjectState.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../Enums/ObjectStateEnum.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::DTO
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
struct ObjectState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
T object;
|
||||||
|
Enums::ObjectStateEnum state = Enums::ObjectStateEnum::none;
|
||||||
|
};
|
||||||
|
}
|
14
L2BotCore/Domain/DTO/Player.h
Normal file
14
L2BotCore/Domain/DTO/Player.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "WorldObject.h"
|
||||||
|
#include "../ValueObjects/FullName.h"
|
||||||
|
#include "../ValueObjects/VitalStats.h"
|
||||||
|
#include "../ValueObjects/Phenotype.h"
|
||||||
|
namespace L2Bot::Domain::DTO
|
||||||
|
{
|
||||||
|
struct Player : public WorldObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const ValueObjects::FullName fullName = ValueObjects::FullName();
|
||||||
|
const ValueObjects::Phenotype phenotype = ValueObjects::Phenotype();
|
||||||
|
};
|
||||||
|
}
|
22
L2BotCore/Domain/DTO/Skill.h
Normal file
22
L2BotCore/Domain/DTO/Skill.h
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::DTO
|
||||||
|
{
|
||||||
|
struct Skill
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint32_t skillId = 0;
|
||||||
|
const uint8_t level = 0;
|
||||||
|
const bool isActive = false;
|
||||||
|
const uint8_t cost = 0;
|
||||||
|
const int16_t range = 0;
|
||||||
|
const std::string name = "";
|
||||||
|
const std::string description = "";
|
||||||
|
const std::string iconName = "";
|
||||||
|
const bool isToggled = false;
|
||||||
|
const bool isCasting = false;
|
||||||
|
const bool isReloading = false;
|
||||||
|
};
|
||||||
|
}
|
13
L2BotCore/Domain/DTO/WorldObject.h
Normal file
13
L2BotCore/Domain/DTO/WorldObject.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "../ValueObjects/Transform.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::DTO
|
||||||
|
{
|
||||||
|
struct WorldObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint32_t id = 0;
|
||||||
|
const ValueObjects::Transform transform = ValueObjects::Transform();
|
||||||
|
};
|
||||||
|
}
|
97
L2BotCore/Domain/Entities/Drop.h
Normal file
97
L2BotCore/Domain/Entities/Drop.h
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include "WorldObject.h"
|
||||||
|
#include "../DTO/Drop.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Entities
|
||||||
|
{
|
||||||
|
class Drop : public WorldObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint32_t GetItemId() const
|
||||||
|
{
|
||||||
|
return m_ItemId;
|
||||||
|
}
|
||||||
|
const uint32_t GetAmount() const
|
||||||
|
{
|
||||||
|
return m_Amount;
|
||||||
|
}
|
||||||
|
const std::string GetName() const
|
||||||
|
{
|
||||||
|
return m_Name;
|
||||||
|
}
|
||||||
|
const std::string GetIconName() const
|
||||||
|
{
|
||||||
|
return m_IconName;
|
||||||
|
}
|
||||||
|
void UpdateFromDTO(const DTO::WorldObject* dto) override
|
||||||
|
{
|
||||||
|
const DTO::Drop* castedDto = static_cast<const DTO::Drop*>(dto);
|
||||||
|
WorldObject::UpdateFromDTO(dto);
|
||||||
|
m_ItemId = castedDto->itemId;
|
||||||
|
m_Amount = castedDto->amount;
|
||||||
|
m_Name = castedDto->name;
|
||||||
|
m_IconName = castedDto->iconName;
|
||||||
|
}
|
||||||
|
void SaveState() override
|
||||||
|
{
|
||||||
|
WorldObject::SaveState();
|
||||||
|
m_IsNewState = false;
|
||||||
|
}
|
||||||
|
const static Drop CreateFromDTO(const DTO::Drop& dto)
|
||||||
|
{
|
||||||
|
return Drop(dto.id, dto.transform, dto.itemId, dto.amount, dto.name, dto.iconName);
|
||||||
|
}
|
||||||
|
const bool IsEqual(const DTO::WorldObject* dto) const override
|
||||||
|
{
|
||||||
|
const DTO::Drop* castedDto = static_cast<const DTO::Drop*>(dto);
|
||||||
|
return WorldObject::IsEqual(dto) &&
|
||||||
|
m_ItemId == castedDto->itemId &&
|
||||||
|
m_Amount == castedDto->amount &&
|
||||||
|
m_Name == castedDto->name &&
|
||||||
|
m_IconName == castedDto->iconName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result = WorldObject::BuildSerializationNodes();
|
||||||
|
|
||||||
|
if (m_IsNewState)
|
||||||
|
{
|
||||||
|
result.push_back({ "itemId", std::to_string(m_ItemId) });
|
||||||
|
result.push_back({ "amount", std::to_string(m_Amount) });
|
||||||
|
result.push_back({ "name", m_Name });
|
||||||
|
result.push_back({ "iconName", m_IconName });
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Drop(
|
||||||
|
const uint32_t id,
|
||||||
|
const ValueObjects::Transform transform,
|
||||||
|
const uint32_t itemId,
|
||||||
|
const uint32_t amount,
|
||||||
|
const std::string name,
|
||||||
|
const std::string iconName
|
||||||
|
) :
|
||||||
|
WorldObject(id, transform),
|
||||||
|
m_ItemId(itemId),
|
||||||
|
m_Amount(amount),
|
||||||
|
m_Name(name),
|
||||||
|
m_IconName(iconName)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Drop() = default;
|
||||||
|
virtual ~Drop() = default;
|
||||||
|
private:
|
||||||
|
uint32_t m_ItemId = 0;
|
||||||
|
uint32_t m_Amount = 0;
|
||||||
|
std::string m_Name = "";
|
||||||
|
std::string m_IconName = "";
|
||||||
|
bool m_IsNewState = true;
|
||||||
|
};
|
||||||
|
}
|
235
L2BotCore/Domain/Entities/Hero.h
Normal file
235
L2BotCore/Domain/Entities/Hero.h
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "WorldObject.h"
|
||||||
|
#include "../DTO/Hero.h"
|
||||||
|
#include "../ValueObjects/FullName.h"
|
||||||
|
#include "../ValueObjects/VitalStats.h"
|
||||||
|
#include "../ValueObjects/Phenotype.h"
|
||||||
|
#include "../ValueObjects/ExperienceInfo.h"
|
||||||
|
#include "../ValueObjects/PermanentStats.h"
|
||||||
|
#include "../ValueObjects/VariableStats.h"
|
||||||
|
#include "../ValueObjects/Reputation.h"
|
||||||
|
#include "../ValueObjects/InventoryInfo.h"
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Entities
|
||||||
|
{
|
||||||
|
class Hero : public WorldObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const ValueObjects::FullName& GetFullName() const
|
||||||
|
{
|
||||||
|
return m_FullName;
|
||||||
|
}
|
||||||
|
const ValueObjects::VitalStats& GetVitalStats() const
|
||||||
|
{
|
||||||
|
return m_VitalStats;
|
||||||
|
}
|
||||||
|
const ValueObjects::Phenotype& GetPhenotype() const
|
||||||
|
{
|
||||||
|
return m_Phenotype;
|
||||||
|
}
|
||||||
|
const ValueObjects::ExperienceInfo& GetExperienceInfo() const
|
||||||
|
{
|
||||||
|
return m_ExperienceInfo;
|
||||||
|
}
|
||||||
|
const ValueObjects::PermanentStats& GetPermanentStats() const
|
||||||
|
{
|
||||||
|
return m_PermanentStats;
|
||||||
|
}
|
||||||
|
const ValueObjects::VariableStats& GetVariableStats() const
|
||||||
|
{
|
||||||
|
return m_VariableStats;
|
||||||
|
}
|
||||||
|
const ValueObjects::Reputation& GetReputation() const
|
||||||
|
{
|
||||||
|
return m_Reputation;
|
||||||
|
}
|
||||||
|
const ValueObjects::InventoryInfo& GetInventoryInfo() const
|
||||||
|
{
|
||||||
|
return m_InventoryInfo;
|
||||||
|
}
|
||||||
|
const uint32_t GetTargetId() const
|
||||||
|
{
|
||||||
|
return m_TargetId;
|
||||||
|
}
|
||||||
|
const bool IsStanding() const
|
||||||
|
{
|
||||||
|
return m_IsStanding;
|
||||||
|
}
|
||||||
|
void UpdateFromDTO(const DTO::WorldObject* dto) override
|
||||||
|
{
|
||||||
|
const DTO::Hero* castedDto = static_cast<const DTO::Hero*>(dto);
|
||||||
|
WorldObject::UpdateFromDTO(dto);
|
||||||
|
m_FullName = castedDto->fullName;
|
||||||
|
m_VitalStats = castedDto->vitalStats;
|
||||||
|
m_Phenotype = castedDto->phenotype;
|
||||||
|
m_ExperienceInfo = castedDto->experienceInfo;
|
||||||
|
m_PermanentStats = castedDto->permanentStats;
|
||||||
|
m_VariableStats = castedDto->variableStats;
|
||||||
|
m_Reputation = castedDto->reputation;
|
||||||
|
m_InventoryInfo = castedDto->inventoryInfo;
|
||||||
|
m_TargetId = castedDto->targetId;
|
||||||
|
m_IsStanding = castedDto->isStanding;
|
||||||
|
}
|
||||||
|
void SaveState() override
|
||||||
|
{
|
||||||
|
WorldObject::SaveState();
|
||||||
|
m_PrevState =
|
||||||
|
{
|
||||||
|
m_FullName,
|
||||||
|
m_VitalStats,
|
||||||
|
m_Phenotype,
|
||||||
|
m_ExperienceInfo,
|
||||||
|
m_PermanentStats,
|
||||||
|
m_VariableStats,
|
||||||
|
m_Reputation,
|
||||||
|
m_InventoryInfo,
|
||||||
|
m_TargetId,
|
||||||
|
m_IsStanding,
|
||||||
|
false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const static Hero CreateFromDTO(const DTO::Hero& dto)
|
||||||
|
{
|
||||||
|
return Hero(
|
||||||
|
dto.id,
|
||||||
|
dto.transform,
|
||||||
|
dto.fullName,
|
||||||
|
dto.vitalStats,
|
||||||
|
dto.phenotype,
|
||||||
|
dto.experienceInfo,
|
||||||
|
dto.permanentStats,
|
||||||
|
dto.variableStats,
|
||||||
|
dto.reputation,
|
||||||
|
dto.inventoryInfo,
|
||||||
|
dto.targetId,
|
||||||
|
dto.isStanding
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const bool IsEqual(const DTO::WorldObject* dto) const override
|
||||||
|
{
|
||||||
|
const DTO::Hero* castedDto = static_cast<const DTO::Hero*>(dto);
|
||||||
|
return WorldObject::IsEqual(dto) &&
|
||||||
|
m_FullName.IsEqual(&castedDto->fullName) &&
|
||||||
|
m_VitalStats.IsEqual(&castedDto->vitalStats) &&
|
||||||
|
m_Phenotype.IsEqual(&castedDto->phenotype) &&
|
||||||
|
m_ExperienceInfo.IsEqual(&castedDto->experienceInfo) &&
|
||||||
|
m_PermanentStats.IsEqual(&castedDto->permanentStats) &&
|
||||||
|
m_VariableStats.IsEqual(&castedDto->variableStats) &&
|
||||||
|
m_Reputation.IsEqual(&castedDto->reputation) &&
|
||||||
|
m_InventoryInfo.IsEqual(&castedDto->inventoryInfo) &&
|
||||||
|
m_TargetId == castedDto->targetId &&
|
||||||
|
m_IsStanding == castedDto->isStanding;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result = WorldObject::BuildSerializationNodes();
|
||||||
|
|
||||||
|
if (m_PrevState.isNewState || !m_FullName.IsEqual(&m_PrevState.fullName))
|
||||||
|
{
|
||||||
|
result.push_back({ "fullName", m_FullName.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || !m_VitalStats.IsEqual(&m_PrevState.vitalStats))
|
||||||
|
{
|
||||||
|
result.push_back({ "vitalStats", m_VitalStats.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || !m_Phenotype.IsEqual(&m_PrevState.phenotype))
|
||||||
|
{
|
||||||
|
result.push_back({ "phenotype", m_Phenotype.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || !m_ExperienceInfo.IsEqual(&m_PrevState.experienceInfo))
|
||||||
|
{
|
||||||
|
result.push_back({ "experienceInfo", m_ExperienceInfo.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || !m_PermanentStats.IsEqual(&m_PrevState.permanentStats))
|
||||||
|
{
|
||||||
|
result.push_back({ "permanentStats", m_PermanentStats.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || !m_VariableStats.IsEqual(&m_PrevState.variableStats))
|
||||||
|
{
|
||||||
|
result.push_back({ "variableStats", m_VariableStats.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || !m_Reputation.IsEqual(&m_PrevState.reputation))
|
||||||
|
{
|
||||||
|
result.push_back({ "reputation", m_Reputation.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || !m_InventoryInfo.IsEqual(&m_PrevState.inventoryInfo))
|
||||||
|
{
|
||||||
|
result.push_back({ "inventoryInfo", m_InventoryInfo.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_TargetId != m_PrevState.targetId)
|
||||||
|
{
|
||||||
|
result.push_back({ "targetId", std::to_string(m_TargetId) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_IsStanding != m_PrevState.isStanding)
|
||||||
|
{
|
||||||
|
result.push_back({ "isStanding", std::to_string(m_IsStanding) });
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Hero(
|
||||||
|
const uint32_t id,
|
||||||
|
const ValueObjects::Transform transform,
|
||||||
|
const ValueObjects::FullName fullName,
|
||||||
|
const ValueObjects::VitalStats vitalStats,
|
||||||
|
const ValueObjects::Phenotype phenotype,
|
||||||
|
const ValueObjects::ExperienceInfo experienceInfo,
|
||||||
|
const ValueObjects::PermanentStats permanentStats,
|
||||||
|
const ValueObjects::VariableStats variableStats,
|
||||||
|
const ValueObjects::Reputation reputation,
|
||||||
|
const ValueObjects::InventoryInfo inventoryInfo,
|
||||||
|
const uint32_t targetId,
|
||||||
|
const bool isStanding
|
||||||
|
) :
|
||||||
|
WorldObject(id, transform),
|
||||||
|
m_FullName(fullName),
|
||||||
|
m_VitalStats(vitalStats),
|
||||||
|
m_Phenotype(phenotype),
|
||||||
|
m_ExperienceInfo(experienceInfo),
|
||||||
|
m_PermanentStats(permanentStats),
|
||||||
|
m_VariableStats(variableStats),
|
||||||
|
m_Reputation(reputation),
|
||||||
|
m_InventoryInfo(inventoryInfo),
|
||||||
|
m_TargetId(targetId),
|
||||||
|
m_IsStanding(isStanding)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Hero() = default;
|
||||||
|
virtual ~Hero() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct State
|
||||||
|
{
|
||||||
|
ValueObjects::FullName fullName = ValueObjects::FullName();
|
||||||
|
ValueObjects::VitalStats vitalStats = ValueObjects::VitalStats();
|
||||||
|
ValueObjects::Phenotype phenotype = ValueObjects::Phenotype();
|
||||||
|
ValueObjects::ExperienceInfo experienceInfo = ValueObjects::ExperienceInfo();
|
||||||
|
ValueObjects::PermanentStats permanentStats = ValueObjects::PermanentStats();
|
||||||
|
ValueObjects::VariableStats variableStats = ValueObjects::VariableStats();
|
||||||
|
ValueObjects::Reputation reputation = ValueObjects::Reputation();
|
||||||
|
ValueObjects::InventoryInfo inventoryInfo = ValueObjects::InventoryInfo();
|
||||||
|
uint32_t targetId = 0;
|
||||||
|
bool isStanding = true;
|
||||||
|
|
||||||
|
bool isNewState = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
ValueObjects::FullName m_FullName = ValueObjects::FullName();
|
||||||
|
ValueObjects::VitalStats m_VitalStats = ValueObjects::VitalStats();
|
||||||
|
ValueObjects::Phenotype m_Phenotype = ValueObjects::Phenotype();
|
||||||
|
ValueObjects::ExperienceInfo m_ExperienceInfo = ValueObjects::ExperienceInfo();
|
||||||
|
ValueObjects::PermanentStats m_PermanentStats = ValueObjects::PermanentStats();
|
||||||
|
ValueObjects::VariableStats m_VariableStats = ValueObjects::VariableStats();
|
||||||
|
ValueObjects::Reputation m_Reputation = ValueObjects::Reputation();
|
||||||
|
ValueObjects::InventoryInfo m_InventoryInfo = ValueObjects::InventoryInfo();
|
||||||
|
uint32_t m_TargetId = 0;
|
||||||
|
bool m_IsStanding = true;
|
||||||
|
State m_PrevState = State();
|
||||||
|
};
|
||||||
|
}
|
149
L2BotCore/Domain/Entities/NPC.h
Normal file
149
L2BotCore/Domain/Entities/NPC.h
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "WorldObject.h"
|
||||||
|
#include "../DTO/NPC.h"
|
||||||
|
#include "../ValueObjects/FullName.h"
|
||||||
|
#include "../ValueObjects/VitalStats.h"
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
#include "../Enums/SpoilStateEnum.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Entities
|
||||||
|
{
|
||||||
|
class NPC : public WorldObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const bool IsHostile() const
|
||||||
|
{
|
||||||
|
return m_IsHostile;
|
||||||
|
}
|
||||||
|
const uint32_t GetNpcId() const
|
||||||
|
{
|
||||||
|
return m_NpcId;
|
||||||
|
}
|
||||||
|
const bool IsSpoiled() const
|
||||||
|
{
|
||||||
|
return m_SpoilState == Enums::SpoilStateEnum::spoiled;
|
||||||
|
}
|
||||||
|
const bool CanBeSweeped() const
|
||||||
|
{
|
||||||
|
return !m_VitalStats.IsAlive() && m_SpoilState == Enums::SpoilStateEnum::sweepable;
|
||||||
|
}
|
||||||
|
const ValueObjects::FullName& GetFullName() const
|
||||||
|
{
|
||||||
|
return m_FullName;
|
||||||
|
}
|
||||||
|
const ValueObjects::VitalStats& GetVitalStats() const
|
||||||
|
{
|
||||||
|
return m_VitalStats;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateFromDTO(const DTO::WorldObject* dto) override
|
||||||
|
{
|
||||||
|
const DTO::NPC* castedDto = static_cast<const DTO::NPC*>(dto);
|
||||||
|
WorldObject::UpdateFromDTO(dto);
|
||||||
|
m_IsHostile = castedDto->isHostile;
|
||||||
|
m_NpcId = castedDto->npcId;
|
||||||
|
m_SpoilState = castedDto->spoilState;
|
||||||
|
m_FullName = castedDto->fullName;
|
||||||
|
m_VitalStats = castedDto->vitalStats;
|
||||||
|
}
|
||||||
|
void SaveState() override
|
||||||
|
{
|
||||||
|
WorldObject::SaveState();
|
||||||
|
m_PrevState =
|
||||||
|
{
|
||||||
|
m_FullName,
|
||||||
|
m_SpoilState,
|
||||||
|
m_VitalStats,
|
||||||
|
false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const static NPC CreateFromDTO(const DTO::NPC& dto)
|
||||||
|
{
|
||||||
|
return NPC(
|
||||||
|
dto.id,
|
||||||
|
dto.transform,
|
||||||
|
dto.isHostile,
|
||||||
|
dto.npcId,
|
||||||
|
dto.spoilState,
|
||||||
|
dto.fullName,
|
||||||
|
dto.vitalStats
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const bool IsEqual(const DTO::WorldObject* dto) const override
|
||||||
|
{
|
||||||
|
const DTO::NPC* castedDto = static_cast<const DTO::NPC*>(dto);
|
||||||
|
return WorldObject::IsEqual(dto) &&
|
||||||
|
m_IsHostile == castedDto->isHostile &&
|
||||||
|
m_NpcId == castedDto->npcId &&
|
||||||
|
m_SpoilState == castedDto->spoilState &&
|
||||||
|
m_FullName.IsEqual(&castedDto->fullName) &&
|
||||||
|
m_VitalStats.IsEqual(&castedDto->vitalStats);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result = WorldObject::BuildSerializationNodes();
|
||||||
|
|
||||||
|
if (m_PrevState.isNewState || !m_FullName.IsEqual(&m_PrevState.fullName))
|
||||||
|
{
|
||||||
|
result.push_back({ "fullName", m_FullName.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState)
|
||||||
|
{
|
||||||
|
result.push_back({ "isHostile", std::to_string(m_IsHostile) });
|
||||||
|
result.push_back({ "npcId", std::to_string(m_NpcId) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_SpoilState != m_PrevState.spoilState)
|
||||||
|
{
|
||||||
|
result.push_back({ "spoilState", std::to_string(static_cast<uint32_t>(m_SpoilState)) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || !m_VitalStats.IsEqual(&m_PrevState.vitalStats))
|
||||||
|
{
|
||||||
|
result.push_back({ "vitalStats", m_VitalStats.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
NPC(
|
||||||
|
const uint32_t id,
|
||||||
|
const ValueObjects::Transform transform,
|
||||||
|
const bool isHostile,
|
||||||
|
const uint32_t npcId,
|
||||||
|
const Enums::SpoilStateEnum spoilState,
|
||||||
|
const ValueObjects::FullName fullName,
|
||||||
|
const ValueObjects::VitalStats vitalStats
|
||||||
|
) :
|
||||||
|
WorldObject(id, transform),
|
||||||
|
m_IsHostile(isHostile),
|
||||||
|
m_NpcId(npcId),
|
||||||
|
m_SpoilState(spoilState),
|
||||||
|
m_FullName(fullName),
|
||||||
|
m_VitalStats(vitalStats)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
NPC() = default;
|
||||||
|
virtual ~NPC() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct State
|
||||||
|
{
|
||||||
|
ValueObjects::FullName fullName = ValueObjects::FullName();
|
||||||
|
Enums::SpoilStateEnum spoilState = Enums::SpoilStateEnum::none;
|
||||||
|
ValueObjects::VitalStats vitalStats = ValueObjects::VitalStats();
|
||||||
|
|
||||||
|
bool isNewState = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_IsHostile = false;
|
||||||
|
uint32_t m_NpcId = 0;
|
||||||
|
Enums::SpoilStateEnum m_SpoilState = Enums::SpoilStateEnum::none;
|
||||||
|
ValueObjects::FullName m_FullName = ValueObjects::FullName();
|
||||||
|
ValueObjects::VitalStats m_VitalStats = ValueObjects::VitalStats();
|
||||||
|
State m_PrevState = State();
|
||||||
|
};
|
||||||
|
}
|
101
L2BotCore/Domain/Entities/Player.h
Normal file
101
L2BotCore/Domain/Entities/Player.h
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "WorldObject.h"
|
||||||
|
#include "../DTO/Player.h"
|
||||||
|
#include "../ValueObjects/FullName.h"
|
||||||
|
#include "../ValueObjects/VitalStats.h"
|
||||||
|
#include "../ValueObjects/Phenotype.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Entities
|
||||||
|
{
|
||||||
|
class Player : public WorldObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const ValueObjects::FullName& GetFullName() const
|
||||||
|
{
|
||||||
|
return m_FullName;
|
||||||
|
}
|
||||||
|
const ValueObjects::Phenotype& GetPhenotype() const
|
||||||
|
{
|
||||||
|
return m_Phenotype;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateFromDTO(const DTO::WorldObject* dto) override
|
||||||
|
{
|
||||||
|
const DTO::Player* castedDto = static_cast<const DTO::Player*>(dto);
|
||||||
|
WorldObject::UpdateFromDTO(dto);
|
||||||
|
m_FullName = castedDto->fullName;
|
||||||
|
m_Phenotype = castedDto->phenotype;
|
||||||
|
}
|
||||||
|
void SaveState() override
|
||||||
|
{
|
||||||
|
WorldObject::SaveState();
|
||||||
|
m_PrevState =
|
||||||
|
{
|
||||||
|
m_FullName,
|
||||||
|
m_Phenotype
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const static Player CreateFromDTO(const DTO::Player& dto)
|
||||||
|
{
|
||||||
|
return Player(
|
||||||
|
dto.id,
|
||||||
|
dto.transform,
|
||||||
|
dto.fullName,
|
||||||
|
dto.phenotype
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const bool IsEqual(const DTO::WorldObject* dto) const override
|
||||||
|
{
|
||||||
|
const DTO::Player* castedDto = static_cast<const DTO::Player*>(dto);
|
||||||
|
return WorldObject::IsEqual(dto) &&
|
||||||
|
m_FullName.IsEqual(&castedDto->fullName) &&
|
||||||
|
m_Phenotype.IsEqual(&castedDto->phenotype);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result = WorldObject::BuildSerializationNodes();
|
||||||
|
|
||||||
|
if (m_PrevState.isNewState || !m_FullName.IsEqual(&m_PrevState.fullName))
|
||||||
|
{
|
||||||
|
result.push_back({ "fullName", m_FullName.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || !m_Phenotype.IsEqual(&m_PrevState.phenotype))
|
||||||
|
{
|
||||||
|
result.push_back({ "phenotype", m_Phenotype.BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player(
|
||||||
|
const uint32_t id,
|
||||||
|
const ValueObjects::Transform transform,
|
||||||
|
const ValueObjects::FullName fullName,
|
||||||
|
const ValueObjects::Phenotype phenotype
|
||||||
|
) :
|
||||||
|
WorldObject(id, transform),
|
||||||
|
m_FullName(fullName),
|
||||||
|
m_Phenotype(phenotype)
|
||||||
|
{
|
||||||
|
SaveState();
|
||||||
|
}
|
||||||
|
|
||||||
|
Player() = default;
|
||||||
|
virtual ~Player() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct State
|
||||||
|
{
|
||||||
|
ValueObjects::FullName fullName = ValueObjects::FullName();
|
||||||
|
ValueObjects::Phenotype phenotype = ValueObjects::Phenotype();
|
||||||
|
|
||||||
|
bool isNewState = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
ValueObjects::FullName m_FullName = ValueObjects::FullName();
|
||||||
|
ValueObjects::Phenotype m_Phenotype = ValueObjects::Phenotype();
|
||||||
|
State m_PrevState = State();
|
||||||
|
};
|
||||||
|
}
|
79
L2BotCore/Domain/Entities/WorldObject.h
Normal file
79
L2BotCore/Domain/Entities/WorldObject.h
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "../ValueObjects/Transform.h"
|
||||||
|
#include "../DTO/WorldObject.h"
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Entities
|
||||||
|
{
|
||||||
|
class WorldObject : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint32_t GetId() const
|
||||||
|
{
|
||||||
|
return m_Id;
|
||||||
|
}
|
||||||
|
const ValueObjects::Transform& GetTransform() const
|
||||||
|
{
|
||||||
|
return m_Transform;
|
||||||
|
}
|
||||||
|
virtual void UpdateFromDTO(const DTO::WorldObject* dto)
|
||||||
|
{
|
||||||
|
SaveState();
|
||||||
|
|
||||||
|
m_Id = dto->id;
|
||||||
|
m_Transform = dto->transform;
|
||||||
|
}
|
||||||
|
virtual void SaveState()
|
||||||
|
{
|
||||||
|
m_PrevState = { m_Transform, false };
|
||||||
|
}
|
||||||
|
virtual const bool IsEqual(const DTO::WorldObject* dto) const
|
||||||
|
{
|
||||||
|
return m_Id == dto->id && m_Transform.IsEqual(&dto->transform);
|
||||||
|
}
|
||||||
|
const float_t GetSqrDistance(const WorldObject& other) const
|
||||||
|
{
|
||||||
|
return m_Transform.GetSqrDistance(other.m_Transform);
|
||||||
|
}
|
||||||
|
const float_t GetHorizontalSqrDistance(const WorldObject& other) const
|
||||||
|
{
|
||||||
|
return m_Transform.GetHorizontalSqrDistance(other.m_Transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result;
|
||||||
|
|
||||||
|
result.push_back({ "id", std::to_string(GetId()) });
|
||||||
|
if (m_PrevState.isNewState || !GetTransform().IsEqual(&m_PrevState.transform))
|
||||||
|
{
|
||||||
|
result.push_back({ "transform", GetTransform().BuildSerializationNodes() });
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldObject(const uint32_t id, const ValueObjects::Transform transform) :
|
||||||
|
m_Id(id), m_Transform(transform)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WorldObject() = default;
|
||||||
|
virtual ~WorldObject() = default;
|
||||||
|
private:
|
||||||
|
private:
|
||||||
|
struct State
|
||||||
|
{
|
||||||
|
ValueObjects::Transform transform = ValueObjects::Transform();
|
||||||
|
|
||||||
|
bool isNewState = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t m_Id = 0;
|
||||||
|
ValueObjects::Transform m_Transform = ValueObjects::Transform();
|
||||||
|
State m_PrevState = State();
|
||||||
|
};
|
||||||
|
}
|
99
L2BotCore/Domain/Enums/ClassEnum.h
Normal file
99
L2BotCore/Domain/Enums/ClassEnum.h
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Enums
|
||||||
|
{
|
||||||
|
enum class ClassEnum : uint8_t
|
||||||
|
{
|
||||||
|
none = 255,
|
||||||
|
humanFighter = 0,
|
||||||
|
warrior,
|
||||||
|
gladiator,
|
||||||
|
warlord,
|
||||||
|
humanKnight,
|
||||||
|
paladin,
|
||||||
|
darkAvenger,
|
||||||
|
rogue,
|
||||||
|
treasureHunter,
|
||||||
|
hawkeye,
|
||||||
|
humanMystic,
|
||||||
|
humanWizard,
|
||||||
|
sorceror,
|
||||||
|
necromancer,
|
||||||
|
warlock,
|
||||||
|
cleric,
|
||||||
|
bishop,
|
||||||
|
prophet,
|
||||||
|
elvenFighter,
|
||||||
|
elvenKnight,
|
||||||
|
templeKnight,
|
||||||
|
swordsinger,
|
||||||
|
elvenScout,
|
||||||
|
plainsWalker,
|
||||||
|
silverRanger,
|
||||||
|
elvenMystic,
|
||||||
|
elvenWizard,
|
||||||
|
spellsinger,
|
||||||
|
elementalSummoner,
|
||||||
|
elvenOracle,
|
||||||
|
elvenElder,
|
||||||
|
darkElvenFighter,
|
||||||
|
palusKnight,
|
||||||
|
shillienKnight,
|
||||||
|
bladedancer,
|
||||||
|
assassin,
|
||||||
|
abyssWalker,
|
||||||
|
phantomRanger,
|
||||||
|
darkElvenMystic,
|
||||||
|
darkElvenWizard,
|
||||||
|
spellhowler,
|
||||||
|
phantomSummoner,
|
||||||
|
shillienOracle,
|
||||||
|
shillienElder,
|
||||||
|
orcFighter,
|
||||||
|
orcRaider,
|
||||||
|
destroyer,
|
||||||
|
orcMonk,
|
||||||
|
tyrant,
|
||||||
|
orcMystic,
|
||||||
|
orcShaman,
|
||||||
|
overlord,
|
||||||
|
warcryer,
|
||||||
|
dwarvenFighter,
|
||||||
|
dwarvenScavenger,
|
||||||
|
bountyHunter,
|
||||||
|
dwarvenArtisan,
|
||||||
|
warsmith,
|
||||||
|
duelist = 88,
|
||||||
|
dreadnought,
|
||||||
|
phoenixKnight,
|
||||||
|
hellKnight,
|
||||||
|
sagittarius,
|
||||||
|
adventurer,
|
||||||
|
archmage,
|
||||||
|
soultaker,
|
||||||
|
arcanaLord,
|
||||||
|
cardinal,
|
||||||
|
hierophant,
|
||||||
|
evaTemplar,
|
||||||
|
swordMuse,
|
||||||
|
windRider,
|
||||||
|
moonlightSentinel,
|
||||||
|
mysticMuse,
|
||||||
|
elementalMaster,
|
||||||
|
evaSaint,
|
||||||
|
shillienTemplar,
|
||||||
|
spectralDancer,
|
||||||
|
ghostHunter,
|
||||||
|
ghostSentinel,
|
||||||
|
stormScreamer,
|
||||||
|
spectralMaster,
|
||||||
|
shillienSaint,
|
||||||
|
titan,
|
||||||
|
grandKhauatari,
|
||||||
|
dominator,
|
||||||
|
doomcryer,
|
||||||
|
fortuneSeeker,
|
||||||
|
maestro
|
||||||
|
};
|
||||||
|
}
|
12
L2BotCore/Domain/Enums/ObjectStateEnum.h
Normal file
12
L2BotCore/Domain/Enums/ObjectStateEnum.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Enums
|
||||||
|
{
|
||||||
|
enum class ObjectStateEnum
|
||||||
|
{
|
||||||
|
none,
|
||||||
|
created,
|
||||||
|
updated,
|
||||||
|
deleted
|
||||||
|
};
|
||||||
|
}
|
15
L2BotCore/Domain/Enums/RaceEnum.h
Normal file
15
L2BotCore/Domain/Enums/RaceEnum.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Enums
|
||||||
|
{
|
||||||
|
enum class RaceEnum : uint8_t
|
||||||
|
{
|
||||||
|
none = 255,
|
||||||
|
darkElf = 2,
|
||||||
|
dwarf = 4,
|
||||||
|
elf = 1,
|
||||||
|
human = 0,
|
||||||
|
orc = 3
|
||||||
|
};
|
||||||
|
}
|
13
L2BotCore/Domain/Enums/SpoilStateEnum.h
Normal file
13
L2BotCore/Domain/Enums/SpoilStateEnum.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Enums
|
||||||
|
{
|
||||||
|
enum class SpoilStateEnum : uint32_t
|
||||||
|
{
|
||||||
|
none = 0,
|
||||||
|
spoiled,
|
||||||
|
sweepable
|
||||||
|
};
|
||||||
|
};
|
14
L2BotCore/Domain/Repositories/DropRepositoryInterface.h
Normal file
14
L2BotCore/Domain/Repositories/DropRepositoryInterface.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectRepositoryInterface.h"
|
||||||
|
#include "../DTO/Drop.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Repositories
|
||||||
|
{
|
||||||
|
class DropRepositoryInterface : public ObjectRepositoryInterface<DTO::Drop>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const std::map<uint32_t, DTO::Drop> GetObjects() override = 0;
|
||||||
|
};
|
||||||
|
}
|
14
L2BotCore/Domain/Repositories/HeroRepositoryInterface.h
Normal file
14
L2BotCore/Domain/Repositories/HeroRepositoryInterface.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectRepositoryInterface.h"
|
||||||
|
#include "../DTO/Hero.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Repositories
|
||||||
|
{
|
||||||
|
class HeroRepositoryInterface : public ObjectRepositoryInterface<DTO::Hero>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const std::map<uint32_t, DTO::Hero> GetObjects() override = 0;
|
||||||
|
};
|
||||||
|
}
|
14
L2BotCore/Domain/Repositories/ItemRepositoryInterface.h
Normal file
14
L2BotCore/Domain/Repositories/ItemRepositoryInterface.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectRepositoryInterface.h"
|
||||||
|
#include "../DTO/BaseItem.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Repositories
|
||||||
|
{
|
||||||
|
class ItemRepositoryInterface : public ObjectRepositoryInterface<DTO::BaseItem>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const std::map<uint32_t, DTO::BaseItem> GetObjects() override = 0;
|
||||||
|
};
|
||||||
|
}
|
14
L2BotCore/Domain/Repositories/NPCRepositoryInterface.h
Normal file
14
L2BotCore/Domain/Repositories/NPCRepositoryInterface.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectRepositoryInterface.h"
|
||||||
|
#include "../DTO/NPC.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Repositories
|
||||||
|
{
|
||||||
|
class NPCRepositoryInterface : public ObjectRepositoryInterface<DTO::NPC>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const std::map<uint32_t, DTO::NPC> GetObjects() override = 0;
|
||||||
|
};
|
||||||
|
}
|
13
L2BotCore/Domain/Repositories/ObjectRepositoryInterface.h
Normal file
13
L2BotCore/Domain/Repositories/ObjectRepositoryInterface.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Repositories
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
class ObjectRepositoryInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const std::map<uint32_t, T> GetObjects() = 0;
|
||||||
|
};
|
||||||
|
}
|
14
L2BotCore/Domain/Repositories/PlayerRepositoryInterface.h
Normal file
14
L2BotCore/Domain/Repositories/PlayerRepositoryInterface.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectRepositoryInterface.h"
|
||||||
|
#include "../DTO/Player.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Repositories
|
||||||
|
{
|
||||||
|
class PlayerRepositoryInterface : public ObjectRepositoryInterface<DTO::Player>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const std::map<uint32_t, DTO::Player> GetObjects() override = 0;
|
||||||
|
};
|
||||||
|
}
|
14
L2BotCore/Domain/Repositories/SkillRepositoryInterface.h
Normal file
14
L2BotCore/Domain/Repositories/SkillRepositoryInterface.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectRepositoryInterface.h"
|
||||||
|
#include "../DTO/Skill.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Repositories
|
||||||
|
{
|
||||||
|
class SkillRepositoryInterface : public ObjectRepositoryInterface<DTO::Skill>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const std::map<uint32_t, DTO::Skill> GetObjects() override = 0;
|
||||||
|
};
|
||||||
|
}
|
26
L2BotCore/Domain/Serializers/Node.h
Normal file
26
L2BotCore/Domain/Serializers/Node.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Serializers
|
||||||
|
{
|
||||||
|
struct Node
|
||||||
|
{
|
||||||
|
const std::string name = "";
|
||||||
|
const std::string value = "";
|
||||||
|
const std::vector<Node> children;
|
||||||
|
const bool isArray = false;
|
||||||
|
const bool isContainer = false;
|
||||||
|
|
||||||
|
Node() = delete;
|
||||||
|
Node(const std::string name, const std::string value) :
|
||||||
|
name(name), value(value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
Node(const std::string name, const std::vector<Node> children, const bool isArray = false) :
|
||||||
|
name(name), children(children), isArray(isArray), isContainer(true)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
12
L2BotCore/Domain/Serializers/Serializable.h
Normal file
12
L2BotCore/Domain/Serializers/Serializable.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include "Node.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Serializers
|
||||||
|
{
|
||||||
|
class Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const std::vector<Node> BuildSerializationNodes() const = 0;
|
||||||
|
};
|
||||||
|
}
|
57
L2BotCore/Domain/Serializers/SerializableStateContainer.h
Normal file
57
L2BotCore/Domain/Serializers/SerializableStateContainer.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include "../DTO/ObjectState.h"
|
||||||
|
#include "Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Serializers
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
class SerializableStateContainer : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result;
|
||||||
|
|
||||||
|
for (const auto& kvp : m_Objects)
|
||||||
|
{
|
||||||
|
std::string operationName = "";
|
||||||
|
switch (kvp.state)
|
||||||
|
{
|
||||||
|
case Enums::ObjectStateEnum::created:
|
||||||
|
operationName = "created";
|
||||||
|
break;
|
||||||
|
case Enums::ObjectStateEnum::updated:
|
||||||
|
operationName = "updated";
|
||||||
|
break;
|
||||||
|
case Enums::ObjectStateEnum::deleted:
|
||||||
|
operationName = "deleted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operationName != "")
|
||||||
|
{
|
||||||
|
result.push_back(
|
||||||
|
{
|
||||||
|
m_ContainerName,
|
||||||
|
std::vector<Serializers::Node>{ { operationName, kvp.object.BuildSerializationNodes() } }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
SerializableStateContainer(const std::vector<DTO::ObjectState<T>> objects, const std::string containerName) :
|
||||||
|
m_Objects(objects), m_ContainerName(containerName)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
SerializableStateContainer() = delete;
|
||||||
|
virtual ~SerializableStateContainer() = default;
|
||||||
|
private:
|
||||||
|
const std::vector<DTO::ObjectState<T>> m_Objects;
|
||||||
|
const std::string m_ContainerName;
|
||||||
|
};
|
||||||
|
}
|
57
L2BotCore/Domain/Serializers/SerializableStateContainerPtr.h
Normal file
57
L2BotCore/Domain/Serializers/SerializableStateContainerPtr.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <vector>
|
||||||
|
#include "../DTO/ObjectState.h"
|
||||||
|
#include "Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Serializers
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
class SerializableStateContainerPtr : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result;
|
||||||
|
|
||||||
|
for (const auto& kvp : m_Objects)
|
||||||
|
{
|
||||||
|
std::string operationName = "";
|
||||||
|
switch (kvp.state)
|
||||||
|
{
|
||||||
|
case Enums::ObjectStateEnum::created:
|
||||||
|
operationName = "created";
|
||||||
|
break;
|
||||||
|
case Enums::ObjectStateEnum::updated:
|
||||||
|
operationName = "updated";
|
||||||
|
break;
|
||||||
|
case Enums::ObjectStateEnum::deleted:
|
||||||
|
operationName = "deleted";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (operationName != "")
|
||||||
|
{
|
||||||
|
result.push_back(
|
||||||
|
{
|
||||||
|
m_ContainerName,
|
||||||
|
std::vector<Serializers::Node>{ { operationName, kvp.object->BuildSerializationNodes() } }
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
SerializableStateContainerPtr(const std::vector<DTO::ObjectState<T>> objects, const std::string containerName) :
|
||||||
|
m_Objects(objects), m_ContainerName(containerName)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
SerializableStateContainerPtr() = delete;
|
||||||
|
virtual ~SerializableStateContainerPtr() = default;
|
||||||
|
private:
|
||||||
|
const std::vector<DTO::ObjectState<T>> m_Objects;
|
||||||
|
const std::string m_ContainerName;
|
||||||
|
};
|
||||||
|
}
|
13
L2BotCore/Domain/Serializers/SerializerInterface.h
Normal file
13
L2BotCore/Domain/Serializers/SerializerInterface.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Serializers
|
||||||
|
{
|
||||||
|
class SerializerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const std::string Serialize(std::vector<Node> nodes, const bool isArray = false) const = 0;
|
||||||
|
};
|
||||||
|
}
|
20
L2BotCore/Domain/Services/DropService.h
Normal file
20
L2BotCore/Domain/Services/DropService.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectService.h"
|
||||||
|
#include "../DTO/Drop.h"
|
||||||
|
#include "../Entities/Drop.h"
|
||||||
|
#include "../Repositories/DropRepositoryInterface.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Services
|
||||||
|
{
|
||||||
|
class DropService : public ObjectService<Entities::Drop, DTO::Drop>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DropService(Repositories::DropRepositoryInterface& repository) : ObjectService(repository)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
virtual ~DropService() override = default;
|
||||||
|
};
|
||||||
|
}
|
31
L2BotCore/Domain/Services/HeroService.h
Normal file
31
L2BotCore/Domain/Services/HeroService.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectService.h"
|
||||||
|
#include "../DTO/Hero.h"
|
||||||
|
#include "../Entities/Hero.h"
|
||||||
|
#include "../Repositories/HeroRepositoryInterface.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Services
|
||||||
|
{
|
||||||
|
class HeroService : public ObjectService<Entities::Hero, DTO::Hero>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const DTO::ObjectState<Entities::Hero> GetHero()
|
||||||
|
{
|
||||||
|
const auto map = GetObjects();
|
||||||
|
if (map.size() == 0)
|
||||||
|
{
|
||||||
|
return DTO::ObjectState <Entities::Hero>{};
|
||||||
|
}
|
||||||
|
|
||||||
|
return map[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
HeroService(Repositories::HeroRepositoryInterface& repository) : ObjectService(repository)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
virtual ~HeroService() override = default;
|
||||||
|
};
|
||||||
|
}
|
20
L2BotCore/Domain/Services/ItemService.h
Normal file
20
L2BotCore/Domain/Services/ItemService.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectService.h"
|
||||||
|
#include "../DTO/BaseItem.h"
|
||||||
|
#include "../ValueObjects/BaseItem.h"
|
||||||
|
#include "../Repositories/ItemRepositoryInterface.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Services
|
||||||
|
{
|
||||||
|
class ItemService : public ObjectService<ValueObjects::BaseItem, DTO::BaseItem>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ItemService(Repositories::ItemRepositoryInterface& repository) : ObjectService(repository)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
virtual ~ItemService() override = default;
|
||||||
|
};
|
||||||
|
}
|
20
L2BotCore/Domain/Services/NPCService.h
Normal file
20
L2BotCore/Domain/Services/NPCService.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectService.h"
|
||||||
|
#include "../DTO/NPC.h"
|
||||||
|
#include "../Entities/NPC.h"
|
||||||
|
#include "../Repositories/NPCRepositoryInterface.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Services
|
||||||
|
{
|
||||||
|
class NPCService : public ObjectService<Entities::NPC, DTO::NPC>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NPCService(Repositories::NPCRepositoryInterface& repository) : ObjectService(repository)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
virtual ~NPCService() override = default;
|
||||||
|
};
|
||||||
|
}
|
100
L2BotCore/Domain/Services/ObjectService.h
Normal file
100
L2BotCore/Domain/Services/ObjectService.h
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include <math.h>
|
||||||
|
#include "../DTO/ObjectState.h"
|
||||||
|
#include "../Entities/Hero.h"
|
||||||
|
#include "../Repositories/ObjectRepositoryInterface.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Services
|
||||||
|
{
|
||||||
|
template <typename T, typename U>
|
||||||
|
class ObjectService
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObjectService(Repositories::ObjectRepositoryInterface<U>& repository) : m_Repository(repository)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
ObjectService() = delete;
|
||||||
|
virtual ~ObjectService() = default;
|
||||||
|
|
||||||
|
virtual const std::vector<DTO::ObjectState<T>> GetObjects()
|
||||||
|
{
|
||||||
|
UpdateObjectsFromRepository();
|
||||||
|
|
||||||
|
std::vector<DTO::ObjectState<T>> objects;
|
||||||
|
|
||||||
|
for (const auto& kvp : m_ObjectStates) {
|
||||||
|
objects.push_back(kvp.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Invalidate()
|
||||||
|
{
|
||||||
|
m_ObjectStates.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void UpdateObjectsFromRepository()
|
||||||
|
{
|
||||||
|
auto objects = m_Repository.GetObjects();
|
||||||
|
|
||||||
|
RemoveOutdatedStates();
|
||||||
|
|
||||||
|
|
||||||
|
for (const auto& kvp : objects)
|
||||||
|
{
|
||||||
|
const auto& dto = kvp.second;
|
||||||
|
if (m_ObjectStates.contains(kvp.first))
|
||||||
|
{
|
||||||
|
if (!m_ObjectStates[kvp.first].object.IsEqual(&dto)) {
|
||||||
|
m_ObjectStates[kvp.first].object.UpdateFromDTO(&dto);
|
||||||
|
m_ObjectStates[kvp.first].state = Enums::ObjectStateEnum::updated;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ObjectStates[kvp.first].state = Enums::ObjectStateEnum::none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ObjectStates.emplace(kvp.first, DTO::ObjectState<T>{ T::CreateFromDTO(dto), Enums::ObjectStateEnum::created });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& kvp : m_ObjectStates)
|
||||||
|
{
|
||||||
|
if (!objects.contains(kvp.second.object.GetId()))
|
||||||
|
{
|
||||||
|
m_ObjectStates[kvp.first].object.SaveState();
|
||||||
|
kvp.second.state = Enums::ObjectStateEnum::deleted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void RemoveOutdatedStates()
|
||||||
|
{
|
||||||
|
auto it = m_ObjectStates.begin();
|
||||||
|
while (it != m_ObjectStates.end())
|
||||||
|
{
|
||||||
|
if (it->second.state == Enums::ObjectStateEnum::deleted)
|
||||||
|
{
|
||||||
|
m_ObjectStates.erase(it++);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Repositories::ObjectRepositoryInterface<U>& m_Repository;
|
||||||
|
std::map<uint32_t, DTO::ObjectState<T>> m_ObjectStates;
|
||||||
|
};
|
||||||
|
}
|
99
L2BotCore/Domain/Services/ObjectServicePtr.h
Normal file
99
L2BotCore/Domain/Services/ObjectServicePtr.h
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
#include <math.h>
|
||||||
|
#include "../DTO/ObjectState.h"
|
||||||
|
#include "../Entities/Hero.h"
|
||||||
|
#include "../Repositories/ObjectRepositoryInterface.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Services
|
||||||
|
{
|
||||||
|
template <typename T, typename U>
|
||||||
|
class ObjectServicePtr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ObjectServicePtr(Repositories::ObjectRepositoryInterface<U>& repository) : m_Repository(repository)
|
||||||
|
{
|
||||||
|
|
||||||
|
}ObjectServicePtr() = delete;
|
||||||
|
virtual ~ObjectServicePtr() = default;
|
||||||
|
|
||||||
|
virtual const std::vector<DTO::ObjectState<T>> GetObjects()
|
||||||
|
{
|
||||||
|
UpdateObjectsFromRepository();
|
||||||
|
|
||||||
|
std::vector<DTO::ObjectState<T>> objects;
|
||||||
|
|
||||||
|
for (const auto& kvp : m_ObjectStates) {
|
||||||
|
objects.push_back(kvp.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Invalidate()
|
||||||
|
{
|
||||||
|
m_ObjectStates.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void UpdateObjectsFromRepository()
|
||||||
|
{
|
||||||
|
auto objects = m_Repository.GetObjects();
|
||||||
|
|
||||||
|
RemoveOutdatedStates();
|
||||||
|
|
||||||
|
|
||||||
|
for (const auto& kvp : objects)
|
||||||
|
{
|
||||||
|
const auto& dto = kvp.second;
|
||||||
|
if (m_ObjectStates.contains(kvp.first))
|
||||||
|
{
|
||||||
|
if (!m_ObjectStates[kvp.first].object->IsEqual(dto.get())) {
|
||||||
|
m_ObjectStates[kvp.first].object->UpdateFromDTO(dto.get());
|
||||||
|
m_ObjectStates[kvp.first].state = Enums::ObjectStateEnum::updated;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_ObjectStates[kvp.first].state = Enums::ObjectStateEnum::none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//m_ObjectStates.emplace(kvp.first, DTO::ObjectState<T>{ T::CreateFromDTO(dto), Enums::ObjectStateEnum::created });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& kvp : m_ObjectStates)
|
||||||
|
{
|
||||||
|
if (!objects.contains(kvp.second.object->GetId()))
|
||||||
|
{
|
||||||
|
m_ObjectStates[kvp.first].object->SaveState();
|
||||||
|
kvp.second.state = Enums::ObjectStateEnum::deleted;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void RemoveOutdatedStates()
|
||||||
|
{
|
||||||
|
auto it = m_ObjectStates.begin();
|
||||||
|
while (it != m_ObjectStates.end())
|
||||||
|
{
|
||||||
|
if (it->second.state == Enums::ObjectStateEnum::deleted)
|
||||||
|
{
|
||||||
|
m_ObjectStates.erase(it++);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Repositories::ObjectRepositoryInterface<U>& m_Repository;
|
||||||
|
std::map<uint32_t, DTO::ObjectState<T>> m_ObjectStates;
|
||||||
|
};
|
||||||
|
}
|
20
L2BotCore/Domain/Services/PlayerService.h
Normal file
20
L2BotCore/Domain/Services/PlayerService.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectService.h"
|
||||||
|
#include "../DTO/Player.h"
|
||||||
|
#include "../Entities/Player.h"
|
||||||
|
#include "../Repositories/PlayerRepositoryInterface.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Services
|
||||||
|
{
|
||||||
|
class PlayerService : public ObjectService<Entities::Player, DTO::Player>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlayerService(Repositories::PlayerRepositoryInterface& repository) : ObjectService(repository)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
virtual ~PlayerService() override = default;
|
||||||
|
};
|
||||||
|
}
|
20
L2BotCore/Domain/Services/SkillService.h
Normal file
20
L2BotCore/Domain/Services/SkillService.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <map>
|
||||||
|
#include "ObjectService.h"
|
||||||
|
#include "../DTO/Skill.h"
|
||||||
|
#include "../ValueObjects/Skill.h"
|
||||||
|
#include "../Repositories/SkillRepositoryInterface.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Services
|
||||||
|
{
|
||||||
|
class SkillService : public ObjectService<ValueObjects::Skill, DTO::Skill>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SkillService(Repositories::SkillRepositoryInterface& repository) : ObjectService(repository)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
virtual ~SkillService() override = default;
|
||||||
|
};
|
||||||
|
}
|
14
L2BotCore/Domain/Transports/TransportInterface.h
Normal file
14
L2BotCore/Domain/Transports/TransportInterface.h
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::Transports
|
||||||
|
{
|
||||||
|
class TransportInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const bool Connect() = 0;
|
||||||
|
virtual const bool IsConnected() const = 0;
|
||||||
|
virtual const void Send(std::string data) = 0;
|
||||||
|
virtual const std::string Receive() = 0;
|
||||||
|
};
|
||||||
|
}
|
158
L2BotCore/Domain/ValueObjects/BaseItem.h
Normal file
158
L2BotCore/Domain/ValueObjects/BaseItem.h
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "../DTO/BaseItem.h"
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
#include "../Serializers/Node.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class BaseItem : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint32_t GetId() const
|
||||||
|
{
|
||||||
|
return m_ItemId;
|
||||||
|
}
|
||||||
|
void UpdateFromDTO(const DTO::BaseItem* dto)
|
||||||
|
{
|
||||||
|
SaveState();
|
||||||
|
|
||||||
|
m_ItemId = dto->itemId;
|
||||||
|
m_Amount = dto->amount;
|
||||||
|
m_IsEquipped = dto->isEquipped;
|
||||||
|
m_EnchantLevel = dto->enchantLevel;
|
||||||
|
m_Mana = dto->mana;
|
||||||
|
m_Name = dto->name;
|
||||||
|
m_IconName = dto->iconName;
|
||||||
|
m_Description = dto->description;
|
||||||
|
m_Weight = dto->weight;
|
||||||
|
}
|
||||||
|
void SaveState()
|
||||||
|
{
|
||||||
|
m_PrevState =
|
||||||
|
{
|
||||||
|
m_Amount,
|
||||||
|
m_IsEquipped,
|
||||||
|
m_EnchantLevel,
|
||||||
|
m_Mana,
|
||||||
|
m_Weight,
|
||||||
|
false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const static BaseItem CreateFromDTO(const DTO::BaseItem& dto)
|
||||||
|
{
|
||||||
|
return BaseItem(
|
||||||
|
dto.itemId,
|
||||||
|
dto.amount,
|
||||||
|
dto.isEquipped,
|
||||||
|
dto.enchantLevel,
|
||||||
|
dto.mana,
|
||||||
|
dto.name,
|
||||||
|
dto.iconName,
|
||||||
|
dto.description,
|
||||||
|
dto.weight
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const bool IsEqual(const DTO::BaseItem* dto) const
|
||||||
|
{
|
||||||
|
return m_ItemId == dto->itemId &&
|
||||||
|
m_Amount == dto->amount &&
|
||||||
|
m_IsEquipped == dto->isEquipped &&
|
||||||
|
m_EnchantLevel == dto->enchantLevel &&
|
||||||
|
m_Mana == dto->mana &&
|
||||||
|
m_Name == dto->name &&
|
||||||
|
m_IconName == dto->iconName &&
|
||||||
|
m_Description == dto->description &&
|
||||||
|
m_Weight == dto->weight;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result;
|
||||||
|
|
||||||
|
result.push_back({ "itemId", std::to_string(m_ItemId) });
|
||||||
|
|
||||||
|
if (m_PrevState.isNewState)
|
||||||
|
{
|
||||||
|
result.push_back({ "name", m_Name });
|
||||||
|
result.push_back({ "iconName", m_IconName });
|
||||||
|
result.push_back({ "description", m_Description });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_PrevState.isNewState || m_Amount != m_PrevState.amount)
|
||||||
|
{
|
||||||
|
result.push_back({ "amount", std::to_string(m_Amount) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_IsEquipped != m_PrevState.isEquipped)
|
||||||
|
{
|
||||||
|
result.push_back({ "isEquipped", std::to_string(m_IsEquipped) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_EnchantLevel != m_PrevState.enchantLevel)
|
||||||
|
{
|
||||||
|
result.push_back({ "enchantLevel", std::to_string(m_EnchantLevel) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_Mana != m_PrevState.mana)
|
||||||
|
{
|
||||||
|
result.push_back({ "mana", std::to_string(m_Mana) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_Weight != m_PrevState.weight)
|
||||||
|
{
|
||||||
|
result.push_back({ "weight", std::to_string(m_Weight) });
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseItem(
|
||||||
|
const uint32_t itemId,
|
||||||
|
const uint32_t amount,
|
||||||
|
const bool isEquipped,
|
||||||
|
const uint16_t enchantLevel,
|
||||||
|
const int32_t mana,
|
||||||
|
const std::string name,
|
||||||
|
const std::string iconName,
|
||||||
|
const std::string description,
|
||||||
|
const uint16_t weight
|
||||||
|
) :
|
||||||
|
m_ItemId(itemId),
|
||||||
|
m_Amount(amount),
|
||||||
|
m_IsEquipped(isEquipped),
|
||||||
|
m_EnchantLevel(enchantLevel),
|
||||||
|
m_Mana(mana),
|
||||||
|
m_Name(name),
|
||||||
|
m_IconName(iconName),
|
||||||
|
m_Description(description),
|
||||||
|
m_Weight(weight)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseItem() = default;
|
||||||
|
virtual ~BaseItem() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct State
|
||||||
|
{
|
||||||
|
uint32_t amount = 0;
|
||||||
|
bool isEquipped = 0;
|
||||||
|
uint16_t enchantLevel = 0;
|
||||||
|
int32_t mana = -1;
|
||||||
|
uint16_t weight = 0;
|
||||||
|
|
||||||
|
bool isNewState = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t m_ItemId = 0;
|
||||||
|
uint32_t m_Amount = 0;
|
||||||
|
bool m_IsEquipped = 0;
|
||||||
|
uint16_t m_EnchantLevel = 0;
|
||||||
|
int32_t m_Mana = -1;
|
||||||
|
std::string m_Name = "";
|
||||||
|
std::string m_IconName = "";
|
||||||
|
std::string m_Description = "";
|
||||||
|
uint16_t m_Weight = 0;
|
||||||
|
State m_PrevState = State();
|
||||||
|
};
|
||||||
|
}
|
55
L2BotCore/Domain/ValueObjects/ExperienceInfo.h
Normal file
55
L2BotCore/Domain/ValueObjects/ExperienceInfo.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class ExperienceInfo : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint8_t GetLevel() const
|
||||||
|
{
|
||||||
|
return m_Level;
|
||||||
|
}
|
||||||
|
const uint8_t GetExp() const
|
||||||
|
{
|
||||||
|
return m_Exp;
|
||||||
|
}
|
||||||
|
const uint8_t GetSp() const
|
||||||
|
{
|
||||||
|
return m_Sp;
|
||||||
|
}
|
||||||
|
const bool IsEqual(const ExperienceInfo* other) const
|
||||||
|
{
|
||||||
|
return m_Level == other->m_Level && m_Exp == other->m_Exp && m_Sp == other->m_Sp;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
return std::vector<Serializers::Node>
|
||||||
|
{
|
||||||
|
{ "level", std::to_string(m_Level) },
|
||||||
|
{ "exp", std::to_string(m_Exp) },
|
||||||
|
{ "sp", std::to_string(m_Sp) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
ExperienceInfo(
|
||||||
|
const uint8_t level,
|
||||||
|
const uint32_t exp,
|
||||||
|
const uint32_t sp
|
||||||
|
) :
|
||||||
|
m_Level(level),
|
||||||
|
m_Exp(exp),
|
||||||
|
m_Sp(sp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ExperienceInfo() = default;
|
||||||
|
virtual ~ExperienceInfo() = default;
|
||||||
|
private:
|
||||||
|
uint8_t m_Level = 0;
|
||||||
|
uint32_t m_Exp = 0;
|
||||||
|
uint32_t m_Sp = 0;
|
||||||
|
};
|
||||||
|
}
|
47
L2BotCore/Domain/ValueObjects/FullName.h
Normal file
47
L2BotCore/Domain/ValueObjects/FullName.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class FullName : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const std::string& GetNickname() const
|
||||||
|
{
|
||||||
|
return m_Nickname;
|
||||||
|
}
|
||||||
|
const std::string& GetTitle() const
|
||||||
|
{
|
||||||
|
return m_Title;
|
||||||
|
}
|
||||||
|
const bool IsEqual(const FullName* other) const
|
||||||
|
{
|
||||||
|
return m_Nickname == other->m_Nickname && m_Title == other->m_Title;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
return std::vector<Serializers::Node>
|
||||||
|
{
|
||||||
|
{ "nickname", m_Nickname },
|
||||||
|
{ "title", m_Title }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
FullName(
|
||||||
|
const std::string nickname,
|
||||||
|
const std::string title
|
||||||
|
) :
|
||||||
|
m_Nickname(nickname),
|
||||||
|
m_Title(title)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FullName() = default;
|
||||||
|
virtual ~FullName() = default;
|
||||||
|
private:
|
||||||
|
std::string m_Nickname = "";
|
||||||
|
std::string m_Title = "";
|
||||||
|
};
|
||||||
|
}
|
61
L2BotCore/Domain/ValueObjects/InventoryInfo.h
Normal file
61
L2BotCore/Domain/ValueObjects/InventoryInfo.h
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class InventoryInfo : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const bool IsOverloaded() const
|
||||||
|
{
|
||||||
|
return m_Weight >= m_MaxWeight;
|
||||||
|
}
|
||||||
|
const uint16_t GetMaxWeight() const
|
||||||
|
{
|
||||||
|
return m_MaxWeight;
|
||||||
|
}
|
||||||
|
const uint16_t GetWeight() const
|
||||||
|
{
|
||||||
|
return m_Weight;
|
||||||
|
}
|
||||||
|
const uint16_t GetSlots() const
|
||||||
|
{
|
||||||
|
return m_Slots;
|
||||||
|
}
|
||||||
|
const bool IsEqual(const InventoryInfo* other) const
|
||||||
|
{
|
||||||
|
return m_MaxWeight == other->m_MaxWeight &&
|
||||||
|
m_Weight == other->m_Weight &&
|
||||||
|
m_Slots == other->m_Slots;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
return std::vector<Serializers::Node>
|
||||||
|
{
|
||||||
|
{ "maxWeight", std::to_string(m_MaxWeight) },
|
||||||
|
{ "weight", std::to_string(m_Weight) },
|
||||||
|
{ "slots", std::to_string(m_Slots) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
InventoryInfo(
|
||||||
|
const uint16_t maxWeight,
|
||||||
|
const uint16_t weight,
|
||||||
|
const uint16_t slots
|
||||||
|
) :
|
||||||
|
m_MaxWeight(maxWeight),
|
||||||
|
m_Weight(weight),
|
||||||
|
m_Slots(slots)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
InventoryInfo() = default;
|
||||||
|
virtual ~InventoryInfo() = default;
|
||||||
|
private:
|
||||||
|
uint16_t m_MaxWeight = 0;
|
||||||
|
uint16_t m_Weight = 0;
|
||||||
|
uint16_t m_Slots = 0;
|
||||||
|
};
|
||||||
|
}
|
85
L2BotCore/Domain/ValueObjects/PermanentStats.h
Normal file
85
L2BotCore/Domain/ValueObjects/PermanentStats.h
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class PermanentStats : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint16_t GetStr() const
|
||||||
|
{
|
||||||
|
return m_Str;
|
||||||
|
}
|
||||||
|
const uint16_t GetDex() const
|
||||||
|
{
|
||||||
|
return m_Dex;
|
||||||
|
}
|
||||||
|
const uint16_t GetCon() const
|
||||||
|
{
|
||||||
|
return m_Con;
|
||||||
|
}
|
||||||
|
const uint16_t GetInt() const
|
||||||
|
{
|
||||||
|
return m_Int;
|
||||||
|
}
|
||||||
|
const uint16_t GetMen() const
|
||||||
|
{
|
||||||
|
return m_Men;
|
||||||
|
}
|
||||||
|
const uint16_t GetWit() const
|
||||||
|
{
|
||||||
|
return m_Wit;
|
||||||
|
}
|
||||||
|
const bool IsEqual(const PermanentStats* other) const
|
||||||
|
{
|
||||||
|
return m_Str == other->m_Str &&
|
||||||
|
m_Dex == other->m_Dex &&
|
||||||
|
m_Con == other->m_Con &&
|
||||||
|
m_Int == other->m_Int &&
|
||||||
|
m_Men == other->m_Men &&
|
||||||
|
m_Wit == other->m_Wit;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
return std::vector<Serializers::Node>
|
||||||
|
{
|
||||||
|
{ "str", std::to_string(m_Str) },
|
||||||
|
{ "dex", std::to_string(m_Dex) },
|
||||||
|
{ "con", std::to_string(m_Con) },
|
||||||
|
{ "int", std::to_string(m_Int) },
|
||||||
|
{ "men", std::to_string(m_Men) },
|
||||||
|
{ "wit", std::to_string(m_Wit) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
PermanentStats(
|
||||||
|
uint16_t str,
|
||||||
|
uint16_t dex,
|
||||||
|
uint16_t con,
|
||||||
|
uint16_t int_,
|
||||||
|
uint16_t men,
|
||||||
|
uint16_t wit
|
||||||
|
) :
|
||||||
|
m_Str(str),
|
||||||
|
m_Dex(dex),
|
||||||
|
m_Con(con),
|
||||||
|
m_Int(int_),
|
||||||
|
m_Men(men),
|
||||||
|
m_Wit(wit)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
PermanentStats() = default;
|
||||||
|
virtual ~PermanentStats() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint16_t m_Str = 0;
|
||||||
|
uint16_t m_Dex = 0;
|
||||||
|
uint16_t m_Con = 0;
|
||||||
|
uint16_t m_Int = 0;
|
||||||
|
uint16_t m_Men = 0;
|
||||||
|
uint16_t m_Wit = 0;
|
||||||
|
};
|
||||||
|
}
|
72
L2BotCore/Domain/ValueObjects/Phenotype.h
Normal file
72
L2BotCore/Domain/ValueObjects/Phenotype.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../Enums/RaceEnum.h"
|
||||||
|
#include "../Enums/ClassEnum.h"
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class Phenotype : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const bool IsSubClass() const
|
||||||
|
{
|
||||||
|
return m_ActiveClass != Enums::ClassEnum::none && m_Class != m_ActiveClass;
|
||||||
|
}
|
||||||
|
const Enums::RaceEnum GetRace() const
|
||||||
|
{
|
||||||
|
return m_Race;
|
||||||
|
}
|
||||||
|
const bool IsMale() const
|
||||||
|
{
|
||||||
|
return m_IsMale;
|
||||||
|
}
|
||||||
|
const Enums::ClassEnum GetClass() const
|
||||||
|
{
|
||||||
|
return m_Class;
|
||||||
|
}
|
||||||
|
const Enums::ClassEnum GetActiveClass() const
|
||||||
|
{
|
||||||
|
return m_ActiveClass;
|
||||||
|
}
|
||||||
|
const bool IsEqual(const Phenotype* other) const
|
||||||
|
{
|
||||||
|
return m_Race == other->m_Race &&
|
||||||
|
m_IsMale == other->m_IsMale &&
|
||||||
|
m_Class == other->m_Class &&
|
||||||
|
m_ActiveClass == other->m_ActiveClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
return std::vector<Serializers::Node>
|
||||||
|
{
|
||||||
|
{ "race", std::to_string(static_cast<uint8_t>(m_Race)) },
|
||||||
|
{ "isMale", std::to_string(m_IsMale) },
|
||||||
|
{ "class", std::to_string(static_cast<uint8_t>(m_Class)) },
|
||||||
|
{ "activeClass", std::to_string(static_cast<uint8_t>(m_ActiveClass)) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Phenotype(
|
||||||
|
Enums::RaceEnum race,
|
||||||
|
bool isMale,
|
||||||
|
Enums::ClassEnum class_,
|
||||||
|
Enums::ClassEnum activeClass
|
||||||
|
) :
|
||||||
|
m_Race(race),
|
||||||
|
m_IsMale(isMale),
|
||||||
|
m_Class(class_),
|
||||||
|
m_ActiveClass(activeClass)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Phenotype() = default;
|
||||||
|
virtual ~Phenotype() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Enums::RaceEnum m_Race = Enums::RaceEnum::none;
|
||||||
|
bool m_IsMale = true;
|
||||||
|
Enums::ClassEnum m_Class = Enums::ClassEnum::none;
|
||||||
|
Enums::ClassEnum m_ActiveClass = Enums::ClassEnum::none;
|
||||||
|
};
|
||||||
|
}
|
80
L2BotCore/Domain/ValueObjects/Reputation.h
Normal file
80
L2BotCore/Domain/ValueObjects/Reputation.h
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class Reputation : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const bool IsPlayerKiller() const
|
||||||
|
{
|
||||||
|
return m_Karma > 0;
|
||||||
|
}
|
||||||
|
const uint16_t GetKarma() const
|
||||||
|
{
|
||||||
|
return m_Karma;
|
||||||
|
}
|
||||||
|
const uint16_t GetPkKills() const
|
||||||
|
{
|
||||||
|
return m_PkKills;
|
||||||
|
}
|
||||||
|
const uint16_t GetPvpKills() const
|
||||||
|
{
|
||||||
|
return m_PvpKills;
|
||||||
|
}
|
||||||
|
const uint8_t GetRecRemaining() const
|
||||||
|
{
|
||||||
|
return m_RecRemaining;
|
||||||
|
}
|
||||||
|
const uint8_t GetEvalScore() const
|
||||||
|
{
|
||||||
|
return m_EvalScore;
|
||||||
|
}
|
||||||
|
const bool IsEqual(const Reputation* other) const
|
||||||
|
{
|
||||||
|
return m_Karma == other->m_Karma &&
|
||||||
|
m_PkKills == other->m_PkKills &&
|
||||||
|
m_PvpKills == other->m_PvpKills &&
|
||||||
|
m_RecRemaining == other->m_RecRemaining &&
|
||||||
|
m_EvalScore == other->m_EvalScore;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
return std::vector<Serializers::Node>
|
||||||
|
{
|
||||||
|
{ "karma", std::to_string(m_Karma) },
|
||||||
|
{ "pkKills", std::to_string(m_PkKills) },
|
||||||
|
{ "pvpKills", std::to_string(m_PvpKills) },
|
||||||
|
{ "recRemaining", std::to_string(m_RecRemaining) },
|
||||||
|
{ "evalScore", std::to_string(m_EvalScore) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Reputation(
|
||||||
|
uint16_t karma,
|
||||||
|
uint16_t pkKills,
|
||||||
|
uint16_t pvpKills,
|
||||||
|
uint8_t recRemaining,
|
||||||
|
uint8_t evalScore
|
||||||
|
) :
|
||||||
|
m_Karma(karma),
|
||||||
|
m_PkKills(pkKills),
|
||||||
|
m_PvpKills(pvpKills),
|
||||||
|
m_RecRemaining(recRemaining),
|
||||||
|
m_EvalScore(evalScore)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Reputation() = default;
|
||||||
|
virtual ~Reputation() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint16_t m_Karma = 0;
|
||||||
|
uint16_t m_PkKills = 0;
|
||||||
|
uint16_t m_PvpKills = 0;
|
||||||
|
uint8_t m_RecRemaining = 0;
|
||||||
|
uint8_t m_EvalScore = 0;
|
||||||
|
};
|
||||||
|
}
|
188
L2BotCore/Domain/ValueObjects/Skill.h
Normal file
188
L2BotCore/Domain/ValueObjects/Skill.h
Normal file
@ -0,0 +1,188 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include "../DTO/Skill.h"
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
#include "../Serializers/Node.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class Skill : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint32_t GetId() const
|
||||||
|
{
|
||||||
|
return m_SkillId;
|
||||||
|
}
|
||||||
|
const bool IsReadyToUse() const
|
||||||
|
{
|
||||||
|
return !m_IsCasting && !m_IsReloading;
|
||||||
|
}
|
||||||
|
void UpdateFromDTO(const DTO::Skill* dto)
|
||||||
|
{
|
||||||
|
SaveState();
|
||||||
|
|
||||||
|
m_SkillId = dto->skillId;
|
||||||
|
m_Level = dto->level;
|
||||||
|
m_IsActive = dto->isActive;
|
||||||
|
m_Cost = dto->cost;
|
||||||
|
m_Range = dto->range;
|
||||||
|
m_Name = dto->name;
|
||||||
|
m_Description = dto->description;
|
||||||
|
m_IconName = dto->iconName;
|
||||||
|
m_IsToggled = dto->isToggled;
|
||||||
|
m_IsCasting = dto->isCasting;
|
||||||
|
m_IsReloading = dto->isReloading;
|
||||||
|
}
|
||||||
|
void SaveState()
|
||||||
|
{
|
||||||
|
m_PrevState =
|
||||||
|
{
|
||||||
|
m_Cost,
|
||||||
|
m_Range,
|
||||||
|
m_Description,
|
||||||
|
m_IsToggled,
|
||||||
|
m_IsCasting,
|
||||||
|
m_IsReloading,
|
||||||
|
IsReadyToUse(),
|
||||||
|
false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const static Skill CreateFromDTO(const DTO::Skill& dto)
|
||||||
|
{
|
||||||
|
return Skill(
|
||||||
|
dto.skillId,
|
||||||
|
dto.level,
|
||||||
|
dto.isActive,
|
||||||
|
dto.cost,
|
||||||
|
dto.range,
|
||||||
|
dto.name,
|
||||||
|
dto.description,
|
||||||
|
dto.iconName,
|
||||||
|
dto.isToggled,
|
||||||
|
dto.isCasting,
|
||||||
|
dto.isReloading
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const bool IsEqual(const DTO::Skill* dto) const
|
||||||
|
{
|
||||||
|
return m_SkillId == dto->skillId &&
|
||||||
|
m_Level == dto->level &&
|
||||||
|
m_IsActive == dto->isActive &&
|
||||||
|
m_Cost == dto->cost &&
|
||||||
|
m_Range == dto->range &&
|
||||||
|
m_Name == dto->name &&
|
||||||
|
m_Description == dto->description &&
|
||||||
|
m_IconName == dto->iconName &&
|
||||||
|
m_IsToggled == dto->isToggled &&
|
||||||
|
m_IsCasting == dto->isCasting &&
|
||||||
|
m_IsReloading == dto->isReloading;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Node> result;
|
||||||
|
|
||||||
|
result.push_back({ "skillId", std::to_string(m_SkillId) });
|
||||||
|
result.push_back({ "level", std::to_string(m_Level) });
|
||||||
|
|
||||||
|
if (m_PrevState.isNewState)
|
||||||
|
{
|
||||||
|
result.push_back({ "isActive", std::to_string(m_IsActive) });
|
||||||
|
result.push_back({ "name", m_Name });
|
||||||
|
result.push_back({ "iconName", m_IconName });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_PrevState.isNewState || m_Description != m_PrevState.description)
|
||||||
|
{
|
||||||
|
result.push_back({ "description", m_Description });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_Cost != m_PrevState.cost)
|
||||||
|
{
|
||||||
|
result.push_back({ "cost", std::to_string(m_Cost) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_Range != m_PrevState.range)
|
||||||
|
{
|
||||||
|
result.push_back({ "range", std::to_string(m_Range) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_IsToggled != m_PrevState.isToggled)
|
||||||
|
{
|
||||||
|
result.push_back({ "isToggled", std::to_string(m_IsToggled) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_IsCasting != m_PrevState.isCasting)
|
||||||
|
{
|
||||||
|
result.push_back({ "isCasting", std::to_string(m_IsCasting) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || m_IsReloading != m_PrevState.isReloading)
|
||||||
|
{
|
||||||
|
result.push_back({ "isReloading", std::to_string(m_IsReloading) });
|
||||||
|
}
|
||||||
|
if (m_PrevState.isNewState || IsReadyToUse() != m_PrevState.isReadyToUse)
|
||||||
|
{
|
||||||
|
result.push_back({ "isReadyToUse", std::to_string(IsReadyToUse()) });
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Skill(
|
||||||
|
const uint32_t skillId,
|
||||||
|
const uint8_t level,
|
||||||
|
const bool isActive,
|
||||||
|
const uint8_t cost,
|
||||||
|
const int16_t range,
|
||||||
|
const std::string& name,
|
||||||
|
const std::string& description,
|
||||||
|
const std::string& iconName,
|
||||||
|
const bool isToggled,
|
||||||
|
const bool isCasting,
|
||||||
|
const bool isReloading
|
||||||
|
) :
|
||||||
|
m_SkillId(skillId),
|
||||||
|
m_Level(level),
|
||||||
|
m_IsActive(isActive),
|
||||||
|
m_Cost(cost),
|
||||||
|
m_Range(range),
|
||||||
|
m_Name(name),
|
||||||
|
m_Description(description),
|
||||||
|
m_IconName(iconName),
|
||||||
|
m_IsToggled(isToggled),
|
||||||
|
m_IsCasting(isCasting),
|
||||||
|
m_IsReloading(isReloading)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Skill() = default;
|
||||||
|
virtual ~Skill() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
struct State
|
||||||
|
{
|
||||||
|
uint8_t cost = 0;
|
||||||
|
int16_t range = 0;
|
||||||
|
std::string description = "";
|
||||||
|
bool isToggled = false;
|
||||||
|
bool isCasting = false;
|
||||||
|
bool isReloading = false;
|
||||||
|
bool isReadyToUse = true;
|
||||||
|
|
||||||
|
bool isNewState = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t m_SkillId = 0;
|
||||||
|
uint8_t m_Level = 0;
|
||||||
|
bool m_IsActive = false;
|
||||||
|
uint8_t m_Cost = 0;
|
||||||
|
int16_t m_Range = 0;
|
||||||
|
std::string m_Name = "";
|
||||||
|
std::string m_Description = "";
|
||||||
|
std::string m_IconName = "";
|
||||||
|
bool m_IsToggled = false;
|
||||||
|
bool m_IsCasting = false;
|
||||||
|
bool m_IsReloading = false;
|
||||||
|
State m_PrevState = State();
|
||||||
|
};
|
||||||
|
}
|
74
L2BotCore/Domain/ValueObjects/Transform.h
Normal file
74
L2BotCore/Domain/ValueObjects/Transform.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../ValueObjects/Vector3.h"
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class Transform : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const Vector3& GetPosition() const
|
||||||
|
{
|
||||||
|
return m_Position;
|
||||||
|
}
|
||||||
|
const Vector3& GetRotation() const
|
||||||
|
{
|
||||||
|
return m_Rotation;
|
||||||
|
}
|
||||||
|
const Vector3& GetVelocity() const
|
||||||
|
{
|
||||||
|
return m_Velocity;
|
||||||
|
}
|
||||||
|
const Vector3& GetAcceleration() const
|
||||||
|
{
|
||||||
|
return m_Acceleration;
|
||||||
|
}
|
||||||
|
const bool IsEqual(const Transform* other) const
|
||||||
|
{
|
||||||
|
return m_Position.IsEqual(&other->m_Position) &&
|
||||||
|
m_Rotation.IsEqual(&other->m_Rotation) &&
|
||||||
|
m_Velocity.IsEqual(&other->m_Velocity) &&
|
||||||
|
m_Acceleration.IsEqual(&other->m_Acceleration);
|
||||||
|
}
|
||||||
|
const float_t GetSqrDistance(const Transform& other) const
|
||||||
|
{
|
||||||
|
return m_Position.GetSqrDistance(other.m_Position);
|
||||||
|
}
|
||||||
|
const float_t GetHorizontalSqrDistance(const Transform& other) const
|
||||||
|
{
|
||||||
|
return m_Position.GetHorizontalSqrDistance(other.m_Position);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
return std::vector<Serializers::Node>
|
||||||
|
{
|
||||||
|
{ "position", m_Position.BuildSerializationNodes() },
|
||||||
|
{ "rotation", m_Rotation.BuildSerializationNodes() },
|
||||||
|
{ "velocity", m_Velocity.BuildSerializationNodes() },
|
||||||
|
{ "acceleration", m_Acceleration.BuildSerializationNodes() }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform(
|
||||||
|
const Vector3 position,
|
||||||
|
const Vector3 rotation,
|
||||||
|
const Vector3 velocity,
|
||||||
|
const Vector3 acceleration
|
||||||
|
) :
|
||||||
|
m_Position(position),
|
||||||
|
m_Rotation(rotation),
|
||||||
|
m_Velocity(velocity),
|
||||||
|
m_Acceleration(acceleration)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform() = default;
|
||||||
|
virtual ~Transform() = default;
|
||||||
|
private:
|
||||||
|
Vector3 m_Position = Vector3();
|
||||||
|
Vector3 m_Rotation = Vector3();
|
||||||
|
Vector3 m_Velocity = Vector3();
|
||||||
|
Vector3 m_Acceleration = Vector3();
|
||||||
|
};
|
||||||
|
}
|
112
L2BotCore/Domain/ValueObjects/VariableStats.h
Normal file
112
L2BotCore/Domain/ValueObjects/VariableStats.h
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class VariableStats : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const uint16_t GetAccuracy() const
|
||||||
|
{
|
||||||
|
return m_Accuracy;
|
||||||
|
}
|
||||||
|
const uint16_t GetCritRate() const
|
||||||
|
{
|
||||||
|
return m_CritRate;
|
||||||
|
}
|
||||||
|
const uint16_t GetPAttack() const
|
||||||
|
{
|
||||||
|
return m_PAttack;
|
||||||
|
}
|
||||||
|
const uint16_t GetAttackSpeed() const
|
||||||
|
{
|
||||||
|
return m_AttackSpeed;
|
||||||
|
}
|
||||||
|
const uint16_t GetPDefense() const
|
||||||
|
{
|
||||||
|
return m_PDefense;
|
||||||
|
}
|
||||||
|
const uint16_t GetEvasion() const
|
||||||
|
{
|
||||||
|
return m_Evasion;
|
||||||
|
}
|
||||||
|
const uint16_t GetMAttack() const
|
||||||
|
{
|
||||||
|
return m_MAttack;
|
||||||
|
}
|
||||||
|
const uint16_t GetMDefense() const
|
||||||
|
{
|
||||||
|
return m_MDefense;
|
||||||
|
}
|
||||||
|
const uint16_t GetCastingSpeed() const
|
||||||
|
{
|
||||||
|
return m_CastingSpeed;
|
||||||
|
}
|
||||||
|
const bool IsEqual(const VariableStats* other) const
|
||||||
|
{
|
||||||
|
return m_Accuracy == other->m_Accuracy &&
|
||||||
|
m_CritRate == other->m_CritRate &&
|
||||||
|
m_PAttack == other->m_PAttack &&
|
||||||
|
m_AttackSpeed == other->m_AttackSpeed &&
|
||||||
|
m_PDefense == other->m_PDefense &&
|
||||||
|
m_Evasion == other->m_Evasion &&
|
||||||
|
m_MAttack == other->m_MAttack &&
|
||||||
|
m_MDefense == other->m_MDefense &&
|
||||||
|
m_CastingSpeed == other->m_CastingSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
return std::vector<Serializers::Node>
|
||||||
|
{
|
||||||
|
{ "accuracy", std::to_string(m_Accuracy) },
|
||||||
|
{ "critRate", std::to_string(m_CritRate) },
|
||||||
|
{ "pAttack", std::to_string(m_PAttack) },
|
||||||
|
{ "attackSpeed", std::to_string(m_AttackSpeed) },
|
||||||
|
{ "pDefense", std::to_string(m_PDefense) },
|
||||||
|
{ "evasion", std::to_string(m_Evasion) },
|
||||||
|
{ "mAttack", std::to_string(m_MAttack) },
|
||||||
|
{ "mDefense", std::to_string(m_MDefense) },
|
||||||
|
{ "castingSpeed", std::to_string(m_CastingSpeed) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
VariableStats(
|
||||||
|
uint16_t accuracy,
|
||||||
|
uint16_t critRate,
|
||||||
|
uint16_t pAttack,
|
||||||
|
uint16_t attackSpeed,
|
||||||
|
uint16_t pDefense,
|
||||||
|
uint16_t evasion,
|
||||||
|
uint16_t mAttack,
|
||||||
|
uint16_t mDefense,
|
||||||
|
uint16_t castingSpeed
|
||||||
|
) :
|
||||||
|
m_Accuracy(accuracy),
|
||||||
|
m_CritRate(critRate),
|
||||||
|
m_PAttack(pAttack),
|
||||||
|
m_AttackSpeed(attackSpeed),
|
||||||
|
m_PDefense(pDefense),
|
||||||
|
m_Evasion(evasion),
|
||||||
|
m_MAttack(mAttack),
|
||||||
|
m_MDefense(mDefense),
|
||||||
|
m_CastingSpeed(castingSpeed)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VariableStats() = default;
|
||||||
|
virtual ~VariableStats() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint16_t m_Accuracy = 0;
|
||||||
|
uint16_t m_CritRate = 0;
|
||||||
|
uint16_t m_PAttack = 0;
|
||||||
|
uint16_t m_AttackSpeed = 0;
|
||||||
|
uint16_t m_PDefense = 0;
|
||||||
|
uint16_t m_Evasion = 0;
|
||||||
|
uint16_t m_MAttack = 0;
|
||||||
|
uint16_t m_MDefense = 0;
|
||||||
|
uint16_t m_CastingSpeed = 0;
|
||||||
|
};
|
||||||
|
}
|
64
L2BotCore/Domain/ValueObjects/Vector3.h
Normal file
64
L2BotCore/Domain/ValueObjects/Vector3.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <math.h>
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class Vector3 : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const float_t GetX() const
|
||||||
|
{
|
||||||
|
return m_X;
|
||||||
|
}
|
||||||
|
const float_t GetY() const
|
||||||
|
{
|
||||||
|
return m_Y;
|
||||||
|
}
|
||||||
|
const float_t GetZ() const
|
||||||
|
{
|
||||||
|
return m_Z;
|
||||||
|
}
|
||||||
|
const bool IsEqual(const Vector3* other) const
|
||||||
|
{
|
||||||
|
float_t epsilon = 0.0001f;
|
||||||
|
return fabsf(m_X - other->m_X) < epsilon &&
|
||||||
|
fabsf(m_Y - other->m_Y) < epsilon &&
|
||||||
|
fabsf(m_Z - other->m_Z) < epsilon;
|
||||||
|
}
|
||||||
|
const float_t GetSqrDistance(const Vector3& other) const
|
||||||
|
{
|
||||||
|
return (m_X - other.m_X) * (m_X - other.m_X) +
|
||||||
|
(m_Y - other.m_Y) * (m_Y - other.m_Y) +
|
||||||
|
(m_Z - other.m_Z) * (m_Z - other.m_Z);
|
||||||
|
}
|
||||||
|
const float_t GetHorizontalSqrDistance(const Vector3& other) const
|
||||||
|
{
|
||||||
|
return (m_X - other.m_X) * (m_X - other.m_X) +
|
||||||
|
(m_Y - other.m_Y) * (m_Y - other.m_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
return std::vector<Serializers::Node>
|
||||||
|
{
|
||||||
|
{ "x", std::to_string(m_X) },
|
||||||
|
{ "y", std::to_string(m_Y) },
|
||||||
|
{ "z", std::to_string(m_Z) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3(const float_t x, const float_t y, const float_t z) :
|
||||||
|
m_X(x), m_Y(y), m_Z(z)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3() = default;
|
||||||
|
virtual ~Vector3() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
float_t m_X = 0;
|
||||||
|
float_t m_Y = 0;
|
||||||
|
float_t m_Z = 0;
|
||||||
|
};
|
||||||
|
}
|
89
L2BotCore/Domain/ValueObjects/VitalStats.h
Normal file
89
L2BotCore/Domain/ValueObjects/VitalStats.h
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include "../Serializers/Serializable.h"
|
||||||
|
|
||||||
|
namespace L2Bot::Domain::ValueObjects
|
||||||
|
{
|
||||||
|
class VitalStats : public Serializers::Serializable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const bool IsAlive() const
|
||||||
|
{
|
||||||
|
return m_MaxHp <= 0 || m_Hp > 0;
|
||||||
|
}
|
||||||
|
const uint32_t GetMaxHp() const
|
||||||
|
{
|
||||||
|
return m_MaxHp;
|
||||||
|
}
|
||||||
|
const uint32_t GetHp() const
|
||||||
|
{
|
||||||
|
return m_Hp;
|
||||||
|
}
|
||||||
|
const uint32_t GetMaxMp() const
|
||||||
|
{
|
||||||
|
return m_MaxMp;
|
||||||
|
}
|
||||||
|
const uint32_t GetMp() const
|
||||||
|
{
|
||||||
|
return m_Mp;
|
||||||
|
}
|
||||||
|
const uint32_t GetMaxCp() const
|
||||||
|
{
|
||||||
|
return m_MaxCp;
|
||||||
|
}
|
||||||
|
const uint32_t GetCp() const
|
||||||
|
{
|
||||||
|
return m_Cp;
|
||||||
|
}
|
||||||
|
const bool IsEqual(const VitalStats* other) const
|
||||||
|
{
|
||||||
|
return m_MaxHp == other->m_MaxHp &&
|
||||||
|
m_Hp == other->m_Hp &&
|
||||||
|
m_MaxMp == other->m_MaxMp &&
|
||||||
|
m_Mp == other->m_Mp &&
|
||||||
|
m_MaxCp == other->m_MaxCp &&
|
||||||
|
m_Cp == other->m_Cp;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
|
{
|
||||||
|
return std::vector<Serializers::Node>
|
||||||
|
{
|
||||||
|
{ "maxHp", std::to_string(m_MaxHp) },
|
||||||
|
{ "hp", std::to_string(m_Hp) },
|
||||||
|
{ "maxMp", std::to_string(m_MaxMp) },
|
||||||
|
{ "mp", std::to_string(m_Mp) },
|
||||||
|
{ "maxCp", std::to_string(m_MaxCp) },
|
||||||
|
{ "cp", std::to_string(m_Cp) }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
VitalStats(
|
||||||
|
uint32_t maxHp,
|
||||||
|
uint32_t hp,
|
||||||
|
uint32_t maxMp,
|
||||||
|
uint32_t mp,
|
||||||
|
uint32_t maxCp,
|
||||||
|
uint32_t cp
|
||||||
|
) :
|
||||||
|
m_MaxHp(maxHp),
|
||||||
|
m_Hp(hp),
|
||||||
|
m_MaxMp(maxMp),
|
||||||
|
m_Mp(mp),
|
||||||
|
m_MaxCp(maxCp),
|
||||||
|
m_Cp(cp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
VitalStats() = default;
|
||||||
|
virtual ~VitalStats() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint32_t m_MaxHp = 0;
|
||||||
|
uint32_t m_Hp = 0;
|
||||||
|
uint32_t m_MaxMp = 0;
|
||||||
|
uint32_t m_Mp = 0;
|
||||||
|
uint32_t m_MaxCp = 0;
|
||||||
|
uint32_t m_Cp = 0;
|
||||||
|
};
|
||||||
|
}
|
230
L2BotCore/L2BotCore.vcxproj
Normal file
230
L2BotCore/L2BotCore.vcxproj
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{504a5403-ba08-46df-aa8a-b79993b56bca}</ProjectGuid>
|
||||||
|
<RootNamespace>L2BotCore</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\bin\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\bin\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>
|
||||||
|
</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Domain\DTO\BaseItem.h" />
|
||||||
|
<ClInclude Include="Domain\DTO\Skill.h" />
|
||||||
|
<ClInclude Include="Domain\Repositories\ItemRepositoryInterface.h" />
|
||||||
|
<ClInclude Include="Domain\Repositories\SkillRepositoryInterface.h" />
|
||||||
|
<ClInclude Include="Domain\Serializers\SerializableStateContainerPtr.h" />
|
||||||
|
<ClInclude Include="Domain\Services\ItemService.h" />
|
||||||
|
<ClInclude Include="Domain\Services\ObjectServicePtr.h" />
|
||||||
|
<ClInclude Include="Domain\Services\SkillService.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\BaseItem.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\Skill.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\Vector3.h" />
|
||||||
|
<ClInclude Include="Domain\Enums\SpoilStateEnum.h" />
|
||||||
|
<ClInclude Include="Domain\Transports\TransportInterface.h" />
|
||||||
|
<ClInclude Include="Domain\DTO\Drop.h" />
|
||||||
|
<ClInclude Include="Domain\DTO\Hero.h" />
|
||||||
|
<ClInclude Include="Domain\DTO\NPC.h" />
|
||||||
|
<ClInclude Include="Domain\DTO\ObjectState.h" />
|
||||||
|
<ClInclude Include="Domain\DTO\Player.h" />
|
||||||
|
<ClInclude Include="Domain\DTO\WorldObject.h" />
|
||||||
|
<ClInclude Include="Domain\Entities\Drop.h" />
|
||||||
|
<ClInclude Include="Domain\Entities\Hero.h" />
|
||||||
|
<ClInclude Include="Domain\Entities\NPC.h" />
|
||||||
|
<ClInclude Include="Domain\Entities\Player.h" />
|
||||||
|
<ClInclude Include="Domain\Entities\WorldObject.h" />
|
||||||
|
<ClInclude Include="Domain\Enums\ClassEnum.h" />
|
||||||
|
<ClInclude Include="Domain\Enums\ObjectStateEnum.h" />
|
||||||
|
<ClInclude Include="Domain\Enums\RaceEnum.h" />
|
||||||
|
<ClInclude Include="Domain\Repositories\DropRepositoryInterface.h" />
|
||||||
|
<ClInclude Include="Domain\Repositories\HeroRepositoryInterface.h" />
|
||||||
|
<ClInclude Include="Domain\Repositories\NPCRepositoryInterface.h" />
|
||||||
|
<ClInclude Include="Domain\Repositories\ObjectRepositoryInterface.h" />
|
||||||
|
<ClInclude Include="Domain\Repositories\PlayerRepositoryInterface.h" />
|
||||||
|
<ClInclude Include="Domain\Serializers\Node.h" />
|
||||||
|
<ClInclude Include="Domain\Serializers\Serializable.h" />
|
||||||
|
<ClInclude Include="Domain\Serializers\SerializerInterface.h" />
|
||||||
|
<ClInclude Include="Domain\Services\DropService.h" />
|
||||||
|
<ClInclude Include="Domain\Services\HeroService.h" />
|
||||||
|
<ClInclude Include="Domain\Services\NPCService.h" />
|
||||||
|
<ClInclude Include="Domain\Services\ObjectService.h" />
|
||||||
|
<ClInclude Include="Domain\Services\PlayerService.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\ExperienceInfo.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\FullName.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\InventoryInfo.h" />
|
||||||
|
<ClInclude Include="Domain\Serializers\SerializableStateContainer.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\PermanentStats.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\Phenotype.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\Reputation.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\Transform.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\VariableStats.h" />
|
||||||
|
<ClInclude Include="Domain\ValueObjects\VitalStats.h" />
|
||||||
|
<ClInclude Include="framework.h" />
|
||||||
|
<ClInclude Include="pch.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="pch.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||||
|
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">stdcpp20</LanguageStandard>
|
||||||
|
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">stdcpp20</LanguageStandard>
|
||||||
|
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">stdcpp20</LanguageStandard>
|
||||||
|
<LanguageStandard Condition="'$(Configuration)|$(Platform)'=='Release|x64'">stdcpp20</LanguageStandard>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
180
L2BotCore/L2BotCore.vcxproj.filters
Normal file
180
L2BotCore/L2BotCore.vcxproj.filters
Normal file
@ -0,0 +1,180 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="framework.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="pch.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\Vector3.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\DTO\Drop.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\DTO\WorldObject.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Entities\Drop.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Entities\Hero.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Entities\NPC.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Entities\Player.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Entities\WorldObject.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Enums\ClassEnum.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Enums\RaceEnum.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Repositories\DropRepositoryInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Services\DropService.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\ExperienceInfo.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\FullName.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\InventoryInfo.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\PermanentStats.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\Phenotype.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\Reputation.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\Transform.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\VariableStats.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\VitalStats.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\DTO\Hero.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\DTO\NPC.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\DTO\Player.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Services\ObjectService.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Repositories\ObjectRepositoryInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Services\NPCService.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Repositories\NPCRepositoryInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Repositories\PlayerRepositoryInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Services\PlayerService.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Repositories\HeroRepositoryInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Services\HeroService.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Enums\ObjectStateEnum.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\DTO\ObjectState.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Serializers\Serializable.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Serializers\SerializerInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Serializers\Node.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Serializers\SerializableStateContainer.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Transports\TransportInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Enums\SpoilStateEnum.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\DTO\Skill.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\Skill.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Repositories\SkillRepositoryInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Services\SkillService.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\DTO\BaseItem.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\ValueObjects\BaseItem.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Repositories\ItemRepositoryInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Services\ItemService.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Serializers\SerializableStateContainerPtr.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Domain\Services\ObjectServicePtr.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="pch.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
7
L2BotCore/framework.h
Normal file
7
L2BotCore/framework.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||||
|
// Windows Header Files
|
||||||
|
#include <windows.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <cstdint>
|
5
L2BotCore/pch.cpp
Normal file
5
L2BotCore/pch.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// pch.cpp: source file corresponding to the pre-compiled header
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
|
13
L2BotCore/pch.h
Normal file
13
L2BotCore/pch.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// pch.h: This is a precompiled header file.
|
||||||
|
// Files listed below are compiled only once, improving build performance for future builds.
|
||||||
|
// This also affects IntelliSense performance, including code completion and many code browsing features.
|
||||||
|
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
|
||||||
|
// Do not add files here that you will be updating frequently as this negates the performance advantage.
|
||||||
|
|
||||||
|
#ifndef PCH_H
|
||||||
|
#define PCH_H
|
||||||
|
|
||||||
|
// add headers that you want to pre-compile here
|
||||||
|
#include "framework.h"
|
||||||
|
|
||||||
|
#endif //PCH_H
|
68
L2BotDll/Application.h
Normal file
68
L2BotDll/Application.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "Services/WorldHandler.h"
|
||||||
|
#include "Domain/Repositories/SkillRepositoryInterface.h"
|
||||||
|
#include "Serializers/JsonSerializer.h"
|
||||||
|
#include "Transports/NamedPipeTransport.h"
|
||||||
|
|
||||||
|
#include "Versions/VersionAbstractFactory.h"
|
||||||
|
|
||||||
|
using namespace L2Bot::Domain;
|
||||||
|
|
||||||
|
class Application
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Application(const VersionAbstractFactory::Version version) :
|
||||||
|
m_AbstractFactory(VersionAbstractFactory::GetFactory(version, Application::RADIUS)),
|
||||||
|
m_Transport(Application::PIPE_NAME),
|
||||||
|
m_WorldHandler
|
||||||
|
(
|
||||||
|
m_AbstractFactory.GetHeroRepository(),
|
||||||
|
m_AbstractFactory.GetDropRepository(),
|
||||||
|
m_AbstractFactory.GetNPCRepository(),
|
||||||
|
m_AbstractFactory.GetPlayerRepository(),
|
||||||
|
m_AbstractFactory.GetSkillRepository(),
|
||||||
|
m_Serializer,
|
||||||
|
m_Transport
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
Application() = delete;
|
||||||
|
virtual ~Application() = default;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
HMODULE hEngine = GetModuleHandleA("Engine.dll");
|
||||||
|
HMODULE hCore = GetModuleHandleA("Core.dll");
|
||||||
|
|
||||||
|
m_AbstractFactory.GetNetworkHandler().Init(hEngine);
|
||||||
|
m_AbstractFactory.GetGameEngine().Init(hEngine);
|
||||||
|
m_AbstractFactory.GetL2GameData().Init(hEngine);
|
||||||
|
m_AbstractFactory.GetFName().Init(hCore);
|
||||||
|
m_WorldHandler.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stop()
|
||||||
|
{
|
||||||
|
m_WorldHandler.Stop();
|
||||||
|
m_AbstractFactory.GetL2GameData().Restore();
|
||||||
|
m_AbstractFactory.GetGameEngine().Restore();
|
||||||
|
m_AbstractFactory.GetNetworkHandler().Restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const VersionAbstractFactory& m_AbstractFactory;
|
||||||
|
WorldHandler m_WorldHandler;
|
||||||
|
JsonSerializer m_Serializer;
|
||||||
|
NamedPipeTransport m_Transport;
|
||||||
|
|
||||||
|
static const std::string PIPE_NAME;
|
||||||
|
static const uint16_t RADIUS;
|
||||||
|
};
|
||||||
|
|
||||||
|
const std::string Application::PIPE_NAME = std::string("PipeL2Bot");
|
||||||
|
const uint16_t Application::RADIUS = 2000;
|
34
L2BotDll/Common/Common.cpp
Normal file
34
L2BotDll/Common/Common.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <Rpc.h>
|
||||||
|
#pragma comment(lib, "Rpcrt4.lib")
|
||||||
|
|
||||||
|
std::string ConvertFromWideChar(const wchar_t* str)
|
||||||
|
{
|
||||||
|
std::wstring ws(str);
|
||||||
|
std::string result(ws.begin(), ws.end());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GenerateUUID()
|
||||||
|
{
|
||||||
|
UUID uuid;
|
||||||
|
::ZeroMemory(&uuid, sizeof(UUID));
|
||||||
|
|
||||||
|
::UuidCreate(&uuid);
|
||||||
|
|
||||||
|
WCHAR* wszUuid = NULL;
|
||||||
|
::UuidToStringW(&uuid, (RPC_WSTR*)&wszUuid);
|
||||||
|
|
||||||
|
if (wszUuid == NULL)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::wstring ws = wszUuid;
|
||||||
|
|
||||||
|
::RpcStringFree((RPC_WSTR*)&wszUuid);
|
||||||
|
wszUuid = NULL;
|
||||||
|
|
||||||
|
return std::string(ws.begin(), ws.end());
|
||||||
|
}
|
6
L2BotDll/Common/Common.h
Normal file
6
L2BotDll/Common/Common.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
std::string ConvertFromWideChar(const wchar_t* str);
|
||||||
|
std::string GenerateUUID();
|
81
L2BotDll/Common/TimerMap.h
Normal file
81
L2BotDll/Common/TimerMap.h
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <functional>
|
||||||
|
#include <atomic>
|
||||||
|
#include <condition_variable>
|
||||||
|
#include <thread>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
class TimerMap
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TimerMap() = default;
|
||||||
|
virtual ~TimerMap()
|
||||||
|
{
|
||||||
|
StopAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void StartTimer(const uint32_t key, const uint32_t milliseconds, const std::function<void(uint32_t)> callback)
|
||||||
|
{
|
||||||
|
StopTimer(key);
|
||||||
|
|
||||||
|
m_Timers[key].Start(milliseconds, callback, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StopTimer(uint32_t key)
|
||||||
|
{
|
||||||
|
if (m_Timers.find(key) != m_Timers.end())
|
||||||
|
{
|
||||||
|
m_Timers[key].Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StopAll()
|
||||||
|
{
|
||||||
|
m_Timers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Timer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void Start(const uint32_t milliseconds, const std::function<void(uint32_t)> callback, const uint32_t data)
|
||||||
|
{
|
||||||
|
m_Terminate = false;
|
||||||
|
m_Thread = std::thread([this, milliseconds, callback, data] {
|
||||||
|
std::unique_lock<std::mutex> lk(m_Mutex);
|
||||||
|
|
||||||
|
if (!m_Condition.wait_for(lk, std::chrono::milliseconds(milliseconds), [this]() { return m_Terminate == true; }))
|
||||||
|
{
|
||||||
|
callback(data);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stop()
|
||||||
|
{
|
||||||
|
m_Terminate = true;
|
||||||
|
m_Condition.notify_all();
|
||||||
|
if (m_Thread.joinable())
|
||||||
|
{
|
||||||
|
m_Thread.join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer() = default;
|
||||||
|
virtual ~Timer()
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::condition_variable m_Condition;
|
||||||
|
std::mutex m_Mutex;
|
||||||
|
std::atomic_bool m_Terminate = false;
|
||||||
|
std::thread m_Thread;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::map<uint32_t, Timer> m_Timers;
|
||||||
|
};
|
75
L2BotDll/Common/apihook.cpp
Normal file
75
L2BotDll/Common/apihook.cpp
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
#include "apihook.h"
|
||||||
|
#include "Trampoline.h"
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct CallJmpInstr
|
||||||
|
{
|
||||||
|
BYTE opcode;
|
||||||
|
DWORD rel32;
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct SavedFunction
|
||||||
|
{
|
||||||
|
DWORD originalAddress;
|
||||||
|
BYTE size;
|
||||||
|
BYTE oldCode[5];
|
||||||
|
CallJmpInstr* jumpInstruction;
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Åñëè â íà÷àëå ôóíêöèè äëÿ ñïëàéñèíã ñòîèò èíñòðóêöèÿ jump (0xe9), òî îáû÷íûé ñïëàéñèíã íå áóäåò ðàáîòàòü
|
||||||
|
* Íåîáõîäèìî ïåðåñ÷èòàòü ñìåùåíèå äæàìïà èç îðèãèíàëüíîé ôóíêöèè êàê ïðè ñîõðàíåíèè, òàê è ïðè âîññòàíîâëåíèè îðèãèíàëüíîãî êîäà
|
||||||
|
*/
|
||||||
|
void recalculateRel32IfIsJump(void* dest, void* source)
|
||||||
|
{
|
||||||
|
CallJmpInstr* mayBeJump = (CallJmpInstr*)dest;
|
||||||
|
if (mayBeJump->opcode == 0xe9)
|
||||||
|
{
|
||||||
|
mayBeJump->rel32 = (DWORD)source - (DWORD)dest + mayBeJump->rel32;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BYTE saveOldFunction(void* proc, void* old)
|
||||||
|
{
|
||||||
|
CopyMemory(old, proc, 5);
|
||||||
|
recalculateRel32IfIsJump(old, proc);
|
||||||
|
CallJmpInstr* instr = (CallJmpInstr*)((BYTE*)old + 5);
|
||||||
|
instr->opcode = 0xe9;
|
||||||
|
instr->rel32 = (DWORD)((BYTE*)proc - (BYTE*)old - 5);
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* splice(void* splicedFunctionAddress, void* hookFunction)
|
||||||
|
{
|
||||||
|
DWORD oldProtect;
|
||||||
|
VirtualProtect((DWORD*)splicedFunctionAddress, 5, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||||
|
void* oldFunction = malloc(255);
|
||||||
|
*(DWORD*)oldFunction = (DWORD)splicedFunctionAddress;
|
||||||
|
*((BYTE*)oldFunction + 4) = saveOldFunction((DWORD*)((BYTE*)splicedFunctionAddress), (DWORD*)((BYTE*)oldFunction + 5));
|
||||||
|
CallJmpInstr* instr = (CallJmpInstr*)((BYTE*)splicedFunctionAddress);
|
||||||
|
instr->opcode = 0xe9;
|
||||||
|
instr->rel32 = (DWORD)hookFunction - (DWORD)splicedFunctionAddress - 5;
|
||||||
|
VirtualProtect((DWORD*)splicedFunctionAddress, 5, oldProtect, &oldProtect);
|
||||||
|
|
||||||
|
return (DWORD*)((BYTE*)oldFunction + 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL restore(void*& oldProc)
|
||||||
|
{
|
||||||
|
if (oldProc != 0 && *((BYTE*)(*(DWORD*)((BYTE*)oldProc - 5))) == 0xe9) {
|
||||||
|
void* proc = (DWORD*)(*(DWORD*)((BYTE*)oldProc - 5));
|
||||||
|
DWORD size = (BYTE)(*(DWORD*)((BYTE*)oldProc - 1));
|
||||||
|
DWORD oldProtect;
|
||||||
|
VirtualProtect(proc, size, PAGE_EXECUTE_READWRITE, &oldProtect);
|
||||||
|
CopyMemory(proc, oldProc, size);
|
||||||
|
recalculateRel32IfIsJump(proc, oldProc);
|
||||||
|
VirtualProtect(proc, size, oldProtect, &oldProtect);
|
||||||
|
free((DWORD*)((BYTE*)oldProc - 5));
|
||||||
|
oldProc = 0;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
5
L2BotDll/Common/apihook.h
Normal file
5
L2BotDll/Common/apihook.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
void* splice(void* splicedFunctionAddress, void* hookFunction);
|
||||||
|
BOOL restore(void*& oldProc);
|
33
L2BotDll/Events/AbnormalEffectChangedEvent.h
Normal file
33
L2BotDll/Events/AbnormalEffectChangedEvent.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class AbnormalEffectChangedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr const char* name = "abnormalEffectChanged";
|
||||||
|
|
||||||
|
const std::string GetName() const
|
||||||
|
{
|
||||||
|
return std::string(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<int32_t> GetSkillInfo() const
|
||||||
|
{
|
||||||
|
return m_SkillInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbnormalEffectChangedEvent(const std::vector<int32_t> skillInfo) :
|
||||||
|
m_SkillInfo(skillInfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
AbnormalEffectChangedEvent() = delete;
|
||||||
|
virtual ~AbnormalEffectChangedEvent() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::vector<int32_t> m_SkillInfo;
|
||||||
|
};
|
32
L2BotDll/Events/CreatureDiedEvent.h
Normal file
32
L2BotDll/Events/CreatureDiedEvent.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class CreatureDiedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr const char* name = "creatureDied";
|
||||||
|
|
||||||
|
const std::string GetName() const
|
||||||
|
{
|
||||||
|
return std::string(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t GetCreatureId() const
|
||||||
|
{
|
||||||
|
return m_CreatureId;
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatureDiedEvent(uint32_t creatureId) :
|
||||||
|
m_CreatureId(creatureId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatureDiedEvent() = delete;
|
||||||
|
virtual ~CreatureDiedEvent() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const uint32_t m_CreatureId;
|
||||||
|
};
|
12
L2BotDll/Events/Event.h
Normal file
12
L2BotDll/Events/Event.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const std::string GetName() const = 0;
|
||||||
|
|
||||||
|
Event() = default;
|
||||||
|
virtual ~Event() = default;
|
||||||
|
};
|
47
L2BotDll/Events/EventDispatcher.h
Normal file
47
L2BotDll/Events/EventDispatcher.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <functional>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <vector>
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class EventDispatcher
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Delegate = std::function<void(const Event&)>;
|
||||||
|
|
||||||
|
static EventDispatcher& GetInstance() {
|
||||||
|
static EventDispatcher instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dispatch(const Event& evt)
|
||||||
|
{
|
||||||
|
const auto& name = evt.GetName();
|
||||||
|
|
||||||
|
if (m_Handlers.find(name) == m_Handlers.end())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& handler : m_Handlers[name])
|
||||||
|
{
|
||||||
|
handler(evt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Subscribe(std::string eventName, Delegate handler)
|
||||||
|
{
|
||||||
|
m_Handlers[eventName].push_back(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
EventDispatcher() = default;
|
||||||
|
virtual ~EventDispatcher() = default;
|
||||||
|
EventDispatcher(const EventDispatcher&) = delete;
|
||||||
|
EventDispatcher& operator=(const EventDispatcher&) = delete;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unordered_map<std::string, std::vector<Delegate>> m_Handlers;
|
||||||
|
};
|
19
L2BotDll/Events/HeroCreatedEvent.h
Normal file
19
L2BotDll/Events/HeroCreatedEvent.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class HeroCreatedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr const char* name = "heroCreated";
|
||||||
|
|
||||||
|
const std::string GetName() const
|
||||||
|
{
|
||||||
|
return std::string(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
HeroCreatedEvent() = default;
|
||||||
|
virtual ~HeroCreatedEvent() = default;
|
||||||
|
};
|
17
L2BotDll/Events/HeroDeletedEvent.h
Normal file
17
L2BotDll/Events/HeroDeletedEvent.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class HeroDeletedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr const char* name = "heroDeleted";
|
||||||
|
|
||||||
|
const std::string GetName() const
|
||||||
|
{
|
||||||
|
return std::string(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
HeroDeletedEvent() = default;
|
||||||
|
virtual ~HeroDeletedEvent() = default;
|
||||||
|
};
|
32
L2BotDll/Events/SkillCancelledEvent.h
Normal file
32
L2BotDll/Events/SkillCancelledEvent.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class SkillCancelledEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr const char* name = "skillCancelled";
|
||||||
|
|
||||||
|
const std::string GetName() const
|
||||||
|
{
|
||||||
|
return std::string(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t GetInitiatorId() const
|
||||||
|
{
|
||||||
|
return m_InitiatorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkillCancelledEvent(const uint32_t initiatorId) :
|
||||||
|
m_InitiatorId(initiatorId)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SkillCancelledEvent() = delete;
|
||||||
|
virtual ~SkillCancelledEvent() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const uint32_t m_InitiatorId;
|
||||||
|
};
|
33
L2BotDll/Events/SkillCreatedEvent.h
Normal file
33
L2BotDll/Events/SkillCreatedEvent.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class SkillCreatedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr const char* name = "skillCreated";
|
||||||
|
|
||||||
|
const std::string GetName() const
|
||||||
|
{
|
||||||
|
return std::string(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<int32_t> GetSkillInfo() const
|
||||||
|
{
|
||||||
|
return m_SkillInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkillCreatedEvent(const std::vector<int32_t> skillInfo) :
|
||||||
|
m_SkillInfo(skillInfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SkillCreatedEvent() = delete;
|
||||||
|
virtual ~SkillCreatedEvent() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::vector<int32_t> m_SkillInfo;
|
||||||
|
};
|
33
L2BotDll/Events/SkillUsedEvent.h
Normal file
33
L2BotDll/Events/SkillUsedEvent.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <vector>
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class SkillUsedEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr const char* name = "skillUsed";
|
||||||
|
|
||||||
|
const std::string GetName() const
|
||||||
|
{
|
||||||
|
return std::string(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<int32_t> GetSkillInfo() const
|
||||||
|
{
|
||||||
|
return m_SkillInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkillUsedEvent(const std::vector<int32_t> skillInfo) :
|
||||||
|
m_SkillInfo(skillInfo)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SkillUsedEvent() = delete;
|
||||||
|
virtual ~SkillUsedEvent() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::vector<int32_t> m_SkillInfo;
|
||||||
|
};
|
18
L2BotDll/Events/SpoiledEvent.h
Normal file
18
L2BotDll/Events/SpoiledEvent.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include "Event.h"
|
||||||
|
|
||||||
|
class SpoiledEvent : public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr const char* name = "spoiled";
|
||||||
|
|
||||||
|
const std::string GetName() const
|
||||||
|
{
|
||||||
|
return std::string(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
SpoiledEvent() = default;
|
||||||
|
virtual ~SpoiledEvent() = default;
|
||||||
|
};
|
238
L2BotDll/L2BotDll.vcxproj
Normal file
238
L2BotDll/L2BotDll.vcxproj
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<VCProjectVersion>16.0</VCProjectVersion>
|
||||||
|
<Keyword>Win32Proj</Keyword>
|
||||||
|
<ProjectGuid>{f077b130-780f-4c72-af56-e98b104a2a7d}</ProjectGuid>
|
||||||
|
<RootNamespace>L2BotDll</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="Shared">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\bin\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\bin\</OutDir>
|
||||||
|
<IntDir>$(SolutionDir)$(Configuration)\$(ProjectName)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<LinkIncremental>true</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<LinkIncremental>false</LinkIncremental>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;L2BOTDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
<AdditionalIncludeDirectories>D:\Lineage 2 bot\Bot 2.0\L2Bot\InjectionLibrary;D:\Lineage 2 bot\Bot 2.0\L2Bot\L2BotCore;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;L2BOTDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
<LanguageStandard_C>stdc17</LanguageStandard_C>
|
||||||
|
<AdditionalIncludeDirectories>D:\Lineage 2 bot\Bot 2.0\L2Bot\InjectionLibrary;D:\Lineage 2 bot\Bot 2.0\L2Bot\L2BotCore;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>_DEBUG;L2BOTDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<SDLCheck>true</SDLCheck>
|
||||||
|
<PreprocessorDefinitions>NDEBUG;L2BOTDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
<ConformanceMode>true</ConformanceMode>
|
||||||
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
|
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<SubSystem>Windows</SubSystem>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableUAC>false</EnableUAC>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Common\apihook.h" />
|
||||||
|
<ClInclude Include="Common\Common.h" />
|
||||||
|
<ClInclude Include="Common\TimerMap.h" />
|
||||||
|
<ClInclude Include="Events\CreatureDiedEvent.h" />
|
||||||
|
<ClInclude Include="Events\Event.h" />
|
||||||
|
<ClInclude Include="Events\EventDispatcher.h" />
|
||||||
|
<ClInclude Include="Events\HeroCreatedEvent.h" />
|
||||||
|
<ClInclude Include="Events\HeroDeletedEvent.h" />
|
||||||
|
<ClInclude Include="Events\SkillCancelledEvent.h" />
|
||||||
|
<ClInclude Include="Events\SkillCreatedEvent.h" />
|
||||||
|
<ClInclude Include="Events\AbnormalEffectChangedEvent.h" />
|
||||||
|
<ClInclude Include="Events\SkillUsedEvent.h" />
|
||||||
|
<ClInclude Include="Events\SpoiledEvent.h" />
|
||||||
|
<ClInclude Include="Application.h" />
|
||||||
|
<ClInclude Include="Serializers\JsonSerializer.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\Repositories\SkillRepository.h" />
|
||||||
|
<ClInclude Include="Services\WorldHandler.h" />
|
||||||
|
<ClInclude Include="Versions\GameStructs\FNameInterface.h" />
|
||||||
|
<ClInclude Include="Versions\GameStructs\GameEngineInterface.h" />
|
||||||
|
<ClInclude Include="Versions\GameStructs\L2GameDataInterface.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\Factories\SkillFactory.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\GameEngineWrapper.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\L2GameDataWrapper.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\FName.h" />
|
||||||
|
<ClInclude Include="Transports\DebugViewTransport.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\Repositories\DropRepository.h" />
|
||||||
|
<ClInclude Include="framework.h" />
|
||||||
|
<ClInclude Include="Versions\GameStructs\FindObjectsTrait.h" />
|
||||||
|
<ClInclude Include="Versions\GameStructs\GameStructs.h" />
|
||||||
|
<ClInclude Include="Transports\NamedPipe.h" />
|
||||||
|
<ClInclude Include="Transports\NamedPipeTransport.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\Repositories\NPCRepository.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\Repositories\HeroRepository.h" />
|
||||||
|
<ClInclude Include="pch.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\Repositories\PlayerRepository.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\GameStructs.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\L2ParamStack.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\NetworkHandlerWrapper.h" />
|
||||||
|
<ClInclude Include="Versions\GameStructs\NetworkHandlerInterface.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\Factories\DropFactory.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\Factories\HeroFactory.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\AbstractFactory.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\Factories\NPCFactory.h" />
|
||||||
|
<ClInclude Include="Versions\Interlude\Factories\PlayerFactory.h" />
|
||||||
|
<ClInclude Include="Versions\VersionAbstractFactory.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="Common\apihook.cpp" />
|
||||||
|
<ClCompile Include="Common\Common.cpp" />
|
||||||
|
<ClCompile Include="dllmain.cpp" />
|
||||||
|
<ClCompile Include="pch.cpp">
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||||
|
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Versions\Interlude\GameStructs\GameEngineWrapper.cpp" />
|
||||||
|
<ClCompile Include="Versions\Interlude\GameStructs\L2GameDataWrapper.cpp" />
|
||||||
|
<ClCompile Include="Versions\Interlude\GameStructs\FName.cpp" />
|
||||||
|
<ClCompile Include="Versions\Interlude\GameStructs\L2ParamStack.cpp" />
|
||||||
|
<ClCompile Include="Versions\Interlude\GameStructs\NetworkHandlerWrapper.cpp" />
|
||||||
|
<ClCompile Include="Versions\VersionAbstractFactory.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\InjectionLibrary\InjectionLibrary.vcxproj">
|
||||||
|
<Project>{54fbe631-3f9b-458c-9db2-43a868cdb806}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\L2BotCore\L2BotCore.vcxproj">
|
||||||
|
<Project>{504a5403-ba08-46df-aa8a-b79993b56bca}</Project>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
186
L2BotDll/L2BotDll.vcxproj.filters
Normal file
186
L2BotDll/L2BotDll.vcxproj.filters
Normal file
@ -0,0 +1,186 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="Source Files">
|
||||||
|
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||||
|
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Header Files">
|
||||||
|
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||||
|
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="Resource Files">
|
||||||
|
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||||
|
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="framework.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="pch.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Common\apihook.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\GameStructs\GameStructs.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\NetworkHandlerWrapper.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\Repositories\HeroRepository.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\Repositories\NPCRepository.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\Repositories\DropRepository.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Transports\DebugViewTransport.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\Repositories\PlayerRepository.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Transports\NamedPipeTransport.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Transports\NamedPipe.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Common\Common.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\FName.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\L2GameDataWrapper.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\VersionAbstractFactory.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\Factories\DropFactory.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\Factories\HeroFactory.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\Factories\NPCFactory.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\Factories\PlayerFactory.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\AbstractFactory.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Events\Event.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Events\SpoiledEvent.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Events\EventDispatcher.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Events\CreatureDiedEvent.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\GameStructs\NetworkHandlerInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\GameStructs.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\GameStructs\FindObjectsTrait.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\GameStructs\L2GameDataInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\GameStructs\FNameInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Application.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Services\WorldHandler.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\Factories\SkillFactory.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\Repositories\SkillRepository.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\GameStructs\GameEngineInterface.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\GameEngineWrapper.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Versions\Interlude\GameStructs\L2ParamStack.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Events\SkillCreatedEvent.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Events\SkillUsedEvent.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Events\SkillCancelledEvent.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Common\TimerMap.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Events\HeroCreatedEvent.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Events\HeroDeletedEvent.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Events\AbnormalEffectChangedEvent.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Serializers\JsonSerializer.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="dllmain.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="pch.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Common\apihook.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Versions\Interlude\GameStructs\NetworkHandlerWrapper.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Common\Common.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Versions\Interlude\GameStructs\FName.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Versions\Interlude\GameStructs\L2GameDataWrapper.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Versions\VersionAbstractFactory.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Versions\Interlude\GameStructs\L2ParamStack.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Versions\Interlude\GameStructs\GameEngineWrapper.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
39
L2BotDll/Serializers/JsonSerializer.h
Normal file
39
L2BotDll/Serializers/JsonSerializer.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Domain/Serializers/SerializerInterface.h"
|
||||||
|
#include "Domain/Serializers/Node.h"
|
||||||
|
|
||||||
|
using namespace L2Bot::Domain;
|
||||||
|
|
||||||
|
class JsonSerializer : public Serializers::SerializerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const std::string Serialize(std::vector<Serializers::Node> nodes, const bool isArray = false) const override
|
||||||
|
{
|
||||||
|
std::string result = isArray ? "[" : "{";
|
||||||
|
|
||||||
|
for (auto it = nodes.begin(); it != nodes.end(); ++it)
|
||||||
|
{
|
||||||
|
if (!isArray)
|
||||||
|
{
|
||||||
|
result += "\"" + it->name + "\":";
|
||||||
|
}
|
||||||
|
if (it->isContainer)
|
||||||
|
{
|
||||||
|
result += Serialize(it->children, it->isArray);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result += "\"" + it->value + "\"";
|
||||||
|
}
|
||||||
|
if (std::next(it) != nodes.end())
|
||||||
|
{
|
||||||
|
result += ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result += isArray ? "]" : "}";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
168
L2BotDll/Services/WorldHandler.h
Normal file
168
L2BotDll/Services/WorldHandler.h
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <cstdint>
|
||||||
|
#include <thread>
|
||||||
|
#include <Windows.h>
|
||||||
|
#include "Domain/Services/DropService.h"
|
||||||
|
#include "Domain/Services/HeroService.h"
|
||||||
|
#include "Domain/Services/NPCService.h"
|
||||||
|
#include "Domain/Services/PlayerService.h"
|
||||||
|
#include "Domain/Services/SkillService.h"
|
||||||
|
#include "Domain/Serializers/SerializableStateContainer.h"
|
||||||
|
#include "Domain/Serializers/SerializerInterface.h"
|
||||||
|
#include "Domain/Repositories/DropRepositoryInterface.h"
|
||||||
|
#include "Domain/Repositories/SkillRepositoryInterface.h"
|
||||||
|
#include "Domain/Transports/TransportInterface.h"
|
||||||
|
|
||||||
|
using namespace L2Bot::Domain;
|
||||||
|
|
||||||
|
class WorldHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WorldHandler(
|
||||||
|
Repositories::HeroRepositoryInterface& heroRepository,
|
||||||
|
Repositories::DropRepositoryInterface& dropRepository,
|
||||||
|
Repositories::NPCRepositoryInterface& npcRepository,
|
||||||
|
Repositories::PlayerRepositoryInterface& playerRepository,
|
||||||
|
Repositories::SkillRepositoryInterface& skillRepository,
|
||||||
|
const Serializers::SerializerInterface& serializer,
|
||||||
|
Transports::TransportInterface& transport
|
||||||
|
) :
|
||||||
|
m_DropService(Services::DropService(dropRepository)),
|
||||||
|
m_HeroService(Services::HeroService(heroRepository)),
|
||||||
|
m_NPCService(Services::NPCService(npcRepository)),
|
||||||
|
m_PlayerService(Services::PlayerService(playerRepository)),
|
||||||
|
m_SkillService(Services::SkillService(skillRepository)),
|
||||||
|
m_Serializer(serializer),
|
||||||
|
m_Transport(transport)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
m_ConnectingThread = std::thread(&WorldHandler::Connect, this);
|
||||||
|
m_SendingThread = std::thread(&WorldHandler::Send, this);
|
||||||
|
m_ReceivingThread = std::thread(&WorldHandler::Receive, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stop()
|
||||||
|
{
|
||||||
|
m_Stopped = true;
|
||||||
|
if (m_ConnectingThread.joinable())
|
||||||
|
{
|
||||||
|
m_ConnectingThread.join();
|
||||||
|
}
|
||||||
|
if (m_SendingThread.joinable())
|
||||||
|
{
|
||||||
|
m_SendingThread.join();
|
||||||
|
}
|
||||||
|
if (m_ReceivingThread.joinable())
|
||||||
|
{
|
||||||
|
m_ReceivingThread.join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~WorldHandler()
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Send()
|
||||||
|
{
|
||||||
|
while (!m_Stopped)
|
||||||
|
{
|
||||||
|
const auto& data = GetData();
|
||||||
|
|
||||||
|
if (m_Transport.IsConnected())
|
||||||
|
{
|
||||||
|
for (const auto& item : data)
|
||||||
|
{
|
||||||
|
m_Transport.Send(
|
||||||
|
m_Serializer.Serialize({ item })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Receive()
|
||||||
|
{
|
||||||
|
while (!m_Stopped)
|
||||||
|
{
|
||||||
|
if (m_Transport.IsConnected())
|
||||||
|
{
|
||||||
|
const std::string& response = m_Transport.Receive();
|
||||||
|
if (response == "invalidate")
|
||||||
|
{
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Connect()
|
||||||
|
{
|
||||||
|
while (!m_Stopped)
|
||||||
|
{
|
||||||
|
if (!m_Transport.IsConnected())
|
||||||
|
{
|
||||||
|
m_Transport.Connect();
|
||||||
|
}
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<Serializers::Node> GetData()
|
||||||
|
{
|
||||||
|
std::vector<Serializers::Serializable*> items
|
||||||
|
{
|
||||||
|
new Serializers::SerializableStateContainer<Entities::Hero>(m_HeroService.GetObjects(), "hero"),
|
||||||
|
new Serializers::SerializableStateContainer<Entities::Drop>(m_DropService.GetObjects(), "drop"),
|
||||||
|
new Serializers::SerializableStateContainer<Entities::NPC>(m_NPCService.GetObjects(), "npc"),
|
||||||
|
new Serializers::SerializableStateContainer<Entities::Player>(m_PlayerService.GetObjects(), "player"),
|
||||||
|
new Serializers::SerializableStateContainer<ValueObjects::Skill>(m_SkillService.GetObjects(), "skill")
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Serializers::Node> result;
|
||||||
|
for (const auto& item : items)
|
||||||
|
{
|
||||||
|
for (const auto node : item->BuildSerializationNodes())
|
||||||
|
{
|
||||||
|
result.push_back(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& item : items)
|
||||||
|
{
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Invalidate()
|
||||||
|
{
|
||||||
|
m_HeroService.Invalidate();
|
||||||
|
m_DropService.Invalidate();
|
||||||
|
m_NPCService.Invalidate();
|
||||||
|
m_PlayerService.Invalidate();
|
||||||
|
m_SkillService.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Services::DropService m_DropService;
|
||||||
|
Services::HeroService m_HeroService;
|
||||||
|
Services::NPCService m_NPCService;
|
||||||
|
Services::PlayerService m_PlayerService;
|
||||||
|
Services::SkillService m_SkillService;
|
||||||
|
const Serializers::SerializerInterface& m_Serializer;
|
||||||
|
Transports::TransportInterface& m_Transport;
|
||||||
|
bool m_Stopped = false;
|
||||||
|
std::thread m_ConnectingThread;
|
||||||
|
std::thread m_SendingThread;
|
||||||
|
std::thread m_ReceivingThread;
|
||||||
|
};
|
34
L2BotDll/Transports/DebugViewTransport.h
Normal file
34
L2BotDll/Transports/DebugViewTransport.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Domain/Transports/TransportInterface.h"
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
using namespace L2Bot::Domain;
|
||||||
|
|
||||||
|
class DebugViewTransport : public Transports::TransportInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const bool Connect() override
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool IsConnected() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void Send(std::string data) override
|
||||||
|
{
|
||||||
|
OutputDebugStringA(data.c_str());
|
||||||
|
}
|
||||||
|
const std::string Receive() override
|
||||||
|
{
|
||||||
|
// delay imitation
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugViewTransport() = default;
|
||||||
|
virtual ~DebugViewTransport() = default;
|
||||||
|
};
|
193
L2BotDll/Transports/NamedPipe.h
Normal file
193
L2BotDll/Transports/NamedPipe.h
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <string>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#define BUFFER_SIZE 16384
|
||||||
|
|
||||||
|
class NamedPipe
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const bool Connect(const std::string& pipeName)
|
||||||
|
{
|
||||||
|
if (m_Pipe == NULL || m_PipeName != pipeName)
|
||||||
|
{
|
||||||
|
if (m_Pipe != NULL) {
|
||||||
|
DisconnectNamedPipe(m_Pipe);
|
||||||
|
CloseHandle(m_Pipe);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CreateOverlapped(m_ConntectingOverlapped);
|
||||||
|
CreateOverlapped(m_ReadingOverlapped);
|
||||||
|
CreateOverlapped(m_WritingOverlapped);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Pipe = CreateNamedPipeA(("\\\\.\\pipe\\" + pipeName).c_str(),
|
||||||
|
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
||||||
|
PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
||||||
|
PIPE_UNLIMITED_INSTANCES,
|
||||||
|
BUFFER_SIZE * sizeof(char),
|
||||||
|
BUFFER_SIZE * sizeof(char),
|
||||||
|
NMPWAIT_USE_DEFAULT_WAIT,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
if (m_Pipe == INVALID_HANDLE_VALUE)
|
||||||
|
{
|
||||||
|
OutputDebugStringA(std::to_string(GetLastError()).c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DisconnectNamedPipe(m_Pipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
TryToConnect();
|
||||||
|
|
||||||
|
WaitForMultipleObjects(1, &m_ConntectingOverlapped.hEvent, false, INFINITE);
|
||||||
|
|
||||||
|
DWORD ret;
|
||||||
|
m_Connected = GetOverlappedResult(m_Pipe, &m_ConntectingOverlapped, &ret, false);
|
||||||
|
|
||||||
|
m_PipeName = pipeName;
|
||||||
|
|
||||||
|
return m_Connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Send(const std::string& message)
|
||||||
|
{
|
||||||
|
if (!m_Connected)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD written;
|
||||||
|
const auto result = WriteFile(m_Pipe, message.c_str(), message.size() + 1, &written, &m_WritingOverlapped);
|
||||||
|
|
||||||
|
const auto lastError = GetLastError();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
if (lastError == ERROR_IO_PENDING)
|
||||||
|
{
|
||||||
|
WaitForMultipleObjects(1, &m_WritingOverlapped.hEvent, false, INFINITE);
|
||||||
|
DWORD ret;
|
||||||
|
const auto overlappedResult = GetOverlappedResult(m_Pipe, &m_WritingOverlapped, &ret, false);
|
||||||
|
if (!overlappedResult)
|
||||||
|
{
|
||||||
|
m_Connected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Connected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string Receive()
|
||||||
|
{
|
||||||
|
if (!m_Connected)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD dwRead;
|
||||||
|
char* buffer = new char[BUFFER_SIZE];
|
||||||
|
const auto result = ReadFile(m_Pipe, buffer, BUFFER_SIZE * sizeof(char), &dwRead, &m_ReadingOverlapped);
|
||||||
|
|
||||||
|
const auto lastError = GetLastError();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
if (lastError == ERROR_IO_PENDING)
|
||||||
|
{
|
||||||
|
WaitForMultipleObjects(1, &m_ReadingOverlapped.hEvent, false, INFINITE);
|
||||||
|
DWORD ret;
|
||||||
|
const auto overlappedResult = GetOverlappedResult(m_Pipe, &m_ReadingOverlapped, &ret, false);
|
||||||
|
if (!overlappedResult)
|
||||||
|
{
|
||||||
|
delete[] buffer;
|
||||||
|
m_Connected = false;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete[] buffer;
|
||||||
|
m_Connected = false;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message = std::string(buffer);
|
||||||
|
delete[] buffer;
|
||||||
|
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool IsConnected() const
|
||||||
|
{
|
||||||
|
return m_Connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~NamedPipe()
|
||||||
|
{
|
||||||
|
if (m_Pipe != NULL)
|
||||||
|
{
|
||||||
|
CloseHandle(m_Pipe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NamedPipe() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void TryToConnect()
|
||||||
|
{
|
||||||
|
const bool connected = ConnectNamedPipe(m_Pipe, &m_ConntectingOverlapped) == 0;
|
||||||
|
if (!connected)
|
||||||
|
{
|
||||||
|
OutputDebugStringA(std::to_string(GetLastError()).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (GetLastError())
|
||||||
|
{
|
||||||
|
// The overlapped connection in progress.
|
||||||
|
case ERROR_IO_PENDING:
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Client is already connected, so signal an event.
|
||||||
|
|
||||||
|
case ERROR_PIPE_CONNECTED:
|
||||||
|
if (SetEvent(m_ConntectingOverlapped.hEvent))
|
||||||
|
break;
|
||||||
|
|
||||||
|
// If an error occurs during the connect operation...
|
||||||
|
default:
|
||||||
|
OutputDebugStringA(std::to_string(GetLastError()).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateOverlapped(OVERLAPPED& overlapped)
|
||||||
|
{
|
||||||
|
if (overlapped.hEvent == NULL)
|
||||||
|
{
|
||||||
|
overlapped.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
|
||||||
|
if (overlapped.hEvent == NULL)
|
||||||
|
{
|
||||||
|
OutputDebugStringA(std::to_string(GetLastError()).c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
overlapped.Offset = 0;
|
||||||
|
overlapped.OffsetHigh = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_PipeName = "";
|
||||||
|
HANDLE m_Pipe = NULL;
|
||||||
|
bool m_Connected = false;
|
||||||
|
OVERLAPPED m_ConntectingOverlapped = OVERLAPPED();
|
||||||
|
OVERLAPPED m_ReadingOverlapped = OVERLAPPED();
|
||||||
|
OVERLAPPED m_WritingOverlapped = OVERLAPPED();
|
||||||
|
};
|
76
L2BotDll/Transports/NamedPipeTransport.h
Normal file
76
L2BotDll/Transports/NamedPipeTransport.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Domain/Transports/TransportInterface.h"
|
||||||
|
#include <Windows.h>
|
||||||
|
#include "NamedPipe.h"
|
||||||
|
#include "../Common/Common.h"
|
||||||
|
|
||||||
|
using namespace L2Bot::Domain;
|
||||||
|
|
||||||
|
class NamedPipeTransport : public Transports::TransportInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
const bool Connect() override
|
||||||
|
{
|
||||||
|
OutputDebugStringA(m_PipeName.c_str());
|
||||||
|
if (!m_ConnectionPipe.Connect(m_PipeName))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
OutputDebugStringA("Client connected to connection pipe");
|
||||||
|
|
||||||
|
const std::string mainPipeName = GenerateUUID();
|
||||||
|
|
||||||
|
m_ConnectionPipe.Send("\\\\.\\pipe\\" + mainPipeName);
|
||||||
|
|
||||||
|
OutputDebugStringA("Name of main pipe sended");
|
||||||
|
|
||||||
|
if (!m_Pipe.Connect(mainPipeName))
|
||||||
|
{
|
||||||
|
OutputDebugStringA(std::to_string(GetLastError()).c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
OutputDebugStringA("Client connected to main pipe");
|
||||||
|
|
||||||
|
m_Pipe.Send("Hello!");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const void Send(std::string data) override
|
||||||
|
{
|
||||||
|
if (!m_Pipe.IsConnected())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Pipe.Send(data);
|
||||||
|
}
|
||||||
|
const std::string Receive() override
|
||||||
|
{
|
||||||
|
if (!m_Pipe.IsConnected())
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_Pipe.Receive();
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool IsConnected() const override
|
||||||
|
{
|
||||||
|
return m_Pipe.IsConnected();
|
||||||
|
}
|
||||||
|
|
||||||
|
NamedPipeTransport(const std::string& pipeName) :
|
||||||
|
m_PipeName(pipeName)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NamedPipeTransport() = delete;
|
||||||
|
virtual ~NamedPipeTransport() = default;
|
||||||
|
|
||||||
|
private:
|
||||||
|
NamedPipe m_ConnectionPipe;
|
||||||
|
NamedPipe m_Pipe;
|
||||||
|
std::string m_PipeName = "";
|
||||||
|
};
|
12
L2BotDll/Versions/GameStructs/FNameInterface.h
Normal file
12
L2BotDll/Versions/GameStructs/FNameInterface.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GameStructs.h"
|
||||||
|
|
||||||
|
class FNameInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FNameInterface() = default;
|
||||||
|
virtual ~FNameInterface() = default;
|
||||||
|
|
||||||
|
virtual void Init(HMODULE hModule) = 0;
|
||||||
|
};
|
31
L2BotDll/Versions/GameStructs/FindObjectsTrait.h
Normal file
31
L2BotDll/Versions/GameStructs/FindObjectsTrait.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <math.h>
|
||||||
|
#include <functional>
|
||||||
|
#include "GameStructs.h"
|
||||||
|
|
||||||
|
class FindObjectsTrait
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template <typename T>
|
||||||
|
std::map<uint32_t, T> GetAllObjects(float_t radius, std::function<const T(float_t, int32_t)> getNextObject) const
|
||||||
|
{
|
||||||
|
std::map<uint32_t, T> result;
|
||||||
|
|
||||||
|
auto object = getNextObject(radius, -1);
|
||||||
|
|
||||||
|
while (object)
|
||||||
|
{
|
||||||
|
if (result.find(object->objectId) != result.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.emplace(object->objectId, object);
|
||||||
|
}
|
||||||
|
object = getNextObject(radius, object->objectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
};
|
13
L2BotDll/Versions/GameStructs/GameEngineInterface.h
Normal file
13
L2BotDll/Versions/GameStructs/GameEngineInterface.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
class GameEngineInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GameEngineInterface() = default;
|
||||||
|
virtual ~GameEngineInterface() = default;
|
||||||
|
|
||||||
|
virtual void Init(HMODULE hModule) = 0;
|
||||||
|
virtual void Restore() = 0;
|
||||||
|
};
|
184
L2BotDll/Versions/GameStructs/GameStructs.h
Normal file
184
L2BotDll/Versions/GameStructs/GameStructs.h
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
namespace L2
|
||||||
|
{
|
||||||
|
enum class UserType : int32_t
|
||||||
|
{
|
||||||
|
NPC = 1,
|
||||||
|
USER = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class Race : int32_t
|
||||||
|
{
|
||||||
|
DARK_ELF = 2,
|
||||||
|
DWARF = 4,
|
||||||
|
ELF = 1,
|
||||||
|
HUMAN = 0,
|
||||||
|
ORC = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class Gender : int32_t
|
||||||
|
{
|
||||||
|
FEMALE = 1,
|
||||||
|
MALE = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ItemSlot : int32_t
|
||||||
|
{
|
||||||
|
BABYPET = 4194304,
|
||||||
|
BACK = 8192,
|
||||||
|
CHEST = 1024,
|
||||||
|
DHAIR = 524288,
|
||||||
|
FACE = 262144,
|
||||||
|
FEET = 4096,
|
||||||
|
FULL_ARMOR = 32768,
|
||||||
|
GLOVES = 512,
|
||||||
|
HAIR = 65536,
|
||||||
|
HATCHLING = 1048576,
|
||||||
|
HEAD = 64,
|
||||||
|
L_EAR = 4,
|
||||||
|
L_FINGER = 32,
|
||||||
|
L_HAND = 256,
|
||||||
|
LEGS = 2048,
|
||||||
|
LR_HAND = 16384,
|
||||||
|
NECK = 8,
|
||||||
|
NONE = 0,
|
||||||
|
R_EAR = 2,
|
||||||
|
R_FINGER = 16,
|
||||||
|
LoR_EAR = L_EAR | R_EAR,
|
||||||
|
LoR_FINGER = L_FINGER | R_FINGER,
|
||||||
|
R_HAND = 128,
|
||||||
|
STRIDER = 2097152,
|
||||||
|
UNDERWEAR = 1,
|
||||||
|
WOLF = 131072
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ItemDataType : int32_t
|
||||||
|
{
|
||||||
|
ARMOR = 1,
|
||||||
|
ETC = 2,
|
||||||
|
WEAPON = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ItemType2 : int16_t
|
||||||
|
{
|
||||||
|
ACCESSORY = 2,
|
||||||
|
MONEY = 4,
|
||||||
|
OTHER = 5,
|
||||||
|
PET_BABY = 9,
|
||||||
|
PET_HATCHLING = 7,
|
||||||
|
PET_STRIDER = 8,
|
||||||
|
PET_WOLF = 6,
|
||||||
|
QUEST = 3,
|
||||||
|
SHIELD_ARMOR = 1,
|
||||||
|
WEAPON = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class CrystalType : int32_t
|
||||||
|
{
|
||||||
|
A = 4,
|
||||||
|
B = 3,
|
||||||
|
C = 2,
|
||||||
|
D = 1,
|
||||||
|
NG = 0,
|
||||||
|
S = 5,
|
||||||
|
NONE = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class WeaponType : int32_t
|
||||||
|
{
|
||||||
|
BLUNT = 2,
|
||||||
|
BOW = 6,
|
||||||
|
DAGGER = 3,
|
||||||
|
DUALSWORD = 8,
|
||||||
|
ETC = 7,
|
||||||
|
FISHING_ROD = 10,
|
||||||
|
FIST = 5,
|
||||||
|
PET = 9,
|
||||||
|
POLE = 4,
|
||||||
|
SHIELD = 0,
|
||||||
|
SWORD = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ArmorType : int32_t
|
||||||
|
{
|
||||||
|
NONE = 0,
|
||||||
|
HEAVY = 2,
|
||||||
|
LIGHT = 1,
|
||||||
|
ROBE = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
class UserWear
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
char pad_0000[4]; //0x0000
|
||||||
|
int32_t leftEarring; //0x0004
|
||||||
|
int32_t rightEarring; //0x0008
|
||||||
|
int32_t neclace; //0x000C
|
||||||
|
int32_t leftRing; //0x0010
|
||||||
|
int32_t rightRing; //0x0014
|
||||||
|
int32_t helmet; //0x0018
|
||||||
|
int32_t weapon; //0x001C
|
||||||
|
int32_t shield; //0x0020
|
||||||
|
int32_t gloves; //0x0024
|
||||||
|
int32_t breastplate; //0x0028
|
||||||
|
int32_t gaiters; //0x002C
|
||||||
|
int32_t boots; //0x0030
|
||||||
|
char pad_0034[64]; //0x0034
|
||||||
|
}; //Size: 0x0074
|
||||||
|
|
||||||
|
class FColor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint8_t r; //0x0000
|
||||||
|
uint8_t g; //0x0001
|
||||||
|
uint8_t b; //0x0002
|
||||||
|
uint8_t a; //0x0003
|
||||||
|
}; //Size: 0x0004
|
||||||
|
|
||||||
|
class FVector
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
float x = 0; //0x0000
|
||||||
|
float y = 0; //0x0004
|
||||||
|
float z = 0; //0x0008
|
||||||
|
}; //Size: 0x000C
|
||||||
|
|
||||||
|
class FRotator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int32_t Pitch; //0x0000
|
||||||
|
int32_t Yaw; //0x0004
|
||||||
|
int32_t Roll; //0x0008
|
||||||
|
}; //Size: 0x000C
|
||||||
|
|
||||||
|
#pragma pack(push, 1)
|
||||||
|
struct NetworkPacket
|
||||||
|
{
|
||||||
|
unsigned char id, _padding1, exid, _padding2;
|
||||||
|
unsigned short size, _padding3;
|
||||||
|
unsigned char* data;
|
||||||
|
};
|
||||||
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
struct SystemMessagePacket : NetworkPacket
|
||||||
|
{
|
||||||
|
enum class Type
|
||||||
|
{
|
||||||
|
ALREADY_SPOILED = 357,
|
||||||
|
SPOIL_SUCCESS = 612,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint32_t GetMessageId() const
|
||||||
|
{
|
||||||
|
return ((uint32_t*)data)[0];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class NetworkPacketId
|
||||||
|
{
|
||||||
|
SYSTEM_MESSAGE = 0x64
|
||||||
|
};
|
||||||
|
}
|
13
L2BotDll/Versions/GameStructs/L2GameDataInterface.h
Normal file
13
L2BotDll/Versions/GameStructs/L2GameDataInterface.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GameStructs.h"
|
||||||
|
|
||||||
|
class L2GameDataInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
L2GameDataInterface() = default;
|
||||||
|
virtual ~L2GameDataInterface() = default;
|
||||||
|
|
||||||
|
virtual void Init(HMODULE hModule) = 0;
|
||||||
|
virtual void Restore() = 0;
|
||||||
|
};
|
13
L2BotDll/Versions/GameStructs/NetworkHandlerInterface.h
Normal file
13
L2BotDll/Versions/GameStructs/NetworkHandlerInterface.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
class NetworkHandlerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NetworkHandlerInterface() = default;
|
||||||
|
virtual ~NetworkHandlerInterface() = default;
|
||||||
|
|
||||||
|
virtual void Init(HMODULE hModule) = 0;
|
||||||
|
virtual void Restore() = 0;
|
||||||
|
};
|
93
L2BotDll/Versions/Interlude/AbstractFactory.h
Normal file
93
L2BotDll/Versions/Interlude/AbstractFactory.h
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../VersionAbstractFactory.h"
|
||||||
|
#include "Factories/HeroFactory.h"
|
||||||
|
#include "Factories/DropFactory.h"
|
||||||
|
#include "Factories/NPCFactory.h"
|
||||||
|
#include "Factories/PlayerFactory.h"
|
||||||
|
#include "Factories/SkillFactory.h"
|
||||||
|
#include "Repositories/HeroRepository.h"
|
||||||
|
#include "Repositories/DropRepository.h"
|
||||||
|
#include "Repositories/NPCRepository.h"
|
||||||
|
#include "Repositories/PlayerRepository.h"
|
||||||
|
#include "Repositories/SkillRepository.h"
|
||||||
|
#include "GameStructs/NetworkHandlerWrapper.h"
|
||||||
|
#include "GameStructs/GameEngineWrapper.h"
|
||||||
|
#include "GameStructs/L2GameDataWrapper.h"
|
||||||
|
#include "GameStructs/FName.h"
|
||||||
|
|
||||||
|
namespace Interlude
|
||||||
|
{
|
||||||
|
class AbstractFactory : public VersionAbstractFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AbstractFactory(const uint16_t radius) :
|
||||||
|
m_Radius(radius)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
AbstractFactory() = delete;
|
||||||
|
virtual ~AbstractFactory() = default;
|
||||||
|
|
||||||
|
HeroRepository& GetHeroRepository() const override
|
||||||
|
{
|
||||||
|
static auto factory = HeroFactory();
|
||||||
|
static auto result = HeroRepository(
|
||||||
|
GetNetworkHandler(),
|
||||||
|
factory
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
DropRepository& GetDropRepository() const override
|
||||||
|
{
|
||||||
|
static auto factory = DropFactory(GetL2GameData(), GetFName());
|
||||||
|
static auto result = DropRepository(
|
||||||
|
GetNetworkHandler(),
|
||||||
|
factory,
|
||||||
|
m_Radius
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
NPCRepository& GetNPCRepository() const override
|
||||||
|
{
|
||||||
|
static auto factory = NPCFactory();
|
||||||
|
static auto result = NPCRepository(GetNetworkHandler(), factory, m_Radius);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
PlayerRepository& GetPlayerRepository() const override
|
||||||
|
{
|
||||||
|
static auto factory = PlayerFactory();
|
||||||
|
static auto result = PlayerRepository(GetNetworkHandler(), factory, m_Radius);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
SkillRepository& GetSkillRepository() const override
|
||||||
|
{
|
||||||
|
static auto factory = SkillFactory(GetL2GameData(), GetFName());
|
||||||
|
static auto result = SkillRepository(GetNetworkHandler(), factory);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
NetworkHandlerWrapper& GetNetworkHandler() const override
|
||||||
|
{
|
||||||
|
static NetworkHandlerWrapper result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
GameEngineWrapper& GetGameEngine() const override
|
||||||
|
{
|
||||||
|
static GameEngineWrapper result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
L2GameDataWrapper& GetL2GameData() const override
|
||||||
|
{
|
||||||
|
static L2GameDataWrapper result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
FName& GetFName() const override
|
||||||
|
{
|
||||||
|
static FName result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const uint16_t m_Radius;
|
||||||
|
};
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user