forked from github/server
commit
5b342f9b11
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "market.h"
|
#include "market.h"
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
#include <kernel/alliance.h>
|
#include <kernel/alliance.h>
|
||||||
#include <kernel/item.h>
|
#include <kernel/item.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
|
@ -94,7 +94,7 @@ static int count_demand(const region * r)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
recurse_regions(region * r, region_list ** rlist,
|
recurse_regions(region * r, region_list ** rlist,
|
||||||
bool(*fun) (const region * r))
|
bool(*fun) (const region * r))
|
||||||
{
|
{
|
||||||
if (!fun(r))
|
if (!fun(r))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -159,12 +159,13 @@ newfaction *read_newfactions(const char *filename)
|
||||||
if (sscanf(buf, "%54s %20s %8s %d %d %16s %d", email, race, lang, &bonus,
|
if (sscanf(buf, "%54s %20s %8s %d %d %16s %d", email, race, lang, &bonus,
|
||||||
&subscription, password, &alliance) < 3) {
|
&subscription, password, &alliance) < 3) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (email[0] == '#') {
|
if (email[0] == '#') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (email[0] == '\0')
|
if (email[0] == '\0') {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (password[0] == '\0') {
|
if (password[0] == '\0') {
|
||||||
size_t sz;
|
size_t sz;
|
||||||
sz = strlcpy(password, itoa36(rng_int()), sizeof(password));
|
sz = strlcpy(password, itoa36(rng_int()), sizeof(password));
|
||||||
|
@ -172,17 +173,22 @@ newfaction *read_newfactions(const char *filename)
|
||||||
}
|
}
|
||||||
for (f = factions; f; f = f->next) {
|
for (f = factions; f; f = f->next) {
|
||||||
if (strcmp(f->email, email) == 0 && f->subscription
|
if (strcmp(f->email, email) == 0 && f->subscription
|
||||||
&& f->age < MINAGE_MULTI)
|
&& f->age < MINAGE_MULTI) {
|
||||||
|
log_warning("email %s already in use by %s", email, factionname(f));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (f && f->units)
|
if (f && f->units)
|
||||||
continue; /* skip the ones we've already got */
|
continue; /* skip the ones we've already got */
|
||||||
for (nf = newfactions; nf; nf = nf->next) {
|
for (nf = newfactions; nf; nf = nf->next) {
|
||||||
if (strcmp(nf->email, email) == 0)
|
if (strcmp(nf->email, email) == 0) {
|
||||||
|
log_warning("duplicate new faction %s", email);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (nf)
|
if (nf) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
nf = calloc(sizeof(newfaction), 1);
|
nf = calloc(sizeof(newfaction), 1);
|
||||||
if (set_email(&nf->email, email) != 0) {
|
if (set_email(&nf->email, email) != 0) {
|
||||||
log_error("Invalid email address for subscription %s: %s\n", itoa36(subscription), email);
|
log_error("Invalid email address for subscription %s: %s\n", itoa36(subscription), email);
|
||||||
|
@ -782,7 +788,7 @@ const terrain_type *random_terrain_e3(direction_t dir)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
random_neighbours(region * r, region_list ** rlist,
|
random_neighbours(region * r, region_list ** rlist,
|
||||||
const terrain_type * (*terraformer) (direction_t), int n)
|
const terrain_type * (*terraformer) (direction_t), int n)
|
||||||
{
|
{
|
||||||
int nsize = 0;
|
int nsize = 0;
|
||||||
direction_t dir;
|
direction_t dir;
|
||||||
|
@ -935,7 +941,7 @@ int build_island_e3(int x, int y, int minsize, newfaction ** players, int numfac
|
||||||
fset(r, RF_MARK);
|
fset(r, RF_MARK);
|
||||||
if (r->land) {
|
if (r->land) {
|
||||||
if (nsize < minsize) {
|
if (nsize < minsize) {
|
||||||
nsize += random_neighbours(r, &rlist, &random_terrain_e3, minsize-nsize);
|
nsize += random_neighbours(r, &rlist, &random_terrain_e3, minsize - nsize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nsize += random_neighbours(r, &rlist, &get_ocean, minsize - nsize);
|
nsize += random_neighbours(r, &rlist, &get_ocean, minsize - nsize);
|
||||||
|
@ -993,7 +999,7 @@ int build_island_e3(int x, int y, int minsize, newfaction ** players, int numfac
|
||||||
rsetmoney(r, 50000); /* 2% = 1000 silver */
|
rsetmoney(r, 50000); /* 2% = 1000 silver */
|
||||||
}
|
}
|
||||||
else if (r->land) {
|
else if (r->land) {
|
||||||
rsetmoney(r, rmoney(r) *4);
|
rsetmoney(r, rmoney(r) * 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nfactions;
|
return nfactions;
|
||||||
|
|
Loading…
Reference in New Issue