- Wurmlöcher in externer Datei

- Neue Gebäude: Portal, Pavillion
- LUA-Erweiterungen:
  - Gebäude machen
  - Gebäude benennen
  - Gebäuden ein Skript zuweisen
This commit is contained in:
Enno Rehling 2004-07-10 12:00:21 +00:00
parent d783bf8bc7
commit d6f61b26f8
5 changed files with 190 additions and 40 deletions

View File

@ -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

View File

@ -4,6 +4,7 @@
// kernel includes
#include <building.h>
#include <region.h>
// lua includes
#include <lua.hpp>
@ -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<int>(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_<struct building>("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)
];
}

View File

@ -1,25 +1,33 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<strings>
<string name="newbie_info_1">
<text locale="de">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.</text>
</string>
<string name="newbie_info_2">
<text locale="de">Die ersten beiden Züge mußt du abgeben, sonst wird deine Partei sofort wieder gelöscht, um Karteileichen zu vermeiden.</text>
</string>
<string name="newbie_info_3">
<text locale="de">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.</text>
</string>
<string name="defaultorder">
<text locale="de">ARBEITE</text>
</string>
<string name="temple">
<text locale="de">Tempel</text>
<text locale="en">temple</text>
</string>
<string name="seaserpenthead">
<text locale="de">Seeschlangenkopf</text>
</string>
<string name="seaserpenthead_p">
<text locale="de">Seeschlangenköpfe</text>
</string>
<string name="newbie_info_1">
<text locale="de">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.</text>
</string>
<string name="newbie_info_2">
<text locale="de">Die ersten beiden Züge mußt du abgeben, sonst wird deine Partei sofort wieder gelöscht, um Karteileichen zu vermeiden.</text>
</string>
<string name="newbie_info_3">
<text locale="de">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.</text>
</string>
<string name="defaultorder">
<text locale="de">ARBEITE</text>
</string>
<string name="temple">
<text locale="de">Tempel</text>
<text locale="en">temple</text>
</string>
<string name="seaserpenthead">
<text locale="de">Seeschlangenkopf</text>
</string>
<string name="seaserpenthead_p">
<text locale="de">Seeschlangenköpfe</text>
</string>
<string name="pavilion">
<text locale="de">Pavillion</text>
<text locale="en">pavilion</text>
</string>
<string name="portal">
<text locale="de">Portal</text>
<text locale="en">portal</text>
</string>
</strings>

View File

@ -1,4 +1,7 @@
<?xml version="1.0"?>
<buildings>
<building name="temple" maxsize="50" maxcapacity="2" nobuild="yes" nodestroy="yes" unique="yes" auraregen="1.00" />
<building name="temple" maxsize="50" maxcapacity="2" nobuild="yes" nodestroy="yes" unique="yes" auraregen="1.00" />
<building name="wormhole" maxsize="4" capacity="1" maxcapacity="4" nobuild="yes" nodestroy="yes" unique="yes" />
<building name="portal" maxsize="2" capacity="1" maxcapacity="2" nobuild="yes" nodestroy="yes" unique="yes" />
<building name="pavilion" maxsize="2" capacity="1" maxcapacity="2" nobuild="yes" nodestroy="yes" unique="yes" />
</buildings>

View File

@ -6006,5 +6006,27 @@
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - $unit($target) is too heavy."</text>
</message>
<message name="heroes_maxed" section="errors">
<type>
<arg name="command" type="order"/>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="max" type="int"/>
<arg name="count" type="int"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - Die Partei hat bereits $int($count) von $int($max) Helden."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - The faction already has $int($count) of $int($max) heroes."</text>
</message>
<message name="heroes_race" section="errors">
<type>
<arg name="command" type="order"/>
<arg name="region" type="region"/>
<arg name="unit" type="unit"/>
<arg name="race" type="race"/>
</type>
<text locale="de">"$unit($unit) in $region($region): '$order($command)' - $race($race,0) können keine Helden erwählen."</text>
<text locale="en">"$unit($unit) in $region($region): '$order($command)' - $race($race,0) cannot be heroes."</text>
</message>
</messages>