Closed catloversg closed 1 month ago
I think this is a good change. However, I wonder if there are not still holes such as doing ns.run
or ns.spawn
inside atExit, to further get around the prestige.
In the end, some level of that might be impossible to patch completely, and that might be OK. (Certainly there are plenty of other exploits that we acknowledge.)
I'll take a look at them (run
, exec
, spawn
, etc.). If I find any problems, I'll open an issue/PR.
A player reports a bug with stock,
ns.atExit
and soft reset. The gist is that when they sell the stock inns.atExit
, the profit is added to the player's money after the soft reset.MRE:
After the soft reset, the player has "initital money" + profit instead of just "initital money".
The bug happens because
prestigeWorkerScripts()
is called afterPlayer.prestigeAugmentation()
and beforeinitStockMarket
. The flow:Player.prestigeAugmentation()
: Reset the player's money.prestigeWorkerScripts()
: callns.atExit
.ns.atExit
sells stocks and adds the profit to the player's money.initStockMarket
: reset the stock market.The fix is fairly simple: We only need to call
prestigeWorkerScripts()
beforePlayer.prestigeAugmentation()
. However, the problem is more complicated than that. BecauseprestigeWorkerScripts()
will runns.atExit
, it allows the player to run arbitrary code when the game logic is performing the prestige and be in an incomplete transition state. This can create many subtle bugs/weird behaviors/exploits. This is an exploit that I come up with:MRE:
In this PoC:
Player
andFactions
; you can use the dev tool as an alternative way):ns.atExit
.ns.singularity.installAugmentations()
.The cost of QLink will be increased after we buy Synfibril Muscle, but we can "reset" that cost requirement with this exploit.
To prevent this kind of problem, this PR does these things:
prestigeWorkerScripts
as early as possible inprestigeAugmentation
andprestigeSourceFile
.prestigeAugmentation
andprestigeSourceFile
. If those callers modify the game state (installing augmentations, setting BitNode data, etc.), we callprestigeWorkerScripts
before those code.