Merge pull request #9 from PixieCore/master

Fixed a console crash, added a broadcasting bool for the server browser.
This commit is contained in:
PixieCore 2021-07-19 14:38:58 +02:00 committed by GitHub
commit 42b27028cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 13 deletions

View File

@ -182,10 +182,11 @@ public:
////////////////////
std::vector<std::string> MapsList;
std::string* SelectedMap = nullptr;
std::string HostRequestMessage;
ImVec4 HostRequestMessageColor;
std::string HostRequestMessage = "";
ImVec4 HostRequestMessageColor = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
char ServerNameBuffer[64] = { 0 };
bool StartAsDedi;
bool StartAsDedi = false;
bool BroadCastServer = false;
void SetSection(ESection section)
{

View File

@ -246,7 +246,7 @@ void CGameConsole::ProcessCommand(const char* command_line)
{
if (Stricmp(History[i], command_line) == 0)
{
free(History[i]);
delete History[i];
History.erase(History.begin() + i);
break;
}
@ -384,6 +384,9 @@ void CCompanion::UpdateHostingStatus()
}
case EHostStatus::Hosting:
{
if (!BroadCastServer) // Do we wanna broadcast server to the browser?
break;
SendHostingPostRequest(GameGlobals::HostState->m_levelName);
break;
}
@ -559,6 +562,8 @@ void CCompanion::ServerBrowserSection()
void CCompanion::HostServerSection()
{
static std::string ServerNameErr = "";
ImGui::InputTextWithHint("Server Name##ServerHost_ServerName", "Required Field", ServerNameBuffer, IM_ARRAYSIZE(ServerNameBuffer));
ImGui::Spacing();
if (ImGui::BeginCombo("Map##ServerHost_MapListBox", SelectedMap->c_str()))
@ -576,10 +581,17 @@ void CCompanion::HostServerSection()
ImGui::Checkbox("Start as dedicated server (HACK)##ServerHost_DediCheckbox", &StartAsDedi);
ImGui::SameLine();
ImGui::Checkbox("Broadcast Server to Server Browser", &BroadCastServer);
ImGui::Separator();
if (ImGui::Button("Start The Server##ServerHost_StartServerButton", ImVec2(ImGui::GetWindowSize().x, 32)))
{
if (strlen(ServerNameBuffer) != 0)
{
ServerNameErr = std::string();
UpdateHostingStatus();
std::stringstream cmd;
@ -591,7 +603,13 @@ void CCompanion::HostServerSection()
ToggleDevCommands();
}
}
else
{
ServerNameErr = "No Server Name assigned.";
}
}
ImGui::TextColored(ImVec4(1.00f, 0.00f, 0.00f, 1.00f), ServerNameErr.c_str());
ImGui::TextColored(HostRequestMessageColor, HostRequestMessage.c_str());
if (StartAsDedi)
@ -696,7 +714,10 @@ void Strtrim(char* s)
void DrawConsole()
{
static CGameConsole console;
static bool AssignPtr = []() {
g_GameConsole = &console;
return true;
} ();
console.Draw("Console");
}