qbsp: use the common logfile code
Not too intrusive, since the Message() layer still acts as a shim here. Most of the changes are for the Makefile. Qbsp now links to the threading code as a result, but no thread support... yet! Signed-off-by: Kevin Shanahan <kmshanah@disenchant.net>
This commit is contained in:
parent
75666712e7
commit
4c6142e97f
54
Makefile
54
Makefile
|
|
@ -465,29 +465,31 @@ $(BIN_DIR)/$(BIN_PFX)bsputil$(EXT): $(patsubst %,$(BUILD_DIR)/%,$(BSPUTIL_OBJS))
|
|||
########
|
||||
|
||||
QBSP_OBJS = \
|
||||
brush.o \
|
||||
bspfile.o \
|
||||
cmdlib.o \
|
||||
csg4.o \
|
||||
file.o \
|
||||
globals.o \
|
||||
map.o \
|
||||
mathlib.o \
|
||||
merge.o \
|
||||
outside.o \
|
||||
parser.o \
|
||||
portals.o \
|
||||
qbsp.o \
|
||||
solidbsp.o \
|
||||
surfaces.o \
|
||||
tjunc.o \
|
||||
util.o \
|
||||
wad.o \
|
||||
winding.o \
|
||||
writebsp.o
|
||||
common/threads.o \
|
||||
common/log.o \
|
||||
qbsp/brush.o \
|
||||
qbsp/bspfile.o \
|
||||
qbsp/cmdlib.o \
|
||||
qbsp/csg4.o \
|
||||
qbsp/file.o \
|
||||
qbsp/globals.o \
|
||||
qbsp/map.o \
|
||||
qbsp/mathlib.o \
|
||||
qbsp/merge.o \
|
||||
qbsp/outside.o \
|
||||
qbsp/parser.o \
|
||||
qbsp/portals.o \
|
||||
qbsp/qbsp.o \
|
||||
qbsp/solidbsp.o \
|
||||
qbsp/surfaces.o \
|
||||
qbsp/tjunc.o \
|
||||
qbsp/util.o \
|
||||
qbsp/wad.o \
|
||||
qbsp/winding.o \
|
||||
qbsp/writebsp.o
|
||||
|
||||
$(BIN_DIR)/$(BIN_PFX)qbsp$(EXT): $(patsubst %,$(BUILD_DIR)/qbsp/%,$(QBSP_OBJS))
|
||||
$(call do_cc_link,-lm)
|
||||
$(BIN_DIR)/$(BIN_PFX)qbsp$(EXT): $(patsubst %,$(BUILD_DIR)/%,$(QBSP_OBJS))
|
||||
$(call do_cc_link,-lm $(LPTHREAD))
|
||||
$(call do_strip,$@)
|
||||
|
||||
clean:
|
||||
|
|
@ -580,8 +582,8 @@ $(1)/bin/$$(BIN_PFX)bsputil$$(EXT): $$(patsubst %,$(1)/%,$$(BSPUTIL_OBJS))
|
|||
$$(call do_cc_link,-lm $$(LPTHREAD) $(2))
|
||||
$$(call do_strip,$$@)
|
||||
|
||||
$(1)/bin/$$(BIN_PFX)qbsp$$(EXT): $$(patsubst %,$(1)/qbsp/%,$$(QBSP_OBJS))
|
||||
$$(call do_cc_link,-lm $(2))
|
||||
$(1)/bin/$$(BIN_PFX)qbsp$$(EXT): $$(patsubst %,$(1)/%,$$(QBSP_OBJS))
|
||||
$$(call do_cc_link,-lm $$(LPTHREAD) $(2))
|
||||
$$(call do_strip,$$@)
|
||||
endef
|
||||
|
||||
|
|
@ -637,8 +639,8 @@ $(BUILD_DIR)/win32/bin/$(BIN_PFX)bsputil$(EXT): $(patsubst %,$(BUILD_DIR)/win32/
|
|||
$(call do_cc_link,-lm $(LPTHREAD))
|
||||
$(call do_strip,$@)
|
||||
|
||||
$(BUILD_DIR)/win32/bin/$(BIN_PFX)qbsp$(EXT): $(patsubst %,$(BUILD_DIR)/win32/qbsp/%,$(QBSP_OBJS))
|
||||
$(call do_cc_link,-lm)
|
||||
$(BUILD_DIR)/win32/bin/$(BIN_PFX)qbsp$(EXT): $(patsubst %,$(BUILD_DIR)/win32/%,$(QBSP_OBJS))
|
||||
$(call do_cc_link,-lm $(LPTHREAD))
|
||||
$(call do_strip,$@)
|
||||
|
||||
# Simple rules to copy distribution files
|
||||
|
|
|
|||
13
qbsp/qbsp.c
13
qbsp/qbsp.c
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "common/log.h"
|
||||
#include "qbsp.h"
|
||||
#include "wad.h"
|
||||
|
||||
|
|
@ -515,8 +516,6 @@ InitQBSP(int argc, char **argv)
|
|||
char *szBuf;
|
||||
int length;
|
||||
|
||||
logfile = NULL;
|
||||
|
||||
// Initial values
|
||||
options.dxLeakDist = 2;
|
||||
options.dxSubdivide = 240;
|
||||
|
|
@ -566,11 +565,9 @@ InitQBSP(int argc, char **argv)
|
|||
/* Start logging to <bspname>.log */
|
||||
StripExtension(options.szBSPName);
|
||||
strcat(options.szBSPName, ".log");
|
||||
logfile = fopen(options.szBSPName, "wt");
|
||||
if (!logfile)
|
||||
Message(msgWarning, warnNoLogFile);
|
||||
else
|
||||
Message(msgFile, IntroString);
|
||||
init_log(options.szBSPName);
|
||||
|
||||
Message(msgFile, IntroString);
|
||||
|
||||
/* If no wadpath given, default to the map directory */
|
||||
if (options.wadPath[0] == 0) {
|
||||
|
|
@ -627,7 +624,7 @@ main(int argc, char **argv)
|
|||
// FreeAllMem();
|
||||
// PrintMem();
|
||||
|
||||
fclose(logfile);
|
||||
close_log();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -686,6 +686,4 @@ void Message(int MsgType, ...);
|
|||
void Error(const char *error, ...)
|
||||
__attribute__((format(printf,1,2),noreturn));
|
||||
|
||||
extern FILE *logfile;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
26
qbsp/util.c
26
qbsp/util.c
|
|
@ -23,6 +23,9 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common/threads.h"
|
||||
#include "common/log.h"
|
||||
|
||||
#include "qbsp.h"
|
||||
|
||||
static int rgMemTotal[GLOBAL + 1];
|
||||
|
|
@ -205,17 +208,15 @@ void
|
|||
Error(const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char message[512];
|
||||
|
||||
/* Using lockless prints so we can error out while holding the lock */
|
||||
InterruptThreadProgress__();
|
||||
logprint_locked__("************ ERROR ************\n");
|
||||
|
||||
va_start(argptr, error);
|
||||
vsnprintf(message, sizeof(message), error, argptr);
|
||||
logvprint(error, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
fprintf(stderr, "\nERROR: %s\n\n", message);
|
||||
if (logfile) {
|
||||
fprintf(logfile, "\nERROR: %s\n\n", message);
|
||||
fclose(logfile);
|
||||
}
|
||||
logprint_locked__("\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -313,11 +314,12 @@ Message(int msgType, ...)
|
|||
return;
|
||||
}
|
||||
|
||||
if (msgType != msgFile)
|
||||
if (msgType == msgScreen)
|
||||
printf("%s", szBuffer);
|
||||
if (msgType != msgScreen && logfile)
|
||||
fprintf(logfile, "%s", szBuffer);
|
||||
else if (msgType == msgFile)
|
||||
logprint_silent("%s", szBuffer);
|
||||
else
|
||||
logprint("%s", szBuffer);
|
||||
|
||||
va_end(argptr);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue