From: Christian Heller Date: Sat, 9 Nov 2013 02:14:05 +0000 (+0100) Subject: More consistent code styling whitespace rules. X-Git-Tag: tce~932 X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/static/%7Broute%7D?a=commitdiff_plain;h=350ef2e2d17e8122e2991466f76a9a083a6303e7;p=plomrogue More consistent code styling whitespace rules. --- diff --git a/src/command_db.h b/src/command_db.h index bbc60f4..866f5e3 100644 --- a/src/command_db.h +++ b/src/command_db.h @@ -36,8 +36,6 @@ extern uint8_t get_command_id(char * dsc_short); /* Give short description of command ("dsc_short"), get long description. */ extern char * get_command_longdsc(char * dsc_short); - - /* Read in CommandDB from file "config/commands" to world.cmd_db. */ extern void init_command_db(); diff --git a/src/control.h b/src/control.h index 30b2dda..8c44cc0 100644 --- a/src/control.h +++ b/src/control.h @@ -13,24 +13,18 @@ /* Return keycode to action of "name" if available in current window config. */ extern uint16_t get_available_keycode_to_action(char * name); - - /* Control the player character, either via action id "action" or pressed "key". * Return 1 on success, 0 if no appropriate action to trigger was found. */ extern uint8_t player_control_by_key(int key); extern uint8_t player_control_by_id(int action); - - /* Control via "key" active window's geometry / keybindings in respective config * view. */ extern uint8_t wingeom_control(int key); extern uint8_t winkeyb_control(int key); - - /* Call by "key" further game / window management actions that don't influence * the player character. If the "quit" action is called, return 1 (instead of * exiting directly). diff --git a/src/draw_wins.h b/src/draw_wins.h index af80a14..958d8a9 100644 --- a/src/draw_wins.h +++ b/src/draw_wins.h @@ -21,8 +21,6 @@ extern void draw_win_keybindings_global(struct Win * win); extern void draw_win_keybindings_winconf_geometry(struct Win * win); extern void draw_win_keybindings_winconf_keybindings(struct Win * win); - - /* Routines to draw windows' configuration views. */ extern void draw_winconf_keybindings(struct Win * win); extern void draw_winconf_geometry(struct Win * win); diff --git a/src/keybindings.h b/src/keybindings.h index b2e74c0..fc0faae 100644 --- a/src/keybindings.h +++ b/src/keybindings.h @@ -18,8 +18,6 @@ struct KeyBinding char * name; /* name of functionality bound to keycode */ }; - - /* Wrapper to keybinding chain, contains some keybinding editing metadata. */ struct KeyBiData { @@ -48,8 +46,6 @@ extern uint16_t get_n_of_keybs(struct KeyBinding * kb_p); /* Return "n"-th keybinding in keybindings chain from "kb_p" on. */ extern struct KeyBinding * get_keyb_of_n(struct KeyBinding * kb_p, uint16_t n); - - /* Initialize/save keybindings data from/to file at "path" to/from keybindings * data pointer "kbd". */ @@ -59,8 +55,6 @@ extern void save_keybindings(char * path, struct KeyBiData * kbd); /* Free keybinding chain starting at "kb_start". */ extern void free_keybindings(struct KeyBinding * kb_start); - - /* Mark keybinding selected for modification as being edited, get user input to * modify it, then unmark it again. Ensure there are max. three digits in the * keycode ASCII representation. diff --git a/src/map.h b/src/map.h index 4f67bb1..6a39e35 100644 --- a/src/map.h +++ b/src/map.h @@ -29,15 +29,11 @@ struct Map */ extern struct Map init_map(); - - /* Try to change the view center of map into directino described by "d" (north * = "N", east = "E" etc.). */ extern void map_scroll(char d); - - /* Center map on player. */ extern void map_center(); diff --git a/src/map_object_actions.h b/src/map_object_actions.h index 1b2d95b..8e0af47 100644 --- a/src/map_object_actions.h +++ b/src/map_object_actions.h @@ -19,30 +19,22 @@ struct MapObj; */ extern uint8_t move_actor(struct MapObj * actor, char d); - - /* Wrapper for using move_actor() on the MapObj representing the player; updates * the game log with appropriate messages on the move attempt and its results; * turns over to turn_over() when finished. */ extern void move_player(char d); - - /* Make player wait one turn, i.e. only update_log with a "you wait" message * and turn control over to the enemy. */ extern void player_wait(); - - /* Check if coordinate pos on (or beyond) map is accessible to map object * movement. */ extern char is_passable(struct Map * map, struct yx_uint16 pos); - - /* Make player drop to ground map ojbect indexed by world.inventory_select. */ extern void player_drop(); diff --git a/src/map_objects.c b/src/map_objects.c index 4deaa08..d114c5b 100644 --- a/src/map_objects.c +++ b/src/map_objects.c @@ -18,8 +18,6 @@ /* Write representation of "mo" and all of the map objects it owns to "file". */ static void write_map_object(FILE * file, struct MapObj * mo); - - /* Return pointer to map object of "id" in chain starting at "ptr". */ static struct MapObj * get_map_object(struct MapObj * ptr, uint8_t id); diff --git a/src/map_objects.h b/src/map_objects.h index 5cc6ee4..6342f4b 100644 --- a/src/map_objects.h +++ b/src/map_objects.h @@ -23,8 +23,6 @@ struct MapObj struct yx_uint16 pos; /* coordinate on map */ }; - - struct MapObjDef { struct MapObjDef * next; @@ -40,13 +38,9 @@ struct MapObjDef /* Initialize map object defnitions chain from file at path "filename". */ extern void init_map_object_defs(char * filename); - - /* Free map object definitions chain starting at "mod_start". */ extern void free_map_object_defs(struct MapObjDef * mod_start); - - /* Add new object(s) ("n": how many?) of "type" to map on random position(s). * New animate objects are never placed in the same square with other animated * ones. @@ -54,8 +48,6 @@ extern void free_map_object_defs(struct MapObjDef * mod_start); extern void add_map_object(uint8_t type); extern void add_map_objects(uint8_t type, uint8_t n); - - /* Write map objects chain to "file". */ extern void write_map_objects(FILE * file); @@ -64,29 +56,19 @@ extern void write_map_objects(FILE * file); */ extern void read_map_objects(FILE * file, char * line, int linemax); - - /* Free map objects in map object chain starting at "mo_start. */ extern void free_map_objects(struct MapObj * mo_start); - - /* Move object of "id" from "source" inventory to "target" inventory. */ extern void own_map_object(struct MapObj ** target, struct MapObj ** source, uint8_t id); - - /* Get pointer to the MapObj struct that represents the player. */ extern struct MapObj * get_player(); - - /* Get pointer to the map object definition of identifier "def_id". */ extern struct MapObjDef * get_map_object_def(uint8_t id); - - /* Move not only "mo" to "pos", but also all map objects owned by it. */ extern void set_object_position(struct MapObj * mo, struct yx_uint16 pos); diff --git a/src/misc.h b/src/misc.h index 7e106fe..fad27f6 100644 --- a/src/misc.h +++ b/src/misc.h @@ -23,59 +23,43 @@ extern char * trouble_msg(char * parent, char * child); extern void * try_malloc(size_t size, char * f); extern void * try_calloc(size_t nmemb, size_t size, char * f); - - /* Check if tempfile "path" exists, and if so, exit with explanation that. */ extern void check_tempfile(char * path); /* If one and only one of files at "p1", "p2" exists, fail with explanation. */ extern void check_files_xor(char * p1, char * p2); - - /* Save / load / unload (free) / reload interface configuration data. */ extern void save_interface_conf(); extern void load_interface_conf(); extern void unload_interface_conf(); extern void reload_interface_conf(); - - /* Update game log by appending "text", or by appending a "." if "text" is the * same as the last one passed. */ extern void update_log(char * text); - - /* Return the offset necessary to center a map of "mapsize" on position "pos" in * a frame of "framesize. */ extern uint16_t center_offset(uint16_t pos, uint16_t mapsize, uint16_t framesize); - - /* Record last player "action" in game record file "record, increment the game * turn and trigger enemy movement. */ extern void turn_over(char action); - - /* Save or load current game data to / from file "savefile". */ extern void save_game(); extern void load_game(); - - /* Return a random position on the map "map" that is passable (as determined by * is_passable(). */ extern struct yx_uint16 find_passable_pos(struct Map * map); - - /* Navigate (as far as possible) up (dir=='u') or (else) down in player's * inventory selection. */ diff --git a/src/readwrite.h b/src/readwrite.h index 2810820..01a6f38 100644 --- a/src/readwrite.h +++ b/src/readwrite.h @@ -19,16 +19,12 @@ extern void try_fclose(FILE * file, char * f); extern void try_fwrite(void * ptr, size_t size, size_t nmemb, FILE * stream, char * f); - - /* Wrapper to calling fgets() from function called "f". The return code of * fgets() is returned unless it is NULL *and* ferror() indicates that an error * occured; otherwise end of file is assumed and NULL is returned properly. */ extern char * try_fgets(char * line, int size, FILE * file, char * f); - - /* Wrapper to successive call of fclose() from function called "f" on "file", * then unlink() on file at "p2" if it exists, then rename() on "p1" to "p2". * Used for handling atomic saving of files via temp files. @@ -36,16 +32,12 @@ extern char * try_fgets(char * line, int size, FILE * file, char * f); extern void try_fclose_unlink_rename(FILE * file, char * p1, char * p2, char * f); - - /* Wrapper: Call textfile_sizes() from function called "f" to get max line * length of "file", exit via exit_err() with trouble_msg()-generated error * message on failure. */ extern uint16_t get_linemax(FILE * file, char * f); - - /* Learn from "file" the largest line length (pointed to by "linemax_p"; length * includes newline chars) and (pointed to by "n_lines_p" if it is not set to * NULL) the number of lines (= number of newline chars). @@ -56,8 +48,6 @@ extern uint16_t get_linemax(FILE * file, char * f); extern uint8_t textfile_sizes(FILE * file, uint16_t * linemax_p, uint16_t * n_lines_p); - - /* These routines for reading values "x" from / writing values to "file" ensure * a defined endianness and consistent error codes: return 0 on success and 1 on * fgetc()/fputc() failure. diff --git a/src/rexit.h b/src/rexit.h index 3ccd470..47a9993 100644 --- a/src/rexit.h +++ b/src/rexit.h @@ -35,8 +35,6 @@ extern void set_cleanup_flag(enum cleanup_flag flag); /* Exit orderly, clean up. */ extern void exit_game(); - - /* If "err" == 0, do nothing. Else, clean up and exit with an error message that * consists, first, of "msg" or (if "msg" is a NULL pointer) a generic "Details * unknown", secondly of "err" as the "internal error code", and thirdly of diff --git a/src/rrand.h b/src/rrand.h index 47f561f..056be9b 100644 --- a/src/rrand.h +++ b/src/rrand.h @@ -15,8 +15,6 @@ /* Return 16-bit number pseudo-randomly generated. */ extern uint16_t rrand(); - - /* Set seed that rrand() starts from. */ extern void rrand_seed(uint32_t new_seed); diff --git a/src/wincontrol.c b/src/wincontrol.c index 7933d48..f6e0d29 100644 --- a/src/wincontrol.c +++ b/src/wincontrol.c @@ -33,8 +33,6 @@ /* Return string "prefix" + "id"; malloc()'s string, remember to call free()! */ static char * string_prefixed_id(char * prefix, char id); - - /* Create Winconf, init ->view/height_type/width_type to 0, ->id to "id". */ static void create_winconf(char id, struct WinConf * wcp); @@ -50,15 +48,11 @@ static void save_win_config(char id); /* Free data pointed to inside WinConf struct. */ static void free_winconf_data(char id); - - /* Write geometry of a window to its WinConf, as positive or negative values * (dependent on state ofWinConf->height_type / WinConf->width_type). */ static void set_winconf_geometry(char id); - - /* Get WinConf by "id"; get id of WinConf mothering "win". */ static struct WinConf * get_winconf_by_id(char id); diff --git a/src/wincontrol.h b/src/wincontrol.h index b75b0e7..9807b62 100644 --- a/src/wincontrol.h +++ b/src/wincontrol.h @@ -42,15 +42,11 @@ struct WinConf extern struct WinConf * get_winconf_by_win(struct Win * win); extern struct Win * get_win_by_id(char id); - - /* Create/initialize (from config files)/free Winconf structs. */ extern void init_winconfs(); extern void free_winconfs(); extern void init_wins(); - - /* Toggle windows in world.wins in the order desribed by the first line of * config/windows/toggle_order_and_active, wherein each character should * correspond to one window whose ID is found in world.winconf_ids. Unknown @@ -60,42 +56,30 @@ extern void init_wins(); */ extern void sorted_wintoggle_and_activate(); - - /* Save all window's configurations to their configuration files. */ extern void save_win_configs(); - - /* Toggle "window configuration" view for active window. This also sets sensible * values for Win->center for the various configuration views (y=0, x=0 for * winconf_geometry and x= for winconf_keys). */ extern void toggle_winconfig(); - - /* Toggle interpretation type for active Win's width/height in WinConf. Width * only toggles to 1 if terminal window is at least as wide as WinConf->width. */ extern void toggle_win_height_type(); extern void toggle_win_width_type(); - - /* Toggle display of a window identified by "id". */ extern void toggle_window(char id); - - /* Try to scroll virtual screen left ("dir" = "-") or right ("dir" = "+"), * subject to the limitations provided by the window manager via * reset_pad_offset(). */ extern void scroll_pad(char dir); - - /* Try to grow or shrink the active window horizontally ("change" = "*"/"_") or * vertically ("change = "+"/"-") by one cell size, subject to the limitations * provided by the window manager via resize_active_win(). diff --git a/src/windows.c b/src/windows.c index c87b6ce..f71be65 100644 --- a/src/windows.c +++ b/src/windows.c @@ -20,16 +20,12 @@ */ static void refit_pad(); - - /* Update geometry (sizes, positions) of window "w" and its successors in the * window chain. For the positioning algorithm place_win() is used. */ static void update_wins(struct Win * w); static void place_win(struct Win * w); - - /* Draw scroll hint (a line saying that there are "dist" more elements of * "unit" further into the direction symbolized by the "dir" char) into virtual * screen pad, onto an appropriate edge of either a window or the screen; the @@ -43,13 +39,9 @@ static void scroll_hint(struct yx_uint16 fsize, char dir, uint16_t dist, static void winscroll_hint(struct Win * w, char dir, uint16_t dist); static void padscroll_hint(char dir, uint16_t dist); - - /* Draw contents of all windows in window chain from window "w" onwards. */ static void draw_wins(struct Win * w); - - /* draw_win_borderlines() draws the vertical and horizontal borders of window * "w" sans corners into the virtual screen "pad", and draws the top border * line as the windows' title bar (highlighted if the window is described @@ -67,8 +59,6 @@ static void draw_wins_borderlines(struct Win * w, struct Win * w_active, WINDOW * pad); static void draw_wins_bordercorners(struct Win * w, WINDOW * pad); - - /* Shift active window forwards / backwards in window chain. */ static void shift_win_forward(); static void shift_win_backward(); diff --git a/src/windows.h b/src/windows.h index ab3cace..4b62233 100644 --- a/src/windows.h +++ b/src/windows.h @@ -97,14 +97,10 @@ extern void init_win_meta(WINDOW * screen); extern void init_win(struct Win ** wp, char * title, int16_t height, int16_t width, void * func); - - /* Free allocated memory for an initialized Win / WinMeta structs. */ extern void free_winmeta(); extern void free_win(struct Win * win); - - /* Append/suspend window "w" to/from chain of visible windows below "wmeta". * Appended windows will become active. Suspended active windows will move the * active window selection to their successor in the window chain or, failing @@ -113,8 +109,6 @@ extern void free_win(struct Win * win); extern void append_win(struct Win * w); extern void suspend_win(struct Win * w); - - /* Apply scrolling offset "new_offset" to virtual screen if it is sane, i.e. * it's equal/greater zero and does not push the view (further) beyond the * virtual screen's border. If the view is already beyond the virtual screen's @@ -123,8 +117,6 @@ extern void suspend_win(struct Win * w); */ extern void reset_pad_offset(uint16_t new_offset); - - /* Apply new size "size" to the active window, but only if it provides for at * least one cell width/height and is in height at least one cell smaller than * the screen's vertical height (to provide space for the title bar). Does @@ -132,24 +124,18 @@ extern void reset_pad_offset(uint16_t new_offset); */ extern void resize_active_win(struct yx_uint16 size); - - /* Cycle active window selection forwards ("dir" == "f") or backwards (any * other "dir"). Wrap around in the windows chain if start / end of it is met. * Does nothing if no window is active. */ extern void cycle_active_win(char dir); - - /* Move active window forwards ("dir" == "f") or backwards (any other "dir"). * Wrap around in the window chain if start / end of it is met. Does nothing if * no window is active. */ extern void shift_active_win(char dir); - - /* Draw virtual screen including all windows. Also add scroll hints for where * the edges of the terminal screen hit non-edges of and inside the virtual * screen. Then update the terminal screen. diff --git a/src/yx_uint16.h b/src/yx_uint16.h index 7e3d13b..188e553 100644 --- a/src/yx_uint16.h +++ b/src/yx_uint16.h @@ -23,8 +23,6 @@ struct yx_uint16 /* Return 1 if two yx_uint16 coordinates at "a" and "b" are equal, else 0. */ extern uint8_t yx_uint16_cmp(struct yx_uint16 * a, struct yx_uint16 * b); - - /* Return yx_uint16 coordinate one step from coordinate yx in direction "dir" * (east: 'E', west: 'W', north: 'N', south: 'S'). *