forked from github/server
Merge pull request #235 from badgerman/develop
fixing some small non-critical bugs
This commit is contained in:
commit
f1e3bc7013
13 changed files with 106 additions and 83 deletions
78
src/battle.c
78
src/battle.c
|
@ -3760,7 +3760,7 @@ static int battle_report(battle * b)
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
|
||||||
if (komma) {
|
if (komma) {
|
||||||
strlcpy(bufp, ", ", size);
|
bytes = strlcpy(bufp, ", ", size);
|
||||||
if (wrptr(&bufp, &size, bytes) != 0)
|
if (wrptr(&bufp, &size, bytes) != 0)
|
||||||
WARN_STATIC_BUFFER();
|
WARN_STATIC_BUFFER();
|
||||||
}
|
}
|
||||||
|
@ -4236,48 +4236,48 @@ static void battle_flee(battle * b)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_enemy(battle *b, unit *u1, unit *u2) {
|
static bool is_enemy(battle *b, unit *u1, unit *u2) {
|
||||||
if (u1->faction != u2->faction) {
|
if (u1->faction != u2->faction) {
|
||||||
if (b) {
|
if (b) {
|
||||||
side *es, *s1 = 0, *s2 = 0;
|
side *es, *s1 = 0, *s2 = 0;
|
||||||
for (es = b->sides; es != b->sides + b->nsides; ++es) {
|
for (es = b->sides; es != b->sides + b->nsides; ++es) {
|
||||||
if (!s1 && es->faction == u1->faction) s1 = es;
|
if (!s1 && es->faction == u1->faction) s1 = es;
|
||||||
else if (!s2 && es->faction == u2->faction) s2 = es;
|
else if (!s2 && es->faction == u2->faction) s2 = es;
|
||||||
if (s1 && s2) break;
|
if (s1 && s2) break;
|
||||||
}
|
}
|
||||||
return enemy(s1, s2);
|
return enemy(s1, s2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return !help_enter(u1, u2);
|
return !help_enter(u1, u2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void force_leave(region *r, battle *b) {
|
void force_leave(region *r, battle *b) {
|
||||||
unit *u;
|
unit *u;
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
unit *uo = NULL;
|
unit *uo = NULL;
|
||||||
if (u->building) {
|
if (u->building) {
|
||||||
uo = building_owner(u->building);
|
uo = building_owner(u->building);
|
||||||
}
|
}
|
||||||
if (u->ship && r->land) {
|
if (u->ship && r->land) {
|
||||||
uo = ship_owner(u->ship);
|
uo = ship_owner(u->ship);
|
||||||
}
|
}
|
||||||
if (uo && is_enemy(b, uo, u)) {
|
if (uo && is_enemy(b, uo, u)) {
|
||||||
message *msg = NULL;
|
message *msg = NULL;
|
||||||
if (u->building) {
|
if (u->building) {
|
||||||
msg = msg_message("force_leave_building", "unit owner building", u, uo, u->building);
|
msg = msg_message("force_leave_building", "unit owner building", u, uo, u->building);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg = msg_message("force_leave_ship", "unit owner ship", u, uo, u->ship);
|
msg = msg_message("force_leave_ship", "unit owner ship", u, uo, u->ship);
|
||||||
}
|
}
|
||||||
if (msg) {
|
if (msg) {
|
||||||
ADDMSG(&u->faction->msgs, msg);
|
ADDMSG(&u->faction->msgs, msg);
|
||||||
}
|
}
|
||||||
leave(u, false);
|
leave(u, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -130,13 +130,13 @@ extern "C" {
|
||||||
} weapon;
|
} weapon;
|
||||||
|
|
||||||
/*** fighter::person::flags ***/
|
/*** fighter::person::flags ***/
|
||||||
#define FL_TIRED 1
|
#define FL_TIRED 1
|
||||||
#define FL_DAZZLED 2 /* durch Untote oder Dämonen eingeschüchtert */
|
#define FL_DAZZLED 2 /* durch Untote oder Dämonen eingeschüchtert */
|
||||||
#define FL_PANICED 4
|
#define FL_PANICED 4
|
||||||
#define FL_COURAGE 8 /* Helden fliehen nie */
|
#define FL_COURAGE 8 /* Helden fliehen nie */
|
||||||
#define FL_SLEEPING 16
|
#define FL_SLEEPING 16
|
||||||
#define FL_STUNNED 32 /* eine Runde keinen Angriff */
|
#define FL_STUNNED 32 /* eine Runde keinen Angriff */
|
||||||
#define FL_HIT 64 /* the person at attacked */
|
#define FL_HIT 64 /* the person at attacked */
|
||||||
|
|
||||||
typedef struct troop {
|
typedef struct troop {
|
||||||
struct fighter *fighter;
|
struct fighter *fighter;
|
||||||
|
@ -270,7 +270,7 @@ extern "C" {
|
||||||
const struct group * g, unsigned int flags,
|
const struct group * g, unsigned int flags,
|
||||||
const struct faction * stealthfaction);
|
const struct faction * stealthfaction);
|
||||||
int skilldiff(troop at, troop dt, int dist);
|
int skilldiff(troop at, troop dt, int dist);
|
||||||
void force_leave(struct region *r, struct battle *b);
|
void force_leave(struct region *r, struct battle *b);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
+-------------------+
|
+-------------------+
|
||||||
| | Enno Rehling <enno@eressea.de>
|
| | Enno Rehling <enno@eressea.de>
|
||||||
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
| Eressea PBEM host | Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||||
|
@ -191,13 +191,13 @@ static int tolua_building_create(lua_State * L)
|
||||||
{
|
{
|
||||||
region *r = (region *)tolua_tousertype(L, 1, 0);
|
region *r = (region *)tolua_tousertype(L, 1, 0);
|
||||||
const char *bname = tolua_tostring(L, 2, 0);
|
const char *bname = tolua_tostring(L, 2, 0);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
log_error("building.create expects a region as argument 1");
|
log_error("building.create expects a region as argument 1");
|
||||||
}
|
}
|
||||||
if (!bname) {
|
if (!bname) {
|
||||||
log_error("building.create expects a name as argument 2");
|
log_error("building.create expects a name as argument 2");
|
||||||
}
|
}
|
||||||
if (bname) {
|
if (bname) {
|
||||||
const building_type *btype = bt_find(bname);
|
const building_type *btype = bt_find(bname);
|
||||||
if (btype) {
|
if (btype) {
|
||||||
building *b = new_building(btype, r, default_locale);
|
building *b = new_building(btype, r, default_locale);
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#define VERSION_MAJOR 3
|
#define VERSION_MAJOR 3
|
||||||
#define VERSION_MINOR 6
|
#define VERSION_MINOR 6
|
||||||
#define VERSION_BUILD 0
|
#define VERSION_BUILD 1
|
||||||
|
|
|
@ -1441,13 +1441,13 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sr->mode == see_unit || sr->mode == see_travel) {
|
if (sr->mode == see_unit || sr->mode == see_travel) {
|
||||||
cr_output_messages(F, r->msgs, f);
|
cr_output_messages(F, r->msgs, f);
|
||||||
{
|
{
|
||||||
message_list *mlist = r_getmessages(r, f);
|
message_list *mlist = r_getmessages(r, f);
|
||||||
if (mlist)
|
if (mlist)
|
||||||
cr_output_messages(F, mlist, f);
|
cr_output_messages(F, mlist, f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* buildings */
|
/* buildings */
|
||||||
for (b = rbuildings(r); b; b = b->next) {
|
for (b = rbuildings(r); b; b = b->next) {
|
||||||
int fno = -1;
|
int fno = -1;
|
||||||
|
|
|
@ -55,6 +55,9 @@ static void test_alliance_join(CuTest *tc) {
|
||||||
setalliance(fix.f2, al);
|
setalliance(fix.f2, al);
|
||||||
CuAssertPtrEquals(tc, fix.f1, alliance_get_leader(al));
|
CuAssertPtrEquals(tc, fix.f1, alliance_get_leader(al));
|
||||||
CuAssertTrue(tc, is_allied(fix.f1, fix.f2));
|
CuAssertTrue(tc, is_allied(fix.f1, fix.f2));
|
||||||
|
setalliance(fix.f1, 0);
|
||||||
|
CuAssertPtrEquals(tc, fix.f2, alliance_get_leader(al));
|
||||||
|
CuAssertTrue(tc, !is_allied(fix.f1, fix.f2));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -651,6 +651,9 @@ void remove_empty_factions(void)
|
||||||
*fp = f->next;
|
*fp = f->next;
|
||||||
funhash(f);
|
funhash(f);
|
||||||
free_faction(f);
|
free_faction(f);
|
||||||
|
if (f->alliance && f->alliance->_leader == f) {
|
||||||
|
setalliance(f, 0);
|
||||||
|
}
|
||||||
free(f);
|
free(f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
|
|
||||||
#include <kernel/ally.h>
|
#include <kernel/ally.h>
|
||||||
|
#include <kernel/alliance.h>
|
||||||
#include <kernel/faction.h>
|
#include <kernel/faction.h>
|
||||||
#include <kernel/race.h>
|
#include <kernel/race.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
|
@ -30,6 +31,20 @@ static void test_remove_empty_factions_allies(CuTest *tc) {
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_remove_empty_factions_alliance(CuTest *tc) {
|
||||||
|
faction *f;
|
||||||
|
struct alliance *al;
|
||||||
|
|
||||||
|
test_cleanup();
|
||||||
|
f = test_create_faction(0);
|
||||||
|
al = makealliance(0, "Hodor");
|
||||||
|
setalliance(f, al);
|
||||||
|
CuAssertPtrEquals(tc, f, alliance_get_leader(al));
|
||||||
|
remove_empty_factions();
|
||||||
|
CuAssertPtrEquals(tc, 0, al->_leader);
|
||||||
|
test_cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
static void test_remove_empty_factions(CuTest *tc) {
|
static void test_remove_empty_factions(CuTest *tc) {
|
||||||
faction *f, *fm;
|
faction *f, *fm;
|
||||||
int fno;
|
int fno;
|
||||||
|
@ -160,6 +175,7 @@ CuSuite *get_faction_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_addfaction);
|
SUITE_ADD_TEST(suite, test_addfaction);
|
||||||
SUITE_ADD_TEST(suite, test_remove_empty_factions);
|
SUITE_ADD_TEST(suite, test_remove_empty_factions);
|
||||||
SUITE_ADD_TEST(suite, test_remove_empty_factions_allies);
|
SUITE_ADD_TEST(suite, test_remove_empty_factions_allies);
|
||||||
|
SUITE_ADD_TEST(suite, test_remove_empty_factions_alliance);
|
||||||
SUITE_ADD_TEST(suite, test_remove_dead_factions);
|
SUITE_ADD_TEST(suite, test_remove_dead_factions);
|
||||||
SUITE_ADD_TEST(suite, test_get_monsters);
|
SUITE_ADD_TEST(suite, test_get_monsters);
|
||||||
SUITE_ADD_TEST(suite, test_set_origin);
|
SUITE_ADD_TEST(suite, test_set_origin);
|
||||||
|
|
|
@ -183,7 +183,7 @@ race *rc_get_or_create(const char *zName)
|
||||||
rc->recruit_multi = 1.0F;
|
rc->recruit_multi = 1.0F;
|
||||||
rc->regaura = 1.0F;
|
rc->regaura = 1.0F;
|
||||||
rc->speed = 1.0F;
|
rc->speed = 1.0F;
|
||||||
rc->battle_flags = BF_CANATTACK;
|
rc->battle_flags = BF_CANATTACK;
|
||||||
if (strchr(zName, ' ') != NULL) {
|
if (strchr(zName, ' ') != NULL) {
|
||||||
log_error("race '%s' has an invalid name. remove spaces\n", zName);
|
log_error("race '%s' has an invalid name. remove spaces\n", zName);
|
||||||
assert(strchr(zName, ' ') == NULL);
|
assert(strchr(zName, ' ') == NULL);
|
||||||
|
|
14
src/laws.c
14
src/laws.c
|
@ -4312,7 +4312,7 @@ bool help_enter(unit *uo, unit *u) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_force_leave(region *r) {
|
static void do_force_leave(region *r) {
|
||||||
force_leave(r, NULL);
|
force_leave(r, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rule_force_leave(int flags) {
|
bool rule_force_leave(int flags) {
|
||||||
|
@ -4356,11 +4356,11 @@ void init_processor(void)
|
||||||
{
|
{
|
||||||
int p;
|
int p;
|
||||||
|
|
||||||
while (processors) {
|
while (processors) {
|
||||||
processor * next = processors->next;
|
processor * next = processors->next;
|
||||||
free(processors);
|
free(processors);
|
||||||
processors = next;
|
processors = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = 10;
|
p = 10;
|
||||||
add_proc_global(p, new_units, "Neue Einheiten erschaffen");
|
add_proc_global(p, new_units, "Neue Einheiten erschaffen");
|
||||||
|
@ -4514,7 +4514,7 @@ void processorders(void)
|
||||||
{
|
{
|
||||||
init_processor();
|
init_processor();
|
||||||
|
|
||||||
update_spells();
|
update_spells();
|
||||||
process();
|
process();
|
||||||
/*************************************************/
|
/*************************************************/
|
||||||
|
|
||||||
|
|
|
@ -1126,6 +1126,7 @@ void randomevents(void)
|
||||||
}
|
}
|
||||||
else if (r->age > 20 && rng_int() % 100 < 8) {
|
else if (r->age > 20 && rng_int() % 100 < 8) {
|
||||||
volcano_outbreak(r);
|
volcano_outbreak(r);
|
||||||
|
rsetterrain(r, T_VOLCANO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,18 +114,18 @@ const char *combatstatus[] = {
|
||||||
const char *report_kampfstatus(const unit * u, const struct locale *lang)
|
const char *report_kampfstatus(const unit * u, const struct locale *lang)
|
||||||
{
|
{
|
||||||
static char fsbuf[64]; // FIXME: static return value
|
static char fsbuf[64]; // FIXME: static return value
|
||||||
const char * status = LOC(lang, combatstatus[u->status]);
|
const char * status = LOC(lang, combatstatus[u->status]);
|
||||||
|
|
||||||
if (!status) {
|
if (!status) {
|
||||||
const char *lname = locale_name(lang);
|
const char *lname = locale_name(lang);
|
||||||
struct locale *wloc = get_or_create_locale(lname);
|
struct locale *wloc = get_or_create_locale(lname);
|
||||||
log_error("no translation for combat status %s in %s", combatstatus[u->status], lname);
|
log_error("no translation for combat status %s in %s", combatstatus[u->status], lname);
|
||||||
locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]);
|
locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]);
|
||||||
strlcpy(fsbuf, combatstatus[u->status], sizeof(fsbuf));
|
strlcpy(fsbuf, combatstatus[u->status], sizeof(fsbuf));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strlcpy(fsbuf, status, sizeof(fsbuf));
|
strlcpy(fsbuf, status, sizeof(fsbuf));
|
||||||
}
|
}
|
||||||
if (fval(u, UFL_NOAID)) {
|
if (fval(u, UFL_NOAID)) {
|
||||||
strcat(fsbuf, ", ");
|
strcat(fsbuf, ", ");
|
||||||
strcat(fsbuf, LOC(lang, "status_noaid"));
|
strcat(fsbuf, LOC(lang, "status_noaid"));
|
||||||
|
@ -139,7 +139,7 @@ const char *hp_status(const unit * u)
|
||||||
double p;
|
double p;
|
||||||
int max_hp = u->number * unit_max_hp(u);
|
int max_hp = u->number * unit_max_hp(u);
|
||||||
|
|
||||||
if (u->hp == max_hp)
|
if (u->hp == max_hp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
p = (double)((double)u->hp / (double)(max_hp));
|
p = (double)((double)u->hp / (double)(max_hp));
|
||||||
|
@ -978,7 +978,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned
|
||||||
|
|
||||||
assert(width <= REPORTWIDTH);
|
assert(width <= REPORTWIDTH);
|
||||||
width -= indent;
|
width -= indent;
|
||||||
firstline = (mark!=0 && indent>2);
|
firstline = (mark != 0 && indent > 2);
|
||||||
*SP = 0;
|
*SP = 0;
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
|
@ -1002,7 +1002,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned
|
||||||
if (!cut) {
|
if (!cut) {
|
||||||
cut = s + _min(len, REPORTWIDTH);
|
cut = s + _min(len, REPORTWIDTH);
|
||||||
}
|
}
|
||||||
strncpy(buf+indent, s, cut - s);
|
strncpy(buf + indent, s, cut - s);
|
||||||
buf[indent + (cut - s)] = 0;
|
buf[indent + (cut - s)] = 0;
|
||||||
addstrlist(SP, buf); // TODO: too much string copying, cut out this function
|
addstrlist(SP, buf); // TODO: too much string copying, cut out this function
|
||||||
while (*cut == ' ') {
|
while (*cut == ' ') {
|
||||||
|
@ -2445,7 +2445,7 @@ static void eval_trail(struct opstack **stack, const void *userdata)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*bufp = 0;
|
*bufp = 0;
|
||||||
var.v = strcpy(balloc((size_t)(bufp - buf +1)), buf);
|
var.v = strcpy(balloc((size_t)(bufp - buf + 1)), buf);
|
||||||
opush(stack, var);
|
opush(stack, var);
|
||||||
#ifdef _SECURECRT_ERRCODE_VALUES_DEFINED
|
#ifdef _SECURECRT_ERRCODE_VALUES_DEFINED
|
||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz)
|
||||||
register const char *s = src;
|
register const char *s = src;
|
||||||
register size_t n = siz;
|
register size_t n = siz;
|
||||||
|
|
||||||
assert(src && dst);
|
assert(src && dst);
|
||||||
/* Copy as many bytes as will fit */
|
/* Copy as many bytes as will fit */
|
||||||
if (n != 0 && --n != 0) {
|
if (n != 0 && --n != 0) {
|
||||||
do {
|
do {
|
||||||
|
|
Loading…
Reference in a new issue