Skip to content

Commit 978c859

Browse files
intorrXottab-DUTY
authored andcommitted
Small work on mp_balancer.
1 parent ce688d2 commit 978c859

File tree

7 files changed

+42
-87
lines changed

7 files changed

+42
-87
lines changed

src/utils/mp_balancer/entry_point.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

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

910
SetConsoleOutputCP(1251);
1011

src/utils/mp_balancer/mp_balancer.vcxproj

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<ItemGroup Label="ProjectConfigurations">
44
<ProjectConfiguration Include="Debug|Win32">
55
<Configuration>Debug</Configuration>
@@ -19,13 +19,13 @@
1919
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
2020
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
2121
<ConfigurationType>Application</ConfigurationType>
22-
<PlatformToolset>v120</PlatformToolset>
22+
<PlatformToolset>v141</PlatformToolset>
2323
<CharacterSet>MultiByte</CharacterSet>
2424
<WholeProgramOptimization>true</WholeProgramOptimization>
2525
</PropertyGroup>
2626
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
2727
<ConfigurationType>Application</ConfigurationType>
28-
<PlatformToolset>v120</PlatformToolset>
28+
<PlatformToolset>v141</PlatformToolset>
2929
<CharacterSet>MultiByte</CharacterSet>
3030
</PropertyGroup>
3131
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
@@ -39,66 +39,20 @@
3939
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
4040
<Import Project="$(SolutionDir)Common.props" />
4141
</ImportGroup>
42-
<PropertyGroup Label="UserMacros" />
43-
<PropertyGroup>
44-
<_ProjectFileVersion>12.0.30501.0</_ProjectFileVersion>
45-
</PropertyGroup>
46-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
47-
<OutDir>$(xrBinDir)</OutDir>
48-
<IntDir>$(xrIntDir)$(ProjectName)\</IntDir>
49-
<LinkIncremental>true</LinkIncremental>
50-
</PropertyGroup>
51-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
52-
<OutDir>$(xrBinDir)</OutDir>
53-
<IntDir>$(xrIntDir)$(ProjectName)\</IntDir>
54-
<LinkIncremental>false</LinkIncremental>
55-
</PropertyGroup>
5642
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
5743
<ClCompile>
58-
<Optimization>Disabled</Optimization>
59-
<AdditionalIncludeDirectories>$(xrSdkDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
60-
<PreprocessorDefinitions>WIN32;DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
61-
<StringPooling>true</StringPooling>
62-
<MinimalRebuild>true</MinimalRebuild>
63-
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
64-
<SmallerTypeCheck>true</SmallerTypeCheck>
65-
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
66-
<FunctionLevelLinking>true</FunctionLevelLinking>
67-
<FloatingPointModel>Fast</FloatingPointModel>
68-
<PrecompiledHeader>Use</PrecompiledHeader>
6944
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
70-
<WarningLevel>Level4</WarningLevel>
71-
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
7245
</ClCompile>
7346
<Link>
74-
<AdditionalLibraryDirectories>$(xrSdkDir)libraries;$(xrLibDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
75-
<GenerateDebugInformation>true</GenerateDebugInformation>
7647
<SubSystem>Console</SubSystem>
77-
<TargetMachine>MachineX86</TargetMachine>
7848
</Link>
7949
</ItemDefinitionGroup>
8050
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
8151
<ClCompile>
82-
<AdditionalIncludeDirectories>$(xrSdkDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
83-
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
84-
<StringPooling>true</StringPooling>
85-
<ExceptionHandling />
86-
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
87-
<BufferSecurityCheck>false</BufferSecurityCheck>
88-
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
89-
<FloatingPointModel>Fast</FloatingPointModel>
90-
<PrecompiledHeader>Use</PrecompiledHeader>
9152
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
92-
<WarningLevel>Level4</WarningLevel>
93-
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
9453
</ClCompile>
9554
<Link>
96-
<AdditionalLibraryDirectories>$(xrSdkDir)libraries;$(xrLibDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
97-
<GenerateDebugInformation>true</GenerateDebugInformation>
9855
<SubSystem>Console</SubSystem>
99-
<OptimizeReferences>true</OptimizeReferences>
100-
<EnableCOMDATFolding>true</EnableCOMDATFolding>
101-
<TargetMachine>MachineX86</TargetMachine>
10256
</Link>
10357
</ItemDefinitionGroup>
10458
<ItemGroup>
@@ -108,18 +62,8 @@
10862
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
10963
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
11064
</ClCompile>
111-
<ClCompile Include="statistics_collector.cpp">
112-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
113-
</PrecompiledHeader>
114-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
115-
</PrecompiledHeader>
116-
</ClCompile>
117-
<ClCompile Include="wpn_collection.cpp">
118-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
119-
</PrecompiledHeader>
120-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
121-
</PrecompiledHeader>
122-
</ClCompile>
65+
<ClCompile Include="statistics_collector.cpp" />
66+
<ClCompile Include="wpn_collection.cpp" />
12367
<ClCompile Include="xr_ini_ex.cpp" />
12468
</ItemGroup>
12569
<ItemGroup>
@@ -130,6 +74,14 @@
13074
<ClInclude Include="wpn_collection.hpp" />
13175
<ClInclude Include="xr_ini_ex.h" />
13276
</ItemGroup>
77+
<ItemGroup>
78+
<ProjectReference Include="..\..\xrCore\xrCore.vcxproj">
79+
<Project>{a0f7d1fb-59a7-4717-a7e4-96f37e91998e}</Project>
80+
</ProjectReference>
81+
<ProjectReference Include="..\..\xrMisc\xrMisc.vcxproj">
82+
<Project>{c964d17a-05a8-4bfa-b0a8-7af5c6b627ec}</Project>
83+
</ProjectReference>
84+
</ItemGroup>
13385
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
13486
<ImportGroup Label="ExtensionTargets">
13587
</ImportGroup>

src/utils/mp_balancer/pch.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#ifndef PCH_H_INCLUDED
22
#define PCH_H_INCLUDED
33

4-
#include "../../xrCore/xrCore.h"
4+
#include "Common/Platform.hpp"
5+
#include "Common/Common.hpp"
6+
#include "Common/object_broker.h"
7+
#include "xrCore/xrCore.h"
8+
#include "xrCore/Containers/AssociativeVector.hpp"
9+
510
#include "xr_ini_ex.h"
611

7-
#include <stdio.h>
12+
#include <iostream>
813
#include <conio.h>
9-
#include "iostreams_proxy.h"
10-
#include "tools.hpp"
11-
#include "../../xrServerEntities/object_broker.h"
12-
#include "../../xrServerEntities/associative_vector.h"
13-
14-
#include <winnls.h>
1514

1615
#endif // #define PCH_H_INCLUDED

src/utils/mp_balancer/statistics_collector.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#include "pch.h"
12
#include "statistics_collector.hpp"
23
#include "wpn_collection.hpp"
4+
#include "tools.hpp"
35

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

2628
void statistics_collector::save_files()
2729
{
28-
std::for_each(m_all_params.begin(), m_all_params.end(),
29-
std::bind1st(std::mem_fun<void, statistics_collector>(&statistics_collector::save_file), this));
30+
//std::for_each(m_all_params.begin(), m_all_params.end(),
31+
// std::bind1st(std::mem_fun<void, statistics_collector>(&statistics_collector::save_file), this));
32+
for (auto &it : m_all_params)
33+
save_file(it);
3034
}
3135

3236
statistics_collector::csv_files::const_iterator statistics_collector::get_most_acceptable_group(

src/utils/mp_balancer/statistics_collector.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
#ifndef STATISTICS_COLLECTOR
22
#define STATISTICS_COLLECTOR
33

4-
#include "pch.h"
5-
64
class weapon_collection;
75

86
class statistics_collector
97
{
108
private:
119
weapon_collection* m_wpn_collection;
1210
typedef xr_vector<shared_str> params_collection;
13-
typedef associative_vector<shared_str, params_collection*> csv_files;
11+
typedef AssociativeVector<shared_str, params_collection*> csv_files;
1412
csv_files m_all_params;
1513
void save_file(csv_files::value_type const& val);
1614
csv_files::const_iterator get_most_acceptable_group(shared_str const& section);

src/utils/mp_balancer/wpn_collection.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "pch.h"
12
#include "wpn_collection.hpp"
23

34
weapon_collection::weapon_collection() {}
@@ -21,10 +22,10 @@ void weapon_collection::load_all_mp_weapons()
2122
string_path path_ltx;
2223

2324
FS.update_path(path_ltx, "$patch_config$", "system.ltx");
24-
patch_config = xr_new<CInifileEx>(path_ltx, TRUE, TRUE, FALSE);
25+
patch_config = new CInifileEx(path_ltx, TRUE, TRUE, FALSE);
2526

2627
FS.update_path(path_ltx, "$game_config$", "system.ltx");
27-
priquel_config = xr_new<CInifileEx>(path_ltx, TRUE, TRUE, FALSE);
28+
priquel_config = new CInifileEx(path_ltx, TRUE, TRUE, FALSE);
2829

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

4142
FS.update_path(path_ltx, "$app_data_root$", "export_settings.ltx");
42-
settings = xr_new<CInifileEx>(path_ltx, TRUE, TRUE, FALSE);
43+
settings = new CInifileEx(path_ltx, TRUE, TRUE, FALSE);
4344
load_settings();
4445

4546
/*new_mp_weapons = xr_new<CInifileEx>("new_weapons_mp.ltx", FALSE, FALSE, FALSE);
@@ -89,7 +90,7 @@ void weapon_collection::load_settings()
8990
const char* larg = NULL;
9091
settings->r_line(EXPORT_SETTINGS_SECT, param, &line, &larg);
9192
R_ASSERT(line);
92-
extract_list.push_back(xr_new<tentity_extract_keys>());
93+
extract_list.push_back(new tentity_extract_keys());
9394
extract_list.back()->first = line;
9495
new_config.insert(std::make_pair(shared_str(line), xr_vector<CInifileEx::Sect>()));
9596
if (larg)

src/utils/mp_balancer/xr_ini_ex.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CInifileEx* pSettingsEx = NULL;
88

99
CInifileEx* CInifileEx::Create(const char* szFileName, BOOL ReadOnly)
1010
{
11-
return xr_new<CInifileEx>(szFileName, ReadOnly);
11+
return new CInifileEx(szFileName, ReadOnly);
1212
}
1313

1414
void CInifileEx::Destroy(CInifileEx* ini) { xr_delete(ini); }
@@ -244,10 +244,10 @@ void CInifileEx::Load(IReader* F, LPCSTR path)
244244
// store previous section
245245
RootIt I = std::lower_bound(DATA.begin(), DATA.end(), *Current->Name, sect_pred);
246246
if ((I != DATA.end()) && ((*I)->Name == Current->Name))
247-
Debug.fatal(DEBUG_INFO, "Duplicate section '%s' found.", *Current->Name);
247+
FATAL(make_string("Duplicate section '%s' found.", *Current->Name.c_str()).c_str());
248248
DATA.insert(I, Current);
249249
}
250-
Current = xr_new<Sect>();
250+
Current = new Sect();
251251
Current->Name = 0;
252252
// start new section
253253
R_ASSERT3(strchr(str, ']'), "Bad ini section found: ", str);
@@ -343,7 +343,7 @@ void CInifileEx::Load(IReader* F, LPCSTR path)
343343
{
344344
RootIt I = std::lower_bound(DATA.begin(), DATA.end(), *Current->Name, sect_pred);
345345
if ((I != DATA.end()) && ((*I)->Name == Current->Name))
346-
Debug.fatal(DEBUG_INFO, "Duplicate section '%s' found.", *Current->Name);
346+
FATAL(make_string("Duplicate section '%s' found.", *Current->Name.c_str()).c_str());
347347
DATA.insert(I, Current);
348348
}
349349
}
@@ -467,7 +467,7 @@ CInifileEx::Sect& CInifileEx::r_section(LPCSTR S)
467467
strlwr(section);
468468
RootIt I = std::lower_bound(DATA.begin(), DATA.end(), section, sect_pred);
469469
if (!(I != DATA.end() && xr_strcmp(*(*I)->Name, section) == 0))
470-
Debug.fatal(DEBUG_INFO, "Can't open section '%s'", S);
470+
FATAL(make_string("Can't open section '%s'", S).c_str());
471471
return **I;
472472
}
473473

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

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

0 commit comments

Comments
 (0)