示例#1
0
/// Update the World !
void World::Update(uint32 diff)
{
    /// <li> Handle session updates when the timer has passed
    ///- Update the different timers
    for(int i = 0; i < WUPDATE_COUNT; ++i)
    {
        if (m_timers[i].GetCurrent()>=0)
            m_timers[i].Update(diff);
        else
            m_timers[i].SetCurrent(0);
    }

    if (m_timers[WUPDATE_VILLAGE_PRODUCE].Passed())
    {
        printf("WUPDATE_VILLAGE_PRODUCE at %d\n", GetTickCount());
        UpdateVillages(diff);

        m_timers[WUPDATE_VILLAGE_PRODUCE].Reset();
    }

    if (m_timers[WUPDATE_SESSIONS].Passed())
    {
        m_timers[WUPDATE_SESSIONS].Reset();
        UpdateSessions(diff);
    }
}
示例#2
0
/**
**  Main loop
*/
static void MainLoop(void)
{
	Uint32 ticks[2];
	int delay;
	int done;

	//
	// Start the transactions.
	//
	done = 0;
	while (!done) {
		ticks[0] = SDL_GetTicks();

		//
		// Update sessions and buffers.
		//
		UpdateSessions();
		UpdateParser();

		ticks[1] = SDL_GetTicks();

		//
		// Idle out the remainder of this loop.
		//
		if ((int)(ticks[1] - ticks[0]) > Server.PollingDelay) {
			delay = 0;
		} else {
			delay = Server.PollingDelay - (ticks[1] - ticks[0]);
		}

		if (delay > 2000) {
			delay = 2000;
		}

		SDL_Delay(delay);
	}

}
示例#3
0
void World::UpdateWorld(time_t diff)
{
	UpdateSessions(diff);
	UpdateCollision(diff);
}