Skip to content

Commit

Permalink
Update 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyrest committed Jun 20, 2021
1 parent bfe1325 commit 4dcf37e
Show file tree
Hide file tree
Showing 12 changed files with 229 additions and 7 deletions.
1 change: 1 addition & 0 deletions PriorityMod.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Root", "Root", "{D8F32DB4-3
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
build.bat = build.bat
pack.bat = pack.bat
pack.csx = pack.csx
PriorityMod.toml = PriorityMod.toml
EndProjectSection
Expand Down
12 changes: 10 additions & 2 deletions PriorityMod/PriorityMod.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
Expand Down Expand Up @@ -152,18 +152,24 @@
<PrecompiledHeaderFile>
</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
<CallingConvention>StdCall</CallingConvention>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateDebugInformation>false</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="common.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="Targets\Fallout3.cpp" />
<ClInclude Include="Targets\NewVegas.cpp" />
<ClInclude Include="Targets\Oblivion.cpp" />
<ClInclude Include="Targets\SkyrimSE.cpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
Expand All @@ -173,6 +179,8 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Targets\Fallout4.cpp" />
<ClCompile Include="Targets\Oldrim.cpp" />
<ClCompile Include="toml.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
24 changes: 24 additions & 0 deletions PriorityMod/PriorityMod.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Targets">
<UniqueIdentifier>{6a53091c-4f08-4253-a437-5f360937c238}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
Expand All @@ -17,6 +20,21 @@
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="common.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Targets\SkyrimSE.cpp">
<Filter>Targets</Filter>
</ClInclude>
<ClInclude Include="Targets\NewVegas.cpp">
<Filter>Targets</Filter>
</ClInclude>
<ClInclude Include="Targets\Oblivion.cpp">
<Filter>Targets</Filter>
</ClInclude>
<ClInclude Include="Targets\Fallout3.cpp">
<Filter>Targets</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
Expand All @@ -28,5 +46,11 @@
<ClCompile Include="toml.hpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Targets\Fallout4.cpp">
<Filter>Targets</Filter>
</ClCompile>
<ClCompile Include="Targets\Oldrim.cpp">
<Filter>Targets</Filter>
</ClCompile>
</ItemGroup>
</Project>
19 changes: 19 additions & 0 deletions PriorityMod/Targets/Fallout3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "../common.h"

#if !_WIN64
extern "C"
{
DllExport bool FOSEPlugin_Query(const MasterInterface* se, PluginInfo* info)
{
info->name = ModName;
info->infoVersion = PluginInfo::kInfoVersion;
info->version = ModVersion;
return true;
}

DllExport bool FOSEPlugin_Load(const MasterInterface* se)
{
return true;
}
};
#endif
19 changes: 19 additions & 0 deletions PriorityMod/Targets/Fallout4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "../common.h"

#if _WIN64
extern "C"
{
DllExport bool F4SEPlugin_Query(const MasterInterface* se, PluginInfo* info)
{
info->name = ModName;
info->infoVersion = PluginInfo::kInfoVersion;
info->version = ModVersion;
return true;
}

DllExport bool F4SEPlugin_Load(const MasterInterface* se)
{
return true;
}
};
#endif
19 changes: 19 additions & 0 deletions PriorityMod/Targets/NewVegas.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "../common.h"

#if !_WIN64
extern "C"
{
DllExport bool NVSEPlugin_Query(const MasterInterface* se, PluginInfo* info)
{
info->name = ModName;
info->infoVersion = PluginInfo::kInfoVersion;
info->version = ModVersion;
return true;
}

DllExport bool NVSEPlugin_Load(const MasterInterface* se)
{
return true;
}
};
#endif
19 changes: 19 additions & 0 deletions PriorityMod/Targets/Oblivion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "../common.h"

#if !_WIN64
extern "C"
{
DllExport bool OBSEPlugin_Query(const MasterInterface* se, PluginInfo* info)
{
info->name = ModName;
info->infoVersion = PluginInfo::kInfoVersion;
info->version = ModVersion;
return true;
}

DllExport bool OBSEPlugin_Load(const MasterInterface* se)
{
return true;
}
};
#endif
19 changes: 19 additions & 0 deletions PriorityMod/Targets/Oldrim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "../common.h"

#if !_WIN64
extern "C"
{
DllExport bool SKSEPlugin_Query(const MasterInterface* skse, PluginInfo* info)
{
info->name = ModName;
info->infoVersion = PluginInfo::kInfoVersion;;
info->version = ModVersion;
return true;
}

DllExport bool SKSEPlugin_Load(const MasterInterface* skse)
{
return true;
}
};
#endif
19 changes: 19 additions & 0 deletions PriorityMod/Targets/SkyrimSE.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "../common.h"

#if _WIN64
extern "C"
{
DllExport bool SKSEPlugin_Query(const MasterInterface* se, PluginInfo* info)
{
info->name = ModName;
info->infoVersion = PluginInfo::kInfoVersion;
info->version = ModVersion;
return true;
}

DllExport bool SKSEPlugin_Load(const MasterInterface* se)
{
return true;
}
};
#endif
39 changes: 39 additions & 0 deletions PriorityMod/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#pragma once

#define DllExport __declspec( dllexport )

#define ModName "FallrimPriority";
#define ModVersion 3;

typedef unsigned char UInt8; //!< An unsigned 8-bit integer value
typedef unsigned short UInt16; //!< An unsigned 16-bit integer value
typedef unsigned long UInt32; //!< An unsigned 32-bit integer value
typedef unsigned long long UInt64; //!< An unsigned 64-bit integer value
typedef signed char SInt8; //!< A signed 8-bit integer value
typedef signed short SInt16; //!< A signed 16-bit integer value
typedef signed long SInt32; //!< A signed 32-bit integer value
typedef signed long long SInt64; //!< A signed 64-bit integer value
typedef float Float32; //!< A 32-bit floating point value
typedef double Float64; //!< A 64-bit floating point value

typedef UInt32 PluginHandle; // treat this as an opaque type

struct PluginInfo
{
enum
{
kInfoVersion = 1
};

UInt32 infoVersion;
const char* name;
UInt32 version;
};

struct MasterInterface
{
UInt32 obseVersion;
UInt32 oblivionVersion;
UInt32 editorVersion;
UInt32 isEditor;
};
15 changes: 10 additions & 5 deletions PriorityMod/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ toml::parse_result config;

bool ParseConfig()
{
LPTSTR buffer = new TCHAR[_MAX_PATH * 3];
GetModuleFileNameW((HINSTANCE)&__ImageBase, buffer, _MAX_PATH * 3);
LPTSTR buffer = new WCHAR[_MAX_PATH * 3];
GetModuleFileName((HINSTANCE)&__ImageBase, buffer, _MAX_PATH * 3);

wstring filename = buffer;

Expand Down Expand Up @@ -63,6 +63,7 @@ BOOL CALLBACK enum_windows_callback(HWND handle, LPARAM lParam)

void GetGameWindowHandle()
{

do
{
EnumWindows(enum_windows_callback, NULL);
Expand Down Expand Up @@ -146,9 +147,10 @@ BOOL APIENTRY DllMain(HMODULE hModule,
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
// Prevent mod being unloaded from Script Extender
static HMODULE current;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPTSTR)&current, &current);
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPTSTR)&DllMain, &current);

// Prevent mod being unloaded from Script Extender
int priority_classes[] = {
IDLE_PRIORITY_CLASS,
BELOW_NORMAL_PRIORITY_CLASS,
Expand Down Expand Up @@ -185,6 +187,9 @@ BOOL APIENTRY DllMain(HMODULE hModule,
#endif // !_WIN64
#pragma endregion

ApplyAffinity();
ApplyPriority();

if (config["DynamicPriority"]["enabled"].value_or(1))
_beginthread(DynamicPriority, NULL, NULL);

Expand All @@ -195,5 +200,5 @@ BOOL APIENTRY DllMain(HMODULE hModule,
}

}
return false;
return true;
}
31 changes: 31 additions & 0 deletions pack.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@ REM Check DotNet installed
@ WHERE dotnet >nul 2>nul
@ IF %ERRORLEVEL% NEQ 0 goto DotNetNotFound

@ REM Check DotNet-Script available in Path
@ WHERE dotnet-script >nul 2>nul
@ IF %ERRORLEVEL% NEQ 0 goto DotNetScriptNotFound

@ REM Build the solution
@ call build.bat

@ REM Pack
@ dotnet-script pack.csx

@ exit /b

@ REM ========================
@ REM DotNet is not Available
@ REM Throw an exception
:DotNetNotFound
@ echo DotNet is not found. 1>&2
@ echo Make sure DotNet is installed 1>&2
@ exit /b 1

@ REM ========================
@ REM DotNet-Script is not Available
@ REM Throw an exception
:DotNetScriptNotFound
@ echo DotNet-Script is not found. 1>&2
@ echo Install by 'dotnet tool uninstall dotnet-script -g' 1>&2
@ exit /b 1

0 comments on commit 4dcf37e

Please sign in to comment.