示例#1
0
TInt YModem::StartDownload(TBool aG, TInt& aLength, TDes& aName)
	{
	TInt r;
	// iImageDeflated vaule is true iff the first call of StartDownload()
	// finished AND the ROM Image is deflated. 
	// Practically when the CloseYModem() called.
	if (iImageDeflated)
        {
        // Read the rest of data to correctly finish Y-Modem protocol
        // This is necessary because the deflated ROM IMage size is not
        // aligned to 128 or 1024 byte boundary which are transfer block sizes
        // the Y-Modem protocol.
        // (reuse iHeaderBuf, because it is not necessary anymore)
        TUint8* pD=(TUint8*)iHeaderBuf.Ptr();
        r=ReadPackets(pD, KHeaderBufferSize);
        DEBUG_PRINT((_L("Remaining data :%d, r:%d\r\n"), pD - iHeaderBuf.Ptr(), r ));        
        }
	
	
	iInitChar=aG?BIGG:BIGC;
	iState=0;
	iSeqNum=255;
	TUint8* dummy=NULL;
	r=ReadPackets(dummy, 0);			// read the file description packet
	if (r==KErrNone)
		{
		aLength=iFileSize;				// return file name and file size
		aName=iFileName;
		}
	return r;
	}
void ServerSideNetworkedGame::Frame(int msec)
{
	realtime += msec;
	frametime = msec / 1000.0f;

	// Read packets from clients
	ReadPackets();

	// Wait full 100 ms before allowing to send
	if(realtime < servertime)
	{
		// never let the time get too far off
		if(servertime - realtime > 100)
		{
			realtime = servertime - 100;
		}

		return;
	}

	// Bump frame number, and calculate new servertime
	framenum++;
	servertime = framenum * 100;

	if(servertime < realtime)
		realtime = servertime;

	SendCommand();
}
示例#3
0
//-----------------------------------------------------------------------------
// Name: empty()
// Desc: 
//-----------------------------------------------------------------------------
void CArmyWar::RunNetwork(int msec)
{
	static int time = 0;
	time += msec;

	// Framerate is too high
	if(time < (1000 / 60))
		return;

	frametime = time / 1000.0f;
	time = 0;

	// Read packets from server, and send new commands
	ReadPackets();
	SendCommand();

	int ack = networkClient->GetIncomingAcknowledged();
	int current = networkClient->GetOutgoingSequence();

	// Check that we haven't gone too far
	if(current - ack > COMMAND_HISTORY_SIZE)
		return;

	// Predict the frames that we are waiting from the server
	for(int a = ack + 1; a < current; a++)
	{
		int prevframe = (a-1) & (COMMAND_HISTORY_SIZE-1);
		int frame = a & (COMMAND_HISTORY_SIZE-1);

		PredictMovement(prevframe, frame);
	}

	MoveObjects();
}
示例#4
0
void CBaseServer::PreFrame()
{
	// Check timeouts
	CheckTimeouts();
	
	// Get packets from clients
	ReadPackets();
	
	// update ping based on the last known frame from all clients
	//SV_CalcPings();
	
	// give the clients some timeslices
	//SV_GiveMsec();
	
	// Toggle the log buffer if full
	//SV_CheckLog();
};
void ClientSideNetworkedGame::RunNetwork(int msec)
{
	static int time = 0;
	time += msec;

	// Framerate is too high
	if(time < (1000 / 60)) {
        MovePlayer();
		moveRemotePlayers();
		//do we need to move remote players here?? also..

		return;
	}

	frametime = time / 1000.0f;
	time = 0;

	// Read packets from server, and send new commands
	ReadPackets();
	SendCommand();

	int ack = networkClient->GetIncomingAcknowledged();
	int current = networkClient->GetOutgoingSequence();

//iam going to put the following in Game.cpp's game loop...

	// Check that we haven't gone too far
	if(current - ack > COMMAND_HISTORY_SIZE)
		return;

	// Predict the frames that we are waiting from the server
	for(int a = ack + 1; a < current; a++)
	{
		int prevframe = (a-1) & (COMMAND_HISTORY_SIZE-1);
		int frame = a & (COMMAND_HISTORY_SIZE-1);

		PredictMovement(prevframe, frame);
	}
	MoveObjects();
}
示例#6
0
TInt YModem::GetInnerCompression(TBool &aImageDeflated, TBool &aRomLoaderHeaderExists)
    {
    // Read, analyse and buffer ROM Image Header
    
    DEBUG_PRINT((_L(">>YModem::GetInnerCompression()\r\n")))
    // Try to read first 1k from the ROM Image
    iDataSizeInPuffer = KHeaderBufferSize;
    TUint8* pD=(TUint8*)iHeaderBuf.Ptr();
    TInt r=ReadPackets(pD, iDataSizeInPuffer);
    
    DEBUG_PRINT((_L("r:%d (0x%08x).\r\n"), r, r));
    DEBUG_PRINT((_L("pD->:0x%08x.\r\n"), (TUint8*)pD));
    DEBUG_PRINT((_L("iHeaderBuf.Ptr()->:0x%08x.\r\n"), (TUint8*)iHeaderBuf.Ptr()));
    DEBUG_PRINT((_L("iDataSizeInPuffer:%d (0x%08x).\r\n"), iDataSizeInPuffer, iDataSizeInPuffer));
    
    if( iDataSizeInPuffer != pD - iHeaderBuf.Ptr())
        {
        BOOT_FAULT();
        }
        
    
    // Analyse the inner compression method
    const TUint8 * romLoaderSignature1 = (const TUint8*)"EPOC";
    const TUint8 * romLoaderSignature2 = (const TUint8*)"ROM";
    pD = (TUint8*)iHeaderBuf.Ptr();
    r = KErrNone;
    
    // Check headers
	TRomHeader* romHeader= (TRomHeader *)pD;  
	DEBUG_PRINT((_L("pD       ->:0x%08x.\r\n"), (TUint8*)pD));
	DEBUG_PRINT((_L("romHeader->:0x%08x.\r\n"), (TUint8*)romHeader));
	
	aRomLoaderHeaderExists = EFalse;
	
	if( !memcmp1(pD, romLoaderSignature1, 4) && !memcmp1((pD+8), romLoaderSignature2, 3) )
	    {
        // We have TRomLoaderHeader skip it
        romHeader = (TRomHeader *) (pD +TROM_LOADER_HEADER_SIZE);
        aRomLoaderHeaderExists = ETrue;
	    }

    DEBUG_PRINT((_L("TRomLoaderHeader exists:%d.\r\n"), aRomLoaderHeaderExists));
    DEBUG_PRINT((_L("romHeader->:0x%08x (0x%08x).\r\n"), (TUint8*)romHeader, (TUint8*)romHeader-pD));

    if(romHeader->iCompressionType == 0 )
        {
         aImageDeflated = EFalse;   
        }
    else if (romHeader->iCompressionType == KUidCompressionDeflate )
        {
        iImageDeflated = aImageDeflated = ETrue;
        }
    else
        {
        PrintToScreen(_L("Not supported compression method:0x%08x\r\n"), romHeader->iCompressionType);
        r = KErrNotSupported;
        }

    DEBUG_PRINT((_L("iCompressionType :0x%08x\r\n"), romHeader->iCompressionType));
	DEBUG_PRINT((_L("iCompressedSize  :0x%08x\r\n"), romHeader->iCompressedSize));
	DEBUG_PRINT((_L("iUncompressedSize:0x%08x\r\n"), romHeader->iUncompressedSize));
    // Buffer it.
    iHeaderStored = true;
 
    DEBUG_PRINT((_L("<<YModem::GetInnerCompression():%d\r\n"), r))
	return r;   
    }