]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/socket.cpp
Don't remove furnace if something is inside it.
[dragonfireclient.git] / src / socket.cpp
index 499ee504e0d7e33c3c793577a5f040b2971a8486..ac4871f6145524059f4ed73b1d2de0a1864a7f59 100644 (file)
@@ -26,7 +26,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "utility.h"
 
 // Debug printing options
+// Set to 1 for debug output
 #define DP 0
+// This is prepended to everything printed here
 #define DPS ""
 
 bool g_sockets_initialized = false;
@@ -51,6 +53,8 @@ void sockets_cleanup()
 
 Address::Address()
 {
+       m_address = 0;
+       m_port = 0;
 }
 
 Address::Address(unsigned int address, unsigned short port)
@@ -93,6 +97,16 @@ void Address::Resolve(const char *name)
        freeaddrinfo(resolved);
 }
 
+std::string Address::serializeString()
+{
+       unsigned int a, b, c, d;
+       a = (m_address & 0xFF000000)>>24;
+       b = (m_address & 0x00FF0000)>>16;
+       c = (m_address & 0x0000FF00)>>8;
+       d = (m_address & 0x000000FF);
+       return itos(a)+"."+itos(b)+"."+itos(c)+"."+itos(d);
+}
+
 unsigned int Address::getAddress() const
 {
        return m_address;
@@ -108,6 +122,12 @@ void Address::setAddress(unsigned int address)
        m_address = address;
 }
 
+void Address::setAddress(unsigned int a, unsigned int b,
+               unsigned int c, unsigned int d)
+{
+       m_address = (a<<24) | (b<<16) | ( c<<8) | d;
+}
+
 void Address::setPort(unsigned short port)
 {
        m_port = port;