Skip to content

Commit 9da7e69

Browse files
authored
Merge pull request #114 from InfiniteC0re/master
Clean up and actualize code a bit
2 parents f11fff9 + 9bf94f4 commit 9da7e69

533 files changed

Lines changed: 81097 additions & 74804 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: BlockIndent
5+
AlignConsecutiveMacros: true
6+
AlignConsecutiveAssignments: true
7+
AlignConsecutiveDeclarations: true
8+
AlignEscapedNewlines: Left
9+
AlignOperands: false
10+
AlignTrailingComments: true
11+
AllowAllArgumentsOnNextLine: true
12+
AllowAllConstructorInitializersOnNextLine: true
13+
AllowAllParametersOfDeclarationOnNextLine: false
14+
AllowShortBlocksOnASingleLine: Never
15+
AllowShortCaseLabelsOnASingleLine: true
16+
AllowShortFunctionsOnASingleLine: InlineOnly
17+
AllowShortLambdasOnASingleLine: Inline
18+
AllowShortIfStatementsOnASingleLine: WithoutElse
19+
AllowShortLoopsOnASingleLine: true
20+
AlwaysBreakAfterDefinitionReturnType: None
21+
AlwaysBreakAfterReturnType: None
22+
AlwaysBreakBeforeMultilineStrings: false
23+
AlwaysBreakTemplateDeclarations: No
24+
BinPackArguments: true
25+
BinPackParameters: false
26+
BreakBeforeBraces: Custom
27+
BraceWrapping:
28+
AfterCaseLabel: true
29+
AfterClass: true
30+
AfterControlStatement: Always
31+
AfterEnum: true
32+
AfterFunction: true
33+
AfterNamespace: true
34+
AfterObjCDeclaration: true
35+
AfterStruct: true
36+
AfterUnion: true
37+
AfterExternBlock: true
38+
BeforeCatch: true
39+
BeforeElse: true
40+
IndentBraces: false
41+
SplitEmptyFunction: false
42+
SplitEmptyRecord: false
43+
SplitEmptyNamespace: false
44+
BreakBeforeBinaryOperators: None
45+
BreakBeforeInheritanceComma: false
46+
BreakBeforeTernaryOperators: false
47+
BreakAfterJavaFieldAnnotations: false
48+
BreakStringLiterals: false
49+
ColumnLimit: 0
50+
CommentPragmas: '^ IWYU pragma:'
51+
CompactNamespaces: false
52+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
53+
ConstructorInitializerIndentWidth: 4
54+
ContinuationIndentWidth: 4
55+
Cpp11BracedListStyle: false
56+
DerivePointerAlignment: false
57+
DisableFormat: false
58+
ExperimentalAutoDetectBinPacking: false
59+
FixNamespaceComments: true
60+
IndentCaseLabels: true
61+
IndentGotoLabels: true
62+
IndentPPDirectives: AfterHash
63+
PPIndentWidth: 2
64+
InsertNewlineAtEOF: true
65+
IndentWidth: 4
66+
IndentWrappedFunctionNames: false
67+
JavaScriptQuotes: Leave
68+
JavaScriptWrapImports: true
69+
KeepEmptyLinesAtTheStartOfBlocks: true
70+
MacroBlockBegin: ''
71+
MacroBlockEnd: ''
72+
MaxEmptyLinesToKeep: 10000
73+
NamespaceIndentation: None
74+
ObjCBinPackProtocolList: Auto
75+
ObjCBlockIndentWidth: 4
76+
ObjCSpaceAfterProperty: false
77+
ObjCSpaceBeforeProtocolList: true
78+
PenaltyBreakAssignment: 2
79+
PenaltyBreakBeforeFirstCallParameter: 19
80+
PenaltyBreakComment: 300
81+
PenaltyBreakFirstLessLess: 120
82+
PenaltyBreakString: 1000
83+
PenaltyBreakTemplateDeclaration: 10
84+
PenaltyExcessCharacter: 1000000
85+
PenaltyReturnTypeOnItsOwnLine: 1000
86+
PointerAlignment: Left
87+
ReflowComments: false
88+
SortIncludes: false
89+
SortUsingDeclarations: false
90+
SpaceAfterCStyleCast: false
91+
SpaceAfterLogicalNot: false
92+
SpaceAfterTemplateKeyword: true
93+
SpaceBeforeAssignmentOperators: true
94+
SpaceBeforeCpp11BracedList: false
95+
SpaceBeforeCtorInitializerColon: true
96+
SpaceBeforeInheritanceColon: true
97+
SpaceBeforeParens: ControlStatements
98+
SpaceBeforeRangeBasedForLoopColon: true
99+
SpaceInEmptyBlock: false
100+
SpaceInEmptyParentheses: false
101+
SpacesBeforeTrailingComments: 1
102+
SpacesInAngles: false
103+
SpacesInContainerLiterals: false
104+
SpacesInCStyleCastParentheses: false
105+
SpacesInParentheses: false
106+
SpacesInSquareBrackets: false
107+
Standard: Latest
108+
TabWidth: 4
109+
UseTab: ForIndentation
110+
BreakInheritanceList: BeforeComma
111+
BreakConstructorInitializers: BeforeComma

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
run: .\bin\Release_Windows_x86\UnitTests\UnitTests.exe
3333

