diff --git a/SHNFileDecryptor/SHNFileDecryptor.cpp b/SHNFileDecryptor/SHNFileDecryptor.cpp index 31d8cd2..8dfaec6 100644 --- a/SHNFileDecryptor/SHNFileDecryptor.cpp +++ b/SHNFileDecryptor/SHNFileDecryptor.cpp @@ -4,7 +4,6 @@ #include #include #include -#include typedef std::byte byte; typedef char sbyte; @@ -39,8 +38,8 @@ class SHNFile{ num = num3; } } - std::listReadBytes(int bytes){ - std::listbyteArr={}; + std::vectorReadBytes(int bytes){ + std::vectorbyteArr={}; for(int i=0;ib=ReadBytes(1); + std::vectorb=ReadBytes(1); if(b.size()>0){ - return b.front(); + return b[0]; } else { return byte(0); } } uint16_t ReadUInt16(){ - std::listintBytes=ReadBytes(2); - uint16_t numb = uint16_t(intBytes.back())<<8; - intBytes.pop_back(); - numb |= uint16_t(intBytes.back()); + std::vectorintBytes=ReadBytes(2); + uint16_t numb = uint16_t(intBytes[1])<<8|uint16_t(intBytes[0]); return numb; } int16_t ReadInt16(){ - std::listintBytes=ReadBytes(2); - int16_t numb = int16_t(intBytes.back())<<8; - intBytes.pop_back(); - numb |= int16_t(intBytes.back()); + std::vectorintBytes=ReadBytes(2); + int16_t numb = int16_t(intBytes[1])<<8|int16_t(intBytes[0]); return numb; } uint32_t ReadUInt32(){ - std::listintBytes=ReadBytes(4); - uint32_t numb = uint32_t(intBytes.back())<<24; - intBytes.pop_back(); - numb |= uint32_t(intBytes.back())<<16; - intBytes.pop_back(); - numb |= uint32_t(intBytes.back())<<8; - intBytes.pop_back(); - numb |= uint32_t(intBytes.back()); + std::vectorintBytes=ReadBytes(4); + uint32_t numb = uint32_t(intBytes[3])<<24|uint32_t(intBytes[2])<<16|uint32_t(intBytes[1])<<8|uint32_t(intBytes[0]); return numb; } int ReadInt32(){ - std::listintBytes=ReadBytes(4); - int numb = int(intBytes.back())<<24; - intBytes.pop_back(); - numb |= int(intBytes.back())<<16; - intBytes.pop_back(); - numb |= int(intBytes.back())<<8; - intBytes.pop_back(); - numb |= int(intBytes.back()); + std::vectorintBytes=ReadBytes(4); + int numb = int(intBytes[3])<<24|int(intBytes[2])<<16|int(intBytes[1])<<8|int(intBytes[0]); return numb; } struct Column{ @@ -101,38 +84,31 @@ class SHNFile{ int length=0; }; std::string ReadString(int bytes){ - std::liststrBytes=ReadBytes(bytes); + std::vectorstrBytes=ReadBytes(bytes); std::string str=""; - for(auto it=strBytes.begin();it!=strBytes.end();++it){ - if(*it!=byte(0)){ - str+=unsigned char(*it); + for(int i=0;istrBytes=ReadBytes(4); - byte bytes[4]; - bytes[0]=strBytes.front(); - strBytes.pop_front(); - bytes[1]=strBytes.front(); - strBytes.pop_front(); - bytes[2]=strBytes.front(); - strBytes.pop_front(); - bytes[3]=strBytes.front(); + std::vectorstrBytes=ReadBytes(4); + byte bytes[]={strBytes[0],strBytes[1],strBytes[2],strBytes[3]}; float f; memcpy(&f,&bytes,sizeof(float)); return f; } sbyte ReadSByte(){ - return sbyte(ReadBytes(1).front()); + return sbyte(ReadBytes(1)[0]); } std::string ReadString(){ std::string str=""; while(true){ - std::listbyteArr=ReadBytes(1); - if(byteArr.size()>0&&byteArr.front()!=byte(0)){ - str+=unsigned char(byteArr.front()); + std::vectorbyteArr=ReadBytes(1); + if(byteArr.size()>0&&byteArr[0]!=byte(0)){ + str+=unsigned char(byteArr[0]); }else{ break; }