[-] Fixed compilation for metaserver and in release mode

This commit is contained in:
cybermind 2013-04-30 17:33:12 +06:00
parent b45c081b0b
commit 7383712a0d
4 changed files with 65 additions and 11 deletions
metaserver
src
action
network
stratagus

View file

@ -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

View file

@ -33,9 +33,7 @@
-- Includes
----------------------------------------------------------------------------*/
#ifdef DEBUG
#include <time.h>
#endif
#include "stratagus.h"
#include "version.h"

View file

@ -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)

View file

@ -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