forked from github/server
fallback for generating building/ship names in tests, when no translations are available
This commit is contained in:
parent
ad05ec8c53
commit
8cd99bf88c
3 changed files with 33 additions and 14 deletions
|
@ -1,5 +1,3 @@
|
||||||
#include <cutest/CuTest.h>
|
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "market.h"
|
#include "market.h"
|
||||||
#include "tests.h"
|
#include "tests.h"
|
||||||
|
@ -15,6 +13,9 @@
|
||||||
|
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
|
||||||
|
#include <cutest/CuTest.h>
|
||||||
|
#include <tests.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static void market_curse(CuTest * tc)
|
static void market_curse(CuTest * tc)
|
||||||
|
@ -33,7 +34,6 @@ static void market_curse(CuTest * tc)
|
||||||
luxury_type *lux = new_luxurytype(ltype, 0);
|
luxury_type *lux = new_luxurytype(ltype, 0);
|
||||||
building_type *btype;
|
building_type *btype;
|
||||||
race *rc = rc_add(rc_new("human"));
|
race *rc = rc_add(rc_new("human"));
|
||||||
struct locale *lang = make_locale("en");
|
|
||||||
|
|
||||||
free_gamedata();
|
free_gamedata();
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ static void market_curse(CuTest * tc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r = findregion(1, 1);
|
r = findregion(1, 1);
|
||||||
b = new_building(btype, r, lang);
|
b = test_create_building(r, btype);
|
||||||
b->flags |= BLD_WORKING;
|
b->flags |= BLD_WORKING;
|
||||||
b->size = b->type->maxsize;
|
b->size = b->type->maxsize;
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
|
#include <util/bsdstring.h>
|
||||||
#include <util/event.h>
|
#include <util/event.h>
|
||||||
#include <util/functions.h>
|
#include <util/functions.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
@ -452,6 +453,8 @@ building *new_building(const struct building_type * btype, region * r,
|
||||||
building *b = (building *) calloc(1, sizeof(building));
|
building *b = (building *) calloc(1, sizeof(building));
|
||||||
static boolean init_lighthouse = false;
|
static boolean init_lighthouse = false;
|
||||||
static const struct building_type *bt_lighthouse = 0;
|
static const struct building_type *bt_lighthouse = 0;
|
||||||
|
const char *bname = 0;
|
||||||
|
char buffer[32];
|
||||||
|
|
||||||
if (!init_lighthouse) {
|
if (!init_lighthouse) {
|
||||||
bt_lighthouse = bt_find("lighthouse");
|
bt_lighthouse = bt_find("lighthouse");
|
||||||
|
@ -471,15 +474,21 @@ building *new_building(const struct building_type * btype, region * r,
|
||||||
if (b->type == bt_lighthouse) {
|
if (b->type == bt_lighthouse) {
|
||||||
r->flags |= RF_LIGHTHOUSE;
|
r->flags |= RF_LIGHTHOUSE;
|
||||||
}
|
}
|
||||||
{
|
if (b->type->name) {
|
||||||
const char *bname;
|
bname = LOC(lang, buildingtype(btype, b, 0));
|
||||||
if (b->type->name == NULL) {
|
|
||||||
bname = LOC(lang, btype->_name);
|
|
||||||
} else {
|
|
||||||
bname = LOC(lang, buildingtype(btype, b, 0));
|
|
||||||
}
|
|
||||||
b->name = strdup(bname);
|
|
||||||
}
|
}
|
||||||
|
if (!bname) {
|
||||||
|
bname = LOC(lang, btype->_name);
|
||||||
|
}
|
||||||
|
if (!bname) {
|
||||||
|
bname = LOC(lang, parameters[P_GEBAEUDE]);
|
||||||
|
}
|
||||||
|
if (!bname) {
|
||||||
|
bname = parameters[P_GEBAEUDE];
|
||||||
|
}
|
||||||
|
assert(bname);
|
||||||
|
slprintf(buffer, sizeof(buffer), "%s %s", bname, buildingid(b));
|
||||||
|
b->name = strdup(bname);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
|
#include <util/bsdstring.h>
|
||||||
#include <util/event.h>
|
#include <util/event.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/lists.h>
|
#include <util/lists.h>
|
||||||
|
@ -165,8 +166,9 @@ static ship *deleted_ships;
|
||||||
|
|
||||||
ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
|
ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
|
||||||
{
|
{
|
||||||
static char buffer[7 + IDSIZE + 1];
|
static char buffer[32];
|
||||||
ship *sh = (ship *) calloc(1, sizeof(ship));
|
ship *sh = (ship *) calloc(1, sizeof(ship));
|
||||||
|
const char *sname = 0;
|
||||||
|
|
||||||
assert(stype);
|
assert(stype);
|
||||||
assert(r);
|
assert(r);
|
||||||
|
@ -175,7 +177,15 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
|
||||||
sh->type = stype;
|
sh->type = stype;
|
||||||
sh->region = r;
|
sh->region = r;
|
||||||
|
|
||||||
sprintf(buffer, "%s %s", LOC(lang, stype->name[0]), shipid(sh));
|
sname = LOC(lang, stype->name[0]);
|
||||||
|
if (!sname) {
|
||||||
|
sname = LOC(lang, parameters[P_SHIP]);
|
||||||
|
if (!sname) {
|
||||||
|
sname = parameters[P_SHIP];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(sname);
|
||||||
|
slprintf(buffer, sizeof(buffer), "%s %s", sname, shipid(sh));
|
||||||
sh->name = strdup(buffer);
|
sh->name = strdup(buffer);
|
||||||
shash(sh);
|
shash(sh);
|
||||||
addlist(&r->ships, sh);
|
addlist(&r->ships, sh);
|
||||||
|
|
Loading…
Reference in a new issue