featfix.cc 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include <iostream>
  2. #include <stdexcept>
  3. #include "../serialize.h"
  4. #include "../common_types.h"
  5. #include "../common.h"
  6. #include "../permafeats.h"
  7. int main(int argc, char** argv) {
  8. try {
  9. serialize::Source source(argv[1]);
  10. serialize::Sink sink(argv[2]);
  11. while (1) {
  12. try {
  13. permafeats::key_t key;
  14. permafeats::pt xy;
  15. tag_t tag;
  16. serialize::read(source, key);
  17. serialize::read(source, xy);
  18. serialize::read(source, tag);
  19. bool walk = true;
  20. bool water = false;
  21. if (tag.null()) {
  22. serialize::read(source, walk);
  23. serialize::read(source, water);
  24. }
  25. //
  26. serialize::write(sink, key);
  27. serialize::write(sink, xy);
  28. serialize::write(sink, tag);
  29. if (!tag.null()) {
  30. serialize::write(sink, -1);
  31. serialize::write(sink, -1);
  32. } else {
  33. serialize::write(sink, walk);
  34. serialize::write(sink, water);
  35. }
  36. serialize::write(sink, -1);
  37. } catch (...) {
  38. break;
  39. }
  40. }
  41. } catch (std::exception& e) {
  42. std::cerr << "Fatal error: " << e.what() << std::endl;
  43. return 1;
  44. } catch (...) {
  45. std::cerr << "Unknown fatal error." << std::endl;
  46. return 1;
  47. }
  48. return 0;
  49. }