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"
msgstr "Ballon"
msgid "nr_schemes_postfix"
msgstr "sind erkennbar."
msgid "nr_schemes_template"
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"
msgstr "SILBER"
@ -4408,9 +4420,6 @@ msgstr "Magie"
msgid "see_lighthouse"
msgstr "vom Turm erblickt"
msgid "nr_schemes_prefix"
msgstr "Schemen der Regionen"
msgid "aoc_p"
msgstr "Katzenamulette"

View File

@ -444,9 +444,6 @@ msgctxt "spellinfo"
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."
msgid "nr_schemes_postfix"
msgstr "can be discerned."
msgid "SILBER"
msgstr "SILVER"
@ -3937,8 +3934,20 @@ msgstr "magic"
msgid "see_lighthouse"
msgstr "from lighthouse"
msgid "nr_schemes_prefix"
msgstr "Schemes of "
msgid "list_two"
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"
msgstr "amulets of the kitten"

View File

@ -71,6 +71,7 @@
#include <util/rng.h>
#include <util/strings.h>
#include <format.h>
#include <selist.h>
#include <filestream.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) {
char buf[4096];
sbstring sbs;
sbs_init(&sbs, buf, sizeof(buf));
if (r->seen.mode >= seen_unit && is_astral(r) &&
!is_cursed(r->attribs, &ct_astralblock)) {
/* Sonderbehandlung Teleport-Ebene */
region_list *rl = astralregions(r, inhabitable);
region_list *rl2;
region *rl[MAX_SCHEMES];
int num = get_astralregions(r, inhabitable, rl);
char buf[4096];
if (rl) {
/* this localization might not work for every language but is fine for de and en */
sbs_strcat(&sbs, LOC(f->locale, "nr_schemes_prefix"));
rl2 = rl;
while (rl2) {
if (num == 1) {
/* single region is easy */
region *rn = rl[0];
f_regionid(rn, f, buf, sizeof(buf));
}
else if (num > 1) {
int i;
char *rnames[MAX_SCHEMES];
for (i = 0; i != num; ++i) {
char rbuf[REPORTWIDTH];
f_regionid(rl2->data, f, rbuf, sizeof(rbuf));
sbs_strcat(&sbs, rbuf);
rl2 = rl2->next;
if (rl2) {
sbs_strcat(&sbs, ", ");
}
region *rn = rl[i];
f_regionid(rn, f, rbuf, sizeof(rbuf));
rnames[i] = str_strdup(rbuf);
}
sbs_strcat(&sbs,LOC(f->locale, "nr_schemes_postfix"));
free_regionlist(rl);
/* Schreibe Paragraphen */
report_list(f->locale, buf, sizeof(buf), num, rnames);
for (i = 0; i != num; ++i) {
free(rnames[i]);
}
}
if (num > 0) {
format_replace(LOC(f->locale, "nr_schemes_template"), "{0}", buf, buf, sizeof(buf));
newline(out);
paragraph(out, buf, 0, 0, 0);
}

View File

@ -22,7 +22,6 @@
#include <assert.h>
#define TE_CENTER 1000
#define TP_RADIUS 2
#define TP_DISTANCE 4
int real2tp(int rk)
@ -75,6 +74,33 @@ region_list *astralregions(const region * r, bool(*valid) (const region *))
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)
{
assert(!is_astral(r));

View File

@ -7,6 +7,8 @@
extern "C" {
#endif
#define TP_RADIUS 2 /* Radius von Schemen */
struct region;
struct region_list;
struct plane;
@ -20,6 +22,7 @@ extern "C" {
bool inhabitable(const struct region *r);
bool is_astral(const struct region *r);
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 spawn_braineaters(float chance);