Dateien nach "/" hochladen
This commit is contained in:
@@ -0,0 +1,230 @@
|
||||
-- Freewood-OctoWoW-Codex: Verkehrsverbindungen (Schiff, Zeppelin, U-Bahn, Portal)
|
||||
--
|
||||
-- Berechtigte (Modul Freewood-OctoWoW-Dev, Rolle Bearbeiter oder hoeher) erfassen Verbindungen: Start hier, Fahrt, Ziel hier,
|
||||
-- die Fahrzeit wird gemessen. Gespeichert wird in db.transport[id] und ueber das normale Teilen als Datensatz "g<ID>"
|
||||
-- verschickt; angenommen werden sie nur von Absendern, die selbst berechtigt sind.
|
||||
--
|
||||
-- db.transport[id] = { k = Art, f = "A" | "H" | nil, n = Name, t = Sekunden, a = { m, x, y }, b = { m, x, y },
|
||||
-- two = Rueckfahrt moeglich, del = geloescht, upd = Stand }
|
||||
-- Die ID ist ein Pruefwert aus Art, Fraktion und beiden Orten: derselbe Weg, von zwei Berechtigten erfasst, ergibt denselben Datensatz.
|
||||
|
||||
local ADDON, NS = ...
|
||||
|
||||
local FW = _G.Freewood
|
||||
local Codex = NS and NS.Codex
|
||||
if not FW or not Codex then
|
||||
return
|
||||
end
|
||||
|
||||
local Transport = { draft = {} }
|
||||
Codex.Transport = Transport
|
||||
NS.Transport = Transport
|
||||
|
||||
Transport.KINDS = { "boat", "zeppelin", "subway", "portal" }
|
||||
local KIND_OK = {}
|
||||
for _, k in ipairs(Transport.KINDS) do KIND_OK[k] = true end
|
||||
|
||||
local function Now() return _G.time and _G.time() or 0 end
|
||||
|
||||
local function DB()
|
||||
local db = Codex.db
|
||||
if not db then return nil end
|
||||
db.transport = db.transport or {}
|
||||
return db
|
||||
end
|
||||
|
||||
local function CanEdit()
|
||||
return Codex.Trust ~= nil and Codex.Trust.CanEdit()
|
||||
end
|
||||
|
||||
local function Round(v, f) return math.floor(v * f + 0.5) end
|
||||
|
||||
local function Hash(text)
|
||||
local h = 5381
|
||||
for i = 1, #text do h = (h * 33 + text:byte(i)) % 99999989 end
|
||||
return h
|
||||
end
|
||||
|
||||
-- Pruefwert (0..99999988) aus Art, Fraktion und den auf etwa 0,5 % gerundeten Orten
|
||||
function Transport.Id(rec)
|
||||
local a, b = rec.a or {}, rec.b or {}
|
||||
return Hash(table.concat({ tostring(rec.k), tostring(rec.f or "-"), tostring(a.m), Round(a.x or 0, 200), Round(a.y or 0, 200),
|
||||
tostring(b.m), Round(b.x or 0, 200), Round(b.y or 0, 200) }, "|"))
|
||||
end
|
||||
|
||||
-- Aktueller Ort { m, x, y } oder nil
|
||||
function Transport.Here()
|
||||
local loc = FW.Util and FW.Util.GetPlayerLocation and FW.Util.GetPlayerLocation()
|
||||
if loc and loc.mapID and loc.x and loc.y then
|
||||
return { m = loc.mapID, x = math.floor(loc.x * 10000 + 0.5) / 10000, y = math.floor(loc.y * 10000 + 0.5) / 10000 }
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function Clock() return _G.GetTime and _G.GetTime() or 0 end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- Erfassen (Entwurf)
|
||||
------------------------------------------------------------------------
|
||||
|
||||
function Transport.Draft()
|
||||
return Transport.draft
|
||||
end
|
||||
|
||||
function Transport.Reset()
|
||||
local d = Transport.draft
|
||||
d.a, d.b, d.t0, d.t = nil, nil, nil, nil
|
||||
FW:Fire("CODEX_TRANSPORT_DRAFT")
|
||||
end
|
||||
|
||||
function Transport.Start()
|
||||
local here = Transport.Here()
|
||||
if not here then return false end
|
||||
local d = Transport.draft
|
||||
d.a, d.b, d.t = here, nil, nil
|
||||
d.t0 = Clock()
|
||||
FW:Fire("CODEX_TRANSPORT_DRAFT")
|
||||
return true
|
||||
end
|
||||
|
||||
function Transport.Finish()
|
||||
local d = Transport.draft
|
||||
if not d.a or not d.t0 then return false end
|
||||
local here = Transport.Here()
|
||||
if not here then return false end
|
||||
d.b = here
|
||||
d.t = math.max(1, math.floor(Clock() - d.t0 + 0.5))
|
||||
FW:Fire("CODEX_TRANSPORT_DRAFT")
|
||||
return true
|
||||
end
|
||||
|
||||
-- Laeuft gerade eine Aufnahme (Start gesetzt, Ziel noch nicht)? Dann zeichnet das Wegenetz nicht mit.
|
||||
function Transport.Recording()
|
||||
local d = Transport.draft
|
||||
return d.a ~= nil and d.b == nil and d.t0 ~= nil
|
||||
end
|
||||
|
||||
function Transport.SetDraft(key, value)
|
||||
Transport.draft[key] = value
|
||||
end
|
||||
|
||||
-- Entwurf pruefen. Rueckgabe: true oder false, Grund
|
||||
function Transport.CheckDraft()
|
||||
local d = Transport.draft
|
||||
if not d.a then return false, "start" end
|
||||
if not d.b or not d.t then return false, "finish" end
|
||||
if not KIND_OK[d.kind or "boat"] then return false, "kind" end
|
||||
if d.a.m == d.b.m and math.abs(d.a.x - d.b.x) < 0.005 and math.abs(d.a.y - d.b.y) < 0.005 then return false, "same" end
|
||||
return true
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- Speichern und Loeschen
|
||||
------------------------------------------------------------------------
|
||||
|
||||
local function Touch(id)
|
||||
if Codex.Share and Codex.Share.InvalidateScan then Codex.Share.InvalidateScan() end
|
||||
Transport.rev = (Transport.rev or 0) + 1
|
||||
FW:Fire("CODEX_TRANSPORT_CHANGED", id)
|
||||
FW:Fire("CODEX_CHANGED", "transport", id)
|
||||
end
|
||||
|
||||
local function Log(id, field, old, new)
|
||||
if Codex.DevLog then
|
||||
pcall(Codex.DevLog, { who = Codex.Trust and Codex.Trust.SelfKey() or "?", kind = "g", id = id, field = field, old = old, new = new })
|
||||
end
|
||||
end
|
||||
|
||||
local function Describe(rec)
|
||||
local M = Codex.MapName
|
||||
return string.format("%s: %s -> %s (%ds)", tostring(rec.k), M and M(rec.a.m) or rec.a.m, M and M(rec.b.m) or rec.b.m, rec.t or 0)
|
||||
end
|
||||
|
||||
-- Speichert den Entwurf. Rueckgabe: id oder nil, Grund
|
||||
function Transport.Save()
|
||||
if not CanEdit() then return nil, "rights" end
|
||||
local ok, why = Transport.CheckDraft()
|
||||
if not ok then return nil, why end
|
||||
local d = Transport.draft
|
||||
local rec = {
|
||||
k = d.kind or "boat", f = (d.faction == "A" or d.faction == "H") and d.faction or nil,
|
||||
n = type(d.name) == "string" and d.name:sub(1, 40) ~= "" and d.name:sub(1, 40) or nil,
|
||||
t = d.t, a = { m = d.a.m, x = d.a.x, y = d.a.y }, b = { m = d.b.m, x = d.b.x, y = d.b.y },
|
||||
two = d.two ~= false, upd = Now(),
|
||||
}
|
||||
local db = DB()
|
||||
local id = Transport.Id(rec)
|
||||
local old = db.transport[id]
|
||||
rec.upd = math.max(rec.upd, (old and old.upd or 0) + 1)
|
||||
db.transport[id] = rec
|
||||
Log(id, "add", old and not old.del and Describe(old) or nil, Describe(rec))
|
||||
Touch(id)
|
||||
Transport.Reset()
|
||||
return id
|
||||
end
|
||||
|
||||
function Transport.Delete(id)
|
||||
if not CanEdit() then return false end
|
||||
local db = DB()
|
||||
local own = db.transport[id]
|
||||
local rec = own
|
||||
if not rec then
|
||||
for _, r in ipairs(Transport.All(true)) do
|
||||
if r.id == id then rec = r break end
|
||||
end
|
||||
end
|
||||
if not rec then return false end
|
||||
local del = { k = rec.k, f = rec.f, n = rec.n, t = rec.t, a = rec.a, b = rec.b, two = rec.two, del = true,
|
||||
upd = math.max(Now(), (rec.upd or 0) + 1) }
|
||||
db.transport[id] = del
|
||||
Log(id, "del", Describe(rec), nil)
|
||||
Touch(id)
|
||||
return true
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- Lesen: eigene und empfangene Verbindungen
|
||||
------------------------------------------------------------------------
|
||||
|
||||
-- Liste { id, k, f, n, t, a, b, two, upd }, je ID der neueste Stand; geloeschte nur mit withDeleted
|
||||
function Transport.All(withDeleted)
|
||||
local best = {}
|
||||
local db = DB()
|
||||
if not db then return {} end
|
||||
for id, rec in pairs(db.transport) do
|
||||
if type(rec) == "table" and rec.a and rec.b then best[id] = rec end
|
||||
end
|
||||
if Codex.Share and Codex.Share.RemoteRecords then
|
||||
for _, rec in ipairs(Codex.Share.RemoteRecords("g")) do
|
||||
local cur = best[rec.id]
|
||||
if not cur or (rec.upd or 0) > (cur.upd or 0) then best[rec.id] = rec end
|
||||
end
|
||||
end
|
||||
local out = {}
|
||||
for id, rec in pairs(best) do
|
||||
if withDeleted or not rec.del then
|
||||
out[#out + 1] = { id = id, k = rec.k, f = rec.f, n = rec.n, t = rec.t, a = rec.a, b = rec.b, two = rec.two ~= false, upd = rec.upd, del = rec.del }
|
||||
end
|
||||
end
|
||||
table.sort(out, function(x, y)
|
||||
if x.k ~= y.k then return x.k < y.k end
|
||||
return x.id < y.id
|
||||
end)
|
||||
return out
|
||||
end
|
||||
|
||||
-- Fahrten als gerichtete Kanten { id, k, t, from = { m, x, y }, to = { m, x, y } }; faction = "A" | "H" | nil (alle)
|
||||
function Transport.Edges(faction)
|
||||
local out = {}
|
||||
for _, r in ipairs(Transport.All()) do
|
||||
if not (faction and r.f and r.f ~= faction) then
|
||||
out[#out + 1] = { id = r.id, k = r.k, t = r.t, from = r.a, to = r.b, name = r.n }
|
||||
if r.two then out[#out + 1] = { id = r.id, k = r.k, t = r.t, from = r.b, to = r.a, name = r.n } end
|
||||
end
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
function Transport.Count()
|
||||
return #Transport.All()
|
||||
end
|
||||
+309
@@ -0,0 +1,309 @@
|
||||
-- Freewood-OctoWoW-Codex: Berechtigungen (wer darf Daten fuer alle bearbeiten?)
|
||||
--
|
||||
-- Rollen:
|
||||
-- owner steht in CodexOwners.lua, darf die Liste veroeffentlichen
|
||||
-- moderator darf Namen aendern, Datensaetze als fehlerhaft markieren und fremde Markierungen aufheben
|
||||
-- editor darf Namen aendern und Datensaetze als fehlerhaft markieren
|
||||
-- blocked gesperrt: nichts wird mehr von diesem Charakter uebernommen
|
||||
--
|
||||
-- Die Liste (Charakter -> Rolle) kommt von einem Eigentuemer ueber den Kanal (Nachricht "T"). Der Absender einer
|
||||
-- Addon-Nachricht wird vom Spiel gesetzt; Listen anderer Absender werden ignoriert.
|
||||
-- Battle.net-Namen und Notizen bleiben beim Eigentuemer (Modul Freewood-OctoWoW-Rechte) und werden nie verschickt.
|
||||
-- Bearbeiten (Namen, Markierungen) geht nur, wenn zusaetzlich das Modul Freewood-OctoWoW-Dev vorhanden ist.
|
||||
|
||||
local ADDON, NS = ...
|
||||
|
||||
local FW = _G.Freewood
|
||||
local Codex = NS and NS.Codex
|
||||
if not FW or not Codex then
|
||||
return
|
||||
end
|
||||
|
||||
local Trust = { buffers = {} }
|
||||
NS.Trust = Trust
|
||||
Codex.Trust = Trust
|
||||
|
||||
local MAX_ENTRIES = 150
|
||||
local ROLE_CODE = { editor = "e", moderator = "m", blocked = "b" }
|
||||
local CODE_ROLE = { e = "editor", m = "moderator", b = "blocked" }
|
||||
Trust.ROLES = { "editor", "moderator", "blocked" }
|
||||
|
||||
local ACTIONS = {
|
||||
editor = { name = true, bad = true, export = true },
|
||||
moderator = { name = true, bad = true, unbad = true, export = true },
|
||||
}
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- Namen
|
||||
------------------------------------------------------------------------
|
||||
|
||||
local function Core(name)
|
||||
if type(name) ~= "string" then return "" end
|
||||
local n = name:gsub("\194\160", " "):match("^([^%-]*)") or ""
|
||||
return (n:gsub("%s", ""):lower())
|
||||
end
|
||||
|
||||
local function RealmPart(name)
|
||||
local r = type(name) == "string" and name:match("%-(.+)$")
|
||||
if r then
|
||||
r = r:gsub("[%s%-']", ""):lower()
|
||||
if r ~= "" then return r end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
local function OwnRealm()
|
||||
local r = (GetNormalizedRealmName and GetNormalizedRealmName()) or (GetRealmName and GetRealmName()) or ""
|
||||
return (tostring(r):gsub("[%s%-']", ""):lower())
|
||||
end
|
||||
|
||||
-- Der eigene Realm hat im Spiel mehrere Schreibweisen (z.B. GetNormalizedRealmName = "ClassicBetaPvP2",
|
||||
-- UnitFullName liefert "Steel"). Alle gelten als derselbe Realm und werden auf OwnRealm() vereinheitlicht.
|
||||
local function IsOwnRealmVariant(r)
|
||||
if r == OwnRealm() then return true end
|
||||
local variants = {}
|
||||
if GetRealmName then variants[#variants + 1] = GetRealmName() end
|
||||
if UnitFullName then
|
||||
local ok, _, ur = pcall(UnitFullName, "player")
|
||||
if ok then variants[#variants + 1] = ur end
|
||||
end
|
||||
for _, v in ipairs(variants) do
|
||||
if type(v) == "string" and v:gsub("[%s%-']", ""):lower() == r then return true end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- "name-realm" in Kleinschreibung; ohne Realm gilt der eigene
|
||||
function Trust.Key(name)
|
||||
local core = Core(name)
|
||||
if core == "" then return nil end
|
||||
local realm = RealmPart(name)
|
||||
if not realm or IsOwnRealmVariant(realm) then realm = OwnRealm() end
|
||||
return core .. "-" .. realm
|
||||
end
|
||||
|
||||
-- Eintrag aus einer Liste oder von Hand getippt: "Name" (gilt fuer den eigenen Realm) oder "Name-Realm"
|
||||
-- (z.B. "Fwaroki-NZoth"). Auf OctoWoW gibt es nur einen Namen, keinen Nachnamen: ein Bindestrich trennt den Realm ab.
|
||||
function Trust.EntryKey(name)
|
||||
if type(name) ~= "string" then return nil end
|
||||
local clean = name:gsub("\194\160", " "):gsub("^%s+", ""):gsub("%s+$", "")
|
||||
return Trust.Key(clean)
|
||||
end
|
||||
|
||||
-- Eigener voller Name (OctoWoW: nur ein Name; der zweite Rueckgabewert von UnitFullName ist der Realm, kein Nachname)
|
||||
function Trust.SelfKey()
|
||||
local name
|
||||
if UnitFullName then
|
||||
local ok, n = pcall(UnitFullName, "player")
|
||||
if ok then name = n end
|
||||
end
|
||||
if not name and UnitName then name = (UnitName("player")) end
|
||||
if not name then return nil end
|
||||
return Trust.Key(name)
|
||||
end
|
||||
|
||||
local function Data()
|
||||
local db = Codex.db
|
||||
if not db then return { rev = 0, list = {} } end
|
||||
db.trust = db.trust or { rev = 0, list = {} }
|
||||
db.trust.list = db.trust.list or {}
|
||||
return db.trust
|
||||
end
|
||||
|
||||
local function OwnerKeys()
|
||||
local set = {}
|
||||
for _, n in ipairs(NS.Owners or {}) do
|
||||
local k = Trust.EntryKey(n)
|
||||
if k then set[k] = true end
|
||||
end
|
||||
return set
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- Abfragen
|
||||
------------------------------------------------------------------------
|
||||
|
||||
local function ModeratorKeys()
|
||||
local set = {}
|
||||
for _, n in ipairs(NS.Moderators or {}) do
|
||||
local k = Trust.EntryKey(n)
|
||||
if k then set[k] = true end
|
||||
end
|
||||
return set
|
||||
end
|
||||
|
||||
function Trust.IsOwner(name)
|
||||
local k = Trust.Key(name)
|
||||
return k ~= nil and OwnerKeys()[k] == true
|
||||
end
|
||||
|
||||
function Trust.IsSelfOwner()
|
||||
return Trust.IsOwner(Trust.SelfKey())
|
||||
end
|
||||
|
||||
-- Rolle: "owner", "moderator", "editor", "blocked" oder nil
|
||||
function Trust.RoleOf(name)
|
||||
local k = Trust.Key(name)
|
||||
if not k then return nil end
|
||||
local entry = Data().list[k]
|
||||
if entry and entry.role == "blocked" then return "blocked" end
|
||||
if OwnerKeys()[k] then return "owner" end
|
||||
if ModeratorKeys()[k] then return "moderator" end
|
||||
return entry and entry.role or nil
|
||||
end
|
||||
|
||||
function Trust.IsDev(name)
|
||||
local r = Trust.RoleOf(name)
|
||||
return r == "owner" or r == "moderator" or r == "editor"
|
||||
end
|
||||
|
||||
function Trust.SelfRole()
|
||||
-- OctoWoW-Test: Bypass der Berechtigungsliste (FW.OCTO.testBypass in Freewood-OctoWoW-Core/Core/Init.lua)
|
||||
if FW.OCTO and FW.OCTO.testBypass then return "owner" end
|
||||
return Trust.RoleOf(Trust.SelfKey())
|
||||
end
|
||||
|
||||
-- Darf dieser Charakter eine Aktion ausfuehren? Aktion: name, bad, unbad, export. Braucht das Modul Freewood-OctoWoW-Dev.
|
||||
function Trust.Can(action)
|
||||
if not Codex.DevModule then return false end
|
||||
if FW.OCTO and FW.OCTO.testBypass then return true end -- OctoWoW-Test
|
||||
local role = Trust.SelfRole()
|
||||
if role == "owner" then return true end
|
||||
local a = role and ACTIONS[role]
|
||||
return a ~= nil and a[action] == true
|
||||
end
|
||||
|
||||
function Trust.CanEdit()
|
||||
return Trust.Can("name")
|
||||
end
|
||||
|
||||
function Trust.Revision()
|
||||
return Data().rev or 0
|
||||
end
|
||||
|
||||
function Trust.Entries()
|
||||
local out = {}
|
||||
for key, e in pairs(Data().list) do
|
||||
out[#out + 1] = { key = key, role = e.role }
|
||||
end
|
||||
table.sort(out, function(a, b) return a.key < b.key end)
|
||||
return out
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- Liste setzen und verschicken
|
||||
------------------------------------------------------------------------
|
||||
|
||||
local function Changed()
|
||||
if Codex.Share and Codex.Share.TrustChanged then Codex.Share.TrustChanged() end
|
||||
FW:Fire("CODEX_TRUST_CHANGED")
|
||||
FW:Fire("CODEX_CHANGED", "trust")
|
||||
end
|
||||
|
||||
-- entries: Liste { key, role }
|
||||
function Trust.SetList(entries, rev)
|
||||
local d = Data()
|
||||
local list = {}
|
||||
local n = 0
|
||||
for _, e in ipairs(entries or {}) do
|
||||
local key = Trust.Key(e.key)
|
||||
if key and ROLE_CODE[e.role] and n < MAX_ENTRIES then
|
||||
list[key] = { role = e.role }
|
||||
n = n + 1
|
||||
end
|
||||
end
|
||||
d.list = list
|
||||
d.rev = rev or math.max((d.rev or 0) + 1, time and time() or 1) -- Zeitstempel: bleibt auch nach einem Zuruecksetzen steigend
|
||||
d.stamp = time and time() or 0
|
||||
Changed()
|
||||
return d.rev
|
||||
end
|
||||
|
||||
-- Nachrichten "T|rev|i/n|text" (Eintraege "name-realm,e;name-realm,m;...")
|
||||
function Trust.Chunks()
|
||||
local d = Data()
|
||||
local parts = {}
|
||||
for _, e in ipairs(Trust.Entries()) do
|
||||
local key = e.key:gsub("[;,|]", "")
|
||||
parts[#parts + 1] = key .. "," .. ROLE_CODE[e.role]
|
||||
end
|
||||
local chunks, cur = {}, ""
|
||||
for _, p in ipairs(parts) do
|
||||
if #cur + #p + 1 > 190 then
|
||||
chunks[#chunks + 1] = cur
|
||||
cur = ""
|
||||
end
|
||||
cur = cur .. (cur ~= "" and ";" or "") .. p
|
||||
end
|
||||
chunks[#chunks + 1] = cur
|
||||
local out = {}
|
||||
for i, c in ipairs(chunks) do
|
||||
out[i] = string.format("T|%d|%d/%d|%s", d.rev or 0, i, #chunks, c)
|
||||
end
|
||||
return out
|
||||
end
|
||||
|
||||
local function Parse(payload)
|
||||
local list = {}
|
||||
for item in (payload .. ";"):gmatch("([^;]*);") do
|
||||
local key, code = item:match("^(.-),([emb])$")
|
||||
if key and key ~= "" then
|
||||
list[#list + 1] = { key = key, role = CODE_ROLE[code] }
|
||||
end
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
-- Empfang: nur von Eigentuemern. body = "rev|i/n|text". Rueckgabe: true, wenn eine neue Liste uebernommen wurde
|
||||
function Trust.Receive(sender, body)
|
||||
if not Trust.IsOwner(sender) then return false end
|
||||
local rev, i, n, payload = tostring(body):match("^(%d+)|(%d+)/(%d+)|(.*)$")
|
||||
rev, i, n = tonumber(rev), tonumber(i), tonumber(n)
|
||||
if not rev or not i or not n or n < 1 or n > 12 or i < 1 or i > n then return false end
|
||||
local d = Data()
|
||||
if rev <= (d.rev or 0) then return false end -- aelter oder schon vorhanden
|
||||
local key = Trust.Key(sender)
|
||||
local buf = Trust.buffers[key]
|
||||
if not buf or buf.rev ~= rev or buf.n ~= n then
|
||||
buf = { rev = rev, n = n, parts = {}, got = 0 }
|
||||
Trust.buffers[key] = buf
|
||||
end
|
||||
if not buf.parts[i] then
|
||||
buf.parts[i] = payload
|
||||
buf.got = buf.got + 1
|
||||
end
|
||||
if buf.got < n then return false end
|
||||
Trust.buffers[key] = nil
|
||||
local all = {}
|
||||
for idx = 1, n do all[#all + 1] = buf.parts[idx] end
|
||||
Trust.SetList(Parse(table.concat(all, ";")), rev)
|
||||
return true
|
||||
end
|
||||
|
||||
------------------------------------------------------------------------
|
||||
-- Diagnose: /fwrolle
|
||||
------------------------------------------------------------------------
|
||||
|
||||
SLASH_FREEWOODROLE1 = "/fwrolle"
|
||||
SlashCmdList["FREEWOODROLE"] = function()
|
||||
local d = Data()
|
||||
local n = 0
|
||||
for _ in pairs(d.list) do n = n + 1 end
|
||||
local L = FW.L
|
||||
FW:Print(string.format(L.CODEX_ROLE_INFO, tostring(Trust.SelfKey()), tostring(Trust.SelfRole() or "-"),
|
||||
Codex.DevModule and L.CODEX_YES or L.CODEX_NO, n, d.rev or 0))
|
||||
-- Ausfuehrliche Diagnose: was liefert das Spiel, und welche Schluessel stehen in der Eigentuemer-Liste?
|
||||
local ok, un, ur = false, nil, nil
|
||||
if UnitFullName then ok, un, ur = pcall(UnitFullName, "player") end
|
||||
FW:Print(string.format("Rolle: UnitFullName = %s | %s, UnitName = %s, GetRealmName = %s, GetNormalizedRealmName = %s, eigener Realm = %s",
|
||||
tostring(un), tostring(ur), tostring(UnitName and UnitName("player")), tostring(GetRealmName and GetRealmName()),
|
||||
tostring(GetNormalizedRealmName and GetNormalizedRealmName()), OwnRealm()))
|
||||
local self = Trust.SelfKey()
|
||||
local found = false
|
||||
for _, entry in ipairs(NS.Owners or {}) do
|
||||
local k = Trust.EntryKey(entry)
|
||||
if k == self then found = true end
|
||||
FW:Print(string.format("Rolle: Eigentuemer \"%s\" -> %s%s", tostring(entry), tostring(k), k == self and " <== du" or ""))
|
||||
end
|
||||
FW:Print(string.format("Rolle: dein Schluessel %s steht %s in der Eigentuemer-Liste", tostring(self), found and "" or "NICHT"))
|
||||
end
|
||||
+4415
File diff suppressed because it is too large
Load Diff
+1406
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user