Trying to understand the Angband 3.X source code

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

    Trying to understand the Angband 3.X source code

    This weekend I began the project of trying to update the NPP source code with as much of the Andi Sidwell era development as possible (NPP is currently based on Angband 3.0.6, the last RR version).

    My first attempt is to get the stores to interact like they do in the current Angband. I didn't get very far. I incorporated most of the updates in store.c, but my compiler (lcc-win32) gives more than a screenful errors for the display related functions, like this one:

    static void store_display_entry(menu_type *menu, int oid, bool cursor, int row, int col, int width)

    I added the ui-event.c and ui-menu.c to the build, along with the helper files listed in store.c, and now I get pagefuls of compile errors from those files instead. I am clearly missing a major section of code that need to be worked into my project, but I can't tell what it is. Is there anyone out there who can give me any guidance on this? 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
  • PowerDiver
    Prophet
    • Mar 2008
    • 2820

    #2
    Are you #including ui-menu.h ?

    Comment

    • nppangband
      NPPAngband Maintainer
      • Dec 2008
      • 926

      #3
      Yes, I included that. I made sure all of the .h files at the top of Angband's current store.c are included. Now they are giving me pages and pages of error messages.

      I was wondering if I have to include all the changes in main-win.c as well, or if that is completely unrelated.

      I probably also need to try to compile Angband with lcc-win as well. There used to be instructions for it. Maybe that compiler can't do it any more.
      NPPAngband current home page: http://nppangband.bitshepherd.net/
      Source code repository:
      https://github.com/nppangband/NPPAngband_QT
      Downloads:
      https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

      Comment

      • nppangband
        NPPAngband Maintainer
        • Dec 2008
        • 926

        #4
        I found most of the problem, I was missing ui.h.

        The final compile error I get is for any code related to "ui_event_data".

        I grepped the angband source code, and I cannot find where this is defined.

        Thanks to anyone who can help with this.
        NPPAngband current home page: http://nppangband.bitshepherd.net/
        Source code repository:
        https://github.com/nppangband/NPPAngband_QT
        Downloads:
        https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

        Comment

        • PowerDiver
          Prophet
          • Mar 2008
          • 2820

          #5
          Originally posted by nppangband
          I found most of the problem, I was missing ui.h.

          The final compile error I get is for any code related to "ui_event_data".

          I grepped the angband source code, and I cannot find where this is defined.

          Thanks to anyone who can help with this.
          ui-event.h

          I guess it looks a little different since the def is at the end of a struct statement.

          Comment

          • Nick
            Vanilla maintainer
            • Apr 2007
            • 9637

            #6
            Originally posted by nppangband
            This weekend I began the project of trying to update the NPP source code with as much of the Andi Sidwell era development as possible (NPP is currently based on Angband 3.0.6, the last RR version).
            Excellent
            One for the Dark Lord on his dark throne
            In the Land of Mordor where the Shadows lie.

            Comment

            • nppangband
              NPPAngband Maintainer
              • Dec 2008
              • 926

              #7
              Thanks! I wasn't sure that was it, because I had it included in ui-menu.c. But once I included it in z-term.h as well, it compiled.

              Of course getting it to compile and getting it to work are two completely different things, but that's a good first step.
              NPPAngband current home page: http://nppangband.bitshepherd.net/
              Source code repository:
              https://github.com/nppangband/NPPAngband_QT
              Downloads:
              https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

              Comment

              • Pete Mack
                Prophet
                • Apr 2007
                • 6883

                #8
                @jeff [nppangband] --
                If you have questions about the menu code, let me know. I wrote the menu event model 2 or 3 years back, along with the big refactoring of cmd4.c (now cmd-know.c)

                The menu code you can live without. The cmd4.c stuff you will certainly want. (npp 5 still uses the original crazy non-relational knowledge model.) You can get standalone cmd4.c from unangband if you don't want to port all your menu code. The menu code is useful only if you want small-screen and/or mouse support.

                If you do want small-screen support, you will also need to port files.c, and get a whole bunch of stuff from Nick (FAAnangband)
                Last edited by Pete Mack; June 2, 2010, 06:07.

                Comment

                • nppangband
                  NPPAngband Maintainer
                  • Dec 2008
                  • 926

                  #9
                  @Pete - thanks for the offer help me get up to speed on the Angband code. I am going to need it. I am going to try to work things one file at a time....starting with store.c (but now I have to figure out how the menu code works, because I have to change the Angband store.c code so it handles NPPAngband's store services and the adventurer's guild quests. Next will come birth.c, which should be easier.

                  After that, I want to get the new main-win.c to work with NPP. I don't know what to do about the other operating systems (MAC and Linux). I can look at the new main*.c files and change things I know need to be changed for NPP, but I can't compile or test it. The new makefiles make absolutely no sense to me (they don't list the individual files, so I can't tell if I have to modify them to add the files unique to NPP such as effects.c, quest.c, and terrain.c). Then after all that I will take on updating cmd4.c.

                  It looks like Angband has made alot of good changes, and dropped support for alot of the older operating systems. IMHO that was a good thing, since it allowed Angband to move to a modern open source license. My first goal is to get NPP there too.

                  I seriously debated which would be the bigger project, adding all the new Angband code to NPP, or putting all the NPP changes into the current Angband code. But the changes necessary to add 4gai and UnAngband terrain features are so extensive those two features alone would have made it a bigger task.
                  NPPAngband current home page: http://nppangband.bitshepherd.net/
                  Source code repository:
                  https://github.com/nppangband/NPPAngband_QT
                  Downloads:
                  https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

                  Comment

                  • nppangband
                    NPPAngband Maintainer
                    • Dec 2008
                    • 926

                    #10
                    One quick question (since you mentioned small screen support). Is Angband still married to a default 80x24 screen support?

                    Has anyone ever decided to make the default screen size a little bit larger?
                    NPPAngband current home page: http://nppangband.bitshepherd.net/
                    Source code repository:
                    https://github.com/nppangband/NPPAngband_QT
                    Downloads:
                    https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

                    Comment

                    • Derakon
                      Prophet
                      • Dec 2009
                      • 9022

                      #11
                      You can freely resize all of the windows in Vanilla and they'll make use of the extra space (or try to fit themselves in tighter).

                      Comment

                      • Pete Mack
                        Prophet
                        • Apr 2007
                        • 6883

                        #12
                        @jeff --
                        check out the make include files. (Makefile.src, Makefile.inc)
                        This is a much better model for maintaining dependencies.

                        Also, V does support small screen mode, but not to the extent that FA does.
                        One well-known player (Psi) plays FA on a small screen almost exclusively.

                        Also, the various ui fixes (menus, cmd0.c, cmd-know.c, etc) are supposed to make porting easier, not harder. If this is not the case, we've done something wrong.
                        Last edited by Pete Mack; June 2, 2010, 16:40.

                        Comment

                        • nppangband
                          NPPAngband Maintainer
                          • Dec 2008
                          • 926

                          #13
                          Pete - I am sure it will be easier, once I understand it. You all have done a fine job. Everything I know about C and programming I learned from reading & working with the Angband source code, so all the code cleanup you all have done are completely new concepts to me. My NPP co-developer Diego is the true programmer who usually does the heavy lifting when it comes to new ideas. I usually work on incorporating ideas from other variants, where I have somebody else's written code as a starting point. So I will spend a couple weeks poking around the new Angband source, RTFM, and ask questions and then hopefully I will understand it enough to fully incorporate it into NPP.

                          But the quests, 4gai and Unangband terrain projects required a re-write of more than half the source code. I will definitely be quicker and easier to put the Angband ui improvements into NPP and then gradually change the code so that it is current with the latest Vanilla releases.
                          NPPAngband current home page: http://nppangband.bitshepherd.net/
                          Source code repository:
                          https://github.com/nppangband/NPPAngband_QT
                          Downloads:
                          https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57

                          Comment

                          • PowerDiver
                            Prophet
                            • Mar 2008
                            • 2820

                            #14
                            Originally posted by nppangband
                            Has anyone ever decided to make the default screen size a little bit larger?
                            I usually resize my window to cover most of the screen. Others leave room for secondary windows for monster lists etc. Ever since the detection spells were changed to areas independent of the screen size, it is not abusive, so it seems like the obvious thing to do.

                            Comment

                            • d_m
                              Angband Devteam member
                              • Aug 2008
                              • 1517

                              #15
                              Originally posted by nppangband
                              One quick question (since you mentioned small screen support). Is Angband still married to a default 80x24 screen support?

                              Has anyone ever decided to make the default screen size a little bit larger?
                              I want Angband to always be playable on the Linux console in GCU mode, so I would oppose any change that makes an 80x24 main screen unplayable (or really, worse than it currently is). Beyond that I'm not invested in what the default sizes are--if main-win (or main-sdl or main-x11) had other defaults it wouldn't bother me.
                              linux->xterm->screen->pmacs

                              Comment

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