Aussetzen von newfactions mit Allianzen

This commit is contained in:
Enno Rehling 2002-09-29 18:26:07 +00:00
parent b1ab3a0a91
commit aeda0730df
3 changed files with 36 additions and 0 deletions

View File

@ -258,6 +258,9 @@ autoseed(struct regionlist * rlist)
unit * u; unit * u;
while (*nfp!=nf) nfp=&(*nfp)->next; while (*nfp!=nf) nfp=&(*nfp)->next;
u = addplayer(seeds[i].region, nf->email, nf->password, nf->race, nf->lang); u = addplayer(seeds[i].region, nf->email, nf->password, nf->race, nf->lang);
#ifdef ALLIANCES
u->faction->alliance = nf->allies;
#endif
++numnewbies; ++numnewbies;
*nfp = nf->next; *nfp = nf->next;
free(nf); free(nf);
@ -355,6 +358,9 @@ mkisland(int nsize)
terraform(r, preferred_terrain(nextf->race)); terraform(r, preferred_terrain(nextf->race));
++isize; ++isize;
u = addplayer(r, nextf->email, nextf->password, nextf->race, nextf->lang); u = addplayer(r, nextf->email, nextf->password, nextf->race, nextf->lang);
#ifdef ALLIANCES
u->faction->alliance = nextf->allies;
#endif
/* remove duplicate email addresses */ /* remove duplicate email addresses */
nfp=&newfactions; nfp=&newfactions;

View File

@ -24,6 +24,9 @@ typedef struct newfaction {
const struct race * race; const struct race * race;
int bonus; int bonus;
boolean oldregions; boolean oldregions;
#ifdef ALLIANCES
struct alliance * allies;
#endif
} newfaction; } newfaction;
extern newfaction * newfactions; extern newfaction * newfactions;

View File

@ -31,6 +31,9 @@
#include <skill.h> #include <skill.h>
#include <unit.h> #include <unit.h>
/* modules */
#include <modules/alliance.h>
/* util includes */ /* util includes */
#include <base36.h> #include <base36.h>
#include <language.h> #include <language.h>
@ -285,6 +288,9 @@ seed_dropouts(void)
newfaction * nf = *nfp; newfaction * nf = *nfp;
if (nf->race==drop->race && !nf->bonus) { if (nf->race==drop->race && !nf->bonus) {
unit * u = addplayer(r, nf->email, nf->password, nf->race, nf->lang); unit * u = addplayer(r, nf->email, nf->password, nf->race, nf->lang);
#ifdef ALLIANCES
u->faction->alliance = nf->allies;
#endif
++numnewbies; ++numnewbies;
if (nf->bonus) give_latestart_bonus(r, u, nf->bonus); if (nf->bonus) give_latestart_bonus(r, u, nf->bonus);
found=true; found=true;
@ -312,8 +318,14 @@ read_newfactions(const char * filename)
char race[20], email[64], lang[8], password[16]; char race[20], email[64], lang[8], password[16];
newfaction *nf; newfaction *nf;
int bonus; int bonus;
#ifdef ALLIANCES
int alliance;
/* email;race;locale;startbonus;alliance */
if (fscanf(F, "%s %s %s %d %s %d", email, race, lang, &bonus, password, &alliance)<=0) break;
#else
/* email;race;locale;startbonus */ /* email;race;locale;startbonus */
if (fscanf(F, "%s %s %s %d %s", email, race, lang, &bonus, password)<=0) break; if (fscanf(F, "%s %s %s %d %s", email, race, lang, &bonus, password)<=0) break;
#endif
while (f) { while (f) {
if (strcmp(f->email, email)==0 && f->age==0) { if (strcmp(f->email, email)==0 && f->age==0) {
break; break;
@ -329,6 +341,17 @@ read_newfactions(const char * filename)
nf->email = strdup(email); nf->email = strdup(email);
nf->password = strdup(password); nf->password = strdup(password);
nf->race = rc_find(race); nf->race = rc_find(race);
#ifdef ALLIANCES
{
struct alliance * al = findalliance(alliance);
if (al==NULL) {
char zText[64];
sprintf(zText, "Allianz %d", alliance);
al = makealliance(alliance, zText);
}
nf->allies = al;
}
#endif
if (nf->race==NULL) nf->race = findrace(race, default_locale); if (nf->race==NULL) nf->race = findrace(race, default_locale);
nf->lang = find_locale(lang); nf->lang = find_locale(lang);
nf->bonus = bonus; nf->bonus = bonus;
@ -354,7 +377,11 @@ select_newfaction(const struct race * rc)
while (player) { while (player) {
if (rc==NULL || player->race==rc) { if (rc==NULL || player->race==rc) {
char str[80]; char str[80];
#ifdef ALLIANCES
snprintf(str, 70, "%s %d %s %s", player->bonus?"!":" ", player->allies?player->allies->id:0, locale_string(default_locale, rc_name(player->race, 0)), player->email);
#else
snprintf(str, 70, "%s %s %s", player->bonus?"!":" ", locale_string(default_locale, rc_name(player->race, 0)), player->email); snprintf(str, 70, "%s %s %s", player->bonus?"!":" ", locale_string(default_locale, rc_name(player->race, 0)), player->email);
#endif
insert_selection(iinsert, prev, strdup(str), (void*)player); insert_selection(iinsert, prev, strdup(str), (void*)player);
prev = *iinsert; prev = *iinsert;
iinsert = &prev->next; iinsert = &prev->next;