void PinTimer::begin(Updater& up,Connectable* who) { PinControl::begin(who); up.add(this); }
void SerialLineIn::begin(Updater& up) { up.add(this); }
void RtcEvTable::begin(Updater& up) { up.add(this); begin(); }
void SpawnerMgr::load(const string& root_dir, const string& index_fn) { AutoLock lock(_lock); if (_inited) return; _root_dir = root_dir; _index_fn = index_fn; ifstream file(index_fn.c_str()); if (!file.good()) { LogError(LN, "Could not open spaners conf : %s", index_fn.c_str()); return; } _inited = true; string buf; while (getline(file, buf)) { if (buf.empty()) continue; // empty line. int i = 0; while ((buf[i] == ' ' || buf[i] == '\t')&& i < buf.size()) { ++i; } if (i == buf.size()) continue; // only has space. if (buf[i] == '#') continue; //commented. LogDebug(LN, "Processing %s", buf.c_str()); LogDebug(LN, "start from : %d", i); if (buf[i] == '[') { SMF_Node node; int j = buf.find(']', i); if (j == buf.npos) { LogDebug(LN, "Can not found ]"); continue; } node._index = conversion_cast<unsigned int>(buf.substr(i + 1, j)); if (read_node(file, node)) { // load spawner. int id = 0 - node._index; if(_smf_nodes.find(id) == _smf_nodes.end()) { Spawner* s = new Spawner(id); string path = root_dir + "/"; path += node._file_name; s->load(path); // TODO: _spawners.push_back(s); _smf_nodes.insert(make_pair<int, SMF_Node>(id, node)); } else { //TODO: } } } else { LogError(LN, "Incorrect formate found!!"); } } Updater* updater = WorldMgr::get_singleton().get_updater(); MapMgr* map_mgr = MapMgr::get_instance(); for (std::list<Spawner*>::iterator ptr = _spawners.begin(); ptr != _spawners.end(); ++ptr) { Map* map = map_mgr->get_map((*ptr)->get_spawn_info()._map); if (!map) continue; map->add_unit(*ptr); updater->add(*ptr); } LogSuccess(LN, "Loaded spawner conf successful, count : %u", _smf_nodes.size()); }