![]() |
#1 |
DaJAngband Maintainer
Join Date: Apr 2007
Location: San Antonio, TX
Posts: 1,124
Donated: $10
![]() |
tiny little unimportant DJA bug that's been bugging me
There's a very unimportant bug that's been getting on my nerves and it involves a piece of code which is gibberish to me so I'm asking for help:
The "C" line in p_race text lists recommended classes for that race. The recommended classes show up in a brighter color in the birth menu, but this doesn't work. No recommended classes below the alchemist (class index 7) ever show up in a brighter color. The relevant piece of code (I think) is this little function in birth.c Code:
/* CLASS */ static void display_class(menu_type *menu, int oid, bool cursor, int row, int col, int width) { byte attr = curs_attrs[0 != (rp_ptr->choice & (1L << oid))][0 != cursor]; c_put_str(attr, c_name + c_info[oid].name, row, col); } I looked in init.c where it reads the C: line in p_race.txt and it uses a similar thing: Code:
/* Hack - Parse this entry */ pr_ptr->choice |= (1 << atoi(s)); "atoi" isn't defined as a function anywhere so I assume it's an innate C thing that I haven't learned.
__________________
Will_Asher aka LibraryAdventurer My old variant DaJAngband: http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...) |
![]() |
![]() |
![]() |
#2 |
Angband Devteam member
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 42
Posts: 1,516
![]() |
Here's the idea:
Code:
1 << 1 == 2 1 << 2 == 4 1 << 3 == 8 ... 1 << 8 == 256 Also, atoi is translating a string representation of a number into an int. Code:
atoi("10") == 10 atoi("3") == 3 |
![]() |
![]() |
![]() |
#3 | |
Prophet
Join Date: Mar 2008
Posts: 2,725
![]() |
Quote:
The simple change is to define choice to be a different size, say unsigned int, but that may break savefile compatibility if the value is written and reloaded from the savefile. |
|
![]() |
![]() |
![]() |
#4 |
Angband Devteam member
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 42
Posts: 1,516
![]() |
Angband does *love* bit-encodings. I guess 640k should be enough for anyone, huh?
|
![]() |
![]() |
![]() |
#5 |
DaJAngband Maintainer
Join Date: Apr 2007
Location: San Antonio, TX
Posts: 1,124
Donated: $10
![]() |
Thanks, it works as it should now.
BTW, 'choice' isn't used in savefiles, but I've already broken savefiles in other ways.
__________________
Will_Asher aka LibraryAdventurer My old variant DaJAngband: http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...) |
![]() |
![]() |
![]() |
#6 |
Prophet
Join Date: Mar 2008
Posts: 2,725
![]() |
It's one thing to try to save space in a structure that is used 1000 times. But to worry about space in a variable that is only used once is insane. It makes more sense to use a long than a byte if you think anyone might ever want to extend things in the future.
|
![]() |
![]() |
![]() |
#7 | |
Angband Devteam member
|
Quote:
|
|
![]() |
![]() |
![]() |
#8 | |
Hellband maintainer
Join Date: Jul 2007
Location: New York, the Big Apple
Age: 45
Posts: 367
Donated: $120
![]() |
Quote:
![]() T.
__________________
* Are you ready for something else ? Hellband 0.8.8 is out! * |
|
![]() |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
DJA: Tossing around ideas | will_asher | Variants | 61 | April 4, 2011 02:02 |
Tiny 3.1 bug | Zikke | Vanilla | 1 | January 8, 2009 22:41 |