Skip to content

Commit

Permalink
Better save files format
Browse files Browse the repository at this point in the history
Fix error in development reload
  • Loading branch information
pinguin999 committed Jun 10, 2024
1 parent 85d38df commit e5bab7c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,11 @@ std::string Game::backupLuaTable(const sol::table table, const std::string &pare
k = std::to_string(key.as<int>());
}

if (!parent.empty())
{
k = "[\"" + k + "\"]";
}

if (k != "_entry_node" &&
k != "_VERSION" &&
k.substr(0, 4) != "sol." &&
Expand Down Expand Up @@ -829,7 +834,12 @@ std::string Game::backupLuaTable(const sol::table table, const std::string &pare
result += parent + k + " = \"" + v + "\"\n";
break;
case sol::type::number:
if (value.is<int>())
{
v = std::to_string(value.as<int>());
}else{
v = std::to_string(value.as<double>());
}
result += parent + k + " = " + v + "\n";
break;
case sol::type::boolean:
Expand All @@ -847,7 +857,7 @@ std::string Game::backupLuaTable(const sol::table table, const std::string &pare
break;
case sol::type::table:
result += parent + k + " = {}\n";
result += backupLuaTable(value.as<sol::table>(), parent + k + ".");
result += backupLuaTable(value.as<sol::table>(), parent + k);
break;
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/spine_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,12 @@ std::optional<jngl::Vec2> SpineObject::getPoint(const std::string &point_name) c
spPointAttachment *point = SUB_CAST(spPointAttachment, att);
float x = 0;
float y = 0;
if (point)
if (point && point->super.type == SP_ATTACHMENT_POINT)
{
spPointAttachment_computeWorldPosition(point, slot->bone, &x, &y);
return jngl::Vec2(x, y);
}
return jngl::Vec2(x, y);
return std::nullopt;
}

std::vector<std::string> SpineObject::getPointNames() const
Expand Down

0 comments on commit e5bab7c

Please sign in to comment.