Skip to content

Commit 14258bc

Browse files
committed
API v1
* promote v0 to v1 * swap to references instead of pointers * update `GameState` hooks * update documentation * fix incorrect naming of `IGameState::OnUpdate` to `OnTick` * rename `GameStates::Add` to `AddHook` * split `GameState` hooks to before/after hooks for more granular control and better verbosity * add `EMainReason::Run` for notifying plugins about entry to `CRunningState` * add NOMINMAX preprocessor define
1 parent 588936e commit 14258bc

33 files changed

Lines changed: 503 additions & 469 deletions

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ else()
111111
RED4EXT_STATIC_LIB
112112
PRIVATE
113113
WIN32_LEAN_AND_MEAN
114+
NOMINMAX
114115
)
115116

116117
if(RED4EXT_USE_PCH)

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ foreach(EXAMPLE_PATH ${EXAMPLE_PATHS})
1313
set_target_properties(${EXAMPLE_NAME} PROPERTIES FOLDER "Examples")
1414
target_link_libraries(${EXAMPLE_NAME} PRIVATE RED4ext::SDK)
1515

16-
target_compile_definitions(${EXAMPLE_NAME} PRIVATE WIN32_LEAN_AND_MEAN)
16+
target_compile_definitions(${EXAMPLE_NAME} PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX)
1717
endif()
1818
endforeach()

include/RED4ext/Api/EMainReason.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace RED4ext
1010
enum class EMainReason : uint8_t
1111
{
1212
Load = 0,
13-
Unload
13+
Unload,
14+
Run
1415
};
1516
} // namespace RED4ext

include/RED4ext/Api/FileVer.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#pragma once
22

3-
#include <RED4ext/Api/v0/FileVer.hpp>
3+
#include <RED4ext/Api/v1/FileVer.hpp>
44

55
/**
66
* @brief Creates a file version using the latest version info type.
77
*/
8-
#define RED4EXT_FILEVER(major, minor, build, revision) RED4EXT_V0_FILEVER(major, minor, build, revision)
8+
#define RED4EXT_FILEVER(major, minor, build, revision) RED4EXT_V1_FILEVER(major, minor, build, revision)
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#pragma once
22

3-
#include <Windows.h>
4-
53
namespace RED4ext
64
{
75
/**
86
* @brief The identifier of the plugin.
97
*/
10-
using PluginHandle = HMODULE;
8+
using PluginHandle = void*;
119
} // namespace RED4ext

include/RED4ext/Api/Runtime.hpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
#pragma once
22

3-
#include <RED4ext/Api/v0/Runtime.hpp>
3+
#include <RED4ext/Api/v1/Runtime.hpp>
44

