<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -283,8 +283,6 @@ libmangosgame_a_SOURCES = \
 	Weather.h \
 	World.cpp \
 	World.h \
-	WorldLog.cpp \
-	WorldLog.h \
 	WorldSession.cpp \
 	WorldSession.h \
 	WorldSocket.cpp \</diff>
      <filename>src/game/Makefile.am</filename>
    </modified>
    <modified>
      <diff>@@ -42,7 +42,6 @@
 #include &quot;WorldSession.h&quot;
 #include &quot;WorldSocketMgr.h&quot;
 #include &quot;Log.h&quot;
-#include &quot;WorldLog.h&quot;
 
 #if defined( __GNUC__ )
 #pragma pack(1)
@@ -166,24 +165,21 @@ int WorldSocket::SendPacket (const WorldPacket&amp; pct)
         return -1;
 
     // Dump outgoing packet.
-    if (sWorldLog.LogWorld ())
+    if (sLog.IsLogWorld())
     {
-        sWorldLog.Log (&quot;SERVER:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n&quot;,
-                     (uint32) get_handle (),
-                     pct.size (),
-                     LookupOpcodeName (pct.GetOpcode ()),
-                     pct.GetOpcode ());
-
-        uint32 p = 0;
-        while (p &lt; pct.size ())
+        sLog.outWorld(&quot;S-&gt;C - SOCKET: %u LENGTH: %u OPCODE: %s (0x%.4X)\n&quot;,
+            uint32(get_handle()), pct.size (), LookupOpcodeName(pct.GetOpcode()), pct.GetOpcode());
+
+        size_t p = 0;
+        while (p &lt; pct.size())
         {
-            for (uint32 j = 0; j &lt; 16 &amp;&amp; p &lt; pct.size (); j++)
-                sWorldLog.Log (&quot;%.2X &quot;, const_cast&lt;WorldPacket&amp;&gt;(pct)[p++]);
+            for (size_t j = 0; j &lt; 16 &amp;&amp; p &lt; pct.size(); ++j)
+                sLog.outWorld(&quot;%.2X &quot;, const_cast&lt;WorldPacket&amp;&gt;(pct)[p++]);
 
-            sWorldLog.Log (&quot;\n&quot;);
+            sLog.outWorld(&quot;\n&quot;);
         }
 
-        sWorldLog.Log (&quot;\n\n&quot;);
+        sLog.outWorld(&quot;\n\n&quot;);
     }
 
     ServerPktHeader header(pct.size()+2, pct.GetOpcode());
@@ -682,25 +678,25 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
         return -1;
 
     // Dump received packet.
-    if (sWorldLog.LogWorld ())
+    if (sLog.IsLogWorld())
     {
-        sWorldLog.Log (&quot;CLIENT:\nSOCKET: %u\nLENGTH: %u\nOPCODE: %s (0x%.4X)\nDATA:\n&quot;,
-                     (uint32) get_handle (),
-                     new_pct-&gt;size (),
-                     LookupOpcodeName (new_pct-&gt;GetOpcode ()),
-                     new_pct-&gt;GetOpcode ());
-
-        uint32 p = 0;
-        while (p &lt; new_pct-&gt;size ())
+        sLog.outWorld(&quot;C-&gt;S - SOCKET: %u LENGTH: %u OPCODE: %s (0x%.4X)\n&quot;,
+            uint32(get_handle()), new_pct-&gt;size(), LookupOpcodeName(new_pct-&gt;GetOpcode()), new_pct-&gt;GetOpcode());
+
+        size_t p = 0;
+        while (p &lt; new_pct-&gt;size())
         {
-            for (uint32 j = 0; j &lt; 16 &amp;&amp; p &lt; new_pct-&gt;size (); j++)
-                sWorldLog.Log (&quot;%.2X &quot;, (*new_pct)[p++]);
-            sWorldLog.Log (&quot;\n&quot;);
+            for (size_t j = 0; j &lt; 16 &amp;&amp; p &lt; new_pct-&gt;size(); ++j)
+                sLog.outWorld(&quot;%.2X &quot;, (*new_pct)[p++]);
+
+            sLog.outWorld(&quot;\n&quot;);
         }
-        sWorldLog.Log (&quot;\n\n&quot;);
+
+        sLog.outWorld(&quot;\n\n&quot;);
     }
 
