Really impressed with the angband code base

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pete Mack
    Prophet
    • Apr 2007
    • 6883

    Really impressed with the angband code base

    The use of tables, etc, is very well done now. I made some early stabs at 10 years ago in the leadup to v3.5. But where it is now is vastly improved. (Flag values, for example!) The only potential downside is any variant maintainer will have a difficult time applying the improvements because they are so extensive and with so much file reorganization--diff3 doesn't work well.
  • Nick
    Vanilla maintainer
    • Apr 2007
    • 9637

    #2
    Thanks Pete, there's been a lot of work gone into it over a long time.

    The aim is to move more stuff still out to edit files - messages, for example - and only have compiled-in tables where strictly necessary.
    One for the Dark Lord on his dark throne
    In the Land of Mordor where the Shadows lie.

    Comment

    • Pete Mack
      Prophet
      • Apr 2007
      • 6883

      #3
      There is roughly 25% less non-comment code vs 3.1, which is a really large cut as such things go, especially since there's added functionality (like working randarts)

      Comment

      • takkaria
        Veteran
        • Apr 2007
        • 1951

        #4
        Originally posted by Pete Mack
        There is roughly 25% less non-comment code vs 3.1, which is a really large cut as such things go, especially since there's added functionality (like working randarts)
        Some portion of this might be just from a shift in coding style from having opening braces on separate lines? But that's a good count! I would have figured that the codebase was increasing in size, but seems like that's an illusion caused by having the code spread across more files.
        takkaria whispers something about options. -more-

        Comment

        • Pete Mack
          Prophet
          • Apr 2007
          • 6883

          #5
          I'm wrong. There is more now, not less. I was comparing with 3.0.5. I'd forgotten when the cleanup started.

          It still is shorter than 3.0.5 by 10%, even excluding all lua stuff.

          Comment

          • PowerWyrm
            Prophet
            • Apr 2008
            • 2986

            #6
            Originally posted by Pete Mack
            The use of tables, etc, is very well done now. I made some early stabs at 10 years ago in the leadup to v3.5. But where it is now is vastly improved. (Flag values, for example!) The only potential downside is any variant maintainer will have a difficult time applying the improvements because they are so extensive and with so much file reorganization--diff3 doesn't work well.
            <- variant maintainer who did exactly that
            PWMAngband variant maintainer - check https://github.com/draconisPW/PWMAngband (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!

            Comment

            • Pete Mack
              Prophet
              • Apr 2007
              • 6883

              #7
              ...and just what part was the hardest?
              It occurs to me that a separate changes.txt file in the src directory should have a list of all the historical improvements, since most variants forked from 3.0.
              I can start: (Note: code cleanup and UI only. No gameplay changes)
              Removal of lua (3.1.0)
              Menus (3.1.0)
              Events (3.1.0)
              Knowledge (3.1.0)
              First use of generator .h files and use of loops instead of of ugly switch blocks (3.1.0)
              commands function pointers ("object oriented" C) 3.1.1
              Event-driven display (3.1.3?)
              I don't know when the other changes were made
              Readable .txt files/
              prettification of txt parser
              Full use of loops/generator .h files
              Clean implementation of extended flags
              Cleanup of options
              Reorganization to comprehensible file names
              I don't know what else. (These all belong in any notional angband base)

              The code now makes an excellent example for well written C. (3.0.x was emphatically not, although it has moments of brilliance, like the illumination computation and terminal model.)

              Originally posted by PowerWyrm
              <- variant maintainer who did exactly that

              Comment

              • PowerWyrm
                Prophet
                • Apr 2008
                • 2986

                #8
                Originally posted by Pete Mack
                ...and just what part was the hardest?
                Nothing was hard... except porting 20+ pages of commits from the master branch and for each checking how it would work with real time + multiplayer. Currently, the only big problem with the Angband source code is that it implies in too many places that there is only one player and uses the "player" global variable:

                Code:
                void foo(struct player *p)
                {
                    do_something(player); <-- should be do_something(p)
                 ...
                    if (monster_is_visible) {...} <-- should be if (player_can_see_monster(p))
                 ...
                }
                PWMAngband variant maintainer - check https://github.com/draconisPW/PWMAngband (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!

                Comment

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