Commit Graph

37 Commits

Author SHA1 Message Date
nhmall
50811037f3 split some code into separate files
new .h files: hacklib.h selvar.h stairs.h

new .c files: calendar.c, getpos.c, report.c, selvar.c, stairs.c,
              strutil.c, wizcmds.c

cleanup of hacklib.c and mdlib.c

hacklib contains functions that do not have to link with the core

relocate wiz commands from cmd.c to wizcmds.c

relocate CRASHREPORT stuff to report.c

relocate getpos stuff from do_name.c to getpos.c

remove temporary struct definition from extern.h

cross-compile PRE-section split into cross-pre1.370 and cross-pre2.370

Windows sys/windows/Makefile.nmake and sys/windows/Makefile.mingw32 and
visual studio project file updates

Unix sys/unix/Makefile.src, sys/unix/Makefile.utl

populate selvar.c and selvar.h

build on MS-DOS (not cross-compile) Makefile updates
for sys/msdos/Makefile.GCC (untested)

vms updates for above (untested)
2024-03-07 11:01:04 -05:00
nhmall
20d2ac726c have tile2bmp describe the bmp file layout 2024-02-16 22:15:09 -05:00
nhmall
9b01ab2fd5 some tilebmp.c code cleanup
Remove some conditional code that isn't needed these days.

Use C99 fixed width integer types for all platforms, instead
of using it for some and Microsoft types for others.
2023-01-16 13:58:58 -05:00
nhmall
11705aa108 free newbmp memory
Even though the program is exiting on the next line, free the
memory that was allocated. That should keep any monitoring tools
content.
2023-01-12 19:24:52 -05:00
Pasi Kallinen
698ac27146 Avoid magic numbers in tile2bmp 2023-01-12 17:34:58 +02:00
nhmall
40ebfab8e4 tab to spaces 2023-01-12 09:52:14 -05:00
nhmall
99a9f8600e remove some outdated code, tidy up 2023-01-12 09:42:02 -05:00
nhmall
45780b5d37 do exit 2023-01-12 09:21:53 -05:00
nhmall
a22b56174f fix actual problem of #955 by counting the tiles 2023-01-12 08:51:59 -05:00
PatR
a7756a1327 fix github issue #955 - tile2bmp bounds failure
Issue reported by argrath:  building with 'address sanitizing'
reported tile2bmp writing out of array bounds after the addition
of the generic object tiles.

'MAGICTILENO' in tile2bmp.c is extremely fragile.  It was already
inaccurate before the generic tiles, but had a big enough value to
handle the final row of tiles prior to that.

Fixes #955
2023-01-12 03:12:56 -08:00
nhmall
88f6df2d8b some tabs to spaces
cd src
    grep -P -n '\t' *.c | grep -v "1:"
    cd ../include
    grep -P -n '\t' *.h | grep -v "1:"
    cd ..

