Browse Source

Remove vision tables from makedefs

Update makdefs source and its man page.

Remove all mentions of the vision table files from:
o .gitattributes
o .gitignore
o Files
o Cross-compiling

Add a brief note in the fixes file.
NetHack-3.7
Dean Luick 9 months ago
parent
commit
3ffd330c31
  1. 2
      Cross-compiling
  2. 3
      Files
  3. 1
      doc/fixes37.0
  4. 8
      doc/makedefs.6
  5. 42
      doc/makedefs.txt
  6. 3
      include/.gitattributes
  7. 1
      include/.gitignore
  8. 4
      src/.gitattributes
  9. 1
      src/.gitignore
  10. 416
      util/makedefs.c

2
Cross-compiling

@ -388,7 +388,7 @@ Using the cross-compiler, build the following targets:
src/symbols.c, src/sys.c, src/teleport.c,
src/timeout.c, src/topten.c, src/track.c,
src/trap.c, src/u_init.c, src/uhitm.c, src/vault.c,
src/version.c, src/vis_tab.c, src/vision.c,
src/version.c, src/vision.c,
src/weapon.c, src/were.c, src/wield.c, src/windows.c,
src/wizard.c, src/worm.c, src/worn.c, src/write.c,
src/zap.c, sys/share/cppregex.cpp

3
Files

@ -537,7 +537,7 @@ tile.h
win32api.h
(files generated by makedefs at compile time)
date.h onames.h pm.h vis_tab.h
date.h onames.h pm.h
(files generated by yacc (or copied from sys/share) at compile time)
dgn_comp.h lev_comp.h
@ -553,7 +553,6 @@ qt_kde0.moc qt_win.moc qttableview.moc
monstr.c
(file generated by makedefs at compile time)
vis_tab.c
(file optionally generated by tilemap at compile time)
tile.c

1
doc/fixes37.0

@ -478,6 +478,7 @@ replace "aligned priest" entries in Pri-loca.lua, astral.lua, minetn-1.lua,
and sanctum.lua, with "aligned cleric"
attempting to swap places with a peaceful monster might cause it to flee
gender-specific monster names can be used in .lua files with the gender upheld
remove unused vision tables
curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support

8
doc/makedefs.6

@ -34,8 +34,6 @@ makedefs \- NetHack miscellaneous build-time functions
.B -r
|
.B -h
|
.B -z
}
.P
.B makedefs --input
@ -127,12 +125,6 @@ Generate the
.B oracles
file.
.br
.TP
.B -z
Generate
.I vis_tab.c
and
.IR vis_tab.h .
.SH LONG COMMANDS
.TP
.B --debug

42
doc/makedefs.txt

