Cube  Diff

Differences From Artifact [89ff04e5c2]:

To Artifact [cdd53f348e]:


86
87
88
89
90
91
92
93

94
95
96
97
98
99
100
86
87
88
89
90
91
92

93
94
95
96
97
98
99
100







-
+







void
connects(OFString *servername)
{
	disconnect(1); // reset state
	addserver(servername);

	conoutf(@"attempting to connect to %@", servername);
	ENetAddress address = {ENET_HOST_ANY, CUBE_SERVER_PORT};
	ENetAddress address = { ENET_HOST_ANY, CUBE_SERVER_PORT };
	@autoreleasepool {
		if (enet_address_set_host(&address, servername.UTF8String) <
		    0) {
			conoutf(@"could not resolve server %@", servername);
			return;
		}
	}
116
117
118
119
120
121
122
123

124
125
126
127
128

129
130

131
132
133
134
135
136
137
116
117
118
119
120
121
122

123
124
125
126
127

128
129

130
131
132
133
134
135
136
137







-
+




-
+

-
+







disconnect(int onlyclean, int async)
{
	if (clienthost) {
		if (!connecting && !disconnecting) {
			enet_peer_disconnect(clienthost->peers);
			enet_host_flush(clienthost);
			disconnecting = lastmillis;
		};
		}
		if (clienthost->peers->state != ENET_PEER_STATE_DISCONNECTED) {
			if (async)
				return;
			enet_peer_reset(clienthost->peers);
		};
		}
		enet_host_destroy(clienthost);
	};
	}

	if (clienthost && !connecting)
		conoutf(@"disconnected");
	clienthost = NULL;
	connecting = 0;
	connattempts = 0;
	disconnecting = 0;
381
382
383
384
385
386
387
388
389


390
391
392
393
394
395
396
381
382
383
384
385
386
387


388
389
390
391
392
393
394
395
396







-
-
+
+







		conoutf(@"attempting to connect...");
		connecting = lastmillis;
		++connattempts;
		if (connattempts > 3) {
			conoutf(@"could not connect to server");
			disconnect();
			return;
		};
	};
		}
	}
	while (
	    clienthost != NULL && enet_host_service(clienthost, &event, 0) > 0)
		switch (event.type) {
		case ENET_EVENT_TYPE_CONNECT:
			conoutf(@"connected to server");
			connecting = 0;
			throttle();