Jump to content
Eternal Lands Official Forums
Malaclypse

Cleaning up the code

Recommended Posts

Ok, this will become a bigger post :P

 

After the macros, I looked into the variables. I generally commented variable declarations in header files, when they were unused, or used by one file only. If a variable is used by more than one file, I looked at (1) how much files use it and (2) how often said variable is used in any of those files.

 

These are the variables that are either unused or used by only one file (syntax is <type> <var-name> {, <var-name>}):

 

2d_objects.h:

int map_meters_size_x, map_meters_size_y

 

buddy.h:

int buddy_menu_x, buddy_menu_y, buddy_menu_x_len, buddy_menu_y_len

 

cache.h:

cache_struct* cache_texture (unused)

 

cursors.h:

cursors_struct cursors_array[20]

 

dialogues.h:

int dialogue_menu_y_len

 

draw_scene.h:

double camera_x_speed, camera_y_speed, camera_z_speed

int camera_x_frames, camera_y_frames, camera_z_frames

float terrain_scale

 

elconfig.h:

variables our_vars

 

encyclopedia.h:

int encyclopedia_menu_x_len, encyclopedia_menu_y_len

_Category Category[100]

 

events.h:

SDL_TimerID event_timer_clock (unused)

moved struct marking and variales adding_mark, mark_x, mark_y, max_mark and marks to mapwin.h as they belong more there then in events.h

 

filter.h:

filter_slot filter_list[MAX_FILTERS] as a side effect this allows us to move the macro MAX_FILTERS and the struct filter_slot to filter.c as well.

int filtered_so_far

int save_filters (unused)

 

font.h:

int cur_font_num

int max_font

font_info* fonts[] as a side effect the struct font_info gets also moved to font.c, also the macros FONT_START_CHAR, FONT_CHARS_PER_LINE, FONT_X_SPACING and FONT_Y_SPACING

moved the macros DRAW_INGAME_NORMAL, DRAW_INGAME_SMALL and DRAW_INGAME_ALT to actors.c as they are used only there.

 

gl_init.h:

int desktop_with, desktop_height

int have_sgis_generate_mipmap

int have_arb_shadow

void (*ELglMultiTexCoord2fvARB)(GLenum, const GLfloat)

 

hud.h:

moved variables to the top of file. They were spread throughout the file; removed double declaration of int hud_y; grouped the *_win variables together in one documentation block

icons_struct icons

float map_icon_u_start, map_icon_v_start

int icons_win, stats_bar_win, misc_win

int max_icon_x_start, map_icon_y_start, map_icon_x_end, map_icon_y_end (unused: they are used in a commented line in pathfinder.c)

 

ignore.h:

int ignored_so_far

 

init.h:

int ini_file_size

int have_stencil -> moved to gl_init.h, as it belongs more to this file than to init.h

struct e3d_list

e3d_list* e3dlist

int e3dlistsize

 

interface.h

int username_text_lenght, password_text_lenght

int open_text -> unused: it's declared both in draw_scene.c and in interface.c, but it's never used

int selected_3d_object, selected_inventory_object (unused)

 

items.h:

ground_item ground_item_list[50] as a side effect the struct ground_item gets moved to items.c too

bag bag_list[200] as a side effect the struct bag gets moved to items.c also

item inventory_trade_list[iTEM_WEAR_START]

int item_menu_x_len, item_menu_y_len

int ground_items_menu_x_len, ground_items_menu_y_len

int click_speed -> commented, already declared in interface.h

 

knowledge.h:

int knowledge_menu_x_len, knowledge_menu_y_len

int knowledge_page_start (unused)

 

lights.h:

GLfloat light_[0-6]_position[4], light_[0-6]_diffuse[4], light_[0-6]_dist

GLfloat global_lights[GLOBAL_LIGHTS_NO][4]

sun sun_pos[60*3] as a side effect the struct sun gets moved to lights.c too.

int sun_use_static_position

char lights_on (unused)

 

multiplayer.h:

const char* web_address

char our_name[20], our_password[20]

SDLNet_SocketSet set

Uint8 in_data[8192]

int previously_logged_in

int server_time_stamp, client_time_stamp, client_server_delta_time

 

options.h:

moved struct option_struct and struct options_struct to file options.c

 

questlog.h:

int questlog_menu_x_len, questlog_menu_y_len

moved typedef struct ld {}_logdata to questlog.c as it's only used in this file.

 

reflection.h:

water_vertex noise_array[16*16] as a side effect, struct water_vertex gets also moved to reflection.c

int sky_text1

float water_deepth_offset

 

sector.h:

int num_sectors

 

shadows.h:

float fDestMat[16] (unused)

float fPlane[4] (unused)

int shadows_texture

GLuint z_texture_id

 

sound.h:

moved struct playlist_entry to sound.c, it's used only there

 

spells.h:

sigil_def sigils_list[sIGIL_NO] as a side effect the macro SIGIL_NO and struct sigil_def gets also move to spells.c

