wormhole:

- ageing happens to early, must do it in two steps
- set the size of the wormhole on creation
This commit is contained in:
Enno Rehling 2004-02-21 23:20:50 +00:00
parent 552e58d3a2
commit 90ac737d60

View file

@ -73,25 +73,30 @@ static int
wormhole_age(struct attrib * a) wormhole_age(struct attrib * a)
{ {
wormhole_data * data = (wormhole_data*)a->data.v; wormhole_data * data = (wormhole_data*)a->data.v;
region * r = data->entry->region; int maxtransport = data->entry->size;
unit * u = r->units;
int maxtransport = 4;
for (;u!=NULL && maxtransport!=0;u=u->next) { if (data->entry->size==0) {
message * m; destroy_building(data->entry);
if (u->number>maxtransport) continue; } else {
if (teure_talente(u)) continue; region * r = data->entry->region;
if (u->building!=data->entry) continue; unit * u = r->units;
move_unit(u, data->exit->region, NULL); for (;u!=NULL && maxtransport!=0;u=u->next) {
maxtransport -= u->number; message * m;
m = msg_message("wormhole_exit", "unit region", u, data->exit); if (u->number>maxtransport) continue;
add_message(&data->exit->region->msgs, m); if (teure_talente(u)) continue;
add_message(&u->faction->msgs, m); if (u->building!=data->entry) continue;
msg_release(m);
move_unit(u, data->exit->region, NULL);
maxtransport -= u->number;
m = msg_message("wormhole_exit", "unit region", u, data->exit);
add_message(&data->exit->region->msgs, m);
add_message(&u->faction->msgs, m);
msg_release(m);
}
data->entry->size = 0;
} }
destroy_building(data->entry);
/* age returns 0 if the attribute needs to be removed, !=0 otherwise */ /* age returns 0 if the attribute needs to be removed, !=0 otherwise */
return -1; return -1;
} }
@ -136,6 +141,8 @@ make_wormhole(region * r1, region * r2)
wormhole_data * d2 = (wormhole_data*)a2->data.v; wormhole_data * d2 = (wormhole_data*)a2->data.v;
d1->entry = d2->exit = b1; d1->entry = d2->exit = b1;
d2->entry = d1->exit = b2; d2->entry = d1->exit = b2;
b1->size = bt_wormhole.maxsize;
b2->size = bt_wormhole.maxsize;
ADDMSG(&r1->msgs, msg_message("wormhole_appear", "region", r1)); ADDMSG(&r1->msgs, msg_message("wormhole_appear", "region", r1));
ADDMSG(&r2->msgs, msg_message("wormhole_appear", "region", r2)); ADDMSG(&r2->msgs, msg_message("wormhole_appear", "region", r2));
} }