MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / writeWorld

Method writeWorld

src/clientbase/World.cpp:854–1063  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

852
853
854bool 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()) {

Callers 2

executeMethod · 0.80
operator()Method · 0.80

Calls 15

getWorldDirNameFunction · 0.85
writeDefaultOBJMaterialsFunction · 0.85
writeOBJGroundFunction · 0.85
isTrueMethod · 0.80
c_strMethod · 0.80
createDataOutStreamMethod · 0.80
evalMethod · 0.80
printMTLMethod · 0.80
printReferenceMethod · 0.80
printMethod · 0.45
iterateMethod · 0.45
getDefaultMethod · 0.45

Tested by

no test coverage detected