forked from github/server
repair units that are toads without a time-limit.
This commit is contained in:
parent
63799d823d
commit
80a907d78f
2 changed files with 29 additions and 2 deletions
|
@ -50,6 +50,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
/* attributes includes */
|
/* attributes includes */
|
||||||
#include <attributes/key.h>
|
#include <attributes/key.h>
|
||||||
|
#include <triggers/timeout.h>
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
|
@ -1391,6 +1392,31 @@ void writefaction(struct storage *store, const faction * f)
|
||||||
write_spells(f->spellbook, store);
|
write_spells(f->spellbook, store);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void repair_unit(unit * u) {
|
||||||
|
static const race * rctoad;
|
||||||
|
if (!rctoad) rctoad = rc_find("toad");
|
||||||
|
|
||||||
|
if (u->race==rctoad) {
|
||||||
|
int found = 0;
|
||||||
|
attrib * a = a_find(u->attribs, &at_eventhandler);
|
||||||
|
while (!found && a && a->type==&at_eventhandler) {
|
||||||
|
struct trigger ** tlist = get_triggers(a, "timer");
|
||||||
|
while (!found && tlist && *tlist) {
|
||||||
|
trigger * t = *tlist;
|
||||||
|
if (strcmp("changerace", t->type->name)==0) {
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
|
tlist = &t->next;
|
||||||
|
}
|
||||||
|
a = a->next;
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
u->race = u->faction->race;
|
||||||
|
log_warning(("This toad did not have a changerace trigger: %s\n", unitname(u)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int readgame(const char *filename, int mode, int backup)
|
int readgame(const char *filename, int mode, int backup)
|
||||||
{
|
{
|
||||||
int i, n, p;
|
int i, n, p;
|
||||||
|
@ -1616,6 +1642,7 @@ int readgame(const char *filename, int mode, int backup)
|
||||||
unit *u = read_unit(store);
|
unit *u = read_unit(store);
|
||||||
sc_mage *mage;
|
sc_mage *mage;
|
||||||
|
|
||||||
|
repair_unit(u);
|
||||||
assert(u->region == NULL);
|
assert(u->region == NULL);
|
||||||
u->region = r;
|
u->region = r;
|
||||||
*up = u;
|
*up = u;
|
||||||
|
|
|
@ -265,8 +265,8 @@ int a_read(struct storage *store, attrib ** attribs, void *owner)
|
||||||
{
|
{
|
||||||
int key, retval = AT_READ_OK;
|
int key, retval = AT_READ_OK;
|
||||||
char zText[128];
|
char zText[128];
|
||||||
strcpy(zText, "unknown");
|
|
||||||
|
zText[0] = 0;
|
||||||
key = -1;
|
key = -1;
|
||||||
store->r_tok_buf(store, zText, sizeof(zText));
|
store->r_tok_buf(store, zText, sizeof(zText));
|
||||||
if (strcmp(zText, "end") == 0)
|
if (strcmp(zText, "end") == 0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue