forked from github/server
fix smurfication, properly now.
This commit is contained in:
parent
a1d59b99cb
commit
da7725e58f
|
@ -105,11 +105,6 @@ int handle_triggers(trigger ** triggers, void *param)
|
|||
** at_eventhandler
|
||||
**/
|
||||
|
||||
typedef struct handler_info {
|
||||
char *event;
|
||||
trigger *triggers;
|
||||
} handler_info;
|
||||
|
||||
static void init_handler(variant *var)
|
||||
{
|
||||
var->v = calloc(1, sizeof(handler_info));
|
||||
|
|
|
@ -37,6 +37,11 @@ extern "C" {
|
|||
variant data;
|
||||
} event_arg;
|
||||
|
||||
typedef struct handler_info {
|
||||
char *event;
|
||||
trigger *triggers;
|
||||
} handler_info;
|
||||
|
||||
trigger *t_new(trigger_type * ttype);
|
||||
void t_free(trigger * t);
|
||||
void t_add(trigger ** tlist, trigger * t);
|
||||
|
|
|
@ -374,6 +374,26 @@ static void write_skills(gamedata *data, const unit *u) {
|
|||
}
|
||||
}
|
||||
|
||||
static void fix_smurfication(unit *u) {
|
||||
if (u->attribs) {
|
||||
attrib *a;
|
||||
for (a = a_find(u->attribs, &at_eventhandler); a && a->type == &at_eventhandler; a = a->next) {
|
||||
handler_info *info = (handler_info *)a->data.v;
|
||||
if (0 == strcmp("timer", info->event)) {
|
||||
trigger *t;
|
||||
for (t = info->triggers; t; t = t->next) {
|
||||
if (t->type == &tt_changerace) {
|
||||
/* is a smurf, but will change back */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
log_error("%s was a %s in a %s faction", unitname(u), u->_race->_name, u->faction->race->_name);
|
||||
u->_race = u->faction->race;
|
||||
}
|
||||
|
||||
unit *read_unit(gamedata *data)
|
||||
{
|
||||
unit *u;
|
||||
|
@ -532,10 +552,7 @@ unit *read_unit(gamedata *data)
|
|||
if (rc_demon) {
|
||||
const struct race *rc = u_race(u);
|
||||
if (rc == rc_smurf) {
|
||||
if (!u->attribs) {
|
||||
log_error("%s was a %s in a %s faction", unitname(u), rc->_name, u->faction->race->_name);
|
||||
u->_race = u->faction->race;
|
||||
}
|
||||
fix_smurfication(u);
|
||||
}
|
||||
if (rc == rc_demon) {
|
||||
if (data->version < FIX_SHAPESHIFT_VERSION) {
|
||||
|
|
Loading…
Reference in New Issue