Skip to content

Commit 68ccdb9

Browse files
Merge remote-tracking branch 'upstream/master'
2 parents 3f70c0f + 19e538f commit 68ccdb9

File tree

20 files changed

+92
-75
lines changed

20 files changed

+92
-75
lines changed

aimake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ handling (to place the files in the right place).
299299

300300
=item LEXFLAGS
301301

302-
Command-line arguments to pass to C<lex>. The default is to pass C<--warn>,
303-
which tells C<flex> (the default C<lex> implementation) to produce warnings.
302+
Command-line arguments to pass to C<lex>. The default is an empty set of
303+
options.
304304

305305
=back
306306

@@ -10820,7 +10820,7 @@ EOF
1082010820

1082110821
default_lexflags => {
1082210822
output => 'optionset:LEXFLAGS',
10823-
outdepends => ['optstring:--warn'],
10823+
outdepends => [],
1082410824
verb => 'determined',
1082510825
low_message_priority => 1,
1082610826
command_line_override => 'LEXFLAGS',

libnethack/dat/history

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
NetHack History file for release 4.3.0-beta3
2-
This file was last updated by Alex Smith, 2015-04-01
2+
This file was last updated by Alex Smith, 2017-09-01
33

44
Behold, mortal, the origins of NetHack...
55

@@ -270,8 +270,7 @@ The NetHack 4 distribution also contains contributions from:
270270
Edoardo Spadolini Nathan Eady Tim Visher
271271
Eric S. Raymond Nephi Trevor Cook
272272
Fredrik Ljungdahl Pasi Kallinnen Tung Nguyen
273-
GreyKnight Patric Müller Wan-ichi
274-
Grunt Paul Pliska Zmy
275-
Haruko Numata Paula Breton Zsbán Ambrus
276-
Hojita Discordia quuxplusone
277-
273+
GreyKnight Patric Müller Vincent Ho
274+
Grunt Paul Pliska Wan-ichi
275+
Haruko Numata Paula Breton Zmy
276+
Hojita Discordia quuxplusone Zsbán Ambrus

libnethack/include/extern.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2015-07-22 */
2+
/* Last modified by Alex Smith, 2017-06-29 */
33
/* Copyright (c) Steve Creps, 1988. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -646,7 +646,8 @@ extern void lookaround(enum u_interaction_mode);
646646
extern int monster_nearby(void);
647647
extern void losehp(int, const char *);
648648
extern int weight_cap(void);
649-
extern int inv_weight(void);
649+
extern int inv_weight_over_cap(void);
650+
extern int inv_weight_total(void);
650651
extern int near_capacity(void);
651652
extern int calc_capacity(int);
652653
extern int max_capacity(void);

libnethack/include/permonst.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2014-04-05 */
2+
/* Last modified by Alex Smith, 2017-07-15 */
33
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -81,7 +81,7 @@ extern const struct permonst mons[]; /* the master list of monster types */
8181
# define FAST_SPEED 15
8282
# define VERY_FAST 24
8383

84-
# define NON_PM PM_PLAYERMON /* "not a monster" */
84+
# define NON_PM (-1) /* "not a monster" */
8585
# define LOW_PM (NON_PM+1) /* first monster in mons[] */
8686
# define SPECIAL_PM PM_LONG_WORM_TAIL /* [normal] < ~ < [special] */
8787
/* mons[SPECIAL_PM] through mons[NUMMONS-1], inclusive, are never

libnethack/src/cmd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2015-10-11 */
2+
/* Last modified by Alex Smith, 2017-07-15 */
33
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -868,7 +868,7 @@ doattributes(const struct nh_cmd_arg *arg)
868868
add_menutext(&menu, buf);
869869

870870
wc = weight_cap();
871-
buf = msgprintf("%-10s: %ld (", "burden", wc + inv_weight());
871+
buf = msgprintf("%-10s: %d (", "burden", inv_weight_total());
872872

873873
switch (calc_capacity(wc / 4)) {
874874
case UNENCUMBERED:

libnethack/src/do.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2015-07-20 */
2+
/* Last modified by Alex Smith, 2017-06-29 */
33
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -827,7 +827,7 @@ doup(void)
827827
return 1;
828828
}
829829
if (near_capacity() > SLT_ENCUMBER) {
830-
/* No levitation check; inv_weight() already allows for it */
830+
/* No levitation check; the weight check already allows for it */
831831
pline("Your load is too heavy to climb the %s.",
832832
level->locations[u.ux][u.uy].typ == STAIRS ? "stairs" : "ladder");
833833
return 1;

libnethack/src/dokick.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2015-07-12 */
2+
/* Last modified by Alex Smith, 2017-06-29 */
33
/* Copyright (c) Izchak Miller, Mike Stephenson, Steve Linhart, 1989. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -200,7 +200,7 @@ kick_monster(xchar x, xchar y, schar dx, schar dy)
200200
return attack_status;
201201
}
202202

203-
i = -inv_weight();
203+
i = -inv_weight_over_cap();
204204
j = weight_cap();
205205

206206
if (i < (j * 3) / 10) {
@@ -800,7 +800,7 @@ dokick(const struct nh_cmd_arg *arg)
800800
if (Is_airlevel(&u.uz) || Levitation) {
801801
int range;
802802

803-
range = ((int)youmonst.data->cwt + (weight_cap() + inv_weight()));
803+
range = ((int)youmonst.data->cwt + inv_weight_total());
804804
if (range < 1)
805805
range = 1; /* divide by zero avoidance */
806806
range = (3 * (int)mdat->cwt) / range;

libnethack/src/dothrow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2015-05-19 */
2+
/* Last modified by Alex Smith, 2017-06-29 */
33
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -474,7 +474,7 @@ hurtle_step(void *arg, int x, int y)
474474
}
475475
if ((u.ux - x) && (u.uy - y) && bad_rock(youmonst.data, u.ux, y) &&
476476
bad_rock(youmonst.data, x, u.uy)) {
477-
boolean too_much = (invent && (inv_weight() + weight_cap() > 600));
477+
boolean too_much = (invent && (inv_weight_total() > 600));
478478

479479
/* Move at a diagonal. */
480480
if (bigmonst(youmonst.data) || too_much) {

libnethack/src/files.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/* 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 Alex Smith, 2015-07-11 */
2+
/* Last modified by Alex Smith, 2017-09-01 */
33
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
44
/* NetHack may be freely redistributed. See license for details. */
55

66
#if defined(AIMAKE_BUILDOS_MSWin32)
77
# define WIN32_LEAN_AND_MEAN
8-
# include <Windows.h> /* must be before compilers.h */
8+
# include <windows.h> /* must be before compilers.h */
99

1010
# if !defined(S_IRUSR)
1111
# define S_IRUSR _S_IREAD

libnethack/src/hack.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 */
33
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -859,7 +859,7 @@ test_move(int ux, int uy, int dx, int dy, int dz, int mode,
859859
pline("Your body is too large to fit through.");
860860
return FALSE;
861861
}
862-
if (invent && (inv_weight() + weight_cap() > 600)) {
862+
if (invent && (inv_weight_total() > 600)) {
863863
if (mode == DO_MOVE)
864864
pline("You are carrying too much to get through.");
865865
return FALSE;
@@ -905,7 +905,7 @@ test_move(int ux, int uy, int dx, int dy, int dz, int mode,
905905
/* Can we be blocked by a boulder? */
906906
if (!throws_rocks(youmonst.data) &&
907907
!(verysmall(youmonst.data) && !u.usteed) &&
908-
!((!invent || inv_weight() <= -850) && !u.usteed)) {
908+
!((!invent || inv_weight_over_cap() <= -850) && !u.usteed)) {
909909
/* We assume we can move boulders when we're at a distance from them.
910910
When it comes to actually do the move, resolve_uim() may replace the
911911
move with a #pushboulder command. If it doesn't, the move fails
@@ -3099,12 +3099,8 @@ weight_cap(void)
30993099
return (int)carrcap;
31003100
}
31013101

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. */
31063102
int
3107-
inv_weight(void)
3103+
inv_weight_total(void)
31083104
{
31093105
struct obj *otmp = invent;
31103106
int wt = 0;
@@ -3116,18 +3112,27 @@ inv_weight(void)
31163112
wt += otmp->owt;
31173113
otmp = otmp->nobj;
31183114
}
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();
31213124
}
31223125

3126+
31233127
/*
31243128
* Returns 0 if below normal capacity, or the number of "capacity units"
31253129
* over the normal capacity the player is loaded. Max is 5.
31263130
*/
31273131
int
31283132
calc_capacity(int xtra_wt)
31293133
{
3130-
int cap, wt = inv_weight() + xtra_wt;
3134+
int wc = weight_cap();
3135+
int cap, wt = inv_weight_total() + xtra_wt - wc;
31313136

31323137
if (wt <= 0)
31333138
return UNENCUMBERED;
@@ -3146,9 +3151,9 @@ near_capacity(void)
31463151
int
31473152
max_capacity(void)
31483153
{
3149-
int wt = inv_weight();
3154+
int wt = inv_weight_over_cap();
31503155

3151-
return wt - (2 * wc);
3156+
return wt - (2 * weight_cap());
31523157
}
31533158

31543159
boolean

libnethack/src/memfile.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2015-11-11 */
2+
/* Last modified by Alex Smith, 2017-06-28 */
33
/* Copyright (c) Daniel Thaler, 2011. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -472,7 +472,7 @@ mdiffcmd_width(const struct memfile *mf, struct mdiff_command_instance *mdci,
472472
static void
473473
mdiffwritecmd(struct memfile *mf, struct mdiff_command_instance *mdci)
474474
{
475-
int widenings, usedbits, usedbytes, i;
475+
int widenings, usedbits, usedbytes, splitbytes, i;
476476

477477
/* Count the number of widenings we need. */
478478
usedbytes = mdiffcmd_width(mf, mdci, &widenings);
@@ -490,27 +490,42 @@ mdiffwritecmd(struct memfile *mf, struct mdiff_command_instance *mdci)
490490
usedbits += mdiff_command_sizes[mdci->command].arg2;
491491
encoding |= mdci->arg2;
492492

493-
/* Add the encoding of arg1. */
493+
/* Add the encoding of arg1.
494+
495+
We have to be careful here: the MRU prefix + arg2 + arg1 might come to
496+
more than 8 bytes (e.g. in the case of an eof_crc32 command with a very
497+
large copy count). As such, we split the largest possible whole number
498+
of bytes off from the end of arg1. */
494499
usedbits = usedbytes * 8 - usedbits;
495-
encoding <<= usedbits;
500+
splitbytes = usedbits / 8;
501+
encoding <<= usedbits % 8;
496502
unsigned long long arg1_2c = mdci->arg1 & ((1ULL << usedbits) - 1);
497-
encoding |= arg1_2c;
503+
encoding |= arg1_2c >> (splitbytes * 8);
498504

499-
i = usedbytes;
505+
i = usedbytes - splitbytes;
500506
while (i--)
501507
mdiffwrite8(mf, encoding >> (i * 8));
508+
i = splitbytes;
509+
while (i--)
510+
mdiffwrite8(mf, arg1_2c >> (i * 8));
502511

503512
if (debuglog) {
504513
fprintf(debuglog, "%s %" PRIdLEAST64 " %" PRIuLEAST64 " (",
505514
mdiff_command_sizes[mdci->command].name,
506515
(int_least64_t)mdci->arg1, (uint_least64_t)mdci->arg2);
507516

508-
i = usedbytes*8;
517+
i = (usedbytes - splitbytes) * 8;
509518
while (i--) {
510519
fprintf(debuglog, "%d", (int)(1 & (encoding >> i)));
511520
if (i && !(i%8))
512521
fprintf(debuglog, " ");
513522
}
523+
i = splitbytes * 8;
524+
while (i--) {
525+
fprintf(debuglog, "%d", (int)(1 & (arg1_2c >> i)));
526+
if (i && !(i%8))
527+
fprintf(debuglog, " ");
528+
}
514529
}
515530

516531
/* Record that this command appears in the diff. */

libnethack/src/timeout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2015-07-22 */
2+
/* Last modified by Alex Smith, 2017-06-29 */
33
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -320,7 +320,7 @@ nh_timeout(void)
320320
/* The more you are carrying the more likely you are to
321321
make noise when you fumble. Adjustments to this number
322322
must be thoroughly play tested. */
323-
if ((inv_weight() > -500)) {
323+
if ((inv_weight_over_cap() > -500)) {
324324
pline("You make a lot of noise!");
325325
wake_nearby(FALSE);
326326
}

libnethack/src/trap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2015-10-11 */
2+
/* Last modified by Alex Smith, 2017-06-29 */
33
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -3263,7 +3263,7 @@ try_disarm(struct trap *ttmp, boolean force_failure, schar dx, schar dy)
32633263
/* duplicate tight-space checks from test_move */
32643264
if (dx && dy && bad_rock(youmonst.data, u.ux, ttmp->ty) &&
32653265
bad_rock(youmonst.data, ttmp->tx, u.uy)) {
3266-
if ((invent && (inv_weight() + weight_cap() > 600)) ||
3266+
if ((invent && (inv_weight_total() > 600)) ||
32673267
bigmonst(youmonst.data)) {
32683268
/* don't allow untrap if they can't get thru to it */
32693269
pline("You are unable to reach the %s!", trapexplain[ttype - 1]);
@@ -3538,7 +3538,7 @@ help_monster_out(struct monst *mtmp, struct trap *ttmp)
35383538
}
35393539

35403540
/* is the monster too heavy? */
3541-
wt = inv_weight() + mtmp->data->cwt;
3541+
wt = inv_weight_over_cap() + mtmp->data->cwt;
35423542
if (!try_lift(mtmp, ttmp, wt, FALSE))
35433543
return 1;
35443544

libnethack/src/u_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2015-06-15 */
2+
/* Last modified by Alex Smith, 2017-06-29 */
33
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
44
/* NetHack may be freely redistributed. See license for details. */
55

@@ -851,7 +851,7 @@ u_init_inv_skills(void)
851851
}
852852

853853
/* make sure you can carry all you have - especially for Tourists */
854-
while (inv_weight() > 0) {
854+
while (inv_weight_over_cap() > 0) {
855855
if (adjattrib(A_STR, 1, TRUE))
856856
continue;
857857
if (adjattrib(A_CON, 1, TRUE))

libnethack/util/makedefs.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2015-03-21 */
2+
/* Last modified by Alex Smith, 2017-07-15 */
33
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
44
/* Copyright (c) M. Stephenson, 1990, 1991. */
55
/* Copyright (c) Dean Luick, 1990. */
@@ -985,9 +985,6 @@ do_permonst(const char *outfile)
985985
fprintf(ofp, "%s", Dont_Edit_Code);
986986
fprintf(ofp, "#ifndef PM_H\n#define PM_H\n");
987987

988-
if (strcmp(mons[0].mname, "playermon") != 0)
989-
fprintf(ofp, "\n#define\tPM_PLAYERMON\t(-1)");
990-
991988
for (i = 0; mons[i].mlet; i++) {
992989
fprintf(ofp, "\n#define\tPM_");
993990
if (mons[i].mlet == S_HUMAN && !strncmp(mons[i].mname, "were", 4))

libnethack_common/include/netconnect.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* 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 Alex Smith, 2014-10-05 */
2+
/* Last modified by Alex Smith, 2017-09-01 */
33
/* Copyright (c) Daniel Thaler, 2012. */
44
/* Copyright (c) 2014 Alex Smith. */
55
/* This network connection library may be freely redistributed under the terms of
@@ -30,9 +30,9 @@
3030
# include <sys/select.h>
3131
# include <sys/time.h>
3232
# else
33-
# include <Winsock2.h>
34-
# include <Ws2def.h>
35-
# include <Ws2tcpip.h>
33+
# include <winsock2.h>
34+
# include <ws2def.h>
35+
# include <ws2tcpip.h>
3636

3737
# define snprintf(buf, len, fmt, ...) \
3838
_snprintf_s(buf, len, len-1, fmt, __VA_ARGS__)

0 commit comments

Comments
 (0)