-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drawbridge jams #76
base: master
Are you sure you want to change the base?
Drawbridge jams #76
Conversation
Mentioned in 1654735 and a comment in do_play_instrument(music.c) as something which would be a nice future improvement if there were more bits available in flags/drawbridgemask. Turns out the DB_UNDER states are all mutually exclusive and never overlap, so a bit for the jam can be saved by rearranging those.
When a drawbridge becomes jammed, it can be unjammed with the #untrap command, on either the drawbridge itself or the portcullis.
#define DB_MOAT 0x0 | ||
#define DB_LAVA 0x4 | ||
#define DB_ICE 0x8 | ||
#define DB_FLOOR 0xc | ||
#define DB_UNDER 0xc /* mask for underneath */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, DB_UNDER = DB_LAVA | DB_ICE | DB_FLOOR
. In this change, DB_UNDER = DB_FLOOR
. Does this not introduce bugs in code that uses DB_UNDER?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still DB_MOAT | DB_LAVA | DB_ICE | DB_FLOOR
(0x0 | 0x4 | 0x8 | 0xc
is 0xc
), it's just that because they are mutually exclusive states, there can be overlap -- in other words, the checks are always (flags & DB_UNDER) == DB_MOAT
, never (flags & DB_MOAT) != 0
(which would be impossible even in the current arrangement, since one of them is 0
). So it's not necessary to give each one a unique bit; as long as the values themselves are unique and distinguishable all the existing code works fine.
But this hack to save a bit is also not really necessary if you've expanded flags
.
Mentioned in 1654735 and a comment in do_play_instrument(music.c) as
something which would be a nice future improvement if there were more
bits available in flags/drawbridgemask. Turns out the DB_UNDER states
are all mutually exclusive and never overlap, so a bit for the jam can
be saved by rearranging those. An attempt at implementing this.