No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

game.lua 2.9KB

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