Sint8 active_spells[10]

int sigil_menu_x_len, sigil_menu_y_len

int sigils_we_have

 

stats.h:

int attrib_menu_x_len, attrib_menu_y_len

player_attrib someone_info

 

text.h:

int display_console_text_buffer_last -> unused: it's declared and initialized in text.c, but never used; also commented declaration in text.c

char console_mode -> unused: declared and initialized in text.c, but never used; also commented declaration in text.c

 

timers.h:

int my_timer_clock

 

weather.h:

int lightning_text -> unused: declared and initialized in weather.c, but never used

thunder thunders[MAX_THUNDERS] -> commented, already declared in weather.c and used only there; as a side effect the macro MAX_THUNDERS and struct thunder also gets moved to weather.c

rain_drop rain_drops[MAX_RAIN_DROPS] -> moved to weather.c as it's used only there; as a side effect the macro MAX_RAIN_DROPS and struct rain_drop also gets moved to weather.c

 

widgets.h:

moved structs label, image, checkbox, button, progressbar, vscrollbar, tab and tab_collection to widgets.c, they are only used there.

 

 

----------------

 

The following variables are used in more than one file, but I felt of removing them from public declaration space. To prevent misunderstandings, if it reads redeclared as extern in somefile.c below, this means, I have commented the declaration of a variable extern <type> somevar, in some header file and added and extern <type> somevar to the said implementation file.

 

 

dialogues.h:

int dialogue_menu_x, dialogue_menu_y, dialogue_menu_x_len -> used by dialogues.c, init.c and multiplayer.c (redelcared as extern in init.c, multiplayer.c)

int portraits[1-5]_tex -> used by dialogues.c and init.c (redeclared as extern in init.c)

int cur_portrait -> used by dialogues.c and multiplayer.c (redeclared as extern in multiplayer.c)

char npc_name[20] -> used by dialogues.c and multiplayer.c (redeclared as extern in multiplayer.c)

char dialogue_string[2048] -> used by dialogues.c and multiplayer.c (redeclared as extern in multiplayer.c)

 

draw_scene.h:

float camera_tilt_speed -> used by draw_scene.c and events.c (redeclared as extern in events.c)

int camera_tilt_frames -> used by draw_scene.c and events.c (redeclared as extern in evetns.c)

int camera_zoom_dir -> used in draw_scene.c and events.c (redeclared as extern in events.c)

int camera_zoom_frames -> used in draw_scene.c and events.c (redeclared as extern in events.c)

Uint32 last_clear_clouds -> used in draw_scene.c and 3d_objects.c (redeclared as extern in 3d_objects.c)

 

e3d.h:

int highest_obj_3d -> used in 3d_objects.c and map_io.c (redeclared as extern in map_io.c)

 

elconfig.h:

int write_ini_on_exit -> used in elconfig.c and main.c (redeclared as extern in main.c)

 

encyclopedia.h:

int encyclopedia_menu_x, encyclopedia_menu_y -> used by encyclopedia.c and init.c (redeclared as extern in init.c)

_Page Page[500] -> used in encyclopedia.c and help.c (redeclared as extern in help.c)

int numpage -> used in encyclopedia.c and help.c (redeclared as extern in help.c)

 

filter.h:

int use_global_filters -> used in filter.c and elconfig.c (redeclared as extern in elconfig.c)

char text_filter_replace[] -> used in filter.c and elconfig.c (redeclared as extern in elconfig.c)

char storage_filter[128] -> used in filter.c and console.c (redeclared as extern in console.c)

 

gl_init.h:

int bpp -> used in gl_init.c and interface.c (redeclared as extern in interface.c)

int have_arb_compression -> used in gl_init.c and textures.c (redeclared as extern in textures.c)

int have_s3_compression -> used in gl_init.c and textures.c (redeclared as extern in textures.c)

 

hud.h:

int qb_action_mode -> used in hud.c, gamewin.c and events.c (redeclared as extern in gamewin.c)

int view_digital_clock -> used in hud.c and elconfig.c (redeclared as extern in elconfig.c)

int quickbar_x, quickbar_y, quickbar_dir -> used in hud.c and init.c (redeclared as extern in init.c)

 

ignore.h:

ignore_slot ignore_list[MAX_IGNORES] -> used in ignore.c and in 1 call in filter.c (redeclared as extern in filter.c)

int use_global_ignores -> used in ignore.c and in 1 call in elconfig.c (redeclared as extern in elconfig.c)

 

init.h:

int show_stats_in_hud, show_help_text -> moved to hud.c, as it belongs more to this file. Also is used only in hud.c and in 1 call in elconfig.c (redeclared as extern in elconfig.c)

int video_mode_set -> used in init.c and elconfig.c (redeclared as extern in elconfig.c)

 

interface.h:

int auto_camera -> used once in actor_scripts.c and options.c, although it's declared and initialized in interface.c (redeclared as extern in actor_scripts.c and options.c)

