diff --git a/PKGBUILD b/PKGBUILD index fc7f066..635508e 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,7 +1,7 @@ # PKGBUILD for libAthena _pkgname=libathena pkgname=$_pkgname-git -pkgver=1.1.0.37.g3dfb001 +pkgver=1.1.0.39.g2d8aeb7 pkgrel=1 pkgdesc="Basic cross platform IO library" arch=('i686' 'x86_64') diff --git a/src/Athena/FileReader.cpp b/src/Athena/FileReader.cpp index f45e41e..97ca03b 100644 --- a/src/Athena/FileReader.cpp +++ b/src/Athena/FileReader.cpp @@ -346,12 +346,13 @@ std::string FileReader::readString(atInt32 fixedLen) atUint8 chr = readByte(); atInt32 i; - for (i = 0 ; chr != 0 ; ++i) + for (i = 1 ; chr != 0 ; ++i) { - if (fixedLen >= 0 && i >= fixedLen - 1) + ret += chr; + + if (fixedLen >= 0 && i >= fixedLen) break; - ret += chr; chr = readByte(); } @@ -367,12 +368,13 @@ std::wstring FileReader::readWString(atInt32 fixedLen) atUint16 chr = readUint16(); atInt32 i; - for (i = 0 ; chr != 0 ; ++i) + for (i = 1 ; chr != 0 ; ++i) { - if (fixedLen >= 0 && i >= fixedLen - 1) + ret += chr; + + if (fixedLen >= 0 && i >= fixedLen) break; - ret += chr; chr = readUint16(); } diff --git a/src/Athena/MemoryReader.cpp b/src/Athena/MemoryReader.cpp index 7b0b630..31c5603 100644 --- a/src/Athena/MemoryReader.cpp +++ b/src/Athena/MemoryReader.cpp @@ -528,12 +528,13 @@ std::string MemoryReader::readString(atInt32 fixedLen) atUint8 chr = readByte(); atInt32 i; - for (i = 0 ; chr != 0 ; ++i) + for (i = 1 ; chr != 0 ; ++i) { - if (fixedLen >= 0 && i >= fixedLen - 1) + ret += chr; + + if (fixedLen >= 0 && i >= fixedLen) break; - ret += chr; chr = readByte(); } @@ -549,12 +550,13 @@ std::wstring MemoryReader::readWString(atInt32 fixedLen) atUint16 chr = readUint16(); atInt32 i; - for (i = 0 ; chr != 0 ; ++i) + for (i = 1 ; chr != 0 ; ++i) { - if (fixedLen >= 0 && i >= fixedLen - 1) + ret += chr; + + if (fixedLen >= 0 && i >= fixedLen) break; - ret += chr; chr = readUint16(); }