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
|
@ -3760,7 +3760,7 @@ static int battle_report(battle * b)
|
|||
char buffer[32];
|
||||
|
||||
if (komma) {
|
||||
strlcpy(bufp, ", ", size);
|
||||
bytes = strlcpy(bufp, ", ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#define VERSION_MAJOR 3
|
||||
#define VERSION_MINOR 6
|
||||
#define VERSION_BUILD 0
|
||||
#define VERSION_BUILD 1
|
||||
|
|
|
@ -55,6 +55,9 @@ static void test_alliance_join(CuTest *tc) {
|
|||
setalliance(fix.f2, al);
|
||||
CuAssertPtrEquals(tc, fix.f1, alliance_get_leader(al));
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -651,6 +651,9 @@ void remove_empty_factions(void)
|
|||
*fp = f->next;
|
||||
funhash(f);
|
||||
free_faction(f);
|
||||
if (f->alliance && f->alliance->_leader == f) {
|
||||
setalliance(f, 0);
|
||||
}
|
||||
free(f);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <platform.h>
|
||||
|
||||
#include <kernel/ally.h>
|
||||
#include <kernel/alliance.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
|
@ -30,6 +31,20 @@ static void test_remove_empty_factions_allies(CuTest *tc) {
|
|||
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) {
|
||||
faction *f, *fm;
|
||||
int fno;
|
||||
|
@ -160,6 +175,7 @@ CuSuite *get_faction_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_addfaction);
|
||||
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_alliance);
|
||||
SUITE_ADD_TEST(suite, test_remove_dead_factions);
|
||||
SUITE_ADD_TEST(suite, test_get_monsters);
|
||||
SUITE_ADD_TEST(suite, test_set_origin);
|
||||
|
|
|
@ -1126,6 +1126,7 @@ void randomevents(void)
|
|||
}
|
||||
else if (r->age > 20 && rng_int() % 100 < 8) {
|
||||
volcano_outbreak(r);
|
||||
rsetterrain(r, T_VOLCANO);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -978,7 +978,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned
|
|||
|
||||
assert(width <= REPORTWIDTH);
|
||||
width -= indent;
|
||||
firstline = (mark!=0 && indent>2);
|
||||
firstline = (mark != 0 && indent > 2);
|
||||
*SP = 0;
|
||||
|
||||
while (len > 0) {
|
||||
|
@ -1002,7 +1002,7 @@ void split_paragraph(strlist ** SP, const char *s, unsigned int indent, unsigned
|
|||
if (!cut) {
|
||||
cut = s + _min(len, REPORTWIDTH);
|
||||
}
|
||||
strncpy(buf+indent, s, cut - s);
|
||||
strncpy(buf + indent, s, cut - s);
|
||||
buf[indent + (cut - s)] = 0;
|
||||
addstrlist(SP, buf); // TODO: too much string copying, cut out this function
|
||||
while (*cut == ' ') {
|
||||
|
@ -2445,7 +2445,7 @@ static void eval_trail(struct opstack **stack, const void *userdata)
|
|||
}
|
||||
}
|
||||
*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);
|
||||
#ifdef _SECURECRT_ERRCODE_VALUES_DEFINED
|
||||
if (errno == ERANGE) {
|
||||
|
|
Loading…
Reference in a new issue