forked from github/server
fix largestbuilding, broken in prev commit.
This commit is contained in:
parent
bdc7457a08
commit
3f8de76b9d
|
@ -643,12 +643,9 @@ bool is_building_type(const struct building_type *btype, const char *name) {
|
|||
building *largestbuilding(const region * r, cmp_building_cb cmp_gt,
|
||||
bool imaginary)
|
||||
{
|
||||
building *b, *best = r->buildings;
|
||||
building *b, *best = NULL;
|
||||
|
||||
if (!best) {
|
||||
return NULL;
|
||||
}
|
||||
for (b = best->next; b; b = b->next) {
|
||||
for (b = r->buildings; b; b = b->next) {
|
||||
if (cmp_gt(b, best) <= 0)
|
||||
continue;
|
||||
if (!imaginary) {
|
||||
|
|
|
@ -536,7 +536,8 @@ static void test_building_effsize(CuTest *tc) {
|
|||
}
|
||||
|
||||
static int cmp_size(const building *lhs, const building *rhs) {
|
||||
return lhs->size - rhs->size;
|
||||
assert(lhs);
|
||||
return rhs ? lhs->size - rhs->size : 1;
|
||||
}
|
||||
|
||||
static void test_largestbuilding(CuTest *tc) {
|
||||
|
|
Loading…
Reference in New Issue