- Schiffe können erzeugt und Einheiten zugewiesen werden.

Reichweiten-Bug (http://eressea.upb.de/mantis/view.php?id=339) evtl. gefixt, cap_route war evtl. einen zu lang.
This commit is contained in:
Enno Rehling 2004-12-22 22:02:31 +00:00
parent 7beb84acb4
commit e60e14930e
5 changed files with 87 additions and 28 deletions

View File

@ -1031,12 +1031,11 @@ cap_route(region * r, region_list * route, region_list * route_end, int speed)
region * next = iroute->data; region * next = iroute->data;
direction_t reldir = reldirection(current, next); direction_t reldir = reldirection(current, next);
iroute = iroute->next;
/* adjust the range of the unit */ /* adjust the range of the unit */
if (roadto(current, reldir)) moves -= BP_ROAD; if (roadto(current, reldir)) moves -= BP_ROAD;
else moves -= BP_NORMAL; else moves -= BP_NORMAL;
if (moves<0) break; if (moves<0) break;
iroute = iroute->next;
current = next; current = next;
} }
return iroute; return iroute;

View File

@ -2,6 +2,7 @@
#include <eressea.h> #include <eressea.h>
// kernel includes // kernel includes
#include <build.h>
#include <ship.h> #include <ship.h>
#include <region.h> #include <region.h>
@ -34,11 +35,21 @@ operator==(const ship& a, const ship& sh)
return a.no==sh.no; return a.no==sh.no;
} }
static ship *
add_ship(const char * sname, region& r)
{
const ship_type * stype = st_find(sname);
ship * sh = new_ship(stype, NULL, &r);
sh->size = stype->construction->maxsize;
return sh;
}
void void
bind_ship(lua_State * L) bind_ship(lua_State * L)
{ {
module(L)[ module(L)[
def("get_ship", &findship), def("get_ship", &findship),
def("add_ship", &add_ship),
class_<struct ship>("ship") class_<struct ship>("ship")
.def(self == ship()) .def(self == ship())

View File

@ -17,6 +17,7 @@
#include <kernel/order.h> #include <kernel/order.h>
#include <kernel/race.h> #include <kernel/race.h>
#include <kernel/region.h> #include <kernel/region.h>
#include <kernel/ship.h>
#include <kernel/skill.h> #include <kernel/skill.h>
#include <kernel/spell.h> #include <kernel/spell.h>
#include <kernel/unit.h> #include <kernel/unit.h>
@ -250,10 +251,29 @@ unit_getregion(const unit& u)
return u.region; return u.region;
} }
static void
unit_setship(unit& u, ship& s)
{
leave(u.region, &u);
if (u.region!=s.region) {
unit_setregion(u, *s.region);
}
u.ship = &s;
}
static ship *
unit_getship(const unit& u)
{
return u.ship;
}
static void static void
unit_setbuilding(unit& u, building& b) unit_setbuilding(unit& u, building& b)
{ {
leave(u.region, &u); leave(u.region, &u);
if (u.region!=b.region) {
unit_setregion(u, *b.region);
}
u.building = &b; u.building = &b;
} }
@ -538,6 +558,7 @@ bind_unit(lua_State * L)
.property("magic", &unit_getmagic, &unit_setmagic) .property("magic", &unit_getmagic, &unit_setmagic)
.property("aura", &unit_getaura, &unit_setaura) .property("aura", &unit_getaura, &unit_setaura)
.property("building", &unit_getbuilding, &unit_setbuilding) .property("building", &unit_getbuilding, &unit_setbuilding)
.property("ship", &unit_getship, &unit_setship)
.property("region", &unit_getregion, &unit_setregion) .property("region", &unit_getregion, &unit_setregion)
.property("is_familiar", &unit_isfamiliar) .property("is_familiar", &unit_isfamiliar)
.property("spells", &unit_spells, return_stl_iterator) .property("spells", &unit_spells, return_stl_iterator)

View File

@ -144,7 +144,7 @@ static int nowrite = 0;
static boolean g_writemap = false; static boolean g_writemap = false;
static boolean opt_reportonly = false; static boolean opt_reportonly = false;
static const char * luafile = "default.lua"; static const char * luafile = "default.lua";
static const char * script_path = NULL; static const char * script_path = "scripts";
struct settings global = { struct settings global = {
"Eressea", /* gamename */ "Eressea", /* gamename */

View File

@ -1,24 +1,20 @@
function test_sail() function mkunit(f, r, num)
r0 = terraform(0, 0, "plain") u = add_unit(f, r)
u.number = num
orcs = add_faction("enno@eressea.de", "orc", "de") u:add_item("money", num*10)
orcs.age = 20 return u
orc = add_unit(orcs, r0)
orc.number = 1
orc:add_item("speedsail", orc.number)
orc:clear_orders()
orc:add_order("NUMMER PARTEI orcs")
orc:add_order("NUMMER EINHEIT orc")
orc:add_order("BENENNE EINHEIT Orks")
orc:add_order("ZEIGEN \"Sonnensegel\"")
end end
function test_movement() function test_movement()
west = direction("west") west = direction("west")
east = direction("east") east = direction("east")
-- im westen ohne strassen
ocean = terraform(-3, 0, "ocean")
terraform(-2, 0, "plain")
terraform(-1, 0, "plain")
-- im osten mit strassen
r0 = terraform(0, 0, "plain") r0 = terraform(0, 0, "plain")
r1 = terraform(1, 0, "desert") r1 = terraform(1, 0, "desert")
r2 = terraform(2, 0, "glacier") r2 = terraform(2, 0, "glacier")
@ -37,18 +33,28 @@ function test_movement()
orcs = add_faction("enno@eressea.de", "orc", "de") orcs = add_faction("enno@eressea.de", "orc", "de")
orcs.age = 20 orcs.age = 20
orc = add_unit(orcs, r0)
orc.number = 10
orc:add_item("money", orc.number*10)
orc:add_item("horse", orc.number*3)
orc:set_skill("sk_riding", 10)
bugs = add_faction("enno@eressea.de", "insect", "de") bugs = add_faction("enno@eressea.de", "insect", "de")
bugs.age = 20 bugs.age = 20
bug = add_unit(bugs, r0) orc = mkunit(orcs, r0, 10)
bug.number = 1 orc:add_item("horse", orc.number*3)
bug:add_item("money", bug.number*10) orc:set_skill("sk_riding", 10)
foot = mkunit(orcs, r0, 1)
ship = add_ship("boat", r0)
sail = mkunit(orcs, r0, 1)
sail.ship = ship
bug = mkunit(bugs, r0, 1)
sail:clear_orders()
sail:add_order("NACH O")
sail:add_order("NUMMER EINHEIT saiL")
foot:clear_orders()
foot:add_order("ROUTE W W")
foot:add_order("NUMMER EINHEIT foot")
orc:clear_orders() orc:clear_orders()
orc:add_order("NUMMER PARTEI orcs") orc:add_order("NUMMER PARTEI orcs")
@ -93,6 +99,23 @@ function test_movement()
end end
function test_sail()
r0 = terraform(0, 0, "plain")
orcs = add_faction("enno@eressea.de", "orc", "de")
orcs.age = 20
orc = add_unit(orcs, r0)
orc.number = 1
orc:add_item("speedsail", orc.number)
orc:clear_orders()
orc:add_order("NUMMER PARTEI orcs")
orc:add_order("NUMMER EINHEIT orc")
orc:add_order("BENENNE EINHEIT Orks")
orc:add_order("ZEIGEN \"Sonnensegel\"")
end
function test_handler() function test_handler()
local function msg_handler(u, evt) local function msg_handler(u, evt)
@ -323,7 +346,12 @@ end
-- test_give() -- test_give()
-- test_write() -- test_write()
test_sail() -- test_sail()
-- write_game("../testg.txt")
-- read_game("../testg.txt")
test_movement()
run_scripts() run_scripts()
process_orders() process_orders()
write_reports() write_reports()