question about bitflags

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nppangband
    NPPAngband Maintainer
    • Dec 2008
    • 926

    question about bitflags

    The NPP codebase is current with NPP 3.1.2v2. I noticed the big change to bitflags in later versions, and I have seen the devteam talk about it. I was wondering, what was the big advantage to make that change?

    My main reason for asking was for me to try to figure out when to update the NPP codebase again. My thoughts are I might wait several years between updates. To go from the 2.9 codebase to 3.1.2v2 took me about 6 months to implement get relatively bug-free. Diego and I have made *ALOT* of changes in 8 years.

    Also, is 3.1.2v2 later or earlier than the 3.1.2 tagged on github?

    Thanks,
    NPPAngband current home page: http://nppangband.bitshepherd.net/
    Source code repository:
    https://github.com/nppangband/NPPAngband_QT
    Downloads:
    https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57
  • Nick
    Vanilla maintainer
    • Apr 2007
    • 9647

    #2
    Originally posted by nppangband
    The NPP codebase is current with NPP 3.1.2v2. I noticed the big change to bitflags in later versions, and I have seen the devteam talk about it. I was wondering, what was the big advantage to make that change?
    The big advantage is that, jointly with the new list*.h files and correct parsing (in init2.c), they mean that anything defined by bitflags (monster flags, object flags, etc etc) is no longer as hard-coded. It takes considerable effort to change over, but subsequent bitflag changes become almost painless.

    My main reason for asking was for me to try to figure out when to update the NPP codebase again. My thoughts are I might wait several years between updates. To go from the 2.9 codebase to 3.1.2v2 took me about 6 months to implement get relatively bug-free. Diego and I have made *ALOT* of changes in 8 years.
    Getting updated to 3.2.0 from (about) 3.1.0 for me was a lot of work. I'm now starting to think of moving to 3.3 sooner rather than later; a quick look make me think that won't be as painful.

    This page may help.
    One for the Dark Lord on his dark throne
    In the Land of Mordor where the Shadows lie.

    Comment

    • Magnate
      Angband Devteam member
      • May 2007
      • 5110

      #3
      IMO the main advantage of bitflags is the ability to use a whole bunch of macros to the functions in z-bitflag.c - so providing you have defined OF_SIZE correctly you can use of_on(o_ptr, flag), of_off(ditto), of_has(), of_empty() etc. etc. This is a really nice and intuitive interface which gets rid of all the if (variable & HARDCODED_FOO) constructions. There are also some really useful tricks like of_next() for cycling through flags without needing to know which ones are set, and of_union/inter/diff to deal with two bitflags.

      Edit: 3.1.2v2 was to 3.1.2 what 3.3.1 was to 3.3.0 - it should really have been called 3.1.3
      "Been away so long I hardly knew the place, gee it's good to be back home" - The Beatles

      Comment

      Working...
      😀
      😂
      🥰
      😘
      🤢
      😎
      😞
      😡
      👍
      👎