Crossfire Server, Trunk  R20513
Data Structures | Macros | Typedefs | Variables
global.h File Reference

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 "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 "race.h"
#include "recipe.h"
#include "spells.h"
#include "stringbuffer.h"
#include "libproto.h"
#include "sockproto.h"
#include "typesproto.h"
#include "plugin.h"
Include dependency graph for global.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_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 GET_ANIM_ID(ob)   (ob->temp_animation_id ? ob->temp_animation_id : ob->animation_id)
 
#define GET_ANIMATION(ob, anim)   (ob->temp_animation_id ? animations[ob->temp_animation_id].faces[anim] : animations[ob->animation_id].faces[anim])
 
#define NAMLEN(dirent)   (dirent)->d_namlen
 
#define NUM_ANIMATIONS(ob)   (ob->temp_animation_id ? animations[ob->temp_animation_id].num_animations : animations[ob->animation_id].num_animations)
 
#define NUM_FACINGS(ob)   (ob->temp_animation_id ? animations[ob->temp_animation_id].facings : animations[ob->animation_id].facings)
 
#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)   { if (ob->temp_animation_id) { ob->face = animations[ob->temp_animation_id].faces[newanim]; } else { ob->face = animations[ob->animation_id].faces[newanim]; } }
 

Typedefs

typedef struct linked_char linked_char
 
typedef struct Settings Settings
 Server settings. More...
 
typedef const char * sstring
 Strings that should be manipulated through add_string() and free_string(). More...
 
typedef struct Statistics Statistics
 This is used for various performance tracking statistics, or just how often certain events are done. More...
 

Variables

EXTERN archetypeamulet_arch
 
EXTERN Animationsanimations
 
EXTERN int animations_allocated
 
New_Faceblank_face
 Following can just as easily be pointers, but it is easier to keep them like this. More...
 
EXTERN int bmaps_checksum
 
EXTERN archetypecrown_arch
 
EXTERN archetypeempty_archetype
 Nice to have fast access to it. More...
 
New_Faceempty_face
 
EXTERN int exiting
 True if the game is about to exit. More...
 
EXTERN archetypefirst_archetype
 First archetype. More...
 
EXTERN artifactlistfirst_artifactlist
 First artifact. More...
 
EXTERN objectlinkfirst_friendly_object
 Objects monsters will go after. More...
 
EXTERN godlinkfirst_god
 God list. More...
 
EXTERN mapstructfirst_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 playerfirst_player
 First player. More...
 
EXTERN racelinkfirst_race
 Race list. More...
 
EXTERN regionfirst_region
 First region. More...
 
EXTERN treasurelistfirst_treasurelist
 First treasure. 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...
 
EXTERN long init_done
 Ignores signals until init_done is true. More...
 
socket_structinit_sockets
 Established connections for clients not yet playing. More...
 
int leftof_x [9]
 
int leftof_y [9]
 
EXTERN FILE * logfile
 Used by server/daemon.c. More...
 
EXTERN archetypemap_archeytpe
 
uint32_t max_time
 Gloabal variables: More...
 
int maxfree [SIZEOFFREE]
 Number of spots around a location, including that location (except for 0) More...
 
New_Facenew_faces
 Contains face information, with names, numbers, magicmap color and such. 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 nroftreasures
 Only used in malloc_info(). More...
 
EXTERN int num_animations
 
EXTERN long ob_count
 
uint32_t pticks
 Used by various function to determine how often to save the character. More...
 
int reopen_logfile
 
int rightof_x [9]
 
int rightof_y [9]
 
EXTERN archetypering_arch
 
Settings settings
 Server settings. More...
 
New_Facesmooth_face
 
EXTERN archetypestaff_arch
 
Statistics statistics
 Merged spell statistics. More...
 
EXTERN long trying_emergency_save
 True when emergency_save() is reached. More...
 
EXTERN const char * undead_name
 
EXTERN long warn_archetypes
 If true, write warnings when failing to find archetypes when loading from file. More...
 

Detailed Description

Global type definitions and header inclusions.

Definition in file global.h.

Macro Definition Documentation

#define dirent   direct

Definition at line 220 of file global.h.

#define EXTERN   extern

Define external variables.

This is used in an ugly hack where EXTERN is re-defined to "" in 'init.c' in order to resolve missing symbols. Do not use this macro in new code.

Definition at line 15 of file global.h.

#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 203 of file global.h.

Referenced by free_experience(), free_globals(), free_map(), free_newsocket(), include_map_in_map(), init_stats(), metaserver2_init(), object_clear(), object_copy(), object_free2(), and object_merge_spell().