3434
- name: Publish Artifact
35-
uses: actions/upload-artifact@v3
35+
uses: actions/upload-artifact@v4
3636
with:
3737
name: Toshi Binaries
3838
path: bin

Format-Code.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@echo off
2+
set clang_format=%cd%\vendor\clang-format.exe
3+
set directories=(Toshi\Source,OpenBlob\Source,OpenGlobs\Source,Shared\Source)
4+
5+
for %%P in %directories% do (for %%G in (.cpp, .hpp, .h) do forfiles /p .\%%P\ /s /m *%%G /c "cmd /c %clang_format% -i @path")

OpenBlob/Source/ABaseEntity.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#include "pch.h"
22
#include "ABaseEntity.h"
33

4-
void ABaseEntity::SetState(int a_State)
4+
void ABaseEntity::SetState(TINT a_State)
55
{
66
TASSERT(a_State >= 0);
77
if (a_State != m_State)
88
{
99
OnLeaveState(m_State);
10-
m_State = a_State;
10+
m_State = a_State;
1111
m_fTicks = 0.0f;
1212
OnEnterState(m_State);
1313
}

OpenBlob/Source/ABaseEntity.h

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,37 @@
44
#include "Toshi2/T2DList.h"
55
#include "Toshi/Math/Math.h"
66

7-
class ABaseEntity :
8-
public Toshi::TGenericClassDerived<ABaseEntity, Toshi::TObject, "ABaseEntity", TMAKEVERSION(1, 0), TTRUE>,
9-
public Toshi::T2DList<ABaseEntity>::Node
7+
class ABaseEntity : public Toshi::TGenericClassDerived<ABaseEntity, Toshi::TObject, "ABaseEntity", TMAKEVERSION(1, 0), TTRUE>
8+
, public Toshi::T2DList<ABaseEntity>::Node
109
{
11-
static constexpr int ENTITY_HASH_SIZE = 0x400;
10+
static constexpr TINT ENTITY_HASH_SIZE = 0x400;
1211

1312
enum FLAG
1413
{
15-
FLAG_Created = BITFIELD(0),
16-
FLAG_Visible = BITFIELD(2),
17-
FLAG_DontTick = BITFIELD(8),
18-
FLAG_LowLOD = BITFIELD(9),
19-
FLAG_MediumLOD = BITFIELD(10),
20-
FLAG_HighLOD = BITFIELD(11),
21-
FLAG_LODMask = FLAG_LowLOD | FLAG_MediumLOD | FLAG_HighLOD,
22-
FLAG_UPDATEMATRIX = BITFIELD(15)
14+
FLAG_Created = BITFIELD(0),
15+
FLAG_Visible = BITFIELD(2),
16+
FLAG_DontTick = BITFIELD(8),
17+
FLAG_LowLOD = BITFIELD(9),
18+
FLAG_MediumLOD = BITFIELD(10),
19+
FLAG_HighLOD = BITFIELD(11),
20+
FLAG_LODMask = FLAG_LowLOD | FLAG_MediumLOD | FLAG_HighLOD,
21+
FLAG_UPDATEMATRIX = BITFIELD(15)
2322
};
23+
2424
public:
2525
virtual ~ABaseEntity() = default;
26-
virtual void Tick(float a_fTicks) { m_fTicks += a_fTicks; }
27-
virtual void OnLODChanging() {};
26+
virtual void Tick(TFLOAT a_fTicks) { m_fTicks += a_fTicks; }
27+
virtual void OnLODChanging(){};
2828
virtual void Create()
2929
{
3030
TASSERT(0 == (m_Flags & FLAG_Created));
3131
m_Flags |= FLAG_Created;
3232
}
33-
virtual void PostCreate() {};
34-
virtual void Destroy() {};
35-
36-
virtual float GetAnimationSpeed(int) const { return 1.0f; }
37-
virtual void SetVisible(bool bEnable)
33+
virtual void PostCreate(){};
34+
virtual void Destroy(){};
35+
36+
virtual TFLOAT GetAnimationSpeed(TINT) const { return 1.0f; }
37+
virtual void SetVisible(TBOOL bEnable)
3838
{
3939
bEnable ? m_Flags |= FLAG_Visible : m_Flags &= ~FLAG_Visible;
4040
}
@@ -56,34 +56,33 @@ class ABaseEntity :
5656
m_mMatrix = a_matrix;
5757
m_Flags |= FLAG_UPDATEMATRIX;
5858
}
59-
59+
6060
virtual void GetReactionForce(Toshi::TVector4& a_reactionForce)
6161
{
6262
a_reactionForce = Toshi::TVector4::VEC_ZERO;
6363
}
64-
65-
virtual float GetStepUpHeight() const { return 0.3f; }
66-
virtual void SetBBox(Toshi::TVector4 a_bbox)
64+
65+
virtual TFLOAT GetStepUpHeight() const { return 0.3f; }
66+
virtual void SetBBox(Toshi::TVector4 a_bbox)
6767
{
68-
m_vBoundingBox = a_bbox;
68+
m_vBoundingBox = a_bbox;
6969
m_fBoundingSphereRadius = a_bbox.Magnitude();
7070
}
71-
virtual float GetInteractionRadius() const { return 2.5f; }
72-
virtual void OnLeaveState(int a_State) {};
73-
virtual void OnEnterState(int a_State) {};
71+
virtual TFLOAT GetInteractionRadius() const { return 2.5f; }
72+
virtual void OnLeaveState(TINT a_State){};
73+
virtual void OnEnterState(TINT a_State){};
7474

75-
void SetState(int a_State);
75+
void SetState(TINT a_State);
7676

7777

78-
static int sm_EntityHash[ENTITY_HASH_SIZE];
78+
static TINT sm_EntityHash[ENTITY_HASH_SIZE];
7979

80-
short m_State; // 0xC
81-
short m_iID; // 0xE
82-
Toshi::TMatrix44 m_mMatrix; // 0x10
83-
Toshi::TVector4 m_vBoundingBox; // 0x50
84-
float m_fBoundingSphereRadius; // 0x68
85-
float m_fTicks; // 0x6C
86-
uint8_t m_Flags; // 0x70
87-
Toshi::T2DList<ABaseEntity>::Node* m_pEntityCellPair; // 0x7C
80+
TSHORT m_State; // 0xC
81+
TSHORT m_iID; // 0xE
82+
Toshi::TMatrix44 m_mMatrix; // 0x10
83+
Toshi::TVector4 m_vBoundingBox; // 0x50
84+
TFLOAT m_fBoundingSphereRadius; // 0x68
85+
TFLOAT m_fTicks; // 0x6C
86+
TUINT8 m_Flags; // 0x70
87+
Toshi::T2DList<ABaseEntity>::Node* m_pEntityCellPair; // 0x7C
8888
};
89-

