#define __USE_MINGW_ANSI_STDIO 1
#endif
/* extern int getlock(void); */
-#endif
+extern char *exepath(void);
+#endif /* __MINGW32__ */
#ifdef _MSC_VER
#define MD_USE_TMPFILE_S
{
#ifdef SND_SOUNDEFFECTS_AUTOMAP
int reslt = 0;
+ int32_t sefnflag = 0;
char buf[PATHLEN];
const char *filename;
DWORD fdwsound;
if (seid >= se_squeak_C || seid <= se_squeak_B) {
- filename = get_sound_effect_filename(seid, buf, sizeof buf, 1);
- fdwsound = SND_ASYNC | SND_RESOURCE;
+#if defined(__MINGW32__)
+ /* The mingw32 resources don't seem to be able to be retrieved by the
+ * API PlaySound function with the SND_RESOURCE flag. Use files from
+ * the file system instead. */
+ extern char *sounddir; /* in sounds.c, set in files.c */
+ char *exedir;
+
+ if (!sounddir) {
+ exedir = exepath();
+ if (exedir)
+ if (strlen(exedir) < sizeof buf - 30) {
+ Strcpy(buf, exedir);
+ sefnflag = 2; /* 2 = use the directory name already in buf */
+ }
+ }
+ filename = get_sound_effect_filename(seid, buf, sizeof buf, sefnflag);
+ fdwsound = SND_ASYNC | SND_NODEFAULT;
+#else
+ sefnflag = 1;
+ /* sefnflag = 1 means just obtain the soundeffect base name with
+ * no directory name and no file extension. That's because we're
+ * going to use the base soundeffect name as the name of a resource
+ * that's embedded into the .exe file, passing SND_RESOURCE flag to
+ * Windows API PlaySound().
+ */
+ filename = get_sound_effect_filename(seid, buf, sizeof buf, sefnflag);
+ fdwsound = SND_ASYNC | SND_RESOURCE;
+#endif
} else {
- filename = get_sound_effect_filename(seid, buf, sizeof buf, 0);
+ filename = get_sound_effect_filename(seid, buf, sizeof buf, sefnflag);
fdwsound = SND_ASYNC | SND_NODEFAULT;
}
int32_t seidint,
char *buf,
size_t bufsz,
- int32_t baseflag) /* non-zero means return without
- * directory or extension suffix */
+ int32_t baseflag) /* 0 = soundir + '/' + sound + '.wav'
+ * 1 = sound only (no dir, no extension) '
+ * 2 = dir is already in buf incl '/',
+ * add sound + ".wav"
+ */
{
static const char prefix[] = "se_", suffix[] = ".wav";
- size_t consumes = 0, baselen = 0;
+ size_t consumes = 0, baselen = 0, existinglen = 0;
/* enum sound_effect_entries seid = (enum sound_effect_entries) seidint; */
char *ourdir = sounddir; /* sounddir would get set in files.c */
+ char *cp = buf;
+ boolean needslash = TRUE;
if (!buf || (!ourdir && baseflag == 0))
return (char *) 0;
baselen = strlen(semap_basenames[seidint]);
consumes = (sizeof prefix - 1) + baselen;
- if (baseflag == 0)
- consumes += (sizeof suffix - 1) + strlen(ourdir);
- consumes += 1 + 1; /* '\0' and '/' */
- if (baselen <= 0 || consumes > bufsz)
+ if (baseflag == 0) {
+ consumes += (sizeof suffix - 1) + strlen(ourdir) + 1; /* 1 for '/' */
+ } else if (baseflag == 2) {
+
+ consumes += (sizeof suffix - 1);
+ existinglen = strlen(buf);
+ if (existinglen > 0) {
+ cp = buf + existinglen; /* points at trailing NUL */
+ cp--; /* points at last character */
+ if (*cp == '/' || *cp == '\\')
+ needslash = FALSE;
+ cp++; /* points back at trailing NUL */
+ }
+ if (needslash)
+ consumes++; /* for '/' */
+ consumes += (sizeof suffix - 1);
+ consumes += existinglen;
+ }
+ consumes += 1; /* for trailing NUL */
+ /* existinglen could be >= bufsz if caller didn't initialize buf
+ * to properly include a trailing NUL */
+ if (baselen <= 0 || consumes > bufsz || existinglen >= bufsz)
return (char *) 0;
#if 0
- if (!baseflag) {
+ if (baseflag == 0) {
Strcpy(buf, ourdir);
Strcat(buf, "/");
+ } else if (baseflag == 2) {
+ if (needslash)
+ Strcat(buf, "/");
+ } else if (baseflag == 1) {
+ buf[0] = '\0';
}
Strcat(buf, prefix);
Strcat(buf, semap_basenames[seidint]);
- if (!baseflag) {
+ if (baseflag == 0 || baseflag == 2) {
Strcat(buf, suffix);
}
#else
- if (!baseflag)
+ if (baseflag == 0) {
Snprintf(buf, bufsz , "%s/%s%s%s", ourdir, prefix,
semap_basenames[seidint], suffix);
- else
- Snprintf(buf, bufsz , "%s%s", prefix, semap_basenames[seidint]);
+ } else if (baseflag == 2) {
+ if (needslash) {
+ *cp = '/';
+ cp++;
+ *cp = '\0';
+ existinglen++;
+ }
+ Snprintf(cp, bufsz - (existinglen + 1) , "%s%s%s",
+ prefix, semap_basenames[seidint], suffix);
+ } else if (baseflag == 1) {
+ Snprintf(buf, bufsz, "%s%s", prefix, semap_basenames[seidint]);
+ } else {
+ return (char *) 0;
+ }
#endif
return buf;
}
WCURSES =../win/curses
WSHR =../win/share
QT =../win/Qt
-SNDWAVDIR =../sound/wav
+SNDWAVDIR = ../sound/wav
#
# Object directory.
# Soundlib Support
#==========================================
-ifeq "$(HAVE_SOUNDLIB)" "Y"
-ifeq "$(NEED_USERSOUNDS)" "Y"
-SOUNDLIBDEFS += -DUSER_SOUNDS
-endif
-ifeq "$(NEED_SEAUTOMAP)" "Y"
-SOUNDLIBDEFS += -DSND_SOUNDEFFECTS_AUTOMAP
-endif
-ifeq "$(NEED_WAV)" "Y"
WAVLIST = se_squeak_A se_squeak_B se_squeak_B_flat se_squeak_C \
se_squeak_D se_squeak_D_flat se_squeak_E \
se_squeak_E_flat se_squeak_F se_squeak_F_sharp \
sound_Wooden_Harp_E sound_Wooden_Harp_F \
sound_Wooden_Harp_G
WAVS = $(addprefix $(SNDWAVDIR)/, $(addsuffix .wav, $(WAVLIST)))
+
+ifeq "$(HAVE_SOUNDLIB)" "Y"
+ifeq "$(NEED_USERSOUNDS)" "Y"
+SOUNDLIBDEFS += -DUSER_SOUNDS
+endif
+ifeq "$(NEED_SEAUTOMAP)" "Y"
+SOUNDLIBDEFS += -DSND_SOUNDEFFECTS_AUTOMAP
+endif
+ifeq "$(NEED_WAV)" "Y"
+$(info Built-in sound file integration included)
+#RCFLAGS = --include-dir=$(SNDWAVDIR) --define RCWAV
+WAV = $(WAVS)
endif # NEED_WAV
+else
+$(info No soundlib integration)
endif # HAVE_SOUNDLIB
#==========================================
$(ONHW)/%.o: $(WSHR)/%.c $(NHLUAH) | $(ONHW)
$(cc) $(CFLAGSW) $< -o$@
-$(NHWRES): $(MSWIN)/NetHackW.rc $(BMPS) $(WAVS) $(MSWIN)/NetHack.ico | $(ONHW)
- $(rc) --include-dir=$(MSWIN) --include-dir=$(SNDWAVDIR) --input=$< -o$@
+$(NHWRES): $(MSWIN)/NetHackW.rc $(BMPS) $(WAV) $(MSWIN)/NetHack.ico | $(ONHW)
+ $(rc) --include-dir=$(MSWIN) $(RCFLAGS) --input=$< -o$@
$(MSWIN)/tiles.bmp: $(U)tile2bmp.exe $(TILEFILES)
$< $@
@mkdir -p $@
CLEAN_DIR += $(ONHW)
-CLEAN_FILE += $(NHWTARGETS) $(NHWOBJS) $(NHWRES) $(BMPS) $(WAVS)
+CLEAN_FILE += $(NHWTARGETS) $(NHWOBJS) $(NHWRES) $(BMPS) $(WAV)
#==========================================
# nethack
$(ONH)/%.o: $(WCURSES)/%.c $(NHLUAH) | $(ONH)
$(cc) $(CFLAGSNH) $(PDCINCL) $< -o$@
-$(NHRES): $(MSWIN)/NetHack.rc $(WAVS) $(MSWIN)/NetHack.ico | $(ONH)
- $(rc) --include-dir=$(MSWIN) --include-dir=$(SNDWAVDIR) --input=$< -o$@
+$(NHRES): $(MSWIN)/NetHack.rc $(WAV) $(MSWIN)/NetHack.ico | $(ONH)
+ $(rc) --include-dir=$(MSWIN) $(RCFLAGS) --input=$< -o$@
$(ONH):
@mkdir -p $@
$(addprefix $(GAMEDIR)/, $(addsuffix .template, sysconf .nethackrc) \
Guidebook.txt NetHack.txt license opthelp record symbols)
+ifeq "$(HAVE_SOUNDLIB)" "Y"
+TO_INSTALL += $(addprefix $(GAMEDIR)/, $(addsuffix .wav, $(WAVLIST)))
+endif
+
ifeq "$(USE_LUADLL)" "Y"
TO_INSTALL += $(LUADLL)
endif
$(GAMEDIR)/%: $(MSWSYS)/%
cp $< $@
+$(GAMEDIR)/%: $(SNDWAVDIR)/%
+ cp $< $@
+
CLEAN_FILE += $(TO_INSTALL)
clean:
}
#endif
+static boolean path_buffer_set = FALSE;
+static char path_buffer[MAX_PATH];
+
char *
get_executable_path(void)
{
- static char path_buffer[MAX_PATH];
#ifdef UNICODE
{
if (seperator)
*seperator = '\0';
+ path_buffer_set = TRUE;
return path_buffer;
}
+#ifdef __MINGW32__
+char *
+exepath(void)
+{
+ char *p = (char *) 0;
+
+ if (path_buffer_set)
+ p = path_buffer;
+ return p;
+}
+#endif
+
char *
translate_path_variables(const char* str, char* buf)
{