Ejemplo n.º 1
0
void ProcessSessionBuffer(session_node *s)
{
	int prev_session_state;
	
	/* need a loop, in case the state changes, so the new
	state can handle the rest of the waiting bytes */
	
	/*
	int i;
	if (s->session_id == 0)
	{
	for (i=0;i<s->num_receiving;i++)
	dprintf("%5u\n",(unsigned)(unsigned char)(s->receiving_buf[i]));
	}
	*/
	do
	{
		prev_session_state = s->state;
		
		switch (s->state)
		{
		case STATE_ADMIN :
			AdminProcessSessionBuffer(s);
			break;
		case STATE_MAINTENANCE :
			MaintenanceProcessSessionBuffer(s);
			break;
		case STATE_GAME :
			GameProcessSessionBuffer(s);
			break;
		case STATE_TRYSYNC :
			TrySyncProcessSessionBuffer(s);
			break;
		case STATE_SYNCHED :
			SynchedProcessSessionBuffer(s);
			break;
		case STATE_RESYNC :
			ResyncProcessSessionBuffer(s);
			break;
		}
	} while (s->connected && s->state != prev_session_state);
}
Ejemplo n.º 2
0
void GameSyncProcessSessionBuffer(session_node *s)
{
   char ch;

   while (s->receive_list != NULL)
   {
      if (ReadSessionBytes(s,1,&ch) == False)
	 return;
      
      GameSyncInputChar(s,ch);

      /* any character could change our state back to game normal.  if so, leave */
      if (s->game->game_state == GAME_NORMAL)
      {
	 if (s->game->object_id == INVALID_OBJECT)
	    GameSendSystemEnter(s);
	 GameProcessSessionBuffer(s);
	 break;
      }
   }
}