Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions Core_Fix_LoadFileLimited/Core.LoadFileLimitedFix.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using BepInEx;
using HarmonyLib;
using Common;
using System.Collections.Generic;
using System.Reflection.Emit;

namespace Core_Fix_LoadFileLimited
{
[BepInPlugin(GUID, PluginName, Constants.PluginsVersion)]
public class LoadFileLimitedFix : BaseUnityPlugin
{
public const string GUID = "LoadFileLmitedFix";
public const string PluginName = "LoadFileLimitedFix";

internal void Awake()
{
Harmony.CreateAndPatchAll(typeof(Hooks));
}

internal class Hooks
{
// Makes ChaFileControl.LoadFileLimited (used by Maker to partially load a character) overwrite the charaFileName property whenever new parameters are loaded.
// This should keep the value of that property and the character the player thinks of as currently loaded in sync.
[HarmonyTranspiler]
[HarmonyPatch(typeof(ChaFileControl), nameof(ChaFileControl.LoadFileLimited), typeof(string), typeof(byte), typeof(bool), typeof(bool), typeof(bool), typeof(bool), typeof(bool)
#if KKS
,typeof(bool)
#endif
)]
private static IEnumerable<CodeInstruction> MakeLoadLimitedCopyCardFileNameTooWhenCopyingParameters(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
List<CodeInstruction> code = new List<CodeInstruction>(instructions);

CodeMatcher cm = new CodeMatcher(instructions, generator);

// match [this.parameter.Copy(chaFileControl.parameter);]
cm.MatchForward(false, new CodeMatch(OpCodes.Callvirt, AccessTools.Method(typeof(ChaFileParameter), nameof(ChaFileParameter.Copy))));
// insert [base.charaFileName = chaFileControl.charaFileName;]
cm.InsertAndAdvance(
new CodeInstruction(OpCodes.Ldarg_0),
new CodeInstruction(OpCodes.Ldloc_1),
new CodeInstruction(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(ChaFile), nameof(ChaFile.charaFileName))),
new CodeInstruction(OpCodes.Call, AccessTools.PropertySetter(typeof(ChaFile), nameof(ChaFile.charaFileName)))
);

return cm.Instructions();
}
}
}
}
15 changes: 15 additions & 0 deletions Core_Fix_LoadFileLimited/Core_Fix_LoadFileLimited.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>c26c16e5-9a33-42c2-a0b2-5d0c16361ab9</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Core_Fix_LoadFileLimited</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Core.LoadFileLimitedFix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Core.LoadFileLimitedFix.Hooks.cs" />
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions Core_Fix_LoadFileLimited/Core_Fix_LoadFileLimited.shproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>c26c16e5-9a33-42c2-a0b2-5d0c16361ab9</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Core_Fix_LoadFileLimited.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
24 changes: 24 additions & 0 deletions IllusionFixes.sln
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Fix_LoadFileLimited", "Fix_LoadFileLimited", "{8157F835-C618-4A68-9B6D-ABBBF9602A8B}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Core_Fix_LoadFileLimited", "Core_Fix_LoadFileLimited\Core_Fix_LoadFileLimited.shproj", "{C26C16E5-9A33-42C2-A0B2-5D0C16361AB9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KK_Fix_LoadFileLimited", "KK_Fix_LoadFileLimited\KK_Fix_LoadFileLimited.csproj", "{51E42BBE-E0CC-4C9B-8B7D-C2E9B2159002}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KKS_Fix_LoadFileLimited", "KKS_Fix_LoadFileLimited\KKS_Fix_LoadFileLimited.csproj", "{B39DADD0-4BC0-4C6D-B121-90E3F3F29EA7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -758,6 +766,14 @@ Global
{27D21C00-8152-4D1F-8A1C-1DC2E875AF3F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27D21C00-8152-4D1F-8A1C-1DC2E875AF3F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27D21C00-8152-4D1F-8A1C-1DC2E875AF3F}.Release|Any CPU.Build.0 = Release|Any CPU
{51E42BBE-E0CC-4C9B-8B7D-C2E9B2159002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{51E42BBE-E0CC-4C9B-8B7D-C2E9B2159002}.Debug|Any CPU.Build.0 = Debug|Any CPU
{51E42BBE-E0CC-4C9B-8B7D-C2E9B2159002}.Release|Any CPU.ActiveCfg = Release|Any CPU
{51E42BBE-E0CC-4C9B-8B7D-C2E9B2159002}.Release|Any CPU.Build.0 = Release|Any CPU
{B39DADD0-4BC0-4C6D-B121-90E3F3F29EA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B39DADD0-4BC0-4C6D-B121-90E3F3F29EA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B39DADD0-4BC0-4C6D-B121-90E3F3F29EA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B39DADD0-4BC0-4C6D-B121-90E3F3F29EA7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -876,6 +892,9 @@ Global
{C68CDDBC-570F-403A-92E3-B44EB3A31D31} = {1EF89218-A9E1-492D-8F37-61B2F1668886}
{018A823B-2248-419E-8A7A-3F7E4D65FDA9} = {40715440-0FF3-47D1-BC1F-96AC7FDAF26E}
{27D21C00-8152-4D1F-8A1C-1DC2E875AF3F} = {BA2338CF-E35A-4ABA-BF89-8538E433B29D}
{C26C16E5-9A33-42C2-A0B2-5D0C16361AB9} = {8157F835-C618-4A68-9B6D-ABBBF9602A8B}
{51E42BBE-E0CC-4C9B-8B7D-C2E9B2159002} = {8157F835-C618-4A68-9B6D-ABBBF9602A8B}
{B39DADD0-4BC0-4C6D-B121-90E3F3F29EA7} = {8157F835-C618-4A68-9B6D-ABBBF9602A8B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D3F10C8B-FD6C-43DA-94B4-1D9688BBE11B}
Expand Down Expand Up @@ -940,6 +959,8 @@ Global
src\Common\Common.projitems*{5065ba00-d9ad-4e37-a2b5-5b7e369c10cf}*SharedItemsImports = 4
src\Core_Fix_PoseLoad\Core_Fix_PoseLoad.projitems*{50b014d7-1d96-47b7-a3b5-f1d682073f0a}*SharedItemsImports = 13
src\Common\Common.projitems*{517cb02c-cb77-4746-ac5a-14d1fecc0cb8}*SharedItemsImports = 4
Core_Fix_LoadFileLimited\Core_Fix_LoadFileLimited.projitems*{51e42bbe-e0cc-4c9b-8b7d-c2e9b2159002}*SharedItemsImports = 4
src\Common\Common.projitems*{51e42bbe-e0cc-4c9b-8b7d-c2e9b2159002}*SharedItemsImports = 4
src\Common\Common.projitems*{51f20404-6a48-4578-b994-ff0a867ef2c0}*SharedItemsImports = 4
src\Common\Common.projitems*{52d92c5e-f220-473c-b683-bd17198efd32}*SharedItemsImports = 4
src\Common\Common.projitems*{541ed181-1370-47f1-9d95-6187ee59686c}*SharedItemsImports = 4
Expand Down Expand Up @@ -1034,6 +1055,8 @@ Global
src\Common\Common.projitems*{b02ce742-4626-4d73-9e2a-8789eff525e9}*SharedItemsImports = 4
src\Common\Common.projitems*{b211581c-80f2-422d-8180-46b0228aae2c}*SharedItemsImports = 4
src\Core_Fix_CameraTarget\Core_Fix_CameraTarget.projitems*{b211581c-80f2-422d-8180-46b0228aae2c}*SharedItemsImports = 4
Core_Fix_LoadFileLimited\Core_Fix_LoadFileLimited.projitems*{b39dadd0-4bc0-4c6d-b121-90e3f3f29ea7}*SharedItemsImports = 4
src\Common\Common.projitems*{b39dadd0-4bc0-4c6d-b121-90e3f3f29ea7}*SharedItemsImports = 4
src\Common\Common.projitems*{b3a37bdb-238f-47a7-9a73-1c15ea1a05ab}*SharedItemsImports = 4
src\Core_Fix_StudioOptimizations\Core_Fix_StudioOptimizations.projitems*{b3a37bdb-238f-47a7-9a73-1c15ea1a05ab}*SharedItemsImports = 4
src\Common\Common.projitems*{b50199ca-ba76-4628-8e86-2a2b40e40520}*SharedItemsImports = 4
Expand All @@ -1042,6 +1065,7 @@ Global
src\Common\Common.projitems*{be04b9fb-6862-49df-a8d1-26e185f0d9b8}*SharedItemsImports = 4
src\Common\Common.projitems*{bf58115b-8249-4f38-9f73-96cddda819e1}*SharedItemsImports = 4
src\Core_Fix_CameraTarget\Core_Fix_CameraTarget.projitems*{bf58115b-8249-4f38-9f73-96cddda819e1}*SharedItemsImports = 4
Core_Fix_LoadFileLimited\Core_Fix_LoadFileLimited.projitems*{c26c16e5-9a33-42c2-a0b2-5d0c16361ab9}*SharedItemsImports = 13
src\Common\Common.projitems*{c2d1e929-6936-4b1d-921d-ed11a7504e38}*SharedItemsImports = 4
src\Core_Fix_Heterochromia\Core_Fix_Heterochromia.projitems*{c2d1e929-6936-4b1d-921d-ed11a7504e38}*SharedItemsImports = 4
src\Common\Common.projitems*{c68cddbc-570f-403a-92e3-b44eb3a31d31}*SharedItemsImports = 4
Expand Down
91 changes: 91 additions & 0 deletions KKS_Fix_LoadFileLimited/KKS_Fix_LoadFileLimited.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B39DADD0-4BC0-4C6D-B121-90E3F3F29EA7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>KKS_Fix_LoadFileLimited</RootNamespace>
<AssemblyName>KKS_Fix_LoadFileLimited</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG;KKS</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.9.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.BepInEx.Harmony.2.9.0\lib\net35\0Harmony.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.9.17\lib\net46\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BepInEx, Version=5.4.22.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.BepInEx.5.4.22\lib\net35\BepInEx.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Sirenix.Serialization, Version=2.1.13.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\lib\net46\Sirenix.Serialization.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\lib\net46\UnityEngine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\lib\net46\UnityEngine.CoreModule.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="..\Core_Fix_LoadFileLimited\Core_Fix_LoadFileLimited.projitems" Label="Shared" />
<Import Project="..\src\Common\Common.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\IllusionLibs.BepInEx.Harmony.2.9.0\build\IllusionLibs.BepInEx.Harmony.targets" Condition="Exists('..\packages\IllusionLibs.BepInEx.Harmony.2.9.0\build\IllusionLibs.BepInEx.Harmony.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>Dieses Projekt verweist auf mindestens ein NuGet-Paket, das auf diesem Computer fehlt. Verwenden Sie die Wiederherstellung von NuGet-Paketen, um die fehlenden Dateien herunterzuladen. Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkID=322105". Die fehlende Datei ist "{0}".</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\IllusionLibs.BepInEx.Harmony.2.9.0\build\IllusionLibs.BepInEx.Harmony.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IllusionLibs.BepInEx.Harmony.2.9.0\build\IllusionLibs.BepInEx.Harmony.targets'))" />
<Error Condition="!Exists('..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\build\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\build\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.targets'))" />
<Error Condition="!Exists('..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.9.17\build\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.9.17\build\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.targets'))" />
</Target>
<Import Project="..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\build\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.targets" Condition="Exists('..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\build\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.targets')" />
<Import Project="..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.9.17\build\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.targets" Condition="Exists('..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.9.17\build\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.targets')" />
</Project>
7 changes: 7 additions & 0 deletions KKS_Fix_LoadFileLimited/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="IllusionLibs.BepInEx" version="5.4.22" targetFramework="net46" />
<package id="IllusionLibs.BepInEx.Harmony" version="2.9.0" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.Assembly-CSharp" version="2021.9.17" targetFramework="net46" />
<package id="IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule" version="2019.4.9" targetFramework="net46" />
</packages>
Loading