Skip to content

Commit fc95c78

Browse files
committed
AITrafficManager progress, lots of header work again
1 parent 870eb8a commit fc95c78

30 files changed

+751
-166
lines changed

src/Speed/Indep/Libs/Support/Utility/UCOM.h

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
#ifndef SUPPORT_UTILITY_UCOM_H
22
#define SUPPORT_UTILITY_UCOM_H
33

4-
#include "Speed/Indep/bWare/Inc/bMemory.hpp"
54
#ifdef EA_PRAGMA_ONCE_SUPPORTED
65
#pragma once
76
#endif
87

8+
#include "Speed/Indep/Libs/Support/Utility/UStandard.h"
9+
#include "Speed/Indep/bWare/Inc/bMemory.hpp"
10+
11+
typedef void *HINTERFACE;
12+
13+
struct _type_UComObject {
14+
const char *name() {
15+
return "UComObject";
16+
}
17+
};
18+
919
namespace UTL {
1020
namespace COM {
1121

@@ -23,43 +33,53 @@ class Object {
2333
// bool operator<(const _IPair &rhs) {}
2434
};
2535

26-
struct _IList // : public std::vector<_IPair, _type_UComObject>
27-
{
28-
int pad;
29-
void *_M_start;
30-
void *_M_finish;
31-
void *_M_end_of_storage;
32-
33-
// _IList(unsigned int icount) {}
34-
35-
// ~_IList() {}
36-
37-
// void Add(void *handle, IUnknown *ref) {}
38-
39-
// IUnknown *Find(void *handle) {}
40-
41-
// void *Find(const IUnknown *pUnk) const {}
42-
43-
// void Remove(IUnknown *pUnk) {}
36+
class _IList : public UTL::Std::vector<_IPair, _type_UComObject> {
37+
// int pad;
38+
// void *_M_start;
39+
// void *_M_finish;
40+
// void *_M_end_of_storage;
41+
42+
public:
43+
_IList(unsigned int icount);
44+
~_IList();
45+
void Add(HINTERFACE handle, IUnknown *ref);
46+
IUnknown *Find(HINTERFACE handle);
47+
void *Find(const IUnknown *pUnk) const;
48+
void Remove(IUnknown *pUnk);
4449
};
4550

51+
public:
4652
// total size: 0x10
4753
_IList _mInterfaces; // offset 0x0, size 0x10
4854

4955
protected:
5056
void *operator new(std::size_t size) {
5157
return gFastMem.Alloc(size, nullptr);
5258
}
59+
60+
Object(unsigned int icount) : _mInterfaces(icount) {}
61+
62+
~Object() {}
5363
};
5464

5565
class IUnknown {
66+
public:
5667
// total size: 0x8
5768
Object *_mCOMObject; // offset 0x0, size 0x4
5869

70+
template <typename T> bool QueryInterface(T **out) {
71+
HINTERFACE handle = T::_IHandle();
72+
73+
*out = (T *)_mCOMObject->_mInterfaces.Find(handle);
74+
return *out != nullptr;
75+
}
76+
5977
protected:
6078
IUnknown(Object *owner, void *handle) {}
6179

62-
virtual ~IUnknown() {}
80+
virtual ~IUnknown() {
81+
this->_mCOMObject->_mInterfaces.Remove(this);
82+
}
6383
};
6484

6585
template <typename T, typename U, typename V> class Factory {

src/Speed/Indep/Libs/Support/Utility/UCollections.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct _KeyedNode {
1717
};
1818

1919
template <typename T, std::size_t Size> class _Storage : public FixedVector<T, Size, 16> {
20+
public:
2021
_Storage() {}
2122

2223
~_Storage() {}
@@ -25,7 +26,7 @@ template <typename T, std::size_t Size> class _Storage : public FixedVector<T, S
2526
template <typename T> class Singleton {
2627
protected:
2728
Singleton() {}
28-
virtual ~Singleton() {}
29+
~Singleton() {}
2930

3031
public:
3132
// static T *Get() {}

src/Speed/Indep/Libs/Support/Utility/UListable.h

Lines changed: 76 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,113 @@
77

88
#include <cstddef>
99

10+
#include "UTLVector.h"
11+
1012
namespace UTL {
1113
namespace Collections {
1214

1315
template <typename T, std::size_t U> class Listable {
14-
struct List {};
16+
public:
17+
typedef T value_type;
18+
typedef value_type *pointer;
19+
typedef const value_type *const_pointer;
20+
typedef pointer *iterator;
21+
typedef const pointer *const_iterator;
1522

16-
static List _mTable;
23+
class List : public FixedVector<pointer, U> {
24+
public:
25+
List(const List &);
26+
List();
27+
virtual ~List();
1728

18-
typedef void (*ForEachFunc_t)(T *);
29+
// List &operator=(List &);
30+
};
1931

20-
public:
32+
typedef void (*ForEachFunc)(pointer);
33+
34+
protected:
2135
Listable() {}
2236

2337
~Listable() {}
2438

2539
void Unlist() {}
2640

27-
ForEachFunc_t ForEach(ForEachFunc_t f) {}
41+
public:
42+
ForEachFunc ForEach(ForEachFunc f) {}
2843

29-
const List &GetList() {}
44+
static const List &GetList() {
45+
return _mTable;
46+
}
47+
48+
private:
49+
static List _mTable;
3050
};
3151

32-
template <typename T, std::size_t Tsize, typename U, std::size_t Usize> class ListableSet {
33-
struct List {};
52+
template <typename T, std::size_t ListSize, typename Enum, std::size_t EnumMax> class ListableSet {
53+
public:
54+
typedef T value_type;
55+
typedef value_type *pointer;
56+
typedef const value_type *const_pointer;
57+
typedef pointer *iterator;
58+
typedef const pointer *const_iterator;
3459

35-
typedef void (*ForEachFunc_t)(T *);
60+
class List : public FixedVector<pointer, ListSize> {
61+
public:
62+
List(const List &);
63+
List();
64+
virtual ~List();
3665

37-
public:
38-
T *First(U idx);
39-
T *Last(U idx);
66+
// List &operator=(List &);
67+
};
68+
69+
typedef void (*ForEachFunc_t)(pointer);
70+
71+
static int Count(Enum idx);
72+
73+
T *First(Enum idx);
74+
T *Last(Enum idx);
4075

4176
~ListableSet() {}
4277

4378
void UnList() {}
4479

45-
T *Next(U idx) {}
80+
T *Next(Enum idx) {}
4681

47-
ForEachFunc_t ForEach(U idx, ForEachFunc_t f) {}
82+
ForEachFunc_t ForEach(Enum idx, ForEachFunc_t f) {}
83+
84+
void AddToList(Enum to) {}
85+
86+
static const List &GetList(Enum idx) {
87+
return _mLists._buckets[idx];
88+
}
4889

49-
void AddToList(U to) {}
90+
private:
91+
class _ListSet {
92+
public:
93+
// how to access _buckets without making it public?
94+
List _buckets[EnumMax];
5095

51-
const List &GetList(U idx) {}
96+
void _add(T *, unsigned int);
97+
98+
void _remove(T *, unsigned int);
99+
100+
_ListSet();
101+
// _ListSet(_ListSet &);
102+
~_ListSet();
103+
104+
// _ListSet &operator=(const _ListSet &);
105+
};
106+
107+
static _ListSet _mLists;
52108
};
53109

54110
template <typename T> class Countable {
55111
static int _mCount;
56112

113+
protected:
114+
Countable() {}
115+
~Countable() {}
116+
57117
public:
58118
static int Count() {
59119
return _mCount;

src/Speed/Indep/Libs/Support/Utility/UMath.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ const Matrix4 Matrix4::kIdentity = {{1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f,
117117

118118
void BuildRotate(Matrix4 &m, float r, float x, float y, float z);
119119

120+
inline float DistanceSquarexz(const Vector3 &a, const Vector3 &b) {
121+
return VU0_v3distancesquare(a, b);
122+
}
123+
124+
inline Vector3 &Vector4To3(Vector4 &c4) {
125+
return *reinterpret_cast<Vector3 *>(&c4);
126+
}
127+
120128
inline void RotateTranslate(const Vector3 &a, const Matrix4 &m, Vector3 &r) {
121129
VU0_MATRIX4_vect3mult(a, m, r);
122130
}

src/Speed/Indep/Libs/Support/Utility/USpline.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
#pragma once
66
#endif
77

8+
#include <list>
9+
810
#include "Speed/Indep/Libs/Support/Utility/UMath.h"
911

10-
class SplinePointList /* : public STLlist<UMath::Vector4, _STL::allocator<UMath::Vector4> >*/ {};
12+
class SplinePointList : public std::list<UMath::Vector4> {};
1113

1214
class USpline {
1315
enum SplineType {

src/Speed/Indep/Libs/Support/Utility/UTLVector.h

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
#include <cstddef>
99

1010
namespace UTL {
11-
template <typename T, int Alignment> class Vector {
12-
// total size: 0x10
13-
T *mBegin; // offset 0x0, size 0x4
14-
std::size_t mCapacity; // offset 0x4, size 0x4
15-
std::size_t mSize; // offset 0x8, size 0x4
16-
// _vptr; // offset 0xC, size 0x4
11+
template <typename T, int Alignment = 16> class Vector {
12+
public:
13+
typedef T value_type;
14+
typedef value_type *pointer;
15+
typedef const value_type *const_pointer;
16+
typedef value_type *iterator;
17+
typedef const value_type *const_iterator;
1718

1819
public:
1920
void Init() {}
@@ -36,15 +37,27 @@ template <typename T, int Alignment> class Vector {
3637

3738
void clear() {}
3839

39-
T *const *begin() const {}
40+
const_iterator begin() const {
41+
return mBegin;
42+
}
43+
44+
iterator begin() {
45+
return mBegin;
46+
}
4047

41-
T *const *end() const {}
48+
const_iterator end() const {
49+
return mBegin + mSize;
50+
}
51+
52+
iterator end() {
53+
return mBegin + mSize;
54+
}
4255

4356
virtual std::size_t GetGrowSize(std::size_t minSize) const {}
4457

4558
virtual void OnGrowRequest(std::size_t newSize) {}
4659

47-
virtual T **VectorAllocVectorSpace(unsigned int num, std::size_t alignment) {}
60+
virtual T **VectorAllocVectorSpace(std::size_t num, unsigned int alignment) {}
4861

4962
virtual void FreeVectorSpace(T **buffer, unsigned int num) {}
5063

@@ -55,9 +68,15 @@ template <typename T, int Alignment> class Vector {
5568
std::size_t indexof(T **pos) {}
5669

5770
T **erase(T **begIt, T **endIt) {}
71+
72+
private:
73+
// total size: 0x10
74+
T *mBegin; // offset 0x0, size 0x4
75+
std::size_t mCapacity; // offset 0x4, size 0x4
76+
std::size_t mSize; // offset 0x8, size 0x4
5877
};
5978

60-
template <typename T, std::size_t Size, int Alignment> class FixedVector : public Vector<T, Alignment> {
79+
template <typename T, std::size_t Size, int Alignment = 16> class FixedVector : public Vector<T, Alignment> {
6180
// TODO speed considerations for 64 bit
6281
int mVectorSpace[(sizeof(T) * Size) / sizeof(int)];
6382

@@ -68,9 +87,9 @@ template <typename T, std::size_t Size, int Alignment> class FixedVector : publi
6887

6988
virtual std::size_t GetGrowSize(std::size_t minSize) const {}
7089

71-
virtual T **AllocVectorSpace(unsigned int num, std::size_t alignment) {}
90+
virtual T **AllocVectorSpace(std::size_t num, unsigned int alignment) {}
7291

73-
virtual void FreeVectorSpace(T **buffer, unsigned int num) {}
92+
virtual void FreeVectorSpace(T **buffer, std::size_t) {}
7493

7594
virtual std::size_t GetMaxCapacity() const {}
7695
};

src/Speed/Indep/Libs/Support/Utility/UVectorMath.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ struct Matrix4;
1515
} // namespace UMath
1616

1717
void VU0_v3scale(const UMath::Vector3 &a, const float scaleby, UMath::Vector3 &result);
18-
void VU0_v4subxyz(const UMath::Vector4 &a, const UMath::Vector4 &b, UMath::Vector4 &result);
1918
void VU0_v3scale(const UMath::Vector3 &a, const UMath::Vector3 &b, UMath::Vector3 &result);
19+
float VU0_v3distancesquare(const UMath::Vector3 &p1, const UMath::Vector3 &p2);
20+
float VU0_v3distancesquarexz(const UMath::Vector3 &p1, const UMath::Vector3 &p2);
21+
22+
void VU0_v4subxyz(const UMath::Vector4 &a, const UMath::Vector4 &b, UMath::Vector4 &result);
2023
void VU0_v4scale(const UMath::Vector4 &a, const float scaleby, UMath::Vector4 &result);
24+
float VU0_v4distancesquarexyz(const UMath::Vector4 &p1, const UMath::Vector4 &p2);
2125

2226
void VU0_MATRIX4_vect3mult(const UMath::Vector3 &v, const UMath::Matrix4 &m, UMath::Vector3 &result);
2327
void VU0_MATRIX4_vect4mult(const UMath::Vector4 &v, const UMath::Matrix4 &m, UMath::Vector4 &result);

0 commit comments

Comments
 (0)