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

Add enum for FatalError + void-alize all functions taking no arguments #202

Merged
merged 3 commits into from
Oct 16, 2022

Conversation

madebr
Copy link
Collaborator

@madebr madebr commented Oct 1, 2022

  • Add an enum for the first argument of FatalError. The suffix _S means it takes one string arguments.
    By doing this, I found a few places where an error expects a string argument, but did not pass one.

  • Add explicit void to all functions accepting no arguments because in C, void no_args() declares a function that takes an unspecified (but not variable) number of parameters (and returns nothing). So all calls are valid (according to the prototype) in C.

    I did the () -> (void) using the following command.

    find . -iname "*.h" -exec sed -i -E s/\\\(\\\)/\(void\)/g {} \;
    

    Afterwards I manually checked the changes and reverted a few unneeded conversions.

@@ -346,7 +346,7 @@ void CreateStainlessClasses() {
for (i = 129; i < 246; i++) {
gStainless_classes[i - 129].res_class = i;
if (!BrResClassAdd(&gStainless_classes[i - 129])) {
FatalError(94);
FatalError(kFatalError_OOMCarmageddon_S, gStainless_classes[i - 129].identifier);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error type 94 needs a string argument.

if (!gHorizon_material) {
FatalError(89);
if (gHorizon_material == NULL) {
FatalError(kFatalError_FindSkyMaterial_S, "HORIZON.MAT"); // 2nd argument added
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error type 89 needs a string argument.

@@ -1532,7 +1532,7 @@ void GetDamageProgram(FILE* pF, tCar_spec* pCar_spec, tImpact_location pImpact_l
}
}
if (the_clause->effects[j].type < 0) {
FatalError(91);
FatalError(kFatalError_UnknownDamageType_S, str);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error type 91 needs a string argument as well

if (!total) {
FatalError(82);
if (total == 0) {
FatalError(kFatalError_LoadModelFile_S, str);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error type 82 needs a string argument as well.

@@ -314,14 +314,14 @@ int LoadNPixelmaps(tBrender_storage* pStorage_space, FILE* pF, int pCount) {
PathCat(the_path, the_path, str);
total = DRPixelmapLoadMany(the_path, temp_array, COUNT_OF(temp_array));
if (total == 0) {
FatalError(79);
FatalError(kFatalError_LoadPixelmapFile_S, str);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error type 79 needs a string as well.

if (!total) {
FatalError(80);
if (total == 0) {
FatalError(kFatalError_LoadShadeTableFile_S, str);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error type 80 needs a string as well.

if (!total) {
FatalError(81);
if (total == 0) {
FatalError(kFatalError_LoadMaterialFile_S, str);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error type 81 needs a string as well.

@dethrace-labs
Copy link
Owner

Nice one! Great that it uncovered some places where we weren't passing the expected string arg too!

@dethrace-labs dethrace-labs merged commit d3efa46 into dethrace-labs:main Oct 16, 2022
@madebr madebr deleted the cosmetic-changes branch October 16, 2022 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants