Compare commits

...

11 Commits
main ... szy_

@ -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,29 +115,35 @@ 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;

@ -30,18 +30,19 @@ static boolean makemon_rnd_goodpos(struct monst *, mmflags_nht, coord *);
boolean
is_home_elemental(struct permonst *ptr)
{
if (ptr->mlet == S_ELEMENTAL)
switch (monsndx(ptr)) {
if (ptr->mlet == S_ELEMENTAL)// Check if the monster is an elemental creature
switch (monsndx(ptr)) {// Determine the specific type of the elemental creature
case PM_AIR_ELEMENTAL:
case PM_AIR_ELEMENTAL:
return Is_airlevel(&u.uz);
return Is_airlevel(&u.uz);// Check if the player is on an air elemental level
case PM_FIRE_ELEMENTAL:
return Is_firelevel(&u.uz);
return Is_firelevel(&u.uz);// Check if the player is on a fire elemental level
case PM_EARTH_ELEMENTAL:
return Is_earthlevel(&u.uz);
return Is_earthlevel(&u.uz);// Check if the player is on an earth elemental level
case PM_WATER_ELEMENTAL:
return Is_waterlevel(&u.uz);
return Is_waterlevel(&u.uz);// Check if the player is on a water elemental level
}
return FALSE;
return FALSE;// The monster is not an elemental or the player is not on a matching elemental level
}
/*
@ -50,23 +51,24 @@ is_home_elemental(struct permonst *ptr)
static boolean
wrong_elem_type(struct permonst *ptr)
{
if (ptr->mlet == S_ELEMENTAL) {
return (boolean) !is_home_elemental(ptr);
if (ptr->mlet == S_ELEMENTAL) { // Check if the monster is an elemental creature
return (boolean) !is_home_elemental(ptr);// Return the opposite of is_home_elemental
} else if (Is_earthlevel(&u.uz)) {
/* no restrictions? */
} else if (Is_waterlevel(&u.uz)) {
/* just monsters that can swim */
if (!is_swimmer(ptr))
return TRUE;
return TRUE; // Return true if the monster cannot swim
} else if (Is_firelevel(&u.uz)) {
if (!pm_resistance(ptr, MR_FIRE))
return TRUE;
return TRUE; // Return true if the monster is not resistant to fire
} else if (Is_airlevel(&u.uz)) {
if (!(is_flyer(ptr) && ptr->mlet != S_TRAPPER) && !is_floater(ptr)
&& !amorphous(ptr) && !noncorporeal(ptr) && !is_whirly(ptr))
return TRUE;
return TRUE; // Return true if the monster is not suited for an air level
}
return FALSE;
return FALSE; // The monster is suitable for the current level or is not an elemental
}
/* make a group just like mtmp */
@ -142,12 +144,12 @@ m_initthrow(struct monst *mtmp, int otyp, int oquan)
{
register struct obj *otmp;
otmp = mksobj(otyp, TRUE, FALSE);
otmp->quan = (long) rn1(oquan, 3);
otmp->owt = weight(otmp);
otmp = mksobj(otyp, TRUE, FALSE); // Create a new object of the given type
otmp->quan = (long) rn1(oquan, 3); // Set the quantity of the object
otmp->owt = weight(otmp); // Set the weight of the object
if (otyp == ORCISH_ARROW)
otmp->opoisoned = TRUE;
(void) mpickobj(mtmp, otmp);
otmp->opoisoned = TRUE;// Set the poisoned flag if the object type is ORCISH_ARROW
(void) mpickobj(mtmp, otmp);// Add the object to the monster's inventory
}
static void

