/
CFBG-18.05.2014.patch
1423 lines (1328 loc) · 65.6 KB
/
CFBG-18.05.2014.patch
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
diff --git a/sql/Custom/world/ABFix.sql b/sql/Custom/world/ABFix.sql
new file mode 100644
index 0000000..c1857d9
--- /dev/null
+++ b/sql/Custom/world/ABFix.sql
@@ -0,0 +1,2 @@
+UPDATE `gameobject_template` SET `faction`=83 WHERE `entry` IN (180058,180059);
+UPDATE `gameobject_template` SET `faction`=84 WHERE `entry` IN (180060,180061);
diff --git a/sql/Custom/world/AVFix.sql b/sql/Custom/world/AVFix.sql
new file mode 100644
index 0000000..ebcda32
--- /dev/null
+++ b/sql/Custom/world/AVFix.sql
@@ -0,0 +1,2 @@
+UPDATE creature_template SET faction_A = 1, faction_H = 1 WHERE entry IN (4255,4257,5134,5135,5139,11948,11949,11997,12050,12096,12127,13086,13096,13138,13216,13257,13296,13298,13299,13317,13318,13319,13320,13326,13327,13331,13422,13437,13438,13439,13442,13443,13447,13546,13576,13577,13598,13617,13797,14187,14188,14284,14762,14763,14765,14766,14768,14769,12047,13396,13358,13080,13078);
+UPDATE creature_template SET faction_A = 2, faction_H = 2 WHERE entry IN (2225,3343,3625,10364,10367,11946,11947,11998,12051,12052,12053,12097,12121,12122,13088,13089,13097,13137,13140,13143,13144,13145,13146,13147,13152,13153,13154,13176,13179,13180,13181,13218,13236,13284,13316,13359,13377,13397,13425,13428,13441,13448,13536,13539,13545,13597,13616,13618,13798,14185,14186,14282,14285,14772,14773,14774,14775,14776,14777,13332,13099,13079);
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index c4aa3ef..7c6503d 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -306,7 +306,7 @@ inline void Battleground::_CheckSafePositions(uint32 diff)
if (Player* player = ObjectAccessor::FindPlayer(itr->first))
{
player->GetPosition(&pos);
- GetTeamStartLoc(player->GetBGTeam(), x, y, z, o);
+ GetTeamStartLoc(player->GetTeam(), x, y, z, o);
if (pos.GetExactDistSq(x, y, z) > maxDist)
{
TC_LOG_DEBUG("bg.battleground", "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName().c_str(), GetMapId());
@@ -512,7 +512,7 @@ inline void Battleground::_ProcessJoin(uint32 diff)
WorldPacket status;
BattlegroundQueueTypeId bgQueueTypeId = sBattlegroundMgr->BGQueueTypeId(m_TypeID, GetArenaType());
uint32 queueSlot = player->GetBattlegroundQueueIndex(bgQueueTypeId);
- sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), player->GetBGTeam());
+ sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, queueSlot, STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), player->GetTeam());
player->SendDirectMessage(&status);
player->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
@@ -693,12 +693,32 @@ void Battleground::RewardHonorToTeam(uint32 Honor, uint32 TeamID)
UpdatePlayerScore(player, SCORE_BONUS_HONOR, Honor);
}
-void Battleground::RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID)
+void Battleground::RewardReputationToTeam(uint32 a_faction_id, uint32 h_faction_id, uint32 Reputation, uint32 teamID)
{
- if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction_id))
- for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
- if (Player* player = _GetPlayerForTeam(TeamID, itr, "RewardReputationToTeam"))
- player->GetReputationMgr().ModifyReputation(factionEntry, Reputation);
+ FactionEntry const* a_factionEntry = sFactionStore.LookupEntry(a_faction_id);
+ FactionEntry const* h_factionEntry = sFactionStore.LookupEntry(h_faction_id);
+
+ if (!a_factionEntry || !h_factionEntry)
+ return;
+
+ for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
+ {
+ if (itr->second.OfflineRemoveTime)
+ continue;
+
+ Player* plr = ObjectAccessor::FindPlayer(itr->first);
+
+ if (!plr)
+ {
+ TC_LOG_ERROR("bg.battleground", "BattleGround:RewardReputationToTeam: %u not found!");
+ continue;
+ }
+
+ uint32 team = plr->GetTeam();
+
+ if (team == teamID)
+ plr->GetReputationMgr().ModifyReputation(plr->GetOTeam() == ALLIANCE ? a_factionEntry : h_factionEntry, Reputation);
+ }
}
void Battleground::UpdateWorldState(uint32 Field, uint32 Value)
@@ -907,7 +927,7 @@ void Battleground::EndBattleground(uint32 winner)
player->SendDirectMessage(&pvpLogData);
WorldPacket data;
- sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType(), player->GetBGTeam());
+ sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType(), player->GetTeam());
player->SendDirectMessage(&data);
player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, 1);
}
@@ -1056,6 +1076,7 @@ void Battleground::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPac
if (player)
{
+ player->FitPlayerInTeam(false, this);
// Do next only if found in battleground
player->SetBattlegroundId(0, BATTLEGROUND_TYPE_NONE); // We're not in BG.
// reset destination bg team
@@ -1122,7 +1143,7 @@ void Battleground::AddPlayer(Player* player)
// score struct must be created in inherited class
uint64 guid = player->GetGUID();
- uint32 team = player->GetBGTeam();
+ uint32 team = player->GetTeam();
BattlegroundPlayer bp;
bp.OfflineRemoveTime = 0;
@@ -1188,6 +1209,8 @@ void Battleground::AddPlayer(Player* player)
// setup BG group membership
PlayerAddedToBGCheckIfBGIsRunning(player);
AddOrSetPlayerToCorrectBgGroup(player, team);
+
+ player->FitPlayerInTeam(true, this);
}
// this method adds player to his team's bg group, or sets his correct group if player is already in bg group
@@ -1257,8 +1280,8 @@ void Battleground::EventPlayerLoggedOut(Player* player)
// 1 player is logging out, if it is the last, then end arena!
if (isArena())
- if (GetAlivePlayersCountByTeam(player->GetBGTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetBGTeam())))
- EndBattleground(GetOtherTeam(player->GetBGTeam()));
+ if (GetAlivePlayersCountByTeam(player->GetTeam()) <= 1 && GetPlayersCountByTeam(GetOtherTeam(player->GetTeam())))
+ EndBattleground(GetOtherTeam(player->GetTeam()));
}
}
@@ -1858,7 +1881,7 @@ void Battleground::PlayerAddedToBGCheckIfBGIsRunning(Player* player)
sBattlegroundMgr->BuildPvpLogDataPacket(&data, this);
player->SendDirectMessage(&data);
- sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType(), player->GetBGTeam());
+ sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetBattlegroundQueueIndex(bgQueueTypeId), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType(), player->GetTeam());
player->SendDirectMessage(&data);
}
diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h
index 5e2aa4b..ee923cd 100644
--- a/src/server/game/Battlegrounds/Battleground.h
+++ b/src/server/game/Battlegrounds/Battleground.h
@@ -422,7 +422,7 @@ class Battleground
void CastSpellOnTeam(uint32 SpellID, uint32 TeamID);
void RemoveAuraOnTeam(uint32 SpellID, uint32 TeamID);
void RewardHonorToTeam(uint32 Honor, uint32 TeamID);
- void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID);
+ void RewardReputationToTeam(uint32 a_faction_id, uint32 h_faction_id, uint32 Reputation, uint32 teamID);
void UpdateWorldState(uint32 Field, uint32 Value);
void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player* player);
void EndBattleground(uint32 winner);
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index ab69c95..02a6e9d 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -284,7 +284,7 @@ void BattlegroundMgr::BuildPvpLogDataPacket(WorldPacket* data, Battleground* bg)
Player* player = ObjectAccessor::FindPlayer(itr2->first);
uint32 team = bg->GetPlayerTeam(itr2->first);
if (!team && player)
- team = player->GetBGTeam();
+ team = player->GetTeam();
*data << uint8(team == ALLIANCE ? 1 : 0); // green or yellow
}
*data << uint32(score->DamageDone); // damage done
@@ -894,7 +894,7 @@ void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, Batt
{
float x, y, z, O;
uint32 mapid = bg->GetMapId();
- uint32 team = player->GetBGTeam();
+ uint32 team = player->GetTeam();
if (team == 0)
team = player->GetTeam();
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
index 547d6e9..0418e67 100644
--- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
@@ -154,6 +154,10 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
index += BG_TEAMS_COUNT;
if (ginfo->Team == HORDE)
index++;
+
+ if (sWorld->getBoolConfig(BATTLEGROUND_CROSSFACTION_ENABLED) && ArenaType == 0)
+ index = BG_QUEUE_MIXED;
+
TC_LOG_DEBUG("bg.battleground", "Adding Group to BattlegroundQueue bgTypeId : %u, bracket_id : %u, index : %u", BgTypeId, bracketId, index);
uint32 lastOnlineTime = getMSTime();
@@ -199,31 +203,56 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
{
if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(ginfo->BgTypeId))
{
- char const* bgName = bg->GetName();
- uint32 MinPlayers = bg->GetMinPlayersPerTeam();
- uint32 qHorde = 0;
- uint32 qAlliance = 0;
- uint32 q_min_level = bracketEntry->minLevel;
- uint32 q_max_level = bracketEntry->maxLevel;
- GroupsQueueType::const_iterator itr;
- for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr)
- if (!(*itr)->IsInvitedToBGInstanceGUID)
- qAlliance += (*itr)->Players.size();
- for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
- if (!(*itr)->IsInvitedToBGInstanceGUID)
- qHorde += (*itr)->Players.size();
-
- // Show queue status to player only (when joining queue)
- if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
+ if (sWorld->getBoolConfig(BATTLEGROUND_CROSSFACTION_ENABLED))
{
- ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level,
- qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
+ char const* bgName = bg->GetName();
+ uint32 MinPlayers = bg->GetMinPlayersPerTeam()*2;
+ uint32 qPlayers = 0;
+ uint32 q_min_level = bracketEntry->minLevel;
+ uint32 q_max_level = bracketEntry->maxLevel;
+ for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracketId][BG_QUEUE_MIXED].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_MIXED].end(); ++itr)
+ if (!(*itr)->IsInvitedToBGInstanceGUID)
+ qPlayers += (*itr)->Players.size();
+
+ if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
+ {
+ ChatHandler(leader->GetSession()).PSendSysMessage("Queue status for %s (Lvl: %u to %u) Queued players: %u (Need at least %u more)", bgName, q_min_level, q_max_level, qPlayers, MinPlayers - qPlayers);
+ }
+ else
+ {
+ std::ostringstream ss;
+ ss << "|cffff0000[BG Queue Announcer]:|r " << bgName << " -- [" << q_min_level << "-" << q_max_level << "] " << qPlayers << "/" << MinPlayers;
+ sWorld->SendGlobalText(ss.str().c_str(), NULL);
+ }
}
- // System message
else
{
- sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level,
- qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
+ char const* bgName = bg->GetName();
+ uint32 MinPlayers = bg->GetMinPlayersPerTeam();
+ uint32 qHorde = 0;
+ uint32 qAlliance = 0;
+ uint32 q_min_level = bracketEntry->minLevel;
+ uint32 q_max_level = bracketEntry->maxLevel;
+ GroupsQueueType::const_iterator itr;
+ for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_ALLIANCE].end(); ++itr)
+ if (!(*itr)->IsInvitedToBGInstanceGUID)
+ qAlliance += (*itr)->Players.size();
+ for (itr = m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].begin(); itr != m_QueuedGroups[bracketId][BG_QUEUE_NORMAL_HORDE].end(); ++itr)
+ if (!(*itr)->IsInvitedToBGInstanceGUID)
+ qHorde += (*itr)->Players.size();
+
+ // Show queue status to player only (when joining queue)
+ if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
+ {
+ ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level,
+ qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
+ }
+ // System message
+ else
+ {
+ sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level,
+ qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
+ }
}
}
}
@@ -310,7 +339,7 @@ void BattlegroundQueue::RemovePlayer(uint64 guid, bool decreaseInvitedCount)
{
//we must check premade and normal team's queue - because when players from premade are joining bg,
//they leave groupinfo so we can't use its players size to find out index
- for (uint32 j = index; j < BG_QUEUE_GROUP_TYPES_COUNT; j += BG_TEAMS_COUNT)
+ for (uint8 j = 0; j < BG_QUEUE_GROUP_TYPES_COUNT; ++j)
{
GroupsQueueType::iterator k = m_QueuedGroups[bracket_id_tmp][j].begin();
for (; k != m_QueuedGroups[bracket_id_tmp][j].end(); ++k)
@@ -499,6 +528,10 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId
int32 hordeFree = bg->GetFreeSlotsForTeam(HORDE);
int32 aliFree = bg->GetFreeSlotsForTeam(ALLIANCE);
+ if (!bg->isArena())
+ if (FillXPlayersToBG(bracket_id, bg, false))
+ return;
+
//iterator for iterating through bg queue
GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].begin();
//count of groups in queue - used to stop cycles
@@ -747,7 +780,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
if (m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_ALLIANCE].empty() &&
m_QueuedGroups[bracket_id][BG_QUEUE_PREMADE_HORDE].empty() &&
m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].empty() &&
- m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty())
+ m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].empty() &&
+ m_QueuedGroups[bracket_id][BG_QUEUE_MIXED].empty())
return;
// battleground with free slot for player should be always in the beggining of the queue
@@ -838,7 +872,8 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 /*diff*/, BattlegroundTyp
{
// if there are enough players in pools, start new battleground or non rated arena
if (CheckNormalMatch(bg_template, bracket_id, MinPlayersPerTeam, MaxPlayersPerTeam)
- || (bg_template->isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam)))
+ || (bg_template->isArena() && CheckSkirmishForSameFaction(bracket_id, MinPlayersPerTeam))
+ || CheckCrossFactionMatch(bracket_id, bg_template))
{
// we successfully created a pool
Battleground* bg2 = sBattlegroundMgr->CreateNewBattleground(bgTypeId, bracketEntry, arenaType, false);
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h
index af283cb..9f07d35 100644
--- a/src/server/game/Battlegrounds/BattlegroundQueue.h
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.h
@@ -42,6 +42,7 @@ struct GroupQueueInfo // stores informatio
{
std::map<uint64, PlayerQueueInfo*> Players; // player queue info map
uint32 Team; // Player team (ALLIANCE/HORDE)
+ uint32 OTeam; // Player team (ALLIANCE/HORDE)
BattlegroundTypeId BgTypeId; // battleground type id
bool IsRated; // rated
uint8 ArenaType; // 2v2, 3v3, 5v5 or 0 when BG
@@ -60,9 +61,10 @@ enum BattlegroundQueueGroupTypes
BG_QUEUE_PREMADE_ALLIANCE = 0,
BG_QUEUE_PREMADE_HORDE = 1,
BG_QUEUE_NORMAL_ALLIANCE = 2,
- BG_QUEUE_NORMAL_HORDE = 3
+ BG_QUEUE_NORMAL_HORDE = 3,
+ BG_QUEUE_MIXED = 4
};
-#define BG_QUEUE_GROUP_TYPES_COUNT 4
+#define BG_QUEUE_GROUP_TYPES_COUNT 5
class Battleground;
class BattlegroundQueue
@@ -74,6 +76,11 @@ class BattlegroundQueue
void BattlegroundQueueUpdate(uint32 diff, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id, uint8 arenaType = 0, bool isRated = false, uint32 minRating = 0);
void UpdateEvents(uint32 diff);
+ bool FillXPlayersToBG(BattlegroundBracketId bracket_id, Battleground* bg, bool start = false);
+ typedef std::multimap<int32, GroupQueueInfo*> QueuedGroupMap;
+ int32 PreAddPlayers(QueuedGroupMap m_PreGroupMap, int32 MaxAdd, uint32 MaxInTeam);
+ bool CheckCrossFactionMatch(BattlegroundBracketId bracket_id, Battleground* bg);
+
void FillPlayersToBG(Battleground* bg, BattlegroundBracketId bracket_id);
bool CheckPremadeMatch(BattlegroundBracketId bracket_id, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam);
bool CheckNormalMatch(Battleground* bg_template, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
index c05bd98..9d669dc 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
@@ -142,7 +142,7 @@ void BattlegroundAB::PostUpdateImpl(uint32 diff)
if (m_ReputationScoreTics[team] >= m_ReputationTics)
{
- (team == TEAM_ALLIANCE) ? RewardReputationToTeam(509, 10, ALLIANCE) : RewardReputationToTeam(510, 10, HORDE);
+ RewardReputationToTeam(509, 510, 10, team == ALLIANCE ? ALLIANCE : HORDE);
m_ReputationScoreTics[team] -= m_ReputationTics;
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
index 610e0bc..3405f2b 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp
@@ -94,7 +94,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
if (entry == BG_AV_CreatureInfo[AV_NPC_A_BOSS][0])
{
CastSpellOnTeam(23658, HORDE); //this is a spell which finishes a quest where a player has to kill the boss
- RewardReputationToTeam(729, BG_AV_REP_BOSS, HORDE);
+ RewardReputationToTeam(729, 730, BG_AV_REP_BOSS, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_BOSS), HORDE);
EndBattleground(HORDE);
DelCreature(AV_CPLACE_TRIGGER17);
@@ -102,7 +102,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
else if (entry == BG_AV_CreatureInfo[AV_NPC_H_BOSS][0])
{
CastSpellOnTeam(23658, ALLIANCE); //this is a spell which finishes a quest where a player has to kill the boss
- RewardReputationToTeam(730, BG_AV_REP_BOSS, ALLIANCE);
+ RewardReputationToTeam(729, 730, BG_AV_REP_BOSS, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_BOSS), ALLIANCE);
EndBattleground(ALLIANCE);
DelCreature(AV_CPLACE_TRIGGER19);
@@ -115,7 +115,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
return;
}
m_CaptainAlive[0]=false;
- RewardReputationToTeam(729, BG_AV_REP_CAPTAIN, HORDE);
+ RewardReputationToTeam(729, 730, BG_AV_REP_CAPTAIN, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_CAPTAIN), HORDE);
UpdateScore(ALLIANCE, (-1)*BG_AV_RES_CAPTAIN);
//spawn destroyed aura
@@ -134,7 +134,7 @@ void BattlegroundAV::HandleKillUnit(Creature* unit, Player* killer)
return;
}
m_CaptainAlive[1]=false;
- RewardReputationToTeam(730, BG_AV_REP_CAPTAIN, ALLIANCE);
+ RewardReputationToTeam(729, 730, BG_AV_REP_CAPTAIN, killer->GetTeam() == ALLIANCE ? ALLIANCE : HORDE);
RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_CAPTAIN), ALLIANCE);
UpdateScore(HORDE, (-1)*BG_AV_RES_CAPTAIN);
//spawn destroyed aura
@@ -156,6 +156,7 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player)
if (GetStatus() != STATUS_IN_PROGRESS)
return;//maybe we should log this, cause this must be a cheater or a big bug
uint8 team = GetTeamIndexByTeamId(player->GetTeam());
+ uint8 oteam = GetTeamIndexByTeamId(GetOtherTeam(player->GetTeam()));
/// @todo add reputation, events (including quest not available anymore, next quest availabe, go/npc de/spawning)and maybe honor
TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed", questid);
switch (questid)
@@ -180,21 +181,21 @@ void BattlegroundAV::HandleQuestComplete(uint32 questid, Player* player)
case AV_QUEST_A_COMMANDER1:
case AV_QUEST_H_COMMANDER1:
m_Team_QuestStatus[team][1]++;
- RewardReputationToTeam(team, 1, player->GetTeam());
+ RewardReputationToTeam(team, oteam, 1, player->GetTeam());
if (m_Team_QuestStatus[team][1] == 30)
TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed (need to implement some events here", questid);
break;
case AV_QUEST_A_COMMANDER2:
case AV_QUEST_H_COMMANDER2:
m_Team_QuestStatus[team][2]++;
- RewardReputationToTeam(team, 1, player->GetTeam());
+ RewardReputationToTeam(team, oteam, 1, player->GetTeam());
if (m_Team_QuestStatus[team][2] == 60)
TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed (need to implement some events here", questid);
break;
case AV_QUEST_A_COMMANDER3:
case AV_QUEST_H_COMMANDER3:
m_Team_QuestStatus[team][3]++;
- RewardReputationToTeam(team, 1, player->GetTeam());
+ RewardReputationToTeam(team, oteam, 1, player->GetTeam());
if (m_Team_QuestStatus[team][3] == 120)
TC_LOG_DEBUG("bg.battleground", "BG_AV Quest %i completed (need to implement some events here", questid);
break;
@@ -506,7 +507,7 @@ void BattlegroundAV::EndBattleground(uint32 winner)
rep[i] += BG_AV_REP_SURVIVING_CAPTAIN;
}
if (rep[i] != 0)
- RewardReputationToTeam(i == 0 ? 730 : 729, rep[i], i == 0 ? ALLIANCE : HORDE);
+ RewardReputationToTeam(729, 730, 10, i == ALLIANCE ? ALLIANCE : HORDE);
if (kills[i] != 0)
RewardHonorToTeam(GetBonusHonor(kills[i]), i == 0 ? ALLIANCE : HORDE);
}
@@ -625,7 +626,7 @@ void BattlegroundAV::EventPlayerDestroyedPoint(BG_AV_Nodes node)
SpawnBGObject(BG_AV_OBJECT_BURN_DUNBALDAR_SOUTH + i + (tmp * 10), RESPAWN_IMMEDIATELY);
UpdateScore((owner == ALLIANCE) ? HORDE : ALLIANCE, -1 * BG_AV_RES_TOWER);
- RewardReputationToTeam(owner == ALLIANCE ? 730 : 729, BG_AV_REP_TOWER, owner);
+ RewardReputationToTeam(729, 730, BG_AV_REP_TOWER, owner);
RewardHonorToTeam(GetBonusHonor(BG_AV_KILL_TOWER), owner);
SpawnBGObject(BG_AV_OBJECT_TAURA_A_DUNBALDAR_SOUTH+GetTeamIndexByTeamId(owner)+(2*tmp), RESPAWN_ONE_DAY);
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
index 92d56bb..3f0a76d 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp
@@ -312,7 +312,6 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* player)
if (GetTeamScore(TEAM_ALLIANCE) < BG_WS_MAX_TEAM_SCORE)
AddPoint(ALLIANCE, 1);
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_ALLIANCE);
- RewardReputationToTeam(890, m_ReputationCapture, ALLIANCE);
}
else
{
@@ -331,8 +330,8 @@ void BattlegroundWS::EventPlayerCapturedFlag(Player* player)
if (GetTeamScore(TEAM_HORDE) < BG_WS_MAX_TEAM_SCORE)
AddPoint(HORDE, 1);
PlaySoundToAll(BG_WS_SOUND_FLAG_CAPTURED_HORDE);
- RewardReputationToTeam(889, m_ReputationCapture, HORDE);
}
+ RewardReputationToTeam(890, 889, m_ReputationCapture, player->GetTeam());
//for flag capture is reward 2 honorable kills
RewardHonorToTeam(GetBonusHonorFromKill(2), player->GetTeam());
diff --git a/src/server/game/Cfbg/Cfbg.cpp b/src/server/game/Cfbg/Cfbg.cpp
new file mode 100644
index 0000000..c46a5da
--- /dev/null
+++ b/src/server/game/Cfbg/Cfbg.cpp
@@ -0,0 +1,346 @@
+#include "Cfbg.h"
+#include "Battleground.h"
+#include "BattlegroundMgr.h"
+#include "Player.h"
+#include "Chat.h"
+#include "BattlegroundQueue.h"
+
+/*####################################################################################
+###############################CROSSFACTION BATTLEGROUNDS#############################
+####################################################################################*/
+
+uint8 Unit::getRace(bool forceoriginal) const
+{
+ if (GetTypeId() == TYPEID_PLAYER)
+ {
+ Player* pPlayer = ((Player*)this);
+
+ if (forceoriginal)
+ return pPlayer->getORace();
+
+ if (pPlayer->InArena())
+ return GetByteValue(UNIT_FIELD_BYTES_0, 0);
+
+ if (!pPlayer->IsPlayingNative())
+ return pPlayer->getFRace();
+ }
+
+ return GetByteValue(UNIT_FIELD_BYTES_0, 0);
+}
+
+bool Player::SendRealNameQuery()
+{
+ if (IsPlayingNative())
+ return false;
+
+ WorldPacket data(SMSG_NAME_QUERY_RESPONSE, (8 + 1 + 1 + 1 + 1 + 1 + 10));
+ data.appendPackGUID(GetGUID()); // player guid
+ data << uint8(0); // added in 3.1; if > 1, then end of packet
+ data << GetName(); // played name
+ data << uint8(0); // realm name for cross realm BG usage
+ data << uint8(getORace());
+ data << uint8(getGender());
+ data << uint8(getClass());
+ data << uint8(0); // is not declined
+ GetSession()->SendPacket(&data);
+
+ return true;
+}
+
+void Player::SetFakeRaceAndMorph()
+{
+ if (getClass() == CLASS_DRUID)
+ {
+ if (GetOTeam() == ALLIANCE)
+ {
+ m_FakeMorph = getGender() == GENDER_MALE ? FAKE_M_TAUREN : FAKE_F_TAUREN;
+ m_FakeRace = RACE_TAUREN;
+ }
+ else if (getGender() == GENDER_MALE) // HORDE PLAYER, ONLY HAVE MALE NELF ID
+ {
+ m_FakeMorph = FAKE_M_NELF;
+ m_FakeRace = RACE_NIGHTELF;
+ }
+ else
+ m_FakeRace = GetOTeam() == ALLIANCE ? RACE_BLOODELF : RACE_HUMAN;
+ }
+ else if (getClass() == CLASS_SHAMAN && GetOTeam() == HORDE && getGender() == GENDER_FEMALE)
+ {
+ m_FakeMorph = FAKE_F_DRANAEI; // Female Draenei
+ m_FakeRace = RACE_DRAENEI;
+ }
+ else
+ {
+ m_FakeRace = GetOTeam() == ALLIANCE ? RACE_BLOODELF : RACE_HUMAN;
+
+ if (GetOTeam() == HORDE)
+ {
+ if (getGender() == GENDER_MALE)
+ m_FakeMorph = 19723;
+ else
+ m_FakeMorph = 19724;
+ }
+ else
+ {
+ if (getGender() == GENDER_MALE)
+ m_FakeMorph = 20578;
+ else
+ m_FakeMorph = 20579;
+ }
+ }
+}
+
+bool Player::SendBattleGroundChat(uint32 msgtype, std::string message)
+{
+ // Select distance to broadcast to.
+ float distance = msgtype == CHAT_MSG_SAY ? sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY) : sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL);
+
+ if (Battleground* pBattleGround = GetBattleground())
+ {
+ if (pBattleGround->isArena()) // Only fake chat in BG's. CFBG should not interfere with arenas.
+ return false;
+
+ for (Battleground::BattlegroundPlayerMap::const_iterator itr = pBattleGround->GetPlayers().begin(); itr != pBattleGround->GetPlayers().end(); ++itr)
+ {
+ if (Player* pPlayer = ObjectAccessor::FindPlayer(itr->first))
+ {
+ if (GetDistance2d(pPlayer->GetPositionX(), pPlayer->GetPositionY()) <= distance)
+ {
+ WorldPacket data(SMSG_MESSAGECHAT, 200);
+
+ if (GetTeam() == pPlayer->GetTeam())
+ {
+ WorldPacket data;
+ ChatHandler::BuildChatPacket(data, ChatMsg(msgtype), LANG_UNIVERSAL, pPlayer, NULL, message);
+ pPlayer->GetSession()->SendPacket(&data);
+ }
+ else if (msgtype != CHAT_MSG_EMOTE)
+ {
+ WorldPacket data;
+ ChatHandler::BuildChatPacket(data, ChatMsg(msgtype), pPlayer->GetTeam() == ALLIANCE ? LANG_ORCISH : LANG_COMMON, pPlayer, NULL, message);
+ pPlayer->GetSession()->SendPacket(&data);
+ }
+ pPlayer->GetSession()->SendPacket(&data);
+ }
+ }
+ }
+ return true;
+ }
+ else
+ return false;
+}
+
+void Player::MorphFit(bool value)
+{
+ if (!IsPlayingNative() && value)
+ {
+ SetDisplayId(GetFakeMorph());
+ SetNativeDisplayId(GetFakeMorph());
+ }
+ else
+ InitDisplayIds();
+}
+
+void Player::FitPlayerInTeam(bool action, Battleground* pBattleGround)
+{
+ if (!pBattleGround)
+ pBattleGround = GetBattleground();
+
+ if ((!pBattleGround || pBattleGround->isArena()) && action)
+ return;
+
+ if(!IsPlayingNative() && action)
+ setFactionForRace(getRace());
+ else
+ setFactionForRace(getORace());
+
+ if (action)
+ SetForgetBGPlayers(true);
+ else
+ SetForgetInListPlayers(true);
+
+ MorphFit(action);
+
+ if (pBattleGround && action)
+ SendChatMessage("%sYou are playing for the %s%s in this %s", MSG_COLOR_WHITE, GetTeam() == ALLIANCE ? MSG_COLOR_DARKBLUE"alliance" : MSG_COLOR_RED"horde", MSG_COLOR_WHITE, pBattleGround->GetName());
+}
+
+void Player::DoForgetPlayersInList()
+{
+ // m_FakePlayers is filled from a vector within the battleground
+ // they were in previously so all players that have been in that BG will be invalidated.
+ for (FakePlayers::const_iterator itr = m_FakePlayers.begin(); itr != m_FakePlayers.end(); ++itr)
+ {
+ WorldPacket data(SMSG_INVALIDATE_PLAYER, 8);
+ data << *itr;
+ GetSession()->SendPacket(&data);
+ if (Player* pPlayer = ObjectAccessor::FindPlayer(*itr))
+ GetSession()->SendNameQueryOpcode(pPlayer->GetGUID());
+ }
+ m_FakePlayers.clear();
+}
+
+void Player::DoForgetPlayersInBG(Battleground* pBattleGround)
+{
+ for (Battleground::BattlegroundPlayerMap::const_iterator itr = pBattleGround->GetPlayers().begin(); itr != pBattleGround->GetPlayers().end(); ++itr)
+ {
+ // Here we invalidate players in the bg to the added player
+ WorldPacket data1(SMSG_INVALIDATE_PLAYER, 8);
+ data1 << itr->first;
+ GetSession()->SendPacket(&data1);
+
+ if (Player* pPlayer = ObjectAccessor::FindPlayer(itr->first))
+ {
+ GetSession()->SendNameQueryOpcode(pPlayer->GetGUID()); // Send namequery answer instantly if player is available
+ // Here we invalidate the player added to players in the bg
+ WorldPacket data2(SMSG_INVALIDATE_PLAYER, 8);
+ data2 << GetGUID();
+ pPlayer->GetSession()->SendPacket(&data2);
+ pPlayer->GetSession()->SendNameQueryOpcode(GetGUID());
+ }
+ }
+}
+
+bool BattlegroundQueue::CheckCrossFactionMatch(BattlegroundBracketId bracket_id, Battleground* bg)
+{
+ if (!sWorld->getBoolConfig(BATTLEGROUND_CROSSFACTION_ENABLED) || bg->isArena())
+ return false; // Only do this if crossbg's are enabled.
+
+ // Here we will add all players to selectionpool, later we check if there are enough and launch a bg.
+ FillXPlayersToBG(bracket_id, bg, true);
+
+ if (sBattlegroundMgr->isTesting() && (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_HORDE].GetPlayerCount()))
+ return true;
+
+ uint8 MPT = bg->GetMinPlayersPerTeam();
+ if (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() < MPT || m_SelectionPools[TEAM_HORDE].GetPlayerCount() < MPT)
+ return false;
+
+ return true;
+}
+
+// This function will invite players in the least populated faction, which makes battleground queues much faster.
+// This function will return true if cross faction battlegrounds are enabled, otherwise return false,
+// which is useful in FillPlayersToBG. Because then we can interrupt the regular invitation if cross faction bg's are enabled.
+bool BattlegroundQueue::FillXPlayersToBG(BattlegroundBracketId bracket_id, Battleground* bg, bool start)
+{
+ uint8 queuedPeople = 0;
+ for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_MIXED].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_MIXED].end(); ++itr)
+ if (!(*itr)->IsInvitedToBGInstanceGUID)
+ queuedPeople += (*itr)->Players.size();
+
+ if (sWorld->getBoolConfig(BATTLEGROUND_CROSSFACTION_ENABLED) && (sBattlegroundMgr->isTesting() || queuedPeople >= bg->GetMinPlayersPerTeam()*2 || !start))
+ {
+ int32 aliFree = start ? bg->GetMaxPlayersPerTeam() : bg->GetFreeSlotsForTeam(ALLIANCE);
+ int32 hordeFree = start ? bg->GetMaxPlayersPerTeam() : bg->GetFreeSlotsForTeam(HORDE);
+ // Empty selection pools. They will be refilled from queued groups.
+ m_SelectionPools[TEAM_ALLIANCE].Init();
+ m_SelectionPools[TEAM_HORDE].Init();
+ int32 valiFree = aliFree;
+ int32 vhordeFree = hordeFree;
+ int32 diff = 0;
+
+
+ // Add teams to their own factions as far as possible.
+ if (start)
+ {
+ QueuedGroupMap m_PreGroupMap_a, m_PreGroupMap_h;
+ int32 m_SmallestOfTeams = 0;
+ int32 queuedAlliance = 0;
+ int32 queuedHorde = 0;
+
+ for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_MIXED].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_MIXED].end(); ++itr)
+ {
+ if ((*itr)->IsInvitedToBGInstanceGUID)
+ continue;
+
+ bool alliance = (*itr)->OTeam == ALLIANCE;
+
+ if (alliance)
+ {
+ m_PreGroupMap_a.insert(std::make_pair((*itr)->Players.size(), *itr));
+ queuedAlliance += (*itr)->Players.size();
+ }
+ else
+ {
+ m_PreGroupMap_h.insert(std::make_pair((*itr)->Players.size(), *itr));
+ queuedHorde += (*itr)->Players.size();
+ }
+ }
+
+ m_SmallestOfTeams = std::min(std::min(aliFree, queuedAlliance), std::min(hordeFree, queuedHorde));
+
+ valiFree -= PreAddPlayers(m_PreGroupMap_a, m_SmallestOfTeams, aliFree);
+ vhordeFree -= PreAddPlayers(m_PreGroupMap_h, m_SmallestOfTeams, hordeFree);
+ }
+
+ QueuedGroupMap m_QueuedGroupMap;
+
+ for (GroupsQueueType::const_iterator itr = m_QueuedGroups[bracket_id][BG_QUEUE_MIXED].begin(); itr != m_QueuedGroups[bracket_id][BG_QUEUE_MIXED].end(); ++itr)
+ m_QueuedGroupMap.insert(std::make_pair((*itr)->Players.size(), *itr));
+
+ for (QueuedGroupMap::reverse_iterator itr = m_QueuedGroupMap.rbegin(); itr != m_QueuedGroupMap.rend(); ++itr)
+ {
+ GroupsQueueType allypool = m_SelectionPools[TEAM_ALLIANCE].SelectedGroups;
+ GroupsQueueType hordepool = m_SelectionPools[TEAM_HORDE].SelectedGroups;
+
+ GroupQueueInfo* ginfo = itr->second;
+
+ // If player already was invited via pre adding (add to own team first) or he was already invited to a bg, skip.
+ if (ginfo->IsInvitedToBGInstanceGUID ||
+ std::find(allypool.begin(), allypool.end(), ginfo) != allypool.end() ||
+ std::find(hordepool.begin(), hordepool.end(), ginfo) != hordepool.end() ||
+ (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= bg->GetMinPlayersPerTeam() &&
+ m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= bg->GetMinPlayersPerTeam()))
+ continue;
+
+ diff = abs(valiFree - vhordeFree);
+ bool moreAli = valiFree < vhordeFree;
+
+ if (diff > 0)
+ ginfo->Team = moreAli ? HORDE : ALLIANCE;
+
+ bool alliance = ginfo->Team == ALLIANCE;
+
+ if (m_SelectionPools[alliance ? TEAM_ALLIANCE : TEAM_HORDE].AddGroup(ginfo, alliance ? aliFree : hordeFree))
+ alliance ? valiFree -= ginfo->Players.size() : vhordeFree -= ginfo->Players.size();
+ }
+
+ return true;
+ }
+ return false;
+}
+
+int32 BattlegroundQueue::PreAddPlayers(QueuedGroupMap m_PreGroupMap, int32 MaxAdd, uint32 MaxInTeam)
+{
+ int32 LeftToAdd = MaxAdd;
+ uint32 Added = 0;
+
+ for (QueuedGroupMap::reverse_iterator itr = m_PreGroupMap.rbegin(); itr != m_PreGroupMap.rend(); ++itr)
+ {
+ int32 PlayerSize = itr->first;
+ bool alliance = itr->second->OTeam == ALLIANCE;
+
+ if (PlayerSize <= LeftToAdd && m_SelectionPools[alliance ? TEAM_ALLIANCE : TEAM_HORDE].AddGroup(itr->second, MaxInTeam))
+ LeftToAdd -= PlayerSize, Added -= PlayerSize;
+ }
+
+ return LeftToAdd;
+}
+
+void Player::SendChatMessage(const char *format, ...)
+{
+ if (!IsInWorld())
+ return;
+
+ if (format)
+ {
+ va_list ap;
+ char str [2048];
+ va_start(ap, format);
+ vsnprintf(str, 2048, format, ap);
+ va_end(ap);
+
+ ChatHandler(GetSession()).SendSysMessage(str);
+ }
+}
diff --git a/src/server/game/Cfbg/Cfbg.h b/src/server/game/Cfbg/Cfbg.h
new file mode 100644
index 0000000..bda4199
--- /dev/null
+++ b/src/server/game/Cfbg/Cfbg.h
@@ -0,0 +1,44 @@
+#ifndef _CUSTOM_H
+#define _CUSTOM_H
+
+#define MSG_COLOR_LIGHTRED "|cffff6060"
+#define MSG_COLOR_LIGHTBLUE "|cff00ccff"
+#define MSG_COLOR_ANN_GREEN "|c1f40af20"
+#define MSG_COLOR_RED "|cffff0000"
+#define MSG_COLOR_GOLD "|cffffcc00"
+#define MSG_COLOR_SUBWHITE "|cffbbbbbb"
+#define MSG_COLOR_MAGENTA "|cffff00ff"
+#define MSG_COLOR_YELLOW "|cffffff00"
+#define MSG_COLOR_CYAN "|cff00ffff"
+#define MSG_COLOR_DARKBLUE "|cff0000ff"
+
+#define MSG_COLOR_GREY "|cff9d9d9d"
+#define MSG_COLOR_WHITE "|cffffffff"
+#define MSG_COLOR_GREEN "|cff1eff00"
+#define MSG_COLOR_BLUE "|cff0080ff"
+#define MSG_COLOR_PURPLE "|cffb048f8"
+#define MSG_COLOR_ORANGE "|cffff8000"
+
+#define MSG_COLOR_DRUID "|cffff7d0a"
+#define MSG_COLOR_HUNTER "|cffabd473"
+#define MSG_COLOR_MAGE "|cff69ccf0"
+#define MSG_COLOR_PALADIN "|cfff58cba"
+#define MSG_COLOR_PRIEST "|cffffffff"
+#define MSG_COLOR_ROGUE "|cfffff569"
+#define MSG_COLOR_SHAMAN "|cff0070de"
+#define MSG_COLOR_WARLOCK "|cff9482c9"
+#define MSG_COLOR_WARRIOR "|cffc79c6e"
+#define MSG_COLOR_DEATH_KNIGHT "|cffc41f3b"
+#define MSG_COLOR_MONK "|cff00ff96"
+
+#define LIMIT_UINT32 2147483647
+
+enum FakeMorphs
+{
+ FAKE_F_TAUREN = 20584,
+ FAKE_M_TAUREN = 20585,
+ FAKE_M_NELF = 20318,
+ FAKE_F_DRANAEI = 20323,
+};
+
+#endif
\ No newline at end of file
diff --git a/src/server/game/CMakeLists.txt b/src/server/game/CMakeLists.txt
index bf46c1f..a87edb0 100644
--- a/src/server/game/CMakeLists.txt
+++ b/src/server/game/CMakeLists.txt
@@ -48,6 +48,7 @@ file(GLOB_RECURSE sources_Tickets Tickets/*.cpp Tickets/*.h)
file(GLOB_RECURSE sources_Warden Warden/*.cpp Warden/*.h)
file(GLOB_RECURSE sources_Weather Weather/*.cpp Weather/*.h)
file(GLOB_RECURSE sources_World World/*.cpp World/*.h)
+file(GLOB_RECURSE sources_Cfbg Cfbg/*.cpp Cfbg/*.h)
# Create game-libary
@@ -98,6 +99,7 @@ set(game_STAT_SRCS
${sources_Warden}
${sources_Weather}
${sources_World}
+ ${sources_Cfbg}
)
include_directories(
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 2691a68..8f25156 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -653,6 +653,12 @@ Player::Player(WorldSession* session): Unit(true)
#pragma warning(default:4355)
#endif
+ m_FakeRace = 0;
+ m_RealRace = 0;
+ m_FakeMorph = 0;
+ m_ForgetBGPlayers = false;
+ m_ForgetInListPlayers = false;
+
m_speakTime = 0;
m_speakCount = 0;
@@ -1001,6 +1007,12 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo)
uint32 RaceClassGender = (createInfo->Race) | (createInfo->Class << 8) | (createInfo->Gender << 16);
SetUInt32Value(UNIT_FIELD_BYTES_0, (RaceClassGender | (powertype << 24)));
+
+ SetORace();
+ m_team = TeamForRace(getORace());
+ SetFakeRaceAndMorph(); // m_team must be set before this can be used.
+ setFactionForRace(getORace());
+
InitDisplayIds();
if (sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_PVP || sWorld->getIntConfig(CONFIG_GAME_TYPE) == REALM_TYPE_RPPVP)
{
@@ -3025,7 +3037,7 @@ void Player::GiveLevel(uint8 level)
guild->UpdateMemberData(this, GUILD_MEMBER_DATA_LEVEL, level);
PlayerLevelInfo info;
- sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), level, &info);
+ sObjectMgr->GetPlayerLevelInfo(getORace(), getClass(), level, &info);
PlayerClassLevelInfo classInfo;
sObjectMgr->GetPlayerClassLevelInfo(getClass(), level, &classInfo);
@@ -3163,7 +3175,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
sObjectMgr->GetPlayerClassLevelInfo(getClass(), getLevel(), &classInfo);
PlayerLevelInfo info;
- sObjectMgr->GetPlayerLevelInfo(getRace(), getClass(), getLevel(), &info);
+ sObjectMgr->GetPlayerLevelInfo(getORace(), getClass(), getLevel(), &info);
SetUInt32Value(PLAYER_FIELD_MAX_LEVEL, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
SetUInt32Value(PLAYER_NEXT_LEVEL_XP, sObjectMgr->GetXPForLevel(getLevel()));
@@ -5261,7 +5273,7 @@ void Player::CreateCorpse()
return;
}
- _uf = GetUInt32Value(UNIT_FIELD_BYTES_0);
+ _uf = getORace();
_pb = GetUInt32Value(PLAYER_BYTES);
_pb2 = GetUInt32Value(PLAYER_BYTES_2);
@@ -6924,10 +6936,10 @@ uint32 Player::TeamForRace(uint8 race)
void Player::setFactionForRace(uint8 race)
{
- m_team = TeamForRace(race);
+ SetBGTeam(TeamForRace(race));
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(race);
- setFaction(rEntry ? rEntry->FactionID : 0);
+ setFaction(rEntry ? rEntry->FactionID : getFaction());
}
ReputationRank Player::GetReputationRank(uint32 faction) const
@@ -7029,6 +7041,27 @@ void Player::RewardReputation(Unit* victim, float rate)
if (!Rep)
return;
+ uint32 repfaction1 = Rep->RepFaction1;
+ uint32 repfaction2 = Rep->RepFaction2;
+
+ if (!IsPlayingNative())
+ {
+ if (GetOTeam() == ALLIANCE)
+ {
+ if (repfaction1 == 729)
+ repfaction1 = 730;
+ if (repfaction2 == 729)
+ repfaction2 = 730;
+ }
+ else
+ {
+ if (repfaction1 == 730)
+ repfaction1 = 729;
+ if (repfaction2 == 730)
+ repfaction2 = 729;
+ }
+ }
+
uint32 ChampioningFaction = 0;
if (GetChampioningFaction())
@@ -7043,23 +7076,23 @@ void Player::RewardReputation(Unit* victim, float rate)
uint32 team = GetTeam();
- if (Rep->RepFaction1 && (!Rep->TeamDependent || team == ALLIANCE))
+ if (repfaction1 && (!Rep->TeamDependent || team == ALLIANCE))
{
- int32 donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->getLevel(), Rep->RepValue1, ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);