View Single Post
Old July 17, 2019, 17:39   #228
Join Date: Jul 2019
Posts: 11
jml34 is on a distinguished road
@takkaria If you mean the accesses to s[2] and s[3] they can't be out of bounds (null-terminated string so these expressions are in bound when evaluated) -- I copied this from elsewhere in the code.
Now your code is much cleaner, and faster too. Er, I think you could have a look at some elsewheres in the code
I just quickly tested it with
if (s && sscanf(s, "!L%d", &stack_limit) > 0 && 0<stack_limit &&
                      stack_limit<=gear_obj->kind->base->max_stack) {
and it worked (ignoring !L with numbers>40).
I haven't coded in C for like 20 years so I also tested !L0x20 but it seems %d doesn't accept hexa format

Another quick note (I realize I wasn't clear): I think the player_pickup_aux code would work the same without the 4th parameter and
                if (!pickup_limit) num = get_quantity(NULL, max);
                else num = max;
(don't use auto_max since it's unused). Silly me just got scared of that call to get_quantity that I didn't understand so I left auto_max for no good reason that I know of...

About @<cmd><letter>, my plan would be to have the menu scan the keys, check if they're hidden by an entry in the inscriptions array, in which case the inscriptions array would be scanned for an entry that points to the item: this key would be displayed in the menu if there's one, if not, the first free slot would be assigned first. Degenerate case: the player engraved multiple @ commands to objects so there's no free slot available, we display a space in the menu and the object is not reachable.
@Sideways So @<cmd><letter> could actually be made to work with multiple ways to select an item. Use a key displayed in the menu -> select the corresponding item, use some other key -> select the first engraved item if any.
Now I don't know if that's a desirable feature, the code could be messy, perhaps I can't get back to it before the 1st of 08, and above all other people have said there's a more desirable way to have @<cmd><letter> work so I'll leave it at that for now

Last edited by jml34; July 17, 2019 at 17:47.
jml34 is offline   Reply With Quote