@ -242,7 +242,7 @@ castmu(
canseemon(mtmp) ? Monnam(mtmp) : "Something",
is_waterwall(mtmp->mux,mtmp->muy) ? "empty water"
: "thin air");
return M_ATTK_MISS;
return M_ATTK_MISS;// Return a miss attack if the monster hasn't found you but thinks it has and casts a directed spell
}
nomul(0);
@ -300,14 +300,14 @@ castmu(
burn_away_slime();
break;
case AD_COLD:
pline("You're covered in frost.");
if (Cold_resistance) {
shieldeff(u.ux, u.uy);
pline("But you resist the effects.");
monstseesu(M_SEEN_COLD);
dmg = 0;
pline("You're covered in frost."); // Display a message indicating that the player is covered in frost
if (Cold_resistance) { // Check if the player has cold resistance
shieldeff(u.ux, u.uy); // Shield the player with an icy shield animation
pline("But you resist the effects."); // Display a message indicating that the player resists the effects
monstseesu(M_SEEN_COLD); // Indicate that the monster saw the player being hit with a cold attack
dmg = 0; // Set the damage amount to 0 since the player resisted the attack
} else {
monstunseesu(M_SEEN_COLD);
monstunseesu(M_SEEN_COLD);// Indicate that the monster saw the player being hit with a cold attack
}
break;
case AD_MAGM:
@ -341,15 +341,15 @@ castmu(
static int
m_cure_self(struct monst *mtmp, int dmg)
{
if (mtmp->mhp < mtmp->mhpmax) {
if (canseemon(mtmp))
pline("%s looks better.", Monnam(mtmp));
if (mtmp->mhp < mtmp->mhpmax) { // Check if the monster's current hit points are less than its maximum hit points
if (canseemon(mtmp)) // Check if the player can see the monster
pline("%s looks better.", Monnam(mtmp)); // Display a message indicating that the monster looks better
/* note: player healing does 6d4; this used to do 1d8 */
if ((mtmp->mhp += d(3, 6)) > mtmp->mhpmax)
mtmp->mhp = mtmp->mhpmax;
dmg = 0;
if ((mtmp->mhp += d(3, 6)) > mtmp->mhpmax) // Restore some of the monster's health
mtmp->mhp = mtmp->mhpmax; // Cap the monster's hit points to its maximum hit points
dmg = 0; // Set the damage amount to 0 since the monster is healing itself
}
return dmg;
return dmg; // Return the updated damage amount
}
/* unlike the finger of death spell which behaves like a wand of death,

@ -163,10 +163,10 @@ static struct win_information window_opts[] = {
static int count_and_validate_soundlibopts(void);
struct soundlib_information {
enum soundlib_ids id;
const char *const text_id;
const char *const Url;
boolean valid;
enum soundlib_ids id; // The ID of the sound library
const char *const text_id; // The ID of the text associated with the sound library
const char *const Url; // A URL to the sound library's homepage or download link
boolean valid; // Whether or not the sound library is valid (i.e., exists and is properly configured)
};
/*
@ -959,14 +959,14 @@ case_insensitive_comp(const char *s1, const char *s2)
void
runtime_info_init(void)
{
if (!done_runtime_opt_init_once) {
done_runtime_opt_init_once = 1;
build_savebones_compat_string();
if (!done_runtime_opt_init_once) { // Check if runtime info has already been initialized
done_runtime_opt_init_once = 1; // Mark that runtime info has been initialized
build_savebones_compat_string(); // Build a string for save file compatibility
/* construct the current version number */
make_version();
make_version();// Constructs the version number of the game
populate_nomakedefs(&version); /* date.c */
idxopttext = 0;
build_options();
idxopttext = 0;// Set the index of option text to 0
build_options(); // Construct the game options
}
}

@ -479,8 +479,8 @@ mattackm(
break;
case AT_GAZE:
strike = 0;
res[i] = gazemm(magr, mdef, mattk);
strike = 0; // Set the strike value to 0, indicating that a physical attack does not occur
res[i] = gazemm(magr, mdef, mattk); // Perform a gaze attack and store the result in the corresponding position of the res array
break;
case AT_EXPL:
@ -1437,9 +1437,9 @@ xdrainenergym(struct monst *mon, boolean givemsg)
if (mon->mspec_used < 20 /* limit draining */
&& (attacktype(mon->data, AT_MAGC)
|| attacktype(mon->data, AT_BREA))) {
mon->mspec_used += d(2, 2);
mon->mspec_used += d(2, 2);// Increase the monster's special ability used count by rolling 2d2
if (givemsg)
pline("%s seems lethargic.", Monnam(mon));
pline("%s seems lethargic.", Monnam(mon));// Display a message indicating the monster seems lethargic
}
}

@ -157,14 +157,15 @@ mpoisons_subj(struct monst *mtmp, struct attack *mattk)
void
u_slow_down(void)
{
HFast = 0L;
HFast = 0L; // Clear the duration of the fast status
if (!Fast)
You("slow down.");
You("slow down."); // Displays a message to indicate that the player is slowing down
else /* speed boots */
Your("quickness feels less natural.");
exercise(A_DEX, FALSE);
Your("quickness feels less natural.");// Displays a message indicating that the player's quickness feels less natural, likely due to the effect of having worn magical speed boots
exercise(A_DEX, FALSE); // Increase the player's dexterity by exercising it
}
/* monster attacked wrong location due to monster blindness, hero
invisibility, hero displacement, or hero being underwater */
static void
@ -1194,14 +1195,14 @@ gulp_blnd_check(void)
{
struct attack *mattk;
if (!Blinded && u.uswallow
&& (mattk = attacktype_fordmg(u.ustuck->data, AT_ENGL, AD_BLND))
&& can_blnd(u.ustuck, &gy.youmonst, mattk->aatyp, (struct obj *) 0)) {
++u.uswldtim; /* compensate for gulpmu change */
(void) gulpmu(u.ustuck, mattk);
return TRUE;
if (!Blinded && u.uswallow// Check if the player is not already blinded and is currently swallowed by another creature
&& (mattk = attacktype_fordmg(u.ustuck->data, AT_ENGL, AD_BLND)) // Get the type of attack used by the creature to blind its prey
&& can_blnd(u.ustuck, &gy.youmonst, mattk->aatyp, (struct obj *) 0)) { // Check if this kind of attack can blind the player
++u.uswldtim; /* compensate for gulpmu change */ // Increase the swallow delay timer to compensate for any changes caused by swallowing the player
(void) gulpmu(u.ustuck, mattk); // Perform the swallow attack
return TRUE; // Return that the player should be blinded
}
return FALSE;
return FALSE;// Return that the player should not be blinded
}
/* monster swallows you, or damage if u.uswallow */
@ -1810,16 +1811,17 @@ gazemu(struct monst *mtmp, struct attack *mattk)
void
mdamageu(struct monst *mtmp, int n)
{
gc.context.botl = 1;
if (Upolyd) {
u.mh -= n;
if (u.mh < 1)
rehumanize();
} else {
n = saving_grace(n);
u.uhp -= n;
if (u.uhp < 1)
done_in_by(mtmp, DIED);
gc.context.botl = 1; // Set the botl (bottom line) flag to indicate that the status line needs to be updated
if (Upolyd) { // If the player is currently in a polymorphed form
u.mh -= n; // Reduce the player's monster hit points by the specified amount of damage
if (u.mh < 1) // If the player's monster hit points drop below 1
rehumanize(); // Change the player back to human form
} else { // If the player is in human form
n = saving_grace(n); // Apply any necessary reductions to the damage based on the player's abilities
u.uhp -= n; // Reduce the player's hit points by the modified amount of damage
if (u.uhp < 1) // If the player's hit points drop below 1
done_in_by(mtmp, DIED); // Handle the player's death caused by the monster
}
}

@ -16,22 +16,22 @@ static const int elementals[4] = {
void
newemin(struct monst *mtmp)
{
if (!mtmp->mextra)
mtmp->mextra = newmextra();
if (!EMIN(mtmp)) {
EMIN(mtmp) = (struct emin *) alloc(sizeof(struct emin));
(void) memset((genericptr_t) EMIN(mtmp), 0, sizeof(struct emin));
if (!mtmp->mextra) // If the monster does not have an mextra structure
mtmp->mextra = newmextra(); // Create a new mextra structure for the monster
if (!EMIN(mtmp)) { // If the monster does not have an emin structure
EMIN(mtmp) = (struct emin *) alloc(sizeof(struct emin)); // Allocate memory for the emin structure
(void) memset((genericptr_t) EMIN(mtmp), 0, sizeof(struct emin)); // Initialize the emin structure with zeros
}
}
void
free_emin(struct monst *mtmp)
{
if (mtmp->mextra && EMIN(mtmp)) {
free((genericptr_t) EMIN(mtmp));
EMIN(mtmp) = (struct emin *) 0;
if (mtmp->mextra && EMIN(mtmp)) { // If the monster has an mextra structure and an emin structure
free((genericptr_t) EMIN(mtmp)); // Free the memory allocated for the emin structure
EMIN(mtmp) = (struct emin *) 0; // Set the emin pointer to null
}
mtmp->isminion = 0;
mtmp->isminion = 0; // Set the isminion flag to 0 to indicate that the monster is not a minion
}
/* count the number of monsters on the level */
@ -42,15 +42,15 @@ monster_census(boolean spotted) /* seen|sensed vs all */
int count = 0;
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (DEADMONSTER(mtmp))
if (DEADMONSTER(mtmp)) // If the monster is dead, skip to the next monster
continue;
if (mtmp->isgd && mtmp->mx == 0)
if (mtmp->isgd && mtmp->mx == 0) // If the monster is a guardian and is not on the map, skip to the next monster
continue;
if (spotted && !canspotmon(mtmp))
if (spotted && !canspotmon(mtmp)) // If spotted flag is true and the monster is not visible, skip to the next monster
continue;
++count;
++count; // Increment the count
}
return count;
return count; // Return the final count
}
/* mon summons a monster */
@ -133,10 +133,10 @@ msummon(struct monst *mon)
* If this daemon is unique and being re-summoned (the only way we
* could get this far with an extinct dtype), try another.
*/
if ((gm.mvitals[dtype].mvflags & G_GONE) != 0) {
dtype = ndemon(atyp);
if (dtype == NON_PM)
return 0;
if ((gm.mvitals[dtype].mvflags & G_GONE) != 0) { // Check if the monster type is flagged as gone
dtype = ndemon(atyp); // Generate a new demon monster type
if (dtype == NON_PM) // If the generated type is not a valid monster type
return 0; // Return 0 to indicate failure
}
/* some candidates can generate a group of monsters, so simple
@ -426,12 +426,12 @@ lminion(void)
struct permonst *ptr;
for (tryct = 0; tryct < 20; tryct++) {
ptr = mkclass(S_ANGEL, 0);
if (ptr && !is_lord(ptr))
return monsndx(ptr);
ptr = mkclass(S_ANGEL, 0); // Generate a random monster class of angels
if (ptr && !is_lord(ptr)) // If a valid non-lord monster is generated
return monsndx(ptr); // Return the monster number
}
return NON_PM;
return NON_PM; // Return NON_PM if no valid non-lord monster can be generated after 20 tries
}
int

@ -56,8 +56,8 @@ mkroom_cmp(const genericptr vx, const genericptr vy)
x = (const struct mkroom *) vx;
y = (const struct mkroom *) vy;
if (x->lx < y->lx)
return -1;
return (x->lx > y->lx);
return -1; // x's lx is less than y's lx
return (x->lx > y->lx); // x's lx is greater than y's lx
}
/* Return TRUE if a door placed at (x, y) which otherwise passes okdoor()
@ -1896,13 +1896,13 @@ static void
mksink(struct mkroom *croom)
{
coord m;
// Find a valid position for the sink within the room
if (!find_okay_roompos(croom, &m))
return;
return;// No valid position found, return
/* Put a sink at m.x, m.y */
if (!set_levltyp(m.x, m.y, SINK))
return;
return;// Failed to set the level type to SINK, return
gl.level.flags.nsinks++;
}

@ -27,9 +27,9 @@ init_map(schar bg_typ)
for (i = 1; i < COLNO; i++)
for (j = 0; j < ROWNO; j++) {
levl[i][j].roomno = NO_ROOM;
levl[i][j].typ = bg_typ;
levl[i][j].lit = FALSE;
levl[i][j].roomno = NO_ROOM; // Set room number to NO_ROOM
levl[i][j].typ = bg_typ; // Set cell type to the specified background type
levl[i][j].lit = FALSE; // Set the cell as not lit
}
}
@ -250,9 +250,9 @@ join_map_cleanup(void)
for (x = 1; x < COLNO; x++)
for (y = 0; y < ROWNO; y++)
levl[x][y].roomno = NO_ROOM;
gn.nroom = gn.nsubroom = 0;
gr.rooms[gn.nroom].hx = gs.subrooms[gn.nsubroom].hx = -1;
levl[x][y].roomno = NO_ROOM; // Set room number to NO_ROOM
gn.nroom = gn.nsubroom = 0; // Reset the number of rooms and subrooms
gr.rooms[gn.nroom].hx = gs.subrooms[gn.nsubroom].hx = -1; // Reset room boundaries
}
static void

@ -43,9 +43,9 @@ iswall(coordxy x, coordxy y)
{
int type;
if (!isok(x, y))
return 0;
type = levl[x][y].typ;
if (!isok(x, y)) // Check if the specified coordinates are valid
return 0; // Return false if not
type = levl[x][y].typ;// Get the type of the cell at the specified coordinates
return (IS_WALL(type) || IS_DOOR(type)
|| type == SDOOR || type == IRONBARS);
}
@ -280,12 +280,12 @@ wallification(coordxy x1, coordxy y1, coordxy x2, coordxy y2)
static boolean
okay(coordxy x, coordxy y, coordxy dir)
{
mz_move(x, y, dir);
mz_move(x, y, dir);
mz_move(x, y, dir); // Move the player one space in the given direction
mz_move(x, y, dir); // Move the player another space in the same direction
if (x < 3 || y < 3 || x > gx.x_maze_max || y > gy.y_maze_max
|| levl[x][y].typ != STONE)
return FALSE;
return TRUE;
return FALSE;// Return false if the player is not on a valid location
return TRUE;// Return true if the player is on a valid location
}
/* find random starting point for maze generation */
@ -294,7 +294,7 @@ maze0xy(coord *cc)
{
cc->x = 3 + 2 * rn2((gx.x_maze_max >> 1) - 1);
cc->y = 3 + 2 * rn2((gy.y_maze_max >> 1) - 1);
return;
return;// Return after storing the generated coordinates
}
static boolean

@ -85,10 +85,10 @@ struct oextra *
newoextra(void)
{
struct oextra *oextra;
// Allocate memory for oextra structure
oextra = (struct oextra *) alloc(sizeof (struct oextra));
init_oextra(oextra);
return oextra;
return oextra;// Return the pointer to the newly allocated oextra structure
}
void
@ -113,13 +113,13 @@ void
newomonst(struct obj *otmp)
{
if (!otmp->oextra)
otmp->oextra = newoextra();
otmp->oextra = newoextra(); // Allocate and initialize a new oextra structure
if (!OMONST(otmp)) {
struct monst *m = newmonst();
struct monst *m = newmonst(); // Allocate memory for a new monster
*m = cg.zeromonst;
OMONST(otmp) = m;
*m = cg.zeromonst; // Initialize the monster with cg.zeromonst
OMONST(otmp) = m; // Assign the new monster to the object
}
}
@ -127,13 +127,13 @@ void
free_omonst(struct obj *otmp)
{
if (otmp->oextra) {
struct monst *m = OMONST(otmp);
struct monst *m = OMONST(otmp);// Get the monster associated with the object
if (m) {
if (m->mextra)
dealloc_mextra(m);
free((genericptr_t) m);
OMONST(otmp) = (struct monst *) 0;
dealloc_mextra(m); // Deallocate any extra memory associated with the monster
free((genericptr_t)m); // Deallocate the memory for the monster
OMONST(otmp) = (struct monst *)0; // Set the OMONST field of the object to null
}
}
}
@ -166,8 +166,8 @@ void
free_omailcmd(struct obj *otmp)
{
if (otmp->oextra && OMAILCMD(otmp)) {
free((genericptr_t) OMAILCMD(otmp));
OMAILCMD(otmp) = (char *) 0;
free((genericptr_t)OMAILCMD(otmp)); // Deallocate the memory for the mail command
OMAILCMD(otmp) = (char *)0; // Set the OMAILCMD field of the object to null
}
}
@ -2595,15 +2595,7 @@ add_to_migration(struct obj *obj)
}
void
add_to_buried(struct obj *obj)
{
if (obj->where != OBJ_FREE)
panic("add_to_buried: obj not free");
obj->where = OBJ_BURIED;
obj->nobj = gl.level.buriedobjlist;
gl.level.buriedobjlist = obj;
}
/* Recalculate the weight of this container and all of _its_ containers. */
static void

Loading…
Cancel
Save