int mouse_delta_x, mouse_delta_y -> used in interface.c and events.c (redeclared as extern in events.c)

int login_screen_menus -> used in interface.c and in 1 call each in loginwin.c and new_character.c (redeclared as extern in loginwin.c and new_character.c)

Uint32 click_time -> declared in interface.c and used once each in hud.c and items.c (redeclared as extern in hud.c and items.c)

int click_speed -> declared in interface.c and used only in elconfig.c (redeclared as extern in elconfig.c)

int cur_map -> used in interface.c and map_io.c (redeclared as extern in map_io.c)

GLuint cont_text, legend_text -> used only in interface.c and once in init.c (redelcared as extern in init.c)

GLuint map_text -> used in interface.c and once in hud.c (redeclared as extern in hud.c)

 

items.h:

item manufacture_list[iTEM_NUM_ITEMS] -> used only in manufacture.c although it is declared in items.c (redeclared as extern in manufacture.c)

item your_trade_list[24], others_trade_list[24] -> moved to trade.c, as they are only used there, although they are declared in items.c

char other_player_trade_name[20] -> moved to trade.c, as it is only used there, although it's declared in items.c

int view_ground_items -> used in items.c and interface.c (redeclared as extern in interface.c)

int no_view_my_items -> moved to trade.c, as it's only used there, although it's declared in items.c

int item_menu_x, item_menu_y -> used in items.c and init.c (redeclared as extern in init.c)

int ground_items_menu_x, ground_items_menu_y -> used in items.c and init.c (redeclared as extern in init.c)

int manufactur_menu_x, manufacture_menu_y -> used in items.c, init.c and manufacture.c (redelcared as extern in init.c and manufacture.c)

int manufacture_menu_x_len, manufacture_menu_y_len -> moved to manufacture.c, as it's only used there, although it's declared and initialized in items.c (redeclared as extern in manufacture.c)

int trade_menu_x, trade_menu_y -> used in items.c, init.c and trade.c (redeclared as extern in init.c and trade.c)

int trade_menu_x_len, trade_menu_y_len -> moved to trade.c, as it's only used there, although it's declared in items.c

 

knowledge.h:

int knowledge_menu_x, knowledge_menu_y -> used in knowledge.c and init.c (redeclared as extern in init.c)

knowledge knowledge_list[KNOWLEDGE_LIST_SIZE] -> used in knowledge.c and 2 times in init.c (redeclared as extern in init.c)

char knowledge_string[400] -> used in knowledge.c and once in multiplayer.c (redeclared as extern in multiplayer.c)

 

lights.h:

GLfloat sky_lights_c[1-4][GLOBAL_LIGHTS_NO*2][4] -> used in lights.c and reflection.c (redeclared as extern in reflection.c)

GLfloat sun_ambient_light[] -> used in lights.c and once in shadows.c (redeclared as extern in shadows.c)

 

map_io.h:

float ambient_r, ambient_g, ambient_b -> used in map_io.c and once in lights.c, declared in tile_map.c (redeclared as extern in lights.c and map_io.c)

 

multiplayer.h:

char create_char_error_str[520] -> declared in interface.c, used in multiplayer.c and once each in init.c and new_character.c (redeclared as extern in multiplayer.c, init.c and new_character.c)

char log_in_error_str[520] -> declared in interface.c, used in multiplayer.c and once each in interface.c and loginwin.c (redeclared as extern in multiplayer.c and loginwin.c)

int port -> used in multiplayer.c and once in elconfig.c (redeclared as extern in elconfig.c)

char server_address[60] -> used in multiplayer.c and once in elconfig.c (redeclared as extern in elconfig.c)

int combat_mode -> declared in interface.c and only used once in hud.c (redeclared as extern in hud.c)

Uint32 last_heart_beat -> used in multiplayer.c and twice in timers.c (redeclared as extern in timers.c)

int log_conn_data -> used in multiplayer.c and once in console.c (redeclared as extern in console.c)

 

new_actors.h:

float sitting -> used in new_actors.c and draw_scene.c (redeclared as extern in draw_scene.c)

 

options.h:

int options_menu_x, options_menu_y -> declared in items.c, used in init.c and options.c (redeclared as extern in init.c and options.c)

int options_menu_x_len, options_menu_y_len -> declared in items.c, only used in options.c (redeclared as extern in options.c)

 

particles.h:

int particles_percentage -> used in particles.c and elconfig.c (redeclared as extern in elconfig.c)

 

pathfinder.h:

PF_TILE* pf_dst_tile -> used in pathfinder.c and twice in interface.c (redeclared as extern in interface.c)

 

questlog.h:

int questlog_menu_x, questlog_menu_y -> used in questlog.c and init.c (redeclared as extern in init.c)

 

reflection.h:

int lake_waves_timer -> used in reflection.c and timers.c (redeclared as extern in timers.c)