-    try {
+    try
+    {
         switch(opcode)
         {
             case CMSG_PING:
@@ -738,13 +734,13 @@ int WorldSocket::ProcessIncoming (WorldPacket* new_pct)
             }
         }
     }
-    catch(ByteBufferException &amp;)
+    catch (ByteBufferException &amp;)
     {
         sLog.outError(&quot;WorldSocket::ProcessIncoming ByteBufferException occured while parsing an instant handled packet (opcode: %u) from client %s, accountid=%i. Disconnected client.&quot;,
                 opcode, GetRemoteAddress().c_str(), m_Session?m_Session-&gt;GetAccountId():-1);
         if(sLog.IsOutDebug())
         {
-            sLog.outDebug(&quot;Dumping error causing packet:&quot;);
+            sLog.outDebug(&quot;Dumping error-causing packet:&quot;);
             new_pct-&gt;hexlike();
         }
 </diff>
      <filename>src/game/WorldSocket.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -22,7 +22,6 @@
 
 #include &quot;Common.h&quot;
 #include &quot;Database/DatabaseEnv.h&quot;
-#include &quot;ByteBuffer.h&quot;
 #include &quot;Config/ConfigEnv.h&quot;
 #include &quot;Log.h&quot;
 #include &quot;RealmList.h&quot;
@@ -252,14 +251,37 @@ void AuthSocket::OnRead()
     ///- Read the packet
     TcpSocket::OnRead();
     uint8 _cmd;
-    while (1)
+    while (true)
     {
         if (!ibuf.GetLength())
             return;
 
-        ///- Get the command out of it
+        ///- Get the command out of it. We can assume it's there, since length is not 0.
         ibuf.SoftRead((char *)&amp;_cmd, 1);                    // UQ1: No longer exists in new net code ???
 
+        // Dump incoming packet.
+        if (sLog.IsLogWorld())
+        {
+            sLog.outWorld (&quot;C-&gt;S - SOCKET: %u LENGTH: %u OPCODE: 0x%.4X\n&quot;,
+                GetSocket(), ibuf.GetLength(), _cmd);
+
+            size_t p = 0;
+            while (p &lt; ibuf.GetLength())
+            {
+                char dest;
+                for (size_t j = 0; j &lt; 16 &amp;&amp; p &lt; ibuf.GetLength(); ++j)
+                {
+                    ibuf.SoftRead(&amp;dest, 1);
+                    sLog.outWorld(&quot;%.2X &quot;, *((uint8*)dest));
+                    p++;
+                }
+
+                sLog.outWorld(&quot;\n&quot;);
+            }
+
+            sLog.outWorld(&quot;\n\n&quot;);
+        }
+
         size_t i;
 
         ///- Circle through known commands and call the correct command handler
@@ -289,7 +311,34 @@ void AuthSocket::OnRead()
     }
 }
 
-/// Make the SRP6 calculation from hash in dB
+void AuthSocket::SendPacket(ByteBuffer* buf)
+{
+    // TODO: Also handle outgoing structs?
+
+    uint8 _cmd = buf-&gt;read&lt;uint8&gt;();
+
+    // Dump outgoing packet.
+    if (sLog.IsLogWorld())
+    {
+        sLog.outWorld (&quot;S-&gt;C - SOCKET: %u LENGTH: %u OPCODE: 0x%.4X\n&quot;,
+            GetSocket(), buf-&gt;size(), _cmd);
+
+        size_t p = 0;
+        while (p &lt; buf-&gt;size())
+        {
+            for (size_t j = 0; j &lt; 16 &amp;&amp; p &lt; buf-&gt;size(); ++j)
+                sLog.outWorld(&quot;%.2X &quot;, (*buf)[p++]);
+
+            sLog.outWorld(&quot;\n&quot;);
+        }
+
+        sLog.outWorld(&quot;\n\n&quot;);
+    }
+
+    SendBuf((char const*)buf-&gt;contents(), buf-&gt;size());
+}
+
+/// Make the SRP6 calculation from hash in DB
 void AuthSocket::_SetVSFields(const std::string&amp; rI)
 {
     s.SetRand(s_BYTE_SIZE * 8);
@@ -521,7 +570,8 @@ bool AuthSocket::_HandleLogonChallenge()
             pkt&lt;&lt; (uint8) REALM_AUTH_NO_MATCH;
         }
     }
