diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 6174a446f..268fcfadc 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1192,6 +1192,7 @@ skip sanity_check handling when current command is ^P, otherwise it might line-at-a-line feedback applying a cream pie (always) or lump of royal jelly (sometimes) would use up the object and then access its memory after that had been freed +keep track of hero's pending movement points across save and restore Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/include/patchlevel.h b/include/patchlevel.h index f6d3b39a3..a74f49e97 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -17,7 +17,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 84 +#define EDITLEVEL 85 /* * Development status possibilities. diff --git a/include/you.h b/include/you.h index f0ed074cf..7528199ba 100644 --- a/include/you.h +++ b/include/you.h @@ -482,6 +482,7 @@ struct you { struct skills weapon_skills[P_NUM_SKILLS]; boolean twoweap; /* KMH -- Using two-weapon combat */ short mcham; /* vampire mndx if shapeshifted to bat/cloud */ + short umovement; /* instead of youmonst.movement */ schar uachieved[N_ACH]; /* list of achievements in the order attained */ }; /* end of `struct you' */ diff --git a/src/allmain.c b/src/allmain.c index 22ce1d6f7..88f89aa0a 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -68,6 +68,9 @@ moveloop_preamble(boolean resuming) clairvoyance (wizard with cornuthaum perhaps?); without this, first "random" occurrence would always kick in on turn 1 */ gc.context.seer_turn = (long) rnd(30); + /* give hero initial movement points; new game only--for restore, + pending movement points were included in the save file */ + u.umovement = NORMAL_SPEED; } gc.context.botlx = TRUE; /* for STATUS_HILITES */ if (resuming) { /* restoring old game */ @@ -83,7 +86,6 @@ moveloop_preamble(boolean resuming) initrack(); u.uz0.dlevel = u.uz.dlevel; - gy.youmonst.movement = NORMAL_SPEED; /* give hero some movement points */ gc.context.move = 0; gp.program_state.in_moveloop = 1; @@ -135,9 +137,9 @@ u_calc_moveamt(int wtcap) break; } - gy.youmonst.movement += moveamt; - if (gy.youmonst.movement < 0) - gy.youmonst.movement = 0; + u.umovement += moveamt; + if (u.umovement < 0) + u.umovement = 0; } #if defined(MICRO) || defined(WIN32) @@ -168,7 +170,7 @@ moveloop_core(void) if (gc.context.move) { /* actual time passed */ - gy.youmonst.movement -= NORMAL_SPEED; + u.umovement -= NORMAL_SPEED; do { /* hero can't move this turn loop */ mvl_wtcap = encumber_msg(); @@ -176,12 +178,12 @@ moveloop_core(void) gc.context.mon_moving = TRUE; do { monscanmove = movemon(); - if (gy.youmonst.movement >= NORMAL_SPEED) + if (u.umovement >= NORMAL_SPEED) break; /* it's now your turn */ } while (monscanmove); gc.context.mon_moving = FALSE; - if (!monscanmove && gy.youmonst.movement < NORMAL_SPEED) { + if (!monscanmove && u.umovement < NORMAL_SPEED) { /* both hero and monsters are out of steam this round */ struct monst *mtmp; @@ -347,7 +349,7 @@ moveloop_core(void) } } } - } while (gy.youmonst.movement < NORMAL_SPEED); /* hero can't move */ + } while (u.umovement < NORMAL_SPEED); /* hero can't move */ /******************************************/ /* once-per-hero-took-time things go here */ diff --git a/src/mondata.c b/src/mondata.c index 297a2fbfd..1892cf46f 100644 --- a/src/mondata.c +++ b/src/mondata.c @@ -10,14 +10,15 @@ /* set up an individual monster's base type (initial creation, shapechange) */ void -set_mon_data(struct monst* mon, struct permonst* ptr) +set_mon_data(struct monst *mon, struct permonst *ptr) { int new_speed, old_speed = mon->data ? mon->data->mmove : 0; + short *movement_p = (mon == &gy.youmonst) ? &u.umovement : &mon->movement; mon->data = ptr; mon->mnum = (short) monsndx(ptr); - if (mon->movement) { /* used to adjust poly'd hero as well as monsters */ + if (*movement_p) { /* used to adjust poly'd hero as well as monsters */ new_speed = ptr->mmove; /* prorate unused movement if new form is slower so that it doesn't get extra moves leftover from previous form; @@ -28,9 +29,9 @@ set_mon_data(struct monst* mon, struct permonst* ptr) mon->movement = new_speed * mon->movement / old_speed; * so add a redundant test to suppress that. */ - mon->movement *= new_speed; + *movement_p *= new_speed; if (old_speed > 0) /* old > new and new >= 0, so always True */ - mon->movement /= old_speed; + *movement_p /= old_speed; } } return;