// Launch button click void dlgMain::OnLaunch(wxCommandEvent &event) { wxString Password; wxString UsrPwHash; wxString SrvPwHash; wxInt32 i; i = GetSelectedServerArrayIndex(); if (i == -1) return; // If the server is passworded, pop up a password entry dialog for them to // specify one before going any further SrvPwHash = QServer[i].Info.PasswordHash; if (SrvPwHash.IsEmpty() == false) { wxPasswordEntryDialog ped(this, wxT("Please enter a password"), wxT("This server is passworded"), wxT("")); SrvPwHash.MakeUpper(); while (1) { // Show the dialog box and get the resulting value ped.ShowModal(); Password = ped.GetValue(); // User possibly hit cancel or did not enter anything, just exit if (Password.IsEmpty()) return; UsrPwHash = MD5SUM(Password); UsrPwHash.MakeUpper(); // Do an MD5 comparison of the password with the servers one, if it // fails, keep asking the user to enter a valid password, otherwise // dive out and connect to the server if (SrvPwHash != UsrPwHash) { wxMessageDialog Message(this, wxT("Incorrect password"), wxT("Incorrect password"), wxOK | wxICON_HAND); Message.ShowModal(); // Reset the text so weird things don't happen ped.SetValue(wxT("")); } else break; } } LaunchGame(QServer[i].GetAddress(), launchercfg_s.odamex_directory, launchercfg_s.wad_paths, Password); }
std::string MD5SUM(std::string in) { return MD5SUM(in.c_str(), in.length()); }
void IntDownloadComplete(void) { std::string actual_md5 = MD5SUM(download.buf->ptr(), download.buf->maxsize()); Printf(PRINT_HIGH, "\nDownload complete, got %u bytes\n", download.buf->maxsize()); Printf(PRINT_HIGH, "%s\n %s\n", download.filename.c_str(), actual_md5.c_str()); if(download.md5 == "") { Printf(PRINT_HIGH, "Server gave no checksum, assuming valid\n", (int)download.buf->maxsize()); } else if(actual_md5 != download.md5) { Printf(PRINT_HIGH, " %s on server\n", download.md5.c_str()); Printf(PRINT_HIGH, "Download failed: bad checksum\n"); download.clear(); CL_QuitNetGame(); ClearDownloadProgressBar(); return; } // got the wad! save it! std::vector<std::string> dirs; std::string filename; size_t i; #ifdef _WIN32 const char separator = ';'; #else const char separator = ':'; #endif // Try to save to the wad paths in this order -- Hyper_Eye D_AddSearchDir(dirs, Args.CheckValue("-waddir"), separator); D_AddSearchDir(dirs, getenv("DOOMWADDIR"), separator); D_AddSearchDir(dirs, getenv("DOOMWADPATH"), separator); D_AddSearchDir(dirs, waddirs.cstring(), separator); dirs.push_back(startdir); dirs.push_back(progdir); dirs.erase(std::unique(dirs.begin(), dirs.end()), dirs.end()); for(i = 0; i < dirs.size(); i++) { filename.clear(); filename = dirs[i]; if(filename[filename.length() - 1] != PATHSEPCHAR) filename += PATHSEP; filename += download.filename; // check for existing file if(M_FileExists(filename.c_str())) { // there is an existing file, so use a new file whose name includes the checksum filename += "."; filename += actual_md5; } if (M_WriteFile(filename, download.buf->ptr(), download.buf->maxsize())) break; } // Unable to write if(i == dirs.size()) { download.clear(); CL_QuitNetGame(); return; } Printf(PRINT_HIGH, "Saved download as \"%s\"\n", filename.c_str()); download.clear(); CL_QuitNetGame(); CL_Reconnect(); ClearDownloadProgressBar(); }
wxString MD5SUM(const wxString& Input) { std::string str = MD5SUM(Input.char_str(), Input.Len()); return stdstr_towxstr(str); }
// // IntQryBuildInformation() // // Protocol building routine, the passed parameter is the enquirer version static void IntQryBuildInformation(const DWORD &EqProtocolVersion, const DWORD &EqTime) { std::vector<CvarField_t> Cvars; // bond - time MSG_WriteLong(&ml_message, EqTime); // The servers real protocol version // bond - real protocol MSG_WriteLong(&ml_message, PROTOCOL_VERSION); // Built revision of server MSG_WriteLong(&ml_message, last_revision); cvar_t *var = GetFirstCvar(); // Count our cvars and add them while (var) { if (var->flags() & CVAR_SERVERINFO) { CvarField.Name = var->name(); CvarField.Value = var->cstring(); Cvars.push_back(CvarField); } var = var->GetNext(); } // Cvar count MSG_WriteByte(&ml_message, (BYTE)Cvars.size()); // Write cvars for (size_t i = 0; i < Cvars.size(); ++i) { MSG_WriteString(&ml_message, Cvars[i].Name.c_str()); MSG_WriteString(&ml_message, Cvars[i].Value.c_str()); } MSG_WriteString(&ml_message, (strlen(join_password.cstring()) ? MD5SUM(join_password.cstring()).c_str() : "")); MSG_WriteString(&ml_message, level.mapname); int timeleft = (int)(sv_timelimit - level.time/(TICRATE*60)); if (timeleft < 0) timeleft = 0; MSG_WriteShort(&ml_message, timeleft); // Team data MSG_WriteByte(&ml_message, 2); // Blue MSG_WriteString(&ml_message, "Blue"); MSG_WriteLong(&ml_message, 0x000000FF); MSG_WriteShort(&ml_message, (short)TEAMpoints[it_blueflag]); MSG_WriteString(&ml_message, "Red"); MSG_WriteLong(&ml_message, 0x00FF0000); MSG_WriteShort(&ml_message, (short)TEAMpoints[it_redflag]); // TODO: When real dynamic teams are implemented //byte TeamCount = (byte)sv_teamsinplay; //MSG_WriteByte(&ml_message, TeamCount); //for (byte i = 0; i < TeamCount; ++i) //{ // TODO - Figure out where the info resides //MSG_WriteString(&ml_message, ""); //MSG_WriteLong(&ml_message, 0); //MSG_WriteShort(&ml_message, TEAMpoints[i]); //} // Patch files MSG_WriteByte(&ml_message, patchfiles.size()); for (size_t i = 0; i < patchfiles.size(); ++i) { MSG_WriteString(&ml_message, patchfiles[i].c_str()); } // Wad files MSG_WriteByte(&ml_message, wadnames.size()); for (size_t i = 0; i < wadnames.size(); ++i) { MSG_WriteString(&ml_message, wadnames[i].c_str()); MSG_WriteString(&ml_message, wadhashes[i].c_str()); } MSG_WriteByte(&ml_message, players.size()); // Player info for (size_t i = 0; i < players.size(); ++i) { MSG_WriteString(&ml_message, players[i].userinfo.netname); MSG_WriteByte(&ml_message, players[i].userinfo.team); MSG_WriteShort(&ml_message, players[i].ping); int timeingame = (time(NULL) - players[i].JoinTime)/60; if (timeingame < 0) timeingame = 0; MSG_WriteShort(&ml_message, timeingame); // FIXME - Treat non-players (downloaders/others) as spectators too for // now bool spectator; spectator = (players[i].spectator || ((players[i].playerstate != PST_LIVE) && (players[i].playerstate != PST_DEAD) && (players[i].playerstate != PST_REBORN))); MSG_WriteBool(&ml_message, spectator); MSG_WriteShort(&ml_message, players[i].fragcount); MSG_WriteShort(&ml_message, players[i].killcount); MSG_WriteShort(&ml_message, players[i].deathcount); } }