GrimSqueaker / remc2

Recode Binary code of game Magic Carpet2 to C/C++ language(remake MC2 for any platform)
6 stars 0 forks source link

Clang tidy #56

Closed GrimSqueaker closed 3 years ago

GrimSqueaker commented 3 years ago

I used Clang tidy in "fix" mode for removing unused parameters. The purpose is to clarify which variables are used at all in functions so that we can simplify the code later on. Could you please check, if you are fine with that? (No need to look into details, just to see if you agree, because it touches a lot of lines of code) If so, I would like to explore other Clang tidy checks as well.

Tim-Hobbs commented 3 years ago

It seems to be just commenting them out, not removing them.

turican0 commented 3 years ago

Definitely the right step, just please best mark this commit (removing unused variables) so that we can copy the code from it, if necessary in future. Tom.

turican0 commented 3 years ago

Some functions adresses is hardcoded in data/structures. I add all functions, when used in my gameplay by all game, may we find next functions when test multiplayer or VR(this code we can copy from commit before deleting unused code), Tom.

GrimSqueaker commented 3 years ago

Exactly, Clang tidy does not remove them, this is still up to us, because it could be a function in a library for which you do not want to automatically change the ABI/API. But when we are working on a function and notice that some of the parameters are commented out, then we can safely change the declaration and the call in all calling functions. Moreover, we can also check, if the variables that were originally passed to the function become obsolete in the calling function. This, sadly, is nothing that can be automated AFAIK.

GrimSqueaker commented 3 years ago

I did run Clang tidy in 64bit on Linux. This is why both CI failed. I should be able to re-run it in 32 bit mode which should definitely fix the Linux CI and then try to check with Windows as well.

turican0 commented 3 years ago

You must before this action disable COMPILE_FOR_64BIT, else it disabling used variables: void sub_98709_create_index_dattab_power_add(uint8_t tabbuffer, uint8_t tabbufferend, uint8_t* /datbuffer/, posistruct_t* dattabindex, int add)//279709

IN: void sub_98709_create_index_dattab_power_add(uint8_t tabbuffer, uint8_t tabbufferend, uint8_t datbuffer, posistruct_t dattabindex, int add)//279709 { for (uint32_t i = 0; i < (tabbufferend - (tabbuffer + add)) / 6; i++) {

ifdef TEST_x64

allert_error();

endif

ifdef COMPILE_FOR_64BIT // FIXME: 64bit

    std::cout << "FIXME: 64bit @ function " << __FUNCTION__ << ", line " << __LINE__ << std::endl;

else

    dattabindex[i].data = (uint8_t*)(*(uint32_t*)((tabbuffer + add) + 6 * i)) + **(int32_t)datbuffer;**

endif

    dattabindex[i].width = (tabbuffer + add)[6 * i + 4] * 2;
    dattabindex[i].height = (tabbuffer + add)[6 * i + 5] * 2;
}

}