Example #1
0
void Spawn::checkSpawn()
{
	checkSpawnEvent = 0;

	cleanup();

	uint32_t spawnCount = 0;

	for (auto& it : spawnMap) {
		uint32_t spawnId = it.first;
		if (spawnedMap.find(spawnId) != spawnedMap.end()) {
			continue;
		}

		spawnBlock_t& sb = it.second;
		if (OTSYS_TIME() >= sb.lastSpawn + sb.interval) {
			if (findPlayer(sb.pos)) {
				sb.lastSpawn = OTSYS_TIME();
				continue;
			}

			spawnMonster(spawnId, sb.mType, sb.pos, sb.direction);
			if (++spawnCount >= (uint32_t)g_config.getNumber(ConfigManager::RATE_SPAWN)) {
				break;
			}
		}
	}

	if (spawnedMap.size() < spawnMap.size()) {
		checkSpawnEvent = g_scheduler.addEvent(createSchedulerTask(getInterval(), boost::bind(&Spawn::checkSpawn, this)));
	}
}
std::wstring
HLAinteger64Interval::toString() const
{
    std::wstringstream stream;
    stream << getInterval();
    return stream.str();
}
Example #3
0
void PathVset::setDeceleration()
{
  int velocity_change_range = 5;
  double intervel = getInterval();
  double temp1 = _current_vel*_current_vel;
  double temp2 = 2*_decel*intervel;

  for (int i = 0; i < velocity_change_range; i++) {
    if (!checkWaypoint(_closest_waypoint+i, "setDeceleration"))
      continue;
    double waypoint_velocity = current_waypoints_.waypoints[_closest_waypoint+i].twist.twist.linear.x;
    double changed_vel = temp1 - temp2;
    if (changed_vel < 0) {
      changed_vel = _deceleration_minimum * _deceleration_minimum;
    }
    if (sqrt(changed_vel) > waypoint_velocity || _deceleration_minimum > waypoint_velocity)
      continue;
    if (sqrt(changed_vel) < _deceleration_minimum) {
      current_waypoints_.waypoints[_closest_waypoint+i].twist.twist.linear.x = _deceleration_minimum;
      continue;
    }
    current_waypoints_.waypoints[_closest_waypoint+i].twist.twist.linear.x = sqrt(changed_vel);
  }

  return;
}
Example #4
0
bool RenderablePath::initialize() {
    if (!_successfullDictionaryFetch) {
        LERROR("The following keys need to be set in the Dictionary. Cannot initialize!");
        LERROR(keyBody << ": " << _target);
        LERROR(keyObserver << ": " << _observer);
        LERROR(keyFrame << ": " << _frame);
        return false;
    }

    bool completeSuccess = true;


    RenderEngine& renderEngine = OsEng.renderEngine();
    _programObject = renderEngine.buildRenderProgram("PathProgram",
                     "${MODULE_BASE}/shaders/path_vs.glsl",
                     "${MODULE_BASE}/shaders/path_fs.glsl");
    if (!_programObject)
        return false;

    bool intervalSet = hasTimeInterval();
    if (intervalSet) {
        completeSuccess &= getInterval(_start, _stop);
    }

    return completeSuccess;
}
Example #5
0
// set about '_temporal_waypoints_size' meter waypoints from closest waypoint
void PathVset::setTemporalWaypoints()
{
  if (_closest_waypoint < 0)
    return;
  int size = (int)(_temporal_waypoints_size/getInterval())+1;

  temporal_waypoints_.waypoints.clear();
  temporal_waypoints_.header = current_waypoints_.header;
  temporal_waypoints_.increment = current_waypoints_.increment;
  // push current pose
  waypoint_follower::waypoint current_point;

  current_point.pose = _control_pose;
  if (g_sim_mode)
    current_point.pose = _current_pose;
  current_point.twist = current_waypoints_.waypoints[_closest_waypoint].twist;
  current_point.dtlane = current_waypoints_.waypoints[_closest_waypoint].dtlane;
  temporal_waypoints_.waypoints.push_back(current_point);
  for (int i = 0; i < size; i++) {
    if (_closest_waypoint+i >= getSize())
      return;
    temporal_waypoints_.waypoints.push_back(current_waypoints_.waypoints[_closest_waypoint+i]);
  }

  return;
}
Example #6
0
void Spawn::checkSpawn()
{
#ifdef __DEBUG_SPAWN__
	std::clog << "[Notice] Spawn::checkSpawn " << this << std::endl;
#endif
	Monster* monster;
	uint32_t spawnId;

	checkSpawnEvent = 0;
	for(SpawnedMap::iterator it = spawnedMap.begin(); it != spawnedMap.end();)
	{
		spawnId = it->first;
		monster = it->second;
		if(monster->isRemoved())
		{
			if(spawnId)
				spawnMap[spawnId].lastSpawn = OTSYS_TIME();

			monster->unRef();
			spawnedMap.erase(it++);
		}
		else
		{
			/*if(spawnId && !isInSpawnZone(monster->getPosition()) && monster->getIdleStatus())
				g_game.internalTeleport(monster, monster->getMasterPosition(), true);

			*/++it;
		}
	}

	uint32_t spawnCount = 0;
	for(SpawnMap::iterator it = spawnMap.begin(); it != spawnMap.end(); ++it)
	{
		spawnId = it->first;
		spawnBlock_t& sb = it->second;
		if(spawnedMap.count(spawnId))
			continue;

		if(OTSYS_TIME() < sb.lastSpawn + sb.interval)
			continue;

		if(findPlayer(sb.pos))
		{
			sb.lastSpawn = OTSYS_TIME();
			continue;
		}

		spawnMonster(spawnId, sb.mType, sb.pos, sb.direction);
		++spawnCount;
		if(spawnCount >= (uint32_t)g_config.getNumber(ConfigManager::RATE_SPAWN))
			break;
	}

	if(spawnedMap.size() < spawnMap.size())
		checkSpawnEvent = Scheduler::getInstance().addEvent(createSchedulerTask(getInterval(), boost::bind(&Spawn::checkSpawn, this)));
#ifdef __DEBUG_SPAWN__
	else
		std::clog << "[Notice] Spawn::checkSpawn stopped " << this << std::endl;
#endif
}
Example #7
0
void Playlist::getAutoplaySettings(AutoplayStructure *settings) {
    settings->order = getPlayOrder();
    settings->interval = getInterval();
    settings->startMinute = READ_FROM_PLAYLIST(autoplaySettings.startMinute);
    settings->repeatMinutes = READ_FROM_PLAYLIST(autoplaySettings.repeatMinutes);
    settings->count = READ_FROM_PLAYLIST(autoplaySettings.count);
    settings->maxChirps = READ_FROM_PLAYLIST(autoplaySettings.maxChirps);
}
Module* PacketCountFilterCfg::getInstance()
{
	if (!instance)
		instance = new SystematicSampler(SYSTEMATIC_SAMPLER_COUNT_BASED,
						getInterval(), getSpacing());

	return (Module*)instance;
}
Example #9
0
void PathVset::avoidSuddenBraking()
{
  int i = 0;
  int fill_in_zero = 20;
  int fill_in_vel = 15;
  int examin_range = 1; // need to change according to waypoint interval?
  int num;
  double interval = getInterval();
  double changed_vel;

  for (int j = -1; j < examin_range; j++) {
    if (!checkWaypoint(_closest_waypoint+j, "avoidSuddenBraking"))
      return;
    if (getWaypointVelocityMPS(_closest_waypoint+j) < _current_vel - _velocity_change_limit) // we must change waypoints
      break;
    if (j == examin_range-1) // we don't have to change waypoints
      return;
  }


  std::cout << "====avoid sudden braking====" << std::endl;
  std::cout << "vehicle is decelerating..." << std::endl;
  std::cout << "closest_waypoint: " << _closest_waypoint << std::endl;


  // fill in waypoints velocity behind vehicle
  for (num = _closest_waypoint-1; fill_in_vel > 0; fill_in_vel--) {
    if (!checkWaypoint(num-fill_in_vel, "avoidSuddenBraking"))
      continue;
    current_waypoints_.waypoints[num-fill_in_vel].twist.twist.linear.x = _current_vel;
  }

  // decelerate gradually
  double temp1 = (_current_vel-_velocity_change_limit+1.389)*(_current_vel-_velocity_change_limit+1.389);
  double temp2 = 2*_decel*interval;
  for (num = _closest_waypoint-1; ; num++) {
    if (num >= getSize())
      return;
    if (!checkWaypoint(num, "avoidSuddenBraking"))
      continue;
    changed_vel = temp1 - temp2*(double)i; // sqrt(v^2 - 2*a*x)
    if (changed_vel <= 0)
      break;
    current_waypoints_.waypoints[num].twist.twist.linear.x = sqrt(changed_vel);

    i++;
  }

  for (int j = 0; j < fill_in_zero; j++) {
    if (!checkWaypoint(num+j, "avoidSuddenBraking"))
      continue;
    current_waypoints_.waypoints[num+j].twist.twist.linear.x = 0.0;
  }

  std::cout << "====changed waypoints====" << std::endl;

  return;
}
Example #10
0
std::string ReferenceInfo::
        toString() const
{
    stringstream ss;
    ss      << "T[" << r.a.time << ":" << r.b.time << ") "
            << "F[" << r.a.scale << ":" << r.b.scale << ") "
            << "S" << getInterval();
    return ss.str();
}
Example #11
0
static void timer_callback(void *data) {
  DictionaryIterator *iter;
  uint8_t value = 1;
  app_message_outbox_begin(&iter);
  dict_write_int(iter, TEMPERATURE_KEY, &value, 1, true);
  dict_write_end(iter);
  app_message_outbox_send();
  
  weather_timer = app_timer_register(getInterval() * 60 * 1000 /* milliseconds */, timer_callback, NULL);
}
Example #12
0
void IntervalMap::deletePCfromInterval(int interval, PointCell vehicle) {
	node* intvl = getInterval(map, interval);
	if (intvl->tracks == NULL) {
		std::cerr
				<< "ERROR WHILE DELETING PC FROM INTERVAL: NO PC CONTAINED IN INTERVAL!"
				<< std::endl;
		return;
	} else {
		deletePC(intvl->tracks, vehicle, interval);
	}
}
Example #13
0
bool OBB::intersects(const OBB& box) const
{
    float min1, max1, min2, max2;
    for (int i = 0; i < 3; i++)
    {
        getInterval(*this, getFaceDirection(i), min1, max1);
        getInterval(box, getFaceDirection(i), min2, max2);
        if (max1 < min2 || max2 < min1) return false;
    }
    
    for (int i = 0; i < 3; i++)
    {
        getInterval(*this, box.getFaceDirection(i), min1, max1);
        getInterval(box, box.getFaceDirection(i), min2, max2);
        if (max1 < min2 || max2 < min1) return false;
    }
    
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            Vec3 axis;
            Vec3::cross(getEdgeDirection(i), box.getEdgeDirection(j), &axis);
            getInterval(*this, axis, min1, max1);
            getInterval(box, axis, min2, max2);
            if (max1 < min2 || max2 < min1) return false;
        }
    }
    
    return true;
}
float IAlgoGen::getPercent(IntervalType type) const
{
    try
    {
        unsigned char interval = getInterval(type);
        float r = static_cast<float>(interval) / 100.0f;
        return r;
    }
    catch (std::exception&)
    {
        return 0.0f;
    }
}
	/*Create New Appointment if Interval is not Once*/
	void Camera_Appointment::createNewAppointmentBasedFromInterval(sql::Connection *con){
		sql::PreparedStatement  *prep_stmt;

		string new_datetime = getNextIntervalDateTime();

		prep_stmt = con->prepareStatement("INSERT INTO `camera_appointment` (`Date_Taken`, `Camera_ID`, `Interval`) VALUES (?, ?, ?)");
		prep_stmt->setString(1, new_datetime);
		prep_stmt->setInt(2, getCameraId());
		prep_stmt->setString(3, getInterval());
		prep_stmt->execute();

		delete prep_stmt;
	}