@ -6,7 +6,7 @@ NAME
makedefs - NetHack miscellaneous build-time functions
SYNOPSIS
makedefs { -o | -d | -e | -m | -v | -p | -q | -r | -h | -z }
makedefs { -o | -d | -e | -m | -v | -p | -q | -r | -h }
makedefs --input file --output file --command
@ -26,19 +26,22 @@ SHORT COMMANDS
-d Generate data.base.
-v Generate date.h and options file. It will read dat/gitinfo.txt,
-e Generate dungeon.pdf. The input file dungeon.def is passed
through the same logic as that used by the --grep command; see
the MDGREP FUNCTIONS section below for details.
-m Generate date.h and options file. It will read dat/gitinfo.txt,
only if it is present, to obtain githash= and gitbranch=
info and include related preprocessor #defines in date.h file.
-p Generate pm.h
-r Generate the rumors file.
-q Generate the rumors file.
-s Generate the bogusmon , engrave and epitaphfiles.
-h Generate the oracles file.
-z Generate vis_tab.c and vis_tab.h.
LONG COMMANDS
--debug
Show debugging output.
@ -60,13 +63,13 @@ LONG COMMANDS
newline. If specified, the delimiter is used between each part
of the version string.
--grep Filter the input file to the output file. See the MDGREP FUNC-
--grep Filter the input file to the output file. See the MDGREP FUNC
TIONS section below for information on controlling the filtering
operation.
--grep-showvars
Show the name and value for each variable known to the grep
option.
Show the name and value for each variable known to the grep op‐
tion.
--grep-trace
Turn on debug tracing for the grep function ( --grep must be
@ -83,32 +86,32 @@ LONG COMMANDS
MDGREP FUNCTIONS
The --grep command (and certain other commands) filter their input, on
a line-by-line basis, according to control lines embedded in the input
and on information gleaned from the NetHack(6) configuration. This
allows certain changes such as embedding platform-specific documenta-
tion into the master documentation files.
and on information gleaned from the NetHack(6) configuration. This al‐
lows certain changes such as embedding platform-specific documentation
into the master documentation files.
Rules:
- The default conditional state is printing enabled.
- Any line NOT starting with a caret (^) is either suppressed
or passed through unchanged depending on the current condi-
or passed through unchanged depending on the current condi
tional state.
- Any line starting with a caret is a control line; as in C,
zero or more spaces may be embedded in the line almost any-
zero or more spaces may be embedded in the line almost any
where (except immediately after the caret); however the
caret must be in column 1.
- Conditionals may be nested.
- Makedefs will exit with an error code if any errors are
detected; processing will continue (if it can) to allow as
- Makedefs will exit with an error code if any errors are de‐
tected; processing will continue (if it can) to allow as
many errors as possible to be detected.
- Unknown identifiers are treated as both TRUE and as an
error. Note that --undef or #undef in the NetHack(6) con-
figuration are different from unknown.
- Unknown identifiers are treated as both TRUE and as an er‐
ror. Note that --undef or #undef in the NetHack(6) configu‐
ration are different from unknown.
Control lines:
@ -134,10 +137,9 @@ SEE ALSO
COPYRIGHT
This file is Copyright (C) Kenneth Lorber and was last modified
2018/04/25 (version NetHack-3.6.0:1.10). NetHack may be freely redis-
2018/04/25 (version NetHack-3.6.0:1.10). NetHack may be freely redis
tributed. See license for details.
NETHACK 1 Jan 2020 MAKEDEFS(6)

3
include/.gitattributes

@ -1,5 +1,5 @@
* NH_filestag=(file%s_for_all_versions)
..files NH_filegenerated=win32api.h,tile.h,dgn_comp.h,lev_comp.h,date.h,onames.h,pm.h,vis_tab.h
..files NH_filegenerated=win32api.h,tile.h,dgn_comp.h,lev_comp.h,date.h,onames.h,pm.h
win32api.h NH_filesgentag=(file%s_for_win32_that_are_moved_into_include_at_compile_time)
@ -11,7 +11,6 @@ lev_comp.h NH_filesgentag=>dgn_comp.h
date.h NH_filesgentag=(file%s_generated_by_makedefs_at_compile_time)
onames.h NH_filesgentag=>date.h
pm.h NH_filesgentag=>date.h
vis_tab.h NH_filesgentag=>date.h
wintty.h NH_filestag=(file%s_for_tty_versions)

1
include/.gitignore

@ -2,7 +2,6 @@
date.h
onames.h
pm.h
vis_tab.h
dgn_comp.h
lev_comp.h
tile.h

4
src/.gitattributes

@ -1,5 +1,5 @@
* NH_filestag=(file%s_for_all_versions)
..files NH_filegenerated=Makefile,Makefile.bcc,Makefile.gcc,qt_kde0.moc,qt_win.moc,qttableview.moc,tile.c,monstr.c,vis_tab.c
..files NH_filegenerated=Makefile,Makefile.bcc,Makefile.gcc,qt_kde0.moc,qt_win.moc,qttableview.moc,tile.c,monstr.c
Makefile.bcc NH_filesgentag=(file%s_for_win32_that_are_moved_into_src_at_compile_time)
Makefile.gcc NH_filesgentag=>Makefile.bcc
Makefile NH_filesgentag=>Makefile.bcc
@ -10,5 +10,3 @@ qttableview.moc NH_filesgentag=>qt_kde0.moc
tile.c NH_filesgentag=(file%s_optionally_generated_by_tilemap_at_compile_time)
monstr.c NH_filesgentag=(file%s_generated_by_makedefs_at_compile_time_by_some_ports)
vis_tab.c NH_filesgentag=(file%s_generated_by_makedefs_at_compile_time)

1
src/.gitignore

@ -1,5 +1,4 @@
config.h-t
vis_tab.c
monstr.c
hack.h-t
tile.c

416
util/makedefs.c

@ -66,8 +66,6 @@ static const char SCCS_Id[] UNUSED = "@(#)makedefs.c\t3.7\t2020/01/18";
#define QTXT_I_FILE "quest.txt"
#define QTXT_O_FILE "quest.dat"
#endif
#define VIS_TAB_H "vis_tab.h"
#define VIS_TAB_C "vis_tab.c"
#define GITINFO_FILE "gitinfo.txt"
/* locations for those files */
#ifdef AMIGA
@ -114,24 +112,7 @@ static const char
static struct version_info version;
/* definitions used for vision tables */
#define TEST_WIDTH COLNO
#define TEST_HEIGHT ROWNO
#define BLOCK_WIDTH (TEST_WIDTH + 10)
#define BLOCK_HEIGHT TEST_HEIGHT /* don't need extra spaces */
#define MAX_ROW (BLOCK_HEIGHT + TEST_HEIGHT)
#define MAX_COL (BLOCK_WIDTH + TEST_WIDTH)
/* Use this as an out-of-bound value in the close table. */
#define CLOSE_OFF_TABLE_STRING "99" /* for the close table */
#define FAR_OFF_TABLE_STRING "0xff" /* for the far table */
#define FLG_TEMPFILE 0x01 /* flag for temp file */
#define sign(z) ((z) < 0 ? -1 : ((z) ? 1 : 0))
#ifdef VISION_TABLES
static char xclear[MAX_ROW][MAX_COL];
#endif
/*-end of vision defs-*/
#define MAXFNAMELEN 600
static char filename[MAXFNAMELEN];
@ -158,7 +139,6 @@ void NDECL(do_permonst);
void NDECL(do_questtxt);
void NDECL(do_rumors);
void NDECL(do_oracles);
void NDECL(do_vision);
void NDECL(do_date);
extern void NDECL(monst_globals_init); /* monst.c */
@ -175,14 +155,6 @@ static boolean FDECL(d_filter, (char *));
static boolean FDECL(h_filter, (char *));
static void FDECL(opt_out_words, (char *, int *));
#ifdef VISION_TABLES
static void NDECL(H_close_gen);
static void NDECL(H_far_gen);
static void NDECL(C_close_gen);
static void NDECL(C_far_gen);
static int FDECL(clear_path, (int, int, int, int));
#endif
static char *FDECL(fgetline, (FILE*));
static char *FDECL(tmpdup, (const char *));
static char *FDECL(limit, (char *, int));
@ -355,10 +327,6 @@ char *options;
case 'H':
do_oracles();
break;
case 'z':
case 'Z':
do_vision();
break;
default:
Fprintf(stderr, "Unknown option '%c'.\n", *options);
@ -2251,390 +2219,6 @@ const char *str;
return buf;
}
/*
* macro used to control vision algorithms:
* VISION_TABLES => generate tables
*/
void
do_vision()
{
#ifdef VISION_TABLES
int i, j;
/* Everything is clear. xclear may be malloc'ed.
* Block the upper left corner (BLOCK_HEIGHTxBLOCK_WIDTH)
*/
for (i = 0; i < MAX_ROW; i++)
for (j = 0; j < MAX_COL; j++)
if (i < BLOCK_HEIGHT && j < BLOCK_WIDTH)
xclear[i][j] = '\000';
else
xclear[i][j] = '\001';
#endif /* VISION_TABLES */
SpinCursor(3);
/*
* create the include file, "vis_tab.h"
*/
filename[0] = '\0';
#ifdef FILE_PREFIX
Strcat(filename, file_prefix);
#endif
Sprintf(eos(filename), INCLUDE_TEMPLATE, VIS_TAB_H);
if (!(ofp = fopen(filename, WRTMODE))) {
perror(filename);
exit(EXIT_FAILURE);
}
Fprintf(ofp, "%s", Dont_Edit_Code);
Fprintf(ofp, "#ifdef VISION_TABLES\n");
#ifdef VISION_TABLES
H_close_gen();
H_far_gen();
#endif /* VISION_TABLES */
Fprintf(ofp, "\n#endif /* VISION_TABLES */\n");
Fclose(ofp);
SpinCursor(3);
/*
* create the source file, "vis_tab.c"
*/
filename[0] = '\0';
#ifdef FILE_PREFIX
Strcat(filename, file_prefix);
#endif
Sprintf(eos(filename), SOURCE_TEMPLATE, VIS_TAB_C);
if (!(ofp = fopen(filename, WRTMODE))) {
perror(filename);
/* creating vis_tab.c failed; remove the vis_tab.h we just made */
filename[0] = '\0';
#ifdef FILE_PREFIX
Strcat(filename, file_prefix);
#endif
Sprintf(eos(filename), INCLUDE_TEMPLATE, VIS_TAB_H);
Unlink(filename);
exit(EXIT_FAILURE);
}
Fprintf(ofp, "%s", Dont_Edit_Code);
Fprintf(ofp, "#include \"config.h\"\n");
Fprintf(ofp, "#ifdef VISION_TABLES\n");
Fprintf(ofp, "#include \"vis_tab.h\"\n");
SpinCursor(3);
#ifdef VISION_TABLES
C_close_gen();
C_far_gen();
Fprintf(ofp, "\nvoid vis_tab_init() { return; }\n");
#endif /* VISION_TABLES */
SpinCursor(3);
Fprintf(ofp, "\n#endif /* VISION_TABLES */\n");
Fprintf(ofp, "\n/*vis_tab.c*/\n");
Fclose(ofp);
return;
}
#ifdef VISION_TABLES
/*-------------- vision tables --------------*\
*
* Generate the close and far tables. This is done by setting up a
* fake dungeon and moving our source to different positions relative
* to a block and finding the first/last visible position. The fake
* dungeon is all clear execpt for the upper left corner (BLOCK_HEIGHT
* by BLOCK_WIDTH) is blocked. Then we move the source around relative
* to the corner of the block. For each new position of the source
* we check positions on rows "kittycorner" from the source. We check
* positions until they are either in sight or out of sight (depends on
* which table we are generating). The picture below shows the setup
* for the generation of the close table. The generation of the far
* table would switch the quadrants of the '@' and the "Check rows
* here".
*
*
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,,,,,,,,, Check rows here ,,,,,,,,,,,,
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXB,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
* ...............................
* ...............................
* .........@.....................
* ...............................
*
* Table generation figure (close_table). The 'X's are blocked points.
* The 'B' is a special blocked point. The '@' is the source. The ','s
* are the target area. The '.' are just open areas.
*
*
* Example usage of close_table[][][].
*
* The table is as follows:
*
* dy = |row of '@' - row of 'B'| - 1
* dx = |col of '@' - col of 'B'|
*
* The first indices are the deltas from the source '@' and the block 'B'.
* You must check for the value inside the abs value bars being zero. If
* so then the block is on the same row and you don't need to do a table
* lookup. The last value:
*
* dcy = |row of block - row to be checked|
*
* Is the value of the first visible spot on the check row from the
* block column. So
*
* first visible col = close_table[dy][dx][dcy] + col of 'B'
*
\*-------------- vision tables --------------*/
static void
H_close_gen()
{
Fprintf(ofp, "\n/* Close */\n");
Fprintf(ofp,
"#define CLOSE_MAX_SB_DY %2d\t/* |src row - block row| - 1\t*/\n",
TEST_HEIGHT - 1);
Fprintf(ofp,
"#define CLOSE_MAX_SB_DX %2d\t/* |src col - block col|\t*/\n",
TEST_WIDTH);
Fprintf(ofp,
"#define CLOSE_MAX_BC_DY %2d\t/* |block row - check row|\t*/\n",
TEST_HEIGHT);
Fprintf(ofp, "typedef struct {\n");
Fprintf(ofp,
" unsigned char close[CLOSE_MAX_SB_DX][CLOSE_MAX_BC_DY];\n");
Fprintf(ofp, "} close2d;\n");
Fprintf(ofp, "extern close2d close_table[CLOSE_MAX_SB_DY];\n");
return;
}
static void
H_far_gen()
{
Fprintf(ofp, "\n/* Far */\n");
Fprintf(ofp, "#define FAR_MAX_SB_DY %2d\t/* |src row - block row|\t*/\n",
TEST_HEIGHT);
Fprintf(ofp,
"#define FAR_MAX_SB_DX %2d\t/* |src col - block col| - 1\t*/\n",
TEST_WIDTH - 1);
Fprintf(ofp,
"#define FAR_MAX_BC_DY %2d\t/* |block row - check row| - 1\t*/\n",
TEST_HEIGHT - 1);
Fprintf(ofp, "typedef struct {\n");
Fprintf(ofp, " unsigned char far_q[FAR_MAX_SB_DX][FAR_MAX_BC_DY];\n");
Fprintf(ofp, "} far2d;\n");
Fprintf(ofp, "extern far2d far_table[FAR_MAX_SB_DY];\n");
return;
}
static void
C_close_gen()
{
int i, dx, dy;
int src_row, src_col; /* source */
int block_row, block_col; /* block */
int this_row;
int no_more;
const char *delim;
block_row = BLOCK_HEIGHT - 1;
block_col = BLOCK_WIDTH - 1;
Fprintf(ofp, "\n#ifndef FAR_TABLE_ONLY\n");
Fprintf(ofp, "\nclose2d close_table[CLOSE_MAX_SB_DY] = {\n");
#ifndef no_vision_progress
Fprintf(stderr, "\nclose:");
#endif
for (dy = 1; dy < TEST_HEIGHT; dy++) {
src_row = block_row + dy;
Fprintf(ofp, "/* DY = %2d (- 1)*/\n {{\n", dy);
#ifndef no_vision_progress
Fprintf(stderr, " %2d", dy), (void) fflush(stderr);
#endif
for (dx = 0; dx < TEST_WIDTH; dx++) {
src_col = block_col - dx;
Fprintf(ofp, " /*%2d*/ {", dx);
no_more = 0;
for (this_row = 0; this_row < TEST_HEIGHT; this_row++) {
delim = (this_row < TEST_HEIGHT - 1) ? "," : "";
if (no_more) {
Fprintf(ofp, "%s%s", CLOSE_OFF_TABLE_STRING, delim);
continue;
}
SpinCursor(3);
/* Find the first column that we can see. */
for (i = block_col + 1; i < MAX_COL; i++) {
if (clear_path(src_row, src_col, block_row - this_row, i))
break;
}
if (i == MAX_COL)
no_more = 1;
Fprintf(ofp, "%2d%s", i - block_col, delim);
}
Fprintf(ofp, "}%s", (dx < TEST_WIDTH - 1) ? ",\n" : "\n");
}
Fprintf(ofp, " }},\n");
}
Fprintf(ofp, "}; /* close_table[] */\n"); /* closing brace for table */
Fprintf(ofp, "#endif /* !FAR_TABLE_ONLY */\n");
#ifndef no_vision_progress
Fprintf(stderr, "\n");
#endif
return;
}
static void
C_far_gen()
{
int i, dx, dy;
int src_row, src_col; /* source */
int block_row, block_col; /* block */
int this_row;
const char *delim;
block_row = BLOCK_HEIGHT - 1;
block_col = BLOCK_WIDTH - 1;
Fprintf(ofp, "\n#ifndef CLOSE_TABLE_ONLY\n");
Fprintf(ofp, "\nfar2d far_table[FAR_MAX_SB_DY] = {\n");
#ifndef no_vision_progress
Fprintf(stderr, "\n_far_:");
#endif
for (dy = 0; dy < TEST_HEIGHT; dy++) {
src_row = block_row - dy;
Fprintf(ofp, "/* DY = %2d */\n {{\n", dy);
#ifndef no_vision_progress
Fprintf(stderr, " %2d", dy), (void) fflush(stderr);
#endif
for (dx = 1; dx < TEST_WIDTH; dx++) {
src_col = block_col + dx;
Fprintf(ofp, " /*%2d(-1)*/ {", dx);
for (this_row = block_row + 1; this_row < block_row + TEST_HEIGHT;
this_row++) {
delim = (this_row < block_row + TEST_HEIGHT - 1) ? "," : "";
SpinCursor(3);
/* Find first col that we can see. */
for (i = 0; i <= block_col; i++) {
if (clear_path(src_row, src_col, this_row, i))
break;
}
if (block_col - i < 0)
Fprintf(ofp, "%s%s", FAR_OFF_TABLE_STRING, delim);
else
Fprintf(ofp, "%2d%s", block_col - i, delim);
}
Fprintf(ofp, "}%s", (dx < TEST_WIDTH - 1) ? ",\n" : "\n");
}
Fprintf(ofp, " }},\n");
}
Fprintf(ofp, "}; /* far_table[] */\n"); /* closing brace for table */
Fprintf(ofp, "#endif /* !CLOSE_TABLE_ONLY */\n");
#ifndef no_vision_progress
Fprintf(stderr, "\n");
#endif
return;
}
/*
* "Draw" a line from the hero to the given location. Stop if we hit a
* wall.
*
* Generalized integer Bresenham's algorithm (fast line drawing) for
* all quadrants. From _Procedural Elements for Computer Graphics_, by
* David F. Rogers. McGraw-Hill, 1985.
*
* I have tried a little bit of optimization by pulling compares out of
* the inner loops.
*
* NOTE: This had better *not* be called from a position on the
* same row as the hero.
*/
static int
clear_path(you_row, you_col, y2, x2)
int you_row, you_col, y2, x2;
{
int dx, dy, s1, s2;
register int i, error, x, y, dxs, dys;
x = you_col;
y = you_row;
dx = abs(x2 - you_col);
dy = abs(y2 - you_row);
s1 = sign(x2 - you_col);
s2 = sign(y2 - you_row);
if (s1 == 0) { /* same column */
if (s2 == 1) { /* below (larger y2 value) */
for (i = you_row + 1; i < y2; i++)
if (!xclear[i][you_col])
return 0;
} else { /* above (smaller y2 value) */
for (i = y2 + 1; i < you_row; i++)
if (!xclear[i][you_col])
return 0;
}
return 1;
}
/*
* Lines at 0 and 90 degrees have been weeded out.
*/
if (dy > dx) {
error = dx;
dx = dy;
dy = error; /* swap the values */
dxs = dx << 1; /* save the shifted values */
dys = dy << 1;
error = dys - dx; /* NOTE: error is used as a temporary above */
for (i = 0; i < dx; i++) {
if (!xclear[y][x])
return 0; /* plot point */
while (error >= 0) {
x += s1;
error -= dxs;
}
y += s2;
error += dys;
}
} else {
dxs = dx << 1; /* save the shifted values */
dys = dy << 1;
error = dys - dx;
for (i = 0; i < dx; i++) {
if (!xclear[y][x])
return 0; /* plot point */
while (error >= 0) {
y += s2;
error -= dxs;
}
x += s1;
error += dys;
}
}
return 1;
}
#endif /* VISION_TABLES */
#ifdef STRICT_REF_DEF
NEARDATA struct flag flags;
#ifdef ATTRIB_H

Loading…
Cancel
Save