forked from github/server
Merge pull request #609 from ennorehling/develop
BUG: broken ship names
This commit is contained in:
commit
f5da163d18
|
@ -181,7 +181,7 @@ static int potion_power(unit *u, int amount) {
|
|||
if (u->number % 10 > 0) ++use;
|
||||
amount = use;
|
||||
}
|
||||
/* Verfünffacht die HP von max. 10 Personen in der Einheit */
|
||||
/* Verf<EFBFBD>nffacht die HP von max. 10 Personen in der Einheit */
|
||||
u->hp += _min(u->number, 10 * amount) * unit_max_hp(u) * 4;
|
||||
return amount;
|
||||
}
|
||||
|
@ -241,8 +241,7 @@ static void init_potiondelay(attrib * a)
|
|||
a->data.v = malloc(sizeof(potiondelay));
|
||||
}
|
||||
|
||||
static void free_potiondelay(attrib * a)
|
||||
{
|
||||
static void free_potiondelay(attrib * a) {
|
||||
free(a->data.v);
|
||||
}
|
||||
|
||||
|
|
22
src/battle.c
22
src/battle.c
|
@ -1022,16 +1022,15 @@ static int armor_bonus(const race *rc) {
|
|||
int natural_armor(unit * du)
|
||||
{
|
||||
const race *rc = u_race(du);
|
||||
int bonus, an = rc->armor;
|
||||
int an;
|
||||
|
||||
assert(rc);
|
||||
bonus = armor_bonus(rc);
|
||||
if (bonus > 0) {
|
||||
an = armor_bonus(rc);
|
||||
if (an > 0) {
|
||||
int sk = effskill(du, SK_STAMINA, 0);
|
||||
sk /= bonus;
|
||||
an += sk;
|
||||
return rc->armor + sk / an;
|
||||
}
|
||||
return an;
|
||||
return rc->armor;
|
||||
}
|
||||
|
||||
static int rc_specialdamage(const unit *au, const unit *du, const struct weapon_type *wtype)
|
||||
|
@ -2042,19 +2041,12 @@ int hits(troop at, troop dt, weapon * awp)
|
|||
void dazzle(battle * b, troop * td)
|
||||
{
|
||||
/* Nicht kumulativ ! */
|
||||
if (td->fighter->person[td->index].flags & FL_DAZZLED)
|
||||
return;
|
||||
|
||||
#ifdef TODO_RUNESWORD
|
||||
if (td->fighter->weapon[WP_RUNESWORD].count > td->index) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (td->fighter->person[td->index].flags & FL_COURAGE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (td->fighter->person[td->index].flags & FL_DAZZLED) {
|
||||
if (td->fighter->person[td->index].flags & (FL_COURAGE|FL_DAZZLED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2497,7 +2489,7 @@ static int loot_quota(const unit * src, const unit * dst,
|
|||
{
|
||||
if (dst && src && src->faction != dst->faction) {
|
||||
double divisor = config_get_flt("rules.items.loot_divisor", 1);
|
||||
assert(divisor == 0 || divisor >= 1);
|
||||
assert(divisor <= 0 || divisor >= 1);
|
||||
if (divisor >= 1) {
|
||||
double r = n / divisor;
|
||||
int x = (int)r;
|
||||
|
|
|
@ -211,7 +211,7 @@ border_type *find_bordertype(const char *name)
|
|||
{
|
||||
border_type *bt = bordertypes;
|
||||
|
||||
while (bt && strcmp(bt->__name, name))
|
||||
while (bt && strcmp(bt->__name, name)!=0)
|
||||
bt = bt->next;
|
||||
return bt;
|
||||
}
|
||||
|
@ -620,7 +620,6 @@ int read_borders(gamedata *data)
|
|||
assert(type || !"connection type not registered");
|
||||
}
|
||||
|
||||
|
||||
READ_INT(store, &bid);
|
||||
if (data->version < UIDHASH_VERSION) {
|
||||
int fx, fy, tx, ty;
|
||||
|
@ -639,9 +638,7 @@ int read_borders(gamedata *data)
|
|||
to = findregionbyid(tid);
|
||||
}
|
||||
if (!to || !from) {
|
||||
if (!to || !from) {
|
||||
log_error("%s connection %d has missing regions", zText, bid);
|
||||
}
|
||||
log_error("%s connection %d has missing regions", zText, bid);
|
||||
if (type->read) {
|
||||
// skip ahead
|
||||
connection dummy;
|
||||
|
@ -650,7 +647,7 @@ int read_borders(gamedata *data)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (to == from && type && from) {
|
||||
if (to == from && from) {
|
||||
direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS);
|
||||
region *r = rconnect(from, dir);
|
||||
log_error("[read_borders] invalid %s in %s\n", type->__name, regionname(from, NULL));
|
||||
|
@ -659,7 +656,7 @@ int read_borders(gamedata *data)
|
|||
}
|
||||
if (type->read) {
|
||||
connection *b = new_border(type, from, to);
|
||||
nextborder--; /* new_border erhöht den Wert */
|
||||
nextborder--; /* new_border erh<EFBFBD>ht den Wert */
|
||||
b->id = bid;
|
||||
assert(bid <= nextborder);
|
||||
type->read(b, data);
|
||||
|
|
|
@ -796,7 +796,7 @@ static void json_settings(cJSON *json) {
|
|||
else {
|
||||
char value[32];
|
||||
if (child->type == cJSON_Number && child->valuedouble && child->valueint<child->valuedouble) {
|
||||
_snprintf(value, sizeof(value), "%lf", child->valuedouble);
|
||||
_snprintf(value, sizeof(value), "%f", child->valuedouble);
|
||||
}
|
||||
else {
|
||||
_snprintf(value, sizeof(value), "%d", child->valueint);
|
||||
|
|
|
@ -297,10 +297,9 @@ int crew_skill(const ship *sh) {
|
|||
|
||||
int shipspeed(const ship * sh, const unit * u)
|
||||
{
|
||||
int k = sh->type->range;
|
||||
attrib *a;
|
||||
struct curse *c;
|
||||
int bonus;
|
||||
int k, bonus;
|
||||
|
||||
assert(sh);
|
||||
if (!u) u = ship_owner(sh);
|
||||
|
@ -310,6 +309,7 @@ int shipspeed(const ship * sh, const unit * u)
|
|||
assert(sh->type->construction);
|
||||
assert(sh->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */
|
||||
|
||||
k = sh->type->range;
|
||||
if (sh->size != sh->type->construction->maxsize)
|
||||
return 0;
|
||||
|
||||
|
@ -417,7 +417,7 @@ static unit * ship_owner_ex(const ship * sh, const struct faction * last_owner)
|
|||
{
|
||||
unit *u, *heir = 0;
|
||||
|
||||
/* Eigentümer tot oder kein Eigentümer vorhanden. Erste lebende Einheit
|
||||
/* Eigent<EFBFBD>mer tot oder kein Eigent<6E>mer vorhanden. Erste lebende Einheit
|
||||
* nehmen. */
|
||||
for (u = sh->region->units; u; u = u->next) {
|
||||
if (u->ship == sh) {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
const attrib_type at_lighthouse = {
|
||||
"lighthouse"
|
||||
/* Rest ist NULL; temporäres, nicht alterndes Attribut */
|
||||
/* Rest ist NULL; tempor<EFBFBD>res, nicht alterndes Attribut */
|
||||
};
|
||||
|
||||
/* update_lighthouse: call this function whenever the size of a lighthouse changes
|
||||
|
@ -127,7 +127,7 @@ bool check_leuchtturm(region * r, faction * f)
|
|||
c += u->number;
|
||||
if (c > buildingcapacity(b))
|
||||
break;
|
||||
if (f == NULL || u->faction == f) {
|
||||
if (u->faction == f) {
|
||||
if (!d)
|
||||
d = distance(r, r2);
|
||||
if (maxd < d)
|
||||
|
|
|
@ -1240,9 +1240,9 @@ static bool roadto(const region * r, direction_t dir)
|
|||
if (!r || dir >= MAXDIRECTIONS || dir < 0)
|
||||
return false;
|
||||
r2 = rconnect(r, dir);
|
||||
if (r == NULL || r2 == NULL)
|
||||
if (!r2) {
|
||||
return false;
|
||||
|
||||
}
|
||||
if (r->attribs || r2->attribs) {
|
||||
const curse_type *roads_ct = ct_find("magicstreet");
|
||||
if (roads_ct != NULL) {
|
||||
|
|
|
@ -273,10 +273,10 @@ void setup_drift (struct drift_fixture *fix) {
|
|||
fix->st_boat->cabins = 20000;
|
||||
|
||||
fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r=findregion(-1,0));
|
||||
assert(fix->r);
|
||||
assert(fix->r && fix->u && fix->f);
|
||||
set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
|
||||
u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
|
||||
assert(fix->f && fix->u && fix->sh);
|
||||
assert(fix->sh);
|
||||
}
|
||||
|
||||
static void test_ship_no_overload(CuTest *tc) {
|
||||
|
|
|
@ -83,12 +83,12 @@ static void test_piracy_cmd(CuTest * tc) {
|
|||
t_ocean = get_or_create_terrain("ocean");
|
||||
st_boat = st_get_or_create("boat");
|
||||
u2 = test_create_unit(test_create_faction(0), test_create_region(1, 0, t_ocean));
|
||||
u_set_ship(u2, test_create_ship(u2->region, st_boat));
|
||||
assert(u2);
|
||||
u_set_ship(u2, test_create_ship(u2->region, st_boat));
|
||||
u = test_create_unit(f = test_create_faction(0), r = test_create_region(0, 0, t_ocean));
|
||||
assert(f && u);
|
||||
set_level(u, SK_SAILING, st_boat->sumskill);
|
||||
u_set_ship(u, test_create_ship(u->region, st_boat));
|
||||
assert(f && u);
|
||||
f->locale = get_or_create_locale("de");
|
||||
u->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36(u2->faction->no));
|
||||
|
||||
|
|
|
@ -489,13 +489,14 @@ size_t size)
|
|||
building *b;
|
||||
bool isbattle = (bool)(mode == seen_battle);
|
||||
item *itm, *show = NULL;
|
||||
faction *fv = visible_faction(f, u);
|
||||
faction *fv;
|
||||
char *bufp = buf;
|
||||
int result = 0;
|
||||
item results[MAX_INVENTORY];
|
||||
|
||||
assert(f);
|
||||
bufp = STRLCPY(bufp, unitname(u), size);
|
||||
|
||||
fv = visible_faction(f, u);
|
||||
if (!isbattle) {
|
||||
attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
||||
if (u->faction == f) {
|
||||
|
@ -770,7 +771,7 @@ size_t size)
|
|||
}
|
||||
|
||||
dh = 0;
|
||||
if (!getarnt && f) {
|
||||
if (!getarnt) {
|
||||
if (alliedfaction(rplane(u->region), f, fv, HELP_ALL)) {
|
||||
dh = 1;
|
||||
}
|
||||
|
|
|
@ -3237,8 +3237,7 @@ static int sp_magicboost(castorder * co)
|
|||
}
|
||||
|
||||
effect = 6;
|
||||
c = create_curse(mage, &mage->attribs, ct_magicboost, power, 10, effect, 1);
|
||||
|
||||
create_curse(mage, &mage->attribs, ct_magicboost, power, 10, effect, 1);
|
||||
/* one aura boost with 200% aura now: */
|
||||
effect = 200;
|
||||
c = create_curse(mage, &mage->attribs, ct_auraboost, power, 4, effect, 1);
|
||||
|
@ -4031,7 +4030,7 @@ static int sp_recruit(castorder * co)
|
|||
* ein mehrfaches von Stufe 1, denn in beiden Faellen gibt es nur 1
|
||||
* Bauer, nur die Kosten steigen. */
|
||||
n = (pow(force, 1.6) * 100) / f->race->recruitcost;
|
||||
if (rc->recruit_multi != 0) {
|
||||
if (rc->recruit_multi > 0) {
|
||||
double multp = (double)maxp / rc->recruit_multi;
|
||||
n = _min(multp, n);
|
||||
n = _max(n, 1);
|
||||
|
|
|
@ -185,9 +185,7 @@ plane *get_astralplane(void)
|
|||
if (!rule_astralplane) {
|
||||
return NULL;
|
||||
}
|
||||
if (!astralspace) {
|
||||
astralspace = getplanebyname("Astralraum");
|
||||
}
|
||||
astralspace = getplanebyname("Astralraum");
|
||||
if (!astralspace) {
|
||||
astralspace = create_new_plane(1, "Astralraum",
|
||||
TE_CENTER_X - 500, TE_CENTER_X + 500,
|
||||
|
|
|
@ -81,10 +81,11 @@ void test_upkeep_from_pool(CuTest * tc)
|
|||
i_silver = it_find("money");
|
||||
assert(i_silver);
|
||||
r = findregion(0, 0);
|
||||
assert(r);
|
||||
u1 = test_create_unit(test_create_faction(test_create_race("human")), r);
|
||||
assert(u1);
|
||||
u2 = test_create_unit(u1->faction, r);
|
||||
assert(r && u1 && u2);
|
||||
assert(u2);
|
||||
|
||||
config_set("rules.food.flags", "0");
|
||||
i_change(&u1->items, i_silver, 30);
|
||||
|
|
|
@ -40,12 +40,19 @@ int unicode_utf8_trim(utf8_t *buf)
|
|||
size_t size = 1;
|
||||
wint_t wc = *ip;
|
||||
if (wc & 0x80) {
|
||||
ucs4_t ucs;
|
||||
int ret = unicode_utf8_to_ucs4(&ucs, ip, &size);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
ucs4_t ucs = 0;
|
||||
if (ip[1]) {
|
||||
int ret = unicode_utf8_to_ucs4(&ucs, ip, &size);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
wc = (wint_t)ucs;
|
||||
}
|
||||
else {
|
||||
wc = *op = '?';
|
||||
size = 1;
|
||||
++result;
|
||||
}
|
||||
wc = (wint_t)ucs;
|
||||
}
|
||||
if (op == buf && iswspace(wc)) {
|
||||
++result;
|
||||
|
|
|
@ -28,6 +28,10 @@ static void test_unicode_trim(CuTest * tc)
|
|||
strcpy(buffer, " \t Hello Word");
|
||||
CuAssertIntEquals(tc, 3, unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello Word", buffer);
|
||||
|
||||
buffer[9] = (char)0xc3;
|
||||
CuAssertIntEquals(tc, 1, unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello Wor?", buffer);
|
||||
}
|
||||
|
||||
static void test_unicode_tolower(CuTest * tc)
|
||||
|
@ -87,11 +91,21 @@ static void test_unicode_utf8_to_other(CuTest *tc)
|
|||
CuAssertIntEquals(tc, 'l', ch);
|
||||
}
|
||||
|
||||
static void test_unicode_utf8_to_ucs(CuTest *tc) {
|
||||
ucs4_t ucs;
|
||||
size_t sz;
|
||||
|
||||
CuAssertIntEquals(tc, 0, unicode_utf8_to_ucs4(&ucs, "a", &sz));
|
||||
CuAssertIntEquals(tc, 'a', ucs);
|
||||
CuAssertIntEquals(tc, 1, sz);
|
||||
}
|
||||
|
||||
CuSuite *get_unicode_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_unicode_tolower);
|
||||
SUITE_ADD_TEST(suite, test_unicode_trim);
|
||||
SUITE_ADD_TEST(suite, test_unicode_utf8_to_other);
|
||||
SUITE_ADD_TEST(suite, test_unicode_utf8_to_ucs);
|
||||
return suite;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue