Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void WorldDB::flush(WorldInfo info)
- {
- std::ofstream o("worlds/" + info.name + ".json");
- if (!o.is_open()) {
- cout << GetLastError() << endl;
- }
- json j;
- j["name"] = info.name;
- j["width"] = info.width;
- j["height"] = info.height;
- j["owner"] = info.owner;
- j["isPublic"] = info.isPublic;
- j["weather"] = info.weather;
- json tiles = json::array();
- int square = info.width*info.height;
- for (int i = 0; i < square; i++)
- {
- json tile;
- tile["fg"] = info.items[i].foreground;
- tile["bg"] = info.items[i].background;
- tiles.push_back(tile);
- }
- j["tiles"] = tiles;
- o << j << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment