forked from github/server
Merge pull request #696 from ennorehling/develop
BUG 2328: absolutely final changes for 3.12
This commit is contained in:
commit
4efe6f6a71
7 changed files with 69 additions and 52 deletions
|
@ -2,17 +2,18 @@
|
||||||
"calendar" : {
|
"calendar" : {
|
||||||
"months" : [
|
"months" : [
|
||||||
{ "storm" : 60, "season" : 2 },
|
{ "storm" : 60, "season" : 2 },
|
||||||
{ "storm" : 10, "season" : 2 },
|
|
||||||
|
|
||||||
{ "storm" : 60, "season" : 3 },
|
|
||||||
{ "storm" : 10, "season" : 3 },
|
{ "storm" : 10, "season" : 3 },
|
||||||
|
{ "storm" : 60, "season" : 3 },
|
||||||
|
|
||||||
|
{ "storm" : 10, "season" : 0 },
|
||||||
{ "storm" : 60, "season" : 0 },
|
{ "storm" : 60, "season" : 0 },
|
||||||
{ "storm" : 80, "season" : 0 },
|
{ "storm" : 80, "season" : 0 },
|
||||||
|
|
||||||
{ "storm" : 50, "season" : 1 },
|
{ "storm" : 50, "season" : 1 },
|
||||||
{ "storm" : 30, "season" : 1 },
|
{ "storm" : 30, "season" : 1 },
|
||||||
{ "storm" : 60, "season" : 1 }
|
|
||||||
|
{ "storm" : 60, "season" : 2 }
|
||||||
],
|
],
|
||||||
"weeks" : [
|
"weeks" : [
|
||||||
"firstweek", "secondweek", "thirdweek"
|
"firstweek", "secondweek", "thirdweek"
|
||||||
|
|
|
@ -404,3 +404,7 @@ function test_demonstealth()
|
||||||
desc = u:show()
|
desc = u:show()
|
||||||
assert_equal(nil, string.find(desc, "Drache"))
|
assert_equal(nil, string.find(desc, "Drache"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_calendar_season_2328()
|
||||||
|
assert_equal("fall", get_season(1026))
|
||||||
|
end
|
||||||
|
|
|
@ -75,15 +75,16 @@ static building_type *bt_find_i(const char *name)
|
||||||
if (match) {
|
if (match) {
|
||||||
cb_get_kv(match, &btype, sizeof(btype));
|
cb_get_kv(match, &btype, sizeof(btype));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
log_warning("st_find: could not find ship '%s'\n", name);
|
|
||||||
}
|
|
||||||
return btype;
|
return btype;
|
||||||
}
|
}
|
||||||
|
|
||||||
const building_type *bt_find(const char *name)
|
const building_type *bt_find(const char *name)
|
||||||
{
|
{
|
||||||
return bt_find_i(name);
|
building_type *btype = bt_find_i(name);
|
||||||
|
if (!btype) {
|
||||||
|
log_warning("bt_find: could not find building '%s'\n", name);
|
||||||
|
}
|
||||||
|
return btype;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bt_changes = 1;
|
static int bt_changes = 1;
|
||||||
|
|
|
@ -97,14 +97,15 @@ static ship_type *st_find_i(const char *name)
|
||||||
if (match) {
|
if (match) {
|
||||||
cb_get_kv(match, &st, sizeof(st));
|
cb_get_kv(match, &st, sizeof(st));
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
log_warning("st_find: could not find ship '%s'\n", name);
|
|
||||||
}
|
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ship_type *st_find(const char *name) {
|
const ship_type *st_find(const char *name) {
|
||||||
return st_find_i(name);
|
ship_type *st = st_find_i(name);
|
||||||
|
if (!st) {
|
||||||
|
log_warning("st_find: could not find ship '%s'\n", name);
|
||||||
|
}
|
||||||
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void st_register(ship_type *stype) {
|
static void st_register(ship_type *stype) {
|
||||||
|
|
|
@ -2390,6 +2390,7 @@ static void display_race(unit * u, const race * rc)
|
||||||
|
|
||||||
static void reshow_other(unit * u, struct order *ord, const char *s) {
|
static void reshow_other(unit * u, struct order *ord, const char *s) {
|
||||||
int err = 21;
|
int err = 21;
|
||||||
|
bool found = false;
|
||||||
|
|
||||||
if (s) {
|
if (s) {
|
||||||
const spell *sp = 0;
|
const spell *sp = 0;
|
||||||
|
@ -2426,7 +2427,7 @@ static void reshow_other(unit * u, struct order *ord, const char *s) {
|
||||||
else {
|
else {
|
||||||
display_item(u, itype);
|
display_item(u, itype);
|
||||||
}
|
}
|
||||||
return;
|
found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sp) {
|
if (sp) {
|
||||||
|
@ -2437,14 +2438,15 @@ static void reshow_other(unit * u, struct order *ord, const char *s) {
|
||||||
if (a != NULL) {
|
if (a != NULL) {
|
||||||
a_remove(&u->faction->attribs, a);
|
a_remove(&u->faction->attribs, a);
|
||||||
}
|
}
|
||||||
return;
|
found = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc && u_race(u) == rc) {
|
if (rc && u_race(u) == rc) {
|
||||||
display_race(u, rc);
|
display_race(u, rc);
|
||||||
return;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!found)
|
||||||
cmistake(u, ord, err, MSG_EVENT);
|
cmistake(u, ord, err, MSG_EVENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1363,42 +1363,6 @@ static void test_show_without_item(CuTest *tc)
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_show_elf(CuTest *tc) {
|
|
||||||
order *ord;
|
|
||||||
race * rc;
|
|
||||||
unit *u;
|
|
||||||
struct locale *loc;
|
|
||||||
message * msg;
|
|
||||||
|
|
||||||
test_setup();
|
|
||||||
|
|
||||||
mt_register(mt_new_va("msg_event", "string:string", 0));
|
|
||||||
rc = test_create_race("elf");
|
|
||||||
test_create_itemtype("elvenhorse");
|
|
||||||
|
|
||||||
loc = test_create_locale();
|
|
||||||
locale_setstring(loc, "elvenhorse", "Elfenpferd");
|
|
||||||
locale_setstring(loc, "elvenhorse_p", "Elfenpferde");
|
|
||||||
locale_setstring(loc, "race::elf_p", "Elfen");
|
|
||||||
locale_setstring(loc, "race::elf", "Elf");
|
|
||||||
init_locale(loc);
|
|
||||||
|
|
||||||
CuAssertPtrNotNull(tc, finditemtype("elf", loc));
|
|
||||||
CuAssertPtrNotNull(tc, findrace("elf", loc));
|
|
||||||
|
|
||||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
|
|
||||||
u->faction->locale = loc;
|
|
||||||
ord = create_order(K_RESHOW, loc, "Elf");
|
|
||||||
reshow_cmd(u, ord);
|
|
||||||
CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error36") == NULL);
|
|
||||||
msg = test_find_messagetype(u->faction->msgs, "msg_event");
|
|
||||||
CuAssertPtrNotNull(tc, msg);
|
|
||||||
CuAssertTrue(tc, memcmp("Elf:", msg->parameters[0].v, 4) == 0);
|
|
||||||
test_clear_messages(u->faction);
|
|
||||||
free_order(ord);
|
|
||||||
test_cleanup();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void test_show_race(CuTest *tc) {
|
static void test_show_race(CuTest *tc) {
|
||||||
order *ord;
|
order *ord;
|
||||||
race * rc;
|
race * rc;
|
||||||
|
@ -1440,6 +1404,48 @@ static void test_show_race(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_show_both(CuTest *tc) {
|
||||||
|
order *ord;
|
||||||
|
race * rc;
|
||||||
|
unit *u;
|
||||||
|
struct locale *loc;
|
||||||
|
message * msg;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
|
||||||
|
mt_register(mt_new_va("msg_event", "string:string", 0));
|
||||||
|
mt_register(mt_new_va("displayitem", "weight:int", "item:resource", "description:string", 0));
|
||||||
|
rc = test_create_race("elf");
|
||||||
|
test_create_itemtype("elvenhorse");
|
||||||
|
|
||||||
|
loc = get_or_create_locale("de");
|
||||||
|
locale_setstring(loc, "elvenhorse", "Elfenpferd");
|
||||||
|
locale_setstring(loc, "elvenhorse_p", "Elfenpferde");
|
||||||
|
locale_setstring(loc, "iteminfo::elvenhorse", "Hiyaa!");
|
||||||
|
locale_setstring(loc, "race::elf_p", "Elfen");
|
||||||
|
locale_setstring(loc, "race::elf", "Elf");
|
||||||
|
init_locale(loc);
|
||||||
|
|
||||||
|
CuAssertPtrNotNull(tc, finditemtype("elf", loc));
|
||||||
|
CuAssertPtrNotNull(tc, findrace("elf", loc));
|
||||||
|
|
||||||
|
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, 0));
|
||||||
|
u->faction->locale = loc;
|
||||||
|
i_change(&u->items, finditemtype("elfenpferd", loc), 1);
|
||||||
|
ord = create_order(K_RESHOW, loc, "Elf");
|
||||||
|
reshow_cmd(u, ord);
|
||||||
|
CuAssertTrue(tc, test_find_messagetype(u->faction->msgs, "error36") == NULL);
|
||||||
|
msg = test_find_messagetype(u->faction->msgs, "msg_event");
|
||||||
|
CuAssertPtrNotNull(tc, msg);
|
||||||
|
CuAssertTrue(tc, memcmp("Elf:", msg->parameters[0].v, 4) == 0);
|
||||||
|
msg = test_find_messagetype(u->faction->msgs, "displayitem");
|
||||||
|
CuAssertPtrNotNull(tc, msg);
|
||||||
|
CuAssertTrue(tc, memcmp("Hiyaa!", msg->parameters[2].v, 4) == 0);
|
||||||
|
test_clear_messages(u->faction);
|
||||||
|
free_order(ord);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_immigration(CuTest * tc)
|
static void test_immigration(CuTest * tc)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
|
@ -1607,8 +1613,8 @@ CuSuite *get_laws_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_name_building);
|
SUITE_ADD_TEST(suite, test_name_building);
|
||||||
SUITE_ADD_TEST(suite, test_name_ship);
|
SUITE_ADD_TEST(suite, test_name_ship);
|
||||||
SUITE_ADD_TEST(suite, test_show_without_item);
|
SUITE_ADD_TEST(suite, test_show_without_item);
|
||||||
SUITE_ADD_TEST(suite, test_show_elf);
|
|
||||||
SUITE_ADD_TEST(suite, test_show_race);
|
SUITE_ADD_TEST(suite, test_show_race);
|
||||||
|
SUITE_ADD_TEST(suite, test_show_both);
|
||||||
SUITE_ADD_TEST(suite, test_immigration);
|
SUITE_ADD_TEST(suite, test_immigration);
|
||||||
SUITE_ADD_TEST(suite, test_demon_hunger);
|
SUITE_ADD_TEST(suite, test_demon_hunger);
|
||||||
SUITE_ADD_TEST(suite, test_armedmen);
|
SUITE_ADD_TEST(suite, test_armedmen);
|
||||||
|
|
|
@ -15,11 +15,13 @@
|
||||||
#define NO_MKDIR
|
#define NO_MKDIR
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
#define _USE_MATH_DEFINES
|
#define _USE_MATH_DEFINES
|
||||||
|
#if _MSC_VER >= 1900
|
||||||
#pragma warning(disable: 4710 4820)
|
#pragma warning(disable: 4710 4820)
|
||||||
#pragma warning(disable: 4100) // unreferenced formal parameter
|
#pragma warning(disable: 4100) // unreferenced formal parameter
|
||||||
#pragma warning(disable: 4456) // declaration hides previous
|
#pragma warning(disable: 4456) // declaration hides previous
|
||||||
#pragma warning(disable: 4457) // declaration hides function parameter
|
#pragma warning(disable: 4457) // declaration hides function parameter
|
||||||
#pragma warning(disable: 4459) // declaration hides global
|
#pragma warning(disable: 4459) // declaration hides global
|
||||||
|
#endif
|
||||||
#else /* assume gcc */
|
#else /* assume gcc */
|
||||||
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
|
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
|
||||||
# define va_copy(a,b) __va_copy(a,b)
|
# define va_copy(a,b) __va_copy(a,b)
|
||||||
|
|
Loading…
Reference in a new issue