Skip to content

Commit 03fe492

Browse files
committed
C#: Add rewriting of dbdf/dbde files & cleanup
1 parent ff7cdee commit 03fe492

10 files changed

Lines changed: 114 additions & 45 deletions

code/C#/DBDefsLib/DBDEnumWriter.cs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
using DBDefsLib.Constants;
2+
using DBDefsLib.Structs;
3+
using System.IO;
4+
using System.Text;
5+
6+
namespace DBDefsLib
7+
{
8+
public class DBDEnumWriter
9+
{
10+
public void Save(EnumDefinition enumDefinition, string filePath)
11+
{
12+
var sb = new StringBuilder();
13+
14+
foreach (var entry in enumDefinition.entries)
15+
{
16+
if ((entry.builds != null && entry.builds.Length > 0) || entry.buildRanges != null && entry.buildRanges.Length > 0)
17+
{
18+
sb.Append($"(BUILD ");
19+
20+
if (entry.builds != null && entry.builds.Length > 0)
21+
{
22+
for (int i = 0; i < entry.builds.Length; i++)
23+
{
24+
sb.Append(entry.builds[i].ToString());
25+
if (i < entry.builds.Length - 1 || (entry.buildRanges != null && entry.buildRanges.Length > 0))
26+
sb.Append(", ");
27+
}
28+
}
29+
30+
if (entry.buildRanges != null && entry.buildRanges.Length > 0)
31+
{
32+
for (int i = 0; i < entry.buildRanges.Length; i++)
33+
{
34+
sb.Append(entry.buildRanges[i].ToString());
35+
if (i < entry.buildRanges.Length - 1)
36+
sb.Append(", ");
37+
}
38+
}
39+
40+
sb.Append(") ");
41+
}
42+
43+
if (enumDefinition.metaType == MetaType.FLAGS)
44+
sb.Append("0x" + entry.value.ToString("X"));
45+
else
46+
sb.Append(entry.value);
47+
48+
if (!string.IsNullOrEmpty(entry.name))
49+
sb.Append($" {entry.name}");
50+
51+
if (!string.IsNullOrEmpty(entry.comment))
52+
{
53+
sb.Append($" // {entry.comment}");
54+
}
55+
56+
sb.AppendLine();
57+
}
58+
59+
File.WriteAllText(filePath, sb.ToString());
60+
}
61+
}
62+
}