-    SendBuf((char const*)pkt.contents(), pkt.size());
+
+    SendPacket(&amp;pkt);
     return true;
 }
 
@@ -567,7 +617,7 @@ bool AuthSocket::_HandleLogonProof()
             pkt &lt;&lt; (uint8) REALM_AUTH_WRONG_BUILD_NUMBER;
             DEBUG_LOG(&quot;[AuthChallenge] %u is not a valid client version!&quot;, _build);
             DEBUG_LOG(&quot;[AuthChallenge] Patch %s not found&quot;, tmp);
-            SendBuf((char const*)pkt.contents(), pkt.size());
+            SendPacket(&amp;pkt);
             return true;
         }
         else                                                // have patch
@@ -807,7 +857,7 @@ bool AuthSocket::_HandleReconnectChallenge()
     _reconnectProof.SetRand(16 * 8);
     pkt.append(_reconnectProof.AsByteArray(16),16);         // 16 bytes random
     pkt &lt;&lt; (uint64) 0x00 &lt;&lt; (uint64) 0x00;                  // 16 bytes zeros
-    SendBuf((char const*)pkt.contents(), pkt.size());
+    SendPacket(&amp;pkt);
     return true;
 }
 
@@ -839,7 +889,7 @@ bool AuthSocket::_HandleReconnectProof()
         pkt &lt;&lt; (uint8)  AUTH_RECONNECT_PROOF;
         pkt &lt;&lt; (uint8)  0x00;
         pkt &lt;&lt; (uint16) 0x00;                               // 2 bytes zeros
-        SendBuf((char const*)pkt.contents(), pkt.size());
+        SendPacket(&amp;pkt);
 
         ///- Set _authed to true!
         _authed = true;
@@ -921,7 +971,7 @@ bool AuthSocket::_HandleRealmList()
     hdr &lt;&lt; (uint16)pkt.size();
     hdr.append(pkt);
 
-    SendBuf((char const*)hdr.contents(), hdr.size());
+    SendPacket(&amp;pkt);
 
     return true;
 }</diff>
      <filename>src/realmd/AuthSocket.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -24,6 +24,7 @@
 #define _AUTHSOCKET_H
 
 #include &quot;Common.h&quot;
+#include &quot;ByteBuffer.h&quot;
 #include &quot;Auth/BigNumber.h&quot;
 #include &quot;sockets/TcpSocket.h&quot;
 #include &quot;sockets/SocketHandler.h&quot;
@@ -55,6 +56,8 @@ class AuthSocket: public TcpSocket
         bool _HandleXferCancel();
         bool _HandleXferAccept();
 
+        void SendPacket(ByteBuffer* buf);
+
         void _SetVSFields(const std::string&amp; rI);
 
         FILE *pPatch;</diff>
      <filename>src/realmd/AuthSocket.h</filename>
    </modified>
    <modified>
      <diff>@@ -49,6 +49,10 @@ ConfVersion=2007062001
 #        Default: &quot;Realmd.log&quot;
 #                 &quot;&quot; - empty name disable creating log file
 #
+#    WorldLogFile
+#        Packet logging file for the realmserver
+#        Default: &quot;world.log&quot;
+#
 #    LogTimestamp
 #        Logfile with timestamp of server start in name
 #        Default: 0 - no timestamp in name
@@ -105,6 +109,7 @@ PidFile = &quot;&quot;
 LogLevel = 0
 LogTime = 0
 LogFile = &quot;Realmd.log&quot;
+WorldLogFile = &quot;&quot;
 LogTimestamp = 0
 LogFileLevel = 0
 LogColors = &quot;&quot;</diff>
      <filename>src/realmd/realmd.conf.dist.in</filename>
    </modified>
    <modified>
      <diff>@@ -225,9 +225,9 @@ void Log::Initialize()
     }
 
     charLogfile = openLogFile(&quot;CharLogFile&quot;,&quot;CharLogTimestamp&quot;,&quot;a&quot;);
