Merge branch 'develop' of github.com:ennorehling/eressea into develop

This commit is contained in:
Enno Rehling 2019-09-21 22:17:06 +02:00
commit e4099bf17e
6 changed files with 93 additions and 31 deletions

2
clibs

@ -1 +1 @@
Subproject commit f8969f44de1ec413cfee82b23c9f4b3c32d49b56 Subproject commit abe774f70265de14ea7f5e530518ca130562a9c9

View File

@ -570,8 +570,20 @@ msgstr "Dieses Ritual, ausgeführt vor einem Kampf, verwirbelt die astralen Ener
msgid "balloon" msgid "balloon"
msgstr "Ballon" msgstr "Ballon"
msgid "nr_schemes_postfix" msgid "nr_schemes_template"
msgstr "sind erkennbar." msgstr "Schemen der Regionen {0} sind erkennbar."
msgid "list_two"
msgstr "{0} und {1}"
msgid "list_start"
msgstr "{0}, {1}"
msgid "list_middle"
msgstr "{0}, {1}"
msgid "list_end"
msgstr "{0} und {1}"
msgid "SILBER" msgid "SILBER"
msgstr "SILBER" msgstr "SILBER"
@ -4408,9 +4420,6 @@ msgstr "Magie"
msgid "see_lighthouse" msgid "see_lighthouse"
msgstr "vom Turm erblickt" msgstr "vom Turm erblickt"
msgid "nr_schemes_prefix"
msgstr "Schemen der Regionen"
msgid "aoc_p" msgid "aoc_p"
msgstr "Katzenamulette" msgstr "Katzenamulette"

View File

@ -444,9 +444,6 @@ msgctxt "spellinfo"
msgid "draigfumbleshield" msgid "draigfumbleshield"
msgstr "This ritual, performed before a battle, causes the astral energies on the battlefield to whirl and churn and thereby makes spellcasting more difficult for the enemy mages." msgstr "This ritual, performed before a battle, causes the astral energies on the battlefield to whirl and churn and thereby makes spellcasting more difficult for the enemy mages."
msgid "nr_schemes_postfix"
msgstr "can be discerned."
msgid "SILBER" msgid "SILBER"
msgstr "SILVER" msgstr "SILVER"
@ -3937,8 +3934,20 @@ msgstr "magic"
msgid "see_lighthouse" msgid "see_lighthouse"
msgstr "from lighthouse" msgstr "from lighthouse"
msgid "nr_schemes_prefix" msgid "list_two"
msgstr "Schemes of " msgstr "{0} and {1}"
msgid "list_start"
msgstr "{0}, {1}"
msgid "list_middle"
msgstr "{0}, {1}"
msgid "list_end"
msgstr "{0}, and {1}"
msgid "nr_schemes_template"
msgstr "Schemes of {0} can be discerned."
msgid "aoc_p" msgid "aoc_p"
msgstr "amulets of the kitten" msgstr "amulets of the kitten"

View File

