-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathByteHelper.cs
More file actions
53 lines (48 loc) · 1.58 KB
/
ByteHelper.cs
File metadata and controls
53 lines (48 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
namespace L2Script.Library
{
public class ByteHelper
{
public static int ByteInt(byte[] ko, int off)
{
int edx = (ko[off] & 0xFF);
edx |= (ko[1 + off] & 0xFF) << 8;
edx |= (ko[2 + off] & 0xFF) << 16;
edx |= (ko[3 + off] & 0xFF) << 24;
return edx;
}
public static int ByteIntR(byte[] ko, int off)
{
int edx = (ko[off + 3] & 0xFF);
edx |= (ko[off + 2] & 0xFF) << 8;
edx |= (ko[off + 1] & 0xFF) << 16;
edx |= (ko[off] & 0xFF) << 24;
return edx;
}
public static int Vuelta(int edx)
{
byte[] uy = new byte[4];
uy[0] = (byte)(edx & 0xFF);
uy[1] = (byte)(edx >> 8 & 0xFF);
uy[2] = (byte)(edx >> 16 & 0xFF);
uy[3] = (byte)(edx >> 24 & 0xFF);
return ByteIntR(uy, 0);
}
public static byte[] IntByte(int[] ji)
{
byte[] jo = new byte[ji.Length * 4];
for (int g = 0; g < ji.Length; g++)
{
jo[(g * 4)] = (byte)(ji[g] & 0xFF);
jo[(g * 4) + 1] = (byte)(ji[g] >> 8 & 0xFF);
jo[(g * 4) + 2] = (byte)(ji[g] >> 16 & 0xFF);
jo[(g * 4) + 3] = (byte)(ji[g] >> 24 & 0xFF);
}
byte[] ja = new byte[jo.Length];
for (int g = 0; g < jo.Length; g++)
{
ja[g] = jo[jo.Length - g - 1];
}
return ja;
}
}
}