diff --git a/doc/test.txt b/doc/test.txt index 9d07aa0..2aefa72 100644 --- a/doc/test.txt +++ b/doc/test.txt @@ -1 +1,4 @@ -111 \ No newline at end of file +whatever you do +wherever you gou +i am always here +waitting for you \ No newline at end of file diff --git a/doc/~$陈冠宇第二次.txt b/doc/~$陈冠宇第二次.txt new file mode 100644 index 0000000..9208392 Binary files /dev/null and b/doc/~$陈冠宇第二次.txt differ diff --git a/doc/陈冠宇第二次.docx b/doc/陈冠宇第二次.docx new file mode 100644 index 0000000..553a20c Binary files /dev/null and b/doc/陈冠宇第二次.docx differ diff --git a/doc/陈冠宇第二次.txt b/doc/陈冠宇第二次.txt new file mode 100644 index 0000000..0a9a6f1 --- /dev/null +++ b/doc/陈冠宇第二次.txt @@ -0,0 +1,34 @@ +°üͼ£º + + + + + + + + + + + + + + + + + + + + + + + + +±¾²¿·Ö´úÂëµÄ¹¦ÄÜÊǽéÉܽÇÉ«ºÍÆä³èÎïµÄ¹Øϵ¡£ÆäÖнÇÉ«°üÀ¨ÐÕÃûµÈ¼¶ÊÇ·ñ×ã¹»µÈ¼¶ÊÇ·ñ¿ÉÒÔ²¶×½²¶×½ÀàÐÍ¡£³èÎï°üÀ¨Ãû×ÖÊôÐԵȼ¶ÊÇ·ñ¿ÉÒÔ²¶×½¡£ÁíÍ⻹°üÀ¨½ÇÉ«µÄÖ°Òµ£¬¶ÔÓÚ³èÎﻹÓл·¾³µÄÓ°Ï죬°üÀ¨µØÐÎÖÜΧ×ÊÔ´ÊÇ·ñ¿É²É¼¯×ÊÔ´ÒÔ¼°¶Ô½ÇÉ«µÄΣÏճ̶ȵȵȡ£ + + + + + + + + diff --git a/src/NetHack_3.7/src/dog.c b/src/NetHack_3.7/src/dog.c index 934d88a..a21b61d 100644 --- a/src/NetHack_3.7/src/dog.c +++ b/src/NetHack_3.7/src/dog.c @@ -19,7 +19,7 @@ enum arrival { }; void -newedog(struct monst *mtmp) +newedog(struct monst *mtmp) /*Create a new dog*/ { if (!mtmp->mextra) mtmp->mextra = newmextra(); @@ -30,26 +30,26 @@ newedog(struct monst *mtmp) } void -free_edog(struct monst *mtmp) +free_edog(struct monst *mtmp) /*This code is about releasing a struct resource called "edog"*/ { - if (mtmp->mextra && EDOG(mtmp)) { - free((genericptr_t) EDOG(mtmp)); - EDOG(mtmp) = (struct edog *) 0; + if (mtmp->mextra && EDOG(mtmp)) { /*This line of code first checks if the mextra member of mtmp is non-empty, and calls the EDOG(mtmp) macro to get the edog struct associated with mtmp. If both conditions are met, the code in curly braces is executed.*/ + free((genericptr_t) EDOG(mtmp)); /*This line of code uses the free function to free up the memory space occupied by the EDOG struct obtained through the EDOG(mtmp) macro. (genericptr_t) EDOG(mtmp) converts Pointers to the edog structure to a generic pointer type to ensure proper memory release.*/ + EDOG(mtmp) = (struct edog *) 0; /*This line sets the pointer to the EDOG struct fetched by the EDOG(mtmp) macro to NULL to indicate that the struct has been released.*/ } mtmp->mtame = 0; } void -initedog(struct monst *mtmp) +initedog(struct monst *mtmp) /*Initialize the dog*/ { - mtmp->mtame = is_domestic(mtmp->data) ? 10 : 5; + mtmp->mtame = is_domestic(mtmp->data) ? 10 : 5; /*This line of code determines whether the dog is a domestic dog, and sets its taming to 10 if it is, or 5 if it is not. is_domestic might be a function that checks whether mtmp->data represents a domestic dog.*/ mtmp->mpeaceful = 1; mtmp->mavenge = 0; set_malign(mtmp); /* recalc alignment now that it's tamed */ mtmp->mleashed = 0; mtmp->meating = 0; EDOG(mtmp)->droptime = 0; - EDOG(mtmp)->dropdist = 10000; + EDOG(mtmp)->dropdist = 10000; /*These two lines of code set the dog's item drop time and distance.*/ EDOG(mtmp)->apport = ACURR(A_CHA); EDOG(mtmp)->whistletime = 0; EDOG(mtmp)->hungrytime = 1000 + gm.moves; @@ -61,18 +61,18 @@ initedog(struct monst *mtmp) EDOG(mtmp)->killed_by_u = 0; u.uconduct.pets++; } - +/*In general, this code initializes a dog's status, including its tame, flatness, marital status, evil, whether it is tied, whether it is eating, the related Settings for item drop, charisma, hunger time, target location, whether it has been abused, whether it has been resurrected, maximum health penalty, and whether it has been killed by the player. At the same time, this code also reflects that in the game, the player can have pets, and the number of pets has been increased during the initialization process.*/ static int pet_type(void) { - if (gu.urole.petnum != NON_PM) + if (gu.urole.petnum != NON_PM) /*The number of pets of a user character (possibly a player character in the game) is checked here*/ return gu.urole.petnum; else if (gp.preferred_pet == 'c') return PM_KITTEN; else if (gp.preferred_pet == 'd') return PM_LITTLE_DOG; else - return rn2(2) ? PM_KITTEN : PM_LITTLE_DOG; + return rn2(2) ? PM_KITTEN : PM_LITTLE_DOG; /*A ternary operator is used here. It first calls the function rn2(2) (probably a random number generating function, but the argument 2 May represent some kind of distribution or range) and then decides which pet class to return based on the result of this random number*/ } struct monst * @@ -178,7 +178,7 @@ make_familiar(struct obj *otmp, coordxy x, coordxy y, boolean quietly) struct monst * makedog(void) -{ +{ /*When the pet type is 'n', the function returns an empty struct pointer; When the pet type is PM_LITTLE_DOG, set the pet name to gd.dogname. When the pet type is PM_PONY, set the pet name to gh.horsename; Otherwise, set pet name to gc.catname.*/ register struct monst *mtmp; register struct obj *otmp; const char *petname; @@ -434,7 +434,19 @@ mon_arrive(struct monst *mtmp, int when) wander = (xint16) min(nmv, 8L); } else wander = 0; + /*If the value of xyloc is MIGR_APPROX_XY, the code doesn't do anything, because xlocale and ylocale are already set above. + +If xyloc has a value of MIGR_EXACT_XY, set wander's value to 0. + +If the value of xyloc is MIGR_WITH_HERO, assign the values U.U.X and U.U.Y to xlocale and ylocale, respectively. +If the value of xyloc is MIGR_STAIRS_UP or MIGR_STAIRS_DOWN, look for stairs starting from the given floor, and if found, assign the x and y coordinates of the stairs to xlocale and ylocale, respectively. + +If the value of xyloc is MIGR_LADDER_UP or MIGR_LADDER_DOWN, look for the stairs starting from the given floor, and if found, assign the x and y coordinates of the stairs to xlocale and ylocale, respectively. + +If the value of xyloc is MIGR_SSTAIRS, find the stairs for the given floor, and if found, assign the x and y coordinates of the stairs to xlocale and ylocale, respectively. + +If the value of xyloc is MIGR_PORTAL, check whether you are in the final game level. If it is, it randomly generates an internal coordinate in the target region and assigns it to xlocale and ylocale.*/ switch (xyloc) { case MIGR_APPROX_XY: /* {x,y}locale set above */ break; @@ -1246,18 +1258,18 @@ wary_dog(struct monst *mtmp, boolean was_dead) void abuse_dog(struct monst *mtmp) { - if (!mtmp->mtame) + if (!mtmp->mtame) /*If the monster is not tamed (mtame is 0), the function returns directly.*/ return; - if (Aggravate_monster || Conflict) + if (Aggravate_monster || Conflict) /*If Aggravate_monster or Conflict variables in the game are true, then the monster's tame level (mtame) will be halved. Otherwise, the monster's taming level will be reduced by 1.*/ mtmp->mtame /= 2; else mtmp->mtame--; - if (mtmp->mtame && !mtmp->isminion) + if (mtmp->mtame && !mtmp->isminion) /*If the monster is not a pawn (isminion is 0) and the monster's taming level is greater than 0, the monster's abuse count is increased by 1*/ EDOG(mtmp)->abuse++; - if (!mtmp->mtame && mtmp->mleashed) + if (!mtmp->mtame && mtmp->mleashed) /*If the monster has been tamed (mtame greater than or equal to 0) and is tethered (mleashed is true), the monster will be untethered.*/ m_unleash(mtmp, TRUE); /* don't make a sound if pet is in the middle of leaving the level */ diff --git a/src/NetHack_3.7/src/eat.c b/src/NetHack_3.7/src/eat.c index 11ec198..e850046 100644 --- a/src/NetHack_3.7/src/eat.c +++ b/src/NetHack_3.7/src/eat.c @@ -4,7 +4,7 @@ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" - +/*Define the required structure*/ static int eatmdone(void); static int eatfood(void); static struct obj *costly_tin(int); @@ -392,7 +392,7 @@ food_disappears(struct obj *obj) resume eating/opening would restart from scratch */ void food_substitution(struct obj *old_obj, struct obj *new_obj) -{ +{ /*A declaration of a function, which defines a function named food_substitution and takes two arguments: old_obj and new_obj. Both of these parameters are Pointers to the obj structure.*/ if (old_obj == gc.context.victual.piece) { gc.context.victual.piece = new_obj; gc.context.victual.o_id = new_obj->o_id; @@ -406,7 +406,7 @@ food_substitution(struct obj *old_obj, struct obj *new_obj) static void do_reset_eat(void) { - debugpline0("do_reset_eat..."); + debugpline0("do_reset_eat..."); /*´úÂë¼ì²égc.context.victual.pieceÊÇ·ñΪÕæ¡£gc.context.victual.piece¿ÉÄÜ´ú±íµ±Ç°ÕýÔÚ±»³ÔµÄʳÎï»òÕ߶ÔÏó¡£*/ if (gc.context.victual.piece) { gc.context.victual.o_id = 0; gc.context.victual.piece = touchfood(gc.context.victual.piece); @@ -513,24 +513,24 @@ eatfood(void) static void done_eating(boolean message) -{ +{// ´Ógc½á¹¹ÌåÖлñÈ¡µ½ÕýÔÚ±»³ÔµÄʳÎï»ò¶ÔÏ󣬲¢½«ÆäµØÖ·¸³¸øpieceÖ¸Õë struct obj *piece = gc.context.victual.piece; - + // ½«¸ÃʳÎï»ò¶ÔÏó±ê¼ÇΪÕýÔÚʹÓ㬱íʾÒѾ­±»½ÇÉ«Ñ¡ÖÐ piece->in_use = TRUE; go.occupation = 0; /* do this early, so newuhs() knows we're done */ - newuhs(FALSE); - if (gn.nomovemsg) { + newuhs(FALSE);// µ÷ÓÃnewuhsº¯Êý£¬½«FALSE×÷Ϊ²ÎÊý´«È룬¿ÉÄܱíʾ½ÇÉ«ÒѾ­Íê³ÉÁËÒ»¸öÖÜÆڵĻ»ò״̬ + if (gn.nomovemsg) {// ¼ì²égn½á¹¹ÌåÖеÄnomovemsg×ֶΣ¬Èç¹û´æÔÚ£¬²¢ÇÒmessageΪÕ棬Ôò´òÓ¡Ò»ÌõÏûÏ¢ if (message) pline1(gn.nomovemsg); gn.nomovemsg = 0; } else if (message) { - You("finish %s %s.", + You("finish %s %s.", // Èç¹ûnomovemsg×ֶβ»´æÔÚ£¬²¢ÇÒmessageΪÕ棬Ôò´òÓ¡Ò»ÌõÏûÏ¢£¬±íʾ½ÇÉ«ÒѾ­Íê³ÉÁËÒ»¸ö¶¯×÷£¬ÕâÀï¿ÉÄܱíʾ½ÇÉ«ÒѾ­³ÔÍêÁËÒ»¸öʳÎï»òÕ߶ÔÏó (gy.youmonst.data == &mons[PM_FIRE_ELEMENTAL]) ? "consuming" : "eating", food_xname(piece, TRUE)); } - if (piece->otyp == CORPSE || piece->globby) + if (piece->otyp == CORPSE || piece->globby)// Èç¹ûʳÎï»ò¶ÔÏóÊÇÒ»¸öʬÌå»òÕßÊÇÒ»¸öÆÕͨµÄ¶ÔÏ󣬵÷ÓÃcpostfxº¯Êý´¦ÀíËüµÄºóЧ£»·ñÔò£¬µ÷ÓÃfpostfxº¯Êý´¦ÀíËüµÄºóЧ cpostfx(piece->corpsenm); else fpostfx(piece); @@ -539,14 +539,14 @@ done_eating(boolean message) useup(piece); else useupf(piece, 1L); - + //½«gc½á¹¹ÌåÖеÄvictual×Ö¶ÎÖØÖÃΪÁ㣬±íʾ½ÇÉ«ÒѾ­Íê³ÉÁËÒ»¸ö½øʳÖÜÆÚ£¬²¢½«Ê³Îï»ò¶ÔÏóµÄÖ¸ÕëÉèÖÃΪ0£¬ÒÔ¼°½«Æäo_id×Ö¶ÎÒ²ÉèÖÃΪ0 gc.context.victual = zero_victual; /* victual.piece = 0, .o_id = 0 */ } void eating_conducts(struct permonst *pd) { - int ll_conduct = 0; + int ll_conduct = 0;// ¶¨ÒåÒ»¸öÕûÐͱäÁ¿ll_conduct²¢½«Æä³õʼ»¯Îª0¡£Õâ¸ö±äÁ¿¿ÉÄÜÓÃÀ´¼ÆÊýijÖÖÐÐΪ»òÌõ¼þ±»Âú×ãµÄ´ÎÊý if (!u.uconduct.food++) { livelog_printf(LL_CONDUCT, "ate for the first time - %s", @@ -554,18 +554,20 @@ eating_conducts(struct permonst *pd) ll_conduct++; } if (!vegan(pd)) { - if (!u.uconduct.unvegan++ && !ll_conduct) { - livelog_printf(LL_CONDUCT, + if (!u.uconduct.unvegan++ + && !ll_conduct) { // ¼ì²éu.uconduct.foodµÄÖµ¡£Èç¹ûËüΪÕ棬ÄÇôִÐÐÏÂÃæµÄ´úÂë¡£·ñÔò£¬Ìø¹ý¡£ÔÚÕâ¸öÇé¿öÏ£¬ÓÉÓÚfoodµÄÖµ±»µÝÔöÁË£¬ËùÒÔËüʼÖÕΪÕ棬Õâ¿ÉÄÜÊÇ´úÂëµÄÒ»¸ö´íÎó¡£ + livelog_printf( + LL_CONDUCT, // ´òÓ¡Ò»ÌõÏûÏ¢µ½ÈÕÖ¾£¬ËµÃ÷Õâ¸öÉúÎïµÚÒ»´Î½øʳ¡£ÏûÏ¢µÄÄÚÈÝÊÇÕâ¸öÉúÎïµÄÖÐÐÔÃû³Æ "consumed animal products (%s) for the first time", pd->pmnames[NEUTRAL]); - ll_conduct++; + ll_conduct++; // ÓÉÓÚfoodµÄÖµÒѾ­±»µÝÔö£¬ËùÒÔll_conductµÄÖµÔö¼Ó1 } } - if (!vegetarian(pd)) { - if (!u.uconduct.unvegetarian && !ll_conduct) - livelog_printf(LL_CONDUCT, "tasted meat (%s) for the first time", + if (!vegetarian(pd)) {// ¼ì²épdÊÇ·ñÊÇËØʳµÄ¡£Èç¹û²»ÊÇ£¬Ö´ÐÐÏÂÃæµÄ´úÂë¡£·ñÔò£¬Ìø¹ý¡£ + if (!u.uconduct.unvegetarian && !ll_conduct)// Èç¹ûÕâ¸öÉúÎïµÚÒ»´ÎÏû·Ñ·ÇËØʳÇÒ֮ǰûÓÐÎ¥·´ÈκÎÌõ¼þ£¨ll_conductΪ0£©£¬ÄÇôִÐÐÏÂÃæµÄ´úÂë¡£ + livelog_printf(LL_CONDUCT, "tasted meat (%s) for the first time",// ´òÓ¡Ò»ÌõÏûÏ¢µ½ÈÕÖ¾£¬ËµÃ÷Õâ¸öÉúÎïµÚÒ»´ÎÏû·Ñ¶¯Îï²úÆ·¡£ÏûÏ¢µÄÄÚÈÝÊÇÕâ¸öÉúÎïµÄÖÐÐÔÃû³Æ¡£ pd->pmnames[NEUTRAL]); - violated_vegetarian(); + violated_vegetarian();// µ÷ÓÃviolated_vegetarianº¯Êý£¬¿ÉÄÜÊÇ´¦ÀíÎ¥·´ËØʳ¹æ¶¨µÄÇé¿ö¡£ } } @@ -575,6 +577,7 @@ eat_brains( struct monst *magr, struct monst *mdef, boolean visflag, + int *dmg_p) /* for dishing out extra damage in lieu of Int loss */ { struct permonst *pd = mdef->data; @@ -755,18 +758,25 @@ maybe_cannibal(int pm, boolean allowmsg) static void cprefx(register int pm) { - (void) maybe_cannibal(pm, TRUE); - if (flesh_petrifies(&mons[pm])) { - if (!Stone_resistance - && !(poly_when_stoned(gy.youmonst.data) + (void) maybe_cannibal( + pm, + TRUE); // µ÷ÓÃmaybe_cannibalº¯Êý£¬½«pmºÍTRUE×÷Ϊ²ÎÊý´«Èë¡£maybe_cannibalº¯Êý¿ÉÄÜ´¦Àí¹ØÓÚʳÈ˵ÄÌض¨Çé¿ö + if (flesh_petrifies(&mons[pm])) {// µ÷ÓÃflesh_petrifiesº¯Êý£¬½«mons[pm]µÄµØÖ·×÷Ϊ²ÎÊý´«Èë¡£Èç¹û¸Ãº¯Êý·µ»ØÕ棬ÔòÖ´ÐÐÏÂÃæµÄ´úÂë¿é + if (!Stone_resistance// ¼ì²é½ÇÉ«ÊÇ·ñ¶ÔʯͷÓеֿ¹Á¦ + && !( + poly_when_stoned( + gy.youmonst + .data) // ¼ì²é½ÇÉ«ÊÇ·ñÔÚ±ä³Éʯͷʱ¾ßÓжà̬ÐÔ£¨¿ÉÒÔ±ä³ÉÆäËûµÄ¹ÖÎ && polymon(PM_STONE_GOLEM))) { - Sprintf(gk.killer.name, "tasting %s meat", + Sprintf(gk.killer.name, "tasting %s meat",// ¸ñʽ»¯×Ö·û´®£¬½«¹ÖÎïmons[pm]µÄÖÐÐÔÃû³ÆÌí¼Óµ½×Ö·û´®ÖУ¬²¢´æ´¢ÔÚgk.killer.nameÖС£Õâ¿ÉÄܱíʾɱÊÖµÄÃû³Æ»òÕßijÖÖɱÈËÐÐΪµÄÃèÊö mons[pm].pmnames[NEUTRAL]); - gk.killer.format = KILLED_BY; + gk.killer.format = + KILLED_BY; // ÉèÖÃgk.killer.formatΪKILLED_BY¡£Õâ¿ÉÄÜÊÇÒ»¸ö±êÖ¾£¬±íʾijÖÖËÀÍö·½Ê½£¬ÀýÈç±»xxɱËÀ You("turn to stone."); - done(STONING); - if (gc.context.victual.piece) - gc.context.victual.eating = 0; + done(STONING);// µ÷ÓÃdoneº¯Êý£¬½«STONING×÷Ϊ²ÎÊý´«Èë¡£Õâ¿ÉÄܱíʾÍê³ÉÁ˱ä³ÉʯͷµÄ¶¯»­»òÕß״̬ + if (gc.context.victual.piece)// ¼ì²égc.context.victual.pieceÊÇ·ñΪÕæ¡£Èç¹ûΪÕ棬ִÐÐÏÂÃæµÄ´úÂë¿é + gc.context.victual.eating = + 0; // ½«gc.context.victual.eatingÉèÖÃΪ0¡£¿ÉÄܱíʾֹͣ½øʳµÄÐÐΪ»òÕßÖØÖÃijÖÖ״̬ return; /* lifesaved */ } } @@ -960,7 +970,7 @@ temp_givit(int type, struct permonst *ptr) * and what type of intrinsic it is trying to give you. */ static void -givit(int type, register struct permonst *ptr) +givit(int type, register struct permonst *ptr)//Analysis for different situations { debugpline1("Attempting to give intrinsic %d", type); @@ -1384,9 +1394,11 @@ tin_details(struct obj *obj, int mnum, char *buf) Strcat(buf, " of spinach"); else if (mnum == NON_PM) Strcpy(buf, "empty tin"); - else { + else {//// Èç¹û obj->cknown ΪÕæ»òÕß iflags.override_ID ΪÕ棬²¢ÇÒ obj->spe < 0£¬ÄÇôִÐÐÒÔÏ´úÂë¿é¡£ + // Õâ¿ÉÄÜÒâζ×ÅÕâÊÇÒ»¸öÒÑÖªµÄ¡¢±»Öض¨ÏòµÄ¡¢²¢ÇÒÆäÌØÊâÊôÐÔСÓÚ0µÄÎïÌå¡£ if ((obj->cknown || iflags.override_ID) && obj->spe < 0) { - if (r == ROTTEN_TIN || r == HOMEMADE_TIN) { + if (r == ROTTEN_TIN || r == HOMEMADE_TIN) {//// Èç¹û r µÄֵΪ ROTTEN_TIN »òÕß HOMEMADE_TIN£¬ÄÇô½«×Ö·û´® " of " ºÍ tintxts[r].txt ×·¼Óµ½ buf2 ÖУ¬È»ºó½« buf2 ¸´ÖƵ½ buf ÖС£ + if (r == ROTTEN_TIN || r == HOMEMADE_TIN) { /* put these before the word tin */ Sprintf(buf2, "%s %s of ", tintxts[r].txt, buf); Strcpy(buf, buf2); @@ -1396,7 +1408,12 @@ tin_details(struct obj *obj, int mnum, char *buf) } else { Strcpy(eos(buf), " of "); } - if (vegetarian(&mons[mnum])) + if (vegetarian( + &mons[mnum])) // ¼ì²é mons[mnum] + // ÊÇ·ñΪËØʳ¡£Èç¹ûÊÇËØʳ£¬ÄÇô½« + // mons[mnum].pmnames[NEUTRAL] ×·¼Óµ½ buf + // µÄĩβ¡£·ñÔò£¬½«×Ö·û´® "meat" ºÍ + // mons[mnum].pmnames[NEUTRAL] ×·¼Óµ½ buf µÄĩβ Sprintf(eos(buf), "%s", mons[mnum].pmnames[NEUTRAL]); else Sprintf(eos(buf), "%s meat", mons[mnum].pmnames[NEUTRAL]);