mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Zmiany do Programming challenge.
This commit is contained in:
parent
5d4cfc0d0f
commit
bdd66b6537
@ -92,6 +92,7 @@
|
|||||||
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||||
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
|
||||||
|
<MinimalRebuild>false</MinimalRebuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
6
Odpalarka/Makefile.am
Normal file
6
Odpalarka/Makefile.am
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
bin_PROGRAMS = odpalarka
|
||||||
|
|
||||||
|
odpalarka_LDADD = $(top_builddir)/lib/libvcmi.la
|
||||||
|
odpalarka_CXXFLAGS = @SDL_CXXFLAGS@
|
||||||
|
odpalarka_LDFLAGS = -L$(top_builddir)/lib
|
||||||
|
odpalarka_SOURCES = main.cpp
|
134
Odpalarka/Odpalarka.vcxproj
Normal file
134
Odpalarka/Odpalarka.vcxproj
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{27B69211-D138-4142-BBC9-40F5DEA39067}</ProjectGuid>
|
||||||
|
<RootNamespace>Odpalarka</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</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" />
|
||||||
|
<Import Project="..\VCMI_global.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="..\VCMI_global.props" />
|
||||||
|
</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" />
|
||||||
|
<Import Project="..\VCMI_global.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="..\VCMI_global.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)</OutDir>
|
||||||
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<OutDir>$(SolutionDir)</OutDir>
|
||||||
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\bin\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(SolutionDir)$(Configuration)\bin\</OutDir>
|
||||||
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
14
Odpalarka/main.cpp
Normal file
14
Odpalarka/main.cpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include "../global.h"
|
||||||
|
#include <boost/thread.hpp>
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
boost::thread t(boost::bind(std::system, "VCMI_server.exe b1.json StupidAI StupidAI"));
|
||||||
|
boost::thread tt(boost::bind(std::system, "VCMI_BattleAiHost.exe"));
|
||||||
|
boost::thread ttt(boost::bind(std::system, "VCMI_BattleAiHost.exe"));
|
||||||
|
boost::thread tttt(boost::bind(std::system, "VCMI_BattleAiHost.exe"));
|
||||||
|
boost::this_thread::sleep(boost::posix_time::seconds(5));
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
6
VCMI_BattleAiHost/Makefile.am
Normal file
6
VCMI_BattleAiHost/Makefile.am
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
bin_PROGRAMS = vcmirunner
|
||||||
|
|
||||||
|
vcmirunner_LDADD = $(top_builddir)/lib/libvcmi.la
|
||||||
|
vcmirunner_CXXFLAGS = @SDL_CXXFLAGS@
|
||||||
|
vcmirunner_LDFLAGS = -L$(top_builddir)/lib
|
||||||
|
vcmirunner_SOURCES = main.cpp
|
140
VCMI_BattleAiHost/VCMI_BattleAiHost.vcxproj
Normal file
140
VCMI_BattleAiHost/VCMI_BattleAiHost.vcxproj
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{6A72AA10-D8CC-4685-A076-368CA64CA7C6}</ProjectGuid>
|
||||||
|
<RootNamespace>VCMI_BattleAiHost</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
<CLRSupport>false</CLRSupport>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</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" />
|
||||||
|
<Import Project="..\VCMI_global.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="..\VCMI_global.props" />
|
||||||
|
</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" />
|
||||||
|
<Import Project="..\VCMI_global.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
<Import Project="..\VCMI_global.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)</OutDir>
|
||||||
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(SolutionDir)</OutDir>
|
||||||
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<OutDir>$(SolutionDir)</OutDir>
|
||||||
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(SolutionDir)</OutDir>
|
||||||
|
<IntDir>$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalLibraryDirectories>$(OutDir);</AdditionalLibraryDirectories>
|
||||||
|
<AdditionalDependencies>VCMI_lib.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>VCMI_lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>VCMI_lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level3</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>VCMI_lib.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
82
VCMI_BattleAiHost/main.cpp
Normal file
82
VCMI_BattleAiHost/main.cpp
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#include "../global.h"
|
||||||
|
#include "../lib/Connection.h"
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
#include <boost/thread.hpp>
|
||||||
|
#include <fstream>
|
||||||
|
#include "../StartInfo.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <Windows.h>
|
||||||
|
#else
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#include "../lib/CGameState.h"
|
||||||
|
#include "../CCallback.h"
|
||||||
|
#include "../lib/CGameInterface.h"
|
||||||
|
#include <boost/format.hpp>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace boost;
|
||||||
|
|
||||||
|
std::string NAME = NAME_VER + std::string(" DLL runner");
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
int pid = -1;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
pid = GetCurrentProcessId();
|
||||||
|
#else
|
||||||
|
pid = getpid();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
logfile = new std::ofstream(("VCMI_Server_log_" + boost::lexical_cast<std::string>(pid) + ".txt").c_str());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
string host = "127.0.0.1";
|
||||||
|
string port = "3030";
|
||||||
|
|
||||||
|
CConnection *serv = NULL;
|
||||||
|
while(!serv)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tlog0 << "Establishing connection...\n";
|
||||||
|
serv = new CConnection(host, port, "DLL host");
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
tlog1 << "\nCannot establish connection! Retrying within 2 seconds" << std::endl;
|
||||||
|
boost::this_thread::sleep(boost::posix_time::seconds(2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui8 color;
|
||||||
|
StartInfo si;
|
||||||
|
string battleAIName;
|
||||||
|
*serv >> si >> battleAIName >> color;
|
||||||
|
assert(si.mode == StartInfo::DUEL);
|
||||||
|
tlog0 << format("Server wants us to run %s in battle %s as side %d") % battleAIName % si.mapname % color;
|
||||||
|
|
||||||
|
|
||||||
|
CGameState *gs = new CGameState();
|
||||||
|
gs->init(&si, 0, 0);
|
||||||
|
|
||||||
|
|
||||||
|
CBattleCallback * cbc = new CBattleCallback(gs, color, this);
|
||||||
|
CBattleGameInterface *ai = CDynLibHandler::getNewBattleAI(battleAIName);
|
||||||
|
ai->init(cbc);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(std::exception &e)
|
||||||
|
{
|
||||||
|
tlog1 << "Encountered exception: " << e.what() << std::endl;
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
tlog1 << "Encountered unknown exception!" << std::endl;
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||||
# Visual C++ Express 2010
|
# Visual Studio 2010
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VCMI_client", "client\VCMI_client.vcxproj", "{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VCMI_client", "client\VCMI_client.vcxproj", "{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VCMI_lib", "lib\VCMI_lib.vcxproj", "{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VCMI_lib", "lib\VCMI_lib.vcxproj", "{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}"
|
||||||
@ -14,7 +14,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StupidAI", "AI\StupidAI\Stu
|
|||||||
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F} = {B952FFC5-3039-4DE1-9F08-90ACDA483D8F}
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F} = {B952FFC5-3039-4DE1-9F08-90ACDA483D8F}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ERM", "Scripting\ERM\ERM.vcxproj", "{8F202F43-106D-4F63-AD9D-B1D43E803E8C}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VCMI_BattleAiHost", "VCMI_BattleAiHost\VCMI_BattleAiHost.vcxproj", "{6A72AA10-D8CC-4685-A076-368CA64CA7C6}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F} = {B952FFC5-3039-4DE1-9F08-90ACDA483D8F}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Odpalarka", "Odpalarka\Odpalarka.vcxproj", "{27B69211-D138-4142-BBC9-40F5DEA39067}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F} = {B952FFC5-3039-4DE1-9F08-90ACDA483D8F}
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F} = {B952FFC5-3039-4DE1-9F08-90ACDA483D8F}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
@ -25,6 +30,8 @@ Global
|
|||||||
Debug|x64 = Debug|x64
|
Debug|x64 = Debug|x64
|
||||||
RD|Win32 = RD|Win32
|
RD|Win32 = RD|Win32
|
||||||
RD|x64 = RD|x64
|
RD|x64 = RD|x64
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
Release|x64 = Release|x64
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.Debug|Win32.ActiveCfg = Debug|Win32
|
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
@ -35,6 +42,9 @@ Global
|
|||||||
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.RD|Win32.Build.0 = RD|Win32
|
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.RD|Win32.Build.0 = RD|Win32
|
||||||
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.RD|x64.ActiveCfg = RD|x64
|
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.RD|x64.ActiveCfg = RD|x64
|
||||||
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.RD|x64.Build.0 = RD|x64
|
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.RD|x64.Build.0 = RD|x64
|
||||||
|
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.Release|Win32.ActiveCfg = RD|x64
|
||||||
|
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.Release|x64.ActiveCfg = RD|x64
|
||||||
|
{8355EBA8-65C2-44A4-BC2D-78053E1BF2D6}.Release|x64.Build.0 = RD|x64
|
||||||
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.Debug|Win32.ActiveCfg = Debug|Win32
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.Debug|Win32.Build.0 = Debug|Win32
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.Debug|x64.ActiveCfg = Debug|x64
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
@ -43,6 +53,9 @@ Global
|
|||||||
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.RD|Win32.Build.0 = RD|Win32
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.RD|Win32.Build.0 = RD|Win32
|
||||||
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.RD|x64.ActiveCfg = RD|x64
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.RD|x64.ActiveCfg = RD|x64
|
||||||
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.RD|x64.Build.0 = RD|x64
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.RD|x64.Build.0 = RD|x64
|
||||||
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.Release|Win32.ActiveCfg = RD|x64
|
||||||
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.Release|x64.ActiveCfg = RD|x64
|
||||||
|
{B952FFC5-3039-4DE1-9F08-90ACDA483D8F}.Release|x64.Build.0 = RD|x64
|
||||||
{8AF697C3-465E-4910-B31B-576A9ECDB309}.Debug|Win32.ActiveCfg = Debug|Win32
|
{8AF697C3-465E-4910-B31B-576A9ECDB309}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{8AF697C3-465E-4910-B31B-576A9ECDB309}.Debug|Win32.Build.0 = Debug|Win32
|
{8AF697C3-465E-4910-B31B-576A9ECDB309}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{8AF697C3-465E-4910-B31B-576A9ECDB309}.Debug|x64.ActiveCfg = Debug|x64
|
{8AF697C3-465E-4910-B31B-576A9ECDB309}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
@ -51,6 +64,9 @@ Global
|
|||||||
{8AF697C3-465E-4910-B31B-576A9ECDB309}.RD|Win32.Build.0 = RD|Win32
|
{8AF697C3-465E-4910-B31B-576A9ECDB309}.RD|Win32.Build.0 = RD|Win32
|
||||||
{8AF697C3-465E-4910-B31B-576A9ECDB309}.RD|x64.ActiveCfg = RD|x64
|
{8AF697C3-465E-4910-B31B-576A9ECDB309}.RD|x64.ActiveCfg = RD|x64
|
||||||
{8AF697C3-465E-4910-B31B-576A9ECDB309}.RD|x64.Build.0 = RD|x64
|
{8AF697C3-465E-4910-B31B-576A9ECDB309}.RD|x64.Build.0 = RD|x64
|
||||||
|
{8AF697C3-465E-4910-B31B-576A9ECDB309}.Release|Win32.ActiveCfg = RD|x64
|
||||||
|
{8AF697C3-465E-4910-B31B-576A9ECDB309}.Release|x64.ActiveCfg = RD|x64
|
||||||
|
{8AF697C3-465E-4910-B31B-576A9ECDB309}.Release|x64.Build.0 = RD|x64
|
||||||
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.Debug|Win32.ActiveCfg = Debug|Win32
|
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.Debug|Win32.Build.0 = Debug|Win32
|
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.Debug|x64.ActiveCfg = Debug|x64
|
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
@ -59,6 +75,9 @@ Global
|
|||||||
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.RD|Win32.Build.0 = RD|Win32
|
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.RD|Win32.Build.0 = RD|Win32
|
||||||
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.RD|x64.ActiveCfg = RD|x64
|
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.RD|x64.ActiveCfg = RD|x64
|
||||||
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.RD|x64.Build.0 = RD|x64
|
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.RD|x64.Build.0 = RD|x64
|
||||||
|
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.Release|Win32.ActiveCfg = RD|x64
|
||||||
|
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.Release|x64.ActiveCfg = RD|x64
|
||||||
|
{B6A14ED9-E7C1-411B-A596-2FE90B3145B4}.Release|x64.Build.0 = RD|x64
|
||||||
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.Debug|Win32.ActiveCfg = Debug|Win32
|
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.Debug|Win32.Build.0 = Debug|Win32
|
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.Debug|x64.ActiveCfg = Debug|x64
|
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
@ -67,14 +86,27 @@ Global
|
|||||||
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.RD|Win32.Build.0 = RD|Win32
|
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.RD|Win32.Build.0 = RD|Win32
|
||||||
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.RD|x64.ActiveCfg = RD|x64
|
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.RD|x64.ActiveCfg = RD|x64
|
||||||
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.RD|x64.Build.0 = RD|x64
|
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.RD|x64.Build.0 = RD|x64
|
||||||
{8F202F43-106D-4F63-AD9D-B1D43E803E8C}.Debug|Win32.ActiveCfg = Debug|Win32
|
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.Release|Win32.ActiveCfg = RD|x64
|
||||||
{8F202F43-106D-4F63-AD9D-B1D43E803E8C}.Debug|Win32.Build.0 = Debug|Win32
|
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.Release|x64.ActiveCfg = RD|x64
|
||||||
{8F202F43-106D-4F63-AD9D-B1D43E803E8C}.Debug|x64.ActiveCfg = Debug|x64
|
{15DABC90-234A-4B6B-9EEB-777C4768B82B}.Release|x64.Build.0 = RD|x64
|
||||||
{8F202F43-106D-4F63-AD9D-B1D43E803E8C}.Debug|x64.Build.0 = Debug|x64
|
{6A72AA10-D8CC-4685-A076-368CA64CA7C6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
{8F202F43-106D-4F63-AD9D-B1D43E803E8C}.RD|Win32.ActiveCfg = RD|Win32
|
{6A72AA10-D8CC-4685-A076-368CA64CA7C6}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
{8F202F43-106D-4F63-AD9D-B1D43E803E8C}.RD|Win32.Build.0 = RD|Win32
|
{6A72AA10-D8CC-4685-A076-368CA64CA7C6}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{8F202F43-106D-4F63-AD9D-B1D43E803E8C}.RD|x64.ActiveCfg = RD|x64
|
{6A72AA10-D8CC-4685-A076-368CA64CA7C6}.RD|Win32.ActiveCfg = Release|Win32
|
||||||
{8F202F43-106D-4F63-AD9D-B1D43E803E8C}.RD|x64.Build.0 = RD|x64
|
{6A72AA10-D8CC-4685-A076-368CA64CA7C6}.RD|Win32.Build.0 = Release|Win32
|
||||||
|
{6A72AA10-D8CC-4685-A076-368CA64CA7C6}.RD|x64.ActiveCfg = Release|Win32
|
||||||
|
{6A72AA10-D8CC-4685-A076-368CA64CA7C6}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{6A72AA10-D8CC-4685-A076-368CA64CA7C6}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{6A72AA10-D8CC-4685-A076-368CA64CA7C6}.Release|x64.ActiveCfg = Release|Win32
|
||||||
|
{27B69211-D138-4142-BBC9-40F5DEA39067}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{27B69211-D138-4142-BBC9-40F5DEA39067}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{27B69211-D138-4142-BBC9-40F5DEA39067}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{27B69211-D138-4142-BBC9-40F5DEA39067}.RD|Win32.ActiveCfg = Release|Win32
|
||||||
|
{27B69211-D138-4142-BBC9-40F5DEA39067}.RD|Win32.Build.0 = Release|Win32
|
||||||
|
{27B69211-D138-4142-BBC9-40F5DEA39067}.RD|x64.ActiveCfg = Release|Win32
|
||||||
|
{27B69211-D138-4142-BBC9-40F5DEA39067}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{27B69211-D138-4142-BBC9-40F5DEA39067}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{27B69211-D138-4142-BBC9-40F5DEA39067}.Release|x64.ActiveCfg = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
16
b1.json
Normal file
16
b1.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[
|
||||||
|
"terType" : 0,
|
||||||
|
"bfieldType" : 0,
|
||||||
|
|
||||||
|
"sides" :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"side" : 0,
|
||||||
|
"army" : [[10, 40]]
|
||||||
|
}
|
||||||
|
{
|
||||||
|
"side" : 1,
|
||||||
|
"army" : [[11, 41]]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
@ -124,18 +124,25 @@ void CDefObjInfoHandler::load()
|
|||||||
castles[nobj->subid]=nobj;
|
castles[nobj->subid]=nobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 8 ; i++)
|
if(vstd::contains(gobjs, 124))
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < 8 ; i++)
|
||||||
static const char *holeDefs[] = {"AVLHOLD0.DEF", "AVLHLDS0.DEF", "AVLHOLG0.DEF", "AVLHLSN0.DEF",
|
|
||||||
"AVLHOLS0.DEF", "AVLHOLR0.DEF", "AVLHOLX0.DEF", "AVLHOLL0.DEF"};
|
|
||||||
|
|
||||||
if(i)
|
|
||||||
{
|
{
|
||||||
gobjs[124][i] = new CGDefInfo(*gobjs[124][0]);
|
|
||||||
gobjs[124][i]->name = holeDefs[i];
|
static const char *holeDefs[] = {"AVLHOLD0.DEF", "AVLHLDS0.DEF", "AVLHOLG0.DEF", "AVLHLSN0.DEF",
|
||||||
|
"AVLHOLS0.DEF", "AVLHOLR0.DEF", "AVLHOLX0.DEF", "AVLHOLL0.DEF"};
|
||||||
|
|
||||||
|
if(i)
|
||||||
|
{
|
||||||
|
gobjs[124][i] = new CGDefInfo(*gobjs[124][0]);
|
||||||
|
gobjs[124][i]->name = holeDefs[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tlog1 << "No def info for holes!\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CDefObjInfoHandler::~CDefObjInfoHandler()
|
CDefObjInfoHandler::~CDefObjInfoHandler()
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "CMapInfo.h"
|
#include "CMapInfo.h"
|
||||||
#include "BattleState.h"
|
#include "BattleState.h"
|
||||||
#include "../lib/JsonNode.h"
|
#include "../lib/JsonNode.h"
|
||||||
|
#include <boost/algorithm/string/predicate.hpp>
|
||||||
|
|
||||||
boost::rand48 ran;
|
boost::rand48 ran;
|
||||||
class CGObjectInstance;
|
class CGObjectInstance;
|
||||||
@ -939,9 +940,18 @@ void CGameState::init( StartInfo * si, ui32 checksum, int Seed )
|
|||||||
DuelParameters dp;
|
DuelParameters dp;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CLoadFile lf(scenarioOps->mapname);
|
if(boost::algorithm::ends_with(scenarioOps->mapname, ".json"))
|
||||||
lf >> dp;
|
{
|
||||||
success = true;
|
tlog0 << "Loading duel settings from JSON file: " << scenarioOps->mapname << std::endl;
|
||||||
|
dp = DuelParameters::fromJSON(scenarioOps->mapname);
|
||||||
|
tlog0 << "JSON file has been succesfully read!\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CLoadFile lf(scenarioOps->mapname);
|
||||||
|
lf >> dp;
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch(...)
|
catch(...)
|
||||||
{}
|
{}
|
||||||
@ -2694,6 +2704,28 @@ DuelParameters::DuelParameters()
|
|||||||
bfieldType = 15;
|
bfieldType = 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DuelParameters DuelParameters::fromJSON(const std::string &fname)
|
||||||
|
{
|
||||||
|
DuelParameters ret;
|
||||||
|
|
||||||
|
const JsonNode duelData(fname);
|
||||||
|
ret.terType = duelData["terType"].Float();
|
||||||
|
ret.bfieldType = duelData["bfieldType"].Float();
|
||||||
|
BOOST_FOREACH(const JsonNode &n, duelData["sides"].Vector())
|
||||||
|
{
|
||||||
|
SideSettings &ss = ret.sides[(int)n["side"].Float()];
|
||||||
|
int i = 0;
|
||||||
|
BOOST_FOREACH(const JsonNode &stackNode, n["army"].Vector())
|
||||||
|
{
|
||||||
|
ss.stacks[i].type = stackNode.Vector()[0].Float();
|
||||||
|
ss.stacks[i].count = stackNode.Vector()[1].Float();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
TeamState::TeamState()
|
TeamState::TeamState()
|
||||||
{
|
{
|
||||||
setNodeType(TEAM);
|
setNodeType(TEAM);
|
||||||
|
@ -305,6 +305,8 @@ struct DLL_EXPORT DuelParameters
|
|||||||
}
|
}
|
||||||
} sides[2];
|
} sides[2];
|
||||||
|
|
||||||
|
static DuelParameters fromJSON(const std::string &fname);
|
||||||
|
|
||||||
DuelParameters();
|
DuelParameters();
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
|
@ -271,38 +271,40 @@ void CLodHandler::init(const std::string lodFile, const std::string dirName)
|
|||||||
if (!LOD.is_open())
|
if (!LOD.is_open())
|
||||||
{
|
{
|
||||||
tlog1 << "Cannot open " << lodFile << std::endl;
|
tlog1 << "Cannot open " << lodFile << std::endl;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
Uint32 temp;
|
|
||||||
LOD.seekg(8);
|
|
||||||
LOD.read((char *)&temp, 4);
|
|
||||||
totalFiles = SDL_SwapLE32(temp);
|
|
||||||
|
|
||||||
LOD.seekg(0x5c, std::ios::beg);
|
|
||||||
if(!LOD)
|
|
||||||
{
|
{
|
||||||
tlog2 << lodFile << " doesn't store anything!\n";
|
|
||||||
return;
|
Uint32 temp;
|
||||||
|
LOD.seekg(8);
|
||||||
|
LOD.read((char *)&temp, 4);
|
||||||
|
totalFiles = SDL_SwapLE32(temp);
|
||||||
|
|
||||||
|
LOD.seekg(0x5c, std::ios::beg);
|
||||||
|
if(!LOD)
|
||||||
|
{
|
||||||
|
tlog2 << lodFile << " doesn't store anything!\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct LodEntry *lodEntries = new struct LodEntry[totalFiles];
|
||||||
|
LOD.read((char *)lodEntries, sizeof(struct LodEntry) * totalFiles);
|
||||||
|
|
||||||
|
for (unsigned int i=0; i<totalFiles; i++)
|
||||||
|
{
|
||||||
|
Entry entry;
|
||||||
|
initEntry(entry, lodEntries[i].filename);
|
||||||
|
|
||||||
|
entry.offset= SDL_SwapLE32(lodEntries[i].offset);
|
||||||
|
entry.realSize = SDL_SwapLE32(lodEntries[i].uncompressedSize);
|
||||||
|
entry.size = SDL_SwapLE32(lodEntries[i].size);
|
||||||
|
|
||||||
|
entries.insert(entry);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete [] lodEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct LodEntry *lodEntries = new struct LodEntry[totalFiles];
|
|
||||||
LOD.read((char *)lodEntries, sizeof(struct LodEntry) * totalFiles);
|
|
||||||
|
|
||||||
for (unsigned int i=0; i<totalFiles; i++)
|
|
||||||
{
|
|
||||||
Entry entry;
|
|
||||||
initEntry(entry, lodEntries[i].filename);
|
|
||||||
|
|
||||||
entry.offset= SDL_SwapLE32(lodEntries[i].offset);
|
|
||||||
entry.realSize = SDL_SwapLE32(lodEntries[i].uncompressedSize);
|
|
||||||
entry.size = SDL_SwapLE32(lodEntries[i].size);
|
|
||||||
|
|
||||||
entries.insert(entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] lodEntries;
|
|
||||||
|
|
||||||
boost::filesystem::recursive_directory_iterator enddir;
|
boost::filesystem::recursive_directory_iterator enddir;
|
||||||
if(boost::filesystem::exists(dirName))
|
if(boost::filesystem::exists(dirName))
|
||||||
{
|
{
|
||||||
|
@ -408,6 +408,7 @@ CSerializer::CSerializer()
|
|||||||
|
|
||||||
void CSerializer::addStdVecItems(CGameState *gs, LibClasses *lib)
|
void CSerializer::addStdVecItems(CGameState *gs, LibClasses *lib)
|
||||||
{
|
{
|
||||||
|
assert(gs);
|
||||||
registerVectoredType(&gs->map->objects, &CGObjectInstance::id);
|
registerVectoredType(&gs->map->objects, &CGObjectInstance::id);
|
||||||
registerVectoredType(&lib->heroh->heroes, &CHero::ID);
|
registerVectoredType(&lib->heroh->heroes, &CHero::ID);
|
||||||
registerVectoredType(&lib->creh->creatures, &CCreature::idNumber);
|
registerVectoredType(&lib->creh->creatures, &CCreature::idNumber);
|
||||||
|
@ -107,7 +107,7 @@ bool & JsonNode::Bool()
|
|||||||
return data.Bool;
|
return data.Bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
float & JsonNode::Float()
|
double & JsonNode::Float()
|
||||||
{
|
{
|
||||||
setType(DATA_FLOAT);
|
setType(DATA_FLOAT);
|
||||||
return data.Float;
|
return data.Float;
|
||||||
@ -140,8 +140,8 @@ const bool & JsonNode::Bool() const
|
|||||||
return data.Bool;
|
return data.Bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float floatDefault = 0;
|
const double floatDefault = 0;
|
||||||
const float & JsonNode::Float() const
|
const double & JsonNode::Float() const
|
||||||
{
|
{
|
||||||
if (type == DATA_NULL)
|
if (type == DATA_NULL)
|
||||||
return floatDefault;
|
return floatDefault;
|
||||||
@ -562,7 +562,7 @@ bool JsonParser::extractFloat(JsonNode &node)
|
|||||||
{
|
{
|
||||||
assert(input[pos] == '-' || (input[pos] >= '0' && input[pos] <= '9'));
|
assert(input[pos] == '-' || (input[pos] >= '0' && input[pos] <= '9'));
|
||||||
bool negative=false;
|
bool negative=false;
|
||||||
float result=0;
|
double result=0;
|
||||||
|
|
||||||
if (input[pos] == '-')
|
if (input[pos] == '-')
|
||||||
{
|
{
|
||||||
@ -583,7 +583,7 @@ bool JsonParser::extractFloat(JsonNode &node)
|
|||||||
{
|
{
|
||||||
//extract fractional part
|
//extract fractional part
|
||||||
pos++;
|
pos++;
|
||||||
float fractMult = 0.1;
|
double fractMult = 0.1;
|
||||||
if (input[pos] < '0' || input[pos] > '9')
|
if (input[pos] < '0' || input[pos] > '9')
|
||||||
return error("Decimal part expected!");
|
return error("Decimal part expected!");
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ private:
|
|||||||
union JsonData
|
union JsonData
|
||||||
{
|
{
|
||||||
bool Bool;
|
bool Bool;
|
||||||
float Float;
|
double Float;
|
||||||
std::string* String;
|
std::string* String;
|
||||||
JsonVector* Vector;
|
JsonVector* Vector;
|
||||||
JsonMap* Struct;
|
JsonMap* Struct;
|
||||||
@ -60,14 +60,14 @@ public:
|
|||||||
|
|
||||||
//non-const accessors, node will change type on type mismatch
|
//non-const accessors, node will change type on type mismatch
|
||||||
bool & Bool();
|
bool & Bool();
|
||||||
float & Float();
|
double & Float();
|
||||||
std::string & String();
|
std::string & String();
|
||||||
JsonVector & Vector();
|
JsonVector & Vector();
|
||||||
JsonMap & Struct();
|
JsonMap & Struct();
|
||||||
|
|
||||||
//const accessors, will cause assertion failure on type mismatch
|
//const accessors, will cause assertion failure on type mismatch
|
||||||
const bool & Bool() const;
|
const bool & Bool() const;
|
||||||
const float & Float() const;
|
const double & Float() const;
|
||||||
const std::string & String() const;
|
const std::string & String() const;
|
||||||
const JsonVector & Vector() const;
|
const JsonVector & Vector() const;
|
||||||
const JsonMap & Struct() const;
|
const JsonMap & Struct() const;
|
||||||
|
@ -1213,12 +1213,6 @@ void CGameHandler::run(bool resume)
|
|||||||
boost::thread(boost::bind(&CGameHandler::handleConnection,this,pom,boost::ref(**i)));
|
boost::thread(boost::bind(&CGameHandler::handleConnection,this,pom,boost::ref(**i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gs->scenarioOps->mode == StartInfo::DUEL)
|
|
||||||
{
|
|
||||||
runBattle();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!end2)
|
while (!end2)
|
||||||
{
|
{
|
||||||
if(!resume)
|
if(!resume)
|
||||||
|
@ -335,7 +335,6 @@ CGameHandler * CVCMIServer::initGhFromHostingConnection(CConnection &c)
|
|||||||
c << ui8(0); //OK!
|
c << ui8(0); //OK!
|
||||||
}
|
}
|
||||||
|
|
||||||
gh->init(&si,std::time(NULL));
|
|
||||||
c.addStdVecItems(gh->gs);
|
c.addStdVecItems(gh->gs);
|
||||||
gh->conns.insert(&c);
|
gh->conns.insert(&c);
|
||||||
|
|
||||||
@ -499,6 +498,51 @@ void CVCMIServer::loadGame()
|
|||||||
gh.run(true);
|
gh.run(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CVCMIServer::startDuel(const std::string &battle, const std::string &leftAI, const std::string &rightAI)
|
||||||
|
{
|
||||||
|
//we need three connections
|
||||||
|
CConnection *conns[3] = {0};
|
||||||
|
for (int i = 0; i < 3 ; i++)
|
||||||
|
{
|
||||||
|
boost::system::error_code error;
|
||||||
|
tcp::socket * s = new tcp::socket(acceptor->get_io_service());
|
||||||
|
acceptor->accept(*s, error);
|
||||||
|
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
tlog2<<"Got connection but there is an error " << std::endl << error;
|
||||||
|
i--;
|
||||||
|
delNull(s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tlog0<<"We've accepted someone... " << std::endl;
|
||||||
|
conns[i] = new CConnection(s, NAME);
|
||||||
|
tlog0<<"Got connection!" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StartInfo si;
|
||||||
|
si.mode = StartInfo::DUEL;
|
||||||
|
si.mapname = battle;
|
||||||
|
|
||||||
|
CGameHandler *gh = new CGameHandler();
|
||||||
|
gh->init(&si,std::time(NULL));
|
||||||
|
|
||||||
|
BOOST_FOREACH(CConnection *c, conns)
|
||||||
|
{
|
||||||
|
c->addStdVecItems(gh->gs, VLC);
|
||||||
|
gh->connections[gh->conns.size()] = c;
|
||||||
|
gh->conns.insert(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
gh->runBattle();
|
||||||
|
|
||||||
|
delNull(gh);
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef __GNUC__
|
#ifndef __GNUC__
|
||||||
int _tmain(int argc, _TCHAR* argv[])
|
int _tmain(int argc, _TCHAR* argv[])
|
||||||
#else
|
#else
|
||||||
@ -523,6 +567,9 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
io_service io_service;
|
io_service io_service;
|
||||||
CVCMIServer server;
|
CVCMIServer server;
|
||||||
|
assert(argc == 4);
|
||||||
|
server.startDuel(argv[1], argv[2], argv[3]);
|
||||||
|
|
||||||
while(!end2)
|
while(!end2)
|
||||||
{
|
{
|
||||||
server.start();
|
server.start();
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
~CVCMIServer(); //d-tor
|
~CVCMIServer(); //d-tor
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
void startDuel(const std::string &battle, const std::string &leftAI, const std::string &rightAI);
|
||||||
CGameHandler *initGhFromHostingConnection(CConnection &c);
|
CGameHandler *initGhFromHostingConnection(CConnection &c);
|
||||||
|
|
||||||
void newGame();
|
void newGame();
|
||||||
|
@ -1,17 +1,6 @@
|
|||||||
bin_PROGRAMS = vcmiserver
|
bin_PROGRAMS = odpalarka
|
||||||
|
|
||||||
vcmiserver_LDADD = $(top_builddir)/lib/libvcmi.la
|
odpalarka_LDADD = $(top_builddir)/lib/libvcmi.la
|
||||||
vcmiserver_CXXFLAGS = @SDL_CXXFLAGS@
|
odpalarka_CXXFLAGS = @SDL_CXXFLAGS@
|
||||||
vcmiserver_LDFLAGS = -L$(top_builddir)/lib
|
odpalarka_LDFLAGS = -L$(top_builddir)/lib
|
||||||
vcmiserver_SOURCES = \
|
odpalarka_SOURCES = main.cpp
|
||||||
../CConsoleHandler.cpp \
|
|
||||||
../CConsoleHandler.h \
|
|
||||||
../CThreadHelper.cpp \
|
|
||||||
../CThreadHelper.h \
|
|
||||||
CGameHandler.cpp \
|
|
||||||
CGameHandler.h \
|
|
||||||
CVCMIServer.cpp \
|
|
||||||
CVCMIServer.h \
|
|
||||||
NetPacksServer.cpp \
|
|
||||||
stdafx.cpp \
|
|
||||||
stdafx.h
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>MultiByte</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
Loading…
Reference in New Issue
Block a user