2010-10-07 12:41:56 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2008-2010 TrinityCore <http://www.trinitycore.org/>
|
|
|
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-10-02 16:23:55 -05:00
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
#include "SQLStorage.h"
|
2008-11-20 16:16:57 -06:00
|
|
|
#include "SQLStorageImpl.h"
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2010-03-21 14:57:49 -03:00
|
|
|
const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifffliiiiiiiliiisi";
|
|
|
|
|
const char CreatureInfodstfmt[]="iiiiiiiiiisssibbiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiiiiiiisiifffliiiiiiiliiiii";
|
2010-01-02 19:52:08 -03:00
|
|
|
const char CreatureDataAddonInfofmt[]="iiiiiis";
|
2008-10-02 16:23:55 -05:00
|
|
|
const char CreatureModelfmt[]="iffbi";
|
2010-01-02 19:52:08 -03:00
|
|
|
const char CreatureInfoAddonInfofmt[]="iiiiiis";
|
2008-12-24 09:58:26 -06:00
|
|
|
const char EquipmentInfofmt[]="iiii";
|
2010-02-14 19:13:14 -07:00
|
|
|
const char GameObjectInfosrcfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiisi";
|
|
|
|
|
const char GameObjectInfodstfmt[]="iiissssiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii";
|
|
|
|
|
const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiisiiiii";
|
|
|
|
|
const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiii";
|
|
|
|
|
const char PageTextfmt[]="isii";
|
2010-08-06 14:56:41 +02:00
|
|
|
const char InstanceTemplatesrcfmt[]="iiffffsb";
|
|
|
|
|
const char InstanceTemplatedstfmt[]="iiffffib";
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-11-20 16:16:57 -06:00
|
|
|
SQLStorage sCreatureStorage(CreatureInfosrcfmt, CreatureInfodstfmt, "entry","creature_template");
|
2008-10-02 16:23:55 -05:00
|
|
|
SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon");
|
|
|
|
|
SQLStorage sCreatureModelStorage(CreatureModelfmt,"modelid","creature_model_info");
|
|
|
|
|
SQLStorage sCreatureInfoAddonStorage(CreatureInfoAddonInfofmt,"entry","creature_template_addon");
|
|
|
|
|
SQLStorage sEquipmentStorage(EquipmentInfofmt,"entry","creature_equip_template");
|
2008-11-20 16:16:57 -06:00
|
|
|
SQLStorage sGOStorage(GameObjectInfosrcfmt, GameObjectInfodstfmt, "entry","gameobject_template");
|
|
|
|
|
SQLStorage sItemStorage(ItemPrototypesrcfmt, ItemPrototypedstfmt, "entry","item_template");
|
2008-10-02 16:23:55 -05:00
|
|
|
SQLStorage sPageTextStore(PageTextfmt,"entry","page_text");
|
2008-11-20 16:16:57 -06:00
|
|
|
SQLStorage sInstanceTemplate(InstanceTemplatesrcfmt, InstanceTemplatedstfmt, "map","instance_template");
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
void SQLStorage::Free ()
|
|
|
|
|
{
|
|
|
|
|
uint32 offset=0;
|
2009-10-17 16:20:24 -07:00
|
|
|
for (uint32 x=0; x<iNumFields; x++)
|
2008-11-20 16:16:57 -06:00
|
|
|
if (dst_format[x]==FT_STRING)
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2009-10-17 16:20:24 -07:00
|
|
|
for (uint32 y=0; y<MaxEntry; y++)
|
2008-10-02 16:23:55 -05:00
|
|
|
if(pIndex[y])
|
|
|
|
|
delete [] *(char**)((char*)(pIndex[y])+offset);
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-11-20 16:16:57 -06:00
|
|
|
offset += sizeof(char*);
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|
2008-11-20 16:16:57 -06:00
|
|
|
else if (dst_format[x]==FT_LOGIC)
|
|
|
|
|
offset += sizeof(bool);
|
|
|
|
|
else if (dst_format[x]==FT_BYTE)
|
|
|
|
|
offset += sizeof(char);
|
2008-10-02 16:23:55 -05:00
|
|
|
else
|
2008-11-20 16:16:57 -06:00
|
|
|
offset += 4;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
delete [] pIndex;
|
|
|
|
|
delete [] data;
|
|
|
|
|
}
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-11-20 16:16:57 -06:00
|
|
|
void SQLStorage::Load()
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2008-11-20 16:16:57 -06:00
|
|
|
SQLStorageLoader loader;
|
|
|
|
|
loader.Load(*this);
|
2008-10-02 16:23:55 -05:00
|
|
|
}
|