5-
#define RED4EXT_RUNTIME_1_50 RED4EXT_V0_RUNTIME_1_50
6-
#define RED4EXT_RUNTIME_1_50_HOTFIX_1 RED4EXT_V0_RUNTIME_1_50_HOTFIX_1
7-
#define RED4EXT_RUNTIME_1_50_HOTFIX_2 RED4EXT_V0_RUNTIME_1_50_HOTFIX_2
8-
#define RED4EXT_RUNTIME_1_52 RED4EXT_V0_RUNTIME_1_52
9-
#define RED4EXT_RUNTIME_1_52_HOTFIX_1 RED4EXT_V0_RUNTIME_1_52_HOTFIX_1
10-
#define RED4EXT_RUNTIME_1_60 RED4EXT_V0_RUNTIME_1_60
11-
#define RED4EXT_RUNTIME_1_61 RED4EXT_V0_RUNTIME_1_61
12-
#define RED4EXT_RUNTIME_1_61_HOTFIX_1 RED4EXT_V0_RUNTIME_1_61_HOTFIX_1
13-
#define RED4EXT_RUNTIME_1_62 RED4EXT_V0_RUNTIME_1_62
14-
#define RED4EXT_RUNTIME_1_62_HOTFIX_1 RED4EXT_V0_RUNTIME_1_62_HOTFIX_1
15-
#define RED4EXT_RUNTIME_1_63 RED4EXT_V0_RUNTIME_1_63
16-
#define RED4EXT_RUNTIME_1_63_HOTFIX_1 RED4EXT_V0_RUNTIME_1_63_HOTFIX_1
17-
#define RED4EXT_RUNTIME_2_00 RED4EXT_V0_RUNTIME_2_00
18-
#define RED4EXT_RUNTIME_2_01 RED4EXT_V0_RUNTIME_2_01
19-
#define RED4EXT_RUNTIME_2_02 RED4EXT_V0_RUNTIME_2_02
20-
#define RED4EXT_RUNTIME_2_10 RED4EXT_V0_RUNTIME_2_10
21-
#define RED4EXT_RUNTIME_2_11 RED4EXT_V0_RUNTIME_2_11
22-
#define RED4EXT_RUNTIME_2_12 RED4EXT_V0_RUNTIME_2_12
23-
#define RED4EXT_RUNTIME_2_12_HOTFIX_1 RED4EXT_V0_RUNTIME_2_12_HOTFIX_1
24-
#define RED4EXT_RUNTIME_2_13 RED4EXT_V0_RUNTIME_2_13
25-
#define RED4EXT_RUNTIME_2_20 RED4EXT_V0_RUNTIME_2_20
26-
#define RED4EXT_RUNTIME_2_21 RED4EXT_V0_RUNTIME_2_21
5+
#define RED4EXT_RUNTIME_1_50 RED4EXT_V1_RUNTIME_1_50
6+
#define RED4EXT_RUNTIME_1_50_HOTFIX_1 RED4EXT_V1_RUNTIME_1_50_HOTFIX_1
7+
#define RED4EXT_RUNTIME_1_50_HOTFIX_2 RED4EXT_V1_RUNTIME_1_50_HOTFIX_2
8+
#define RED4EXT_RUNTIME_1_52 RED4EXT_V1_RUNTIME_1_52
9+
#define RED4EXT_RUNTIME_1_52_HOTFIX_1 RED4EXT_V1_RUNTIME_1_52_HOTFIX_1
10+
#define RED4EXT_RUNTIME_1_60 RED4EXT_V1_RUNTIME_1_60
11+
#define RED4EXT_RUNTIME_1_61 RED4EXT_V1_RUNTIME_1_61
12+
#define RED4EXT_RUNTIME_1_61_HOTFIX_1 RED4EXT_V1_RUNTIME_1_61_HOTFIX_1
13+
#define RED4EXT_RUNTIME_1_62 RED4EXT_V1_RUNTIME_1_62
14+
#define RED4EXT_RUNTIME_1_62_HOTFIX_1 RED4EXT_V1_RUNTIME_1_62_HOTFIX_1
15+
#define RED4EXT_RUNTIME_1_63 RED4EXT_V1_RUNTIME_1_63
16+
#define RED4EXT_RUNTIME_1_63_HOTFIX_1 RED4EXT_V1_RUNTIME_1_63_HOTFIX_1
17+
#define RED4EXT_RUNTIME_2_00 RED4EXT_V1_RUNTIME_2_00
18+
#define RED4EXT_RUNTIME_2_01 RED4EXT_V1_RUNTIME_2_01
19+
#define RED4EXT_RUNTIME_2_02 RED4EXT_V1_RUNTIME_2_02
20+
#define RED4EXT_RUNTIME_2_10 RED4EXT_V1_RUNTIME_2_10
21+
#define RED4EXT_RUNTIME_2_11 RED4EXT_V1_RUNTIME_2_11
22+
#define RED4EXT_RUNTIME_2_12 RED4EXT_V1_RUNTIME_2_12
23+
#define RED4EXT_RUNTIME_2_12_HOTFIX_1 RED4EXT_V1_RUNTIME_2_12_HOTFIX_1
24+
#define RED4EXT_RUNTIME_2_13 RED4EXT_V1_RUNTIME_2_13
25+
#define RED4EXT_RUNTIME_2_20 RED4EXT_V1_RUNTIME_2_20
26+
#define RED4EXT_RUNTIME_2_21 RED4EXT_V1_RUNTIME_2_21
2727

2828
/**
2929
* @brief Supports all game versions.
3030
* @note Only use this if you do not use RED4ext.SDK library, but you want to use RED4ext as a loader only.
3131
*/
32-
#define RED4EXT_RUNTIME_INDEPENDENT RED4EXT_V0_RUNTIME_INDEPENDENT
32+
#define RED4EXT_RUNTIME_INDEPENDENT RED4EXT_V1_RUNTIME_INDEPENDENT
3333

3434
/*
3535
* @brief The latest game version.
3636
*/
37-
#define RED4EXT_RUNTIME_LATEST RED4EXT_V0_RUNTIME_LATEST
37+
#define RED4EXT_RUNTIME_LATEST RED4EXT_V1_RUNTIME_LATEST

include/RED4ext/Api/Sdk.hpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,59 @@
11
#pragma once
22

3-
#include <RED4ext/Api/v0/PluginInfo.hpp>
4-
#include <RED4ext/Api/v0/Sdk.hpp>
3+
#include <RED4ext/Api/v1/PluginInfo.hpp>
4+
#include <RED4ext/Api/v1/Sdk.hpp>
55

