Commit Graph

2424 Commits

Author SHA1 Message Date
nhmall
046ff4129b bump editlevel 2021-02-10 19:54:10 -05:00
nhmall
e512e98966 Merge branch 'copperwater-pr460' into NetHack-3.7 2021-02-10 19:53:07 -05:00
Pasi Kallinen
cc25f40d69 Add lua tests for config file parsing
Bare-bones for now, more tests needed.
2021-02-10 19:22:16 +02:00
Pasi Kallinen
9576154690 Add in_lua flag
In preparation of making config errors available to lua scripts,
instead outputting them via pline.
2021-02-10 17:06:12 +02:00
PatR
71bb01c328 curses persistent inventory window tweak
Under curses interface, provide a way to get a little more space
for perm_invent without turning off windowborders entirely.

Possible 'windowborders' values:
 0 = no borders, max screen space available for useful info
 1 = full borders, two lines and two columns wasted for each window
 2 = contingent borders, show if screen is big enough, else hide
New:
 3 = as 1 except no borders for perm_invent window
 4 = as 2 except never borders for perm_invent window

3 and 4 let the map, message, and status windows have borders while
providing two extra lines and two extra columns on each line for
persistent inventory.  It's not much but better than nothing when
borders are enabled.
2021-02-08 16:34:29 -08:00
nhmall
449786dd93 Merge branch 'engraving-occupation' of https://github.com/copperwater/NetHack into copperwater-pr460 2021-02-08 08:39:50 -05:00
copperwater
9c6a5fc423 Make engraving an occupation
Instead of inexplicably paralyzing the player for the duration of their
engraving. Many a character has died by trying to engrave something and
then sitting there diligently writing it while monsters surround and
attack them. (This was especially prominent back in the 3.4.3 era when
repeated Elbereths were viable, but it still occurs today with e.g.
using a hard stone to engrave Elbereth). There were also some other
oddities - for instance, if something teleported the player away while
they were engraving, they would continue to "engrave" (be paralyzed) on
their new location, but would not produce any text there; the full
engraving would be placed on their initial position.

In this commit, I have converted engraving to use the occupation
framework, which treats it as an interruptible activity. This
necessitated some logical restructuring, mostly involving the engraving
being written out in chunks as the player spends more uninterrupted time
on it.

I've tried to keep this free of regressions except for those inherent to
the occupation system.

What has NOT changed:
- The rate of engraving is still 10 characters per turn, or 1 character
  using slow methods.
- The formulas for determining how much a bladed weapon or marker can
  engrave before getting exhausted are kept. Though this is a bit
  convoluted, and if it's not considered important to preserve the
  existing behavior, I would recommend simplifying it by decreasing the
  maximum engraving length for weapons by 1 so that each point of
  enchantment simply gets you 2 characters' worth of engraving (e.g. a
  -2 weapon will only engrave 1 or 2 characters before dulling to -3,
  rather than giving it a third "grace character".
- The input buffer is still modified based on confusion/blindness/etc
  only at the time when the player inputs it (if they gain a
  debilitating status while engraving, it will not affect the text). My
  personal preference is to make the text affected in scenarios like
  that, but it's not strictly necessary to do here, so I didn't.
- Wand messages such as "The floor is riddled by bullet holes", and
  blinding from engraving lightning, still appear before the hero starts
  to take any time engraving. As noted above, getting blinded by the
  wand still has no effect on accurately engraving the text, unless the
  hero was already blind or impaired.

What has changed:
- Moving off the engraving or losing the object being engraved with
  causes the player to stop engraving.
- Wands can still engrave an arbitrary amount of text using a single
  charge, but if the hero is interrupted and decides to start engraving
  again, they will consume a second charge.

