Skip to content

Commit d4a777a

Browse files
authored
Link xBehaviour and xBehaveGoalSimple (#685)
1 parent 31aa52a commit d4a777a

File tree

5 files changed

+86
-92
lines changed

5 files changed

+86
-92
lines changed

configure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,8 @@ def MatchingFor(*versions):
560560
Object(NonMatching, "SB/Game/zNPCTypeAmbient.cpp"),
561561
Object(NonMatching, "SB/Game/zNPCTypeTiki.cpp"),
562562
Object(NonMatching, "SB/Core/x/xBehaveMgr.cpp"),
563-
Object(NonMatching, "SB/Core/x/xBehaviour.cpp"), # breaks build (weak functions)
564-
Object(NonMatching, "SB/Core/x/xBehaveGoalSimple.cpp"), # breaks build (weak functions)
563+
Object(Matching, "SB/Core/x/xBehaviour.cpp", extra_cflags=["-sym on"]),
564+
Object(Matching, "SB/Core/x/xBehaveGoalSimple.cpp", extra_cflags=["-sym on"]),
565565
Object(NonMatching, "SB/Core/x/xSkyDome.cpp"),
566566
Object(Matching, "SB/Core/x/xRMemData.cpp", extra_cflags=["-sym on"]),
567567
Object(Matching, "SB/Core/x/xFactory.cpp"),

src/SB/Core/x/xBehaveGoalSimple.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void xGoalSimple_RegisterTypes(xFactory* fac)
66
fac->RegItemType('GSM\x01', GOALCreate_Generic, GOALDestroy_Generic);
77
}
88

9-
xFactoryInst* GOALCreate_Generic(S32 who, RyzMemGrow* growCtxt, void*)
9+
static xFactoryInst* GOALCreate_Generic(S32 who, RyzMemGrow* growCtxt, void*)
1010
{
1111
xGoal* goal = NULL;
1212

@@ -27,7 +27,7 @@ xFactoryInst* GOALCreate_Generic(S32 who, RyzMemGrow* growCtxt, void*)
2727
return goal;
2828
}
2929

30-
void GOALDestroy_Generic(xFactoryInst* item)
30+
static void GOALDestroy_Generic(xFactoryInst* item)
3131
{
3232
delete item;
3333
}
@@ -73,7 +73,7 @@ S32 xGoalGeneric::Resume(F32 dt, void* updCtxt)
7373
}
7474

7575
S32 xGoalGeneric::SysEvent(xBase* from, xBase* to, U32 toEvent, const F32* toParam,
76-
xBase* toParamWidget, S32* handled)
76+
xBase* toParamWidget, S32* handled)
7777
{
7878
if (this->fun_sysevent)
7979
{

src/SB/Core/x/xBehaveGoalSimple.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ struct xGoalGeneric : xGoal
4848
virtual S32 Suspend(F32 dt, void* updCtxt);
4949
virtual S32 Resume(F32 dt, void* updCtxt);
5050
virtual S32 SysEvent(xBase* from, xBase* to, U32 toEvent, const F32* toParam,
51-
xBase* toParamWidget, S32* handled);
51+
xBase* toParamWidget, S32* handled);
5252
};
5353

5454
void xGoalSimple_RegisterTypes(xFactory* fac);
55-
xFactoryInst* GOALCreate_Generic(S32 who, RyzMemGrow* growCtxt, void* dat);
56-
void GOALDestroy_Generic(xFactoryInst* item);
55+
static xFactoryInst* GOALCreate_Generic(S32 who, RyzMemGrow* growCtxt, void* dat);
56+
static void GOALDestroy_Generic(xFactoryInst* item);
5757

5858
#endif

src/SB/Core/x/xBehaviour.cpp

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,6 @@
11
#include "xBehaviour.h"
22

