Skip to content

Commit

Permalink
[patch 161] Added special table to DB for storage non-existed in DBC …
Browse files Browse the repository at this point in the history
…spells. Patch provided by QAston and Wowka321
  • Loading branch information
insider42 committed May 15, 2010
1 parent 0d382ee commit 486307e
Show file tree
Hide file tree
Showing 6 changed files with 308 additions and 12 deletions.
105 changes: 105 additions & 0 deletions addition/161_mangos_spell_dbc.sql
@@ -0,0 +1,105 @@
DROP TABLE IF EXISTS `spell_dbc`;
CREATE TABLE `spell_dbc` (
`Id` int(10) unsigned NOT NULL,
`Dispel` tinyint(3) unsigned NOT NULL DEFAULT '0',
`Mechanic` tinyint(3) unsigned NOT NULL DEFAULT '0',
`Attributes` int(10) unsigned NOT NULL DEFAULT '0',
`AttributesEx` int(10) unsigned NOT NULL DEFAULT '0',
`AttributesEx2` int(10) unsigned NOT NULL DEFAULT '0',
`AttributesEx3` int(10) unsigned NOT NULL DEFAULT '0',
`AttributesEx4` int(10) unsigned NOT NULL DEFAULT '0',
`AttributesEx5` int(10) unsigned NOT NULL DEFAULT '0',
`Stances` tinyint(3) unsigned NOT NULL DEFAULT '0',
`Targets` int(10) unsigned NOT NULL DEFAULT '0',
`CastingTimeIndex` tinyint(3) unsigned NOT NULL DEFAULT '1',
`AuraInterruptFlags` int(10) unsigned NOT NULL DEFAULT '0',
`ProcFlags` int(10) unsigned NOT NULL DEFAULT '0',
`ProcChance` tinyint(3) unsigned NOT NULL DEFAULT '0',
`ProcCharges` tinyint(3) unsigned NOT NULL DEFAULT '0',
`MaxLevel` tinyint(3) unsigned NOT NULL DEFAULT '0',
`BaseLevel` tinyint(3) unsigned NOT NULL DEFAULT '0',
`SpellLevel` tinyint(3) unsigned NOT NULL DEFAULT '0',
`DurationIndex` smallint(5) unsigned NOT NULL DEFAULT '0',
`RangeIndex` tinyint(3) unsigned NOT NULL DEFAULT '1',
`StackAmount` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EquippedItemClass` int(11) NOT NULL DEFAULT '-1',
`EquippedItemSubClassMask` int(11) NOT NULL DEFAULT '0',
`EquippedItemInventoryTypeMask` int(11) NOT NULL DEFAULT '0',
`Effect1` tinyint(3) unsigned NOT NULL DEFAULT '0',
`Effect2` tinyint(3) unsigned NOT NULL DEFAULT '0',
`Effect3` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectDieSides1` int(11) NOT NULL DEFAULT '0',
`EffectDieSides2` int(11) NOT NULL DEFAULT '0',
`EffectDieSides3` int(11) NOT NULL DEFAULT '0',
`EffectRealPointsPerLevel1` float NOT NULL DEFAULT '0',
`EffectRealPointsPerLevel2` float NOT NULL DEFAULT '0',
`EffectRealPointsPerLevel3` float NOT NULL DEFAULT '0',
`EffectBasePoints1` int(11) NOT NULL DEFAULT '0',
`EffectBasePoints2` int(11) NOT NULL DEFAULT '0',
`EffectBasePoints3` int(11) NOT NULL DEFAULT '0',
`EffectMechanic1` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectMechanic2` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectMechanic3` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectImplicitTargetA1` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectImplicitTargetA2` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectImplicitTargetA3` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectImplicitTargetB1` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectImplicitTargetB2` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectImplicitTargetB3` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectRadiusIndex1` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectRadiusIndex2` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectRadiusIndex3` tinyint(3) unsigned NOT NULL DEFAULT '0',
`EffectApplyAuraName1` smallint(5) unsigned NOT NULL DEFAULT '0',
`EffectApplyAuraName2` smallint(5) unsigned NOT NULL DEFAULT '0',
`EffectApplyAuraName3` smallint(5) unsigned NOT NULL DEFAULT '0',
`EffectAmplitude1` int(11) NOT NULL DEFAULT '0',
`EffectAmplitude2` int(11) NOT NULL DEFAULT '0',
`EffectAmplitude3` int(11) NOT NULL DEFAULT '0',
`EffectMultipleValue1` float NOT NULL DEFAULT '0',
`EffectMultipleValue2` float NOT NULL DEFAULT '0',
`EffectMultipleValue3` float NOT NULL DEFAULT '0',
`EffectMiscValue1` int(11) NOT NULL DEFAULT '0',
`EffectMiscValue2` int(11) NOT NULL DEFAULT '0',
`EffectMiscValue3` int(11) NOT NULL DEFAULT '0',
`EffectMiscValueB1` int(11) NOT NULL DEFAULT '0',
`EffectMiscValueB2` int(11) NOT NULL DEFAULT '0',
`EffectMiscValueB3` int(11) NOT NULL DEFAULT '0',
`EffectTriggerSpell1` int(10) unsigned NOT NULL DEFAULT '0',
`EffectTriggerSpell2` int(10) unsigned NOT NULL DEFAULT '0',
`EffectTriggerSpell3` int(10) unsigned NOT NULL DEFAULT '0',
`EffectSpellClassMaskA1` int(10) unsigned NOT NULL DEFAULT '0',
`EffectSpellClassMaskA2` int(10) unsigned NOT NULL DEFAULT '0',
`EffectSpellClassMaskA3` int(10) unsigned NOT NULL DEFAULT '0',
`EffectSpellClassMaskB1` int(10) unsigned NOT NULL DEFAULT '0',
`EffectSpellClassMaskB2` int(10) unsigned NOT NULL DEFAULT '0',
`EffectSpellClassMaskB3` int(10) unsigned NOT NULL DEFAULT '0',
`EffectSpellClassMaskC1` int(10) unsigned NOT NULL DEFAULT '0',
`EffectSpellClassMaskC2` int(10) unsigned NOT NULL DEFAULT '0',
`EffectSpellClassMaskC3` int(10) unsigned NOT NULL DEFAULT '0',
`MaxTargetLevel` tinyint(3) unsigned NOT NULL DEFAULT '0',
`SpellFamilyName` tinyint(3) unsigned NOT NULL DEFAULT '0',
`SpellFamilyFlags1` int(10) unsigned NOT NULL DEFAULT '0',
`SpellFamilyFlags2` int(10) unsigned NOT NULL DEFAULT '0',
`SpellFamilyFlags3` int(10) unsigned NOT NULL DEFAULT '0',
`MaxAffectedTargets` tinyint(3) unsigned NOT NULL DEFAULT '0',
`DmgClass` tinyint(3) unsigned NOT NULL DEFAULT '0',
`PreventionType` tinyint(3) unsigned NOT NULL DEFAULT '0',
`DmgMultiplier1` float NOT NULL DEFAULT '0',
`DmgMultiplier2` float NOT NULL DEFAULT '0',
`DmgMultiplier3` float NOT NULL DEFAULT '0',
`AreaGroupId` int(11) NOT NULL DEFAULT '0',
`SchoolMask` int(10) unsigned NOT NULL DEFAULT '0',
`Comment` text NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Custom spell.dbc entries';

INSERT INTO `spell_dbc` VALUES
('24395', '0', '0', '536936848', '32768', '4', '0', '0', '0', '0', '1', '1', '0', '0', '101', '0', '0', '40', '40', '85', '1', '0', '-1', '0', '0', '6', '6', '6', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '0', '0', '0', '0', '0', '0', '77', '77', '77', '0', '0', '0', '0', '0', '0', '1', '5', '17', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '9', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'Bestial Wrath - Immunity'),
('24396', '0', '0', '536936848', '32768', '4', '0', '0', '0', '0', '1', '1', '0', '0', '101', '0', '0', '40', '40', '85', '1', '0', '-1', '0', '0', '6', '6', '6', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '0', '0', '0', '0', '0', '0', '77', '77', '77', '0', '0', '0', '0', '0', '0', '14', '13', '24', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '9', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'Bestial Wrath - Immunity'),
('24397', '0', '0', '536936848', '268468224', '4', '0', '0', '0', '0', '1', '1', '0', '0', '101', '0', '0', '40', '40', '85', '1', '0', '-1', '0', '0', '6', '6', '6', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '0', '0', '0', '0', '0', '0', '77', '77', '77', '0', '0', '0', '0', '0', '0', '7', '10', '11', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '9', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'Bestial Wrath - Immunity'),
('26592', '0', '0', '536936848', '268468224', '4', '0', '0', '0', '0', '1', '1', '0', '0', '101', '0', '0', '40', '40', '85', '1', '0', '-1', '0', '0', '6', '6', '6', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '0', '0', '0', '0', '0', '0', '77', '77', '77', '0', '0', '0', '0', '0', '0', '2', '18', '30', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '9', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'Bestial Wrath - Immunity'),
('24900', '0', '0', '400', '1024', '0', '0', '2097152', '0', '1', '0', '1', '0', '0', '101', '0', '0', '0', '0', '21', '1', '0', '-1', '0', '0', '6', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '166', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '7', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'Heart of the Wild - Cat Bonus'),
('24899', '0', '0', '400', '1024', '0', '0', '2097152', '0', '144', '0', '1', '0', '0', '101', '0', '0', '0', '0', '21', '1', '0', '-1', '0', '0', '6', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '137', '0', '0', '0', '0', '0', '0', '0', '0', '2', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '7', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'Heart of the Wild - Bear Bonus'),
('56817', '0', '0', '384', '0', '0', '0', '0', '0', '0', '0', '1', '0', '16', '100', '1', '0', '67', '67', '1', '0', '0', '-1', '0', '0', '6', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '4', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '15', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'Rune Strike - Aura for 56815'),
('58428', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '100', '0', '0', '0', '0', '18', '1', '0', '-1', '0', '0', '6', '0', '0', '0', '0', '0', '0', '0', '0', '9', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '226', '0', '0', '0', '0', '0', '0', '0', '0', '9', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '8', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'Overkill'),
('62388', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '21', '1', '0', '-1', '0', '0', '6', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0', '4', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'Demonic Circle: Teleport(48020) - casterAuraSpell');
15 changes: 12 additions & 3 deletions src/game/DBCStores.cpp
Expand Up @@ -256,13 +256,19 @@ struct LocalData
};

template<class T>
inline void LoadDBC(LocalData& localeData,barGoLink& bar, StoreProblemList& errlist, DBCStorage<T>& storage, const std::string& dbc_path, const std::string& filename)
inline void LoadDBC(LocalData& localeData,barGoLink& bar, StoreProblemList& errlist, DBCStorage<T>& storage, const std::string& dbc_path, const std::string& filename, const std::string * custom_entries = NULL, const std::string * idname = NULL)
{
// compatibility format and C++ structure sizes
ASSERT(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T) || LoadDBC_assert_print(DBCFileLoader::GetFormatRecordSize(storage.GetFormat()),sizeof(T),filename));

std::string dbc_filename = dbc_path + filename;
if(storage.Load(dbc_filename.c_str()))

SqlDbc * sql = NULL;

if (custom_entries)
sql = new SqlDbc(&filename,custom_entries,idname,storage.GetFormat());

if(storage.Load(dbc_filename.c_str(),sql))
{
bar.step();
for(uint8 i = 0; fullLocaleNameList[i].name; ++i)
Expand Down Expand Up @@ -316,6 +322,9 @@ inline void LoadDBC(LocalData& localeData,barGoLink& bar, StoreProblemList& errl
else
errlist.push_back(dbc_filename);
}

if (sql)
delete sql;
}

void LoadDBCStores(const std::string& dataPath)
Expand Down Expand Up @@ -448,7 +457,7 @@ void LoadDBCStores(const std::string& dataPath)
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSkillLineStore, dbcPath,"SkillLine.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSkillLineAbilityStore, dbcPath,"SkillLineAbility.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSoundEntriesStore, dbcPath,"SoundEntries.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellStore, dbcPath,"Spell.dbc");
LoadDBC(availableDbcLocales,bar,bad_dbc_files,sSpellStore, dbcPath,"Spell.dbc", &CustomSpellEntryfmt, &CustomSpellEntryIndex);
for(uint32 i = 1; i < sSpellStore.GetNumRows(); ++i)
{
SpellEntry const * spell = sSpellStore.LookupEntry(i);
Expand Down
2 changes: 2 additions & 0 deletions src/game/DBCfmt.h
Expand Up @@ -89,6 +89,8 @@ const char SpellCastTimefmt[]="nixx";
const char SpellDurationfmt[]="niii";
const char SpellDifficultyfmt[]="niiii";
const char SpellEntryfmt[]="niiiiiiiiiixixixiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifxiiiiiiiiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiiiiiiiiiiixssssssssssssssssxssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiixfffxxxiiiiixxxxxxi";
const std::string CustomSpellEntryfmt="pappppppppaapaaapaaaaaaaaaaapaaapapppppppaaaaapaapaaaaaaaaaaaaaaaaaappppppppppppppppppppppppppppppppppppaaaaaapppppppppaaapppppppppaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaappppppppapppaaaaappaaaaaaa";
const std::string CustomSpellEntryIndex = "Id";
const char SpellFocusObjectfmt[]="nxxxxxxxxxxxxxxxxx";
const char SpellItemEnchantmentfmt[]="nxiiiiiixxxiiissssssssssssssssxiiiiiii";
const char SpellItemEnchantmentConditionfmt[]="nbbbbbxxxxxbbbbbbbbbbiiiiiXXXXX";
Expand Down
14 changes: 10 additions & 4 deletions src/shared/Database/DBCFileLoader.cpp
Expand Up @@ -135,7 +135,7 @@ uint32 DBCFileLoader::GetFormatRecordSize(const char * format,int32* index_pos)
return recordsize;
}

char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char**& indexTable)
char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char**& indexTable, uint32 sqlRecordCount, uint32 sqlHighestIndex, char *& sqlDataTable)
{
/*
format STRING, NA, FLOAT,NA,INT <=>
Expand Down Expand Up @@ -166,18 +166,22 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char**
if(ind>maxi)maxi=ind;
}

// If higher index avalible from sql - use it instead of dbcs
if (sqlHighestIndex > maxi)
maxi = sqlHighestIndex;

++maxi;
records=maxi;
indexTable=new ptr[maxi];
memset(indexTable,0,maxi*sizeof(ptr));
}
else
{
records = recordCount;
indexTable = new ptr[recordCount];
records = recordCount + sqlRecordCount;
indexTable = new ptr[recordCount + sqlRecordCount];
}

char* dataTable= new char[recordCount*recordsize];
char* dataTable= new char[(recordCount + sqlRecordCount)*recordsize];

uint32 offset=0;

Expand Down Expand Up @@ -215,6 +219,8 @@ char* DBCFileLoader::AutoProduceData(const char* format, uint32& records, char**
}
}

sqlDataTable = dataTable + offset;

return dataTable;
}

Expand Down
9 changes: 6 additions & 3 deletions src/shared/Database/DBCFileLoader.h
Expand Up @@ -32,7 +32,9 @@ enum
FT_BYTE='b', //uint8
FT_SORT='d', //sorted by this field, field is not included
FT_IND='n', //the same,but parsed to data
FT_LOGIC='l' //Logical (boolean)
FT_LOGIC='l', //Logical (boolean)
FT_SQL_PRESENT='p', //Used in sql format to mark column present in sql dbc
FT_SQL_ABSENT='a' //Used in sql format to mark column absent in sql dbc
};

class DBCFileLoader
Expand Down Expand Up @@ -87,11 +89,12 @@ class DBCFileLoader
Record getRecord(size_t id);
/// Get begin iterator over records

uint32 GetNumRows() const { return recordCount;}
uint32 GetNumRows() const { return recordCount; }
uint32 GetRowSize() const { return recordSize; }
uint32 GetCols() const { return fieldCount; }
uint32 GetOffset(size_t id) const { return (fieldsOffset != NULL && id < fieldCount) ? fieldsOffset[id] : 0; }
bool IsLoaded() {return (data!=NULL);}
char* AutoProduceData(const char* fmt, uint32& count, char**& indexTable);
char* AutoProduceData(const char* fmt, uint32& count, char**& indexTable, uint32 sqlRecordCount, uint32 sqlHighestIndex, char *& sqlDataTable);
char* AutoProduceStrings(const char* fmt, char* dataTable);
static uint32 GetFormatRecordSize(const char * format, int32 * index_pos = NULL);
private:
Expand Down

2 comments on commit 486307e

@waza123
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и чё это даёт?

@insider42
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Помогает "правильно" реализовать некоторые спелы, в основном все они в таблице.

Please sign in to comment.