mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-08 23:07:33 +07:00
Privileged read/write fix
This commit is contained in:
@ -62,7 +62,7 @@ public class LExecutor{
|
|||||||
//yes, this is a minor memory leak, but it's probably not significant enough to matter
|
//yes, this is a minor memory leak, but it's probably not significant enough to matter
|
||||||
protected static IntFloatMap unitTimeouts = new IntFloatMap();
|
protected static IntFloatMap unitTimeouts = new IntFloatMap();
|
||||||
//lookup variable by name, lazy init.
|
//lookup variable by name, lazy init.
|
||||||
protected ObjectIntMap<String> nameMap;
|
protected @Nullable ObjectIntMap<String> nameMap;
|
||||||
|
|
||||||
static{
|
static{
|
||||||
Events.on(ResetEvent.class, e -> unitTimeouts.clear());
|
Events.on(ResetEvent.class, e -> unitTimeouts.clear());
|
||||||
@ -571,7 +571,7 @@ public class LExecutor{
|
|||||||
|
|
||||||
if(from instanceof MemoryBuild mem && (exec.privileged || (from.team == exec.team && !mem.block.privileged))){
|
if(from instanceof MemoryBuild mem && (exec.privileged || (from.team == exec.team && !mem.block.privileged))){
|
||||||
output.setnum(address < 0 || address >= mem.memory.length ? 0 : mem.memory[address]);
|
output.setnum(address < 0 || address >= mem.memory.length ? 0 : mem.memory[address]);
|
||||||
}else if(from instanceof LogicBuild logic && (exec.privileged || from.team == exec.team) && position.isobj && position.objval instanceof String name){
|
}else if(from instanceof LogicBuild logic && (exec.privileged || (from.team == exec.team && !from.block.privileged)) && position.isobj && position.objval instanceof String name){
|
||||||
LVar fromVar = logic.executor.optionalVar(name);
|
LVar fromVar = logic.executor.optionalVar(name);
|
||||||
if(fromVar != null && !output.constant){
|
if(fromVar != null && !output.constant){
|
||||||
output.objval = fromVar.objval;
|
output.objval = fromVar.objval;
|
||||||
@ -601,10 +601,7 @@ public class LExecutor{
|
|||||||
|
|
||||||
if(from instanceof MemoryBuild mem && (exec.privileged || (from.team == exec.team && !mem.block.privileged)) && address >= 0 && address < mem.memory.length){
|
if(from instanceof MemoryBuild mem && (exec.privileged || (from.team == exec.team && !mem.block.privileged)) && address >= 0 && address < mem.memory.length){
|
||||||
mem.memory[address] = value.num();
|
mem.memory[address] = value.num();
|
||||||
}else if(from instanceof LogicBuild logic && (exec.privileged || from.team == exec.team) && position.isobj && position.objval instanceof String name){
|
}else if(from instanceof LogicBuild logic && (exec.privileged || (from.team == exec.team && !from.block.privileged)) && position.isobj && position.objval instanceof String name){
|
||||||
//limit write, need target processor set writable.
|
|
||||||
LVar writable = logic.executor.optionalVar("@writable");
|
|
||||||
if(writable == null || !writable.bool()) return;
|
|
||||||
LVar toVar = logic.executor.optionalVar(name);
|
LVar toVar = logic.executor.optionalVar(name);
|
||||||
if(toVar != null && !toVar.constant){
|
if(toVar != null && !toVar.constant){
|
||||||
toVar.objval = value.objval;
|
toVar.objval = value.objval;
|
||||||
|
Reference in New Issue
Block a user