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

This commit is contained in:
Enno Rehling 2018-11-29 16:22:05 +01:00
commit ed1cd367b1
6 changed files with 319 additions and 371 deletions

View file

@ -7,7 +7,7 @@
#ifndef ERESSEA_VERSION #ifndef ERESSEA_VERSION
/* the version number, if it was not passed to make with -D */ /* the version number, if it was not passed to make with -D */
#define ERESSEA_VERSION "3.18.0" #define ERESSEA_VERSION "3.19.0"
#endif #endif
const char *eressea_version(void) { const char *eressea_version(void) {

File diff suppressed because it is too large Load diff

View file

@ -106,12 +106,30 @@ static void test_report_region(CuTest *tc) {
rsettrees(r, 0, 1); rsettrees(r, 0, 1);
rsettrees(r, 1, 2); rsettrees(r, 1, 2);
rsettrees(r, 2, 3); rsettrees(r, 2, 3);
region_setname(r, "Hodor");
f = test_create_faction(NULL); f = test_create_faction(NULL);
f->locale = lang; f->locale = lang;
u = test_create_unit(f, r); u = test_create_unit(f, r);
set_level(u, SK_QUARRYING, 1); set_level(u, SK_QUARRYING, 1);
region_setname(r, "1234567890123456789012345678901234567890");
r->seen.mode = seen_travel;
report_region(&out, r, f);
out.api->rewind(out.handle);
len = out.api->read(out.handle, buf, sizeof(buf));
buf[len] = '\0';
CuAssertStrEquals(tc, "1234567890123456789012345678901234567890 (0,0) (durchgereist), Ebene, 3/2\nBlumen, 5 Bauern, 2 Silber, 7 Pferde.\n", buf);
out.api->rewind(out.handle);
region_setname(r, "12345678901234567890123456789012345678901234567890123456789012345678901234567890");
r->seen.mode = seen_travel;
report_region(&out, r, f);
out.api->rewind(out.handle);
len = out.api->read(out.handle, buf, sizeof(buf));
buf[len] = '\0';
CuAssertStrEquals(tc, "12345678901234567890123456789012345678901234567890123456789012345678901234567890\n(0,0) (durchgereist), Ebene, 3/2 Blumen, 5 Bauern, 2 Silber, 7 Pferde.\n", buf);
out.api->rewind(out.handle);
region_setname(r, "Hodor");
r->seen.mode = seen_travel; r->seen.mode = seen_travel;
report_region(&out, r, f); report_region(&out, r, f);
out.api->rewind(out.handle); out.api->rewind(out.handle);
@ -119,27 +137,40 @@ static void test_report_region(CuTest *tc) {
buf[len] = '\0'; buf[len] = '\0';
CuAssertStrEquals(tc, "Hodor (0,0) (durchgereist), Ebene, 3/2 Blumen, 5 Bauern, 2 Silber, 7 Pferde.\n", buf); CuAssertStrEquals(tc, "Hodor (0,0) (durchgereist), Ebene, 3/2 Blumen, 5 Bauern, 2 Silber, 7 Pferde.\n", buf);
r->seen.mode = seen_unit;
out.api->rewind(out.handle); out.api->rewind(out.handle);
r->seen.mode = seen_unit;
report_region(&out, r, f); report_region(&out, r, f);
out.api->rewind(out.handle); out.api->rewind(out.handle);
len = out.api->read(out.handle, buf, sizeof(buf)); len = out.api->read(out.handle, buf, sizeof(buf));
buf[len] = '\0'; buf[len] = '\0';
CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 135 Steine/1, 5 Bauern, 2 Silber, 7 Pferde.\n", buf); CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 135 Steine/1, 5 Bauern, 2 Silber, 7 Pferde.\n", buf);
out.api->rewind(out.handle);
r->resources->amount = 1; r->resources->amount = 1;
r->land->peasants = 1; r->land->peasants = 1;
r->land->horses = 1; r->land->horses = 1;
r->land->money = 1; r->land->money = 1;
r->seen.mode = seen_unit; r->seen.mode = seen_unit;
out.api->rewind(out.handle);
report_region(&out, r, f); report_region(&out, r, f);
out.api->rewind(out.handle); out.api->rewind(out.handle);
len = out.api->read(out.handle, buf, sizeof(buf)); len = out.api->read(out.handle, buf, sizeof(buf));
buf[len] = '\0'; buf[len] = '\0';
CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 1 Stein/1, 1 Bauer, 1 Silber, 1 Pferd.\n", buf); CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 3/2 Blumen, 1 Stein/1, 1 Bauer, 1 Silber, 1 Pferd.\n", buf);
r->land->peasants = 0;
r->land->horses = 0;
r->land->money = 0;
rsettrees(r, 0, 0);
rsettrees(r, 1, 0);
rsettrees(r, 2, 0);
out.api->rewind(out.handle);
report_region(&out, r, f);
out.api->rewind(out.handle);
len = out.api->read(out.handle, buf, sizeof(buf));
buf[len] = '\0';
CuAssertStrEquals(tc, "Hodor (0,0), Ebene, 1 Stein/1.\n", buf);
mstream_done(&out); mstream_done(&out);
test_teardown(); test_teardown();
} }

View file

@ -270,6 +270,16 @@ void sbs_init(struct sbstring *sbs, char *buffer, size_t size)
buffer[0] = '\0'; buffer[0] = '\0';
} }
void sbs_adopt(struct sbstring *sbs, char *buffer, size_t size)
{
size_t len = strlen(buffer);
assert(sbs);
assert(size > len);
sbs->begin = buffer;
sbs->size = size;
sbs->end = buffer + len;
}
void sbs_strncat(struct sbstring *sbs, const char *str, size_t size) void sbs_strncat(struct sbstring *sbs, const char *str, size_t size)
{ {
size_t len; size_t len;

View file

@ -50,6 +50,7 @@ extern "C" {
} sbstring; } sbstring;
void sbs_init(struct sbstring *sbs, char *buffer, size_t size); void sbs_init(struct sbstring *sbs, char *buffer, size_t size);
void sbs_adopt(struct sbstring *sbs, char *buffer, size_t size);
void sbs_strcat(struct sbstring *sbs, const char *str); void sbs_strcat(struct sbstring *sbs, const char *str);
void sbs_strncat(struct sbstring *sbs, const char *str, size_t size); void sbs_strncat(struct sbstring *sbs, const char *str, size_t size);
void sbs_strcpy(struct sbstring *sbs, const char *str); void sbs_strcpy(struct sbstring *sbs, const char *str);

View file

@ -157,6 +157,10 @@ static void test_sbstring(CuTest * tc)
CuAssertStrEquals(tc, "12345678901234", sbs.begin); CuAssertStrEquals(tc, "12345678901234", sbs.begin);
sbs_strncat(&sbs, "567890", 6); sbs_strncat(&sbs, "567890", 6);
CuAssertStrEquals(tc, "123456789012345", sbs.begin); CuAssertStrEquals(tc, "123456789012345", sbs.begin);
sbs_adopt(&sbs, buffer + 2, sizeof(buffer) - 2);
CuAssertStrEquals(tc, "3456789012345", sbs.begin);
CuAssertIntEquals(tc, 13, sbs_length(&sbs));
} }
static void test_sbs_strcat(CuTest * tc) static void test_sbs_strcat(CuTest * tc)