Skip to content

Commit 9593f1d

Browse files
committed
WIP of xrAI and xrSE_Factory. Load xrSE_Factory only for spawn build. Some headers cleanup.
1 parent fc17faa commit 9593f1d

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

src/utils/xrAI/factory_api.h

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

3+
#include "xrServer_Object_Base.h"
4+
35
extern "C" {
46
typedef XR_IMPORT IServerEntity* __stdcall Factory_Create(LPCSTR section);
57
typedef XR_IMPORT void __stdcall Factory_Destroy(IServerEntity*&);

src/utils/xrAI/game_spawn_constructor.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
#include "alife_space.h"
1212
#include "xr_graph_merge.h"
13-
#include "utils/xrLCUtil/xrThread.hpp"
1413
#include "xrAICore/Navigation/graph_abstract.h"
15-
#include "xrServer_Object_Base.h"
1614
#include "spawn_constructor_space.h"
1715
#include "server_entity_wrapper.h"
1816
#include "guid_generator.h"

src/utils/xrAI/xrAI.cpp

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
#include "stdafx.h"
2-
#include "xrCore/xr_ini.h"
3-
#include <process.h>
42
#include "xrAI.h"
53

6-
#include "xr_graph_merge.h"
74
#include "game_spawn_constructor.h"
8-
#include "xrCrossTable.h"
95

10-
#include "game_graph_builder.h"
116
#include <mmsystem.h>
12-
#include "spawn_patcher.h"
137

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

@@ -18,6 +12,11 @@
1812
#include "xrCore/cdecl_cast.hpp"
1913
#include "xrCore/ModuleLookup.hpp"
2014

15+
#include "factory_api.h"
16+
17+
Factory_Create* create_entity = 0;
18+
Factory_Destroy* destroy_entity = 0;
19+
2120
LevelCompilerLoggerWindow& Logger = LevelCompilerLoggerWindow();
2221

2322
CThread::LogFunc ProxyMsg = cdecl_cast([](const char* format, ...) {
@@ -126,7 +125,25 @@ void execute(LPSTR cmd)
126125
}
127126
char* no_separator_check = strstr(cmd, "-no_separator_check");
128127
clear_temp_folder();
128+
129+
const auto hFactory = std::make_unique<XRay::Module>("xrSE_Factory");
130+
131+
if (!hFactory->exist())
132+
R_CHK(GetLastError());
133+
R_ASSERT2(hFactory->exist(), "Factory DLL raised exception during loading or there is no factory DLL at all");
134+
135+
create_entity = (Factory_Create*)hFactory->getProcAddress("_create_entity@4");
136+
R_ASSERT(create_entity);
137+
138+
destroy_entity = (Factory_Destroy*)hFactory->getProcAddress("_destroy_entity@4");
139+
R_ASSERT(destroy_entity);
140+
129141
CGameSpawnConstructor(name, output, start, !!no_separator_check);
142+
143+
hFactory->close();
144+
145+
create_entity = nullptr;
146+
destroy_entity = nullptr;
130147
}
131148
else if (strstr(cmd, "-verify"))
132149
{
@@ -169,32 +186,13 @@ void Startup(LPSTR lpCmdLine)
169186
Logger.Destroy();
170187
}
171188

172-
#include "factory_api.h"
173-
174-
Factory_Create* create_entity = 0;
175-
Factory_Destroy* destroy_entity = 0;
176-
177189
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
178190
{
179191
xrDebug::Initialize(false);
180192
Core.Initialize("xrai", 0);
181193

182-
const auto hFactory = std::make_unique<XRay::Module>("xrSE_Factory");
183-
184-
if (!hFactory->exist())
185-
R_CHK(GetLastError());
186-
R_ASSERT2(hFactory->exist(), "Factory DLL raised exception during loading or there is no factory DLL at all");
187-
188-
create_entity = (Factory_Create*)hFactory->getProcAddress("_create_entity@4");
189-
R_ASSERT(create_entity);
190-
191-
destroy_entity = (Factory_Destroy*)hFactory->getProcAddress("_destroy_entity@4");
192-
R_ASSERT(destroy_entity);
193-
194194
Startup(lpCmdLine);
195195

196-
hFactory->close();
197-
198196
Core._destroy();
199197

200198
return (0);

0 commit comments

Comments
 (0)