static void readList(Tokeniser& tokeniser, malValueVec* items, const String& end) { while (1) { MAL_CHECK(!tokeniser.eof(), "expected '%s', got EOF", end.c_str()); if (tokeniser.peek() == end) { tokeniser.next(); return; } items->push_back(readForm(tokeniser)); } }
void CaelumEnvironment::runCommand(const std::string &command, const std::string &args) { if (SetCaelumTime == command) { Tokeniser tokeniser; tokeniser.initTokens(args); std::string hourString = tokeniser.nextToken(); std::string minuteString = tokeniser.nextToken(); int hour = ::Ogre::StringConverter::parseInt(hourString); int minute = ::Ogre::StringConverter::parseInt(minuteString); setTime(hour, minute); } }
QColor ConfigManager::parseColour(QColor deflt){ QColor c; switch(tok.getnext()){ case T_IDENT: case T_STRING: c = QColor(tok.getstring()); return c; break; case T_DEFAULT: return deflt; default: throw UnexpException(&tok,"colour name or \"#rgb\""); } }
void EmberEntityFactory::runCommand(const std::string &command, const std::string &args) { if (command == ShowModels.getCommand()) { Tokeniser tokeniser; tokeniser.initTokens(args); std::string value = tokeniser.nextToken(); if (value == "true") { S_LOG_INFO("Showing models."); Model::ModelDefinitionManager::getSingleton().setShowModels(true); } else if (value == "false") { S_LOG_INFO("Hiding models."); Model::ModelDefinitionManager::getSingleton().setShowModels(false); } } }
void Map_Read (scene::Node& root, Tokeniser& tokeniser, EntityCreator& entityTable, const PrimitiveParser& parser) { // Create an info display panel to track load progress gtkutil::ModalProgressDialog dialog(GlobalRadiant().getMainWindow(), _("Loading map")); // Read each entity in the map, until EOF is reached for (int entCount = 0; ; entCount++) { // Update the dialog text dialog.setText("Loading entity " + string::toString(entCount)); // Check for end of file if (tokeniser.getToken().empty()) break; // Create an entity node by parsing from the stream NodeSmartReference entity(Entity_parseTokens(tokeniser, entityTable, parser, entCount)); if (entity == g_nullNode) { globalErrorStream() << "entity " << entCount << ": parse error\n"; return; } // Insert the new entity into the scene graph Node_getTraversable(root)->insert(entity); } }
static void parseAudio(){ char warning[1024]; bool speech; DataBuffer<float> *buf = ConfigManager::parseFloatSource(); switch(tok.getnext()){ case T_SAMPLE:speech=false;break; case T_SPEECH:speech=true;break; default: throw UnexpException(&tok,"'speech' or 'sample'"); } tok.getnextstring(warning); getApp()->addAudio(warning,buf,speech); }
void LoggedInState::runCommand(const std::string &command, const std::string &args) { if (Logout == command) { ConsoleBackend::getSingleton().pushMessage("Logging out...", "important"); mAccount.logout(); // Create Character command } else if (CreateChar == command) { // Split string into name/type/sex/description Tokeniser tokeniser = Tokeniser(); tokeniser.initTokens(args); std::string name = tokeniser.nextToken(); std::string sex = tokeniser.nextToken(); std::string type = tokeniser.nextToken(); std::string spawnPoint = tokeniser.nextToken(); std::string description = tokeniser.remainingTokens(); createCharacter(name, sex, type, description, spawnPoint, Atlas::Message::MapType()); // Take Character Command } else if (TakeChar == command) { takeCharacter(args); // List Characters Command } else if (ListChars == command) { mAccount.refreshCharacterInfo(); // Say (In-Game chat) Command } }
void EntityMoveManager::runCommand(const std::string &command, const std::string &args) { if (Move == command) { //the first argument must be a valid entity id Tokeniser tokeniser; tokeniser.initTokens(args); std::string entityId = tokeniser.nextToken(); if (entityId != "") { EmberEntity* entity = mWorld.getEmberEntity(entityId); if (entity != 0) { startMove(*entity); } } else { ConsoleBackend::getSingletonPtr()->pushMessage("You must specify a valid entity id to move.", "error"); } } }
void AccountAvailableState::runCommand(const std::string &command, const std::string &args) { if (CreateAcc == command) { Tokeniser tokeniser = Tokeniser(); tokeniser.initTokens(args); std::string uname = tokeniser.nextToken(); std::string password = tokeniser.nextToken(); std::string realname = tokeniser.remainingTokens(); std::string msg; msg = "Creating account: Name: [" + uname + "], Password: [" + password + "], Real Name: [" + realname + "]"; try { mAccount.createAccount(uname, realname, password); } catch (const std::exception& except) { S_LOG_WARNING("Got error on account creation." << except); return; } catch (...) { S_LOG_WARNING("Got unknown error on account creation."); return; } } else if (Login == command) { // Split string into userid / password pair Tokeniser tokeniser = Tokeniser(); tokeniser.initTokens(args); std::string userid = tokeniser.nextToken(); std::string password = tokeniser.remainingTokens(); mAccount.login(userid, password); std::string msg; msg = "Login: [" + userid + "," + password + "]"; ConsoleBackend::getSingleton().pushMessage(msg, "info"); } }
static void parseWaypoint(){ tok.getnextcheck(T_OCURLY); wpResetDefinitions(); for(;;){ char buf[256]; tok.getnextcheck(T_IDENT); strcpy(buf,tok.getstring()); wpAddField(buf,tok.getnextfloat()); int t = tok.getnext(); if(t==T_CCURLY) break; else if(t!=T_COMMA) throw UnexpException(&tok,"comma or '}'"); } }
static void parseVars(){ tok.getnextcheck(T_OCURLY); for(;;){ int t = tok.getnext(); switch(t){ case T_DIAMOND: // diamond variables #if !DIAMOND throw ParseException(&tok,"diamond not supported in this build"); #else if(!diamondapparatus::isRunning()){ diamondapparatus::init(); } switch(t=tok.getnext()){ case T_NAMEFLOAT: parseAVar(true); break; case T_LINKED: parseLinkedVars(true); break; default: throw UnexpException(&tok,"'float' or 'linked'"); break; } #endif break; case T_NAMEFLOAT: parseAVar(false); break; case T_BOOL: throw ParseException(&tok,"bools not currently supported"); break; case T_LINKED: parseLinkedVars(false); break; case T_CCURLY: return; default:printf("%d\n",tok.getcurrent()); throw UnexpException(&tok); } } }
void NonConnectedState::runCommand(const std::string &command, const std::string &args) { // Connect command if (Connect == command) { // Split string into server / port pair Tokeniser tokeniser = Tokeniser(); tokeniser.initTokens(args); std::string server = tokeniser.nextToken(); std::string port = tokeniser.remainingTokens(); std::string msg; msg = "Connecting to: [" + server + "]"; ConsoleBackend::getSingleton().pushMessage(msg, "info"); if (port == "") connect(server); else connect(server, (short)atoi(port.c_str())); // Disonnect command } }
void ConfigService::runCommand ( const std::string &command, const std::string &args ) { if ( command == SETVALUE ) { Tokeniser tokeniser; tokeniser.initTokens ( args ); std::string section ( tokeniser.nextToken() ); std::string key ( tokeniser.nextToken() ); std::string value ( tokeniser.remainingTokens() ); if ( section == "" || key == "" || value == "" ) { ConsoleBackend::getSingleton().pushMessage ( "Usage: set_value <section> <key> <value>", "help" ); } else { setValue ( section, key, value ); ConsoleBackend::getSingleton().pushMessage ( "New value set, section: " + section + " key: " + key + " value: " + value, "info" ); } } else if ( command == GETVALUE ) { Tokeniser tokeniser; tokeniser.initTokens ( args ); std::string section ( tokeniser.nextToken() ); std::string key ( tokeniser.nextToken() ); if ( section == "" || key == "" ) { ConsoleBackend::getSingleton().pushMessage ( "Usage: get_value <section> <key>", "help" ); } else { if ( !hasItem ( section, key ) ) { ConsoleBackend::getSingleton().pushMessage ( "No such value.", "error" ); } else { varconf::Variable value = getValue ( section, key ); ConsoleBackend::getSingleton().pushMessage ( std::string ( "Value: " ) + static_cast<std::string> ( value ), "info" ); } } } }
void UMPFile::parse (Tokeniser &tokeniser) { std::string token = tokeniser.getToken(); while (token.length()) { if (token == "base") { _base = tokeniser.getToken(); if (_base.empty()) { globalErrorStream() << _fileName << ": base without parameter given\n"; return; } } else if (token == "tile") { try { parseTile(tokeniser); } catch (UMPException &e) { globalErrorStream() << _fileName << ": " << e.getMessage() << "\n"; return; } } token = tokeniser.getToken(); } }
bool ConfigFile::Load(const std::string& filename) { // Ctor args: arg 1 (true) => has version info // arg2 (false) => don't use Glue File implementation. File f(true, File::STD); if (!f.OpenRead(filename)) { #ifdef _DEBUG // This is ok for a clean install, so don't complain in a release build. f.ReportError("Couldn't open config file."); #endif return false; } // This config file simply consists of pairs of tokens. The first of each // pair is the key; the second is the value. Tokeniser toker; string configLine; while (f.GetDataLine(&configLine)) { string key; string value; if (!toker.Tokenise(&configLine, &key)) { string error = "No value for " + key + " in config file."; f.ReportError(error); return false; } // Tokeniser chops head (the key) off configLine, leaving the value tail. value = configLine; // Set value in map. Set(key, value); } // No more tokens. This is ok, we have finished. return true; }
static malValuePtr readAtom(Tokeniser& tokeniser) { struct ReaderMacro { const char* token; const char* symbol; }; ReaderMacro macroTable[] = { { "@", "deref" }, { "`", "quasiquote" }, { "'", "quote" }, { "~@", "splice-unquote" }, { "~", "unquote" }, }; struct Constant { const char* token; malValuePtr value; }; Constant constantTable[] = { { "false", mal::falseValue() }, { "nil", mal::nilValue() }, { "true", mal::trueValue() }, }; String token = tokeniser.next(); if (token[0] == '"') { return mal::string(unescape(token)); } if (token[0] == ':') { return mal::keyword(token); } if (token == "^") { malValuePtr meta = readForm(tokeniser); malValuePtr value = readForm(tokeniser); // Note that meta and value switch places return mal::list(mal::symbol("with-meta"), value, meta); } for (auto &constant : constantTable) { if (token == constant.token) { return constant.value; } } for (auto ¯o : macroTable) { if (token == macro.token) { return processMacro(tokeniser, macro.symbol); } } if (std::regex_match(token, intRegex)) { return mal::integer(token); } return mal::symbol(token); }
void InspectWidget::runCommand(const std::string &command, const std::string &args) { if(Inspect == command && EmberOgre::getSingleton().getWorld()) { //the first argument must be a valid entity id Tokeniser tokeniser; tokeniser.initTokens(args); std::string entityId = tokeniser.nextToken(); if (entityId != "") { EmberEntity* entity = EmberOgre::getSingleton().getWorld()->getEmberEntity(entityId); if (entity != 0) { startInspecting(entity); } } else { ConsoleBackend::getSingletonPtr()->pushMessage("You must specifify a valid entity id to inspect.", "error"); } } else { Widget::runCommand(command, args); } }
void Map_Read(scene::Node& root, Tokeniser& tokeniser, EntityCreator& entityTable, const PrimitiveParser& parser) { int count_entities = 0; for(;;) { tokeniser.nextLine(); if (!tokeniser.getToken()) // { or 0 break; NodeSmartReference entity(Entity_parseTokens(tokeniser, entityTable, parser, count_entities)); if(entity == g_nullNode) { globalErrorStream() << "entity " << count_entities << ": parse error\n"; return; } Node_getTraversable(root)->insert(entity); ++count_entities; } }
DataBuffer<float> *ConfigManager::parseFloatSource(){ DataBuffer<float> *b; char buf[256]; switch(tok.getnext()){ case T_VAR: tok.getnextident(buf); b = DataManager::findFloatBuffer(buf); if(!b) throw ParseException(&tok).set("undefined variable '%s'",buf); break; case T_EXPR: tok.getnextstring(buf); // OK, we're going to lose a reference to this, but such is life. // In this version we never delete expressions anyway. try { b = (new Expression(buf))->buffer; } catch(Exception& e){ throw Exception(e,tok.getline()); } // now parse the extra bits tok.getnextcheck(T_RANGE); float mn,mx; switch(tok.getnext()){ case T_INT: case T_FLOAT: mn = tok.getfloat(); tok.getnextcheck(T_TO); mx = tok.getnextfloat(); b->setMinMax(mn,mx); break; case T_AUTO: b->setAutoRange(); break; default: throw UnexpException(&tok,"expected number or 'auto'"); } break; default: throw UnexpException(&tok,"'var' or 'expr'"); } return b; }
bool UFOFaceTokenImporter::importTextureName (FaceShader& faceShader, Tokeniser& tokeniser) { const std::string texture = tokeniser.getToken(); if (texture.empty()) { Tokeniser_unexpectedError(tokeniser, texture, "#texture-name"); return false; } if (texture == "NULL" || texture.empty()) { faceShader.setShader(""); } else { faceShader.setShader(GlobalTexturePrefix_get() + texture); } return true; }
NudgeType ConfigManager::parseNudgeType(){ switch(tok.getnext()){ case T_UP: return UP; case T_DOWN: return DOWN; case T_MIN: return MIN; case T_MAX: return MAX; case T_CENTRE: return CENTRE; default: throw UnexpException(&tok,"nudge type (up, down, centre)"); } }
/// handy function for creating a buffer of any type - mn and mx will be cast from float or just ignored, /// whatever is appropriate for the type. static RawDataBuffer *createVar(int type, const char *s, int size,float mn=0,float mx=1){ switch(type){ case T_NAMEFLOAT: if(DataManager::findFloatBuffer(s)) throw Exception(tok.getline()).set("variable %s already exists",s); else { printf("Adding var %s, size %d, range (%f,%f)\n",s,size,mn,mx); return DataManager::createFloatBuffer(s,size,mn,mx); } break; default: throw ParseException(&tok).set("unsupported type for variable %s",s); } return NULL; }
static void parseContainer(QWidget *parent){ // now start reading widgets for(;;){ switch(tok.getnext()){ case T_FRAME: parseFrame(parent); break; case T_GAUGE: new Gauge(parent,&tok); break; case T_NUMBER: new Number(parent,&tok); break; case T_COMPASS: new Compass(parent,&tok); break; case T_GRAPH: new Graph(parent,&tok); break; case T_MAP: #if MARBLE new MapWidget(parent,&tok); #else throw ParseException(&tok,"map not supported in this build"); #endif break; case T_STATUS: new StatusBlockWrapper(parent,&tok); break; case T_SWITCH: new Switch(parent,&tok); break; case T_MOMENTARY: new Momentary(parent,&tok); break; case T_SLIDER: new Slider(parent,&tok); break; case T_CCURLY: return; default: throw UnexpException(&tok,"widget name"); } } }
void LicenseParser::parseLicensesFile (Tokeniser& tokeniser, const std::string& filename) { for (;;) { std::string token = tokeniser.getToken(); if (token.empty()) break; if (tokeniser.getLine() > 1) { tokeniser.ungetToken(); break; } } std::size_t lastLine = 1; for (;;) { std::string token = tokeniser.getToken(); if (token.empty()) break; if (string::contains(token, "base/textures/") && lastLine != tokeniser.getLine()) { _licensesMap[os::stripExtension(token.substr(5))] = true; lastLine = tokeniser.getLine(); } } }
bool EntityClassDoom3_parseString( Tokeniser& tokeniser, CopiedString& s ){ const char* token = tokeniser.getToken(); PARSE_RETURN_FALSE_IF_FAIL( token != 0 ); s = token; return true; }
bool EntityClassDoom3_parseToken( Tokeniser& tokeniser, const char* string ){ const char* token = tokeniser.getToken(); PARSE_RETURN_FALSE_IF_FAIL( token != 0 ); return string_equal( token, string ); }
bool EntityClassDoom3_parseToken( Tokeniser& tokeniser ){ const char* token = tokeniser.getToken(); PARSE_RETURN_FALSE_IF_FAIL( token != 0 ); return true; }
static bool EntityClass_parse( EntityClass& entityClass, Tokeniser& tokeniser ){ PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, entityClass.m_name ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "{" ) ); tokeniser.nextLine(); StringOutputStream usage( 256 ); StringOutputStream description( 256 ); CopiedString* currentDescription = 0; StringOutputStream* currentString = 0; for (;; ) { const char* key; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, key ) ); const char* last = string_findFirstSpaceOrTab( key ); CopiedString first( StringRange( key, last ) ); if ( !string_empty( last ) ) { last = string_findFirstNonSpaceOrTab( last ); } if ( currentString != 0 && string_equal( key, "\\" ) ) { tokeniser.nextLine(); *currentString << " "; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, *currentString ) ); continue; } if ( currentDescription != 0 ) { *currentDescription = description.c_str(); description.clear(); currentDescription = 0; } currentString = 0; if ( string_equal( key, "}" ) ) { tokeniser.nextLine(); break; } else if ( string_equal( key, "model" ) ) { const char* token; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) ); entityClass.fixedsize = true; StringOutputStream buffer( 256 ); buffer << PathCleaned( token ); entityClass.m_modelpath = buffer.c_str(); } else if ( string_equal( key, "editor_color" ) ) { const char* value; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) ); if ( !string_empty( value ) ) { entityClass.colorSpecified = true; bool success = string_parse_vector3( value, entityClass.color ); ASSERT_MESSAGE( success, "editor_color: parse error" ); } } else if ( string_equal( key, "editor_ragdoll" ) ) { //bool ragdoll = atoi(tokeniser.getToken()) != 0; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } else if ( string_equal( key, "editor_mins" ) ) { entityClass.sizeSpecified = true; const char* value; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) ); if ( !string_empty( value ) && !string_equal( value, "?" ) ) { entityClass.fixedsize = true; bool success = string_parse_vector3( value, entityClass.mins ); ASSERT_MESSAGE( success, "editor_mins: parse error" ); } } else if ( string_equal( key, "editor_maxs" ) ) { entityClass.sizeSpecified = true; const char* value; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) ); if ( !string_empty( value ) && !string_equal( value, "?" ) ) { entityClass.fixedsize = true; bool success = string_parse_vector3( value, entityClass.maxs ); ASSERT_MESSAGE( success, "editor_maxs: parse error" ); } } else if ( string_equal( key, "editor_usage" ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, usage ) ); currentString = &usage; } else if ( string_equal_n( key, "editor_usage", 12 ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, usage ) ); currentString = &usage; } else if ( string_equal( key, "editor_rotatable" ) || string_equal( key, "editor_showangle" ) || string_equal( key, "editor_showangles" ) // typo? in prey movables.def || string_equal( key, "editor_mover" ) || string_equal( key, "editor_model" ) || string_equal( key, "editor_material" ) || string_equal( key, "editor_combatnode" ) || ( !string_empty( last ) && string_equal( first.c_str(), "editor_gui" ) ) || string_equal_n( key, "editor_copy", 11 ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } else if ( !string_empty( last ) && ( string_equal( first.c_str(), "editor_var" ) || string_equal( first.c_str(), "editor_string" ) ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "string"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_float" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "string"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_snd" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "sound"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_bool" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "boolean"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_int" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "integer"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_model" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "model"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && string_equal( first.c_str(), "editor_color" ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "color"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( !string_empty( last ) && ( string_equal( first.c_str(), "editor_material" ) || string_equal( first.c_str(), "editor_mat" ) ) ) { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, last ).second; attribute.m_type = "shader"; currentDescription = &attribute.m_description; currentString = &description; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, description ) ); } else if ( string_equal( key, "inherit" ) ) { entityClass.inheritanceResolved = false; ASSERT_MESSAGE( entityClass.m_parent.empty(), "only one 'inherit' supported per entityDef" ); const char* token; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) ); entityClass.m_parent.push_back( token ); } // begin quake4-specific keys else if ( string_equal( key, "editor_targetonsel" ) ) { //const char* value = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } else if ( string_equal( key, "editor_menu" ) ) { //const char* value = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } else if ( string_equal( key, "editor_ignore" ) ) { //const char* value = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } // end quake4-specific keys // begin ignore prey (unknown/unused?) entity keys else if ( string_equal( key, "editor_light" ) || string_equal( key, "editor_def def_debrisspawner" ) || string_equal( key, "editor_def def_drop" ) || string_equal( key, "editor_def def_guihand" ) || string_equal( key, "editor_def def_mine" ) ) { //const char* value = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); } // end ignore prey entity keys else { CopiedString tmp( key ); if ( string_equal_n( key, "editor_", 7 ) ) { globalErrorStream() << "unsupported editor key " << makeQuoted( key ) ; } EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, key ).second; attribute.m_type = "string"; const char* value; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, value ) ); if ( string_equal( value, "}" ) ) { // hack for quake4 powerups.def bug globalErrorStream() << "entityDef " << makeQuoted( entityClass.m_name.c_str() ) << " key " << makeQuoted( tmp.c_str() ) << " has no value\n"; break; } else { attribute.m_value = value; } } tokeniser.nextLine(); } entityClass.m_comments = usage.c_str(); if ( string_equal( entityClass.m_name.c_str(), "light" ) ) { { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "light_radius" ).second; attribute.m_type = "vector3"; attribute.m_value = "300 300 300"; } { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "light_center" ).second; attribute.m_type = "vector3"; } { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "noshadows" ).second; attribute.m_type = "boolean"; attribute.m_value = "0"; } { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "nospecular" ).second; attribute.m_type = "boolean"; attribute.m_value = "0"; } { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "nodiffuse" ).second; attribute.m_type = "boolean"; attribute.m_value = "0"; } { EntityClassAttribute& attribute = EntityClass_insertAttribute( entityClass, "falloff" ).second; attribute.m_type = "real"; } } return true; }
bool EntityClassDoom3_parseModel( Tokeniser& tokeniser ){ const char* name; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, name ) ); Model& model = g_models[name]; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "{" ) ); tokeniser.nextLine(); for (;; ) { const char* parameter; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, parameter ) ); if ( string_equal( parameter, "}" ) ) { tokeniser.nextLine(); break; } else if ( string_equal( parameter, "inherit" ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, model.m_parent ) ); tokeniser.nextLine(); } else if ( string_equal( parameter, "remove" ) ) { //const char* remove = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); tokeniser.nextLine(); } else if ( string_equal( parameter, "mesh" ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, model.m_mesh ) ); tokeniser.nextLine(); } else if ( string_equal( parameter, "skin" ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, model.m_skin ) ); tokeniser.nextLine(); } else if ( string_equal( parameter, "offset" ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "(" ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, ")" ) ); tokeniser.nextLine(); } else if ( string_equal( parameter, "channel" ) ) { //const char* channelName = PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseToken( tokeniser, "(" ) ); for (;; ) { const char* end; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, end ) ); if ( string_equal( end, ")" ) ) { tokeniser.nextLine(); break; } } } else if ( string_equal( parameter, "anim" ) ) { CopiedString animName; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, animName ) ); const char* animFile; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, animFile ) ); model.m_anims.insert( Model::Anims::value_type( animName, animFile ) ); const char* token; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) ); while ( string_equal( token, "," ) ) { PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, animFile ) ); PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, token ) ); } if ( string_equal( token, "{" ) ) { for (;; ) { const char* end; PARSE_RETURN_FALSE_IF_FAIL( EntityClassDoom3_parseString( tokeniser, end ) ); if ( string_equal( end, "}" ) ) { tokeniser.nextLine(); break; } tokeniser.nextLine(); } } else { tokeniser.ungetToken(); } } else { globalErrorStream() << "unknown model parameter: " << makeQuoted( parameter ) << "\n"; return false; } tokeniser.nextLine(); } return true; }
bool EntityClassDoom3_parseString( Tokeniser& tokeniser, StringOutputStream& s ){ const char* token = tokeniser.getToken(); PARSE_RETURN_FALSE_IF_FAIL( token != 0 ); s << token; return true; }