[crossfire] Archetype and inventory bug

Mark Wedel mwedel at sonic.net
Mon Jan 23 01:28:24 CST 2012


On 01/22/12 07:40 AM, Nicolas Weeger wrote:
> Hello.
>
>
> After a crash on invidious, I've found a bug related to archetypes in
> inventory handling, and I'm really wondering how to fix it :s
>
>
> Here's the description:
> - when a random map is generated, a special submap can be
> /styles/specialmaps/powerroom
>
> - in this map are firewalls, with a "transferrence" spell in their inventory.
> The archetypes are "firewall_1", "firewall_2" and such
>
> - those archetype contain an archetype "firebullet", because they are firewalls
>
> - when the map is generated, the "firebullet" is copied from the archetype,
> then the "transferrence spell is added
>
> - transferrence is the first item in inventory, so that's what the wall casts ;
> casting this, the wall increases its stats.sp (probably from the crystal, or a
> player standing on the crystal)
>
> - if the map is swapped out, then reloaded from disk, the firewall will have
> its firebullet item copied from the archetype, then reloads the transferrence
> item, and the initial firebullet

  Yes - the re-arranging of objects on load/save is a bit of a headache.  This 
was probably originally done for efficiency - it is a lot faster to insert the 
new object at the head of the list than to walk the list and get the tail (in 
this case, it doesn't make much difference with just a few objects, but imagine 
a chest with 500)

  In practical terms, it may not be that costly to save the map with proper 
ordering - for objects with inventory, you traverse the list to get to the end, 
and then just walk backwards - that really isn't going to be any more costly 
than walking it forward.

  I also think that if the server is loading in a swapped out map (vs original 
map), it should not be doing anything with regards to fixing up these objects - 
the server did that when it originally loaded it, so there is no reason for it 
to do it again.  So the fact it does is a bug.


> So I'm really puzzled on a correct fix for that... So far I can see:
>
> - using a treasurelist for the firewall's spell, having it set to NONE in the
> map

  That is also a pretty good solution, as it is more generally useful.  As 
things are now, there is a reliance on object ordering when the map is loaded. 
I think it is fair to say that if an archetype has an inventory and it shows up 
on a map, it is presume that the inventory will be created when the map is 
loaded.  As such, there is no way to remove an archetypes inventory within a map 
file - one could only add to it.

>
> - somehow detecting the map defines an inventory, and not generating the
> default firebullet, not saving it, or something like that

  That seems fairly complicated, as there could be many different special cases 
(in some cases, the map make could be assuming that the object they put in the 
inventory will get added to what is already there, so if that doesn't happen 
anymore, that could cause some breakage)


More information about the crossfire mailing list