When you start "Edit Zone" some data is read from world.db in test.game\data\worlds\singleplayer\editworld. Then a copy is made from test.game\data\worlds\multiplayer.baseline which is recreated by Genesis.py. The saved data is then added to this fresh copy.
This way all items without a player and/or character ID were deleted and the item_dropped table was reset.
The only way was to add the table to the set of data saved and that is done in mud/world/worldupdate.py.
First of all import the class:
from mud.world.item import Item,ItemProto,ItemSpell,ItemDropped
Then we need a copier for the entries just like the other ones:
class DroppedItemCopier:
def __init__(self,conn,id):
self.dbAttr = {}
cur = conn.cursor()
t = mixedToUnder("ItemDropped")
cur.execute("SELECT * from %s WHERE id = %i;"%(t,id))
for name,value in zip(WSCHEMA["ItemDropped"],cur.fetchall()[0]):
self.dbAttr[str(name)]=value
self.item = None
try:
self.item = ItemCopier(conn.cursor(), int(self.dbAttr['itemID']))
except:
print "Item %i does not exist anymore."%int(self.dbAttr['itemID'])
pass
cur.close()
def install(self):
if self.item:
FilterColumns(ItemDropped,self.dbAttr)
self.item.install(DummyCharacter())
ditem = ItemDropped(**self.dbAttr)
The DummyCharacter is a helper to make item.install work. This needs a character instance where it takes the id from. As all dropped items have a character_id of None.
class DummyCharacter:
def __init__(self):
self.id = None;
Finally the copier is called: line 805
droppedItems = []
line 823:
#dropped items
cur.execute("select id from item_dropped;")
for r in cur.fetchall():
i = DroppedItemCopier(WCONN,r[0])
droppedItems.append(i)
line 854:
for i in droppedItems:
i.install()

