mirror of
https://github.com/MonsterDruide1/OdysseyDecomp.git
synced 2024-11-26 23:00:25 +00:00
Library/Movement: Implement RailMoveMovement
(#180)
Some checks failed
Compile and verify functions / compile_verify (push) Has been cancelled
Copy headers to separate repo / copy_headers (push) Has been cancelled
lint / clang-format (push) Has been cancelled
lint / custom-lint (push) Has been cancelled
progress / publish_progress (push) Has been cancelled
testcompile / test_compile (push) Has been cancelled
Some checks failed
Compile and verify functions / compile_verify (push) Has been cancelled
Copy headers to separate repo / copy_headers (push) Has been cancelled
lint / clang-format (push) Has been cancelled
lint / custom-lint (push) Has been cancelled
progress / publish_progress (push) Has been cancelled
testcompile / test_compile (push) Has been cancelled
This commit is contained in:
parent
ba93c13e20
commit
36fb2fa78f
@ -59944,11 +59944,11 @@ Address,Quality,Size,Name
|
||||
0x0000007100956228,U,000092,_ZN2al30calcPassCheckPointRecoverTransEPKNS_17RaceJudgeDirectorEPKNS_9LiveActorE
|
||||
0x0000007100956284,U,000092,_ZN2al29calcPassCheckPointRecoverPoseEPKNS_17RaceJudgeDirectorEPKNS_9LiveActorE
|
||||
0x00000071009562e0,U,000016,_ZN2al13getRacerActorEPKNS_17RaceJudgeDirectorEi
|
||||
0x00000071009562f0,U,000164,_ZN2al16RailMoveMovementC1EPNS_9LiveActorERKNS_13ActorInitInfoE
|
||||
0x0000007100956394,U,000136,_ZN2al16RailMoveMovement7exeMoveEv
|
||||
0x000000710095641c,U,000208,_ZN2al25tryCreateRailMoveMovementEPNS_9LiveActorERKNS_13ActorInitInfoE
|
||||
0x00000071009564ec,U,000036,_ZN2al16RailMoveMovementD0Ev
|
||||
0x0000007100956510,U,000136,
|
||||
0x00000071009562f0,O,000164,_ZN2al16RailMoveMovementC1EPNS_9LiveActorERKNS_13ActorInitInfoE
|
||||
0x0000007100956394,O,000136,_ZN2al16RailMoveMovement7exeMoveEv
|
||||
0x000000710095641c,O,000208,_ZN2al25tryCreateRailMoveMovementEPNS_9LiveActorERKNS_13ActorInitInfoE
|
||||
0x00000071009564ec,O,000036,_ZN2al16RailMoveMovementD0Ev
|
||||
0x0000007100956510,O,000136,_ZNK12_GLOBAL__N_123RailMoveMovementNrvMove7executeEPN2al11NerveKeeperE
|
||||
0x0000007100956598,U,000048,_ZN2al16RumbleCalculatorC2Efffj
|
||||
0x00000071009565c8,U,000020,_ZN2al16RumbleCalculator8setParamEfffj
|
||||
0x00000071009565dc,U,000024,_ZN2al16RumbleCalculator5startEj
|
||||
|
Can't render this file because it is too large.
|
55
lib/al/Library/Movement/RailMoveMovement.cpp
Normal file
55
lib/al/Library/Movement/RailMoveMovement.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
#include "Library/Movement/RailMoveMovement.h"
|
||||
|
||||
#include "Library/LiveActor/LiveActor.h"
|
||||
#include "Library/Nerve/NerveSetupUtil.h"
|
||||
#include "Library/Placement/PlacementFunction.h"
|
||||
#include "Library/Rail/RailUtil.h"
|
||||
|
||||
namespace {
|
||||
using namespace al;
|
||||
|
||||
NERVE_IMPL(RailMoveMovement, Move)
|
||||
|
||||
NERVES_MAKE_STRUCT(RailMoveMovement, Move)
|
||||
} // namespace
|
||||
|
||||
namespace al {
|
||||
RailMoveMovement::RailMoveMovement(LiveActor* host, const ActorInitInfo& info)
|
||||
: HostStateBase("レール移動挙動", host) {
|
||||
tryGetArg(&mSpeed, info, "Speed");
|
||||
tryGetArg((s32*)&mMoveType, info, "MoveType");
|
||||
|
||||
if (mMoveType > MoveType::Ahead)
|
||||
mMoveType = MoveType::Loop;
|
||||
|
||||
initNerve(&NrvRailMoveMovement.Move, 0);
|
||||
}
|
||||
|
||||
void RailMoveMovement::exeMove() {
|
||||
if (!isExistRail(getHost()))
|
||||
return;
|
||||
|
||||
switch (mMoveType) {
|
||||
case MoveType::Loop:
|
||||
moveSyncRailLoop(getHost(), mSpeed);
|
||||
break;
|
||||
case MoveType::Turn:
|
||||
moveSyncRailTurn(getHost(), mSpeed);
|
||||
break;
|
||||
case MoveType::Ahead:
|
||||
moveSyncRail(getHost(), mSpeed);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
RailMoveMovement* tryCreateRailMoveMovement(LiveActor* host, const ActorInitInfo& info) {
|
||||
if (!isExistRail(host))
|
||||
return nullptr;
|
||||
|
||||
setSyncRailToNearestPos(host);
|
||||
|
||||
return new RailMoveMovement(host, info);
|
||||
}
|
||||
} // namespace al
|
24
lib/al/Library/Movement/RailMoveMovement.h
Normal file
24
lib/al/Library/Movement/RailMoveMovement.h
Normal file
@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Library/Nerve/NerveStateBase.h"
|
||||
|
||||
namespace al {
|
||||
class ActorInitInfo;
|
||||
|
||||
class RailMoveMovement : public HostStateBase<LiveActor> {
|
||||
public:
|
||||
RailMoveMovement(LiveActor* host, const ActorInitInfo& info);
|
||||
|
||||
void exeMove();
|
||||
|
||||
private:
|
||||
enum class MoveType : u32 { Loop, Turn, Ahead };
|
||||
|
||||
f32 mSpeed = 10.0f;
|
||||
MoveType mMoveType = MoveType::Loop;
|
||||
};
|
||||
|
||||
static_assert(sizeof(RailMoveMovement) == 0x28);
|
||||
|
||||
RailMoveMovement* tryCreateRailMoveMovement(LiveActor* host, const ActorInitInfo& info);
|
||||
} // namespace al
|
@ -28,5 +28,4 @@ void NerveStateBase::control() {}
|
||||
|
||||
ActorStateBase::ActorStateBase(const char* name, LiveActor* actor)
|
||||
: NerveStateBase(name), mActor(actor) {}
|
||||
|
||||
} // namespace al
|
||||
|
@ -34,9 +34,9 @@ protected:
|
||||
template <class T>
|
||||
class HostStateBase : public NerveStateBase {
|
||||
public:
|
||||
HostStateBase(const char* name, T* host) : NerveStateBase(name), mHost(host){};
|
||||
HostStateBase(const char* name, T* host) : NerveStateBase(name), mHost(host) {}
|
||||
|
||||
T* getHost() { return mHost; }
|
||||
T* getHost() const { return mHost; }
|
||||
|
||||
private:
|
||||
T* mHost;
|
||||
|
@ -6,6 +6,7 @@ namespace al {
|
||||
class IUseRail;
|
||||
class LiveActor;
|
||||
|
||||
void setSyncRailToNearestPos(LiveActor* actor);
|
||||
void setRailPosToStart(IUseRail* railHolder);
|
||||
void moveSyncRail(LiveActor* actor, f32 speed);
|
||||
void moveSyncRailLoop(LiveActor* actor, f32 speed);
|
||||
|
@ -1,11 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from setup import get_build_dir
|
||||
import subprocess
|
||||
import os
|
||||
import re
|
||||
from functools import cache
|
||||
|
||||
from common import setup_common as setup
|
||||
|
||||
# ------
|
||||
@ -28,7 +27,6 @@ def CHECK(cond, line, message, path):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
# Common
|
||||
|
||||
def common_no_namespace_qualifiers(c, path):
|
||||
@ -37,13 +35,16 @@ def common_no_namespace_qualifiers(c, path):
|
||||
line = line[0:line.find("//")] if "//" in line else line
|
||||
if line.startswith("using namespace"):
|
||||
match = re.search(r"^using namespace ([^;\s]+);$", line)
|
||||
if CHECK(lambda a:match, line, "Unexpected \"using namespace\" line: should follow format \"using namespace xy;\"", path): return
|
||||
if CHECK(lambda a: match, line,
|
||||
"Unexpected \"using namespace\" line: should follow format \"using namespace xy;\"", path): return
|
||||
continue
|
||||
if CHECK(lambda a:a.rfind("namespace") in [-1, 0], line, "\"namespace\" must only be listed at the start of a line!", path): return
|
||||
if CHECK(lambda a: a.rfind("namespace") in [-1, 0], line,
|
||||
"\"namespace\" must only be listed at the start of a line!", path): return
|
||||
|
||||
if line.startswith("namespace"):
|
||||
match = re.search(r"^namespace ([^{\s]*) ?{$", line)
|
||||
if CHECK(lambda a:match, line, "Unexpected namespace line: should follow format \"namespace xy {\"", path): return
|
||||
if CHECK(lambda a: match, line, "Unexpected namespace line: should follow format \"namespace xy {\"",
|
||||
path): return
|
||||
nest_level.append(match.group(1))
|
||||
# can be "" for "namespace {" and "nn::g3d" for double/triple/... namespaces
|
||||
continue
|
||||
@ -63,7 +64,8 @@ def common_no_namespace_qualifiers(c, path):
|
||||
continue
|
||||
if x == "}":
|
||||
if nest_level[-1] != None: # is closing namespace
|
||||
if CHECK(lambda a:a=="}", line.rstrip(), "Closing namespace expects only \"}\" in line!", path): return
|
||||
if CHECK(lambda a: a == "}", line.rstrip(), "Closing namespace expects only \"}\" in line!",
|
||||
path): return
|
||||
del nest_level[-1]
|
||||
continue
|
||||
|
||||
@ -71,7 +73,8 @@ def common_no_namespace_qualifiers(c, path):
|
||||
for match in matches:
|
||||
match = match[0:-2]
|
||||
# examples: "sead", "al", "nn::g3d"
|
||||
if CHECK(lambda a:match not in allowed_namespaces, line, match+" should be omitted here!", path): return
|
||||
if CHECK(lambda a: match not in allowed_namespaces, line, match + " should be omitted here!",
|
||||
path): return
|
||||
|
||||
if len(nest_level) != 0:
|
||||
print("ERROR: nest_level not empty at end of the file!")
|
||||
@ -87,14 +90,28 @@ def get_includes():
|
||||
file_path = os.path.join(root, file)
|
||||
fs.append(os.path.relpath(file_path, path))
|
||||
return fs
|
||||
cpp_files = ["concepts","coroutine","any","bitset","chrono","compare","csetjmp","csignal","cstdarg","cstddef","cstdlib","ctime","expected","functional","initializer_list","optional","source_location","tuple","type_traits","typeindex","typeinfo","utility","variant","version","memory","memory_resource","new","scoped_allocator","cfloat","cinttypes","climits","cstdint","limits","stdfloat","cassert","cerrno","exception","stacktrace","stdexcept","system_error","cctype","charconv","cstring","cuchar","cwchar","cwctype","format","string","string_view","array","deque","flat_map","flat_set","forward_list","list","map","mdspan","queue","set","span","stack","unordered_map","unordered_set","vector","iterator","generator","ranges","algorithm","execution","bit","cfenv","cmath","complex","numbers","numeric","random","ratio","valarray","clocale","codecvt","locale","text_encoding","cstdio","fstream","iomanip","ios","iosfwd","iostream","istream","ostream","print","spanstream","sstream","streambuf","strstream","syncstream","filesystem","regex","atomic","barrier","condition_variable","future","hazard_pointer","latch","mutex","rcu","semaphore","shared_mutex","stop_token","thread","stdatomic.h"]
|
||||
sead_files = get_files(project_root/'lib'/'sead'/'include')
|
||||
nintendo_sdk_files = get_files(project_root/'lib'/'NintendoSDK'/'include')
|
||||
agl_files = get_files(project_root/'lib'/'agl'/'include')
|
||||
aarch_files = get_files(project_root/'lib'/'aarch64')
|
||||
eui_files = get_files(project_root/'lib'/'eui'/'include')
|
||||
al_files = [a for a in get_files(project_root/'lib'/'al') if a.endswith(".h")]
|
||||
game_files = [a for a in get_files(project_root/'src') if a.endswith(".h")]
|
||||
|
||||
cpp_files = ["concepts", "coroutine", "any", "bitset", "chrono", "compare", "csetjmp", "csignal", "cstdarg",
|
||||
"cstddef", "cstdlib", "ctime", "expected", "functional", "initializer_list", "optional",
|
||||
"source_location", "tuple", "type_traits", "typeindex", "typeinfo", "utility", "variant", "version",
|
||||
"memory", "memory_resource", "new", "scoped_allocator", "cfloat", "cinttypes", "climits", "cstdint",
|
||||
"limits", "stdfloat", "cassert", "cerrno", "exception", "stacktrace", "stdexcept", "system_error",
|
||||
"cctype", "charconv", "cstring", "cuchar", "cwchar", "cwctype", "format", "string", "string_view",
|
||||
"array", "deque", "flat_map", "flat_set", "forward_list", "list", "map", "mdspan", "queue", "set",
|
||||
"span", "stack", "unordered_map", "unordered_set", "vector", "iterator", "generator", "ranges",
|
||||
"algorithm", "execution", "bit", "cfenv", "cmath", "complex", "numbers", "numeric", "random", "ratio",
|
||||
"valarray", "clocale", "codecvt", "locale", "text_encoding", "cstdio", "fstream", "iomanip", "ios",
|
||||
"iosfwd", "iostream", "istream", "ostream", "print", "spanstream", "sstream", "streambuf", "strstream",
|
||||
"syncstream", "filesystem", "regex", "atomic", "barrier", "condition_variable", "future",
|
||||
"hazard_pointer", "latch", "mutex", "rcu", "semaphore", "shared_mutex", "stop_token", "thread",
|
||||
"stdatomic.h"]
|
||||
sead_files = get_files(project_root / 'lib' / 'sead' / 'include')
|
||||
nintendo_sdk_files = get_files(project_root / 'lib' / 'NintendoSDK' / 'include')
|
||||
agl_files = get_files(project_root / 'lib' / 'agl' / 'include')
|
||||
aarch_files = get_files(project_root / 'lib' / 'aarch64')
|
||||
eui_files = get_files(project_root / 'lib' / 'eui' / 'include')
|
||||
al_files = [a for a in get_files(project_root / 'lib' / 'al') if a.endswith(".h")]
|
||||
game_files = [a for a in get_files(project_root / 'src') if a.endswith(".h")]
|
||||
|
||||
angled_includes = cpp_files + aarch_files + nintendo_sdk_files + sead_files + agl_files + eui_files
|
||||
al_includes = al_files
|
||||
@ -105,9 +122,10 @@ def get_includes():
|
||||
def common_include_order(c, path, is_header):
|
||||
lines = c.split("\n")
|
||||
if is_header:
|
||||
if CHECK(lambda a:a=="#pragma once", lines[0], "Headers must start with \"#pragma once\"!", path): return
|
||||
if CHECK(lambda a: a == "#pragma once", lines[0], "Headers must start with \"#pragma once\"!", path): return
|
||||
del lines[0]
|
||||
if CHECK(lambda a:a=="", lines[0], "\"#pragma once\" must be followed by exactly one empty line!", path): return
|
||||
if CHECK(lambda a: a == "", lines[0], "\"#pragma once\" must be followed by exactly one empty line!",
|
||||
path): return
|
||||
del lines[0]
|
||||
elif not path.endswith("src/System/Init.cpp"):
|
||||
# hardcoded exception: Init.cpp contains C functions and no header to relate to
|
||||
@ -119,17 +137,21 @@ def common_include_order(c, path, is_header):
|
||||
rel_path = path.split("include/")[-1]
|
||||
else:
|
||||
rel_path = path
|
||||
header_line = "#include \""+rel_path[0:-3]+"h\""
|
||||
if CHECK(lambda a:a==header_line, lines[0], "Source files must start with including respective header in double quotes (here: "+header_line+")!", path): return
|
||||
header_line = "#include \"" + rel_path[0:-3] + "h\""
|
||||
if CHECK(lambda a: a == header_line, lines[0],
|
||||
"Source files must start with including respective header in double quotes (here: " + header_line + ")!",
|
||||
path): return
|
||||
del lines[0]
|
||||
if CHECK(lambda a:a=="", lines[0], "\""+header_line+"\" must be followed by exactly one empty line!", path): return
|
||||
if CHECK(lambda a: a == "", lines[0], "\"" + header_line + "\" must be followed by exactly one empty line!",
|
||||
path): return
|
||||
del lines[0]
|
||||
|
||||
include_lines = []
|
||||
end_of_includes = False
|
||||
for line in lines:
|
||||
if line.startswith("#include"):
|
||||
if CHECK(lambda a:not end_of_includes, line, "Includes have to be listed at the very top of the file!", path): return
|
||||
if CHECK(lambda a: not end_of_includes, line, "Includes have to be listed at the very top of the file!",
|
||||
path): return
|
||||
include_lines.append(line)
|
||||
elif line == "" and not end_of_includes:
|
||||
include_lines.append(line)
|
||||
@ -140,24 +162,30 @@ def common_include_order(c, path, is_header):
|
||||
|
||||
order = -1 # -1=none (after initial newline) ; 0=angled (sead, agl, nn, eui) ; 1=al ; 2=game ; -2,-3,-4=newline after respective section (angled, al, game)
|
||||
for line in include_lines:
|
||||
if line=="":
|
||||
if CHECK(lambda a:order in [0,1,2], line, "Unexpected newline in includes! Please re-read the contribution guide and format accordingly.", path): return
|
||||
order = -order-2
|
||||
if line == "":
|
||||
if CHECK(lambda a: order in [0, 1, 2], line,
|
||||
"Unexpected newline in includes! Please re-read the contribution guide and format accordingly.",
|
||||
path): return
|
||||
order = -order - 2
|
||||
continue
|
||||
|
||||
if line.startswith("#include <") and line.endswith(">"):
|
||||
file = line[10:-1]
|
||||
if CHECK(lambda a:order in [-1,0], line, "Angled \"#includes <...>\" can only appear in the first block of includes!", path): return
|
||||
if CHECK(lambda a:file in angled_includes, line, "This file is not allowed to be included with <>!", path): return
|
||||
if CHECK(lambda a: order in [-1, 0], line,
|
||||
"Angled \"#includes <...>\" can only appear in the first block of includes!", path): return
|
||||
if CHECK(lambda a: file in angled_includes, line, "This file is not allowed to be included with <>!",
|
||||
path): return
|
||||
order = 0
|
||||
elif line.startswith("#include \"") and line.endswith("\""):
|
||||
file = line[10:-1]
|
||||
if file in al_includes:
|
||||
if CHECK(lambda a:order in [-1,-2,1], line, "Wrong order for includes: Found \"al\"-include outside of expected block!", path): return
|
||||
order=1
|
||||
if CHECK(lambda a: order in [-1, -2, 1], line,
|
||||
"Wrong order for includes: Found \"al\"-include outside of expected block!", path): return
|
||||
order = 1
|
||||
elif file in game_includes:
|
||||
if CHECK(lambda a:order in [-1,-2,-3,2], line, "Wrong order for includes: Found \"game\"-include outside of expected block!", path): return
|
||||
order=2
|
||||
if CHECK(lambda a: order in [-1, -2, -3, 2], line,
|
||||
"Wrong order for includes: Found \"game\"-include outside of expected block!", path): return
|
||||
order = 2
|
||||
else:
|
||||
FAIL("This file is not allowed to be included with <>!", line, path)
|
||||
return
|
||||
@ -165,10 +193,10 @@ def common_include_order(c, path, is_header):
|
||||
FAIL("Unknown include format", line, path)
|
||||
return
|
||||
|
||||
CHECK(lambda a:order in [-1,-2,-3,-4], "not applicable", "Empty line expected after includes!", path)
|
||||
CHECK(lambda a: order in [-1, -2, -3, -4], "not applicable", "Empty line expected after includes!", path)
|
||||
|
||||
def common_newline_eof(c, path):
|
||||
CHECK(lambda a:a=="", c.split("\n")[-1], "Files should end with a newline!", path)
|
||||
CHECK(lambda a: a == "", c.split("\n")[-1], "Files should end with a newline!", path)
|
||||
|
||||
def common_sead_types(c, path):
|
||||
FORBIDDEN_TYPES = ["int", "float", "short", "long", "double"]
|
||||
@ -179,13 +207,15 @@ def common_sead_types(c, path):
|
||||
index = line.find(t, index)
|
||||
if index == -1:
|
||||
break
|
||||
if index > 0 and line[index-1].isalnum():
|
||||
if index > 0 and line[index - 1].isalnum():
|
||||
index += 1
|
||||
continue
|
||||
if index+len(t) < len(line) and line[index+len(t)].isalnum():
|
||||
if index + len(t) < len(line) and line[index + len(t)].isalnum():
|
||||
index += 1
|
||||
continue
|
||||
FAIL("Forbidden type used: "+t+". Use equivalent of <basis/seadTypes.h> instead (f32, s32, u32, ...)", line, path)
|
||||
FAIL(
|
||||
"Forbidden type used: " + t + ". Use equivalent of <basis/seadTypes.h> instead (f32, s32, u32, ...)",
|
||||
line, path)
|
||||
return
|
||||
|
||||
def common_void_params(c, path):
|
||||
@ -202,10 +232,10 @@ def common_const_type(c, path):
|
||||
index = line.find("const", index)
|
||||
if index == -1:
|
||||
break
|
||||
if index > 0 and line[index-1].isalnum(): # const is just part of a longer string
|
||||
if index > 0 and line[index - 1].isalnum(): # const is just part of a longer string
|
||||
index += 1
|
||||
continue
|
||||
if index >= 0 and line[index+len("const")] in ['*', '&']:
|
||||
if index >= 0 and line[index + len("const")] in ['*', '&']:
|
||||
FAIL("Const must be placed before the type: const T* or const T&", line, path)
|
||||
index += 1
|
||||
continue
|
||||
@ -240,7 +270,9 @@ def header_sorted_visibility(c, path):
|
||||
if line not in visibilities_ordered:
|
||||
header_check_line(line, path, nest_level[-1], should_start_class)
|
||||
if "{" in line and "}" in line:
|
||||
if CHECK(lambda a:a.count("{")==a.count("}") or (a.startswith("{") and a.endswith("}};")), line, "Unbalanced \"{\" and \"}\" in the same line! (exception: end of brace-initialized array)", path): return
|
||||
if CHECK(lambda a: a.count("{") == a.count("}") or (a.startswith("{") and a.endswith("}};")), line,
|
||||
"Unbalanced \"{\" and \"}\" in the same line! (exception: end of brace-initialized array)",
|
||||
path): return
|
||||
if line.startswith("{") and line.endswith("}};"):
|
||||
del nest_level[-1]
|
||||
should_start_class = False
|
||||
@ -249,13 +281,17 @@ def header_sorted_visibility(c, path):
|
||||
if line.startswith("class ") and not line.endswith(";"):
|
||||
should_start_class = True
|
||||
|
||||
if CHECK(lambda a:[b for b in visibilities_ordered if b in a and a!=b]==[], line, "visibility modifier must be its own line!", path): return
|
||||
if CHECK(lambda a:a.count("{")+a.count("}")<=1, line, "Only one \"{\" and \"}\" is allowed per line!", path): return
|
||||
if CHECK(lambda a: [b for b in visibilities_ordered if b in a and a != b] == [], line,
|
||||
"visibility modifier must be its own line!", path): return
|
||||
if CHECK(lambda a: a.count("{") + a.count("}") <= 1, line, "Only one \"{\" and \"}\" is allowed per line!",
|
||||
path): return
|
||||
|
||||
if line in visibilities_ordered:
|
||||
i = visibilities_ordered.index(line)
|
||||
if CHECK(lambda a:i>nest_level[-1], line, "Wrong order of visibilities: Must be public, protected, private!", path): return
|
||||
if nest_level[-1] == -2: # outside of class, only seen in SubActorKeeper.h in a macro definition - ignore then
|
||||
if CHECK(lambda a: i > nest_level[-1], line,
|
||||
"Wrong order of visibilities: Must be public, protected, private!", path): return
|
||||
if nest_level[
|
||||
-1] == -2: # outside of class, only seen in SubActorKeeper.h in a macro definition - ignore then
|
||||
continue
|
||||
nest_level[-1] = i
|
||||
continue
|
||||
@ -275,24 +311,28 @@ def header_check_line(line, path, visibility, should_start_class):
|
||||
if (line.startswith("class") and (not line.endswith(";") or "{" in line)) or should_start_class:
|
||||
if ": " in line and not ": public" in line and not ": virtual public" in line:
|
||||
FAIL("All superclasses must be public!", line, path)
|
||||
if should_start_class and not ": " in line and not line.startswith("public") and not line.startswith("virtual public"):
|
||||
if should_start_class and not ": " in line and not line.startswith("public") and not line.startswith(
|
||||
"virtual public"):
|
||||
FAIL("All superclasses must be public!", line, path)
|
||||
|
||||
if line.startswith("class") and "{" in line and ": " in line:
|
||||
index = 0
|
||||
while index < len(line):
|
||||
index = line.find(",", index+1)
|
||||
index = line.find(",", index + 1)
|
||||
if index == -1: break
|
||||
if index < line.find(": "): continue
|
||||
if index != line.find(", public", index) and index != line.find(", virtual public", index):
|
||||
FAIL("All superclasses must be public!", line, path)
|
||||
elif visibility == -1: # inside class, but not in a visibility block
|
||||
allowed = line in ["", "};"] or line.startswith("SEAD_SINGLETON_DISPOSER") or line.startswith("SEAD_RTTI_BASE") or line.startswith("SEAD_RTTI_OVERRIDE")
|
||||
CHECK(lambda a:allowed, line, "Inside class, but not in a visibility block, only empty lines and closing brace allowed!", path)
|
||||
allowed = line in ["", "};"] or line.startswith("SEAD_SINGLETON_DISPOSER") or line.startswith(
|
||||
"SEAD_RTTI_BASE") or line.startswith("SEAD_RTTI_OVERRIDE")
|
||||
CHECK(lambda a: allowed, line,
|
||||
"Inside class, but not in a visibility block, only empty lines and closing brace allowed!", path)
|
||||
elif visibility == 0: # public
|
||||
if "(" in line: # function
|
||||
function_name = line.split("(")[-2].split(" ")[-1]
|
||||
CHECK(lambda a:not function_name.endswith("_"), line, "Functions ending with an underscore are either protected or private!", path)
|
||||
CHECK(lambda a: not function_name.endswith("_"), line,
|
||||
"Functions ending with an underscore are either protected or private!", path)
|
||||
elif visibility == 2: # private
|
||||
if line == "};" or line == "" or line == "union {" or line.startswith("struct"): return
|
||||
if "(" in line and ")" in line: return
|
||||
@ -310,23 +350,30 @@ def header_check_line(line, path, visibility, should_start_class):
|
||||
var_name = newline.split(" ")[-1]
|
||||
var_type = " ".join(newline.split(" ")[0:-1])
|
||||
|
||||
if var_type.startswith("enum"):
|
||||
return # Allow enum inside class
|
||||
|
||||
PREFIXES = ["padding", "field", "unk", "gap", "_", "filler"]
|
||||
|
||||
if var_type.startswith("static"):
|
||||
CHECK(lambda a:var_name.startswith("s") and var_name[1].isupper(), line, "Static member variables must be prefixed with `s`!", path)
|
||||
CHECK(lambda a: var_name.startswith("s") and var_name[1].isupper(), line,
|
||||
"Static member variables must be prefixed with `s`!", path)
|
||||
else:
|
||||
allowed_name = (var_name.startswith("m") and var_name[1].isupper()) or any([var_name.startswith(p) for p in PREFIXES])
|
||||
CHECK(lambda a:allowed_name, line, "Member variables must be prefixed with `m`!", path)
|
||||
allowed_name = (var_name.startswith("m") and var_name[1].isupper()) or any(
|
||||
[var_name.startswith(p) for p in PREFIXES])
|
||||
CHECK(lambda a: allowed_name, line, "Member variables must be prefixed with `m`!", path)
|
||||
|
||||
if var_type == "bool":
|
||||
BOOL_PREFIXES = ["mIs", "mHas"]
|
||||
allowed_name = any([var_name.startswith(p) and (var_name[len(p)].isupper() or var_name[len(p)].isdigit()) for p in BOOL_PREFIXES]) or any([var_name.startswith(p) for p in PREFIXES])
|
||||
allowed_name = any(
|
||||
[var_name.startswith(p) and (var_name[len(p)].isupper() or var_name[len(p)].isdigit()) for p in
|
||||
BOOL_PREFIXES]) or any([var_name.startswith(p) for p in PREFIXES])
|
||||
if path.endswith("ByamlWriterData.h") and var_name == "mValue": return
|
||||
CHECK(lambda a:allowed_name, line, "Boolean member variables must start with `mIs` or `mHas`!", path)
|
||||
CHECK(lambda a: allowed_name, line, "Boolean member variables must start with `mIs` or `mHas`!", path)
|
||||
|
||||
def header_no_offset_comments(c, path):
|
||||
for line in c.splitlines():
|
||||
CHECK(lambda a:"// 0x" not in a, line, "Offset comments are not allowed in headers!", path)
|
||||
CHECK(lambda a: "// 0x" not in a, line, "Offset comments are not allowed in headers!", path)
|
||||
|
||||
# Source files
|
||||
|
||||
@ -368,7 +415,6 @@ def check_file(file_str):
|
||||
else:
|
||||
FAIL("Must only contain .h and .cpp files!", "NOT APPLICABLE", file_str)
|
||||
|
||||
|
||||
project_root = setup.ROOT
|
||||
|
||||
def main():
|
||||
@ -378,7 +424,7 @@ def main():
|
||||
help="Give verbose output")
|
||||
args = parser.parse_args()
|
||||
|
||||
for dir in [project_root/'lib'/'al', project_root/'src']:
|
||||
for dir in [project_root / 'lib' / 'al', project_root / 'src']:
|
||||
for root, _, files in os.walk(dir):
|
||||
for file in files:
|
||||
file_path = os.path.join(root, file)
|
||||
|
Loading…
Reference in New Issue
Block a user