+ added light element type to the detection list, not supported yet

+ added PKGV0004, PKGV0005, PKGV0006 to the list

Signed-off-by: Alexis Maiquez <almamu@almamu.com>
This commit is contained in:
Alexis Maiquez 2021-06-16 18:10:05 +02:00
parent a0ed644491
commit 10191202df
2 changed files with 24 additions and 15 deletions

View File

@ -27,6 +27,8 @@ CObject::CObject (
CObject* CObject::fromJSON (json data)
{
std::string json = data.dump ();
auto id_it = jsonFindRequired (data, "id", "Objects must have id");
auto visible_it = data.find ("visible");
auto origin_it = jsonFindRequired (data, "origin", "Objects must have origin point");
@ -57,6 +59,7 @@ CObject* CObject::fromJSON (json data)
auto sound_it = data.find ("sound");
auto particle_it = data.find ("particle");
auto text_it = data.find ("text");
auto light_it = data.find ("light");
CObject* object = nullptr;
@ -72,7 +75,7 @@ CObject* CObject::fromJSON (json data)
WallpaperEngine::Core::ato3vf (*angles_it)
);
}
else if (sound_it != data.end ())
else if (sound_it != data.end () && (*sound_it).is_null () == false)
{
object = Objects::CSound::fromJSON (
data,
@ -84,7 +87,7 @@ CObject* CObject::fromJSON (json data)
WallpaperEngine::Core::ato3vf (*angles_it)
);
}
else if (particle_it != data.end ())
else if (particle_it != data.end () && (*particle_it).is_null () == false)
{
/// TODO: XXXHACK -- TO REMOVE WHEN PARTICLE SUPPORT IS PROPERLY IMPLEMENTED
try
@ -102,11 +105,16 @@ CObject* CObject::fromJSON (json data)
return nullptr;
}
}
else if (text_it != data.end ())
else if (text_it != data.end () && (*text_it).is_null () == false)
{
/// TODO: XXXHACK -- TO REMOVE WHEN TEXT SUPPORT IS IMPLEMENTED
return nullptr;
}
else if (light_it != data.end () && (*light_it).is_null () == false)
{
/// TODO: XXXHACK -- TO REMOVE WHEN LIGHT SUPPORT IS IMPLEMENTED
return nullptr;
}
else
{
throw std::runtime_error (std::string ("Unkonwn object type detected ").append (*name_it));

View File

@ -2,6 +2,17 @@
namespace WallpaperEngine::Irrlicht
{
bool isPkgHeaderVersionValid(char* version)
{
return strcmp ("PKGV0007", version) == 0 ||
strcmp ("PKGV0002", version) == 0 ||
strcmp ("PKGV0001", version) == 0 ||
strcmp ("PKGV0008", version) == 0 ||
strcmp ("PKGV0009", version) == 0 ||
strcmp ("PKGV0004", version) == 0 ||
strcmp ("PKGV0005", version) == 0 ||
strcmp ("PKGV0006", version) == 0;
}
CArchiveLoaderPkg::CArchiveLoaderPkg (CContext* context) :
m_context (context)
@ -59,12 +70,7 @@ namespace WallpaperEngine::Irrlicht
file->read (pointer, size - 1);
if (
strcmp ("PKGV0007", pointer) != 0 &&
strcmp ("PKGV0002", pointer) != 0 &&
strcmp ("PKGV0001", pointer) != 0 &&
strcmp ("PKGV0008", pointer) != 0 &&
strcmp ("PKGV0009", pointer) != 0)
if (isPkgHeaderVersionValid (pointer) == false)
{
delete [] pointer;
return false;
@ -112,12 +118,7 @@ namespace WallpaperEngine::Irrlicht
{
char* headerVersion = this->readSizedString ();
if (
strcmp ("PKGV0007", headerVersion) != 0 &&
strcmp ("PKGV0002", headerVersion) != 0 &&
strcmp ("PKGV0001", headerVersion) != 0 &&
strcmp ("PKGV0008", headerVersion) != 0 &&
strcmp ("PKGV0009", headerVersion) != 0)
if (isPkgHeaderVersionValid (headerVersion) == false)
{
delete [] headerVersion;