Example #1
0
void CDecalsDrawerGL4::FreeDecal(int idx)
{
	if (idx == 0)
		return;

	SCOPED_TIMER("DecalsDrawerGL4::Update");

	Decal& d = decals[idx];
	if ((d.owner == nullptr) && (d.type == Decal::BUILDING)) {
		auto it = spring::find(alphaDecayingDecals, idx);
		assert(it != alphaDecayingDecals.end());
		alphaDecayingDecals.erase(it);
	}

	d = Decal();
	decalsToUpdate.push_back(idx);
	freeIds.push_back(idx);



	// we were the worst rated decal? -> find new one
	if (idx == curWorstDecalIdx) {
		GetWorstRatedDecal(&curWorstDecalIdx, &curWorstDecalRating, false);
	}

	RemoveFromGroup(idx);
}
Example #2
0
bool CPVRChannelGroup::UpdateGroupEntries(const CPVRChannelGroup &channels)
{
  bool bChanged(false);
  CSingleLock lock(m_critSection);
  int iCurSize = size();

  CPVRDatabase *database = CPVRManager::Get()->GetTVDatabase();
  if (!database || !database->Open())
    return false;

  /* go through the channel list and check for updated or new channels */
  for (unsigned int iChannelPtr = 0; iChannelPtr < channels.size(); iChannelPtr++)
  {
    CPVRChannel *channel = channels.at(iChannelPtr).channel;
    int iChannelNumber   = channels.at(iChannelPtr).iChannelNumber;
    if (!channel)
      continue;

    CPVRChannel *realChannel = (CPVRChannel *) CPVRManager::GetChannelGroups()->GetGroupAll(m_bRadio)->GetByClient(channel->UniqueID(), channel->ClientID());
    if (!realChannel)
      continue;

    if (!IsGroupMember(realChannel))
    {
      AddToGroup(realChannel, iChannelNumber, false);

      bChanged = true;
      m_bChanged = true;
      CLog::Log(LOGINFO,"PVRChannelGroup - %s - added %s channel '%s' at position %d in group '%s'",
          __FUNCTION__, m_bRadio ? "radio" : "TV", realChannel->ChannelName().c_str(), iChannelNumber, GroupName().c_str());
    }
  }

  /* check for deleted channels */
  unsigned int iSize = size();
  for (unsigned int iChannelPtr = 0; iChannelPtr < iSize; iChannelPtr++)
  {
    CPVRChannel *channel = (CPVRChannel *) GetByIndex(iChannelPtr);
    if (!channel)
      continue;
    if (channels.GetByClient(channel->UniqueID(), channel->ClientID()) == NULL)
    {
      /* channel was not found */
      CLog::Log(LOGINFO,"PVRChannelGroup - %s - deleted %s channel '%s' from group '%s'",
          __FUNCTION__, m_bRadio ? "radio" : "TV", channel->ChannelName().c_str(), GroupName().c_str());

      /* remove this channel from all non-system groups */
      RemoveFromGroup(channel);

      m_bChanged = true;
      bChanged = true;
      iChannelPtr--;
      iSize--;
    }
  }

  if (bChanged)
  {
    /* sort by client channel number if this is the first time */
    if (iCurSize == 0)
      SortByClientChannelNumber();

    /* renumber to make sure all channels have a channel number.
       new channels were added at the back, so they'll get the highest numbers */
    Renumber();

    return Persist();
  }

  return true;
}