forked from github/server
DESTROY command will recycle materials again (but only when building/ship is completely destroyed).
This commit is contained in:
parent
31bcc1030a
commit
e2c06c8b46
|
@ -343,10 +343,8 @@ destroy_cmd(unit * u, struct order * ord)
|
||||||
ship *sh;
|
ship *sh;
|
||||||
unit *u2;
|
unit *u2;
|
||||||
region * r = u->region;
|
region * r = u->region;
|
||||||
#if 0
|
|
||||||
const construction * con = NULL;
|
const construction * con = NULL;
|
||||||
int size = 0;
|
int size = 0;
|
||||||
#endif
|
|
||||||
const char *s;
|
const char *s;
|
||||||
int n = INT_MAX;
|
int n = INT_MAX;
|
||||||
|
|
||||||
|
@ -364,7 +362,7 @@ destroy_cmd(unit * u, struct order * ord)
|
||||||
|
|
||||||
if (s && *s) {
|
if (s && *s) {
|
||||||
n = atoi(s);
|
n = atoi(s);
|
||||||
if(n <= 0) {
|
if (n <= 0) {
|
||||||
cmistake(u, ord, 288, MSG_PRODUCE);
|
cmistake(u, ord, 288, MSG_PRODUCE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -383,17 +381,19 @@ destroy_cmd(unit * u, struct order * ord)
|
||||||
if (u->building) {
|
if (u->building) {
|
||||||
building *b = u->building;
|
building *b = u->building;
|
||||||
|
|
||||||
if(n >= b->size) {
|
if (n >= b->size) {
|
||||||
/* destroy completly */
|
/* destroy completly */
|
||||||
/* all units leave the building */
|
/* all units leave the building */
|
||||||
for (u2 = r->units; u2; u2 = u2->next)
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->building == b) {
|
if (u2->building == b) {
|
||||||
u2->building = 0;
|
u2->building = 0;
|
||||||
freset(u2, UFL_OWNER);
|
freset(u2, UFL_OWNER);
|
||||||
}
|
}
|
||||||
ADDMSG(&u->faction->msgs, msg_message("destroy",
|
}
|
||||||
"building unit", b, u));
|
ADDMSG(&u->faction->msgs, msg_message("destroy",
|
||||||
destroy_building(b);
|
"building unit", b, u));
|
||||||
|
con = b->type->construction;
|
||||||
|
destroy_building(b);
|
||||||
} else {
|
} else {
|
||||||
/* partial destroy */
|
/* partial destroy */
|
||||||
b->size -= n;
|
b->size -= n;
|
||||||
|
@ -408,17 +408,19 @@ destroy_cmd(unit * u, struct order * ord)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(n >= (sh->size*100)/sh->type->construction->maxsize) {
|
if (n >= (sh->size*100)/sh->type->construction->maxsize) {
|
||||||
/* destroy completly */
|
/* destroy completly */
|
||||||
/* all units leave the ship */
|
/* all units leave the ship */
|
||||||
for (u2 = r->units; u2; u2 = u2->next)
|
for (u2 = r->units; u2; u2 = u2->next) {
|
||||||
if (u2->ship == sh) {
|
if (u2->ship == sh) {
|
||||||
u2->ship = 0;
|
u2->ship = 0;
|
||||||
freset(u2, UFL_OWNER);
|
freset(u2, UFL_OWNER);
|
||||||
}
|
}
|
||||||
ADDMSG(&u->faction->msgs, msg_message("shipdestroy",
|
}
|
||||||
"unit region ship", u, r, sh));
|
ADDMSG(&u->faction->msgs, msg_message("shipdestroy",
|
||||||
destroy_ship(sh);
|
"unit region ship", u, r, sh));
|
||||||
|
con = sh->type->construction;
|
||||||
|
destroy_ship(sh);
|
||||||
} else {
|
} else {
|
||||||
/* partial destroy */
|
/* partial destroy */
|
||||||
sh->size -= (sh->type->construction->maxsize * n)/100;
|
sh->size -= (sh->type->construction->maxsize * n)/100;
|
||||||
|
@ -430,19 +432,17 @@ destroy_cmd(unit * u, struct order * ord)
|
||||||
unitname(u), u->faction->name, u->faction->email));
|
unitname(u), u->faction->name, u->faction->email));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Achtung: Nicht an ZERSTÖRE mit Punktangabe angepaßt! */
|
|
||||||
if (con) {
|
if (con) {
|
||||||
/* TODO: ZERSTÖRE - Man sollte alle Materialien zurückkriegen können: */
|
/* TODO: Nicht an ZERSTÖRE mit Punktangabe angepaßt! */
|
||||||
int c;
|
int c;
|
||||||
for (c=0;con->materials[c].number;++c) {
|
for (c=0;con->materials[c].number;++c) {
|
||||||
const requirement * rq = con->materials+c;
|
const requirement * rq = con->materials+c;
|
||||||
int recycle = (int)(rq->recycle * rq->number * size/con->reqsize);
|
int recycle = (int)(rq->recycle * rq->number * size/con->reqsize);
|
||||||
if (recycle)
|
if (recycle) {
|
||||||
change_resource(u, rq->rtype, recycle);
|
change_resource(u, rq->rtype, recycle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* ------------------------------------------------------------- */
|
/* ------------------------------------------------------------- */
|
||||||
|
|
Loading…
Reference in New Issue