Vanilla Code Questions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DavidMedley
    Veteran
    • Oct 2019
    • 1004

    #76
    Originally posted by Nick
    Here is my recommendation for managing your own version of the angband git repository:
    1. Fork the official repo (angband/angband) using the fork button on github
    2. Clone/download this to get your own local copy
    3. Keep your master branch up-to-date with the official master branch, do not do development work on your master branch
    4. For development work, create a branch and do your work there. Once it's ready for inclusion, push it to your github repo and make a pull request
    5. The official master branch will be updated frequently. Make sure that you (fairly frequently):
      • Pull changes from the official repo and update your master (it should be just a fast-forward, since you are not developing on your master);
      • Rebase your development branch or branches against your master branch, resolving any conflicts that arise


    This is how I work, and it should keep confusion to a minimum.
    I did some much overdue study on git. The above directions helped me a lot. I think the main step I was missing, and maybe should have been in these directions, was to add the original fork to my list of remotes:
    Code:
    git remote add official https://github.com/angband/angband.git
    After that it was pretty smooth sailing.
    Please like my indie game company on Facebook! https://www.facebook.com/RatherFunGames

    Comment

    • DavidMedley
      Veteran
      • Oct 2019
      • 1004

      #77
      Thanks for the advice, Sideways!
      Please like my indie game company on Facebook! https://www.facebook.com/RatherFunGames

      Comment

      • DavidMedley
        Veteran
        • Oct 2019
        • 1004

        #78
        I don't understand these errors.

        Code:
                         from player.c:19:
        player-attack.h:46:55: warning: ‘struct player’ declared inside parameter list will not be visible outside of this definition or declaration
         typedef struct attack_result (*ranged_attack) (struct player *p,
                                                               ^~~~~~
        player-attack.h:56:38: warning: ‘struct player’ declared inside parameter list will not be visible outside of this definition or declaration
         int chance_of_melee_hit(const struct player *p, const struct object *weapon);
                                              ^~~~~~
        player-attack.h:59:30: warning: ‘struct player’ declared inside parameter list will not be visible outside of this definition or declaration
         extern void py_attack(struct player *p, struct loc grid);
                                      ^~~~~~
        player-attack.h:60:35: warning: ‘struct player’ declared inside parameter list will not be visible outside of this definition or declaration
         extern bool py_attack_real(struct player *p, struct loc grid, bool *fear);
                                           ^~~~~~
        Successfully compiled player.c.
        My "BGmod" branch on Github is up to date now, if that helps.
        A free, single-player roguelike dungeon exploration game - damedley/myband
        Please like my indie game company on Facebook! https://www.facebook.com/RatherFunGames

        Comment

        • backwardsEric
          Knight
          • Aug 2019
          • 527

          #79
          Originally posted by DavidMedley
          I don't understand these errors.

          Code:
                           from player.c:19:
          player-attack.h:46:55: warning: ‘struct player’ declared inside
          parameter list will not be visible outside of this definition or declaration
           typedef struct attack_result (*ranged_attack) (struct player *p,
                                                                 ^~~~~~
          ...
          Successfully compiled player.c.
          Those are the first references to struct player that it saw in that compilation unit: effects.h is your first include file in player.c and neither it nor the files it pulls in bring in player.h. You could include player.h in player-attack.h or you could add a forward declaration of struct player to player-attack.h. The latter is just a way of introducing the name but doesn't provide a full declaration; it would look like

          Code:
          struct player;
          and you'd put it in player-attack.h before you mention struct player in the typedefs or function prototypes.

          Comment

          • DavidMedley
            Veteran
            • Oct 2019
            • 1004

            #80
            Yeah, that all makes sense. I guess the real question is: how did I introduce this warning, when I haven't touched player-attack.h, other than to add:
            Code:
            extern bool py_attack_real(struct player *p, struct loc grid, bool *fear);
            But that's probably something I have to figure out for myself.
            Please like my indie game company on Facebook! https://www.facebook.com/RatherFunGames

            Comment

            • Pete Mack
              Prophet
              • Apr 2007
              • 6883

              #81
              That reference to player IS the reason. If you first include player.h instead of picking it up later, the warning will vanish. But a forward declaration is better:

              strict player;

              ...
              Reference to *player. You only need the full structure when you dereference the pointer (with * or ->), and that never happens in .h files.

              Comment

              • DavidMedley
                Veteran
                • Oct 2019
                • 1004

                #82
                Who gets credit for this?
                Code:
                const s16b ddd[9] =
                { 2, 8, 6, 4, 3, 1, 9, 7, 5 };
                Or:
                Code:
                7 1 6
                3 5 2
                5 0 4
                Please like my indie game company on Facebook! https://www.facebook.com/RatherFunGames

                Comment

                • Pete Mack
                  Prophet
                  • Apr 2007
                  • 6883

                  #83
                  Not sure about what the second bit is, but the first part--the list of directions to allow iterating loops--is old, old code.

                  Originally posted by DavidMedley
                  Who gets credit for this?
                  Code:
                  const s16b ddd[9] =
                  { 2, 8, 6, 4, 3, 1, 9, 7, 5 };
                  Or:
                  Code:
                  7 1 6
                  3 5 2
                  5 0 4

                  Comment

                  • DavidMedley
                    Veteran
                    • Oct 2019
                    • 1004

                    #84
                    The second part is arranging it like you would on a numpad. 4 -> down and to the right, for example.
                    Please like my indie game company on Facebook! https://www.facebook.com/RatherFunGames

                    Comment

                    • DavidMedley
                      Veteran
                      • Oct 2019
                      • 1004

                      #85
                      Found this interesting bit:
                      #define PY_KNOW_LEVEL 30 /* Level to know all runes */

                      But it doesn't appear to be in use. Does this mean someone intended all runes to be instantly known at character level 30? If this constant isn't used again, shouldn't it throw a compiler warning?
                      Please like my indie game company on Facebook! https://www.facebook.com/RatherFunGames

                      Comment

                      • DavidMedley
                        Veteran
                        • Oct 2019
                        • 1004

                        #86
                        Code:
                        /**
                         * Return the player's chance to hit with a particular weapon.
                         */
                        int chance_of_melee_hit(const struct player *p, const struct object *weapon)
                        {
                        	int chance, bonus = p->state.to_h;
                        
                        	if (weapon)
                        		bonus += weapon->to_h;
                        	chance = p->state.skills[SKILL_TO_HIT_MELEE] + bonus * BTH_PLUS_ADJ;
                        	return chance;
                        }
                        
                        /* elsewhere */
                        #define BTH_PLUS_ADJ    	3 		/* Adjust BTH per plus-to-hit */
                        So a +1 to hit is equivalent to 3 skill points, right? So a warrior that starts with 70 melee skill effectively has +11 to-hit over a rogue who starts with 35, for example. (They both advance at the same rate.)
                        Last edited by DavidMedley; April 7, 2020, 19:58. Reason: Better example
                        Please like my indie game company on Facebook! https://www.facebook.com/RatherFunGames

                        Comment

                        • Pete Mack
                          Prophet
                          • Apr 2007
                          • 6883

                          #87
                          No. The 3x applies to the to_h bonus on the character sheet, sum of effects from equipment, stats, and buffs.

                          Comment

                          • wobbly
                            Prophet
                            • May 2012
                            • 2629

                            #88
                            I'm failing to see the difference. 35 + 11 * 3 is well not exactly 70 but pretty close & if you look at how it displays on the character sheet:

                            human warrior: to-hit: 24,
                            human rogue: to-hit: 13,

                            Comment

                            • Nick
                              Vanilla maintainer
                              • Apr 2007
                              • 9634

                              #89
                              Originally posted by DavidMedley
                              Found this interesting bit:
                              #define PY_KNOW_LEVEL 30 /* Level to know all runes */

                              But it doesn't appear to be in use. Does this mean someone intended all runes to be instantly known at character level 30? If this constant isn't used again, shouldn't it throw a compiler warning?
                              IIRC there was a plan for that to happen at some time during the development of rune ID, but it was decided not to be necessary. And I think the compiler doesn't throw an error because it's not in actual code, it's just the preprocessor.
                              One for the Dark Lord on his dark throne
                              In the Land of Mordor where the Shadows lie.

                              Comment

                              • DavidMedley
                                Veteran
                                • Oct 2019
                                • 1004

                                #90
                                Coming back to compiling for Windows... Any help is greatly appreciated because I have no idea what I'm doing.

                                Instructions:
                                Cross-building for Windows with Mingw
                                Many developers (as well as the auto-builder) build Angband for Windows using Mingw on Linux. This requires that the necessary Mingw packages are all installed.

                                This type of build now also uses autotools, so you must configure it to cross-compile, e.g.:

                                ./autogen.sh
                                ./configure --enable-win --disable-curses --build=i686-pc-linux-gnu --host=i586-mingw32msvc
                                ./autogen.sh
                                Code:
                                *info* running aclocal (-I m4)
                                *info* running autoheader
                                *info* running autoconf
                                ./configure --enable-win --disable-curses --build=i686-pc-linux-gnu --host=i586-mingw32msvc
                                Code:
                                checking build system type... i686-pc-linux-gnu
                                checking host system type... i586-pc-mingw32msvc
                                checking target system type... i586-pc-mingw32msvc
                                checking for tput... /usr/bin/tput
                                configure: touching .deps files
                                Note: You have chosen to compile for installation, with data files
                                    in standard locations. For development, you may wish to consider using
                                    --with-no-install which will leave the game to run from the directory
                                    into which it was extracted and compiled.
                                
                                checking for i586-mingw32msvc-gcc... no
                                checking for gcc... gcc
                                configure: WARNING: using cross tools not prefixed with host triplet
                                checking whether the C compiler works... yes
                                checking for C compiler default output file name... a.out
                                checking for suffix of executables...
                                checking whether we are cross compiling... yes
                                checking for suffix of object files... o
                                checking whether we are using the GNU C compiler... yes
                                checking whether gcc accepts -g... yes
                                checking for gcc option to accept ISO C89... none needed
                                checking whether make sets $(MAKE)... yes
                                checking whether ln -s works... yes
                                checking for a BSD-compatible install... /usr/bin/install -c
                                checking for a thread-safe mkdir -p... /bin/mkdir -p
                                checking for i586-mingw32msvc-windres... no
                                checking for windres... no
                                checking for rst2html.py... no
                                checking for rst2html... no
                                checking for rst2latex.py... no
                                checking for rst2latex... no
                                checking for pdflatex... no
                                checking for rm... /bin/rm
                                checking for mv... /bin/mv
                                checking for cp... /bin/cp
                                checking for dirent.h that defines DIR... yes
                                checking for library containing opendir... none required
                                checking how to run the C preprocessor... gcc -E
                                checking for grep that handles long lines and -e... /bin/grep
                                checking for egrep... /bin/grep -E
                                checking for ANSI C header files... yes
                                checking for sys/types.h... yes
                                checking for sys/stat.h... yes
                                checking for stdlib.h... yes
                                checking for string.h... yes
                                checking for memory.h... yes
                                checking for strings.h... yes
                                checking for inttypes.h... yes
                                checking for stdint.h... yes
                                checking for unistd.h... yes
                                checking fcntl.h usability... yes
                                checking fcntl.h presence... yes
                                checking for fcntl.h... yes
                                checking for stdint.h... (cached) yes
                                checking for stdbool.h that conforms to C99... yes
                                checking for _Bool... yes
                                checking for an ANSI C-conforming const... yes
                                checking return type of signal handlers... void
                                checking for mkdir... yes
                                checking for setresgid... yes
                                checking for setegid... yes
                                checking for stat... yes
                                checking if gcc supports -Wno-missing-field-initializers... yes
                                checking if make supports SysV-style inclusion... yes
                                checking for make silent include syntax... gnu
                                checking for mvwaddnwstr... no
                                checking for use_default_colors... no
                                checking for can_change_color... no
                                checking for X... no
                                configure: creating ./config.status
                                config.status: creating mk/buildsys.mk
                                config.status: creating mk/extra.mk
                                config.status: creating mk/sinclude.mk
                                config.status: creating src/autoconf.h
                                
                                Configuration:
                                
                                  Install path:                           /usr/local
                                  binary path:                            /usr/local/games
                                  config path:                            /usr/local/etc/angband/
                                  lib path:                               /usr/local/share/angband/
                                  doc path:                               /usr/local/share/doc/angband/
                                  var path:                               (not used)
                                  (with private save and score files in ~/.angband/Angband/)
                                
                                -- Frontends --
                                - Curses                                  Disabled
                                - X11                                     No; missing libraries
                                - SDL2                                    Disabled
                                - SDL                                     Disabled
                                - Windows                                 Yes
                                - Test                                    No
                                - Stats                                   No
                                
                                - SDL2 sound                              Disabled
                                - SDL sound                               Disabled
                                make
                                Code:
                                Entering directory src.
                                win/readpng.c:21:10: fatal error: windows.h: No such file or directory
                                 #include <windows.h>
                                          ^~~~~~~~~~~
                                compilation terminated.
                                win/scrnshot.c:19:10: fatal error: windows.h: No such file or directory
                                 #include <windows.h>
                                          ^~~~~~~~~~~
                                compilation terminated.
                                win/win-layout.c:19:10: fatal error: windows.h: No such file or directory
                                 #include <windows.h>
                                          ^~~~~~~~~~~
                                compilation terminated.
                                Successfully generated dependencies.
                                /bin/bash: no: command not found
                                Makefile:31: recipe for target 'win/angband.res' failed
                                make[3]: *** [win/angband.res] Error 127
                                ../mk/buildsys.mk:110: recipe for target 'all' failed
                                make[2]: *** [all] Error 2
                                mk/buildsys.mk:115: recipe for target 'subdirs' failed
                                make[1]: *** [subdirs] Error 2
                                mk/buildsys.mk:110: recipe for target 'all' failed
                                make: *** [all] Error 2
                                Please like my indie game company on Facebook! https://www.facebook.com/RatherFunGames

                                Comment

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