Server is processing a request for a marker
| 8791 | |
| 8792 | // Server is processing a request for a marker |
| 8793 | void MultiDoRequestMarker(uint8_t *data) { |
| 8794 | MULTI_ASSERT_NOMESSAGE(Netgame.local_role == LR_SERVER); |
| 8795 | |
| 8796 | int count = 0; |
| 8797 | char message[100]; |
| 8798 | SKIP_HEADER(data, &count); |
| 8799 | |
| 8800 | int pnum = MultiGetByte(data, &count); |
| 8801 | uint8_t len = MultiGetByte(data, &count); |
| 8802 | memcpy(message, &data[count], len); |
| 8803 | count += len; |
| 8804 | |
| 8805 | int limit = 2; |
| 8806 | int cur_marker_num; |
| 8807 | |
| 8808 | object *pobj = &Objects[Players[pnum].objnum]; |
| 8809 | |
| 8810 | if (Players[pnum].num_markers >= limit) { |
| 8811 | // Delete the oldest marker |
| 8812 | int found = -1; |
| 8813 | float low_time = 999999999.0f; |
| 8814 | for (int i = 0; i <= Highest_object_index; i++) { |
| 8815 | if (Objects[i].type == OBJ_MARKER && Objects[i].parent_handle == pobj->handle && |
| 8816 | Objects[i].creation_time < low_time) { |
| 8817 | found = i; |
| 8818 | low_time = Objects[i].creation_time; |
| 8819 | } |
| 8820 | } |
| 8821 | |
| 8822 | ASSERT(found != -1); |
| 8823 | |
| 8824 | SetObjectDeadFlag(&Objects[found], true, false); |
| 8825 | |
| 8826 | cur_marker_num = Objects[found].id; |
| 8827 | } else { |
| 8828 | cur_marker_num = pnum * 2 + Players[pnum].num_markers; |
| 8829 | Players[pnum].num_markers++; |
| 8830 | } |
| 8831 | |
| 8832 | int objnum = ObjCreate(OBJ_MARKER, cur_marker_num, pobj->roomnum, &pobj->pos, &pobj->orient, pobj->handle); |
| 8833 | |
| 8834 | if (objnum >= 0) { |
| 8835 | strcpy(MarkerMessages[cur_marker_num], message); |
| 8836 | MultiSendObject(&Objects[objnum], 0); |
| 8837 | } |
| 8838 | } |
| 8839 | |
| 8840 | // Client is asking for a marker |
| 8841 | void MultiSendRequestForMarker(char *message) { |
no test coverage detected