diff --git a/metaserver/main.cpp b/metaserver/main.cpp index 2213288f1..6a31794a8 100644 --- a/metaserver/main.cpp +++ b/metaserver/main.cpp @@ -68,13 +68,15 @@ extern int getopt(int argc, char *const *argv, const char *opt); #if 1 // from stratagus.cpp, to avoid link issues. +bool EnableDebugPrint; /// if enabled, print the debug messages +bool EnableAssert; /// if enabled, halt on assertion failures +bool EnableUnitDebug; /// if enabled, a unit info dump will be created + void PrintLocation(const char *file, int line, const char *funcName) { fprintf(stdout, "%s:%d: %s: ", file, line, funcName); } -#ifdef DEBUG - void AbortAt(const char *file, int line, const char *funcName, const char *conditionStr) { fprintf(stderr, "Assertion failed at %s:%d: %s: %s\n", file, line, funcName, conditionStr); @@ -89,6 +91,67 @@ void PrintOnStdOut(const char *format, ...) va_end(valist); } +// from util.cpp + +#ifndef HAVE_GETOPT + +int opterr = 1; +int optind = 1; +int optopt; +char *optarg; + +static void getopt_err(const char *argv0, const char *str, char opt) +{ + if (opterr) { + const char *x; + + while ((x = strchr(argv0, '/'))) { + argv0 = x + 1; + } + + fprintf(stderr, "%s%s%c\n", argv0, str, opt); + } +} + +int getopt(int argc, char *const *argv, const char *opts) +{ + static int sp = 1; + register int c; + register const char *cp; + + optarg = NULL; + + if (sp == 1) { + if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0') { + return EOF; + } else if (!strcmp(argv[optind], "--")) { + optind++; + return EOF; + } + } + optopt = c = argv[optind][sp]; + if (c == ':' || (cp = strchr(opts, c)) == NULL) { + getopt_err(argv[0], ": illegal option -", (char)c); + cp = "xx"; /* make the next if false */ + c = '?'; + } + if (*++cp == ':') { + if (argv[optind][++sp] != '\0') { + optarg = &argv[optind++][sp]; + } else if (++optind < argc) { + optarg = argv[optind++]; + } else { + getopt_err(argv[0], ": option requires an argument -", (char)c); + c = (*opts == ':') ? ':' : '?'; + } + sp = 1; + } else if (argv[optind][++sp] == '\0') { + optind++; + sp = 1; + } + return c; +} + #endif #endif diff --git a/src/action/actions.cpp b/src/action/actions.cpp index ce3ff9d29..1d17384fe 100644 --- a/src/action/actions.cpp +++ b/src/action/actions.cpp @@ -33,9 +33,7 @@ -- Includes ----------------------------------------------------------------------------*/ -#ifdef DEBUG #include <time.h> -#endif #include "stratagus.h" #include "version.h" diff --git a/src/network/netconnect.cpp b/src/network/netconnect.cpp index f897bd3ba..204433a2e 100644 --- a/src/network/netconnect.cpp +++ b/src/network/netconnect.cpp @@ -214,7 +214,6 @@ void NetworkSendICMessage(CUDPSocket &socket, const CHost &host, const CInitMess delete[] buf; } -#ifdef DEBUG static const char *ncconstatenames[] = { "ccs_unused", "ccs_connecting", // new client @@ -261,7 +260,6 @@ static const char *icmsgsubtypenames[] = { "AreYouThere", // Server asks are you there "IAmHere", // Client answers I am here }; -#endif template <typename T> static void NetworkSendICMessage_Log(CUDPSocket &socket, const CHost &host, const T &msg) diff --git a/src/stratagus/util.cpp b/src/stratagus/util.cpp index c08a6494a..f7de96d53 100644 --- a/src/stratagus/util.cpp +++ b/src/stratagus/util.cpp @@ -492,8 +492,6 @@ void PrintLocation(const char *file, int line, const char *funcName) fprintf(stdout, "%s:%d: %s: ", file, line, funcName); } -#ifdef DEBUG - void AbortAt(const char *file, int line, const char *funcName, const char *conditionStr) { fprintf(stderr, "Assertion failed at %s:%d: %s: %s\n", file, line, funcName, conditionStr); @@ -510,6 +508,3 @@ void PrintOnStdOut(const char *format, ...) va_end(valist); fflush(stdout); } - -#endif -