lua bindings

addplayer gesplittet
This commit is contained in:
Enno Rehling 2003-12-14 10:10:30 +00:00
parent 601f562ad4
commit 532cbd0a36
18 changed files with 394 additions and 116 deletions

View File

@ -596,18 +596,6 @@ mistake(const unit * u, const char *command, const char *comment, int mtype)
extern unsigned int new_hashstring(const char* s); extern unsigned int new_hashstring(const char* s);
static int
old_hashstring(const char* s)
{
int key = 0;
int i = strlen(s);
while (i) {
--i;
key = ((key >> 31) & 1) ^ (key << 1) ^ s[i];
}
return key & 0x7fff;
}
void void
set_msglevel(struct warning ** warnings, const char * type, int level) set_msglevel(struct warning ** warnings, const char * type, int level)
{ {

View File

@ -760,9 +760,11 @@ void
read_items(FILE *F, item **ilist) read_items(FILE *F, item **ilist)
{ {
for (;;) { for (;;) {
const item_type * itype;
rs(F, buf); rs(F, buf);
if (!strcmp("end", buf)) break; if (!strcmp("end", buf)) break;
i_change(ilist, it_find(buf), ri(F)); itype = it_find(buf);
if (itype!=NULL) i_change(ilist, itype, ri(F));
} }
} }

View File

@ -111,6 +111,7 @@ read_gmcreate(attrib * a, FILE * F)
*p_itype = it_find(zText); *p_itype = it_find(zText);
if (a->data.v==NULL) { if (a->data.v==NULL) {
log_error(("unknown itemtype %s in gmcreate attribute\n", zText)); log_error(("unknown itemtype %s in gmcreate attribute\n", zText));
return AT_READ_FAIL;
} }
return AT_READ_OK; return AT_READ_OK;
} }

View File

@ -24,7 +24,7 @@
AdditionalIncludeDirectories="../kernel,../util,../..,.." AdditionalIncludeDirectories="../kernel,../util,../..,.."
PreprocessorDefinitions="_WINDOWS,WIN32" PreprocessorDefinitions="_WINDOWS,WIN32"
BasicRuntimeChecks="0" BasicRuntimeChecks="0"
RuntimeLibrary="5" RuntimeLibrary="3"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
PrecompiledHeaderThrough="stdafx.h" PrecompiledHeaderThrough="stdafx.h"
@ -76,7 +76,7 @@
AdditionalIncludeDirectories="../kernel,../util,../..,.." AdditionalIncludeDirectories="../kernel,../util,../..,.."
PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS" PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="4" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
@ -123,21 +123,12 @@
<File <File
RelativePath=".\alliance.h"> RelativePath=".\alliance.h">
</File> </File>
<File
RelativePath=".\arena.h">
</File>
<File
RelativePath=".\dungeon.h">
</File>
<File <File
RelativePath=".\gmcmd.h"> RelativePath=".\gmcmd.h">
</File> </File>
<File <File
RelativePath=".\infocmd.h"> RelativePath=".\infocmd.h">
</File> </File>
<File
RelativePath=".\museum.h">
</File>
<File <File
RelativePath=".\score.h"> RelativePath=".\score.h">
</File> </File>
@ -154,21 +145,12 @@
<File <File
RelativePath=".\alliance.c"> RelativePath=".\alliance.c">
</File> </File>
<File
RelativePath=".\arena.c">
</File>
<File
RelativePath=".\dungeon.c">
</File>
<File <File
RelativePath=".\gmcmd.c"> RelativePath=".\gmcmd.c">
</File> </File>
<File <File
RelativePath=".\infocmd.c"> RelativePath=".\infocmd.c">
</File> </File>
<File
RelativePath=".\museum.c">
</File>
<File <File
RelativePath=".\score.c"> RelativePath=".\score.c">
</File> </File>

View File

