-
Notifications
You must be signed in to change notification settings - Fork 0
/
liteQueue.lua
13127 lines (11774 loc) · 407 KB
/
liteQueue.lua
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
--[[
@file oqueue.lua
@brief warcraft addon for finding and queuing premade groups for bgs
@author rmcinnis
@date april 06, 2012
@copyright Solid ICE Technologies
this file may be distributed so long as it remains unaltered
if this file is posted to a web site, credit must be given to me along with a link to my web page
no code in this file may be used in other works without expressed permission
]]--
local addonName, OQ = ... ;
local L = OQ._T ; -- for literal string translations
if (OQ.table == nil) then
OQ.table = {} ;
end
local tbl = OQ.table ;
local OQ_MAJOR = 1 ;
local OQ_MINOR = 6 ;
local OQ_REVISION = 1 ;
local OQ_BUILD = 161 ;
local OQ_SPECIAL_TAG = "" ;
local OQUEUE_VERSION = tostring(OQ_MAJOR) ..".".. tostring(OQ_MINOR) ..".".. OQ_REVISION ;
local OQUEUE_VERSION_SHORT = tostring(OQ_MAJOR) ..".".. tostring(OQ_MINOR) .."".. OQ_REVISION ;
local OQ_VERSION = tostring(OQ_MAJOR) .."".. tostring(OQ_MINOR) .."".. tostring(OQ_REVISION) ;
local OQ_VER_STR = OQUEUE_VERSION ;
local OQ_VER = "0Z" ; -- just removing the dot
local OQSK_VER = "0C" ;
local OQSK_HEADER = "OQSK" ;
local OQ_NOTIFICATION_CYCLE = 2 * 60 * 60 ; -- every 2 hrs
local OQ_VERSION_SWAP_TM = 24 * 60 * 60 ; -- daily check for toons that are OQ enabled
local OQ_ONEDAY = 24 * 60 * 60 ;
local OQ_MAX_RELAY_REALMS = 5 ;
local OQ_NOEMAIL = "." ;
local OQ_OLDBNHEADER = "[OQ] " ;
local OQ_BNHEADER_TAG = "(OQ)" ;
local OQ_BNHEADER = OQ_BNHEADER_TAG .." " ;
local OQ_SKHEADER = "[SK] " ;
local OQ_HEADER = "OQ" ;
local OQ_MSGHEADER = OQ_HEADER .."," ;
local OQ_FLD_TO = "#to:" ;
local OQ_FLD_FROM = "#fr:" ;
local OQ_FLD_REALM = "#rlm:" ;
local OQ_TTL = 5 ;
local OQ_PREMADE_STAT_LIFETIME = 5*60 ; -- 5 minutes
local OQ_GROUP_TIMEOUT = 2*60 ; -- 2 minutes (matches raid-timeout) if no response will remove group
local OQ_GROUP_RECOVERY_TM = 5*60 ; -- 5 minutes
local OQ_SEC_BETWEEN_ADS = 25 ;
local OQ_SEC_BETWEEN_PROMO = 25 ;
local OQ_BOOKKEEPING_INTERVAL = 10 ;
local OQ_BRIEF_INTERVAL = 30 ;
local OQ_MAX_ATOKEN_LIFESPAN = 120 ; -- 120 seconds before token removed from ATOKEN list
local OQ_MIN_ATOKEN_RELAY_TM = 30 ; -- do not relay atokens more then once every 30 seconds
local OQ_MAX_SUBMIT_ATTEMPTS = 20 ;
local OQ_MAX_WAITLIST = 40 ;
local OQ_MIN_CONNECTION = 20 ;
local OQ_MIN_BNET_CONNECTIONS = 10 ;
local OQ_FINDMESH_CD = 7 ; -- seconds
local OQ_CREATEPREMADE_CD = 5 ; -- seconds
local OQ_BTAG_SUBMIT_INTERVAL = 4*24*60*60 ;
local MAX_OQGENERAL_TALKERS = 20 ;
local my_group = 0 ;
local my_slot = 0 ;
local next_bn_check = 0 ;
local next_check = 0 ;
local next_invite_tm = 0 ;
local last_ident_tm = 0 ;
local last_stats_tm = 0 ;
local skip_stats = 0 ;
local last_stats = "" ;
local player_name = nil ;
local player_class = nil ;
local player_realm = nil ;
local player_realm_id = 0 ;
local player_realid = nil ;
local player_faction = nil ;
local player_level = 1 ;
local player_ilevel = 1 ;
local player_resil = 1 ;
local player_role = 3 ;
local player_deserter = nil ;
local player_queued = nil ;
local player_online = 1 ;
local player_karma = 0 ;
local _source = nil ; -- bnet, addon, bnfinvite, oqgeneral, party
local _sender_pid = nil ;
local _msg_token = nil ;
local _debug = nil ;
local _inc_channel = nil ;
local _received = nil ;
local _ok2relay = 1 ;
local _ok2decline = true ;
local _ok2accept = true ;
local _local_msg = nil ;
local _last_find_tm = 0 ;
local _inside_bg = nil ;
local _bg_shortname = nil ;
local _bg_zone = nil ;
local _winner = nil ;
local _msg = nil ;
local _msg_type = nil ;
local _msg_id = nil ;
local _oq_note = nil ;
local _oq_msg = nil ;
local _dest_realm = nil ;
local _core_msg = nil ;
local _to_name = nil ;
local _to_realm = nil ;
local _from = nil ;
local _last_report = nil ;
local _map_open = nil ;
local _ui_open = nil ;
local _oqgeneral_id = nil ;
local _oqgeneral_count = 0 ;
local _oqgeneral_lockdown = true ; -- restricted until unlocked once the # of members of oqgeneral are determined
local _f = {} ;
local _toon = {} ;
local _flags = nil ;
local _enemy = nil ;
local _nkbs = 0 ;
local _arg = {} ;
local _opts = {} ;
local _vars = {} ;
local _hop = 0 ;
local player_away = nil ;
local oq_ascii = {} ;
local oq_mime64 = {} ;
local lead_ticker = 0 ;
local OQ_MAX_BNFRIENDS = 85 ;
OQ.BNET_CAPB4THECAP = 100 ; -- blizz increased the cap from 100 to 112 (also fixed the crash. capb4cap needed?).
local _ ; -- throw away (was getting taint warning; what happened blizz?)
if (OQ_toon == nil) then
OQ_toon = { last_tm = 0,
auto_role = 1,
class_portrait = 1
} ;
end
--[[ OQ_toon used to help save group information if disconnected, reloaded, or quickly logged out
my_group = 0 ;
my_slot = 0 ;
last_tm = 0 ; -- if within 1 minute from now, try to re-establish
raid = {} ; -- copied from oq on_logout
]]
local oq = { my_tok = nil, ui = {}, channels = {}, premades = {}, raid = {}, waitlist = {}, pending = {} } ;
--[[
raid = {
name = 'the raid'
leader = 'bigdk'
leader_realm = 'magtheridon'
leader_rid = '[email protected]'
level_range = '80-84'
faction = 'H'
min_ilevel = 380 ;
min_resil = 3000 ;
bgs = 'IoC,AV,AB,EotS'
notes = 'nothing much here'
raid_token = 'OQ10002xxx'
type = OQ.TYPE_BG (D dungeon, A rated bgs, B battlegrounds(def))
group = {
[1] = { status = 'queued' -- group[1].member[1] is always the raid leader
member = {
[1] = { name = 'bigman', class = 'dk' , realm = '', bgroup = '', realid = nil, level = 0, hp = 0, flags = 0, bg[1]{ type,status } }, -- member[1] is always the group leader
[2] = { name = 'jack' , class = 'rogue', realm = '', bgroup = '', realid = nil }, -- realid is nil all but the raid leader
}
},
}
channel = 'oq00010022'
pword = 'pw00050001'
},
pending_invites = {
[ name-realm ] = { raid_tok = oq.raid.raid_token, gid = group_id, slot = slot_, rid = rid_ }
},
premades = {
[1] = { raid_token = '', name = '', leader = '', leader_rid = '', level_range = '', faction = '', min_ilevel = '', min_resil = '', bgs = '' },
},
-- non-nil only for raid leader
waitlist = {
[1] = { name = 'slash', class = 'pally', realm = '', realid = '', level = '84', ilevel = '390', resil = '4200', realid = '' },
[2] = { name = 'hack' , class = 'rogue', realm = '', realid = '', level = '84', ilevel = '390', resil = '4200', realid = '' },
},
]]
local dtp = oq ;
function OQ:mod() return oq ; end
if (OQ_data == nil) then
OQ_data = {
bn_friends = {},
autoaccept_mesh_request = 1,
ok2submit_tag = 1,
} ;
OQ_data.stats = {
nGames = 0 ;
nWins = 0 ;
nLosses = 0 ;
start_tm = 0 ; -- time() when this raid was created
bg_start = 0 ; -- place holder - time() of bg start
bg_end = 0 ; -- place holder - time() of bg end
tm = 0 ; -- time of last update from source. able to know which data is the latest
} ;
end
--[[
-- OQ enabled BN friends
bn_friends = {
[toonName-realm] = { presenceID, givenName, surName, toonName, realm, isOnline, oq_enabled } ;
}
]]
-------------------------------------------------------------------------------
-- local defines
-------------------------------------------------------------------------------
oq.old_bncustommsg = nil ;
oq.old_bn_msg = nil ;
OQ.CHK_VLIST_TM = 15 ;
OQ.FLAG_ONLINE = 0x01 ;
OQ.FLAG_DESERTER = 0x02 ;
OQ.FLAG_QUEUED = 0x04 ;
OQ.FLAG_BRB = 0x08 ;
OQ.FLAG_TANK = 0x10 ;
OQ.FLAG_HEALER = 0x20 ;
OQ.FLAG_CLEAR = 0x00 ;
OQ.FLAG_READY = 0x01 ;
OQ.FLAG_NOTREADY = 0x02 ;
OQ.FLAG_WAITING = 0x04 ;
OQ.FACTION_ICON = {} ;
OQ.FACTION_ICON["H"] = "|TInterface\\BattlefieldFrame\\Battleground-Horde.blp:20:20:0:0|t";
OQ.FACTION_ICON["A"] = "|TInterface\\BattlefieldFrame\\Battleground-Alliance.blp:20:20:0:0|t";
local OQ_LOCK = "|TInterface\\BUTTONS\\UI-Button-KeyRing.blp:28:20:0:0:20:24:0:16:0:16|t";
local OQ_KEY = "Interface\\BUTTONS\\UI-Button-KeyRing" ;
local OQ_STAR_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:16:16:0:0:64:64:0:16:0:16|t";
local OQ_CIRCLE_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:16:16:0:0:64:64:16:32:0:16|t";
local OQ_DIAMOND_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:10:10:0:0:64:64:32:48:0:16|t";
local OQ_BIGDIAMOND_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:16:16:0:0:64:64:32:48:0:16|t";
local OQ_TRIANGLE_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:16:16:0:0:64:64:48:64:0:16|t";
local OQ_LILTRIANGLE_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:8:8:0:0:64:64:48:64:0:16|t";
local OQ_MOON_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:16:16:0:0:64:64:0:16:16:32|t";
local OQ_SQUARE_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:16:16:0:0:64:64:16:32:16:32|t";
local OQ_REDX_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:16:16:0:0:64:64:32:48:16:32|t";
local OQ_LILREDX_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:8:8:0:0:64:64:32:48:16:32|t";
local OQ_SKULL_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:16:16:0:0:64:64:48:64:16:32|t";
local OQ_LILSKULL_ICON = "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:10:10:0:0:64:64:48:64:16:32|t";
local OQ_LILCIRCLE_ICON= "|TInterface\\TARGETINGFRAME\\UI-RaidTargetingIcons.blp:8:8:0:0:64:64:16:32:0:16|t";
OQ.ICON_NONE = 0 ;
OQ.ICON_STAR = 1 ;
OQ.ICON_CIRCLE = 2 ;
OQ.ICON_DIAMOND = 3 ;
OQ.ICON_TRIANGLE = 4 ;
OQ.ICON_MOON = 5 ;
OQ.ICON_SQUARE = 6 ;
OQ.ICON_REDX = 7 ;
OQ.ICON_SKULL = 8 ;
OQ.ICON_STRINGS = {
[ OQ.ICON_NONE ] = nil,
[ OQ.ICON_STAR ] = OQ_STAR_ICON,
[ OQ.ICON_CIRCLE ] = OQ_CIRCLE_ICON,
[ OQ.ICON_DIAMOND ] = OQ_DIAMOND_ICON,
[ OQ.ICON_TRIANGLE ] = OQ_TRIANGLE_ICON,
[ OQ.ICON_MOON ] = OQ_MOON_ICON,
[ OQ.ICON_SQUARE ] = OQ_SQUARE_ICON,
[ OQ.ICON_REDX ] = OQ_REDX_ICON,
[ OQ.ICON_SKULL ] = OQ_SKULL_ICON,
} ;
OQ.ICON_COORDS = {
[ OQ.ICON_NONE ] = { 0.00, 0.00, 0.00, 0.00 },
[ OQ.ICON_STAR ] = { 0.00, 0.25, 0.00, 0.25 },
[ OQ.ICON_CIRCLE ] = { 0.25, 0.50, 0.00, 0.25 },
[ OQ.ICON_DIAMOND ] = { 0.50, 0.75, 0.00, 0.25 },
[ OQ.ICON_TRIANGLE ] = { 0.75, 1.00, 0.00, 0.25 },
[ OQ.ICON_MOON ] = { 0.00, 0.25, 0.25, 0.50 },
[ OQ.ICON_SQUARE ] = { 0.25, 0.50, 0.25, 0.50 },
[ OQ.ICON_REDX ] = { 0.50, 0.75, 0.25, 0.50 },
[ OQ.ICON_SKULL ] = { 0.75, 1.00, 0.25, 0.50 },
} ;
-------------------------------------------------------------------------------
local OQ_versions =
{ [ "1.5.0" ] = 28,
[ "1.5.1" ] = 29,
[ "1.5.2" ] = 30,
[ "1.5.3" ] = 31,
[ "1.5.4" ] = 32,
[ "1.5.5" ] = 33,
[ "1.5.6" ] = 34,
[ "1.5.7" ] = 35,
[ "1.5.8" ] = 36,
[ "1.5.9" ] = 37,
[ "1.6.0" ] = 39,
[ "1.6.1" ] = 40,
[ "1.6.2" ] = 41,
[ "1.6.3" ] = 42,
[ "1.6.4" ] = 43,
[ "1.6.5" ] = 44,
[ "1.6.6" ] = 45,
[ "1.6.7" ] = 46,
[ "1.6.8" ] = 47,
[ "1.6.9" ] = 48,
[ "1.7.0" ] = 49,
[ "1.8.0" ] = 50,
[ "1.8.1" ] = 51,
[ "1.8.2" ] = 52,
[ "1.8.3" ] = 53,
[ "1.8.4" ] = 54,
[ "1.8.5" ] = 55,
[ "1.8.6" ] = 56,
[ "1.8.7" ] = 57,
[ "1.8.8" ] = 58,
[ "1.8.9" ] = 59,
[ "1.9.0" ] = 60,
[ "1.9.1" ] = 1,
} ;
function oq.get_version_id()
return OQ_versions[OQ_VER_STR] or 0 ;
end
function oq.get_version_str( id )
if (id == 0) then
return "" ;
end
for i,v in pairs(OQ_versions) do
if (v == id) then
return i ;
end
end
return "" ;
end
-------------------------------------------------------------------------------
-- slash commands
-------------------------------------------------------------------------------
SLASH_OQUEUE1 = '/oqueue' ;
SLASH_OQUEUE2 = '/oq' ;
SlashCmdList["OQUEUE"] = function (msg, editbox)
if (msg == nil) or (msg == "") then
oq.ui_toggle() ;
return ;
end
local arg1 = msg ;
local opts = nil ;
if (msg ~= nil) and (msg:find(" ") ~= nil) then
arg1 = msg:sub(1,msg:find(" ")-1) ;
opts = msg:sub(msg:find(" ")+1,-1) ;
end
if (oq.options[ arg1 ] ~= nil) then
oq.options[ arg1 ]( opts ) ;
end
end
--------------------------------------------------------------------------
--------------------------------------------------------------------------
oq.options = {} ;
function oq.hook_options()
oq.options[ "?" ] = oq.usage ;
oq.options[ "adds" ] = oq.show_adds ;
oq.options[ "ban" ] = oq.ban_user ;
oq.options[ "bnclear" ] = oq.bn_clear ;
oq.options[ "check" ] = oq.bn_force_verify ;
oq.options[ "cp" ] = oq.toggle_class_portraits ;
oq.options[ "debug" ] = oq.debug_toggle ;
oq.options[ "dg" ] = oq.leave_party ; -- drop group
oq.options[ "dp" ] = oq.leave_party ; -- drop party
oq.options[ "fixui" ] = oq.reposition_ui ;
oq.options[ "godark" ] = oq.godark ;
oq.options[ "harddrop" ] = oq.harddrop ;
oq.options[ "help" ] = oq.usage ;
oq.options[ "lust" ] = oq.last_lust ;
oq.options[ "mbsync" ] = oq.mbsync ;
oq.options[ "mycrew" ] = oq.mycrew ;
oq.options[ "mini" ] = oq.toggle_mini ;
oq.options[ "now" ] = oq.show_now ;
oq.options[ "pnow" ] = oq.show_now2party ;
oq.options[ "partynow" ] = oq.show_now2party ;
oq.options[ "off" ] = oq.oq_off ;
oq.options[ "on" ] = oq.oq_on ;
oq.options[ "pending" ] = oq.bn_show_pending ;
oq.options[ "ping" ] = oq.ping_toon ;
oq.options[ "purge" ] = oq.remove_OQadded_bn_friends ;
oq.options[ "rage" ] = oq.report_rage ;
oq.options[ "rc" ] = oq.start_role_check ;
oq.options[ "refresh" ] = oq.raid_find ;
oq.options[ "reset" ] = oq.data_reset ;
oq.options[ "show" ] = oq.show_data ;
oq.options[ "spy" ] = oq.battleground_spy ;
oq.options[ "stats" ] = oq.dump_statistics ;
oq.options[ "threat" ] = oq.toggle_threat_level ;
oq.options[ "thx" ] = oq.special_thanks ;
oq.options[ "time" ] = oq.force_time_reset ;
oq.options[ "timer" ] = oq.user_timer ;
oq.options[ "toggle" ] = oq.toggle_option ;
oq.options[ "version" ] = oq.show_version ;
oq.options[ "-v" ] = oq.show_version ;
oq.options[ "wallet" ] = oq.show_wallet ;
oq.options[ "who" ] = oq.show_bn_enabled ;
oq.options[ "kk" ] = function()
oq.req_karma("player") ;
end
end
function oq.toggle_mini()
if (OQ_MinimapButton:IsVisible()) then
OQ_MinimapButton:Hide() ;
OQ_toon.mini_hide = true ;
print( OQ.MINIMAP_HIDDEN ) ;
else
OQ_MinimapButton:Show() ;
OQ_toon.mini_hide = nil ;
print( OQ.MINIMAP_SHOWN ) ;
end
end
function oq.reposition_ui()
x = 500 ;
-- main ui
local f = OQMainFrame ;
if (not f:IsVisible()) then
oq.ui_toggle() ;
end
f:SetWidth( 800 ) ;
f:SetHeight( 425 ) ;
f:SetPoint("TOPLEFT", UIParent,"TOPLEFT", x, -150 ) ;
-- toggle minimap button so it's on top
OQ_MinimapButton:Show() ;
OQ_MinimapButton:SetFrameStrata( "MEDIUM" ) ;
OQ_MinimapButton:SetFrameLevel(50) ;
end
function oq.show_count()
local p = nil ;
local nLeaders = 0 ;
local nWaiting = 0 ;
local nMembers = 0 ;
for i,v in pairs(oq.premades) do
nLeaders = nLeaders + 1 ;
nMembers = nMembers + v.stats.nMembers ;
nWaiting = nWaiting + v.stats.nWaiting ;
end
print( "nLeaders: ".. tostring(nLeaders) ) ;
print( "nMembers: ".. tostring(nMembers) ) ;
print( "nWaiting: ".. tostring(nWaiting) ) ;
end
function oq.show_data( opt )
if (opt == nil) or (opt == "?") then
print( "oQueue v".. OQUEUE_VERSION .." build ".. OQ_BUILD .." (".. tostring(OQ.REGION) ..")" ) ;
print( " usage: /oq show <option>" ) ;
print( " remove list all the battle-tags that will be removed with 'remove now'" ) ;
print( " report show battleground reports yet to be filed" ) ;
print( " stats list various stats" ) ;
elseif (opt == "remove") then
oq.remove_OQadded_bn_friends( "show" ) ;
elseif (opt == "btags") then
oq.show_btags() ;
elseif (opt == "count") then
oq.show_count() ;
elseif (opt == "raid") then
oq.show_raid() ;
elseif (opt == "stats") then
oq.dump_statistics() ;
elseif (opt == "frames") then
oq.frame_report() ;
end
end
function oq.toggle_option( opt )
if (opt == nil) or (opt == "?") then
print( "oQueue v".. OQUEUE_VERSION .." build ".. OQ_BUILD .." (".. tostring(OQ.REGION) ..")" ) ;
print( " usage: /oq toggle <option>" ) ;
print( " mini toggle the minimap icon" ) ;
elseif (opt == "mini") then
oq.toggle_mini() ;
end
end
function oq.harddrop()
oq.raid_init() ;
end
function oq.leave_party()
oq._last_raid_token = oq.raid.raid_token ;
if (oq.iam_raid_leader()) then
oq.raid_disband() ;
else
LeaveParty() ;
oq.raid_init() ;
end
oq.raid_cleanup() ;
end
function oq.ban_user( tag )
if (tag == nil) then
return ;
end
local dialog = StaticPopup_Show("OQ_BanUser", tag ) ;
if (dialog ~= nil) then
dialog.data2 = { flag = 3, btag = tag } ;
end
end
function oq.usage()
print( "oQueue v".. OQUEUE_VERSION .." build ".. OQ_BUILD .." (".. tostring(OQ.REGION) ..")" ) ;
print( L["usage: /oq [command]"] ) ;
print( L["command such as:"] ) ;
print( L[" adds show the list of OQ added b.net friends"] ) ;
print( L[" ban [b-tag] manually add battle-tag to your ban list"] ) ;
print( L[" bnclear clear OQ enabled battle-net associations"] ) ;
print( L[" check force OQ capability check"] ) ;
print( L[" cp toggle class portraits to normal portrait"] ) ;
print( L[" dg drop group. same as /script LeaveParty()"] ) ;
print( L[" fixui will reposition the UI to upper left area"] ) ;
print( L[" godark send 'oq stop' to all your OQ enabled friends"] ) ;
print( L[" id show guid, id, and name of target"] ) ;
print( L[" log [clear] toggle log on/off or clear"] ) ;
print( L[" lust re-display the last lust message"] ) ;
print( L[" mini toggle the minimap button"] ) ;
print( L[" mycrew [clear] for boxers, populate the alt list"] ) ;
print( L[" now print the current utc time (only visible to user)"] ) ;
print( L[" off turn off OQ messaging"] ) ;
print( L[" on turn on OQ messaging"] ) ;
print( L[" pnow print the current utc time to party chat"] ) ;
print( L[" pos print your current locaiton in the world"] ) ;
print( L[" purge purge friends list of OQ added b.net friends"] ) ;
print( L[" rc start role check (OQ premade leader only)"] ) ;
print( L[" refresh sends out a request to refresh find-premade list"] ) ;
print( L[" show <opt> show various information"] ) ;
print( L[" stats various statistics about the player"] ) ;
print( L[" spy [on|off] display summary of enemy class types"] ) ;
print( L[" toggle <opt> toggle specific option"] ) ;
print( L[" who list of OQ enabled battle-net friends"] ) ;
end
function oq.data_reset()
oq = { my_tok = nil, ui = {}, channels = {}, premades = {}, raid = {}, waitlist = {} } ;
OQ_data = { bn_friends = {} } ;
oq.init_stats_data() ;
OQ_toon = { last_tm = 0,
auto_role = 1,
class_portrait = 1,
reports = {},
} ;
print( "oQueue data reset. for it to take effect, type /reload" ) ;
end
function oq.debug_toggle( level )
if (level) then
if (level == "off") then
_debug = nil ;
print( "debug off" ) ;
elseif (level == "on") then
_debug = true ;
print( "debug on" ) ;
elseif (tonumber(level)) then
oq._debug_level = tonumber(level) ;
print( "debug level: ".. tostring(oq._debug_level) ) ;
end
else
if (_debug) then
_debug = nil ;
print( "debug off" ) ;
else
_debug = true ;
print( "debug on" ) ;
end
end
end
function oq.godark()
-- clear out bn friends
oq.bn_clear() ;
-- turn it off
oq.oq_off() ;
-- update OQ friends count
oq.n_connections() ;
end
function oq.oq_off()
OQ_toon.disabled = true ;
oq.reset_bn_custom_msg() ;
print( OQ.DISABLED ) ;
end
function oq.oq_on()
OQ_toon.disabled = nil ;
oq.init_bn_custom_msg() ;
print( OQ.ENABLED ) ;
end
function oq.GetNumPartyMembers()
return GetNumGroupMembers() ;
end
function oq.mycrew( arg )
-- use the current raid/party to poulate the OQ_data.my_toons
if (arg == "clear") then
oq.clear_alt_list() ;
return ;
end
if (not UnitInParty("player")) then
return ;
end
oq.clear_alt_list() ;
local n = GetNumGroupMembers() ;
if (n > 0) then
for i=1,n do
local name = select( 1, GetRaidRosterInfo(i) ) ;
oq.add_toon( name ) ;
end
else
n = oq.GetNumPartyMembers() ;
oq.add_toon( player_name ) ;
for i=1,n do
local name = GetUnitName( "party".. i ) ;
oq.add_toon( name ) ;
end
end
end
function oq.timezone_reset()
oq.__date1 = nil ;
oq.__date2 = nil ;
end
function oq.force_time_reset()
print( "OQ: forcing timezone reset" ) ;
oq.timezone_reset() ;
oq.show_now() ;
end
local function utc_time( arg )
if (arg == nil) then
local now = time() ;
if (oq.__date1 == nil) then
oq.__date1 = date("!*t") ;
oq.__date2 = date("!*t", now) ;
end
return time( oq.__date1 ) + difftime(now, time( oq.__date2 )) - (OQ_data.sk_adjust or 0) ;
--
-- date("!*t") leaks a table after every call. to avoid, only call once
-- this will cause a problem for those ppl with incorrect set timezones.
-- whereas they will automatically pick up the timezone change now, this
-- will force them to tell oq to re-calc the tables
--
-- return time(date("!*t")) + difftime(now, time(date("!*t", now) )) ;
elseif (arg == "pure") then
local now = time() ;
if (oq.__date1 == nil) then
oq.__date1 = date("!*t") ;
oq.__date2 = date("!*t", now) ;
end
return time( oq.__date1 ) + difftime(now, time( oq.__date2 )) ;
else
return time(date("!*t")) ;
end
end
function oq.reset_portrait( f, player, show_default )
if (f == nil) or (f.portrait == nil) then
return ;
end
if (show_default) then
SetPortraitTexture( f.portrait, player ) ;
f.portrait:SetTexCoord(0,1,0,1) ;
else
OQ_ClassPortrait( f ) ;
end
end
function oq.toggle_class_portraits()
if (OQ_toon.class_portrait == 1) then
OQ_toon.class_portrait = 0 ;
else
OQ_toon.class_portrait = 1 ;
end
oq.reset_portrait( PlayerFrame , "player", (OQ_toon.class_portrait == 0) ) ;
oq.reset_portrait( TargetFrame , "target", (OQ_toon.class_portrait == 0) ) ;
oq.reset_portrait( PartyMemberFrame1, "party1", (OQ_toon.class_portrait == 0) ) ;
oq.reset_portrait( PartyMemberFrame2, "party2", (OQ_toon.class_portrait == 0) ) ;
oq.reset_portrait( PartyMemberFrame3, "party3", (OQ_toon.class_portrait == 0) ) ;
oq.reset_portrait( PartyMemberFrame4, "party4", (OQ_toon.class_portrait == 0) ) ;
oq.reset_portrait( PartyMemberFrame5, "party5", (OQ_toon.class_portrait == 0) ) ;
end
function oq.render_tm( dt )
dt = abs(dt) ;
if (dt >= 0) then
local dsec, dmin, dhr, ddays, dyrs, dstr ;
ddays = floor(dt / (24*60*60)) ;
dt = dt % (24*60*60) ;
dyrs = floor( ddays / 365 ) ;
ddays = ddays % 365 ;
dhr = floor(dt / (60*60)) ;
dt = dt % (60*60) ;
dmin = floor(dt / 60) ;
dt = dt % 60 ;
dsec = dt ;
dstr = "" ;
if (dyrs > 0) then
dstr = dyrs .."y ".. ddays .."d ".. string.format("%02d:%02d:%02d", dhr, dmin, dsec ) ;
elseif (ddays > 0) then
dstr = ddays .."d ".. string.format("%02d:%02d:%02d", dhr, dmin, dsec ) ;
elseif (dhr > 0) then
dstr = string.format("%02d:%02d:%02d", dhr, dmin, dsec ) ;
elseif (dmin > 0) then
dstr = string.format("%02d:%02d", dmin, dsec ) ;
else
dstr = string.format("00:%02d", dsec ) ;
end
return dstr ;
else
return "xx:xx" ;
end
end
function oq.show_now( arg )
local now = utc_time( arg ) ;
local msg = string.format( OQ.THETIMEIS, now ) ;
print( string.format( OQ.THETIMEIS, now ) .." ".. date("!%H:%M %d %b %Y UTC", now ) ) ;
local dt = abs(OQ_data.sk_adjust or 0) ;
if (dt > 0) or true then
local dsec, dmin, dhr, ddays, dyrs, dstr ;
ddays = floor(dt / (24*60*60)) ;
dt = dt % (24*60*60) ;
dyrs = floor( ddays / 365 ) ;
ddays = ddays % 365 ;
dhr = floor(dt / (60*60)) ;
dt = dt % (60*60) ;
dmin = floor(dt / 60) ;
dt = dt % 60 ;
dsec = dt ;
dstr = "local time varies from scorekeeper by: " ;
if (dyrs > 0) then
dstr = dstr .." ".. dyrs .." yrs ".. ddays .." days ".. dhr ..":".. dmin ..":".. dsec ;
elseif (ddays > 0) then
dstr = dstr .." ".. ddays .." days ".. dhr ..":".. dmin ..":".. dsec ;
elseif (dhr > 0) then
dstr = dstr .." ".. dhr ..":".. dmin ..":".. dsec .." hours" ;
elseif (dmin > 0) then
dstr = dstr .." ".. dmin ..":".. dsec .." minutes" ;
else
dstr = dstr .." ".. dsec .." seconds" ;
end
print( dstr ) ;
end
end
function oq.show_now2party( arg )
local msg = string.format( OQ.THETIMEIS, utc_time( arg )) ;
SendChatMessage( msg, "PARTY", nil ) ;
end
-------------------------------------------------------------------------------
-- token functions
-------------------------------------------------------------------------------
local OQ_atoken = {} ;
function oq.atok_last_seen( token )
if (token == nil) or (OQ_atoken[ token ] == nil) then
return 0 ;
end
return OQ_atoken[ token ] ;
end
function oq.atok_seen( token )
if (token ~= nil) then
OQ_atoken[ token ] = utc_time() ;
end
end
-- will register token as seen if ok to process
--
function oq.atok_ok2process( token )
local last_seen = oq.atok_last_seen( token ) ;
local now = utc_time() ;
if ((now - last_seen) > OQ_MIN_ATOKEN_RELAY_TM) then
oq.atok_seen( now ) ;
return true ;
end
end
function oq.atok_clear_old()
local now = utc_time() ;
for i,v in pairs(OQ_atoken) do
if ((now - v) > OQ_MAX_ATOKEN_LIFESPAN) then
OQ_atoken[i] = nil ;
end
end
end
function oq.atok_clear()
tbl.clear( OQ_atoken ) ;
end
function oq.token_gen()
--[[
local tm = floor( GetTime() * 1000 ) ;
local r = random( 0, 10000 ) ;
local token = (tm % 100000) * 10000 + r ;
return oq.encode_mime64_5digit(token) ;
]]--
return oq.encode_mime64_5digit( utc_time() * 10000 + random( 0, 10000 )) ;
end
function oq.is_my_token( t )
if (OQ_data.my_tokens[t]) and (OQ_data.my_tokens[t] > utc_time()) then
return true ;
end
return nil ;
end
function oq.store_my_token( t )
if (t == nil) then
return ;
end
OQ_data.my_tokens[t] = utc_time() + 8*60*60 ; -- expires in 8 hrs
end
function oq.clear_old_tokens()
if (OQ_data.my_tokens == nil) then
OQ_data.my_tokens = {} ;
end
local now = utc_time() ;
for i,v in pairs(OQ_data.my_tokens) do
if (v < now) then
OQ_data.my_tokens[i] = nil ;
end
end
end
local OQ_recent_tokens = {} ;
local OQ_recent_keys = {} ;
local OQ_tok_cnt = 0 ;
function oq.token_list_init()
for i=1,500 do
OQ_recent_tokens[i] = i ;
OQ_recent_keys[i] = i ;
end
OQ_tok_cnt = 501 ;
end
function oq.token_was_seen( token )
return (OQ_recent_keys[ token ] ~= nil) ;
end
--
-- remove one from the front, push one to the back
--
function oq.token_push( token_ )
local key = table.remove( OQ_recent_tokens, 1 ) ;
if (OQ_recent_keys == nil) then
OQ_recent_keys = tbl.new() ;
end
if (OQ_recent_tokens == nil) then
OQ_recent_tokens = tbl.new() ;
end
if (key ~= nil) then
OQ_recent_keys[ key ] = nil ;
end
OQ_tok_cnt = OQ_tok_cnt + 1 ;
OQ_recent_tokens[ OQ_tok_cnt ] = token_ ;
OQ_recent_keys [ token_ ] = OQ_tok_cnt ;
end
-------------------------------------------------------------------------------
--
-------------------------------------------------------------------------------
function oq.tremove_value( t, val )
for i,v in pairs(t) do
if (v == val) then
tremove( t, i ) ;
return ;
end
end
end
-- Print contents of `tbl`, with indentation.
-- `indent` sets the initial level of indentation.
local function tprint_col (tbl, indent, key )
if not indent then indent = 0 end
local ln = string.rep(" ", indent) ;
for k, v in pairs(tbl) do
if type(v) == "table" then
formatting = string.rep(" ", indent) ;
tprint_col(v, indent+1, k)
elseif (k ~= "leader_rid") then
ln = ln .." ".. k ..": ".. tostring(v) ;
end
end
if (key ~= nil) then
print( tostring(key) ..": ".. ln ) ;
else
print( ln ) ;
end
end
function oq.n_rows(t)
local n = 0 ;
for i,v in pairs(t) do
n = n + 1 ;
end
return n ;
end
function oq.n_premades()
local nShown, nPremades = 0, 0 ;
if (oq.tab2_raids ~= nil) then
for n,v in pairs(oq.tab2_raids) do
local p = oq.premades[ v.token ] ;
if (p ~= nil) then
if (v._isvis) then
nShown = nShown + 1 ;
end
nPremades = nPremades + 1 ;
end
end
end
return nShown, nPremades ;
end
function oq.dump_statistics()
oq.req_karma("player") ;
oq.gather_my_stats() ;
print( "oQueue premade stats" ) ;
print( "---" ) ;
print( " leader stats" ) ;
print( " - regular bg : ".. tostring(OQ_data.leader["bg"].nWins or 0) .." - ".. tostring(OQ_data.leader["bg"].nLosses or 0) .." over ".. tostring(OQ_data.leader["bg"].nGames or 0) .." games" ) ;
print( " - rated bg : ".. tostring(OQ_data.leader["rbg"].nWins or 0) .." - ".. tostring(OQ_data.leader["rbg"].nLosses or 0) .." over ".. tostring(OQ_data.leader["rbg"].nGames or 0) .." games" ) ;
print( " - 5Mans : ".. tostring(OQ_data.leader["pve.5man"].nBosses) .." - ".. tostring(OQ_data.leader["pve.5man"].nWipes) .." pts: ".. tostring(OQ_data.leader["pve.5man"].pts) ) ;
print( " - raids : ".. tostring(OQ_data.leader["pve.raid"].nBosses) .." - ".. tostring(OQ_data.leader["pve.raid"].nWipes) .." pts: ".. tostring(OQ_data.leader["pve.raid"].pts) ) ;
print( " - challenges : ".. tostring(OQ_data.leader["pve.challenge"].nBosses) .." - ".. tostring(OQ_data.leader["pve.challenge"].nWipes) .." pts: ".. tostring(OQ_data.leader["pve.challenge"].pts) ) ;
print( " - scenarios : ".. tostring(OQ_data.leader["pve.scenario"].nBosses) .." - ".. tostring(OQ_data.leader["pve.scenario"].nWipes) .." pts: ".. tostring(OQ_data.leader["pve.scenario"].pts) ) ;
print( " my win-loss : " ) ;
print( " - regular bg : ".. tostring(OQ_toon.stats["bg"].nWins or 0) .." - ".. tostring(OQ_toon.stats["bg"].nLosses or 0) .." over ".. tostring(OQ_toon.stats["bg"].nGames or 0) .." games") ;
print( " - rated bg : ".. tostring(OQ_toon.stats["rbg"].nWins or 0) .." - ".. tostring(OQ_toon.stats["rbg"].nLosses or 0) .." over ".. tostring(OQ_toon.stats["rbg"].nGames or 0) .." games" ) ;
print( " my_region : ".. tostring(OQ.REGION) ) ;
print( " my_realmlist : ".. tostring(GetCVar("realmlist")) ) ;
print( " my_realm : ".. tostring(player_realm) .." (".. tostring(oq.realm_cooked(player_realm)) ..")" ) ;
if (player_realid == nil) then
print( " my_btag : ".. OQ_LILREDX_ICON .." |cFFFF8080no battle-tag assigned|r" ) ;
else
print( " my_btag : ".. tostring( player_realid ) ) ;
end
print( " my_karma : ".. tostring( player_karma ) ) ;
print( " my_role : ".. tostring( OQ.ROLES[player_role] ) ) ;
print( " my_ilevel : ".. oq.get_ilevel() ) ;
print( " my_rbg_rating : ".. oq.get_mmr() ) ;
print( " my_2s_rating : ".. oq.get_arena_rating(1) ) ;
print( " my_3s_rating : ".. oq.get_arena_rating(2) ) ;
print( " my_5s_rating : ".. oq.get_arena_rating(3) ) ;
print( " my_resil : ".. oq.get_resil() ) ;
print( " my_timevariance : ".. tostring( OQ_data.sk_adjust or 0 ) .." seconds" ) ;
print( " my_next_timechk : ".. oq.render_tm( (OQ_data.sk_next_update or 0) - utc_time("pure") )) ;
if (oq.raid.raid_token == nil) then
print( " my_group: not in an OQ premade" ) ;
else
print( " my_group: ".. tostring( oq.raid.type ) ..".".. tostring( oq.raid.raid_token ) .." . ".. tostring( my_group ) .." . ".. tostring( my_slot ) .." ".. tostring(oq.raid.leader) .."-".. tostring(oq.raid.leader_realm) ) ;
if (oq.iam_related_to_boss()) then
print( " -- i am related to the boss" ) ;
end
end
if (_inside_bg) then
print( " inside bg : yes [".. tostring(_bg_zone) ..". ".. tostring(_bg_shortname) .."]" ) ;
else
print( " inside bg : no" ) ;
end
if (OQ_toon.disabled) then
print( " OQ messaging is DISABLED" ) ;
else
print( " OQ messaging is ENABLED" ) ;
end
local nShown, nPremades = oq.n_premades() ;
print( " # of premades : ".. nShown .." / ".. nPremades ) ;
print( " # of BN friends : ".. select( 1, BNGetNumFriends() ) ) ;
print( " packets recv : ".. oq.pkt_recv._cnt .." (".. string.format( "%5.3f", oq.pkt_recv._aps ) .." per sec)" ) ;
print( " packets processed : ".. oq.pkt_processed._cnt .." (".. string.format( "%5.3f", oq.pkt_processed._aps ) .." per sec)" ) ;
print( " packets sent : ".. oq.pkt_sent._cnt .." (".. string.format( "%5.3f", oq.pkt_sent._aps ) .." per sec) ".. #oq.send_q .." q'd" ) ;
print( "" ) ;