int prod_plane(int etus, int natnum, struct bp *bp, int buildem) /* Build = 1, maintain =0 */ { struct plnstr *pp; struct natstr *np; int n, k = 0; int start_money; for (n = 0; NULL != (pp = getplanep(n)); n++) { if (pp->pln_own == 0) continue; if (pp->pln_own != natnum) continue; if (pp->pln_effic < PLANE_MINEFF) { makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y); pp->pln_own = 0; continue; } if (pln_is_in_orbit(pp)) { if (!player->simulation && buildem == 0 && !(pp->pln_flags & PLN_SYNCHRONOUS)) move_sat(pp); continue; } np = getnatp(pp->pln_own); start_money = np->nat_money; upd_plane(pp, etus, np, bp, buildem); air_money[pp->pln_own] += np->nat_money - start_money; if (buildem == 0 || np->nat_money != start_money) k++; if (player->simulation) np->nat_money = start_money; } return k; }
void user_move (void) { int i, sec, sec_start; piece_type_t n; piece_info_t *obj, *next_obj; int prod; /* * First we loop through objects to update the user's view * of the world and perform any other necessary processing. * We would like to have the world view up to date before * asking the user any questions. This means that we should * also scan through all cities before possibly asking the * user what to produce in each city. */ for (n = FIRST_OBJECT; n < NUM_OBJECTS; n++) for (obj = user_obj[n]; obj != NULL; obj = obj->piece_link.next) { obj->moved = 0; /* nothing moved yet */ scan (user_map, obj->loc); /* refresh user's view of world */ } /* produce new hardware */ for (i = 0; i < NUM_CITY; i++) if (city[i].owner == USER) { scan (user_map, city[i].loc); prod = city[i].prod; if (prod == NOPIECE) { /* need production? */ set_prod (&(city[i])); /* ask user what to produce */ } else if (city[i].work++ >= (long)piece_attr[prod].build_time) { info("City at %d has completed %s.", city[i].loc, piece_attr[prod].article); produce (&city[i]); /* produce should set object.moved to 0 */ } } /* move all satellites */ for (obj = user_obj[SATELLITE]; obj != NULL; obj = next_obj) { next_obj = obj->piece_link.next; move_sat (obj); } sec_start = cur_sector (); /* get currently displayed sector */ if (sec_start == -1) sec_start = 0; /* loop through sectors, moving every piece in the sector */ for (i = sec_start; i < sec_start + NUM_SECTORS; i++) { sec = i % NUM_SECTORS; sector_change (); /* allow screen to be redrawn */ for (n = FIRST_OBJECT; n < NUM_OBJECTS; n++) /* loop through obj lists */ for (obj = user_obj[move_order[n]]; obj != NULL; obj = next_obj) { /* loop through objs in list */ next_obj = obj->piece_link.next; if (!obj->moved) /* object not moved yet? */ if (loc_sector (obj->loc) == sec) /* object in sector? */ piece_move (obj); /* yup; move the object */ } if (cur_sector() == sec) { /* is sector displayed? */ print_sector_u (sec); /* make screen up-to-date */ } } if (save_movie) save_movie_screen (); }