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