Import of Empire 4.2.12

This commit is contained in:
Markus Armbruster 2003-08-23 12:23:04 +00:00
commit d8b7fdfae1
817 changed files with 126589 additions and 0 deletions

276
src/doconfig/doconfig.c Normal file
View file

@ -0,0 +1,276 @@
/*
* Empire - A multi-player, client/server Internet based war game.
* Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* ---
*
* See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
* related information and legal notices. It is expected that any future
* projects/authors will amend these files as needed.
*
* ---
*
* doconfig.c: Generates the gamesdef.h file used to build the game, and
* the various make include files needed to build correctly.
*
* Known contributors to this file:
* Steve McClure, 1996-2000
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#if !defined(_WIN32)
#include <unistd.h>
#endif
#include <string.h>
void wrmakesrc(char *pathname);
void wripglob(char *filename);
void wrauth(char *filename);
void wrgamesdef(char *filename);
char *_c_copyright_header = "/*\n * Empire - A multi-player, client/server Internet based war game.\n * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,\n * Ken Stevens, Steve McClure\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n * ---\n *\n * See the \"LEGAL\", \"LICENSE\", \"CREDITS\" and \"README\" files for all the\n * related information and legal notices. It is expected that any future\n * projects/authors will amend these files as needed.\n *\n * ---\n *\n * gamesdef.h: This is an auto-generated file.\n * \n * Known contributors to this file:\n * Automatically generated by doconfig.c\n */\n\n";
char *_ipglob_copyright_header = "/*\n * Empire - A multi-player, client/server Internet based war game.\n * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,\n * Ken Stevens, Steve McClure\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 2 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\n *\n * ---\n *\n * See the \"LEGAL\", \"LICENSE\", \"CREDITS\" and \"README\" files for all the\n * related information and legal notices. It is expected that any future\n * projects/authors will amend these files as needed.\n *\n * ---\n *\n * ipglob.c: This is an auto-generated file.\n * \n * Known contributors to this file:\n * Automatically generated by doconfig.c\n */\n\n";
#if defined(_WIN32)
char *
rindex(char *path, char c)
{
int i;
char *cp;
i = strlen(path);
cp = &path[i - 1];
while (i) {
if (*cp == c)
return cp;
i--;
cp--;
}
return (char *)0;
}
char *
index(char *path, char c)
{
int i;
char *cp;
cp = &path[0];
i = 0;
while (path[i]) {
if (*cp == c)
return cp;
i++;
cp++;
}
return (char *)0;
}
#endif
int
main()
{
char buf[256];
char *cp;
char *pathname;
if ((pathname = getcwd(NULL, 255)) == NULL) {
printf("Can't get current path!\n");
exit(-1);
}
#if !defined(_WIN32)
cp = (char *)rindex(pathname, '/');
*cp = '\0';
cp = (char *)rindex(pathname, '/');
*cp = '\0';
#else
cp = (char *)rindex(pathname, '\\');
*cp = '\0';
cp = (char *)rindex(pathname, '\\');
*cp = '\0';
#endif
printf("Configuring...\n");
wrmakesrc(pathname);
sprintf(buf, "%s/include/gamesdef.h", pathname);
wrgamesdef(buf);
sprintf(buf, "%s/src/client/ipglob.c", pathname);
wripglob(buf);
if (access(EP, 0)) {
printf("making directory %s\n", EP);
if (mkdir(EP, 493)) {
printf("mkdir failed on %s, exiting.\n", EP);
exit(-1);
}
}
sprintf(buf, "%s/data", EP);
if (access(buf, 0)) {
printf("making directory %s\n", buf);
if (mkdir(buf, 493)) {
printf("mkdir failed on %s, exiting.\n", buf);
exit(-1);
}
}
sprintf(buf, "%s/data/auth", EP);
wrauth(buf);
exit(0);
}
void
wrmakesrc(char *pathname)
{
FILE *fp;
char buf[256];
sprintf(buf, "%s/src/make.src", pathname);
if ((fp = fopen(buf, "w")) == NULL) {
printf("Cannot open %s for writing, exiting.\n", buf);
exit(-1);
}
fprintf(fp, "# make.src - Wolfpack, 1996-2000\n");
fprintf(fp, "# Source tree absolute pathname - auto generated.\n\n");
fprintf(fp, "SRCDIR = %s\n", pathname);
fclose(fp);
}
void
wripglob(char *filename)
{
FILE *fp;
printf("Writing %s\n", filename);
if ((fp = fopen(filename, "w")) == NULL) {
printf("Cannot open %s for writing, exiting.\n", filename);
exit(-1);
}
fprintf(fp, _ipglob_copyright_header);
fprintf(fp, "#include <stdio.h>\n");
fprintf(fp, "#include <setjmp.h>\n");
fprintf(fp, "#include \"misc.h\"\n");
fprintf(fp, "#include \"fnlist.h\"\n");
fprintf(fp, "#include \"proto.h\"\n\n");
fprintf(fp, "s_char empirehost[] = \"%s\";\n", HN);
fprintf(fp, "s_char empireport[] = \"%d\";\n", PN);
fclose(fp);
}
void
wrauth(char *filename)
{
FILE *fp;
printf("Writing %s\n", filename);
if ((fp = fopen(filename, "w")) == NULL) {
printf("Cannot open %s for writing, exiting.\n", filename);
exit(-1);
}
fprintf(fp, "# Wolfpack, 1996-2000\n#\n");
fprintf(fp, "# Empire Authorization File - Users listed will be allowed to log in as deities.\n#\n");
fprintf(fp, "# Format is:\n");
fprintf(fp, "# hostname that authorized user uses on a line\n");
fprintf(fp, "# username that authorized user uses on a line\n#\n");
fprintf(fp, "# REMEMBER TO USE PAIRS OF LINES!\n#\n");
fprintf(fp, "# Example:\n#\n");
fprintf(fp, "nowhere.land.edu\nnowhereman\n");
fprintf(fp, "%s\n%s\n", HN, UN);
fprintf(fp, "%s\n%s\n", IP, UN);
fprintf(fp, "127.0.0.1\n%s\n", UN);
fclose(fp);
}
void
wrgamesdef(char *filename)
{
FILE *fp;
char path[512];
char *cp;
unsigned int i;
int s_p_etu;
char buf[40];
char c = 'b';
cp = &path[0];
for (i = 0; i < strlen(EP); i++) {
*cp++ = EP[i];
if (EP[i] == '\\')
*cp++ = '\\';
}
*cp = 0;
strcpy(buf, EF);
if (strlen(buf) > 0)
c = buf[strlen(buf) - 1];
if (index("dhm", c) && strlen(buf) > 0) {
s_p_etu = atoi(buf);
if (c == 'd')
s_p_etu = (((double)s_p_etu * 60.0 * 60.0 * 24.0) / (double)ET);
else if (c == 'h')
s_p_etu = (((double)s_p_etu * 60.0 * 60.0) / (double)ET);
else if (c == 'm')
s_p_etu = (((double)s_p_etu * 60.0) / (double)ET);
} else {
printf("ETU frequency is bad - using 10 minutes.\n");
s_p_etu = 600 / ET;
}
printf("Writing %s\n", filename);
if ((fp = fopen(filename, "w")) == NULL) {
printf("Cannot open %s for writing, exiting.\n", filename);
exit(-1);
}
fprintf(fp, _c_copyright_header);
fprintf(fp, "/*\n * Wolfpack, 1996-2000\n *\n");
fprintf(fp, " * gamesdef.h - generated automatically by doconfig. Feel\n");
fprintf(fp, " * free to change these, but if you rebuild with overwrite on\n");
fprintf(fp, " * this file will be overwritten again.\n");
fprintf(fp, " */\n\n");
fprintf(fp, "#ifndef _GAMESDEF_H_\n");
fprintf(fp, "#define _GAMESDEF_H_\n\n");
fprintf(fp, "#if !defined(_WIN32)\n");
fprintf(fp, "#ifdef __STDC__\n");
fprintf(fp, "#define EMPPATH(xyz) \"%s/\" #xyz /* ANSI C */\n", EP);
fprintf(fp, "#else\n");
fprintf(fp, "#define EMPPATH(xyz) \"%s/xyz\" /* traditional */\n", EP);
fprintf(fp, "#endif /* __STDC__ */\n");
fprintf(fp, "#else\n");
fprintf(fp, "#define EMPPATH(xyz) \"%s\\\\\" #xyz /* ANSI C */\n", path);
fprintf(fp, "#endif /* _WIN32 */\n\n");
fprintf(fp, "#define PRVNAM \"%s\"\n", PV);
fprintf(fp, "#define PRVLOG \"%s\"\n", EM);
fprintf(fp, "#define GET_SOURCE \"using:\\n ftp://ftp.wolfpackempire.com/pub/empire/server or \\n http://www.wolfpackempire.com/\"\n");
fprintf(fp, "#define EMP_HOST \"%s\"\n", IP);
fprintf(fp, "#define EMP_PORT \"%d\"\n\n", PN);
fprintf(fp, "#define MAXNOC %d\n\n", MC);
fprintf(fp, "#define DEF_WORLD_X %d\n", WX);
fprintf(fp, "#define DEF_WORLD_Y %d\n\n", WY);
fprintf(fp, "#define DEF_S_P_ETU %d\n", s_p_etu);
fprintf(fp, "#define ETUS %d\n\n", ET);
if (BL)
fprintf(fp, "#define BLITZ 1\n\n");
fprintf(fp, "#endif /* _GAMESDEF_H_ */\n");
fclose(fp);
}