2001-01-25 10:37:55 +01:00
|
|
|
|
/* vi: set ts=2:
|
|
|
|
|
*
|
2001-12-10 01:13:39 +01:00
|
|
|
|
*
|
2003-07-29 11:48:03 +02:00
|
|
|
|
* Eressea PB(E)M host Copyright (C) 1998-2003
|
2001-01-25 10:37:55 +01:00
|
|
|
|
* Christian Schlittchen (corwin@amber.kn-bremen.de)
|
|
|
|
|
* Katja Zedel (katze@felidae.kn-bremen.de)
|
|
|
|
|
* Henning Peters (faroul@beyond.kn-bremen.de)
|
|
|
|
|
* Enno Rehling (enno@eressea-pbem.de)
|
|
|
|
|
* Ingo Wilken (Ingo.Wilken@informatik.uni-oldenburg.de)
|
|
|
|
|
*
|
|
|
|
|
* based on:
|
|
|
|
|
*
|
|
|
|
|
* Atlantis v1.0 13 September 1993 Copyright 1993 by Russell Wallace
|
|
|
|
|
* Atlantis v1.7 Copyright 1996 by Alex Schr<EFBFBD>der
|
|
|
|
|
*
|
|
|
|
|
* This program may not be used, modified or distributed without
|
|
|
|
|
* prior permission by the authors of Eressea.
|
|
|
|
|
* This program may not be sold or used commercially without prior written
|
|
|
|
|
* permission from the authors.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define LOCALE_CHECK
|
|
|
|
|
#ifdef __LCC__
|
|
|
|
|
#undef LOCALE_CHECK
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
2003-12-17 11:28:23 +01:00
|
|
|
|
#include "eressea.h"
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2001-01-26 17:19:41 +01:00
|
|
|
|
/* initialization - TODO: init in separate module */
|
|
|
|
|
#include <attributes/attributes.h>
|
2001-02-03 14:45:35 +01:00
|
|
|
|
#include <spells/spells.h>
|
|
|
|
|
#include <triggers/triggers.h>
|
2005-01-30 09:57:16 +01:00
|
|
|
|
#include <items/itemtypes.h>
|
2001-01-26 17:19:41 +01:00
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
/* modules includes */
|
|
|
|
|
#include <modules/score.h>
|
2003-08-03 19:56:17 +02:00
|
|
|
|
#include <modules/xmas.h>
|
2001-01-30 21:26:06 +01:00
|
|
|
|
#include <modules/gmcmd.h>
|
2001-12-10 01:13:39 +01:00
|
|
|
|
#include <modules/infocmd.h>
|
2005-04-30 16:48:32 +02:00
|
|
|
|
#include <modules/autoseed.h>
|
2002-09-02 22:36:12 +02:00
|
|
|
|
#ifdef MUSEUM_MODULE
|
|
|
|
|
#include <modules/museum.h>
|
|
|
|
|
#endif
|
2004-02-21 23:25:00 +01:00
|
|
|
|
#ifdef WORMHOLE_MODULE
|
|
|
|
|
#include <modules/wormhole.h>
|
|
|
|
|
#endif
|
2002-09-02 22:36:12 +02:00
|
|
|
|
#ifdef ARENA_MODULE
|
|
|
|
|
#include <modules/arena.h>
|
|
|
|
|
#endif
|
2004-03-28 22:53:47 +02:00
|
|
|
|
#ifdef DUNGEON_MODULE
|
|
|
|
|
#include <modules/dungeon.h>
|
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
/* gamecode includes */
|
2005-01-30 09:57:16 +01:00
|
|
|
|
#include <gamecode/economy.h>
|
|
|
|
|
#include <gamecode/items.h>
|
|
|
|
|
#include <gamecode/laws.h>
|
|
|
|
|
#include <gamecode/monster.h>
|
2005-10-25 14:38:01 +02:00
|
|
|
|
#include <gamecode/creport.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
/* kernel includes */
|
2004-03-29 19:41:19 +02:00
|
|
|
|
#include <kernel/xmlreader.h>
|
2004-04-11 02:01:05 +02:00
|
|
|
|
#include <kernel/spell.h>
|
2005-10-25 14:38:01 +02:00
|
|
|
|
#include <kernel/building.h>
|
|
|
|
|
#include <kernel/faction.h>
|
|
|
|
|
#include <kernel/message.h>
|
|
|
|
|
#include <kernel/plane.h>
|
|
|
|
|
#include <kernel/race.h>
|
|
|
|
|
#include <kernel/skill.h>
|
|
|
|
|
#include <kernel/teleport.h>
|
|
|
|
|
#include <kernel/unit.h>
|
|
|
|
|
#include <kernel/region.h>
|
|
|
|
|
#include <kernel/reports.h>
|
|
|
|
|
#include <kernel/resources.h>
|
|
|
|
|
#include <kernel/save.h>
|
|
|
|
|
#include <kernel/ship.h>
|
|
|
|
|
#include <kernel/border.h>
|
|
|
|
|
#include <kernel/region.h>
|
|
|
|
|
#include <kernel/terrain.h>
|
|
|
|
|
#include <kernel/item.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
/* util includes */
|
|
|
|
|
#include <rand.h>
|
2004-03-29 19:41:19 +02:00
|
|
|
|
#include <util/xml.h>
|
2005-01-30 09:57:16 +01:00
|
|
|
|
#include <util/goodies.h>
|
2003-06-22 10:38:55 +02:00
|
|
|
|
#include <log.h>
|
2002-04-16 19:54:05 +02:00
|
|
|
|
#include <sql.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#include <base36.h>
|
|
|
|
|
|
|
|
|
|
/* libc includes */
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <string.h>
|
2001-04-13 16:39:57 +02:00
|
|
|
|
#include <time.h>
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#include <locale.h>
|
|
|
|
|
|
2005-04-30 16:48:32 +02:00
|
|
|
|
#define ISLANDSIZE 20
|
|
|
|
|
|
2001-12-10 01:13:39 +01:00
|
|
|
|
/**
|
2001-02-05 17:11:59 +01:00
|
|
|
|
** global variables we are importing from other modules
|
|
|
|
|
**/
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern char * g_reportdir;
|
|
|
|
|
extern char * g_datadir;
|
|
|
|
|
extern char * g_basedir;
|
2001-02-03 14:45:35 +01:00
|
|
|
|
extern char * g_resourcedir;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
extern boolean nonr;
|
2005-04-30 16:48:32 +02:00
|
|
|
|
extern boolean nosh;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern boolean nocr;
|
2002-02-16 11:37:18 +01:00
|
|
|
|
extern boolean noreports;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern boolean nomer;
|
|
|
|
|
extern boolean nobattle;
|
2003-09-21 12:09:08 +02:00
|
|
|
|
extern boolean nomonsters;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
extern boolean nobattledebug;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
extern boolean dirtyload;
|
|
|
|
|
|
2002-05-05 11:34:36 +02:00
|
|
|
|
extern int loadplane;
|
|
|
|
|
|
2001-04-13 16:39:57 +02:00
|
|
|
|
extern void debug_messagetypes(FILE * out);
|
2001-12-10 01:13:39 +01:00
|
|
|
|
extern void free_region(region * r);
|
2001-04-13 16:39:57 +02:00
|
|
|
|
extern void render_init(void);
|
2001-12-10 01:13:39 +01:00
|
|
|
|
extern void free_borders(void);
|
|
|
|
|
|
2001-04-13 16:39:57 +02:00
|
|
|
|
|
2001-02-05 17:11:59 +01:00
|
|
|
|
#ifdef FUZZY_BASE36
|
|
|
|
|
extern int fuzzy_hits;
|
|
|
|
|
#endif /* FUZZY_BASE36 */
|
|
|
|
|
|
2001-12-10 01:13:39 +01:00
|
|
|
|
/**
|
2003-11-10 11:05:18 +01:00
|
|
|
|
** global variables that we are exporting
|
2001-02-05 17:11:59 +01:00
|
|
|
|
**/
|
2001-04-13 16:39:57 +02:00
|
|
|
|
static char * orders = NULL;
|
|
|
|
|
static int nowrite = 0;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
static boolean g_writemap = false;
|
2003-11-10 10:19:07 +01:00
|
|
|
|
static boolean opt_reportonly = false;
|
2003-12-14 13:27:09 +01:00
|
|
|
|
extern boolean opt_cr_absolute_coords;
|
2001-04-13 16:39:57 +02:00
|
|
|
|
|
2001-02-05 17:11:59 +01:00
|
|
|
|
struct settings global = {
|
|
|
|
|
"Eressea", /* gamename */
|
2001-12-15 15:44:18 +01:00
|
|
|
|
"eressea", /* resourcepath */
|
2001-12-15 13:26:04 +01:00
|
|
|
|
1000, /* maxunits */
|
2001-02-05 17:11:59 +01:00
|
|
|
|
};
|
|
|
|
|
|
2001-01-25 10:37:55 +01:00
|
|
|
|
static void
|
2003-10-05 09:29:31 +02:00
|
|
|
|
game_init(void)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
{
|
2001-02-03 14:45:35 +01:00
|
|
|
|
init_triggers();
|
2003-08-03 19:56:17 +02:00
|
|
|
|
init_xmas();
|
- Neue Messages fertig
Messages werden jetzt in einem anderen Meta-Format (message* of
message_type*) gespeichert, das man in beliebige Formate (CR oder NR)
rendern kann. crmessage.c und nrmessage.c sind die render-engines dafür.
Die Messagetypen werden in res/{de,en}/messages.xml gesammelt, ultimativ
kann das aber durchaus eine einzelne Datei sein. Die ist derzeit nicht
wirklich xml (Umlaute drin, keine Definitionsdatei), aber gut lesbar.
- make_message
Diese Funktion ersetzt new_message, und ist etwas einfacher in der Syntax:
make_message("dumb_mistake", "unit region command", u, r, cmd) erzeugt
eine neue Nachricht, die dann einfach mit add_message wie bisher an die
Nachrichtenliste gehängt werden kann.
TODO: Messages könnte man durchaus reference-counten, und in mehrere Listen
einfügen, solang sie a) mehrfachverwendet (Kampf!) und b) vom Betrachter
unabhängig sind. Das spart einigen Speicher.
- CR Version erhöht.
Weil die MESSAGETYPES Blocks anders sind als früher
- OFFENSIVE_DELAY
Verbietet Einheiten, deren Partei eine Reigon niht bewachen, den
Angriff in der Region, wenn sie sich in der Runde zuvor bewegt haben.
Status der letzten Runde wird in neuem Attribut at_moved gespeichert.
- SHORT_ATTACKS
ein define, das angibt ob Kämpfen grundsätzlich keine lange Aktion ist.
- XML Parser
xml.[hc] enthält einen XML-Parser, dem man ein plugin mit callbacks
übergibt, die nach dem Parsen eines tokens aufgerufen werden.
2001-04-12 19:21:57 +02:00
|
|
|
|
report_init();
|
|
|
|
|
creport_init();
|
|
|
|
|
|
2001-04-16 16:34:19 +02:00
|
|
|
|
debug_language("locales.log");
|
2002-01-09 09:20:33 +01:00
|
|
|
|
register_races();
|
|
|
|
|
register_resources();
|
2002-03-27 22:49:27 +01:00
|
|
|
|
register_buildings();
|
2002-01-31 23:18:00 +01:00
|
|
|
|
register_ships();
|
2005-10-26 21:02:45 +02:00
|
|
|
|
register_itemfunctions();
|
2002-01-09 09:20:33 +01:00
|
|
|
|
register_spells();
|
2004-03-28 22:53:47 +02:00
|
|
|
|
#ifdef DUNGEON_MODULE
|
2002-01-09 09:20:33 +01:00
|
|
|
|
register_dungeon();
|
2004-03-28 22:53:47 +02:00
|
|
|
|
#endif
|
2001-12-10 01:13:39 +01:00
|
|
|
|
|
2004-03-29 19:41:19 +02:00
|
|
|
|
register_xmlreader();
|
2005-01-31 00:33:28 +01:00
|
|
|
|
enable_xml_gamecode();
|
2004-04-11 02:01:05 +02:00
|
|
|
|
init_spells();
|
2004-03-29 19:41:19 +02:00
|
|
|
|
init_data(xmlfile);
|
2001-12-10 01:13:39 +01:00
|
|
|
|
|
2004-03-29 19:41:19 +02:00
|
|
|
|
init_locales();
|
|
|
|
|
init_attributes();
|
|
|
|
|
init_races();
|
2005-01-30 09:57:16 +01:00
|
|
|
|
init_itemtypes();
|
2004-03-07 13:50:53 +01:00
|
|
|
|
init_races();
|
2001-12-10 01:13:39 +01:00
|
|
|
|
init_economy();
|
2001-12-15 13:26:04 +01:00
|
|
|
|
#if NEW_RESOURCEGROWTH
|
2001-12-10 01:13:39 +01:00
|
|
|
|
init_rawmaterials();
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-01-30 21:26:06 +01:00
|
|
|
|
init_gmcmd();
|
2004-06-21 18:45:27 +02:00
|
|
|
|
#ifdef INFOCMD_MODULE
|
2001-12-10 01:13:39 +01:00
|
|
|
|
init_info();
|
2004-06-21 18:45:27 +02:00
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2002-09-02 22:36:12 +02:00
|
|
|
|
#ifdef MUSEUM_MODULE
|
2003-07-29 11:48:03 +02:00
|
|
|
|
register_museum();
|
2002-09-02 22:36:12 +02:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef ARENA_MODULE
|
2003-07-29 11:48:03 +02:00
|
|
|
|
register_arena();
|
2002-09-02 22:36:12 +02:00
|
|
|
|
#endif
|
2004-02-21 23:25:00 +01:00
|
|
|
|
#ifdef WORMHOLE_MODULE
|
|
|
|
|
register_wormholes();
|
|
|
|
|
#endif
|
2001-02-14 02:38:51 +01:00
|
|
|
|
#ifdef REMOVE_THIS
|
2001-02-05 17:27:07 +01:00
|
|
|
|
render_init();
|
2001-02-14 02:38:51 +01:00
|
|
|
|
{
|
|
|
|
|
FILE * F = fopen("messagetypes.txt", "w");
|
|
|
|
|
debug_messagetypes(F);
|
|
|
|
|
fclose(F);
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2001-02-05 17:27:07 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-06-22 10:38:55 +02:00
|
|
|
|
#ifdef SHORTPWDS
|
|
|
|
|
static void
|
|
|
|
|
readshortpwds()
|
|
|
|
|
{
|
|
|
|
|
FILE * F;
|
|
|
|
|
char zText[MAX_PATH];
|
|
|
|
|
sprintf(zText, "%s/%s.%u", basepath(), "shortpwds", turn);
|
|
|
|
|
|
|
|
|
|
F = fopen(zText, "r");
|
|
|
|
|
if (F==NULL) {
|
|
|
|
|
log_error(("could not open password file %s", zText));
|
|
|
|
|
} else {
|
|
|
|
|
while (!feof(F)) {
|
|
|
|
|
faction * f;
|
|
|
|
|
char passwd[16], faction[5], email[64];
|
|
|
|
|
fscanf(F, "%s %s %s\n", faction, passwd, email);
|
|
|
|
|
f = findfaction(atoi36(faction));
|
|
|
|
|
if (f!=NULL) {
|
|
|
|
|
shortpwd * pwd = (shortpwd*)malloc(sizeof(shortpwd));
|
2004-08-22 11:33:15 +02:00
|
|
|
|
if (set_email(&pwd->email, email)!=0) {
|
2004-08-29 01:06:15 +02:00
|
|
|
|
log_error(("Invalid email address faction %s: %s\n", faction, email));
|
2004-08-22 11:33:15 +02:00
|
|
|
|
}
|
2003-06-22 10:38:55 +02:00
|
|
|
|
pwd->pwd = strdup(passwd);
|
|
|
|
|
pwd->used = false;
|
|
|
|
|
pwd->next = f->shortpwds;
|
|
|
|
|
f->shortpwds = pwd;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fclose(F);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-02-05 17:11:59 +01:00
|
|
|
|
static int
|
2001-01-25 10:37:55 +01:00
|
|
|
|
processturn(char *filename)
|
|
|
|
|
{
|
|
|
|
|
struct summary * begin, * end;
|
2005-04-30 16:48:32 +02:00
|
|
|
|
newfaction * players;
|
2001-02-05 17:11:59 +01:00
|
|
|
|
int i;
|
|
|
|
|
|
2005-06-10 00:10:35 +02:00
|
|
|
|
if (turn == 0) srand((int)time(0));
|
2004-06-23 00:00:36 +02:00
|
|
|
|
else srand(turn);
|
|
|
|
|
|
2003-06-22 10:38:55 +02:00
|
|
|
|
#ifdef SHORTPWDS
|
|
|
|
|
readshortpwds("passwords");
|
|
|
|
|
#endif
|
2005-04-24 23:49:51 +02:00
|
|
|
|
begin = make_summary();
|
2001-01-25 10:37:55 +01:00
|
|
|
|
turn++;
|
2001-02-05 17:11:59 +01:00
|
|
|
|
if ((i=readorders(filename))!=0) return i;
|
2004-06-23 00:00:36 +02:00
|
|
|
|
if (!nomonsters) {
|
2005-06-10 00:10:35 +02:00
|
|
|
|
if (turn == 0) srand((int)time(0));
|
2004-06-23 00:00:36 +02:00
|
|
|
|
else srand(turn);
|
|
|
|
|
puts(" - Monster KI...");
|
|
|
|
|
plan_monsters();
|
|
|
|
|
}
|
2001-02-05 17:11:59 +01:00
|
|
|
|
processorders();
|
2005-04-30 16:48:32 +02:00
|
|
|
|
sprintf(buf, "%s/newfactions", basepath());
|
|
|
|
|
players = read_newfactions(filename);
|
|
|
|
|
while (players) {
|
|
|
|
|
int n = listlen(players);
|
|
|
|
|
int k = (n+ISLANDSIZE-1)/ISLANDSIZE;
|
|
|
|
|
k = n / k;
|
2005-08-07 15:48:18 +02:00
|
|
|
|
autoseed(&players, k, true);
|
2005-04-30 16:48:32 +02:00
|
|
|
|
}
|
2001-02-05 17:11:59 +01:00
|
|
|
|
score();
|
2001-01-25 10:37:55 +01:00
|
|
|
|
remove_unequipped_guarded();
|
2002-02-16 11:37:18 +01:00
|
|
|
|
if (!noreports) reports();
|
2001-01-25 10:37:55 +01:00
|
|
|
|
free_units();
|
|
|
|
|
puts(" - Beseitige leere Parteien");
|
2002-05-02 01:47:32 +02:00
|
|
|
|
remove_empty_factions(true);
|
2005-04-24 23:49:51 +02:00
|
|
|
|
end = make_summary();
|
2001-01-25 10:37:55 +01:00
|
|
|
|
report_summary(end, begin, false);
|
|
|
|
|
report_summary(end, begin, true);
|
|
|
|
|
free(end);
|
|
|
|
|
free(begin);
|
|
|
|
|
writepasswd();
|
|
|
|
|
#ifdef FUZZY_BASE36
|
|
|
|
|
fputs("==--------------------------==\n", stdout);
|
|
|
|
|
fprintf(stdout, "## fuzzy base10 hits: %5d ##\n", fuzzy_hits);
|
|
|
|
|
fputs("==--------------------------==\n", stdout);
|
|
|
|
|
#endif /* FUZZY_BASE36 */
|
|
|
|
|
if (!nowrite) {
|
|
|
|
|
char ztext[64];
|
2003-12-28 11:58:26 +01:00
|
|
|
|
sprintf(ztext, "%d", turn);
|
2003-12-28 11:54:47 +01:00
|
|
|
|
return writegame(ztext, 0);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
2001-02-05 17:11:59 +01:00
|
|
|
|
return 0;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-10 01:13:39 +01:00
|
|
|
|
#ifdef CLEANUP_CODE
|
2001-02-05 17:11:59 +01:00
|
|
|
|
static void
|
|
|
|
|
game_done(void)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
{
|
|
|
|
|
/* Diese Routine enfernt allen allokierten Speicher wieder. Das ist nur
|
|
|
|
|
* zum Debugging interessant, wenn man Leak Detection hat, und nach
|
|
|
|
|
* nicht freigegebenem Speicher sucht, der nicht bis zum Ende ben<EFBFBD>tigt
|
|
|
|
|
* wird (tempor<EFBFBD>re Hilsstrukturen) */
|
|
|
|
|
unit *u, *u2;
|
|
|
|
|
region *r, *r2;
|
|
|
|
|
building *b, *b2;
|
|
|
|
|
faction *f, *f2;
|
|
|
|
|
ship *s, *s2;
|
|
|
|
|
|
|
|
|
|
free(used_faction_ids);
|
|
|
|
|
for (r = regions; r; r = r2) {
|
|
|
|
|
#if 0
|
|
|
|
|
msg * m = r->msgs;
|
|
|
|
|
while (m) {
|
|
|
|
|
msg * x = m;
|
|
|
|
|
m = m->next;
|
|
|
|
|
if (x->type->finalize) x->type->finalize(x);
|
|
|
|
|
free(x);
|
|
|
|
|
}
|
|
|
|
|
rm = rm->next;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
for (u = r->units; u; u = u2) {
|
|
|
|
|
u2 = u->next;
|
|
|
|
|
stripunit(u);
|
|
|
|
|
uunhash(u);
|
|
|
|
|
free(u);
|
|
|
|
|
}
|
|
|
|
|
for (b = r->buildings; b; b = b2) {
|
|
|
|
|
free(b->name);
|
|
|
|
|
free(b->display);
|
|
|
|
|
b2 = b->next;
|
|
|
|
|
free(b);
|
|
|
|
|
}
|
|
|
|
|
for (s = r->ships; s; s = s2) {
|
|
|
|
|
free(s->name);
|
|
|
|
|
free(s->display);
|
|
|
|
|
s2 = s->next;
|
|
|
|
|
free(s);
|
|
|
|
|
}
|
|
|
|
|
r2 = r->next;
|
2001-12-10 01:13:39 +01:00
|
|
|
|
free_region(r);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
|
|
|
|
for (f = factions; f; f = f2) {
|
|
|
|
|
stripfaction(f);
|
|
|
|
|
f2 = f->next;
|
|
|
|
|
free(f);
|
|
|
|
|
}
|
|
|
|
|
while (planes) {
|
|
|
|
|
plane * pl = planes;
|
|
|
|
|
planes = planes->next;
|
|
|
|
|
free(pl);
|
|
|
|
|
}
|
2001-02-05 17:11:59 +01:00
|
|
|
|
creport_cleanup();
|
- Neue Messages fertig
Messages werden jetzt in einem anderen Meta-Format (message* of
message_type*) gespeichert, das man in beliebige Formate (CR oder NR)
rendern kann. crmessage.c und nrmessage.c sind die render-engines dafür.
Die Messagetypen werden in res/{de,en}/messages.xml gesammelt, ultimativ
kann das aber durchaus eine einzelne Datei sein. Die ist derzeit nicht
wirklich xml (Umlaute drin, keine Definitionsdatei), aber gut lesbar.
- make_message
Diese Funktion ersetzt new_message, und ist etwas einfacher in der Syntax:
make_message("dumb_mistake", "unit region command", u, r, cmd) erzeugt
eine neue Nachricht, die dann einfach mit add_message wie bisher an die
Nachrichtenliste gehängt werden kann.
TODO: Messages könnte man durchaus reference-counten, und in mehrere Listen
einfügen, solang sie a) mehrfachverwendet (Kampf!) und b) vom Betrachter
unabhängig sind. Das spart einigen Speicher.
- CR Version erhöht.
Weil die MESSAGETYPES Blocks anders sind als früher
- OFFENSIVE_DELAY
Verbietet Einheiten, deren Partei eine Reigon niht bewachen, den
Angriff in der Region, wenn sie sich in der Runde zuvor bewegt haben.
Status der letzten Runde wird in neuem Attribut at_moved gespeichert.
- SHORT_ATTACKS
ein define, das angibt ob Kämpfen grundsätzlich keine lange Aktion ist.
- XML Parser
xml.[hc] enthält einen XML-Parser, dem man ein plugin mit callbacks
übergibt, die nach dem Parsen eines tokens aufgerufen werden.
2001-04-12 19:21:57 +02:00
|
|
|
|
report_cleanup();
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
2001-12-10 01:13:39 +01:00
|
|
|
|
#endif
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
|
|
|
|
#include "magic.h"
|
|
|
|
|
|
2005-05-07 12:07:06 +02:00
|
|
|
|
#ifdef CRTDBG
|
2003-03-08 21:57:38 +01:00
|
|
|
|
void
|
2005-05-07 12:07:06 +02:00
|
|
|
|
init_crtdbg(void)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
{
|
|
|
|
|
#if (defined(_MSC_VER))
|
|
|
|
|
# if MALLOCDBG == 2
|
|
|
|
|
# define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF)
|
2003-03-08 21:57:38 +01:00
|
|
|
|
# elif MALLOCDBG == 3
|
|
|
|
|
# define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & 0)
|
2001-01-25 10:37:55 +01:00
|
|
|
|
# elif MALLOCDBG == 1
|
|
|
|
|
# define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_DELAY_FREE_MEM_DF)
|
|
|
|
|
# endif
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-12-10 01:13:39 +01:00
|
|
|
|
static int
|
2001-02-05 17:11:59 +01:00
|
|
|
|
usage(const char * prog, const char * arg)
|
|
|
|
|
{
|
|
|
|
|
if (arg) {
|
|
|
|
|
fprintf(stderr, "unknown argument: %s\n\n", arg);
|
|
|
|
|
}
|
|
|
|
|
fprintf(stderr, "Usage: %s [options]\n"
|
|
|
|
|
"-x n : L<>dt nur die ersten n regionen\n"
|
|
|
|
|
"-f x y : L<>dt nur die regionen ab (x,y)\n"
|
|
|
|
|
"-v befehlsdatei : verarbeitet automatisch die angegebene Befehlsdatei\n"
|
|
|
|
|
"-d datadir : gibt das datenverzeichnis an\n"
|
|
|
|
|
"-b basedir : gibt das basisverzeichnis an\n"
|
|
|
|
|
"-r resdir : gibt das resourceverzeichnis an\n"
|
|
|
|
|
"-t turn : read this datafile, not the most current one\n"
|
|
|
|
|
"-o reportdir : gibt das reportverzeichnis an\n"
|
2001-03-04 19:41:27 +01:00
|
|
|
|
"-l logfile : specify an alternative logfile\n"
|
2003-11-10 10:19:07 +01:00
|
|
|
|
"-R : erstellt nur die Reports neu\n"
|
2005-04-23 11:47:03 +02:00
|
|
|
|
"--lomem : keine Messages (RAM sparen)\n"
|
2001-02-05 17:11:59 +01:00
|
|
|
|
"--nobattle : keine K<>mpfe\n"
|
2003-09-21 12:09:08 +02:00
|
|
|
|
"--nomonsters : keine monster KI\n"
|
2001-02-05 17:11:59 +01:00
|
|
|
|
"--nodebug : keine Logfiles f<>r K<>mpfe\n"
|
2005-09-03 11:13:36 +02:00
|
|
|
|
"--noreports : absolut keine Reporte schreiben\n"
|
2001-02-05 17:11:59 +01:00
|
|
|
|
"--debug : schreibt Debug-Ausgaben in die Datei debug\n"
|
|
|
|
|
"--nocr : keine CRs\n"
|
|
|
|
|
"--nonr : keine Reports\n"
|
2005-04-30 16:48:32 +02:00
|
|
|
|
"--nosh : keine Mail-skripte\n"
|
2003-11-10 11:05:18 +01:00
|
|
|
|
"--crabsolute : absolute Koordinaten im CR\n"
|
2001-02-05 17:11:59 +01:00
|
|
|
|
"--help : help\n", prog);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2002-03-11 22:20:31 +01:00
|
|
|
|
extern int demonfix;
|
|
|
|
|
|
2001-02-05 17:11:59 +01:00
|
|
|
|
static int
|
|
|
|
|
read_args(int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
2004-01-11 11:05:03 +01:00
|
|
|
|
|
2001-02-05 17:11:59 +01:00
|
|
|
|
for (i=1;i!=argc;++i) {
|
|
|
|
|
if (argv[i][0]!='-') {
|
|
|
|
|
return usage(argv[0], argv[i]);
|
|
|
|
|
} else if (argv[i][1]=='-') { /* long format */
|
2002-02-16 11:37:18 +01:00
|
|
|
|
if (strcmp(argv[i]+2, "nocr")==0) nocr = true;
|
2001-02-05 17:11:59 +01:00
|
|
|
|
else if (strcmp(argv[i]+2, "nosave")==0) nowrite = true;
|
2002-02-16 11:37:18 +01:00
|
|
|
|
else if (strcmp(argv[i]+2, "noreports")==0) {
|
|
|
|
|
noreports = true;
|
|
|
|
|
nocr = true;
|
|
|
|
|
nocr = true;
|
|
|
|
|
}
|
2001-12-13 23:00:33 +01:00
|
|
|
|
else if (strcmp(argv[i]+2, "xml")==0) xmlfile = argv[++i];
|
2001-09-05 21:40:40 +02:00
|
|
|
|
else if (strcmp(argv[i]+2, "dirtyload")==0) dirtyload = true;
|
2001-02-05 17:11:59 +01:00
|
|
|
|
else if (strcmp(argv[i]+2, "nonr")==0) nonr = true;
|
2005-04-30 16:48:32 +02:00
|
|
|
|
else if (strcmp(argv[i]+2, "nosh")==0) nosh = true;
|
2005-04-23 11:47:03 +02:00
|
|
|
|
else if (strcmp(argv[i]+2, "lomem")==0) lomem = true;
|
2001-02-05 17:11:59 +01:00
|
|
|
|
else if (strcmp(argv[i]+2, "nobattle")==0) nobattle = true;
|
2003-09-21 12:09:08 +02:00
|
|
|
|
else if (strcmp(argv[i]+2, "nomonsters")==0) nomonsters = true;
|
2001-02-05 17:11:59 +01:00
|
|
|
|
else if (strcmp(argv[i]+2, "nodebug")==0) nobattledebug = true;
|
2003-11-10 11:05:18 +01:00
|
|
|
|
else if (strcmp(argv[i]+2, "crabsolute")==0) opt_cr_absolute_coords = true;
|
2001-12-10 01:13:39 +01:00
|
|
|
|
else if (strcmp(argv[i]+2, "help")==0)
|
2001-02-05 17:11:59 +01:00
|
|
|
|
return usage(argv[0], NULL);
|
|
|
|
|
else
|
|
|
|
|
return usage(argv[0], argv[i]);
|
|
|
|
|
} else switch(argv[i][1]) {
|
2001-01-25 10:37:55 +01:00
|
|
|
|
case 'o':
|
|
|
|
|
g_reportdir = argv[++i];
|
|
|
|
|
break;
|
2001-03-04 19:41:27 +01:00
|
|
|
|
case 'D': /* DEBUG */
|
2002-03-11 22:20:31 +01:00
|
|
|
|
demonfix = atoi(argv[++i]);
|
2001-03-04 19:41:27 +01:00
|
|
|
|
break;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
case 'd':
|
|
|
|
|
g_datadir = argv[++i];
|
|
|
|
|
break;
|
2001-02-03 14:45:35 +01:00
|
|
|
|
case 'r':
|
|
|
|
|
g_resourcedir = argv[++i];
|
|
|
|
|
break;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
case 'b':
|
|
|
|
|
g_basedir = argv[++i];
|
|
|
|
|
break;
|
2002-07-29 09:49:44 +02:00
|
|
|
|
case 'i':
|
|
|
|
|
xmlfile = argv[++i];
|
|
|
|
|
break;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
case 't':
|
|
|
|
|
turn = atoi(argv[++i]);
|
|
|
|
|
break;
|
|
|
|
|
case 'f':
|
|
|
|
|
firstx = atoi(argv[++i]);
|
|
|
|
|
firsty = atoi(argv[++i]);
|
|
|
|
|
break;
|
|
|
|
|
case 'q':
|
|
|
|
|
quiet = 1;
|
|
|
|
|
break;
|
2001-02-05 17:11:59 +01:00
|
|
|
|
case 'v':
|
|
|
|
|
if (i<argc) orders = argv[++i];
|
|
|
|
|
else return usage(argv[0], argv[i]);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
break;
|
2002-05-05 11:34:36 +02:00
|
|
|
|
case 'p':
|
|
|
|
|
loadplane = atoi(argv[++i]);
|
|
|
|
|
break;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
case 'x':
|
|
|
|
|
maxregions = atoi(argv[++i]);
|
|
|
|
|
maxregions = (maxregions*81+80) / 81;
|
|
|
|
|
break;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
case 'X':
|
|
|
|
|
dirtyload = true;
|
|
|
|
|
break;
|
2001-02-12 23:39:57 +01:00
|
|
|
|
case 'l':
|
|
|
|
|
log_open(argv[++i]);
|
|
|
|
|
break;
|
2001-09-05 21:40:40 +02:00
|
|
|
|
case 'w':
|
|
|
|
|
g_writemap = true;
|
|
|
|
|
break;
|
2003-11-10 10:19:07 +01:00
|
|
|
|
case 'R':
|
|
|
|
|
opt_reportonly = true;
|
|
|
|
|
break;
|
2001-02-05 17:11:59 +01:00
|
|
|
|
default:
|
|
|
|
|
usage(argv[0], argv[i]);
|
|
|
|
|
}
|
2001-01-25 10:37:55 +01:00
|
|
|
|
}
|
2001-02-05 17:11:59 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
2001-02-03 14:45:35 +01:00
|
|
|
|
|
2002-01-09 09:20:33 +01:00
|
|
|
|
#ifdef BETA_CODE
|
2001-12-10 01:13:39 +01:00
|
|
|
|
extern int xml_writeitems(const char * filename);
|
2002-03-27 22:49:27 +01:00
|
|
|
|
extern int xml_writeships(void);
|
|
|
|
|
extern int xml_writebuildings(void);
|
2002-01-09 09:20:33 +01:00
|
|
|
|
#endif
|
2001-12-10 01:13:39 +01:00
|
|
|
|
|
|
|
|
|
typedef struct lostdata {
|
|
|
|
|
int x, y;
|
|
|
|
|
int prevunit;
|
|
|
|
|
int building;
|
|
|
|
|
int ship;
|
|
|
|
|
} lostdata;
|
|
|
|
|
|
2002-04-16 19:54:05 +02:00
|
|
|
|
void
|
|
|
|
|
confirm_newbies(void)
|
|
|
|
|
{
|
2002-10-28 07:41:16 +01:00
|
|
|
|
faction * f = factions;
|
2002-04-16 19:54:05 +02:00
|
|
|
|
while (f) {
|
2002-10-28 07:41:16 +01:00
|
|
|
|
if (!fval(f, FFL_DBENTRY)) {
|
2002-12-01 12:23:17 +01:00
|
|
|
|
if (f->subscription) {
|
2004-07-10 19:16:15 +02:00
|
|
|
|
sql_print(("UPDATE subscriptions SET status='ACTIVE', faction='%s', race='%s' WHERE id=%u;\n",
|
|
|
|
|
itoa36(f->no), dbrace(f->race), f->subscription));
|
2002-12-01 12:23:17 +01:00
|
|
|
|
fset(f, FFL_DBENTRY);
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-04-16 19:54:05 +02:00
|
|
|
|
f = f->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-01 12:23:17 +01:00
|
|
|
|
void
|
|
|
|
|
update_subscriptions(void)
|
|
|
|
|
{
|
|
|
|
|
FILE * F;
|
|
|
|
|
char zText[MAX_PATH];
|
|
|
|
|
faction * f;
|
|
|
|
|
strcat(strcpy(zText, basepath()), "/subscriptions");
|
|
|
|
|
F = fopen(zText, "r");
|
|
|
|
|
if (F==NULL) {
|
|
|
|
|
log_error(("could not open %s.\n", zText));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (;;) {
|
|
|
|
|
char zFaction[5];
|
|
|
|
|
int subscription, fno;
|
|
|
|
|
if (fscanf(F, "%d %s", &subscription, zFaction)<=0) break;
|
|
|
|
|
fno = atoi36(zFaction);
|
|
|
|
|
f = findfaction(fno);
|
|
|
|
|
if (f!=NULL) {
|
|
|
|
|
f->subscription=subscription;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-05 17:11:59 +01:00
|
|
|
|
int
|
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
char zText[MAX_PATH];
|
|
|
|
|
|
2002-10-13 13:08:04 +02:00
|
|
|
|
sqlpatch = true;
|
2001-02-12 23:39:57 +01:00
|
|
|
|
log_open("eressea.log");
|
2001-02-05 17:11:59 +01:00
|
|
|
|
printf("\n%s PBEM host\n"
|
|
|
|
|
"Copyright (C) 1996-2001 C.Schlittchen, K.Zedel, E.Rehling, H.Peters.\n\n"
|
|
|
|
|
"Compilation: " __DATE__ " at " __TIME__ "\nVersion: %f\n\n", global.gamename, version());
|
|
|
|
|
|
|
|
|
|
setlocale(LC_ALL, "");
|
2001-12-10 01:13:39 +01:00
|
|
|
|
setlocale(LC_NUMERIC, "C");
|
2001-02-05 17:11:59 +01:00
|
|
|
|
#ifdef LOCALE_CHECK
|
|
|
|
|
if (!locale_check()) {
|
- Neue Messages fertig
Messages werden jetzt in einem anderen Meta-Format (message* of
message_type*) gespeichert, das man in beliebige Formate (CR oder NR)
rendern kann. crmessage.c und nrmessage.c sind die render-engines dafür.
Die Messagetypen werden in res/{de,en}/messages.xml gesammelt, ultimativ
kann das aber durchaus eine einzelne Datei sein. Die ist derzeit nicht
wirklich xml (Umlaute drin, keine Definitionsdatei), aber gut lesbar.
- make_message
Diese Funktion ersetzt new_message, und ist etwas einfacher in der Syntax:
make_message("dumb_mistake", "unit region command", u, r, cmd) erzeugt
eine neue Nachricht, die dann einfach mit add_message wie bisher an die
Nachrichtenliste gehängt werden kann.
TODO: Messages könnte man durchaus reference-counten, und in mehrere Listen
einfügen, solang sie a) mehrfachverwendet (Kampf!) und b) vom Betrachter
unabhängig sind. Das spart einigen Speicher.
- CR Version erhöht.
Weil die MESSAGETYPES Blocks anders sind als früher
- OFFENSIVE_DELAY
Verbietet Einheiten, deren Partei eine Reigon niht bewachen, den
Angriff in der Region, wenn sie sich in der Runde zuvor bewegt haben.
Status der letzten Runde wird in neuem Attribut at_moved gespeichert.
- SHORT_ATTACKS
ein define, das angibt ob Kämpfen grundsätzlich keine lange Aktion ist.
- XML Parser
xml.[hc] enthält einen XML-Parser, dem man ein plugin mit callbacks
übergibt, die nach dem Parsen eines tokens aufgerufen werden.
2001-04-12 19:21:57 +02:00
|
|
|
|
log_error(("The current locale is not suitable for international Eressea.\n"));
|
2001-02-05 17:11:59 +01:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
2001-02-03 14:45:35 +01:00
|
|
|
|
#endif
|
2005-05-07 12:07:06 +02:00
|
|
|
|
#ifdef CRTDBG
|
|
|
|
|
init_crtdbg();
|
|
|
|
|
#endif
|
|
|
|
|
#ifdef DMALLOC
|
|
|
|
|
init_dmalloc();
|
2001-01-25 10:37:55 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
2001-02-05 17:11:59 +01:00
|
|
|
|
if ((i=read_args(argc, argv))!=0) return i;
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2001-02-05 17:11:59 +01:00
|
|
|
|
printf(
|
|
|
|
|
"version %d.%d\n"
|
|
|
|
|
"turn %d.\n"
|
|
|
|
|
"orders %s.\n",
|
|
|
|
|
global.data_version / 10, global.data_version % 10, turn, orders);
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2001-02-05 17:11:59 +01:00
|
|
|
|
kernel_init();
|
2003-10-05 09:29:31 +02:00
|
|
|
|
game_init();
|
2002-03-27 22:49:27 +01:00
|
|
|
|
#if defined(BETA_CODE)
|
2002-02-10 08:53:54 +01:00
|
|
|
|
/* xml_writeships(); */
|
2002-05-01 21:08:32 +02:00
|
|
|
|
/* xml_writebuildings(); */
|
|
|
|
|
xml_writeitems("items.xml");
|
2001-12-10 01:13:39 +01:00
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-12-17 11:28:23 +01:00
|
|
|
|
sprintf(zText, "%d", turn);
|
2004-06-23 00:00:36 +02:00
|
|
|
|
i = readgame(zText, false);
|
2003-12-17 11:28:23 +01:00
|
|
|
|
if (i!=0) return i;
|
2003-12-14 20:17:59 +01:00
|
|
|
|
|
|
|
|
|
confirm_newbies();
|
2002-12-01 12:23:17 +01:00
|
|
|
|
update_subscriptions();
|
|
|
|
|
{
|
|
|
|
|
char zText[128];
|
|
|
|
|
FILE * F;
|
|
|
|
|
faction * f = factions;
|
|
|
|
|
sprintf(zText, "subscriptions.%u", turn);
|
|
|
|
|
F = fopen(zText, "w");
|
|
|
|
|
while (f!=NULL) {
|
|
|
|
|
fprintf(F, "%s:%u:%s:%s:%s:%u:\n",
|
|
|
|
|
itoa36(f->no), f->subscription, f->email, f->override,
|
|
|
|
|
dbrace(f->race), f->lastorders);
|
|
|
|
|
f = f->next;
|
|
|
|
|
}
|
|
|
|
|
fclose(F);
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-20 15:00:07 +01:00
|
|
|
|
#ifdef BETA_CODE
|
2002-01-09 09:20:33 +01:00
|
|
|
|
if (dungeonstyles) {
|
|
|
|
|
struct dungeon * d = dungeonstyles;
|
|
|
|
|
struct region * r = make_dungeon(d);
|
|
|
|
|
make_dungeongate(findregion(0, 0), r, d);
|
|
|
|
|
}
|
2002-01-20 15:00:07 +01:00
|
|
|
|
#endif
|
2001-12-10 01:13:39 +01:00
|
|
|
|
writepasswd();
|
2002-03-11 22:20:31 +01:00
|
|
|
|
|
2003-11-10 10:19:07 +01:00
|
|
|
|
if (opt_reportonly) {
|
|
|
|
|
reports();
|
|
|
|
|
return 0;
|
2002-03-11 22:20:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-11-10 10:19:07 +01:00
|
|
|
|
if (g_writemap) {
|
2005-07-26 12:50:00 +02:00
|
|
|
|
return crwritemap("world.cr");
|
2003-11-10 10:19:07 +01:00
|
|
|
|
}
|
2001-01-25 10:37:55 +01:00
|
|
|
|
|
2005-06-10 00:10:35 +02:00
|
|
|
|
if (turn == 0) srand((int)time(0));
|
2004-06-23 00:00:36 +02:00
|
|
|
|
else srand(turn);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((i = processturn(orders))!=0) {
|
2003-11-10 10:19:07 +01:00
|
|
|
|
return i;
|
2002-03-11 22:20:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2001-12-10 01:13:39 +01:00
|
|
|
|
#ifdef CLEANUP_CODE
|
|
|
|
|
game_done();
|
|
|
|
|
#endif
|
2001-02-05 17:11:59 +01:00
|
|
|
|
kernel_done();
|
2001-02-12 23:39:57 +01:00
|
|
|
|
log_close();
|
2001-01-25 10:37:55 +01:00
|
|
|
|
return 0;
|
|
|
|
|
}
|