Store fighters in a quicklist, not a cvector.

This commit is contained in:
Enno Rehling 2011-02-27 12:04:49 -08:00
parent e6f6061819
commit b40f3d19b0
3 changed files with 5 additions and 27 deletions

View File

@ -61,6 +61,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/log.h>
#include <util/os.h>
#include <util/parser.h>
#include <util/quicklist.h>
#include <util/rand.h>
#include <util/rng.h>
@ -1606,31 +1607,13 @@ select_opponent(battle * b, troop at, int mindist, int maxdist)
return dt;
}
/*
* Abfrage mit
*
* cvector *fgs=fighters(b,af,FIGHT_ROW,BEHIND_ROW, FS_HELP|FS_ENEMY);
* fighter *fig;
*
* Optional: Verwirbeln. Vorsicht: Aufwändig!
* v_scramble(fgs->begin, fgs->end);
*
* for (fig = fgs->begin; fig != fgs->end; ++fig) {
* fighter *df = *fig;
*
* }
*
* cv_kill(fgs); free(fgs); Nicht vergessen
*/
cvector *
quicklist *
fighters(battle *b, const side * vs, int minrow, int maxrow, int mask)
{
side * s;
cvector *fightervp = malloc(sizeof(cvector));
quicklist *fightervp = 0;
assert(vs!=NULL);
cv_init(fightervp);
for (s=b->sides;s!=b->sides+b->nsides;++s) {
fighter *fig;
@ -1647,7 +1630,7 @@ fighters(battle *b, const side * vs, int minrow, int maxrow, int mask)
for (fig = s->fighters; fig; fig = fig->next) {
int row = get_unitrow(fig, vs);
if (row >= minrow && row <= maxrow) {
cv_pushback(fightervp, fig);
ql_push(&fightervp, fig);
}
}
}

View File

@ -248,7 +248,7 @@ extern "C" {
extern void message_all(battle * b, struct message * m);
extern int hits(troop at, troop dt, weapon * awp);
extern void damage_building(struct battle *b, struct building *bldg, int damage_abs);
extern struct cvector * fighters(struct battle *b, const struct side * vs, int minrow, int maxrow, int mask);
extern struct quicklist * fighters(struct battle *b, const struct side * vs, int minrow, int maxrow, int mask);
extern int count_allies(const struct side * as, int minrow, int maxrow, int select, int allytype);
extern int get_unitrow(const struct fighter * af, const struct side * vs);
extern boolean helping(const struct side * as, const struct side * ds);

View File

@ -119,11 +119,6 @@ typedef struct resource_limit {
#define ENOSKILL -3;
#define EUNUSABLE -4;
typedef struct itemtype_list {
struct itemtype_list * next;
const struct item_type * type;
} itemtype_list;
typedef struct item_type {
resource_type * rtype;
/* --- constants --- */