Implementing the restructure changes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PowerWyrm
    Prophet
    • Apr 2008
    • 2986

    Originally posted by PowerWyrm
    inven_carry() and (possibly in the future for V, currently in my variant which has a limit on monster inventory size) monster_carry() can fail, leaving an allocated object unfreed. So some tests should be added:
    - if (!inven_carry(object)) delete object
    - if (!monster_carry(object) delete object
    - be sure object is not referenced afterwards (set object to NULL and check vs NULL)
    Note that inven_carry() failing means a lot of trouble, because it means a valid object disappears without any reason from a player's inventory or the floor. IMHO inven_carry() should never fail, or if it does, it should trigger an assertion. Then no check on the return value should be done.

    Note that monster_carry() failing means that the item picked up is removed from the world, which was the case before monster inventories were introduced. A check on the return value could be done.
    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

    • PowerWyrm
      Prophet
      • Apr 2008
      • 2986

      Commit 4d9b69: monster base graphics parser loops on every race checking for any race that matches base race, but does a "parser_getint" each time; this should be done once before the loop.

      Code:
          byte attr;
          char chr;
      
          attr = (byte)parser_getint(p, "attr");
          chr = (char)parser_getint(p, "char");
      
          for (i = 0; i < z_info->r_max; i++)
          {
              struct monster_race *race = &r_info[i];
      
              if (race->base != mb) continue;
      
              monster_x_attr[race->ridx] = attr;
              monster_x_char[race->ridx] = chr;
          }
      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

      • PowerWyrm
        Prophet
        • Apr 2008
        • 2986

        Commit 5357c6:

        Code:
        void place_random_stairs(struct chunk *c, int y, int x)
        {
            int feat = randint0(100) < 50 ? FEAT_LESS : FEAT_MORE;
            if (square_canputitem(c, y, x) && !square_isplayertrap(c, y, x))
        		place_stairs(c, y, x, feat);
        }
        The check on square_isplayertrap() is redundant, since it's already done in square_canputitem():

        Code:
        bool square_canputitem(struct chunk *c, int y, int x) {
        	if (!square_isfloor(c, y, x))
        		return FALSE;
        	if (square_iswarded(c, y, x) || square_isplayertrap(c, y, x))
        		return FALSE;
        	return !square_object(c, y, x);
        }
        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

        • PowerWyrm
          Prophet
          • Apr 2008
          • 2986

          Commit 23ad55:

          Code:
          	if (player->upkeep->command_wrk == USE_QUIVER)
          		m->selections = "012345789";
          	else
          		m->selections = lower_case;
          Why not "6"?
          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

          • PowerWyrm
            Prophet
            • Apr 2008
            • 2986

            Commit 5fbac3:

            I don't see how this change fixes anything, since square_open_door() and square_close_door() both call square_set_feat() which already does square_note_spot() and square_light_spot().
            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

            • PowerWyrm
              Prophet
              • Apr 2008
              • 2986

              Commit b30e09:

              Code:
              memset(&list->total_entries, 0, OBJECT_LIST_SECTION_MAX * sizeof(u16b));
              memset(&list->total_objects, 0, OBJECT_LIST_SECTION_MAX * sizeof(u16b));
              I think the "&" shouldn't be there, since total_entries and total_objects are arrays.

              Code:
              memset(list->total_entries, 0, OBJECT_LIST_SECTION_MAX * sizeof(u16b));
              memset(list->total_objects, 0, OBJECT_LIST_SECTION_MAX * sizeof(u16b));
              Looking at the monster list, it seems the same error is there too.
              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

              • hjklyubn
                Rookie
                • Jan 2014
                • 19

                Originally posted by PowerWyrm
                Commit b30e09:

                Code:
                memset(&list->total_entries, 0, OBJECT_LIST_SECTION_MAX * sizeof(u16b));
                memset(&list->total_objects, 0, OBJECT_LIST_SECTION_MAX * sizeof(u16b));
                I think the "&" shouldn't be there, since total_entries and total_objects are arrays.

                Code:
                memset(list->total_entries, 0, OBJECT_LIST_SECTION_MAX * sizeof(u16b));
                memset(list->total_objects, 0, OBJECT_LIST_SECTION_MAX * sizeof(u16b));
                Looking at the monster list, it seems the same error is there too.
                I think this makes no difference, precisely because total_entries and total_objects are arrays. If they were pointers, the first version would indeed be wrong, and the second version is probably clearer in any case.

                That said, this made me wonder whether anyone has run the angband source through a static analyzer like Coverity Scan? (Free for open-source projects.)

                Comment

                • PowerWyrm
                  Prophet
                  • Apr 2008
                  • 2986

                  Commit 9e8acf:

                  Help has been updated for the removal of sexes... but still states there are six stats. :/
                  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

                  • PowerWyrm
                    Prophet
                    • Apr 2008
                    • 2986

                    Looking at the code, savefiles and high scores are placed into /save and /scores if USE_PRIVATE_PATHS is not defined, and in /user/save and /user/scores if defined.

                    When you download the game and play it without the source code, files are placed in the /user subdirectory, which means that the game has been compiled with USE_PRIVATE_PATHS on. This is not the case in the source code.
                    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

                    • PowerWyrm
                      Prophet
                      • Apr 2008
                      • 2986

                      Originally posted by PowerWyrm
                      Looking at the code, savefiles and high scores are placed into /save and /scores if USE_PRIVATE_PATHS is not defined, and in /user/save and /user/scores if defined.

                      When you download the game and play it without the source code, files are placed in the /user subdirectory, which means that the game has been compiled with USE_PRIVATE_PATHS on. This is not the case in the source code.
                      Nevermind, it's in the makefile...
                      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

                      • PowerWyrm
                        Prophet
                        • Apr 2008
                        • 2986

                        Modifying.txt:

                        names.txt
                        `````````
                        This file contains lists of words which are used to generate names for random
                        character names, random artifacts and scrolls. Again, in the case of a change
                        of theme, this is a good way of
                        A good way of... what?
                        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

                        • PowerWyrm
                          Prophet
                          • Apr 2008
                          • 2986

                          Typos in the same file:
                          - "selesction"
                          - "dungein"
                          - "ned"
                          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

                          • PowerWyrm
                            Prophet
                            • Apr 2008
                            • 2986

                            Online help and manual seem to be out of sync now.

                            - help.hlp

                            .. menu:: [a] general.txt

                            .. menu:: [b] birth.txt

                            .. menu:: [c] dungeon.txt

                            .. menu:: [d] attack.txt

                            .. menu:: [e] playing.txt

                            .. menu:: [f] command.txt

                            .. menu:: [g] option.txt

                            .. menu:: [h] customize.txt

                            .. menu:: [i] modifying.txt

                            .. menu:: [j] version.txt

                            .. menu:: [k] copying.txt
                            - index.txt

                            .. include:: general.txt

                            .. include:: birth.txt

                            .. include:: dungeon.txt

                            .. include:: attack.txt

                            .. include:: playing.txt

                            .. include:: command.txt

                            .. include:: option.txt

                            .. include:: customize.txt

                            .. include:: version.txt
                            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

                            • PowerWyrm
                              Prophet
                              • Apr 2008
                              • 2986

                              Typos in attack.txt:
                              - "bonuses to hit and/or do damage" (to damage)
                              - "care or paralyze the target" (scare)
                              - "canresist"
                              - "plasma and force" (force is already described on the previous line)
                              - "Velocity" (Power)
                              - "all other lays" (slays)
                              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

                              • PowerWyrm
                                Prophet
                                • Apr 2008
                                • 2986

                                Typos in customize.txt:
                                - "comamnds"
                                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...
                                😀
                                😂
                                🥰
                                😘
                                🤢
                                😎
                                😞
                                😡
                                👍
                                👎