| 69 | } |
| 70 | |
| 71 | void Quake3MapReader::parsePrimitive(parser::DefTokeniser& tok, const scene::INodePtr& parentEntity) |
| 72 | { |
| 73 | _primitiveCount++; |
| 74 | |
| 75 | std::string primitiveKeyword = tok.peek(); |
| 76 | |
| 77 | // Get a parser for this keyword |
| 78 | PrimitiveParsers::const_iterator p = _primitiveParsers.find(primitiveKeyword); |
| 79 | |
| 80 | if (p == _primitiveParsers.end()) |
| 81 | { |
| 82 | throw FailureException("Unknown primitive type: " + primitiveKeyword); |
| 83 | } |
| 84 | |
| 85 | const PrimitiveParserPtr& parser = p->second; |
| 86 | |
| 87 | // All primitive formats except for the legacy brushDef format have a proper keyword |
| 88 | // which should be parsed away before reading in the tokens. |
| 89 | if (primitiveKeyword != "(") |
| 90 | { |
| 91 | tok.nextToken(); |
| 92 | } |
| 93 | |
| 94 | // Try to parse the primitive, throwing exception if failed |
| 95 | try |
| 96 | { |
| 97 | scene::INodePtr primitive = parser->parse(tok); |
| 98 | |
| 99 | if (!primitive) |
| 100 | { |
| 101 | std::string text = fmt::format(_("Primitive #{0:d}: parse error"), _primitiveCount); |
| 102 | throw FailureException(text); |
| 103 | } |
| 104 | |
| 105 | // Now add the primitive as a child of the entity |
| 106 | _importFilter.addPrimitiveToEntity(primitive, parentEntity); |
| 107 | } |
| 108 | catch (parser::ParseException& e) |
| 109 | { |
| 110 | // Translate ParseExceptions to FailureExceptions |
| 111 | std::string text = fmt::format(_("Primitive #{0:d}: parse exception {1}"), _primitiveCount, e.what()); |
| 112 | throw FailureException(text); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | scene::INodePtr Quake3MapReader::createEntity(const EntityKeyValues& keyValues) |
| 117 | { |
nothing calls this directly
no test coverage detected