float water_movement_u, water_movement_v -> used in reflection.c and once each in timer.c (redeclared as extern in timers.c)

 

rules.h:

int have_rules -> declared in rules.c but only used in init.c (redeclared as extern in init.c)

int last_display -> used in rules.c and once loginwin.c (redeclared as extern in loginwin.c)

int countdown -> used in rules.c and once in timers.c (redeclared as extern in timers.c)

int has_accepted -> used in rules.c and init.c (redeclared as extern in init.c)

 

shadows.h:

float sun_position[4] -> used in shadows.c and lights.c (redeclared as extern in lights.c)

GLuint depth_map_id -> used in shadows.c and gl_init.c (redeclared as extern in gl_init.c)

GLenum depth_texture_target -> used in shadows.c and once in actors.c (redeclared as extern in actors.c)

int max_shadow_map_size -> used in shadows.c and once in elconfig.c (redeclared as extern in elconfig.c)

 

sound.h:

int have_sound -> used in sound.c and once in options.c (redeclared as extern in options.c)

int have_music -> used in sound.c and once each in options.c and main.c (redeclared as extern in options.c and main.c)

int sound_on, music_on -> used in sound.c and options.c (redeclared as extern in options.c)

int playing_music -> used in sound.c and once in multiplayer.c (redeclared as extern in multiplayer.c)

 

spells.h:

int sigil_menu_x, sigil_menu_y -> used in spells.c and init.c (redeclared as extern in init.c)

int sigils_text -> used in spells.c and once in init.c (redeclared as extern in init.c)

Uint8 spell_text[256] -> used in spells.c and once in multiplayer.c (redeclared as extern in multiplayer.c)

int have_error_message -> used in spells.c and once in multiplayer.c (redeclared as extern in multiplayer.c)

 

stats.h:

int attrib_menu_x, attrib_menu_y -> used in stats.c and init.c (redeclared as extern in init.c)

int watch_this_stat -> used in stats.c, init.c and once in hud.c (redeclared as extern in init.c and hud.c)

 

text.h:

int nr_text_buffer_lines -> used in text.c and twice in chat.c (redeclared as extern in chat.c)

int display_text_buffer_first -> used in text.c and once each in console.c, draw_scene.c and gamewin.c (redeclared as extern in console.c and gamewin.c)

int display_text_buffer_last -> used in text.c and twice in console.c (redeclared as extern in console.c)

int display_console_text_buffer_first -> used in text.c and once in console.c (redeclared as extern in console.c)

Uint32 last_server_message_time -> used in text.c and once in console.c (redeclared as extern in console.c)

int lines_to_show -> used in text.c and once in console.c (redeclared as extern in console.c)

int max_lines_no -> used in text.c and once each in draw_scene.c and gamewin.c (redeclared as extern in draw_scene.c and gamewin.c)

char not_from_the_end_console -> used in text.c and once in console.c (redeclared as extern in console.c)

int log_server -> used in text.c and once in elconfig.c (redeclared as extern in elconfig.c)

 

timers.h:

int my_timer_adjust -> used in timers.c and once in actor_scripts.c (redeclared as extern in actor_scripts.c)

SDL_TimerID draw_scene_timer -> used in timers.c and once each in init.c and main.c (redeclared as extern in init.c and main.c)

SDL_TimerID misc_timer -> used in timers.c and once each in init.c and main.c (redeclared as extern in init.c and main.c)

 

weather.h:

int seconds_till_rain_start, seconds_till_rain_stops -> used in weather.c and multiplayer.c (redeclared as extern in multiplayer.c)

int rain_sound -> used in weather.c and multiplayer.c (redeclared as extern in multiplayer.c)

int rain_light_offset -> used in weather.c and multiplayer.c (redeclared as extern in multiplayer.c)

int thunder_light_offset -> used in weather.c and lights.c (redeclared as extern in lights.c)

 

 

-----------------------

 

So far. Any objections, to this? Please note, if you haven't read all of the above, that also some datatypes have been moved from public scope to the corresponding implementation files. If any of the above changes should not be done for any reason, please let me know.

 

If there are no doubts until tomorrow late afternoon GMT, I will commit those changes and will look at the functions.

 

Sorry for this really big post.

 

<edit>Forgot this. I verified this against the map_editor and it compiles and runs just fine. I also played with a client using this changes yesterday all evening</edit>

Edited by Malaclypse

Share this post


Link to post
Share on other sites

Well, my personal feeling is that it's better to have the extern dec larations in the header file belonging to the object file int which the variable is declared. That way, it's obvious that this variable is used in more than one object file. If it's not declared in the header, I always assume that the variable is local to that file only.

Share this post


Link to post
Share on other sites

I talked to Grum yesterday in-game, after I saw his reply and I agree with him to not move the variables around that are used by more than one .c file. So I will undo the changes noted in the lower (second) part of my above post.

 

