1
1
/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/
2
- /* Last modified by Fredrik Ljungdahl, 2015-10-02 */
2
+ /* Last modified by Alex Smith, 2017-06-29 */
3
3
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
4
4
/* NetHack may be freely redistributed. See license for details. */
5
5
@@ -859,7 +859,7 @@ test_move(int ux, int uy, int dx, int dy, int dz, int mode,
859
859
pline ("Your body is too large to fit through." );
860
860
return FALSE;
861
861
}
862
- if (invent && (inv_weight () + weight_cap () > 600 )) {
862
+ if (invent && (inv_weight_total () > 600 )) {
863
863
if (mode == DO_MOVE )
864
864
pline ("You are carrying too much to get through." );
865
865
return FALSE;
@@ -905,7 +905,7 @@ test_move(int ux, int uy, int dx, int dy, int dz, int mode,
905
905
/* Can we be blocked by a boulder? */
906
906
if (!throws_rocks (youmonst .data ) &&
907
907
!(verysmall (youmonst .data ) && !u .usteed ) &&
908
- !((!invent || inv_weight () <= -850 ) && !u .usteed )) {
908
+ !((!invent || inv_weight_over_cap () <= -850 ) && !u .usteed )) {
909
909
/* We assume we can move boulders when we're at a distance from them.
910
910
When it comes to actually do the move, resolve_uim() may replace the
911
911
move with a #pushboulder command. If it doesn't, the move fails
@@ -3099,12 +3099,8 @@ weight_cap(void)
3099
3099
return (int )carrcap ;
3100
3100
}
3101
3101
3102
- static int wc ; /* current weight_cap(); valid after call to inv_weight() */
3103
-
3104
- /* returns how far beyond the normal capacity the player is currently. */
3105
- /* inv_weight() is negative if the player is below normal capacity. */
3106
3102
int
3107
- inv_weight (void )
3103
+ inv_weight_total (void )
3108
3104
{
3109
3105
struct obj * otmp = invent ;
3110
3106
int wt = 0 ;
@@ -3116,18 +3112,27 @@ inv_weight(void)
3116
3112
wt += otmp -> owt ;
3117
3113
otmp = otmp -> nobj ;
3118
3114
}
3119
- wc = weight_cap ();
3120
- return wt - wc ;
3115
+ return wt ;
3116
+ }
3117
+
3118
+ /* Returns how far beyond the normal capacity the player is currently. Negative
3119
+ if the player is below normal capacity. */
3120
+ int
3121
+ inv_weight_over_cap (void )
3122
+ {
3123
+ return inv_weight_total () - weight_cap ();
3121
3124
}
3122
3125
3126
+
3123
3127
/*
3124
3128
* Returns 0 if below normal capacity, or the number of "capacity units"
3125
3129
* over the normal capacity the player is loaded. Max is 5.
3126
3130
*/
3127
3131
int
3128
3132
calc_capacity (int xtra_wt )
3129
3133
{
3130
- int cap , wt = inv_weight () + xtra_wt ;
3134
+ int wc = weight_cap ();
3135
+ int cap , wt = inv_weight_total () + xtra_wt - wc ;
3131
3136
3132
3137
if (wt <= 0 )
3133
3138
return UNENCUMBERED ;
@@ -3146,9 +3151,9 @@ near_capacity(void)
3146
3151
int
3147
3152
max_capacity (void )
3148
3153
{
3149
- int wt = inv_weight ();
3154
+ int wt = inv_weight_over_cap ();
3150
3155
3151
- return wt - (2 * wc );
3156
+ return wt - (2 * weight_cap () );
3152
3157
}
3153
3158
3154
3159
boolean
0 commit comments