Commit Graph

1075 Commits

Author SHA1 Message Date
nhmall
9bb96322a8 compile NetHack-3.7 without makedefs-generated .h files
This evolves and hopefully eases the game-build requirements by
removing game-compile dependencies on any header files generated
by the makedefs utility, including:

date.h dependency and its inclusion is removed and comparable functionality
is produced at runtime via new file src/date.c.

pm.h dependency and its inclusion is removed and comparable functionality is
produced by moving the monster definitions from monst.c into new header
file called monsters.h and altering them slightly. The former pm.h header
file #define PM_ values are now replaced with appropriate emitted enum
entries during the compiler preprocessing.

onames.h dependency and	its inclusion is removed and comparable functionality
is produced by moving the object definitions from objects.c into new header
file called objects.h and altering them slightly. The former onames.h header
file #define values are now replaced with appropriate emitted enum entries
during the compiler preprocessing.

artilist.h has been slightly altered, and the former onames.h artifact-related
header file #define ART_ values are now replaced with appropriate emitted enum
entries during the compiler preprocessing.

makedefs can still produce date.h (makedefs -v), pm.h (makedefs -p), and
onames.h (makedefs -o) for reference purposes. They won't be used during
the compiler.

The other uses for makedefs remain. They are used to prepare external
file content that the game utilizes, not prerequisite code for the
compile:
    makedefs -d    (database)
    makedefs -r    (rumors)
    makedefs -h    (oracles)
    makedefs -s    (epitaphs, engravings, bogusmons)

date.c

Pull the code for date/time stamping from mdlib.c into date.c.
Set date.o to be dependent on source files, header files, and .o files
so that date.o is rebuilt from date.c when any of those changes, thus
ensuring an accurate date/time stamp. It also includes git sha
functionality formerly done by makedefs writing #define directives
into include/date.h. For unix it passes the git info on
the compile line for date.c (via sys/unix/hints/linux.2020, macOS.2020)

nethack --dumpenums (optional, but on by default)

Allow developer to obtain some internal enum values from NetHack
without having to resort to an external utility such as
makedefs.

Uncomment #define NODUMPENUMS in config.h to disable this.

The updates to sys/windows/Makefile.gcc have not been tested yet.
2021-08-21 07:59:18 -04:00
nhmall
29aca6276e fix some VS warnings that recently appeared
..\src\explode.c(884): warning C4028: formal parameter 1 different from declaration

  That one stems from commit 6b60618e0e.
  Adjust the prototype in include/extern.h to match the function definition in
  src/explode.c

  Also, a recent update to the Microsoft Visual Studio 2019 causes the
  compiler to complain while compiling a vendor c++ header (string) if
  warning C4774 is enabled.

  We force that warning to be enabled during the Makefile build, even though
  it is not enabled by default.

  Only do so in the Makefile.msc for c source files, and not for c++
  (sys/share/cppregex.cpp).

  See below for an example of the compiler complaint.

  cppregex.cpp
  C:\Program Files (x86)\Microsoft Visual
  Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530):
  warning C4774: '_scprintf' : format string expected in argument 1 is
  not a string literal
  C:\Program Files (x86)\Microsoft Visual
  Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530):
  note: e.g. instead of printf(name); use printf("%s", name); because
  format specifiers in 'name' may pose a security issue
  C:\Program Files (x86)\Microsoft Visual
  Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(530):
  note: consider using constexpr specifier for named string literals
  C:\Program Files (x86)\Microsoft Visual
  Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\string(583):
  note: see reference to function template instantiation 'std::string
  std::_Floating_to_string<float>(const char *,_Ty)' being compiled
          with
	[
	   _Ty=float
	]
2021-08-14 15:36:54 -04:00
PatR
8e3fbb3588 known_branch_stairs
New routine known_branch_stairs() was performing two different things
and was unnecessarly complicated because of that.  Split off newer
routine stairs_description() to handle one of those.
2021-07-30 14:11:26 -07:00
PatR
f2019e2ec6 concealing unknown branch stairs
First cut at displaying branch stairs/ladder up/down as ordinary
stairs/ladder up/down if the destination hasn't been visited yet.

Stepping on stairs with 'mention_decor' enabled, or using ':' when
already on them, will report regular stairs' destination level.
Probably not very useful since it's just N+1 for downstairs or N-1
for upstairs when currently on level N.

It's based on whether the destination level has been visited, not
on whether the stairs have been traversed, so reaching a level via
trap or level teleporation can make the level's stairs known when
their destination really shouldn't be discovered yet.
2021-07-29 03:32:58 -07:00
Pasi Kallinen
65b320de39 Start of movement tests
Adds the following lua functions:

- nh.pushkey("x")
    Pushes a key into the command queue. Support is spotty,
    currently only the keys handled in rhack.
- nh.doturn()
    Runs one turn of main loop, or if optional boolean param
    is true, until g.multi == 0
- nh.monster_generation(false)
    Disable monster generation, and kill off all monsters.

Adds a testmove.lua script to test hero movement. Currently
covers only hjklyubn and HJKLYUBN.
2021-07-28 19:19:40 +03:00
Pasi Kallinen
7f39d53ad3 Lua: improve level testing
Add des.finalize_level() used for testing in conjunction with
des.reset_level().
Add nhc.DLB to return 0 or 1 if DLB was defined at compile-time.
Change the test_lev.lua to give more informative messages instead of
just lua error when required file doesn't exist.
Add bigrm-11 to the level tests.
2021-07-24 10:49:06 +03:00
PatR
5a09a01a13 gold dragon and scales
Add two new monsters and two new objects:
 gold dragon
 baby gold dragon
 gold dragon scale mail
 set of gold dragon scales

A couple of variants seem to have added these already, but this came
off my ancient list of monsters to add and was done from scratch.
It's a clone of silver dragon, but instead of having reflection and
breathing cold, a gold dragon emits light and breathes fire; because
of the latter it can be seen with infravision like a red dragon.
Adult gold dragons are lawful as in the AD&D Monster Manual rather
than chaotic as the wiki pages show for the variant versions.

Worn gold dragon scales operate similar to wielded Sunsword:  when
blessed, radius is 3 (same as a lamp), if uncursed, radius is 2, and
if cursed, radius is 1 (but functions as 2 when worn by the hero,
otherwise there would be no tangible effect).  Gold dragon scale mail
gets an extra +1, making blessed gold DSM have a bigger radius than
lamps.  Embedded scales have radius 1 regardless of BUC state; light
for that case comes from the gold dragon monster form the hero is in.
When not worn, gold scales and scale-mail don't emit any light.

