pull request #1024 - keep hero movement points
Pull request from saltwaterterrapin: record current move's pending movement points in save file. They were being thrown away during save and hero given 12 at time of restore. Hero had to have had at least 12 in order for player to issue the S command, but might have had more than that if able to move faster than normal speed. This implements it differently from the suggested commit. Add new field umovement to 'struct u' instead of using youmonst.movement and needing to save and restore that separately. Invalidates existing save and bones files. Closes #1024
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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' */
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user