forked from github/server
refactoring castorder, because it's a bit of a mess of units, fighters, familliars and casters.
This commit is contained in:
parent
6dcf6669c3
commit
02559f6869
|
@ -464,9 +464,10 @@ static void unit_castspell(unit * u, const char *name)
|
||||||
if (sp->sp_function == NULL) {
|
if (sp->sp_function == NULL) {
|
||||||
log_error(("spell '%s' has no function.\n", sp->sname));
|
log_error(("spell '%s' has no function.\n", sp->sname));
|
||||||
} else {
|
} else {
|
||||||
castorder *co = new_castorder(u, 0, sp, u->region, sp->level, sp->level, 0, 0, 0);
|
castorder co;
|
||||||
sp->sp_function(co);
|
create_castorder(&co, u, 0, sp, u->region, sp->level, sp->level, 0, 0, 0);
|
||||||
free(co);
|
sp->sp_function(&co);
|
||||||
|
free_castorder(&co);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2102,7 +2102,7 @@ castorder *new_castorder(void *u, unit * u2, const spell * sp, region * r,
|
||||||
{
|
{
|
||||||
castorder *corder;
|
castorder *corder;
|
||||||
|
|
||||||
corder = calloc(1, sizeof(castorder));
|
corder = (castorder*)calloc(1, sizeof(castorder));
|
||||||
corder->magician.u = u;
|
corder->magician.u = u;
|
||||||
corder->familiar = u2;
|
corder->familiar = u2;
|
||||||
corder->sp = sp;
|
corder->sp = sp;
|
||||||
|
@ -2116,6 +2116,29 @@ castorder *new_castorder(void *u, unit * u2, const spell * sp, region * r,
|
||||||
return corder;
|
return corder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
castorder *create_castorder(castorder * co, unit *caster, unit * familiar, const spell * sp, region * r,
|
||||||
|
int lev, double force, int range, struct order * ord, spellparameter * p)
|
||||||
|
{
|
||||||
|
if (!co) co = (castorder*)calloc(1, sizeof(castorder));
|
||||||
|
|
||||||
|
co->magician.u = caster;
|
||||||
|
co->familiar = familiar;
|
||||||
|
co->sp = sp;
|
||||||
|
co->level = lev;
|
||||||
|
co->force = force;
|
||||||
|
co->rt = r;
|
||||||
|
co->distance = range;
|
||||||
|
co->order = copy_order(ord);
|
||||||
|
co->par = p;
|
||||||
|
|
||||||
|
return co;
|
||||||
|
}
|
||||||
|
|
||||||
|
void free_castorder(struct castorder *co)
|
||||||
|
{
|
||||||
|
free_order(co->order);
|
||||||
|
}
|
||||||
|
|
||||||
/* Hänge c-order co an die letze c-order von cll an */
|
/* Hänge c-order co an die letze c-order von cll an */
|
||||||
void add_castorder(spellrank * cll, castorder * co)
|
void add_castorder(spellrank * cll, castorder * co)
|
||||||
{
|
{
|
||||||
|
|
|
@ -314,9 +314,13 @@ typedef struct sc_mage {
|
||||||
struct castorder **end;
|
struct castorder **end;
|
||||||
} spellrank;
|
} spellrank;
|
||||||
|
|
||||||
castorder *new_castorder(void *u, struct unit *familiar, const spell * sp,
|
struct castorder *new_castorder(void *u, struct unit *familiar, const spell * sp,
|
||||||
struct region *r, int lev, double force, int distance, struct order *ord,
|
struct region *r, int lev, double force, int distance, struct order *ord,
|
||||||
spellparameter * p);
|
spellparameter * p);
|
||||||
|
struct castorder *create_castorder(struct castorder * co, struct unit *caster,
|
||||||
|
struct unit * familiar, const struct spell * sp, struct region * r,
|
||||||
|
int lev, double force, int range, struct order * ord, struct spellparameter * p);
|
||||||
|
void free_castorder(struct castorder *co);
|
||||||
/* Zwischenspreicher für Zauberbefehle, notwendig für Prioritäten */
|
/* Zwischenspreicher für Zauberbefehle, notwendig für Prioritäten */
|
||||||
void add_castorder(struct spellrank *cll, struct castorder *co);
|
void add_castorder(struct spellrank *cll, struct castorder *co);
|
||||||
/* Hänge c-order co an die letze c-order von cll an */
|
/* Hänge c-order co an die letze c-order von cll an */
|
||||||
|
|
Loading…
Reference in New Issue