Skip to content

Commit 8908cc7

Browse files
committed
Merge remote-tracking branch 'myvanilla/master' into 9.0-savebreaking
This is an enormous merge, but that's to be expected when it covers 1 year and 8 months of vanilla development. Enjoy reading 3000 words of conflict notes from the almost 1200 conflicts which took nearly a week to resolve: COMPLYING WITH UPSTREAM REFORMATS/RENAMES/REFACTORS - Added NONNULL* declarations to xNetHack-specific functions in extern.h as appropriate. Some of the functions did actually check for nulls and produced an impossible; turns out gcc will actually catch potential uses of null in there AND will error if an argument specified as non-null is checked for null within the function, so I removed those checks and impossibles. - Moved hash functions from hacklib.c to rnd.c because coord_hash relies on nethack globals that have been stripped from hacklib . - Moved current_holidays() to calendar.c. - Converted xNetHack array[rn2(SIZE(array))] to vanilla's ROLL_FROM(array). Replaced a rnd_name macro defined by xNetHack for the same purpose. Left some that are unchanged in vanilla or which have a slightly different calculation such as rn2(SIZE(array) - 1) in place. - Formatted monsters.h changes in tune with the guidelines mentioned in 627b40f. - Discarded xNetHack additions to the controllable verbosity system, since this apparently got entirely reverted upstream and no longer exists. If it gets added back at some point and I need to reimplement it I will be very cross. - Updated vanilla's big comment grid documenting room flags in rm.h, but if this causes merge conflicts in the future I will probably just ditch it... - Moved DUMPHTML handling in config.h so that if DUMPHTML is defined at compile time but DUMPLOG isn't, DUMPLOG_CORE code will still be compiled in (which DUMPHTML relies on). - Added vanilla's odd FALLTHROUGH before a /* FALLTHRU */ comment where observed, but didn't do it comprehensively. - Inserted xNetHack timeouts MOLDY_CORPSE and FERMENT into timer_is_obj; the commit that introduced that macro is older than the last merge, so perhaps this was an oversight. - Changed g[a-z] instance_globals to sv[a-z] instance_globals_saved whenever appropriate. - Added and removed monsters as necessary from the "all other cases" giant switch statement in makemon(). - Renamed saved globals in xNetHack code to sv[a-z] as opposed to g[a-z] unsaved globals. NEW ADDITIONS TO THE ENDS OF ARRAYS/ENUMS/ETC - bigrm-12 "Tea Party" leapfrogs over bigrm-13 "The Great Bridge" to become bigrm-14 since vanilla added its own bigrm-12. - Bump PARANOID_THROW, TER_VISIT, WITHERING & DOOMED, etc to the end of their lists rather than sandwiching them between vanilla values, so that the vanilla values remain the same in both versions. COLLIDING ENGRAVING DISPLAY IMPLEMENTATIONS - - Moved engraving_to_glyph into a function. - Deleted secret corridors' eligiblity to show engravings. Vanilla appears to have dropped that. FEATURES WHERE THE UPSTREAM IMPLEMENTATION WAS TAKEN OR XNETHACK CHANGES WERE DISCARDED - Took vanilla's implementation of petless conduct (in which the pet counter is incremented in initedog() and there is only one place that it needs to be decremented because it wasn't a "real" pet). - Discarded xNetHack-specific HI_BOSS in favor of vanilla's HI_OVERLORD. - It looks like vanilla commit 4927b2c (putting shop overview names into the shclass struct) basically reimplemented xNetHack commit 313d59b, so take their implementation. - Discard xNetHack logic around strong gear for lawful minions (only difference should be that the weapon will no longer have a chance of generating at very high enchantment and keeping it; now it's just vanilla's +0 to +3 for swords and +3 to +6 for maces). - Took vanilla's teledest implementation, which has better checks on the teledest coordinate. - Took vanilla's (qt's) implementation of NO_PART for bodypart math. - Took vanilla's teleport exclusion zones in the hellfill prefabs that contain some interior region that's blocked off somehow. - Kept vanilla's changes to relative object probabilities, notably with spellbooks (which the DevTeam is treating as if every object class still has to add its probabilities up to 1000, which it doesn't). - Took, for now, vanilla's enumeration of "all other" monster species in make_corpse (only compiled when NH_DEVEL_STATUS isn't "released"); but if this proves to be a headache-inducing source of merge conflicts, I may delete it. - Took vanilla's implementation of blessed destroy armor scroll allowing you to choose the piece to destroy. - Took saving grace without changes. - Took vanilla's 3-stages-of-cracking system for glass armor. As of this commit, it applies only to armor, and glass weapons (and any other object classes) will still shatter completely the first time they take damage, but erodeproofing them still protects them. The game now uses vanilla's term "tempered" to denote some erodeproof glass object, except it still uses "indestructible" to refer to erodeproofed glass rings and wands which could also break from shock damage. - Took vanilla's implementations of paranoid swim and paranoid trap. (This means if you do NOT have paranoid trap set, you will NOT be prompted to confirm before moving into a trap, and if you have it set but do not have paranoid confirm set, you will accept moving into it by pressing 'y'). - Took vanilla's implementation of force-fighting a web. - Discarded xNetHack's "You find many hidden bugs on the floor" case for engraving with a wand of secret door detection, since it now always identifies itself. - Adopted vanilla's code for handling searing damage from equipment on the left and right hands separately when a martial arts user gets a double attack, instead of just assuming searing damage would always be applied on every hit. - Restored vanilla's behavior of not considering two objects mergable with different known, bknown or rknown - provided you are both a non-priest (for bknown) and are either blind or hallucinating, meaning most of the time, they are still mergable. - Largely took the sacrifice gifting rebalance as-is; a few small notes: - Odds of a gift are 1/(6*gifts^2) instead of 1/(6*gifts*artifacts_existing). - Mirror Brand and the Apple of Discord need new +x and minimum sacrifice difficulty stats for the artifact rebalance made in vanilla. For now these are both zeroes; a follow-up commit will provide actual values. For Quest artifacts, the numbers are irrelevant, so I used the 0, 12 numbers for quest artifacts added in xNetHack, same as all the other quest artifacts. - Took vanilla's implementation of shop annotations, deleting xNetHack function get_shtype() in the process. - Took vanilla's code for suppressing the Quest leader summon message when the leader is dead (as opposed to xNetHack's slightly less accurate implementation of when you personally killed them). - Took vanilla's code for item destruction, which was based on xNetHack code anyway and had only minor differences, mostly improvements. - Took vanilla's implementation of looking up an object in inventory and discarded xNetHack's. FEATURES WHERE THE XNETHACK IMPLEMENTATION WAS KEPT OR UPSTREAM CHANGES WERE DISCARDED - Barbed devils kept both their passive barb attack from xNetHack and their active sticky attack from vanilla (which replaced one of their claw attacks; they still only make 3 active attacks). - Kept vrocks as orange, not green, though as of this commit their tile recoloration from vanilla to a greener demon has stayed. - Discarded ice devil's slowing touch from vanilla. In xNetHack their cold sting already did this if you don't have cold resistance. - Kept xNetHack secret door odds rather than vanilla's "none on first 2 levels, flat 1/8 beyond that". The xNetHack formula already has none on the first few levels and scales up gradually. - Discarded various additions for the Rogue level such as traptype_roguelvl(). - Kept xNetHack's implementation of "concealed hiders don't venture out often"; vanilla's happens before the m_move adjacent-finding code, which means monsters hiding in large grassy areas would move extremely slowly. - Stripped the can_unlock and can_open arguments from postmov(), since they are used in mon_open_door, not here. - Discarded NO_HIDING_UNDER_STATUES. The bug that led to its creation is already fixed upstream - monsters won't hide under statue trap statues because the space has a trap on it. - Didn't take vanilla's "small bonus" for wielding a quarterstaff while spellcasting; this already confers a gear bonus in xNetHack. - No updates to patchlevel since this is merged into the 9.0 savebreaking branch. EDITLEVEL is still 0. FEATURES WHERE UPSTREAM AND XNETHACK IMPLEMENTATIONS WERE MERGED - Vanilla added 4 guaranteed food rations to the Mon-strt level, whereas xNetHack added a chest with 5 random (not guaranteed vegetarian) comestibles. I moved the food rations into that chest and removed the 5 comestibles. It feels appropriate for the monks to only have bland food instead of an interesting variety. Also, fixed the location of the spinach tin to be next to the Grand Master, as it is in vanilla. - Paupers keep race-based skill cap minimums, since these are natural affinities and not anything to do with background or training. (The hero doesn't actually start with any skill in them anyway.) - Moved some code (regarding traps) from vanilla's implementation of can_hide_under_obj to xNetHack-native concealed_spot(), because vanilla assumes the only things that can hide monsters are objects, which is not true in xNetHack. - Changed inventory weight format from "{xyz}" to vanilla's wizweight format of "(xyz aum)". If the extra 4 characters prove to make messages too long, this could be reverted, or have invweight turned into a compound option to select between styles. (Unlike in vanilla, non-wizards can still see object weights). - Incorporated vanilla's code for protection from item destruction being percentage-based on worn gear (90% for dwarvish cloaks versus fire and cold), but maintained the principles from xNetHack commit e340c90 of keeping the protection symmetric for monsters and extrinsics being 100% protective. - Took vanilla's unification of mulch logic in should_mulch_missile, but applied xNetHack-specific skill-based logic that favors the player. (Monsters' 2/3 chance of breaking ammo is now 1/4, and is subject to the same enchantment-based and BUC-based saving throws to save or destroy it as the player gets.) Noticed a double implementation of "Flint and hard gems get an extra chance not to break because they don't easily break" and removed the extra one. - Took vanilla's implementation of dipping in sinks, which allows washing hands and wetting objects in addition to identifying potions. It adds special effects for a few potions that weren't implemented in xNetHack, but I kept the xNetHack part where potions which unambiguously identify themselves by their effects on the sink get auto-identified rather than offering the player an opportunity to call them. - Took vanilla's 30+d15 turns of invisibility from zapping self with a wand as opposed to xNetHack's 50+d50, but kept the xNetHack amount of d(spe*250) turns when breaking the wand. - Discarded much of the vanilla code for a vampire reforming on a door and smashing it, specifically the part about triggering its trap which assumed the only door trap blows the door up. They will still smash doors, and they will still cause ones trapped with a fiery explosion to blow up, but they won't trigger other types of traps. - Discarded xNetHack macro is_hard() in favor of vanilla's hard_helmet(), but moved the checks for other material helms that only exist in xNetHack (wood, bone, and stone) into that function. FEATURES NOT ACTUALLY MERGED YET WHICH WILL GET A FOLLOW-UP COMMIT - Artifact gift values for xNetHack-added artifacts as mentioned above. - As of this commit, Dispater fiend adversity will usually completely shut down HP recovery, since the formula for HP recovery changed upstream. - As of this commit, the xNetHack "garden" themed room coexists with paxed's "garden" themed room fill (which can appear in various room shapes). Other themed rooms still exist and haven't been checked for duplicates. They will probably be properly merged in a follow-up commit. - Kept both vanilla's bone devil skeleton gating and xNetHack's bone devil skeleton summoning for now. - As of this commit, both xNetHack fall damage from falling into open air and vanilla fall damage for falling down trapdoors (but which I believe also applies to falling into air) coexist. - Erinyes are still guaranteed in some Gehennom special levels, which coexists with the new erinys revamp where they can be summoned to punish bad behavior. For now I kept their xNetHack statblock: G_NOGEN instead of G_SGROUP | 2, flying by default, green not red, always hostile. - Temporarily left keeps_distance in mondata.h despite nhmall cleaning out the macros which took a struct monst * into mon.h. This will be fixed in a follow-up commit. NEW IMPLEMENTATIONS IN THIS MERGE COMMIT - Changed the code for vapors from the various potions of healing to call healup() instead of relying on janky switch case fallthru logic. - Split part of ring_from_sink into a new function, find_sink_ring, which only returns the ring without making it come to the surface. This is so that pouring object detection down the sink can tell whether there's a ring there. - Inserted a default case to some switch statements handling monsters that now get tripped up on -Werror=switch. - Added some prototypes for html dumplog functions that never had them.
2 parents 801e191 + df06fc3 commit 8908cc7

File tree

543 files changed

+82147
-53325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

543 files changed

+82147
-53325
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ src/xnethack
3838
Debug/
3939
Release/
4040
binary/
41+
package/*
42+
vspackage/
43+
vsbinary/
4144
build/
4245
ipch/
4346
lib/*
@@ -94,3 +97,4 @@ bundle/*
9497
*.user
9598
util/*.lib
9699
util/*.exp
100+
submodules/CHKSUMS.tmp

Cross-compiling

Lines changed: 63 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Part B Contents:
2020
B4. Case sample: msdos
2121
B5. Case sample: amiga (started but incomplete)
2222
B6. Case sample: Web Assembly, libnh
23+
B7. Case sample: mips
2324

2425
--------------------------------------------------------------------------------
2526
Part A - Cross-compiling NetHack
@@ -360,41 +361,44 @@ Using the cross-compiler, build the following targets:
360361
cross-compile and link with these compiler switches:
361362
-DCROSSCOMPILE and -DCROSSCOMPILE_TARGET
362363

363-
core sources (2019): src/allmain.c, src/alloc.c, src/apply.c,
364+
core sources (2024): src/allmain.c, src/alloc.c, src/apply.c,
364365
src/artifact.c, src/attrib.c, src/ball.c,
365-
src/bones.c, src/botl.c, src/cmd.c, src/dbridge.c,
366+
src/bones.c, src/botl.c, src/calendar.c,
367+
src/coloratt.c, src/cmd.c, src/dbridge.c,
366368
src/decl.c, src/detect.c, src/dig.c, src/display.c,
367369
src/dlb.c, src/do.c, src/do_name.c, src/do_wear.c,
368370
src/dog.c, src/dogmove.c, src/dokick.c,
369371
src/dothrow.c, src/drawing.c, src/dungeon.c,
370372
src/eat.c, src/end.c, src/engrave.c, src/exper.c,
371-
src/explode.c, src/files.c,
372-
src/fountain.c, src/hack.c, src/hacklib.c,
373-
src/insight.c, src/invent.c, src/isaac64.c,
374-
src/light.c, src/lock.c, src/mail.c,
375-
src/makemon.c, src/mcastu.c,
373+
src/explode.c, src/extralev.c, src/files.c,
374+
src/fountain.c, src/getpos.c, src/glyphs.c,
375+
src/hack.c, src/hacklib.c, src/insight.c,
376+
src/invent.c, src/isaac64.c, src/light.c,
377+
src/lock.c, src/mail.c, src/makemon.c, src/mcastu.c,
376378
src/mdlib.c, src/mhitm.c, src/mhitu.c, src/minion.c,
377379
src/mklev.c, src/mkmap.c, src/mkmaze.c, src/mkobj.c,
378380
src/mkroom.c, src/mon.c, src/mondata.c,
379381
src/monmove.c, src/monst.c, src/mplayer.c,
380382
src/mthrowu.c, src/muse.c, src/music.c,
381-
src/nhlsel.c, src/nhlua.c, src/nhlobj.c,
382-
src/o_init.c, src/objects.c, src/objnam.c,
383-
src/options.c, src/pager.c, src/pickup.c,
384-
src/pline.c, src/polyself.c, src/potion.c,
385-
src/pray.c, src/priest.c, src/quest.c,
383+
src/nhlua.c, src/nhlsel.c, src/nhlobj.c,
384+
src/nhmd4.c, src/objects.c, src/o_init.c,
385+
src/objnam.c, src/options.c, src/pager.c,
386+
src/pickup.c, src/pline.c, src/polyself.c,
387+
src/potion.c, src/pray.c, src/priest.c, src/quest.c,
386388
src/questpgr.c, src/read.c, src/rect.c,
387-
src/region.c, src/restore.c, src/rip.c, src/rnd.c,
388-
src/role.c, src/rumors.c, src/save.c, src/sfstruct.c,
389-
src/shk.c, src/shknam.c, src/sit.c, src/sounds.c,
390-
src/sp_lev.c, src/spell.c, src/steal.c, src/steed.c,
389+
src/region.c, src/report.c, src/restore.c,src/rip.c,
390+
src/rnd.c, src/role.c, src/rumors.c, src/save.c,
391+
src/selvar.c, src/sfstruct.c, src/shk.c,
392+
src/shknam.c, src/sit.c, src/sounds.c, src/sp_lev.c,
393+
src/spell.c, src/stairs.c, src/steal.c, src/steed.c,
391394
src/symbols.c, src/sys.c, src/teleport.c,
392395
src/timeout.c, src/topten.c, src/track.c,
393-
src/trap.c, src/u_init.c, src/uhitm.c, src/vault.c,
394-
src/version.c, src/vision.c,
395-
src/weapon.c, src/were.c, src/wield.c, src/windows.c,
396-
src/wizard.c, src/worm.c, src/worn.c, src/write.c,
397-
src/zap.c, sys/share/cppregex.cpp
396+
src/trap.c, src/u_init.c, src/uhitm.c,
397+
src/utf8map.c, src/vault.c, src/version.c,
398+
src/vision.c, src/weapon.c, src/were.c, src/wield.c,
399+
src/windows.c, src/wizard.c, src/wizcmds.c,
400+
src/worm.c, src/worn.c, src/write.c, src/zap.c,
401+
sys/share/cppregex.cpp
398402

399403
tty sources: win/tty/getline.c, win/tty/termcap.c,
400404
win/tty/topl.c, win/tty/wintty.c
@@ -409,7 +413,7 @@ Using the cross-compiler, build the following targets:
409413

410414
b) Lua (mandatory in 3.7)
411415

412-
lib/lua-5.4.4/src
416+
lib/lua-5.4.6/src
413417

414418
from sources: lua.c, lapi.c, lauxlib.c, lbaselib.c, lcode.c,
415419
lcorolib.c, lctype.c, ldblib.c, ldebug.c,
@@ -468,18 +472,18 @@ Cross-compiler pre-built binary downloads:
468472
or pdcursesmod from:
469473
https://github.com/Bill-Gray/PDCursesMod.git
470474

471-
- A shell script to download that djgpp cross-compiler and associated
475+
- A bash script to download that djgpp cross-compiler and associated
472476
pieces for either linux or macOS is available:
473477

474-
sh sys/msdos/fetch-cross-compiler.sh
478+
bash sys/msdos/fetch-cross-compiler.sh
475479

476480
That script won't install anything, it just does file fetches and stores
477481
them in subfolders of lib. The linux.370 and macOS.370 hints files are
478482
configured to find the cross-compiler there if you add
479483
CROSS_TO_MSDOS=1
480484
on your make command line.
481485

482-
Note: Both the fetch-cross-compiler.sh script and and the msdos
486+
Note: Both the fetch-cross-compiler.sh bash script and the msdos
483487
cross-compile and package procedures require unzip and zip to be available
484488
on your host build system.
485489

@@ -554,7 +558,7 @@ Cross-compiler url: https://github.com/bebbo/amiga-gcc
554558
make update
555559

556560
[Note that you may have to take ownership of the files in the bebbo
557-
repo via chown before succesfully carrying out the next steps]
561+
repo via chown before successfully carrying out the next steps]
558562

559563
make clean
560564
make clean-prefix
@@ -692,5 +696,38 @@ Cross-compiler url: https://emscripten.org/docs/getting_started/downloads.html
692696
and shouldn't interfere with the non-cross-compile builds using
693697
hints/linux.370 or hints/macOS.370.
694698

699+
700+
+--------------------------------+
701+
| B7. Case sample: mips |
702+
+--------------------------------+
703+
704+
Cross-compiler used: gcc-mipsel-linux-gnu, g++-mipsel-linux-gnu
705+
Cross-compiler url:
706+
707+
Here's a brief guide to obtaining the cross-compiler sources on an
708+
Ubuntu system and building NetHack with it.
709+
710+
For Ubuntu, the build prerequisite packages for building the compiler can
711+
be easily obtained:
712+
sudo apt install gcc-mipsel-linux-gnu
713+
sudo apt install g++-mipsel-linux-gnu
714+
715+
On your linux host, prepare to cross-compile NetHack as follows:
716+
cd sys/unix ; sh setup.sh hints/linux.370 ; cd ../..
717+
make fetch-lua
718+
719+
Then, cross-compile to targets/mips as follows:
720+
make CROSS_TO_MIPS=1 fetch-ncurses
721+
make CROSS_TO_MIPS=1 package
722+
723+
Do not add any additional windowport interfaces to your build
724+
(such as WANT_WIN_TTY=1 WANT_WIN_CURSES=1 WANT_WIN_X11=1 or
725+
WANT_WIN_QT=1) as those aren't applicable to the mips cross-compile.
726+
727+
The cross-compiler hints additions are enclosed inside ifdef sections
728+
and shouldn't interfere with the non-cross-compile builds using
729+
hints/linux.370 or hints/macOS.370.
730+
731+
695732
---
696733

DEVEL/Developer.txt

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,36 @@ NOTE: These instructions assume you are on the default branch; this _is_
5858
NOTE: The following instructions require perl. If you do not have perl on
5959
your system, please install it before proceeding.
6060

61+
NOTE: More information on nhgitset.pl is available before installation via:
62+
perldoc DEVEL/nhgitset.pl
63+
After installation, the same information is available with:
64+
git nhhelp nhgitset
65+
6166
A. If you have never set up git on this machine before:
6267
(This assumes you will only be using git for NetHack. If you are going to
6368
use it for other projects as well, think before you type.)
6469
Tell git what name (or nickname) and email address to use for you:
6570
git config --global user.name "MY NAME"
6671
git config --global user.email USER@EXAMPLE.COM
6772
You probably want to set up a credential cache.
68-
macOS (10 - 12):
69-
git config --global credential.helper osxkeychain
70-
Windows:
71-
git config --global credential.helper store
72-
XXX linux
73+
macOS (10 or greater):
74+
git config --global credential.helper osxkeychain
75+
Linux:
76+
(This will vary by distribution.)
77+
cd /usr/share/doc/git/contrib/credentail/libsecret
78+
sudo apt-get install libglib-2.0-dev libsecret-1-dev
79+
sudo make
80+
git config --global credential.helper `pwd`/git-credential-libsecret
81+
OR
82+
sudo yum install git-credential-libsecret
83+
git config --global credential.helper /usr/libexec/git-core/git-credential-libsecret
84+
Windows: (The following three assume that Git for Windows is already installed on
85+
the underlying Windows system https://git-scm.com/download/win):
86+
git config --global credential.helper store
87+
MSYS2 UCRT64 bash shell:
88+
git config --global credential.helper "/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"
89+
Windows Subsystem for Linux 2 (WSL2) bash shell:
90+
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"
7391
B. Specify the prefix for variable substitution:
7492
(This assumes you are not a member of DevTeam or any variant's development
7593
team. If you are, this may be wrong. Look for more specific documentation.
@@ -79,10 +97,11 @@ B. Specify the prefix for variable substitution:
7997
tree you cloned from git. I use ~/nethack/GITADDDIR; for that base,
8098
create the needed directories and edit the file:
8199
~/nethack/GITADDDIR/DOTGIT/PRE
82-
Put this in it (if your OS is not Unix-like you may need to change
83-
the first line):
100+
Put this in it, adapting it to your variant (if your OS is not Unix-like
101+
you may need to change the first line):
84102
#!/bin/sh
85103
git config nethack.substprefix MINE
104+
git config nethack.projectname MineHack
86105
Now make it executable:
87106
chmod +x ~/nethack/GITADDDIR/DOTGIT/PRE
88107
C. Configure the repository:
@@ -156,8 +175,8 @@ A. Introduction
156175
The PREFIX is the value in the git config variable nethack.substprefix.
157176
VARNAME is one of:
158177
Date
159-
Branch (experimental)
160-
Revision (experimental)
178+
Branch
179+
Revision
161180
other names will give a warning.
162181

163182
B. Enabling variable expansion

DEVEL/VERSION

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
5
2+
Please see "git log DEVEL" for previous changes.
3+
Make documentation of nhgitset.pl easier to find and
4+
find out about.

DEVEL/code_features.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,23 @@ engine are incompatible.
101101
Additional regular expression implementations can be written. The full
102102
interface documentation is in sys/share/posixregex.c
103103

104+
===========================================================
105+
HEADER FILE NOTES
106+
107+
hack.h defines values that are available to all NetHack source files,
108+
contains enums for use in all NetHack source files, and contains a
109+
number of struct definitions for use in all NetHack source files.
110+
hack.h does not contain variable declarations or variable definitions.
111+
112+
decl.h and decl.c are related: decl.h contains the extern declarations
113+
for variables that are defined in decl.c. These variables are global
114+
and available to all NetHack source files.
115+
decl.c variable definitions are generally laid out in much the same
116+
order as their corresponding declarations in decl.h.
117+
118+
A new header file cstd.h was added to coincide with 3.7's switch to
119+
C99. It contains calls to some C99 standard header files.
120+
104121
=================== NEXT FEATURE ==========================
105122

106123

DEVEL/code_style.txt

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# NetHack 3.7 code_style.txt $NHDT-Date: 1596498264 2020/08/03 23:44:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.5 $
1+
# NetHack 3.7 code_style.txt $NHDT-Date: 1694890786 2023/09/16 18:59:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.8 $
22
# Copyright (c) 2015 by Derek S. Ray
33
# NetHack may be freely redistributed. See license for details.
44

@@ -45,7 +45,7 @@ possible:
4545
Single blank lines should be used wherever convenient to improve readability.
4646

4747
Functions and Control Statements
48-
-------------------------------
48+
--------------------------------
4949

5050
For a function definition, the return type, declarator, and opening brace
5151
should each appear on a line of their own. Arguments are defined in the following
@@ -170,6 +170,19 @@ Variable names to avoid
170170
processors with segmented architectures may treat
171171
those as keywords. It is safest to just avoid them.
172172

173+
NEARDATA Some data is marked with this define; the Amiga port uses
174+
it to mark data items to be used with a short addressing mode.
175+
You don't need to use this.
176+
177+
static vs staticfn
178+
------------------
179+
180+
The staticfn macro evaluates to either "static" or to nothing (see config.h).
181+
If possible, functions in src/*.c that would otherwise be marked static should
182+
be marked staticfn so platforms that do not name static functions in their
183+
stack traces can be forced to do so; this means function names cannot be
184+
reused. Never use staticfn with data.
185+
173186
Spaces in Expressions
174187
---------------------
175188

@@ -183,6 +196,63 @@ immediately inside a pair of parentheses:
183196
/* body */
184197
}
185198

199+
Casts and sizeof
200+
----------------
201+
202+
Casts should separate the cast operator and its expression with a space:
203+
'(char *) str'
204+
'sizeof (type)' requires the parentheses. 'sizeof expression' does not;
205+
using them is not wrong but omitting them avoids some visual clutter.
206+
Using them without the separating space gives the false impression of a
207+
function call or macro-with-argument(s) expansion; 'sizeof' is an operator
208+
and the parentheses required for '(type)' are to treat it like a cast.
209+
210+
Comments
211+
--------
212+
213+
Some block comments are undecorated, just split into reasonable width lines:
214+
/* this is
215+
a comment */
216+
They usually don't include sentence punctuation.
217+
218+
Others are more elaborate:
219+
/*
220+
* This is
221+
* another comment.
222+
*/
223+
This style is usually used with sentence punctuation, particularly if they
224+
contain more than one sentence.
225+
226+
End-of-line comments which need to span lines
227+
somecode(); /* this comment
228+
* is ok */
229+
should start every continuation line with an asterisk, otherwise clang-format
230+
would convert them into a block comment
231+
othercode(); /* this comment
232+
should be avoided */
233+
because it would be converted into
234+
othercode();
235+
/* this comment
236+
should be avoided */
237+
if another bulk reformatting ever gets performed. Similarly, multiple
238+
comments intended to read as one
239+
morecode(); /* start of comment */
240+
/* more of comment */
241+
/* end of comment */
242+
are deprecated because they will end up losing the indentation of the
243+
followup lines if reformatted.
244+
245+
Many files end with
246+
/*filename*/
247+
usually preceded by a blank line. This was intended as a workaround for a
248+
comment--somewhere, possibly in Amiga or Atari code--that stated that some
249+
compiler or other didn't always process the last line of the file. If that
250+
last line is a comment, nothing is lost. The real issue almost certainly
251+
was source file(s) that didn't end in newline. These days we try to force
252+
the final newline for every file, prior to release if not always maintained
253+
day-to-day. The name at the end can still be worthwhile when editing or
254+
browsing multiple files.
255+
186256
Vim Configuration
187257
=================
188258

@@ -202,7 +272,7 @@ ensure that indentation is done correctly:
202272
Visual Studio Configuration
203273
===========================
204274

205-
In Visual Studio under Tools->Options->Text Editor->C/C++, you can set the
275+
In Visual Studio under Tools->Options->Text Editor->C/C++, you can set the
206276
following options to obtain desired behavior:
207277

208278
[Tabs]
@@ -213,8 +283,8 @@ Insert Spaces
213283

214284
There are a number of other options under [Formatting] that should be
215285
checked (Indentation, New Lines, Spacing, and Wrapping), but there are so
216-
many entries that reproducing them here is impractical. Fortunately, the
217-
options are in plain English, so walking through them with a copy of
286+
many entries that reproducing them here is impractical. Fortunately, the
287+
options are in plain English, so walking through them with a copy of
218288
this Guide handy and making changes as required will suffice.
219289

220290
Emacs Configuration

0 commit comments

Comments
 (0)