Macros | Typedefs
h-basic.h File Reference

The lowest level header. More...

#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <errno.h>
#include <limits.h>
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <pwd.h>
#include <sys/stat.h>
#include <unistd.h>

Go to the source code of this file.


#define HAVE_FCNTL_H
 Include autoconf autodetections, otherwise try to autodetect ourselves. More...
#define HAVE_STAT
#define UNIX
 Extract the "WINDOWS" flag from the compiler. More...
#define PATH_SEP   "/"
 Define SETGID if we are running as a central install on a multiuser system that has setgid support. More...
#define PATH_SEPC   '/'
#define _GNU_SOURCE

Include the library header files

#define DSTRINGIFY(x)   #x
 Debugging macros. More...
#define DSTRING(x)   DSTRINGIFY(x)
#define DHERE   __FILE__ ":" DSTRING(__LINE__) ": "
#define MIN(a, b)   (((a) > (b)) ? (b) : (a))

Basic math macros

#define MAX(a, b)   (((a) < (b)) ? (b) : (a))
#define ABS(a)   (((a) < 0) ? (-(a)) : (a))
#define SGN(a)   (((a) < 0) ? (-1) : ((a) != 0))
#define CMP(a, b)   ((a) < (b) ? -1 : ((b) < (a) ? 1 : 0))
#define N_ELEMENTS(a)   (sizeof(a) / sizeof((a)[0]))

Useful fairly generic macros

#define A2I(X)   ((X) - 'a')

Some hackish character manipulation

#define I2A(X)   ((X) + 'a')
#define D2I(X)   ((X) - '0')
#define I2D(X)   ((X) + '0')


typedef int errr
 ANSI C headers. More...
typedef uint8_t byte
typedef uint16_t u16b
typedef int16_t s16b
typedef uint32_t u32b
typedef int32_t s32b
typedef uint64_t u64b
typedef int64_t s64b

Detailed Description

The lowest level header.

Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke

This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies. Other copyrights may also apply.

Macro Definition Documentation


#define _GNU_SOURCE

Include the library header files

◆ A2I

#define A2I (   X)    ((X) - 'a')

Some hackish character manipulation

Note that all "index" values must be "lowercase letters", while all "digits" must be "digits".

Referenced by build_prob(), dehex(), and show_file().


#define ABS (   a)    (((a) < 0) ? (-(a)) : (a))


#define CMP (   a,
)    ((a) < (b) ? -1 : ((b) < (a) ? 1 : 0))

◆ D2I

#define D2I (   X)    ((X) - '0')


#define DHERE   __FILE__ ":" DSTRING(__LINE__) ": "


#define DSTRING (   x)    DSTRINGIFY(x)


#define DSTRINGIFY (   x)    #x

Debugging macros.




#define HAVE_FCNTL_H

Include autoconf autodetections, otherwise try to autodetect ourselves.

Native MSVC compiler doesn't understand inline or snprintf Using C99, assume we have stdint and stdbool Everyone except RISC OS has fcntl.h and sys/stat.h


#define HAVE_STAT

◆ I2A

#define I2A (   X)    ((X) + 'a')

◆ I2D

#define I2D (   X)    ((X) + '0')


#define MAX (   a,
)    (((a) < (b)) ? (b) : (a))

Referenced by build_crossed(), build_overlap(), calc_blows(), calc_bonuses(), calc_digging_chances(), calculate_melee_crits(), calculate_missile_crits(), cavern_gen(), classic_gen(), copy_artifact_data(), curse_menu(), describe_effect(), design_artifact(), display_scrolling(), do_cmd_throw(), do_mon_spell(), edit_text(), effect_handler_ARC(), effect_handler_BREATH(), effect_handler_COMMAND(), effect_handler_DRAIN_MANA(), effect_handler_JUMP_AND_BITE(), effect_handler_MON_TIMED_INC(), effect_handler_NOURISH(), effect_handler_TELEPORT(), effect_handler_TIMED_DEC(), effect_handler_TIMED_INC(), effect_handler_TIMED_INC_NO_RES(), effect_handler_TIMED_SET(), ego_apply_magic(), ego_find_random(), fill_terrain_info(), gauntlet_gen(), get_min_level_size(), get_move_find_range(), get_obj_num(), hard_centre_gen(), improve_attack_modifier(), inven_carry_num(), item_menu(), item_menu_browser(), labyrinth_gen(), lair_gen(), melee_effect_handler_DRAIN_CHARGES(), modified_gen(), mon_create_drop(), mon_inc_timed(), monster_effect_level(), monster_list_format_section(), monster_list_format_textblock(), moria_gen(), object_absorb_partial(), object_list_format_section(), object_list_format_textblock(), object_skin_display(), place_new_monster_one(), player_set_recall_depth(), player_set_timed(), poly_race(), process_world(), project(), project_m_apply_side_effects(), region_erase_bordered(), saving_throw(), set_obj_names(), show_obj(), show_obj_list(), steal_monster_item(), store_create_random(), textui_get_item(), tile_picker_command(), and use_aux().


