forked from github/server
Merge branch 'develop' of github.com:ennorehling/eressea into develop
This commit is contained in:
commit
aef475f663
20 changed files with 162 additions and 57 deletions
10
src/battle.c
10
src/battle.c
|
@ -1216,7 +1216,7 @@ terminate(troop dt, troop at, int type, const char *damage, bool missile)
|
||||||
|
|
||||||
while (chance(kritchance)) {
|
while (chance(kritchance)) {
|
||||||
if (bdebug) {
|
if (bdebug) {
|
||||||
fprintf(bdebug, "%s/%d lands a critical hit\n", unitid(au), at.index);
|
fprintf(bdebug, "%s/%d lands a critical hit\n", itoa36(au->no), at.index);
|
||||||
}
|
}
|
||||||
da += dice_rand(damage);
|
da += dice_rand(damage);
|
||||||
}
|
}
|
||||||
|
@ -1980,10 +1980,10 @@ debug_hit(troop at, const weapon * awp, troop dt, const weapon * dwp,
|
||||||
int skdiff, int dist, bool success)
|
int skdiff, int dist, bool success)
|
||||||
{
|
{
|
||||||
fprintf(bdebug, "%.4s/%d [%6s/%d] %s %.4s/%d [%6s/%d] with %d, distance %d\n",
|
fprintf(bdebug, "%.4s/%d [%6s/%d] %s %.4s/%d [%6s/%d] with %d, distance %d\n",
|
||||||
unitid(at.fighter->unit), at.index,
|
itoa36(at.fighter->unit->no), at.index,
|
||||||
LOC(default_locale, awp ? resourcename(awp->type->itype->rtype,
|
LOC(default_locale, awp ? resourcename(awp->type->itype->rtype,
|
||||||
0) : "unarmed"), weapon_effskill(at, dt, awp, true, dist > 1),
|
0) : "unarmed"), weapon_effskill(at, dt, awp, true, dist > 1),
|
||||||
success ? "hits" : "misses", unitid(dt.fighter->unit), dt.index,
|
success ? "hits" : "misses", itoa36(dt.fighter->unit->no), dt.index,
|
||||||
LOC(default_locale, dwp ? resourcename(dwp->type->itype->rtype,
|
LOC(default_locale, dwp ? resourcename(dwp->type->itype->rtype,
|
||||||
0) : "unarmed"), weapon_effskill(dt, at, dwp, false, dist > 1), skdiff,
|
0) : "unarmed"), weapon_effskill(dt, at, dwp, false, dist > 1), skdiff,
|
||||||
dist);
|
dist);
|
||||||
|
@ -2194,7 +2194,7 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
|
||||||
if (reload && wp && wp->type->reload && !getreload(ta)) {
|
if (reload && wp && wp->type->reload && !getreload(ta)) {
|
||||||
int i = setreload(ta);
|
int i = setreload(ta);
|
||||||
if (bdebug) {
|
if (bdebug) {
|
||||||
fprintf(bdebug, "%s/%d reloading %d turns\n", unitid(au),
|
fprintf(bdebug, "%s/%d reloading %d turns\n", itoa36(au->no),
|
||||||
ta.index, i);
|
ta.index, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3130,7 +3130,7 @@ static void print_stats(battle * b)
|
||||||
|
|
||||||
static int weapon_weight(const weapon * w, bool missile)
|
static int weapon_weight(const weapon * w, bool missile)
|
||||||
{
|
{
|
||||||
if (missile == i2b(fval(w->type, WTF_MISSILE))) {
|
if (missile == !!(fval(w->type, WTF_MISSILE))) {
|
||||||
return w->attackskill + w->defenseskill;
|
return w->attackskill + w->defenseskill;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -782,7 +782,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
|
||||||
if (sf != u->faction)
|
if (sf != u->faction)
|
||||||
stream_printf(out, "%d;Verkleidung\n", sf->no);
|
stream_printf(out, "%d;Verkleidung\n", sf->no);
|
||||||
if (fval(u, UFL_ANON_FACTION))
|
if (fval(u, UFL_ANON_FACTION))
|
||||||
stream_printf(out, "%d;Parteitarnung\n", i2b(fval(u, UFL_ANON_FACTION)));
|
stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION)!=0);
|
||||||
if (otherfaction && otherfaction != u->faction) {
|
if (otherfaction && otherfaction != u->faction) {
|
||||||
stream_printf(out, "%d;Anderepartei\n", otherfaction->no);
|
stream_printf(out, "%d;Anderepartei\n", otherfaction->no);
|
||||||
}
|
}
|
||||||
|
@ -794,7 +794,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f,
|
||||||
else {
|
else {
|
||||||
if (fval(u, UFL_ANON_FACTION)) {
|
if (fval(u, UFL_ANON_FACTION)) {
|
||||||
/* faction info is hidden */
|
/* faction info is hidden */
|
||||||
stream_printf(out, "%d;Parteitarnung\n", i2b(fval(u, UFL_ANON_FACTION)));
|
stream_printf(out, "%d;Parteitarnung\n", (u->flags & UFL_ANON_FACTION) != 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
const attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction);
|
||||||
|
|
|
@ -426,7 +426,7 @@ building *new_building(const struct building_type * btype, region * r,
|
||||||
bname = parameters[P_GEBAEUDE];
|
bname = parameters[P_GEBAEUDE];
|
||||||
}
|
}
|
||||||
assert(bname);
|
assert(bname);
|
||||||
slprintf(buffer, sizeof(buffer), "%s %s", bname, buildingid(b));
|
slprintf(buffer, sizeof(buffer), "%s %s", bname, itoa36(b->no));
|
||||||
b->name = _strdup(bname);
|
b->name = _strdup(bname);
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,6 @@ struct settings global = {
|
||||||
};
|
};
|
||||||
|
|
||||||
bool lomem = false;
|
bool lomem = false;
|
||||||
FILE *logfile;
|
|
||||||
int turn = -1;
|
int turn = -1;
|
||||||
|
|
||||||
const char *parameters[MAXPARAMS] = {
|
const char *parameters[MAXPARAMS] = {
|
||||||
|
|
|
@ -34,8 +34,6 @@ struct param;
|
||||||
#define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. L<>nge der Strings, die
|
#define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. L<>nge der Strings, die
|
||||||
* von struct unitname, etc. zur<EFBFBD>ckgegeben werden. ohne die 0 */
|
* von struct unitname, etc. zur<EFBFBD>ckgegeben werden. ohne die 0 */
|
||||||
|
|
||||||
#define i2b(i) ((bool)((i)?(true):(false)))
|
|
||||||
|
|
||||||
#define fval(u, i) ((u)->flags & (i))
|
#define fval(u, i) ((u)->flags & (i))
|
||||||
#define fset(u, i) ((u)->flags |= (i))
|
#define fset(u, i) ((u)->flags |= (i))
|
||||||
#define freset(u, i) ((u)->flags &= ~(i))
|
#define freset(u, i) ((u)->flags &= ~(i))
|
||||||
|
@ -47,13 +45,6 @@ struct param;
|
||||||
bool isparam(const char *s, const struct locale * lang, param_t param);
|
bool isparam(const char *s, const struct locale * lang, param_t param);
|
||||||
param_t getparam(const struct locale *lang);
|
param_t getparam(const struct locale *lang);
|
||||||
|
|
||||||
#define unitid(x) itoa36((x)->no)
|
|
||||||
|
|
||||||
#define buildingid(x) itoa36((x)->no)
|
|
||||||
#define shipid(x) itoa36((x)->no)
|
|
||||||
#define factionid(x) itoa36((x)->no)
|
|
||||||
#define curseid(x) itoa36((x)->no)
|
|
||||||
|
|
||||||
const char * game_name(void);
|
const char * game_name(void);
|
||||||
int game_id(void);
|
int game_id(void);
|
||||||
/* returns a value between [0..xpct_2], generated with two dice */
|
/* returns a value between [0..xpct_2], generated with two dice */
|
||||||
|
@ -166,10 +157,8 @@ struct param;
|
||||||
extern const char *localenames[];
|
extern const char *localenames[];
|
||||||
extern settings global;
|
extern settings global;
|
||||||
|
|
||||||
extern bool sqlpatch;
|
|
||||||
extern bool lomem; /* save memory */
|
extern bool lomem; /* save memory */
|
||||||
extern int turn;
|
extern int turn;
|
||||||
extern bool getunitpeasants;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -273,11 +273,11 @@ faction *addfaction(const char *email, const char *password,
|
||||||
addlist(&factions, f);
|
addlist(&factions, f);
|
||||||
fhash(f);
|
fhash(f);
|
||||||
|
|
||||||
slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), factionid(f));
|
slprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), itoa36(f->no));
|
||||||
f->name = _strdup(buf);
|
f->name = _strdup(buf);
|
||||||
|
|
||||||
if (!f->race) {
|
if (!f->race) {
|
||||||
log_warning("creating a faction that has no race", factionid(f));
|
log_warning("creating a faction that has no race", itoa36(f->no));
|
||||||
}
|
}
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
|
@ -828,7 +828,7 @@ int writepasswd(void)
|
||||||
|
|
||||||
for (f = factions; f; f = f->next) {
|
for (f = factions; f; f = f->next) {
|
||||||
fprintf(F, "%s:%s:%s:%u\n",
|
fprintf(F, "%s:%s:%s:%u\n",
|
||||||
factionid(f), f->email, f->_password, f->subscription);
|
itoa36(f->no), f->email, f->_password, f->subscription);
|
||||||
}
|
}
|
||||||
fclose(F);
|
fclose(F);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -1291,7 +1291,7 @@ faction *read_faction(struct gamedata * data)
|
||||||
};
|
};
|
||||||
f->banner = _strdup(name);
|
f->banner = _strdup(name);
|
||||||
|
|
||||||
log_debug(" - Lese Partei %s (%s)", f->name, factionid(f));
|
log_debug(" - Lese Partei %s (%s)", f->name, itoa36(f->no));
|
||||||
|
|
||||||
READ_STR(data->store, name, sizeof(name));
|
READ_STR(data->store, name, sizeof(name));
|
||||||
if (set_email(&f->email, name) != 0) {
|
if (set_email(&f->email, name) != 0) {
|
||||||
|
|
|
@ -201,7 +201,7 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
|
||||||
sname = parameters[P_SHIP];
|
sname = parameters[P_SHIP];
|
||||||
}
|
}
|
||||||
assert(sname);
|
assert(sname);
|
||||||
slprintf(buffer, sizeof(buffer), "%s %s", sname, shipid(sh));
|
slprintf(buffer, sizeof(buffer), "%s %s", sname, itoa36(sh->no));
|
||||||
sh->name = _strdup(buffer);
|
sh->name = _strdup(buffer);
|
||||||
shash(sh);
|
shash(sh);
|
||||||
if (r) {
|
if (r) {
|
||||||
|
|
|
@ -494,6 +494,10 @@ attrib_type at_alias = {
|
||||||
NO_READ
|
NO_READ
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** remember old unit.no (for the creport, mostly)
|
||||||
|
* if alias is positive, then this unit was a TEMP
|
||||||
|
* if alias is negative, then this unit has been RENUMBERed
|
||||||
|
*/
|
||||||
int ualias(const unit * u)
|
int ualias(const unit * u)
|
||||||
{
|
{
|
||||||
attrib *a = a_find(u->attribs, &at_alias);
|
attrib *a = a_find(u->attribs, &at_alias);
|
||||||
|
@ -1716,7 +1720,7 @@ void renumber_unit(unit *u, int no) {
|
||||||
uunhash(u);
|
uunhash(u);
|
||||||
if (!ualias(u)) {
|
if (!ualias(u)) {
|
||||||
attrib *a = a_add(&u->attribs, a_new(&at_alias));
|
attrib *a = a_add(&u->attribs, a_new(&at_alias));
|
||||||
a->data.i = -u->no; // TODO: why is the alias negative? confusing!
|
a->data.i = -u->no;
|
||||||
}
|
}
|
||||||
u->no = no;
|
u->no = no;
|
||||||
uhash(u);
|
uhash(u);
|
||||||
|
|
|
@ -997,7 +997,7 @@ int quit_cmd(unit * u, struct order *ord)
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
write_order(ord, buffer, sizeof(buffer));
|
write_order(ord, buffer, sizeof(buffer));
|
||||||
cmistake(u, ord, 86, MSG_EVENT);
|
cmistake(u, ord, 86, MSG_EVENT);
|
||||||
log_warning("QUIT with illegal password for faction %s: %s\n", factionid(f), buffer);
|
log_warning("QUIT with illegal password for faction %s: %s\n", itoa36(f->no), buffer);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -347,7 +347,7 @@ attrib_type at_mage = {
|
||||||
|
|
||||||
bool is_mage(const unit * u)
|
bool is_mage(const unit * u)
|
||||||
{
|
{
|
||||||
return i2b(get_mage(u) != NULL);
|
return get_mage(u) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
sc_mage *get_mage(const unit * u)
|
sc_mage *get_mage(const unit * u)
|
||||||
|
@ -2167,7 +2167,7 @@ typedef struct familiar_data {
|
||||||
bool is_familiar(const unit * u)
|
bool is_familiar(const unit * u)
|
||||||
{
|
{
|
||||||
attrib *a = a_find(u->attribs, &at_familiarmage);
|
attrib *a = a_find(u->attribs, &at_familiarmage);
|
||||||
return i2b(a != NULL);
|
return a != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -169,7 +169,7 @@ void score(void)
|
||||||
fprintf(scoreFP, "%30.30s (%3.3s) %5s (%3d)\n",
|
fprintf(scoreFP, "%30.30s (%3.3s) %5s (%3d)\n",
|
||||||
f->name,
|
f->name,
|
||||||
f->race->_name,
|
f->race->_name,
|
||||||
factionid(f),
|
itoa36(f->no),
|
||||||
f->age);
|
f->age);
|
||||||
}
|
}
|
||||||
fclose(scoreFP);
|
fclose(scoreFP);
|
||||||
|
|
|
@ -36,7 +36,6 @@ void renumber_factions(void)
|
||||||
attrib *a = a_find(f->attribs, &at_number);
|
attrib *a = a_find(f->attribs, &at_number);
|
||||||
int want;
|
int want;
|
||||||
struct renum **rn;
|
struct renum **rn;
|
||||||
faction *old;
|
|
||||||
|
|
||||||
if (!a)
|
if (!a)
|
||||||
continue;
|
continue;
|
||||||
|
@ -45,12 +44,6 @@ void renumber_factions(void)
|
||||||
ADDMSG(&f->msgs, msg_message("renumber_twice", "id", want));
|
ADDMSG(&f->msgs, msg_message("renumber_twice", "id", want));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
old = findfaction(want);
|
|
||||||
if (old) {
|
|
||||||
a_remove(&f->attribs, a);
|
|
||||||
ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!faction_id_is_unused(want)) {
|
if (!faction_id_is_unused(want)) {
|
||||||
a_remove(&f->attribs, a);
|
a_remove(&f->attribs, a);
|
||||||
ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want));
|
ADDMSG(&f->msgs, msg_message("renumber_inuse", "id", want));
|
||||||
|
@ -151,7 +144,7 @@ int renumber_cmd(unit * u, order * ord)
|
||||||
cmistake(u, ord, 114, MSG_EVENT);
|
cmistake(u, ord, 114, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (findship(i) || findbuilding(i)) {
|
if (findship(i)) {
|
||||||
cmistake(u, ord, 115, MSG_EVENT);
|
cmistake(u, ord, 115, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +173,7 @@ int renumber_cmd(unit * u, order * ord)
|
||||||
cmistake(u, ord, 114, MSG_EVENT);
|
cmistake(u, ord, 114, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (findship(i) || findbuilding(i)) {
|
if (findbuilding(i)) {
|
||||||
cmistake(u, ord, 115, MSG_EVENT);
|
cmistake(u, ord, 115, MSG_EVENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,25 @@ static void test_renumber_faction(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_renumber_faction_duplicate(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
faction *f, *f2;
|
||||||
|
int no;
|
||||||
|
const struct locale *lang;
|
||||||
|
|
||||||
|
test_setup_ex(tc);
|
||||||
|
f2 = test_create_faction(0);
|
||||||
|
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
no = f->no;
|
||||||
|
lang = f->locale;
|
||||||
|
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_FACTION]), itoa36(f2->no));
|
||||||
|
renumber_cmd(u, u->thisorder);
|
||||||
|
renumber_factions();
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "renumber_inuse"));
|
||||||
|
CuAssertIntEquals(tc, no, u->faction->no);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_renumber_building(CuTest *tc) {
|
static void test_renumber_building(CuTest *tc) {
|
||||||
unit *u;
|
unit *u;
|
||||||
int uno, no;
|
int uno, no;
|
||||||
|
@ -46,6 +65,26 @@ static void test_renumber_building(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_renumber_building_duplicate(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
faction *f;
|
||||||
|
int uno, no;
|
||||||
|
const struct locale *lang;
|
||||||
|
|
||||||
|
test_setup_ex(tc);
|
||||||
|
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
u->building = test_create_building(u->region, 0);
|
||||||
|
uno = u->building->no;
|
||||||
|
u->building = test_create_building(u->region, 0);
|
||||||
|
no = u->building->no;
|
||||||
|
lang = f->locale;
|
||||||
|
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_BUILDING]), itoa36(uno));
|
||||||
|
renumber_cmd(u, u->thisorder);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
|
||||||
|
CuAssertIntEquals(tc, no, u->building->no);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_renumber_ship(CuTest *tc) {
|
static void test_renumber_ship(CuTest *tc) {
|
||||||
unit *u;
|
unit *u;
|
||||||
int uno, no;
|
int uno, no;
|
||||||
|
@ -63,6 +102,26 @@ static void test_renumber_ship(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_renumber_ship_duplicate(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
faction *f;
|
||||||
|
int uno, no;
|
||||||
|
const struct locale *lang;
|
||||||
|
|
||||||
|
test_setup_ex(tc);
|
||||||
|
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
u->ship = test_create_ship(u->region, 0);
|
||||||
|
uno = u->ship->no;
|
||||||
|
u->ship = test_create_ship(u->region, 0);
|
||||||
|
no = u->ship->no;
|
||||||
|
lang = f->locale;
|
||||||
|
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_SHIP]), itoa36(uno));
|
||||||
|
renumber_cmd(u, u->thisorder);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
|
||||||
|
CuAssertIntEquals(tc, no, u->ship->no);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_renumber_unit(CuTest *tc) {
|
static void test_renumber_unit(CuTest *tc) {
|
||||||
unit *u;
|
unit *u;
|
||||||
int uno, no;
|
int uno, no;
|
||||||
|
@ -76,7 +135,62 @@ static void test_renumber_unit(CuTest *tc) {
|
||||||
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_UNIT]), itoa36(uno));
|
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_UNIT]), itoa36(uno));
|
||||||
renumber_cmd(u, u->thisorder);
|
renumber_cmd(u, u->thisorder);
|
||||||
CuAssertIntEquals(tc, uno, u->no);
|
CuAssertIntEquals(tc, uno, u->no);
|
||||||
CuAssertIntEquals(tc, -no, ualias(u)); // TODO: why is ualias negative?
|
CuAssertIntEquals(tc, -no, ualias(u));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_renumber_unit_duplicate(CuTest *tc) {
|
||||||
|
unit *u, *u2;
|
||||||
|
faction *f;
|
||||||
|
int no;
|
||||||
|
const struct locale *lang;
|
||||||
|
|
||||||
|
test_setup_ex(tc);
|
||||||
|
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
no = u->no;
|
||||||
|
u2 = test_create_unit(f, u->region);
|
||||||
|
lang = f->locale;
|
||||||
|
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_UNIT]), itoa36(u2->no));
|
||||||
|
renumber_cmd(u, u->thisorder);
|
||||||
|
CuAssertIntEquals(tc, no, u->no);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error115"));
|
||||||
|
CuAssertIntEquals(tc, 0, ualias(u));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_renumber_unit_limit(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
faction *f;
|
||||||
|
int no;
|
||||||
|
const struct locale *lang;
|
||||||
|
|
||||||
|
test_setup_ex(tc);
|
||||||
|
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
no = u->no;
|
||||||
|
lang = f->locale;
|
||||||
|
u->thisorder = create_order(K_NUMBER, lang, "%s 10000", LOC(lang, parameters[P_UNIT]));
|
||||||
|
renumber_cmd(u, u->thisorder);
|
||||||
|
CuAssertIntEquals(tc, no, u->no);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error114"));
|
||||||
|
CuAssertIntEquals(tc, 0, ualias(u));
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_renumber_unit_invalid(CuTest *tc) {
|
||||||
|
unit *u;
|
||||||
|
faction *f;
|
||||||
|
int no;
|
||||||
|
const struct locale *lang;
|
||||||
|
|
||||||
|
test_setup_ex(tc);
|
||||||
|
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
|
||||||
|
no = u->no;
|
||||||
|
lang = f->locale;
|
||||||
|
u->thisorder = create_order(K_NUMBER, lang, "%s TEMP", LOC(lang, parameters[P_UNIT]));
|
||||||
|
renumber_cmd(u, u->thisorder);
|
||||||
|
CuAssertIntEquals(tc, no, u->no);
|
||||||
|
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error116"));
|
||||||
|
CuAssertIntEquals(tc, 0, ualias(u));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,8 +198,14 @@ CuSuite *get_renumber_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_renumber_unit);
|
SUITE_ADD_TEST(suite, test_renumber_unit);
|
||||||
|
SUITE_ADD_TEST(suite, test_renumber_unit_limit);
|
||||||
|
SUITE_ADD_TEST(suite, test_renumber_unit_duplicate);
|
||||||
|
SUITE_ADD_TEST(suite, test_renumber_unit_invalid);
|
||||||
SUITE_ADD_TEST(suite, test_renumber_building);
|
SUITE_ADD_TEST(suite, test_renumber_building);
|
||||||
|
SUITE_ADD_TEST(suite, test_renumber_building_duplicate);
|
||||||
SUITE_ADD_TEST(suite, test_renumber_ship);
|
SUITE_ADD_TEST(suite, test_renumber_ship);
|
||||||
|
SUITE_ADD_TEST(suite, test_renumber_ship_duplicate);
|
||||||
SUITE_ADD_TEST(suite, test_renumber_faction);
|
SUITE_ADD_TEST(suite, test_renumber_faction);
|
||||||
|
SUITE_ADD_TEST(suite, test_renumber_faction_duplicate);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1406,7 +1406,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
||||||
newline(out);
|
newline(out);
|
||||||
newline(out);
|
newline(out);
|
||||||
|
|
||||||
sprintf(buf, "%s %s \"password\"", LOC(f->locale, "ERESSEA"), factionid(f));
|
sprintf(buf, "%s %s \"password\"", LOC(f->locale, "ERESSEA"), itoa36(f->no));
|
||||||
rps_nowrap(out, buf);
|
rps_nowrap(out, buf);
|
||||||
newline(out);
|
newline(out);
|
||||||
newline(out);
|
newline(out);
|
||||||
|
@ -1453,7 +1453,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
||||||
size = sizeof(buf) - 1;
|
size = sizeof(buf) - 1;
|
||||||
bytes = _snprintf(bufp, size, "%s %s; %s [%d,%d$",
|
bytes = _snprintf(bufp, size, "%s %s; %s [%d,%d$",
|
||||||
LOC(u->faction->locale, parameters[P_UNIT]),
|
LOC(u->faction->locale, parameters[P_UNIT]),
|
||||||
unitid(u), unit_getname(u), u->number, get_money(u));
|
itoa36(u->no), unit_getname(u), u->number, get_money(u));
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
if (u->building && building_owner(u->building) == u) {
|
if (u->building && building_owner(u->building) == u) {
|
||||||
|
@ -1479,7 +1479,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
||||||
}
|
}
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
bytes = (int)strlcpy(bufp, shipid(u->ship), size);
|
bytes = (int)strlcpy(bufp, itoa36(u->ship->no), size);
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,7 +140,7 @@ static char *groupid(const struct group *g, const struct faction *f)
|
||||||
static name idbuf[8];
|
static name idbuf[8];
|
||||||
static int nextbuf = 0;
|
static int nextbuf = 0;
|
||||||
char *buf = idbuf[(++nextbuf) % 8];
|
char *buf = idbuf[(++nextbuf) % 8];
|
||||||
sprintf(buf, "%s (%s)", g->name, factionid(f));
|
sprintf(buf, "%s (%s)", g->name, itoa36(f->no));
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1418,7 +1418,7 @@ int write_reports(faction * f, time_t ltime)
|
||||||
do {
|
do {
|
||||||
char filename[32];
|
char filename[32];
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
sprintf(filename, "%d-%s.%s", turn, factionid(f),
|
sprintf(filename, "%d-%s.%s", turn, itoa36(f->no),
|
||||||
rtype->extension);
|
rtype->extension);
|
||||||
join_path(reportpath(), filename, path, sizeof(path));
|
join_path(reportpath(), filename, path, sizeof(path));
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
@ -1441,7 +1441,7 @@ int write_reports(faction * f, time_t ltime)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!gotit) {
|
if (!gotit) {
|
||||||
log_warning("No report for faction %s!", factionid(f));
|
log_warning("No report for faction %s!", itoa36(f->no));
|
||||||
}
|
}
|
||||||
finish_reports(&ctx);
|
finish_reports(&ctx);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1452,7 +1452,7 @@ static void write_script(FILE * F, const faction * f)
|
||||||
report_type *rtype;
|
report_type *rtype;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
fprintf(F, "faction=%s:email=%s:lang=%s", factionid(f), f->email,
|
fprintf(F, "faction=%s:email=%s:lang=%s", itoa36(f->no), f->email,
|
||||||
locale_name(f->locale));
|
locale_name(f->locale));
|
||||||
if (f->options & (1 << O_BZIP2))
|
if (f->options & (1 << O_BZIP2))
|
||||||
fputs(":compression=bz2", F);
|
fputs(":compression=bz2", F);
|
||||||
|
|
12
src/spells.c
12
src/spells.c
|
@ -6291,21 +6291,21 @@ int sp_q_antimagie(castorder * co)
|
||||||
{
|
{
|
||||||
unit *u = pa->param[0]->data.u;
|
unit *u = pa->param[0]->data.u;
|
||||||
ap = &u->attribs;
|
ap = &u->attribs;
|
||||||
ts = unitid(u);
|
ts = itoa36(u->no);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPP_BUILDING:
|
case SPP_BUILDING:
|
||||||
{
|
{
|
||||||
building *b = pa->param[0]->data.b;
|
building *b = pa->param[0]->data.b;
|
||||||
ap = &b->attribs;
|
ap = &b->attribs;
|
||||||
ts = buildingid(b);
|
ts = itoa36(b->no);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPP_SHIP:
|
case SPP_SHIP:
|
||||||
{
|
{
|
||||||
ship *sh = pa->param[0]->data.sh;
|
ship *sh = pa->param[0]->data.sh;
|
||||||
ap = &sh->attribs;
|
ap = &sh->attribs;
|
||||||
ts = shipid(sh);
|
ts = itoa36(sh->no);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -6384,21 +6384,21 @@ int sp_break_curse(castorder * co)
|
||||||
{
|
{
|
||||||
unit *u = pa->param[0]->data.u;
|
unit *u = pa->param[0]->data.u;
|
||||||
ap = &u->attribs;
|
ap = &u->attribs;
|
||||||
ts = unitid(u);
|
ts = itoa36(u->no);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPP_BUILDING:
|
case SPP_BUILDING:
|
||||||
{
|
{
|
||||||
building *b = pa->param[0]->data.b;
|
building *b = pa->param[0]->data.b;
|
||||||
ap = &b->attribs;
|
ap = &b->attribs;
|
||||||
ts = buildingid(b);
|
ts = itoa36(b->no);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SPP_SHIP:
|
case SPP_SHIP:
|
||||||
{
|
{
|
||||||
ship *sh = pa->param[0]->data.sh;
|
ship *sh = pa->param[0]->data.sh;
|
||||||
ap = &sh->attribs;
|
ap = &sh->attribs;
|
||||||
ts = shipid(sh);
|
ts = itoa36(sh->no);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -439,7 +439,7 @@ int teach_cmd(unit * u, struct order *ord)
|
||||||
strncat(zOrder, " ", sz - 1);
|
strncat(zOrder, " ", sz - 1);
|
||||||
--sz;
|
--sz;
|
||||||
}
|
}
|
||||||
sz -= strlcpy(zOrder + 4096 - sz, unitid(u2), sz);
|
sz -= strlcpy(zOrder + 4096 - sz, itoa36(u2->no), sz);
|
||||||
|
|
||||||
if (getkeyword(u2->thisorder) != K_STUDY) {
|
if (getkeyword(u2->thisorder) != K_STUDY) {
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
|
|
|
@ -96,12 +96,12 @@ int update_nmrs(void)
|
||||||
int nmr = turn - f->lastorders + 1;
|
int nmr = turn - f->lastorders + 1;
|
||||||
if (timeout>0) {
|
if (timeout>0) {
|
||||||
if (nmr < 0 || nmr > timeout) {
|
if (nmr < 0 || nmr > timeout) {
|
||||||
log_error("faction %s has %d NMR", factionid(f), nmr);
|
log_error("faction %s has %d NMR", itoa36(f->no), nmr);
|
||||||
nmr = _max(0, nmr);
|
nmr = _max(0, nmr);
|
||||||
nmr = _min(nmr, timeout);
|
nmr = _min(nmr, timeout);
|
||||||
}
|
}
|
||||||
if (nmr > 0) {
|
if (nmr > 0) {
|
||||||
log_debug("faction %s has %d NMR", factionid(f), nmr);
|
log_debug("faction %s has %d NMR", itoa36(f->no), nmr);
|
||||||
}
|
}
|
||||||
++nmrs[nmr];
|
++nmrs[nmr];
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ static void shock_write(const trigger * t, struct storage *store)
|
||||||
next = next->next;
|
next = next->next;
|
||||||
}
|
}
|
||||||
if (next && u) {
|
if (next && u) {
|
||||||
log_error("more than one shock-attribut for %s on a unit. FIXED.\n", unitid(u));
|
log_error("more than one shock-attribut for %s on a unit. FIXED.\n", itoa36(u->no));
|
||||||
write_unit_reference(NULL, store);
|
write_unit_reference(NULL, store);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue