]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - netconn.c
made darkplaces compile successfully with g++ to test for errors C doesn't care about...
[xonotic/darkplaces.git] / netconn.c
index c914d0c2a179635a3340d44b0d9ea69fed313719..dea1166001d35f7fb13790fe7088c0294d1c8bd1 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -208,10 +208,10 @@ static qboolean _ServerList_CompareStr( const char *A, serverlist_maskop_t op, c
 {
        int i;
        char bufferA[ 256 ], bufferB[ 256 ]; // should be more than enough
-       for (i = 0;i < sizeof(bufferA)-1 && A[i];i++)
+       for (i = 0;i < (int)sizeof(bufferA)-1 && A[i];i++)
                bufferA[i] = (A[i] >= 'A' && A[i] <= 'Z') ? (A[i] + 'a' - 'A') : A[i];
        bufferA[i] = 0;
-       for (i = 0;i < sizeof(bufferB)-1 && B[i];i++)
+       for (i = 0;i < (int)sizeof(bufferB)-1 && B[i];i++)
                bufferB[i] = (B[i] >= 'A' && B[i] <= 'Z') ? (B[i] + 'a' - 'A') : B[i];
        bufferB[i] = 0;
 
@@ -397,7 +397,7 @@ int NetConn_Read(lhnetsocket_t *mysocket, void *data, int maxlength, lhnetaddres
                {
                        LHNETADDRESS_ToString(peeraddress, addressstring2, sizeof(addressstring2), true);
                        Con_Printf("LHNET_Read(%p (%s), %p, %i, %p) = %i from %s:\n", mysocket, addressstring, data, maxlength, peeraddress, length, addressstring2);
-                       Com_HexDumpToConsole(data, length);
+                       Com_HexDumpToConsole((qbyte *)data, length);
                }
                else
                        Con_Printf("LHNET_Read(%p (%s), %p, %i, %p) = %i\n", mysocket, addressstring, data, maxlength, peeraddress, length);
@@ -420,7 +420,7 @@ int NetConn_Write(lhnetsocket_t *mysocket, const void *data, int length, const l
                LHNETADDRESS_ToString(LHNET_AddressFromSocket(mysocket), addressstring, sizeof(addressstring), true);
                LHNETADDRESS_ToString(peeraddress, addressstring2, sizeof(addressstring2), true);
                Con_Printf("LHNET_Write(%p (%s), %p, %i, %p (%s)) = %i%s\n", mysocket, addressstring, data, length, peeraddress, addressstring2, length, ret == length ? "" : " (ERROR)");
-               Com_HexDumpToConsole(data, length);
+               Com_HexDumpToConsole((qbyte *)data, length);
        }
        return ret;
 }
@@ -428,7 +428,7 @@ int NetConn_Write(lhnetsocket_t *mysocket, const void *data, int length, const l
 int NetConn_WriteString(lhnetsocket_t *mysocket, const char *string, const lhnetaddress_t *peeraddress)
 {
        // note this does not include the trailing NULL because we add that in the parser
-       return NetConn_Write(mysocket, string, strlen(string), peeraddress);
+       return NetConn_Write(mysocket, string, (int)strlen(string), peeraddress);
 }
 
 int NetConn_SendReliableMessage(netconn_t *conn, sizebuf_t *data)
@@ -474,7 +474,7 @@ int NetConn_SendReliableMessage(netconn_t *conn, sizebuf_t *data)
 
        packetLen = NET_HEADERSIZE + dataLen;
 
-       header = (void *)sendbuffer;
+       header = (unsigned int *)sendbuffer;
        header[0] = BigLong(packetLen | (NETFLAG_DATA | eom));
        header[1] = BigLong(conn->sendSequence);
        memcpy(sendbuffer + NET_HEADERSIZE, conn->sendMessage, dataLen);
@@ -513,7 +513,7 @@ static void NetConn_SendMessageNext(netconn_t *conn)
 
                packetLen = NET_HEADERSIZE + dataLen;
 
-               header = (void *)sendbuffer;
+               header = (unsigned int *)sendbuffer;
                header[0] = BigLong(packetLen | (NETFLAG_DATA | eom));
                header[1] = BigLong(conn->sendSequence);
                memcpy(sendbuffer + NET_HEADERSIZE, conn->sendMessage, dataLen);
@@ -551,7 +551,7 @@ static void NetConn_ReSendMessage(netconn_t *conn)
 
                packetLen = NET_HEADERSIZE + dataLen;
 
-               header = (void *)sendbuffer;
+               header = (unsigned int *)sendbuffer;
                header[0] = BigLong(packetLen | (NETFLAG_DATA | eom));
                header[1] = BigLong(conn->sendSequence - 1);
                memcpy(sendbuffer + NET_HEADERSIZE, conn->sendMessage, dataLen);
@@ -574,7 +574,7 @@ qboolean NetConn_CanSendMessage(netconn_t *conn)
 int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data)
 {
        int packetLen;
-       int *header;
+       unsigned int *header;
 
        packetLen = NET_HEADERSIZE + data->cursize;
 
@@ -592,7 +592,7 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data)
        }
 //#endif
 
-       header = (void *)sendbuffer;
+       header = (unsigned int *)sendbuffer;
        header[0] = BigLong(packetLen | NETFLAG_UNRELIABLE);
        header[1] = BigLong(conn->unreliableSendSequence);
        memcpy(sendbuffer + NET_HEADERSIZE, data->data, data->cursize);
@@ -681,7 +681,7 @@ void NetConn_OpenServerPort(const char *addressstring, int defaultport)
                                Con_Printf("Server failed to open socket on address %s\n", addressstring2);
                        }
                }
-               else 
+               else
                {
                        Con_Printf("Server unable to parse address %s\n", addressstring);
                        // if it cant parse one address, it wont be able to parse another for sure
@@ -732,7 +732,7 @@ lhnetsocket_t *NetConn_ChooseServerSocketForAddress(lhnetaddress_t *address)
 netconn_t *NetConn_Open(lhnetsocket_t *mysocket, lhnetaddress_t *peeraddress)
 {
        netconn_t *conn;
-       conn = Mem_Alloc(netconn_mempool, sizeof(*conn));
+       conn = (netconn_t *)Mem_Alloc(netconn_mempool, sizeof(*conn));
        conn->mysocket = mysocket;
        conn->peeraddress = *peeraddress;
        conn->canSend = true;
@@ -887,7 +887,7 @@ int NetConn_ReceivedMessage(netconn_t *conn, qbyte *data, int length)
                                        conn->lastMessageTime = realtime;
                                        conn->timeout = realtime + net_messagetimeout.value;
                                        conn->receiveSequence++;
-                                       if( conn->receiveMessageLength + length <= sizeof( conn->receiveMessage ) ) {
+                                       if( conn->receiveMessageLength + length <= (int)sizeof( conn->receiveMessage ) ) {
                                                memcpy(conn->receiveMessage + conn->receiveMessageLength, data, length);
                                                conn->receiveMessageLength += length;
                                        } else {
@@ -1169,7 +1169,7 @@ int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, qbyte *data, int length,
                        if (developer.integer)
                                Con_Printf("Datagram_ParseConnectionless: received CCREP_REJECT from %s.\n", addressstring2);
                        cls.connect_trying = false;
-                       M_Update_Return_Reason(data);
+                       M_Update_Return_Reason((char *)data);
                        break;
 #if 0
                case CCREP_SERVER_INFO:
@@ -1399,7 +1399,7 @@ static qboolean NetConn_BuildStatusResponse(const char* challenge, char* out_msg
                int left;
 
                ptr = out_msg + length;
-               left = out_size - length;
+               left = (int)out_size - length;
 
                for (i = 0;i < (unsigned int)svs.maxclients;i++)
                {