diff --git a/src/common/gamecode/economy.c b/src/common/gamecode/economy.c index 07ff0b3ad..c49dc3d9f 100644 --- a/src/common/gamecode/economy.c +++ b/src/common/gamecode/economy.c @@ -841,20 +841,7 @@ gebaeude_stuerzt_ein(region * r, building * b) int opfer = 0; int road = 0; struct message * msg; - /* - "$building($crashed) stürzte ein.$if($road," Beim Einsturz wurde die halbe Straße vernichtet.","")$if($victims,"$int($victims) $if($eq($victims,1),"ist","sind"),"") zu beklagen." - */ - /* Falls Karawanserei, Damm oder Tunnel einstürzen, wird die schon - * gebaute Straße zur Hälfte vernichtet */ - for (d=0;d!=MAXDIRECTIONS;++d) if (rroad(r, d) > 0 && - (b->type == bt_find("caravan") || - b->type == bt_find("dam") || - b->type == bt_find("tunnel"))) - { - rsetroad(r, d, rroad(r, d) / 2); - road = 1; - } for (u = r->units; u; u = u->next) { if (u->building == b) { int loss = 0; @@ -873,6 +860,15 @@ gebaeude_stuerzt_ein(region * r, building * b) } } + /* Falls Karawanserei, Damm oder Tunnel einstürzen, wird die schon + * gebaute Straße zur Hälfte vernichtet */ + if (b->type == bt_find("caravan") || b->type == bt_find("dam") || b->type == bt_find("tunnel")) { + for (d=0;d!=MAXDIRECTIONS;++d) if (rroad(r, d) > 0) { + road = 1; + /* vernichtung findet erst in destroy_building statt! */ + break; + } + } msg = msg_message("buildingcrash", "region building opfer road", r, b, opfer, road); add_message(&r->msgs, msg); for (u=r->units; u; u=u->next) { diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index 142df4fa0..f38eff21a 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -469,16 +469,35 @@ void destroy_building(building * b) { unit *u; + direction_t d; + static const struct building_type * bt_caravan, * bt_dam, * bt_tunnel; + boolean init = false; - if(!bfindhash(b->no)) return; - for(u=b->region->units; u; u=u->next) { - if(u->building == b) leave(b->region, u); + if (!init) { + init = true; + bt_caravan = bt_find("caravan"); + bt_dam = bt_find("dam"); + bt_tunnel = bt_find("tunnel"); + } + + if (!bfindhash(b->no)) return; + for (u=b->region->units; u; u=u->next) { + if (u->building == b) leave(b->region, u); } b->size = 0; update_lighthouse(b); bunhash(b); + /* Falls Karawanserei, Damm oder Tunnel einstürzen, wird die schon + * gebaute Straße zur Hälfte vernichtet */ + if (b->type == bt_caravan || b->type == bt_dam || b->type == bt_tunnel) { + region * r = b->region; + for (d=0;d!=MAXDIRECTIONS;++d) if (rroad(r, d) > 0) { + rsetroad(r, d, rroad(r, d) / 2); + } + } + #if 0 /* Memoryleak. Aber ohne klappt das Rendern nicht! */ removelist(&b->region->buildings, b); #endif diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index 9c6e7e46a..94f0c651f 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -1366,42 +1366,42 @@ travel(unit * u, region * next, int flucht, region_list ** routep) ut = getunit(first, u->faction); if (ut) { boolean found = false; - if (get_keyword(ut->thisorder) == K_DRIVE - && !fval(ut, UFL_LONGACTION) && !LongHunger(ut)) { + if (get_keyword(ut->thisorder) == K_DRIVE) { + if (!fval(ut, UFL_LONGACTION) && !LongHunger(ut)) { init_tokens(ut->thisorder); skip_token(); u2 = getunit(first, ut->faction); - if(u2 == u) { + if (u2 == u) { found = true; add_message(&u->faction->msgs, new_message( u->faction, "transport%u:unit%u:target%r:start%r:end", u, ut, first, current)); - if(!(terrain[current->terrain].flags & WALK_INTO) - && get_item(ut, I_HORSE)) { - cmistake(u, u->thisorder, 67, MSG_MOVE); - cmistake(ut, ut->thisorder, 67, MSG_MOVE); - continue; - } - if (can_survive(ut, current)) { - travel_route(ut, ut->region, route); - move_unit(ut, current, NULL); - if (fval(ut, UFL_FOLLOWED) && route!=NULL) { - followers += notify_followers(first, ut, route); - } - } else { - cmistake(u, u->thisorder, 287, MSG_MOVE); - cmistake(ut, ut->thisorder, 230, MSG_MOVE); - continue; + if (!(terrain[current->terrain].flags & WALK_INTO) && get_item(ut, I_HORSE)) { + cmistake(u, u->thisorder, 67, MSG_MOVE); + cmistake(ut, ut->thisorder, 67, MSG_MOVE); + continue; + } + if (can_survive(ut, current)) { + travel_route(ut, ut->region, route); + move_unit(ut, current, NULL); + if (fval(ut, UFL_FOLLOWED) && route!=NULL) { + followers += notify_followers(first, ut, route); } + } else { + cmistake(u, u->thisorder, 287, MSG_MOVE); + cmistake(ut, ut->thisorder, 230, MSG_MOVE); + continue; + } } } - if (!found) { - if(cansee(u->faction, u->region, ut, 0)) { - cmistake(u, u->thisorder, 90, MSG_MOVE); - } else { - cmistake(u, u->thisorder, 63, MSG_MOVE); - } + } + if (!found) { + if (cansee(u->faction, u->region, ut, 0)) { + cmistake(u, u->thisorder, 90, MSG_MOVE); + } else { + cmistake(u, u->thisorder, 63, MSG_MOVE); } + } } else { if (ut) { cmistake(u, u->thisorder, 63, MSG_MOVE);