Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: Validate strings #234

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21,762 changes: 21,762 additions & 0 deletions data/data_strings.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/al/Project/Camera/CameraAngleSwingInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CameraAngleSwingInfo::CameraAngleSwingInfo() {
}

void CameraAngleSwingInfo::load(const ByamlIter& iter) {
tryGetByamlBool(&mIsInvalidSwing, iter, "IsInvalidString");
tryGetByamlBool(&mIsInvalidSwing, iter, "IsInvalidSwing");
if (mIsInvalidSwing)
return;

Expand Down
2 changes: 1 addition & 1 deletion src/Layout/ButtonMiiverse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ NERVE_IMPL(ButtonMiiverse, HoldOff);
NERVES_MAKE_STRUCT(ButtonMiiverse, Wait, Decide, OnWait, Disable, HoldOn, HoldOff);
} // namespace

ButtonMiiverse::ButtonMiiverse() : al::LayoutActor("Miiverse") {}
ButtonMiiverse::ButtonMiiverse() : al::LayoutActor("Miiverseボタン") {}

void ButtonMiiverse::init(const al::LayoutInitInfo& info) {
al::initLayoutActor(this, info, "ButtonMiiverse", 0);
Expand Down
2 changes: 1 addition & 1 deletion src/Layout/MenuSelectParts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void MenuSelectParts::exeSelect() {

param.mIsUseController = 1;
alPadRumbleFunction::startPadRumbleNo3DWithParam(
alPadRumbleFunction::getPadRumbleDirector(mLayoutActor), "240Hz", param, -1);
alPadRumbleFunction::getPadRumbleDirector(mLayoutActor), "240Hz単発", param, -1);

al::startAction(mLayoutArray[calcPartsIndex(mCursorItemIndex)], "Select", nullptr);
startActionMarioSelectIndex();
Expand Down
72 changes: 36 additions & 36 deletions src/Player/PlayerConst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ PlayerConst::PlayerConst() {
mSlopeRollingEndBrakeEndSpeed = 10.0;
mSlopeRollingReStartAccel = 6.0;
mSlopeRollingReStartMaxAdd = 3.0;
mSlopeRollingReStartinterval = 15;
mSlopeRollingReStartInterval = 15;
mSlopeRollingReStartSwing = 0;
mSlopeRollingReStartCharge = 40;
mSlopeRollingReStartForce = 60;
Expand Down Expand Up @@ -295,7 +295,7 @@ PlayerConst::PlayerConst() {
mWallCatchMoveDegree = 40.0;
mWallCatchMoveSpeed = 70.0;
mWallCatchMoveHeightRange = 70.0;
mWallCatchMoveinterpolate = 10;
mWallCatchMoveInterpolate = 10;
mWallCatchMoveFrame = 10;
mWallCatchMoveFrameFast = 8;
mWallCatchMoveFrameSwing = 6;
Expand Down Expand Up @@ -390,7 +390,7 @@ PlayerConst::PlayerConst() {
mHipDropSpeedMax = 45.0;
mHipDropLandCancelFrame = 24;
mHipDropHeight = 40.0;
mHipDropMsginterval = 8;
mHipDropMsgInterval = 8;
mJumpHipDropPower = 40.0;
mJumpHipDropPermitBeginFrame = 5;
mJumpHipDropPermitEndFrame = 30;
Expand Down Expand Up @@ -516,8 +516,8 @@ PlayerConst::PlayerConst() {
mOxygenReduceFrame = 1380;
mOxygenNoReduceFrame = 60;
mOxygenRecoveryFrame = 30;
mOxygenDamageinterval = 300;
mIceWaterDamageinterval = 300;
mOxygenDamageInterval = 300;
mIceWaterDamageInterval = 300;
mIceWaterRecoveryFrame = 70;
mMoveAnimSpeedMax = 25.0;
mAnimFrameRateSpeedMin = 6.0;
Expand Down Expand Up @@ -547,9 +547,9 @@ PlayerConst::PlayerConst() {
mRollingAnimBorderSpeedMax = 35.0;
mRollingAnimFrameRateMin = 0.2;
mRollingAnimFrameRateMax = 1.0;
mSwimPaddleAniminterval = 32;
mSwimPaddleAnimRateintervalMax = 22;
mSwimPaddleAnimRateintervalMin = 5;
mSwimPaddleAnimInterval = 32;
mSwimPaddleAnimRateIntervalMax = 22;
mSwimPaddleAnimRateIntervalMin = 5;
mSwimPaddleAnimMaxRate = 3.0;
mSwimBentForwardMax = 30.0;
mSwimBentForwardBlendRate = 0.05;
Expand Down Expand Up @@ -590,7 +590,7 @@ PlayerConst::PlayerConst() {
mMustacheStability = 0.3;
mMustacheFriction = 0.8;
mMustacheLimitDegree = 10.0;
mCapinterpolateFrame = 15;
mCapInterpolateFrame = 15;
mCapChildLocalOffset = 100.0;
mCapStability = 0.75;
mCapFriction = 0.2;
Expand Down Expand Up @@ -973,8 +973,8 @@ PlayerConst::PlayerConst(const al::ByamlIter& byaml) {
byaml.tryGetFloatByKey(&mSlopeRollingReStartAccel, "SlopeRollingReStartAccel");
mSlopeRollingReStartMaxAdd = 3.0;
byaml.tryGetFloatByKey(&mSlopeRollingReStartMaxAdd, "SlopeRollingReStartMaxAdd");
mSlopeRollingReStartinterval = 15;
byaml.tryGetIntByKey(&mSlopeRollingReStartinterval, "SlopeRollingReStartinterval");
mSlopeRollingReStartInterval = 15;
byaml.tryGetIntByKey(&mSlopeRollingReStartInterval, "SlopeRollingReStartInterval");
mSlopeRollingReStartSwing = 0;
byaml.tryGetIntByKey(&mSlopeRollingReStartSwing, "SlopeRollingReStartSwing");
mSlopeRollingReStartCharge = 40;
Expand Down Expand Up @@ -1207,8 +1207,8 @@ PlayerConst::PlayerConst(const al::ByamlIter& byaml) {
byaml.tryGetFloatByKey(&mWallCatchMoveSpeed, "WallCatchMoveSpeed");
mWallCatchMoveHeightRange = 70.0;
byaml.tryGetFloatByKey(&mWallCatchMoveHeightRange, "WallCatchMoveHeightRange");
mWallCatchMoveinterpolate = 10;
byaml.tryGetIntByKey(&mWallCatchMoveinterpolate, "WallCatchMoveinterpolate");
mWallCatchMoveInterpolate = 10;
byaml.tryGetIntByKey(&mWallCatchMoveInterpolate, "WallCatchMoveInterpolate");
mWallCatchMoveFrame = 10;
byaml.tryGetIntByKey(&mWallCatchMoveFrame, "WallCatchMoveFrame");
mWallCatchMoveFrameFast = 8;
Expand Down Expand Up @@ -1397,8 +1397,8 @@ PlayerConst::PlayerConst(const al::ByamlIter& byaml) {
byaml.tryGetIntByKey(&mHipDropLandCancelFrame, "HipDropLandCancelFrame");
mHipDropHeight = 40.0;
byaml.tryGetFloatByKey(&mHipDropHeight, "HipDropHeight");
mHipDropMsginterval = 8;
byaml.tryGetIntByKey(&mHipDropMsginterval, "HipDropMsginterval");
mHipDropMsgInterval = 8;
byaml.tryGetIntByKey(&mHipDropMsgInterval, "HipDropMsgInterval");
mJumpHipDropPower = 40.0;
byaml.tryGetFloatByKey(&mJumpHipDropPower, "JumpHipDropPower");
mJumpHipDropPermitBeginFrame = 5;
Expand Down Expand Up @@ -1649,10 +1649,10 @@ PlayerConst::PlayerConst(const al::ByamlIter& byaml) {
byaml.tryGetIntByKey(&mOxygenNoReduceFrame, "OxygenNoReduceFrame");
mOxygenRecoveryFrame = 30;
byaml.tryGetIntByKey(&mOxygenRecoveryFrame, "OxygenRecoveryFrame");
mOxygenDamageinterval = 300;
byaml.tryGetIntByKey(&mOxygenDamageinterval, "OxygenDamageinterval");
mIceWaterDamageinterval = 300;
byaml.tryGetIntByKey(&mIceWaterDamageinterval, "IceWaterDamageinterval");
mOxygenDamageInterval = 300;
byaml.tryGetIntByKey(&mOxygenDamageInterval, "OxygenDamageInterval");
mIceWaterDamageInterval = 300;
byaml.tryGetIntByKey(&mIceWaterDamageInterval, "IceWaterDamageInterval");
mIceWaterRecoveryFrame = 70;
byaml.tryGetIntByKey(&mIceWaterRecoveryFrame, "IceWaterRecoveryFrame");
mMoveAnimSpeedMax = 25.0;
Expand Down Expand Up @@ -1711,12 +1711,12 @@ PlayerConst::PlayerConst(const al::ByamlIter& byaml) {
byaml.tryGetFloatByKey(&mRollingAnimFrameRateMin, "RollingAnimFrameRateMin");
mRollingAnimFrameRateMax = 1.0;
byaml.tryGetFloatByKey(&mRollingAnimFrameRateMax, "RollingAnimFrameRateMax");
mSwimPaddleAniminterval = 32;
byaml.tryGetIntByKey(&mSwimPaddleAniminterval, "SwimPaddleAniminterval");
mSwimPaddleAnimRateintervalMax = 22;
byaml.tryGetIntByKey(&mSwimPaddleAnimRateintervalMax, "SwimPaddleAnimRateintervalMax");
mSwimPaddleAnimRateintervalMin = 5;
byaml.tryGetIntByKey(&mSwimPaddleAnimRateintervalMin, "SwimPaddleAnimRateintervalMin");
mSwimPaddleAnimInterval = 32;
byaml.tryGetIntByKey(&mSwimPaddleAnimInterval, "SwimPaddleAnimInterval");
mSwimPaddleAnimRateIntervalMax = 22;
byaml.tryGetIntByKey(&mSwimPaddleAnimRateIntervalMax, "SwimPaddleAnimRateIntervalMax");
mSwimPaddleAnimRateIntervalMin = 5;
byaml.tryGetIntByKey(&mSwimPaddleAnimRateIntervalMin, "SwimPaddleAnimRateIntervalMin");
mSwimPaddleAnimMaxRate = 3.0;
byaml.tryGetFloatByKey(&mSwimPaddleAnimMaxRate, "SwimPaddleAnimMaxRate");
mSwimBentForwardMax = 30.0;
Expand Down Expand Up @@ -1797,8 +1797,8 @@ PlayerConst::PlayerConst(const al::ByamlIter& byaml) {
byaml.tryGetFloatByKey(&mMustacheFriction, "MustacheFriction");
mMustacheLimitDegree = 10.0;
byaml.tryGetFloatByKey(&mMustacheLimitDegree, "MustacheLimitDegree");
mCapinterpolateFrame = 15;
byaml.tryGetIntByKey(&mCapinterpolateFrame, "CapinterpolateFrame");
mCapInterpolateFrame = 15;
byaml.tryGetIntByKey(&mCapInterpolateFrame, "CapInterpolateFrame");
mCapChildLocalOffset = 100.0;
byaml.tryGetFloatByKey(&mCapChildLocalOffset, "CapChildLocalOffset");
mCapStability = 0.75;
Expand Down Expand Up @@ -2560,7 +2560,7 @@ f32 PlayerConst::getSlopeRollingReStartMaxAdd() const {
}

s32 PlayerConst::getSlopeRollingReStartInterval() const {
return mSlopeRollingReStartinterval;
return mSlopeRollingReStartInterval;
}

s32 PlayerConst::getSlopeRollingReStartSwing() const {
Expand Down Expand Up @@ -3028,7 +3028,7 @@ f32 PlayerConst::getWallCatchMoveHeightRange() const {
}

s32 PlayerConst::getWallCatchMoveInterpolate() const {
return mWallCatchMoveinterpolate;
return mWallCatchMoveInterpolate;
}

s32 PlayerConst::getWallCatchMoveFrame() const {
Expand Down Expand Up @@ -3408,7 +3408,7 @@ f32 PlayerConst::getHipDropHeight() const {
}

s32 PlayerConst::getHipDropMsgInterval() const {
return mHipDropMsginterval;
return mHipDropMsgInterval;
}

f32 PlayerConst::getJumpHipDropPower() const {
Expand Down Expand Up @@ -3912,11 +3912,11 @@ s32 PlayerConst::getOxygenRecoveryFrame() const {
}

s32 PlayerConst::getOxygenDamageInterval() const {
return mOxygenDamageinterval;
return mOxygenDamageInterval;
}

s32 PlayerConst::getIceWaterDamageInterval() const {
return mIceWaterDamageinterval;
return mIceWaterDamageInterval;
}

s32 PlayerConst::getIceWaterRecoveryFrame() const {
Expand Down Expand Up @@ -4036,15 +4036,15 @@ f32 PlayerConst::getRollingAnimFrameRateMax() const {
}

s32 PlayerConst::getSwimPaddleAnimInterval() const {
return mSwimPaddleAniminterval;
return mSwimPaddleAnimInterval;
}

s32 PlayerConst::getSwimPaddleAnimRateIntervalMax() const {
return mSwimPaddleAnimRateintervalMax;
return mSwimPaddleAnimRateIntervalMax;
}

s32 PlayerConst::getSwimPaddleAnimRateIntervalMin() const {
return mSwimPaddleAnimRateintervalMin;
return mSwimPaddleAnimRateIntervalMin;
}

f32 PlayerConst::getSwimPaddleAnimMaxRate() const {
Expand Down Expand Up @@ -4208,7 +4208,7 @@ f32 PlayerConst::getMustacheLimitDegree() const {
}

s32 PlayerConst::getCapInterpolateFrame() const {
return mCapinterpolateFrame;
return mCapInterpolateFrame;
}

f32 PlayerConst::getCapChildLocalOffset() const {
Expand Down
18 changes: 9 additions & 9 deletions src/Player/PlayerConst.h
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ class PlayerConst : public al::HioNode {
f32 mSlopeRollingEndBrakeEndSpeed;
f32 mSlopeRollingReStartAccel;
f32 mSlopeRollingReStartMaxAdd;
s32 mSlopeRollingReStartinterval;
s32 mSlopeRollingReStartInterval;
s32 mSlopeRollingReStartSwing;
s32 mSlopeRollingReStartCharge;
s32 mSlopeRollingReStartForce;
Expand Down Expand Up @@ -919,7 +919,7 @@ class PlayerConst : public al::HioNode {
f32 mWallCatchMoveDegree;
f32 mWallCatchMoveSpeed;
f32 mWallCatchMoveHeightRange;
s32 mWallCatchMoveinterpolate;
s32 mWallCatchMoveInterpolate;
s32 mWallCatchMoveFrame;
s32 mWallCatchMoveFrameFast;
s32 mWallCatchMoveFrameSwing;
Expand Down Expand Up @@ -1014,7 +1014,7 @@ class PlayerConst : public al::HioNode {
f32 mHipDropSpeedMax;
s32 mHipDropLandCancelFrame;
f32 mHipDropHeight;
s32 mHipDropMsginterval;
s32 mHipDropMsgInterval;
f32 mJumpHipDropPower;
s32 mJumpHipDropPermitBeginFrame;
s32 mJumpHipDropPermitEndFrame;
Expand Down Expand Up @@ -1140,8 +1140,8 @@ class PlayerConst : public al::HioNode {
s32 mOxygenReduceFrame;
s32 mOxygenNoReduceFrame;
s32 mOxygenRecoveryFrame;
s32 mOxygenDamageinterval;
s32 mIceWaterDamageinterval;
s32 mOxygenDamageInterval;
s32 mIceWaterDamageInterval;
s32 mIceWaterRecoveryFrame;
f32 mMoveAnimSpeedMax;
f32 mAnimFrameRateSpeedMin;
Expand Down Expand Up @@ -1171,9 +1171,9 @@ class PlayerConst : public al::HioNode {
f32 mRollingAnimBorderSpeedMax;
f32 mRollingAnimFrameRateMin;
f32 mRollingAnimFrameRateMax;
s32 mSwimPaddleAniminterval;
s32 mSwimPaddleAnimRateintervalMax;
s32 mSwimPaddleAnimRateintervalMin;
s32 mSwimPaddleAnimInterval;
s32 mSwimPaddleAnimRateIntervalMax;
s32 mSwimPaddleAnimRateIntervalMin;
f32 mSwimPaddleAnimMaxRate;
f32 mSwimBentForwardMax;
f32 mSwimBentForwardBlendRate;
Expand Down Expand Up @@ -1214,7 +1214,7 @@ class PlayerConst : public al::HioNode {
f32 mMustacheStability;
f32 mMustacheFriction;
f32 mMustacheLimitDegree;
s32 mCapinterpolateFrame;
s32 mCapInterpolateFrame;
f32 mCapChildLocalOffset;
f32 mCapStability;
f32 mCapFriction;
Expand Down
43 changes: 43 additions & 0 deletions tools/check-format.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

import argparse
import csv
import os
import re
from functools import cache
Expand Down Expand Up @@ -257,6 +258,30 @@ def common_sead_math_template(c, path):
continue
FAIL("Use short sead types: sead::Vector3f, sead::Mathi and similar!", line, path)

def common_string_finder(c, path):
string_table = get_string_table()

for line in c.splitlines():
if "#include" in line:
continue
if "extern \"C\"" in line:
continue
if "//" in line:
continue

matches = re.findall(r'"(.+?)"', line)

for match in matches:
if len(match) < 2:
continue
found = False
for x in string_table:
if match == x[1]:
found = True
break
if not found:
FAIL("String not found in binary: \""+match+"\"", line, path)

# Header files

def header_sorted_visibility(c, path):
Expand Down Expand Up @@ -389,6 +414,7 @@ def check_source(c, path):
common_void_params(c, path)
common_const_type(c, path)
common_this_prefix(c, path)
common_string_finder(c, path)
common_sead_math_template(c, path)

def check_header(c, path):
Expand All @@ -415,6 +441,23 @@ def check_file(file_str):
else:
FAIL("Must only contain .h and .cpp files!", "NOT APPLICABLE", file_str)

def read_csv_file(path):
if not os.path.isfile(path):
raise FileNotFoundError('CSV File not found')

rows = []

with open(path, "r") as file:
reader = csv.reader(file)
for row in reader:
rows.append(row)

return rows;

@cache
def get_string_table():
return read_csv_file(project_root / 'data' / "data_strings.csv");

project_root = setup.ROOT

def main():
Expand Down
Loading
Loading