diff --git a/SHNFileDecryptor/AbState.shn.bak b/SHNFileDecryptor/AbState.shn.bak index 49c9c46..2fd7fc3 100644 Binary files a/SHNFileDecryptor/AbState.shn.bak and b/SHNFileDecryptor/AbState.shn.bak differ diff --git a/SHNFileDecryptor/SHNFileDecryptor.h b/SHNFileDecryptor/SHNFileDecryptor.h index d1a6d1f..2daf97f 100644 --- a/SHNFileDecryptor/SHNFileDecryptor.h +++ b/SHNFileDecryptor/SHNFileDecryptor.h @@ -37,9 +37,19 @@ class SHNFile{ std::string ReadString(); uint32_t GetRecordLength(); public: + enum class DataType:int{ + BYTE=1, + SBYTE=7, + UINT16=2, + INT16=6, + UINT32=3, + INT32=8, + FLOAT=4, + STRING=5 + }; struct Data{ std::shared_ptrdata; - int type=0; + DataType type=DataType::BYTE; Data(byte b); Data(sbyte b); Data(uint16_t n); @@ -82,6 +92,7 @@ public: void Write(int row,int col,uint32_t val); void Write(int row,int col,float val); void Write(int row,int col,std::string val); + const SHNFile::Data Get(int row,int col)const; SHNFile(); }; #ifdef OLC_PGEX_SHNFile @@ -223,7 +234,7 @@ float SHNFile::ReadSingle(){ return f; } void SHNFile::WriteSingle(std::ofstream&f,float n){ - byte bytes[4]; + byte bytes[4]={}; memcpy(&n,&bytes,4); for(int i=0;i<4;i++){ f<ptr=std::make_shared(byte(b)); data=ptr; - type=1; + type=DataType::BYTE; } SHNFile::Data::Data(sbyte b){ std::shared_ptrptr=std::make_shared(sbyte(b)); data=ptr; - type=7; + type=DataType::SBYTE; } SHNFile::Data::Data(uint16_t n){ std::shared_ptrptr=std::make_shared(uint16_t(n)); data=ptr; - type=2; + type=DataType::UINT16; } SHNFile::Data::Data(int16_t n){ std::shared_ptrptr=std::make_shared(int16_t(n)); data=ptr; - type=6; + type=DataType::INT16; } SHNFile::Data::Data(uint32_t n){ std::shared_ptrptr=std::make_shared(uint32_t(n)); data=ptr; - type=3; + type=DataType::UINT32; } SHNFile::Data::Data(int32_t n){ std::shared_ptrptr=std::make_shared(int32_t(n)); data=ptr; - type=8; + type=DataType::INT32; } SHNFile::Data::Data(float n){ std::shared_ptrptr=std::make_shared(float(n)); data=ptr; - type=4; + type=DataType::FLOAT; } SHNFile::Data::Data(std::string str){ std::shared_ptrptr=std::make_shared(str); data=ptr; - type=5; + type=DataType::STRING; } template T SHNFile::Data::Get(){ @@ -301,28 +312,28 @@ void SHNFile::Data::Set(T b){ } std::string SHNFile::Data::GetDisplayText(){ switch(type){ - case 1:{ + case DataType::BYTE:{ return std::to_string(int(Get())); }break; - case 7:{ + case DataType::SBYTE:{ return std::to_string(int(Get())); }break; - case 2:{ + case DataType::UINT16:{ return std::to_string(Get()); }break; - case 6:{ + case DataType::INT16:{ return std::to_string(Get()); }break; - case 3:{ + case DataType::UINT32:{ return std::to_string(Get()); }break; - case 8:{ + case DataType::INT32:{ return std::to_string(Get()); }break; - case 4:{ + case DataType::FLOAT:{ return std::to_string(Get()); }break; - case 5:{ + case DataType::STRING:{ return Get(); }break; } @@ -497,6 +508,9 @@ void SHNFile::Save(){ WriteBytes(encryptedFile,data); std::cout<<"File "<(val); } diff --git a/SHNFileDecryptor/SHNFile_example.cpp b/SHNFileDecryptor/SHNFile_example.cpp index 3fec96d..d6cfc23 100644 --- a/SHNFileDecryptor/SHNFile_example.cpp +++ b/SHNFileDecryptor/SHNFile_example.cpp @@ -4,6 +4,8 @@ int main(){ SHNFile shn; shn.Load("AbState.shn"); + SHNFile::Data dat=shn.Get(3,6); + std::cout<