]> git.lizzy.rs Git - minetest.git/blobdiff - src/connection.h
Fix getVisibleBrightness() to return sunlight visibility correctly even if not much...
[minetest.git] / src / connection.h
index 570bc92ab22ba817873c0e549af2a59882b46940..b793f580f90d4c73687d6b720c4a183f68b6e5b7 100644 (file)
@@ -59,6 +59,14 @@ class ConnectionException : public BaseException
        {}
 };
 
+class ConnectionBindFailed : public BaseException
+{
+public:
+       ConnectionBindFailed(const char *s):
+               BaseException(s)
+       {}
+};
+
 /*class ThrottlingException : public BaseException
 {
 public:
@@ -424,13 +432,14 @@ enum ConnectionEventType{
        CONNEVENT_DATA_RECEIVED,
        CONNEVENT_PEER_ADDED,
        CONNEVENT_PEER_REMOVED,
+       CONNEVENT_BIND_FAILED,
 };
 
 struct ConnectionEvent
 {
        enum ConnectionEventType type;
        u16 peer_id;
-       SharedBuffer<u8> data;
+       Buffer<u8> data;
        bool timeout;
        Address address;
 
@@ -447,6 +456,8 @@ struct ConnectionEvent
                        return "CONNEVENT_PEER_ADDED";
                case CONNEVENT_PEER_REMOVED: 
                        return "CONNEVENT_PEER_REMOVED";
+               case CONNEVENT_BIND_FAILED: 
+                       return "CONNEVENT_BIND_FAILED";
                }
                return "Invalid ConnectionEvent";
        }
@@ -470,6 +481,10 @@ struct ConnectionEvent
                timeout = timeout_;
                address = address_;
        }
+       void bindFailed()
+       {
+               type = CONNEVENT_BIND_FAILED;
+       }
 };
 
 enum ConnectionCommandType{
@@ -489,7 +504,7 @@ struct ConnectionCommand
        Address address;
        u16 peer_id;
        u8 channelnum;
-       SharedBuffer<u8> data;
+       Buffer<u8> data;
        bool reliable;
        
        ConnectionCommand(): type(CONNCMD_NONE) {}
@@ -551,7 +566,7 @@ class Connection: public SimpleThread
        void Connect(Address address);
        bool Connected();
        void Disconnect();
-       u32 Receive(u16 &peer_id, u8 *data, u32 datasize);
+       u32 Receive(u16 &peer_id, SharedBuffer<u8> &data);
        void SendToAll(u8 channelnum, SharedBuffer<u8> data, bool reliable);
        void Send(u16 peer_id, u8 channelnum, SharedBuffer<u8> data, bool reliable);
        void RunTimeouts(float dtime); // dummy