forked from simulationcraft/simc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsc_util.cpp
3100 lines (2665 loc) · 105 KB
/
sc_util.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==========================================================================
// Dedmonwakeen's Raid DPS/TPS Simulator.
// Send questions to [email protected]
// ==========================================================================
#include "simulationcraft.hpp"
#if !defined(SC_WINDOWS)
#include <sys/time.h>
#endif
#include <cerrno>
namespace { // anonymous namespace ==========================================
struct spec_map_t
{
specialization_e spec;
const char* name;
};
const spec_map_t spec_map[] =
{
{ WARRIOR_ARMS, "Arms Warrior" },
{ WARRIOR_FURY, "Fury Warrior" },
{ WARRIOR_PROTECTION, "Protection Warrior" },
{ PALADIN_HOLY, "Holy Paladin" },
{ PALADIN_PROTECTION, "Protection Paladin" },
{ PALADIN_RETRIBUTION, "Retribution Paladin" },
{ HUNTER_BEAST_MASTERY, "Beast Mastery Hunter" },
{ HUNTER_BEAST_MASTERY, "Beast-Mastery Hunter" }, // Alternate
{ HUNTER_MARKSMANSHIP, "Marksmanship Hunter" },
{ HUNTER_SURVIVAL, "Survival Hunter" },
{ ROGUE_ASSASSINATION, "Assassination Rogue" },
{ ROGUE_COMBAT, "Combat Rogue" },
{ ROGUE_SUBTLETY, "Subtlety Rogue" },
{ PRIEST_DISCIPLINE, "Discipline Priest" },
{ PRIEST_HOLY, "Holy Priest" },
{ PRIEST_SHADOW, "Shadow Priest" },
{ DEATH_KNIGHT_BLOOD, "Blood Death Knight" }, // Default
{ DEATH_KNIGHT_BLOOD, "Blood DeathKnight" }, // Alternate (battle.net match)
{ DEATH_KNIGHT_FROST, "Frost Death Knight" }, // Default
{ DEATH_KNIGHT_FROST, "Frost DeathKnight" }, // Alternate (battle.net match)
{ DEATH_KNIGHT_UNHOLY, "Unholy Death Knight" }, // Default
{ DEATH_KNIGHT_UNHOLY, "Unholy DeathKnight" }, // Alternate (battle.net match)
{ SHAMAN_ELEMENTAL, "Elemental Shaman" },
{ SHAMAN_ENHANCEMENT, "Enhancement Shaman" },
{ SHAMAN_RESTORATION, "Restoration Shaman" },
{ MAGE_ARCANE, "Arcane Mage" },
{ MAGE_FIRE, "Fire Mage" },
{ MAGE_FROST, "Frost Mage" },
{ WARLOCK_AFFLICTION, "Affliction Warlock" },
{ WARLOCK_DEMONOLOGY, "Demonology Warlock" },
{ WARLOCK_DESTRUCTION, "Destruction Warlock" },
{ MONK_BREWMASTER, "Brewmaster Monk" },
{ MONK_MISTWEAVER, "Mistweaver Monk" },
{ MONK_WINDWALKER, "Windwalker Monk" },
{ DRUID_BALANCE, "Balance Druid" },
{ DRUID_FERAL, "Feral Druid" },
{ DRUID_GUARDIAN, "Guardian Druid" },
{ DRUID_RESTORATION, "Restoration Druid" },
};
struct html_named_character_t
{
const char* encoded;
const char* decoded;
};
const html_named_character_t html_named_character_map[] =
{
{ "amp", "&" },
{ "gt", ">" },
{ "lt", "<" },
{ "quot", "\"" },
};
// parse_enum ===============================================================
template <typename T, T Min, T Max, const char* F( T )>
inline T parse_enum( const std::string& name )
{
for ( T i = Min; i < Max; ++i )
if ( util::str_compare_ci( name, F( i ) ) )
return i;
return Min;
}
// pred_ci ==================================================================
bool pred_ci ( char a, char b )
{
return std::tolower( a ) == std::tolower( b );
}
// vfprintf_helper ==========================================================
int vfprintf_helper( FILE *stream, const char *fmt, va_list args )
{
std::string p_locale = setlocale( LC_CTYPE, nullptr );
setlocale( LC_CTYPE, "" );
int retcode = ::fprintf( stream, "%s", str::format( fmt, args ).c_str() );
setlocale( LC_CTYPE, p_locale.c_str() );
return retcode;
}
stopwatch_t wall_sw( STOPWATCH_WALL );
stopwatch_t cpu_sw( STOPWATCH_CPU );
} // anonymous namespace ============================================
double util::wall_time() { return wall_sw.elapsed(); }
double util::cpu_time() { return cpu_sw.elapsed(); }
/// case-insensitive string comparison
bool util::str_compare_ci( const std::string& l,
const std::string& r )
{
if ( l.size() != r.size() )
return false;
else
return std::equal( l.begin(), l.end(), r.begin(), pred_ci );
}
// glyph_name ===============================================================
std::string& util::glyph_name( std::string& n )
{
tokenize( n );
if ( n.compare( 0, 7, "glyph__" ) == 0 )
n.erase( 0, 7 );
else if ( n.compare( 0, 13, "glyph_of_the_" ) == 0 )
n.erase( 0, 13 );
else if ( n.compare( 0, 9, "glyph_of_" ) == 0 )
n.erase( 0, 9 );
return n;
}
// str_prefix_ci ============================================================
bool util::str_prefix_ci( const std::string& str,
const std::string& prefix )
{
if ( str.size() < prefix.size() )
return false;
else
return std::equal( prefix.begin(), prefix.end(), str.begin(), pred_ci );
}
// str_in_str_ci ============================================================
bool util::str_in_str_ci( const std::string& l,
const std::string& r )
{
return std::search( l.begin(), l.end(), r.begin(), r.end(), pred_ci ) != l.end();
}
// rating_t::interpolate ====================================================
double util::interpolate( int level,
double val_60,
double val_70,
double val_80,
double val_85 )
{
if ( val_85 < 0 ) val_85 = val_80; // TODO
if ( level <= 60 )
{
return val_60;
}
else if ( level == 70 )
{
return val_70;
}
else if ( level == 80 )
{
return val_80;
}
else if ( level >= 85 )
{
return val_85;
}
else if ( level < 70 )
{
// Assume linear progression for now.
double adjust = ( level - 60 ) / 10.0;
return val_60 + adjust * ( val_70 - val_60 );
}
else if ( level < 80 )
{
// Assume linear progression for now.
double adjust = ( level - 70 ) / 10.0;
return val_70 + adjust * ( val_80 - val_70 );
}
else // ( level < 85 )
{
// Assume linear progression for now.
double adjust = ( level - 80 ) / 5.0;
return val_80 + adjust * ( val_85 - val_80 );
}
assert( 0 );
return 0;
}
// dot_behavior_type_string =================================================
const char* util::dot_behavior_type_string( dot_behavior_e t )
{
switch ( t )
{
case DOT_REFRESH: return "DOT_REFRESH";
case DOT_CLIP: return "DOT_CLIP";
case DOT_EXTEND: return "DOT_EXTEND";
default: return "unknown";
}
}
// role_type_string =========================================================
const char* util::role_type_string( role_e role )
{
switch ( role )
{
case ROLE_ATTACK: return "attack";
case ROLE_SPELL: return "spell";
case ROLE_HYBRID: return "hybrid";
case ROLE_DPS: return "dps";
case ROLE_TANK: return "tank";
case ROLE_HEAL: return "heal";
case ROLE_NONE: return "auto";
default: return "unknown";
}
}
// parse_role_type ==========================================================
role_e util::parse_role_type( const std::string& name )
{
return parse_enum<role_e, ROLE_NONE, ROLE_MAX, role_type_string>( name );
}
// race_type_string =========================================================
const char* util::race_type_string( race_e type )
{
switch ( type )
{
case RACE_NONE: return "none";
case RACE_BEAST: return "beast";
case RACE_BLOOD_ELF: return "blood_elf";
case RACE_DEMON: return "demon";
case RACE_DRAENEI: return "draenei";
case RACE_DRAGONKIN: return "dragonkin";
case RACE_DWARF: return "dwarf";
case RACE_GIANT: return "giant";
case RACE_GNOME: return "gnome";
case RACE_HUMAN: return "human";
case RACE_HUMANOID: return "humanoid";
case RACE_NIGHT_ELF: return "night_elf";
case RACE_ORC: return "orc";
case RACE_TAUREN: return "tauren";
case RACE_TROLL: return "troll";
case RACE_UNDEAD: return "undead";
case RACE_GOBLIN: return "goblin";
case RACE_WORGEN: return "worgen";
case RACE_PANDAREN: return "pandaren";
case RACE_PANDAREN_ALLIANCE: return "pandaren_alliance";
case RACE_PANDAREN_HORDE: return "pandaren_horde";
default: return "unknown";
}
}
// race_type_string =========================================================
const char* util::stats_type_string( stats_e type )
{
switch ( type )
{
case STATS_NEUTRAL: return "neutral";
case STATS_DMG: return "damage";
case STATS_HEAL: return "heal";
case STATS_ABSORB: return "absorb";
default: return "unknown";
}
}
// parse_race_type ==========================================================
race_e util::parse_race_type( const std::string &name )
{
if ( name == "forsaken" ) return RACE_UNDEAD;
return parse_enum<race_e, RACE_NONE, RACE_MAX, race_type_string>( name );
}
// position_type_string =====================================================
const char* util::position_type_string( position_e type )
{
switch ( type )
{
case POSITION_NONE: return "none";
case POSITION_BACK: return "back";
case POSITION_FRONT: return "front";
case POSITION_RANGED_BACK: return "ranged_back";
case POSITION_RANGED_FRONT: return "ranged_front";
default: return "unknown";
}
}
// parse_position_type ======================================================
position_e util::parse_position_type( const std::string &name )
{
return parse_enum<position_e, POSITION_NONE, POSITION_MAX, position_type_string>( name );
}
// profession_type_string ===================================================
const char* util::profession_type_string( profession_e type )
{
switch ( type )
{
case PROFESSION_NONE: return "none";
case PROF_ALCHEMY: return "alchemy";
case PROF_BLACKSMITHING: return "blacksmithing";
case PROF_ENCHANTING: return "enchanting";
case PROF_ENGINEERING: return "engineering";
case PROF_HERBALISM: return "herbalism";
case PROF_INSCRIPTION: return "inscription";
case PROF_JEWELCRAFTING: return "jewelcrafting";
case PROF_LEATHERWORKING: return "leatherworking";
case PROF_MINING: return "mining";
case PROF_SKINNING: return "skinning";
case PROF_TAILORING: return "tailoring";
default: return "unknown";
}
}
// parse_profession_type ====================================================
profession_e util::parse_profession_type( const std::string& name )
{
return parse_enum<profession_e, PROFESSION_NONE, PROFESSION_MAX, profession_type_string>( name );
}
// translate_profession_id ==================================================
profession_e util::translate_profession_id( int skill_id )
{
switch ( skill_id )
{
case 164: return PROF_BLACKSMITHING;
case 165: return PROF_LEATHERWORKING;
case 171: return PROF_ALCHEMY;
case 182: return PROF_HERBALISM;
case 186: return PROF_MINING;
case 197: return PROF_TAILORING;
case 202: return PROF_ENGINEERING;
case 333: return PROF_ENCHANTING;
case 393: return PROF_SKINNING;
case 755: return PROF_JEWELCRAFTING;
case 773: return PROF_INSCRIPTION;
}
return PROFESSION_NONE;
}
// player_type_string =======================================================
const char* util::player_type_string( player_e type )
{
switch ( type )
{
case PLAYER_NONE: return "none";
case DEATH_KNIGHT: return "deathknight";
case DRUID: return "druid";
case HUNTER: return "hunter";
case MAGE: return "mage";
case MONK: return "monk";
case PALADIN: return "paladin";
case PRIEST: return "priest";
case ROGUE: return "rogue";
case SHAMAN: return "shaman";
case WARLOCK: return "warlock";
case WARRIOR: return "warrior";
case PLAYER_PET: return "pet";
case PLAYER_GUARDIAN: return "guardian";
case ENEMY: return "enemy";
case ENEMY_ADD: return "add";
case TMI_BOSS: return "tmi_boss";
case TANK_DUMMY: return "tank_dummy";
default: return "unknown";
}
}
// parse_player_type ========================================================
player_e util::parse_player_type( const std::string& name )
{
return parse_enum<player_e, PLAYER_NONE, PLAYER_MAX, player_type_string>( name );
}
// translate_class_str ======================================================
player_e util::translate_class_str( const std::string& s )
{
return parse_enum<player_e, PLAYER_NONE, PLAYER_MAX, player_type_string>( s );
}
// pet_type_string ==========================================================
const char* util::pet_type_string( pet_e type )
{
switch ( type )
{
case PET_NONE: return "none";
case PET_CARRION_BIRD: return "carrion_bird";
case PET_CAT: return "cat";
case PET_CORE_HOUND: return "core_hound";
case PET_DEVILSAUR: return "devilsaur";
case PET_FOX: return "fox";
case PET_HYENA: return "hyena";
case PET_MOTH: return "moth";
case PET_MONKEY: return "monkey";
case PET_DOG: return "dog";
case PET_BEETLE: return "beetle";
case PET_RAPTOR: return "raptor";
case PET_SPIRIT_BEAST: return "spirit_beast";
case PET_TALLSTRIDER: return "tallstrider";
case PET_WASP: return "wasp";
case PET_WOLF: return "wolf";
case PET_BEAR: return "bear";
case PET_BOAR: return "boar";
case PET_CRAB: return "crab";
case PET_CROCOLISK: return "crocolisk";
case PET_GORILLA: return "gorilla";
case PET_RHINO: return "rhino";
case PET_SCORPID: return "scorpid";
case PET_SHALE_SPIDER: return "shale_spider";
case PET_TURTLE: return "turtle";
case PET_WARP_STALKER: return "warp_stalker";
case PET_WORM: return "worm";
case PET_BAT: return "bat";
case PET_BIRD_OF_PREY: return "bird_of_prey";
case PET_CHIMAERA: return "chimaera";
case PET_DRAGONHAWK: return "dragonhawk";
case PET_NETHER_RAY: return "nether_ray";
case PET_RAVAGER: return "ravager";
case PET_SERPENT: return "serpent";
case PET_SILITHID: return "silithid";
case PET_SPIDER: return "spider";
case PET_SPOREBAT: return "sporebat";
case PET_WIND_SERPENT: return "wind_serpent";
case PET_FELGUARD: return "felguard";
case PET_WRATHGUARD: return "wrathguard";
case PET_FELHUNTER: return "felhunter";
case PET_IMP: return "imp";
case PET_VOIDWALKER: return "voidwalker";
case PET_SUCCUBUS: return "succubus";
case PET_INFERNAL: return "infernal";
case PET_DOOMGUARD: return "doomguard";
case PET_GHOUL: return "ghoul";
case PET_BLOODWORMS: return "bloodworms";
case PET_DANCING_RUNE_WEAPON: return "dancing_rune_weapon";
case PET_TREANTS: return "treants";
case PET_WATER_ELEMENTAL: return "water_elemental";
case PET_SHADOWFIEND: return "shadowfiend";
case PET_SPIRIT_WOLF: return "spirit_wolf";
case PET_FIRE_ELEMENTAL: return "fire_elemental";
case PET_EARTH_ELEMENTAL: return "earth_elemental";
case PET_ENEMY: return "pet_enemy";
default: return "unknown";
}
}
// parse_pet_type ===========================================================
pet_e util::parse_pet_type( const std::string& name )
{
return parse_enum<pet_e, PET_NONE, PET_MAX, pet_type_string>( name );
}
// attribute_type_string ====================================================
const char* util::attribute_type_string( attribute_e type )
{
switch ( type )
{
case ATTR_STRENGTH: return "strength";
case ATTR_AGILITY: return "agility";
case ATTR_STAMINA: return "stamina";
case ATTR_INTELLECT: return "intellect";
case ATTR_SPIRIT: return "spirit";
case ATTR_AGI_INT: return "agility/intellect";
case ATTR_STR_AGI: return "strength/agility";
case ATTR_STR_INT: return "strength/intellect";
case ATTR_STR_AGI_INT: return "strength/agility/intellect";
default: return "unknown";
}
}
// parse_attribute_type =====================================================
attribute_e util::parse_attribute_type( const std::string& name )
{
return parse_enum<attribute_e, ATTRIBUTE_NONE, ATTRIBUTE_MAX, attribute_type_string>( name );
}
// meta_gem_type_string =====================================================
const char* util::meta_gem_type_string( meta_gem_e type )
{
switch ( type )
{
case META_AGILE_SHADOWSPIRIT: return "agile_shadowspirit";
case META_AGILE_PRIMAL: return "agile_primal";
case META_AUSTERE_EARTHSIEGE: return "austere_earthsiege";
case META_AUSTERE_SHADOWSPIRIT: return "austere_shadowspirit";
case META_AUSTERE_PRIMAL: return "austere_primal";
case META_BEAMING_EARTHSIEGE: return "beaming_earthsiege";
case META_BRACING_EARTHSIEGE: return "bracing_earthsiege";
case META_BRACING_EARTHSTORM: return "bracing_earthstorm";
case META_BRACING_SHADOWSPIRIT: return "bracing_shadowspirit";
case META_BURNING_SHADOWSPIRIT: return "burning_shadowspirit";
case META_BURNING_PRIMAL: return "burning_primal";
case META_CHAOTIC_SHADOWSPIRIT: return "chaotic_shadowspirit";
case META_CHAOTIC_SKYFIRE: return "chaotic_skyfire";
case META_CHAOTIC_SKYFLARE: return "chaotic_skyflare";
case META_DESTRUCTIVE_SHADOWSPIRIT: return "destructive_shadowspirit";
case META_DESTRUCTIVE_PRIMAL: return "destructive_primal";
case META_DESTRUCTIVE_SKYFIRE: return "destructive_skyfire";
case META_DESTRUCTIVE_SKYFLARE: return "destructive_skyflare";
case META_EFFULGENT_SHADOWSPIRIT: return "effulgent_shadowspirit";
case META_EFFULGENT_PRIMAL: return "effulgent_primal";
case META_EMBER_SHADOWSPIRIT: return "ember_shadowspirit";
case META_EMBER_PRIMAL: return "ember_primal";
case META_EMBER_SKYFIRE: return "ember_skyfire";
case META_EMBER_SKYFLARE: return "ember_skyflare";
case META_ENIGMATIC_SHADOWSPIRIT: return "enigmatic_shadowspirit";
case META_ENIGMATIC_PRIMAL: return "enigmatic_primal";
case META_ENIGMATIC_SKYFLARE: return "enigmatic_skyflare";
case META_ENIGMATIC_STARFLARE: return "enigmatic_starflare";
case META_ENIGMATIC_SKYFIRE: return "enigmatic_skyfire";
case META_ETERNAL_EARTHSIEGE: return "eternal_earthsiege";
case META_ETERNAL_EARTHSTORM: return "eternal_earthstorm";
case META_ETERNAL_SHADOWSPIRIT: return "eternal_shadowspirit";
case META_ETERNAL_PRIMAL: return "eternal_primal";
case META_FLEET_SHADOWSPIRIT: return "fleet_shadowspirit";
case META_FLEET_PRIMAL: return "fleet_primal";
case META_FORLORN_SHADOWSPIRIT: return "forlorn_shadowspirit";
case META_FORLORN_PRIMAL: return "forlorn_primal";
case META_FORLORN_SKYFLARE: return "forlorn_skyflare";
case META_FORLORN_STARFLARE: return "forlorn_starflare";
case META_IMPASSIVE_SHADOWSPIRIT: return "impassive_shadowspirit";
case META_IMPASSIVE_PRIMAL: return "impassive_primal";
case META_IMPASSIVE_SKYFLARE: return "impassive_skyflare";
case META_IMPASSIVE_STARFLARE: return "impassive_starflare";
case META_INSIGHTFUL_EARTHSIEGE: return "insightful_earthsiege";
case META_INSIGHTFUL_EARTHSTORM: return "insightful_earthstorm";
case META_INVIGORATING_EARTHSIEGE: return "invigorating_earthsiege";
case META_MYSTICAL_SKYFIRE: return "mystical_skyfire";
case META_PERSISTENT_EARTHSHATTER: return "persistent_earthshatter";
case META_PERSISTENT_EARTHSIEGE: return "persistent_earthsiege";
case META_POWERFUL_EARTHSHATTER: return "powerful_earthshatter";
case META_POWERFUL_EARTHSIEGE: return "powerful_earthsiege";
case META_POWERFUL_EARTHSTORM: return "powerful_earthstorm";
case META_POWERFUL_SHADOWSPIRIT: return "powerful_shadowspirit";
case META_POWERFUL_PRIMAL: return "powerful_primal";
case META_RELENTLESS_EARTHSIEGE: return "relentless_earthsiege";
case META_RELENTLESS_EARTHSTORM: return "relentless_earthstorm";
case META_REVERBERATING_SHADOWSPIRIT: return "reverberating_shadowspirit";
case META_REVERBERATING_PRIMAL: return "reverberating_primal";
case META_REVITALIZING_SHADOWSPIRIT: return "revitalizing_shadowspirit";
case META_REVITALIZING_PRIMAL: return "revitalizing_primal";
case META_REVITALIZING_SKYFLARE: return "revitalizing_skyflare";
case META_SWIFT_SKYFIRE: return "swift_skyfire";
case META_SWIFT_SKYFLARE: return "swift_skyflare";
case META_SWIFT_STARFIRE: return "swift_starfire";
case META_SWIFT_STARFLARE: return "swift_starflare";
case META_THUNDERING_SKYFIRE: return "thundering_skyfire";
case META_THUNDERING_SKYFLARE: return "thundering_skyflare";
case META_TIRELESS_STARFLARE: return "tireless_starflare";
case META_TIRELESS_SKYFLARE: return "tireless_skyflare";
case META_TRENCHANT_EARTHSHATTER: return "trenchant_earthshatter";
case META_TRENCHANT_EARTHSIEGE: return "trenchant_earthsiege";
case META_SINISTER_PRIMAL: return "sinister_primal";
case META_CAPACITIVE_PRIMAL: return "capacitive_primal";
case META_INDOMITABLE_PRIMAL: return "indomitable_primal";
case META_COURAGEOUS_PRIMAL: return "courageous_primal";
default: return "unknown";
}
}
// parse_meta_gem_type ======================================================
meta_gem_e util::parse_meta_gem_type( const std::string& name )
{
return parse_enum<meta_gem_e, META_GEM_NONE, META_GEM_MAX, meta_gem_type_string>( name );
}
// result_type_string =======================================================
const char* util::result_type_string( result_e type )
{
switch ( type )
{
case RESULT_NONE: return "none";
case RESULT_MISS: return "miss";
case RESULT_DODGE: return "dodge";
case RESULT_PARRY: return "parry";
case RESULT_GLANCE: return "glance";
case RESULT_CRIT: return "crit";
case RESULT_HIT: return "hit";
case RESULT_MULTISTRIKE: return "multistrike";
case RESULT_MULTISTRIKE_CRIT: return "multistrike_crit";
default: return "unknown";
}
}
// block_result_type_string =================================================
const char* util::block_result_type_string( block_result_e type )
{
switch ( type )
{
case BLOCK_RESULT_UNBLOCKED: return "unblocked or avoided";
case BLOCK_RESULT_BLOCKED: return "blocked";
case BLOCK_RESULT_CRIT_BLOCKED: return "crit-blocked";
default: return "unknown";
}
}
// full_result_type_string ==================================================
const char* util::full_result_type_string( full_result_e fulltype )
{
switch ( fulltype )
{
case FULLTYPE_NONE: return "none";
case FULLTYPE_MISS: return "miss";
case FULLTYPE_DODGE: return "dodge";
case FULLTYPE_PARRY: return "parry";
case FULLTYPE_GLANCE_CRITBLOCK: return "glance (crit blocked)";
case FULLTYPE_GLANCE_BLOCK: return "glance (blocked)";
case FULLTYPE_GLANCE: return "glance";
case FULLTYPE_CRIT_CRITBLOCK: return "crit (crit blocked)";
case FULLTYPE_CRIT_BLOCK: return "crit (blocked)";
case FULLTYPE_CRIT: return "crit";
case FULLTYPE_HIT_CRITBLOCK: return "hit (crit blocked)";
case FULLTYPE_HIT_BLOCK: return "hit (blocked)";
case FULLTYPE_HIT: return "hit";
case FULLTYPE_MULTISTRIKE_CRITBLOCK: return "multistrike (crit blocked)";
case FULLTYPE_MULTISTRIKE_BLOCK: return "multistrike (blocked)";
case FULLTYPE_MULTISTRIKE: return "multistrike";
case FULLTYPE_MULTISTRIKE_CRIT_CRITBLOCK: return "multistrike_crit (crit blocked)";
case FULLTYPE_MULTISTRIKE_CRIT_BLOCK: return "multistrike_crit (blocked)";
case FULLTYPE_MULTISTRIKE_CRIT: return "multistrike_crit";
default: return "unknown";
}
}
// amount_type_string =======================================================
const char* util::amount_type_string( dmg_e type )
{
switch ( type )
{
case RESULT_TYPE_NONE: return "none";
case DMG_DIRECT: return "direct_damage";
case DMG_OVER_TIME: return "tick_damage";
case HEAL_DIRECT: return "direct_heal";
case HEAL_OVER_TIME: return "tick_heal";
case ABSORB: return "absorb";
default: return "unknown";
}
}
// parse_result_type ========================================================
result_e util::parse_result_type( const std::string& name )
{
return parse_enum<result_e, RESULT_NONE, RESULT_MAX, result_type_string>( name );
}
// resource_type_string =====================================================
const char* util::resource_type_string( resource_e resource_type )
{
switch ( resource_type )
{
case RESOURCE_NONE: return "none";
case RESOURCE_HEALTH: return "health";
case RESOURCE_MANA: return "mana";
case RESOURCE_RAGE: return "rage";
case RESOURCE_ECLIPSE: return "eclipse";
case RESOURCE_ENERGY: return "energy";
case RESOURCE_FOCUS: return "focus";
case RESOURCE_RUNIC_POWER: return "runic_power";
case RESOURCE_RUNE: return "rune";
case RESOURCE_RUNE_BLOOD: return "blood_rune";
case RESOURCE_RUNE_UNHOLY: return "unholy_rune";
case RESOURCE_RUNE_FROST: return "frost_rune";
case RESOURCE_SOUL_SHARD: return "soul_shard";
case RESOURCE_BURNING_EMBER: return "burning_ember";
case RESOURCE_DEMONIC_FURY: return "demonic_fury";
case RESOURCE_HOLY_POWER: return "holy_power";
case RESOURCE_CHI: return "chi";
case RESOURCE_SHADOW_ORB: return "shadow_orb";
case RESOURCE_COMBO_POINT: return "combo_points";
default: return "unknown";
}
}
// parse_resource_type ======================================================
resource_e util::parse_resource_type( const std::string& name )
{
return parse_enum<resource_e, RESOURCE_NONE, RESOURCE_MAX, resource_type_string>( name );
}
// school_type_component ====================================================
uint32_t util::school_type_component( school_e s_type, school_e c_type )
{
return( dbc::get_school_mask( s_type ) &
dbc::get_school_mask( c_type ) );
}
// school_type_string =======================================================
const char* util::school_type_string( school_e school )
{
switch ( school )
{
case SCHOOL_ARCANE: return "arcane";
case SCHOOL_CHAOS: return "chaos";
case SCHOOL_FIRE: return "fire";
case SCHOOL_FROST: return "frost";
case SCHOOL_FROSTFIRE: return "frostfire";
case SCHOOL_HOLY: return "holy";
case SCHOOL_NATURE: return "nature";
case SCHOOL_PHYSICAL: return "physical";
case SCHOOL_SHADOW: return "shadow";
case SCHOOL_HOLYSTRIKE: return "holystrike";
case SCHOOL_FLAMESTRIKE: return "flamestrike";
case SCHOOL_HOLYFIRE: return "holyfire";
case SCHOOL_STORMSTRIKE: return "stormstrike";
case SCHOOL_HOLYSTORM: return "holystorm";
case SCHOOL_FIRESTORM: return "firestorm";
case SCHOOL_FROSTSTRIKE: return "froststrike";
case SCHOOL_HOLYFROST: return "holyfrost";
case SCHOOL_FROSTSTORM: return "froststorm";
case SCHOOL_SHADOWSTRIKE: return "shadowstrike";
case SCHOOL_SHADOWLIGHT: return "shadowlight";
case SCHOOL_SHADOWFLAME: return "shadowflame";
case SCHOOL_SHADOWSTORM: return "shadowstorm";
case SCHOOL_SHADOWFROST: return "shadowfrost";
case SCHOOL_SPELLSTRIKE: return "spellstrike";
case SCHOOL_DIVINE: return "divine";
case SCHOOL_SPELLFIRE: return "spellfire";
case SCHOOL_SPELLSTORM: return "spellstorm";
case SCHOOL_SPELLFROST: return "spellfrost";
case SCHOOL_SPELLSHADOW: return "spellshadow";
case SCHOOL_ELEMENTAL: return "elemental";
case SCHOOL_CHROMATIC: return "chromatic";
case SCHOOL_MAGIC: return "magic";
case SCHOOL_DRAIN: return "drain";
case SCHOOL_NONE: return "none";
default: return "unknown";
}
}
// parse_school_type ========================================================
school_e util::parse_school_type( const std::string& name )
{
return parse_enum<school_e, SCHOOL_NONE, SCHOOL_MAX, school_type_string>( name );
}
resource_e util::translate_power_type( power_e pt )
{
switch ( pt )
{
case POWER_HEALTH: return RESOURCE_HEALTH;
case POWER_MANA: return RESOURCE_MANA;
case POWER_RAGE: return RESOURCE_RAGE;
case POWER_FOCUS: return RESOURCE_FOCUS;
case POWER_ENERGY: return RESOURCE_ENERGY;
case POWER_MONK_ENERGY: return RESOURCE_ENERGY;
case POWER_RUNIC_POWER: return RESOURCE_RUNIC_POWER;
case POWER_SOUL_SHARDS: return RESOURCE_SOUL_SHARD;
case POWER_BURNING_EMBER: return RESOURCE_BURNING_EMBER;
case POWER_DEMONIC_FURY: return RESOURCE_DEMONIC_FURY;
case POWER_HOLY_POWER: return RESOURCE_HOLY_POWER;
case POWER_CHI: return RESOURCE_CHI;
case POWER_SHADOW_ORB: return RESOURCE_SHADOW_ORB;
default: return RESOURCE_NONE;
}
}
// weapon_type_string =======================================================
const char* util::weapon_type_string( weapon_e weapon )
{
switch ( weapon )
{
case WEAPON_NONE: return "none";
case WEAPON_DAGGER: return "dagger";
case WEAPON_FIST: return "fist";
case WEAPON_BEAST: return "beast";
case WEAPON_SWORD: return "sword";
case WEAPON_MACE: return "mace";
case WEAPON_AXE: return "axe";
case WEAPON_BEAST_2H: return "beast2h";
case WEAPON_SWORD_2H: return "sword2h";
case WEAPON_MACE_2H: return "mace2h";
case WEAPON_AXE_2H: return "axe2h";
case WEAPON_STAFF: return "staff";
case WEAPON_POLEARM: return "polearm";
case WEAPON_BOW: return "bow";
case WEAPON_CROSSBOW: return "crossbow";
case WEAPON_GUN: return "gun";
case WEAPON_THROWN: return "thrown";
case WEAPON_WAND: return "wand";
default: return "unknown";
}
}
// weapon_subclass_string ===================================================
const char* util::weapon_subclass_string( int subclass )
{
switch ( subclass )
{
case ITEM_SUBCLASS_WEAPON_AXE:
case ITEM_SUBCLASS_WEAPON_AXE2: return "Axe";
case ITEM_SUBCLASS_WEAPON_BOW: return "Bow";
case ITEM_SUBCLASS_WEAPON_GUN: return "Gun";
case ITEM_SUBCLASS_WEAPON_MACE:
case ITEM_SUBCLASS_WEAPON_MACE2: return "Mace";
case ITEM_SUBCLASS_WEAPON_POLEARM: return "Polearm";
case ITEM_SUBCLASS_WEAPON_SWORD:
case ITEM_SUBCLASS_WEAPON_SWORD2: return "Sword";
case ITEM_SUBCLASS_WEAPON_STAFF: return "Staff";
case ITEM_SUBCLASS_WEAPON_FIST: return "Fist Weapon";
case ITEM_SUBCLASS_WEAPON_DAGGER: return "Dagger";
case ITEM_SUBCLASS_WEAPON_THROWN: return "Thrown";
case ITEM_SUBCLASS_WEAPON_CROSSBOW: return "Crossbow";
case ITEM_SUBCLASS_WEAPON_WAND: return "Wand";
default: return "Unknown";
}
}
// weapon_class_string ======================================================
const char* util::weapon_class_string( int it )
{
switch ( it )
{
case INVTYPE_WEAPON:
return "One Hand";
case INVTYPE_2HWEAPON:
return "Two-Hand";
case INVTYPE_WEAPONMAINHAND:
return "Main Hand";
case INVTYPE_WEAPONOFFHAND:
return "Off Hand";
case INVTYPE_RANGEDRIGHT:
return "Ranged";
default:
return nullptr;
}
}
// parse_weapon_type ========================================================
weapon_e util::parse_weapon_type( const std::string& name )
{
return parse_enum<weapon_e, WEAPON_NONE, WEAPON_MAX, weapon_type_string>( name );
}
// flask_type_string ========================================================
const char* util::flask_type_string( flask_e flask )
{
switch ( flask )
{
case FLASK_NONE: return "none";
// cataclysm
case FLASK_DRACONIC_MIND: return "draconic_mind";
case FLASK_FLOWING_WATER: return "flowing_water";
case FLASK_STEELSKIN: return "steelskin";
case FLASK_TITANIC_STRENGTH: return "titanic_strength";
case FLASK_WINDS: return "winds";
// mop
case FLASK_WARM_SUN: return "warm_sun";
case FLASK_FALLING_LEAVES: return "falling_leaves";
case FLASK_EARTH: return "earth";
case FLASK_WINTERS_BITE: return "winters_bite";
case FLASK_SPRING_BLOSSOMS: return "spring_blossoms";
case FLASK_CRYSTAL_OF_INSANITY: return "crystal_of_insanity";
// wod
case FLASK_DRAENIC_STRENGTH_FLASK: return "draenic_strength_flask";
case FLASK_DRAENIC_INTELLECT_FLASK: return "draenic_intellect_flask";
case FLASK_DRAENIC_AGILITY_FLASK: return "draenic_agility_flask";
case FLASK_DRAENIC_STAMINA_FLASK: return "draenic_stamina_flask";
case FLASK_GREATER_DRAENIC_STRENGTH_FLASK: return "greater_draenic_strength_flask";
case FLASK_GREATER_DRAENIC_INTELLECT_FLASK: return "greater_draenic_intellect_flask";
case FLASK_GREATER_DRAENIC_AGILITY_FLASK: return "greater_draenic_agility_flask";
case FLASK_GREATER_DRAENIC_STAMINA_FLASK: return "greater_draenic_stamina_flask";
// alchemist's
case FLASK_ALCHEMISTS: return "alchemists";
default: return "unknown";
}
}
// parse_flask_type =========================================================
flask_e util::parse_flask_type( const std::string& name )
{
return parse_enum<flask_e, FLASK_NONE, FLASK_MAX, flask_type_string>( name );
}
// food_type_string =========================================================
const char* util::food_type_string( food_e food )
{
switch ( food )
{
case FOOD_NONE: return "none";
case FOOD_BAKED_ROCKFISH: return "baked_rockfish";
case FOOD_BANQUET_OF_THE_BREW: return "banquet_of_the_brew";
case FOOD_BANQUET_OF_THE_GRILL: return "banquet_of_the_grill";
case FOOD_BANQUET_OF_THE_OVEN: return "banquet_of_the_oven";
case FOOD_BANQUET_OF_THE_POT: return "banquet_of_the_pot";
case FOOD_BANQUET_OF_THE_STEAMER: return "banquet_of_the_steamer";
case FOOD_BANQUET_OF_THE_WOK: return "banquet_of_the_wok";
case FOOD_BASILISK_LIVERDOG: return "basilisk_liverdog";
case FOOD_BEER_BASTED_CROCOLISK: return "beer_basted_crocolisk";
case FOOD_BLACK_PEPPER_RIBS_AND_SHRIMP: return "black_pepper_ribs_and_shrimp";
case FOOD_BLACKBELLY_SUSHI: return "blackbelly_sushi";
case FOOD_BLANCHED_NEEDLE_MUSHROOMS: return "blanched_needle_mushrooms";
case FOOD_BOILED_SILKWORM_PUPA: return "boiled_silkworm_pupa";
case FOOD_BRAISED_TURTLE: return "braised_turtle";
case FOOD_CHARBROILED_TIGER_STEAK: return "charbroiled_tiger_steak";
case FOOD_CHUN_TIAN_SPRING_ROLLS: return "chun_tian_spring_rolls";
case FOOD_CRAZY_SNAKE_NOODLES: return "crazy_snake_noodles";
case FOOD_CROCOLISK_AU_GRATIN: return "crocolisk_au_gratin";
case FOOD_DELICIOUS_SAGEFISH_TAIL: return "delicious_sagefish_tail";
case FOOD_DELUX_NOODLE_SOUP: return "delux_noodle_soup";
case FOOD_DRIED_NEEDLE_MUSHROOMS: return "dried_needle_mushrooms";
case FOOD_DRIED_PEACHES: return "dried_peaches";
case FOOD_ETERNAL_BLOSSOM_FISH: return "eternal_blossom_fish";
case FOOD_FIRE_SPIRIT_SALMON: return "fire_spirit_salmon";
case FOOD_FISH_FEAST: return "fish_feast";
case FOOD_FORTUNE_COOKIE: return "fortune_cookie";
case FOOD_GOLDEN_DRAGON_NOODLES: return "golden_dragon_noodles";
case FOOD_GREAT_BANQUET_OF_THE_BREW: return "great_banquet_of_the_brew";
case FOOD_GREAT_BANQUET_OF_THE_GRILL: return "great_banquet_of_the_grill";
case FOOD_GREAT_BANQUET_OF_THE_OVEN: return "great_banquet_of_the_oven";
case FOOD_GREAT_BANQUET_OF_THE_POT: return "great_banquet_of_the_pot";
case FOOD_GREAT_BANQUET_OF_THE_STEAMER: return "great_banquet_of_the_steamer";
case FOOD_GREAT_BANQUET_OF_THE_WOK: return "great_banquet_of_the_wok";
case FOOD_GREAT_PANDAREN_BANQUET: return "great_pandaren_banquet";
case FOOD_GREEN_CURRY_FISH: return "green_curry_fish";
case FOOD_GRILLED_DRAGON: return "grilled_dragon";
case FOOD_HARMONIOUS_RIVER_NOODLES: return "harmonious_river_noodles";
case FOOD_LAVASCALE_FILLET: return "lavascale_fillet";
case FOOD_LUCKY_MUSHROOM_NOODLES: return "lucky_mushroom_noodles";
case FOOD_MANGO_ICE: return "mango_ice";
case FOOD_MOGU_FISH_STEW: return "mogu_fish_stew";
case FOOD_MUSHROOM_SAUCE_MUDFISH: return "mushroom_sauce_mudfish";
case FOOD_NOODLE_SOUP: return "noodle_soup";
case FOOD_PANDAREN_BANQUET: return "pandaren_banquet";
case FOOD_PANDAREN_TREASURE_NOODLE_SOUP: return "pandaren_treasure_noodle_soup";
case FOOD_PEACH_PIE: return "peach_pie";
case FOOD_PEARL_MILK_TEA: return "pearl_milk_tea";
case FOOD_PERFECTLY_COOKED_INSTANT_NOODLES: return "perfectly_cooked_instant_noodles";
case FOOD_POUNDED_RICE_CAKE: return "pounded_rice_cake";
case FOOD_RED_BEAN_BUN: return "red_bean_bun";
case FOOD_RICE_PUDDING: return "rice_pudding";
case FOOD_ROASTED_BARLEY_TEA: return "roasted_barley_tea";
case FOOD_SAUTEED_CARROTS: return "sauteed_carrots";
case FOOD_SEA_MIST_RICE_NOODLES: return "sea_mist_rice_noodles";
case FOOD_SEAFOOD_MAGNIFIQUE_FEAST: return "seafood_magnifique_feast";
case FOOD_SEVERED_SAGEFISH_HEAD: return "severed_sagefish_head";
case FOOD_SHRIMP_DUMPLINGS: return "shrimp_dumplings";
case FOOD_SKEWERED_EEL: return "skewered_eel";
case FOOD_SKEWERED_PEANUT_CHICKEN: return "skewered_peanut_chicken";
case FOOD_SPICY_MUSHAN_NOODLES: return "spicy_mushan_noodles";
case FOOD_SPICY_SALMON: return "spicy_salmon";