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

Some C files, and functions, are too long. #41

Open
malespiaut opened this issue Aug 7, 2023 · 0 comments
Open

Some C files, and functions, are too long. #41

malespiaut opened this issue Aug 7, 2023 · 0 comments

Comments

@malespiaut
Copy link
Contributor

I'm sure that anybody who have read Rise of the Triad's source code have noticed that some functions, and therefore C files, are exceptionnaly long.

Right now, the longest file is rt_actor.c, with 13,475 lines.

$ wc -l *.c *.h | sort -h
     22 fli_glob.h
     24 rt_crc.h
     25 gmove.h
     25 _rt_msg.h
     25 _rt_scal.h
     26 profile.h
     27 _engine.h
     27 watcom.h
     28 rt_datadir.h
     28 rt_error.h
     28 _rt_floo.h
     28 version.h
     29 _rt_dman.h
     32 _isr.h
     32 rt_map.h
     32 rt_vh_a.h
     33 f_scale.h
     33 myprint.h
     33 rt_sqrt.h
     34 rt_debug.h
     34 rt_sc_a.h
     35 rt_fc_a.h
     35 _rt_main.h
     36 cin_main.h
     36 rt_rand.h
     37 cin_glob.h
     37 rt_dr_a.h
     40 cin_actr.h
     40 _rt_util.h
     41 cin_evnt.h
     41 _rt_str.h
     41 scriplib.h
     42 watcom.c
     43 byteordr.h
     43 cin_glob.c
     44 rt_floor.h
     44 _rt_map.h
     45 m_misc2.h
     45 _rt_vid.h
     46 sndcards.h
     48 _rt_buil.h
     48 rt_com.h
     48 _rt_door.h
     51 w_wad.h
     52 engine.h
     53 _rt_com.h
     53 rt_scale.h
     54 _rt_in.h
     55 WinRott.h
     58 _rt_stat.h
     65 rt_build.h
     69 develop.h
     69 task_man.h
     70 cin_efct.h
     70 rt_sqrt.c
     71 rt_msg.h
     72 rottnet.h
     72 _w_wad.h
     74 _rt_draw.h
     77 z_zone.h
     79 isr.h
     82 modexlib.h
     84 byteordr.c
     90 _rt_ted.h
     94 rt_vid.h
     96 music.h
    103 rt_crc.c
    104 cin_def.h
    106 keyb.h
    110 rt_cfg.h
    111 rt_rand.c
    114 rt_dmand.h
    114 _rt_soun.h
    120 fx_man.h
    122 _rt_net.h
    125 _rt_play.h
    125 rt_str.h
    127 rt_draw.h
    131 rt_view.h
    132 sbconfig.h
    135 rt_util.h
    147 rt_game.h
    151 lumpy.h
    152 winrott.c
    165 _rt_game.h
    167 rt_main.h
    176 isr.c
    182 rt_ted.h
    205 dosutil.c
    207 splib.h
    209 rt_in.h
    212 rt_menu.h
    215 z_zone.c
    216 rt_datadir.c
    224 rt_battl.h
    238 rt_stat.h
    264 rt_playr.h
    270 rt_door.h
    275 cin_main.c
    291 _rt_rand.h
    296 _rt_acto.h
    303 cin_actr.c
    312 scriplib.c
    322 rt_net.h
    336 rt_err.c
    369 _rt_menu.h
    394 rt_dmand.c
    402 dukemusc.c
    417 engine.c
    424 rt_actor.h
    459 m_misc2.c
    459 w_wad.c
    487 rt_def.h
    502 modexlib.c
    524 cin_evnt.c
    611 rt_floor.c
    644 states.h
    689 rt_sound.h
    759 rt_com.c
    802 rt_msg.c
    868 cin_efct.c
    885 rt_view.c
    967 rt_vid.c
    985 rt_map.c
   1117 rt_battl.c
   1188 rt_scale.c
   1286 rt_util.c
   1302 snd_shar.h
   1331 rt_table.h
   1382 rt_sound.c
   1393 rt_in.c
   1435 snd_reg.h
   1518 rt_debug.c
   1554 rt_build.c
   1611 sprites.h
   1629 rt_str.c
   1896 rt_stat.c
   1981 rt_state.c
   1991 rt_cfg.c
   2572 rt_main.c
   3016 rt_net.c
   4211 rt_door.c
   5308 rt_draw.c
   5350 rt_game.c
   5965 rt_playr.c
   6296 rt_ted.c
   8624 rt_menu.c
  13475 rt_actor.c
  99522 total

Although I'm not a suckless zealot, I think that some work should be in that direction. Either refactoring functions to make them smaller (some functions are copies with only a small variation and could be rewriten to be a single function with a switch case), a lot of useless comments could be replaced with usefull comments, or splitting big C files into smaller ones. I think that a “limit” of around 2,000 lines per files (including comments) is not a bad idea.

However, I must precise that this is, in my opinion, a very low priority issue, that should only happen after all functional changes has been made to the code. But it's something to keep in mind to increase code readability, and therefore increase the number of potential contributors, or tinkerers.

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

No branches or pull requests

1 participant