mirror of
https://github.com/zenith391/OCEmu.git
synced 2025-09-29 07:53:29 -04:00
Fix the hack
I totally tested the previous hack New hack! Allow us to travel backwards in time, as far as the computer is concerned, that minute long request only took about ~0 seconds
This commit is contained in:
parent
b3494872f1
commit
744e640bea
@ -1,12 +1,12 @@
|
||||
local env = ...
|
||||
|
||||
local sok,socket = pcall(require,"socket")
|
||||
local gettime
|
||||
if sok then
|
||||
gettime = socket.gettime
|
||||
else
|
||||
gettime = os.time
|
||||
end
|
||||
timeoffset = 0
|
||||
|
||||
local tmpaddr = "tmp-address"
|
||||
|
||||
@ -21,7 +21,7 @@ env.computer = {}
|
||||
function env.computer.realTime()
|
||||
--TODO
|
||||
--cprint("computer.realTime") -- Spammy
|
||||
return gettime()
|
||||
return gettime()-timeoffset
|
||||
end
|
||||
function env.computer.uptime()
|
||||
--TODO
|
||||
|
@ -122,11 +122,11 @@ function obj.request(url, postData) -- Starts an HTTP request. If this returns t
|
||||
end
|
||||
-- TODO: This works ... but is slow.
|
||||
-- TODO: Infact so slow, it can trigger the machine's sethook, so we have to work around that.
|
||||
local hookf,hookm,hookc = debug.gethook()
|
||||
local co = coroutine.running()
|
||||
debug.sethook(co)
|
||||
local starttime = gettime()
|
||||
local page, err, headers, status = http.request(url, postData)
|
||||
debug.sethook(co,hookf,hookm,hookc)
|
||||
local offset = gettime() - starttime
|
||||
timeoffset = timeoffset + offset
|
||||
cprint("(request.hack) Going back in time: " .. offset .. "s")
|
||||
if not page then
|
||||
cprint("(request) request failed",err)
|
||||
end
|
||||
|
@ -271,6 +271,7 @@ boot_machine()
|
||||
|
||||
local resume_thread
|
||||
function resume_thread(...)
|
||||
timeoffset = 0
|
||||
if coroutine.status(machine.thread) ~= "dead" then
|
||||
cprint("resume",...)
|
||||
local results = { coroutine.resume(machine.thread, ...) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user