But I have some issues with the *_menu_[xy]{_len} variables. Some of them are only used in one implementation file, while others are used in more than one. This is due to the way, .c files are currently split up. Imho they should be all non-public, because we have the *_win window handler variables for each of the windows, which should be enough to handle the public scope of windows.

 

I feel we should handle those particular variables all the same, no matter whether they are used in one .c file or in several. What do you think? Shall we do an exception for those, or shall we just make them all public?

 

The variables in question are:

dialogue_menu_x, dialogue_menu_y, dialogue_menu_x_len, encyclopedia_menu_x, encyclopedia_menu_y, item_menu_x, item_menu_y, ground_items_menu_x, ground_items_menu_y, manufacture_menu_x, manufacture_menu_y, trade_menu_x, trade_menu_y, knowledge_menu_x, knowledge_menu_y, options_menu_x, options_menu_y, questlog_menu_x, questlog_menu_y, sigil_menu_x, sigil_menu_y, attrib_menu_x, attrib_menu_y.

 

For your convenience here are the variables of this kind, that are only used by one file are:

buddy_menu_x, buddy_menu_y, buddy_menu_x_len, buddy_menu_y_len, dialogue_menu_y_len, encyclopedia_menu_x_len, encyclopedia_menu_y_len, item_menu_x_len, item_menu_y_len, ground_items_menu_x_len, ground_items_menu_y_len, knowledge_menu_x_len, knowledge_menu_y_len, questlog_menu_x_len, questlog_menu_y_len, sigil_menu_x_len, sigil_menu_y_len, attrib_menu_x_len, attrib_menu_y_len

 

 

Also I would like to know what you think of those changes (from the second part of the above post):

items.h:

item your_trade_list[24], others_trade_list[24] -> moved to trade.c, as they are only used there, although they are declared in items.c

char other_player_trade_name[20] -> moved to trade.c, as it is only used there, although it's declared in items.c

int no_view_my_items -> moved to trade.c, as it's only used there, although it's declared in items.c

int trade_menu_x_len, trade_menu_y_len -> moved to trade.c, as it's only used there, although it's declared in items.c

 

options.h:

nt options_menu_x_len, options_menu_y_len -> declared in items.c, only used in options.c (redeclared as extern in options.c)

 

rules.h:

int have_rules -> declared in rules.c but only used in init.c (redeclared as extern in init.c)

 

 

One other thing is the translate.h file. It contains hundreds of variable declarations related to the i18n handling. I didn't check them all by now, but afaik each of them is only used by one .c file. So I would split this big declaration block and distribute them among the files where they are used. I will do this in a separate commit, after the current one has become clear and is commited.

Share this post


Link to post
Share on other sites
I feel we should handle those particular variables all the same, no matter whether they are used in one .c file or in several. What do you think? Shall we do an exception for those, or shall we just make them all public?

Let's keep them public, and make them private when we have cleaned up the code to the point where they're used in one file only.

Also I would like to know what you think of those changes (from the second part of the above post): <quote snipped>

Good idea, their current location makes no sense.

One other thing is the translate.h file. It contains hundreds of variable declarations related to the i18n handling. I didn't check them all by now, but afaik each of them is only used by one .c file. them.

I believe each of those is also given a default value in translate.c . I wouldn't move those, otherwise you'd be searching like crazy all over the code for your translation strings.

Share this post


Link to post
Share on other sites

The reason why "variables our_vars" in elconfig.h is declared as an extern is that i.e. gtk-elconfig is using the elconfig variable.

Share this post


Link to post
Share on other sites

So, I will change things, to reflect this changes. Thanks Wytter, for pointing this out, then I will keep this variable in elconfig.h

Share this post


Link to post
Share on other sites

I have commited the changes to the variables. Only variables used by only one implementation (.c) file are affected. I only commented them for now and marked them with an OBSOLETE comment and a remark that they are marked for removal from the respective file. I will do the actual removal in 2 weeks if anything is running well.

 

I noticed gtk-elconfig is currently broken. This is both due to code cleanup as well as due to changes in the windowing system. I'll go and look into this and mark the sections in elconfig.c respectively or else undo changes I made to the variables.

 

<edit>I fixed the issues with gtk-elconfig hopefully. I added some conditional compilation preprocessor instructions for it.</edit>

Edited by Malaclypse

Share this post


Link to post
Share on other sites

The last pass for the cleanup, covering function declarations. This is (hopefully) also the last big post for this topic.

 

Any of the functions listed below is only used in the corresponding .c file. I haven't touched any function declaration that is called from more than one file.

 

For each file affected, I list the functions that will be removed from the header file (in bold-face) and after that all the other functions in the resp. C file, that use (call) the particular function. Some functions are currently unused, they are marked with [uNUSED] after their name, other don't even have an implementation, they will be marked with [uNUSED/NO-IMPL]. For those functions that are unused, I have commented the implementation in the corresponding .c file as well. For some functions I had to add a forward declaration to the .c file to keep the compiler happy, those have an additional mark [FW].

 

