/** * \brief Constructor. */ tunnel::player_pending_action::player_pending_action( const std::string & str ) { std::vector<std::string> params; claw::text::split(params, str, '|'); if ( params.size() == 5 ) { size_t t; std::istringstream iss0(params[0]); iss0 >> t; if ( t == start_action ) pending_type = start_action; else if ( t == stop_action ) pending_type = stop_action; else pending_type = do_action; std::istringstream iss1(params[1]); iss1 >> date; std::istringstream iss2(params[2]); iss2 >> player_index; std::istringstream iss3(params[3]); iss3 >> action; std::istringstream iss4(params[4]); iss4 >> duration; }
RTC::ReturnCode_t GyroRTC::onInitialize() { // Registration: InPort/OutPort/Service // <rtc-template block="registration"> // Set InPort buffers // Set OutPort buffer addOutPort("gyro", m_gyroOut); // Set service provider to Ports // Set service consumers to Ports // Set CORBA Service Ports // </rtc-template> // <rtc-template block="bind_config"> // Bind variables and configuration variable bindParameter("objectName", m_objectName, "none"); //bindParameter("geometry_offset", m_offsetStr, "0,0,0,0,0,0"); //bindParameter("maxGyro", m_maxGyro, "30.0"); //bindParameter("minGyro", m_minGyro, "0.3"); // </rtc-template> std::cout << " - Initializing GyroRTC: " << m_properties.getProperty("conf.default.objectName") << std::endl; std::string tubehandle = m_properties.getProperty("conf.__innerparam.tubeHandle"); std::istringstream iss0(tubehandle); iss0 >> m_tubeHandle; std::cout << " -- TubeHandle = " << m_tubeHandle << std::endl; std::string objhandle = m_properties.getProperty("conf.__innerparam.objectHandle"); std::istringstream iss1(objhandle); iss1 >> m_objectHandle; std::string buflength = m_properties.getProperty("conf.__innerparam.bufSize"); std::istringstream iss2(buflength); iss2 >> m_bufferSize; m_pBuffer = new uint8_t[m_bufferSize]; return RTC::RTC_OK; }
/** * @brief Loads a map into the game. * @param game the game * @param map the map to load */ void MapLoader::load_map(Game &game, Map &map) { map.game = &game; // get the id of the map int id = map.get_id(); // compute the file name, depending on the id std::ostringstream oss; oss << "maps/map" << std::setfill('0') << std::setw(4) << id << ".dat"; const std::string &file_name = oss.str(); // open the map file std::istream &map_file = FileTools::data_file_open(file_name); // parse the map file std::string line; TilesetId tileset_id; int x, y, width, height; // first line: map general info // syntax: width height world floor x y small_keys_variable tileset_id music_id if (!std::getline(map_file, line)) { Debug::die(StringConcat() << "Cannot load map '" << id << "': the file '" << file_name << "' is empty"); } std::istringstream iss0(line); FileTools::read(iss0, width); FileTools::read(iss0, height); FileTools::read(iss0, map.world); FileTools::read(iss0, map.floor); FileTools::read(iss0, x); FileTools::read(iss0, y); FileTools::read(iss0, map.small_keys_variable); FileTools::read(iss0, tileset_id); FileTools::read(iss0, map.music_id); map.location.set_size(width, height); map.width8 = width / 8; map.height8 = height / 8; map.location.set_xy(x, y); map.tileset = new Tileset(tileset_id); map.tileset->load(); // initialize data MapEntities &entities = map.get_entities(); entities.map_width8 = map.width8; entities.map_height8 = map.height8; entities.tiles_grid_size = map.width8 * map.height8; for (int layer = 0; layer < LAYER_NB; layer++) { entities.animated_tiles[layer] = new bool[entities.tiles_grid_size]; entities.obstacle_tiles[layer] = new Obstacle[entities.tiles_grid_size]; Obstacle initial_obstacle = (layer == LAYER_LOW) ? OBSTACLE_NONE : OBSTACLE_EMPTY; for (int i = 0; i < entities.tiles_grid_size; i++) { entities.animated_tiles[layer][i] = false; entities.obstacle_tiles[layer][i] = initial_obstacle; } } entities.boomerang = NULL; // read the entities while (std::getline(map_file, line)) { int entity_type, layer; std::istringstream iss(line); FileTools::read(iss, entity_type); FileTools::read(iss, layer); FileTools::read(iss, x); FileTools::read(iss, y); MapEntity *entity = MapEntity::creation_functions[entity_type](game, iss, Layer(layer), x, y); entities.add_entity(entity); } FileTools::data_file_close(map_file); // load the script map.script = new MapScript(map); map.camera = new Camera(map); }
void ComponentFactory::ParseType(Serializer& _ser, tinyxml2::XMLElement* _element) { const natChar *type_str = _element->Attribute("type"); ref_t type = Hash::Compute(type_str); if(type == s_type_ref_t) { const natChar* value = _element->Attribute("value"); ref_t ref; if(strcmp(value, "") != 0) { ref = Hash::Compute(value); } else { ref = 0; } _ser << ref; } else if(type == s_type_tex_t) { const natChar* value = _element->Attribute("value"); ref_t ref; if(strcmp(value, "") != 0) { ref = Hash::Compute(value); // add it to preload TextureManager* texturemanager = GetEntity()->GetKernel()->GetLayer(Layer::s_LayerManager)->GetRootEntity()->GetComponent<TextureManager>(); texturemanager->Preload(value); } else { ref = 0; } _ser << ref; } else if(type == s_type_natBool) { natBool value = _element->BoolAttribute("value"); _ser << value; } else if(type == s_type_natChar) { const natChar* value = _element->Attribute("value"); natChar value0 = value[0]; _ser << value0; } else if(type == s_type_natU8) { const natU8* value = reinterpret_cast<const natU8*>(_element->Attribute("value")); natU8 value0 = value[0]; _ser << value0; } else if(type == s_type_natS8) { const natS8* value = reinterpret_cast<const natS8*>(_element->Attribute("value")); natS8 value0 = value[0]; _ser << value0; } else if(type == s_type_natU16) { natU16 value = static_cast<natU16>(_element->IntAttribute("value")); _ser << value; } else if(type == s_type_natS16) { natS16 value = static_cast<natS16>(_element->IntAttribute("value")); _ser << value; } else if(type == s_type_natU32) { natU32 value = static_cast<natU32>(_element->IntAttribute("value")); _ser << value; } else if(type == s_type_natS32) { natS32 value = static_cast<natS32>(_element->IntAttribute("value")); _ser << value; } else if(type == s_type_natU64) { natU64 value = static_cast<natU64>(_element->IntAttribute("value")); _ser << value; } else if(type == s_type_natS64) { natS64 value = static_cast<natS64>(_element->IntAttribute("value")); _ser << value; } else if(type == s_type_natF32) { natF32 value = static_cast<natF32>(_element->FloatAttribute("value")); _ser << value; } else if(type == s_type_natF64) { natF64 value = static_cast<natF64>(_element->DoubleAttribute("value")); _ser << value; } else if(type == s_type_std_string) { const natChar* value = _element->Attribute("value"); std::string str = value; _ser << str; } else if(type == s_type_glm_vec2) { // ugly stl const natChar* value = _element->Attribute("value"); std::istringstream iss(value); std::string value0; std::string value1; glm::vec2 ret; std::getline(iss, value0, ' '); if(!std::getline(iss, value1, ' ')) { value1 = "0"; } std::istringstream iss0(value0); iss0 >> ret.x; std::istringstream iss1(value1); iss1 >> ret.y; _ser << ret; } else if(type == s_type_glm_vec3)