#define FREE_AND_CLEAR_STR (   xyz)    { free_string(xyz); xyz = NULL; }
#define FREE_AND_COPY (   sv,
  nv 
)    { if (sv) free_string(sv); sv = add_string(nv); }
#define GET_ANIM_ID (   ob)    (ob->temp_animation_id ? ob->temp_animation_id : ob->animation_id)
#define GET_ANIMATION (   ob,
  anim 
)    (ob->temp_animation_id ? animations[ob->temp_animation_id].faces[anim] : animations[ob->animation_id].faces[anim])

Definition at line 172 of file global.h.

Referenced by trap_show().

#define NAMLEN (   dirent)    (dirent)->d_namlen

Definition at line 221 of file global.h.

Referenced by help_topics().

#define NUM_ANIMATIONS (   ob)    (ob->temp_animation_id ? animations[ob->temp_animation_id].num_animations : animations[ob->animation_id].num_animations)
#define NUM_FACINGS (   ob)    (ob->temp_animation_id ? animations[ob->temp_animation_id].facings : animations[ob->animation_id].facings)

Definition at line 180 of file global.h.

Referenced by animate_object().

#define ROTATE_RIGHT (   c)    if ((c)&01) (c) = ((c)>>1)+0x80000000; else (c) >>= 1;

Definition at line 169 of file global.h.

Referenced by read_bmap_names(), and read_client_images().

#define SCRIPT_FIX_ACTIVATOR   2

Definition at line 360 of file global.h.

Referenced by do_throw().

#define SCRIPT_FIX_ALL   1
#define SCRIPT_FIX_NOTHING   0
#define SET_ANIMATION (   ob,
  newanim 
)    { if (ob->temp_animation_id) { ob->face = animations[ob->temp_animation_id].faces[newanim]; } else { ob->face = animations[ob->animation_id].faces[newanim]; } }

Typedef Documentation

typedef struct linked_char linked_char
typedef struct Settings Settings

Server settings.

typedef const char* sstring

Strings that should be manipulated through add_string() and free_string().

Definition at line 40 of file global.h.

typedef struct Statistics Statistics

This is used for various performance tracking statistics, or just how often certain events are done.

It is much better to use a common structure then variables about. Note that since these are often counters, I'm using uint64s - this may be overkill, but it is just a couple extra bytes. This is initialized/declared in common/init.c. Note that if it only contains integer values, very easy to initialize/clear it - just a memset.

Variable Documentation

EXTERN archetype * amulet_arch

Definition at line 162 of file global.h.

Referenced by fix_generated_item(), init_archetype_pointers(), and init_globals().

EXTERN Animations* animations
EXTERN int animations_allocated

Definition at line 166 of file global.h.

Referenced by init_anim(), and init_globals().

New_Face* blank_face
EXTERN int bmaps_checksum

Definition at line 166 of file global.h.

Referenced by read_bmap_names(), and send_image_info().

EXTERN archetype * crown_arch

Definition at line 162 of file global.h.

Referenced by fix_generated_item(), and init_archetype_pointers().

New_Face * empty_face

Definition at line 39 of file image.c.

Referenced by esrv_draw_look(), and esrv_send_inventory().

short freearr_x[SIZEOFFREE]

X offset when searching around a spot.

Definition at line 65 of file object.c.

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(), CREAnimationControl::CREAnimationControl(), create_bomb(), dimension_door(), dispel_rune(), 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(), map_find_dir(), monster_communicate(), monster_compute_path(), monster_find_nearest_living_creature(), monster_use_bow(), move_aura(), 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(), probe(), process_players1(), 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 71 of file object.c.

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(), CREAnimationControl::CREAnimationControl(), create_bomb(), dimension_door(), dispel_rune(), 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(), map_find_dir(), monster_communicate(), monster_compute_path(), monster_find_nearest_living_creature(), monster_use_bow(), move_aura(), 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(), probe(), process_players1(), 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 83 of file object.c.

Referenced by map_find_dir(), pets_summon_object(), and spell_find_dir().

EXTERN long init_done

Ignores signals until init_done is true.

Definition at line 134 of file global.h.

Referenced by init(), and init_races().

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.

Definition at line 56 of file init.c.

Referenced by account_get_logged_in_init_socket(), block_until_new_connection(), do_server(), and new_connection().

int leftof_x[9]
int leftof_y[9]
uint32_t max_time

Gloabal variables:

Definition at line 35 of file time.c.

Referenced by command_speed(), command_statistics(), set_max_time(), sleep_delta(), tick_length(), and time_info().

int maxfree[SIZEOFFREE]

Number of spots around a location, including that location (except for 0)

Definition at line 77 of file object.c.

Referenced by map_find_dir(), and object_find_free_spot().

New_Face* new_faces
EXTERN long nroferrors

If it exceeds MAX_ERRORS, call fatal()

Definition at line 136 of file global.h.

Referenced by init_defaults(), LOG(), and server_main().