void
FocusShootDelayAction:: focusAndShoot()
{
    press();

    if (getInterval() > 0)
    {
        activate();
    }
    else
    {
        release();
    }
}
Example #17
0
void MainWindow::iperfFinished(int exitCode, QProcess::ExitStatus status){
    qDebug()<<"process (throughput) finished with exitCode"<<exitCode;
    //update graph
    updatePlot();
    if(stopRequested){
        //enable start
        stopRequested = false;
        stopTest();
    }else{ //setup a timer to run the test again with given interval.
        timer->start(getInterval());
        ui->statusLabel->setText("WAITING");
    }
    qDebug()<<"test finished properly";
}
Example #18
0
 virtual void substrateValueChanged(double aCurrentTime)
   {
     const double anOldTime(theTime);
     theTime = aCurrentTime + getInterval(aCurrentTime);
     //std::cout << getIDString() << " curr:" << aCurrentTime << " theQueueID:" << theQueueID << " oldTime:" << anOldTime << " theTime:" << theTime << std::endl;
     if(theTime >= anOldTime)
       {
         thePriorityQueue->moveDown(theQueueID);
       }
     else if(theTime < anOldTime)
       {
         thePriorityQueue->moveUp(theQueueID);
       }          
   }
Example #19
0
void CallUserAttention() {
	/* '************************************************* */
	/* 'Author: Unknown */
	/* 'Last modified: 03/10/2010 */
	/* 'Makes noise and FX to call the user's attention. */
	/* '03/10/2010: ZaMa - Adaptado para que funcione mas de un centinela en paralelo. */
	/* '************************************************* */

	/* 'Esta el sistema habilitado? */
	if (!centinelaActivado) {
		return;
	}

	int index;
	int UserIndex;

	int TActual;
	TActual = (vb6::GetTickCount());

	/* ' Chequea todos los centinelas */
	for (index = (1); index <= (NRO_CENTINELA); index++) {

		/* ' Centinela activo? */
		if (Centinela[index].Activo) {

			UserIndex = Centinela[index].RevisandoUserIndex;

			/* ' Esta revisando un usuario? */
			if (UserIndex != 0) {

				if (getInterval(TActual, Centinela[index].SpawnTime) >= 5000) {

					if (!UserList[UserIndex].flags.CentinelaOK) {
						WritePlayWave(UserIndex, SND_WARP, Npclist[Centinela[index].NpcIndex].Pos.X,
								Npclist[Centinela[index].NpcIndex].Pos.Y);
						WriteCreateFX(UserIndex, Npclist[Centinela[index].NpcIndex].Char.CharIndex,
								FXIDs_FXWARP, 0);

						/* 'Resend the key */
						CentinelaSendClave(UserIndex, index);

						FlushBuffer(UserIndex);
					}
				}
			}
		}

	}
}
Example #20
0
/// Calculate the sieving status.
/// @param processed  Sum of recently processed segments.
///
bool PrimeSieve::updateStatus(uint64_t processed, bool waitForLock)
{
  if (isParallelPrimeSieveChild()) {
    toUpdate_ += processed;
    if (parent_->updateStatus(toUpdate_, waitForLock))
      toUpdate_ = 0;
  } else {
    processed_ += processed;
    double percent = processed_ * 100.0 / (getInterval() + 1);
    double old = percent_;
    percent_ = std::min(percent, 100.0);
    if (isFlag(PRINT_STATUS))
      printStatus(old, percent_);
  }
  return true;
}
Example #21
0
static void cb_in_received_handler(DictionaryIterator *iter, void *context) {
  autoconfig_in_received_handler(iter, context);

  Tuple *code_tuple = dict_find(iter, WEATHERCODE_KEY);
  if(code_tuple){
    int32_t weather_code = code_tuple->value->int32;
    APP_LOG(APP_LOG_LEVEL_DEBUG, "code:%ld", weather_code);
    
    if(weather_code != 3200){
        Tuple *temp_tuple = dict_find(iter, TEMPERATURE_KEY);
        if (temp_tuple) {
            int32_t temperature = temp_tuple->value->int32;
            // temperature = -99;
            snprintf(temp_text, sizeof(temp_text), "%ldĀ°", temperature);
            layer_mark_dirty(text_layer_get_layer(text_temp_layer));
        }
        Tuple *city_tuple = dict_find(iter, CITYNAME_KEY);
        if (city_tuple) {
            snprintf(city_text, sizeof(city_text), "%s", city_tuple->value->cstring);
            layer_mark_dirty(text_layer_get_layer(text_city_layer));
        }
        // weather_code = 28;
        if(weather_code > 47){
          weather_code = 0;
        }
    }
    else {
      weather_code = 0;
    }
    if(weather_image){
      gbitmap_destroy(weather_image);
    }
    weather_image = gbitmap_create_with_resource(WEATHER_IMAGE_RESOURCE[weather_code]);
    bitmap_layer_set_bitmap(weather_layer,  weather_image);
  }

  if(dict_find(iter, INTERVAL_PKEY)){
    app_timer_cancel(weather_timer);
    weather_timer = app_timer_register(getInterval() * 1000 /* milliseconds */, timer_callback, NULL);
  }

  if(dict_find(iter, LANGUAGE_PKEY)){
    time_t now = time(NULL);
    struct tm *tick_time = localtime(&now);
    handle_minute_tick(tick_time, MINUTE_UNIT);
  }
}
Example #22
0
int findLongestSubstring(        const char*     p,                                
                                       int       m,   
                                       int*      l,                                                              
                                       int       l0, 
                                       int       r0, 
                                 const ESA*      esa                           )
{

   int c=*l;   
   int i=l0;
   int j=r0;
   

   
   while (getInterval(&i, &j, c, p[c], esa) && c<m)
   {
      if (i!=j)
      {
         int lcp = LI_GET_LCP(i,j,esa);
         
         if (lcp > m)
            lcp = m;               
         for (;c<lcp; c++)
         {
            // Unwind the string comparison for speed.
            if ((esa->t + esa->SA[i])[c] != p[c])
               break;
         }         
      } 
      else
      {
         for (;c<m; c++)
         {              
            // Again, we unwind the string comparison for speed.
            if ((esa->t + esa->SA[i])[c] != p[c])
               break;
         }                   
         break;  
      }
   }
      
   *l = c;   
      
   return esa->SA[i];      

}                                 
Example #23
0
pcNode* IntervalMap::insertPCintoInterval(int interval, PointCell vehicle) {
	node* intvl = getInterval(map, interval);
	if (intvl == NULL) {
		std::cerr << "COULD NOT FIND INTERVALL!!" << std::endl;
	}
	if (intvl->tracks != NULL) {
		return insertPC(intvl->tracks, vehicle);
	} else {
		intvl->tracks = new pcNode;
		intvl->tracks->y = vehicle.stateVector.get(1,0);
		intvl->tracks->vehicle = vehicle;
		intvl->tracks->left = NULL;
		intvl->tracks->right = NULL;
		intvl->tracks->parent = NULL;
		return intvl->tracks;
	}
}
Example #24
0
void PathVset::avoidSuddenAceleration()
{
  double changed_vel;
  double interval = getInterval();
  double temp1 = _current_vel*_current_vel;
  double temp2 = 2*_decel*interval;

  for (int i = 0; ; i++) {
    if (!checkWaypoint(_closest_waypoint+i, "avoidSuddenAceleration"))
      return;
    changed_vel = sqrt(temp1 + temp2*(double)(i+1)) + _velocity_offset;
    if (changed_vel > current_waypoints_.waypoints[_closest_waypoint+i].twist.twist.linear.x)
      return;
    current_waypoints_.waypoints[_closest_waypoint+i].twist.twist.linear.x = changed_vel;
  }

  return;
}
Example #25
0
bool
RTI1516fedTimeInterval::operator<=(rti1516e::LogicalTimeInterval const & value) const
throw (rti1516e::InvalidLogicalTimeInterval)
{
    const RTI1516fedTimeInterval * other = dynamic_cast<const RTI1516fedTimeInterval *>(&value);
    if (other == NULL)
    {
#if defined(_WIN32) && defined(_MSC_VER)
        throw std::wstring(L"Different LogicalTimeInterval implementation");
#else
        //throw rti1516e::InvalidLogicalTimeInterval(L"Different LogicalTimeInterval implementation");
#endif
    } else
    {
        return getInterval() <= other->getInterval();
    }
    return false;
}
Example #26
0
bool Codel::overloaded(std::chrono::nanoseconds delay) {
  bool ret = false;
  auto now = std::chrono::steady_clock::now();

  // Avoid another thread updating the value at the same time we are using it
  // to calculate the overloaded state
  auto minDelay = codelMinDelay_;

  if (now  > codelIntervalTime_ &&
      // testing before exchanging is more cacheline-friendly
      (!codelResetDelay_.load(std::memory_order_acquire)
       && !codelResetDelay_.exchange(true))) {
    codelIntervalTime_ = now + getInterval();

    if (minDelay > getTargetDelay()) {
      overloaded_ = true;
    } else {
      overloaded_ = false;
    }
  }
  // Care must be taken that only a single thread resets codelMinDelay_,
  // and that it happens after the interval reset above
  if (codelResetDelay_.load(std::memory_order_acquire) &&
      codelResetDelay_.exchange(false)) {
    codelMinDelay_ = delay;
    // More than one request must come in during an interval before codel
    // starts dropping requests
    return false;
  } else if(delay < codelMinDelay_) {
    codelMinDelay_ = delay;
  }

  // Here is where we apply different logic than codel proper. Instead of
  // adapting the interval until the next drop, we slough off requests with
  // queueing delay > 2*target_delay while in the overloaded regime. This
  // empirically works better for our services than the codel approach of
  // increasingly often dropping packets.
  if (overloaded_ && delay > getSloughTimeout()) {
    ret = true;
  }

  return ret;

}
Example #27
0
void PathVset::changeWaypoints(int stop_waypoint)
{
  int i = 0;
  int close_waypoint_threshold = 4;
  int fill_in_zero = 20;
  double changed_vel;
  double interval = getInterval();

  // change waypoints to decelerate
  for (int num = stop_waypoint; num > _closest_waypoint - close_waypoint_threshold; num--){
    if (!checkWaypoint(num, "changeWaypoints"))
      continue;

    changed_vel = sqrt(2.0*_decel*(interval*i)); // sqrt(2*a*x)

    //std::cout << "changed_vel[" << num << "]: " << mps2kmph(changed_vel) << " (km/h)";
    //std::cout << "   distance: " << (_obstacle_waypoint-num)*interval << " (m)";
    //std::cout << "   current_vel: " << mps2kmph(_current_vel) << std::endl;

    waypoint_follower::waypoint initial_waypoint = _path_dk.getCurrentWaypoints().waypoints[num];
    if (changed_vel > _velocity_limit || //
	changed_vel > initial_waypoint.twist.twist.linear.x){ // avoid acceleration
      //std::cout << "too large velocity!!" << std::endl;
      current_waypoints_.waypoints[num].twist.twist.linear.x = initial_waypoint.twist.twist.linear.x;
    } else {
      current_waypoints_.waypoints[num].twist.twist.linear.x = changed_vel;
    }

    i++;
  }

  // fill in 0
  for (int j = 1; j < fill_in_zero; j++){
    if (!checkWaypoint(stop_waypoint+j, "changeWaypoints"))
      continue;
    current_waypoints_.waypoints[stop_waypoint+j].twist.twist.linear.x = 0.0;
  }


  std::cout << "---changed waypoints---" << std::endl;

  return;
}
Example #28
0
float VolumeTracer::attenuateLight(float base_light, vec3 pos, ILight* light_source) {
  float light = base_light;

  std::vector<IVolume*> volumes = scene->getVolumes();

  for(unsigned int i = 0; i < volumes.size(); i++) {
    IVolume* volume = volumes[i];

    Ray ray = Ray::generateRay(pos, light_source->getPosition());
    Interval inter = getInterval(ray, volume, light_source->getPosition());
    if(!inter.intersected)
      continue;
    vec3 min = inter.min;
    vec3 max = inter.max;
    if(glm::distance(pos, min) > glm::distance(pos, light_source->getPosition()))
      continue;
    light = glm::exp(-volume->getTau(min, max)) * base_light;
  }
  return light;
}
Example #29
0
VisibleDigits &
FixedPrecision::initVisibleDigits(
        DigitList &value,
        VisibleDigits &digits,
        UErrorCode &status) const {
    if (U_FAILURE(status)) {
        return digits;
    }
    digits.clear();
    if (handleNonNumeric(value, digits)) {
        return digits;
    }
    if (!value.isPositive()) {
        digits.setNegative();
    }
    value.setRoundingMode(fRoundingMode);
    round(value, 0, status);
    getInterval(value, digits.fInterval);
    digits.fExponent = value.getLowerExponent();
    value.appendDigitsTo(digits.fDigits, status);
    return digits;
}
void *LiveJournalClient::processEvent(Event *e)
{
    TCPClient::processEvent(e);
    if (e->type() == EventOpenMessage) {
        Message **msg = (Message**)(e->param());
        if ((*msg)->type() != MessageUpdated)
            return NULL;
        if (dataName(&data.owner) != (*msg)->client())
            return NULL;
        Event eDel(EventMessageDeleted, msg);
        eDel.process();
        string url = "http://";
        url += getServer();
        if (getPort() != 80) {
            url += ":";
            url += number(getPort());
        }
        url += "/";
        Event eGo(EventGoURL, (void*)url.c_str());
        eGo.process();
        if (getState() == Connected)
            m_timer->start(getInterval() * 60 * 1000, true);
        return e->param();
    }
    if (e->type() == EventCommandExec) {
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->id == CmdDeleteJournalMessage) {
            Message *msg = (Message*)(cmd->param);
            Contact *contact = getContacts()->contact(msg->contact());
            if (contact == NULL)
                return NULL;
            LiveJournalUserData *data;
            ClientDataIterator it(contact->clientData, this);
            while ((data = (LiveJournalUserData*)(++it)) != NULL) {
                if (dataName(data) == msg->client()) {
                    Buffer cfg;
                    cfg << "[Title]\n" << msg->save().c_str();
                    cfg.setWritePos(0);
                    cfg.getSection();
                    JournalMessage *m = new JournalMessage(&cfg);
                    m->setContact(msg->contact());
                    m->setOldID(msg->id());
                    m->setText("");
                    if (!send(m, data))
                        delete m;
                    return e->param();
                }
            }
            return NULL;
        }
        unsigned menu_id = cmd->menu_id - MenuWeb;
        if (menu_id > LiveJournalPlugin::MenuCount)
            return NULL;
        unsigned item_id = cmd->id - CmdMenuWeb;
        if ((item_id == 0) || (item_id >= 0x100))
            return NULL;
        const char *url = getMenuUrl(menu_id * 0x100 + item_id);
        if ((url == NULL) || (*url == 0))
            return NULL;
        Event eUrl(EventGoURL, (void*)url);
        eUrl.process();
        return e->param();
    }
    if (e->type() == EventCheckState) {
        CommandDef *cmd = (CommandDef*)(e->param());
        if (cmd->id == CmdMenuWeb) {
            unsigned menu_id = cmd->menu_id - MenuWeb;
            if (menu_id > LiveJournalPlugin::MenuCount)
                return NULL;
            unsigned nItems = 0;
            unsigned list_id = menu_id * 0x100 + 1;
            for (;;) {
                const char *text = getMenu(list_id);
                if ((text == NULL) || (*text == 0))
                    break;
                nItems++;
                list_id++;
            }
            if (nItems == 0)
                return NULL;
            CommandDef *cmds = new CommandDef[nItems + 1];
            memset(cmds, 0, sizeof(CommandDef) * (nItems + 1));
            list_id = menu_id * 0x100 + 1;
            for (unsigned i = 0;; i++) {
                const char *text = getMenu(list_id);
                if ((text == NULL) || (*text == 0))
                    break;
                cmds[i].text = "_";
                if (strcmp(text, "-")) {
                    cmds[i].id = CmdMenuWeb + i + 1;
                    cmds[i].text = "_";
                    QString s = i18n(text);
                    cmds[i].text_wrk = strdup(s.utf8());
                    const char *url = getMenuUrl(list_id);
                    if (url && (*url == '@')) {
                        unsigned nSub = atol(url + 1);
                        while (nSub > LiveJournalPlugin::MenuCount) {
                            unsigned long menu_id = MenuWeb + (++LiveJournalPlugin::MenuCount);
                            Event eMenu(EventMenuCreate, (void*)menu_id);
                            eMenu.process();
                            Command cmd;
                            cmd->id       = CmdMenuWeb;
                            cmd->text     = "_";
                            cmd->menu_id  = menu_id;
                            cmd->menu_grp = 0x1000;
                            cmd->flags    = COMMAND_CHECK_STATE;
                            Event e(EventCommandCreate, cmd);
                            e.process();
                        }
                        cmds[i].popup_id = MenuWeb + nSub;
                    }
                } else {
                    cmds[i].id = 0;
                }
                list_id++;
            }
            cmd->param = cmds;
            cmd->flags |= COMMAND_RECURSIVE;
            return e->param();
        }
    }
    return NULL;
}