Henne / Bright-Eyes

"Bright Eyes" is a variation of DOSBox with customized support for the CRPG "Das schwarze Auge 1 - Schicksalsklinge"
GNU General Public License v2.0
19 stars 7 forks source link

M302de: Original-Bugfix: workaround for bad index calculation in spel… #47

Closed mirbo closed 7 years ago

mirbo commented 7 years ago

…l_analues() or spell_odem_arcanum() if item selection is canceled or spell user has no items

As this file is marked as "Borlandified and identical", there seems to be a (potential) problem in the original code for the spells "Odem Arcanum" and "Analüs". If the player presses the right mouse button or the escape key, when the game shows the list of items (or if the inventory of the spell user is empty), select_item_to_drop() returns -1. This value is then used to calculate an offset into the inventory of the spell user. If the value is -1 the game will look at one inventory slot before the start of the inventory and will therefore use and potentially modify other values of that character.

In the case of "Odem Arcanum" the found value will also be used to find and then display the name of an item, which may in this case show a bit of memory that may not be text at all and may also lead to serious graphical errors (actually this is why i looked at this function). My suggestion would be to set the output buffer to an empty string (which will not be displayed) and just return from the function before anything else gets done.

The spell "Analüs" will probably cause much less trouble, because the found id is compared to a list of ids and it is probably unlikely to get a match here. But if it does happen, the function will still change a bit in a location outside of the inventory. My suggestion would be to set the item id to 0 so that the main part of the function (the loop comparing the item id to the list) gets skipped and the default text is used as output.