EXTERN int num_animations
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 45 of file time.c.

Referenced by apply_race_and_class(), check_login(), do_specials(), get_tod(), handle_newcs_player(), key_change_class(), log_time(), process_players1(), reset_sleep(), send_tick(), and time_info().

int rightof_x[9]
int rightof_y[9]
EXTERN archetype* ring_arch

Definition at line 162 of file global.h.

Referenced by fix_generated_item(), init_archetype_pointers(), and init_globals().

Settings settings

Server settings.

Definition at line 40 of file init.c.

Referenced by CREFilterDialog::accept(), CREReportDialog::accept(), account_block_create(), account_char_load(), account_char_save(), 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(), attack_ob_simple(), attempt_steal(), block_until_new_connection(), calc_perm_exp(), calc_skill_exp(), cast_create_town_portal(), cast_spell(), cctk_init_std_archetypes(), cctk_setconfdir(), cctk_setdatadir(), cctk_setlog(), cfapi_system_directory(), change_abil(), check_exp_loss(), check_login(), check_pick(), check_race_and_class(), checkbanned(), checkdm(), clean_tmp_files(), CREMapInformationManager::clearCache(), command_abil(), command_addexp(), command_banish(), command_create(), command_debug(), command_help(), command_loadtest(), command_nowiz(), command_patch(), command_players(), command_search_items(), command_settings(), command_title(), convert_item(), create_items_path(), create_overlay_pathname(), create_pathname(), create_player_cmd(), create_template_pathname(), CREExperienceWindow::CREExperienceWindow(), CREFilterDialog::CREFilterDialog(), CREReportDialog::CREReportDialog(), dead_player(), delete_character(), display_motd(), do_symptoms(), do_throw(), dragon_eat_flesh(), dump_experience(), enter_exit(), enter_player_maplevel(), enter_player_savebed(), enter_unique_map(), find_help_file(), find_maps(), find_spot_for_submap(), find_style(), MessageManager::findPrePost(), fix_object(), fix_player(), forbid_play(), free_server(), 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_anim(), init_artifacts(), init_beforeplay(), init_book_archive(), init_experience(), init_formulae(), init_msgfile(), init_races(), init_regions(), init_server(), init_startup(), init_stats(), initPlugins(), is_legal_2ways_exit(), 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_archetypes(), load_materials(), load_quests_from_file(), load_settings(), load_table_float(), load_table_int(), load_treasures(), CREMapInformationManager::loadCache(), MessageManager::loadDirectory(), QuestManager::loadQuestFile(), LOG(), main(), metaserver2_init(), monsterFight(), object_clear(), CREMainWindow::onReportQuests(), CREMainWindow::onReportSpellDamage(), MessageFile::parseFile(), 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_bmap_names(), read_client_images(), read_face_data(), read_map_log(), read_smooth(), resurrect_player(), roll_stats(), MessageFile::save(), save_map(), save_player(), QuestManager::saveQuestFile(), scroll_failure(), scroll_type_apply(), send_exp_table(), send_file(), send_new_char_info(), send_news(), send_rules(), set_archetypes(), set_confdir(), set_csport(), set_datadir(), set_debug(), set_disable_plugin(), set_dumpmon1(), set_dumpmon2(), set_dumpmon3(), set_dumpmon4(), set_dumpmon5(), set_dumpmon6(), set_dumpmon7(), set_dumpmon8(), set_dumpmon9(), set_dumpmont(), set_localdir(), set_logfile(), set_mapdir(), set_mondebug(), set_playerdir(), set_regions(), set_templatedir(), set_tmpdir(), set_treasures(), set_uniquedir(), shop_bargain_multiplier(), show_skills(), SP_level_spellpoint_cost(), spell_failure(), spellbook_type_apply(), START_TEST(), CREMapInformationManager::storeCache(), swap_map(), unset_debug(), CREResourcesWindow::updateFilters(), CREResourcesWindow::updateReports(), verify_player(), write_book_archive(), write_map_log(), and write_scroll().

New_Face* smooth_face

Definition at line 39 of file image.c.

Referenced by send_smooth().

EXTERN archetype * staff_arch

Definition at line 162 of file global.h.

Referenced by init_archetype_pointers(), and init_globals().

Statistics statistics

Merged spell statistics.

Definition at line 113 of file init.c.

Referenced by init_globals(), main(), object_merge_spell(), and ok_to_put_more().

EXTERN long trying_emergency_save

True when emergency_save() is reached.

Definition at line 135 of file global.h.

Referenced by emergency_save(), init_globals(), and LOG().

EXTERN const char* undead_name
EXTERN long warn_archetypes

If true, write warnings when failing to find archetypes when loading from file.

Definition at line 132 of file global.h.

Referenced by arch_to_object(), find_archetype(), init_globals(), and load_archetypes().