GrimSqueaker / remc2

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

How to handle dead code? #32

Closed GrimSqueaker closed 3 years ago

GrimSqueaker commented 3 years ago

Whilst working on providing a 64bit build on Linux, I stumbled upon a lot of dead code, i.e. functions that are never called. I started to comment them out which sometimes results in a cascade of functions that become never called. See for example a40a8b1b918abf471837ac3eef55392f926a5525. What are your opinions on that, @turican0 and @thobbsinteractive? For the moment I marked them all with a // NOTE: dead code but I think it would be better to remove them completely. Maybe some of these functions are related to DOS-specifics that we do not need to care for anymore. Or are there reasons for keeping them, @turican0 ?

turican0 commented 3 years ago

Yes, in code is many zombie functions. Mostly garbage. In type_str_0x6E8E pre_sub_4A190_axis_3d(Bit32u adress, axis_3d a1_axis3d, int type) is only function where called when I play all game. Maybe is some unfinded. Some unfinded code maybe used for multiplayer, too.. But it is not a problem to remove them now, if they prove useful, they can be found in older commits. We can remove it. Tom.

GrimSqueaker commented 3 years ago

Ok, I have started to remove that code now. Multiplayer is anyhow something that would need to undergo a lot of rewrites / new code for getting it to work. I guess this will only be feasible later when the logic is better understood and cleaned up. And then you are right that we still have old versions of the code to get an idea.

thobbsinteractive commented 3 years ago

It might be intresting to force enable the multiplayer menu option and see where it goes before removing the zombie code.

While it is likely we will have to drop a lot of it, the packet structure and how and what is updated with each packet might be worth finding and keeping?

Perhaps just remove the commented stuff for now?

On Mon, 8 Feb 2021, 21:59 GrimSqueaker, notifications@github.com wrote:

Ok, I have started to remove that code now. Multiplayer is anyhow something that would need to undergo a lot of rewrites / new code for getting it to work. I guess this will only be feasible later when the logic is better understood and cleaned up. And then you are right that we still have old versions of the code to get an idea.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/GrimSqueaker/remc2/issues/32#issuecomment-775457251, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETQQFHRPEK7GMCI7OTKALDS6BGB5ANCNFSM4XHQHKZA .

GrimSqueaker commented 3 years ago

It might be intresting to force enable the multiplayer menu option and see where it goes before removing the zombie code.

The zombie code I did remove was not referenced at all. So, functions that are declared and defined, but not called once. Not even in code that is commented out and most of it not even in NETHERW.c. I had to revert this because it was on a branch which I could not get updated with changes on development anymore and had to abandon it.

I'll check, if I can find it again and remove it based on a current version of development again.

GrimSqueaker commented 3 years ago

For example: sub_6FE90 I stumbled upon some of these during making 64bit compile.

turican0 commented 3 years ago

sub_6FE90 is after sub_6FE20-some stub code for sound card, sub_6FE90 is maybe some for sound, but unused code, too.

turican0 commented 3 years ago

sub_6FE90 is after sub_6FE20-some stub code for sound card, sub_6FE90 is maybe some for sound, but unused code, too.