* mapper: parteien aus newfaction.<turn> einlesen. erkläre ich noch.

* PFLANZE repariert
* Kampfzaubernutzung von statusrow repariert
* Alte Orks sind keine playerrrace mehr.
* Auch Snotlinge, die Magie/Alchemie gelernt haben, aber noch T0 sind, werden konvertiert.
* Das Erstrundenpasswort erscheint im CR.
* Anzeige von Parteitarnung im CR repariert.
* mapper-makros auf pdcurses-kompatibilität angepasst.
* mapper: SeedPartei ('s') entfernt.
This commit is contained in:
Enno Rehling 2002-03-09 15:16:35 +00:00
parent 1d625d1683
commit bb0aa209e8
17 changed files with 286 additions and 314 deletions

View File

@ -562,14 +562,14 @@ cr_output_unit(FILE * F, const region * r,
fprintf(F, "%d;Partei\n", u->faction->no);
if (sf!=u->faction) fprintf(F, "%d;Verkleidung\n", sf->no);
if (fval(u, FL_PARTEITARNUNG))
fprintf(F, "%d;Parteitarnung\n", fval(u, FL_PARTEITARNUNG));
fprintf(F, "%d;Parteitarnung\n", i2b(fval(u, FL_PARTEITARNUNG)));
if (a_otherfaction)
fprintf(F, "%d;Anderepartei\n", a_otherfaction->data.i);
} else {
const attrib * a = a_find(u->attribs, &at_group);
if (fval(u, FL_PARTEITARNUNG)) {
/* faction info is hidden */
fprintf(F, "%d;Parteitarnung\n", fval(u, FL_PARTEITARNUNG));
fprintf(F, "%d;Parteitarnung\n", i2b(fval(u, FL_PARTEITARNUNG)));
} else {
/* other unit. show visible faction, not u->faction */
fprintf(F, "%d;Partei\n", sf->no);

View File

@ -2512,6 +2512,7 @@ plant(region *r, unit *u, int raw)
/* Skill prüfen */
skill = eff_skill(u, SK_HERBALISM, r);
htype = rherbtype(r);
if (skill < 6) {
add_message(&u->faction->msgs,
msg_error(u, findorder(u, u->thisorder), "plant_skills",
@ -2525,7 +2526,6 @@ plant(region *r, unit *u, int raw)
oldresourcetype[R_TREES]));
return;
}
htype = rherbtype(r);
n = new_get_pooled(u, htype->itype->rtype, GET_DEFAULT);
/* Kräuter prüfen */
if (n==0) {

View File

@ -2062,7 +2062,7 @@ set_passw(void)
if(!isalnum(*c)) pwok = false;
c++;
}
if(pwok == false) {
if (pwok == false) {
cmistake(u, S->s, 283, MSG_EVENT);
for(i=0; i<6; i++) pbuf[i] = (char)(97 + rand() % 26);
pbuf[6] = 0;

View File

@ -1871,6 +1871,10 @@ report(FILE *F, faction * f, const faction_list * addresses,
}
if (f->age <= 2) {
if (f->age <= 1) {
ADDMSG(&f->msgs, msg_message("changepasswd",
"value", gc_add(strdup(buf))));
}
RENDER(f, buf, sizeof(buf), ("newbie_password", "password", f->passw));
rnl(F);
centre(F, buf, true);

View File

@ -235,8 +235,8 @@ extern struct region * fleeregion(const struct unit * u);
extern boolean enemy (const struct side * a, const struct side * b);
extern struct troop select_corpse(struct battle * b, struct fighter * af);
extern fighter * make_fighter(struct battle * b, struct unit * u, boolean attack);
void flee(const troop dt);
void drain_exp(struct unit *u, int d);
extern int statusrow(int status);
extern void flee(const troop dt);
extern void drain_exp(struct unit *u, int d);
#endif

View File

@ -82,7 +82,7 @@ unused_faction_id(void)
}
unit *
addplayer(region *r, char *email, const struct race * frace, locale *loc)
addplayer(region *r, const char *email, const struct race * frace, const locale *loc)
{
int i;
unit *u;
@ -93,6 +93,7 @@ addplayer(region *r, char *email, const struct race * frace, locale *loc)
for (i = 0; i < 6; i++) buf[i] = (char) (97 + rand() % 26); buf[i] = 0;
set_string(&f->passw, buf);
for (i = 0; i < 6; i++) buf[i] = (char) (97 + rand() % 26); buf[i] = 0;
set_string(&f->override, buf);

View File

@ -30,7 +30,7 @@ typedef struct faction {
char *email;
char *passw;
char *override;
struct locale * locale;
const struct locale * locale;
int lastorders; /* enno: short? */
int age; /* enno: short? */
ursprung *ursprung;
@ -77,7 +77,7 @@ typedef struct faction_list {
extern const struct unit * random_unit_in_faction(const struct faction *f);
extern const char * factionname(const struct faction * f);
extern void * resolve_faction(void * data);
extern struct unit * addplayer(struct region *r, char *email, const struct race * frace, struct locale *loc);
extern struct unit * addplayer(struct region *r, const char *email, const struct race * frace, const struct locale *loc);
extern boolean checkpasswd(faction * f, const char * passwd);
#endif

View File

@ -8796,7 +8796,7 @@ spell spelldaten[] =
{SPL_WISPS, "Irrlichter",
"Der Zauberer spricht eine Beschwörung über einen Teil der Region, "
"und in der Folge entstehn dort Irrlichter. "
"und in der Folgewoche entstehen dort Irrlichter. "
"Wer durch diese Nebel wandert, wird von Visionen geplagt und "
"in die Irre geleitet.",
"ZAUBERE [REGION x y] [STUFE n] \"Irrlichter\" <Richtung>",

View File

@ -67,6 +67,7 @@
/* libc includes */
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
@ -2550,6 +2551,34 @@ peasant_adjustment(void)
return 0;
}
static int
orc_conversion2(void)
{
faction *f;
unit *u;
region *r;
for(f=factions; f; f=f->next) {
if(f->race == new_race[RC_ORC]) {
f->race = new_race[RC_URUK];
}
}
for(r=regions; r; r=r->next) {
for(u=r->units; u; u=u->next) {
if (u->race==new_race[RC_ORC] || u->race==new_race[RC_SNOTLING]) {
/* convert to either uruk or snotling */
if (has_skill(u, SK_MAGIC) || has_skill(u, SK_ALCHEMY)) {
u->race = new_race[RC_URUK];
u->irace = new_race[RC_URUK];
}
}
}
}
return 0;
}
static int
orc_conversion(void)
{
@ -2641,6 +2670,28 @@ fix_questcoors(void)
return 0;
}
static int
warn_password(void)
{
faction * f = factions;
while (f) {
boolean pwok = true;
const char * c = f->passw;
while (*c) {
if (!isalnum(*c)) pwok = false;
c++;
}
if (pwok == false) {
ADDMSG(&f->msgs, msg_message("msg_errors", "string",
"Dein Passwort enthält Zeichen, die bei der Nachsendung "
"von Reports Probleme bereiten können. Bitte wähle ein neues "
"Passwort, bevorzugt nur aus Buchstaben un Zahlen bestehend."));
}
f = f->next;
}
return 0;
}
static int
fix_seeds(void)
{
@ -2701,6 +2752,8 @@ korrektur(void)
do_once("heal", heal_all());
do_once("fquc", fix_questcoors());
do_once("fsee", fix_seeds());
do_once("orc2", orc_conversion2());
warn_password();
/* seems something fishy is going on, do this just
* to be on the safe side:

View File

@ -109,182 +109,6 @@ typedef struct island {
int age;
} island;
static region *
goodregion(int trace)
{
#define AGEGROUP 3 /* In diesem Alter wird zusammengefasst */
#define REGPERFAC 3 /* #Regionen pro faction auf einer insel */
region *r;
vmap *xmap = (vmap *) calloc(1, sizeof(vmap));
cvector islands;
void **i;
int maxage = 0;
island *best = 0;
int maxscore = 1000;
region *good = 0;
cv_init(&islands);
for (r = regions; r != 0; r = r->next) {
int x = (r->x + 999) / 9;
int y = (r->y + 999) / 9;
unsigned int xp = vmap_find(xmap, x);
if (xp == xmap->size) {
xp = vmap_insert(xmap, x, calloc(1, sizeof(vmap)));
} {
vmap *ymap = xmap->data[xp].value;
unsigned int yp = vmap_find(ymap, y);
island *is;
unit *u;
if (yp == ymap->size) {
is = calloc(1, sizeof(island));
is->x = x;
is->y = y;
cv_pushback(&islands, is);
yp = vmap_insert(ymap, y, is);
} else
is = ymap->data[yp].value;
if (rterrain(r) != T_OCEAN && rterrain(r) != T_GLACIER)
++is->land;
for (u = r->units; u != 0; u = u->next) {
faction *f = u->faction;
unsigned int pos = vmap_find(&is->factions, f->no);
if (pos == is->factions.size) {
int age = 1 + (f->age / AGEGROUP);
vmap_insert(&is->factions, f->no, f);
is->maxage = max(is->maxage, age);
is->age += age;
maxage = max(maxage, is->maxage);
}
}
}
}
for (i = islands.begin; i != islands.end; ++i) {
island *is = *i;
if (is->maxage > 6 || is->factions.size == 0)
continue;
if (is->land / REGPERFAC < is->factions.size)
continue;
if (is->age < maxscore) {
best = is;
maxscore = is->age;
}
}
if (!best) {
maxscore = 0;
for (i = islands.begin; i != islands.end; ++i) {
island *is = *i;
int x, y;
int score = 0;
if (is->land == 0 || is->age != 0)
continue;
/* insel leer. nachbarn zählen. */
for (x = is->x - 1; x <= is->x + 1; ++x) {
unsigned int p = vmap_find(xmap, x);
vmap *ymap;
if (p == xmap->size)
continue;
ymap = xmap->data[p].value;
for (y = is->y - 1; y <= is->y + 1; ++y) {
unsigned int p = vmap_find(ymap, y);
island *os;
if (p == ymap->size)
continue;
os = ymap->data[p].value;
if (os->age > 0)
score += maxage - os->maxage;
}
}
if (score > maxscore) {
maxscore = score;
best = is;
}
}
}
if (best) {
int a = best->x * 9 - 999;
int b = best->y * 9 - 999;
int x, y;
maxscore = 0;
for (x = a; x != a + 9; ++x) {
for (y = b; y != b + 9; ++y) {
region *r = findregion(x, y);
int score = 0;
if (r && r->units == 0 && rterrain(r) != T_OCEAN && rterrain(r) != T_GLACIER) {
direction_t con;
for (con = 0; con != MAXDIRECTIONS; ++con) {
region *c = rconnect(r, con);
if (!c || c->units == 0)
score += 2;
if (c && rterrain(c) != T_OCEAN)
++score;
}
if (score > maxscore) {
maxscore = score;
good = r;
}
}
}
}
}
/* cleanup */ {
void **i;
unsigned int x;
for (i = islands.begin; i != islands.end; ++i) {
free(*i);
}
for (x = 0; x != xmap->size; ++x) {
vmap *v = xmap->data[x].value;
free(v->data);
free(v);
}
free(xmap->data);
free(xmap);
}
return good;
}
region*
SeedPartei(void)
{
int i, q=0, y=3;
WINDOW *win;
race_t rc = 0;
do {
win = openwin(SX - 10, 6, "< Neue Partei einfügen >");
wmove(win, y, 4);
for (i = 1; i < MAXRACES; i++) if(playerrace(new_race[i]) && i != RC_ORC) {
sprintf(buf, "%d=%s; ", i, new_race[i]->_name[0]);
q += strlen(buf);
if (q > SX - 20) {
q = strlen(buf);
y++;
wmove(win, y, 4);
}
wAddstr(buf);
}
rc = (race_t) map_input(win, 2, 1, "Rasse", 0, MAXRACES-1, rc);
delwin(win);
} while(!playerrace(new_race[i]) || i == RC_ORC);
return goodregion(rc);
}
static int
days2level(int days)
{
@ -326,22 +150,92 @@ give_latestart_bonus(region *r, unit *u, int b)
}
}
static newfaction * newfactions;
void
read_newfactions(const char * filename)
{
FILE * F = fopen(filename, "r");
if (F==NULL) return;
for (;;) {
faction * f = factions;
char race[20], email[64], lang[8];
newfaction * nf;
int bonus;
/* email;race;locale;startbonus */
if (fscanf(F, "%s %s %s %d", email, race, lang, &bonus)<=0) break;
while (f) {
if (strcmp(f->email, email)==0 && f->age==0) {
break;
}
f = f->next;
}
if (f) continue; /* skip the ones we've already got */
nf = calloc(sizeof(newfaction), 1);
nf->email = strdup(email);
nf->race = rc_find(race);
nf->lang = find_locale(lang);
nf->bonus = bonus;
assert(nf->race && nf->email && nf->lang);
nf->next = newfactions;
newfactions = nf;
}
fclose(F);
}
newfaction *
select_newfaction(const struct race * rc)
{
selection *prev, *ilist = NULL, **iinsert;
selection *selected = NULL;
newfaction *player = newfactions;
if (!player) return NULL;
insert_selection(&ilist, NULL, strdup("new player"), NULL);
iinsert=&ilist->next;
prev = ilist;
while (player) {
if (rc==NULL || player->race==rc) {
char str[80];
snprintf(str, 70, "%s %s", locale_string(default_locale, rc_name(player->race, 0)), player->email);
insert_selection(iinsert, prev, strdup(str), (void*)player);
prev = *iinsert;
iinsert = &prev->next;
}
player=player->next;
}
selected = do_selection(ilist, "Partei", NULL, NULL);
if (selected==NULL) return NULL;
return (newfaction*)selected->data;
}
void
NeuePartei(region * r)
{
int i, q, y;
WINDOW *win;
char email[INPUT_BUFSIZE+1];
race_t frace;
newfaction * nf, **nfp;
const struct locale * lang;
const struct race * frace;
int late;
unit *u;
int locale_nr;
if (!r->land) {
warnung(0, "Ungeeignete Region! <Taste>");
return;
}
win = openwin(SX - 10, 12, "< Neue Partei einfügen >");
nf = select_newfaction(NULL);
if (nf!=NULL) {
frace = nf->race;
late = nf->bonus;
lang = nf->lang;
strcpy(email, nf->email);
} else {
int locale_nr;
WINDOW *win = openwin(SX - 10, 12, "< Neue Partei einfügen >");
strcpy(buf, my_input(win, 2, 1, "EMail-Adresse (Leer->Ende): ", NULL));
if (!buf[0]) {
@ -368,12 +262,13 @@ NeuePartei(region * r)
y++;
do {
frace = (char) map_input(win, 2, y, "Rasse", -1, MAXRACES-1, 0);
} while(!playerrace(new_race[frace]));
if(frace == -1) {
int nrace = (char) map_input(win, 2, y, "Rasse", -1, MAXRACES-1, 0);
if (nrace == -1) {
delwin(win);
return;
}
frace = new_race[nrace];
} while(!playerrace(frace));
y++;
late = (int) map_input(win, 2, y, "Startbonus", -1, 99, 0);
@ -381,7 +276,6 @@ NeuePartei(region * r)
delwin(win);
return;
}
i = 0; q = 0; y++;
wmove(win, y, 4);
while(locales[i] != NULL) {
@ -403,11 +297,22 @@ NeuePartei(region * r)
delwin(win);
return;
}
lang = find_locale(locales[locale_nr]);
delwin(win);
modified = 1;
}
u = addplayer(r, email, new_race[frace], find_locale(locales[locale_nr]));
/* remove duplicate email addresses */
nfp=&newfactions;
while (*nfp) {
newfaction * nf = *nfp;
if (strcmp(email, nf->email)==0) {
*nfp = nf->next;
}
else nfp = &nf->next;
}
modified = 1;
u = addplayer(r, email, frace, lang);
if(late) give_latestart_bonus(r, u, late);

View File

@ -264,6 +264,7 @@ insert_selection(selection ** p_sel, selection * prev, char * str, void * payloa
} else {
*p_sel = sel;
sel->prev = prev;
if (prev) sel->index=prev->index+1;
}
}

View File

@ -165,7 +165,7 @@ input_string(const char * text, char * result, size_t len) {
werase(wn);
wmove(wn, 0, 0);
wattron(wn, A_BOLD);
waddstr(wn, text);
waddstr(wn, (char*)text);
waddstr(wn, ": ");
echo();
curs_set(1);
@ -229,7 +229,6 @@ modify_items(unit * u)
return i_modif;
}
#if 0
char
modify_zauber(unit * u)
@ -339,6 +338,7 @@ modify_talente(unit * u, region * r)
{
int q, L;
item_t i;
skill_t sk;
unsigned char x;
char modif=0;
WINDOW *wn;
@ -355,12 +355,12 @@ modify_talente(unit * u, region * r)
wborder(wn, 0, 0, 0, 0, 0, 0, 0, 0);
wmove(wn, 0, 3);
waddnstr(wn, "< Talente >", -1);
for (i = 0; i < MAXSKILLS; i++) {
sprintf(buf, "%s %d", skillname(i, NULL), eff_skill(u, i, r));
TL[i] = strdup(buf);
for (sk = 0; sk != MAXSKILLS; ++sk) {
sprintf(buf, "%s %d", skillname(sk, NULL), eff_skill(u, sk, r));
TL[sk] = strdup(buf);
if (L > 10) {
wmove(wn, i + 1, 4);
waddnstr(wn, TL[i], -1);
wmove(wn, sk + 1, 4);
waddnstr(wn, TL[sk], -1);
}
}

View File

@ -1038,15 +1038,6 @@ movearound(int rx, int ry) {
RemovePartei();
ch = -9;
break;
case 's':
c = SeedPartei();
if (c) {
rx = c->x;
ry = c->y;
recalc_everything(&x, &y, &rx, &ry);
ch = -8;
}
break;
case 'P':
NeuePartei(r);
ch = -9;
@ -1523,6 +1514,10 @@ main(int argc, char *argv[])
sprintf(datafile, "%s/%d", datapath(), turn);
readgame(backup);
sprintf(buf, "%s/newfactions.%d", basepath(), turn);
read_newfactions(buf);
if (findfaction(MONSTER_FACTION)==NULL) {
makemonsters();
}

View File

@ -30,6 +30,7 @@
#endif
#endif
struct race;
typedef struct dbllist dbllist;
struct dbllist {
@ -42,6 +43,15 @@ typedef struct tagregion {
struct region *r;
} tagregion;
typedef struct newfaction {
struct newfaction * next;
const char * email;
const struct locale * lang;
const struct race * race;
int bonus;
boolean oldregions;
} newfaction;
extern tagregion *Tagged;
void saddstr(char *s);
@ -93,8 +103,8 @@ extern struct ship *clipship;
#define NL(S) adddbllist(&S," ")
#define wAddstr(x) waddnstr(win,x,-1)
#define Addstr(x) waddnstr(mywin,x,-1)
#define wAddstr(x) waddnstr(win, (NCURSES_CONST char*)x,-1)
#define Addstr(x) waddnstr(mywin, (NCURSES_CONST char*)x,-1)
#define Movexy(x,y) wmove(mywin,y,x)
#define movexy(x,y) move(y,x)
/* move(zeile, spalte) ist "verkehrt"... */
@ -121,6 +131,9 @@ struct selection * do_selection(struct selection * sel, const char * title, void
struct selection ** push_selection(struct selection ** p_sel, char * str, void * payload);
void insert_selection(struct selection ** p_sel, struct selection * prev, char * str, void * payload);
extern void read_newfactions(const char * filename);
#define sncat(b, s, size) strncat ((b), s, size - strlen (b))
#endif /* MAPPER_H */

View File

@ -4653,7 +4653,7 @@
</type>
<locale name="de">
<nr section="events">
<text>"Die Adresse wurde auf '$value' geändert."</text>
<text>"Die Reportadresse wurde auf ${value} geändert."</text>
</nr>
</locale>
</message>
@ -4664,7 +4664,7 @@
</type>
<locale name="de">
<nr section="events">
<text>"Das Passwort wurde auf '$value' geändert."</text>
<text>"Das Passwort für diese Partei lautet ${value}."</text>
</nr>
</locale>
</message>

View File

@ -3443,7 +3443,7 @@
</type>
<locale name="en">
<nr section="none">
<text>"The password has been changed to '$value'."</text>
<text>"The password of this faction is '$value'."</text>
</nr>
</locale>
</message>

View File

@ -1148,7 +1148,7 @@
<familiar race="demon"></familiar>
</race>
<race name="orc" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="50" maintenance="10" weight="1000" speed="1.000000" hp="24" ac="0" damage="1d5" unarmedattack="-2" unarmeddefense="-2" attackmodifier="0" defensemodifier="0" playerrace walk giveitem giveperson giveunit getitem equipment>
<race name="orc" magres="-0.050000" maxaura="1.000000" regaura="1.000000" recruitcost="50" maintenance="10" weight="1000" speed="1.000000" hp="24" ac="0" damage="1d5" unarmedattack="-2" unarmeddefense="-2" attackmodifier="0" defensemodifier="0" walk giveitem giveperson giveunit getitem equipment>
<ai splitsize="10000" attackrandom moverandom learn></ai>
<skill name="sk_alchemy" modifier="1"></skill>
<skill name="sk_mining" modifier="1"></skill>