Changeset 272 for trunk/src/shared
- Timestamp:
- 11/22/08 00:35:41 (17 years ago)
- Location:
- trunk/src/shared
- Files:
-
- 18 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/shared/Database/DBCStores.cpp
r260 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 122 122 // DBC used only for initialization sTaxiPathSetBySource at startup. 123 123 TaxiPathNodesByPath sTaxiPathNodesByPath; 124 124 struct TaxiPathNodeEntry 125 { 126 uint32 path; 127 uint32 index; 128 uint32 mapid; 129 float x; 130 float y; 131 float z; 132 uint32 actionFlag; 133 uint32 delay; 134 }; 125 135 static DBCStorage <TaxiPathNodeEntry> sTaxiPathNodeStore(TaxiPathNodeEntryfmt); 136 126 137 DBCStorage <TotemCategoryEntry> sTotemCategoryStore(TotemCategoryEntryfmt); 138 127 139 DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore(WorldMapAreaEntryfmt); 128 140 DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt); … … 224 236 } 225 237 } 226 238 227 239 LoadDBC(availableDbcLocales,bar,bad_dbc_files,sFactionTemplateStore, dbcPath,"FactionTemplate.dbc"); 228 240 LoadDBC(availableDbcLocales,bar,bad_dbc_files,sGemPropertiesStore, dbcPath,"GemProperties.dbc"); … … 272 284 { 273 285 SkillLineAbilityEntry const *skillLine = sSkillLineAbilityStore.LookupEntry(j); 274 286 275 287 if(!skillLine) 276 288 continue; … … 279 291 280 292 if(spellInfo && (spellInfo->Attributes & 0x1D0) == 0x1D0) 281 { 293 { 282 294 for (unsigned int i = 1; i < sCreatureFamilyStore.GetNumRows(); ++i) 283 295 { … … 286 298 continue; 287 299 288 if(skillLine->skillId != cFamily->skillLine [0] && skillLine->skillId != cFamily->skillLine[1])300 if(skillLine->skillId != cFamily->skillLine && skillLine->skillId != cFamily->skillLine2) 289 301 continue; 290 302 … … 298 310 LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellFocusObjectStore, dbcPath,"SpellFocusObject.dbc"); 299 311 LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentStore,dbcPath,"SpellItemEnchantment.dbc"); 312 300 313 LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellItemEnchantmentConditionStore,dbcPath,"SpellItemEnchantmentCondition.dbc"); 301 314 LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellRadiusStore, dbcPath,"SpellRadius.dbc"); … … 443 456 // check at up-to-date DBC files (71 is last char title added in 2.4.3) 444 457 // check at up-to-date DBC files (1768 is last area added in 2.4.3) 445 if( !sSpellStore.LookupEntry(53085) || 446 !sSkillLineAbilityStore.LookupEntry(17514) || 458 if( !sSpellStore.LookupEntry(53085) || 459 !sSkillLineAbilityStore.LookupEntry(17514) || 447 460 !sMapStore.LookupEntry(598) || 448 !sGemPropertiesStore.LookupEntry(1127) || 449 !sItemExtendedCostStore.LookupEntry(2425) || 461 !sGemPropertiesStore.LookupEntry(1127) || 462 !sItemExtendedCostStore.LookupEntry(2425) || 450 463 !sCharTitlesStore.LookupEntry(71) || 451 464 !sAreaStore.LookupEntry(1768) ) -
trunk/src/shared/Database/DBCStores.h
r260 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 76 76 bool Load(char const* fn) 77 77 { 78 78 79 DBCFile dbc; 79 80 // Check if load was sucessful, only then continue -
trunk/src/shared/Database/DBCStructure.h
r260 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 22 22 #define DBCSTRUCTURE_H 23 23 24 #include "DBCEnums.h"25 24 #include "Platform/Define.h" 26 25 … … 37 36 #pragma pack(push,1) 38 37 #endif 38 39 enum AreaTeams 40 { 41 AREATEAM_NONE = 0, 42 AREATEAM_ALLY = 2, 43 AREATEAM_HORDE = 4 44 }; 45 46 enum AreaFlags 47 { 48 AREA_FLAG_SNOW = 0x00000001, // snow (only Dun Morogh, Naxxramas, Razorfen Downs and Winterspring) 49 AREA_FLAG_UNK1 = 0x00000002, // unknown, (only Naxxramas and Razorfen Downs) 50 AREA_FLAG_UNK2 = 0x00000004, // Only used on development map 51 AREA_FLAG_SLAVE_CAPITAL = 0x00000008, // slave capital city flag? 52 AREA_FLAG_UNK3 = 0x00000010, // unknown 53 AREA_FLAG_SLAVE_CAPITAL2 = 0x00000020, // slave capital city flag? 54 AREA_FLAG_UNK4 = 0x00000040, // many zones have this flag 55 AREA_FLAG_ARENA = 0x00000080, // arena, both instanced and world arenas 56 AREA_FLAG_CAPITAL = 0x00000100, // main capital city flag 57 AREA_FLAG_CITY = 0x00000200, // only for one zone named "City" (where it located?) 58 AREA_FLAG_OUTLAND = 0x00000400, // outland zones? (only Eye of the Storm not have this flag, but have 0x00004000 flag) 59 AREA_FLAG_SANCTUARY = 0x00000800, // sanctuary area (PvP disabled) 60 AREA_FLAG_NEED_FLY = 0x00001000, // only Netherwing Ledge, Socrethar's Seat, Tempest Keep, The Arcatraz, The Botanica, The Mechanar, Sorrow Wing Point, Dragonspine Ridge, Netherwing Mines, Dragonmaw Base Camp, Dragonmaw Skyway 61 AREA_FLAG_UNUSED1 = 0x00002000, // not used now (no area/zones with this flag set in 2.4.2) 62 AREA_FLAG_OUTLAND2 = 0x00004000, // outland zones? (only Circle of Blood Arena not have this flag, but have 0x00000400 flag) 63 AREA_FLAG_PVP = 0x00008000, // pvp objective area? (Death's Door also has this flag although it's no pvp object area) 64 AREA_FLAG_ARENA_INSTANCE = 0x00010000, // used by instanced arenas only 65 AREA_FLAG_UNUSED2 = 0x00020000, // not used now (no area/zones with this flag set in 2.4.2) 66 AREA_FLAG_UNK5 = 0x00040000, // just used for Amani Pass, Hatchet Hills 67 AREA_FLAG_LOWLEVEL = 0x00100000 // used for some starting areas with area_level <=15 68 }; 69 70 enum FactionTemplateFlags 71 { 72 FACTION_TEMPLATE_FLAG_CONTESTED_GUARD = 0x00001000, // faction will attack players that were involved in PvP combats 73 }; 39 74 40 75 struct AreaTableEntry … … 145 180 // 64 string flags, unused 146 181 // 65-67 unused 147 uint32 addon;// 68 (0 - original race, 1 - tbc addon, ...)182 uint32 addon; // 68 (0 - original race, 1 - tbc addon, ...) 148 183 }; 149 184 … … 159 194 { 160 195 uint32 ID; // 0 161 float minScale; // 1 162 uint32 minScaleLevel; // 2 0/1 196 float minScale; // 1 197 uint32 minScaleLevel; // 2 0/1 163 198 float maxScale; // 3 164 199 uint32 maxScaleLevel; // 4 0/60 165 uint32 skillLine[2]; // 5-6 200 uint32 skillLine; // 5 201 uint32 skillLine2; // 6 166 202 uint32 petFoodMask; // 7 167 203 char* Name[16]; // 8-23 … … 207 243 //char* description[16]; // 36-51 unused 208 244 // 52 string flags, unused 245 }; 246 247 enum FactionMasks 248 { 249 FACTION_MASK_PLAYER = 1, // any player 250 FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team 251 FACTION_MASK_HORDE = 4, // player or creature from horde team 252 FACTION_MASK_MONSTER = 8 // aggressive creature from monster team 253 // if none flags set then non-aggressive creature 209 254 }; 210 255 … … 257 302 258 303 #define GT_MAX_LEVEL 100 259 260 304 struct GtCombatRatingsEntry 261 305 { … … 386 430 // 17 name flags, unused 387 431 //char* content[16]; // 18-33 432 }; 433 434 enum MapTypes 435 { 436 MAP_COMMON = 0, 437 MAP_INSTANCE = 1, 438 MAP_RAID = 2, 439 MAP_BATTLEGROUND = 3, 440 MAP_ARENA = 4 388 441 }; 389 442 … … 491 544 // 36 string flags, not used 492 545 uint32 spellIcon; // 37 546 }; 547 548 enum AbilytyLearnType 549 { 550 ABILITY_LEARNED_ON_GET_PROFESSION_SKILL = 1, 551 ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL = 2 493 552 }; 494 553 … … 700 759 }; 701 760 761 enum ItemEnchantmentType 762 { 763 ITEM_ENCHANTMENT_TYPE_NONE = 0, 764 ITEM_ENCHANTMENT_TYPE_COMBAT_SPELL = 1, 765 ITEM_ENCHANTMENT_TYPE_DAMAGE = 2, 766 ITEM_ENCHANTMENT_TYPE_EQUIP_SPELL = 3, 767 ITEM_ENCHANTMENT_TYPE_RESISTANCE = 4, 768 ITEM_ENCHANTMENT_TYPE_STAT = 5, 769 ITEM_ENCHANTMENT_TYPE_TOTEM = 6 770 }; 771 702 772 struct SpellItemEnchantmentEntry 703 773 { … … 757 827 }; 758 828 829 struct TaxiPathEntry 830 { 831 uint32 ID; 832 uint32 from; 833 uint32 to; 834 uint32 price; 835 }; 836 759 837 struct TaxiNodesEntry 760 838 { … … 770 848 }; 771 849 772 struct TaxiPathEntry 773 { 774 uint32 ID; 775 uint32 from; 776 uint32 to; 777 uint32 price; 778 }; 779 780 struct TaxiPathNodeEntry 781 { 782 uint32 path; 783 uint32 index; 784 uint32 mapid; 785 float x; 786 float y; 787 float z; 788 uint32 actionFlag; 789 uint32 delay; 850 enum TotemCategoryType 851 { 852 TOTEM_CATEGORY_TYPE_KNIFE = 1, 853 TOTEM_CATEGORY_TYPE_TOTEM = 2, 854 TOTEM_CATEGORY_TYPE_ROD = 3, 855 TOTEM_CATEGORY_TYPE_PICK = 21, 856 TOTEM_CATEGORY_TYPE_STONE = 22, 857 TOTEM_CATEGORY_TYPE_HAMMER = 23, 858 TOTEM_CATEGORY_TYPE_SPANNER = 24 790 859 }; 791 860 -
trunk/src/shared/Database/DatabaseEnv.h
r262 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/Database/DatabaseImpl.h
r262 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/Database/DatabaseMysql.cpp
r262 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/Database/DatabaseMysql.h
r262 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/Database/Field.cpp
r262 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/Database/Field.h
r262 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/Database/QueryResult.h
r262 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/Database/SQLStorage.cpp
r260 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 21 21 #include "SQLStorage.h" 22 #include "SQLStorageImpl.h" 22 #include "ProgressBar.h" 23 #include "Log.h" 24 #include "dbcfile.h" 23 25 24 26 #ifdef DO_POSTGRESQL … … 28 30 #endif 29 31 30 const char CreatureInfosrcfmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiis"; 31 const char CreatureInfodstfmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiii"; 32 const char CreatureInfofmt[]="iiiiiisssiiiiiiiiiiffiffiiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiilliiis"; 32 33 const char CreatureDataAddonInfofmt[]="iiiiiiis"; 33 34 const char CreatureModelfmt[]="iffbi"; 34 35 const char CreatureInfoAddonInfofmt[]="iiiiiiis"; 35 36 const char EquipmentInfofmt[]="iiiiiiiiii"; 36 const char GameObjectInfosrcfmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiis"; 37 const char GameObjectInfodstfmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiii"; 38 const char ItemPrototypesrcfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifsiiiii"; 39 const char ItemPrototypedstfmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifiiiiii"; 37 const char GameObjectInfofmt[]="iiissiifiiiiiiiiiiiiiiiiiiiiiiiis"; 38 const char ItemPrototypefmt[]="iiiisiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffiffiffiffiffiiiiiiiiiifiiifiiiiiifiiiiiifiiiiiifiiiiiifiiiisiiiiiiiiiiiiiiiiiiiiiiiiifsiiiii"; 40 39 const char PageTextfmt[]="isi"; 41 40 const char SpellThreatfmt[]="ii"; 42 const char InstanceTemplatesrcfmt[]="iiiiiiffffs"; 43 const char InstanceTemplatedstfmt[]="iiiiiiffffi"; 41 const char InstanceTemplatefmt[]="iiiiiiffffs"; 44 42 45 SQLStorage sCreatureStorage(CreatureInfo srcfmt, CreatureInfodstfmt,"entry","creature_template");43 SQLStorage sCreatureStorage(CreatureInfofmt,"entry","creature_template"); 46 44 SQLStorage sCreatureDataAddonStorage(CreatureDataAddonInfofmt,"guid","creature_addon"); 47 45 SQLStorage sCreatureModelStorage(CreatureModelfmt,"modelid","creature_model_info"); 48 46 SQLStorage sCreatureInfoAddonStorage(CreatureInfoAddonInfofmt,"entry","creature_template_addon"); 49 47 SQLStorage sEquipmentStorage(EquipmentInfofmt,"entry","creature_equip_template"); 50 SQLStorage sGOStorage(GameObjectInfo srcfmt, GameObjectInfodstfmt,"entry","gameobject_template");51 SQLStorage sItemStorage(ItemPrototype srcfmt, ItemPrototypedstfmt,"entry","item_template");48 SQLStorage sGOStorage(GameObjectInfofmt,"entry","gameobject_template"); 49 SQLStorage sItemStorage(ItemPrototypefmt,"entry","item_template"); 52 50 SQLStorage sPageTextStore(PageTextfmt,"entry","page_text"); 53 51 SQLStorage sSpellThreatStore(SpellThreatfmt,"entry","spell_threat"); 54 SQLStorage sInstanceTemplate(InstanceTemplate srcfmt, InstanceTemplatedstfmt,"map","instance_template");52 SQLStorage sInstanceTemplate(InstanceTemplatefmt,"map","instance_template"); 55 53 56 54 void SQLStorage::Free () … … 58 56 uint32 offset=0; 59 57 for(uint32 x=0;x<iNumFields;x++) 60 if ( dst_format[x]==FT_STRING)58 if (format[x]==FT_STRING) 61 59 { 62 60 for(uint32 y=0;y<MaxEntry;y++) … … 64 62 delete [] *(char**)((char*)(pIndex[y])+offset); 65 63 66 offset +=sizeof(char*);64 offset+=sizeof(char*); 67 65 } 68 else if ( dst_format[x]==FT_LOGIC)69 offset +=sizeof(bool);70 else if ( dst_format[x]==FT_BYTE)71 offset +=sizeof(char);66 else if (format[x]==FT_LOGIC) 67 offset+=sizeof(bool); 68 else if (format[x]==FT_BYTE) 69 offset+=sizeof(char); 72 70 else 73 offset +=4;71 offset+=4; 74 72 75 73 delete [] pIndex; … … 77 75 } 78 76 79 void SQLStorage::Load ()77 void SQLStorage::Load () 80 78 { 81 SQLStorageLoader loader; 82 loader.Load(*this); 79 uint32 maxi; 80 Field *fields; 81 QueryResult *result = WorldDatabase.PQuery("SELECT MAX(%s) FROM %s",entry_field,table); 82 if(!result) 83 { 84 sLog.outError("Error loading %s table (not exist?)\n",table); 85 exit(1); // Stop server at loading non exited table or not accessable table 86 } 87 88 maxi= (*result)[0].GetUInt32()+1; 89 delete result; 90 91 result = WorldDatabase.PQuery("SELECT COUNT(*) FROM %s",table); 92 if(result) 93 { 94 fields = result->Fetch(); 95 RecordCount=fields[0].GetUInt32(); 96 delete result; 97 } 98 else 99 RecordCount = 0; 100 101 result = WorldDatabase.PQuery("SELECT * FROM %s",table); 102 103 if(!result) 104 { 105 sLog.outError("%s table is empty!\n",table); 106 RecordCount = 0; 107 return; 108 } 109 110 uint32 recordsize=0; 111 uint32 offset=0; 112 113 if(iNumFields!=result->GetFieldCount()) 114 { 115 RecordCount = 0; 116 sLog.outError("Error in %s table, probably sql file format was updated (there should be %d fields in sql).\n",table,iNumFields); 117 delete result; 118 exit(1); // Stop server at loading broken or non-compatiable table. 119 } 120 121 //get struct size 122 uint32 sc=0; 123 uint32 bo=0; 124 uint32 bb=0; 125 for(uint32 x=0;x<iNumFields;x++) 126 if(format[x]==FT_STRING) 127 ++sc; 128 else if (format[x]==FT_LOGIC) 129 ++bo; 130 else if (format[x]==FT_BYTE) 131 ++bb; 132 recordsize=(iNumFields-sc-bo-bb)*4+sc*sizeof(char*)+bo*sizeof(bool)+bb*sizeof(char); 133 134 char** newIndex=new char*[maxi]; 135 memset(newIndex,0,maxi*sizeof(char*)); 136 137 char * _data= new char[RecordCount *recordsize]; 138 uint32 count=0; 139 barGoLink bar( RecordCount ); 140 do 141 { 142 fields = result->Fetch(); 143 bar.step(); 144 char *p=(char*)&_data[recordsize*count]; 145 newIndex[fields[0].GetUInt32()]=p; 146 147 offset=0; 148 for(uint32 x=0;x<iNumFields;x++) 149 switch(format[x]) 150 { 151 case FT_LOGIC: 152 *((bool*)(&p[offset]))=(fields[x].GetUInt32()>0); 153 offset+=sizeof(bool); 154 break; 155 case FT_BYTE: 156 *((char*)(&p[offset]))=(fields[x].GetUInt8()); 157 offset+=sizeof(char); 158 break; 159 case FT_INT: 160 *((uint32*)(&p[offset]))=fields[x].GetUInt32(); 161 offset+=sizeof(uint32); 162 break; 163 case FT_FLOAT: 164 *((float*)(&p[offset]))=fields[x].GetFloat(); 165 offset+=sizeof(float); 166 break; 167 case FT_STRING: 168 char const* tmp = fields[x].GetString(); 169 char* st; 170 if(!tmp) 171 { 172 st=new char[1]; 173 *st=0; 174 } 175 else 176 { 177 uint32 l=strlen(tmp)+1; 178 st=new char[l]; 179 memcpy(st,tmp,l); 180 } 181 *((char**)(&p[offset]))=st; 182 offset+=sizeof(char*); 183 break; 184 } 185 ++count; 186 }while( result->NextRow() ); 187 188 delete result; 189 190 pIndex =newIndex; 191 MaxEntry=maxi; 192 data=_data; 83 193 } -
trunk/src/shared/Database/SQLStorage.h
r260 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 … … 27 27 class SQLStorage 28 28 { 29 template<class T>30 friend struct SQLStorageLoaderBase;31 32 29 public: 33 30 34 SQLStorage(const char* fmt, const char * _entry_field,const char * sqlname)31 SQLStorage(const char*fmt,const char * _entry_field,const char * sqlname) 35 32 { 36 src_format = fmt; 37 dst_format = fmt; 38 init(_entry_field, sqlname); 33 format=fmt; 34 entry_field = _entry_field; 35 table=sqlname; 36 data=NULL; 37 pIndex=NULL; 38 iNumFields =strlen(fmt); 39 MaxEntry = 0; 39 40 } 40 41 SQLStorage(const char* src_fmt, const char* dst_fmt, const char * _entry_field, const char * sqlname)42 {43 src_format = src_fmt;44 dst_format = dst_fmt;45 init(_entry_field, sqlname);46 }47 48 49 41 ~SQLStorage() 50 42 { … … 65 57 uint32 MaxEntry; 66 58 uint32 iNumFields; 67 68 59 void Load(); 69 60 void Free(); 70 71 61 private: 72 void init(const char * _entry_field, const char * sqlname)73 {74 entry_field = _entry_field;75 table=sqlname;76 data=NULL;77 pIndex=NULL;78 iNumFields = strlen(src_format);79 MaxEntry = 0;80 }81 82 62 char** pIndex; 83 63 84 64 char *data; 85 const char *src_format; 86 const char *dst_format; 65 const char *format; 87 66 const char *table; 88 67 const char *entry_field; 89 68 //bool HasString; 90 69 }; 91 92 template <class T>93 struct SQLStorageLoaderBase94 {95 public:96 void Load(SQLStorage &storage);97 98 template<class S, class D>99 void convert(uint32 field_pos, S src, D &dst);100 template<class S>101 void convert_to_str(uint32 field_pos, S src, char * & dst);102 template<class D>103 void convert_from_str(uint32 field_pos, char * src, D& dst);104 void convert_str_to_str(uint32 field_pos, char *src, char *&dst);105 106 private:107 template<class V>108 void storeValue(V value, SQLStorage &store, char *p, int x, uint32 &offset);109 void storeValue(char * value, SQLStorage &store, char *p, int x, uint32 &offset);110 };111 112 struct SQLStorageLoader : public SQLStorageLoaderBase<SQLStorageLoader>113 {114 };115 116 70 #endif -
trunk/src/shared/Database/SqlOperations.cpp
r262 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/Database/SqlOperations.h
r262 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/Database/dbcfile.cpp
r260 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/Database/dbcfile.h
r260 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/ProgressBar.cpp
r260 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 -
trunk/src/shared/ProgressBar.h
r260 r272 11 11 * This program is distributed in the hope that it will be useful, 12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 * GNU General Public License for more details. 15 15 * 16 16 * You should have received a copy of the GNU General Public License 17 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 19 */ 20 20 #ifndef TRINITYCORE_PROGRESSBAR_H