@ -19,7 +19,7 @@ extern "C" {
#endif #endif
#ifndef MUSEUM_MODULE #ifndef MUSEUM_MODULE
#warning "must define MUSEUM_MODULE to use this module" #error "must define MUSEUM_MODULE to use this module"
#endif #endif
extern attrib_type at_warden; extern attrib_type at_warden;

View File

@ -25,9 +25,10 @@
#include <region.h> #include <region.h>
#include <ship.h> #include <ship.h>
/* libc includes */
#include <base36.h> #include <base36.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
attrib_type at_xontormiaexpress = { attrib_type at_xontormiaexpress = {
"xontormiaexpress", "xontormiaexpress",

View File

@ -24,7 +24,7 @@
AdditionalIncludeDirectories="../kernel,../util,../..,.." AdditionalIncludeDirectories="../kernel,../util,../..,.."
PreprocessorDefinitions="_WINDOWS,WIN32" PreprocessorDefinitions="_WINDOWS,WIN32"
BasicRuntimeChecks="0" BasicRuntimeChecks="0"
RuntimeLibrary="5" RuntimeLibrary="3"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
PrecompiledHeaderThrough="stdafx.h" PrecompiledHeaderThrough="stdafx.h"
@ -76,7 +76,7 @@
AdditionalIncludeDirectories="../kernel,../util,../..,.." AdditionalIncludeDirectories="../kernel,../util,../..,.."
PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS" PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="4" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"

View File

@ -24,7 +24,7 @@
AdditionalIncludeDirectories="../kernel,../util,../..,.." AdditionalIncludeDirectories="../kernel,../util,../..,.."
PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS" PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="4" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
@ -75,7 +75,7 @@
AdditionalIncludeDirectories="../kernel,../util,../..,.." AdditionalIncludeDirectories="../kernel,../util,../..,.."
PreprocessorDefinitions="_WINDOWS,WIN32,_DEBUG" PreprocessorDefinitions="_WINDOWS,WIN32,_DEBUG"
BasicRuntimeChecks="0" BasicRuntimeChecks="0"
RuntimeLibrary="5" RuntimeLibrary="3"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
PrecompiledHeaderThrough="stdafx.h" PrecompiledHeaderThrough="stdafx.h"

View File

@ -24,7 +24,7 @@
AdditionalIncludeDirectories="../util,../kernel,../..,.." AdditionalIncludeDirectories="../util,../kernel,../..,.."
PreprocessorDefinitions="_WINDOWS,WIN32,_DEBUG" PreprocessorDefinitions="_WINDOWS,WIN32,_DEBUG"
BasicRuntimeChecks="0" BasicRuntimeChecks="0"
RuntimeLibrary="5" RuntimeLibrary="3"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
PrecompiledHeaderThrough="stdafx.h" PrecompiledHeaderThrough="stdafx.h"
@ -76,7 +76,7 @@
AdditionalIncludeDirectories="../util,../kernel,../..,.." AdditionalIncludeDirectories="../util,../kernel,../..,.."
PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS" PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="4" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"

View File

@ -27,6 +27,7 @@
/* ansi includes */ /* ansi includes */
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>

View File

@ -24,7 +24,7 @@
AdditionalIncludeDirectories="../.." AdditionalIncludeDirectories="../.."
PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS" PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="4" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
@ -128,7 +128,7 @@
AdditionalIncludeDirectories="../..,.." AdditionalIncludeDirectories="../..,.."
PreprocessorDefinitions="_WINDOWS,WIN32,_DEBUG" PreprocessorDefinitions="_WINDOWS,WIN32,_DEBUG"
BasicRuntimeChecks="0" BasicRuntimeChecks="0"
RuntimeLibrary="5" RuntimeLibrary="3"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
PrecompiledHeaderThrough="stdafx.h" PrecompiledHeaderThrough="stdafx.h"

View File

@ -7,11 +7,33 @@ SubDirHdrs $(SUBDIR)/../common/util ;
SubDirHdrs $(SUBDIR)/../common ; SubDirHdrs $(SUBDIR)/../common ;
SubDirHdrs $(SUBDIR)/.. ; SubDirHdrs $(SUBDIR)/.. ;
SOURCES = if $(HAVE_LUA) {
korrektur.c SubDirC++Flags -DHAVE_LUA ;
main.c UsingLua ;
UsingLuabind ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) lua ] ;
}
if $(HAVE_LUA) {
SOURCES =
<lua>alliance.cpp
<lua>building.cpp
<lua>eressea.cpp
<lua>faction.cpp
<lua>region.cpp
<lua>ship.cpp
<lua>unit.cpp
main.cpp
; ;
LINKLIBS on eressea += -llua50 -llualib50 ;
LINKLIBS on eressea += -lluabind ;
} else {
SOURCES = main.c ;
}
SOURCES += korrektur.c ;
Main eressea : $(SOURCES) ; Main eressea : $(SOURCES) ;
LinkLibraries eressea : LinkLibraries eressea :
kernel kernel

View File

@ -25,7 +25,7 @@
AdditionalIncludeDirectories="../common/kernel,../common/gamecode,../common/util,../common,.." AdditionalIncludeDirectories="../common/kernel,../common/gamecode,../common/util,../common,.."
PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE" PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="4" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
@ -42,6 +42,7 @@
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386" AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="luabind.lib lua50.lib lualib50.lib"
OutputFile=".\Release/eressea.exe" OutputFile=".\Release/eressea.exe"
LinkIncremental="1" LinkIncremental="1"
SuppressStartupBanner="TRUE" SuppressStartupBanner="TRUE"
@ -148,8 +149,8 @@
AdditionalIncludeDirectories="../common/kernel,../common/gamecode,../common/util,../common,.." AdditionalIncludeDirectories="../common/kernel,../common/gamecode,../common/util,../common,.."
PreprocessorDefinitions="_CONSOLE,WIN32" PreprocessorDefinitions="_CONSOLE,WIN32"
BasicRuntimeChecks="0" BasicRuntimeChecks="0"
RuntimeLibrary="5" RuntimeLibrary="3"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="FALSE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
PrecompiledHeaderThrough="stdafx.h" PrecompiledHeaderThrough="stdafx.h"
PrecompiledHeaderFile=".\Debug/eressea.pch" PrecompiledHeaderFile=".\Debug/eressea.pch"
@ -165,6 +166,7 @@
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386" AdditionalOptions="/MACHINE:I386"
AdditionalDependencies="luabindd.lib lua50d.lib lualib50d.lib"
OutputFile=".\Debug/eressea.exe" OutputFile=".\Debug/eressea.exe"
LinkIncremental="2" LinkIncremental="2"
SuppressStartupBanner="TRUE" SuppressStartupBanner="TRUE"
@ -212,14 +214,159 @@
RelativePath="..\todo.txt"> RelativePath="..\todo.txt">
</File> </File>
</Filter> </Filter>
<Filter
Name="bindings"
Filter="">
<File
RelativePath=".\lua\alliance.cpp">
</File>
<File
RelativePath=".\lua\bindings.h">
</File>
<File
RelativePath=".\lua\building.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Profile|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
</File>
<File
RelativePath=".\lua\eressea.cpp">
</File>
<File
RelativePath=".\lua\faction.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Profile|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
</File>
<File
RelativePath=".\lua\list.h">
</File>
<File
RelativePath=".\lua\region.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Profile|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
</File>
<File
RelativePath=".\lua\ship.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Profile|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
</File>
<File
RelativePath=".\lua\unit.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Profile|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
</File>
</Filter>
<File <File
RelativePath=".\korrektur.c"> RelativePath=".\korrektur.c">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Profile|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="TRUE"/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath=".\korrektur.h"> RelativePath=".\korrektur.h">
</File> </File>
<File <File
RelativePath=".\main.c"> RelativePath=".\main.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
DisableLanguageExtensions="FALSE"/>
</FileConfiguration>
</File> </File>
<File <File
RelativePath="..\common\settings-eressea.h"> RelativePath="..\common\settings-eressea.h">

View File

@ -9,6 +9,14 @@
* prior permission by the authors of Eressea. * prior permission by the authors of Eressea.
**/ **/
extern void korrektur(void); #ifdef __cplusplus
extern void korrektur_end(void); extern "C" {
extern void init_conversion(void); #endif
extern void korrektur(void);
extern void korrektur_end(void);
extern void init_conversion(void);
#ifdef __cplusplus
}
#endif

View File

@ -1,7 +1,7 @@
/* vi: set ts=2: /* vi: set ts=2:
* *
* *
* Eressea PB(E)M host Copyright (C) 1998-2000 * Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
* Henning Peters (faroul@beyond.kn-bremen.de) * Henning Peters (faroul@beyond.kn-bremen.de)
@ -24,23 +24,31 @@
#undef LOCALE_CHECK #undef LOCALE_CHECK
#endif #endif
/* config includes */
#include <config.h> #include <config.h>
#include <eressea.h> #include <eressea.h>
#include "korrektur.h" #include "korrektur.h"
/* initialization - TODO: init in separate module */ /* initialization - TODO: init in separate module */
#include <races/races.h>
#include <attributes/attributes.h> #include <attributes/attributes.h>
#include <spells/spells.h>
#include <triggers/triggers.h> #include <triggers/triggers.h>
#include <items/items.h> #include <items/items.h>
/* modules includes */ /* modules includes */
#ifdef DUNGEON_MODULE
#include <modules/dungeon.h> #include <modules/dungeon.h>
#endif
#include <modules/score.h> #include <modules/score.h>
#include <modules/xmas.h>
#include <modules/gmcmd.h> #include <modules/gmcmd.h>
#ifdef INFOCMD_MODULE #include <modules/infocmd.h>
# include <modules/infocmd.h> #ifdef MUSEUM_MODULE
#include <modules/museum.h>
#endif
#ifdef ARENA_MODULE
#include <modules/arena.h>
#endif #endif
/* gamecode includes */ /* gamecode includes */
@ -49,14 +57,13 @@
#include <laws.h> #include <laws.h>
/* kernel includes */ /* kernel includes */
#include <alchemy.h>
#include <building.h> #include <building.h>
#include <creport.h>
#include <faction.h> #include <faction.h>
#include <message.h> #include <message.h>
#include <plane.h> #include <plane.h>
#include <race.h> #include <race.h>
#include <skill.h> #include <skill.h>
#include <technology.h>
#include <teleport.h> #include <teleport.h>
#include <unit.h> #include <unit.h>
#include <region.h> #include <region.h>
@ -70,11 +77,12 @@
/* util includes */ /* util includes */
#include <rand.h> #include <rand.h>
#include <log.h>
#include <sql.h> #include <sql.h>
#include <base36.h> #include <base36.h>
#ifdef HAVE_LUA
/* lua includes */ /* lua includes */
#ifdef HAVE_LUA
#include "lua/bindings.h" #include "lua/bindings.h"
#include <lua.hpp> #include <lua.hpp>
#include <luabind/luabind.hpp> #include <luabind/luabind.hpp>
@ -88,18 +96,14 @@
#include <ctime> #include <ctime>
#include <clocale> #include <clocale>
/** /**
** global variables we are importing from other modules ** global variables we are importing from other modules
**/ **/
extern "C" { extern "C" {
#ifdef BETA_CODE extern char * g_reportdir;
extern int xml_writeitems(const char * filename); extern char * g_datadir;
extern int xml_writeships(void); extern char * g_basedir;
extern int xml_writebuildings(void); extern char * g_resourcedir;
#endif
extern item_type * i_silver; extern item_type * i_silver;
extern boolean nonr; extern boolean nonr;
@ -108,26 +112,33 @@ extern boolean noreports;
extern boolean nomer; extern boolean nomer;
extern boolean nomsg; extern boolean nomsg;
extern boolean nobattle; extern boolean nobattle;
extern boolean nomonsters;
extern boolean nobattledebug; extern boolean nobattledebug;
extern boolean dirtyload; extern boolean dirtyload;
extern int demonfix;
extern int loadplane; extern int loadplane;
extern void debug_messagetypes(FILE * out); extern void debug_messagetypes(FILE * out);
extern void free_region(region * r); extern void free_region(region * r);
extern void render_init(void); extern void render_init(void);
extern void free_borders(void); extern void free_borders(void);
extern boolean opt_cr_absolute_coords;
#ifdef FUZZY_BASE36
extern int fuzzy_hits;
#endif /* FUZZY_BASE36 */
} }
/** /**
** global variables wthat we are exporting ** global variables that we are exporting
**/ **/
static char * orders = NULL; static char * orders = NULL;
static char * xmlfile = NULL; static char * xmlfile = NULL;
static int nowrite = 0; static int nowrite = 0;
static boolean g_writemap = false; static boolean g_writemap = false;
static boolean g_killeiswald = false; static boolean g_killeiswald = false;
static boolean opt_reportonly = false;
struct settings global = { struct settings global = {
"Eressea", /* gamename */ "Eressea", /* gamename */
@ -143,7 +154,7 @@ crwritemap(void)
for (r=regions;r;r=r->next) { for (r=regions;r;r=r->next) {
plane * p = rplane(r); plane * p = rplane(r);
fprintf(F, "REGION %d %d %d\n", r->x, r->y, p?p->id:0); fprintf(F, "REGION %d %d %d\n", r->x, r->y, p?p->id:0);
fprintf(F, "\"%s\";Name\n\"%s\";Terrain\n", rname(r, default_locale), LOC(default_locale, rterrain(r)->name)); fprintf(F, "\"%s\";Name\n\"%s\";Terrain\n", rname(r, default_locale), LOC(default_locale, terrain[rterrain(r)].name));
} }
fclose(F); fclose(F);
return 0; return 0;
@ -153,31 +164,19 @@ static void
game_init(void) game_init(void)
{ {
init_triggers(); init_triggers();
init_xmas();
report_init(); report_init();
creport_init(); creport_init();
debug_language("locales.log"); debug_language("locales.log");
register_skills();
register_raceclass();
register_races(); register_races();
register_resources(); register_resources();
register_terrains();
register_buildings(); register_buildings();
register_ships(); register_ships();
register_items(); register_items();
#ifdef MAGIC
register_spells(); register_spells();
#endif #ifdef DUNGEON_MODULE
register_dungeon(); register_dungeon();
register_technology();
register_alchemy();
#ifdef MUSEUM_MODULE
register_museum();
#endif
#ifdef ARENA_MODULE
register_arena();
#endif #endif
init_data(xmlfile?xmlfile:"eressea.xml"); init_data(xmlfile?xmlfile:"eressea.xml");
@ -187,14 +186,20 @@ game_init(void)
init_resources(); init_resources();
init_items(); init_items();
init_economy(); init_economy();
#if NEW_RESOURCEGROWTH
init_rawmaterials(); init_rawmaterials();
#endif
init_gmcmd(); init_gmcmd();
#ifdef INFOCMD_MODULE
init_info(); init_info();
#endif
init_conversion(); init_conversion();
#ifdef MUSEUM_MODULE
register_museum();
#endif
#ifdef ARENA_MODULE
register_arena();
#endif
#ifdef REMOVE_THIS #ifdef REMOVE_THIS
render_init(); render_init();
{ {
@ -278,6 +283,37 @@ writepasswd(void)
} }
} }
#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));
pwd->email = strdup(email);
pwd->pwd = strdup(passwd);
pwd->used = false;
pwd->next = f->shortpwds;
f->shortpwds = pwd;
}
}
fclose(F);
}
}
#endif
#ifdef HAVE_LUA #ifdef HAVE_LUA
lua_State * luaState; lua_State * luaState;
@ -287,7 +323,10 @@ lua_init(void)
luaState = lua_open(); luaState = lua_open();
luaopen_base(luaState); luaopen_base(luaState);
luabind::open(luaState); luabind::open(luaState);
bind_eressea(luaState);
bind_alliance(luaState);
bind_region(luaState); bind_region(luaState);
bind_faction(luaState);
bind_unit(luaState); bind_unit(luaState);
bind_ship(luaState); bind_ship(luaState);
bind_building(luaState); bind_building(luaState);
@ -306,6 +345,9 @@ processturn(char *filename)
struct summary * begin, * end; struct summary * begin, * end;
int i; int i;
#ifdef SHORTPWDS
readshortpwds("passwords");
#endif
begin = make_summary(false); begin = make_summary(false);
printf(" - Korrekturen Runde %d\n", turn); printf(" - Korrekturen Runde %d\n", turn);
korrektur(); korrektur();
@ -336,6 +378,11 @@ processturn(char *filename)
free(end); free(end);
free(begin); free(begin);
writepasswd(); writepasswd();
#ifdef FUZZY_BASE36
fputs("==--------------------------==\n", stdout);
fprintf(stdout, "## fuzzy base10 hits: %5d ##\n", fuzzy_hits);
fputs("==--------------------------==\n", stdout);
#endif /* FUZZY_BASE36 */
if (!nowrite) { if (!nowrite) {
char ztext[64]; char ztext[64];
sprintf(ztext, "%s/%d", datapath(), turn); sprintf(ztext, "%s/%d", datapath(), turn);
@ -410,13 +457,17 @@ game_done(void)
} }
#endif #endif
#if MALLOCDBG #include "magic.h"
static void
#ifdef MALLOCDBG
void
init_malloc_debug(void) init_malloc_debug(void)
{ {
#if (defined(_MSC_VER)) #if (defined(_MSC_VER))
# if MALLOCDBG == 2 # if MALLOCDBG == 2
# define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF) # define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF)
# elif MALLOCDBG == 3
# define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & 0)
# elif MALLOCDBG == 1 # elif MALLOCDBG == 1
# define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_DELAY_FREE_MEM_DF) # define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_DELAY_FREE_MEM_DF)
# endif # endif
@ -437,7 +488,7 @@ write_stats(void)
for (i=0;spelldaten[i].id;++i) { for (i=0;spelldaten[i].id;++i) {
if (spelldaten[i].magietyp!=m) { if (spelldaten[i].magietyp!=m) {
m=spelldaten[i].magietyp; m=spelldaten[i].magietyp;
fprintf(F, "\n%s\n", magic_schools[m]); fprintf(F, "\n%s\n", magietypen[m]);
} }
fprintf(F, "%d\t%s\n", spelldaten[i].level, spelldaten[i].name); fprintf(F, "%d\t%s\n", spelldaten[i].level, spelldaten[i].name);
} }
@ -490,13 +541,16 @@ usage(const char * prog, const char * arg)
"-t turn : read this datafile, not the most current one\n" "-t turn : read this datafile, not the most current one\n"
"-o reportdir : gibt das reportverzeichnis an\n" "-o reportdir : gibt das reportverzeichnis an\n"
"-l logfile : specify an alternative logfile\n" "-l logfile : specify an alternative logfile\n"
"-R : erstellt nur die Reports neu\n"
"--noeiswald : beruhigt ungemein\n" "--noeiswald : beruhigt ungemein\n"
"--nomsg : keine Messages (RAM sparen)\n" "--nomsg : keine Messages (RAM sparen)\n"
"--nobattle : keine Kämpfe\n" "--nobattle : keine Kämpfe\n"
"--nomonsters : keine monster KI\n"
"--nodebug : keine Logfiles für Kämpfe\n" "--nodebug : keine Logfiles für Kämpfe\n"
"--debug : schreibt Debug-Ausgaben in die Datei debug\n" "--debug : schreibt Debug-Ausgaben in die Datei debug\n"
"--nocr : keine CRs\n" "--nocr : keine CRs\n"
"--nonr : keine Reports\n" "--nonr : keine Reports\n"
"--crabsolute : absolute Koordinaten im CR\n"
#ifdef USE_MERIAN #ifdef USE_MERIAN
"--nomer : keine Meriankarten\n" "--nomer : keine Meriankarten\n"
#endif #endif
@ -525,7 +579,9 @@ read_args(int argc, char **argv)
else if (strcmp(argv[i]+2, "nomsg")==0) nomsg = true; else if (strcmp(argv[i]+2, "nomsg")==0) nomsg = true;
else if (strcmp(argv[i]+2, "noeiswald")==0) g_killeiswald = true; else if (strcmp(argv[i]+2, "noeiswald")==0) g_killeiswald = true;
else if (strcmp(argv[i]+2, "nobattle")==0) nobattle = true; else if (strcmp(argv[i]+2, "nobattle")==0) nobattle = true;
else if (strcmp(argv[i]+2, "nomonsters")==0) nomonsters = true;
else if (strcmp(argv[i]+2, "nodebug")==0) nobattledebug = true; else if (strcmp(argv[i]+2, "nodebug")==0) nobattledebug = true;
else if (strcmp(argv[i]+2, "crabsolute")==0) opt_cr_absolute_coords = true;
#ifdef USE_MERIAN #ifdef USE_MERIAN
else if (strcmp(argv[i]+2, "nomer")==0) nomer = true; else if (strcmp(argv[i]+2, "nomer")==0) nomer = true;
#endif #endif
@ -537,6 +593,9 @@ read_args(int argc, char **argv)
case 'o': case 'o':
g_reportdir = argv[++i]; g_reportdir = argv[++i];
break; break;
case 'D': /* DEBUG */
demonfix = atoi(argv[++i]);
break;
case 'd': case 'd':
g_datadir = argv[++i]; g_datadir = argv[++i];
break; break;
@ -546,6 +605,9 @@ read_args(int argc, char **argv)
case 'b': case 'b':
g_basedir = argv[++i]; g_basedir = argv[++i];
break; break;
case 'i':
xmlfile = argv[++i];
break;
case 't': case 't':
turn = atoi(argv[++i]); turn = atoi(argv[++i]);
break; break;
@ -576,6 +638,9 @@ read_args(int argc, char **argv)
case 'w': case 'w':
g_writemap = true; g_writemap = true;
break; break;
case 'R':
opt_reportonly = true;
break;
default: default:
usage(argv[0], argv[i]); usage(argv[0], argv[i]);
} }
@ -583,6 +648,12 @@ read_args(int argc, char **argv)
return 0; return 0;
} }
#ifdef BETA_CODE
extern int xml_writeitems(const char * filename);
extern int xml_writeships(void);
extern int xml_writebuildings(void);
#endif
typedef struct lostdata { typedef struct lostdata {
int x, y; int x, y;
int prevunit; int prevunit;
@ -590,24 +661,53 @@ typedef struct lostdata {
int ship; int ship;
} lostdata; } lostdata;
static void void
confirm_newbies(void) confirm_newbies(void)
{ {
const faction * f = factions; faction * f = factions;
if (sqlstream) while (f) { if (sqlstream==NULL) return;
if (f->age==0) { while (f) {
fprintf(sqlstream, "UPDATE subscriptions SET status='ACTIVE', faction='%s' WHERE game=%d AND password='%s';\n", itoa36(f->no), GAME_ID, f->passw); if (!fval(f, FFL_DBENTRY)) {
if (f->subscription) {
fprintf(sqlstream, "UPDATE subscriptions SET status='ACTIVE', faction='%s', race='%s' WHERE id=%u;\n", itoa36(f->no), dbrace(f->race), f->subscription);
fset(f, FFL_DBENTRY);
}
} }
f = f->next; f = f->next;
} }
} }
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;
}
}
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int i; int i;
char zText[MAX_PATH]; char zText[MAX_PATH];
sqlpatch = true;
updatelog = fopen("update.log", "w"); updatelog = fopen("update.log", "w");
log_open("eressea.log"); log_open("eressea.log");
printf("\n%s PBEM host\n" printf("\n%s PBEM host\n"
@ -622,7 +722,7 @@ main(int argc, char *argv[])
return -1; return -1;
} }
#endif #endif
#if MALLOCDBG #ifdef MALLOCDBG
init_malloc_debug(); init_malloc_debug();
#endif #endif
@ -642,16 +742,32 @@ main(int argc, char *argv[])
lua_init(); lua_init();
#endif #endif
game_init(); game_init();
#ifdef BETA_CODE #if defined(BETA_CODE)
/* xml_writeships(); */ /* xml_writeships(); */
/* xml_writebuildings(); */ /* xml_writebuildings(); */
/* xml_writeitems("items.xml"); */ xml_writeitems("items.xml");
return 0; return 0;
#endif #endif
if ((i=readgame(false))!=0) return i; if ((i=readgame(false))!=0) return i;
confirm_newbies(); confirm_newbies();
#ifdef BETA_CODE 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);
}
#ifdef DUNGEON_MODULE
if (dungeonstyles) { if (dungeonstyles) {
struct dungeon * d = dungeonstyles; struct dungeon * d = dungeonstyles;
struct region * r = make_dungeon(d); struct region * r = make_dungeon(d);
@ -668,9 +784,19 @@ main(int argc, char *argv[])
for (u=r->units;u;u=u->next) scale_number(u, 1); for (u=r->units;u;u=u->next) scale_number(u, 1);
} }
} }
if (g_writemap) return crwritemap();
if ((i=processturn(orders))!=0) return i; if (opt_reportonly) {
reports();
return 0;
}
if (g_writemap) {
return crwritemap();
}
if ((i=processturn(orders))!=0) {
return i;
}
#ifdef CLEANUP_CODE #ifdef CLEANUP_CODE
game_done(); game_done();

