diff --git a/src/config.h b/src/common/config.h
similarity index 100%
rename from src/config.h
rename to src/common/config.h
diff --git a/src/common/gamecode.vcproj b/src/common/gamecode.vcproj
new file mode 100644
index 000000000..51002c8e4
--- /dev/null
+++ b/src/common/gamecode.vcproj
@@ -0,0 +1,394 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/common/kernel.vcproj b/src/common/kernel.vcproj
new file mode 100644
index 000000000..4321eea91
--- /dev/null
+++ b/src/common/kernel.vcproj
@@ -0,0 +1,1098 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/common/modules/victoryconditions.c b/src/common/modules/victoryconditions.c
deleted file mode 100644
index a6b91a582..000000000
--- a/src/common/modules/victoryconditions.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* vi: set ts=2:
- *
- * Eressea PB(E)M host Copyright (C) 1998-2003
- * 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)
- *
- * This program may not be used, modified or distributed without
- * prior permission by the authors of Eressea.
- */
-
-#include
-#include
-#include "victoryconditions.h"
-
-/* kernel includes */
-#include
-#include
-
-/* util includes */
-#include
-
-/* libc includes */
-#include
-#include
-
-#if VICTORY_CONDITION == VICTORY_MURDER
-
-static void
-print_winners_murder(const int winners)
-{
- faction *f;
- char winner_buf[DISPLAYSIZE+1];
- message *msg;
- boolean first;
-
- winner_buf[0] = 0;
-
- first = true;
- for(f=factions; f; f=f->next) {
- if(f->no != 0 && f->victory_delay == VICTORY_DELAY) {
- if(first == true) {
- /* potential buffer overflow here */
- strcat(winner_buf, factionid(f));
- first = false;
- } else {
- /* potential buffer overflow here */
- strcat(winner_buf, ", ");
- strcat(winner_buf, factionid(f));
- }
- }
- }
-
- msg = msg_message("victory_murder_complete",
- "winners n", strdup(winner_buf), winners);
-
- for(f=factions; f; f=f->next) {
- add_message(&f->messages, msg);
- }
- msg_release(msg);
-}
-
-static boolean
-is_winner_murder(const faction *f)
-{
-}
-
-static void
-check_victory_murder(void)
-{
- faction *f;
- int condfulfilled = 0;
- int winners = 0;
-
- for(f=factions; f; f=f->next) {
- if(f->no != 0 && is_winner_murder(f)) {
- f->victory_delay++;
- condfulfilled++;
- if(f->victory_delay == VICTORY_DELAY)
- winners++;
- } else {
- f->victory_delay = 0;
- }
- }
-
- if(winners > 0) {
- print_winners_murder();
- return true;
- } else if(condfulfilled > 0) {
- for(f=factions; f; f=f->next) {
- if(f->victory_delay > 0) {
- faction *f2;
- message *msg = msg_message("victory_murder_cfulfilled",
- "faction remain", f, VICTORY_DELAY - f->victory_delay);
- for(f2=factions; f2; f2=f2->next) {
- add_message(&f2->messages, msg);
- }
- msg_release(msg);
- }
- }
- }
- return false;
-}
-#endif
-
-void
-check_victory(void)
-{
-#if VICTORY_CONDITION == VICTORY_MURDER
- check_victory_murder();
-#endif
-}
-
diff --git a/src/common/modules/victoryconditions.h b/src/common/modules/victoryconditions.h
deleted file mode 100644
index 86feb6b2a..000000000
--- a/src/common/modules/victoryconditions.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* vi: set ts=2:
- *
- * Eressea PB(E)M host Copyright (C) 1998-2003
- * 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)
- *
- * This program may not be used, modified or distributed without
- * prior permission by the authors of Eressea.
- */
-
-#ifndef H_MOD_VICTORY
-#define H_MOD_VICTORY
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern void check_victory(void);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
diff --git a/src/common/races/races.c b/src/common/races/races.c
index fefd83125..769ac6496 100644
--- a/src/common/races/races.c
+++ b/src/common/races/races.c
@@ -2,13 +2,13 @@
* +-------------------+ Christian Schlittchen
* | | Enno Rehling
* | Eressea PBEM host | Katja Zedel
- * | (c) 1998 - 2007 |
+ * | (c) 1998 - 2007 |
* | | This program may not be used, modified or distributed
* +-------------------+ without prior permission by the authors of Eressea.
- *
+ *
*/
-#include "../../config.h"
+#include
#include
#include "races.h"
diff --git a/src/common/spells/alp.h b/src/common/spells/alp.h
index cc75c3936..4ffd7604e 100644
--- a/src/common/spells/alp.h
+++ b/src/common/spells/alp.h
@@ -1,6 +1,6 @@
/* vi: set ts=2:
*
- *
+ *
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@@ -19,6 +19,8 @@ extern "C" {
#endif
struct castorder;
+struct region;
+struct unit;
/* ------------------------------------------------------------- */
/* Name: Alp
* Stufe: 15
@@ -44,8 +46,8 @@ extern void register_alp(void);
struct unit* alp_target(struct unit *alp);
void alp_findet_opfer(struct unit *alp, struct region *r);
-
-
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/common/spells/spells.h b/src/common/spells/spells.h
index 19c0ec60b..8939a6032 100644
--- a/src/common/spells/spells.h
+++ b/src/common/spells/spells.h
@@ -1,6 +1,6 @@
/* vi: set ts=2:
*
- *
+ *
* Eressea PB(E)M host Copyright (C) 1998-2003
* Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de)
@@ -18,6 +18,10 @@
extern "C" {
#endif
+ struct ship;
+ struct curse;
+ struct unit;
+
extern void register_spells(void);
extern struct curse * shipcurse_flyingship(struct ship* sh, struct unit * mage, double power, int duration);
diff --git a/src/common/util.vcproj b/src/common/util.vcproj
new file mode 100644
index 000000000..7f93d8fdb
--- /dev/null
+++ b/src/common/util.vcproj
@@ -0,0 +1,470 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/common/util/xml.c b/src/common/util/xml.c
index 930277b55..3bdd80e1a 100644
--- a/src/common/util/xml.c
+++ b/src/common/util/xml.c
@@ -6,7 +6,7 @@
| | Ingo Wilken
+-------------------+ Stefan Reich
- This program may not be used, modified or distributed
+ This program may not be used, modified or distributed
without prior permission by the authors of Eressea.
*/
#include
@@ -15,6 +15,8 @@
/* util includes */
#include "log.h"
+#include
+
/* libc includes */
#include
#include
diff --git a/src/eressea.sln b/src/eressea.sln
new file mode 100644
index 000000000..389c29e6c
--- /dev/null
+++ b/src/eressea.sln
@@ -0,0 +1,79 @@
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "common/util.vcproj", "{F70CFB27-8A2F-E447-B452-4E1C590EDA6D}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kernel", "common/kernel.vcproj", "{6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gamecode", "common/gamecode.vcproj", "{1E8BFF9E-3044-0742-992F-C5765B80FE65}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bindings", "eressea/lua/bindings.vcproj", "{74B1CBD4-3B6E-E544-9475-33FBB0BCE165}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "editor", "eressea/editor.vcproj", "{D893D6B3-805D-9848-8EA4-CDA1B79151F6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eressea-lua", "eressea/eressea-lua.vcproj", "{75501170-51C2-E641-BA8B-EDC008184192}"
+ ProjectSection(ProjectDependencies) = postProject
+ {F70CFB27-8A2F-E447-B452-4E1C590EDA6D} = {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}
+ {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D} = {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}
+ {1E8BFF9E-3044-0742-992F-C5765B80FE65} = {1E8BFF9E-3044-0742-992F-C5765B80FE65}
+ {74B1CBD4-3B6E-E544-9475-33FBB0BCE165} = {74B1CBD4-3B6E-E544-9475-33FBB0BCE165}
+ {D893D6B3-805D-9848-8EA4-CDA1B79151F6} = {D893D6B3-805D-9848-8EA4-CDA1B79151F6}
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Profile|Win32 = Profile|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}.Debug|Win32.Build.0 = Debug|Win32
+ {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}.Profile|Win32.ActiveCfg = Profile|Win32
+ {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}.Profile|Win32.Build.0 = Profile|Win32
+ {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}.Release|Win32.ActiveCfg = Release|Win32
+ {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}.Release|Win32.Build.0 = Release|Win32
+ {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}.Debug|Win32.Build.0 = Debug|Win32
+ {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}.Profile|Win32.ActiveCfg = Profile|Win32
+ {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}.Profile|Win32.Build.0 = Profile|Win32
+ {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}.Release|Win32.ActiveCfg = Release|Win32
+ {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}.Release|Win32.Build.0 = Release|Win32
+ {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Debug|Win32.ActiveCfg = Debug|Win32
+ {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Debug|Win32.Build.0 = Debug|Win32
+ {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Profile|Win32.ActiveCfg = Profile|Win32
+ {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Profile|Win32.Build.0 = Profile|Win32
+ {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Release|Win32.ActiveCfg = Release|Win32
+ {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Release|Win32.Build.0 = Release|Win32
+ {74B1CBD4-3B6E-E544-9475-33FBB0BCE165}.Debug|Win32.ActiveCfg = Debug|Win32
+ {74B1CBD4-3B6E-E544-9475-33FBB0BCE165}.Debug|Win32.Build.0 = Debug|Win32
+ {74B1CBD4-3B6E-E544-9475-33FBB0BCE165}.Profile|Win32.ActiveCfg = Profile|Win32
+ {74B1CBD4-3B6E-E544-9475-33FBB0BCE165}.Profile|Win32.Build.0 = Profile|Win32
+ {74B1CBD4-3B6E-E544-9475-33FBB0BCE165}.Release|Win32.ActiveCfg = Release|Win32
+ {74B1CBD4-3B6E-E544-9475-33FBB0BCE165}.Release|Win32.Build.0 = Release|Win32
+ {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Debug|Win32.ActiveCfg = Debug|Win32
+ {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Debug|Win32.Build.0 = Debug|Win32
+ {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Profile|Win32.ActiveCfg = Profile|Win32
+ {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Profile|Win32.Build.0 = Profile|Win32
+ {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Release|Win32.ActiveCfg = Release|Win32
+ {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Release|Win32.Build.0 = Release|Win32
+ {75501170-51C2-E641-BA8B-EDC008184192}.Debug|Win32.ActiveCfg = Debug|Win32
+ {75501170-51C2-E641-BA8B-EDC008184192}.Debug|Win32.Build.0 = Debug|Win32
+ {75501170-51C2-E641-BA8B-EDC008184192}.Profile|Win32.ActiveCfg = Profile|Win32
+ {75501170-51C2-E641-BA8B-EDC008184192}.Profile|Win32.Build.0 = Profile|Win32
+ {75501170-51C2-E641-BA8B-EDC008184192}.Release|Win32.ActiveCfg = Release|Win32
+ {75501170-51C2-E641-BA8B-EDC008184192}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/src/eressea/attributes.c b/src/eressea/attributes.c
deleted file mode 100644
index 42d982e1b..000000000
--- a/src/eressea/attributes.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* vi: set ts=2:
- *
- * Eressea PB(E)M host Copyright (C) 1998-2000
- * 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)
- *
- * This program may not be used, modified or distributed without
- * prior permission by the authors of Eressea.
- */
-
-#include
-#include
-#include
-
-/* attributes includes */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#ifdef AT_OPTION
-# include
-#endif
-
-/* util includes */
-#include
-
-void
-init_attributes(void)
-{
- at_register(&at_overrideroads);
- init_iceberg();
- init_key();
- init_gm();
- init_follow();
- init_targetregion();
- init_orcification();
- init_hate();
- init_reduceproduction();
- init_racename();
- init_otherfaction();
- init_moved();
-#ifdef AT_OPTION
- init_option();
-#endif
-}
diff --git a/src/eressea/attributes.h b/src/eressea/attributes.h
deleted file mode 100644
index 657446f72..000000000
--- a/src/eressea/attributes.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* vi: set ts=2:
- *
- *
- * Eressea PB(E)M host Copyright (C) 1998-2000
- * 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)
- *
- * This program may not be used, modified or distributed without
- * prior permission by the authors of Eressea.
- */
-
-extern void init_attributes(void);
diff --git a/src/eressea/console.c b/src/eressea/console.c
index ac86e7432..4d650d70f 100644
--- a/src/eressea/console.c
+++ b/src/eressea/console.c
@@ -1,7 +1,9 @@
#include "console.h"
/* lua includes */
-#include
+#include
+#include
+#include
/* libc includes */
#include
@@ -20,8 +22,8 @@
#define MAXINPUT 512
#endif
-static int
-stdin_readline(lua_State *l, const char *prompt)
+static int
+stdin_readline(lua_State *l, const char *prompt)
{
static char buffer[MAXINPUT];
if (prompt) {
@@ -57,7 +59,7 @@ set_readline(readline foo)
#endif
static const char *
-get_prompt(lua_State * L, int firstline)
+get_prompt(lua_State * L, int firstline)
{
const char *p = NULL;
lua_pushstring(L, firstline ? "_PROMPT" : "_PROMPT2");
@@ -68,8 +70,8 @@ get_prompt(lua_State * L, int firstline)
return p;
}
-static int
-incomplete(lua_State * L, int status)
+static int
+incomplete(lua_State * L, int status)
{
if (status!=LUA_ERRSYNTAX) return 0;
if (strstr(lua_tostring(L, -1), "near `'") == NULL) return 0;
@@ -78,15 +80,15 @@ incomplete(lua_State * L, int status)
return 1;
}
-static void
-l_message(const char *pname, const char *msg)
+static void
+l_message(const char *pname, const char *msg)
{
if (pname) fprintf(stderr, "%s: ", pname);
fprintf(stderr, "%s\n", msg);
}
-static int
-l_report(lua_State * L, int status)
+static int
+l_report(lua_State * L, int status)
{
const char *msg;
if (status) {
@@ -106,8 +108,8 @@ l_report(lua_State * L, int status)
#define lua_saveline(L,line) /* empty */
#endif
-static int
-load_string(lua_State * L)
+static int
+load_string(lua_State * L)
{
int status;
lua_settop(L, 0);
@@ -129,8 +131,8 @@ load_string(lua_State * L)
return status;
}
-static void
-lstop(lua_State *l, lua_Debug *ar)
+static void
+lstop(lua_State *l, lua_Debug *ar)
{
(void)ar; /* unused arg. */
lua_sethook(l, NULL, 0, 0);
@@ -143,8 +145,8 @@ static lua_State * state_stack[STATESTACK_MAX];
int state_stack_top = -1;
-static void
-laction(int i)
+static void
+laction(int i)
{
signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
terminate process (default action) */
@@ -152,8 +154,8 @@ laction(int i)
lua_sethook(state_stack[state_stack_top], lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
}
-static int
-lcall(lua_State * L, int narg, int clear)
+static int
+lcall(lua_State * L, int narg, int clear)
{
int status, pop_state = state_stack_top;
int base = lua_gettop(L) - narg; /* function index */
@@ -162,7 +164,7 @@ lcall(lua_State * L, int narg, int clear)
lua_insert(L, base); /* put it under chunk and args */
if (state_stack_top<0 || L != state_stack[state_stack_top]) {
assert(state_stack_top+1
- extern int lua_console(lua_State * L);
- extern int lua_do(lua_State * L);
-
+ struct lua_State;
+
+ extern int lua_console(struct lua_State * L);
+ extern int lua_do(struct lua_State * L);
+
typedef int (*readline)(struct lua_State *, const char *);
extern void set_readline(readline foo);
diff --git a/src/eressea/editor.vcproj b/src/eressea/editor.vcproj
new file mode 100644
index 000000000..2e6bab61a
--- /dev/null
+++ b/src/eressea/editor.vcproj
@@ -0,0 +1,262 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/eressea/eressea-lua.vcproj b/src/eressea/eressea-lua.vcproj
new file mode 100644
index 000000000..2990f6c92
--- /dev/null
+++ b/src/eressea/eressea-lua.vcproj
@@ -0,0 +1,306 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/eressea/gmmain.cpp b/src/eressea/gmmain.cpp
deleted file mode 100644
index 2db13a202..000000000
--- a/src/eressea/gmmain.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/* vi: set ts=2:
- * +-------------------+ Christian Schlittchen
- * | | Enno Rehling
- * | Eressea PBEM host | Katja Zedel
- * | (c) 1998 - 2006 |
- * | | This program may not be used, modified or distributed
- * +-------------------+ without prior permission by the authors of Eressea.
- *
- */
-
-/* wenn config.h nicht vor curses included wird, kompiliert es unter windows nicht */
-#include
-#include
-
-#include "console.h"
-#include "gmtool.h"
-
-/* lua includes */
-#include "lua/bindings.h"
-#include
-#pragma warning (push)
-#pragma warning (disable: 4127)
-#include
-#include
-#pragma warning (pop)
-
-static const struct {
- const char * name;
- int (*func)(lua_State *);
-} lualibs[] = {
- {"", luaopen_base},
- {LUA_TABLIBNAME, luaopen_table},
- {LUA_IOLIBNAME, luaopen_io},
- {LUA_STRLIBNAME, luaopen_string},
- {LUA_MATHLIBNAME, luaopen_math},
- { NULL, NULL }
-};
-
-static void
-openlibs(lua_State * L)
-{
- int i;
- for (i=0;lualibs[i].func;++i) {
- lua_pushcfunction(L, lualibs[i].func);
- lua_pushstring(L, lualibs[i].name);
- lua_call(L, 1, 0);
- }
-}
-
-static lua_State *
-lua_init(void)
-{
- lua_State * L = lua_open();
-
- openlibs(L);
-
- luabind::open(L);
- bind_objects(L);
- bind_eressea(L);
- bind_spell(L);
- bind_alliance(L);
- bind_region(L);
- bind_item(L);
- bind_faction(L);
- bind_unit(L);
- bind_ship(L);
- bind_building(L);
- bind_gmtool(L);
- lua_readline = curses_readline;
- return L;
-}
-
-static void
-lua_done(lua_State * L)
-{
- lua_close(L);
-}
-
-int
-main(int argc, char *argv[])
-{
- lua_State* luaState = lua_init();
- global.vm_state = luaState;
-
- int result = gmmain(argc, argv);
- lua_done(luaState);
-
- return result;
-}
diff --git a/src/eressea/gmtool.c b/src/eressea/gmtool.c
index 39c61b5ec..929d46e92 100644
--- a/src/eressea/gmtool.c
+++ b/src/eressea/gmtool.c
@@ -2,10 +2,10 @@
* +-------------------+ Christian Schlittchen
* | | Enno Rehling
* | Eressea PBEM host | Katja Zedel
- * | (c) 1998 - 2006 |
+ * | (c) 1998 - 2006 |
* | | This program may not be used, modified or distributed
* +-------------------+ without prior permission by the authors of Eressea.
- *
+ *
*/
/* wenn config.h nicht vor curses included wird, kompiliert es unter windows nicht */
@@ -60,6 +60,8 @@
#include
+#include
+
#include
#include
@@ -101,12 +103,12 @@ init_curses(void)
short bcol = COLOR_BLACK;
short hcol = COLOR_MAGENTA;
start_color();
-#ifdef WIN32
+#ifdef WIN32
/* looks crap on putty with TERM=linux */
if (can_change_color()) {
init_color(COLOR_YELLOW, 1000, 1000, 0);
}
-#endif
+#endif
for (fg=0;fg!=8;++fg) {
for (bg=0;bg!=2;++bg) {
@@ -213,13 +215,13 @@ mr_tile(const map_region * mr, int highlight)
if (mr!=NULL && mr->r!=NULL) {
const region * r = mr->r;
switch (r->terrain->_name[0]) {
- case 'o' :
+ case 'o' :
return '.' | COLOR_PAIR(hl + COLOR_CYAN);
- case 'd' :
+ case 'd' :
return 'D' | COLOR_PAIR(hl + COLOR_YELLOW) | A_BOLD;
- case 't' :
+ case 't' :
return '%' | COLOR_PAIR(hl + COLOR_YELLOW) | A_BOLD;
- case 'f' :
+ case 'f' :
if (r->terrain->_name[1]=='o') { /* fog */
return '.' | COLOR_PAIR(hl + COLOR_YELLOW) | A_NORMAL;
} else if (r->terrain->_name[1]=='i') { /* firewall */
@@ -229,7 +231,7 @@ mr_tile(const map_region * mr, int highlight)
return 'H' | COLOR_PAIR(hl + COLOR_YELLOW) | A_NORMAL;
case 'm' :
return '^' | COLOR_PAIR(hl + COLOR_WHITE) | A_NORMAL;
- case 'p' :
+ case 'p' :
if (r_isforest(r)) return '#' | COLOR_PAIR(hl + COLOR_GREEN) | A_NORMAL;
return '+' | COLOR_PAIR(hl + COLOR_GREEN) | A_BOLD;
case 'g' :
@@ -514,7 +516,7 @@ select_terrain(state * st, const terrain_type * default_terrain)
st->wnd_info->update |= 1;
st->wnd_map->update |= 1;
st->wnd_status->update |= 1;
-
+
if (selected==NULL) return NULL;
return (const terrain_type*)selected->data;
}
@@ -610,7 +612,7 @@ select_regions(state * st, int selectmode)
}
}
}
- }
+ }
else if (findmode=='p') {
region * r;
sprintf(sbuffer, "%splayers", status);
@@ -628,7 +630,7 @@ select_regions(state * st, int selectmode)
}
}
}
- }
+ }
else if (findmode=='u') {
region * r;
sprintf(sbuffer, "%sunits", status);
@@ -642,7 +644,7 @@ select_regions(state * st, int selectmode)
}
}
}
- }
+ }
else if (findmode=='s') {
region * r;
sprintf(sbuffer, "%sships", status);
@@ -656,17 +658,17 @@ select_regions(state * st, int selectmode)
}
}
}
- }
+ }
else if (findmode=='f') {
char fbuffer[12];
sprintf(sbuffer, "%sfaction:", status);
askstring(st->wnd_status->handle, sbuffer, fbuffer, 12);
if (fbuffer[0]) {
faction * f = findfaction(atoi36(fbuffer));
-
+
if (f!=NULL) {
unit * u;
-
+
sprintf(sbuffer, "%sfaction: %s", status, itoa36(f->no));
statusline(st->wnd_status->handle, sbuffer);
for (u=f->units;u;u=u->nextF) {
@@ -892,7 +894,7 @@ handlekey(state * st, int c)
if (global.vm_state) {
move(0, 0);
refresh();
- lua_do((lua_State*)global.vm_state);
+ lua_do((struct lua_State*)global.vm_state);
/* todo: do this from inside the script */
clear();
st->wnd_info->update |= 1;
@@ -1066,7 +1068,7 @@ update_view(view * vi)
}
}
-void
+void
run_mapper(void)
{
WINDOW * hwinstatus;
@@ -1179,7 +1181,7 @@ run_mapper(void)
#define MAXINPUT 512
int
-curses_readline(lua_State * L, const char * prompt)
+curses_readline(struct lua_State * L, const char * prompt)
{
static char buffer[MAXINPUT];
askstring(hstatus, prompt, buffer, MAXINPUT);
diff --git a/src/eressea/gmtool.vcproj b/src/eressea/gmtool.vcproj
new file mode 100644
index 000000000..e8e0ace46
--- /dev/null
+++ b/src/eressea/gmtool.vcproj
@@ -0,0 +1,314 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/eressea/items.c b/src/eressea/items.c
deleted file mode 100644
index faa5bef72..000000000
--- a/src/eressea/items.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* vi: set ts=2:
- +-------------------+ Christian Schlittchen
- | | Enno Rehling
- | Eressea PBEM host | Katja Zedel
- | (c) 1998 - 2001 | Henning Peters
- | | Ingo Wilken
- +-------------------+ Stefan Reich
-
- This program may not be used, modified or distributed
- without prior permission by the authors of Eressea.
-*/
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-void
-register_items(void)
-{
- register_weapons();
- register_demonseye();
- init_lmsreward();
- register_xerewards();
-}
diff --git a/src/eressea/lua.hpp b/src/eressea/lua.hpp
new file mode 100644
index 000000000..147bfa14a
--- /dev/null
+++ b/src/eressea/lua.hpp
@@ -0,0 +1,11 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include
+#include
+#include
+#ifdef __cplusplus
+}
+
+#endif
diff --git a/src/eressea/lua/bindings.vcproj b/src/eressea/lua/bindings.vcproj
new file mode 100644
index 000000000..9a2674bb7
--- /dev/null
+++ b/src/eressea/lua/bindings.vcproj
@@ -0,0 +1,310 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/eressea/lua/building.cpp b/src/eressea/lua/building.cpp
index 0b9f9f9a4..95d627ac4 100644
--- a/src/eressea/lua/building.cpp
+++ b/src/eressea/lua/building.cpp
@@ -17,9 +17,7 @@
#include
#include
#include
-#if LUABIND_BETA >= 7
-# include
-#endif
+#include
#ifdef _MSC_VER
#pragma warning (pop)
#endif
@@ -136,7 +134,7 @@ building_setregion(building * bld, region * r)
b->region = r;
}
-static std::ostream&
+static std::ostream&
operator<<(std::ostream& stream, const building& b)
{
stream << b.name;
@@ -146,7 +144,7 @@ operator<<(std::ostream& stream, const building& b)
return stream;
}
-static bool
+static bool
operator==(const building& a, const building&b)
{
return a.no==b.no;
@@ -154,7 +152,7 @@ operator==(const building& a, const building&b)
class buildingunit {
public:
- static unit * next(unit * node) {
+ static unit * next(unit * node) {
building * b = node->building;
do {
node = node->next;
@@ -179,7 +177,7 @@ building_gettype(const building& b) {
}
void
-bind_building(lua_State * L)
+bind_building(lua_State * L)
{
at_building_action.age = lc_age;
module(L)[
diff --git a/src/eressea/lua/eressea.cpp b/src/eressea/lua/eressea.cpp
index 6cc63bd74..129806288 100644
--- a/src/eressea/lua/eressea.cpp
+++ b/src/eressea/lua/eressea.cpp
@@ -210,7 +210,6 @@ lua_learnskill(unit * u, const char * skname, float chances)
bool
is_function(struct lua_State * luaState, const char * fname)
{
-#if LUABIND_BETA>7 || (LUABIND_BETA==7 && LUABIND_DEVEL>=2)
object g = globals(luaState);
object fun = g[fname];
if (fun.is_valid()) {
@@ -221,18 +220,6 @@ is_function(struct lua_State * luaState, const char * fname)
log_warning(("Lua global object %s is not a function, type is %u\n", fname, type(fun)));
}
}
-#else
- object g = get_globals(luaState);
- object fun = g[fname];
- if (fun.is_valid()) {
- if (fun.type()==LUA_TFUNCTION) {
- return true;
- }
- if (fun.type()!=LUA_TNIL) {
- log_warning(("Lua global object %s is not a function, type is %u\n", fname, fun.type()));
- }
- }
-#endif
return false;
}
diff --git a/src/eressea/lua/faction.cpp b/src/eressea/lua/faction.cpp
index 4aec6a6ef..1863d3a84 100644
--- a/src/eressea/lua/faction.cpp
+++ b/src/eressea/lua/faction.cpp
@@ -30,9 +30,7 @@
#include
#include
#include
-#if LUABIND_BETA >= 7
-# include
-#endif
+#include
#ifdef _MSC_VER
#pragma warning (pop)
#endif
@@ -94,14 +92,14 @@ faction_setlocale(faction * f, const char * name)
f->locale = find_locale(name);
}
-static std::ostream&
+static std::ostream&
operator<<(std::ostream& stream, const faction& f)
{
stream << factionname(&f);
return stream;
}
-static bool
+static bool
operator==(const faction& a, const faction&b)
{
return a.no==b.no;
@@ -287,7 +285,7 @@ faction_maxheroes(const faction * f)
}
void
-bind_faction(lua_State * L)
+bind_faction(lua_State * L)
{
module(L)[
def("factions", &get_factions, return_stl_iterator),
diff --git a/src/eressea/lua/message.cpp b/src/eressea/lua/message.cpp
index 0750e97ca..906ea7329 100644
--- a/src/eressea/lua/message.cpp
+++ b/src/eressea/lua/message.cpp
@@ -19,9 +19,7 @@
#include
#include
#include
-#if LUABIND_BETA >= 7
-# include
-#endif
+#include
#ifdef _MSC_VER
#pragma warning (pop)
#endif
@@ -171,7 +169,7 @@ protected:
variant * args;
};
-static std::ostream&
+static std::ostream&
operator<<(std::ostream& stream, const lua_message& msg)
{
stream << "(message object)";
@@ -180,12 +178,12 @@ operator<<(std::ostream& stream, const lua_message& msg)
void
-bind_message(lua_State * L)
+bind_message(lua_State * L)
{
module(L)[
class_("message")
.def(constructor())
- .def(tostring(self))
+ .def(tostring(const_self))
.def("set_unit", &lua_message::set_unit)
.def("set_region", &lua_message::set_region)
diff --git a/src/eressea/lua/objects.cpp b/src/eressea/lua/objects.cpp
index 1ac861068..413a45b85 100644
--- a/src/eressea/lua/objects.cpp
+++ b/src/eressea/lua/objects.cpp
@@ -27,101 +27,91 @@ using namespace luabind;
namespace eressea {
- object
- objects::get(const char * name) {
- lua_State * L = (lua_State *)global.vm_state;
- attrib * a = a_find(*mAttribPtr, &at_object);
- for (;a && a->type==&at_object;a=a->next) {
- if (strcmp(object_name(a), name)==0) {
- variant val;
- object_type type;
+object objects::get(const char * name) {
+ lua_State * L = (lua_State *) global.vm_state;
+ attrib * a = a_find(*mAttribPtr, &at_object);
+ for (; a && a->type == &at_object; a = a->next) {
+ if (strcmp(object_name(a), name) == 0) {
+ variant val;
+ object_type type;
- object_get(a, &type, &val);
- switch (type) {
- case TNONE:
- break;
- case TINTEGER:
- return object(L, val.i);
- case TREAL:
- return object(L, val.f);
- case TREGION:
- return object(L, (region*)val.v);
- case TBUILDING:
- return object(L, (building*)val.v);
- case TUNIT:
- return object(L, (unit*)val.v);
- case TSHIP:
- return object(L, (ship*)val.v);
- case TSTRING:
- return object(L, std::string((const char*)val.v));
- default:
- assert(!"not implemented");
- }
- }
- }
-#if LUABIND_BETA<7 || (LUABIND_BETA==7 && LUABIND_DEVEL<2)
- return object(L); // nil
-#else
- return object(); // nil
-#endif
- }
-
- static void set_object(attrib **attribs, const char * name, object_type type, variant val) {
- attrib * a = a_find(*attribs, &at_object);
- for (;a && a->type==&at_object;a=a->next) {
- if (strcmp(object_name(a), name)==0) {
- object_set(a, type, val);
- return;
- }
- }
- a = a_add(attribs, object_create(name, type, val));
- }
-
- template<> void
- objects::set(const char * name, int value) {
- variant val = { 0 };
- val.i = value;
- set_object(mAttribPtr, name, TINTEGER, val);
- }
-
- template<> void
- objects::set(const char * name, double value) {
- variant val = { 0 };
- val.f = (float)value;
- set_object(mAttribPtr, name, TREAL, val);
- }
-
- template<> void
- objects::set(const char * name, const char * value) {
- variant val = { 0 };
- val.v = strdup(value);
- set_object(mAttribPtr, name, TSTRING, val);
- }
-
- template void
- objects::set(const char * name, V value) {
- variant val = { 0 };
- val.v = &value;
- set_object(mAttribPtr, name, T, val);
- }
+ object_get(a, &type, &val);
+ switch (type) {
+ case TNONE:
+ break;
+ case TINTEGER:
+ return object(L, val.i);
+ case TREAL:
+ return object(L, val.f);
+ case TREGION:
+ return object(L, (region*) val.v);
+ case TBUILDING:
+ return object(L, (building*) val.v);
+ case TUNIT:
+ return object(L, (unit*) val.v);
+ case TSHIP:
+ return object(L, (ship*) val.v);
+ case TSTRING:
+ return object(L, std::string((const char*) val.v));
+ default:
+ assert(!"not implemented");
+ }
+ }
+ }
+ return object(); // nil
}
-void
-bind_objects(struct lua_State * L)
-{
- using namespace eressea;
-
- module(L)[
- class_("objects")
- .def("get", &objects::get)
- .def("set", (void(objects::*)(const char*, region&))&objects::set)
- .def("set", (void(objects::*)(const char*, unit&))&objects::set)
- .def("set", (void(objects::*)(const char*, faction&))&objects::set)
- .def("set", (void(objects::*)(const char*, building&))&objects::set)
- .def("set", (void(objects::*)(const char*, ship&))&objects::set)
- // POD:
-// .def("set", (void(objects::*)(const char*, int))&objects::set)
- .def("set", (void(objects::*)(const char*, double))&objects::set)
- .def("set", (void(objects::*)(const char*, const char *))&objects::set)
- ];
+static void set_object(attrib **attribs, const char * name, object_type type,
+ variant val) {
+ attrib * a = a_find(*attribs, &at_object);
+ for (; a && a->type == &at_object; a = a->next) {
+ if (strcmp(object_name(a), name) == 0) {
+ object_set(a, type, val);
+ return;
+ }
+ }
+ a = a_add(attribs, object_create(name, type, val));
}
+
+template<> void objects::set(const char * name, int value) {
+ variant val = { 0 };
+ val.i = value;
+ set_object(mAttribPtr, name, TINTEGER, val);
+}
+
+template<> void objects::set(const char * name, double value) {
+ variant val = { 0 };
+ val.f = (float) value;
+ set_object(mAttribPtr, name, TREAL, val);
+}
+
+template<> void objects::set(const char * name,
+ const char * value) {
+ variant val = { 0 };
+ val.v = strdup(value);
+ set_object(mAttribPtr, name, TSTRING, val);
+}
+
+template void objects::set(const char * name, V value) {
+ variant val = { 0 };
+ val.v = &value;
+ set_object(mAttribPtr, name, T, val);
+}
+}
+
+void bind_objects(struct lua_State * L) {
+ using namespace eressea;
+
+ module(L)[class_ ("objects") .def("get", &objects::get) .def(
+ "set",
+ (void(objects::*)(const char*, region&))&objects::set)
+ .def("set", (void(objects::*)(const char*, unit&))&objects::set)
+ .def("set", (void(objects::*)(const char*, faction&))&objects::set)
+ .def("set", (void(objects::*)(const char*, building&))&objects::set)
+ .def("set", (void(objects::*)(const char*, ship&))&objects::set)
+ // POD:
+ // .def("set", (void(objects::*)(const char*, int))&objects::set)
+ .def("set", (void(objects::*)(const char*, double))&objects::set)
+ .def("set", (void(objects::*)(const char*, const char *))&objects::set)
+ ];
+ }
diff --git a/src/eressea/lua/region.cpp b/src/eressea/lua/region.cpp
index d39734af5..df67f4da9 100644
--- a/src/eressea/lua/region.cpp
+++ b/src/eressea/lua/region.cpp
@@ -27,9 +27,7 @@
#include
#include
#include
-#if LUABIND_BETA >= 7
-# include
-#endif
+#include
#ifdef _MSC_VER
#pragma warning (pop)
#endif
@@ -374,7 +372,7 @@ bind_region(lua_State * L)
def("getplanebyname", &plane_getbyname),
class_("region")
- .def(tostring(self))
+ .def(tostring(const_self))
.def(self == region())
.property("name", ®ion_getname, ®ion_setname)
.property("info", ®ion_getinfo, ®ion_setinfo)
diff --git a/src/eressea/lua/script.cpp b/src/eressea/lua/script.cpp
index 8305dd654..9ca29d948 100644
--- a/src/eressea/lua/script.cpp
+++ b/src/eressea/lua/script.cpp
@@ -36,9 +36,7 @@
#pragma warning (disable: 4127)
#endif
#include
-#if LUABIND_BETA >= 7
-# include
-#endif
+#include
#ifdef _MSC_VER
#pragma warning (pop)
#endif
diff --git a/src/eressea/lua/ship.cpp b/src/eressea/lua/ship.cpp
index e43b1bd4e..b1c9ef8bc 100644
--- a/src/eressea/lua/ship.cpp
+++ b/src/eressea/lua/ship.cpp
@@ -16,9 +16,7 @@
#include
#include
#include
-#if LUABIND_BETA >= 7
-# include
-#endif
+#include
#ifdef _MSC_VER
#pragma warning (pop)
#endif
@@ -28,7 +26,7 @@
#include
using namespace luabind;
-static std::ostream&
+static std::ostream&
operator<<(std::ostream& stream, const ship& sh)
{
stream << sh.name;
@@ -38,7 +36,7 @@ operator<<(std::ostream& stream, const ship& sh)
return stream;
}
-static bool
+static bool
operator==(const ship& a, const ship& sh)
{
return a.no==sh.no;
@@ -88,7 +86,7 @@ ship_getregion(const ship * sh)
}
void
-bind_ship(lua_State * L)
+bind_ship(lua_State * L)
{
module(L)[
def("get_ship", &findship),
diff --git a/src/eressea/lua/spell.cpp b/src/eressea/lua/spell.cpp
index 85308e3e2..93e893212 100644
--- a/src/eressea/lua/spell.cpp
+++ b/src/eressea/lua/spell.cpp
@@ -24,7 +24,7 @@ spell_getschool(const spell& sp)
}
void
-bind_spell(lua_State * L)
+bind_spell(lua_State * L)
{
module(L)[
class_("spell")
diff --git a/src/eressea/lua/unit.cpp b/src/eressea/lua/unit.cpp
index f2cae24e7..88393a399 100644
--- a/src/eressea/lua/unit.cpp
+++ b/src/eressea/lua/unit.cpp
@@ -39,9 +39,7 @@
#include
#include
#include
-#if LUABIND_BETA>=7
-# include
-#endif
+#include
#ifdef _MSC_VER
#pragma warning (pop)
#endif
@@ -73,8 +71,8 @@ public:
class bind_orders {
public:
static order * next(order * node) { return node->next; }
- static std::string value(order * node) {
- char * cmd = (char*)getcommand(node);
+ static std::string value(order * node) {
+ char * cmd = (char*)getcommand(node);
std::string s(cmd);
free(cmd);
return s;
@@ -423,7 +421,7 @@ set_flag(unit * u, const char * name, bool value)
}
}
-static std::ostream&
+static std::ostream&
operator<<(std::ostream& stream, const unit& u)
{
const char * rcname = get_racename(u.attribs);
@@ -432,7 +430,7 @@ operator<<(std::ostream& stream, const unit& u)
return stream;
}
-static bool
+static bool
operator==(const unit& a, const unit &b)
{
return a.no==b.no;
@@ -462,7 +460,7 @@ unit_setfaction(unit * u, faction * f)
u_setfaction(u, f);
}
-static const char *
+static const char *
unit_getmagic(const unit * u)
{
sc_mage * mage = get_mage(u);
@@ -516,7 +514,7 @@ fctr_handle(struct trigger * tp, void * data)
trigger * t = tp;
event * evt = new event(NULL, (event_arg*)data);
fctr_data * fd = (fctr_data*)t->data.v;
- try {
+ try {
fd->fptr->operator()(fd->target, evt);
}
catch (luabind::error& e) {
@@ -580,14 +578,14 @@ unit_addnotice(unit * u, const char * str)
}
void
-bind_unit(lua_State * L)
+bind_unit(lua_State * L)
{
module(L)[
def("get_unit", &findunit),
def("add_unit", &add_unit),
class_("unit")
- .def(tostring(self))
+ .def(tostring(const_self))
.def(self == unit())
.property("name", &unit_getname, &unit_setname)
.property("info", &unit_getinfo, &unit_setinfo)
diff --git a/src/eressea/main.c b/src/eressea/main.c
deleted file mode 100644
index 7415df168..000000000
--- a/src/eressea/main.c
+++ /dev/null
@@ -1,612 +0,0 @@
-/* vi: set ts=2:
- *
- *
- * Eressea PB(E)M host Copyright (C) 1998-2003
- * 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ö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
-#include "eressea.h"
-
-/* initialization - TODO: init in separate module */
-#include
-#include
-#include
-#include
-#include
-
-/* modules includes */
-#include
-#include
-#include
-#include
-#include
-#ifdef MUSEUM_MODULE
-#include
-#endif
-#ifdef WORMHOLE_MODULE
-#include
-#endif
-#ifdef ARENA_MODULE
-#include
-#endif
-#ifdef DUNGEON_MODULE
-#include
-#endif
-
-/* gamecode includes */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-/* kernel includes */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-/* util includes */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-/* libc includes */
-#include
-#include
-#include
-#include
-#include
-
-#define ISLANDSIZE 20
-
-/**
- ** global variables we are importing from other modules
- **/
-extern char * g_reportdir;
-extern char * g_datadir;
-extern char * g_basedir;
-extern char * g_resourcedir;
-
-extern boolean nonr;
-extern boolean nosh;
-extern boolean nocr;
-extern boolean noreports;
-extern boolean nomer;
-extern boolean nobattle;
-extern boolean nomonsters;
-extern boolean battledebug;
-extern boolean dirtyload;
-
-extern int loadplane;
-
-extern void debug_messagetypes(FILE * out);
-extern void free_region(region * r);
-extern void render_init(void);
-extern void free_borders(void);
-
-
-/**
- ** global variables that we are exporting
- **/
-static char * orders = NULL;
-static int nowrite = 0;
-static boolean g_writemap = false;
-static boolean opt_reportonly = false;
-extern boolean opt_cr_absolute_coords;
-
-struct settings global = {
- "Eressea", /* gamename */
- 1000, /* maxunits */
-};
-
-static void
-game_init(void)
-{
- init_triggers();
- init_xmas();
-
- reports_init();
- report_init();
- creport_init();
- xmlreport_init();
-
- debug_language("locales.log");
- register_races();
- register_names();
- register_resources();
- register_buildings();
- register_ships();
- register_itemfunctions();
- register_spells();
- register_gcspells();
-#ifdef DUNGEON_MODULE
- register_dungeon();
-#endif
-
- register_itemtypes();
- register_xmlreader();
- enable_xml_gamecode();
- init_data(xmlfile);
-
- init_locales();
- init_attributes();
- init_races();
- init_itemtypes();
- init_races();
- init_rawmaterials();
-
- init_gmcmd();
-#ifdef INFOCMD_MODULE
- init_info();
-#endif
-
-#ifdef MUSEUM_MODULE
- register_museum();
-#endif
-#ifdef ARENA_MODULE
- register_arena();
-#endif
-#ifdef WORMHOLE_MODULE
- register_wormholes();
-#endif
-#ifdef REMOVE_THIS
- render_init();
- {
- FILE * F = fopen("messagetypes.txt", "w");
- debug_messagetypes(F);
- fclose(F);
- abort();
- }
-#endif
-}
-
-#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));
- if (set_email(&pwd->email, email)!=0) {
- log_error(("Invalid email address faction %s: %s\n", faction, email));
- }
- pwd->pwd = strdup(passwd);
- pwd->used = false;
- pwd->next = f->shortpwds;
- f->shortpwds = pwd;
- }
- }
- fclose(F);
- }
-}
-#endif
-
-static int
-processturn(char *filename)
-{
- struct summary * begin, * end;
- newfaction * players;
- int i;
- char path[MAX_PATH];
-
- if (turn == 0) rng_init((int)time(0));
- else rng_init(turn);
-
-#ifdef SHORTPWDS
- readshortpwds("passwords");
-#endif
- begin = make_summary();
- turn++;
- if ((i=readorders(filename, "ISO-8859-1"))!=0) return i;
- if (!nomonsters) {
- if (turn == 0) rng_init((int)time(0));
- else rng_init(turn);
- puts(" - Monster KI...");
- plan_monsters();
- }
- processorders();
- sprintf(path, "%s/newfactions", basepath());
- players = read_newfactions(filename);
- while (players) {
- int n = listlen(players);
- int k = (n+ISLANDSIZE-1)/ISLANDSIZE;
- k = n / k;
- autoseed(&players, k, true);
- }
- score();
- update_guards();
- if (!noreports) {
- init_reports();
- reports();
- }
- free_units();
- puts(" - Beseitige leere Parteien");
- remove_empty_factions(true);
- end = make_summary();
- report_summary(end, begin, false);
- report_summary(end, begin, true);
- free(end);
- free(begin);
- writepasswd();
- if (!nowrite) {
- char ztext[64];
- sprintf(ztext, "%d", turn);
- return writegame(ztext, 0);
- }
- return 0;
-}
-
-#ifdef CLEANUP_CODE
-static void
-game_done(void)
-{
- /* 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ötigt
- * wird (temporäre Hilsstrukturen) */
- unit *u, *u2;
- region *r, *r2;
- building *b, *b2;
- faction *f, *f2;
- ship *s, *s2;
-
- for (r = regions; r; r = r2) {
- 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;
- free_region(r);
- }
- for (f = factions; f; f = f2) {
- stripfaction(f);
- f2 = f->next;
- free(f);
- }
- while (planes) {
- plane * pl = planes;
- planes = planes->next;
- free(pl->name);
- free(pl);
- }
- creport_cleanup();
- report_cleanup();
-}
-#endif
-
-#include "magic.h"
-
-#ifdef CRTDBG
-void
-init_crtdbg(void)
-{
-#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)
-# elif MALLOCDBG == 3
-# define CHECKON() _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) & 0)
-# 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
-
-static int
-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"
- "-l logfile : specify an alternative logfile\n"
- "-R : erstellt nur die Reports neu\n"
- "--lomem : keine Messages (RAM sparen)\n"
- "--nobattle : keine Kämpfe\n"
- "--nomonsters : keine monster KI\n"
- "--nodebug : keine Logfiles für Kämpfe\n"
- "--noreports : absolut keine Reporte schreiben\n"
- "--debug : schreibt Debug-Ausgaben in die Datei debug\n"
- "--nocr : keine CRs\n"
- "--nonr : keine Reports\n"
- "--nosh : keine Mail-skripte\n"
- "--crabsolute : absolute Koordinaten im CR\n"
- "--help : help\n", prog);
- return -1;
-}
-
-static int
-read_args(int argc, char **argv)
-{
- int i;
-
- for (i=1;i!=argc;++i) {
- if (argv[i][0]!='-') {
- return usage(argv[0], argv[i]);
- } else if (argv[i][1]=='-') { /* long format */
- if (strcmp(argv[i]+2, "nocr")==0) nocr = true;
- else if (strcmp(argv[i]+2, "nosave")==0) nowrite = true;
- else if (strcmp(argv[i]+2, "noreports")==0) {
- noreports = true;
- nocr = true;
- nocr = true;
- }
- else if (strcmp(argv[i]+2, "xml")==0) xmlfile = argv[++i];
- else if (strcmp(argv[i]+2, "dirtyload")==0) dirtyload = true;
- else if (strcmp(argv[i]+2, "nonr")==0) nonr = true;
- else if (strcmp(argv[i]+2, "nosh")==0) nosh = true;
- else if (strcmp(argv[i]+2, "lomem")==0) lomem = 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) battledebug = false;
- else if (strcmp(argv[i]+2, "crabsolute")==0) opt_cr_absolute_coords = true;
- else if (strcmp(argv[i]+2, "help")==0)
- return usage(argv[0], NULL);
- else
- return usage(argv[0], argv[i]);
- } else switch(argv[i][1]) {
- case 'o':
- g_reportdir = argv[++i];
- break;
- case 'd':
- g_datadir = argv[++i];
- break;
- case 'r':
- g_resourcedir = argv[++i];
- break;
- case 'b':
- g_basedir = argv[++i];
- break;
- case 'i':
- xmlfile = argv[++i];
- break;
- case 't':
- turn = atoi(argv[++i]);
- break;
- case 'f':
- firstx = atoi(argv[++i]);
- firsty = atoi(argv[++i]);
- break;
- case 'q':
- quiet = 1;
- break;
- case 'v':
- if (isubscription) {
- sql_print(("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;
- }
-}
-
-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
-main(int argc, char *argv[])
-{
- int i;
- char zText[MAX_PATH];
-
- sqlpatch = true;
- log_open("eressea.log");
- 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, "");
- setlocale(LC_NUMERIC, "C");
-#ifdef LOCALE_CHECK
- if (!locale_check()) {
- log_error(("The current locale is not suitable for international Eressea.\n"));
- return -1;
- }
-#endif
-#ifdef CRTDBG
- init_crtdbg();
-#endif
-#ifdef DMALLOC
- init_dmalloc();
-#endif
-
- if ((i=read_args(argc, argv))!=0) return i;
-
- printf(
- "version %d.%d\n"
- "turn %d.\n"
- "orders %s.\n",
- global.data_version / 10, global.data_version % 10, turn, orders);
-
- kernel_init();
- game_init();
-
- sprintf(zText, "%d", turn);
- i = readgame(zText, false);
- if (i!=0) return i;
-
- confirm_newbies();
- 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 BETA_CODE
- if (dungeonstyles) {
- struct dungeon * d = dungeonstyles;
- struct region * r = make_dungeon(d);
- make_dungeongate(findregion(0, 0), r, d);
- }
-#endif
- writepasswd();
-
- if (opt_reportonly) {
- reports();
- return 0;
- }
-
- if (g_writemap) {
- return crwritemap("world.cr");
- }
-
- if (turn == 0) rng_init((int)time(0));
- else rng_init(turn);
-
-
- if ((i = processturn(orders))!=0) {
- return i;
- }
-
-#ifdef CLEANUP_CODE
- game_done();
-#endif
- kernel_done();
- log_close();
- return 0;
-}
diff --git a/src/eressea/server.cpp b/src/eressea/server.cpp
index a44bfbbc1..ac6fbce43 100644
--- a/src/eressea/server.cpp
+++ b/src/eressea/server.cpp
@@ -180,7 +180,7 @@ static int
setup_signal_handler(void)
{
struct sigaction act;
-
+
act.sa_flags = SA_ONESHOT | SA_SIGINFO;
act.sa_sigaction = report_segfault;
sigfillset(&act.sa_mask);
@@ -243,7 +243,7 @@ game_init(void)
#endif
}
-static const struct {
+static const struct {
const char * name;
int (*func)(lua_State *);
} lualibs[] = {
@@ -380,22 +380,14 @@ usage(const char * prog, const char * arg)
static void
setLuaString(lua_State * luaState, const char * name, const char * value)
{
-#if LUABIND_BETA<7 || (LUABIND_BETA==7 && LUABIND_DEVEL<2)
- luabind::object g = luabind::get_globals(luaState);
-#else
luabind::object g = luabind::globals(luaState);
-#endif
g[name] = value;
}
static void
setLuaNumber(lua_State * luaState, const char * name, double value)
{
-#if LUABIND_BETA<7 || (LUABIND_BETA==7 && LUABIND_DEVEL<2)
- luabind::object g = luabind::get_globals(luaState);
-#else
luabind::object g = luabind::globals(luaState);
-#endif
g[name] = value;
}
@@ -582,7 +574,7 @@ main(int argc, char *argv[])
assert(towlower(0xC4)==0xE4);
if (lc_ctype) lc_ctype = strdup(lc_ctype);
if (lc_numeric) lc_numeric = strdup(lc_numeric);
-
+
lua_State * luaState = lua_init();
global.vm_state = luaState;
load_inifile("eressea.ini");
@@ -609,7 +601,7 @@ main(int argc, char *argv[])
#endif
luabind::call_function(luaState, "dofile", buf);
#ifndef LUABIND_NO_EXCEPTIONS
- }
+ }
catch (std::runtime_error& rte) {
log_error(("%s.\n", rte.what()));
}
diff --git a/src/eressea/spells.c b/src/eressea/spells.c
deleted file mode 100644
index fe7d8a785..000000000
--- a/src/eressea/spells.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* vi: set ts=2:
- *
- *
- * Eressea PB(E)M host Copyright (C) 1998-2000
- * 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)
- *
- * This program may not be used, modified or distributed without
- * prior permission by the authors of Eressea.
- */
-
-#include
-#include
-
-#include
-
-void
-register_spells(void)
-{
- /* sp_summon_alp */
- init_alp();
-}
diff --git a/src/eressea/triggers.c b/src/eressea/triggers.c
deleted file mode 100644
index 85271bfa4..000000000
--- a/src/eressea/triggers.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* vi: set ts=2:
- *
- *
- * Eressea PB(E)M host Copyright (C) 1998-2000
- * 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)
- *
- * This program may not be used, modified or distributed without
- * prior permission by the authors of Eressea.
- */
-
-/** module: eressea/triggers
- * Registration and setup of all the triggers that are used in an Eressea
- * world.
- */
-
-#include
-#include
-
-/* triggers includes */
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-/* util includes */
-#include
-
-/* libc includes */
-#include
-
-void
-init_triggers(void)
-{
- fprintf(stdout, "- registering triggers\n");
- tt_register(&tt_changefaction);
- tt_register(&tt_changerace);
- tt_register(&tt_createcurse);
- tt_register(&tt_createunit);
- tt_register(&tt_gate);
- tt_register(&tt_unguard);
- tt_register(&tt_giveitem);
- tt_register(&tt_killunit);
- tt_register(&tt_removecurse);
- tt_register(&tt_shock);
- tt_register(&tt_unitmessage);
- tt_register(&tt_timeout);
-}
diff --git a/src/eressea/triggers.h b/src/eressea/triggers.h
deleted file mode 100644
index 617174af0..000000000
--- a/src/eressea/triggers.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* vi: set ts=2:
- *
- *
- * Eressea PB(E)M host Copyright (C) 1998-2000
- * 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)
- *
- * This program may not be used, modified or distributed without
- * prior permission by the authors of Eressea.
- */
-
-void register_triggers(void);
diff --git a/src/lua.hpp b/src/lua.hpp
deleted file mode 100644
index 5ff75c612..000000000
--- a/src/lua.hpp
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include
-#include
-#include
-#ifdef __cplusplus
-}
-
-#ifndef LUABIND_BETA
-# include
-# if BOOST_VERSION < 103300
-# define LUABIND_BETA 7
-# define LUABIND_DEVEL 1
-# else
-# define LUABIND_BETA 7
-# define LUABIND_DEVEL 2
-# endif
-#endif
-
-#endif