static void test_plane(CuTest *tc) { struct region *r; plane *pl; test_setup(); r = test_create_region(0, 0, NULL); CuAssertPtrEquals(tc, NULL, findplane(0, 0)); CuAssertPtrEquals(tc, NULL, getplane(r)); CuAssertIntEquals(tc, 0, getplaneid(r)); CuAssertPtrEquals(tc, NULL, getplanebyid(0)); CuAssertIntEquals(tc, 0, plane_center_x(0)); CuAssertIntEquals(tc, 0, plane_center_y(0)); CuAssertIntEquals(tc, 0, plane_width(0)); CuAssertIntEquals(tc, 0, plane_height(0)); CuAssertPtrEquals(tc, NULL, get_homeplane()); pl = create_new_plane(1, "Hell", 4, 8, 40, 80, 15); r = test_create_region(4, 40, 0); CuAssertIntEquals(tc, 15, pl->flags); CuAssertIntEquals(tc, 4, pl->minx); CuAssertIntEquals(tc, 8, pl->maxx); CuAssertIntEquals(tc, 40, pl->miny); CuAssertIntEquals(tc, 80, pl->maxy); CuAssertPtrEquals(tc, NULL, pl->attribs); CuAssertStrEquals(tc, "Hell", pl->name); CuAssertPtrEquals(tc, pl, findplane(4, 40)); CuAssertPtrEquals(tc, pl, getplane(r)); CuAssertPtrEquals(tc, pl, getplanebyid(1)); CuAssertIntEquals(tc, 1, getplaneid(r)); CuAssertIntEquals(tc, 6, plane_center_x(pl)); CuAssertIntEquals(tc, 60, plane_center_y(pl)); CuAssertIntEquals(tc, 5, plane_width(pl)); CuAssertIntEquals(tc, 41, plane_height(pl)); test_teardown(); }
void pln_arm(struct emp_qelem *list, int dist, char mission, struct ichrstr *ip) { struct emp_qelem *qp; struct emp_qelem *next; struct plist *plp; struct plnstr *pp; for (qp = list->q_forw; qp != list; qp = next) { next = qp->q_forw; plp = (struct plist *)qp; pp = &plp->plane; getplane(pp->pln_uid, pp); if ((pp->pln_flags & PLN_LAUNCHED) || pln_equip(plp, ip, mission) < 0) { emp_remque(qp); free(qp); continue; } pp->pln_flags |= PLN_LAUNCHED; pp->pln_mobil -= pln_mobcost(dist, pp, mission); putplane(pp->pln_uid, pp); pr("%s equipped\n", prplane(pp)); } }
static int enter_arena(unit * u, const item_type * itype, int amount, order * ord) { skill_t sk; region *r = u->region; unit *u2; int fee = u->faction->score / 5; unused(ord); unused(amount); unused(itype); if (fee > 2000) fee = 2000; if (getplane(r) == arena) return -1; if (u->number != 1 && enter_fail(u)) return -1; if (get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, fee) < fee && enter_fail(u)) return -1; for (sk = 0; sk != MAXSKILLS; ++sk) { if (get_level(u, sk) > 1 && enter_fail(u)) return -1; } for (u2 = r->units; u2; u2 = u2->next) if (u2->faction == u->faction) break; assert(!"not implemented"); /* for (res=0;res!=MAXRESOURCES;++res) if (res!=R_SILVER && res!=R_ARENA_GATE && (is_item(res) || is_herb(res) || is_potion(res))) { int x = get_resource(u, res); if (x) { if (u2) { change_resource(u2, res, x); change_resource(u, res, -x); } else if (enter_fail(u)) return -1; } } */ if (get_money(u) > fee) { if (u2) change_money(u2, get_money(u) - fee); else if (enter_fail(u)) return -1; } ADDMSG(&u->faction->msgs, msg_message("arena_enter_fail", "region unit", u->region, u)); use_pooled(u, itype->rtype, GET_SLACK | GET_RESERVE, 1); use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT, fee); set_money(u, 109); fset(u, UFL_ANON_FACTION); move_unit(u, start_region[rng_int() % 6], NULL); return 0; }
int nuke(void) { int nnukes, noff; struct nstr_item nstr; struct nukstr nuk; struct plnstr plane; if (!snxtitem(&nstr, EF_NUKE, player->argp[1], NULL)) return RET_SYN; nnukes = noff = 0; while (nxtitem(&nstr, &nuk)) { if (!player->owner || nuk.nuk_own == 0) continue; if (nnukes++ == 0) { if (player->god) pr("own "); pr(" # nuke type x,y s eff tech carry burst\n"); } if (nuk.nuk_off) noff++; if (player->god) pr("%-3d ", nuk.nuk_own); pr("%4d %-19.19s ", nstr.cur, nchr[(int)nuk.nuk_type].n_name); prxy("%4d,%-4d", nuk.nuk_x, nuk.nuk_y); pr(" %1.1s %c%3d%% %4d", &nuk.nuk_stockpile, nuk.nuk_off ? '!' : ' ', nuk.nuk_effic, nuk.nuk_tech); if (nuk.nuk_plane >= 0) { getplane(nuk.nuk_plane, &plane); pr("%5dP %s", nuk.nuk_plane, plane.pln_flags & PLN_AIRBURST ? " air" : "ground"); } pr("\n"); } if (nnukes == 0) { if (player->argp[1]) pr("%s: No nuke(s)\n", player->argp[1]); else pr("%s: No nuke(s)\n", ""); return RET_FAIL; } else { pr("%d nuke%s", nnukes, splur(nnukes)); if (noff) pr(", %d stopped (eff marked with !)", noff); pr("\n"); } return RET_OK; }
int sate(void) { static int sct_shp_or_lnd[] = { EF_SECTOR, EF_SHIP, EF_LAND, EF_BAD }; double tech; int pln_uid; struct plnstr plane; int type = EF_BAD; if (!player->argp[1] || !*player->argp[1] || !isdigit(*player->argp[1]) || (pln_uid = atoi(player->argp[1])) < 0) return RET_SYN; if (!getplane(pln_uid, &plane)) { pr("No such plane\n"); return RET_FAIL; } if (plane.pln_own != player->cnum && !player->god) { pr("You don't own plane #%d\n", pln_uid); return RET_FAIL; } if (!pln_is_in_orbit(&plane)) { pr("%s isn't in orbit\n", prplane(&plane)); return RET_FAIL; } if (plane.pln_mobil < plane_mob_max) { pr("%s doesn't have enough mobility (needs %d)\n", prplane(&plane), plane_mob_max); return RET_FAIL; } if (player->argp[2]) { type = ef_byname_from(player->argp[2], sct_shp_or_lnd); if (type < 0) { return RET_SYN; } } if (plchr[(int)plane.pln_type].pl_flags & P_S) pr("Satellite Spy Report:\n"); else pr("Satellite Map Report:\n"); pr("%s at ", prplane(&plane)); tech = techfact(plane.pln_tech, 20.0); return satmap(plane.pln_x, plane.pln_y, plane.pln_effic, (int)tech, plchr[(int)plane.pln_type].pl_flags, type); }
static void guardian_faction(plane * pl, int id) { region *r; faction *f = findfaction(id); if (!f) { f = calloc(1, sizeof(faction)); f->banner = _strdup("Sie dienen dem großen Wyrm"); f->passw = _strdup(itoa36(rng_int())); set_email(&f->email, "*****@*****.**"); f->name = _strdup("Igjarjuks Kundschafter"); f->race = new_race[RC_ILLUSION]; f->age = turn; f->locale = find_locale("de"); f->options = want(O_COMPRESS) | want(O_REPORT) | want(O_COMPUTER) | want(O_ADRESSEN) | want(O_DEBUG); f->no = id; addlist(&factions, f); fhash(f); } if (f->race != new_race[RC_ILLUSION]) { assert(!"guardian id vergeben"); exit(0); } f->lastorders = turn; f->alive = true; for (r = regions; r; r = r->next) if (getplane(r) == pl && rterrain(r) != T_FIREWALL) { unit *u; freset(r, RF_ENCOUNTER); for (u = r->units; u; u = u->next) { if (u->faction == f) break; } if (u) continue; u = createunit(r, f, 1, new_race[RC_GOBLIN]); set_string(&u->name, "Igjarjuks Auge"); set_item(u, I_RING_OF_INVISIBILITY, 1); set_order(&u->thisorder, NULL); fset(u, UFL_ANON_FACTION); set_money(u, 1000); } }