Skip to content

Commit

Permalink
Faster initialization by ccman (#326)
Browse files Browse the repository at this point in the history
* Moved ipc initialization into the interface initialize function and added mutexes
* Updated all binaries
  • Loading branch information
tarehart authored Dec 31, 2018
1 parent 0c9136c commit d316709
Show file tree
Hide file tree
Showing 31 changed files with 1,304 additions and 983 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
#include <chrono>
#include <thread>
#include <csignal>

#include <Interface.hpp>
#include <Messages.hpp>

#include "PredictionService.hpp"
#include <GameFunctions\GameFunctions.hpp>
#include <rlbot_generated.h>
#include <BoostUtilities\BoostUtilities.hpp>
#include <BoostUtilities\BoostConstants.hpp>


vec3 convertVec(const rlbot::flat::Vector3* vec)
{
return vec3{ vec->x(), vec->y(), vec->z() };
Expand Down Expand Up @@ -65,6 +68,10 @@ int runBallPrediction()

std::list<BallPrediction::BallSlice> empty;
emplacePrediction(&empty); // Clear out any previous predictions
MutexUtilities::CreateBallPredictionMutex();

while (!Interface::IsInitialized())
Sleep(100);

while (true)
{
Expand Down
170 changes: 170 additions & 0 deletions src/main/cpp/RLBotInterface/InterfaceTester/InterfaceTester.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="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">
<ProjectGuid>{CA69F94E-8059-4C05-BBE2-256CD57C1C81}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>InterfaceTester</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</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>
<IncludePath>$(SolutionDir)RLBotInterface;$(SolutionDir)RLBotMessages;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<OutDir>$(SolutionDir)RLBotInterface\Bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Obj\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(SolutionDir)RLBotInterface;$(SolutionDir)RLBotMessages;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<OutDir>$(SolutionDir)RLBotInterface\Bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Obj\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir)RLBotInterface;$(SolutionDir)RLBotMessages;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<OutDir>$(SolutionDir)RLBotInterface\Bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Obj\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(SolutionDir)RLBotInterface;$(SolutionDir)RLBotMessages;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<OutDir>$(SolutionDir)RLBotInterface\Bin\$(Platform)\$(Configuration)\</OutDir>
<IntDir>Obj\$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Main.cpp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RLBotInterface\RLBotInterface.vcxproj">
<Project>{5340e767-57ec-4855-86e4-8f978201b39f}</Project>
</ProjectReference>
<ProjectReference Include="..\RLBotMessages\RLBotMessages.vcxproj">
<Project>{075f4b01-013a-4200-9720-95051226d748}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -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="Quelldateien">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Headerdateien">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Ressourcendateien">
<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="Main.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
</ItemGroup>
</Project>
44 changes: 44 additions & 0 deletions src/main/cpp/RLBotInterface/InterfaceTester/Main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <Windows.h>
#include <GameFunctions\GameFunctions.hpp>
#include <Interface.hpp>

int main()
{
while (!Interface::IsInitialized())
Sleep(100);

MatchSettings settings;
ZeroMemory(&settings, sizeof(MatchSettings));

PlayerConfiguration& player1 = settings.PlayerConfiguration[0];
player1.Bot = false;
player1.RLBotControlled = false;

settings.NumPlayers = 1;
settings.GameMode = GameMode::Soccer;
settings.GameMap = GameMap::Mannfield;
settings.SkipReplays = false;
settings.InstantStart = false;

MutatorSettings& mutators = settings.MutatorSettings;
mutators.MatchLength = MatchLength::Five_Minutes;
mutators.MaxScore = MaxScore::Unlimited;
mutators.OvertimeOptions = OvertimeOption::Unlimited;
mutators.SeriesLengthOptions = SeriesLengthOption::Unlimited;
mutators.GameSpeedOptions = GameSpeedOption::Default;
mutators.BallMaxSpeedOptions = BallMaxSpeedOption::Default;
mutators.BallTypeOptions = BallTypeOption::Default;
mutators.BallWeightOptions = BallWeightOption::Default;
mutators.BallSizeOptions = BallSizeOption::Default;
mutators.BallBouncinessOptions = BallBouncinessOption::Default;
mutators.BoostOptions = BoostOption::Normal_Boost;
mutators.RumbleOptions = RumbleOption::None;
mutators.BoostStrengthOptions = BoostStrengthOption::One;
mutators.GravityOptions = GravityOption::Default;
mutators.DemolishOptions = DemolishOption::Default;
mutators.RespawnTimeOptions = RespawnTimeOption::Three_Seconds;

GameFunctions::StartMatch(settings, nullptr, nullptr);

return ERROR_SUCCESS;
}
10 changes: 10 additions & 0 deletions src/main/cpp/RLBotInterface/RLBotInterface.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BallPrediction", "BallPredi
{5340E767-57EC-4855-86E4-8F978201B39F} = {5340E767-57EC-4855-86E4-8F978201B39F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InterfaceTester", "InterfaceTester\InterfaceTester.vcxproj", "{CA69F94E-8059-4C05-BBE2-256CD57C1C81}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Expand Down Expand Up @@ -45,6 +47,14 @@ Global
{F74571F5-5ADA-4CC5-AAB8-69A4EE1E739D}.Release|x64.Build.0 = Release|x64
{F74571F5-5ADA-4CC5-AAB8-69A4EE1E739D}.Release|x86.ActiveCfg = Release|Win32
{F74571F5-5ADA-4CC5-AAB8-69A4EE1E739D}.Release|x86.Build.0 = Release|Win32
{CA69F94E-8059-4C05-BBE2-256CD57C1C81}.Debug|x64.ActiveCfg = Debug|x64
{CA69F94E-8059-4C05-BBE2-256CD57C1C81}.Debug|x64.Build.0 = Debug|x64
{CA69F94E-8059-4C05-BBE2-256CD57C1C81}.Debug|x86.ActiveCfg = Debug|Win32
{CA69F94E-8059-4C05-BBE2-256CD57C1C81}.Debug|x86.Build.0 = Debug|Win32
{CA69F94E-8059-4C05-BBE2-256CD57C1C81}.Release|x64.ActiveCfg = Release|x64
{CA69F94E-8059-4C05-BBE2-256CD57C1C81}.Release|x64.Build.0 = Release|x64
{CA69F94E-8059-4C05-BBE2-256CD57C1C81}.Release|x86.ActiveCfg = Release|Win32
{CA69F94E-8059-4C05-BBE2-256CD57C1C81}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <DebugHelper.hpp>
#include <Messages.hpp>

#include "BallPrediction.hpp"
#include <MessageTranslation\FlatbufferTranslator.hpp>
Expand All @@ -9,10 +10,21 @@

namespace BallPrediction
{
BoostUtilities::SharedMemReader* pBallPredictionMem = nullptr;

extern "C" ByteBuffer RLBOT_CORE_API GetBallPrediction()
{
static BoostUtilities::SharedMemReader ballPredictionMem(BoostConstants::BallPredictionName);
return ballPredictionMem.fetchData();
if (!MutexUtilities::IsBallPredictionServiceRunning())
{
ByteBuffer empty;
empty.ptr = new char[1]; // Arbitrary valid pointer to an array. We'll be calling delete[] on this later.
empty.size = 0;
return empty;
}
else if (!pBallPredictionMem)
pBallPredictionMem = new BoostUtilities::SharedMemReader(BoostConstants::BallPredictionName);

return pBallPredictionMem->fetchData();
}

// Ctypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,10 @@
#include <ErrorCodes\ErrorCodes.hpp>
#include "..\InterfaceBase\InterfaceBase.hpp"


#ifdef __cplusplus
extern "C"
namespace BallPrediction
{
#endif

namespace BallPrediction
{
DLL_EXPORT ByteBuffer RLBOT_CORE_API GetBallPrediction();
DLL_EXPORT RLBotCoreStatus RLBOT_CORE_API GetBallPredictionStruct(BallPredictionPacket* pBallPrediction);
}

#ifdef __cplusplus
extern "C" DLL_EXPORT ByteBuffer RLBOT_CORE_API GetBallPrediction();
extern "C" DLL_EXPORT RLBotCoreStatus RLBOT_CORE_API GetBallPredictionStruct(BallPredictionPacket* pBallPrediction);
}
#endif

#endif
Loading

0 comments on commit d316709

Please sign in to comment.