Skip to content

Commit

Permalink
Merge pull request #52 from sba5827/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sba5827 authored May 11, 2024
2 parents 5282748 + 6a16074 commit ecaf805
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 27 deletions.
26 changes: 18 additions & 8 deletions CommunicationHandler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function StriLi.CommunicationHandler:On_CHAT_MSG_ADDON(prefix, message, _, sende
elseif prefix == "SL_RS_UHS" then
self:On_Respond_UserHasStriLi(sender);
elseif prefix == "SL_VC" then
self:On_VersionCheck(message);
self:On_VersionCheck(message, sender);
elseif prefix == "SL_IHA" then
self:On_ItemHistoryAdd(message, sender);
elseif prefix == "SL_IHC" then
Expand Down Expand Up @@ -341,30 +341,40 @@ function StriLi.CommunicationHandler:checkIfUserHasStriLi(name, cbf)

end

function StriLi.CommunicationHandler:On_VersionCheck(transmittedVersion)
if tonumber(StriLi_LatestVersion) < tonumber(transmittedVersion) then
StriLi_LatestVersion = tonumber(transmittedVersion);
function StriLi.CommunicationHandler:On_VersionCheck(transmittedVersion, sender)

local vEncrypt = StriLi_StringToVersionEncrypt(transmittedVersion);

if StriLi_isEncryptedVersionValid(vEncrypt) then

if tonumber(StriLi_VersionEncryptToNumber(StriLi_LatestVersionEncrypt)) < StriLi_VersionEncryptToNumber(vEncrypt) then
StriLi_LatestVersionEncrypt = vEncrypt;
end
elseif StriLiOptions["ShowCorruptedVersions"] then
print(CONSTS.striLiMsgFlag..CONSTS.msgColorStringStart.."Received corrupted version from: "..sender..CONSTS.msgColorStringEnd);
end
end

function StriLi.CommunicationHandler:ShoutVersion()

if not StriLi_isEncryptedVersionValid(StriLi_LatestVersionEncrypt) then return end;

if GetNumRaidMembers() > 1 then

local _, instanceType = IsInInstance()

if instanceType == "pvp" then
SendAddonMessage("SL_VC", tostring(StriLi_LatestVersion), "BATTLEGROUND");
SendAddonMessage("SL_VC", StriLi_VersionEncryptToString(StriLi_LatestVersionEncrypt), "BATTLEGROUND");
else
SendAddonMessage("SL_VC", tostring(StriLi_LatestVersion), "RAID");
SendAddonMessage("SL_VC", StriLi_VersionEncryptToString(StriLi_LatestVersionEncrypt), "RAID");
end

elseif GetNumPartyMembers() > 0 then
SendAddonMessage("SL_VC", tostring(StriLi_LatestVersion), "PARTY");
SendAddonMessage("SL_VC", StriLi_VersionEncryptToString(StriLi_LatestVersionEncrypt), "PARTY");
end

if IsInGuild() then
SendAddonMessage("SL_VC", tostring(StriLi_LatestVersion), "GUILD");
SendAddonMessage("SL_VC", StriLi_VersionEncryptToString(StriLi_LatestVersionEncrypt), "GUILD");
end

end
Expand Down
3 changes: 2 additions & 1 deletion Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ function StriLi:OnInitialize()
end

------------------------------------------------------------------------------------------------------------------------------

StriLi.VersionEncrypt = { 95219, 65423, 112556, 8858, 160013, 104715, 39416 };
StriLi.Key = { n = 205889, d = 2633 };
StriLi.EventHandler:init();
9 changes: 7 additions & 2 deletions EventHandler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@ function StriLi.EventHandler:OnEvent(event, ...)

if event == "ADDON_LOADED" and arg1 == "StriLi" then
StriLi.startup = true;
print("|cff00ffffStriLi "..StriLi.Lang.version.." " .. GetAddOnMetadata("StriLi", "Version") .. " "..StriLi.Lang.loaded.."|r");
StriLi_initAddon();
StriLi.MainFrame:init();
StriLi.ItemHistory:initFromRawData(StriLi_ItemHistory);
StriLi.LootRules:init();
StriLi_OptionFrame_init();
if tonumber(StriLi_LatestVersion) > tonumber(GetAddOnMetadata("StriLi", "Version")) then
if StriLi_VersionEncryptToNumber(StriLi_LatestVersionEncrypt) > StriLi_VersionEncryptToNumber(StriLi.VersionEncrypt) then
local versionFrame = CreateFrame("FRAME", "StriLi_VersionFrame", UIParent, "StriLi_CopyVersionFrame_Template");
local editBox = versionFrame:GetChildren():GetChildren();
StriLi_VersionFrame_FontString:SetText();
Expand All @@ -41,6 +40,12 @@ function StriLi.EventHandler:OnEvent(event, ...)
delayedFunctionCall(20.0, function ()
self:OnPartyMembersChanged();
StriLi.startup = false;
print("|cff00ffffStriLi "..StriLi.Lang.version.." " .. StriLi_VersionEncryptToNumber(StriLi.VersionEncrypt) .. " "..StriLi.Lang.loaded.."|r");
if (not StriLi_isVersionValid(StriLi.VersionEncrypt)) then
print("|cff00ffff ".."This does not seem like a valid version of StriLi. Checkout https://github.com/sba5827/StriLi.")
else
print("|cff00ffff ".."This does seem like a valid version of StriLi.")
end
end)
elseif event == "PARTY_MEMBERS_CHANGED" or event == "PARTY_MEMBER_DISABLE" or event == "PARTY_MEMBER_ENABLE" then
self:OnPartyMembersChanged();
Expand Down
1 change: 1 addition & 0 deletions Lang/Language.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ StriLi.Lang = {
TokenSec = "Token sec list.",
IgnoreGroup = "Ignore group",
WhisperTallyMarks = "Strichliste an Raid member flüstern wenn du per Whisper gefragt wirst?",
ShowCorruptedVersions = "Anzeigen, wer eine invalide StriLiVersion hat.",
},
Tooltip = {
rightClickText = "|cffff0000RightClick|r Open/Close ItemHistory",
Expand Down
1 change: 1 addition & 0 deletions Lang/deDE.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function StriLi_Stub_deDE() return {
TokenSec = "Token Sec Liste.",
IgnoreGroup = "Gruppe ignorieren",
WhisperTallyMarks = "Strichliste an Raid member flüstern wenn du per Whisper gefragt wirst?",
ShowCorruptedVersions = "Anzeigen, wer eine invalide StriLiVersion hat.",
},
Tooltip = {
rightClickText = "|cffff0000RechtsKlick|r Öffnet/Schließt ItemHistory",
Expand Down
1 change: 1 addition & 0 deletions Lang/enGB.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function StriLi_Stub_enGB() return {
TokenSec = "Token sec list.",
IgnoreGroup = "Ignore group",
WhisperTallyMarks = "Whispering a tally list to raid members when asked via whisper?",
ShowCorruptedVersions = "Display who has an invalid StriLi version.",
},
Tooltip = {
rightClickText = "|cffff0000RightClick|r Open/Close ItemHistory",
Expand Down
1 change: 1 addition & 0 deletions Lang/esES.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function StriLi_Stub_esES() return {
TokenSec = "Lista Token sec.",
IgnoreGroup = "Ignorar grupo",
WhisperTallyMarks = "¿Susurrar una lista de recuento a los miembros de la incursión cuando se les pide por susurro?",
ShowCorruptedVersions = "Mostrar quién tiene una versión StriLi no válida.",
},
Tooltip = {
rightClickText = "|cffff0000RightClick|r Open/Close ItemHistory",
Expand Down
14 changes: 14 additions & 0 deletions OptionsFrame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ function StriLi_OptionFrame_init()
local fsWhisperTallyMarks = optionFrame:CreateFontString("ARTWORK", nil, "GameFontNormal")
fsWhisperTallyMarks:SetPoint("TOPLEFT", 60, -85)
fsWhisperTallyMarks:SetText(StriLi.Lang.Options.WhisperTallyMarks);

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
local checkBoxCorruptedVersion = CreateFrame("CheckButton", nil, optionFrame, "ChatConfigCheckButtonTemplate")
checkBoxCorruptedVersion:SetPoint("TOPLEFT", 30, -160);

if StriLiOptions["ShowCorruptedVersions"] then checkBoxCorruptedVersion:SetChecked(true) end
checkBoxCorruptedVersion:SetScript("OnClick",
function(this, _, _)
StriLiOptions["ShowCorruptedVersions"] = this:GetChecked();
end);

local fsCorruptedVersion = optionFrame:CreateFontString("ARTWORK", nil, "GameFontNormal")
fsCorruptedVersion:SetPoint("TOPLEFT", 60, -165)
fsCorruptedVersion:SetText(StriLi.Lang.Options.ShowCorruptedVersions);
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

local fsIgnoreGroup = optionFrame:CreateFontString("ARTWORK", nil, "GameFontNormal")
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This Addon was developed for WoW version 3.3.5a WotLK. No guarantee that it will work with other versions.

## How to Install
Download the latest [release](https://github.com/sba5827/StriLi/releases/tag/3.17). Unzip the folder to your WoW Addons folder. Eg.:
Download the latest [release](https://github.com/sba5827/StriLi/releases/tag/3.18). Unzip the folder to your WoW Addons folder. Eg.:

C:\Users\USERNAME\..\WoW\Interface\AddOns\

Expand All @@ -14,7 +14,7 @@ Make sure that the folder name of the unzipped folder is StriLi, otherwise the a

And **NOT** like:

C:\Users\USERNAME\..\WoW\Interface\AddOns\StriLi-3.17
C:\Users\USERNAME\..\WoW\Interface\AddOns\StriLi-3.18

Example Screenshot:
![Screenshot_README](https://user-images.githubusercontent.com/38493688/200170842-d6c7f710-3bb1-491a-9796-1b8fb252d9c7.PNG)
Expand Down Expand Up @@ -62,7 +62,7 @@ Examples:
Dieses Add-on wurde für WoW Version 3.3.5a WotLK entwickelt. Es gibt keine Garantie, dass es mit anderen Versionen funktioniert.

## Wie man es installiert
Laden Sie die neueste [Version](https://github.com/sba5827/StriLi/releases/tag/3.17) herunter. Entpacken Sie den Ordner in Ihren WoW Add-ons Ordner. z.B.:
Laden Sie die neueste [Version](https://github.com/sba5827/StriLi/releases/tag/3.18) herunter. Entpacken Sie den Ordner in Ihren WoW Add-ons Ordner. z.B.:

C:\Users\USERNAME\..\WoW\Interface\AddOns\

Expand All @@ -72,7 +72,7 @@ Achten Sie darauf, dass der Ordnername des entpackten Ordners StriLi lautet, son

Und **NICHT** wie:

C:\Benutzer\USERNAME\..\WoW\Interface\AddOns\StriLi-3.17
C:\Benutzer\USERNAME\..\WoW\Interface\AddOns\StriLi-3.18

Beispiel Screenshot:
![Screenshot_README](https://user-images.githubusercontent.com/38493688/200170842-d6c7f710-3bb1-491a-9796-1b8fb252d9c7.PNG)
Expand Down
4 changes: 2 additions & 2 deletions StriLi.toc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
## OptionalDeps: Ace3, LibSharedMedia-3.0, AceGUI-3.0-SharedMediaWidgets, LibSink-2.0, LibDBIcon-1.0
## Notes: Supports Lootmaster in the standard loot system via tally sheets by providing an in-game tally sheet and automated roll detection. For info about commands /sl help. For more information visit the StriLi github page.
## SavedVariablesPerCharacter:
## SavedVariables: StriLi_Master, StriLi_LatestVersion, StriLi_RaidMembersDB_members, StriLi_newRaidGroup, StriLi_ItemHistory, StriLi_RulesTxt, StriLiOptions, StriLiDB
## Version: 3.17
## SavedVariables: StriLi_Master, StriLi_LatestVersionEncrypt, StriLi_RaidMembersDB_members, StriLi_newRaidGroup, StriLi_ItemHistory, StriLi_RulesTxt, StriLiOptions, StriLiDB
## Version: 3.18

#@no-lib-strip@
Libs\LibStub\LibStub.lua
Expand Down
151 changes: 141 additions & 10 deletions UtilityFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,100 @@ CONSTS = protect({
striLiMsgFlag = "|cffFFFF00<|r|cff33FFF2StriLi|r|cffFFFF00>|r ",
});

-- Funktion zum Modulo-Berechnung
function StriLi_mod(a, b)
local result = a % b
if result < 0 then
result = result + b
end
return result
end

-- Funktion zum Exponieren modulo
function StriLi_pow_mod(base, exponent, modulus)
local result = 1
for i = 1, exponent do
result = StriLi_mod(result * base, modulus)
end
return result
end

-- Funktion zum Entschlüsseln einer Nachricht mit dem Key
function StriLi_decrypt(encrypted_message)
-- Entschlüsseln jedes Zahlenwerts mit dem Key
local decrypted_message = {}
for i = 1, #encrypted_message do
local decrypted_number = StriLi_pow_mod(encrypted_message[i], StriLi.Key.d, StriLi.Key.n)
decrypted_message[i] = decrypted_number
end

-- Konvertieren der numerischen Werte zurück in die Nachricht
local message = ""; -- Konvertierung der Zahlen in Zeichen
for i = 1, #decrypted_message do
if (decrypted_message[i] < 255) then
message = message..string.char(decrypted_message[i]);
else
return "false";
end
end

-- Rückgabe der entschlüsselten Nachricht
return message
end

function StriLi_crc8(t)
local c = 0
for _, b in ipairs(t) do
for i = 0, 7 do
local c0 = c % 2
local b0 = b % 2
c = (c - c0) / 2
b = (b - b0) / 2
if c0 + b0 == 1 then
c = c + 0x80 + (c % 16 < 8 and 8 or -8) + (c % 8 < 4 and 4 or -4)
end
end
end
return c
end

function StriLi_isEncryptedVersionValid(versionTable)

local bValidVersion = true;

local sDecrypt = StriLi_decrypt(versionTable);

if not(string.sub(sDecrypt, 1, 1) == "S") then
bValidVersion = false;
end

if not(string.sub(sDecrypt, 2, 2) == "L") then
bValidVersion = false;
end

local crc = string.char(StriLi_crc8({string.byte(sDecrypt, 1,6)}));

if not(crc == string.sub(sDecrypt, 7,7)) then
bValidVersion = false;
end

return bValidVersion;

end

function StriLi_isVersionValid(versionTable)

local bValidVersion = StriLi_isEncryptedVersionValid(versionTable);
local sDecrypt = StriLi_decrypt(versionTable);

if (not(tonumber(string.sub(sDecrypt,3, 6)) == tonumber(GetAddOnMetadata("StriLi", "Version")))) then
bValidVersion = false;
end

return bValidVersion;

end

function StriLi_isPlayerMaster()
return StriLi.master:get() == UnitName("player");
end
Expand Down Expand Up @@ -248,18 +342,12 @@ function StriLi_initAddon()

StriLi.InitLang()

local addonVersion = tonumber(GetAddOnMetadata("StriLi", "Version"));

if StriLi_LatestVersion ~= nil then
--Secure that StriLi_LatestVersion will never be a String.
StriLi_LatestVersion = tonumber(StriLi_LatestVersion);
if StriLi_LatestVersionEncrypt == nil then
StriLi_LatestVersionEncrypt = StriLi.VersionEncrypt;
elseif StriLi_VersionEncryptToNumber(StriLi_LatestVersionEncrypt) < StriLi_VersionEncryptToNumber(StriLi.VersionEncrypt) then
StriLi_LatestVersionEncrypt = StriLi.VersionEncrypt;
end

if StriLi_LatestVersion == nil then
StriLi_LatestVersion = addonVersion;
elseif StriLi_LatestVersion < addonVersion then
StriLi_LatestVersion = addonVersion;
end
if StriLi_Master == nil then
StriLi.master = ObservableString:new();
StriLi.master:set("");
Expand All @@ -284,13 +372,15 @@ function StriLi_initAddon()
["AutoPromote"] = false,
["TokenSecList"] = false,
["WhisperTallyMarks"] = true,
["ShowCorruptedVersions"] = false;
};
elseif StriLiOptions.AutoPromote == nil then
StriLiOptions.AutoPromote = false;
elseif StriLiOptions.TokenSecList == nil then
StriLiOptions.TokenSecList = false
elseif StriLiOptions.WhisperTallyMarks == nil then
StriLiOptions.WhisperTallyMarks = true;
elseif StriLiOptions.ShowCorruptedVersions == nil then
end

StriLi.LootRules:setText(StriLi_RulesTxt);
Expand Down Expand Up @@ -330,4 +420,45 @@ function delayedFunctionCall(delay_s, functionToCall)
timerFrame:SetScript("OnUpdate", nil);
end
end)
end

function StriLi_VersionEncryptToString(t)
if type(t) ~= "table" then return nil end;

local sResult = "";
for i = 1, #t do
sResult = sResult..tostring(t[i])..",";
end

return sResult;
end

function StriLi_StringToVersionEncrypt(s)
if type(s) ~= "string" then return nil end;
local tResult = {};

local sTemp = "";

for i = 1, string.len(s) do
if string.sub(s,i,i) ~= "," then
sTemp = sTemp..string.sub(s,i,i);
else
table.insert(tResult, tonumber(sTemp));
sTemp = "";
end
end

return tResult;
end

function StriLi_VersionEncryptToNumber(t)
if type(t) ~= "table" then return nil end;

local nResult = 0.0;

if StriLi_isEncryptedVersionValid(t) then
nResult = tonumber(string.sub(StriLi_decrypt(t),3,6));
end

return nResult;
end

0 comments on commit ecaf805

Please sign in to comment.