Trying to understand the Angband 3.X source code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zaimoni
    Knight
    • Apr 2007
    • 590

    #46
    Requiring C99 means dropping support for both MSVC (C89 compiler only) and native MingW32 (recent standard header releases don't compile as C99).
    Zaiband: end the "I shouldn't have survived that" experience. V3.0.6 fork on Hg.
    Zaiband 3.0.10 ETA Mar. 7 2011 (Yes, schedule slipped. Latest testing indicates not enough assert() calls to allow release.)
    Z.C++: pre-alpha C/C++ compiler system (usable preprocessor). Also on Hg. Z.C++ 0.0.10 ETA December 31 2011

    Comment

    • Pete Mack
      Prophet
      • Apr 2007
      • 6883

      #47
      MSVC doesn't support full c99, but it does support the intersection of c99 with C++.
      So bool is ok, but it's a built-in. (Dont' include stdbool.h)

      Comment

      • nppangband
        NPPAngband Maintainer
        • Dec 2008
        • 926

        #48
        I have a bug that should be simple to fix, but I don't know where to do it.

        The game crashes if I use the up, down, left, or right direction keys on my keyboard without the numlock on, but the diagonal direction keys work fine. It crashes on this line, in textui_process_command.

        assert(p_ptr->command_cmd >= CHAR_MIN && p_ptr->command_cmd <= CHAR_MAX);

        If the numlock is on, the p_ptr->command is 59, and if numlock is off, the direction keys are between 138-141, and the game crashes. Again, the diagonal keys work fine either way

        Isn't there a pref file that converts certain keyboard commands like this? I know the 138 is above the 127 limit, but I can't figure out why it would be crashing the game. I have assert.h declared in h-basic.h just like in Angband.

        Any thoughts or suggestions? I am stumped. 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

        Comment

        • Nick
          Vanilla maintainer
          • Apr 2007
          • 9637

          #49
          Originally posted by nppangband
          assert(p_ptr->command_cmd >= CHAR_MIN && p_ptr->command_cmd <= CHAR_MAX);

          If the numlock is on, the p_ptr->command is 59, and if numlock is off, the direction keys are between 138-141, and the game crashes. Again, the diagonal keys work fine either way

          Isn't there a pref file that converts certain keyboard commands like this? I know the 138 is above the 127 limit, but I can't figure out why it would be crashing the game. I have assert.h declared in h-basic.h just like in Angband.
          The relevant file is pref-win.prf, IIRC. I have had endless troubles with it and arrow keys.
          If I understand assert correctly, that is what it does - if the condition is not satisfied, it terminates the program.
          Good luck
          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

            #50
            Originally posted by Nick
            The relevant file is pref-win.prf, IIRC. I have had endless troubles with it and arrow keys.
            If I understand assert correctly, that is what it does - if the condition is not satisfied, it terminates the program.
            Good luck
            Thanks! With that help I found it. Strangely, utting in the updated pref-win.prf fromthe current angband into NPP causes the crashes. If I keep the current one from NPPAngband it works fine.
            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

            • Soluzar
              Rookie
              • Jan 2010
              • 6

              #51
              Any chance you'll be implementing the SDL display module? I've become rather fond of it and miss it whenever I'm playing NPP. I'm really fond of it, actually... it is the main variant that I spend my Angbanding time on other than V.

              Comment

              • nppangband
                NPPAngband Maintainer
                • Dec 2008
                • 926

                #52
                I saw the question in Nick's thread first, ( http://angband.oook.cz/forum/showthread.php?t=3004), but here is the answer:

                For NPP 0.5.0, I am not sure. But very soon, the answer will be a definite yes.

                I have an updated version coming out that updates the core of NPP from Angband 3.0.6 to the current Angband 3.1.2v2 beta. It won't have all of the features yet, but it will have all of the updated makefiles, main-xxx files, mouse support, the improved Angband UI and all of the core files that make Angband run. That that point, anything that can compile the current Vanilla should compile NPP as well.

                My target for releasing a beta is August 1. I am actually almsot done now, but I have a project at work that is going to keep me busy for the next two weeks. I want to hold off the beta release until I actually will have time to fix the problems people discover.
                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

                • Soluzar
                  Rookie
                  • Jan 2010
                  • 6

                  #53
                  Originally posted by nppangband
                  My target for releasing a beta is August 1. I am actually almsot done now, but I have a project at work that is going to keep me busy for the next two weeks. I want to hold off the beta release until I actually will have time to fix the problems people discover.
                  I'm really glad that you're bringing the codebase in line with current V, since it's only fair to say that Andi and co. have implemented some really nice features. I'm glad NPP is still actively under development, and look forward to the results.

                  Comment

                  • nppangband
                    NPPAngband Maintainer
                    • Dec 2008
                    • 926

                    #54
                    Originally posted by Soluzar
                    I'm really glad that you're bringing the codebase in line with current V, since it's only fair to say that Andi and co. have implemented some really nice features. I'm glad NPP is still actively under development, and look forward to the results.
                    Thanks. Implementing the Vanilla changes is long overdue. After more than a decade of minimal changes in Vanilla, I think it is more active than most variants. I just hope I have the time to keep up with them.
                    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

                      #55
                      This is a quick question for the Angband maintainers. I just need to confirm how often store_display_entry is called.

                      The reason I ask is that in NPP, due to store services or quild rewards, charisma can change while a person is in the store (restore stat, increase stat, and sometimes a quest reward are stat increases.

                      I guess the player's charisma can change in Angabnd as well, if they take off or wield equipment. Do these lines (at the end of store_process_command) assure that inventory and prices re-drawn in the store?

                      Thanks.

                      event_signal(EVENT_INVENTORY);
                      event_signal(EVENT_EQUIPMENT);
                      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

                      • d_m
                        Angband Devteam member
                        • Aug 2008
                        • 1517

                        #56
                        Originally posted by nppangband
                        I guess the player's charisma can change in Angabnd as well, if they take off or wield equipment. Do these lines (at the end of store_process_command) assure that inventory and prices re-drawn in the store?

                        event_signal(EVENT_INVENTORY);
                        event_signal(EVENT_EQUIPMENT);
                        The only thing those events do (AFAIK) is to update the inventory/equipment subwindows... I don't think they have anything to do with redrawing prices in the store.

                        The event handlers are reigstered in src/xtra3.c if you want to see what they do.
                        linux->xterm->screen->pmacs

                        Comment

                        • nppangband
                          NPPAngband Maintainer
                          • Dec 2008
                          • 926

                          #57
                          Thanks. I tested it, and although I am not sure what code triggers it (something in ui-menu.c), but the game does re-price everything and re-draw all of the prices if the player's charisma changes when they are inside the store.
                          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

                            #58
                            store_display_entry is the function for displaying store inventory.
                            It's an event handler--it gets called for each row every time a menu action occurs.

                            Comment

                            • Pete Mack
                              Prophet
                              • Apr 2007
                              • 6883

                              #59
                              OK, I agree the current store.c event loop is a bit confusing.
                              I cleaned it up a bit.

                              diff is attached.

                              Edit:
                              Reloaded, to get rid of annoying flicker on double-tap (existing bug)
                              Edit:
                              There's a bug in this-- more prompt is not working for lists too long by one.
                              Attached Files
                              Last edited by Pete Mack; July 11, 2010, 05:21.

                              Comment

                              • Pete Mack
                                Prophet
                                • Apr 2007
                                • 6883

                                #60
                                @Jeff--
                                One other thing.
                                In cleaning up store.c, I recalled another trivial change I made ~3.0.8: adding type union
                                Code:
                                %y
                                to the list of string format characters for vstrnfmt and strnfmt.

                                It makes complicated formatting like files.c a lot easier. Unfortunately, it's not useful when you want to do formatted text with mixed colors.
                                I added some really hacky support for multiple colors in files.c -- display_panel
                                It makes formatting character info much easier, but it does not generalize.

                                ...

                                In fact, let me whip something up... TBC in a week or so.

                                Comment

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