Drops a market at the players current position
| 33 | |
| 34 | // Drops a market at the players current position |
| 35 | void DropMarker(char *message) { |
| 36 | int cur_marker_num; |
| 37 | |
| 38 | #ifdef _DEBUG |
| 39 | char teststring[80]; |
| 40 | strcpy(teststring, message); |
| 41 | teststring[8] = '\0'; |
| 42 | |
| 43 | if (strcmp("ai debug", teststring) == 0) { |
| 44 | sscanf(message, "ai debug %d", &AI_debug_robot_index); |
| 45 | mprintf(0, "Debug robot is object index %d\n", AI_debug_robot_index); |
| 46 | } |
| 47 | #endif |
| 48 | |
| 49 | if (Player_object->type != OBJ_PLAYER) |
| 50 | return; |
| 51 | |
| 52 | if (Game_mode & GM_MULTI) { |
| 53 | MultiSendRequestForMarker(message); |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | int limit = 8; |
| 58 | |
| 59 | if (Players[Player_num].num_markers >= limit) { |
| 60 | // Delete the oldest marker |
| 61 | int found = -1; |
| 62 | float low_time = 999999999.0f; |
| 63 | for (int i = 0; i <= Highest_object_index; i++) { |
| 64 | if (Objects[i].type == OBJ_MARKER && Objects[i].parent_handle == Player_object->handle && |
| 65 | Objects[i].creation_time < low_time) { |
| 66 | found = i; |
| 67 | low_time = Objects[i].creation_time; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | ASSERT(found != -1); |
| 72 | |
| 73 | ObjDelete(found); |
| 74 | |
| 75 | cur_marker_num = Objects[found].id; |
| 76 | } else { |
| 77 | cur_marker_num = Players[Player_num].num_markers; |
| 78 | Players[Player_num].num_markers++; |
| 79 | } |
| 80 | |
| 81 | int objnum = ObjCreate(OBJ_MARKER, cur_marker_num, Player_object->roomnum, &Player_object->pos, |
| 82 | &Player_object->orient, Player_object->handle); |
| 83 | if (objnum >= 0) { |
| 84 | mprintf(0, "Marker %d created!\n", cur_marker_num); |
| 85 | strcpy(MarkerMessages[(Player_num * 2) + cur_marker_num], message); |
| 86 | } else |
| 87 | mprintf(0, "Marker NOT created!\n"); |
| 88 | } |
| 89 | |
| 90 | // Resets markers before a level stars |
| 91 | void ResetMarkers() { Marker_message = 0; } |
no test coverage detected