I have omitted the file books.h for now.

 

2d_objects.h:

void draw_2d_object(): display_2d_objects()

obj_2d_def* load_obj_2d_def(): load_obj_2d_def_cache()

obj_2d_def* load_obj_def_cache(): add_2d_obj()

 

3d_objects.h:

e3d_object* load_e3d()[FW]: load_e3d_cache()

e3d_object* load_e3d_cache(): add_e3d()

void compute_clouds_map()[FW]: draw_3d_object()

 

actor_scripts.h:

float unwindAngle_Degrees(): next_command()

float get_rotation_vector(): next_command()

void update_all_actors(): add_command_to_actor()

 

actors.h:

int add_actor(): add_actor_from_server()

void draw_actor(): display_actors()

void end_actors_list()[uNUSED]: commented implementation in actors.c

draw_actor_overtext()[FW]: draw_actor_banner()

 

asc.h:

Sint32 get_string_after_string()[uNUSED]: commented implemenation in asc.c

void get_file_digest()[uNUSED]: commented implementation in asc.c

void get_string_digest()[uNUSED]: commented implemenation in asc.c

void my_UTF8Toisolat1()[FW]: my_xmlStrncpy()

 

buddy.h:

int compare2(): display_buddy_handler()

int click_buddy_handler(): display_buddy()

int display_buddy_handler(): display_buddy()

int drag_buddy_handler(): display_buddy()

 

cache.h:

void cache_system_shutdown()[uNUSED]: commented implemenation in cache.c

Uint32 cache_system_clean()[FW]: cache_system_maint()

Uint32 cache_system_compact(): cache_system_maint()

void cache_set_free()[uNUSED]: commented implementation in cache.c

Uint32 cache_clean()[FW]: cache_system_clean()

Uint32 cache_compact()[FW]: cache_system_compact()

void cache_delete()[FW]: cache_system_init(), cache_system_shutdown()

void cache_clear_counter()[uNUSED]: commented implementation in cache.c

void cache_set_size()[uNUSED]: commented implementation in cache.c

void cache_use_item()[uNUSED]: commented implementation in cache.c

cache_item_struct* cache_find(): cache_find_item(), cache_remove_item()

cache_item_struct* cache_find_ptr()[FW]: cache_adj_size(), cache_delete(), cache_set_name(), cache_set_size() and cache_use_item()

void cache_remove()[FW]: cache_clean(), cache_delete(), cache_remove_all(), cache_remove_item() and cache_remove_unused()

void cache_remove_item()[uNUSED]: commented implemenation in cache.c

void cache_remove_all()[FW]: cache_delete()

void cache_remove_unused()[uNUSED]: commented implementation in cache.c

 

console.h:

void cls(): test_for_console_command()

void print_log()[uNUSED]: commented implementation in console.c

 

cursors.h:

void assign_cursor(): build_cursors()

void change_cursor_show()[uNUSED]: commented implemenation in cursors.c

 

draw_scene.h:

void get_tmp_actor_data()[FW]: draw_scene()

 

elwindows.h:

int find_window()[uNUSED]: commented implementation in elwindows.c

void* get_window_handler()[uNUSED]: commented implementation in elwindows.c

int display_window()[FW]: display_windows()

int drag_in_window()[FW]: drag_in_windows()

int mouseover_window()[FW]: draw_window()

int keypress_in_window()[FW]: keypress_in_windows()

int draw_window(): display_window()

int draw_window_title(): draw_window()

int draw_window_base()[uNUSED/NO-IMPL]:

Note, there's a function called draw_window_border() implemented in elwindows.c, maybe this is a typo? But even then, it will be commented, because it is only used by draw_window()

 

encyclopedia.h:

int encyclopedia_mouse_over()[uNUSED/NO-IMPL]

void ReadCategoryXML(): ReadIndexXML()

void ReadIndexXML(): ReadXML()

 

events.h:

Uint32 event_timer()[uNUSED/NO-IMPL]

 

filter.h:

int check_if_filtered(): filter_text()

void load_filters_list(): load_filters()

void clear_filter_list(): load_filters()

 

font.h:

int draw_char_scaled(): draw_string_small(), draw_string_zoomed() and draw_string_zoomed_clipped()

int get_font_char()[FW]: find_font_char() and get_char_width()

int find_font_char(): draw_char_scaled() and draw_ingame_string()

int get_font_width()[FW]: draw_char_scaled(), draw_ingame_string(), get_char_width() and reset_soft_breaks()

int get_nstring_width()[FW]: get_string_width()

int set_font_parameters()[FW]: init_fonts()

void remove_font()[uNUSED]: commented implementation in font.c

 

gl_init.h:

void check_gl_mode(): init_video()

 

help.h:

int display_help_handler(): fill_help_win()

int click_help_handler(): fill_help_win()

 

hud.h:

void init_hud_frame()[FW]: init_hud_interface()

void init_peace_icons()[FW]: init_hud_interface()