3-
WEAK void xGoal::SetPsyche(xPsyche* psyche)
4-
{
5-
this->psyche = psyche;
6-
}
7-
8-
WEAK const char* xGoal::Name()
9-
{
10-
return NULL;
11-
}
12-
13-
WEAK void xGoal::SetState(en_GOALSTATE state)
14-
{
15-
this->stat = state;
16-
}
17-
18-
WEAK en_GOALSTATE xGoal::GetState() const
19-
{
20-
return this->stat;
21-
}
22-
23-
WEAK xGoal* xListItem<xGoal>::Next()
24-
{
25-
return this->next;
26-
}
27-
28-
WEAK void xListItem<xGoal>::Insert(xGoal* list)
29-
{
30-
xGoal* node = (xGoal*)this;
31-
32-
node->prev = list;
33-
node->next = list->next;
34-
35-
if (list->next)
36-
{
37-
list->next->prev = node;
38-
}
39-
40-
list->next = node;
41-
}
42-
43-
WEAK xGoal* xListItem<xGoal>::RemHead(xGoal** listhead)
44-
{
45-
if (*listhead == NULL)
46-
{
47-
return NULL;
48-
}
49-
50-
xGoal* oldhead = (*listhead)->Head();
51-
52-
if (!oldhead)
53-
{
54-
*listhead = NULL;
55-
}
56-
else
57-
{
58-
*listhead = oldhead->Next();
59-
oldhead->Remove();
60-
}
61-
62-
return oldhead;
63-
}
64-
65-
WEAK xGoal* xListItem<xGoal>::Head()
66-
{
67-
xGoal* node = (xGoal*)this;
68-
69-
if (!node)
70-
{
71-
return node;
72-
}
73-
74-
while (node->prev)
75-
{
76-
node = node->prev;
77-
}
78-
79-
return node;
80-
}
81-
82-
WEAK xBase* xGoal::GetOwner() const
3+
xBase* xGoal::GetOwner() const
834
{
845
return this->psyche->GetClient();
856
}

src/SB/Core/x/xBehaviour.h

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,22 @@ struct xGoal : xListItem<xGoal>, xFactoryInst
194194
return flg_able;
195195
}
196196

197-
void SetPsyche(xPsyche* psyche);
198-
const char* Name();
199-
void SetState(en_GOALSTATE state);
200-
en_GOALSTATE GetState() const;
197+
void SetPsyche(xPsyche* psyche)
198+
{
199+
this->psyche = psyche;
200+
}
201+
const char* Name()
202+
{
203+
return NULL;
204+
}
205+
void SetState(en_GOALSTATE state)
206+
{
207+
this->stat = state;
208+
}
209+
en_GOALSTATE GetState() const
210+
{
211+
return this->stat;
212+
}
201213
xBase* GetOwner() const;
202214

203215
// vtable
@@ -237,4 +249,65 @@ struct xGoal : xListItem<xGoal>, xFactoryInst
237249
~xGoal(); // prevents implicit destructors from being generated in subclasses of xGoal
238250
};
239251

252+
/* TODO: get these to weakly link into other files without causing redefinitions in xBehaviour
253+
xGoal* xListItem<xGoal>::Next()
254+
{
255+
return this->next;
256+
}
257+
258+
void xListItem<xGoal>::Insert(xGoal* list)
259+
{
260+
xGoal* node = (xGoal*)this;
261+
262+
node->prev = list;
263+
node->next = list->next;
264+
265+
if (list->next)
266+
{
267+
list->next->prev = node;
268+
}
269+
270+
list->next = node;
271+
}
272+
273+
xGoal* xListItem<xGoal>::RemHead(xGoal** listhead)
274+
{
275+
if (*listhead == NULL)
276+
{
277+
return NULL;
278+
}
279+
280+
xGoal* oldhead = (*listhead)->Head();
281+
282+
if (!oldhead)
283+
{
284+
*listhead = NULL;
285+
}
286+
else
287+
{
288+
*listhead = oldhead->Next();
289+
oldhead->Remove();
290+
}
291+
292+
return oldhead;
293+
}
294+
295+
xGoal* xListItem<xGoal>::Head()
296+
{
297+
xGoal* node = (xGoal*)this;
298+
299+
if (!node)
300+
{
301+
return node;
302+
}
303+
304+
while (node->prev)
305+
{
306+
node = node->prev;
307+
}
308+
309+
return node;
310+
}
311+
*/
312+
240313
#endif

0 commit comments

Comments
 (0)