* remove -Wextra from makefile to make older compilers happy
[blender.git] / extern / verse / dist / v_connection.c
index f7a4c23cf5fb3d37b7e3b452576ae52cbe11d5e8..2a97ec66ed1cf6681d9d4b0f30766084c9dbcc4a 100644 (file)
@@ -252,11 +252,14 @@ boolean v_con_network_listen(void)
                else
                {
                        fprintf(stderr, __FILE__ ": Unhandled packet--dropping\n");
-                       fprintf(stderr, __FILE__ ": State: current=%u count=%u stage=%d id=%u\n",
-                              VConData.current_connection,
-                              VConData.con_count,
-                              VConData.con[VConData.current_connection].connect_stage,
-                              packet_id);
+                       if(VConData.con_count > 0)
+                       {
+                               fprintf(stderr, __FILE__ ": State: connections=%u, current=%u (stage %u), packet_id=%u\n",
+                                       VConData.con_count,
+                                       VConData.current_connection,
+                                       (VConData.current_connection < VConData.con_count) ? VConData.con[VConData.current_connection].connect_stage : 0,
+                                       packet_id);
+                       }
                }
                size = v_n_receive_data(&address, buf, sizeof buf); /* See if there are more incoming packets. */
                ret = TRUE;
@@ -315,7 +318,9 @@ void verse_callback_update(unsigned int microseconds)
                        v_destroy_ordered_storage(VConData.con[VConData.current_connection].ordered_storage);
                        if(VConData.con[VConData.current_connection].expected_key != NULL)
                                free(VConData.con[VConData.current_connection].expected_key);
-                       VConData.con[VConData.current_connection] = VConData.con[--VConData.con_count];
+                       if(VConData.con_count - 1 != VConData.current_connection)
+                               VConData.con[VConData.current_connection] = VConData.con[VConData.con_count - 1];
+                       VConData.con_count--;
                        if(connection >= VConData.con_count)
                                VConData.current_connection = 0;
                        return;