forked from github/server
fixing crashes from triggers
This commit is contained in:
parent
4988d0f425
commit
fe841cd3c0
7 changed files with 43 additions and 49 deletions
|
@ -46,7 +46,7 @@ clonedied_handle(trigger * t, void * data)
|
|||
{
|
||||
/* destroy the unit */
|
||||
unit * u = (unit*)t->data.v;
|
||||
if (u!=NULL) {
|
||||
if (u) {
|
||||
attrib *a = a_find(u->attribs, &at_clone);
|
||||
if(a) a_remove(&u->attribs, a);
|
||||
} else
|
||||
|
|
|
@ -65,20 +65,20 @@ createcurse_free(trigger * t)
|
|||
static int
|
||||
createcurse_handle(trigger * t, void * data)
|
||||
{
|
||||
/* call an event handler on createcurse.
|
||||
* data.v -> ( variant event, int timer )
|
||||
*/
|
||||
createcurse_data * td = (createcurse_data*)t->data.v;
|
||||
if (td->mage!=NULL && td->target!=NULL) {
|
||||
/* call an event handler on createcurse.
|
||||
* data.v -> ( variant event, int timer )
|
||||
*/
|
||||
createcurse_data * td = (createcurse_data*)t->data.v;
|
||||
if (td->mage && td->target && td->mage->number && td->target->number) {
|
||||
variant var;
|
||||
var.i = td->effect;
|
||||
create_curse(td->mage, &td->target->attribs,
|
||||
td->type, td->vigour, td->duration, var, td->men);
|
||||
} else {
|
||||
log_error(("could not perform createcurse::handle()\n"));
|
||||
}
|
||||
unused(data);
|
||||
return 0;
|
||||
create_curse(td->mage, &td->target->attribs,
|
||||
td->type, td->vigour, td->duration, var, td->men);
|
||||
} else {
|
||||
log_error(("could not perform createcurse::handle()\n"));
|
||||
}
|
||||
unused(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -44,7 +44,7 @@ gate_handle(trigger * t, void * data)
|
|||
struct building * b = gd->gate;
|
||||
struct region * r = gd->target;
|
||||
|
||||
if (b && r) {
|
||||
if (b && b->region && r) {
|
||||
unit ** up = &b->region->units;
|
||||
while (*up) {
|
||||
unit * u = *up;
|
||||
|
|
|
@ -58,17 +58,17 @@ giveitem_free(trigger * t)
|
|||
static int
|
||||
giveitem_handle(trigger * t, void * data)
|
||||
{
|
||||
/* call an event handler on giveitem.
|
||||
* data.v -> ( variant event, int timer )
|
||||
*/
|
||||
giveitem_data * td = (giveitem_data*)t->data.v;
|
||||
if (td->u!=NULL) {
|
||||
i_change(&td->u->items, td->itype, td->number);
|
||||
/* call an event handler on giveitem.
|
||||
* data.v -> ( variant event, int timer )
|
||||
*/
|
||||
giveitem_data * td = (giveitem_data*)t->data.v;
|
||||
if (td->u && td->u->number) {
|
||||
i_change(&td->u->items, td->itype, td->number);
|
||||
} else {
|
||||
log_error(("could not perform giveitem::handle()\n"));
|
||||
log_error(("could not perform giveitem::handle()\n"));
|
||||
}
|
||||
unused(data);
|
||||
return 0;
|
||||
unused(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -56,21 +56,19 @@ removecurse_free(trigger * t)
|
|||
static int
|
||||
removecurse_handle(trigger * t, void * data)
|
||||
{
|
||||
/* call an event handler on removecurse.
|
||||
* data.v -> ( variant event, int timer )
|
||||
*/
|
||||
removecurse_data * td = (removecurse_data*)t->data.v;
|
||||
if (td->curse!=NULL && td->target!=NULL) {
|
||||
attrib * a = a_select(td->target->attribs, td->curse, cmp_curse);
|
||||
if (a) {
|
||||
a_remove(&td->target->attribs, a);
|
||||
}
|
||||
else log_error(("could not perform removecurse::handle()\n"));
|
||||
} else {
|
||||
log_error(("could not perform removecurse::handle()\n"));
|
||||
}
|
||||
unused(data);
|
||||
return 0;
|
||||
/* call an event handler on removecurse.
|
||||
* data.v -> ( variant event, int timer )
|
||||
*/
|
||||
removecurse_data * td = (removecurse_data*)t->data.v;
|
||||
if (td->curse && td->target) {
|
||||
attrib * a = a_select(td->target->attribs, td->curse, cmp_curse);
|
||||
if (a) {
|
||||
a_remove(&td->target->attribs, a);
|
||||
}
|
||||
else log_error(("could not perform removecurse::handle()\n"));
|
||||
}
|
||||
unused(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -88,15 +88,13 @@ do_shock(unit *u, const char *reason)
|
|||
static int
|
||||
shock_handle(trigger * t, void * data)
|
||||
{
|
||||
/* destroy the unit */
|
||||
unit * u = (unit*)t->data.v;
|
||||
if (u!=NULL) {
|
||||
do_shock(u, "trigger");
|
||||
} else {
|
||||
log_error(("could not perform shock::handle()\n"));
|
||||
/* destroy the unit */
|
||||
unit * u = (unit*)t->data.v;
|
||||
if (u && u->number) {
|
||||
do_shock(u, "trigger");
|
||||
}
|
||||
unused(data);
|
||||
return 0;
|
||||
unused(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -63,11 +63,9 @@ unitmessage_handle(trigger * t, void * data)
|
|||
* data.v -> ( variant event, int timer )
|
||||
*/
|
||||
unitmessage_data * td = (unitmessage_data*)t->data.v;
|
||||
if (td->target!=NULL) {
|
||||
if (td->target && td->target->no) {
|
||||
struct faction * f = td->target->faction;
|
||||
addmessage(td->target->region, f, LOC(f->locale, td->string), td->type, td->level);
|
||||
} else {
|
||||
log_error(("could not perform unitmessage::handle()\n"));
|
||||
}
|
||||
unused(data);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue