From d6f61b26f8f406018a3ceff22c393b4478bbb86b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 10 Jul 2004 12:00:21 +0000 Subject: [PATCH] =?UTF-8?q?-=20Wurml=C3=B6cher=20in=20externer=20Datei=20-?= =?UTF-8?q?=20Neue=20Geb=C3=A4ude:=20Portal,=20Pavillion=20-=20LUA-Erweite?= =?UTF-8?q?rungen:=20=20=20-=20Geb=C3=A4ude=20machen=20=20=20-=20Geb=C3=A4?= =?UTF-8?q?ude=20benennen=20=20=20-=20Geb=C3=A4uden=20ein=20Skript=20zuwei?= =?UTF-8?q?sen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/modules/wormhole.c | 25 +++---- src/eressea/lua/building.cpp | 126 ++++++++++++++++++++++++++++++++- src/res/eressea/de/strings.xml | 52 ++++++++------ src/res/eressea/temple.xml | 5 +- src/res/messages.xml | 22 ++++++ 5 files changed, 190 insertions(+), 40 deletions(-) diff --git a/src/common/modules/wormhole.c b/src/common/modules/wormhole.c index dab49ad1b..9d658e166 100644 --- a/src/common/modules/wormhole.c +++ b/src/common/modules/wormhole.c @@ -47,12 +47,6 @@ cmp_age(const void * v1, const void *v2) return 0; } -static building_type bt_wormhole = { - "wormhole", BTF_NOBUILD|BTF_UNIQUE|BTF_INDESTRUCTIBLE, - 1, 4, 4, - 0, 0, 0, 0.0 -}; - typedef struct wormhole_data { building * entry; building * exit; @@ -102,7 +96,7 @@ wormhole_age(struct attrib * a) return -1; } -void +static void wormhole_write(const struct attrib * a, FILE* F) { wormhole_data * data = (wormhole_data*)a->data.v; @@ -110,7 +104,7 @@ wormhole_write(const struct attrib * a, FILE* F) write_building_reference(data->exit, F); } -int +static int wormhole_read(struct attrib * a, FILE* F) { wormhole_data * data = (wormhole_data*)a->data.v; @@ -132,18 +126,18 @@ static attrib_type at_wormhole = { }; static void -make_wormhole(region * r1, region * r2) +make_wormhole(const building_type * bt_wormhole, region * r1, region * r2) { - building * b1 = new_building(&bt_wormhole, r1, NULL); - building * b2 = new_building(&bt_wormhole, r2, NULL); + building * b1 = new_building(bt_wormhole, r1, NULL); + building * b2 = new_building(bt_wormhole, r2, NULL); attrib * a1 = a_add(&b1->attribs, a_new(&at_wormhole)); attrib * a2 = a_add(&b2->attribs, a_new(&at_wormhole)); wormhole_data * d1 = (wormhole_data*)a1->data.v; wormhole_data * d2 = (wormhole_data*)a2->data.v; d1->entry = d2->exit = b1; d2->entry = d1->exit = b2; - b1->size = bt_wormhole.maxsize; - b2->size = bt_wormhole.maxsize; + b1->size = bt_wormhole->maxsize; + b2->size = bt_wormhole->maxsize; ADDMSG(&r1->msgs, msg_message("wormhole_appear", "region", r1)); ADDMSG(&r2->msgs, msg_message("wormhole_appear", "region", r2)); } @@ -152,11 +146,13 @@ void create_wormholes(void) { #define WORMHOLE_CHANCE 10000 + const building_type * bt_wormhole = bt_find("wormhole"); region_list *rptr, * rlist = NULL; region * r = regions; int i = 0, count = 0; region ** match; + if (bt_wormhole==NULL) return; /* * select a list of regions. we'll sort them by age later. */ @@ -185,14 +181,13 @@ create_wormholes(void) count /= 2; for (i=0;i!=count;++i) { - make_wormhole(match[i], match[i+count]); + make_wormhole(bt_wormhole, match[i], match[i+count]); } } void register_wormholes(void) { - bt_register(&bt_wormhole); at_register(&at_wormhole); } #endif diff --git a/src/eressea/lua/building.cpp b/src/eressea/lua/building.cpp index d862bd17e..c28ac0403 100644 --- a/src/eressea/lua/building.cpp +++ b/src/eressea/lua/building.cpp @@ -4,6 +4,7 @@ // kernel includes #include +#include // lua includes #include @@ -12,16 +13,137 @@ using namespace luabind; +static building * +add_building(region * r, const char * name) +{ + const building_type * btype = bt_find(name); + if (btype==NULL) return NULL; + return new_building(btype, r, NULL); +} + +typedef struct lcbuilding_data { + building * b; + char * fname; +} lcbuilding_data; + +static void +lc_init(struct attrib *a) +{ + a->data.v = calloc(1, sizeof(lcbuilding_data)); +} + +static void +lc_done(struct attrib *a) +{ + lcbuilding_data * data = (lcbuilding_data*)a->data.v; + if (data->fname) free(data->fname); + free(data); +} + +static int +lc_age(struct attrib * a) +{ + lua_State * L = (lua_State *)global.vm_state; + lcbuilding_data * data = (lcbuilding_data*)a->data.v; + const char * fname = data->fname; + building * b = data->b; + + assert(b!=NULL); + if (fname==NULL) return -1; + + luabind::object globals = luabind::get_globals(L); + if (globals.at(fname).type()!=LUA_TFUNCTION) return -1; + + return luabind::call_function(L, fname, *b); +} + +static void +lc_write(const struct attrib * a, FILE* F) +{ + lcbuilding_data * data = (lcbuilding_data*)a->data.v; + const char * fname = data->fname; + building * b = data->b; + + write_building_reference(b, F); + fwritestr(F, fname); +} + +static int +lc_read(struct attrib * a, FILE* F) +{ + char lbuf[256]; + lcbuilding_data * data = (lcbuilding_data*)a->data.v; + + read_building_reference(&data->b, F); + freadstr(F, lbuf, sizeof(lbuf)); + data->fname = strdup(lbuf); + return AT_READ_OK; +} + +attrib_type at_luacall_building = { + "lcbuilding", + lc_init, + lc_done, + lc_age, + lc_write, + lc_read, + ATF_UNIQUE +}; + +int +building_addeffect(building& b, const char * fname) +{ + lua_State * L = (lua_State *)global.vm_state; + + luabind::object globals = luabind::get_globals(L); + if (globals.at(fname).type()!=LUA_TFUNCTION) return -1; + + attrib * a = a_add(&b.attribs, a_new(&at_luacall_building)); + lcbuilding_data * data = (lcbuilding_data*)a->data.v; + data->b = &b; + data->fname = strdup(fname); + + return 0; +} + +static const char * +building_getinfo(const building& b) +{ + return b.display; +} + +static void +building_setinfo(building& b, const char * info) +{ + set_string(&b.display, info); +} + +static const char * +building_getname(const building& b) +{ + return b.name; +} + +static void +building_setname(building& b, const char * name) +{ + set_string(&b.name, name); +} + void bind_building(lua_State * L) { + at_register(&at_luacall_building); module(L)[ def("get_building", &findbuilding), + def("add_building", &add_building), class_("building") - .def_readonly("name", &building::name) + .property("name", &building_getname, &building_setname) + .def_readonly("region", &building::region) .def_readonly("id", &building::no) - .def_readonly("info", &building::display) + .property("info", &building_getinfo, &building_setinfo) .def_readwrite("size", &building::size) + .def("add_effect", &building_addeffect) ]; } diff --git a/src/res/eressea/de/strings.xml b/src/res/eressea/de/strings.xml index 3528fd1e1..627bfc674 100644 --- a/src/res/eressea/de/strings.xml +++ b/src/res/eressea/de/strings.xml @@ -1,25 +1,33 @@ - - Bitte denke daran, deine Befehle mit dem Betreff ERESSEA BEFEHLE an eressea-server@eressea.upb.de zu senden. Am besten, du verwendest die Befehlsvorlage am Ende des Reports. - - - Die ersten beiden Züge mußt du abgeben, sonst wird deine Partei sofort wieder gelöscht, um Karteileichen zu vermeiden. - - - Mit der ersten Auswertung bekommst du einen Computerreport, den du mit vielen der Tools auf http://eressea-pbem.de/download.html benutzen kannst. Wenn du ihn weiterhin bekommen willst, gib einer deiner Einheiten den Befehl OPTION COMPUTER. - - - ARBEITE - - - Tempel - temple - - - Seeschlangenkopf - - - Seeschlangenköpfe - + + Bitte denke daran, deine Befehle mit dem Betreff ERESSEA BEFEHLE an eressea-server@eressea.upb.de zu senden. Am besten, du verwendest die Befehlsvorlage am Ende des Reports. + + + Die ersten beiden Züge mußt du abgeben, sonst wird deine Partei sofort wieder gelöscht, um Karteileichen zu vermeiden. + + + Mit der ersten Auswertung bekommst du einen Computerreport, den du mit vielen der Tools auf http://eressea-pbem.de/download.html benutzen kannst. Wenn du ihn weiterhin bekommen willst, gib einer deiner Einheiten den Befehl OPTION COMPUTER. + + + ARBEITE + + + Tempel + temple + + + Seeschlangenkopf + + + Seeschlangenköpfe + + + Pavillion + pavilion + + + Portal + portal + diff --git a/src/res/eressea/temple.xml b/src/res/eressea/temple.xml index cc46b7c56..4f3c1b2bf 100644 --- a/src/res/eressea/temple.xml +++ b/src/res/eressea/temple.xml @@ -1,4 +1,7 @@ - + + + + diff --git a/src/res/messages.xml b/src/res/messages.xml index 4383eddf6..8888883f1 100644 --- a/src/res/messages.xml +++ b/src/res/messages.xml @@ -6006,5 +6006,27 @@ "$unit($unit) in $region($region): '$order($command)' - $unit($target) is too heavy." + + + + + + + + + "$unit($unit) in $region($region): '$order($command)' - Die Partei hat bereits $int($count) von $int($max) Helden." + "$unit($unit) in $region($region): '$order($command)' - The faction already has $int($count) of $int($max) heroes." + + + + + + + + + + "$unit($unit) in $region($region): '$order($command)' - $race($race,0) können keine Helden erwählen." + "$unit($unit) in $region($region): '$order($command)' - $race($race,0) cannot be heroes." +