void CTgaImageFile::getPackets() { unsigned int current_byte = 0; unsigned char packet_header; int run_length; unsigned char temp_color[4] = { 0x00, 0x00, 0x00, 0x00 }; while(current_byte < m_bytes) { fread(&packet_header, sizeof(unsigned char), 1, m_fp); run_length = ( packet_header&0x7F ) + 1; // If it is a RLE packet if(packet_header & TGA_RLE_PACKET) { fread(temp_color, sizeof(unsigned char), m_components, m_fp); // Optimization for special case. if(m_components == 1) { memset ( m_imgData + current_byte, temp_color[0], run_length ); current_byte += run_length; } else { for(int i = 0; i < run_length; i++) { putPacket(temp_color, current_byte); } } } else // If it is a raw packet { for(int i = 0; i < run_length; i++) { fread(temp_color, sizeof(unsigned char), m_components, m_fp); if(m_components == 1) { memset(m_imgData + current_byte, temp_color[0], run_length); current_byte += run_length; } else { putPacket(temp_color, current_byte); } } } } }
void np::RefineryConstruct::process(float timeSinceLastUpdate) { if(isOn) { double processingAmount = std::min( 0.25, getOutputLeft(0) / (conversionRate)); double totalEnergy = 0; np::ResourcePacket* rawPacket = getPacketOf( rawEnergy, processingAmount); //OgreFramework::getSingletonPtr()->m_pLog->logMessage( "Refinery PROCESSING: " + Ogre::StringConverter::toString( (float)rawPacket->amount)); ResourcePacket* product = new ResourcePacket( sexyEnergy, rawPacket->amount * conversionRate); putPacket( 0, product); } }
void np::EnergyBuffer::process(float timeSinceLastUpdate) { double processingAmount = std::min( 0.25, getOutputLeft(0) / (conversionRate )); double totalEnergy = 0; np::ResourcePacket* rawPacket = getPacketOf( rawEnergy, 40.0 - storage); storage += rawPacket->amount; if ( isReleasing) { ResourcePacket* product = new ResourcePacket( rawEnergy, std::min( 40.0, storage)); storage -= product->amount; if ( putPacket( 0, product) == PARTIAL) { storage += product->amount; } } }