|
Crossfire Server
1.75.0
|
Global type definitions and header inclusions. More...
#include "autoconf.h"#include <sys/socket.h>#include <inttypes.h>#include <stdbool.h>#include <stdio.h>#include <unistd.h>#include "compat.h"#include <time.h>#include <vector>#include <stdarg.h>#include <algorithm>#include <functional>#include <string>#include "sstring.h"#include "config.h"#include "define.h"#include "logger.h"#include "shared/newclient.h"#include "face.h"#include "attack.h"#include "material.h"#include "living.h"#include "object.h"#include "map.h"#include "tod.h"#include "skills.h"#include "account_char.h"#include "newserver.h"#include "party.h"#include "player.h"#include "treasure.h"#include "commands.h"#include "book.h"#include "ob_methods.h"#include "ob_types.h"#include "artifact.h"#include "god.h"#include "recipe.h"#include "spells.h"#include "stringbuffer.h"#include "libproto.h"#include "sockproto.h"#include "typesproto.h"#include "events.h"Go to the source code of this file.
Data Structures | |
| struct | linked_char |
| struct | Settings |
| Server settings. More... | |
| struct | Statistics |
| This is used for various performance tracking statistics, or just how often certain events are done. More... | |
Macros | |
| #define | dirent direct |
| #define | EXTERN extern |
| Define external variables. More... | |
| #define | FREE_AND_CLEAR(xyz) { free(xyz); xyz = NULL; } |
| Free the pointer and then set it to NULL. More... | |
| #define | FREE_AND_CLEAR_STR(xyz) { free_string(xyz); xyz = NULL; } |
| Release the shared string, and set it to NULL. More... | |
| #define | FREE_AND_CLEAR_STR_IF(xyz) { if (xyz) { free_string(xyz); xyz = NULL; } } |
| #define | FREE_AND_COPY(sv, nv) { if (sv) free_string(sv); sv = add_string(nv); } |
| Release the shared string if not NULL, and make it a reference to nv. More... | |
| #define | FREE_AND_COPY_IF(sv, nv) { if (sv) free_string(sv); sv = nv ? add_string(nv) : NULL; } |
| #define | GET_ANIM(ob) (ob->temp_animation ? ob->temp_animation : ob->animation) |
| #define | GET_ANIM_ID(ob) (ob->temp_animation ? ob->temp_animation->num : (ob->animation ? ob->animation->num : 0)) |
| #define | GET_ANIMATION(ob, anim) ((ob->temp_animation ? ob->temp_animation : ob->animation)->faces[anim]) |
| #define | MAX_TOTAL_EXPERIENCE (settings.permanent_exp_ratio ? (MAX_EXPERIENCE * 100 / settings.permanent_exp_ratio) : 0) |
| #define | NAMLEN(dirent) (dirent)->d_namlen |
| #define | NUM_ANIMATIONS(ob) ((ob->temp_animation ? ob->temp_animation : ob->animation)->num_animations) |
| #define | NUM_FACINGS(ob) ((ob->temp_animation ? ob->temp_animation : ob->animation)->facings) |
| #define | PERM_EXP(exptotal) (exptotal * settings.permanent_exp_ratio / 100 ) |
| Convert saved total experience into permanent experience. More... | |
| #define | PRINTF_ARGS(x, y) __attribute__ ((format (printf, x, y))) |
| Used for printf-like functions, mostly LOG and draw_ext_info_format. More... | |
| #define | PROFILE_BEGIN(expr) |
| #define | PROFILE_END(var, expr) |
| #define | ROTATE_RIGHT(c) if ((c)&01) (c) = ((c)>>1)+0x80000000; else (c) >>= 1; |
| #define | SCRIPT_FIX_ACTIVATOR 2 |
| #define | SCRIPT_FIX_ALL 1 |
| #define | SCRIPT_FIX_NOTHING 0 |
| #define | SET_ANIMATION(ob, newanim) { ob->face = (ob->temp_animation ? ob->temp_animation : ob->animation)->faces[newanim]; } |
| #define | SPELL_MAPPINGS 206 |
Typedefs | |
| typedef std::function< void(enum fatal_error err)> | fatalHook |
| typedef void * | language_t |
| Strings that should be manipulated through add_string() and free_string(). More... | |
| typedef std::function< void(LogLevel, const char *, va_list)> | logHook |
Variables | |
| EXTERN std::vector< region * > | all_regions |
| All regions. More... | |
| const Face * | blank_face |
| Following can just as easily be pointers, but it is easier to keep them like this. More... | |
| EXTERN sstring | blocks_prayer |
| For update_position() mostly. More... | |
| EXTERN archetype * | empty_archetype |
| Nice to have fast access to it. More... | |
| const Face * | empty_face |
| EXTERN int | exiting |
| True if the game is about to exit. More... | |
| EXTERN artifactlist * | first_artifactlist |
| First artifact. More... | |
| EXTERN mapstruct * | first_map |
| First map. More... | |
| EXTERN char | first_map_ext_path [MAX_BUF] |
| Path used for per-race start maps. More... | |
| EXTERN char | first_map_path [MAX_BUF] |
| The start-level. More... | |
| EXTERN player * | first_player |
| First player. More... | |
| short | freearr_x [SIZEOFFREE] |
| X offset when searching around a spot. More... | |
| short | freearr_y [SIZEOFFREE] |
| Y offset when searching around a spot. More... | |
| int | freedir [SIZEOFFREE] |
| Direction we're pointing on this spot. More... | |
| socket_struct * | init_sockets |
| Established connections for clients not yet playing. More... | |
| EXTERN FILE * | logfile |
| Used by server/daemon.c. More... | |
| int | maxfree [SIZEOFFREE] |
| Number of spots around a location, including that location (except for 0) More... | |
| EXTERN long | nrofallowedstr |
| Only used in malloc_info(). More... | |
| EXTERN long | nrofartifacts |
| Only used in malloc_info(). More... | |
| EXTERN long | nroferrors |
| If it exceeds MAX_ERRORS, call fatal() More... | |
| EXTERN long | ob_count |
| uint32_t | pticks |
| Used by various function to determine how often to save the character. More... | |
| int | reopen_logfile |
| Settings | settings |
| Global settings. More... | |
| const Face * | smooth_face |
| const char *const | spell_mapping [SPELL_MAPPINGS] |
| This table is only necessary to convert objects that existed before the spell object conversion to the new object. More... | |
| Statistics | statistics |
| Merged spell statistics. More... | |
| uint32_t | tick_duration |
| Gloabal variables: More... | |
| EXTERN long | trying_emergency_save |
| True when emergency_save() is reached. More... | |
| EXTERN const char * | undead_name |
| Used in hit_player() in main.c. More... | |
Global type definitions and header inclusions.
Definition in file global.h.
| #define dirent direct |
Definition at line 215 of file global.h.
Referenced by AssetCollector::collect(), command_players(), find_maps(), getEventFiles(), help_topics(), i18n_init(), initPlugins(), load_dir(), and remove_directory().
| #define EXTERN extern |
| #define FREE_AND_CLEAR | ( | xyz | ) | { free(xyz); xyz = NULL; } |
Free the pointer and then set it to NULL.
This is generally done as a safety, and having this macro makes the code a bit cleaner when doing so.
Definition at line 195 of file global.h.
Referenced by check_all_fds(), clear_player(), free_experience(), free_globals(), free_map(), free_newsocket(), include_map_in_map(), init_connection(), metaserver2_init(), object_copy_no_speed(), object_free(), and object_merge_spell().
| #define FREE_AND_CLEAR_STR | ( | xyz | ) | { free_string(xyz); xyz = NULL; } |
Release the shared string, and set it to NULL.
Must not be NULL.
Definition at line 200 of file global.h.
Referenced by cast_invisible(), clear_player(), command_follow(), do_follow(), explode_bullet(), fix_stopped_arrow(), free_globals(), key_confirm_quit(), make_visible(), move_creator(), object_clear(), object_free(), object_free_key_values(), object_set_value_s(), pets_summon_golem(), place_fountain_with_specials(), receive_play_again(), and set_spell_skill().
| #define FREE_AND_CLEAR_STR_IF | ( | xyz | ) | { if (xyz) { free_string(xyz); xyz = NULL; } } |
Definition at line 202 of file global.h.
Referenced by asset_destroy(), command_reset(), delete_map(), object_free(), quest_clear(), and quest_destroy_step().
| #define FREE_AND_COPY | ( | sv, | |
| nv | |||
| ) | { if (sv) free_string(sv); sv = add_string(nv); } |
Release the shared string if not NULL, and make it a reference to nv.
Definition at line 206 of file global.h.
Referenced by cast_create_town_portal(), cast_detection(), cfapi_object_set_property(), change_treasure(), create_player_cmd(), do_symptoms(), fix_flesh_item(), fix_generated_item(), kill_player_not_permadeath(), kill_player_permadeath(), mimic_type_apply(), move_creator(), move_symptom(), msgfile_msg(), object_give_identified_properties(), place_fountain_with_specials(), prepare_weapon(), receive_player_name(), tailor_god_spell(), use_oratory(), and wrong_password().
| #define FREE_AND_COPY_IF | ( | sv, | |
| nv | |||
| ) | { if (sv) free_string(sv); sv = nv ? add_string(nv) : NULL; } |
Definition at line 208 of file global.h.
Referenced by load_materials(), and Messages::replace().
| #define GET_ANIM | ( | ob | ) | (ob->temp_animation ? ob->temp_animation : ob->animation) |
Definition at line 166 of file global.h.
Referenced by apply_changes_to_player().
| #define GET_ANIM_ID | ( | ob | ) | (ob->temp_animation ? ob->temp_animation->num : (ob->animation ? ob->animation->num : 0)) |
Definition at line 167 of file global.h.
Referenced by common_process_projectile(), do_throw(), fix_generated_item(), and tear_down_wall().
| #define GET_ANIMATION | ( | ob, | |
| anim | |||
| ) | ((ob->temp_animation ? ob->temp_animation : ob->animation)->faces[anim]) |
Definition at line 165 of file global.h.
Referenced by trap_show().
| #define MAX_TOTAL_EXPERIENCE (settings.permanent_exp_ratio ? (MAX_EXPERIENCE * 100 / settings.permanent_exp_ratio) : 0) |
Definition at line 216 of file global.h.
Referenced by help_topics().
| #define NUM_ANIMATIONS | ( | ob | ) | ((ob->temp_animation ? ob->temp_animation : ob->animation)->num_animations) |
Definition at line 173 of file global.h.
Referenced by animate_bomb(), animate_object(), animate_trigger(), animate_turning(), check_trigger(), do_throw(), fix_generated_item(), gate_type_process(), map2_add_ob(), move_hole(), ready_map_name(), tear_down_wall(), and trigger_type_process().
| #define NUM_FACINGS | ( | ob | ) | ((ob->temp_animation ? ob->temp_animation : ob->animation)->facings) |
Definition at line 174 of file global.h.
Referenced by animate_object(), and ready_map_name().
| #define PERM_EXP | ( | exptotal | ) | (exptotal * settings.permanent_exp_ratio / 100 ) |
Convert saved total experience into permanent experience.
Definition at line 232 of file global.h.
Referenced by cfapi_object_perm_exp(), check_exp_loss(), and show_skills().
| #define PRINTF_ARGS | ( | x, | |
| y | |||
| ) | __attribute__ ((format (printf, x, y))) |
| #define PROFILE_BEGIN | ( | expr | ) |
Definition at line 364 of file global.h.
Referenced by check_login(), hiscore_check(), load_objects(), mapfile_load(), save_map(), save_objects(), save_player(), and server_main().
| #define PROFILE_END | ( | var, | |
| expr | |||
| ) |
Definition at line 369 of file global.h.
Referenced by check_login(), hiscore_check(), load_objects(), mapfile_load(), save_map(), save_objects(), save_player(), and server_main().
Definition at line 162 of file global.h.
Referenced by Faces::added(), and PngLoader::load().
| #define SET_ANIMATION | ( | ob, | |
| newanim | |||
| ) | { ob->face = (ob->temp_animation ? ob->temp_animation : ob->animation)->faces[newanim]; } |
Definition at line 164 of file global.h.
Referenced by animate_object(), animate_trigger(), animate_turning(), apply_race_and_class(), cf_handle_type_apply(), cfapi_object_set_property(), check_trigger(), fix_generated_item(), gate_type_process(), key_change_class(), key_roll_stat(), shuffle_attack(), tear_down_wall(), trapdoor_type_move_on(), trigger_connected(), trigger_type_process(), and update_button().
| typedef std::function<void(enum fatal_error err)> fatalHook |
| typedef void* language_t |
Strings that should be manipulated through add_string() and free_string().
| const Face* blank_face |
Following can just as easily be pointers, but it is easier to keep them like this.
Definition at line 36 of file image.cpp.
Referenced by add_abilities(), AllAnimations::added(), animate_object(), artifact_get_face(), Faces::Faces(), knowledge_monster_face(), magic_mapping_mark(), magic_mapping_mark_recursive(), object_clear(), recipe_get_face(), AllAnimations::replace(), tear_down_wall(), and update_position().
For update_position() mostly.
| const Face * empty_face |
Definition at line 36 of file image.cpp.
Referenced by esrv_draw_look(), esrv_send_inventory(), and Faces::Faces().
| short freearr_x[SIZEOFFREE] |
X offset when searching around a spot.
Definition at line 299 of file object.cpp.
Referenced by animate_bomb(), animate_weapon(), apply_builder_floor(), apply_builder_remove(), apply_map_builder(), attempt_jump(), can_see_monsterP(), cast_cause_disease(), cast_cone(), cast_create_obj(), cast_light(), cast_polymorph(), cast_raise_dead_spell(), cast_spell(), cast_transfer(), cfapi_object_insert(), command_summon(), command_teleport(), common_process_projectile(), counterspell(), create_bomb(), dimension_door(), dispel_rune(), do_follow(), do_harvest(), do_skill_ident(), do_throw(), enter_map(), expand_sight(), explosion(), find_closest_monster(), find_doors_in_room_recursive(), find_enclosed_spot(), find_monster_in_room_recursive(), find_spot_in_room_recursive(), find_target_for_friendly_spell(), find_traps(), fix_summon_pet(), forklightning(), gate_type_process(), get_pointed_target(), hideability(), hit_map(), keyplace(), magic_wall(), mimic_type_apply(), monster_communicate(), monster_compute_path(), monster_find_nearest_enemy(), monster_use_bow(), move_ball_spell(), move_bolt(), move_cone(), move_ob(), move_player_attack(), move_player_mover(), move_swarm_spell(), object_find_first_free_spot(), object_find_free_spot(), object_insert_to_free_spot_or_free(), path_to_player(), pets_follow_owner(), pets_get_enemy(), pets_move(), pets_summon_golem(), pets_summon_object(), pick_arrow_target(), pick_lock(), place_chest(), place_exits(), place_fountain_with_specials(), place_monsters(), place_special_exit(), player_fire_bow(), polymorph_living(), probe(), push_ob(), put_a_monster(), remove_adjacent_doors(), remove_door(), remove_locked_door(), remove_trap(), roll_ob(), shop_mat_type_move_on(), singing(), skill_attack(), spell_find_dir(), stand_near_hostile(), steal(), surround_by_doors(), teleport(), transfer_ob(), turn_one_transport(), use_oratory(), and write_rune().
| short freearr_y[SIZEOFFREE] |
Y offset when searching around a spot.
Definition at line 305 of file object.cpp.
Referenced by animate_weapon(), apply_builder_floor(), apply_builder_remove(), apply_map_builder(), attempt_jump(), can_see_monsterP(), cast_cause_disease(), cast_cone(), cast_create_obj(), cast_light(), cast_polymorph(), cast_raise_dead_spell(), cast_spell(), cast_transfer(), cfapi_object_insert(), command_summon(), command_teleport(), common_process_projectile(), counterspell(), create_bomb(), dimension_door(), dispel_rune(), do_follow(), do_harvest(), do_skill_ident(), do_throw(), enter_map(), expand_sight(), explosion(), find_closest_monster(), find_doors_in_room_recursive(), find_enclosed_spot(), find_monster_in_room_recursive(), find_spot_in_room_recursive(), find_target_for_friendly_spell(), find_traps(), fix_summon_pet(), forklightning(), gate_type_process(), get_pointed_target(), hideability(), hit_map(), keyplace(), magic_wall(), mimic_type_apply(), monster_communicate(), monster_compute_path(), monster_find_nearest_enemy(), monster_use_bow(), move_ball_spell(), move_bolt(), move_cone(), move_ob(), move_player_attack(), move_player_mover(), move_swarm_spell(), object_find_first_free_spot(), object_find_free_spot(), object_insert_to_free_spot_or_free(), path_to_player(), pets_follow_owner(), pets_get_enemy(), pets_move(), pets_summon_golem(), pets_summon_object(), pick_arrow_target(), pick_lock(), place_chest(), place_exits(), place_fountain_with_specials(), place_monsters(), place_special_exit(), player_fire_bow(), polymorph_living(), probe(), push_ob(), put_a_monster(), remove_adjacent_doors(), remove_door(), remove_locked_door(), remove_trap(), roll_ob(), shop_mat_type_move_on(), singing(), skill_attack(), spell_find_dir(), stand_near_hostile(), steal(), surround_by_doors(), teleport(), transfer_ob(), turn_one_transport(), use_oratory(), and write_rune().
| int freedir[SIZEOFFREE] |
Direction we're pointing on this spot.
Definition at line 317 of file object.cpp.
Referenced by pets_summon_object(), and spell_find_dir().
| socket_struct* init_sockets |
Established connections for clients not yet playing.
See the page on the login process for a description of its use. Socket at index 0 is the socket listening for connections, and must not be freed. If this socket becomes invalid, then the server will try to reopen it. We also take the opportunity to set TCP_NODELAY - this forces the data in the socket to be flushed sooner to the client - otherwise, the OS tries to wait for full packets and will this hold sending the data for some amount of time, which thus adds some additional latency.
Definition at line 66 of file init.cpp.
Referenced by check_all_fds(), do_server(), and new_connection().
| int maxfree[SIZEOFFREE] |
Number of spots around a location, including that location (except for 0)
Definition at line 311 of file object.cpp.
Referenced by object_find_free_spot().
| EXTERN long nroferrors |
| uint32_t pticks |
Used by various function to determine how often to save the character.
Used by various function to determine how often to save the character.
Definition at line 47 of file time.cpp.
Referenced by apply_race_and_class(), check_login(), do_specials(), get_tod(), handle_client(), handle_newcs_player(), key_change_class(), monster_stand_in_light(), process_players1(), reset_sleep(), send_tick(), tick_game_time(), and time_info().
| Settings settings |
Global settings.
Definition at line 139 of file init.cpp.
Referenced by account_block_create(), account_char_load_from_file(), account_char_save(), account_new_cmd(), accounts_load(), accounts_save(), add_me_cmd(), add_player_exp(), apply_check_item_power(), apply_check_personalized_blessings(), apply_death_exp_penalty(), apply_race_and_class(), assets_collect(), attack_ob_simple(), attempt_steal(), calc_perm_exp(), calc_skill_exp(), cast_create_town_portal(), cast_spell(), cfapi_system_directory(), change_abil(), check_exp_loss(), check_login(), check_pick(), check_probe(), check_race_and_class(), checkbanned(), checkdm(), clean_tmp_files(), command_abil(), command_addexp(), command_banish(), command_create(), command_debug(), command_help(), command_loadtest(), command_nowiz(), command_patch(), command_players(), command_purge_quest_definitions(), command_search_items(), command_settings(), command_title(), compute_price_variation_with_bargaining(), create_items_path(), create_overlay_pathname(), create_pathname(), create_player_cmd(), create_template_pathname(), crypt_string(), dead_player(), delete_character(), display_motd(), do_item_conversion(), do_symptoms(), do_throw(), dragon_eat_flesh(), dump_experience(), dump_stat_bonuses(), enter_player_maplevel(), enter_player_savebed(), exp_level(), fatal(), find_help_file_in(), find_maps(), find_spot_for_submap(), find_style(), fix_object(), fix_player(), forbid_play(), get_cha_bonus(), get_cleric_chance(), get_con_bonus(), get_dam_bonus(), get_dex_bonus(), get_fear_bonus(), get_grace_bonus(), get_learn_spell(), get_sp_bonus(), get_speed_bonus(), get_thaco_bonus(), get_turn_bonus(), get_weight_limit(), god_enchants_weapon(), help_topics(), hiscore_init(), hit_player(), i18n_init(), improve_armour(), improve_weapon(), init_beforeplay(), init_book_archive(), init_experience(), init_modules(), init_server(), init_startup(), init_stats(), key_change_class(), key_confirm_quit(), kill_object(), kill_player(), kill_player_not_permadeath(), kill_player_permadeath(), knowledge_read_player_data(), knowledge_write_player_data(), level_exp(), list_players(), load_assets(), load_settings(), load_table(), LOG(), main(), map_path(), map_remove_unique_files(), metaserver2_init(), object_clear(), pay_for_item(), pick_up_object(), player_lvl_adj(), plugins_init_plugin(), process_events(), process_players1(), quest_read_player_data(), quest_write_player_data(), rangetostring(), read_map_log(), ready_map_name(), resurrect_player(), roll_stats(), save_map(), save_player(), scroll_failure(), scroll_type_apply(), send_exp_table(), send_file(), send_new_char_info(), send_news(), send_rules(), Send_With_Handling(), set_abs_magic(), set_confdir(), set_csport(), set_datadir(), set_debug(), set_dumpmon1(), set_dumpmon2(), set_dumpmon3(), set_dumpmon4(), set_dumpmon5(), set_dumpmon6(), set_dumpmon7(), set_dumpmon8(), set_dumpmon9(), set_dumpmont(), set_ignore_assets_errors(), set_localdir(), set_logfile(), set_mapdir(), set_mondebug(), set_playerdir(), set_regions(), set_templatedir(), set_tmpdir(), set_uniquedir(), show_skills(), SP_level_spellpoint_cost(), spell_failure(), spellbook_type_apply(), swap_map(), unset_debug(), verify_player(), write_book_archive(), write_map_log(), and write_scroll().
| const Face* smooth_face |
Definition at line 36 of file image.cpp.
Referenced by Faces::Faces(), and send_smooth().
| Statistics statistics |
Merged spell statistics.
Definition at line 229 of file init.cpp.
Referenced by init_globals(), object_merge_spell(), and ok_to_put_more().
| uint32_t tick_duration |
Gloabal variables:
Definition at line 35 of file time.cpp.
Referenced by command_speed(), command_statistics(), get_sleep_remaining(), set_tick_duration(), tick_game_time(), tick_length(), ticks_to_seconds(), and time_info().
| EXTERN long trying_emergency_save |
True when emergency_save() is reached.
| EXTERN const char* undead_name |
Used in hit_player() in main.c.