Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old October 2, 2015, 16:01   #211
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,900
PowerWyrm is on a distinguished road
Quote:
Originally Posted by PowerWyrm View Post
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 http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old October 5, 2015, 12:07   #212
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,900
PowerWyrm is on a distinguished road
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 http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old October 6, 2015, 13:28   #213
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,900
PowerWyrm is on a distinguished road
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 http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old October 6, 2015, 13:43   #214
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,900
PowerWyrm is on a distinguished road
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 http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old October 7, 2015, 13:30   #215
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,900
PowerWyrm is on a distinguished road
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 http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old October 7, 2015, 14:04   #216
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,900
PowerWyrm is on a distinguished road
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 http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old October 7, 2015, 16:23   #217
hjklyubn
Rookie
 
Join Date: Jan 2014
Posts: 19
hjklyubn is on a distinguished road
Quote:
Originally Posted by PowerWyrm View Post
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.)
hjklyubn is offline   Reply With Quote
Old October 7, 2015, 16:55   #218
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,900
PowerWyrm is on a distinguished road
Commit 9e8acf:

Help has been updated for the removal of sexes... but still states there are six stats. :/
__________________
PWMAngband variant maintainer - check http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old October 8, 2015, 11:20   #219
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,900
PowerWyrm is on a distinguished road
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 http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old October 8, 2015, 12:22   #220
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,900
PowerWyrm is on a distinguished road
Quote:
Originally Posted by PowerWyrm View Post
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 http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Restructure update Nick Development 80 February 25, 2015 21:56
Ladder restructure request OOD Town drunk Vanilla 7 April 4, 2013 17:11
Implementing different difficulty levels Greebley Vanilla 14 January 11, 2012 15:39


All times are GMT +1. The time now is 16:39.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.