Skip to content

Commit

Permalink
flying ships (#1048)
Browse files Browse the repository at this point in the history
* attempt fallback for bad encoding headers

* Fix levitation duration

Ship flag was persisted and somehow never cleared.
Resolves https://bugs.eressea.de/view.php?id=2997
  • Loading branch information
ennorehling committed Mar 3, 2024
1 parent 0853b65 commit f5d3e6e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
3 changes: 2 additions & 1 deletion scripts/tests/e2/e2features.lua
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,9 @@ function test_levitate()
u:add_order("ARBEITE")
levitate_ship(u.ship, u, 2, 1)
assert_equal(32, u.ship.flags)
assert_not_nil(u.ship:get_curse('flyingship'))
process_orders()
assert_equal(0, u.ship.flags)
assert_nil(u.ship:get_curse('flyingship'))
end

function test_levitation_ring()
Expand Down
1 change: 1 addition & 0 deletions src/kernel/save.c
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,7 @@ ship *read_ship(gamedata *data)

if (data->version >= FOSS_VERSION) {
READ_INT(store, &sh->flags);
sh->flags &= SFL_SAVEMASK;
}

/* Attribute rekursiv einlesen */
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/ship.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ typedef struct ship_type {
#define SF_FISHING (1<<4) /* was on an ocean, can fish */
#define SF_FLYING (1<<5) /* the ship can fly */

#define SFL_SAVEMASK (SF_FLYING)
#define SFL_SAVEMASK 0
#define INCOME_FISHING 10

typedef struct ship {
Expand Down
18 changes: 2 additions & 16 deletions src/spells/flyingship.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,27 +103,13 @@ static int flyingship_read(gamedata * data, curse * c, void *target)
{
ship *sh = (ship *)target;
c->data.v = sh;
if (data->version < FOSS_VERSION) {
sh->flags |= SF_FLYING;
return 0;
}
assert(sh->flags & SF_FLYING);
return 0;
}

static int flyingship_age(curse * c)
{
ship *sh = (ship *)c->data.v;
if (sh && c->duration == 1) {
sh->flags &= ~SF_FLYING;
return 1;
}
sh->flags |= SF_FLYING;
return 0;
}

const struct curse_type ct_flyingship = { "flyingship",
CURSETYP_NORM, 0, NO_MERGE, cinfo_ship, NULL, flyingship_read,
NULL, NULL, flyingship_age
NULL, NULL, NULL
};

void register_flyingship(void)
Expand Down
Binary file added tests/data/test.dat
Binary file not shown.

0 comments on commit f5d3e6e

Please sign in to comment.