1function g_game.getRsa()
2 return G.currentRsa
3end
4
5function g_game.findPlayerItem(itemId, subType)
6 local localPlayer = g_game.getLocalPlayer()
7 if localPlayer then
8 for slot = InventorySlotFirst, InventorySlotLast do
9 local item = localPlayer:getInventoryItem(slot)
10 if item and item:getId() == itemId and (subType == -1 or item:getSubType() == subType) then
11 return item
12 end
13 end
14 end
15
16 return g_game.findItemInContainers(itemId, subType)
17end
18
19function g_game.chooseRsa(host)
20 if G.currentRsa ~= CIPSOFT_RSA and G.currentRsa ~= OTSERV_RSA then return end
21 if host:ends('.tibia.com') or host:ends('.cipsoft.com') then
22 g_game.setRsa(CIPSOFT_RSA)
23
24 if g_app.getOs() == 'windows' then
25 g_game.setCustomOs(OsTypes.Windows)
26 else
27 g_game.setCustomOs(OsTypes.Linux)
28 end
29 else
30 if G.currentRsa == CIPSOFT_RSA then
31 g_game.setCustomOs(-1)
32 end
33 g_game.setRsa(OTSERV_RSA)
34 end
35
36 -- Hack fix to resolve some 760 login issues
37 if g_game.getClientVersion() <= 760 then
38 g_game.setCustomOs(2)
39 end
40end
41
42function g_game.setRsa(rsa, e)
43 e = e or '65537'
44 g_crypt.rsaSetPublicKey(rsa, e)
45 G.currentRsa = rsa
46end
47
48function g_game.isOfficialTibia()
49 return G.currentRsa == CIPSOFT_RSA
50end
51
52function g_game.getSupportedClients()
53 return {
54 740, 741, 750, 760, 770, 772,
55 780, 781, 782, 790, 792,
56
57 800, 810, 811, 820, 821, 822,
58 830, 831, 840, 842, 850, 853,
59 854, 855, 857, 860, 861, 862,
60 870, 871,
61
62 900, 910, 920, 931, 940, 943,
63 944, 951, 952, 953, 954, 960,
64 961, 963, 970, 971, 972, 973,
65 980, 981, 982, 983, 984, 985,
66 986,
67
68 1000, 1001, 1002, 1010, 1011,
69 1012, 1013, 1020, 1021, 1022,
70 1030, 1031, 1032, 1033, 1034,
71 1035, 1036, 1037, 1038, 1039,
72 1040, 1041, 1050, 1051, 1052,
73 1053, 1054, 1055, 1056, 1057,
74 1058, 1059, 1060, 1061, 1062,
75 1063, 1064, 1070, 1071, 1072,
76 1073, 1074, 1075, 1076, 1080,
77 1081, 1082, 1090, 1091, 1092,
78 1093, 1094, 1095, 1096, 1097,
79 1098, 1099
80 }
81end
82
83-- The client version and protocol version where
84-- unsynchronized for some releases, not sure if this
85-- will be the normal standard.
86
87-- Client Version: Publicly given version when
88-- downloading Cipsoft client.
89
90-- Protocol Version: Previously was the same as
91-- the client version, but was unsychronized in some
92-- releases, now it needs to be verified and added here
93-- if it does not match the client version.
94
95-- Reason for defining both: The server now requires a
96-- Client version and Protocol version from the client.
97
98-- Important: Use getClientVersion for specific protocol
99-- features to ensure we are using the proper version.
100
101function g_game.getClientProtocolVersion(client)
102 local clients = {
103 [980] = 971,
104 [981] = 973,
105 [982] = 974,
106 [983] = 975,
107 [984] = 976,
108 [985] = 977,
109 [986] = 978,
110 [1001] = 979,
111 [1002] = 980
112 }
113 return clients[client] or client
114end
115
116if not G.currentRsa then
117 g_game.setRsa(OTSERV_RSA)
118end
119