Changeset 16 for trunk

Show
Ignore:
Timestamp:
11/19/08 13:23:17 (17 years ago)
Author:
yumileroy
Message:

[svn] * Remove debugging code from WorldSocket?.cpp.
* Small cleanup fix in configure.ac.

Original author: derex_tri
Date: 2008-10-06 04:14:44-05:00

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r8 r16  
    1919#  Turn on all warnings and error messages, and enforce GNU 
    2020#  standards for the package. 
    21 AM_INIT_AUTOMAKE([-Wall -Werror]) 
     21AM_INIT_AUTOMAKE([-Wall -Werror gnu]) 
    2222AM_MAINTAINER_MODE 
    2323 
     
    2525# configuration is being performed in the top-level directory. 
    2626# The idea is to prevent this ,because some maintainers tend  
    27 # to break "off src dir" builds. 
     27# to break parallel build trees (a.k.a. VPATH builds). 
    2828if test "$srcdir" = "." && test "$enable_maintainer_mode" != "yes"; then 
    2929  AC_MSG_ERROR( 
     
    3131      Please configure and build in a directory other than the 
    3232      top-level source directory. This is needed because a lot 
    33       of maintainers tend to break "off src dir" builds. This 
    34       is kinda real ensurance they wont do it.  
     33      of maintainers tend to break parallel build trees  
     34      (a.k.a. VPATH builds). This is kinda real ensurance they  
     35      will not do it (by enforcing everybody to do VPATH builds). 
    3536 
    3637      For example, try the following from the top-level source 
     
    4546      start a build in that directory. 
    4647 
    47       If however you realy want to build in src dir, 
    48       then use --enable-maintainer-mode switch. 
     48      If however you realy want to disable this error, 
     49      use --enable-maintainer-mode switch. 
    4950     ]) 
    5051fi 
  • trunk/src/game/WorldSocket.cpp

    r6 r16  
    1919#include "Common.h" 
    2020#include "WorldSocket.h"  
     21 
    2122#include <ace/Message_Block.h> 
    2223#include <ace/OS_NS_string.h> 
     
    6869#endif 
    6970 
    70 // used when testing to alow login without password and encryption 
    71 // #define _NETCODE_FAKE_AUTH 
    72  
    7371WorldSocket::WorldSocket (void) : 
    7472WorldHandler (), 
     
    159157        { 
    160158          for (uint32 j = 0; j < 16 && p < pct.size (); j++) 
    161             sWorldLog.Log ("%.2X ", const_cast<WorldPacket&>(pct)[p++]); 
     159            sWorldLog.Log ("%.2X ", const_cast<WorldPacket&> (pct)[p++]); 
    162160 
    163161          sWorldLog.Log ("\n"); 
     
    312310  if (send_len == 0) 
    313311    return this->cancel_wakeup_output (Guard); 
    314    
    315 // TODO SO_NOSIGPIPE on platforms that support it 
     312 
     313  // TODO SO_NOSIGPIPE on platforms that support it 
    316314#ifdef MSG_NOSIGNAL 
    317315  ssize_t n = this->peer ().send (m_OutBuffer->rd_ptr (), send_len, MSG_NOSIGNAL); 
     
    319317  ssize_t n = this->peer ().send (m_OutBuffer->rd_ptr (), send_len); 
    320318#endif // MSG_NOSIGNAL 
    321            
     319 
    322320  if (n == 0) 
    323321    return -1; 
     
    426424  ACE_NEW_RETURN (m_RecvWPct, WorldPacket ((uint16) header.cmd, header.size), -1); 
    427425 
    428   if(header.size > 0) 
    429   { 
    430      m_RecvWPct->resize (header.size);   
    431      m_RecvPct.base ((char*) m_RecvWPct->contents (), m_RecvWPct->size ()); 
    432   } 
     426  if (header.size > 0) 
     427    { 
     428      m_RecvWPct->resize (header.size); 
     429      m_RecvPct.base ((char*) m_RecvWPct->contents (), m_RecvWPct->size ()); 
     430    } 
    433431  else 
    434   { 
    435      ACE_ASSERT(m_RecvPct.space() == 0); 
    436   } 
     432    { 
     433      ACE_ASSERT (m_RecvPct.space () == 0); 
     434    } 
    437435 
    438436 
     
    599597{ 
    600598  ACE_ASSERT (new_pct); 
    601    
     599 
    602600  // manage memory ;) 
    603601  ACE_Auto_Ptr<WorldPacket> aptr (new_pct); 
     
    713711             account.c_str (), 
    714712             clientSeed); 
    715  
    716 #if defined _NETCODE_FAKE_AUTH 
    717   bool dontchechtheacc = false; 
    718   uint8 digest_fake[sizeof (digest)]; 
    719   memset ((void*) digest_fake, '\0', sizeof (digest_fake)); 
    720   if (memcmp ((void*) digest, (void*) digest_fake, sizeof (digest_fake)) == 0) 
    721     { 
    722       dontchechtheacc = true; 
    723     } 
    724 #endif //_NETCODE_FAKE_AUTH 
    725713 
    726714  // Get the account information from the realmd database 
     
    786774  const char* vold = fields[6].GetString (); 
    787775 
    788   DEBUG_LOG ("WorldSocket::HandleAuthSession: (s,v) check s: %s v_old: %s v_new: %s", 
     776  DEBUG_LOG ("WorldSocket::HandleAuthSession: " 
     777             "(s,v) check s: %s v_old: %s v_new: %s", 
    789778             sStr, 
    790779             vold, 
     
    798787                          safe_account.c_str ()); 
    799788 
    800 #if defined _NETCODE_FAKE_AUTH 
    801   if (!dontchechtheacc) 
    802     { 
    803 #endif 
    804       if (!vold || strcmp (vStr, vold)) 
    805         { 
    806           packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
    807           packet << uint8 (AUTH_UNKNOWN_ACCOUNT); 
    808           SendPacket (packet); 
    809           delete result; 
    810           OPENSSL_free ((void*) sStr); 
    811           OPENSSL_free ((void*) vStr); 
    812  
    813           sLog.outError ("WorldSocket::HandleAuthSession: User not logged."); 
    814           return -1; 
    815         } 
    816 #if defined _NETCODE_FAKE_AUTH 
    817     } 
    818 #endif 
     789  if (!vold || strcmp (vStr, vold)) 
     790    { 
     791      packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
     792      packet << uint8 (AUTH_UNKNOWN_ACCOUNT); 
     793      SendPacket (packet); 
     794      delete result; 
     795      OPENSSL_free ((void*) sStr); 
     796      OPENSSL_free ((void*) vStr); 
     797 
     798      sLog.outBasic ("WorldSocket::HandleAuthSession: User not logged."); 
     799      return -1; 
     800    } 
    819801 
    820802  OPENSSL_free ((void*) sStr); 
     
    831813 
    832814          delete result; 
    833           sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs)."); 
     815          sLog.outBasic ("WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs)."); 
    834816          return -1; 
    835817        } 
     
    848830  delete result; 
    849831 
    850 #if defined _NETCODE_FAKE_AUTH 
    851   if (!dontchechtheacc) 
    852     { 
    853 #endif 
    854       // Re-check account ban (same check as in realmd)  
    855       QueryResult *banresult = 
    856               loginDatabase.PQuery ("SELECT " 
    857                                     "bandate, " 
    858                                     "unbandate " 
    859                                     "FROM account_banned " 
    860                                     "WHERE id = '%u' " 
    861                                     "AND active = 1", 
    862                                     id); 
    863  
    864       if (banresult) // if account banned 
    865         { 
    866           packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
    867           packet << uint8 (AUTH_BANNED); 
    868           SendPacket (packet); 
    869  
    870           delete banresult; 
    871  
    872           sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); 
    873           return -1; 
    874         } 
    875  
    876       // Check locked state for server 
    877       AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit (); 
    878  
    879       if (allowedAccountType > SEC_PLAYER && security < allowedAccountType) 
    880         { 
    881           WorldPacket Packet (SMSG_AUTH_RESPONSE, 1); 
    882           Packet << uint8 (AUTH_UNAVAILABLE); 
    883  
    884           SendPacket (packet); 
    885  
    886           sLog.outBasic ("WorldSocket::HandleAuthSession: User tryes to login but his security level is not enough"); 
    887           return -1; 
    888         } 
    889  
    890       // Check that Key and account name are the same on client and server 
    891       Sha1Hash sha; 
    892  
    893       uint32 t = 0; 
    894       uint32 seed = m_Seed; 
    895  
    896       sha.UpdateData (account); 
    897       sha.UpdateData ((uint8 *) & t, 4); 
    898       sha.UpdateData ((uint8 *) & clientSeed, 4); 
    899       sha.UpdateData ((uint8 *) & seed, 4); 
    900       sha.UpdateBigNumbers (&K, NULL); 
    901       sha.Finalize (); 
    902  
    903       if (memcmp (sha.GetDigest (), digest, 20)) 
    904         { 
    905           packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
    906           packet << uint8 (AUTH_FAILED); 
    907  
    908           SendPacket (packet); 
    909  
    910           sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed)."); 
    911           return -1; 
    912         } 
    913 #if defined _NETCODE_FAKE_AUTH 
    914     } 
    915 #endif 
     832  // Re-check account ban (same check as in realmd)  
     833  QueryResult *banresult = 
     834          loginDatabase.PQuery ("SELECT " 
     835                                "bandate, " 
     836                                "unbandate " 
     837                                "FROM account_banned " 
     838                                "WHERE id = '%u' " 
     839                                "AND active = 1", 
     840                                id); 
     841 
     842  if (banresult) // if account banned 
     843    { 
     844      packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
     845      packet << uint8 (AUTH_BANNED); 
     846      SendPacket (packet); 
     847 
     848      delete banresult; 
     849 
     850      sLog.outBasic ("WorldSocket::HandleAuthSession: Sent Auth Response (Account banned)."); 
     851      return -1; 
     852    } 
     853 
     854  // Check locked state for server 
     855  AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit (); 
     856 
     857  if (allowedAccountType > SEC_PLAYER && security < allowedAccountType) 
     858    { 
     859      WorldPacket Packet (SMSG_AUTH_RESPONSE, 1); 
     860      Packet << uint8 (AUTH_UNAVAILABLE); 
     861 
     862      SendPacket (packet); 
     863 
     864      sLog.outBasic ("WorldSocket::HandleAuthSession: User tryes to login but his security level is not enough"); 
     865      return -1; 
     866    } 
     867 
     868  // Check that Key and account name are the same on client and server 
     869  Sha1Hash sha; 
     870 
     871  uint32 t = 0; 
     872  uint32 seed = m_Seed; 
     873 
     874  sha.UpdateData (account); 
     875  sha.UpdateData ((uint8 *) & t, 4); 
     876  sha.UpdateData ((uint8 *) & clientSeed, 4); 
     877  sha.UpdateData ((uint8 *) & seed, 4); 
     878  sha.UpdateBigNumbers (&K, NULL); 
     879  sha.Finalize (); 
     880 
     881  if (memcmp (sha.GetDigest (), digest, 20)) 
     882    { 
     883      packet.Initialize (SMSG_AUTH_RESPONSE, 1); 
     884      packet << uint8 (AUTH_FAILED); 
     885 
     886      SendPacket (packet); 
     887 
     888      sLog.outBasic ("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed)."); 
     889      return -1; 
     890    } 
    916891 
    917892  std::string address = this->GetRemoteAddress (); 
     
    935910  ACE_NEW_RETURN (m_Session, WorldSession (id, this, security, tbc, mutetime, locale), -1); 
    936911 
    937 #if defined _NETCODE_FAKE_AUTH 
    938   if (!dontchechtheacc) 
    939     { 
    940 #endif 
    941       this->m_Crypt.SetKey (&K); 
    942       this->m_Crypt.Init (); 
    943 #if defined _NETCODE_FAKE_AUTH 
    944     } 
    945 #endif 
     912  m_Crypt.SetKey (&K); 
     913  m_Crypt.Init (); 
    946914 
    947915  // In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec 
     
    10441012  header.cmd = ACE_SWAP_WORD (header.cmd) 
    10451013#endif 
    1046            
    1047   header.size = (uint16) pct.size () + 2; 
     1014 
     1015          header.size = (uint16) pct.size () + 2; 
    10481016  header.size = ACE_HTONS (header.size); 
    10491017