コード例 #1
0
ファイル: admin.c プロジェクト: GarMeridian3/Meridian59
void AdminProcessSessionBuffer(session_node *s)
{
   char ch;

   while (s->receive_list != NULL)
   {
      if (ReadSessionBytes(s,1,&ch) == False)
	 return;
      
      /* give up receive mutex, so the interface/socket thread can
	 read data for us, even if doing something long (GC/save/reload sys) */

      if (!MutexRelease(s->muxReceive))
	 eprintf("APSBPollSession released mutex it didn't own in session %i\n",
		 s->session_id);
      
      AdminInputChar(s,ch);

      if (!MutexAcquireWithTimeout(s->muxReceive,10000))
      {
	 eprintf("APSB bailed waiting for mutex on session %i\n",s->session_id);
	 return;
      }

      /* any character could change our state.  if so, leave */
      if (s->hangup == True || s->state != STATE_ADMIN)
	 return;
   }
}
コード例 #2
0
void MaintenanceProcessSessionBuffer(session_node *s)
{
   char ch;

   while (s->receive_list != NULL)
   {
      if (ReadSessionBytes(s,1,&ch) == False)
	 return;
      
      /* give up receive mutex, so the interface/socket thread can
	 read data for us, even if doing something long (GC/save/reload sys) */

      if (!ReleaseMutex(s->muxReceive))
	 eprintf("APSBPollSession released mutex it didn't own in session %i\n",
		 s->session_id);
      
      MaintenanceInputChar(s,ch);

      if (WaitForSingleObject(s->muxReceive,10000) != WAIT_OBJECT_0)
      {
	 eprintf("APSB bailed waiting for mutex on session %i\n",s->session_id);
	 return;
      }

      /* any character could change our state.  if so, leave */
      if (s->hangup == True || s->state != STATE_MAINTENANCE)
	 return;
   }
}
コード例 #3
0
ファイル: resync.c プロジェクト: AlleyCat1976/Meridian59_103
void ResyncProcessSessionBuffer(session_node *s)
{
   char ch;

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

      /* any character could change our state.  if so, leave */
      if (s->state != STATE_RESYNC)
	 return;
   }
}
コード例 #4
0
ファイル: game.c プロジェクト: AlleyCat1976/Meridian59_103
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;
      }
   }
}
コード例 #5
0
ファイル: game.c プロジェクト: AlleyCat1976/Meridian59_103
void GameProcessSessionBuffer(session_node *s)
{
   client_msg msg;
   unsigned short security;

   s->game->game_last_message_time = GetTime();

   if (s->game->game_state != GAME_NORMAL)
   {
      GameSyncProcessSessionBuffer(s);
      return;
   }

   /* need to copy only as many bytes as we can hold */
   while (s->receive_list != NULL)
   {
      if (PeekSessionBytes(s,HEADERBYTES,&msg) == False)
	 return;

      if (msg.len != msg.len_verify)
      {
	 /* dprintf("GPSB found len != len_verify %i %i\n",msg_len,msg_len_verify); */
	 GameSendResync(s);
	 GameSyncInit(s);
	 GameSyncProcessSessionBuffer(s);
	 return;
      }

      if (msg.len > LEN_MAX_CLIENT_MSG)
      {
         eprintf("GameProcessSessionBuffer got message too long %i\n",msg.len);
	 GameSendResync(s);
	 GameSyncInit(s);
	 GameSyncProcessSessionBuffer(s);
	 return;
      }
      
      /* now read the header for real, plus the actual data */
      if (ReadSessionBytes(s,msg.len+HEADERBYTES,&msg) == False)
	 return;

      /* dprintf("got crc %08x\n",msg.crc16); */

      security = GameRandomStreamsStep(s);

      /* dprintf("%08x is the next stream thing\n",security); */

      security ^= msg.len;
      security ^= ((unsigned int)msg.data[0] << 4);
      security ^= GetCRC16(msg.data,msg.len);

      /* dprintf("%08x is the next stream thing after xor\n",security); */

      if (msg.crc16 != security && !s->seeds_hacked)
      {
			s->seeds_hacked = True;
			if (ConfigBool(SECURITY_LOG_SPOOFS))
			{
				lprintf("GameProcessSessionBuffer found invalid security account %i\n",
						  s->account->account_id);
			}
			if (ConfigBool(SECURITY_HANGUP_SPOOFS))
			{
				HangupSession(s);
			}

			// can't use the packet, so throw it away and go into resync mode
			GameSendResync(s);
			GameSyncInit(s);
			GameSyncProcessSessionBuffer(s);
			return;
      }

      if (msg.seqno != GetEpoch()) /* old sequence ok, just ignore */
      {
	 /* dprintf("Game got bad epoch from session %i\n",s->session_id); */
	 continue;
      }
      
      /* give up receive mutex, so the interface/socket thread can
	 read data for us, even if doing something long (GC/save/reload sys) */
      
      if (!ReleaseMutex(s->muxReceive))
	 eprintf("GPSB released mutex it didn't own in session %i\n",s->session_id);
	 
      GameProtocolParse(s,&msg);
      
      if (WaitForSingleObject(s->muxReceive,10000) != WAIT_OBJECT_0)
      {
	 eprintf("GPSB bailed waiting for mutex on session %i\n",s->session_id);
	 return;
      }
      
      /* if hung up, don't touch */
      if (s->hangup == True)
	 return;

      if (s->state != STATE_GAME)
	 return;
      
      if (s->game->game_state != GAME_NORMAL)
	 return;
      
   }
}