- implemented the automap serializer.

Also optimized the base64 encoder to avoid creating endless memory copies, thanks to using std::string which is a really poor container for this kind of stuff when workig with larger blocks of data.
This commit is contained in:
Christoph Oelckers 2020-09-06 13:39:57 +02:00
parent 809f8b5d4b
commit e8452a79e8
8 changed files with 115 additions and 46 deletions

View file

@ -54,6 +54,7 @@
#include "engineerrors.h"
#include "textures.h"
#include "texturemanager.h"
#include "base64.h"
extern DObject *WP_NOCHANGE;
bool save_full = false; // for testing. Should be removed afterward.
@ -771,6 +772,31 @@ error:
return buff;
}
//==========================================================================
//
//
//
//==========================================================================
FSerializer &FSerializer::SerializeMemory(const char *key, void* mem, size_t length)
{
if (isWriting())
{
auto array = base64_encode((const uint8_t*)mem, length);
AddString(key, (const char*)array.Data());
}
else
{
auto cp = GetString(key);
if (key)
{
base64_decode(mem, length, cp);
}
}
return *this;
}
//==========================================================================
//
//