![]() |
Crossfire Server, Trunk
1.75.0
|
#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 <dirent.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 | 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) strlen((dirent)->d_name) |
#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] |
int | freedir [SIZEOFFREE] |
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... | |
const EXTERN char * | undead_name |
Global type definitions and header inclusions.
Definition in file global.h.
#define EXTERN extern |
#define FREE_AND_CLEAR | ( | xyz | ) | { free(xyz); xyz = NULL; } |
#define FREE_AND_CLEAR_STR | ( | xyz | ) | { free_string(xyz); xyz = NULL; } |
#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); } |
#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 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 ) |
#define PRINTF_ARGS | ( | x, | |
y | |||
) | __attribute__ ((format (printf, x, y))) |
#define PROFILE_BEGIN | ( | expr | ) |
#define PROFILE_END | ( | var, | |
expr | |||
) |
#define SET_ANIMATION | ( | ob, | |
newanim | |||
) | { ob->face = (ob->temp_animation ? ob->temp_animation : ob->animation)->faces[newanim]; } |
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.
EXTERN artifactlist* first_artifactlist |
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] |
int freedir[SIZEOFFREE] |
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(), free_all_newserver(), init_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 nrofallowedstr |
Only used in malloc_info().
EXTERN long nrofartifacts |
Only used in malloc_info().
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_newcs_player(), key_change_class(), monster_stand_in_light(), process_players1(), reset_sleep(), send_tick(), tick_game_time(), and time_info().
int reopen_logfile |
Definition at line 27 of file logger.cpp.
Referenced by LOG(), and rec_sighup().
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(), free_globals(), 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_clocks(), init_emergency_mappath(), init_environ(), init_experience(), init_globals(), init_library(), 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(), random_house_generator_init(), 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(), 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(), while(), write_book_archive(), write_map_log(), write_scroll(), and write_todclock().
const Face* smooth_face |
Definition at line 36 of file image.cpp.
Referenced by Faces::Faces(), and send_smooth().
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.
It was not practical to go through every mapping looking for every potion, rod, wand, etc that had a sp set and update to the new value. So this maps the old spell numbers to the name of the new archs. If you are adding a new spell, you should not modify this - your new spell won't have been used, and thus won't have any legacy object. NULL entries in this table are valid - to denote objects that should not be updated for whatever reason.
Definition at line 74 of file object.cpp.
Referenced by fix_generated_item().
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.