44namespace OpenDreamRuntime . Objects . Types ;
55
66public sealed class DreamObjectCallee : DreamObject {
7- public DMProcState ? ProcState ;
7+ public ProcState ? ProcState ;
88 public long ProcStateId ; // Used to ensure the proc state hasn't been reused for another proc
99 private DreamObjectCallee ? _caller ; // Caching caller prevents issues with returning incorrect info when the proc ends or calls another proc
1010
@@ -19,7 +19,7 @@ protected override bool TryGetVar(string varName, out DreamValue value) {
1919
2020 switch ( varName ) {
2121 case "proc" :
22- value = new ( ProcState . Proc ) ;
22+ value = ProcState . Proc != null ? new ( ProcState . Proc ) : DreamValue . Null ;
2323 return true ;
2424 case "args" :
2525 value = new ( new ProcArgsList ( ObjectTree . List . ObjectDefinition , ProcState ) ) ;
@@ -29,19 +29,23 @@ protected override bool TryGetVar(string varName, out DreamValue value) {
2929 value = new DreamValue ( _caller ) ;
3030 return true ;
3131 case "name" :
32- value = new ( ProcState . Proc . VerbName ) ;
32+ value = ProcState . Proc ? . VerbName != null ? new ( ProcState . Proc . VerbName ) : DreamValue . Null ;
3333 return true ;
3434 case "desc" :
35- value = ProcState . Proc . VerbDesc != null ? new ( ProcState . Proc . VerbDesc ) : DreamValue . Null ;
35+ value = ProcState . Proc ? . VerbDesc != null ? new ( ProcState . Proc . VerbDesc ) : DreamValue . Null ;
3636 return true ;
3737 case "category" :
38- value = ProcState . Proc . VerbCategory != null ? new ( ProcState . Proc . VerbCategory ) : DreamValue . Null ;
38+ value = ProcState . Proc ? . VerbCategory != null ? new ( ProcState . Proc . VerbCategory ) : DreamValue . Null ;
3939 return true ;
4040 case "file" :
41- value = new ( ProcState . Proc . GetSourceAtOffset ( 0 ) . Source ) ;
41+ value = ProcState . Proc is DMProc procFile
42+ ? new DreamValue ( procFile . GetSourceAtOffset ( 0 ) . Source )
43+ : DreamValue . Null ;
4244 return true ;
4345 case "line" :
44- value = new ( ProcState . Proc . GetSourceAtOffset ( 0 ) . Line ) ;
46+ value = ProcState . Proc is DMProc procLine
47+ ? new DreamValue ( procLine . GetSourceAtOffset ( 0 ) . Line )
48+ : DreamValue . Null ;
4549 return true ;
4650 case "src" :
4751 value = new ( ProcState . Instance ) ;
0 commit comments