Added Write function.

master
sigonasr2 1 year ago
parent 82682d6b34
commit 8336b0e305
  1. BIN
      SHNFileDecryptor/AbState.shn
  2. BIN
      SHNFileDecryptor/AbState.shn.bak
  3. BIN
      SHNFileDecryptor/AbState.shn_decoded.bak
  4. 86
      SHNFileDecryptor/SHNFileDecryptor.h
  5. 1
      SHNFileDecryptor/SHNFile_example.cpp

Binary file not shown.

Binary file not shown.

@ -48,7 +48,7 @@ public:
Data(int32_t n);
Data(float n);
Data(std::string str);
template <typename T>
template<typename T>
T Get();
template<typename T>
void Set(T b);
@ -74,6 +74,14 @@ private:
public:
void Load(std::string file);
void Save();
void Write(int row,int col,byte val);
void Write(int row,int col,sbyte val);
void Write(int row,int col,int16_t val);
void Write(int row,int col,uint16_t val);
void Write(int row,int col,int32_t val);
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);
SHNFile();
};
#ifdef OLC_PGEX_SHNFile
@ -289,34 +297,34 @@ T SHNFile::Data::Get(){
}
template<typename T>
void SHNFile::Data::Set(T b){
data=std::make_shared<T>(T(b));
data=std::make_shared<T>(b);
}
std::string SHNFile::Data::GetDisplayText(){
switch(type){
case 1:{
return std::to_string(int(Get<byte>()));
}break;
case 7:{
return std::to_string(int(Get<sbyte>()));
}break;
case 2:{
return std::to_string(Get<uint16_t>());
}break;
case 6:{
return std::to_string(Get<int16_t>());
}break;
case 3:{
return std::to_string(Get<uint32_t>());
}break;
case 8:{
return std::to_string(Get<int32_t>());
}break;
case 4:{
return std::to_string(Get<float>());
}break;
case 5:{
return Get<std::string>();
}break;
case 1:{
return std::to_string(int(Get<byte>()));
}break;
case 7:{
return std::to_string(int(Get<sbyte>()));
}break;
case 2:{
return std::to_string(Get<uint16_t>());
}break;
case 6:{
return std::to_string(Get<int16_t>());
}break;
case 3:{
return std::to_string(Get<uint32_t>());
}break;
case 8:{
return std::to_string(Get<int32_t>());
}break;
case 4:{
return std::to_string(Get<float>());
}break;
case 5:{
return Get<std::string>();
}break;
}
}
void SHNFile::Load(std::string file){
@ -454,7 +462,7 @@ void SHNFile::Save(){
}break;
case 9:
case 0x18:{
WriteString(f,col.Get<std::string>(),columns[colNum].length);
WriteString(f,std::string(col.Get<std::string>()),columns[colNum].length);
}break;
case 13:
case 0x15:{
@ -489,5 +497,29 @@ void SHNFile::Save(){
WriteBytes(encryptedFile,data);
std::cout<<"File "<<filename<<" Saved!"<<std::endl;
}
void SHNFile::Write(int row,int col,byte val){
contents[row][col].Set<byte>(val);
}
void SHNFile::Write(int row,int col,sbyte val){
contents[row][col].Set<sbyte>(val);
}
void SHNFile::Write(int row,int col,int16_t val){
contents[row][col].Set<int16_t>(val);
}
void SHNFile::Write(int row,int col,uint16_t val){
contents[row][col].Set<uint16_t>(val);
}
void SHNFile::Write(int row,int col,int32_t val){
contents[row][col].Set<int32_t>(val);
}
void SHNFile::Write(int row,int col,uint32_t val){
contents[row][col].Set<uint32_t>(val);
}
void SHNFile::Write(int row,int col,float val){
contents[row][col].Set<float>(val);
}
void SHNFile::Write(int row,int col,std::string val){
contents[row][col].Set<std::string>(val);
}
SHNFile::SHNFile(){}
#endif

@ -4,5 +4,6 @@
int main(){
SHNFile shn;
shn.Load("AbState.shn");
shn.Write(1,1,"Noodles");
shn.Save();
}
Loading…
Cancel
Save