Skip to content

Commit

Permalink
Merge pull request #4 from Silver-Ore-Team/fix-3
Browse files Browse the repository at this point in the history
#3 Code triggers compiler warnings with `/W4 ` flag
  • Loading branch information
muczc1wek authored Oct 1, 2024
2 parents 1d99067 + 0eaf72c commit 8cd3374
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
28 changes: 17 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.25)
project(zMultilogue VERSION 0.0.1 LANGUAGES CXX)

set(PLUGIN_NAME zMultilogue)

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
set(GOTHIC_API_G1 OFF)
set(GOTHIC_API_G1A OFF)
set(GOTHIC_API_G2 OFF)
set(GOTHIC_API_G2A ON)
FetchContent_Declare(
union-api
GIT_REPOSITORY https://gitlab.com/union-framework/union-api.git
Expand All @@ -20,15 +22,19 @@ FetchContent_Declare(
FetchContent_MakeAvailable(union-api)
FetchContent_MakeAvailable(gothic-api)

add_library(${PLUGIN_NAME} SHARED)
target_link_libraries(${PLUGIN_NAME} PRIVATE union_api_lib gothic_api)
target_include_directories(${PLUGIN_NAME} PRIVATE src)
target_include_directories(${PLUGIN_NAME} PRIVATE BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/userapi)


add_library(zMultilogue SHARED)
target_link_libraries(zMultilogue PRIVATE union_api_lib gothic_api)
target_include_directories(zMultilogue PRIVATE src)
target_include_directories(zMultilogue PRIVATE BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/userapi)
file(GLOB_RECURSE SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/**.cpp")
target_sources(${PLUGIN_NAME} PRIVATE ${SOURCES})
target_sources(zMultilogue PRIVATE ${SOURCES})

target_compile_options(${PLUGIN_NAME} PRIVATE
/permissive- /std:c++latest /Zc:__cplusplus /Zc:preprocessor /utf-8
/experimental:external /external:W0 /external:anglebrackets
/external:I ${CMAKE_BINARY_DIR}/_deps/gothic-api-src

target_compile_options(zMultilogue PRIVATE
/W4 /permissive- /std:c++latest /Zc:__cplusplus /Zc:preprocessor /utf-8
/experimental:external /external:W0 /external:anglebrackets /external:templates-
/external:I ${CMAKE_BINARY_DIR}/_deps
)

17 changes: 8 additions & 9 deletions src/Gothic/Hooks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace GOTHIC_NAMESPACE {
// G2: 0x00677A00 private: void __thiscall oCGame::DefineExternals_Ulfi(class zCParser *)
// G2A: 0x006D4780 private: void __thiscall oCGame::DefineExternals_Ulfi(class zCParser *)
void* oCGame_DefineExternals_Ulfi = reinterpret_cast<void*>(zSwitch(0x006495B0, 0x006715F0, 0x00677A00, 0x006D4780));
void __fastcall DefineExternals_Ulfi_PartialHook(Union::Registers& reg)
void __fastcall DefineExternals_Ulfi_PartialHook()
{
DefineExternals();
}
Expand All @@ -27,20 +27,19 @@ namespace GOTHIC_NAMESPACE {
// }

auto Ivk_oCNpc_EV_Exchange = Union::CreateHook(reinterpret_cast<void*>(0x00753E30), &oCNpc::EV_Exchange_Hook);
int oCNpc::EV_Exchange_Hook( oCMsgManipulate* csg ) {
zSTRING slot = csg->slot;
if(slot) {
if (slot.Upper() == "EV_FINISH") {
int oCNpc::EV_Exchange_Hook( oCMsgManipulate* msg ) {
zSTRING msgSlot = msg->slot;
if (msgSlot) {
if (msgSlot.Upper() == "EV_FINISH") {
zMultilogue.EV_Finish();
return TRUE;
}
if (slot.Upper() == "EV_NEXT") {
zMultilogue.EV_Next(csg->flag);
if (msgSlot.Upper() == "EV_NEXT") {
zMultilogue.EV_Next(msg->flag);
return TRUE;
}

}
return (this->*Ivk_oCNpc_EV_Exchange)(csg);
return (this->*Ivk_oCNpc_EV_Exchange)(msg);
}


Expand Down
2 changes: 1 addition & 1 deletion src/NH/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace NH

void SetLoggerLevel(LoggerLevel level)
{
for (int i = 0; i < m_Adapters.GetCount(); i++)
for (size_t i = 0; i < m_Adapters.GetCount(); i++)
{
m_Adapters[i]->SetLoggerLevel(level);
}
Expand Down
6 changes: 2 additions & 4 deletions src/Plugin.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// Disable macro redefinition warning
#pragma warning(disable: 4005)

#include <Union/Hook.h>
#include <NH/Logger.h>
#include <ZenGin/zGothicAPI.h>

#include "NH/Logger.h"

#ifdef __G2A
#define GOTHIC_NAMESPACE Gothic_II_Addon
#define ENGINE Engine_G2A
Expand Down
10 changes: 5 additions & 5 deletions src/Plugin.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <Gothic/zMul_Helper.hpp>
#include <Gothic/zMul_Camera.hpp>
#include <Gothic/zMultilogue.hpp>
#include <Gothic/Externals.hpp>
#include <Gothic/Hooks.hpp>
#include "Gothic/zMul_Helper.hpp"
#include "Gothic/zMul_Camera.hpp"
#include "Gothic/zMultilogue.hpp"
#include "Gothic/Externals.hpp"
#include "Gothic/Hooks.hpp"

0 comments on commit 8cd3374

Please sign in to comment.