int check_peace_icons()[uNUSED]: commented implementation in hud.c

void add_icon()[FW]: init_peace_icons()

void set_icon_order()[uNUSED/NO-IMPL]

void reset_states()[uNUSED/NO-IMPL]

int translate_win_id()[uNUSED]: commented implementation in hud.c

void switch_action_mode()[FW]: init_peace_icons()

void init_stats_display()[FW]: init_hud_interface()

int check_stats_display()[uNUSED]: commented implementation in hud.c

void draw_exp_display()[FW]: display_stats_bar_handler()

void draw_stats()[FW]: display_misc_handler()

void init_misc_display()[FW]: init_hud_interface()

int check_misc_display()[uNUSED]: commented implementation in hud.c

void init_quickbar()[FW]: init_hud_interface()

void draw_quickbar()[uNUSED]: commented implementation in hud.c

int check_quickbar()[uNUSED]: commented implementation in hud.c

void flip_quickbar()[FW]: click_quickbar_handler()

void reset_quickbar()[FW]: click_quickbar_handler()

void change_flags()[FW]: click_quickbar_handler(), draw_quickbar() and reset_quickbar()

Uint32 get_flags()[FW]: click_quickbar_handler()

 

ignore.h:

int check_if_ignored(): pre_check_if_ignored()

void load_ignores_list(): load_ignores()

void clear_ignore_list(): load_ignores()

 

init.h:

void load_harvestable_list(), void load_entrable_list(), void read_config(), void read_bin_cfg(), void init_md2_cache(), void init_texture_cache(), void init_e3d_cache(), void init_2d_obj_cache(), void load_e3d_list(), void read_command_line[FW]: init_stuff()

 

interface.h:

void draw_menu_title_bar()[uNUSED]: commented implementation in interface.c

 

items.h:

void draw_pick_up_menu()[FW]: get_bags_items_list()

 

keys.h:

unsigned int CRC32()[FW]: get_key_code()

unsigned short get_key_code()[FW]: parse_key_string()

unsigned int parse_key_string()[FW]: read_key_config()

void add_key()[FW]: parse_key_string()

 

lights.h:

void draw_test_light()[uNUSED]: commented implementation in lights.c

void enable_local_lights(): new_minute()

void make_gradient_light(): build_global_lights_table()

 

map_io.h:

void destroy_map(): load_map() and new_map()

int save_map()[uNUSED]: commented implementation in map_io.c

void new_map()[uNUSED]: commented implementation in map_io.c

 

md2.h:

md2* load_md2()[FW]: load_md2_cache() {md2loader.c}

void free_md2(): destory_md2() {md2loader.c}

 

misc.h:

void project_ortho(): mouse_in_sphere()

 

multiplayer.h:

void send_version_to_server(): connect_to_server()

void process_message_from_server(): process_data_from_server()

int recvpacket()[uNUSED/NO-IMPL]

void get_update()[uNUSED]: commented implementation in multiplayer.c

 

new_actors.h:

void draw_body_part()[uNUSED/NO-IMPL]

int add_enhanced_actor(): add_enhanced_actor_from_server()

 

new_character.h:

void check_for_input(): draw_new_char_screen()

void add_char_2_pass(), void add_char_2_un(), void add_char_2_conf(): add_char_to_new_character()

 

options.h:

void init_display_options_menu()[FW]: display_options_menu()

void add_option()[FW], void change_option()[FW], void move_to_full_screen()[FW] void switch_video_modes()[FW], void change_sound()[FW], void change_music()[FW]: init_display_options_menu()

 

particles.h:

void destroy_all_particle_defs()[FW]: end_particles_list()

int create_particle_sys()[FW]: add_particles_sys()

void create_particle(): create_particles_sys(), update_bag_part_sys(), update_fire_sys(), update_fountain_sys(), update_teleport_sys() and update_teleporter_sys()

void update_teleporter_sys(), void update_fire_sys(), void update_teleport_sys(), void update_bag_part_sys(), void update_burst_sys(), void update_fountain_sys(): update_particles()

void dump_part_sys_info()[uNUSED]: commented implementation in particles.c

int save_particle_def(): added conditional compilation directive MAP_EDITOR. Seems to be only used by mapeditor.(?)

 

pathfinder.h:

PF_TILE* pf_get_tile(): pf_find_path() and pf_move()

PF_TILE* pf_get_next_open_tile(): pf_find_path()

void pf_add_tile_to_open_list(): pf_find_path()

int pf_is_tile_occupied()[FW]: pf_move()

Uint32 pf_movement_timer_callback()[FW]: pf_find_path()

 

pm_log.h:

void add_name_to_pm_log(): add_message_to_pm_log() and send_afk_message()

void print_return_message()[FW]: go_ifk()

int have_name(): add_message_to_pm_log() and send_afk_message()

 

questlog.h:

void add_questlog_line()[FW]: add_questlog() and load_questlog()

