| 852 | |
| 853 | |
| 854 | bool World::writeWorld(const std::string& filename, std::string& fullname) { |
| 855 | const bool saveAsOBJ = BZDB.isTrue("saveAsOBJ"); |
| 856 | if (saveAsOBJ) { |
| 857 | indent = "# "; |
| 858 | } |
| 859 | else { |
| 860 | indent = ""; |
| 861 | } |
| 862 | |
| 863 | fullname = getWorldDirName(); |
| 864 | fullname += filename; |
| 865 | if (saveAsOBJ) { |
| 866 | if (strstr(fullname.c_str(), ".obj") == NULL) { |
| 867 | fullname += ".obj"; |
| 868 | } |
| 869 | } |
| 870 | else { |
| 871 | if (strstr(fullname.c_str(), ".bzw") == NULL) { |
| 872 | fullname += ".bzw"; |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | std::ostream* stream = FILEMGR.createDataOutStream(fullname.c_str()); |
| 877 | if (stream == NULL) { |
| 878 | return false; |
| 879 | } |
| 880 | |
| 881 | // for notational convenience |
| 882 | std::ostream& out = *stream; |
| 883 | |
| 884 | time_t nowTime = time(NULL); |
| 885 | out << "# BZFlag client: saved world on " << ctime(&nowTime) << std::endl; |
| 886 | |
| 887 | // Write the Map Information |
| 888 | mapInfo.print(out, indent); |
| 889 | |
| 890 | // Write the Server Options |
| 891 | { |
| 892 | out << indent << "options" << std::endl; |
| 893 | |
| 894 | // FIXME - would be nice to get a few other thing |
| 895 | // -fb, -sb, rabbit style, a real -mp, etc... (also, flags?) |
| 896 | |
| 897 | if (allowTeamFlags()) { |
| 898 | out << indent << " -c" << std::endl; |
| 899 | out << indent << " -mp 2,"; |
| 900 | for (int t = RedTeam; t <= PurpleTeam; t++) { |
| 901 | out << ((getBase(t, 0) == NULL) ? "0," : "2,"); |
| 902 | } |
| 903 | out << "2" << std::endl; |
| 904 | } |
| 905 | if (allowRabbit()) { |
| 906 | out << indent << " -rabbit" << std::endl; |
| 907 | } |
| 908 | if (allowJumping()) { |
| 909 | out << indent << " -j" << std::endl; |
| 910 | } |
| 911 | if (allShotsRicochet()) { |
no test coverage detected