Skip to content

Commit 0d1f654

Browse files
committed
Bug Fixing and Mass Performance Increase
1 parent a4977c2 commit 0d1f654

File tree

118 files changed

+2303
-6472
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+2303
-6472
lines changed

gamemode/core/derma/mainmenu/character.lua

Lines changed: 78 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local PANEL = {}
1+
local PANEL = {}
22
function PANEL:Init()
33
local client = LocalPlayer()
44
local clientChar = client.getChar and client:getChar()
@@ -36,7 +36,7 @@ function PANEL:Init()
3636
self:loadBackground()
3737
if clientChar and lia.characters and #lia.characters > 0 then
3838
for i, charID in ipairs(lia.characters) do
39-
local charObj = isnumber(charID) and lia.char.loaded[charID] or charID
39+
local charObj = isnumber(charID) and lia.char.getCharacter(charID) or charID
4040
if charObj and charObj.getID and charObj:getID() == clientChar:getID() then
4141
self.currentIndex = i
4242
break
@@ -146,10 +146,21 @@ function PANEL:createStartButton()
146146
local discordURL = lia.config.get("DiscordURL")
147147
local workshopURL = lia.config.get("Workshop")
148148
local buttonsData = {}
149+
local hasStaffChar = false
150+
if lia.characters and #lia.characters > 0 then
151+
for _, charID in pairs(lia.characters) do
152+
local character = lia.char.getCharacter(charID)
153+
if character and character:getFaction() == FACTION_STAFF then
154+
hasStaffChar = true
155+
break
156+
end
157+
end
158+
end
159+
149160
if hook.Run("CanPlayerCreateChar", client) ~= false then
150161
table.insert(buttonsData, {
151162
id = "create",
152-
text = L("create") .. " " .. L("character"),
163+
text = "Create Character",
153164
doClick = function()
154165
for _, b in pairs(self.buttons) do
155166
if IsValid(b) then b:Remove() end
@@ -166,7 +177,7 @@ function PANEL:createStartButton()
166177
if lia.characters and #lia.characters > 0 then
167178
table.insert(buttonsData, {
168179
id = "load",
169-
text = L("loadCharacter"),
180+
text = "Load Character",
170181
doClick = function()
171182
for _, b in pairs(self.buttons) do
172183
if IsValid(b) then b:Remove() end
@@ -180,10 +191,39 @@ function PANEL:createStartButton()
180191
})
181192
end
182193

194+
if client:hasPrivilege("createStaffCharacter") and not client:isStaffOnDuty() then
195+
table.insert(buttonsData, {
196+
id = "staff",
197+
text = hasStaffChar and "Load Staff Character" or "Create Staff Character",
198+
doClick = function()
199+
for _, b in pairs(self.buttons) do
200+
if IsValid(b) then b:Remove() end
201+
end
202+
203+
self:clickSound()
204+
if hasStaffChar then
205+
for _, charID in pairs(lia.characters) do
206+
local character = lia.char.getCharacter(charID)
207+
if character and character:getFaction() == FACTION_STAFF then
208+
lia.module.list["mainmenu"]:chooseCharacter(character:getID()):next(function()
209+
if IsValid(lia.gui.character) then
210+
lia.gui.character:Remove()
211+
end
212+
end):catch(function(err) if err and err ~= "" then LocalPlayer():notifyLocalized(err) end end)
213+
break
214+
end
215+
end
216+
else
217+
self:createStaffCharacter()
218+
end
219+
end
220+
})
221+
end
222+
183223
if discordURL ~= "" then
184224
table.insert(buttonsData, {
185225
id = "discord",
186-
text = L("discord"),
226+
text = "Discord",
187227
doClick = function()
188228
self:clickSound()
189229
gui.OpenURL(discordURL)
@@ -194,18 +234,19 @@ function PANEL:createStartButton()
194234
if workshopURL ~= "" then
195235
table.insert(buttonsData, {
196236
id = "workshop",
197-
text = L("steamWorkshop"),
237+
text = "Workshop",
198238
doClick = function()
199239
self:clickSound()
200240
gui.OpenURL(workshopURL)
201241
end
202242
})
203243
end
204244

245+
-- 6. Mount Content
205246
if lia.workshop and lia.workshop.hasContentToDownload and lia.workshop.hasContentToDownload() then
206247
table.insert(buttonsData, {
207248
id = "mount",
208-
text = L("mountContent"),
249+
text = "Mount Content",
209250
doClick = function()
210251
self:clickSound()
211252
if lia.workshop and lia.workshop.mountContent then
@@ -218,19 +259,21 @@ function PANEL:createStartButton()
218259
})
219260
end
220261

262+
-- 7. Disconnect
221263
table.insert(buttonsData, {
222264
id = "disconnect",
223-
text = L("disconnect"),
265+
text = "Disconnect",
224266
doClick = function()
225267
self:clickSound()
226268
RunConsoleCommand("disconnect")
227269
end
228270
})
229271

272+
-- 8. Return
230273
if clientChar then
231274
table.insert(buttonsData, {
232275
id = "return",
233-
text = L("returnText"),
276+
text = "Return",
234277
doClick = function() self:Remove() end
235278
})
236279
end
@@ -376,13 +419,34 @@ function PANEL:createCharacterCreation()
376419
self.content:Add("liaCharacterCreation")
377420
end
378421

422+
function PANEL:createStaffCharacter()
423+
local client = LocalPlayer()
424+
local steamName = client:Nick()
425+
local staffData = {
426+
name = steamName,
427+
faction = FACTION_STAFF,
428+
model = 1,
429+
desc = "",
430+
skin = 0,
431+
groups = {}
432+
}
433+
434+
lia.module.list["mainmenu"]:createCharacter(staffData):next(function(charID)
435+
lia.module.list["mainmenu"]:chooseCharacter(charID):next(function()
436+
if IsValid(lia.gui.character) then
437+
lia.gui.character:Remove()
438+
end
439+
end):catch(function(err) if err and err ~= "" then LocalPlayer():notifyLocalized(err) end end)
440+
end):catch(function(err) LocalPlayer():notifyLocalized(err or "Failed to create staff character") end)
441+
end
442+
379443
function PANEL:updateSelectedCharacter()
380444
if not self.isLoadMode then return end
381445
local chars = lia.characters or {}
382446
if #chars == 0 then return end
383447
self.currentIndex = self.currentIndex or 1
384448
local sel = chars[self.currentIndex] or chars[1]
385-
local character = lia.char.loaded[sel]
449+
local character = lia.char.getCharacter(sel)
386450
if IsValid(self.infoFrame) then self.infoFrame:Remove() end
387451
if IsValid(self.selectBtn) then self.selectBtn:Remove() end
388452
if IsValid(self.deleteBtn) then self.deleteBtn:Remove() end
@@ -396,7 +460,7 @@ function PANEL:createSelectedCharacterInfoPanel(character)
396460
local total = #chars
397461
local index = 1
398462
for i, cID in ipairs(chars) do
399-
local cObj = isnumber(cID) and lia.char.loaded[cID] or cID
463+
local cObj = isnumber(cID) and lia.char.getCharacter(cID) or cID
400464
if cObj and cObj.getID and cObj:getID() == character:getID() then
401465
index = i
402466
break
@@ -711,6 +775,9 @@ function PANEL:warningSound()
711775
end
712776

713777
function PANEL:OnRemove()
778+
if lia.gui.character == self then
779+
lia.gui.character = nil
780+
end
714781
hook.Run("CharacterMenuClosed")
715782
self:restoreExternalEntities()
716783
hook.Remove("PrePlayerDraw", "liaMainMenuPrePlayerDraw")

gamemode/core/derma/panels/item.lua

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function PANEL:PaintOver(w, h)
5353
hook.Run("ItemPaintOver", self, itemTable, w, h)
5454
end
5555

56-
local function buildActionFunc(action, actionIndex, itemTable, _, sub)
56+
local function buildActionFunc(action, actionIndex, itemTable, sub, optionKey)
5757
return function()
5858
itemTable.player = LocalPlayer()
5959
local send = true
@@ -71,7 +71,7 @@ local function buildActionFunc(action, actionIndex, itemTable, _, sub)
7171
net.Start("invAct")
7272
net.WriteString(actionIndex)
7373
net.WriteType(itemTable.id)
74-
net.WriteType(sub and sub.data)
74+
net.WriteType(optionKey or sub and sub.data)
7575
net.SendToServer()
7676
end
7777

@@ -91,16 +91,36 @@ function PANEL:openActionMenu()
9191

9292
for k, v in SortedPairs(itemTable.functions) do
9393
if hook.Run("CanRunItemAction", itemTable, k) == false or isfunction(v.onCanRun) and not v.onCanRun(itemTable) then continue end
94-
if v.isMulti then
95-
local subMenu, subMenuOption = menu:AddSubMenu(L(v.name or k), buildActionFunc(v, k, itemTable, self.invID))
94+
local isMulti = v.isMulti or v.multiOptions and istable(v.multiOptions)
95+
if isMulti then
96+
local subMenu, subMenuOption = menu:AddSubMenu(L(v.name or k), buildActionFunc(v, k, itemTable))
9697
subMenuOption:SetImage(v.icon or "icon16/brick.png")
97-
local options = isfunction(v.multiOptions) and v.multiOptions(itemTable, LocalPlayer()) or v.multiOptions
98+
local options = v.multiOptions
99+
if isfunction(options) then options = options(itemTable, LocalPlayer()) end
98100
if not options then return end
99-
for _, sub in pairs(options) do
100-
subMenu:AddOption(L(sub.name or "subOption"), buildActionFunc(v, k, itemTable, self.invID, sub)):SetImage(sub.icon or "icon16/brick.png")
101+
for optionKey, optionFunc in pairs(options) do
102+
if isfunction(optionFunc) then
103+
local subOption = {
104+
name = optionKey,
105+
onRun = optionFunc
106+
}
107+
108+
subMenu:AddOption(L(optionKey), buildActionFunc(v, k, itemTable, subOption, optionKey)):SetImage("icon16/brick.png")
109+
elseif istable(optionFunc) then
110+
if isfunction(optionFunc[2]) and not optionFunc[2](itemTable, LocalPlayer()) then continue end
111+
local subOption = {
112+
name = optionFunc.name or optionKey,
113+
onRun = optionFunc[1] or optionFunc.onRun,
114+
icon = optionFunc.icon
115+
}
116+
117+
subMenu:AddOption(L(subOption.name), buildActionFunc(v, k, itemTable, subOption, optionKey)):SetImage(subOption.icon or "icon16/brick.png")
118+
else
119+
subMenu:AddOption(L(optionFunc.name or "subOption"), buildActionFunc(v, k, itemTable, optionFunc)):SetImage(optionFunc.icon or "icon16/brick.png")
120+
end
101121
end
102122
else
103-
menu:AddOption(L(v.name or k), buildActionFunc(v, k, itemTable, self.invID)):SetImage(v.icon or "icon16/brick.png")
123+
menu:AddOption(L(v.name or k), buildActionFunc(v, k, itemTable)):SetImage(v.icon or "icon16/brick.png")
104124
end
105125
end
106126

gamemode/core/derma/panels/itempanel.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ function PANEL:openInspect()
114114
end
115115
end
116116

117-
if LocalPlayer():isStaffOnDuty() or LocalPlayer():hasPrivilege(L("canAccessItemInformations")) then
117+
if LocalPlayer():isStaffOnDuty() or LocalPlayer():hasPrivilege("canAccessItemInformations") then
118118
local cr = self.ent:GetCreator()
119119
if IsValid(cr) then drawLine(scroll, L("spawner"), cr:Name() .. " - " .. cr:SteamID()) end
120120
end

gamemode/core/derma/panels/scoreboard.lua

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,25 @@ local function wrap(text, maxWidth, font)
3232
return lines
3333
end
3434

35+
function PANEL:ApplyConfig()
36+
local screenW, screenH = ScrW(), ScrH()
37+
local w, h = screenW * lia.config.get("sbWidth", 0.35), screenH * lia.config.get("sbHeight", 0.65)
38+
self:SetSize(w, h)
39+
local dock = string.lower(lia.config.get("sbDock", "center"))
40+
if dock == "left" then
41+
self:SetPos(0, (screenH - h) * 0.5)
42+
elseif dock == "right" then
43+
self:SetPos(screenW - w, (screenH - h) * 0.5)
44+
else
45+
self:Center()
46+
end
47+
end
48+
3549
function PANEL:Init()
3650
if IsValid(lia.gui.score) then lia.gui.score:Remove() end
3751
lia.gui.score = self
3852
hook.Run("ScoreboardOpened", self)
39-
local w, h = ScrW() * lia.config.get("sbWidth", 0.35), ScrH() * lia.config.get("sbHeight", 0.65)
40-
self:SetSize(w, h)
41-
self:Center()
53+
self:ApplyConfig()
4254
local header = self:Add("DPanel")
4355
header:Dock(TOP)
4456
header:SetTall(80)

gamemode/core/hooks/client.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ end
469469

470470
function GM:SpawnMenuOpen()
471471
local client = LocalPlayer()
472-
if lia.config.get("SpawnMenuLimit", false) and not (client:hasFlags("pet") or client:isStaffOnDuty() or client:hasPrivilege(L("canSpawnProps"))) then return end
472+
if lia.config.get("SpawnMenuLimit", false) and not (client:hasFlags("pet") or client:isStaffOnDuty() or client:hasPrivilege("canSpawnProps")) then return end
473473
return true
474474
end
475475

gamemode/core/hooks/server.lua

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local GM = GM or GAMEMODE
1+
local GM = GM or GAMEMODE
22
function GM:CharPreSave(character)
33
local client = character:getPlayer()
44
local loginTime = character:getLoginTime()
@@ -70,8 +70,8 @@ function GM:PlayerShouldPermaKill(client)
7070
end
7171

7272
function GM:CharLoaded(id)
73-
local character = lia.char.loaded[id]
74-
if character then
73+
lia.char.getCharacter(id, nil, function(character)
74+
if not character then return end
7575
local client = character:getPlayer()
7676
if IsValid(client) then
7777
local uniqueID = "liaSaveChar" .. client:SteamID64()
@@ -83,7 +83,7 @@ function GM:CharLoaded(id)
8383
end
8484
end)
8585
end
86-
end
86+
end)
8787
end
8888

8989
function GM:PrePlayerLoadedChar(client)
@@ -103,8 +103,7 @@ end
103103

104104
function GM:CanItemBeTransfered(item, curInv, inventory)
105105
if item.isBag and curInv ~= inventory and item.getInv and item:getInv() and table.Count(item:getInv():getItems()) > 0 then
106-
local character = lia.char.loaded[curInv.client]
107-
character:getPlayer():notifyLocalized("forbiddenActionStorage")
106+
lia.char.getCharacter(curInv.client, nil, function(character) if character then character:getPlayer():notifyLocalized("forbiddenActionStorage") end end)
108107
return false
109108
end
110109

@@ -533,7 +532,7 @@ function GM:SetupBotPlayer(client)
533532
inventory.id = "bot" .. character:getID()
534533
character.vars.inv[1] = inventory
535534
lia.inventory.instances[inventory.id] = inventory
536-
lia.char.loaded[botID] = character
535+
lia.char.addCharacter(botID, character)
537536
character:setup()
538537
client:Spawn()
539538
end
@@ -1003,7 +1002,7 @@ concommand.Add("plysetgroup", function(ply, _, args)
10031002
end)
10041003

10051004
lia.administrator.registerPrivilege({
1006-
Name = L("stopSoundForEveryone"),
1005+
Name = "stopSoundForEveryone",
10071006
ID = "stopSoundForEveryone",
10081007
MinAccess = "superadmin",
10091008
Category = "categoryServer"
@@ -1102,9 +1101,4 @@ end)
11021101
hook.Add("server_removeban", "LiliaLogServerUnban", function(data)
11031102
lia.admin(L("unbanLogFormat", data.networkid))
11041103
lia.db.query("DELETE FROM lia_bans WHERE playerSteamID = " .. lia.db.convertDataType(data.networkid))
1105-
end)
1106-
1107-
local networkStrings = {"AdminModeSwapCharacter", "AnimationStatus", "ArgumentsRequest", "BinaryQuestionRequest", "ButtonRequest", "ChangeAttribute", "CharacterInfo", "CheckHack", "CheckSeed", "CreateTableUI", "CurTime-Sync", "CurTimeSync", "DisplayCharList", "ForceUpdateF1", "KickCharacter", "LIA_BigTable_Ack", "MyBigTableNetString", "NetStreamDS", "OpenInvMenu", "OptionsRequest", "RegenChat", "RequestDropdown", "RequestFactionRoster", "RequestRemoveWarning", "RunLocalOption", "RunOption", "ServerChatAddText", "SpawnMenuGiveItem", "SpawnMenuSpawnItem", "StringRequest", "TicketSystem", "TicketSystemClaim", "TicketSystemClose", "TransferMoneyFromP2P", "VendorAllowClass", "VendorAllowFaction", "VendorEdit", "VendorExit", "VendorFaction", "VendorMaxStock", "VendorMode", "VendorMoney", "VendorOpen", "VendorPrice", "VendorStock", "VendorSync", "VendorTrade", "VerifyCheats", "VerifyCheatsResponse", "ViewClaims", "WorkshopDownloader_Info", "WorkshopDownloader_Request", "WorkshopDownloader_Start", "actBar", "attrib", "blindFade", "blindTarget", "cMsg", "cfgList", "cfgSet", "charInfo", "charKick", "charSet", "charVar", "classUpdate", "cmd", "doorMenu", "doorPerm", "gVar", "invAct", "invData", "invQuantity", "item", "liaActiveTickets", "liaAllFlags", "liaAllPKs", "liaAllPlayers", "liaAllWarnings", "liaCharChoose", "liaCharCreate", "liaCharDelete", "liaCharFetchNames", "liaCharList", "liaCharacterData", "liaCharacterInvList", "liaCmdArgPrompt", "liaDBTableData", "liaDBTables", "liaData", "liaDataSync", "liaDatabaseViewData", "liaFactionRosterData", "liaFullCharList", "liaGroupPermChanged", "liaGroupsAdd", "liaGroupsRemove", "liaGroupsRename", "liaGroupsRequest", "liaGroupsSetPerm", "liaInventoryAdd", "liaInventoryData", "liaInventoryDelete", "liaInventoryInit", "liaInventoryRemove", "liaItemDelete", "liaItemInspect", "liaItemInstance", "liaModifyFlags", "liaNotify", "liaNotifyL", "liaPACPartAdd", "liaPACPartRemove", "liaPACPartReset", "liaPACSync", "liaPKsCount", "liaPlayerCharacters", "liaRequestActiveTickets", "liaRequestAllFlags", "liaRequestAllPKs", "liaRequestAllWarnings", "liaRequestDatabaseView", "liaRequestFactionRoster", "liaRequestFullCharList", "liaRequestPKsCount", "liaRequestPlayerCharacters", "liaRequestPlayers", "liaRequestStaffSummary", "liaRequestTableData", "liaRequestTicketsCount", "liaRequestWarningsCount", "liaStaffSummary", "liaStorageExit", "liaStorageOpen", "liaStorageTransfer", "liaStorageUnlock", "liaTeleportToEntity", "liaTicketsCount", "liaTransferItem", "liaWarningsCount", "lia_managesitrooms_action", "managesitrooms", "msg", "nDel", "nLcl", "nVar", "playerLoadedChar", "postPlayerLoadedChar", "prePlayerLoadedChar", "removeF1", "request_respawn", "rgnDone", "send_logs", "send_logs_request", "seqSet", "setWaypoint", "setWaypointWithLogo", "trunkInitStorage", "updateAdminGroups", "updateAdminPrivilegeIDs", "updateAdminPrivilegeMeta", "updateAdminPrivileges"}
1108-
for _, netString in ipairs(networkStrings) do
1109-
util.AddNetworkString(netString)
1110-
end
1104+
end)

0 commit comments

Comments
 (0)