void string_fix(): add_questlog()

 

reflection.h

float mrandom(): make_lake_water_noise()

void draw_body_part_reflection()[uNUSED/NO-IMPL]

void draw_actor_reflection(), void draw_enhanced_actor_reflection(), void draw_3d_reflection(), int find_local_reflection: display_3d_reflection()

void draw_lake_water_tile(): draw_lake_tiles()

 

rules.h:

void free_rules()[FW]: cleanup_rules(), init_rules_interface() and toggle_rules_window()

rule_string* get_interface_rules()[FW]: init_rules_interface() and toggle_rules_window()

void check_mouse_rules_interface()[FW]: draw_rules_interface() and mouseover_rules_handler()

int draw_rules()[FW]: display_rules_handler() and draw_rules_interface()

void reset_rules(): get_interface_rules() and highlight_rule()

 

sector.h:

int sector_add_2do(): sector_add_map()

int sector_add_light()[uNUSED]: commented implementation in sector.c

 

shadows.h:

void draw_3d_object_shadow(): display_shadows()

void draw_body_part_shadow()[uNUSED/NO-IMPL]

void draw_enhanced_actor_shadow(), void draw_actor_shadow(): display_actors_shadow()

void display_actors_shadow(): display_shadows()

void display_shadows(): draw_sun_shadowed_scene() and render_light_view()

void display_3d_ground_objects(), display_3d_non_ground_objects(): draw_sun_shadowed_scene()

 

sound.h:

int realloc_sources[FW]: add_sound_object() and kill_local_sounds()

ALuint get_loaded_buffer(): add_sound_object()

void play_ogg_file(): play_music() and update_music()

void load_ogg_file()[FW]: play_ogg_file()

void stream_music()[FW]: play_ogg_file() and update_music()

void ogg_error()[FW]: stream_music()

 

text.h:

void put_small_colored_text_in_box()[FW]: put_small_text_in_box()

int find_last_console_lines(): display_console_text()

 

textures.h

char* load_bmp8_color_key_no_texture()[uNUSED]: commented implementation in textures.c

char* load_bmp8_alpha_map()[uNUSED]: commented implementation in textures.c

void load_bmp8_to_coordinates(): load_bmp8_enhanced_actor()

 

translate.h:

void init_console()[FW], void init_help()[FW], void init_options()[FW], void init_spells()[FW], void init_stats()[FW], void init_titles()[FW], void init_errors()[FW]: init_translatables()

void* add_xml_group()[FW]: init_groups()

void add_xml_distringid(): init_options() and init_spells()

void add_xml_statid(): init_stats()

void add_xml_identifier(): init_console(), init_errors(), init_help(), init_stats() and init_titles()

void free_xml_parser()[FW]: load_translatables()

void parse_errors()[FW], void parse_console()[FW], void parse_help()[FW], void parse_options()[FW], void parse_spells()[FW], void parse_stats()[FW], void parse_titles()[FW]: load_translatables()

void save_string(): load_translatables()

struct xml_struct load_string()[FW]: load_translatables()

struct xml_struct load_strings_file()[FW]: load_string()

void copy_strings(): parse_distrings()

void copy_stats(): parse_statstrings()

void parse_statstrings(), void parse_distrings(), void parse_strings(): parse_groups()

void parse_groups(): parse_console(), parse_errors(), parse_help(), parse_options(), parse_spells(), parse_stats() and parse_titles()

 

widgets.h:

int ReadXMLWindow()[FW]: AddXMLWindow()

int ParseWindow()[FW]: ReadXMLWindow()

int ParseWidget()[FW]: ParseTab() and ParseWindow()

int ParseTab()[FW]: ParseWidget()

int GetWidgetType()[FW]: ParseWidget()

 

 

 

I have omitted the rest of widgets.h, although most of the functions declared there are currently not used. But they are under heavy development completing the window manager. So I was thinking we should wait until this is finished, then we can have a look at this file once more and see what can be changed.

 

I marked any function with an "OBSOLETE declaration" comment to show the queued removal of those declarations.

 

There are quite some unused functions. Although I have commented the implementation of them in the C files, I think we should keep them at least for another 6 month, until they might be considered for removal. Some of them could already be implemented for future extensions.

 

Any objections or comments about this?

Share this post


Link to post
Share on other sites

The above mentioned changes are commited. I also added comments at top of the C files, if there are unused and commented functions in this file.

Share this post


Link to post
Share on other sites

It takes a while before you know elc in and out and when that time comes, the server is within reach (FYI it takes longer to really get to know the server - I am not yet at that point...) ;-)

Share this post


Link to post
Share on other sites

Removed the commented parts related to this from the header files. Also removed comments from structures that have been moved to .c files due to code cleanup. The unused but implemented functions, I commented have been moved to the end of their respective files.

I tagged the *.[hc] files with a cleanup_050409 tag.

 

So this cleanup is now finished.

Edited by Malaclypse

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×