DestroyItem on CanInsertScript -> Crash (POL 097)

Report core bugs regarding the Ultima Online Emulator Core release (version 097). You can attach your Core Dump. One bug per post.

Moderator: POL Developer

Locked
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

DestroyItem on CanInsertScript -> Crash (POL 097)

Post by ncrsn »

Consider this script:

Code: Select all

use uo;

program CanInsertItemIntoContainer( who, container, movetype, inserttype, adding_item, existing_stack, amount_to_add )
    if (adding_item)
        DestroyItem(adding_item);
    endif
endprogram
Dragging item into container having caninsertscript like that will print into console "remove_item_from_world: item [serial] at 0,0 does not exist in world zone", "Unhandled Exception! Minidump started...", and POL will crash. If this is something _hard_ to fix so that destroying would become possible, how about failing the destroy request and printing something informal, like "GAAH! IDIOT SCRIPTER KILL KILL KILL!" into console instead? Even that would be better than crashing.

I see that this is noted in documentation, "You should not destroy the adding_item in the CanInsert script.", so maybe this should be feature request instead of bug report?
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Post by OldnGrey »

Do you get problems in OnInsert?
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

No. OnInsertScript does not care if item gets destroyed.

To me this is more of a little annoyance, nice-to-not-have-around-if-you-are-new-to-escript, than something that cannot be lived with.
coltain
Grandmaster Poster
Posts: 159
Joined: Tue Mar 20, 2007 7:17 am
Location: Poland

Post by coltain »

caninsert - return 1;
oninsert - destroy;
User avatar
CWO
POL Expert
Posts: 1158
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Post by CWO »

Right coltain... CanInsertScript is only saying to return 1 or 0 saying yes or no it can be inserted... OnInsertScript says what happens on the insert... like destroying and such.
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

Even if it is wrong way to do things, POL should not crash. Say, for an example, that I don't do my homework of reading the docs: I modify a CanInsertScript to look like the one on first post, put it on a live shard, and unload it into use. If shard happens to crash (as it will, as soon as someone activates the script), I (as an average user) would blame the POL for being unstable.

Though I did something that _everyone_ here knows should not be done.

If, instead of crash, POL would print some informal message, I would eventually see that there is something wrong with my script. Result? POL wise, scripter stupid.
Locked