side note: win/Qt/*.cpp are full of tabs
2022-10-26 14:21:23 -04:00
PatR
687e7c12f7 implement realloc() for MONITOR_HEAP or vice versa
Add new routine 're_alloc()' that functions as MONITOR_HEAP-aware
libc realloc().  'nhrealloc()' is the version that passes source
file and line info if built with MONITOR_HEAP enabled.  The heaplog
data might now contain '<' (freed by realloc), '>' (replacement
allocation by realloc), and '*' (resized by realloc) entries in
addition to the previous '+' (allocated) and '-' (freed) entries.
heaputil has already been updated in the NHinternal repository.

Move FITSint_() and FITSuint_() from hacklib.c to alloc.c so that
they can be accessed by miscellaneous utility programs.

Remove three or four copies of FITSint_() that were duplicated in
utility programs like dlb and tile2bmp due to those not having
access to src/hacklib.o.  They do have access to src/alloc.o (and
util/panic.o).
2022-05-30 23:19:35 -07:00
nhkeni
ebe08a8c75 tile2bmp.c needs a local copy of FITSuint_ for alloc.o 2022-03-17 19:27:02 -04:00
nhmall
036169a3b1 bmp file Y dimension 2021-09-28 12:21:49 -04:00
nhmall
3af88b8802 Follow-up to earlier warning correction with Microsoft compiler
The earlier warning is architecture-dependent.

The warning showed up under an x64 build, but not an x86 build.
The __unaligned keyword is not supported under an x86 build.

Refine the preprocessor conditional.
2021-06-08 21:51:55 -04:00
nhmall
710efe4175 Microsoft compiler warning building tile2bmp.c
..\win\share\tile2bmp.c(234): warning C4366: The result of the unary '&'
operator may be unaligned
2021-06-08 14:38:47 -04: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
f963c5aca7 switch source tree from k&r to c99 2021-01-26 21:06:16 -05:00
nhmall
ac9ba38449 file header bump from "NetHack 3.6" to "NetHack 3.7" 2020-08-03 22:07:36 -04:00
PatR
3c6deed5e9 eliminate hack.h usage from win/share/*.c
Switch win/share/*.c from hack.h to config.h plus miscellaenous
other headers.  It's possible that there is conditional code that
didn't get exercised in my testing.  The Unix Makefiles don't deal
with safeproc.c or tileset.c so I just compiled those without any
attempt to link.
2020-05-03 10:52:54 -07:00
nhmall
1e47fe61b9 stale code 2019-07-14 12:17:47 -04:00
Bart House
74caa8d8e4 Moved pray.c globals to instance_globals. 2018-12-19 20:00:35 -08:00
Bart House
912886a73f First set of changes to move globals to instance_globals. 2018-12-19 20:00:35 -08:00
Bart House
8944235282 Enforced the inclusion of windows headers before nethack headers.
Moved the code page 437 mapping table to winnt.c so that it could be
used in window and console clients.
Added check that fonts support unicode values we use from code page 437.
Use unicode to draw text if font supports it otherwise use ASCII.
2018-11-12 01:58:56 -08:00
Pasi Kallinen
030e3c0dfd Use the graymapping stuff in the tile lib 2016-06-23 10:15:55 +03:00
nhmall
5964438e8f use explicit int sizes in win/share/tile2bin.c
64-bit longs caused tile2bin to write an invalid bmp file.
2015-12-29 21:21:05 -05:00
Sean Hunt
97d6fade74 Reformat all C files.
I'll push a formatting guide at some point. There may still be
outstanding changes, but please feel free to resolve those as you arrive
a them.

To the best of my knowledge, there is no changes to the actual code
content, but the formatter does have the occasional bug. If you run into
an issue, please fix it!
2015-05-09 13:43:16 -04:00
karnov
2a907f894e Version number increment 2015-05-06 22:04:27 -04:00
nhmall
0827c0df9d Update the tile RGB values and mappings
Changes to be committed:
	modified:   win/share/monsters.txt
	modified:   win/share/objects.txt
	modified:   win/share/other.txt
	modified:   win/share/tile2bmp.c
	modified:   win/share/tiletext.c
2015-04-19 17:17:03 -04:00
nhmall
56c4475c20 extend the tty statue patch to tiles
Changes to be committed:
	modified:   doc/fixes35.0
	modified:   win/share/gifread.c
	modified:   win/share/monsters.txt
	modified:   win/share/objects.txt
	modified:   win/share/other.txt
	modified:   win/share/tile2bmp.c
	modified:   win/share/tilemap.c

The tty code already had the statue patch included, where
statues are represented by stone versions similar in
appearance to their monster likeness.

This extends it to tiles.

A new pass through the monsters.txt file is done
in tile2bmp to include new modified tiles to the output
file that are gray-scaled versions for mapping to the
NetHack statue glyphs.
2015-04-19 13:31:59 -04:00
keni
03140969ee Bulk recovery of file CVS headers and addition of NHDT- headers. 2015-02-26 09:19:03 -05:00
keni
665dedc3de Add RCS version lines 2009-05-06 11:00:43 +00:00
nethack.allison
e9b022d579 housekeeping: mark trunk sources 3.5 (misc) 2005-01-02 17:21:18 +00:00
warwick
b6ff9d7d73 Use __BIG_ENDIAN__ rather than __ppc__ (more portable, more meaningful). 2003-09-16 00:20:18 +00:00
warwick
4c2486026e Work on BigEndian systems too. Only __ppc__ detected for now (Mac OS X). 2003-09-11 04:00:21 +00:00
nethack.allison
53a7785c48 djgpp parts to general gcc parts 2002-03-14 13:10:17 +00:00
nethack.allison
6c749785e8 Move tile2bmp.c to win/share
This is so it can be shared with Qt.
If, for some reason, we have to cut another source tarball for
3.4.0, then this will be included.  Otherwise, this will
turn out to be a post-3.4.0 patch.
2002-03-14 12:54:06 +00:00