-
     dberLogfile = openLogFile(&quot;DBErrorLogFile&quot;,NULL,&quot;a&quot;);
     raLogfile = openLogFile(&quot;RaLogFile&quot;,NULL,&quot;a&quot;);
+    worldLogfile = openLogFile(&quot;WorldLogFile&quot;,NULL,&quot;a&quot;);
 
     // Main log file settings
     m_includeTime  = sConfig.GetBoolDefault(&quot;LogTime&quot;, false);
@@ -698,6 +698,21 @@ void Log::outChar(const char * str, ... )
     }
 }
 
+void Log::outWorld( const char * str, ... )
+{
+    if (!str)
+        return;
+
+    if (worldLogfile)
+    {
+        va_list args;
+        va_start(args, str);
+        vfprintf(worldLogfile, str, args);
+        va_end(args);
+        fflush(worldLogfile);
+    }
+}
+
 void Log::outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name )
 {
     if(charLogfile)</diff>
      <filename>src/shared/Log.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -80,6 +80,10 @@ class Log : public MaNGOS::Singleton&lt;Log, MaNGOS::ClassLevelLockable&lt;Log, ACE_Th
         if (raLogfile != NULL)
             fclose(raLogfile);
         raLogfile = NULL;
+
+        if (worldLogfile != NULL)
+            fclose(worldLogfile);
+        worldLogfile = NULL;
     }
     public:
         void Initialize();
@@ -106,6 +110,8 @@ class Log : public MaNGOS::Singleton&lt;Log, MaNGOS::ClassLevelLockable&lt;Log, ACE_Th
                                                             // any log level
         void outChar( const char * str, ... )        ATTR_PRINTF(2,3);
                                                             // any log level
+        void outWorld( const char * str, ... )       ATTR_PRINTF(2,3);
+                                                            // any log level
         void outCharDump( const char * str, uint32 account_id, uint32 guid, const char * name );
         void outRALog( const char * str, ... )       ATTR_PRINTF(2,3);
         void SetLogLevel(char * Level);
@@ -118,6 +124,7 @@ class Log : public MaNGOS::Singleton&lt;Log, MaNGOS::ClassLevelLockable&lt;Log, ACE_Th
         uint32 getLogFilter() const { return m_logFilter; }
         bool IsOutDebug() const { return m_logLevel &gt; 2 || (m_logFileLevel &gt; 2 &amp;&amp; logfile); }
         bool IsOutCharDump() const { return m_charLog_Dump; }
+        bool IsLogWorld() const { return (worldLogfile); }
         bool IsIncludeTime() const { return m_includeTime; }
     private:
         FILE* openLogFile(char const* configFileName,char const* configTimeStampFlag, char const* mode);
@@ -128,6 +135,7 @@ class Log : public MaNGOS::Singleton&lt;Log, MaNGOS::ClassLevelLockable&lt;Log, ACE_Th
         FILE* gmLogfile;
         FILE* charLogfile;
         FILE* dberLogfile;
+        FILE* worldLogfile;
 
         // log/console control
         uint32 m_logLevel;
@@ -152,7 +160,7 @@ class Log : public MaNGOS::Singleton&lt;Log, MaNGOS::ClassLevelLockable&lt;Log, ACE_Th
 #define sLog MaNGOS::Singleton&lt;Log&gt;::Instance()
 
 #ifdef MANGOS_DEBUG
-#define DEBUG_LOG MaNGOS::Singleton&lt;Log&gt;::Instance().outDebug
+#define DEBUG_LOG sLog.outDebug
 #else
 #define DEBUG_LOG
 #endif</diff>
      <filename>src/shared/Log.h</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
 #ifndef __REVISION_NR_H__
 #define __REVISION_NR_H__
- #define REVISION_NR &quot;8796&quot;
+ #define REVISION_NR &quot;8797&quot;
 #endif // __REVISION_NR_H__</diff>
      <filename>src/shared/revision_nr.h</filename>
    </modified>
    <modified>
      <diff>@@ -488,7 +488,6 @@
     &lt;ClCompile Include=&quot;..\..\src\game\WaypointMovementGenerator.cpp&quot; /&gt;
     &lt;ClCompile Include=&quot;..\..\src\game\Weather.cpp&quot; /&gt;
     &lt;ClCompile Include=&quot;..\..\src\game\World.cpp&quot; /&gt;
