|
|
|
@ -17,7 +17,7 @@ NEARDATA const struct c_color_names c_color_names = {
|
|
|
|
|
"black", "amber", "golden", "light blue", "red", "green",
|
|
|
|
|
"silver", "blue", "purple", "white", "orange"
|
|
|
|
|
};
|
|
|
|
|
const char *c_obj_colors[] = {
|
|
|
|
|
const char *c_obj_colors[] = { //这里定义了一些物品的颜色
|
|
|
|
|
"black", /* CLR_BLACK */
|
|
|
|
|
"red", /* CLR_RED */
|
|
|
|
|
"green", /* CLR_GREEN */
|
|
|
|
@ -36,8 +36,8 @@ const char *c_obj_colors[] = {
|
|
|
|
|
"white", /* CLR_WHITE */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const struct c_common_strings c_common_strings =
|
|
|
|
|
{ "Nothing happens.",
|
|
|
|
|
const struct c_common_strings c_common_strings = //结构体变量中包含了一些常见的字符串,用于文本输出
|
|
|
|
|
{ "Nothing happens.", //在游戏中提供反馈、描述情况,进行交互
|
|
|
|
|
"That's enough tries!",
|
|
|
|
|
"That is a silly thing to %s.",
|
|
|
|
|
"shudder for a moment.",
|
|
|
|
@ -50,33 +50,34 @@ const struct c_common_strings c_common_strings =
|
|
|
|
|
{ "mon", "you" }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const struct savefile_info default_sfinfo = {
|
|
|
|
|
#ifdef NHSTDC
|
|
|
|
|
const struct savefile_info default_sfinfo = { //定义了保存文件的默认信息
|
|
|
|
|
#ifdef NHSTDC //用于保存文件格式的标志位
|
|
|
|
|
0x00000000UL
|
|
|
|
|
#else
|
|
|
|
|
0x00000000L
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(COMPRESS) || defined(ZLIB_COMP)
|
|
|
|
|
#if defined(COMPRESS) || defined(ZLIB_COMP) //用于外部压缩标志位
|
|
|
|
|
| SFI1_EXTERNALCOMP
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(ZEROCOMP)
|
|
|
|
|
| SFI1_ZEROCOMP
|
|
|
|
|
| SFI1_ZEROCOMP //零压缩标志位
|
|
|
|
|
#endif
|
|
|
|
|
#if defined(RLECOMP)
|
|
|
|
|
| SFI1_RLECOMP
|
|
|
|
|
| SFI1_RLECOMP //RLE压缩标志
|
|
|
|
|
#endif
|
|
|
|
|
,
|
|
|
|
|
#ifdef NHSTDC
|
|
|
|
|
0x00000000UL, 0x00000000UL
|
|
|
|
|
0x00000000UL, 0x00000000UL //保留字段
|
|
|
|
|
#else
|
|
|
|
|
0x00000000L, 0x00000000L
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const char disclosure_options[] = "iavgco";
|
|
|
|
|
char emptystr[] = {0}; /* non-const */
|
|
|
|
|
const char disclosure_options[] = "iavgco"; //是一个字符数组,包含了几个选项。这些选项用于控制信息的披露程度。
|
|
|
|
|
char emptystr[] = {0}; /* non-const */ //是一个字符数组,用于表示空字符串。它是非常量数组,可以被修改。
|
|
|
|
|
|
|
|
|
|
NEARDATA struct flag flags; /* extern declaration is in flag.h, not decl.h */
|
|
|
|
|
//是一个结构体变量,用于存储游戏中的标志位。该变量在flag.h中有外部声明。
|
|
|
|
|
|
|
|
|
|
/* Global windowing data, defined here for multi-window-system support */
|
|
|
|
|
#ifdef WIN32
|
|
|
|
@ -84,25 +85,28 @@ boolean fqn_prefix_locked[PREFIX_COUNT] = { FALSE, FALSE, FALSE,
|
|
|
|
|
FALSE, FALSE, FALSE,
|
|
|
|
|
FALSE, FALSE, FALSE,
|
|
|
|
|
FALSE };
|
|
|
|
|
//是一个布尔数组,用于表示文件名前缀是否被锁定。在这段代码中,它被初始化为全为FALSE。
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef PREFIXES_IN_USE
|
|
|
|
|
const char *fqn_prefix_names[PREFIX_COUNT] = {
|
|
|
|
|
"hackdir", "leveldir", "savedir", "bonesdir", "datadir",
|
|
|
|
|
"scoredir", "lockdir", "sysconfdir", "configdir", "troubledir"
|
|
|
|
|
};
|
|
|
|
|
};//是一个字符串指针数组,包含了一些文件名前缀的名称。这些名称用于指定不同类型文件的存储路径。
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* x/y/z deltas for the 10 movement directions (8 compass pts, 2 down/up) */
|
|
|
|
|
const schar xdir[N_DIRS_Z] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 };
|
|
|
|
|
const schar ydir[N_DIRS_Z] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 };
|
|
|
|
|
const schar zdir[N_DIRS_Z] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, -1 };
|
|
|
|
|
//是三个有符号字符数组,分别表示十个移动方向(包括八个主要方向和上下方向)的x、y和z轴的增量。
|
|
|
|
|
/* redordered directions, cardinals first */
|
|
|
|
|
const schar dirs_ord[N_DIRS] =
|
|
|
|
|
{ DIR_W, DIR_N, DIR_E, DIR_S, DIR_NW, DIR_NE, DIR_SE, DIR_SW };
|
|
|
|
|
//是一个有符号字符数组,表示经过重新排序的移动方向。首先是四个基本方向,然后是四个对角线方向。
|
|
|
|
|
|
|
|
|
|
NEARDATA boolean has_strong_rngseed = FALSE;
|
|
|
|
|
NEARDATA boolean has_strong_rngseed = FALSE; //是一个布尔变量,用于表示是否具有强随机种子。
|
|
|
|
|
struct engr *head_engr;
|
|
|
|
|
NEARDATA struct instance_flags iflags;
|
|
|
|
|
NEARDATA struct instance_flags iflags; //是一个结构体变量,用于存储游戏实例的标志位。
|
|
|
|
|
/* NOTE: the order of these words exactly corresponds to the
|
|
|
|
|
order of oc_material values #define'd in objclass.h. */
|
|
|
|
|
const char *materialnm[] = { "mysterious", "liquid", "wax", "organic",
|
|
|
|
@ -111,37 +115,43 @@ const char *materialnm[] = { "mysterious", "liquid", "wax", "organic",
|
|
|
|
|
"metal", "copper", "silver", "gold",
|
|
|
|
|
"platinum", "mithril", "plastic", "glass",
|
|
|
|
|
"gemstone", "stone" };
|
|
|
|
|
const char quitchars[] = " \r\n\033";
|
|
|
|
|
NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo;
|
|
|
|
|
const int shield_static[SHIELD_COUNT] = {
|
|
|
|
|
//是一个字符串指针数组,包含了一些物品材质的名称。这些名称与objclass.h中定义的oc_material值的顺序完全对应。
|
|
|
|
|
|
|
|
|
|
const char quitchars[] = " \r\n\033";//是一个包含一些表示退出字符的字符串,包括空格、回车、换行和转义字符。
|
|
|
|
|
|
|
|
|
|
NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo; //结构体变量,用于保存文件的信息。
|
|
|
|
|
|
|
|
|
|
const int shield_static[SHIELD_COUNT] = {//是一个整型数组,包含了一些盾牌的静态符号。
|
|
|
|
|
S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, /* 7 per row */
|
|
|
|
|
S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,
|
|
|
|
|
S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,
|
|
|
|
|
};
|
|
|
|
|
NEARDATA struct you u;
|
|
|
|
|
NEARDATA time_t ubirthday;
|
|
|
|
|
NEARDATA struct u_realtime urealtime;
|
|
|
|
|
NEARDATA struct obj *uwep, *uarm, *uswapwep,
|
|
|
|
|
NEARDATA struct you u;//结构体变量,用于表示玩家角色的状态和属性。
|
|
|
|
|
NEARDATA time_t ubirthday; //是一个time_t类型的变量,表示玩家角色的出生时间。
|
|
|
|
|
NEARDATA struct u_realtime urealtime; //用于表示游戏时间的实时信息。
|
|
|
|
|
NEARDATA struct obj *uwep, *uarm, *uswapwep, //结构体的指针变量,用于表示玩家角色的装备和物品。
|
|
|
|
|
*uquiver, /* quiver */
|
|
|
|
|
*uarmu, /* under-wear, so to speak */
|
|
|
|
|
*uskin, /* dragon armor, if a dragon */
|
|
|
|
|
*uarmc, *uarmh, *uarms, *uarmg,*uarmf, *uamul,
|
|
|
|
|
*uright, *uleft, *ublindf, *uchain, *uball;
|
|
|
|
|
const char vowels[] = "aeiouAEIOU";
|
|
|
|
|
NEARDATA winid WIN_MESSAGE, WIN_STATUS, WIN_MAP, WIN_INVEN;
|
|
|
|
|
const char ynchars[] = "yn";
|
|
|
|
|
const char vowels[] = "aeiouAEIOU"; //是一个包含元音字母的字符串,包括小写和大写的元音字母。
|
|
|
|
|
NEARDATA winid WIN_MESSAGE, WIN_STATUS, WIN_MAP, WIN_INVEN;//是窗口标识符(winid类型)变量,用于表示游戏中的不同窗口。
|
|
|
|
|
const char ynchars[] = "yn"; //是包含一些表示"yes"和"no"的字符的字符串。
|
|
|
|
|
const char ynqchars[] = "ynq";
|
|
|
|
|
const char ynaqchars[] = "ynaq";
|
|
|
|
|
const char ynNaqchars[] = "yn#aq";
|
|
|
|
|
NEARDATA long yn_number = 0L;
|
|
|
|
|
//这些变量的定义用于实现游戏的逻辑和界面显示等功能。
|
|
|
|
|
//其中包括随机数种子、文本输出、文件操作、游戏状态、时间管理、玩家角色属性、装备和物品等。
|
|
|
|
|
|
|
|
|
|
#ifdef PANICTRACE
|
|
|
|
|
const char *ARGV0;
|
|
|
|
|
const char *ARGV0; //是一个指向const char类型的指针变量,在宏定义PANICTRACE被定义时生效。
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define IVMAGIC 0xdeadbeef
|
|
|
|
|
#define IVMAGIC 0xdeadbeef //是一个整型常量,表示一个特定的魔数。
|
|
|
|
|
|
|
|
|
|
const struct Role urole_init_data = {
|
|
|
|
|
const struct Role urole_init_data = { //是一个struct Role结构体变量,用于初始化玩家角色的初始数据。其中包括角色名称、属性、初始位置等信息。
|
|
|
|
|
{ "Undefined", 0 },
|
|
|
|
|
{ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
|
|
|
|
|
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
|
|
|
|
@ -167,7 +177,7 @@ const struct Role urole_init_data = {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const struct Race urace_init_data = {
|
|
|
|
|
"something",
|
|
|
|
|
"something", //是一个struct Race结构体变量,用于初始化玩家种族的初始数据。其中包括种族名称、属性、初始位置等信息。
|
|
|
|
|
"undefined",
|
|
|
|
|
"something",
|
|
|
|
|
"Xxx",
|
|
|
|
@ -188,7 +198,8 @@ const struct Race urace_init_data = {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const struct instance_globals_a g_init_a = {
|
|
|
|
|
const struct instance_globals_a g_init_a = { //是一个struct instance_globals_a结构体变量,用于初始化一些全局变量。
|
|
|
|
|
//每个注释后面的注释表示该变量在代码中的使用位置。
|
|
|
|
|
/* artifact.c */
|
|
|
|
|
/* decl.c */
|
|
|
|
|
UNDEFINED_PTR, /* afternmv */
|
|
|
|
@ -216,7 +227,8 @@ const struct instance_globals_a g_init_a = {
|
|
|
|
|
IVMAGIC /* a_magic to validate that structure layout has been preserved */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const struct instance_globals_b g_init_b = {
|
|
|
|
|
const struct instance_globals_b g_init_b = {//是一个struct instance_globals_b结构体变量,用于初始化另一些全局变量。
|
|
|
|
|
//每个注释后面的注释表示该变量在代码中的使用位置。
|
|
|
|
|
/* botl.c */
|
|
|
|
|
{ { { NULL, NULL, 0L, FALSE, FALSE, 0, 0U, { 0 }, { 0 }, NULL, 0, 0, 0
|
|
|
|
|
#ifdef STATUS_HILITES
|
|
|
|
@ -486,26 +498,26 @@ const struct instance_globals_l g_init_l = {
|
|
|
|
|
0U, /* last_hider */
|
|
|
|
|
/* nhlan.c */
|
|
|
|
|
#ifdef MAX_LAN_USERNAME
|
|
|
|
|
UNDEFINED_VALUES, /* lusername */
|
|
|
|
|
MAX_LAN_USERNAME, /* lusername_size */
|
|
|
|
|
UNDEFINED_VALUES, /* lusername */ //是一个全局变量,用于存储本地区域网络的用户名。如果定义了MAX_LAN_USERNAME宏,则将其初始化为UNDEFINED_VALUES,否则将其初始化为未定义的值。注释后面的注释表示该变量在代码中的使用位置。
|
|
|
|
|
MAX_LAN_USERNAME, /* lusername_size */ //是一个全局变量,用于存储本地区域网络用户名的大小。
|
|
|
|
|
#endif /* MAX_LAN_USERNAME */
|
|
|
|
|
/* nhlua.c */
|
|
|
|
|
UNDEFINED_VALUE, /* luacore */
|
|
|
|
|
DUMMY, /* lua_warnbuf[] */
|
|
|
|
|
UNDEFINED_VALUE, /* luacore */ //是一个全局变量,用于存储Lua脚本的核心。将其初始化为未定义的值。
|
|
|
|
|
DUMMY, /* lua_warnbuf[] */ //是一个数组,用于存储Lua警告信息的缓冲区。
|
|
|
|
|
/* options.c */
|
|
|
|
|
FALSE, /* loot_reset_justpicked */
|
|
|
|
|
FALSE, /* loot_reset_justpicked */ //是一个全局变量,用于表示是否刚刚拾取了战利品并需要重置。将其初始化为FALSE。
|
|
|
|
|
/* save.c */
|
|
|
|
|
(struct obj *) 0, /* looseball */
|
|
|
|
|
(struct obj *) 0, /* looseball */ //是全局变量,用于表示游戏中的松散物品
|
|
|
|
|
(struct obj *) 0, /* loosechain */
|
|
|
|
|
/* sp_lev.c */
|
|
|
|
|
NULL, /* lev_message */
|
|
|
|
|
UNDEFINED_PTR, /* lregions */
|
|
|
|
|
NULL, /* lev_message */ //是一个全局变量,用于存储地图生成时的消息。
|
|
|
|
|
UNDEFINED_PTR, /* lregions */ //一个全局变量,用于存储地图生成时的区域信息
|
|
|
|
|
/* trap.c */
|
|
|
|
|
{ UNDEFINED_PTR, 0, 0 }, /* launchplace */
|
|
|
|
|
{ UNDEFINED_PTR, 0, 0 }, /* launchplace */ //是一个结构体变量,用于表示陷阱的发射位置。
|
|
|
|
|
/* windows.c */
|
|
|
|
|
UNDEFINED_PTR, /* last_winchoice */
|
|
|
|
|
UNDEFINED_PTR, /* last_winchoice */ //是一个全局变量,用于存储上次选择的窗口选项。
|
|
|
|
|
/* new */
|
|
|
|
|
DUMMY, /* lua_ver[LUA_VER_BUFSIZ] */
|
|
|
|
|
DUMMY, /* lua_ver[LUA_VER_BUFSIZ] */ //是一个字符数组,用于存储Lua版本信息。
|
|
|
|
|
DUMMY, /* lua_copyright[LUA_COPYRIGHT_BUFSIZ] */
|
|
|
|
|
TRUE, /* havestate*/
|
|
|
|
|
IVMAGIC /* l_magic to validate that structure layout has been preserved */
|
|
|
|
@ -948,8 +960,11 @@ const struct const_globals cg = {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define ZERO(x) memset(&x, 0, sizeof(x))
|
|
|
|
|
//是一个宏定义,用于将变量x的内存空间清零。使用memset函数将x的内存空间的值设置为0,大小为sizeof(x)。
|
|
|
|
|
|
|
|
|
|
#define MAGICCHECK(xx) \
|
|
|
|
|
//是一个宏定义,用于检查结构体变量xx的魔术值和状态。
|
|
|
|
|
//如果xx的magic字段不等于IVMAGIC(预定义的魔术值),则输出错误信息并退出程序。如果xx的havestate字段不等于TRUE,则输出错误信息并退出程序。
|
|
|
|
|
do { \
|
|
|
|
|
if ((xx).magic != IVMAGIC) { \
|
|
|
|
|
raw_printf( \
|
|
|
|
|