Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include "$scripts\\dff\\include\\stream.ms"
- struct gtaRwString
- (
- m_string = "",
- m_isUnicode = false,
- fn Init string isUnicode =
- (
- m_string = string
- m_isUnicode = isUnicode
- ),
- fn StreamRead stream =
- (
- gtaRwStreamReadChunkHeader stream &outType &size &version &build
- while outType != 2 and outType != 19 do --rwID_STRING, rwID_UNICODESTRING
- (
- gtaRwStreamSkip stream size
- gtaRwStreamReadChunkHeader stream &outType &size &version &build
- )
- if size > 0 do
- (
- if outType == 2 then --rwID_STRING
- (
- m_string = gtaRwStreamReadString stream
- gtaRwStreamSkip stream (size - m_string.count - 1)
- )
- else --rwID_UNICODESTRING
- (
- m_isUnicode = true
- for i = 1 to (size / 2) do
- (
- character = gtaRwStreamReadInt16 stream
- if character != 0 then
- (
- m_string += (bit.intAsChar character)
- )
- else
- (
- break
- )
- )
- gtaRwStreamSkip stream (size - (m_string.count * 2) - 2)
- )
- )
- ),
- fn StreamWrite stream =
- (
- if m_isUnicode == true then
- (
- size = bit.and (m_string.count * 2 + 4) 0x7FFFFFFC
- gtaRwStreamWriteVersionedChunkHeader stream 19 size --rwID_UNICODESTRING
- for i = 1 to m_string.count do
- (
- gtaRwStreamWriteInt16 stream (bit.charAsInt m_string[i])
- )
- for i = 1 to (size - m_string.count * 2) do
- (
- gtaRwStreamWriteInt8 stream 0
- )
- )
- else
- (
- size = bit.and (m_string.count + 4) 0x7FFFFFFC
- gtaRwStreamWriteVersionedChunkHeader stream 2 size --rwID_STRING
- gtaRwStreamWriteString stream m_string
- size = size - m_string.count - 1
- if size > 1 do
- (
- for i = 1 to size do
- (
- gtaRwStreamWriteInt8 stream 0
- )
- )
- )
- ),
- fn GetStreamSize =
- (
- if m_string.count == 0 then
- return 16
- else
- (
- if m_isUnicode == true then
- return 12 + bit.and (m_string.count * 2 + 4) 0x7FFFFFFC
- else
- return 12 + bit.and (m_string.count + 4) 0x7FFFFFFC
- )
- )
- )
Add Comment
Please, Sign In to add comment