/************************************************************************** Creates the land/sea barbarian player and inits some stuff. If barbarian player already exists, return player pointer. If barbarians are dead, revive them with a new leader :-) Dead barbarians forget the map and lose the money. **************************************************************************/ static struct player *create_barbarian_player(enum barbarian_type type) { struct player *barbarians; struct nation_type *nation; players_iterate(barbarians) { if ((type == LAND_BARBARIAN && is_land_barbarian(barbarians)) || (type == SEA_BARBARIAN && is_sea_barbarian(barbarians))) { if (!barbarians->is_alive) { barbarians->economic.gold = 0; barbarians->is_alive = TRUE; player_status_reset(barbarians); /* Free old name so pick_random_player_name() can select it again. * This is needed in case ruleset defines just one leader for * barbarian nation. */ barbarians->name[0] = '\0'; sz_strlcpy(barbarians->name, pick_random_player_name(nation_of_player(barbarians))); sz_strlcpy(barbarians->username, ANON_USER_NAME); /* I need to make them to forget the map, I think */ whole_map_iterate(ptile) { map_clear_known(ptile, barbarians); } whole_map_iterate_end; } barbarians->economic.gold += 100; /* New leader, new money */ return barbarians; } } players_iterate_end;
/************************************************************************** Creates the land/sea barbarian player and inits some stuff. If barbarian player already exists, return player pointer. If barbarians are dead, revive them with a new leader :-) Dead barbarians forget the map and lose the money. **************************************************************************/ static struct player *create_barbarian_player(enum barbarian_type type) { struct player *barbarians; struct nation_type *nation; players_iterate(barbarians) { if ((type == LAND_BARBARIAN && is_land_barbarian(barbarians)) || (type == SEA_BARBARIAN && is_sea_barbarian(barbarians))) { if (!barbarians->is_alive) { barbarians->economic.gold = 0; barbarians->is_alive = TRUE; barbarians->is_dying = FALSE; pick_random_player_name(nation_of_player(barbarians), barbarians->name); sz_strlcpy(barbarians->username, ANON_USER_NAME); /* I need to make them to forget the map, I think */ whole_map_iterate(ptile) { map_clear_known(ptile, barbarians); } whole_map_iterate_end; } barbarians->economic.gold += 100; /* New leader, new money */ return barbarians; } } players_iterate_end;