The tiles use a mix of yellow (for gold) and red.  The two object
tiles seem reasonable variations of the corresponding silver dragon
ones.  The two monster tiles definitely need work since the silver
ones were mostly cyan and changing that to red did not produce very
good result; subsequent attempt at a mixture was haphazard at best.
2021-07-23 10:41:57 -07:00
Michael Meyer
d8dc16e393 Add 'readable' Hawaiian shirt designs
Functionally similar to reading a T-shirt or apron, but rather than
actual text printed on the shirt being displayed, the design of the
Hawaiian shirt is described: for example, "hula dancers on an orange
background" or "tropical fish on an abstract background".  Much like
T-shirts have their text included in the game-end inventory list ('a
blessed +2 T-shirt with text "foo"'), Hawaiian shirts now have a brief
description of their design appended to their item name under the same
circumstances.

Because 'reading' a Hawaiian shirt doesn't actually involve reading
text, using the 'r' command in this way doesn't break illiterate
conduct.
2021-07-16 18:05:21 +02:00
nhmall
ed9647310a deal with gold leaving shop via scatter()
fixes #538
2021-07-10 19:41:55 -04:00
Pasi Kallinen
db68395d69 Movement key reworking
Put the rush and run movement keys into g.Cmd instead of bit twiddling
the normal walk keys in multiple places to get the run and rush keys.

Allow meta keys in getpos. Use the normal running keys to fast-move
in getpos, instead of explicit HJKL - I polled couple places online,
and number_pad users did not use the HJKL keys in getpos.

Make meta keys work even after a prefix key.
2021-07-03 18:20:24 +03:00
Pasi Kallinen
075844b4d6 Adjust shopkeeper damage fixing
Allow shopkeeper to remove webs and pits.

Change the damage fix messaging to be more specific when
shopkeeper removes a trap. Before this the message was
"A trap was removed from the floor", which sounds really silly
when it comes to holes.

Change the damage fixing so the shopkeeper will fix one damage spot
at a time (instead of all at once), so it's more like a monster action.

Some code cleanup, splitting into smaller functions.

While doing this, I noticed that shopkeepers don't actually bill
the hero for the damage, but that'll have to be another commit...
2021-06-25 20:02:06 +03:00
Pasi Kallinen
8dfe963652 Allow spiders to spin webs
Revisited this feature, and the chance of a spider spinning a web
depends now on the number of webs already present on the level.

For a giant spider to spin a web in the middle of a room with no
supports, the limit of existing webs is 4, next to one support 9,
next to two supports 14, and so on. Cave spider limits are much lower.
2021-06-23 22:50:57 +03:00
PatR
a9134fd8b9 more "<mon> appears in a cloud of smoke"
Now that the appear message isn't limited to summoning by demon,
seeing "the Angel of <foo> appears in a cloud of smoke" seems
strange.  Angels weren't covered by the vapor/dust/&c change for
elementals.  Make angels appear in a flash of light.
2021-06-21 17:47:51 -07:00
PatR
fa7980c585 monster name formatting
While testing monster summoning by using a debugger to force the
outcome, I saw "the renegade Angel of <foo> appears in a cloud of
smoke" as if only one such creature existed.  Trying to change
that to "a renegate Angel" pointed out some problems:  type names
like Angel, Green-elf, and Uruk-hai fool an() into using "the"
because of their capital letter.  Fixing that was a bit of a hack
and worked for Green-elf and Uruk-hai but not for Angel because
it has the eminion extension so uses priestname() instead of the
guts of x_monnam().  Fixing that involved more hackery and now I
feel unclean, but it seems to be working.

It wasn't as noticeable as it might have been because most of the
time that "the Angel of <foo>" or "the priest of <bar>" was shown,
the caller is requesting "the" rather than "a/an".
2021-06-21 17:44:35 -07:00
PatR
0bb77f455d "<foo> appears in cloud of smoke."
Have water demons appear in a cloud of vapor rather than a cloud of
smoke.  This adds a few other alternatives but they'll never happen.
Elementals could only be summoned by Angels but Angels never call
msummon() as far as I can tell.  Vortices aren't summoned at all
but the smoke/vapor/&c routine has provisions for them.

The cloud of smoke message used to be given only when the summoner
is a demon.  Now it will be given if the last--or only--summoned
creature can be seen to arrive, no matter whether summoned by a
demon, a non-demon (which I think isn't possible), or post-Wizard
harassment.
2021-06-20 16:45:42 -07:00
Pasi Kallinen
76f77ee0cc Add assistance to fire-command
Allows the fire-command to autowield a launcher; it will now
do either swapweapon or wield an appropriate launcher, if you
have ammo quivered.

This assistance can be turned off with the fireassist boolean option.

Adds a rudimentary command queue, which allows the code to add keys
or extended commands into the queue, and they're executed as if
the user did them.  Time passes normally when doing the queue,
and the queue will get cleared if hero is interrupted.
2021-06-16 13:14:32 +03:00
PatR
57e970b227 mon_pmname(), obj_pmname()
Revive some code from 5 or so years ago that's been sitting in a
defunct local git branch.  There are a couple of references to
figurines having gender; the old, unfinished code did already have
support for that, the current code doesn't.  It probably won't take
much effort to add it in but I want to get this first part out of
the way.

Replace some of the
pmname(mon->data, Mgender[mon]) calls with simpler
mon_pmname(mon) and some
pmname(&mons[statue->corpsenm],
   (statue->spe & CORPSTAT_GENDER) == ... ? ... : ...) with simpler
obj_pmname(obj).  There are other instances of them which haven't
been changed but could be.
2021-06-12 03:07:30 -07:00
nhmall
91ab71f0f9 windows and visual studio follow-up bit 2021-06-03 23:43:32 -04:00
nhmall
0a10bd632d change references from winnt to windows
rename sys/winnt to sys/windows
move vs (visual studio) folder out of win/win32 and into sys/windows
rename include/ntconf.h to include/windconf.h
rename winnt.c to windsys.c
place visual studio projects into individual subfolders.

This will hopefully resolve GitHub issue #484 as well.
2021-06-03 23:26:00 -04:00
Pasi Kallinen
8d2407f1f2 Monsters can gain resistances by eating corpses
This is based on both the EvilHack implementation by
k21971 <keith.simpson1971@gmail.com>, and xNetHack
implementation by copperwater <aosdict@gmail.com>.
2021-05-23 19:03:33 +03:00
Pasi Kallinen
20cbadcf85 Unlock your quest by killing your quest leader
Allow killing your quest leader, just to make games winnable if you
converted before doing the quest.
Boost the quest leaders and give them some equipment. King Arthur
gets Excalibur. Killing quest leader gives really bad luck and
makes your god angry at you, and killing quest guardians gives
smaller penalties.

This is based on both the EvilHack implementation by
k21971 <keith.simpson1971@gmail.com>, and xNetHack
implementation by copperwater <aosdict@gmail.com>.
2021-05-23 11:11:58 +03:00
Pasi Kallinen
6b60618e0e Exploding spheres cause real explosions
Despite active explosion attacks being called explosions in-game,
they only affected a single target, and were handled differently
from actual explosions. Make them do an actual explosion instead.
This should make spheres more interesting and inspire different
tactics handling them.

Because spheres deal more damage on average and can destroy items
in their explosions, their difficulty has been increased slightly.

Polyselfed hero exploding won't cause elemental damage to their
own gear.

Originally from xNetHack by copperwater <aosdict@gmail.com>.
2021-05-22 13:37:39 +03:00
Pasi Kallinen
29868036f1 Lua: nhcore script with function callbacks
Adds possible callbacks for "start_new_game", "restore_old_game",
"moveloop_turn", and "game_exit" which when defined, will be called
from core code at the appropriate time.

Adds lua hooks for dump_fmtstr (only if DUMPLOG), dnum_name, u.moves,
u.uhave_amulet, and u.depth.
2021-05-21 21:24:59 +03:00
Pasi Kallinen
2f25556025 Conflict based off of charisma
Higher charisma will make it more likely for monsters to be affected.
Conflict will also now require the monster to see the hero.

Originally from SporkHack by Derek Ray.
2021-05-19 18:35:00 +03:00
Pasi Kallinen
16105ad0d5 Change touch of death from instadeath to maxhp reduction and damage
Touch of death will now do 50 + 8d6 damage, and drain max HP for half
of that. If the drain is equal or greater than your max HP, then it
will kill you instantly.

Change originally from SporkHack by Derek Ray.
2021-05-18 18:58:34 +03:00
Pasi Kallinen
2288452278 Monsters can see player resistances
If monsters see you resist something, generally elemental or magical
attack, or if they see you reflect an attack, they learn that and
will adjust their attack accordingly.

Originally from SporkHack, but this version comes via EvilHack with
some minor changes.
2021-05-17 20:01:11 +03:00
PatR
dae25564bc more object->dknown handling
Fix a couple of places that set obj->dknown to 0 to deal with some
special cases where it should be left at 1.  (Other places do that
but deal with potions where hardcoded 0 remains appropriate.)
2021-05-13 09:38:53 -07:00
PatR
b630d5e038 fix issue #509 - shop 'glob' pricing segfault
A recent change made it possible for a glob to have its dknown flag
cleared and that exposed globby_bill_fixup() passing Null shopkeeper
to get_cost(), triggering a crash.

Make the routine that clears dknown/known/bknown/&c also be the
routine used to initialize those flags for a new object so that it
is the place that handles various special cases.  That hides the
shop bug again.

But also fix the shop bug even though it won't be triggered.

Fixes #509
2021-05-12 16:13:40 -07:00
PatR
cecda13ab2 fix pull request #504 - partly eaten food
that has no nutritional value.  Prevent applying the partly eaten
attribute to wished for food if the full nutrition isn't at least 2.
The problem case was 0 nutrition wraith corpse, yielding "partly
eaten food (1) more nutritious than untouched food (0)" when setting
the corpse's weight.  That one was possible in 3.6.x, unlike corpse
that was actually partly eaten and then revived as a zombie (which
was just fixed for triggering the same warning).

Wishing really ought to ignore "partly eaten" for anything that is
normally eaten in one bite but I'm not sure how to handle that.

Fixes #504
2021-05-06 17:52:30 -07:00
PatR
ad7f2afef9 fix github issue #493 - hero item knowledge
Issue was about being asked what to call a previously seen potion
which has been picked up and thrown by an unseen monster.  Hero
shouldn't remember what the item description was.  This is a much
more general change than just fixing that.  Any item picked up by
an unseen non-tame monster will have all its *known flags cleared
since the hero can't see what that monster does to it.  Same if an
item is picked up while seen but then used when unseen.

Unseen pets are excluded from the pick up case--but not the use
case--because they pick up and drop stuff continually and players
would just slaughter them if they caused item information to be
forgotten.

Fixes #493
2021-05-06 12:36:32 -07:00
PatR
b4ae19ed0c fix "Killed by foo, while paralyzed by a monster"
If the killer and the paralyzer are the same monster, truncate
that to "Killed by a foo, while paralyzed".  When not the same,
spell out the paralyzer's monster type instead of using generic
"monster".  "Killed by a fox, while paralyzed by a ghoul", or
"Killed by a ghoul, while paralyzed by a ghoul" *if* they were
two different ghouls.
2021-04-22 16:13:41 -07:00
PatR
5d6ab55372 opening magic vs holding monster
Zapping wand of opening or spell of knock at engulfer while swallowed
would make the engulfer expel the hero; this change makes zapping
other holders release their hold.  Zapping self now achieves the same
effect, as does breaking a non-empty wand of opening.  When poly'd
hero is holding a monster rather than being held, that monster will
be released.

Engulfers can't re-engulf for 1 or 2 turns after releasing the hero
in order to prevent hero from being immediately re-engulfed.  Impose
the same limitation on other holders.
2021-04-13 13:51:57 -07:00
PatR
8bd08ebb71 level teleporters vs Ft.Ludios
From newsgroup discussion where slash'em changes have revealed a
latent nethack bug:  prevent placing level teleporters in single-
level branches.  The Knox level doesn't have any level teleporters
(or random traps) but wizard mode wishing could create them there.
They wouldn't do anything because the only possible destination
would be the same level.  Pushing a boulder onto one used to trigger
an infinite loop (and still does in slash'em, which has other
single-level branches besides Ft.Ludios) trying to relocate it.

Boulder pushing was changed 15 years ago to prevent the infinite
loop and to avoid giving "the boulder disappears" message when a
level teleporter failed, but rolling boulder traversal lacked that
same change--it wasn't vulnerable to looping but could give an
inaccurate message claiming that the boulder disappeared when it
actually didn't.  Fixing this is a bit late; rolling boulder trap
creation was recently changed to not choose a path that rolls over
teleportation or level tele traps any more.
2021-04-12 13:25:52 -07:00
PatR
328dc5bdfa github issue #475 revisited - Trollsbane
Change Trollsbane versus troll corpse revival:  instead of revival
failing if Trollsbane is wielded at time of revival attempt, mark
the corpse no-revive if killed by Trollsbane (whether by the hero
or a monster).

If a no-revive corpse is within view when time to revive occurs,
give "the troll corpse twitches feebly" even when the hero isn't
responsible.  That used to only apply if the hero zapped the
corpse with undead turning, which would have become inoperative
because now being zapped by undead turning clears the no-revive
flag and revives as normal.  In other words, undead turning magic
overrides killed-by-Trollsbane or non-ice troll having been in an
ice box.
2021-04-02 10:38:57 -07:00
PatR
0479625c94 cancelled zombification
Don't let cancelled zombies or cancelled liches create new zombies.
2021-03-30 17:33:31 -07:00
PatR
3cd45b7c44 "fix" github issue #475 - Trollsbane
Player's pet killed a troll with Trollsbane and the corpse later
revived.  He assumed that killing a troll with Trollsbane is what
prevents troll corpse revival but that is inhibited by the hero
be wielding Trollsbane at the time revival is attempted.

Having killed-by-Trollsbane be the reason for blocking revival
would be much better but looks like a lot of work for something
which was supposed to be a one-line enhancement to an under-used
artifact.  This extends revival inhibition to having anyone on
the level be wielding Trollsbane rather than just the hero.
Not a proper fix but I think it's better than nothing.

Closes #475
2021-03-29 11:48:24 -07:00
PatR
6c70b46ea1 more monster/door interaction
Apply visibility fixups for monsters triggering door trap
explosions or digging through doors similar to the monster-opens-
door-handling from a couple of days.  Again, the issue is that
hero/player can see a closed door in situations where they can't
see an open one, and messages about the door being opened or
destroyed need to take that into account when seeing a closed
door go away.

Not as thoroughly tested as monster just opening closed door.
2021-03-23 08:52:36 -07:00
PatR
a06f5ec494 multiple gold stacks in invent
The pull request that fixed a couple of instances where it was
possible to have multiple entries for gold in inventory indirectly
pointed out that the error checking was clumsy.  If you executed
the #adjust command while having two '$' items in inventory, you
were told twice that you had multiple stacks of gold in inventory.
Change how that's handled so that the warning appears at most once
for any given #adjust command.  Also avoids having #adjust's use
of getobj() re-scan entire invent for every item in invent.

Also, if player did manage to get two or more '$' entries, #adjust
would allow moving any but the last to a letter entry.  Once in a
letter, further #adjust with count specified could split the letter
gold entries into even more gold entries.  Now, if the player picks
gold as the #adjust 'from' item (which is only possible when there
are wrong letter gold entries or multiple ones or both) then #adjust
will now force 'to' slot to be '$' (without asking player to pick).

Lastly, the inventory check for multiple and/or wrong slot gold is
now performed by wizard mode sanity_check() in addition to #adjust.
2021-03-17 10:36:42 -07:00
PatR
946df19ea2 \#perminv, 2 of 2: implementation
Add new '|' command, aka #perminv, which allows the player to
send menu scrolling keystrokes to the persistent inventory window.

Implemented for X11, where its usefulness is limited, and for
curses, where it is more needed and also more fully functional.
The interface can either prompt for one keystroke, act upon it,
and return to normal play, or it can loop for multiple keystrokes
until player types <return> or <escape>.  X11 does the former if
the 'slow' application resource is False so that prompting uses
popups, and the latter when 'slow' is True where prompting is in
a fixed spot and doesn't end up causing the persistent inventory
window to be stacked behind the map window.  curses always does
the loop-until-done approach.  It also accepts up and down arrow
keys to scroll one line at a time.

Also adds two new menu scrolling commands, menu_shift_right (key
'}' by default) and menu_shift_left ('{') if wincap2 flags contain
WC2_MENU_SHIFT.  Shifting allows different substrings of too-long
lines to be seen.

For X11, neither works because their handling requires a horizontal
scrollbar and for some reason that escapes me our menus don't have
one of those.  If they did, shifts could work for all menus but a
shifted window would hide the selection letters.  So shifting would
be most usefully done as:  pan right, read more of any long lines,
immediately pan back to the left.

For curses, they only apply to the persistent inventory window.
Shift right redraws it with class headers and inventory letters
shown normally but the item descriptions omit their leftmost
portion, showing more text towards the end.  Shift left reverses
that and does nothing if the beginning is already in view.  Forward
and backward scrolling while shifted leave the shift in place.
2021-03-13 18:18:53 -08:00
PatR
d8bef90009 options key parsing
OPTIONS=menu_previous_page:\mv
  BINDINGS=M-v:menu_previous_page
both worked, but
  OPTIONS=menu_previous_page:M-v
  BINDINGS=\mv:menu_previous_page
both failed.  Make all four variations work.  Tiny change made large
by the need to move some things around.

The option definition for menu_first_page had a couple of its flag
bits swapped.  I didn't try to figure out whether that had any impact.
2021-03-10 12:28:09 -08:00
nhmall
558b7c27d8 read_simplemail() when SERVER_ADMIN_MSG is defined
Some warnings were mentioned

Add a prototype ahead of the function
Use a non-const copy of SERVER_ADMIN_MSG

quick-tested by:
- uncommenting the following in include/unixconf.h
  /* #define SERVER_ADMIN_MSG "adminmsg" */
- building NetHack
- creating a test message:
  echo "server_admin: system is going down at 2 pm" >~/nh/install/games/lib/nethackdir/adminmsg
- playtested and received the desired message
2021-02-26 09:05:52 -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
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
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
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
nhmall
f963c5aca7 switch source tree from k&r to c99 2021-01-26 21:06:16 -05:00