66
namespace RED4ext
77
{
88
/**
99
* @brief The latest plugin info type.
1010
*/
11-
using PluginInfo = v0::PluginInfo;
11+
using PluginInfo = v1::PluginInfo;
1212

1313
/**
1414
* @brief The latest version info type.
1515
*/
16-
using SemVer = v0::SemVer;
16+
using SemVer = v1::SemVer;
1717

1818
/**
1919
* @brief The latest version info type.
2020
*/
21-
using FileVer = v0::FileVer;
21+
using FileVer = v1::FileVer;
2222

2323
/**
2424
* @brief The latest RED4ext.
2525
*/
26-
using Sdk = v0::Sdk;
26+
using Sdk = v1::Sdk;
2727

2828
/**
29-
* @brief The latest hooking.
29+
* @brief The latest logger.
3030
*/
31-
using Logger = v0::Logger;
31+
using Logger = v1::Logger;
3232

3333
/**
3434
* @brief The latest hooking.
3535
*/
36-
using Hooking = v0::Hooking;
36+
using Hooking = v1::Hooking;
37+
38+
/**
39+
* @brief The latest game state handler.
40+
*/
41+
using GameStates = v1::GameStates;
3742

3843
/**
39-
* @brief The latest game state type.
44+
* @brief The latest game state for hooking.
4045
*/
41-
using GameStates = v0::GameStates;
46+
using GameState = v1::GameState;
4247

4348
/**
44-
* @brief The latest game state type.
49+
* @brief The latest scripts compiler interface.
4550
*/
46-
using GameState = v0::GameState;
51+
using Scripts = v1::Scripts;
4752

4853
/**
49-
* @brief The latest game state type.
54+
* @brief The latest game state hook result.
5055
*/
51-
using Scripts = v0::Scripts;
56+
using EGameStateResult = v1::EGameStateResult;
5257
} // namespace RED4ext
5358

5459
/*
@@ -60,5 +65,5 @@ using Scripts = v0::Scripts;
6065
*/
6166
#ifndef RED4EXT_OFFSET_TO_ADDR
6267
#define RED4EXT_OFFSET_TO_ADDR(offset) \
63-
reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(GetModuleHandle(nullptr)) + offset)
68+
reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(GetModuleHandleW(nullptr)) + offset)
6469
#endif

include/RED4ext/Api/SemVer.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#pragma once
22

3-
#include <RED4ext/Api/v0/SemVer.hpp>
3+
#include <RED4ext/Api/v1/SemVer.hpp>
44

55
/**
66
* @brief Creates a semantic version using the latest version info type.
77
*/
88
#define RED4EXT_SEMVER_EX(major, minor, patch, prereleaseType, prereleaseNumber) \
9-
RED4EXT_V0_SEMVER_EX(major, minor, patch, prereleaseType, prereleaseNumber)
9+
RED4EXT_V1_SEMVER_EX(major, minor, patch, prereleaseType, prereleaseNumber)
1010

1111
/**
1212
* @brief Creates a semantic version using the latest version info type.
1313
*/
14-
#define RED4EXT_SEMVER(major, minor, patch) RED4EXT_V0_SEMVER(major, minor, patch)
14+
#define RED4EXT_SEMVER(major, minor, patch) RED4EXT_V1_SEMVER(major, minor, patch)

include/RED4ext/Api/Version.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#pragma once
22

3-
#include <RED4ext/Api/v0/Version.hpp>
3+
#include <RED4ext/Api/v1/Version.hpp>
44

55
/*
66
* The SDK is using only one API version, the reason behind that is that multiple versions for every structure is
@@ -15,17 +15,18 @@
1515
*/
1616

1717
#define RED4EXT_API_VERSION_0 0
18-
#define RED4EXT_API_VERSION_LATEST RED4EXT_API_VERSION_0
18+
#define RED4EXT_API_VERSION_1 1
19+
#define RED4EXT_API_VERSION_LATEST RED4EXT_API_VERSION_1
1920

2021
/*
2122
* The SDK version, it is maninly used to reject loading plugin that are using a broken SDK version, while API version
2223
* is 0, it is used to load only plugins using the latest SDK version.
2324
*/
2425

25-
#define RED4EXT_SDK_0_1_0 RED4EXT_V0_SDK_0_1_0
26-
#define RED4EXT_SDK_0_2_0 RED4EXT_V0_SDK_0_2_0
27-
#define RED4EXT_SDK_0_3_0 RED4EXT_V0_SDK_0_3_0
28-
#define RED4EXT_SDK_0_4_0 RED4EXT_V0_SDK_0_4_0
29-
#define RED4EXT_SDK_0_5_0 RED4EXT_V0_SDK_0_5_0
26+
#define RED4EXT_SDK_0_1_0 RED4EXT_V1_SDK_0_1_0
27+
#define RED4EXT_SDK_0_2_0 RED4EXT_V1_SDK_0_2_0
28+
#define RED4EXT_SDK_0_3_0 RED4EXT_V1_SDK_0_3_0
29+
#define RED4EXT_SDK_0_4_0 RED4EXT_V1_SDK_0_4_0
30+
#define RED4EXT_SDK_0_5_0 RED4EXT_V1_SDK_0_5_0
3031

31-
#define RED4EXT_SDK_LATEST RED4EXT_V0_SDK_LATEST
32+
#define RED4EXT_SDK_LATEST RED4EXT_V1_SDK_LATEST

include/RED4ext/Api/v0/FileVer.hpp

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)