Exemplo n.º 1
0
void Drop::run(LV2_Handle instance, uint32_t n_samples)
{
    Drop *plugin;
    plugin = (Drop *) instance;

    float *in   = plugin->ports[IN];
	float *out  = plugin->ports[OUT];
	double s    = (double)(*(plugin->ports[STEP]));
	double gain = (double)(*(plugin->ports[GAIN]));
    
    if ( (plugin->obja)->hopa != (int)n_samples )
    {
        plugin->Realloc(n_samples, nBuffersSW(n_samples,16,8,4,3));
		return;
	}

	if (InputAbsSum(in, n_samples) == 0)
	{
		fill_n(out,n_samples,0);
		return;
	}

    (plugin->objg)->SetGaindB(gain);
    (plugin->obja)->PreAnalysis(plugin->nBuffers, in);
    (plugin->objs)->PreSinthesis();
    	
	if (plugin->cont < plugin->nBuffers-1)
		plugin->cont = plugin->cont + 1;
	else
	{
    	(plugin->obja)->Analysis();
        (plugin->objs)->Sinthesis(s);
        (plugin->objg)->SimpleGain((plugin->objs)->yshift, out);
	}
}
void Clear::execute(QVector<Litterale*> litterals) const {
    Drop objDrop;
    while (!Pile::getInstance().isEmpty()) {
        QVector<Litterale*> vec = objDrop.chargerOperande();
        objDrop.execute(vec);
    }
    Pile::lastOpname = "CLEAR";
}
Exemplo n.º 3
0
float Lake::height(const Drop &drop,
                   unsigned int radius,
                   unsigned int timestep) const {
  unsigned int time_elapsed = timestep - drop.time();
  float distance = radius - wave_properties_.speed() * time_elapsed;
  return distance / std::exp(distance*distance + time_elapsed/10);
}
Exemplo n.º 4
0
void Lake::ripple(const Drop &drop, unsigned int step, float timeunit) {
  auto point_map
    = affected_points(drop, radius(drop, step*timeunit), step*timeunit);

  for (const auto &association : point_map) {
    const auto &height = association.first;
    const auto &points = association.second;
    #pragma omp parallel for schedule(static)
    for (unsigned int k = 0; k < points->size(); k++) {
      int i = (*points)[k].first + drop.position().first;
      int j = (*points)[k].second + drop.position().second;
      if (i >= 0 && j >= 0
      &&  i < static_cast<int>(width_) && j < static_cast<int>(length_)) {
        updateSum(i, j, height, step);
        updateVariance(i, j, height, step);
      }
    }
  }
}
Exemplo n.º 5
0
// Miscellaneous
int LuaExports::dropItemReactor(lua_State *luaVm) {
	int32_t itemid = lua_tointeger(luaVm, 1);
	int16_t amount = 1;
	if (lua_isnumber(luaVm, 2)) {
		amount = lua_tointeger(luaVm, 2);
	}
	Reactor *reactor = getReactor(luaVm);
	Player *player = getPlayer(luaVm);
	Drop *drop;
	if (GameLogicUtilities::isEquip(itemid)) {
		Item f(itemid, true);
		drop = new Drop(reactor->getMapId(), f, reactor->getPos(), player != nullptr ? player->getId() : 0);
	}
	else {
		Item f(itemid, amount);
		drop = new Drop(reactor->getMapId(), f, reactor->getPos(), player != nullptr ? player->getId() : 0);
	}
	drop->setTime(player != nullptr ? 100 : 0); // FFA if player isn't around
	drop->doDrop(reactor->getPos());
	return 0;
}
Exemplo n.º 6
0
// same-name slots, connecting to Packet signals
void SpawnShell::newGroundItem(const makeDropStruct *d, uint32_t, uint8_t dir)
{
#ifdef SPAWNSHELL_DIAG
    printf("SpawnShell::newGroundItem(makeDropStruct *)\n");
#endif
    // if zoning, then don't do anything
    if (m_zoneMgr->isZoning())
        return;

    if (dir != DIR_SERVER)
        return;

    if (!d)
        return;

    // attempt to get the item name
    QString name;
    if (m_itemDB != NULL)
        name = m_itemDB->GetItemLoreName(d->itemNr);

    Drop* item = (Drop*)m_drops.find(d->dropId);
    if (item != NULL)
    {
        item->update(d, name);
        if (!showeq_params->fast_machine)
            item->setDistanceToPlayer(m_player->calcDist2DInt(*item));
        else
            item->setDistanceToPlayer(m_player->calcDist(*item));
        updateFilterFlags(item);
        item->updateLastChanged();
        emit changeItem(item, tSpawnChangedALL);
    }
    else
    {
        item = new Drop(d, name);
        if (!showeq_params->fast_machine)
            item->setDistanceToPlayer(m_player->calcDist2DInt(*item));
        else
            item->setDistanceToPlayer(m_player->calcDist(*item));
        updateFilterFlags(item);
        m_drops.insert(d->dropId, item);
        emit addItem(item);
    }

    if (item->filterFlags() & FILTER_FLAG_ALERT)
        emit handleAlert(item, tNewSpawn);
}
Exemplo n.º 7
0
// same-name slots, connecting to Packet signals
void SpawnShell::newGroundItem(const makeDropStruct *d)
{
#ifdef SPAWNSHELL_DIAG
   printf("SpawnShell::newGroundItem(makeDropStruct *)\n");
#endif
  // if zoning, then don't do anything
  if (m_zoneMgr->isZoning())
    return;

  if (!d)
    return;
  
  // attempt to get the item name
  QString name;
  if (m_itemDB != NULL)
    name = m_itemDB->GetItemLoreName(d->itemNr);
  
  Drop* item = (Drop*)m_drops.find(d->dropId);
  if (item != NULL)
  {
    item->update(d, name);
    updateFilterFlags(item);
    item->updateLastChanged();
    emit changeItem(item, tSpawnChangedALL);
  }
  else
  {
    item = new Drop(d, name);
    updateFilterFlags(item);
    m_drops.insert(d->dropId, item);
    emit addItem(item);
  }

  if (item->filterFlags() & FILTER_FLAG_ALERT)
    emit handleAlert(item, tNewSpawn);
}
Exemplo n.º 8
0
// same-name slots, connecting to Packet signals
void SpawnShell::newGroundItem(const uint8_t* data, size_t, uint8_t dir)
{
  const makeDropStruct *d = (const makeDropStruct *)data;
#ifdef SPAWNSHELL_DIAG
   seqDebug("SpawnShell::newGroundItem(makeDropStruct *)");
#endif
  // if zoning, then don't do anything
  if (m_zoneMgr->isZoning())
    return;

  if (dir != DIR_Server)
    return;

  if (!d)
    return;
  
  QString name;
  Drop* item = (Drop*)m_drops.find(d->dropId);
  if (item != NULL)
  {
    item->update(d, name);
    if (!showeq_params->fast_machine)
       item->setDistanceToPlayer(m_player->calcDist2DInt(*item));
    else
       item->setDistanceToPlayer(m_player->calcDist(*item));
    updateFilterFlags(item);
    item->updateLastChanged();
    emit changeItem(item, tSpawnChangedALL);
  }
  else
  {
    item = new Drop(d, name);
    if (!showeq_params->fast_machine)
       item->setDistanceToPlayer(m_player->calcDist2DInt(*item));
     else
       item->setDistanceToPlayer(m_player->calcDist(*item));
    updateFilterFlags(item);
    m_drops.insert(d->dropId, item);
    emit addItem(item);
  }
}
Exemplo n.º 9
0
// same-name slots, connecting to Packet signals
// this packet is variable in length.  everything is dwords except the "idFile" field
// which can be variable
void SpawnShell::newGroundItem(const uint8_t* data, size_t len, uint8_t dir)
{
   if (m_zoneMgr->isZoning())
      return;

   if (dir != DIR_Server)
      return;

   if (!data)
      return;

   NetStream netStream(data, len);
   makeDropStruct ds;
   QString name;
   union { uint32_t n; float f; } x;
   memset(&ds, 0, sizeof(makeDropStruct));

   // read drop id
   ds.dropId = netStream.readUInt32NC();

   // read name
   name = netStream.readText();
   if(name.length())
   {
      strcpy(ds.idFile, name.latin1());
   }

   // read past zone id
   netStream.readUInt32NC();

   // read past zone instance
   netStream.readUInt32NC();

   // read past unknown dword field
   netStream.readUInt32NC();

   // read heading
   x.n = netStream.readUInt32NC();
   ds.heading = x.f;

   // read past unknown dword field
   netStream.readUInt32NC();

   // read past unknown dword field
   netStream.readUInt32NC();

   // read past unknown dword field
   netStream.readUInt32NC();

   // read y pos
   x.n = netStream.readUInt32NC();
   ds.y = x.f;

   // read x pos
   x.n = netStream.readUInt32NC();
   ds.x = x.f;

   // read z pos
   x.n = netStream.readUInt32NC();
   ds.z = x.f;

#ifdef SPAWNSHELL_DIAG
   seqDebug("SpawnShell::newGroundItem(makeDropStruct *)");
#endif

  Drop* item = (Drop*)m_drops.find(ds.dropId);
  if (item != NULL)
  {
    item->update(&ds, name);
    if (!showeq_params->fast_machine)
       item->setDistanceToPlayer(m_player->calcDist2DInt(*item));
    else
       item->setDistanceToPlayer(m_player->calcDist(*item));
    updateFilterFlags(item);
    item->updateLastChanged();
    emit changeItem(item, tSpawnChangedALL);
  }
  else
  {
    item = new Drop(&ds, name);
    if (!showeq_params->fast_machine)
       item->setDistanceToPlayer(m_player->calcDist2DInt(*item));
     else
       item->setDistanceToPlayer(m_player->calcDist(*item));
    updateFilterFlags(item);
    m_drops.insert(ds.dropId, item);
    emit addItem(item);
  }
}
Exemplo n.º 10
0
int main() {
    while(cin >> N >> D >> B >> C) {
        if(T++) puts("");
        memset(G, 0, sizeof(G));
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < N; ++j) {
                char c;
                cin >> c;
                G[i][j] = c - '0';
            }
        }
        while(C--) {
            int x, y;
            cin >> x >> y;
            if(G[x][y] == 0) continue;
            if(D == 0) continue;
            else D--;
            if(++G[x][y] < B) continue;
            G[x][y] = 0;
            Q[0].clear();
            Q[1].clear();
            Q[2].clear();
            Q[3].clear();
            Q[0].push_back(Drop(x, y, 1, 0));
            Q[1].push_back(Drop(x, y, -1, 0));
            Q[2].push_back(Drop(x, y, 0, 1));
            Q[3].push_back(Drop(x, y, 0, -1));
            Q[0].push_back(Drop(-1, 0, 0, 0));
            Q[1].push_back(Drop(-1, 0, 0, 0));
            Q[2].push_back(Drop(-1, 0, 0, 0));
            Q[3].push_back(Drop(-1, 0, 0, 0));
            while(Q[0].front().x >= 0 || Q[1].front().x >= 0 ||
                Q[2].front().x >= 0 || Q[3].front().x >= 0) {
                for(int i = 0; i < 4; ++i) {
                    while(Q[i].front().x >= 0) {
                        Drop now = Q[i].front().inc();
                        x = now.x;
                        y = now.y;
                        Q[i].pop_front();
                        if(now.outside()) continue;
                        if(G[x][y] == 0) {
                            Q[i].push_back(now);
                            continue;
                        }
                        if(++G[x][y] == B) {
                            G[x][y] = 0;
                            Q[0].push_back(Drop(x, y, 1, 0));
                            Q[1].push_back(Drop(x, y, -1, 0));
                            Q[2].push_back(Drop(x, y, 0, 1));
                            Q[3].push_back(Drop(x, y, 0, -1));
                        }
                    }
                }
                for(int i = 0; i < 4; ++i) {
                    Q[i].push_back(Q[i].front());
                    Q[i].pop_front();
                }
            }
        }
        cout << D << endl;
        for(int i = 0; i < N; ++i) {
            for(int j = 0; j < N; ++j)
                putchar(G[i][j] + '0');
            cout << endl;
        }
    }
}
Exemplo n.º 11
0
void InventoryHandler::itemMove(Player *player, PacketReader &packet) {
	if (!player->updateTickCount(packet.get<int32_t>())) {
		// Tickcount was the same or less than 100 of the difference.
		return;
	}

	int8_t inv = packet.get<int8_t>();
	int16_t slot1 = packet.get<int16_t>();
	int16_t slot2 = packet.get<int16_t>();
	if (slot2 == 0) {
		// Dropping an item
		int16_t amount = packet.get<int16_t>();
		Item *item = player->getInventory()->getItem(inv, slot1);
		if (item == nullptr) {
			return;
		}

		if (!GameLogicUtilities::isStackable(item->getId())) {
			amount = item->getAmount();
		}
		else if (amount <= 0 || amount > item->getAmount()) {
			// Hacking
			return;
		}
		else if (ItemDataProvider::Instance()->isCash(item->getId())) {
			// Hacks or modded client.
			return;
		}

		Item droppeditem(item);
		droppeditem.setAmount(amount);
		if (item->getAmount() == amount) {
			InventoryPacket::moveItem(player, inv, slot1, slot2);
			player->getInventory()->deleteItem(inv, slot1);
		}
		else {
			item->decAmount(amount);
			player->getInventory()->changeItemAmount(item->getId(), -amount);
			InventoryPacket::updateItemAmounts(player, inv, slot1, item->getAmount(), 0, 0);
		}
		Drop *drop = new Drop(player->getMap(), droppeditem, player->getPos(), player->getId(), true);
		drop->setTime(0);

		bool istradeable = ItemDataProvider::Instance()->isTradeable(droppeditem.getId());
		drop->setTradeable(istradeable);

		drop->doDrop(player->getPos());
		if (istradeable) {
			// Drop is deleted otherwise, avoid like plague
			ReactorHandler::checkDrop(player, drop);
		}
	}
	else {
		// Change item slot (swapping)
		Item *item1 = player->getInventory()->getItem(inv, slot1);
		Item *item2 = player->getInventory()->getItem(inv, slot2);

		if (item1 == nullptr) {
			// Hacking
			return;
		}

		if (item2 != nullptr && GameLogicUtilities::isStackable(item1->getId()) && item1->getId() == item2->getId()) {
			if (item1->getAmount() + item2->getAmount() <= ItemDataProvider::Instance()->getMaxSlot(item1->getId())) {
				item2->incAmount(item1->getAmount());
				player->getInventory()->deleteItem(inv, slot1, false);
				InventoryPacket::updateItemAmounts(player, inv, slot2, item2->getAmount(), 0, 0);
				InventoryPacket::moveItem(player, inv, slot1, 0);
			}
			else {
				item1->decAmount(ItemDataProvider::Instance()->getMaxSlot(item1->getId()) - item2->getAmount());
				item2->setAmount(ItemDataProvider::Instance()->getMaxSlot(item2->getId()));
				InventoryPacket::updateItemAmounts(player, inv, slot1, item1->getAmount(), slot2, item2->getAmount());
			}
		}
		else {
			if (slot2 < 0) {
				bool iscash = ItemDataProvider::Instance()->isCash(item1->getId());
				uint8_t desiredslot = -(slot2 + (iscash ? 100 : 0));
				if (!EquipDataProvider::Instance()->validSlot(item1->getId(), desiredslot)) {
					// Hacking
					return;
				}
				Item *remove = nullptr;
				int16_t oldslot = 0;
				bool weapon = -slot2 == EquipSlots::Weapon;
				bool shield = -slot2 == EquipSlots::Shield;
				bool top = -slot2 == EquipSlots::Top;
				bool bottom = -slot2 == EquipSlots::Bottom;

				if (weapon && GameLogicUtilities::is2hWeapon(item1->getId()) && player->getInventory()->getEquippedId(EquipSlots::Shield) != 0) {
					oldslot = -EquipSlots::Shield;
				}
				else if (shield && GameLogicUtilities::is2hWeapon(player->getInventory()->getEquippedId(EquipSlots::Weapon))) {
					oldslot = -EquipSlots::Weapon;
				}
				else if (top && GameLogicUtilities::isOverall(item1->getId()) && player->getInventory()->getEquippedId(EquipSlots::Bottom) != 0) {
					oldslot = -EquipSlots::Bottom;
				}
				else if (bottom && GameLogicUtilities::isOverall(player->getInventory()->getEquippedId(EquipSlots::Top))) {
					oldslot = -EquipSlots::Top;
				}
				if (oldslot != 0) {
					remove = player->getInventory()->getItem(inv, oldslot);
					bool onlyswap = true;
					if ((player->getInventory()->getEquippedId(EquipSlots::Shield) != 0) && (player->getInventory()->getEquippedId(EquipSlots::Weapon) != 0)) {
						onlyswap = false;
					}
					else if ((player->getInventory()->getEquippedId(EquipSlots::Top) != 0) && (player->getInventory()->getEquippedId(EquipSlots::Bottom) != 0)) {
						onlyswap = false;
					}
					if (onlyswap) {
						int16_t swapslot = 0;
						if (weapon) {
							swapslot = -EquipSlots::Shield;
							player->getActiveBuffs()->stopBooster();
							player->getActiveBuffs()->stopCharge();
						}
						else if (shield) {
							swapslot = -EquipSlots::Weapon;
							player->getActiveBuffs()->stopBooster();
							player->getActiveBuffs()->stopCharge();
						}
						else if (top) {
							swapslot = -EquipSlots::Bottom;
						}
						else if (bottom) {
							swapslot = -EquipSlots::Top;
						}
						player->getInventory()->setItem(inv, swapslot, nullptr);
						player->getInventory()->setItem(inv, slot1, remove);
						player->getInventory()->setItem(inv, slot2, item1);

						InventoryPacket::moveItem(player, inv, slot1, slot2);
						InventoryPacket::moveItem(player, inv, swapslot, slot1);
						InventoryPacket::updatePlayer(player);
						return;
					}
					else {
						if (player->getInventory()->getOpenSlotsNum(inv) == 0) {
							InventoryPacket::blankUpdate(player);
							return;
						}
						int16_t freeslot = 0;
						for (int16_t s = 1; s <= player->getInventory()->getMaxSlots(inv); s++) {
							Item *olditem = player->getInventory()->getItem(inv, s);
							if (olditem == nullptr) {
								freeslot = s;
								break;
							}
						}
						player->getInventory()->setItem(inv, freeslot, remove);
						player->getInventory()->setItem(inv, oldslot, nullptr);
						InventoryPacket::moveItem(player, inv, oldslot, freeslot);
					}
				}
			}
			else if (slot1 < 0 && item2 != nullptr && !ItemDataProvider::Instance()->isCash(item2->getId())) {
				// Client tries to switch a cash item with a regular item
				return;
			}

			player->getInventory()->setItem(inv, slot1, item2);
			player->getInventory()->setItem(inv, slot2, item1);
			if (item1->getPetId() > 0) {
				player->getPets()->getPet(item1->getPetId())->setInventorySlot((int8_t) slot2);
			}
			if (item2 != nullptr && item2->getPetId() > 0) {
				player->getPets()->getPet(item2->getPetId())->setInventorySlot((int8_t) slot1);
			}
			InventoryPacket::moveItem(player, inv, slot1, slot2);
		}
	}
	if ((slot1 < 0 && -slot1 == EquipSlots::Weapon) || (slot2 < 0 && -slot2 == EquipSlots::Weapon)) {
		player->getActiveBuffs()->stopBooster();
		player->getActiveBuffs()->stopCharge();
		player->getActiveBuffs()->stopBulletSkills();
	}
	// Check if the label ring changed, so we can update the look of the pet.
	if ((slot1 < 0 && -slot1 - 100 == EquipSlots::PetLabelRing1) || (slot2 < 0 && -slot2 - 100 == EquipSlots::PetLabelRing1)) {
		if (Pet *pet = player->getPets()->getSummoned(0)) {
			PetsPacket::changeName(player, pet);
		}
	}
	if ((slot1 < 0 && -slot1 - 100 == EquipSlots::PetLabelRing2) || (slot2 < 0 && -slot2 - 100 == EquipSlots::PetLabelRing2)) {
		if (Pet *pet = player->getPets()->getSummoned(1)) {
			PetsPacket::changeName(player, pet);
		}
	}
	if ((slot1 < 0 && -slot1 - 100 == EquipSlots::PetLabelRing3) || (slot2 < 0 && -slot2 - 100 == EquipSlots::PetLabelRing3)) {
		if (Pet *pet = player->getPets()->getSummoned(2)) {
			PetsPacket::changeName(player, pet);
		}
	}
	if (slot1 < 0 || slot2 < 0) {
		InventoryPacket::updatePlayer(player);
	}
}
Exemplo n.º 12
0
inline float Lake::radius(const Drop &drop, unsigned int timestep) const {
  return wave_properties_.speed() * (timestep - drop.time());
}