#define MIN (   a,
)    (((a) > (b)) ? (b) : (a))


#define N_ELEMENTS (   a)    (sizeof(a) / sizeof((a)[0]))

Useful fairly generic macros

Given an array, determine how many elements are in it.

Referenced by add_high_resist(), build_freq_table(), change_path(), cleanup_arrays(), cmd_idx(), cmd_init(), cmd_lookup_key(), cmd_verb(), count_known_monsters(), death_screen(), display_feeling(), display_options_item(), display_player_xtra_info(), do_cmd_colors(), do_cmd_fire(), do_cmd_keymaps(), do_cmd_knowledge_ego_items(), do_cmd_knowledge_features(), do_cmd_knowledge_monsters(), do_cmd_knowledge_runes(), do_cmd_knowledge_traps(), do_cmd_options(), do_cmd_options_item(), do_cmd_save_screen_html(), do_cmd_spoilers(), do_cmd_throw(), do_cmd_visuals(), effect_lookup(), ego_has_ignore_type(), ego_item_name(), element_power(), enter_score(), expression_add_operations_string(), finish_parse_projection(), flag_index_by_name(), flags_power(), grab_effect_data(), handle_options_item(), ignore_tval(), ignore_type_of(), init_arrays(), keycode_find_code(), keycode_find_desc(), keymap_free(), main(), message_type_color(), option_dump(), parse_mon_spell_name(), parse_player_timed_name(), parse_prefs_keymap_action(), parse_prefs_keymap_input(), parse_prefs_window(), parse_profile_name(), parse_profile_room(), parse_random(), parse_room_height(), parse_room_width(), parse_vault_columns(), parse_vault_rows(), predict_score(), print_sound_help(), process_command(), prt_welcome(), py_attack_real(), redraw_stuff(), rescale_freqs(), show_scores(), subwindow_flag_changed(), tag_options_item(), test_length(), textui_knowledge_init(), timed_name_to_idx(), try_save(), tval_find_idx(), tval_find_name(), ui_enter_world(), ui_leave_world(), update_sidebar(), update_statusline(), and valid_options_item().


#define PATH_SEP   "/"

Define SETGID if we are running as a central install on a multiuser system that has setgid support.

Every system seems to use its own symbol as a path separator.

Default to the standard Unix slash, but attempt to change this for various other systems. Note that any system that uses the "period" as a separator (i.e. RISCOS) will have to pretend that it uses the slash, and do its own mapping of period <-> slash.

It is most definitely wrong to have such things here. Platform-specific code should handle shifting Angband filenames to platform ones. XXX

Referenced by init_file_paths(), init_stuff(), path_build(), path_process(), set_file_paths(), stats_db_open(), and stats_make_output_dir().


#define PATH_SEPC   '/'

Referenced by dir_create(), and path_filename_index().


#define SGN (   a)    (((a) < 0) ? (-1) : ((a) != 0))

Referenced by object_value_real().


#define UNIX

Extract the "WINDOWS" flag from the compiler.

Define UNIX if our OS is UNIXy

Typedef Documentation

◆ byte

typedef uint8_t byte

◆ errr

typedef int errr

ANSI C headers.

POSIX headers

Define the basic game types

errr is an error code

A "byte" is an unsigned byte of memory. s16b/u16b are exactly 2 bytes (where possible) s32b/u32b are exactly 4 bytes (where possible)

◆ s16b

typedef int16_t s16b

◆ s32b

typedef int32_t s32b

◆ s64b

typedef int64_t s64b

◆ u16b

typedef uint16_t u16b

◆ u32b

typedef uint32_t u32b

◆ u64b

typedef uint64_t u64b