Skip to content

Commit

Permalink
Small improvements with debug.registry & FindMetaTable
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown-gd committed Apr 24, 2024
1 parent 9297136 commit 3813f74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/yue_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Download Yuescript and unzip yue
run: |
wget https://github.com/pigpigyyy/Yuescript/releases/download/v0.22.2/yue-linux-x86_64.zip
wget https://github.com/pigpigyyy/Yuescript/releases/download/v0.23.3/yue-linux-x86_64.zip
unzip yue-linux-x86_64.zip
rm yue-linux-x86_64.zip
Expand Down
36 changes: 21 additions & 15 deletions lua/autorun/!!!random-patches.yue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CLIENT = CLIENT
SERVER = SERVER
pairs = pairs

addonName = "Random Patches v5.19.0"
addonName = "Random Patches v5.20.0"

getHookName = ( patchName, hookName ) ->
return addonName .. "::" .. patchName .. ( hookName or "" )
Expand Down Expand Up @@ -159,7 +159,7 @@ do

yield!

local ENTITY, PLAYER, registry
local registry
do

-- Just to be safe
Expand All @@ -170,25 +170,31 @@ do
else
registry = {}

-- registry indexer with metatable
do
findMetaTable = __findMetaTable
unless isfunction( findMetaTable )
findMetaTable = FindMetaTable
global __findMetaTable = findMetaTable

FindMetaTable = FindMetaTable
rawset = rawset
setmetatable( registry, {
"__index": ( tbl, key ) ->
metatable = findMetaTable( key )
if metatable == nil
return

setmetatable( registry, {
"__index": ( tbl, key ) ->
value = FindMetaTable( key )
if value == nil
return
rawset( tbl, key, metatable )
return metatable
} )

rawset( tbl, key, value )
return value
} )
-- patched FindMetaTable & debug.getregistry
global FindMetaTable = ( name ) ->
return registry[ name ]

debug.getregistry = ->
return registry

local ENTITY, PLAYER
do

ENTITY, PLAYER = registry.Entity, registry.Player

getCTable = ENTITY.GetCTable
Expand Down Expand Up @@ -835,9 +841,9 @@ if CLIENT and not MENU_DLL
do

import OnConVarChanged from cvars
:GetDefault = registry.ConVar
GetConVar = GetConVar

:GetDefault = FindMetaTable( "ConVar" )
gameevent.Listen( "server_cvar" )
values = {}

Expand Down

0 comments on commit 3813f74

Please sign in to comment.