Exemple #1
0
 /// <summary>
 /// Resize instruction set
 /// </summary>
 /// <param name="newSize">New size</param>
 private void ResizeInstructionSet(ushort newSize)
 {
     if (newSize != InstructionSet.Length)
     {
         GTA3ScriptInstruction[] instruction_set = new GTA3ScriptInstruction[newSize];
         if (newSize > 0U)
         {
             Array.Copy(InstructionSet, instruction_set, Math.Min(InstructionSet.Length, instruction_set.Length));
             instructionSet = instruction_set;
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// Patch instruction
 /// </summary>
 /// <param name="opCode">GTA3Script operation code</param>
 /// <param name="keywords">Keywords</param>
 /// <param name="onCall">GTA3Script instruction on call event</param>
 /// <param name="argumentTypes">GTA3Script instruction argument types</param>
 /// <exception cref="ArgumentException">Invalid argument</exception>
 public void Patch(ushort opCode, string[] keywords, GTA3ScriptOpCodeCallDelegate onCall, params Type[] argumentTypes)
 {
     Type[] argument_types = ((argumentTypes == null) ? (new Type[0]) : argumentTypes);
     if (IsPatchable && (opCode >= 0))
     {
         if (opCode > InstructionSet.Length)
         {
             ResizeInstructionSet((ushort)(opCode + 1));
         }
         for (int i = 0; i < argument_types.Length; i++)
         {
             if (argument_types[i] == null)
             {
                 throw new ArgumentException("argTypes[" + i + "] is null", "argTypes");
             }
         }
         InstructionSet[opCode] = new GTA3ScriptInstruction(argument_types, onCall);
         AddKeywords(opCode, keywords);
     }
 }