-    &lt;ClCompile Include=&quot;..\..\src\game\WorldLog.cpp&quot; /&gt;
     &lt;ClCompile Include=&quot;..\..\src\game\WorldSession.cpp&quot; /&gt;
     &lt;ClCompile Include=&quot;..\..\src\game\WorldSocket.cpp&quot; /&gt;
     &lt;ClCompile Include=&quot;..\..\src\game\WorldSocketMgr.cpp&quot; /&gt;
@@ -621,7 +620,6 @@
     &lt;ClInclude Include=&quot;..\..\src\game\WaypointMovementGenerator.h&quot; /&gt;
     &lt;ClInclude Include=&quot;..\..\src\game\Weather.h&quot; /&gt;
     &lt;ClInclude Include=&quot;..\..\src\game\World.h&quot; /&gt;
-    &lt;ClInclude Include=&quot;..\..\src\game\WorldLog.h&quot; /&gt;
     &lt;ClInclude Include=&quot;..\..\src\game\WorldSession.h&quot; /&gt;
     &lt;ClInclude Include=&quot;..\..\src\game\WorldSocket.h&quot; /&gt;
     &lt;ClInclude Include=&quot;..\..\src\game\WorldSocketMgr.h&quot; /&gt;</diff>
      <filename>win/VC100/game.vcxproj</filename>
    </modified>
    <modified>
      <diff>@@ -1486,14 +1486,6 @@
 				&gt;
 			&lt;/File&gt;
 			&lt;File
-				RelativePath=&quot;..\..\src\game\WorldLog.cpp&quot;
-				&gt;
-			&lt;/File&gt;
-			&lt;File
-				RelativePath=&quot;..\..\src\game\WorldLog.h&quot;
-				&gt;
-			&lt;/File&gt;
-			&lt;File
 				RelativePath=&quot;..\..\src\game\WorldSession.cpp&quot;
 				&gt;
 			&lt;/File&gt;</diff>
      <filename>win/VC80/game.vcproj</filename>
    </modified>
    <modified>
      <diff>@@ -1487,14 +1487,6 @@
 				&gt;
 			&lt;/File&gt;
 			&lt;File
-				RelativePath=&quot;..\..\src\game\WorldLog.cpp&quot;
-				&gt;
-			&lt;/File&gt;
-			&lt;File
-				RelativePath=&quot;..\..\src\game\WorldLog.h&quot;
-				&gt;
-			&lt;/File&gt;
-			&lt;File
 				RelativePath=&quot;..\..\src\game\WorldSession.cpp&quot;
 				&gt;
 			&lt;/File&gt;</diff>
      <filename>win/VC90/game.vcproj</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>src/game/WorldLog.cpp</filename>
    </removed>
    <removed>
      <filename>src/game/WorldLog.h</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>1798a48d5b65329ccf61c36dbe683d573dcb6fa9</id>
    </parent>
  </parents>
  <author>
    <name>XTZGZoReX</name>
    <email>xtzgzorex@gmail.com</email>
  </author>
  <url>http://github.com/mangos/mangos/commit/d31768fbc6e105ec3d8e6e7b4301af8078d23f59</url>
  <id>d31768fbc6e105ec3d8e6e7b4301af8078d23f59</id>
  <committed-date>2009-11-08T17:24:29-08:00</committed-date>
  <authored-date>2009-11-08T17:24:12-08:00</authored-date>
  <message>[8797] Merge WorldLog class into Log class.

 * Added AuthSocket::SendPacket() function.
 * Packet logging now also possible in realmd.
 * realmd.conf.dist.in updated (added &quot;WorldLogFile&quot; setting).</message>
  <tree>d5250d908d16ae3bee8543c706b35acd943b0340</tree>
  <committer>
    <name>XTZGZoReX</name>
    <email>xtzgzorex@gmail.com</email>
  </committer>
</commit>
