/// <summary> /// Loads the UW block. /// </summary> /// <returns><c>true</c>, if UW block was loaded, <c>false</c> otherwise.</returns> /// <param name="arkData">Ark data.</param> /// <param name="blockNo">Block no.</param> /// <param name="targetDataLen">Target data length.</param> /// <param name="uwb">Uwb.</param> public static bool LoadUWBlock(char[] arkData, int blockNo, long targetDataLen, out UWBlock uwb) { uwb = new UWBlock(); int NoOfBlocks = (int)getValAtAddress(arkData, 0, 32); switch (main.curgame) { case main.GAME_UW2: { //6 + block *4 + (noOfBlocks*type) uwb.Address = (int)getValAtAddress(arkData, 6 + (blockNo * 4), 32); uwb.CompressionFlag = (int)getValAtAddress(arkData, 6 + (blockNo * 4) + (NoOfBlocks * 4), 32); uwb.DataLen = getValAtAddress(arkData, 6 + (blockNo * 4) + (NoOfBlocks * 8), 32); uwb.ReservedSpace = getValAtAddress(arkData, 6 + (blockNo * 4) + (NoOfBlocks * 12), 32); if (uwb.Address != 0) { if (((uwb.CompressionFlag >> 1) & 0x01) == 1) { //data is compressed; uwb.Data = unpackUW2(arkData, uwb.Address, ref uwb.DataLen); return(true); } else { uwb.Data = new char[uwb.DataLen]; int b = 0; for (long i = uwb.Address; i < uwb.Address + uwb.DataLen; i++) { //Copy the data to the block. uwb.Data[b++] = arkData[i]; } return(true); } } else { uwb.DataLen = 0; return(false); } } default: { uwb.Address = getValAtAddress(arkData, (blockNo * 4) + 2, 32); if (uwb.Address != 0) { uwb.Data = new char[targetDataLen]; uwb.DataLen = targetDataLen; uwb.CompressionFlag = 0; int b = 0; for (long i = uwb.Address; i < uwb.Address + uwb.DataLen; i++) { //Copy the data to the block. uwb.Data[b++] = arkData[i]; } return(true); } else { uwb.DataLen = 0; return(false); } } } }