Update the way we get data so we don't have to do ridiculous static pointer casts and indirections.
This commit is contained in:
parent
dded211294
commit
bb3606adc8
@ -12,7 +12,6 @@ typedef char sbyte;
|
|||||||
|
|
||||||
class SHNFile{
|
class SHNFile{
|
||||||
SHNFile(const SHNFile&)=delete;
|
SHNFile(const SHNFile&)=delete;
|
||||||
SHNFile(const SHNFile&&)=delete;
|
|
||||||
std::vector<std::byte>ReadBytes(std::ifstream&file);
|
std::vector<std::byte>ReadBytes(std::ifstream&file);
|
||||||
std::vector<std::byte>ReadBytes(std::ifstream&file,int bytes);
|
std::vector<std::byte>ReadBytes(std::ifstream&file,int bytes);
|
||||||
void WriteBytes(std::ofstream&file,char*data,int length);
|
void WriteBytes(std::ofstream&file,char*data,int length);
|
||||||
@ -99,8 +98,11 @@ public:
|
|||||||
void Write(int row,int col,uint32_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,float val);
|
||||||
void Write(int row,int col,std::string val);
|
void Write(int row,int col,std::string val);
|
||||||
const SHNFile::Data Get(int row,int col)const;
|
//const SHNFile::Data Get(int row,int col)const;
|
||||||
|
template<typename T>
|
||||||
|
const T Get(int row,int col)const;
|
||||||
SHNFile();
|
SHNFile();
|
||||||
|
SHNFile(SHNFile&&)noexcept;
|
||||||
~SHNFile();
|
~SHNFile();
|
||||||
};
|
};
|
||||||
#ifdef OLC_PGEX_SHNFile
|
#ifdef OLC_PGEX_SHNFile
|
||||||
@ -523,8 +525,9 @@ void SHNFile::Save(){
|
|||||||
WriteBytes(encryptedFile,data,readAmt-0x24);
|
WriteBytes(encryptedFile,data,readAmt-0x24);
|
||||||
std::cout<<"File "<<filename<<" Saved!"<<std::endl;
|
std::cout<<"File "<<filename<<" Saved!"<<std::endl;
|
||||||
}
|
}
|
||||||
const SHNFile::Data SHNFile::Get(int row,int col)const{
|
template<typename T>
|
||||||
return contents[row][col];
|
const T SHNFile::Get(int row,int col)const{
|
||||||
|
return *(std::static_pointer_cast<T>(contents[row][col].data));
|
||||||
};
|
};
|
||||||
void SHNFile::Write(int row,int col,std::byte val){
|
void SHNFile::Write(int row,int col,std::byte val){
|
||||||
contents[row][col].Set<std::byte>(val);
|
contents[row][col].Set<std::byte>(val);
|
||||||
@ -556,6 +559,13 @@ SHNFile::SHNFile(){
|
|||||||
SHNFile::~SHNFile(){
|
SHNFile::~SHNFile(){
|
||||||
Cleanup();
|
Cleanup();
|
||||||
}
|
}
|
||||||
|
SHNFile::SHNFile(SHNFile&&temp)noexcept{
|
||||||
|
temp.cryptHeader=cryptHeader;
|
||||||
|
temp.data=data;
|
||||||
|
temp.rawData=rawData;
|
||||||
|
|
||||||
|
cryptHeader=data=rawData=nullptr;
|
||||||
|
}
|
||||||
void SHNFile::Cleanup(){
|
void SHNFile::Cleanup(){
|
||||||
if(cryptHeader!=nullptr){
|
if(cryptHeader!=nullptr){
|
||||||
delete[] cryptHeader;
|
delete[] cryptHeader;
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
int main(){
|
int main(){
|
||||||
SHNFile shn3;
|
SHNFile shn3;
|
||||||
shn3.Load("ItemViewInfo.shn");
|
shn3.Load("ItemViewInfo.shn");
|
||||||
shn3.Write(3,2,14);
|
SHNFile shn4((SHNFile&&)shn3);
|
||||||
shn3.Save();
|
uint32_t test=shn3.Get<uint32_t>(3,2);
|
||||||
|
//shn3.Write(3,2,14);
|
||||||
|
//shn3.Save();
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user