public void changeTo(LuaConstant constant, bool isGlobal = false) { this.globalValue = isGlobal; this.value = constant.value; this.type = constant.type; }
private void readConstants() { this.constantCount = this.inputReader.ReadInt32(); // Create array for constants this.Constants = new LuaConstant[this.constantCount]; // Go through all constants for (int i = 0; i < this.constantCount; i++) { // Make a new constant object LuaConstant constant = new LuaConstant(); // Read the type of constant constant.type = (Datatype.Type) this.inputReader.ReadByte(); // Check if its a constant we can read switch (constant.type) { case Datatype.Type.Nil: constant.value = "nil"; break; case Datatype.Type.Boolean: constant.value = (this.inputReader.ReadByte() == 1) ? "true" : "false"; break; case Datatype.Type.Number: constant.value = this.inputReader.ReadSingle().ToString("0.000000"); break; case Datatype.Type.String: int stringLength = this.inputReader.ReadInt32(); if (this.luaFile.Game != LuaFile.SupportedGames.BlackOps2) { int unkInt = this.inputReader.ReadInt32(); } constant.value = this.inputReader.ReadNullTerminatedString(); break; case Datatype.Type.XHash: // TODO : Add support for switch to string constant.value = String.Format("0x{0:X}", this.inputReader.ReadUInt64() & 0xFFFFFFFFFFFFFFF); break; default: constant.value = "Unknown constant type"; break; } // Add it to the array this.Constants[i] = constant; } }