View File

@ -257,8 +257,8 @@ autoseed(struct regionlist * rlist)
newfaction ** nfp = &newfactions; newfaction ** nfp = &newfactions;
unit * u; unit * u;
while (*nfp!=nf) nfp=&(*nfp)->next; while (*nfp!=nf) nfp=&(*nfp)->next;
u = addplayer(seeds[i].region, nf->email, nf->password, nf->race, u = addplayer(seeds[i].region, addfaction(nf->email, nf->password, nf->race,
nf->lang, nf->subscription); nf->lang, nf->subscription));
#ifdef ALLIANCES #ifdef ALLIANCES
u->faction->alliance = nf->allies; u->faction->alliance = nf->allies;
#endif #endif
@ -358,8 +358,8 @@ mkisland(int nsize)
unit * u; unit * u;
terraform(r, preferred_terrain(nextf->race)); terraform(r, preferred_terrain(nextf->race));
++isize; ++isize;
u = addplayer(r, nextf->email, nextf->password, nextf->race, nextf->lang, u = addplayer(r, addfaction(nextf->email, nextf->password, nextf->race, nextf->lang,
nextf->subscription); nextf->subscription));
#ifdef ALLIANCES #ifdef ALLIANCES
u->faction->alliance = nextf->allies; u->faction->alliance = nextf->allies;
#endif #endif

