29.06.2011, 18:16
No, it's correct. Have tested it now.
---
And here is the renamed function and it's opposite to reverse it.
---
And here is the renamed function and it's opposite to reverse it.
pawn Код:
stock WordToBytes (word, &byte0, &byte1, &byte2, &byte3, mode = 0)
{
switch (mode)
{
case 0:
{
new bytes [4 char]; // 4 char = 1
bytes [0] = word;
byte3 = bytes {0};
byte2 = bytes {1};
byte1 = bytes {2};
byte0 = bytes {3};
}
default:
{
byte0 = word & 0xFF;
byte1 = (word & 0xFF00) >>> 8;
byte2 = (word & 0xFF0000) >>> 16;
byte3 = (word & 0xFF000000) >>> 24;
}
}
}
stock BytesToWord (byte0, byte1, byte2, byte3, &word, mode = 0)
{
switch (mode)
{
case 0:
{
new bytes [4 char]; // 4 char = 1
bytes {0} = byte3;
bytes {1} = byte2;
bytes {2} = byte1;
bytes {3} = byte0;
word = bytes [0];
}
default:
{
word = byte0; // & 0xFF;
word |= (byte1 << 8); // & 0xFF00;
word |= (byte2 << 16); // & 0xFF0000;
word |= (byte3 << 24); // & 0xFF000000;
}
}
}