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

Function parseDrawInfoConfig

tools/modeltool/modeltool.cpp:803–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

801//============================================================================//
802
803void parseDrawInfoConfig(DrawInfoConfig& config, std::string file) {
804 std::string text;
805 FILE* fp = fopen(file.c_str(), "rb");
806 if (!fp) {
807 return;
808 }
809
810 fseek(fp, 0, SEEK_END);
811 int size = ftell(fp);
812 fseek(fp, 0, SEEK_SET);
813
814 if (size) {
815 char* t = (char*)malloc(size + 1);
816 fread(t, size, 1, fp);
817 t[size] = 0;
818 text = t;
819 free(t);
820 }
821 fclose(fp);
822
823 if (!size) {
824 return;
825 }
826
827 text = TextUtils::replace_all(text, std::string("\r"), std::string(""));
828 std::vector<std::string> lines = TextUtils::tokenize(text, std::string("\n"));
829 if (!lines.size()) {
830 return;
831 }
832
833 int numLines = (int)lines.size();
834 for (int i = 0; i < numLines; i++) {
835 std::string& line = lines[i];
836 if (!line.size()) {
837 continue;
838 }
839
840 std::vector<std::string> chunks = TextUtils::tokenize(line, std::string(" "), 0, true);
841 if (!chunks.size()) {
842 continue;
843 }
844
845 std::string key = TextUtils::tolower(chunks[0]);
846 if (key == "static") {
847 config.staticFile = chunks[1];
848 }
849 else if (key == "bounding") {
850 config.boundingFile = chunks[1];
851 }
852 else if (key == "anim") {
853 config.animComands.push_back(chunks[1]);
854 }
855 else if (key == "lod") {
856 if (chunks.size() > 2) {
857 config.lodPixelDistances.push_back((float)atof(chunks[1].c_str()));
858 config.lodFiles.push_back(chunks[2].c_str());
859 }
860 }

Callers 1

mainFunction · 0.85

Calls 6

tolowerFunction · 0.85
c_strMethod · 0.80
replace_allFunction · 0.50
tokenizeFunction · 0.50
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected