int RingBuffer::_incrementEnd(){
    /*

    Increment the pointer to the end of the ring buffer by one.

    */
    if ( spaceAvailable() == 0 ) {
        Serial.println(F("Buffer overflow!"));
        print();    // print buffer info and contents
        return 1;
        }
    else
        _endOfString = (_endOfString+1) % INCBUFFERLENGTH;
        return 0;
 }
Example #2
0
bool shouldGo(CConfigData *config) {
	//char buf[64];
	CTibiaItemProxy itemProxy;
	CMemReaderProxy reader;
	CTibiaCharacter *self = reader.readSelfCharacter();


	int count = 0;
	bool should = false;
	for (int i = 0; i < MAX_SELLERS; i++) {
		if (config->sellOnCap && self->cap < config->sellWhen && individualShouldGo(config, i)) 
			{delete self; return true;}
		if (config->sellOnSpace && !spaceAvailable() && individualShouldGo(config, i))
			{delete self; return true;}
		for (int j = 0; j < 32; j++) {
			int objectId = itemProxy.getItemId(config->sellItem[i].tradeItem[j].itemName);
			if (objectId) {
				//sprintf(buf, "%s\nItem count: %d\nTrigger Quantity: %d", config->sellItem[i].tradeItem[j].itemName, countAllItemsOfType(objectId), config->sellItem[i].tradeItem[j].quantityBuySell);
				//AfxMessageBox(buf);
				count = countAllItemsOfType(objectId);
				if (count && count >= config->sellItem[i].tradeItem[j].quantityBuySell)
					should = true;
			}

		}
		for (j = 0; j < 32; j++) {
			int objectId = itemProxy.getItemId(config->buyItem[i].tradeItem[j].itemName);
			if (objectId) {
				//sprintf(buf, "%s\nItem count: %d\nTrigger Quantity: %d", config->sellItem[i].tradeItem[j].itemName, countAllItemsOfType(objectId), config->sellItem[i].tradeItem[j].quantityBuySell);
				//AfxMessageBox(buf);
				count = countAllItemsOfType(itemProxy.getValueForConst("GP"),true);
				count += countAllItemsOfType(itemProxy.getValueForConst("PlatinumCoin"),true) * 100;
				count += countAllItemsOfType(itemProxy.getValueForConst("CrystalCoin"),true) * 10000;
			
			if (countAllItemsOfType(objectId,true) < config->buyItem[i].tradeItem[j].triggerQuantity && count >= config->buyItem[i].tradeItem[j].salePrice)
				should = true;
			}
		}
	}
//	should?AfxMessageBox("Should go"):AfxMessageBox("Should not go");
	delete self;
	return should;
}
Example #3
0
bool FIFOSoundBuffer::write(s16 value)
{
    if ( spaceAvailable() )
    {
        // We have free space in our buffer.
        data_[ generated_index_++ ] = value;
        total_generated_++;

        // Do we reach the end of the buffer?
        if (generated_index_ == data_size_)
        {
            generated_index_ = 0;
        }
        return true;
    }
    else
    {
        //printf("BF\n");
        // The buffer is full, cancel write operation.
        return false;
    }
}
		TITANIUM_FUNCTION(File, spaceAvailable)
		{
			return get_context().CreateNumber(static_cast<double>(spaceAvailable()));
		}