Skip to content

Commit

Permalink
WIP of xrAI and xrSE_Factory. Load xrSE_Factory only for spawn build.…
Browse files Browse the repository at this point in the history
… Some headers cleanup.
  • Loading branch information
intorr committed Dec 31, 2017
1 parent fc17faa commit 9593f1d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
2 changes: 2 additions & 0 deletions src/utils/xrAI/factory_api.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "xrServer_Object_Base.h"

extern "C" {
typedef XR_IMPORT IServerEntity* __stdcall Factory_Create(LPCSTR section);
typedef XR_IMPORT void __stdcall Factory_Destroy(IServerEntity*&);
Expand Down
2 changes: 0 additions & 2 deletions src/utils/xrAI/game_spawn_constructor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

#include "alife_space.h"
#include "xr_graph_merge.h"
#include "utils/xrLCUtil/xrThread.hpp"
#include "xrAICore/Navigation/graph_abstract.h"
#include "xrServer_Object_Base.h"
#include "spawn_constructor_space.h"
#include "server_entity_wrapper.h"
#include "guid_generator.h"
Expand Down
48 changes: 23 additions & 25 deletions src/utils/xrAI/xrAI.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#include "stdafx.h"
#include "xrCore/xr_ini.h"
#include <process.h>
#include "xrAI.h"

#include "xr_graph_merge.h"
#include "game_spawn_constructor.h"
#include "xrCrossTable.h"

#include "game_graph_builder.h"
#include <mmsystem.h>
#include "spawn_patcher.h"

#pragma comment(linker, "/STACK:0x800000,0x400000")

Expand All @@ -18,6 +12,11 @@
#include "xrCore/cdecl_cast.hpp"
#include "xrCore/ModuleLookup.hpp"

#include "factory_api.h"

Factory_Create* create_entity = 0;
Factory_Destroy* destroy_entity = 0;

LevelCompilerLoggerWindow& Logger = LevelCompilerLoggerWindow();

CThread::LogFunc ProxyMsg = cdecl_cast([](const char* format, ...) {
Expand Down Expand Up @@ -126,7 +125,25 @@ void execute(LPSTR cmd)
}
char* no_separator_check = strstr(cmd, "-no_separator_check");
clear_temp_folder();

const auto hFactory = std::make_unique<XRay::Module>("xrSE_Factory");

if (!hFactory->exist())
R_CHK(GetLastError());
R_ASSERT2(hFactory->exist(), "Factory DLL raised exception during loading or there is no factory DLL at all");

create_entity = (Factory_Create*)hFactory->getProcAddress("_create_entity@4");
R_ASSERT(create_entity);

destroy_entity = (Factory_Destroy*)hFactory->getProcAddress("_destroy_entity@4");
R_ASSERT(destroy_entity);

CGameSpawnConstructor(name, output, start, !!no_separator_check);

hFactory->close();

create_entity = nullptr;
destroy_entity = nullptr;
}
else if (strstr(cmd, "-verify"))
{
Expand Down Expand Up @@ -169,32 +186,13 @@ void Startup(LPSTR lpCmdLine)
Logger.Destroy();
}

#include "factory_api.h"

Factory_Create* create_entity = 0;
Factory_Destroy* destroy_entity = 0;

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
xrDebug::Initialize(false);
Core.Initialize("xrai", 0);

const auto hFactory = std::make_unique<XRay::Module>("xrSE_Factory");

if (!hFactory->exist())
R_CHK(GetLastError());
R_ASSERT2(hFactory->exist(), "Factory DLL raised exception during loading or there is no factory DLL at all");

create_entity = (Factory_Create*)hFactory->getProcAddress("_create_entity@4");
R_ASSERT(create_entity);

destroy_entity = (Factory_Destroy*)hFactory->getProcAddress("_destroy_entity@4");
R_ASSERT(destroy_entity);

Startup(lpCmdLine);

hFactory->close();

Core._destroy();

return (0);
Expand Down

0 comments on commit 9593f1d

Please sign in to comment.