Skip to content

Update global cache properly #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/kz/global/kz_global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ void KZGlobalService::OnActivateServer()
if (mapInfo.data.has_value())
{
META_CONPRINTF("[KZ::Global] %s is approved.\n", mapInfo.data->name.c_str());

for (const auto &course : mapInfo.data->courses)
{
KZ::course::UpdateCourseGlobalID(course.name.c_str(), course.id);
META_CONPRINTF("[KZ::Global] Registered course '%s' with ID %i!\n", course.name.c_str(), course.id);
}
}
else
{
Expand Down Expand Up @@ -475,7 +481,7 @@ void KZGlobalService::OnWebSocketMessage(const ix::WebSocketMessagePtr &message)

case ix::WebSocketMessageType::Message:
{
META_CONPRINTF("[KZ::Global] Received WebSocket message:\n-----\n%s\n------\n", message->str.c_str());
META_CONPRINTF("[KZ::Global] Received WebSocket message:\n-----\n%s\n------\n", message->str.substr(0, 1024).c_str());

Json payload(message->str);

Expand Down Expand Up @@ -573,6 +579,15 @@ void KZGlobalService::CompleteHandshake(KZ::API::handshake::HelloAck &ack)
}).detach();
// clang-format on

if (ack.mapInfo.has_value())
{
for (const auto &course : ack.mapInfo->courses)
{
KZ::course::UpdateCourseGlobalID(course.name.c_str(), course.id);
META_CONPRINTF("[KZ::Global] Registered course '%s' with ID %i!\n", course.name.c_str(), course.id);
}
}

{
std::unique_lock lock(KZGlobalService::currentMap.mutex);
KZGlobalService::currentMap.data = std::move(ack.mapInfo);
Expand Down
3 changes: 0 additions & 3 deletions src/kz/timer/announce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@ void RecordAnnounce::UpdateGlobalCache()
auto mode = KZ::mode::GetModeInfo(this->mode.name.c_str());
if (mode.id > -2)
{
META_CONPRINTF("this->time=%f this->oldGPB.overall.time=%f, this->oldGPB.pro.time=%f", this->time, this->oldGPB.overall.time,
this->oldGPB.pro.time);

if (this->time < this->oldGPB.overall.time)
{
player->timerService->InsertPBToCache(this->time, course, mode.id, true, true, this->metadata.c_str(),
Expand Down