As it adds a new field to g.context, this is a save-breaking change.
2021-02-08 00:11:07 -05:00
Dean Luick
5eaf028c0f Re-fix altar compiler warning
Implement a better fix for commit 2f4f7d22d ("Fix align type
mixup wth align mask") which was reverted in commit 4e35e8b5a
("Revert "Fix align type mixup wth align mask"").

In the present code, the field align in both struct altar and
struct monster is not an aligntyp, but an align mask with extra flags.
Change the type to match its actual use and improve the naming.

Consolidate duplicated code into a single routine.

Change the return type of induced_align() to be unsigned to match
amask usage.

Change the special level align mask values to be separate from
the normal align mask values.
2021-02-07 22:25:25 -06:00
nhmall
4e35e8b5a6 Revert "Fix align type mixup wth align mask"
This reverts commit 2f4f7d22d3
for now while the matter is investigated further.

Also closes #459
2021-02-06 14:54:54 -05:00
Pasi Kallinen
d817564a6a Lua: set and get config options
Still needs more work, especially the error handling.
2021-02-06 19:02:25 +02:00
nhmall
83246a9634 remove debugging statement from warnings.h 2021-02-03 13:25:50 -05:00
nhmall
8b21a170fb clear a number of Qt build warnings on linux related to compiler flags
option ‘-Wimplicit’ is valid for C/ObjC but not for C++
option ‘-Wimplicit-function-declaration’ is valid for C/ObjC but not for C++
option ‘-Wimplicit-int’ is valid for C/ObjC but not for C++
option ‘-Wmissing-prototypes’ is valid for C/ObjC but not for C++
option ‘-Wmissing-parameter-type’ is valid for C/ObjC but not for C++
option ‘-Wold-style-definition’ is valid for C/ObjC but not for C++
option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
2021-02-03 13:18:43 -05:00
nhmall
7900632b50 Qt c++ function name shadow warnings
We have a struct called mkroom and a function called mkroom()
so c++ complains about the mkroom() function hiding the
initializer for the struct.

Similarly, we have a struct called attack and a function
called attack().

There may be a more elegant way of eliminating those two
warnings, but renaming mkroom() to do_mkroom() and
attack() to do_attack() was straightforward enough.
2021-02-03 10:55:07 -05:00
nhmall
6f3337b75a more macOS whitelisting
X11, Qt, and util

also ensure the functional warnings.h macro definitions are used
with c++ clang compiler
2021-02-02 20:11:43 -05:00
nhmall
5b1d668c44 enable -Wformat-nonliteral for linux and equivalent for windows compilers
Whitelist all the verified existing triggers:
makedefs.c: In function ‘name_file’
attrib.c: one compiler balks at a ? b : c for fmtstring
cmd.c: In function ‘extcmd_via_menu’
cmd.c: In function ‘wiz_levltyp_legend’
do.c: In function ‘goto_level’
do_name.c: In function ‘coord_desc’
dungeon.c: In function ‘overview_stats’
eat.c:  one compiler balks at a ? b : c for fmtstring
end.c:  one compiler balks at a ? b : c for fmtstring
engrave.c: In function ‘engr_stats’
hack:c one compiler balks at a ? b : c for fmtstring
hacklib.c: one compiler balks at a ? b : c for fmtstring
insight.c: one compiler balks at a ? b : c for fmtstring
invent.c: In function ‘let_to_name’
light.c: In function ‘light_stats’
mhitm.c: In function ‘missmm’
options.c: In function ‘handler_symset’
options.c: In function ‘basic_menu_colors’
options.c: In function ‘optfn_o_autopickup_exceptions’
options.c: In function ‘optfn_o_menu_colors’
options.c: In function ‘optfn_o_message_types’
options.c: In function ‘optfn_o_status_cond’
options.c: In function ‘optfn_o_status_hilites’
options.c: In function ‘doset’
options.c: In function ‘doset_add_menu’
options.c: In function ‘show_menu_controls’
options.c: In function ‘handle_add_list_remove’
pager.c: In function ‘do_supplemental_info’
pager.c: In function ‘dohelp’
region.c: In function ‘region_stats’
rumors.c: sscanf usage
sounds.c: In function ‘domonnoise’
spell.c: In function ‘dospellmenu’
timeout.c: In function ‘timer_stats’
topten.c: In function ‘outentry’, fscanf, sscanf, fprintf usage
windows.c: In function ‘genl_status_update’
zap.c: one compiler balks at a ? b : c for fmtstring
win/curses/cursstat.c: In function ‘curses_status_update’
win/tty/wintty.c: In function ‘tty_status_update’
win/win32/mswproc.c: In function ‘mswin_status_update’
2021-02-02 19:03:12 -05:00
nhmall
a0116e8734 yet-another typo 2021-02-01 13:46:54 -05:00
nhmall
800999c477 follow-up bit
missed macro and a typo
2021-02-01 13:44:09 -05:00
nhmall
e25b16e844 more warnings.h - macOS issue
It turns out that macOS barked when a POP was issued without
a prior PUSH, so since the DISABLE_WARNING_CONDEXPR_IS_CONSTANT
expanded to an empty macro on that platform.

Include a corresponding
RESTORE_WARNING_CONDEXPR_IS_CONSTANT macro for use with that
particular warning.
2021-02-01 13:37:04 -05:00
nhmall
a6631e3bb0 suppress a particular warning for an individual function; useful for non-gcc
Microsoft and other non-GNU compilers don't recognize gcc tricks
like  /*NOTREACHED*/ to suppress individual warnings. clang recognizes most
of them because it tries to be gcc-compatible. Because of that, a lot of
potentially useful warnings have had to be completely suppressed in the
past in all source files when using the non-gcc compatible compilers.

Now that the code is C99, take advantage of a way to suppress warnings for
individual functions, a big step up from suppressing the warnings
altogether.

Unfortunately, it does require a bit of ugliness caused by the
insertion of some macros in a few spots, but I'm not aware of
a cleaner alternative that still allows warnings to be enabled
in general, while suppressing a warning for known white-listed
instances.

Prior to the warning-tiggering function, place whichever one of
the following is needed to suppress the warning being encountered:

DISABLE_WARNING_UNREACHABLE_CODE
DISABLE_WARNING_CONDEXPR_IS_CONSTANT

After the warning-triggering function, place this:

RESTORE_WARNINGS

Under the hood, the compiler-appropriate warning-disabling
mechanics involve the use of C99 _Pragma, which can be used
in macros.

For unrecognized or inappropriate compilers, or if
DISABLE_WARNING_PRAGMAS is defined, the macros expand
to nothing.
2021-02-01 12:54:19 -05:00
nhmall
0835ae1542 Merge branch 'copperwater-pr455-2' into NetHack-3.7 2021-02-01 09:40:11 -05:00
PatR
0b1f5ea45e outdated vs Unix 'make depend'
After the most recent round of moving old stuff to 'outdated',
src/windows.c contained two references to non-existent files.
That broke 'make depend'.  Updating it to turn those two into
comments seems risky because someone might add an include for
some new interface later in the file.  So comment them out in
the source instead.  Also, redo previous 'make depend' update
from about three weeks ago to do the same thing.
2021-01-31 13:05:32 -08:00
nhmall
e53fcf0940 FDECL and NDECL 2021-01-31 14:15:08 -05:00
nhmall
41fc278cfb CFDECLSPEC -> QSORTCALLBACK
also remove one inappropriate use of CFDECLSPEC
2021-01-31 13:58:19 -05:00
nhmall
b851b28cbe FDECL and NDECL in sys/vms 2021-01-31 12:49:22 -05:00
nhmall
fadc5f8a5e remnant FDECL 2021-01-31 09:20:25 -05:00
nhmall
4a6eb00c84 relocate some gem and Gnome files to outdated folder tree 2021-01-31 08:51:35 -05:00
Bart House
a54a8c6854 Remove awful kludges dealing with command counts. 2021-01-30 19:06:27 -08:00
nhmall
a0874c414d Merge branch 'extract-from-minvent' of https://github.com/copperwater/NetHack into copperwater-pr455-2 2021-01-30 15:24:07 -05:00
Pasi Kallinen
933c7f215c Move the other options to alphabetical order 2021-01-30 19:07:58 +02:00
Pasi Kallinen
10cd5af500 Move other options into the options array 2021-01-30 18:43:21 +02:00
copperwater
ee7664684a Unify code for extracting an object from a monster's inventory
The code for doing this (basically an obj_extract_self() call plus
handling if the object was worn or wielded) was duplicated all over, and
inconsistent - for instance, though all of them updated the monster's
misc_worn_check to indicate it was no longer wearing something in
whatever slot, only one call also set the bit that flags the monster to
consider putting on other gear afterwards.

Under a new function, extract_from_minvent, all this extra handling is
checked in one function, which can simply replace the obj_extract_self
call.

A few callers (such as stealing) have some common code *after* the
object is extracted and some other things happen such as message
printing, such as calling mselftouch if the object was worn
gloves. extract_from_minvent does not handle these cases.
2021-01-29 19:19:03 -05:00
Dean Luick
2f4f7d22d3 Fix align type mixup wth align mask
Fix two cases of missed conversion of an alignment to an align mask.

Change induced_align()'s return type to unsigned int since it returns
an align mask (unsigned), not an align type (signed).
2021-01-29 09:31:08 -06:00
Dean Luick
cf3ad240ac Fix X11 warnings 2021-01-28 21:12:06 -06:00
nhmall
f625a8c553 remove more FDECL, NDECL macro usage 2021-01-28 07:55:34 -05:00
nhmall
f963c5aca7 switch source tree from k&r to c99 2021-01-26 21:06:16 -05:00
PatR
acbf423734 pull request #443 - X11 color status highlighting
for 'fancy status'.  This is from an emailed diff rather than
directly from git, and the git code has a bunch of commits,
so this may or may not match the latest.  It needs formatting
cleanup and triggers a couple of warnings on OSX.  Fix to follow.

Status highlight colors use the same names as menu coloring
but this uses different X11 colors for the two sets.  That
will have to be changed so that yellow either means yellow all
the time or goldenrod all the time instead of sometimes yellow
and sometimes goldenrod.

Adopts #443
2021-01-26 13:39:50 -08:00
nhmall
ea12c70e46 X11 warning on macOS 2021-01-26 10:27:51 -05:00
PatR
8affbf5a24 options parsing madness
I should have reenabled curses before committing an earlier change;
it broke compile.

Make all optfn_FOO() be static in options.c;
fix newly added prototype for optfn_cursesgraphics();
fix conditionals for optfn_palette(), both prototype and function.

Also, add missing prototype for a sound routine.
2021-01-23 15:42:00 -08:00
PatR
ab74ed2c20 SELECTSAVED handling
By default, enable the SELECTSAVED option for everyone instead
of just for Windows or Qt.  And make Qt obey the 'selectsaved'
run-time option.

It can be disabled in config.h if necessary.
2021-01-23 15:02:11 -08:00
nhmall
093c53bead fix missing prototype warning for Qt SELECTSAVED
For whatever reason, Qt relies on late #define of SELECTSAVED
inside files.c.

The prototype in extern.h is therefore not picked up with
as a result of #include "hack.h"

Options were:
1. remove the conditional #if defined(SELECTSAVED) around the
   prototype in extern.h entirely
2. Move the forced #define of SELECTSAVED above the #include "hack.h"
3. Alter the conditional in extern.h to also include the condition for
   the forced #define of SELECTSAVED inside files.c

This goes with option #3.
2021-01-23 09:37:47 -05:00
Dean Luick
16ba1a583a Update nhUse
There is no longer any compiler reason to disable nhUse - remove
nhUse's conditional definition.

Update the nhUse definition to "use" a variable without it needing
to be an integer.

This change removes some gcc compiler unused variable and parameter
warnings.
2021-01-20 22:18:34 -06:00
PatR
cb407eeb61 yet more obj->spe documentation (lamps, candles)
Another mystery.  Candles and oil lamps have obj->spe set to 1
but that isn't used by begin_burn() and such so I don't know why.

Magic lamp has spe set to 1 to indicate that there is a djinni
inside, but letting the djinni out converts it into an oil lamp.
I don't know if there is any case where it might actually be 0.
(Wishing yields an oil lamp rather than an empty magic lamp so
that isn't it.  Cancellation magic doesn't affect it either.)
2021-01-19 15:07:58 -08:00
Dean Luick
8143d55d76 Create and use a snprintf wrapper in the core code
Use a wrapper around snprintf to consilidate all use, add
error checking, and remove gcc 9 warnings about not checking
the result.

Replace the prevous use of snprintf added to weapon.c with the
new scheme.

Update a second spot that has a gcc sprintf warning.  While
there, simplify the code.
2021-01-15 11:33:47 -06:00
PatR
85d3aa4a97 obj->spe usage again
uball->spe used to be used during restore way back in 2.3e.
There hasn't been any any point in setting it when starting
punishment and clearing it when ending punishment for decades
so get rid of that.

Nearly as ancient--but not quite--back in 3.10 patchlevel N,
obj->spe was set to -1 when the Amulet of Yendor was saved in
a bones file.  That was to flag it as fake, before the cheap
plastic imitation got added as a separate object.

So obj->spe isn't "special for uball and amulet" any more.
2021-01-08 15:45:04 -08:00
PatR
9dee1fb521 \#include "fnamesiz.h"
The inclusion shouldn't really come before *conf.h because the
things it sets up could depend on those.  This is better, but
having Amiga 90% dead and 10% comatose seems to be more trouble
that it's worth.
2021-01-08 14:59:36 -08:00
PatR
129ff12245 'make depend' fix
The gone but still referenced state of amiconf.h broke 'make depend'.
Fixing that turns it into a comment in the generated dependencies
but that ran into a problem with it being followed by fnamesiz.h
instead of being last in the list containing it.  So in addition to
the depend fix, move #include "fnamesiz.h" from config.h to global.h
in order to have it come before amiconf.h.
2021-01-08 13:33:27 -08:00
PatR
d625fca828 obj.h - expand documentation of obj->spe uses
Started out adding spe==2 for eggs but ended up changing other
things too.

FIXME?  The line "special for uball and amulet" baffles me:

    uball->spe is set to 1 during punishment (with an ambiguous
comment "special ball (see save)"), and back to 0 afterwards, but
otherwise seems to be unused.

    "and amulet" is ambiguous; it should either be "and the Amulet"
or "and amulets".  I assume it probably referred to the former but
it doesn't seem to be used for either kind as far as I can tell.
2021-01-07 14:02:52 -08:00
copperwater
0b638592a4 Refactor getobj() to use callbacks on candidate objects
This replaces the arcane system previously used by getobj where the
caller would pass in a "string" whose characters were object class
numbers, with the first up to four characters being special constants
that effectively acted as flags and had to be in a certain order.
Because there are many places where getobj must behave more granularly
than just object class filtering, this was supplemented by over a
hundred lines enumerating all these special cases and "ugly checks", as
well as other ugly code spread around in getobj callers that formatted
the "string".

Now, getobj callers pass in a callback which will return one of five
possible values for any given object in the player's inventory. The
logic of determining the eligibility of a given object is handled in the
caller, which greatly simplifies the code and makes it clearer to read.
Particularly since there's no real need to cram everything into one if
statement.

This is related to pull request #77 by FIQ; it's largely a
reimplementation of its callbacks system, without doing a bigger than
necessary refactor of getobj or adding the ability to select a
floor/trap/dungeon feature with getobj. Differences in implementation
are mostly minor:
- using enum constants for returns instead of magic numbers
- 5 possible return values for callbacks instead of 3, due to trying to
  make it behave exactly as it did previously. PR #77 would sometimes
  outright exclude objects because it lacked semantics for invalid
  objects that should be selectable anyway, or give slightly different
  messages.
- passing a bitmask of flags to getobj rather than booleans (easier to
  add more flags later - such as FIQ's "allow floor features" flag, if
  that becomes desirable)
- renaming some of getobj's variables to clearer versions
- naming all callbacks consistently with "_ok"
- generally more comments explaining things

The callbacks use the same logic from getobj_obj_exclude,
getobj_obj_exclude_too and getobj_obj_acceptable_unlisted (and in a few
cases, from special cases still within getobj). In a number of them, I
added comments suggesting possible further refinements to what is and
isn't eligible (e.g. should a bullwhip really be presented as a
candidate for readying a thrown weapon?)

This also removed ALLOW_COUNT and ALLOW_NONE, relics of the old system,
and moved ALLOW_ALL's definition into detect.c which is the only place
it's used now (unrelated to getobj). The ALLOW_ALL functionality still
exists as the GETOBJ_PROMPT flag, because its main use is to force
getobj to prompt for input even if nothing is valid.

I did not refactor ggetobj() as part of this change.
2021-01-07 11:06:58 -05:00
Pasi Kallinen
bc8dd92621 Monster ranged attacks and staying away from hero
Move the check for monsters that want to stay away from hero
due to having a ranged attack into a separate function.

Add monsters with polearms and breath attacks to it.
Monsters with breath attacks stay away only if they haven't
used their breath recently, or if they are injured.
2021-01-06 14:38:39 +02:00
nhmall
2d1cf9591f place a reminder in glyph_info comment 2021-01-05 11:00:07 -05:00