Commit Graph

36 Commits

Author SHA1 Message Date
Pasi Kallinen
c266d05680 Minor special level and compiler tweakage
Fix allowed map characters.
Make some predefined MAPs blend in better with randomly
generated parts.
2015-04-10 16:47:32 +03:00
PatR
71d7eff0a7 revisit variable arguments in new lev_comp
The previous USE_OLDARGS worked with gcc on Intel, but was inherently
unsafe.  This method is completely safe, just obnoxiously intrusive.
It you disliked debugpline*(), you're bound to hate this....
2015-04-10 01:39:55 -07:00
PatR
9072e80085 support pre-ansi varargs in new lev_comp
Remove the requirement for <stdarg.h> that was introduced to lev_comp.
USE_STDARG still works.  USE_OLDARGS required hackery but has been
tested and actually works, although I wouldn't trust it on platforms
where 'long' and 'char *' aren't the same size.  USE_VARARGS didn't
require any hackery--aside from the conversion to core's pline code--
but has not been tested:  <varargs.h> supplied with OSX won't compile,
with an #error directive that basically says "switch to <stdarg.h>".

I changed several printf formats of %i and %li to %d and %ld because
I'm not sure how widespread the 'i' variant was back in days of yore.
[TODO:  avoid use of snprintf since pre-ANSI systems won't have it.]
2015-04-09 03:09:00 -07:00
Pasi Kallinen
68a39aeab4 Fix GCC warnings caused by new lev_comp 2015-04-03 17:40:54 +03:00
Pasi Kallinen
0a9248c7f1 Merge branch 'master' of https://rodney.nethack.org:20040/git/NHsource into paxed-new_lev_comp
Conflicts:
	doc/fixes35.0
	include/extern.h
	include/ntconf.h
	include/obj.h
	include/patchlevel.h
	src/dig.c
	src/do.c
	src/files.c
	src/fountain.c
	src/mklev.c
	src/objnam.c
	src/options.c
	src/potion.c
	src/rumors.c
	src/save.c
	src/topten.c
	src/trap.c
	src/wield.c
	sys/share/pcmain.c
	sys/unix/unixmain.c
	sys/winnt/Makefile.msc
	util/lev_main.c
	util/makedefs.c
2015-03-24 19:46:38 +02:00
Pasi Kallinen
8785f73b7f Use the correct declaration macro 2015-03-24 19:28:27 +02:00
nhmall
b1547c4770 include header file <ctype.h> in lev_main.c
options.c depends on ctype.h  and uses tolower()
so no sense getting into a discussion about
use of _that_
2015-03-24 19:26:01 +02:00
nhmall
c4009b781c Actually use the new routines in lev_main 2015-03-24 19:25:54 +02:00
nhmall
f9d22e02cd lev_main's own internal case-insensitive compare
TEST SUITE

int case_insensitive_comp(const char *, const char *);

/* define your built-in compiler library variation here */

/* #define BUILTIN(a,b) strcasecmp(a,b) */
/* #define BUILTIN(a,b) stricmp(a,b) */

int main(int argc, char *argv[])
{
	const char *t1 = "NetHack";
	const char *t2 = "nethack";
	const char *t3 = "Fred";
	const char *t4 = "Barney lived next door";

	/* try the results with built-in strcmpi first */

	printf("builtin:\tcompare <%s> to <%s>, result %d.\n",
		t1, t2, BUILTIN(t1,t2));
	printf("builtin:\tcompare <%s> to <%s>, result %d.\n",
		t3, t4, BUILTIN(t3,t4));

	/* try the results with case_insensitive_comp 2nd */

	printf("ours:\tcompare <%s> to <%s>, result %d.\n",
		t1, t2, case_insensitive_comp(t1,t2));
	printf("ours:\tcompare <%s> to <%s>, result %d.\n",
		t3, t4, case_insensitive_comp(t3,t4));

}

int
case_insensitive_comp(s1, s2)
const char *s1;
const char *s2;
{
    unsigned char u1, u2;

    for ( ; ; s1++, s2++) {
	u1 = tolower((unsigned char) *s1);
	u2 = tolower((unsigned char) *s2);
	if ((u1 == '\0') || (u1 != u2)) {
	    break;
	}
    }
    return u1-u2;
}

======================== END TEST SUITE ===========================
2015-03-24 19:25:45 +02:00
nhmall
c49dbcc5b3 include this also 2015-03-24 19:16:29 +02:00
nhmall
4c2df285b4 an easy fix for strcmpi and we move on
Here in branch paxed-new_lev_comp-B (branched
from paxed-new_lev_comp) is a simple fix
for the strcmpi issue.

The bottom section of lev_main.c has a bunch
of forced linkages to names from NetHack etc.
	#ifdef STRICT_REF_DEF
	bunch of stuff
	#endif

This change to lev_main should make everything
work for those that don't supply a compiler
library version of strcmpi()

With this patch, those people can just
add a -DSTRICT_REF_DEF to their compile line
for lev_main.c.

This would close the issue in a simple way,
and doesn't require linking in anything new to
the level compiler, or modifying any port's Makefiles etc.
2015-03-24 19:06:01 +02:00
Pasi Kallinen
47bb9abace New level compiler: code changes 2015-03-17 18:52:42 +02:00
Sean Hunt
44ca9fc16a Make SINKS unconditional. 2015-03-17 18:45:58 +02:00
keni
25cd007c48 Bulk recovery of file CVS headers and addition of NHDT- headers. 2015-03-17 18:45:12 +02:00
Sean Hunt
5ee71d2757 Make SINKS unconditional. 2015-02-27 19:33:06 -05:00
keni
03140969ee Bulk recovery of file CVS headers and addition of NHDT- headers. 2015-02-26 09:19:03 -05:00
nethack.rankin
eec34e4144 supress lev_main.c diagnostic (trunk only)
gcc warned about comparing signed with unsigned for one particular
write() that used an expression for the size argument, and there was already
conditional code to try to handle it for a couple of other compilers.  But
this simpler fix should handle it for everybody.
2012-01-12 04:48:12 +00:00
keni
4036a6727c Add RCS version lines 2009-05-06 10:55:43 +00:00
keni
c7858a6d37 more warning cleanup, makedefs grep bits (trunk only)
drop -Wcast-qual
warning cleanup (lev_comp)
comment bits
makedefs grep cleanup: drop magic constant, add --grep-define, --grep-undef,
 #ifdef out code not needed yet, update mdgrep.h, mdgrep.pl
2008-04-22 23:20:44 +00:00
nethack.rankin
697ec97812 hangup hangup bit (trunk only)
Accidentally left out  of the previous patch.
2007-01-18 05:12:36 +00:00
nethack.rankin
2ca87d8a5e more health food shops (trunk only)
Allow health food stores to carry eggs and tins of veggy contents in
their stock.  The tins will almost always contain spinach because random
tins containing meat are converted into that.

     Also, allow health food stores to be placed with the level compiler
(not tested) and to be forcibly placed in wizard mode via SHOPTYPE setting
of "V".  Increments EDITLEVEL in patchlevel.h because lighting store in
Minetown got renumbered and the special level for it needs to be rebuilt.
2005-03-13 05:29:01 +00:00
nethack.allison
e9b022d579 housekeeping: mark trunk sources 3.5 (misc) 2005-01-02 17:21:18 +00:00
nethack.allison
aa6f3df889 new context_info struct in compat checks (trunk only)
lev_main needed to reflect the change too.
2004-02-02 12:44:58 +00:00
kmhugo
1282e5c623 Synch recent 3.4.2 changes to main trunk
This is merely a synchronization of recent changes for the
Macintosh Carbon port, which were committed to the 3.4.2
branch, to the main trunk.
2003-08-30 00:45:58 +00:00
dean
78ae08d384 Place finished .lev files in the MPW build's destination directory. 2002-04-03 05:40:29 +00:00
nethack.allison
51f9892b3b Allow MICRO and WIN32 code paths to diverge
There's still a lot of overlap for 3.4.1, but not
100% any longer and it facilitates some improvements
- Allow error save files on WIN32
2002-03-30 19:09:56 +00:00
nethack.rankin
e835e2f420 lev_comp,dgn_comp vs CRLF style input
Allow the special level and dungeon compilers to handle input
files which have CR+LF delimited lines.  Apparently Cygwin doesn't
convert MSDOS style line ends into newlines the way stdio should
do for text I/O.  The resulting unexpected CR characters result in
syntax errors.

     And explicitly using '\n' on both the lex and yacc sides of
MAP processing allows removal of the old NEWLINE hack for Mac MPW.
It won't matter what numeric value that character escape sequence
has internally.
2002-03-28 01:37:39 +00:00
dean
007ddef858 Fix a typo. 2002-03-01 05:26:36 +00:00
nethack.allison
4b0dab0d0e <Someone> bit
in util/lev_main.c:write_maze(), line which reads
"Write(fd, &(pt->ngold), sizeof(pt->naltar));"

should read
"Write(fd, &(pt->ngold), sizeof(pt->ngold));"
2002-02-19 13:25:06 +00:00
nethack.allison
7d1e6f7d57 from Yitzhak
Add absent prototypes to some core routines.
Also add some port function() to function(void) in some win32 routines.
Also updates the Borland C Makefile for win32.
2002-02-05 13:21:43 +00:00
nethack.allison
742e1e8c90 3.3.2 to 3.4.0 2002-02-04 16:11:00 +00:00
kmhugo
263b6c06b1 Line numbering in lev_comp files
This patch allows the digits 0-9 to be used to indicate line numbers
in the MAP...ENDMAP arrays of level files.  This makes it a wee
bit easier to place features.  The digits get stripped out before
the map is interpreted.
2002-01-19 06:06:16 +00:00
nethack.allison
8ef53b7e30 Get rid of a compiler warning that has been there forever.
This finally gets the entire build process warning-free
under MSVC.
2002-01-15 03:37:36 +00:00
nethack.allison
e02ab47597 Changes to existing files by the win32 port additions. 2002-01-13 05:53:39 +00:00
kmhugo
95143950a9 Macintosh util update
* Updated preprocessor conditionals for the MPW compilers.
* Remove obsolete Mac code in util/*_comp.l.
2002-01-10 06:55:12 +00:00
jwalz
22c021f37c *** empty log message *** 2002-01-05 21:06:00 +00:00