Skip to content

Commit

Permalink
Small work on mp_balancer.
Browse files Browse the repository at this point in the history
  • Loading branch information
intorr authored and Xottab-DUTY committed Dec 23, 2017
1 parent ce688d2 commit 978c859
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 87 deletions.
3 changes: 2 additions & 1 deletion src/utils/mp_balancer/entry_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

void main(int argc, char* argv[])
{
Core._initialize("mp_ballancer", NULL, TRUE, "fsgame4mpu.ltx");
xrDebug::Initialize(false);
Core.Initialize("mp_ballancer", NULL, TRUE, "fsgame.ltx");

SetConsoleOutputCP(1251);

Expand Down
74 changes: 13 additions & 61 deletions src/utils/mp_balancer/mp_balancer.vcxproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
Expand All @@ -19,13 +19,13 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand All @@ -39,66 +39,20 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(SolutionDir)Common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(xrBinDir)</OutDir>
<IntDir>$(xrIntDir)$(ProjectName)\</IntDir>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(xrBinDir)</OutDir>
<IntDir>$(xrIntDir)$(ProjectName)\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(xrSdkDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<SmallerTypeCheck>true</SmallerTypeCheck>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<FloatingPointModel>Fast</FloatingPointModel>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(xrSdkDir)libraries;$(xrLibDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(xrSdkDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<ExceptionHandling />
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
<FloatingPointModel>Fast</FloatingPointModel>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>$(xrSdkDir)libraries;$(xrLibDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
Expand All @@ -108,18 +62,8 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="statistics_collector.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="wpn_collection.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="statistics_collector.cpp" />
<ClCompile Include="wpn_collection.cpp" />
<ClCompile Include="xr_ini_ex.cpp" />
</ItemGroup>
<ItemGroup>
Expand All @@ -130,6 +74,14 @@
<ClInclude Include="wpn_collection.hpp" />
<ClInclude Include="xr_ini_ex.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\xrCore\xrCore.vcxproj">
<Project>{a0f7d1fb-59a7-4717-a7e4-96f37e91998e}</Project>
</ProjectReference>
<ProjectReference Include="..\..\xrMisc\xrMisc.vcxproj">
<Project>{c964d17a-05a8-4bfa-b0a8-7af5c6b627ec}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
Expand Down
15 changes: 7 additions & 8 deletions src/utils/mp_balancer/pch.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#ifndef PCH_H_INCLUDED
#define PCH_H_INCLUDED

#include "../../xrCore/xrCore.h"
#include "Common/Platform.hpp"
#include "Common/Common.hpp"
#include "Common/object_broker.h"
#include "xrCore/xrCore.h"
#include "xrCore/Containers/AssociativeVector.hpp"

#include "xr_ini_ex.h"

#include <stdio.h>
#include <iostream>
#include <conio.h>
#include "iostreams_proxy.h"
#include "tools.hpp"
#include "../../xrServerEntities/object_broker.h"
#include "../../xrServerEntities/associative_vector.h"

#include <winnls.h>

#endif // #define PCH_H_INCLUDED
10 changes: 7 additions & 3 deletions src/utils/mp_balancer/statistics_collector.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "pch.h"
#include "statistics_collector.hpp"
#include "wpn_collection.hpp"
#include "tools.hpp"

statistics_collector::statistics_collector(weapon_collection* wpn_collection) { m_wpn_collection = wpn_collection; }
statistics_collector::~statistics_collector() { delete_data(m_all_params); }
Expand All @@ -14,7 +16,7 @@ void statistics_collector::load_settings()
if (m_wpn_collection->settings->r_line(CSV_SETTINGS, i, &key, &value) && key)
{
csv_files::iterator new_file_iter =
m_all_params.insert(std::make_pair(shared_str(key), xr_new<params_collection>())).first;
m_all_params.insert(std::make_pair(shared_str(key), new params_collection())).first;
if (value)
{
get_string_collection(value, *new_file_iter->second);
Expand All @@ -25,8 +27,10 @@ void statistics_collector::load_settings()

void statistics_collector::save_files()
{
std::for_each(m_all_params.begin(), m_all_params.end(),
std::bind1st(std::mem_fun<void, statistics_collector>(&statistics_collector::save_file), this));
//std::for_each(m_all_params.begin(), m_all_params.end(),
// std::bind1st(std::mem_fun<void, statistics_collector>(&statistics_collector::save_file), this));
for (auto &it : m_all_params)
save_file(it);
}

statistics_collector::csv_files::const_iterator statistics_collector::get_most_acceptable_group(
Expand Down
4 changes: 1 addition & 3 deletions src/utils/mp_balancer/statistics_collector.hpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
#ifndef STATISTICS_COLLECTOR
#define STATISTICS_COLLECTOR

#include "pch.h"

class weapon_collection;

class statistics_collector
{
private:
weapon_collection* m_wpn_collection;
typedef xr_vector<shared_str> params_collection;
typedef associative_vector<shared_str, params_collection*> csv_files;
typedef AssociativeVector<shared_str, params_collection*> csv_files;
csv_files m_all_params;
void save_file(csv_files::value_type const& val);
csv_files::const_iterator get_most_acceptable_group(shared_str const& section);
Expand Down
9 changes: 5 additions & 4 deletions src/utils/mp_balancer/wpn_collection.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "pch.h"
#include "wpn_collection.hpp"

weapon_collection::weapon_collection() {}
Expand All @@ -21,10 +22,10 @@ void weapon_collection::load_all_mp_weapons()
string_path path_ltx;

FS.update_path(path_ltx, "$patch_config$", "system.ltx");
patch_config = xr_new<CInifileEx>(path_ltx, TRUE, TRUE, FALSE);
patch_config = new CInifileEx(path_ltx, TRUE, TRUE, FALSE);

FS.update_path(path_ltx, "$game_config$", "system.ltx");
priquel_config = xr_new<CInifileEx>(path_ltx, TRUE, TRUE, FALSE);
priquel_config = new CInifileEx(path_ltx, TRUE, TRUE, FALSE);

/*FS.update_path (path_ltx, "$game_config$", "mp\\weapons_mp\\weapons_mp_for_work.ltx");
work_mp_weapons = xr_new<CInifileEx>(path_ltx, TRUE, TRUE, FALSE);
Expand All @@ -39,7 +40,7 @@ void weapon_collection::load_all_mp_weapons()
work_mp_outfits = xr_new<CInifileEx>(path_ltx, TRUE, TRUE, FALSE);*/

FS.update_path(path_ltx, "$app_data_root$", "export_settings.ltx");
settings = xr_new<CInifileEx>(path_ltx, TRUE, TRUE, FALSE);
settings = new CInifileEx(path_ltx, TRUE, TRUE, FALSE);
load_settings();

/*new_mp_weapons = xr_new<CInifileEx>("new_weapons_mp.ltx", FALSE, FALSE, FALSE);
Expand Down Expand Up @@ -89,7 +90,7 @@ void weapon_collection::load_settings()
const char* larg = NULL;
settings->r_line(EXPORT_SETTINGS_SECT, param, &line, &larg);
R_ASSERT(line);
extract_list.push_back(xr_new<tentity_extract_keys>());
extract_list.push_back(new tentity_extract_keys());
extract_list.back()->first = line;
new_config.insert(std::make_pair(shared_str(line), xr_vector<CInifileEx::Sect>()));
if (larg)
Expand Down
14 changes: 7 additions & 7 deletions src/utils/mp_balancer/xr_ini_ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CInifileEx* pSettingsEx = NULL;

CInifileEx* CInifileEx::Create(const char* szFileName, BOOL ReadOnly)
{
return xr_new<CInifileEx>(szFileName, ReadOnly);
return new CInifileEx(szFileName, ReadOnly);
}

void CInifileEx::Destroy(CInifileEx* ini) { xr_delete(ini); }
Expand Down Expand Up @@ -244,10 +244,10 @@ void CInifileEx::Load(IReader* F, LPCSTR path)
// store previous section
RootIt I = std::lower_bound(DATA.begin(), DATA.end(), *Current->Name, sect_pred);
if ((I != DATA.end()) && ((*I)->Name == Current->Name))
Debug.fatal(DEBUG_INFO, "Duplicate section '%s' found.", *Current->Name);
FATAL(make_string("Duplicate section '%s' found.", *Current->Name.c_str()).c_str());
DATA.insert(I, Current);
}
Current = xr_new<Sect>();
Current = new Sect();
Current->Name = 0;
// start new section
R_ASSERT3(strchr(str, ']'), "Bad ini section found: ", str);
Expand Down Expand Up @@ -343,7 +343,7 @@ void CInifileEx::Load(IReader* F, LPCSTR path)
{
RootIt I = std::lower_bound(DATA.begin(), DATA.end(), *Current->Name, sect_pred);
if ((I != DATA.end()) && ((*I)->Name == Current->Name))
Debug.fatal(DEBUG_INFO, "Duplicate section '%s' found.", *Current->Name);
FATAL(make_string("Duplicate section '%s' found.", *Current->Name.c_str()).c_str());
DATA.insert(I, Current);
}
}
Expand Down Expand Up @@ -467,7 +467,7 @@ CInifileEx::Sect& CInifileEx::r_section(LPCSTR S)
strlwr(section);
RootIt I = std::lower_bound(DATA.begin(), DATA.end(), section, sect_pred);
if (!(I != DATA.end() && xr_strcmp(*(*I)->Name, section) == 0))
Debug.fatal(DEBUG_INFO, "Can't open section '%s'", S);
FATAL(make_string("Can't open section '%s'", S).c_str());
return **I;
}

Expand All @@ -478,7 +478,7 @@ LPCSTR CInifileEx::r_string(LPCSTR S, LPCSTR L)
if (A != I.Data.end() && xr_strcmp(*A->first, L) == 0)
return *A->second;
else
Debug.fatal(DEBUG_INFO, "Can't find variable %s in [%s]", L, S);
FATAL(make_string("Can't find variable %s in [%s]", L, S).c_str());
return 0;
}

Expand Down Expand Up @@ -661,7 +661,7 @@ void CInifileEx::w_string(LPCSTR S, LPCSTR L, LPCSTR V, LPCSTR comment)
if (!section_exist(sect))
{
// create _new_ section
Sect* NEW = xr_new<Sect>();
Sect* NEW = new Sect();
NEW->Name = sect;
RootIt I = std::lower_bound(DATA.begin(), DATA.end(), sect, sect_pred);
DATA.insert(I, NEW);
Expand Down

0 comments on commit 978c859

Please sign in to comment.