void dmz::InputPluginMouseEventToMessage::_get_targets ( const String &Name, Config &config, HandleContainer &targets) { Config targetList; if (config.lookup_all_config (Name, targetList)) { ConfigIterator it; Config targetConfig; while (targetList.get_next_config (it, targetConfig)) { const String TargetName (config_to_string ("name", targetConfig)); if (TargetName) { const Handle Target (_defs.create_named_handle (TargetName)); targets.add_handle (Target); } else { _log.error << "Unable to add unnamed target" << endl; } } } else if ((&targets) != (&_targetTable)) { targets = _targetTable; } }
// RuntimeModule Interface virtual void get_plugin_list (HandleContainer &container) { HashTableHandleIterator it; PluginStruct *ps (0); while (pluginTable.get_next (it, ps)) { container.add_handle (it.get_hash_key ()); } }
void dmz::ObjectModuleGridBasic::update_object_position ( const UUID &Identity, const Handle ObjectHandle, const Handle AttributeHandle, const Vector &Value, const Vector *PreviousValue) { ObjectStruct *current (_objTable.lookup (ObjectHandle)); if (current && _grid) { current->pos = Value; const Int32 OldPlace = current->place; const Int32 Place = _map_point (Value); if (Place != current->place) { _remove_object_from_grid (*current); current->place = Place; _grid[Place].objTable.store (current->Object, current); } if ((Place != OldPlace) && (OldPlace >= 0)) { HashTableHandleIterator it; GridStruct *cell = &(_grid[OldPlace]); ObserverStruct *os = cell->obsTable.get_first (it); HandleContainer tested; while (os) { tested.add_handle (os->ObsHandle); _update_observer ( os->obs.get_observer_volume (), *current, *os); os = cell->obsTable.get_next (it); } cell = &(_grid[Place]); os = cell->obsTable.get_first (it); while (os) { if (!tested.contains (os->ObsHandle)) { _update_observer ( os->obs.get_observer_volume (), *current, *os); } os = cell->obsTable.get_next (it); } } else { HashTableHandleIterator it; GridStruct *cell = &(_grid[Place]); ObserverStruct *os = cell->obsTable.get_first (it); while (os) { _update_observer ( os->obs.get_observer_volume (), *current, *os); os = cell->obsTable.get_next (it); } } } }
void dmz::ObjectModuleGridBasic::find_objects ( const Volume &SearchSpace, HandleContainer &objects, const ObjectTypeSet *IncludeTypes, const ObjectTypeSet *ExcludeTypes) { Vector origin, min, max; SearchSpace.get_extents (origin, min, max); Int32 minX = 0, minY = 0, maxX = 0, maxY = 0; _map_point_to_coord (min, minX, minY); _map_point_to_coord (max, maxX, maxY); ObjectStruct *list (0); // HandleContainer found; for (Int32 ix = minX; ix <= maxX; ix++) { for (Int32 jy = minY; jy <= maxY; jy++) { HashTableHandleIterator it; GridStruct *cell = &(_grid[_map_coord (ix, jy)]); ObjectStruct *current = cell->objTable.get_first (it); while (current) { Boolean test (True); if (IncludeTypes && !IncludeTypes->contains_type (current->Type)) { test = False; } else if (ExcludeTypes && ExcludeTypes->contains_type (current->Type)) { test = False; } if (test && SearchSpace.contains_point (current->pos)) { #if 0 if (!found.add_handle (current->Object)) { _log.error << "origin: " << origin << endl << "minX: " << minX << endl << "minY: " << minY << endl << "maxX: " << maxX << endl << "maxY: " << maxY << endl; HandleContainer cc; for (Int32 xx = minX; xx <= maxX; xx++) { for (Int32 yy = minY; yy <= maxY; yy++) { Boolean s = cc.add_handle ((Handle)_map_coord (xx, yy)); _log.error << (s ? "" : "##### NOT UNIQUE ") << xx << " " << yy << " = " << _map_coord (xx, yy) << endl; } } } #endif // 0 current->distanceSquared = (origin - current->pos).magnitude_squared (); current->next = 0; if (!list) { list = current; } else { ObjectStruct *p = 0, *c = list; Boolean done (False); while (!done) { if (c->distanceSquared > current->distanceSquared) { if (!c->next) { c->next = current; done = True; } else { p = c; c = c->next; if (!c) { p->next = current; done = True; } } } else { if (p) { p->next = current; } else { list = current; } current->next = c; done = True; } } } } current = cell->objTable.get_next (it); } } } while (list) { if (!objects.add_handle (list->Object)) { _log.error << "Loop detected in object list for object: " << list->Object << endl; list = 0; } else { list = list->next; } } }