Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ ReadDecimal()

unsafe decimal System.IO.UnmanagedMemoryAccessor.ReadDecimal ( long position)
inlineinherited

Definition at line 208 of file UnmanagedMemoryAccessor.cs.

209 {
210 EnsureSafeToRead(position, 16);
211 byte* pointer = null;
212 int lo;
213 int mid;
214 int hi;
215 int num;
216 try
217 {
219 pointer += _offset + position;
220 lo = Unsafe.ReadUnaligned<int>(pointer);
221 mid = Unsafe.ReadUnaligned<int>(pointer + 4);
222 hi = Unsafe.ReadUnaligned<int>(pointer + 8);
223 num = Unsafe.ReadUnaligned<int>(pointer + 12);
224 }
225 finally
226 {
227 if (pointer != null)
228 {
230 }
231 }
232 if (((uint)num & 0x7F00FFFFu) != 0 || (num & 0xFF0000) > 1835008)
233 {
234 throw new ArgumentException(SR.Arg_BadDecimal);
235 }
236 bool isNegative = (num & int.MinValue) != 0;
237 byte scale = (byte)(num >> 16);
238 return new decimal(lo, mid, hi, isNegative, scale);
239 }
void EnsureSafeToRead(long position, int sizeOfType)
unsafe void AcquirePointer(ref byte *pointer)
Definition SafeBuffer.cs:58

References System.IO.UnmanagedMemoryAccessor._buffer, System.IO.UnmanagedMemoryAccessor._offset, System.Runtime.InteropServices.SafeBuffer.AcquirePointer(), System.SR.Arg_BadDecimal, System.IO.UnmanagedMemoryAccessor.EnsureSafeToRead(), System.pointer, and System.Runtime.InteropServices.SafeBuffer.ReleasePointer().