[Dedicated] Add sv_motd dvar, so serverowners can set motds
The motd will be displayed instead of the didyouknow messages in the loadscreen
This commit is contained in:
parent
159f172a07
commit
2969ae64e0
@ -330,6 +330,7 @@ namespace Components
|
|||||||
Dvar::OnInit([] ()
|
Dvar::OnInit([] ()
|
||||||
{
|
{
|
||||||
Dvar::Register<const char*>("sv_sayName", "^7Console", Game::dvar_flag::DVAR_FLAG_NONE, "The name to pose as for 'say' commands");
|
Dvar::Register<const char*>("sv_sayName", "^7Console", Game::dvar_flag::DVAR_FLAG_NONE, "The name to pose as for 'say' commands");
|
||||||
|
Dvar::Register<const char*>("sv_motd", "", Game::dvar_flag::DVAR_FLAG_NONE, "A custom message of the day for servers");
|
||||||
|
|
||||||
// Say command
|
// Say command
|
||||||
Command::AddSV("say", [] (Command::Params params)
|
Command::AddSV("say", [] (Command::Params params)
|
||||||
|
@ -623,7 +623,16 @@ namespace Components
|
|||||||
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_MENUFILE, Menus::MenuFileLoad);
|
AssetHandler::OnFind(Game::XAssetType::ASSET_TYPE_MENUFILE, Menus::MenuFileLoad);
|
||||||
|
|
||||||
// Don't open connect menu
|
// Don't open connect menu
|
||||||
Utils::Hook::Nop(0x428E48, 5);
|
//Utils::Hook::Nop(0x428E48, 5);
|
||||||
|
|
||||||
|
// Use the connect menu open call to update server motds
|
||||||
|
Utils::Hook(0x428E48, []()
|
||||||
|
{
|
||||||
|
if (!Party::GetMotd().empty())
|
||||||
|
{
|
||||||
|
Dvar::Var("didyouknow").set(Party::GetMotd());
|
||||||
|
}
|
||||||
|
}, HOOK_CALL).install()->quick();
|
||||||
|
|
||||||
// Intercept menu painting
|
// Intercept menu painting
|
||||||
Utils::Hook(0x4FFBDF, Menus::IsMenuVisible, HOOK_CALL).install()->quick();
|
Utils::Hook(0x4FFBDF, Menus::IsMenuVisible, HOOK_CALL).install()->quick();
|
||||||
|
@ -72,6 +72,11 @@ namespace Components
|
|||||||
Command::Execute("openmenu menu_xboxlive_partyended");
|
Command::Execute("openmenu menu_xboxlive_partyended");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Party::GetMotd()
|
||||||
|
{
|
||||||
|
return Party::Container.motd;
|
||||||
|
}
|
||||||
|
|
||||||
Game::dvar_t* Party::RegisterMinPlayers(const char* name, int /*value*/, int /*min*/, int max, Game::dvar_flag flag, const char* description)
|
Game::dvar_t* Party::RegisterMinPlayers(const char* name, int /*value*/, int /*min*/, int max, Game::dvar_flag flag, const char* description)
|
||||||
{
|
{
|
||||||
return Dvar::Register<int>(name, 1, 1, max, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED | flag, description).get<Game::dvar_t*>();
|
return Dvar::Register<int>(name, 1, 1, max, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED | flag, description).get<Game::dvar_t*>();
|
||||||
@ -319,6 +324,11 @@ namespace Components
|
|||||||
info.set("securityLevel", fmt::sprintf("%i", Dvar::Var("sv_securityLevel").get<int>()));
|
info.set("securityLevel", fmt::sprintf("%i", Dvar::Var("sv_securityLevel").get<int>()));
|
||||||
info.set("sv_running", (Dvar::Var("sv_running").get<bool>() ? "1" : "0"));
|
info.set("sv_running", (Dvar::Var("sv_running").get<bool>() ? "1" : "0"));
|
||||||
|
|
||||||
|
if (Dedicated::IsEnabled())
|
||||||
|
{
|
||||||
|
info.set("sv_motd", Dvar::Var("sv_motd").get<std::string>());
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure mapname is set
|
// Ensure mapname is set
|
||||||
if (info.get("mapname").empty() || (Dvar::Var("party_enable").get<bool>() && Dvar::Var("party_host").get<bool>() && !Dvar::Var("sv_running").get<bool>()))
|
if (info.get("mapname").empty() || (Dvar::Var("party_enable").get<bool>() && Dvar::Var("party_host").get<bool>() && !Dvar::Var("sv_running").get<bool>()))
|
||||||
{
|
{
|
||||||
@ -398,6 +408,8 @@ namespace Components
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Party::Container.motd = info.get("sv_motd");
|
||||||
|
|
||||||
if (Party::Container.matchType == 1) // Party
|
if (Party::Container.matchType == 1) // Party
|
||||||
{
|
{
|
||||||
// Send playlist request
|
// Send playlist request
|
||||||
|
@ -21,12 +21,15 @@ namespace Components
|
|||||||
|
|
||||||
static void ConnectError(std::string message);
|
static void ConnectError(std::string message);
|
||||||
|
|
||||||
|
static std::string GetMotd();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class JoinContainer
|
class JoinContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Network::Address target;
|
Network::Address target;
|
||||||
std::string challenge;
|
std::string challenge;
|
||||||
|
std::string motd;
|
||||||
DWORD joinTime;
|
DWORD joinTime;
|
||||||
bool valid;
|
bool valid;
|
||||||
int matchType;
|
int matchType;
|
||||||
@ -35,7 +38,7 @@ namespace Components
|
|||||||
|
|
||||||
// Party-specific stuff
|
// Party-specific stuff
|
||||||
DWORD requestTime;
|
DWORD requestTime;
|
||||||
bool awaitingPlaylist;
|
bool awaitingPlaylist;
|
||||||
};
|
};
|
||||||
|
|
||||||
static JoinContainer Container;
|
static JoinContainer Container;
|
||||||
|
Loading…
Reference in New Issue
Block a user