OpenBlob/Source/ACurrentLevelInformation.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ void ACurrentLevelInformation::Create(DataBlock a_type)
66
{
77
auto assetStreaming = AAssetStreaming::GetSingleton();
88

9-
char* szFilename = Toshi::TStringManager::GetTempString8();
9+
TCHAR* szFilename = Toshi::TStringManager::GetTempString8();
1010

1111
for (size_t i = 0; i < DataBlockCount; i++)
1212
{
@@ -23,14 +23,14 @@ void ACurrentLevelInformation::Create(DataBlock a_type)
2323

2424
TASSERT(!m_streamingJobs[i]);
2525
TASSERT(!m_datablocks[i]);
26-
m_datablocks[i] = new Toshi::TTRB();
27-
m_streamingJobs[i] = TSTATICCAST(ATRBLoaderJob*, assetStreaming->CancelAllWaitingTerrainJobs());
26+
m_datablocks[i] = new Toshi::TTRB();
27+
m_streamingJobs[i] = TSTATICCAST(ATRBLoaderJob, assetStreaming->CancelAllWaitingTerrainJobs());
2828
m_streamingJobs[i]->Init(m_datablocks[i], szFilename);
2929
assetStreaming->AddMainThreadJob2(m_streamingJobs[i]);
3030
}
3131
}
3232

