Zetrith / Prepatcher

Structured assembly rewriting library/mod for RW
MIT License
74 stars 7 forks source link

Non nullable types give an error #3

Closed kbatbouta closed 4 years ago

kbatbouta commented 4 years ago

Code

    <Field Name="isNotHackable" FieldType="bool" TargetType="Verse.Pawn" />
    <Field Name="isHacked" FieldType="bool" TargetType="Verse.Pawn" />

results in:

Error

Parameter name: value
  at System.Boolean.Parse (System.String value) [0x00003] in <567df3e0919241ba98db88bec4c6696f>:0 
  at Verse.ParseHelper.ParseBool (System.String str) [0x00000] in <e7db00e0f58f4fffa92cc36fc0e51d82>:0 
  at Verse.ParseHelper+Parsers`1+<>c__DisplayClass2_0[T].<Register>b__0 (System.String str) [0x00000] in <e7db00e0f58f4fffa92cc36fc0e51d82>:0 
  at Verse.ParseHelper.FromString (System.String str, System.Type itemType) [0x00086] in <e7db00e0f58f4fffa92cc36fc0e51d82>:0 
   --- End of inner exception stack trace ---
  at Verse.ParseHelper.FromString (System.String str, System.Type itemType) [0x00124] in <e7db00e0f58f4fffa92cc36fc0e51d82>:0 
ReflectionTypeLoadException getting types in assembly Mono.Cecil.Mdb: System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
  at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 
  at Verse.ModAssemblyHandler.AssemblyIsUsable (System.Reflection.Assembly asm) [0x00000] in <e7db00e0f58f4fffa92cc36fc0e51d82>:0 

Loader exceptions:
   => System.TypeLoadException: Could not resolve type with token 0100002d (from typeref, class/assembly Mono.Cecil.Cil.ISymbolReaderProvider, Mono.Cecil, Version=0.11.2.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e)
   => System.TypeLoadException: Could not resolve type with token 0100002e (from typeref, class/assembly Mono.Cecil.Cil.ISymbolReader, Mono.Cecil, Version=0.11.2.0, Culture=neutral, PublicKeyToken=50
ReflectionTypeLoadException getting types in assembly Mono.Cecil.Pdb: System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
  at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <567df3e0919241ba98db88bec4c6696f>:0 
  at Verse.ModAssemblyHandler.AssemblyIsUsable (System.Reflection.Assembly asm) [0x00000] in <e7db00e0f58f4fffa92cc36fc0e51d82>:0 

Loader exceptions:
   => System.TypeLoadException: Could not resolve type with token 0100001d (from typeref, class/assembly Mono.Cecil.Cil.ISymbolReader, Mono.Cecil, Version=0.11.2.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e)
   => System.TypeLoadException: Could not resolve type with token 01000034 (from typeref, class/assembly Mono.Cecil.Cil.ISymbolWriter, Mono.Cecil, Version=0.11.2.0, Culture=neutral, PublicKeyToken=50cebf1cce

Notes

kbatbouta commented 4 years ago

Update

Using default value for bools result in black screen of death.

Code

<Field Name="isNotHackable" FieldType="bool" TargetType="Verse.Pawn" DefaultValue="False"/>

or

<Field Name="isNotHackable" FieldType="bool" TargetType="Verse.Pawn" DefaultValue="false"/>

Possible solution

Possible problem source

 if (code >= TypeCode.Boolean && code <= TypeCode.UInt32)
         return cecilOpCodes.Ldc_I4;

Player.log

Zetrith commented 4 years ago

Fixed