@ -71,6 +71,7 @@
#include <util/rng.h> #include <util/rng.h>
#include <util/strings.h> #include <util/strings.h>
#include <format.h>
#include <selist.h> #include <selist.h>
#include <filestream.h> #include <filestream.h>
#include <stream.h> #include <stream.h>
@ -1053,33 +1054,47 @@ static void report_region_edges(struct stream *out, const region * r, faction *
} }
} }
char *report_list(const struct locale *lang, char *buffer, size_t len, int argc, const char **argv) {
const char *two = LOC(lang, "list_two");
const char *start = LOC(lang, "list_start");
const char *middle = LOC(lang, "list_middle");
const char *end = LOC(lang, "list_end");
return format_list(argc, argv, buffer, len, two, start, middle, end);
}
#define MAX_SCHEMES ((TP_RADIUS * 2 + 1) * (TP_RADIUS * 2 + 1) - 4)
static void report_region_schemes(struct stream *out, const region * r, faction * f) { static void report_region_schemes(struct stream *out, const region * r, faction * f) {
char buf[4096];
sbstring sbs;
sbs_init(&sbs, buf, sizeof(buf));
if (r->seen.mode >= seen_unit && is_astral(r) && if (r->seen.mode >= seen_unit && is_astral(r) &&
!is_cursed(r->attribs, &ct_astralblock)) { !is_cursed(r->attribs, &ct_astralblock)) {
/* Sonderbehandlung Teleport-Ebene */ /* Sonderbehandlung Teleport-Ebene */
region_list *rl = astralregions(r, inhabitable); region *rl[MAX_SCHEMES];
region_list *rl2; int num = get_astralregions(r, inhabitable, rl);
char buf[4096];
if (rl) { if (num == 1) {
/* this localization might not work for every language but is fine for de and en */ /* single region is easy */
sbs_strcat(&sbs, LOC(f->locale, "nr_schemes_prefix")); region *rn = rl[0];
rl2 = rl; f_regionid(rn, f, buf, sizeof(buf));
while (rl2) { }
else if (num > 1) {
int i;
char *rnames[MAX_SCHEMES];
for (i = 0; i != num; ++i) {
char rbuf[REPORTWIDTH]; char rbuf[REPORTWIDTH];
f_regionid(rl2->data, f, rbuf, sizeof(rbuf)); region *rn = rl[i];
sbs_strcat(&sbs, rbuf); f_regionid(rn, f, rbuf, sizeof(rbuf));
rl2 = rl2->next; rnames[i] = str_strdup(rbuf);
if (rl2) { }
sbs_strcat(&sbs, ", "); report_list(f->locale, buf, sizeof(buf), num, rnames);
for (i = 0; i != num; ++i) {
free(rnames[i]);
} }
} }
sbs_strcat(&sbs,LOC(f->locale, "nr_schemes_postfix")); if (num > 0) {
free_regionlist(rl); format_replace(LOC(f->locale, "nr_schemes_template"), "{0}", buf, buf, sizeof(buf));
/* Schreibe Paragraphen */
newline(out); newline(out);
paragraph(out, buf, 0, 0, 0); paragraph(out, buf, 0, 0, 0);
} }

View File

@ -22,7 +22,6 @@
#include <assert.h> #include <assert.h>
#define TE_CENTER 1000 #define TE_CENTER 1000
#define TP_RADIUS 2
#define TP_DISTANCE 4 #define TP_DISTANCE 4
int real2tp(int rk) int real2tp(int rk)
@ -75,6 +74,33 @@ region_list *astralregions(const region * r, bool(*valid) (const region *))
return rlist; return rlist;
} }
int get_astralregions(const region * r, bool(*valid) (const region *), region *result[])
{
assert(is_astral(r));
r = r_astral_to_standard(r);
if (r) {
int x, y, num = 0;
for (x = -TP_RADIUS; x <= +TP_RADIUS; ++x) {
for (y = -TP_RADIUS; y <= +TP_RADIUS; ++y) {
region *rn;
int dist = koor_distance(0, 0, x, y);
if (dist <= TP_RADIUS) {
int nx = r->x + x, ny = r->y + y;
pnormalize(&nx, &ny, rplane(r));
rn = findregion(nx, ny);
if (rn != NULL && (valid == NULL || valid(rn))) {
result[num++] = rn;
}
}
}
}
return num;
}
return 0;
}
region *r_standard_to_astral(const region * r) region *r_standard_to_astral(const region * r)
{ {
assert(!is_astral(r)); assert(!is_astral(r));

View File

@ -7,6 +7,8 @@
extern "C" { extern "C" {
#endif #endif
#define TP_RADIUS 2 /* Radius von Schemen */
struct region; struct region;
struct region_list; struct region_list;
struct plane; struct plane;
@ -20,6 +22,7 @@ extern "C" {
bool inhabitable(const struct region *r); bool inhabitable(const struct region *r);
bool is_astral(const struct region *r); bool is_astral(const struct region *r);
struct plane *get_astralplane(void); struct plane *get_astralplane(void);
int get_astralregions(const struct region * r, bool(*valid) (const struct region *), struct region *result[]);
void create_teleport_plane(void); void create_teleport_plane(void);
void spawn_braineaters(float chance); void spawn_braineaters(float chance);