Remove accidental usage of the async pipeline (#305)

Removing the parameter default value will prevent this from happening in the future
This commit is contained in:
Edo 2022-06-13 19:59:32 +02:00 committed by GitHub
parent 19d17440ec
commit e754e9d56a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 37 deletions

View File

@ -101,23 +101,17 @@ namespace Components
void Dedicated::TimeWrapStub(Game::errorParm_t code, const char* message)
{
static bool partyEnable;
static std::string mapname;
partyEnable = Dvar::Var("party_enable").get<bool>();
mapname = Dvar::Var("mapname").get<std::string>();
Scheduler::Once([]()
Scheduler::Once([]
{
Dvar::Var("party_enable").set(partyEnable);
const auto partyEnable = Dvar::Var("party_enable").get<bool>();
auto mapname = Dvar::Var("mapname").get<std::string>();
if (!partyEnable) // Time wrapping should not occur in party servers, but yeah...
{
if (mapname.empty()) mapname = "mp_rust";
Command::Execute(Utils::String::VA("map %s", mapname.data()), false);
mapname.clear();
}
});
}, Scheduler::Pipeline::SERVER);
Game::Com_Error(code, message);
}

View File

@ -21,12 +21,12 @@ namespace Components
{
if (Download::CLDownload.running) return;
Scheduler::Once([]()
Scheduler::Once([]
{
Dvar::Var("ui_dl_timeLeft").set(Utils::String::FormatTimeSpan(0));
Dvar::Var("ui_dl_progress").set("(0/0) %");
Dvar::Var("ui_dl_transRate").set("0.0 MB/s");
});
}, Scheduler::Pipeline::MAIN);
Command::Execute("openmenu mod_download_popmenu", false);
@ -155,22 +155,23 @@ namespace Components
}
}
std::string host = "http://" + download->target.getString();
std::string fastHost = Dvar::Var("sv_wwwBaseUrl").get<std::string>();
auto host = "http://" + download->target.getString();
auto fastHost = Dvar::Var("sv_wwwBaseUrl").get<std::string>();
if (Utils::String::StartsWith(fastHost, "https://"))
{
download->thread.detach();
download->clear();
Scheduler::Once([]()
Scheduler::Once([]
{
Command::Execute("closemenu mod_download_popmenu");
Party::ConnectError("HTTPS not supported for downloading!");
});
}, Scheduler::Pipeline::CLIENT);
return 0;
return false;
}
else if (!Utils::String::StartsWith(fastHost, "http://"))
if (!Utils::String::StartsWith(fastHost, "http://"))
{
fastHost = "http://" + fastHost;
}
@ -277,11 +278,11 @@ namespace Components
download->thread.detach();
download->clear();
Scheduler::Once([]()
Scheduler::Once([]
{
Command::Execute("closemenu mod_download_popmenu");
Party::ConnectError("Failed to download the modlist!");
});
}, Scheduler::Pipeline::CLIENT);
return;
}
@ -295,11 +296,11 @@ namespace Components
download->thread.detach();
download->clear();
Scheduler::Once([]()
Scheduler::Once([]
{
Command::Execute("closemenu mod_download_popmenu");
Party::ConnectError("Failed to parse the modlist!");
});
}, Scheduler::Pipeline::CLIENT);
return;
}
@ -321,14 +322,14 @@ namespace Components
download->thread.detach();
download->clear();
Scheduler::Once([]()
Scheduler::Once([]
{
Dvar::Var("partyend_reason").set(mod);
mod.clear();
Command::Execute("closemenu mod_download_popmenu");
Command::Execute("openmenu menu_xboxlive_partyended");
});
}, Scheduler::Pipeline::CLIENT);
return;
}
@ -341,15 +342,15 @@ namespace Components
if (download->isMap)
{
Scheduler::Once([]()
Scheduler::Once([]
{
Command::Execute("reconnect", false);
});
}, Scheduler::Pipeline::CLIENT);
}
else
{
// Run this on the main thread
Scheduler::Once([]()
Scheduler::Once([]
{
auto fsGame = Dvar::Var("fs_game");
fsGame.set(mod);
@ -364,7 +365,7 @@ namespace Components
}
Command::Execute("reconnect", false);
});
}, Scheduler::Pipeline::MAIN);
}
}
@ -419,11 +420,11 @@ namespace Components
dlProgress = static_cast<unsigned int>(progress);
framePushed = true;
Scheduler::Once([]()
Scheduler::Once([]
{
framePushed = false;
Dvar::Var("ui_dl_progress").set(Utils::String::VA("(%d/%d) %d%%", dlIndex, dlSize, dlProgress));
});
}, Scheduler::Pipeline::CLIENT);
}
int delta = Game::Sys_Milliseconds() - fDownload->download->lastTimeStamp;
@ -449,11 +450,11 @@ namespace Components
dlDelta = delta;
dlTsBytes = fDownload->download->timeStampBytes;
Scheduler::Once([]()
Scheduler::Once([]
{
Dvar::Var("ui_dl_timeLeft").set(Utils::String::FormatTimeSpan(dlTimeLeft));
Dvar::Var("ui_dl_transRate").set(Utils::String::FormatBandwidth(dlTsBytes, dlDelta));
});
}, Scheduler::Pipeline::MAIN);
}
fDownload->download->timeStampBytes = 0;

View File

@ -739,7 +739,7 @@ namespace Components
Friends::UpdateState();
Friends::UpdateFriends();
});
}, Scheduler::Pipeline::MAIN);
}
Friends::~Friends()

View File

@ -20,13 +20,13 @@ namespace Components
void preDestroy() override;
static void Schedule(const std::function<bool()>& callback, Pipeline type = Pipeline::ASYNC,
static void Schedule(const std::function<bool()>& callback, Pipeline type,
std::chrono::milliseconds delay = 0ms);
static void Loop(const std::function<void()>& callback, Pipeline type = Pipeline::ASYNC,
static void Loop(const std::function<void()>& callback, Pipeline type,
std::chrono::milliseconds delay = 0ms);
static void Once(const std::function<void()>& callback, Pipeline type = Pipeline::ASYNC,
static void Once(const std::function<void()>& callback, Pipeline type,
std::chrono::milliseconds delay = 0ms);
static void OnGameInitialized(const std::function<void()>& callback, Pipeline type = Pipeline::ASYNC,
static void OnGameInitialized(const std::function<void()>& callback, Pipeline type,
std::chrono::milliseconds delay = 0ms);
static void OnGameShutdown(const std::function<void()>& callback);