network_server.c
changeset 733 ac3d7e1b786e
parent 722 f420fa9bd521
child 734 f4ad2f5805fd
equal deleted inserted replaced
732:0b3002da2589 733:ac3d7e1b786e
   943 		break;
   943 		break;
   944 	case DESTTYPE_PLAYER: {
   944 	case DESTTYPE_PLAYER: {
   945 		bool show_local = true; // If this is false, the message is already displayed
   945 		bool show_local = true; // If this is false, the message is already displayed
   946 														// on the client who did sent it.
   946 														// on the client who did sent it.
   947 		/* Find all clients that belong to this player */
   947 		/* Find all clients that belong to this player */
       
   948 		ci_to = NULL;
   948 		FOR_ALL_CLIENTS(cs) {
   949 		FOR_ALL_CLIENTS(cs) {
   949 			ci = DEREF_CLIENT_INFO(cs);
   950 			ci = DEREF_CLIENT_INFO(cs);
   950 			if (ci->client_playas == dest) {
   951 			if (ci->client_playas == dest) {
   951 				SEND_COMMAND(PACKET_SERVER_CHAT)(cs, action, from_index, false, msg);
   952 				SEND_COMMAND(PACKET_SERVER_CHAT)(cs, action, from_index, false, msg);
   952 				if (cs->index == from_index)
   953 				if (cs->index == from_index) {
   953 					show_local = false;
   954 					show_local = false;
       
   955 				}
       
   956 				ci_to = ci; // Remember a client that is in the company for company-name
   954 			}
   957 			}
   955 		}
   958 		}
       
   959 
   956 		ci = NetworkFindClientInfoFromIndex(from_index);
   960 		ci = NetworkFindClientInfoFromIndex(from_index);
   957 		ci_own = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
   961 		ci_own = NetworkFindClientInfoFromIndex(NETWORK_SERVER_INDEX);
   958 		if (ci != NULL && ci_own != NULL && ci_own->client_playas == dest) {
   962 		if (ci != NULL && ci_own != NULL && ci_own->client_playas == dest) {
   959 			NetworkTextMessage(action, GetDrawStringPlayerColor(ci->client_playas-1), false, ci->client_name, "%s", msg);
   963 			NetworkTextMessage(action, GetDrawStringPlayerColor(ci->client_playas-1), false, ci->client_name, "%s", msg);
   960 			if (from_index == NETWORK_SERVER_INDEX)
   964 			if (from_index == NETWORK_SERVER_INDEX)
   961 				show_local = false;
   965 				show_local = false;
   962 		}
   966 			ci_to = ci;
       
   967 		}
       
   968 
       
   969 		/* There is no such player */
       
   970 		if (ci_to == NULL)
       
   971 			break;
   963 
   972 
   964 		// Display the message locally (so you know you have sent it)
   973 		// Display the message locally (so you know you have sent it)
   965 		if (ci != NULL && show_local) {
   974 		if (ci != NULL && show_local) {
   966 			if (from_index == NETWORK_SERVER_INDEX) {
   975 			if (from_index == NETWORK_SERVER_INDEX) {
   967 				char name[NETWORK_NAME_LENGTH];
   976 				char name[NETWORK_NAME_LENGTH];
   968 				GetString(name, DEREF_PLAYER(ci->client_playas-1)->name_1);
   977 				GetString(name, DEREF_PLAYER(ci_to->client_playas-1)->name_1);
   969 				NetworkTextMessage(action, GetDrawStringPlayerColor(ci->client_playas-1), true, name, "%s", msg);
   978 				NetworkTextMessage(action, GetDrawStringPlayerColor(ci_own->client_playas-1), true, name, "%s", msg);
   970 			} else {
   979 			} else {
   971 				FOR_ALL_CLIENTS(cs) {
   980 				FOR_ALL_CLIENTS(cs) {
   972 					if (cs->index == from_index) {
   981 					if (cs->index == from_index) {
   973 						SEND_COMMAND(PACKET_SERVER_CHAT)(cs, action, from_index, true, msg);
   982 						SEND_COMMAND(PACKET_SERVER_CHAT)(cs, action, dest, true, msg);
   974 					}
   983 					}
   975 				}
   984 				}
   976 			}
   985 			}
   977 		}
   986 		}
   978 		}
   987 		}