Juantlo

Untitled

Oct 28th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. void WorldDB::flush(WorldInfo info)
  2. {
  3. std::ofstream o("worlds/" + info.name + ".json");
  4. if (!o.is_open()) {
  5. cout << GetLastError() << endl;
  6. }
  7. json j;
  8. j["name"] = info.name;
  9. j["width"] = info.width;
  10. j["height"] = info.height;
  11. j["owner"] = info.owner;
  12. j["isPublic"] = info.isPublic;
  13. j["weather"] = info.weather;
  14. json tiles = json::array();
  15. int square = info.width*info.height;
  16.  
  17. for (int i = 0; i < square; i++)
  18. {
  19. json tile;
  20. tile["fg"] = info.items[i].foreground;
  21. tile["bg"] = info.items[i].background;
  22. tiles.push_back(tile);
  23. }
  24. j["tiles"] = tiles;
  25. o << j << std::endl;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment