Dynamic array Find() errors out when called in UI

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Dynamic array Find() errors out when called in UI

Post by Nash »

Code: Select all

class LADCharacterMenu : GenericMenu
{
    override bool MenuEvent (int mkey, bool fromcontroller)
    {
        case MKEY_Enter:
            // find which slot this item is in
            let itemPtr = sia.items[currentSelection];
            int slot = character.myItems.Find(itemPtr); // error
 
gives the error "Readonly struct on left hand side of Find not allowed".

Why is this blocked? Finding something in an array should be safe because you're not writing any data?

EDIT: I mean, I can still do a manual search by doing a for loop and checking for the pointer directly before breaking the loop, and getting the loop index from there, but that's just inconvenience, makes the code look more bloated than it really needs to be, and it still works between scopes anyway so what's the point of blocking Find() is what I'm saying?
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Dynamic array Find() errors out when called in UI

Post by _mental_ »

Could you please post runnable sample?
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Dynamic array Find() errors out when called in UI

Post by Nash »

Sure!
Attachments
zscript.txt
(1.27 KiB) Downloaded 31 times
_mental_
 
 
Posts: 3812
Joined: Sun Aug 07, 2011 4:32 am

Re: Dynamic array Find() errors out when called in UI

Post by _mental_ »

Fixed in b840622.
User avatar
Nash
 
 
Posts: 17434
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Dynamic array Find() errors out when called in UI

Post by Nash »

Thank youuuu! Now I can get rid of all the ugly for-loop hacks I used to work around this problem. >8D
Post Reply

Return to “Closed Bugs [GZDoom]”