Skip to content

Commit

Permalink
Merge pull request #2 from settlers-united/bugfix/CSettlersAPI_Remove…
Browse files Browse the repository at this point in the history
…Selection

Bugfix/c settlers api remove selection
  • Loading branch information
kdsystem1337 committed Mar 29, 2024
2 parents 264b8b0 + 6e9709d commit 4c321c3
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 57 deletions.
Binary file modified Examples/HelloWorld/HelloWorld/S4ModApi.lib
Binary file not shown.
Binary file modified Examples/LuaExample/LuaExample/S4ModApi.lib
Binary file not shown.
Binary file not shown.
7 changes: 2 additions & 5 deletions S4ModApi.sln
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29503.13
# Visual Studio Version 17
VisualStudioVersion = 17.9.34714.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "S4ModApi", "S4ModApi\S4ModApi.vcxproj", "{80F4B5D7-9AB1-4DA7-B3A9-C13241352964}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Debug142|x86 = Debug142|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{80F4B5D7-9AB1-4DA7-B3A9-C13241352964}.Debug|x86.ActiveCfg = Debug|Win32
{80F4B5D7-9AB1-4DA7-B3A9-C13241352964}.Debug|x86.Build.0 = Debug|Win32
{80F4B5D7-9AB1-4DA7-B3A9-C13241352964}.Debug142|x86.ActiveCfg = Debug142|Win32
{80F4B5D7-9AB1-4DA7-B3A9-C13241352964}.Debug142|x86.Build.0 = Debug142|Win32
{80F4B5D7-9AB1-4DA7-B3A9-C13241352964}.Release|x86.ActiveCfg = Release|Win32
{80F4B5D7-9AB1-4DA7-B3A9-C13241352964}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
Expand Down
9 changes: 4 additions & 5 deletions S4ModApi/CS4Selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ BOOL CSettlers4Api::GetSelection(PWORD out, SIZE_T outlen, PSIZE_T selectionCoun
auto ct = s->count();
auto elementsToCopy = min(ct, outlen);
if (selectionCount) *selectionCount = ct;
LOG("s->BasePtr == " << HEXNUM(s->BasePtr))
LOG("s->BasePtr == " << HEXNUM(s->BasePtr));
if (out && elementsToCopy) memget_s(out, s->BasePtr, elementsToCopy * sizeof(*s->BasePtr));
return TRUE;
}
Expand All @@ -59,9 +59,8 @@ BOOL CSettlers4Api::RemoveSelection(PWORD settlers, SIZE_T settlerslen, PSIZE_T
}
auto& s = S4::GetInstance().Selection;
if (!s) return FALSE;
auto ppool = S4::GetInstance().EntityPool;
if (!ppool) return FALSE;
auto pool = *ppool;
auto pool = S4::GetInstance().EntityPool;
if (!pool) return FALSE;

// build a set for settlers to remove
std::unordered_set<WORD> removeSet;
Expand All @@ -74,7 +73,7 @@ BOOL CSettlers4Api::RemoveSelection(PWORD settlers, SIZE_T settlerslen, PSIZE_T
auto cur = s->BasePtr;
for (auto sp = cur; sp < end; ++sp) {
if (removeSet.find(*sp) != removeSet.end()) {
pool[*sp].clrSelectionVisibility();
pool[*sp]->clrSelectionVisibility();
continue;
}
*cur = *sp;
Expand Down
Binary file modified S4ModApi/S4ModApi.rc
Binary file not shown.
50 changes: 3 additions & 47 deletions S4ModApi/S4ModApi.vcxproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug142|Win32">
<Configuration>Debug142</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
Expand All @@ -20,22 +16,18 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>S4Hooks</RootNamespace>
<ProjectName>S4ModApi</ProjectName>
<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>v141_xp</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug142|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand All @@ -46,9 +38,6 @@
<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 Condition="'$(Configuration)|$(Platform)'=='Debug142|Win32'" Label="PropertySheets">
<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>
Expand All @@ -60,13 +49,6 @@
<SourcePath>$(ProjectDir)lib;$(SourcePath)</SourcePath>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug142|Win32'">
<LinkIncremental>true</LinkIncremental>
<LibraryPath>$(ProjectDir)lib\lua321\Release\;$(ProjectDir)lib\$(Configuration)\;$(LibraryPath)</LibraryPath>
<IncludePath>$(ProjectDir)lib\lua321\include\;$(ProjectDir)lib\;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
<SourcePath>$(ProjectDir)lib;$(SourcePath)</SourcePath>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<LibraryPath>$(ProjectDir)lib\lua321\Release\;$(ProjectDir)lib\$(Configuration)\;$(LibraryPath)</LibraryPath>
Expand Down Expand Up @@ -100,32 +82,6 @@
<NullTerminateStrings>true</NullTerminateStrings>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug142|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;S4MODAPI;_DEBUG;S4MODAPI_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<CreateHotpatchableImage>true</CreateHotpatchableImage>
<UseFullPaths>false</UseFullPaths>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<AdditionalOptions>/D_WIN32_WINNT=0x0501 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<CreateHotPatchableImage>Enabled</CreateHotPatchableImage>
<AdditionalDependencies>Precompiled.lib;Lua321.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>if exist "$(OutDir)deploy.bat" (call "$(OutDir)deploy.bat" )</Command>
</PostBuildEvent>
<ResourceCompile>
<NullTerminateStrings>true</NullTerminateStrings>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
Expand Down

0 comments on commit 4c321c3

Please sign in to comment.