diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 090c7edaf..75bd50915 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -542,6 +542,7 @@ void D_RegisterClientCommands(void) COM_AddCommand("stopmovie", Command_StopMovie_f); COM_AddDebugCommand("minigen", M_MinimapGenerate); COM_AddDebugCommand("dumprrautomedaltimes", Command_dumprrautomedaltimes); + COM_AddDebugCommand("platinums", Command_Platinums); #ifdef SRB2_CONFIG_ENABLE_WEBM_MOVIES M_AVRecorder_AddCommands(); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 699108001..d8f91e0fd 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -9501,6 +9501,126 @@ void Command_dumprrautomedaltimes(void) fclose(out); } +void Command_Platinums(void) +{ + srb2::Vector platinums; + + for (INT32 j = 0; j < nummapheaders; j++) + { + mapheader_t *map = mapheaderinfo[j]; + + if (map == NULL || map->ghostCount < 1) + continue; + + srb2::Vector> stafftimes; + for (int i = 0; i < map->ghostCount; i++) + { + tic_t time = map->ghostBrief[i]->time; + if (time <= 0) + { + continue; + } + + stafftimes.push_back(std::make_pair(map->ghostBrief[i]->time, map->ghostBrief[i]->name)); + } + + if (stafftimes.empty()) + { + continue; + } + + std::sort(stafftimes.begin(), stafftimes.end(), [](auto &left, auto &right) { + return left.first < right.first; + }); + + CONS_Printf("%s: ", map->lumpname); + + tic_t platinumtime = UINT32_MAX; + + std::unordered_map names; + + for (auto &stafftime : stafftimes) + { + if (stafftime == stafftimes[0]) + { + CONS_Printf("%s (%02d:%02d:%02d)", stafftime.second.c_str(), + G_TicsToMinutes(stafftime.first, true), G_TicsToSeconds(stafftime.first), G_TicsToCentiseconds(stafftime.first)); + platinumtime = stafftime.first; + } + else + { + CONS_Printf(", %s (+%d:%02d)", stafftime.second.c_str(), + G_TicsToSeconds(stafftime.first - platinumtime), G_TicsToCentiseconds(stafftime.first - platinumtime)); + } + + names[stafftime.second]++; + if (names[stafftime.second] > 1) + { + CONS_Printf(" (DUPLICATE)"); + } + } + + CONS_Printf("\n"); + + platinums.push_back(stafftimes[0].second); + } + + std::unordered_map frequency; + + for (const auto& platinum : platinums) + { + frequency[platinum]++; + } + + for (const auto& pair : frequency) + { + CONS_Printf("%s: %d - ", pair.first.c_str(), pair.second); + + for (INT32 j = 0; j < nummapheaders; j++) + { + mapheader_t *map = mapheaderinfo[j]; + + if (map == NULL || map->ghostCount < 1) + continue; + + // Gather staff ghost times + srb2::Vector stafftimes; + for (int i = 0; i < map->ghostCount; i++) + { + tic_t time = map->ghostBrief[i]->time; + if (time <= 0) + { + continue; + } + + stafftimes.push_back(map->ghostBrief[i]->time); + } + + if (stafftimes.empty()) + { + continue; + } + + std::sort(stafftimes.begin(), stafftimes.end()); + + for (int i = 0; i < map->ghostCount; i++) + { + if (strcmp(pair.first.c_str(), map->ghostBrief[i]->name)) + break; + + tic_t time = map->ghostBrief[i]->time; + if (time == stafftimes.at(0)) + { + CONS_Printf("%s, ", map->lumpname); + break; + } + } + } + + CONS_Printf("\n"); + } +} + // // Add a wadfile to the active wad files, // replace sounds, musics, patches, textures, sprites and maps diff --git a/src/p_setup.h b/src/p_setup.h index a9839e3f8..7233f885f 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -162,6 +162,7 @@ void P_DeleteHeaderFollowers(UINT16 i); void P_ReloadRings(void); void Command_dumprrautomedaltimes(void); +void Command_Platinums(void); #ifdef __cplusplus } // extern "C"