revert ugly hack and fix the client/server problem (thanks to WahnFred)

tbh, i do not believe it is fixed yet :P

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5377 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Rafael Barreto
2010-07-15 15:17:27 +00:00
parent 822ec7f895
commit 173fc6efac
3 changed files with 43 additions and 40 deletions
+5 -4
View File
@@ -837,7 +837,7 @@ int main(int argc, char **argv)
quitdirectly = true;
}
break;
// case 'd': dedicated = true; break; // FIXME why someone would run a dedicated client?
case 'd': dedicated = true; break;
case 't': fullscreen = atoi(a); break;
case 'w': scr_w = atoi(a); break;
case 'h': scr_h = atoi(a); break;
@@ -869,11 +869,12 @@ int main(int argc, char **argv)
if(highprocesspriority) setprocesspriority(true);
#endif
initlog("net");
if (!dedicated) initlog("net");
if(enet_initialize()<0) fatal("Unable to initialise network module");
initclient();
initserver(dedicated); // never returns if dedicated // FIXME crashes if dedicated:: initserver(true) is called inside server.cpp::main
if (!dedicated) initclient();
//FIXME the server executed in this way does not catch the SIGTERM or ^C
initserver(dedicated,argc,argv); // never returns if dedicated
initlog("world");
empty_world(7, true);
+1 -1
View File
@@ -714,7 +714,7 @@ extern const char *modestr(int n, bool acronyms = false);
extern const char *voteerrorstr(int n);
extern const char *mmfullname(int n);
extern void fatal(const char *s, ...);
extern void initserver(bool dedicated);
extern void initserver(bool dedicated, int argc = 0, char **argv = NULL);
extern void cleanupserver();
extern void localconnect();
extern void localdisconnect();
+37 -35
View File
@@ -3792,8 +3792,42 @@ void processmasterinput(const char *cmd, int cmdlen, const char *args)
addgban(val);
}
void initserver(bool dedicated)
string server_name = "unarmed server";
void initserver(bool dedicated, int argc, char **argv)
{
const char *service = NULL;
for(int i = 1; i<argc; i++)
{
if(!scl.checkarg(argv[i]))
{
char *a = &argv[i][2];
if(!scl.checkarg(argv[i]) && argv[i][0]=='-') switch(argv[i][1])
{
case '-': break;
case 'S': service = a; break;
default: break; /*printf("WARNING: unknown commandline option\n");*/ // less warnings
}
else printf("WARNING: unknown commandline argument\n");
}
}
if(service && !svcctrl)
{
#ifdef WIN32
svcctrl = new winservice(service);
#endif
if(svcctrl)
{
svcctrl->argc = argc; svcctrl->argv = argv;
svcctrl->start();
}
}
if ( strlen(scl.servdesc_full) ) global_name = scl.servdesc_full;
else global_name = server_name;
srand(time(NULL));
smapname[0] = '\0';
@@ -3864,8 +3898,6 @@ void fatal(const char *s, ...)
exit(EXIT_FAILURE);
}
string server_name = "unarmed server";
int main(int argc, char **argv)
{
#ifdef WIN32
@@ -3877,43 +3909,13 @@ int main(int argc, char **argv)
#endif
#endif
const char *service = NULL;
for(int i = 1; i<argc; i++)
{
if(!scl.checkarg(argv[i]))
{
char *a = &argv[i][2];
if(!scl.checkarg(argv[i]) && argv[i][0]=='-') switch(argv[i][1])
{
case '-':
if(!strncmp(argv[i], "--wizard", 8))
return wizardmain(argc, argv);
break;
case 'S': service = a; break;
default: printf("WARNING: unknown commandline option\n");
}
else printf("WARNING: unknown commandline argument\n");
}
}
if ( strlen(scl.servdesc_full) ) global_name = scl.servdesc_full;
else global_name = server_name;
if(service && !svcctrl)
{
#ifdef WIN32
svcctrl = new winservice(service);
#endif
if(svcctrl)
{
svcctrl->argc = argc; svcctrl->argv = argv;
svcctrl->start();
}
if (!strncmp(argv[i],"--wizard",8)) return wizardmain(argc, argv);
}
if(enet_initialize()<0) fatal("Unable to initialise network module");
initserver(true);
initserver(true, argc, argv);
return EXIT_SUCCESS;
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)