code/C#/DBDefsValidator/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,13 @@ static void Main(string[] args)
244244
{
245245
var dbdeReader = new DBDEnumReader();
246246
var enumDef = dbdeReader.Read(fs, mapping.meta);
247+
fs.Close();
248+
249+
if(rewrite)
250+
{
251+
var dbdeWriter = new DBDEnumWriter();
252+
dbdeWriter.Save(enumDef, path);
253+
}
247254
}
248255
catch (Exception ex)
249256
{

meta/enums/CriteriaAdditionalCondition.dbde

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
232 MAIN_HAND_VISIBLE_SUBCLASS // Player has main hand weapon of type "{$Weapon Type}"
234234
233 OFF_HAND_VISIBLE_SUBCLASS // Player has off-hand weapon of type "{$Weapon Type}"
235235
234 PVP_TIER // Player is in PvP tier {PvpTier}
236-
235 AZERITE_ITEM_LEVEL // Players\' Azerite Item is at or above level "{#Azerite Level}"
236+
235 AZERITE_ITEM_LEVEL // Players\' Azerite Item is at or above level "{#Azerite Level}"
237237
236 ON_QUESTLINE // Player is on quest in questline "{QuestLine}"
238238
237 ON_SWG_UNLOCK_QUEST // Player is on quest associated with current progressive unlock group "{ScheduledWorldStateGroup}"
239239
238 IN_RAID_GROUP // Player is in raid group

meta/enums/SpellEffectAura.dbde

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,9 @@
446446
445 // UNUSED IN 9.0.1.34199
447447
446 SPELL_AURA_ADVANCED_FLYING
448448
447 MOD_XP_FROM_CREATURE_TYPE
449-
448// Related to PvP rules
450-
449// UNUSED IN 9.0.1.34199
451-
450// Only used in Character Upgrade Spell Tier (156747)
449+
448 // Related to PvP rules
450+
449 // UNUSED IN 9.0.1.34199
451+
450 // Only used in Character Upgrade Spell Tier (156747)
452452
451 OVERRIDE_PET_SPECS
453453
452 // UNUSED IN 9.0.1.34199
454454
453 CHARGE_RECOVERY_MOD

meta/flags/AnimKitConfigFlags.dbdf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
0x800 IF_ANY_BONE_SET_IS_SUPPRESSED_BY_A_HIGHER_PRIORITY_STOP_KIT
1313
0x1000 IF_ALL_BONE_SETS_ARE_SUPPRESSED_BY_A_HIGHER_PRIORITY_STOP_KIT
1414
0x2000 WHEN_NO_LONGER_SUPPRESSED_BY_A_HIGHER_PRIORITY_RESTART_CURRENT_SEGMENT
15-
0x4000 ADVANCED_PLAY_SEGMENT_EVEN_IF_BONE_SET_IS_MISSING// for animation mirroring
15+
0x4000 ADVANCED_PLAY_SEGMENT_EVEN_IF_BONE_SET_IS_MISSING // for animation mirroring
1616
0x8000 ADVANCED_BLOCKS_SECONDARY_ANIMATION_WHEN_ACTIVE
1717
0x10000 ADVANCED_DONT_RESTART_SEGMENT_IF_THE_ANIMATION_IS_UNCHANGED_FOLLOWING_A_SET
1818
0x20000 IF_ANY_BONE_SET_IS_SUPPRESSED_BY_A_HIGHER_PRIORITY_SUPPRESS_SEGMENT

meta/flags/CreatureStaticFlags5.dbdf

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
0x00000001 DO_NOT_AUTO_RESUMMON_THIS_COMPANION_CREATURE
2-
0x00000002 SMOOTH_PHASING_REPLACE_VISIBLE_UNIT_IF_AVAILABLE // Ask programmer first
3-
0x00000004 IGNORE_THE_REALM_COALESCING_HIDING_CODE // Always show
4-
0x00000008 TAPS_TO_FACTION
5-
0x00000010 ONLY_QUESTGIVER_FOR_SUMMONER
6-
0x00000020 AI_COMBAT_RETURN_PRECISE
7-
0x00000040 HOME_REALM_ONLY_LOOT
8-
0x00000080 NO_INTERACT_RESPONSE
9-
0x00000100 NO_INITIAL_POWER
10-
0x00000200 DONT_CANCEL_CHANNEL_ON_MASTER_MOUNTING
11-
0x00000400 CAN_TOGGLE_BETWEEN_DEATH_AND_PERSONAL_LOOT
12-
0x00000800 ALWAYS_TRIES_TO_STAND_RIGHT_ON_TOP_OF_HIS_MOVE_TO_TARGET // ALWAYS!!
13-
0x00001000 UNCONSCIOUS_ON_DEATH
14-
0x00002000 DONT_REPORT_TO_LOCAL_DEFENSE_CHANNEL_ON_DEATH
15-
0x00004000 PREFER_UNENGAGED_MONSTERS_WHEN_PICKING_A_TARGET
16-
0x00008000 USE_PVP_POWER_AND_RESILIENCE_WHEN_PLAYERS_ATTACK_THIS_CREATURE
17-
0x00010000 DONT_CLEAR_DEBUFFS_ON_LEAVE_COMBAT
18-
0x00020000 PERSONAL_LOOT_HAS_FULL_SECURITY // Guaranteed push/mail delivery
19-
0x00040000 TRIPLE_SPELL_VISUALS
20-
0x00080000 USE_GARRISON_OWNER_LEVEL
21-
0x00100000 IMMEDIATE_AOI_UPDATE_ON_SPAWN
22-
0x00200000 UI_CAN_GET_POSITION
23-
0x00400000 SEAMLESS_TRANSFER_PROHIBITED
24-
0x00800000 ALWAYS_USE_GROUP_LOOT_METHOD
25-
0x01000000 NO_BOSS_KILL_BANNER
26-
0x02000000 FORCE_TRIGGERING_PLAYER_LOOT_ONLY
27-
0x04000000 SHOW_BOSS_FRAME_WHILE_UNINTERACTABLE
28-
0x08000000 SCALES_TO_PLAYER_LEVEL
1+
0x1 DO_NOT_AUTO_RESUMMON_THIS_COMPANION_CREATURE
2+
0x2 SMOOTH_PHASING_REPLACE_VISIBLE_UNIT_IF_AVAILABLE // Ask programmer first
3+
0x4 IGNORE_THE_REALM_COALESCING_HIDING_CODE // Always show
4+
0x8 TAPS_TO_FACTION
5+
0x10 ONLY_QUESTGIVER_FOR_SUMMONER
6+
0x20 AI_COMBAT_RETURN_PRECISE
7+
0x40 HOME_REALM_ONLY_LOOT
8+
0x80 NO_INTERACT_RESPONSE
9+
0x100 NO_INITIAL_POWER
10+
0x200 DONT_CANCEL_CHANNEL_ON_MASTER_MOUNTING
11+
0x400 CAN_TOGGLE_BETWEEN_DEATH_AND_PERSONAL_LOOT
12+
0x800 ALWAYS_TRIES_TO_STAND_RIGHT_ON_TOP_OF_HIS_MOVE_TO_TARGET // ALWAYS!!
13+
0x1000 UNCONSCIOUS_ON_DEATH
14+
0x2000 DONT_REPORT_TO_LOCAL_DEFENSE_CHANNEL_ON_DEATH
15+
0x4000 PREFER_UNENGAGED_MONSTERS_WHEN_PICKING_A_TARGET
16+
0x8000 USE_PVP_POWER_AND_RESILIENCE_WHEN_PLAYERS_ATTACK_THIS_CREATURE
17+
0x10000 DONT_CLEAR_DEBUFFS_ON_LEAVE_COMBAT
18+
0x20000 PERSONAL_LOOT_HAS_FULL_SECURITY // Guaranteed push/mail delivery
19+
0x40000 TRIPLE_SPELL_VISUALS
20+
0x80000 USE_GARRISON_OWNER_LEVEL
21+
0x100000 IMMEDIATE_AOI_UPDATE_ON_SPAWN
22+
0x200000 UI_CAN_GET_POSITION
23+
0x400000 SEAMLESS_TRANSFER_PROHIBITED
24+
0x800000 ALWAYS_USE_GROUP_LOOT_METHOD
25+
0x1000000 NO_BOSS_KILL_BANNER
26+
0x2000000 FORCE_TRIGGERING_PLAYER_LOOT_ONLY
27+
0x4000000 SHOW_BOSS_FRAME_WHILE_UNINTERACTABLE
28+
0x8000000 SCALES_TO_PLAYER_LEVEL
2929
0x10000000 AI_DONT_LEAVE_MELEE_FOR_RANGED_WHEN_TARGET_GETS_ROOTED
3030
0x20000000 DONT_USE_COMBAT_REACH_FOR_CHAINING
3131
0x40000000 DO_NOT_PLAY_PROCEDURAL_WOUND_ANIM

meta/flags/GarrFollowerFlags.dbdf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
0x01 UNIQUE_FOLLOWER
2-
0x02 NO_AUTOMATIC_SPAWNING
3-
0x04 INTERNAL_ONLY
4-
0x08 KILLED_BY_ALWAYS_FAIL_MISSIONS
1+
0x1 UNIQUE_FOLLOWER
2+
0x2 NO_AUTOMATIC_SPAWNING
3+
0x4 INTERNAL_ONLY
4+
0x8 KILLED_BY_ALWAYS_FAIL_MISSIONS
55
0x10 HIDDEN_UNLESS_COLLECTED

meta/flags/ItemStaticFlags3.dbdf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
0x8000000 NOT_MULTICRAFTABLE
2929
0x10000000 DONT_REPORT_LOOT_LOG_TO_SELF
3030
0x20000000 SEND_TELEMETRY_ON_USE
31-
0x40000000
32-
0x80000000
31+
0x40000000
32+
0x80000000

meta/flags/QuestObjectiveFlags.dbdf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
0x01 TRACK_ON_MINIMAP
2-
0x02 SEQUENCED
3-
0x04 OPTIONAL
4-
0x08 HIDDEN
1+
0x1 TRACK_ON_MINIMAP
2+
0x2 SEQUENCED
3+
0x4 OPTIONAL
4+
0x8 HIDDEN
55
0x10 HIDE_CREDIT_MSG
66
0x20 PRESERVE_QUEST_ITEMS
77
0x40 PROGRESS_BAR_SUB_TASK

meta/flags/SpellAttributes0.dbdf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
0x1 PROC_FAILURE_BURNS_CHARGE // Proc Failure Burns Charge
1+
0x1 PROC_FAILURE_BURNS_CHARGE // Proc Failure Burns Charge
22
0x2 REQ_AMMO // Uses Ranged Slot
33
0x4 ON_NEXT_SWING // On Next Swing (No Damage)
44
0x8 IS_REPLENISHMENT // Do Not Log Immune Misses, not set in 3.0.3
@@ -9,7 +9,7 @@
99
0x100 HIDE_IN_COMBAT_LOG // Do Not Log, This attribite controls whether spell appears in combat logs
1010
0x200 TARGET_MAINHAND_ITEM // Held Item Only, Client automatically selects item from mainhand slot as a cast target
1111
0x400 ON_NEXT_SWING_2 // On Next Swing
12-
0x800 WEARER_PROC_TRIGGER // Wearer Casts Proc Trigger
12+
0x800 WEARER_PROC_TRIGGER // Wearer Casts Proc Trigger
1313
0x1000 DAYTIME_ONLY // Server Only, only useable at daytime, not set in 2.4.2
1414
0x2000 NIGHT_ONLY // Allow Item Spell In PvP, only useable at night, not set in 2.4.2
1515
0x4000 INDOORS_ONLY // Only Indoors, only useable indoors, not set in 2.4.2

0 commit comments

Comments
 (0)