33-
const char* ACurrentLevelInformation::GetDataBlockFilename(DataBlock a_type)
33+
const TCHAR* ACurrentLevelInformation::GetDataBlockFilename(DataBlock a_type)
3434
{
3535
TASSERT(a_type >= 0 && a_type < DataBlockCount);
3636
return sm_dataBlockFilenames[a_type].second;

OpenBlob/Source/ACurrentLevelInformation.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55

66
class ACurrentLevelInformation
77
{
8-
using DataBlock = int;
9-
static constexpr int DataBlockCount = 24;
8+
using DataBlock = TINT;
9+
static constexpr TINT DataBlockCount = 24;
1010

11-
static constexpr std::pair<int, const char*> sm_dataBlockFilenames[DataBlockCount] = {
12-
{1, "Common/CameraShakeCommon.trb"},
13-
{1, "Blob_FX/FXParticles.trb"},
14-
{1, "Entities/BlobProperties"},
15-
{1, "Sound/SoundBreakPoints,trb"}
11+
static constexpr std::pair<TINT, const TCHAR*> sm_dataBlockFilenames[DataBlockCount] = {
12+
{ 1, "Common/CameraShakeCommon.trb" },
13+
{ 1, "Blob_FX/FXParticles.trb" },
14+
{ 1, "Entities/BlobProperties" },
15+
{ 1, "Sound/SoundBreakPoints,trb" }
1616
};
1717

18-
ACurrentLevelInformation(char* a_szLevelName) : m_szLevelName(a_szLevelName)
18+
ACurrentLevelInformation(TCHAR* a_szLevelName)
19+
: m_szLevelName(a_szLevelName)
1920
{
2021
Toshi::TUtil::MemClear(m_datablocks, sizeof(m_datablocks));
2122
Toshi::TUtil::MemClear(m_streamingJobs, sizeof(m_streamingJobs));
2223
}
2324

24-
void Create(DataBlock a_type);
25-
const char* GetDataBlockFilename(DataBlock a_type);
25+
void Create(DataBlock a_type);
26+
const TCHAR* GetDataBlockFilename(DataBlock a_type);
2627
Toshi::TTRB* GetDataBlock(DataBlock a_type);
2728
Toshi::TTRB* Stream(DataBlock a_type);
2829

29-
char* m_szLevelName;
30+
TCHAR* m_szLevelName;
3031
ATRBLoaderJob* m_streamingJobs[DataBlockCount];
31-
Toshi::TTRB* m_datablocks[DataBlockCount];
32+
Toshi::TTRB* m_datablocks[DataBlockCount];
3233
};
33-

0 commit comments

Comments
 (0)