Compare commits
10 Commits
NetHack-3.
...
twitch-int
| Author | SHA1 | Date | |
|---|---|---|---|
| dc920f6af4 | |||
| eee77d0f1b | |||
| 6642a731c7 | |||
| 85cc045400 | |||
| ebed555f0a | |||
| b7281f0b28 | |||
| 71deeb0416 | |||
| a34a07bb75 | |||
| d03582f685 | |||
| ab0dd2de6e |
@@ -2524,6 +2524,7 @@ extern const char *udeadinside(void);
|
||||
|
||||
/* ### potion.c ### */
|
||||
|
||||
extern long itimeout_incr(long, int);
|
||||
extern void set_itimeout(long *, long) NONNULLARG1;
|
||||
extern void incr_itimeout(long *, int) NONNULLARG1;
|
||||
extern void make_confused(long, boolean);
|
||||
@@ -2558,6 +2559,8 @@ extern void speed_up(long);
|
||||
|
||||
extern boolean critically_low_hp(boolean);
|
||||
extern boolean stuck_in_wall(void);
|
||||
extern int in_trouble(void);
|
||||
extern void fix_worst_trouble(int);
|
||||
extern void desecrate_altar(boolean, aligntyp);
|
||||
extern int dosacrifice(void);
|
||||
extern boolean can_pray(boolean);
|
||||
@@ -3352,6 +3355,11 @@ extern void ignite_items(struct obj *) NO_NNARGS;
|
||||
extern void trap_ice_effects(coordxy x, coordxy y, boolean ice_is_melting);
|
||||
extern void trap_sanity_check(void);
|
||||
|
||||
/* ### twitch.c ### */
|
||||
|
||||
extern void open_twitch(void);
|
||||
extern void check_twitch(void);
|
||||
|
||||
/* ### u_init.c ### */
|
||||
|
||||
extern void u_init_misc(void);
|
||||
|
||||
@@ -108,6 +108,8 @@ moveloop_preamble(boolean resuming)
|
||||
invent is fully populated and the in_moveloop flag has been set */
|
||||
if (iflags.perm_invent)
|
||||
update_inventory();
|
||||
|
||||
open_twitch();
|
||||
}
|
||||
|
||||
staticfn void
|
||||
@@ -538,6 +540,7 @@ moveloop_core(void)
|
||||
#ifdef MAIL
|
||||
ckmailstatus();
|
||||
#endif
|
||||
check_twitch();
|
||||
rhack(0);
|
||||
}
|
||||
if (u.utotype) /* change dungeon level */
|
||||
@@ -857,6 +860,10 @@ newgame(void)
|
||||
void
|
||||
welcome(boolean new_game) /* false => restoring an old game */
|
||||
{
|
||||
#ifndef NO_SIGNAL
|
||||
(void) signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
|
||||
char buf[BUFSZ];
|
||||
boolean currentgend = Upolyd ? u.mfemale : flags.female;
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "hack.h"
|
||||
|
||||
staticfn long itimeout(long);
|
||||
staticfn long itimeout_incr(long, int);
|
||||
staticfn void ghost_from_bottle(void);
|
||||
staticfn int drink_ok(struct obj *);
|
||||
staticfn void peffect_restore_ability(struct obj *);
|
||||
|
||||
@@ -7,9 +7,7 @@
|
||||
staticfn int prayer_done(void);
|
||||
staticfn void maybe_turn_mon_iter(struct monst *);
|
||||
staticfn struct obj *worst_cursed_item(void);
|
||||
staticfn int in_trouble(void);
|
||||
staticfn void fix_curse_trouble(struct obj *, const char *);
|
||||
staticfn void fix_worst_trouble(int);
|
||||
staticfn void angrygods(aligntyp);
|
||||
staticfn void at_your_feet(const char *);
|
||||
staticfn void gcrownu(void);
|
||||
|
||||
244
src/twitch.c
Normal file
244
src/twitch.c
Normal file
@@ -0,0 +1,244 @@
|
||||
#include "hack.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
static int twitch_in_fd = -1;
|
||||
static int twitch_out_fd = -1;
|
||||
static char twitch_buf[1024];
|
||||
static int twitch_buf_size;
|
||||
static char infile[SAVESIZE + 3];
|
||||
static char outfile[SAVESIZE + 4];
|
||||
static time_t last_check = 0;
|
||||
|
||||
staticfn void process_twitch_cmd(char*);
|
||||
staticfn boolean has_out_file(void);
|
||||
staticfn void failed_effect(char*);
|
||||
staticfn void successful_effect(char*);
|
||||
staticfn void grant_object(char*);
|
||||
|
||||
void open_twitch(void) {
|
||||
snprintf(infile, SAVESIZE + 3, "%s.in", gs.SAVEF);
|
||||
snprintf(outfile, SAVESIZE + 4, "%s.out", gs.SAVEF);
|
||||
|
||||
twitch_in_fd = open(infile, O_RDONLY | O_NONBLOCK);
|
||||
if (twitch_in_fd >= 0) {
|
||||
twitch_out_fd = open(outfile, O_WRONLY | O_NONBLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
void check_twitch(void) {
|
||||
if (twitch_in_fd < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
time_t now = getnow();
|
||||
if (timet_delta(now, last_check) < 5) {
|
||||
return;
|
||||
}
|
||||
|
||||
last_check = now;
|
||||
|
||||
int size;
|
||||
size = read(twitch_in_fd, &twitch_buf[twitch_buf_size], 1024 - twitch_buf_size);
|
||||
|
||||
if (size < 0) {
|
||||
if (errno == EAGAIN) {
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (size > 0) {
|
||||
twitch_buf_size += size;
|
||||
|
||||
int i;
|
||||
boolean done;
|
||||
done = FALSE;
|
||||
|
||||
while (!done) {
|
||||
done = TRUE;
|
||||
for (i = 0; i < twitch_buf_size; i++) {
|
||||
if (twitch_buf[i] == '\r' || twitch_buf[i] == '\n') {
|
||||
twitch_buf[i] = '\0';
|
||||
if (i > 0) {
|
||||
process_twitch_cmd(twitch_buf);
|
||||
}
|
||||
int j;
|
||||
for (j = 0; j + i + 1 < twitch_buf_size; j++) {
|
||||
twitch_buf[j] = twitch_buf[j + i + 1];
|
||||
}
|
||||
twitch_buf_size -= i + 1;
|
||||
done = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
staticfn void process_twitch_cmd(char *cmd) {
|
||||
char *id = strtok(cmd, " ");
|
||||
char *effect = strtok(NULL, " ");
|
||||
|
||||
if (effect == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcmp(effect, "create_monster")) {
|
||||
create_critters(1, NULL, FALSE);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "identify")) {
|
||||
identify_pack(1, TRUE);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "teleport")) {
|
||||
/* Temporarily stun the player, if they are not already, to prevent teleport control */
|
||||
boolean removestun = FALSE;
|
||||
if (!Stunned) {
|
||||
removestun = TRUE;
|
||||
make_stunned(1L, FALSE);
|
||||
}
|
||||
tele();
|
||||
if (removestun) {
|
||||
make_stunned(0L, FALSE);
|
||||
}
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "level_teleport")) {
|
||||
if (u.uhave.amulet || In_endgame(&u.uz) || In_sokoban(&u.uz)) {
|
||||
failed_effect(id);
|
||||
} else {
|
||||
/* Temporarily stun the player, if they are not already, to prevent teleport control */
|
||||
boolean removestun = FALSE;
|
||||
if (!Stunned) {
|
||||
removestun = TRUE;
|
||||
make_stunned(1L, FALSE);
|
||||
}
|
||||
level_tele();
|
||||
if (removestun) {
|
||||
make_stunned(0L, FALSE);
|
||||
}
|
||||
successful_effect(id);
|
||||
}
|
||||
} else if (!strcmp(effect, "healing")) {
|
||||
You_feel("better.");
|
||||
healup(8 + d(4, 4), 0, FALSE, FALSE);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "extra_healing")) {
|
||||
You_feel("much better.");
|
||||
healup(16 + d(4, 8), 0, FALSE, FALSE);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "full_healing")) {
|
||||
You_feel("completely healed.");
|
||||
healup(400, 0, FALSE, FALSE);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "curse_inventory")) {
|
||||
if (!Blind) {
|
||||
You("notice a %s glow surrounding you.", hcolor(NH_BLACK));
|
||||
}
|
||||
rndcurse();
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "reduce_luck")) {
|
||||
You_feel("unlucky.");
|
||||
change_luck(-1);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "fix_trouble")) {
|
||||
int trouble = in_trouble();
|
||||
if (trouble != 0) {
|
||||
fix_worst_trouble(trouble);
|
||||
successful_effect(id);
|
||||
} else {
|
||||
failed_effect(id);
|
||||
}
|
||||
} else if (!strcmp(effect, "darkness")) {
|
||||
litroom(FALSE, NULL);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "confuse")) {
|
||||
if (!Confusion) {
|
||||
if (Hallucination) {
|
||||
pline("What a trippy feeling!");
|
||||
} else {
|
||||
pline("Huh, What? Where am I?");
|
||||
}
|
||||
}
|
||||
|
||||
make_confused(itimeout_incr(HConfusion, rn1(7, 16)), FALSE);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "hallucinate")) {
|
||||
(void) make_hallucinated(itimeout_incr(HHallucination, d(10, 12)), TRUE, 0L);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "stun")) {
|
||||
make_stunned(itimeout_incr(HStun, rn1(10, 10)), TRUE);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "blind")) {
|
||||
make_blinded(itimeout_incr(BlindedTimeout, d(10, 12)), (boolean) !Blind);
|
||||
successful_effect(id);
|
||||
} else if (!strcmp(effect, "sleep")) {
|
||||
if (Sleep_resistance) {
|
||||
You("yawn.");
|
||||
failed_effect(id);
|
||||
} else {
|
||||
You("suddenly fall asleep!");
|
||||
fall_asleep(-rn1(10, 13), TRUE);
|
||||
successful_effect(id);
|
||||
}
|
||||
} else if (!strcmp(effect, "grant_object")) {
|
||||
char *object = strtok(NULL, "\n");
|
||||
grant_object(object);
|
||||
successful_effect(id);
|
||||
}
|
||||
}
|
||||
|
||||
staticfn void grant_object(char *objname) {
|
||||
struct obj *otmp;
|
||||
otmp = readobjnam(objname, NULL);
|
||||
if (!otmp) {
|
||||
otmp = readobjnam((char *) 0, (struct obj *) 0);
|
||||
} else if (otmp == &hands_obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (otmp->oartifact) {
|
||||
pline("For a moment, you feel %s in your %s, but it disappears!",
|
||||
something, makeplural(body_part(HAND)));
|
||||
return;
|
||||
}
|
||||
|
||||
const char *verb = ((Is_airlevel(&u.uz) || u.uinwater) ? "slip" : "drop"),
|
||||
*oops_msg = (u.uswallow
|
||||
? "Oops! %s out of your reach!"
|
||||
: (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz)
|
||||
|| levl[u.ux][u.uy].typ < IRONBARS
|
||||
|| levl[u.ux][u.uy].typ >= ICE)
|
||||
? "Oops! %s away from you!"
|
||||
: "Oops! %s to the floor!");
|
||||
|
||||
(void) hold_another_object(otmp, oops_msg, The(aobjnam(otmp, verb)), (const char *) 0);
|
||||
}
|
||||
|
||||
staticfn boolean has_out_file(void) {
|
||||
if (twitch_out_fd >= 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
twitch_out_fd = open(outfile, O_WRONLY | O_NONBLOCK);
|
||||
|
||||
return twitch_out_fd >= 0;
|
||||
}
|
||||
|
||||
staticfn void failed_effect(char *id) {
|
||||
if (has_out_file()) {
|
||||
write(twitch_out_fd, "failure ", 8);
|
||||
write(twitch_out_fd, id, strlen(id));
|
||||
write(twitch_out_fd, "\n", 1);
|
||||
}
|
||||
}
|
||||
|
||||
staticfn void successful_effect(char *id) {
|
||||
if (has_out_file()) {
|
||||
write(twitch_out_fd, "success ", 8);
|
||||
write(twitch_out_fd, id, strlen(id));
|
||||
write(twitch_out_fd, "\n", 1);
|
||||
}
|
||||
}
|
||||
@@ -528,8 +528,8 @@ HACKCSRC = allmain.c alloc.c apply.c artifact.c attrib.c ball.c bones.c \
|
||||
priest.c quest.c questpgr.c read.c rect.c region.c report.c restore.c \
|
||||
rip.c rnd.c role.c rumors.c save.c selvar.c sfbase.c sfstruct.c \
|
||||
shk.c shknam.c sit.c sounds.c sp_lev.c spell.c stairs.c steal.c steed.c \
|
||||
strutil.c symbols.c sys.c teleport.c \
|
||||
timeout.c topten.c track.c trap.c u_init.c utf8map.c \
|
||||
strutil.c symbols.c sys.c teleport.c timeout.c \
|
||||
topten.c track.c trap.c twitch.c u_init.c utf8map.c \
|
||||
uhitm.c vault.c version.c vision.c weapon.c were.c wield.c \
|
||||
windows.c wizard.c wizcmds.c worm.c worn.c write.c zap.c
|
||||
|
||||
@@ -626,12 +626,12 @@ HOBJ = $(TARGETPFX)allmain.o $(TARGETPFX)alloc.o \
|
||||
$(TARGETPFX)stairs.o $(TARGETPFX)symbols.o $(TARGETPFX)sys.o \
|
||||
$(TARGETPFX)steal.o $(TARGETPFX)steed.o $(TARGETPFX)strutil.o \
|
||||
$(TARGETPFX)teleport.o $(TARGETPFX)timeout.o $(TARGETPFX)topten.o \
|
||||
$(TARGETPFX)track.o $(TARGETPFX)trap.o $(TARGETPFX)u_init.o \
|
||||
$(TARGETPFX)uhitm.o $(TARGETPFX)utf8map.o $(TARGETPFX)vault.o \
|
||||
$(TARGETPFX)vision.o $(TARGETPFX)weapon.o $(TARGETPFX)were.o \
|
||||
$(TARGETPFX)wield.o $(TARGETPFX)windows.o $(TARGETPFX)wizard.o \
|
||||
$(TARGETPFX)wizcmds.o $(TARGETPFX)worm.o $(TARGETPFX)worn.o \
|
||||
$(TARGETPFX)write.o $(TARGETPFX)zap.o \
|
||||
$(TARGETPFX)track.o $(TARGETPFX)trap.o $(TARGETPFX)twitch.o \
|
||||
$(TARGETPFX)u_init.o $(TARGETPFX)uhitm.o $(TARGETPFX)utf8map.o \
|
||||
$(TARGETPFX)vault.o $(TARGETPFX)vision.o $(TARGETPFX)weapon.o \
|
||||
$(TARGETPFX)were.o $(TARGETPFX)wield.o $(TARGETPFX)windows.o \
|
||||
$(TARGETPFX)wizard.o $(TARGETPFX)wizcmds.o $(TARGETPFX)worm.o \
|
||||
$(TARGETPFX)worn.o $(TARGETPFX)write.o $(TARGETPFX)zap.o \
|
||||
$(REGEXOBJ) $(RANDOBJ) $(SYSOBJ) $(WINOBJ) $(HINTOBJ) $(SNDLIBOBJ) \
|
||||
$(TARGETPFX)version.o
|
||||
|
||||
|
||||
492
sys/unix/hints/streamhack
Executable file
492
sys/unix/hints/streamhack
Executable file
@@ -0,0 +1,492 @@
|
||||
# NetHack 3.7 linux.370 $NHDT-Date: 1693519390 2023/08/31 22:03:10 $ $NHDT-Branch: keni-crashweb2 $:$NHDT-Revision: 1.61 $
|
||||
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007.
|
||||
# NetHack may be freely redistributed. See license for details.
|
||||
#
|
||||
#---------------------------------------------------------------------
|
||||
# Linux hints file with support for multiple window ports (interfaces)
|
||||
# Tested on:
|
||||
# - Ubuntu focal
|
||||
#
|
||||
# If this doesn't work for your distribution, consider making a new
|
||||
# hints file for it, rather than changing this one.
|
||||
# And let us know about it.
|
||||
#
|
||||
|
||||
#-PRE
|
||||
# linux.370 hints file provides a single-user build for Linux (such
|
||||
# as Ubuntu focal).
|
||||
|
||||
# note: '#-INCLUDE' is not just a comment
|
||||
# multiw-1.370 contains sections 1 to 2
|
||||
#-INCLUDE multiw-1.370
|
||||
|
||||
HINTSVERSION := 370
|
||||
|
||||
ifdef MAKEFILE_TOP
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
PRECHECK+=checkmakefiles
|
||||
# all files included from this hints file get listed
|
||||
# in HINTSINCLNAMES (without suffix and without a path)
|
||||
HINTSINCLNAMES := compiler cross-pre1 cross-pre2 cross-post \
|
||||
gbdates-pre gbdates-post \
|
||||
multiw-1 multiw-2 misc \
|
||||
multisnd1-pre multisnd2-pre multisnd-post
|
||||
HINTSINCLFILES := $(addsuffix .$(HINTSVERSION), $(HINTSINCLNAMES))
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef LIBXPM
|
||||
LIBXPM= -L/opt/X11/lib -lXpm
|
||||
endif
|
||||
|
||||
#4. Other
|
||||
GAMEUID = $(USER)
|
||||
GAMEGRP = games
|
||||
|
||||
# This gives better backtraces by making all core functions global; this
|
||||
# works around a limitation in glibc's backtrace(3) function.
|
||||
# This will be turned on automatically with CRASHREPROT.
|
||||
# 1 to enable, 0 to disable
|
||||
USE_NOSTATICFN = 1
|
||||
# If you want CRASHREPORT but absolutely don't want NOSTATICFN, define this:
|
||||
#USE_NONOSTATICFN = 1
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#-INCLUDE cross-pre1.370
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# You shouldn't need to change anything below here (in the hints file; if
|
||||
# you're reading this in Makefile augmented by hints, that may not be true).
|
||||
#
|
||||
|
||||
#-INCLUDE multiw-2.370
|
||||
|
||||
# compiler.370 contains compiler detection and adjustments common
|
||||
# to both linux and macOS
|
||||
|
||||
#-INCLUDE compiler.370
|
||||
|
||||
ifdef WANT_WIN_QT
|
||||
ifdef WANT_WIN_QT5
|
||||
QTDIR=/usr
|
||||
endif # WANT_WIN_QT5
|
||||
ifdef WANT_WIN_QT6
|
||||
#if your Qt6 is elsewhere, change this to match
|
||||
QTDIR=/usr/local/qt6
|
||||
ifeq "$(GPPGTEQ14)" "1"
|
||||
CCXXFLAGS += -Wno-template-id-cdtor
|
||||
endif # g++ greater than or equal to 14
|
||||
endif # WANT_WIN_QT6
|
||||
endif # WANT_WIN_QT
|
||||
|
||||
# misc.370 must come after compiler.370
|
||||
# and after QTDIR is defined.
|
||||
#
|
||||
#-INCLUDE misc.370
|
||||
|
||||
ifeq "$(USE_ASAN)" "1"
|
||||
CFLAGS+=-fsanitize=address
|
||||
LFLAGS+=-fsanitize=address
|
||||
endif
|
||||
|
||||
ifeq "$(USE_UBSAN)" "1"
|
||||
CFLAGS+=-fsanitize=undefined
|
||||
LFLAGS+=-fsanitize=undefined
|
||||
endif
|
||||
|
||||
ifeq "$(USE_CURSESLIB)" "1"
|
||||
# default
|
||||
CURSESLIB = -lncurses -ltinfo
|
||||
# If CURSES_UNICODE is defined, we need ncursesw.
|
||||
# Without CURSES_UNICODE the following simpler setting works.
|
||||
# CURSESLIB = -lncurses -ltinfo
|
||||
ifdef MAKEFILE_SRC
|
||||
comma:=,
|
||||
NCURSES_LFLAGS = $(shell pkg-config ncursesw --libs)
|
||||
NCURSES_CFLAGS = $(shell pkg-config ncursesw --cflags)
|
||||
ifeq (,$(findstring ncursesw, $(NCURSES_LFLAGS)))
|
||||
ifeq (,$(findstring ncurses, $(NCURSES_LFLAGS)))
|
||||
#this indicates that pkg-config itself was unavailable
|
||||
NCURSES_LFLAGS = -lncursesw -ltinfo
|
||||
endif
|
||||
endif
|
||||
#$(info $(NCURSES_LFLAGS))
|
||||
ifeq (,$(findstring ncursesw, $(NCURSES_LFLAGS)))
|
||||
HAVE_NCURSESW=0
|
||||
else
|
||||
HAVE_NCURSESW=1
|
||||
endif
|
||||
#$(info $(NCURSES_LFLAGS))
|
||||
#$(info HAVE_NCURSESW=$(HAVE_NCURSESW))
|
||||
ifeq "$(HAVE_NCURSESW)" "1"
|
||||
# remove unnecessary -Wl,-Bsymbolic-functions if present
|
||||
ifneq (,$(findstring -Wl$(comma)-Bsymbolic-functions, $(NCURSES_LFLAGS)))
|
||||
CURSESLIB = $(subst -Wl$(comma)-Bsymbolic-functions,,$(NCURSES_LFLAGS))
|
||||
else
|
||||
CURSESLIB = $(NCURSES_LFLAGS)
|
||||
endif
|
||||
endif #HAVE_NCURSESW
|
||||
#$(info $(CURSESLIB))
|
||||
ifeq (,$(findstring ncursesw, $(NCURSES_LFLAGS)))
|
||||
ifeq (,$(findstring ncurses, $(NCURSES_LFLAGS)))
|
||||
#this indicates that pkg-config itself was unavailable
|
||||
NOPKGCONFIG = 1
|
||||
endif #ncurses not in NCURSES_LFLAGS?
|
||||
endif #ncursesw not in NCURSES_LFLAGS?
|
||||
#
|
||||
ifeq "$(NOPKGCONFIG)" "1"
|
||||
NCURSES_CFLAGS = -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600
|
||||
ifeq "$(HAVE_NCURSESW)" "1"
|
||||
ifeq (,$(wildcard /usr/include/ncursesw/curses.h))
|
||||
NCURSES_CFLAGS += -I/usr/include
|
||||
else
|
||||
NCURSES_CFLAGS += -I/usr/include/ncursesw
|
||||
endif
|
||||
NCURSES_LFLAGS = -lncursesw -ltinfo
|
||||
else #HAVE_NCURSESW
|
||||
ifeq (,$(wildcard /usr/include/ncurses/curses.h))
|
||||
NCURSES_CFLAGS += -I/usr/include
|
||||
else
|
||||
NCURSES_CFLAGS += -I/usr/include/ncurses
|
||||
endif
|
||||
NCURSES_LFLAGS = -lncurses -ltinfo
|
||||
endif #HAVE_NCURSESW
|
||||
endif #NOPKGCONFIG
|
||||
endif #MAKEFILE_SRC
|
||||
endif #USE_CURSESLIB
|
||||
|
||||
# NetHack sources control
|
||||
NHCFLAGS+=-DDLB
|
||||
NHCFLAGS+=-DHACKDIR=\"$(HACKDIR)\"
|
||||
NHCFLAGS+=-DDEFAULT_WINDOW_SYS=\"$(WANT_DEFAULT)\"
|
||||
NHCFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
|
||||
NHCFLAGS+=-DTIMED_DELAY
|
||||
NHCFLAGS+=-DDUMPLOG
|
||||
NHCFLAGS+=-DCONFIG_ERROR_SECURE=FALSE
|
||||
#NHCFLAGS+=-DGREPPATH=\"/usr/bin/grep\"
|
||||
NHCFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\"
|
||||
#NHCFLAGS+=-DNOMAIL
|
||||
#NHCFLAGS+=-DEXTRA_SANITY_CHECKS
|
||||
NHCFLAGS+=-DEDIT_GETLIN
|
||||
NHCFLAGS+=-DSCORE_ON_BOTL
|
||||
#NHCFLAGS+=-DMSGHANDLER
|
||||
NHCFLAGS+=-DTTY_TILES_ESCCODES
|
||||
#NHCFLAGS+=-DTTY_SOUND_ESCCODES
|
||||
#NHCFLAGS+=-DNO_CHRONICLE
|
||||
#NHCFLAGS+=-DLIVELOG
|
||||
NHCFLAGS+=-DDUMPLOG
|
||||
NHCFLAGS+=-DDUMPHTML
|
||||
NHCFLAGS+=-DUSE_GENERAL_ALTAR_COLORS
|
||||
#NHCFLAGS+=-DCHANGE_COLOR
|
||||
NHCFLAGS+=-DSELF_RECOVER
|
||||
ifdef WANT_WIN_CURSES
|
||||
NHCFLAGS+=$(NCURSES_CFLAGS)
|
||||
ifeq "$(HAVE_NCURSESW)" "1"
|
||||
NHCFLAGS+=-DCURSES_UNICODE
|
||||
else
|
||||
ifdef MAKEFILE_SRC
|
||||
$(info Attention: CURSES_UNICODE is not being defined without ncursesw)
|
||||
endif #MAKEFILE_SRC
|
||||
endif #HAVE_NCURSESW
|
||||
endif #WANT_WIN_CURSES
|
||||
|
||||
#
|
||||
#-INCLUDE multisnd1-pre.370
|
||||
#
|
||||
|
||||
ifeq "$(CCISCLANG)" "1"
|
||||
# clang-specific starts
|
||||
# clang-specific ends
|
||||
else
|
||||
# gcc-specific starts
|
||||
LIBCFLAGS+=-DSIG_RET_TYPE=__sighandler_t
|
||||
# gcc-specific ends
|
||||
endif
|
||||
|
||||
# WINCFLAGS set from multiw-2.370
|
||||
# SNDCFLAGS set from multisnd-pre.370
|
||||
CFLAGS+= $(WINCFLAGS)
|
||||
CFLAGS+= $(SNDCFLAGS)
|
||||
CFLAGS+= $(NHCFLAGS)
|
||||
CFLAGS+= $(LIBCFLAGS)
|
||||
|
||||
# WINCFLAGS set from multiw-2.370
|
||||
# SNDCFLAGS set from multisnd-pre.370
|
||||
CCXXFLAGS+= $(WINCFLAGS)
|
||||
CCXXFLAGS+= $(SNDCFLAGS)
|
||||
CCXXFLAGS+= $(NHCFLAGS)
|
||||
CCXXFLAGS+= $(LIBCFLAGS)
|
||||
|
||||
VARDATND =
|
||||
VARDATND0 =
|
||||
|
||||
#ifdef WANT_WIN_CHAIN
|
||||
#HINTSRC=$(CHAINSRC)
|
||||
#HINTOBJ=$(CHAINOBJ)
|
||||
#endif # WANT_WIN_CHAIN
|
||||
|
||||
ifdef MAKEFILE_SRC
|
||||
ifdef CURSESLIB
|
||||
WINLIB += $(CURSESLIB)
|
||||
endif #CURSESLIB
|
||||
endif #MAKEFILE_SRC
|
||||
|
||||
ifdef WANT_WIN_X11
|
||||
USE_XPM=1
|
||||
WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
|
||||
VARDATND0 += x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
|
||||
# -x: if built without dlb, some versions of mkfontdir think *.lev are fonts
|
||||
POSTINSTALL += bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; ( cd $(HACKDIR); mkfontdir -x .lev );
|
||||
# separate from CFLAGS so that we don't pass it to every file
|
||||
X11CFLAGS = -I/opt/X11/include
|
||||
# avoid repeated complaints about _X_NONNULL(args...) in <X11/Xfuncproto.h>
|
||||
X11CFLAGS += -Wno-variadic-macros
|
||||
ifdef USE_XPM
|
||||
CFLAGS += -DUSE_XPM
|
||||
WINX11LIB += -lXpm
|
||||
VARDATND0 += rip.xpm
|
||||
endif
|
||||
WINLIB += $(WINX11LIB)
|
||||
LFLAGS+=-L/opt/X11/lib
|
||||
endif # WANT_WIN_X11
|
||||
|
||||
ifdef WANT_WIN_QT
|
||||
LINK = $(CXX)
|
||||
ifdef WANT_WIN_QT4
|
||||
QTCXXFLAGS += $(sort $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config QtGui --cflags)) -DQT_NO_SOUND=1
|
||||
WINLIB += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config QtGui --libs)
|
||||
endif # WANT_WIN_QT4
|
||||
ifdef WANT_WIN_QT5
|
||||
QTCXXFLAGS += $(sort $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --cflags))
|
||||
WINLIB += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --libs)
|
||||
endif # WANT_WIN_QT5
|
||||
ifdef WANT_WIN_QT6
|
||||
ifdef QT6MANUAL
|
||||
# Try some likely spots for a self-built Qt6.
|
||||
# You'll have to change these manually before using the hints file
|
||||
# if they don't match the installed location on your system.
|
||||
ifneq "$(HOSTTYPE)" ""
|
||||
QTHOST=$(HOSTTYPE)
|
||||
else
|
||||
QTHOST=x86_64
|
||||
endif
|
||||
QTTOP=/usr/include/$(HOSTTYPE)-linux-gnu/qt6
|
||||
ifneq ($(wildcard $(QTTOP)/*),)
|
||||
#we don't set QTLOCATED=1 for this
|
||||
QTINCDIR=/usr/include/$(QTHOST)-linux-gnu/qt6
|
||||
QTLIBDIR=/usr/lib/$(QTHOST)-linux.gnu
|
||||
QTCXXFLAGS += -DQT_WIDGETS_LIB -DQT_MULTIMEDIA_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB
|
||||
QTCXXFLAGS += -I$(QTINCDIR)/QtWidgets -I$(QTINCDIR) -I$(QTINCDIR)/QtMultimedia
|
||||
QTCXXFLAGS += -I$(QTINCDIR)/QtNetwork -I$(QTINCDIR)/QtGui -I$(QTINCDIR)/QtCore
|
||||
WINLIB += -L$(QTLIBDIR) -lQt6Widgets -lQt6Multimedia -lQt6Network -lQt6Gui -lQt6Core
|
||||
MOCPATH = /usr/lib/qt6/libexec/moc
|
||||
#/usr/lib/x86_64-linux-gnu/libQt6EglFSDeviceIntegration.so
|
||||
endif # QTTOP/*
|
||||
ifndef QTINCDIR
|
||||
ifneq ($(wildcard /usr/local/Qt6/*),)
|
||||
QTDIR=/usr/local/Qt6
|
||||
QTLOCATED=1
|
||||
endif # wildcard /usr/local/Qt6
|
||||
ifneq ($(wildcard /usr/local/qt6/*),)
|
||||
QTDIR=/usr/local/qt6
|
||||
QTLOCATED=1
|
||||
endif # wildcard /usr/local/qt6
|
||||
endif # !QTINCDIR
|
||||
ifdef QTLOCATED
|
||||
QTCXXFLAGS += -I$(QTDIR)/include/QtCore
|
||||
QTCXXFLAGS += -I$(QTDIR)/include/QtGui
|
||||
QTCXXFLAGS += -I$(QTDIR)/include/QtMultimedia
|
||||
QTCXXFLAGS += -I$(QTDIR)/include/QtWidgets
|
||||
MOCPATH = $(QTDIR)/libexec/moc
|
||||
WINLIB += -L$(QTDIR)/lib -lQt6Widgets -lQt6Multimedia -lQt6Network -lQt6Gui -lQt6Core
|
||||
endif # QTLOCATED
|
||||
else # !QT6MANUAL
|
||||
MOCDIR = $(shell pkg-config Qt6Gui --variable=libexecdir)
|
||||
ifneq ($(wildcard $(MOCDIR)/*),)
|
||||
MOCPATH = $(MOCDIR)/moc
|
||||
else
|
||||
MOCPATH = /usr/lib/qt6/libexec/moc
|
||||
endif # MOCDIR
|
||||
QTCXXFLAGS += $(sort $(shell pkg-config Qt6Gui Qt6Widgets Qt6Multimedia --cflags))
|
||||
WINLIB += $(shell pkg-config Qt6Gui Qt6Widgets Qt6Multimedia --libs)
|
||||
endif # QT6MANUAL
|
||||
endif # WANT_WIN_QT6
|
||||
ifndef QTDIR
|
||||
$(error QTDIR not defined in the environment or Makefile)
|
||||
endif # QTDIR
|
||||
# XXX if /Developer/qt exists and QTDIR not set, use that
|
||||
# XXX make sure QTDIR points to something reasonable
|
||||
QTCXXFLAGS += -fPIC
|
||||
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; \
|
||||
( cd $(INSTDIR); mkfontdir -x .lev );
|
||||
VARDATND0 += nhtiles.bmp rip.xpm nhsplash.xpm
|
||||
else # WANT_WIN_QT
|
||||
LINK = $(CC)
|
||||
endif # !WANT_WIN_QT
|
||||
|
||||
# prevent duplicate tile.o in WINOBJ
|
||||
WINOBJ = $(WINOBJ0) $(sort $(XTRAOBJ))
|
||||
# prevent duplicates in VARDATND if both X11 and Qt are being supported
|
||||
VARDATND += $(sort $(VARDATND0))
|
||||
|
||||
GIT_HASH := $(shell echo `git rev-parse --verify HEAD` 2>&1)
|
||||
GIT_BRANCH := $(shell echo `git rev-parse --abbrev-ref HEAD` 2>&1)
|
||||
GIT_PREFIX := $(shell echo `git config nethack.substprefix` 2>&1)
|
||||
|
||||
ifdef GIT_HASH
|
||||
GITHASH = -DNETHACK_GIT_SHA=\"$(GIT_HASH)\"
|
||||
endif
|
||||
ifdef GIT_BRANCH
|
||||
GITBRANCH = -DNETHACK_GIT_BRANCH=\"$(GIT_BRANCH)\"
|
||||
endif
|
||||
ifdef GIT_PREFIX
|
||||
GITPREFIX = -DNETHACK_GIT_PREFIX=\"$(GIT_PREFIX)\"
|
||||
endif
|
||||
|
||||
ifdef WANT_LIBNH
|
||||
CFLAGS += -DSHIM_GRAPHICS -DNOTTYGRAPHICS -DNOSHELL -DLIBNH -fpic
|
||||
LIBNHSYSSRC = ../sys/libnh/libnhmain.c \
|
||||
../sys/share/ioctl.c ../sys/share/unixtty.c \
|
||||
../sys/unix/unixunix.c ../sys/unix/unixres.c \
|
||||
../win/shim/winshim.c
|
||||
LIBNHSYSOBJ = $(TARGETPFX)libnhmain.o $(TARGETPFX)ioctl.o \
|
||||
$(TARGETPFX)unixtty.o $(TARGETPFX)unixunix.o \
|
||||
$(TARGETPFX)unixres.o $(TARGETPFX)winshim.o \
|
||||
$(TARGETPFX)date.o
|
||||
#don't bother building the game executable as it will fail
|
||||
#without winshim
|
||||
override GAME=
|
||||
MOREALL += ( cd src ; $(MAKE) pregame ; $(MAKE) $(TARGETPFX)libnh.a )
|
||||
endif # WANT_LIBNH
|
||||
|
||||
SYSCONFCREATE = cp sys/unix/sysconf $(INSTDIR)/sysconf
|
||||
SYSCONFINSTALL = $(SYSCONFCREATE) && \
|
||||
$(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf && \
|
||||
$(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf && \
|
||||
chmod $(VARFILEPERM) $(INSTDIR)/sysconf;
|
||||
SYSCONFENSURE = (if ! test -f $(INSTDIR)/sysconf ; then \
|
||||
$(SYSCONFCREATE) && \
|
||||
$(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf && \
|
||||
$(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf && \
|
||||
chmod $(VARFILEPERM) $(INSTDIR)/sysconf; fi );
|
||||
|
||||
ifdef WANT_SOURCE_INSTALL
|
||||
PREFIX=$(abspath $(NHSROOT))
|
||||
#SHELLDIR=
|
||||
HACKDIR=$(PREFIX)/playground
|
||||
GAMEPERM = 0700
|
||||
VARFILEPERM = 0600
|
||||
VARDIRPERM = 0700
|
||||
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
|
||||
MOREALL=$(MAKE) install
|
||||
else #!WANT_SOURCE_INSTALL
|
||||
#PREFIX=/usr
|
||||
PREFIX=$(wildcard ~)/nh/install
|
||||
HACKDIR=$(PREFIX)/games/lib/nethackdir
|
||||
SHELLDIR = $(PREFIX)/games
|
||||
VARDIRPERM = 0755
|
||||
VARFILEPERM = 0600
|
||||
GAMEPERM = 0755
|
||||
endif #?WANT_SOURCE_INSTALL
|
||||
|
||||
INSTDIR=$(HACKDIR)
|
||||
VARDIR = $(HACKDIR)
|
||||
|
||||
ifdef MAKEFILE_TOP
|
||||
TESTGDBPATH=/usr/bin/gdb
|
||||
POSTINSTALL+= test -f $(TESTGDBPATH) || \
|
||||
sed -i -e 's;^GDBPATH=/usr/bin/gdb;\#GDBPATH=/usr/bin/gdb;' \
|
||||
-e 's;PANICTRACE_GDB=1;PANICTRACE_GDB=0;' $(INSTDIR)/sysconf;
|
||||
POSTUPDATE+= test -f $(TESTGDBPATH) || \
|
||||
sed -i -e 's;^GDBPATH=/usr/bin/gdb;\#GDBPATH=/usr/bin/gdb;' \
|
||||
-e 's;PANICTRACE_GDB=1;PANICTRACE_GDB=0;' $(INSTDIR)/sysconf;
|
||||
endif #MAKEFILE_TOP
|
||||
|
||||
ifeq '$(USE_NONOSTATICFN)' '1'
|
||||
CFLAGS += -DNONOSTATICFN
|
||||
else
|
||||
ifeq '$(USE_NOSTATICFN)' '1'
|
||||
CFLAGS += -DNOSTATICFN
|
||||
endif
|
||||
endif
|
||||
|
||||
# Lua
|
||||
# when building liblua.a, avoid warning that use of tmpnam() should be
|
||||
# replaced by mkstemp(); the lua code doesn't use nethack's config.h so
|
||||
# this needs to be passed via make rather than defined in unixconf.h
|
||||
SYSCFLAGS=-DLUA_USE_LINUX
|
||||
ifdef GITSUBMODULES
|
||||
LUAFLAGS=CC='$(CC)' SYSCFLAGS='$(SYSCFLAGS)'
|
||||
ifneq "$(CCISCLANG)" ""
|
||||
# clang
|
||||
LUAFLAGS +=CWARNGCC=''
|
||||
endif # clang
|
||||
override LUAHEADERS = submodules/lua
|
||||
override LUA2NHTOP = ../..
|
||||
override LUAMAKEFLAGS=$(LUAFLAGS)
|
||||
endif # GITSUBMODULES
|
||||
DLLIB = -ldl
|
||||
|
||||
# Only needed for GLIBC stack trace:
|
||||
LFLAGS+=-rdynamic
|
||||
|
||||
# if TTY_TILES_ESCCODES
|
||||
WINSRC += tile.c
|
||||
WINOBJ += tile.o
|
||||
# endif
|
||||
|
||||
CHOWN=true
|
||||
CHGRP=true
|
||||
|
||||
# manpages directory
|
||||
MANDIR=/usr/share/man/man6
|
||||
#
|
||||
#-INCLUDE cross-pre2.370
|
||||
#
|
||||
|
||||
#
|
||||
#-INCLUDE gbdates-pre.370
|
||||
#
|
||||
|
||||
#
|
||||
#-INCLUDE multisnd2-pre.370
|
||||
#
|
||||
|
||||
#
|
||||
#-INCLUDE response.370
|
||||
#
|
||||
|
||||
#-POST
|
||||
|
||||
#
|
||||
#-INCLUDE gbdates-post.370
|
||||
#
|
||||
#
|
||||
#-INCLUDE multisnd-post.370
|
||||
#
|
||||
|
||||
ifdef MAKEFILE_TOP
|
||||
ifeq ($(MAKELEVEL),0)
|
||||
.PHONY: checkmakefiles
|
||||
checkmakefiles:
|
||||
@$(MAKE) -f sys/unix/Makefile.check \
|
||||
HINTSFILE="$(HINTSFILE)" HINTSINCLFILES="$(HINTSINCLFILES)"
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef WANT_LIBNH
|
||||
$(TARGETPFX)libnh.a: $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua-$(LUA_VERSION).a
|
||||
$(AR) rcs $@ $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua-$(LUA_VERSION).a
|
||||
@echo "$@ built."
|
||||
$(TARGETPFX)libnhmain.o : ../sys/libnh/libnhmain.c $(HACK_H)
|
||||
$(CC) $(CFLAGS) -c -o$@ $<
|
||||
#dependency tool added this to Makefile.src
|
||||
#$(TARGETPFX)winshim.o : ../win/shim/winshim.c $(HACK_H)
|
||||
# $(CC) $(CFLAGS) -c -o$@ $<
|
||||
endif # WANT_LIBNH
|
||||
|
||||
#
|
||||
#-INCLUDE cross-post.370
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user