network_udp.c
changeset 4878 744717de172e
parent 4826 63b1eb7c966b
child 4880 0708f34e3586
equal deleted inserted replaced
4877:d4c365e0d2b6 4878:744717de172e
   212 			NetworkSend_uint16(packet, _network_player_info[player->index].num_station[i]);
   212 			NetworkSend_uint16(packet, _network_player_info[player->index].num_station[i]);
   213 
   213 
   214 		/* Find the clients that are connected to this player */
   214 		/* Find the clients that are connected to this player */
   215 		FOR_ALL_CLIENTS(cs) {
   215 		FOR_ALL_CLIENTS(cs) {
   216 			ci = DEREF_CLIENT_INFO(cs);
   216 			ci = DEREF_CLIENT_INFO(cs);
   217 			if (ci->client_playas - 1 == player->index) {
   217 			if (ci->client_playas == player->index) {
   218 				/* The uint8 == 1 indicates that a client is following */
   218 				/* The uint8 == 1 indicates that a client is following */
   219 				NetworkSend_uint8(packet, 1);
   219 				NetworkSend_uint8(packet, 1);
   220 				NetworkSend_string(packet, ci->client_name);
   220 				NetworkSend_string(packet, ci->client_name);
   221 				NetworkSend_string(packet, ci->unique_id);
   221 				NetworkSend_string(packet, ci->unique_id);
   222 				NetworkSend_uint32(packet, ci->join_date);
   222 				NetworkSend_uint32(packet, ci->join_date);
   223 			}
   223 			}
   224 		}
   224 		}
   225 		/* Also check for the server itself */
   225 		/* Also check for the server itself */
   226 		ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
   226 		ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
   227 		if (ci->client_playas - 1 == player->index) {
   227 		if (ci->client_playas == player->index) {
   228 			/* The uint8 == 1 indicates that a client is following */
   228 			/* The uint8 == 1 indicates that a client is following */
   229 			NetworkSend_uint8(packet, 1);
   229 			NetworkSend_uint8(packet, 1);
   230 			NetworkSend_string(packet, ci->client_name);
   230 			NetworkSend_string(packet, ci->client_name);
   231 			NetworkSend_string(packet, ci->unique_id);
   231 			NetworkSend_string(packet, ci->unique_id);
   232 			NetworkSend_uint32(packet, ci->join_date);
   232 			NetworkSend_uint32(packet, ci->join_date);
   237 	}
   237 	}
   238 
   238 
   239 	/* And check if we have any spectators */
   239 	/* And check if we have any spectators */
   240 	FOR_ALL_CLIENTS(cs) {
   240 	FOR_ALL_CLIENTS(cs) {
   241 		ci = DEREF_CLIENT_INFO(cs);
   241 		ci = DEREF_CLIENT_INFO(cs);
   242 		if (ci->client_playas - 1 > MAX_PLAYERS) {
   242 		if (!IsValidPlayer(ci->client_playas)) {
   243 			/* The uint8 == 1 indicates that a client is following */
   243 			/* The uint8 == 1 indicates that a client is following */
   244 			NetworkSend_uint8(packet, 1);
   244 			NetworkSend_uint8(packet, 1);
   245 			NetworkSend_string(packet, ci->client_name);
   245 			NetworkSend_string(packet, ci->client_name);
   246 			NetworkSend_string(packet, ci->unique_id);
   246 			NetworkSend_string(packet, ci->unique_id);
   247 			NetworkSend_uint32(packet, ci->join_date);
   247 			NetworkSend_uint32(packet, ci->join_date);
   248 		}
   248 		}
   249 	}
   249 	}
   250 	/* Also check for the server itself */
   250 	/* Also check for the server itself */
   251 	ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
   251 	ci = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
   252 	if (ci->client_playas - 1 > MAX_PLAYERS) {
   252 	if (!IsValidPlayer(ci->client_playas)) {
   253 		/* The uint8 == 1 indicates that a client is following */
   253 		/* The uint8 == 1 indicates that a client is following */
   254 		NetworkSend_uint8(packet, 1);
   254 		NetworkSend_uint8(packet, 1);
   255 		NetworkSend_string(packet, ci->client_name);
   255 		NetworkSend_string(packet, ci->client_name);
   256 		NetworkSend_string(packet, ci->unique_id);
   256 		NetworkSend_string(packet, ci->unique_id);
   257 		NetworkSend_uint32(packet, ci->join_date);
   257 		NetworkSend_uint32(packet, ci->join_date);