View File

@ -289,8 +289,8 @@ seed_dropouts(void)
if (u==NULL) while (*nfp) { if (u==NULL) while (*nfp) {
newfaction * nf = *nfp; newfaction * nf = *nfp;
if (nf->race==drop->race && !nf->bonus) { if (nf->race==drop->race && !nf->bonus) {
unit * u = addplayer(r, nf->email, nf->password, nf->race, nf->lang, unit * u = addplayer(r, addfaction(nf->email, nf->password, nf->race, nf->lang,
nf->subscription); nf->subscription));
#ifdef ALLIANCES #ifdef ALLIANCES
u->faction->alliance = nf->allies; u->faction->alliance = nf->allies;
#endif #endif
@ -519,7 +519,7 @@ NeuePartei(region * r)
else nfp = &nf->next; else nfp = &nf->next;
} }
modified = 1; modified = 1;
u = addplayer(r, email, passwd, frace, lang, subscription); u = addplayer(r, addfaction(email, passwd, frace, lang, subscription));
++numnewbies; ++numnewbies;
if(late) give_latestart_bonus(r, u, late); if(late) give_latestart_bonus(r, u, late);

View File

@ -25,7 +25,7 @@
AdditionalIncludeDirectories="../common/kernel,../common/gamecode,../common/util,../common,.." AdditionalIncludeDirectories="../common/kernel,../common/gamecode,../common/util,../common,.."
PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE" PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="4" RuntimeLibrary="2"
EnableFunctionLevelLinking="TRUE" EnableFunctionLevelLinking="TRUE"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
@ -86,7 +86,7 @@
AdditionalIncludeDirectories="$(CURSES_ROOT)/include;../common/kernel,../common/gamecode,../common/util,../common,.." AdditionalIncludeDirectories="$(CURSES_ROOT)/include;../common/kernel,../common/gamecode,../common/util,../common,.."
PreprocessorDefinitions="_CONSOLE,WIN32" PreprocessorDefinitions="_CONSOLE,WIN32"
BasicRuntimeChecks="0" BasicRuntimeChecks="0"
RuntimeLibrary="5" RuntimeLibrary="3"
DisableLanguageExtensions="TRUE" DisableLanguageExtensions="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
PrecompiledHeaderThrough="stdafx.h" PrecompiledHeaderThrough="stdafx.h"