void NET_Poll(void) { PollProcedure *pp; bool useModem; if (!configRestored) { if (serialAvailable) { if (config_com_modem.getInt() == 1.0) useModem = true; else useModem = false; SetComPortConfig (0, config_com_port.getInt(), config_com_irq.getInt(), config_com_baud.getInt(), useModem); SetModemConfig (0, config_modem_dialtype.getString(), config_modem_clear.getString(), config_modem_init.getString(), config_modem_hangup.getString()); } configRestored = true; } SetNetTime(); for (pp = pollProcedureList; pp; pp = pp->next) { if (pp->nextTime > net_time) break; pollProcedureList = pp->next; pp->procedure();//(pp->arg); } }
void DesuraJSSettings::setValue(gcString name, gcString val) { CVar* cvar = GetCVarManager()->findCVar(name.c_str()); if (cvar && val != gcString(cvar->getString())) cvar->setValue(val.c_str()); }
void run() { try { MainAppProviderI *pProvider = dynamic_cast<MainAppProviderI*>(g_pMainApp); if (m_bAltProvider) { gcString strProv = gc_login_stage_url.getString(); pProvider->setProvider(strProv.c_str()); } else { pProvider->setProvider(nullptr); } g_pMainApp->logIn(m_szUsername.c_str(), m_szPassword.c_str()); if (m_pCaller) m_pCaller->onLoginEvent(); } catch (gcException &except) { if (m_pCaller) m_pCaller->onLoginErrorEvent(except); } }
/** * An svc_signonnum has been received, perform a client side setup */ void CL_SignonReply(void) { char str[8192]; Con_DPrintf("CL_SignonReply: %i\n", cls.signon); switch (cls.signon) { case 1: MSG_WriteByte(&cls.message, clc_stringcmd); MSG_WriteString(&cls.message, "prespawn"); break; case 2: MSG_WriteByte(&cls.message, clc_stringcmd); MSG_WriteString(&cls.message, va("name \"%s\"\n", cl_name.getString())); MSG_WriteByte(&cls.message, clc_stringcmd); MSG_WriteString(&cls.message, va("color %i %i\n", cl_color.getInt() >> 4, cl_color.getInt()&15)); MSG_WriteByte(&cls.message, clc_stringcmd); sprintf(str, "spawn %s", cls.spawnparms); MSG_WriteString(&cls.message, str); break; case 3: MSG_WriteByte(&cls.message, clc_stringcmd); MSG_WriteString(&cls.message, "begin"); MemoryObj::Report(); // print remaining memory break; case 4: SCR_EndLoadingPlaque(); // allow normal screen updates break; } }
void InitLocalManagers() { GetLanguageManager().loadFromFile(LANG_DEF); GetLanguageManager().loadFromFile(LANG_EXTRA); GetGCThemeManager()->loadFromFolder(THEMEFOLDER); GetGCThemeManager()->loadTheme(gc_theme.getString()); }
void LoginForm::onTextChange(wxCommandEvent& event) { gcWString defaultText; gcTextCtrl* textCtrl; if (event.GetId() == m_tbUsername->GetId()) { textCtrl = m_tbUsername; defaultText = Managers::GetString(L"#LF_USER"); if (gc_saveusername.getBool()) { const char* str = gc_lastusername.getString(); const char* avatar = gc_lastavatar.getString(); if (gcString(str) != gcString(m_tbUsername->GetValue().c_str().AsWChar())) { m_imgAvatar->setImage("#login_default_avatar"); } else { if (avatar && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(avatar))) m_imgAvatar->setImage(avatar); } } } else if (event.GetId() == m_tbPasswordDisp->GetId()) { textCtrl = m_tbPasswordDisp; defaultText = Managers::GetString(L"#LF_PASS"); } else { return; } const char* colorName = "tb-fg"; if (textCtrl->GetValue() == defaultText) colorName = "tb-default-fg"; wxColor color = wxColor(GetThemeManager().getColor("formlogin", colorName)); textCtrl->SetForegroundColour(color); textCtrl->Refresh(); }
void MainApp::onNeedCvar(UserCore::Misc::CVar_s& info) { if (info.name) { CVar* c = GetCVarManager()->findCVar(info.name); if (c) info.value = c->getString(); } }
void MainApp::getSteamUser(WCSpecialInfo *info, wxWindow *parent) { if (gc_steamuser.getString() && strcmp(gc_steamuser.getString(), "") != 0) { info->result = gc_steamuser.getString(); info->handled = true; } else { SteamUserDialog dlg(parent?parent:this); dlg.ShowModal(); const char *steamuser = dlg.getSteamUser(); if (steamuser) { gc_steamuser.setValue(steamuser); info->result = steamuser; info->handled = true; } } }
void LoginForm::onNewAccount() { gcString strApiUrl; if (m_comboProvider && m_comboProvider->GetSelection() != 0) strApiUrl = gc_login_stage_url.getString(); NewAccountDialog naf(this, strApiUrl.c_str()); m_pNewAccount = &naf; naf.ShowModal(); m_pNewAccount = nullptr; }
void run() { Console::ignoreThisThread(); m_strFilter = g_strUnitTestFilter.getString(); GTEST_FLAG(filter) = m_strFilter; RUN_ALL_TESTS(); GTEST_FLAG(filter) = ""; #ifdef WIN32 //Reset this as gtest messes with it :'( _set_error_mode(_OUT_TO_MSGBOX); #endif }
void LoginForm::onAltLogin(const char* szProvider) { if (szProvider == nullptr) return; gcString strApiUrl; if (m_comboProvider && m_comboProvider->GetSelection() != 0) strApiUrl = gc_login_stage_url.getString(); AltLoginDialog naf(this, szProvider, strApiUrl.c_str()); m_pNewAccount = &naf; naf.ShowModal(); m_pNewAccount = nullptr; }
LoginForm::LoginForm(wxWindow* parent) : gcFrame(parent, wxID_ANY, Managers::GetString(L"#LF_TITLE"), wxDefaultPosition, wxSize(420,286), wxCAPTION|wxCLOSE_BOX|wxSYSTEM_MENU|wxWANTS_CHARS|wxMINIMIZE_BOX, true) { m_comboProvider = nullptr; m_bAutoLogin = false; m_pNewAccount = nullptr; Bind(wxEVT_COMMAND_TEXT_ENTER, &LoginForm::onTextBoxEnter, this); Bind(wxEVT_CLOSE_WINDOW, &LoginForm::onClose, this); Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onButtonClick, this); Bind(wxEVT_MOVE, &LoginForm::onMove, this); m_imgLogo = new gcImageControl(this, wxID_ANY, wxDefaultPosition, wxSize( 253,81 )); m_imgAvatar = new gcImageControl(this, wxID_ANY, wxDefaultPosition, wxSize( 66,66 )); m_imgLogo->setImage("#login_logo"); m_imgAvatar->setImage("#login_default_avatar"); m_tbUsername = new gcTextCtrl(this, wxID_ANY, Managers::GetString(L"#LF_USER"), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxWANTS_CHARS); m_tbPassword = new gcTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxWANTS_CHARS|wxTE_PASSWORD); m_tbPasswordDisp = new gcTextCtrl(this, wxID_ANY, Managers::GetString(L"#LF_PASS")); gcString strStagingUrl(gc_login_stage_url.getString()); gcString strStagingLast(gc_login_stage_last.getString()); if (strStagingUrl.size() > 0) { wxArrayString choices; choices.Add("Prod"); choices.Add("Test"); m_comboProvider = new gcChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, choices); if (strStagingLast == "Test") m_comboProvider->SetSelection(1); else m_comboProvider->SetSelection(0); } m_cbRemPass = new gcCheckBox(this, wxID_ANY, Managers::GetString(L"#LF_AUTO")); m_cbRemPass->SetToolTip(Managers::GetString(L"#LF_AUTO_TOOLTIP")); #ifdef WIN32 m_cbProxyOff = new gcCheckBox(this, wxID_ANY, Managers::GetString(L"#LF_PROXYOFF")); m_cbProxyOff->SetToolTip(Managers::GetString(L"#LF_PROXYOFF_TOOLTIP")); #endif m_cbBypassSSLRevocationCheck = new gcCheckBox( this, wxID_ANY, Managers::GetString( L"#LF_REVOCATION" ) ); m_cbBypassSSLRevocationCheck->SetToolTip( Managers::GetString( L"#LF_REVOCATION_TOOLTIP" ) ); m_butSignin = new gcButton(this, wxID_ANY, Managers::GetString(L"#LOGIN"), wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS); m_butCancel = new gcButton(this, wxID_ANY, Managers::GetString(L"#CANCEL"), wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS); m_linkOffline = new LoginLink(this, Managers::GetString(L"#LF_OFFLINE"), wxALIGN_LEFT); m_linkNewAccount = new LoginLink(this, Managers::GetString(L"#LF_NEWACCOUNT"), wxALIGN_CENTER); m_linkLostPassword = new LoginLink( this, Managers::GetString(L"#LF_LOSTPASS"), wxALIGN_RIGHT); m_butTwitter = new gcImageButton(this, wxID_ANY, wxDefaultPosition, wxSize(42, 42)); m_butSteam = new gcImageButton(this, wxID_ANY, wxDefaultPosition, wxSize(42, 42)); m_butFacebook = new gcImageButton(this, wxID_ANY, wxDefaultPosition, wxSize(42, 42)); m_butGoogle = new gcImageButton(this, wxID_ANY, wxDefaultPosition, wxSize(42, 42)); m_butTwitter->setDefaultImage("#login_twitter"); m_butSteam->setDefaultImage("#login_steam"); m_butFacebook->setDefaultImage("#login_facebook"); m_butGoogle->setDefaultImage("#login_google"); m_butTwitter->SetCursor(wxCursor(wxCURSOR_HAND)); m_butSteam->SetCursor(wxCursor(wxCURSOR_HAND)); m_butFacebook->SetCursor(wxCursor(wxCURSOR_HAND)); m_butGoogle->SetCursor(wxCursor(wxCURSOR_HAND)); m_butTwitter->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onAltLoginClick, this); m_butSteam->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onAltLoginClick, this); m_butFacebook->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onAltLoginClick, this); m_butGoogle->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onAltLoginClick, this); //focus gets set to the first child. Redirect input to username box m_imgLogo->Bind(wxEVT_CHAR, &LoginForm::onFormChar, this); m_imgAvatar->Bind(wxEVT_CHAR, &LoginForm::onFormChar, this); #ifdef WIN32 Bind(wxEVT_LEFT_UP, &LoginForm::onMouseUp, this); Bind(wxEVT_LEFT_DOWN, &LoginForm::onMouseDown, this); Bind(wxEVT_MOTION, &LoginForm::onMouseMove, this); m_imgLogo->Bind(wxEVT_LEFT_UP, &LoginForm::onMouseUp, this); m_imgLogo->Bind(wxEVT_LEFT_DOWN, &LoginForm::onMouseDown, this); m_imgLogo->Bind(wxEVT_MOTION, &LoginForm::onMouseMove, this); m_imgAvatar->Bind(wxEVT_LEFT_UP, &LoginForm::onMouseUp, this); m_imgAvatar->Bind(wxEVT_LEFT_DOWN, &LoginForm::onMouseDown, this); m_imgAvatar->Bind(wxEVT_MOTION, &LoginForm::onMouseMove, this); #endif m_tbUsername->Bind(wxEVT_COMMAND_TEXT_UPDATED, &LoginForm::onTextChange, this); m_tbUsername->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_tbUsername->Bind(wxEVT_KILL_FOCUS, &LoginForm::onBlur, this); m_tbUsername->Bind(wxEVT_SET_FOCUS, &LoginForm::onFocus, this); m_tbPassword->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_tbPassword->Bind(wxEVT_KILL_FOCUS, &LoginForm::onBlur, this); m_tbPasswordDisp->Bind(wxEVT_COMMAND_TEXT_UPDATED, &LoginForm::onTextChange, this); m_tbPasswordDisp->Bind(wxEVT_SET_FOCUS, &LoginForm::onFocus, this); m_cbRemPass->Bind(wxEVT_CHAR, &LoginForm::onChar, this); #ifdef WIN32 m_cbProxyOff->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LoginForm::onCheckBoxClick, this ); #endif m_cbBypassSSLRevocationCheck->Bind( wxEVT_COMMAND_CHECKBOX_CLICKED, &LoginForm::onCheckBoxClick, this ); m_linkOffline->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_linkNewAccount->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_linkLostPassword->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_linkOffline->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onLinkClick, this); m_linkNewAccount->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onLinkClick, this); m_linkLostPassword->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onLinkClick, this); m_butCancel->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_butSignin->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_tbUsername->SetValue(Managers::GetString(L"#LF_USER")); m_tbPasswordDisp->SetValue(Managers::GetString(L"#LF_PASS")); m_tbPassword->Show(false); m_tbPasswordDisp->Show(true); #ifdef WIN32 wxFlexGridSizer* fgSizer4 = new wxFlexGridSizer( 1, 3, 0, 0 ); #else wxFlexGridSizer* fgSizer4 = new wxFlexGridSizer( 1, 2, 0, 0 ); #endif fgSizer4->AddGrowableCol( 0 ); fgSizer4->SetFlexibleDirection( wxBOTH ); fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer4->Add( m_cbRemPass, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); #ifdef WIN32 fgSizer4->Add( m_cbProxyOff, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 ); #endif fgSizer4->Add( m_cbBypassSSLRevocationCheck, 0, wxALL | wxALIGN_CENTER_VERTICAL, 5 ); wxFlexGridSizer* fgSizer4a = new wxFlexGridSizer( 1, 2, 0, 0 ); fgSizer4a->AddGrowableCol( 0 ); fgSizer4a->SetFlexibleDirection( wxBOTH ); fgSizer4a->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer4a->Add( m_butSignin, 0, wxTOP | wxBOTTOM | wxLEFT, 5 ); fgSizer4a->Add( m_butCancel, 0, wxTOP | wxBOTTOM | wxLEFT, 5 ); wxFlexGridSizer* fgSizer5 = new wxFlexGridSizer( 1, 3, 0, 0 ); fgSizer5->AddGrowableCol( 0 ); fgSizer5->AddGrowableCol( 1 ); fgSizer5->AddGrowableCol( 2 ); fgSizer5->AddGrowableRow( 0 ); fgSizer5->SetFlexibleDirection( wxBOTH ); fgSizer5->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer5->Add( m_linkOffline, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); fgSizer5->Add( m_linkNewAccount, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); fgSizer5->Add( m_linkLostPassword, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 ); wxFlexGridSizer* fgSizer6 = new wxFlexGridSizer( 5, 1, 0, 0 ); fgSizer6->AddGrowableCol( 0 ); fgSizer6->SetFlexibleDirection( wxBOTH ); fgSizer6->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); if (m_comboProvider) { wxFlexGridSizer* fgSizer10 = new wxFlexGridSizer(1, 2, 0, 0); fgSizer10->AddGrowableCol(0); fgSizer10->Add(m_tbUsername, 0, wxEXPAND, 5); fgSizer10->Add(m_comboProvider, 0, wxLEFT, 5); fgSizer6->Add(fgSizer10, 0, wxEXPAND | wxLEFT, 5); } else { fgSizer6->Add(m_tbUsername, 0, wxEXPAND | wxLEFT, 5); } fgSizer6->Add( m_tbPassword, 0, wxEXPAND|wxTOP|wxLEFT, 5 ); fgSizer6->Add( m_tbPasswordDisp, 0, wxEXPAND|wxTOP|wxLEFT, 5 ); fgSizer6->Add( fgSizer4, 1, wxEXPAND, 5 ); fgSizer6->Add( fgSizer4a, 1, wxEXPAND, 5 ); wxFlexGridSizer* fgSizer3 = new wxFlexGridSizer( 1, 2, 0, 0 ); fgSizer3->AddGrowableCol( 1 ); fgSizer3->SetFlexibleDirection( wxBOTH ); fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer3->Add( m_imgAvatar, 0, 0, 5 ); fgSizer3->Add( fgSizer6, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); wxFlexGridSizer* fgSizerAltLogin = new wxFlexGridSizer(1, 9, 0, 0); fgSizerAltLogin->AddGrowableCol(2); fgSizerAltLogin->AddGrowableCol(4); fgSizerAltLogin->AddGrowableCol(6); fgSizerAltLogin->AddGrowableRow(0); fgSizerAltLogin->Add(15, 0, 1, wxEXPAND, 5); fgSizerAltLogin->Add(m_butTwitter, 0, 0, 5); fgSizerAltLogin->Add(0, 0, 1, wxEXPAND, 5); fgSizerAltLogin->Add(m_butSteam, 0, 0, 5); fgSizerAltLogin->Add(0, 0, 1, wxEXPAND, 5); fgSizerAltLogin->Add(m_butFacebook, 0, 0, 5); fgSizerAltLogin->Add(0, 0, 1, wxEXPAND, 5); fgSizerAltLogin->Add(m_butGoogle, 0, 0, 5); fgSizerAltLogin->Add(15, 0, 1, wxEXPAND, 5); wxFlexGridSizer* fgSizer2 = new wxFlexGridSizer( 6, 1, 0, 0 ); fgSizer2->SetFlexibleDirection( wxBOTH ); fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer2->Add( m_imgLogo, 1, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL, 5 ); fgSizer2->Add( fgSizer3, 1, wxEXPAND, 5 ); fgSizer2->Add(0, 9, 1, wxEXPAND, 5); fgSizer2->Add(fgSizer5, 1, wxEXPAND, 5); fgSizer2->Add(0, 9, 1, wxEXPAND, 5); fgSizer2->Add(fgSizerAltLogin, 1, wxEXPAND, 5); wxFlexGridSizer* fgSizer1 = new wxFlexGridSizer( 1, 3, 0, 0 ); fgSizer1->AddGrowableCol( 0 ); fgSizer1->AddGrowableCol( 2 ); fgSizer1->AddGrowableRow( 0 ); fgSizer1->SetFlexibleDirection( wxBOTH ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); fgSizer1->Add( fgSizer2, 1, wxEXPAND, 5 ); fgSizer1->Add( 0, 15, 1, wxEXPAND|wxBOTTOM, 15 ); this->SetSizer( fgSizer1 ); this->Layout(); m_bSavePos = false; m_vTabOrder.push_back(m_tbUsername); m_vTabOrder.push_back(m_tbPasswordDisp); m_vTabOrder.push_back(m_tbPassword); m_vTabOrder.push_back( m_cbRemPass ); #ifdef WIN32 m_vTabOrder.push_back( m_cbProxyOff ); #endif m_vTabOrder.push_back( m_cbBypassSSLRevocationCheck ); m_vTabOrder.push_back(m_butSignin); m_vTabOrder.push_back(m_butCancel); m_vTabOrder.push_back(m_linkOffline); m_vTabOrder.push_back(m_linkNewAccount); m_vTabOrder.push_back(m_linkLostPassword); Centre(wxCENTRE_ON_SCREEN); SetFocus(); if (gc_login_x.getInt() == -1 || gc_login_y.getInt() == -1) { int x = wxSystemSettings::GetMetric(wxSYS_SCREEN_X); int y = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); int w=0; int h=0; GetSize(&w, &h); int newX = (x-w)/2; int newY = (y-h)/2; if (newX>0 && newY>0) SetSize(newX, newY, -1, -1); } else { #ifdef NIX if (! gc_allow_wm_positioning.getBool()) #endif setSavedWindowPos(gc_login_x.getInt(), gc_login_y.getInt(), UINT_MAX, UINT_MAX); } if (gc_savelogin.getBool()) m_cbRemPass->SetValue(true); #ifdef WIN32 bool isProxyOff = gc_saveProxyOff.getBool(); UTIL::OS::setProxyOff( isProxyOff ); m_cbProxyOff->SetValue( isProxyOff ); #endif bool isBypassSSLRevocationCheck = gc_saveBypassSSLRevocationCheck.getBool(); UTIL::OS::setBypassSSLRevocationCheck( isBypassSSLRevocationCheck ); m_cbBypassSSLRevocationCheck->SetValue( isBypassSSLRevocationCheck ); if (gc_saveusername.getBool()) { const char* str = gc_lastusername.getString(); const char* avatar = gc_lastavatar.getString(); if (gcString(str) != "") { m_tbUsername->SetValue(str); m_tbPasswordDisp->Show(false); m_tbPassword->Show(); m_tbPassword->SetFocus(); Layout(); } if (avatar && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(avatar))) m_imgAvatar->setImage(avatar); } m_pLogThread = nullptr; m_bSavePos = true; m_bMouseDrag = false; onLoginEvent += guiDelegate(this, &LoginForm::onLogin); onLoginErrorEvent += guiDelegate(this, &LoginForm::onLoginError); onStartLoginEvent += guiDelegate(this, &LoginForm::onStartLogin); Managers::LoadTheme(this, "formlogin"); Managers::LoadTheme(m_cbRemPass, "formlogin"); #ifdef WIN32 Managers::LoadTheme(m_cbProxyOff, "formlogin"); #endif Managers::LoadTheme( m_cbBypassSSLRevocationCheck, "formlogin" ); SetSize(wxSize(400,336)); setFrameRegion(); onNewAccountLoginEvent += guiDelegate(this, &LoginForm::newAccountLoginCB); onNewAccountLoginErrorEvent += guiDelegate(this, &LoginForm::newAccountLoginErrorCB); }
bool isValid = UTIL::FS::isValidFile(path); if (!isValid) Warning(gcString("Theme {0} is not a valid theme file.\n", val)); return isValid; } CVar gc_language("gc_language", "english", CFLAG_SAVEONEXIT, (CVarCallBackFn)&LangChanged); CVar gc_theme("gc_theme", "default", CFLAG_SAVEONEXIT, (CVarCallBackFn)&ThemeChanged); CONCOMMAND(cc_reloadlanguage, "reload_language") { gcString lan("{0}{1}.xml", LANGFOLDER(), gc_language.getString()); GetLanguageManager().loadFromFile(lan.c_str()); } UserCore::UserThreadManagerI* GetThreadManager() { if (GetUserCore()) return GetUserCore()->getThreadManager(); return nullptr; } UserCore::UploadManagerI* GetUploadMng() { if (GetUserCore())
gcUnitTestForm::gcUnitTestForm(wxWindow* parent) : gcDialog(parent, wxID_ANY, wxT("Unit Tests Results"), wxDefaultPosition, wxSize(500, 354), wxCAPTION | wxDEFAULT_FRAME_STYLE | wxTAB_TRAVERSAL) , m_pThread(nullptr) , m_ImageList(16, 16) , m_bShouldClose(false) { m_nPassed = 0; m_nFailed = 0; m_nRunTime = 0; showEvent += guiDelegate(this, &gcUnitTestForm::onShow); Bind(wxEVT_COMMAND_BUTTON_CLICKED, &gcUnitTestForm::onButtonClicked, this); Bind(wxEVT_CLOSE_WINDOW, &gcUnitTestForm::OnClose, this); this->SetSizeHints(wxDefaultSize, wxDefaultSize); wxBoxSizer* bSizer2; bSizer2 = new wxBoxSizer(wxHORIZONTAL); m_cbAssertOnError = new wxCheckBox(this, wxID_ANY, wxT("Assert On Error"), wxDefaultPosition, wxDefaultSize, 0); m_cbAssertOnError->SetValue(true); bSizer2->Add(m_cbAssertOnError, 0, wxALL, 5); m_cbRunOnStartup = new wxCheckBox(this, wxID_ANY, wxT("Run On Startup"), wxDefaultPosition, wxDefaultSize, 0); m_cbRunOnStartup->SetValue(true); bSizer2->Add(m_cbRunOnStartup, 0, wxALL, 5); m_staticText1 = new wxStaticText(this, wxID_ANY, wxT("Filter:"), wxDefaultPosition, wxDefaultSize, 0); m_staticText1->Wrap(-1); m_textCtrl1 = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0); m_butRun = new wxButton(this, wxID_ANY, wxT("Run"), wxDefaultPosition, wxDefaultSize, 0); m_lcStats = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(-1, 25), wxLC_REPORT | wxLC_SORT_ASCENDING|wxLC_NO_HEADER); m_lcUnitTests = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SORT_ASCENDING); m_butClose = new wxButton(this, wxID_ANY, wxT("Close"), wxDefaultPosition, wxDefaultSize, 0); wxBoxSizer* bSizer1; bSizer1 = new wxBoxSizer(wxHORIZONTAL); bSizer1->Add(m_staticText1, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM | wxLEFT, 5); bSizer1->Add(m_textCtrl1, 1, wxEXPAND | wxALL, 5); bSizer1->Add(m_butRun, 0, wxTOP | wxBOTTOM | wxRIGHT, 5); wxFlexGridSizer* fgSizer1; fgSizer1 = new wxFlexGridSizer(5, 1, 0, 0); fgSizer1->AddGrowableCol(0); fgSizer1->AddGrowableRow(3); fgSizer1->SetFlexibleDirection(wxBOTH); fgSizer1->SetNonFlexibleGrowMode(wxFLEX_GROWMODE_SPECIFIED); fgSizer1->Add(bSizer2, 1, wxEXPAND, 5); fgSizer1->Add(bSizer1, 1, wxEXPAND, 5); fgSizer1->Add(m_lcStats, 1, wxEXPAND | wxBOTTOM | wxRIGHT | wxLEFT, 5); fgSizer1->Add(m_lcUnitTests, 1, wxEXPAND | wxBOTTOM | wxRIGHT | wxLEFT, 5); fgSizer1->Add(m_butClose, 0, wxALIGN_RIGHT | wxBOTTOM | wxRIGHT | wxLEFT, 5); this->SetSizer(fgSizer1); this->Layout(); this->Centre(wxBOTH); m_cbRunOnStartup->SetValue(g_bRunOnStartup.getBool()); m_cbAssertOnError->SetValue(g_bAssertOnFailure.getBool()); m_textCtrl1->SetValue(g_strUnitTestFilter.getString()); m_cbRunOnStartup->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &gcUnitTestForm::OnRunOnStartupClicked, this); m_cbAssertOnError->Bind(wxEVT_COMMAND_CHECKBOX_CLICKED, &gcUnitTestForm::OnAssertOnErrorClicked, this); m_textCtrl1->Bind(wxEVT_COMMAND_TEXT_UPDATED, &gcUnitTestForm::OnTextChanged, this); m_icoTestGood = GetGCThemeManager()->getImageHandle("#test_good"); m_icoTestBad = GetGCThemeManager()->getImageHandle("#test_bad"); m_ImageList.Add(wxBitmap(m_icoTestBad.getImg()->Scale(16, 16))); m_ImageList.Add(wxBitmap(m_icoTestGood.getImg()->Scale(16, 16))); m_lcStats->SetImageList(&m_ImageList, wxIMAGE_LIST_NORMAL); m_lcStats->SetImageList(&m_ImageList, wxIMAGE_LIST_SMALL); m_lcUnitTests->SetImageList(&m_ImageList, wxIMAGE_LIST_NORMAL); m_lcUnitTests->SetImageList(&m_ImageList, wxIMAGE_LIST_SMALL); g_pTestWatcher->onStartEvent += guiDelegate(this, &gcUnitTestForm::onStart); g_pTestWatcher->onEndEvent += guiDelegate(this, &gcUnitTestForm::onEnd); g_pTestWatcher->onTestStartEvent += guiDelegate(this, &gcUnitTestForm::onTestStart); g_pTestWatcher->onTestResultEvent += guiDelegate(this, &gcUnitTestForm::onTestResult); g_pTestWatcher->onTestEndEnd += guiDelegate(this, &gcUnitTestForm::onTestEnd); if (g_bRunOnStartup.getBool()) runTests(); }
LoginForm::LoginForm(wxWindow* parent) : gcFrame(parent, wxID_ANY, Managers::GetString(L"#LF_TITLE"), wxDefaultPosition, wxSize(420,246), wxCAPTION|wxCLOSE_BOX|wxSYSTEM_MENU|wxWANTS_CHARS|wxMINIMIZE_BOX, true) { m_bAutoLogin = false; m_pNewAccount = NULL; Bind(wxEVT_COMMAND_TEXT_ENTER, &LoginForm::onTextBoxEnter, this); Bind(wxEVT_CLOSE_WINDOW, &LoginForm::onClose, this); Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onButtonClick, this); Bind(wxEVT_MOVE, &LoginForm::onMove, this); m_imgLogo = new gcImageControl(this, wxID_ANY, wxDefaultPosition, wxSize( 253,81 )); m_imgAvatar = new gcImageControl(this, wxID_ANY, wxDefaultPosition, wxSize( 66,66 )); m_imgLogo->setImage("#login_logo"); m_imgAvatar->setImage("#login_default_avatar"); m_tbUsername = new gcTextCtrl(this, wxID_ANY, Managers::GetString(L"#LF_USER"), wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxWANTS_CHARS); m_tbPassword = new gcTextCtrl(this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER|wxWANTS_CHARS|wxTE_PASSWORD); m_tbPasswordDisp = new gcTextCtrl(this, wxID_ANY, Managers::GetString(L"#LF_PASS")); #ifndef UI_HIDE_AUTOLOGIN m_cbRemPass = new gcCheckBox(this, wxID_ANY, Managers::GetString(L"#LF_AUTO")); m_cbRemPass->SetToolTip(Managers::GetString(L"#LF_AUTO_TOOLTIP")); #endif m_butSignin = new gcButton(this, wxID_ANY, Managers::GetString(L"#LOGIN"), wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS); m_butCancel = new gcButton(this, wxID_ANY, Managers::GetString(L"#CANCEL"), wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS); m_linkOffline = new LoginLink(this, Managers::GetString(L"#LF_OFFLINE"), wxALIGN_LEFT); m_linkNewAccount = new LoginLink(this, Managers::GetString(L"#LF_NEWACCOUNT"), wxALIGN_CENTER); m_linkLostPassword = new LoginLink( this, Managers::GetString(L"#LF_LOSTPASS"), wxALIGN_RIGHT); //focus gets set to the first child. Redirect input to username box m_imgLogo->Bind(wxEVT_CHAR, &LoginForm::onFormChar, this); m_imgAvatar->Bind(wxEVT_CHAR, &LoginForm::onFormChar, this); #ifdef WIN32 Bind(wxEVT_LEFT_UP, &LoginForm::onMouseUp, this); Bind(wxEVT_LEFT_DOWN, &LoginForm::onMouseDown, this); Bind(wxEVT_MOTION, &LoginForm::onMouseMove, this); m_imgLogo->Bind(wxEVT_LEFT_UP, &LoginForm::onMouseUp, this); m_imgLogo->Bind(wxEVT_LEFT_DOWN, &LoginForm::onMouseDown, this); m_imgLogo->Bind(wxEVT_MOTION, &LoginForm::onMouseMove, this); m_imgAvatar->Bind(wxEVT_LEFT_UP, &LoginForm::onMouseUp, this); m_imgAvatar->Bind(wxEVT_LEFT_DOWN, &LoginForm::onMouseDown, this); m_imgAvatar->Bind(wxEVT_MOTION, &LoginForm::onMouseMove, this); #endif m_tbUsername->Bind(wxEVT_COMMAND_TEXT_UPDATED, &LoginForm::onTextChange, this); m_tbUsername->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_tbUsername->Bind(wxEVT_KILL_FOCUS, &LoginForm::onBlur, this); m_tbUsername->Bind(wxEVT_SET_FOCUS, &LoginForm::onFocus, this); m_tbPassword->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_tbPassword->Bind(wxEVT_KILL_FOCUS, &LoginForm::onBlur, this); m_tbPasswordDisp->Bind(wxEVT_COMMAND_TEXT_UPDATED, &LoginForm::onTextChange, this); m_tbPasswordDisp->Bind(wxEVT_SET_FOCUS, &LoginForm::onFocus, this); #ifndef UI_HIDE_AUTOLOGIN m_cbRemPass->Bind(wxEVT_CHAR, &LoginForm::onChar, this); #endif m_linkOffline->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_linkNewAccount->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_linkLostPassword->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_linkOffline->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onLinkClick, this); m_linkNewAccount->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onLinkClick, this); m_linkLostPassword->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &LoginForm::onLinkClick, this); m_butCancel->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_butSignin->Bind(wxEVT_CHAR, &LoginForm::onChar, this); m_tbUsername->SetValue(Managers::GetString(L"#LF_USER")); m_tbPasswordDisp->SetValue(Managers::GetString(L"#LF_PASS")); m_tbPassword->Show(false); m_tbPasswordDisp->Show(true); wxFlexGridSizer* fgSizer4 = new wxFlexGridSizer( 1, 3, 0, 0 ); fgSizer4->AddGrowableCol( 0 ); fgSizer4->SetFlexibleDirection( wxBOTH ); fgSizer4->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); #ifndef UI_HIDE_AUTOLOGIN fgSizer4->Add( m_cbRemPass, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); #else fgSizer4->Add(0,0,0,0); #endif fgSizer4->Add( m_butSignin, 0, wxTOP|wxBOTTOM|wxLEFT, 5 ); fgSizer4->Add( m_butCancel, 0, wxTOP|wxBOTTOM|wxLEFT, 5 ); wxFlexGridSizer* fgSizer5 = new wxFlexGridSizer( 1, 3, 0, 0 ); fgSizer5->AddGrowableCol( 0 ); fgSizer5->AddGrowableCol( 1 ); fgSizer5->AddGrowableCol( 2 ); fgSizer5->AddGrowableRow( 0 ); fgSizer5->SetFlexibleDirection( wxBOTH ); fgSizer5->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer5->Add( m_linkOffline, 0, wxTOP|wxBOTTOM|wxRIGHT, 5 ); fgSizer5->Add( m_linkNewAccount, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 ); fgSizer5->Add( m_linkLostPassword, 0, wxALIGN_RIGHT|wxTOP|wxBOTTOM|wxLEFT, 5 ); wxFlexGridSizer* fgSizer6 = new wxFlexGridSizer( 4, 1, 0, 0 ); fgSizer6->AddGrowableCol( 0 ); fgSizer6->SetFlexibleDirection( wxBOTH ); fgSizer6->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer6->Add( m_tbUsername, 0, wxEXPAND|wxLEFT, 5 ); fgSizer6->Add( m_tbPassword, 0, wxEXPAND|wxTOP|wxLEFT, 5 ); fgSizer6->Add( m_tbPasswordDisp, 0, wxEXPAND|wxTOP|wxLEFT, 5 ); fgSizer6->Add( fgSizer4, 1, wxEXPAND, 5 ); wxFlexGridSizer* fgSizer3 = new wxFlexGridSizer( 1, 2, 0, 0 ); fgSizer3->AddGrowableCol( 1 ); fgSizer3->SetFlexibleDirection( wxBOTH ); fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer3->Add( m_imgAvatar, 0, 0, 5 ); fgSizer3->Add( fgSizer6, 1, wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 ); wxFlexGridSizer* fgSizer2 = new wxFlexGridSizer( 4, 1, 0, 0 ); fgSizer2->SetFlexibleDirection( wxBOTH ); fgSizer2->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer2->Add( m_imgLogo, 1, wxTOP|wxBOTTOM|wxALIGN_CENTER_HORIZONTAL, 5 ); fgSizer2->Add( fgSizer3, 1, wxEXPAND, 5 ); fgSizer2->Add( 0, 9, 1, wxEXPAND, 5 ); fgSizer2->Add( fgSizer5, 1, wxEXPAND, 5 ); wxFlexGridSizer* fgSizer1 = new wxFlexGridSizer( 1, 3, 0, 0 ); fgSizer1->AddGrowableCol( 0 ); fgSizer1->AddGrowableCol( 2 ); fgSizer1->AddGrowableRow( 0 ); fgSizer1->SetFlexibleDirection( wxBOTH ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); fgSizer1->Add( fgSizer2, 1, wxEXPAND, 5 ); fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); this->SetSizer( fgSizer1 ); this->Layout(); m_bSavePos = false; m_vTabOrder.push_back(m_tbUsername); m_vTabOrder.push_back(m_tbPasswordDisp); m_vTabOrder.push_back(m_tbPassword); #ifndef UI_HIDE_AUTOLOGIN m_vTabOrder.push_back(m_cbRemPass); #endif m_vTabOrder.push_back(m_butSignin); m_vTabOrder.push_back(m_butCancel); m_vTabOrder.push_back(m_linkOffline); m_vTabOrder.push_back(m_linkNewAccount); m_vTabOrder.push_back(m_linkLostPassword); Centre(wxCENTRE_ON_SCREEN); SetFocus(); if (gc_login_x.getInt() == -1 || gc_login_y.getInt() == -1) { int x = wxSystemSettings::GetMetric(wxSYS_SCREEN_X); int y = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y); int w=0; int h=0; GetSize(&w, &h); int newX = (x-w)/2; int newY = (y-h)/2; if (newX>0 && newY>0) SetSize(newX, newY, -1, -1); } else { #ifdef NIX if (! gc_allow_wm_positioning.getBool()) #endif setSavedWindowPos(gc_login_x.getInt(), gc_login_y.getInt(), UINT_MAX, UINT_MAX); } #ifndef UI_HIDE_AUTOLOGIN if (gc_savelogin.getBool()) m_cbRemPass->SetValue(true); #endif if (gc_saveusername.getBool()) { const char* str = gc_lastusername.getString(); const char* avatar = gc_lastavatar.getString(); if (gcString(str) != "") { m_tbUsername->SetValue(str); m_tbPasswordDisp->Show(false); m_tbPassword->Show(); m_tbPassword->SetFocus(); Layout(); } if (avatar && UTIL::FS::isValidFile(UTIL::FS::PathWithFile(avatar))) m_imgAvatar->setImage(avatar); } m_pLogThread = NULL; m_bSavePos = true; m_bMouseDrag = false; onLoginEvent += guiDelegate(this, &LoginForm::onLogin); onLoginErrorEvent += guiDelegate(this, &LoginForm::onLoginError); onStartLoginEvent += guiDelegate(this, &LoginForm::onStartLogin); Managers::LoadTheme(this, "formlogin"); #ifndef UI_HIDE_AUTOLOGIN Managers::LoadTheme(m_cbRemPass, "formlogin"); #endif #ifdef WIN32 SetSize(wxSize(420,246)); #endif setFrameRegion(); }
static qsocket_t *_Datagram_CheckNewConnections (void) { struct qsockaddr clientaddr; struct qsockaddr newaddr; int newsock; int acceptsock; qsocket_t *sock; qsocket_t *s; int len; int command; int control; int ret; acceptsock = dfunc.CheckNewConnections(); if (acceptsock == -1) return NULL; SZ_Clear(&net_message); len = dfunc.Read (acceptsock, net_message.data, net_message.maxsize, &clientaddr); if (len < sizeof(int)) return NULL; net_message.cursize = len; MSG_BeginReading (); control = BigLong(*((int *)net_message.data)); MSG_ReadLong(); if (control == -1) return NULL; if ((control & (~NETFLAG_LENGTH_MASK)) != NETFLAG_CTL) return NULL; if ((control & NETFLAG_LENGTH_MASK) != len) return NULL; command = MSG_ReadByte(); if (command == CCREQ_SERVER_INFO) { if (strcmp(MSG_ReadString(), "QUAKE") != 0) return NULL; SZ_Clear(&net_message); // save space for the header, filled in later MSG_WriteLong(&net_message, 0); MSG_WriteByte(&net_message, CCREP_SERVER_INFO); dfunc.GetSocketAddr(acceptsock, &newaddr); MSG_WriteString(&net_message, dfunc.AddrToString(&newaddr)); MSG_WriteString(&net_message, hostname.getString()); MSG_WriteString(&net_message, sv.name); MSG_WriteByte(&net_message, net_activeconnections); MSG_WriteByte(&net_message, svs.maxclients); MSG_WriteByte(&net_message, NET_PROTOCOL_VERSION); *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); dfunc.Write (acceptsock, net_message.data, net_message.cursize, &clientaddr); SZ_Clear(&net_message); return NULL; } if (command == CCREQ_PLAYER_INFO) { int playerNumber; int activeNumber; int clientNumber; client_t *client; playerNumber = MSG_ReadByte(); activeNumber = -1; for (clientNumber = 0, client = svs.clients; clientNumber < svs.maxclients; clientNumber++, client++) { if (client->active) { activeNumber++; if (activeNumber == playerNumber) break; } } if (clientNumber == svs.maxclients) return NULL; SZ_Clear(&net_message); // save space for the header, filled in later MSG_WriteLong(&net_message, 0); MSG_WriteByte(&net_message, CCREP_PLAYER_INFO); MSG_WriteByte(&net_message, playerNumber); MSG_WriteString(&net_message, client->name); MSG_WriteLong(&net_message, client->colors); MSG_WriteLong(&net_message, (int)client->edict->v.frags); MSG_WriteLong(&net_message, (int)(net_time - client->netconnection->connecttime)); MSG_WriteString(&net_message, client->netconnection->address); *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); dfunc.Write (acceptsock, net_message.data, net_message.cursize, &clientaddr); SZ_Clear(&net_message); return NULL; } if (command == CCREQ_RULE_INFO){ char *prevCvarName; CVar *var; // find the search start location prevCvarName = MSG_ReadString(); if (*prevCvarName) var = CVar::findNextServerCVar(prevCvarName); else var = CVar::findNextServerCVar(NULL); if (!var) return NULL; // send the response SZ_Clear(&net_message); // save space for the header, filled in later MSG_WriteLong(&net_message, 0); MSG_WriteByte(&net_message, CCREP_RULE_INFO); if (var) { MSG_WriteString(&net_message, var->getName()); MSG_WriteString(&net_message, var->getString()); } *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); dfunc.Write (acceptsock, net_message.data, net_message.cursize, &clientaddr); SZ_Clear(&net_message); return NULL; } if (command != CCREQ_CONNECT) return NULL; if (strcmp(MSG_ReadString(), "QUAKE") != 0) return NULL; if (MSG_ReadByte() != NET_PROTOCOL_VERSION) { SZ_Clear(&net_message); // save space for the header, filled in later MSG_WriteLong(&net_message, 0); MSG_WriteByte(&net_message, CCREP_REJECT); MSG_WriteString(&net_message, "Incompatible version.\n"); *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); dfunc.Write (acceptsock, net_message.data, net_message.cursize, &clientaddr); SZ_Clear(&net_message); return NULL; } #ifdef BAN_TEST // check for a ban if (clientaddr.sa_family == AF_INET) { unsigned long testAddr; testAddr = ((struct sockaddr_in *)&clientaddr)->sin_addr.s_addr; if ((testAddr & banMask) == banAddr) { SZ_Clear(&net_message); // save space for the header, filled in later MSG_WriteLong(&net_message, 0); MSG_WriteByte(&net_message, CCREP_REJECT); MSG_WriteString(&net_message, "You have been banned.\n"); *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); dfunc.Write (acceptsock, net_message.data, net_message.cursize, &clientaddr); SZ_Clear(&net_message); return NULL; } } #endif // see if this guy is already connected for (s = net_activeSockets; s; s = s->next) { if (s->driver != net_driverlevel) continue; ret = dfunc.AddrCompare(&clientaddr, &s->addr); if (ret >= 0) { // is this a duplicate connection reqeust? if (ret == 0 && net_time - s->connecttime < 2.0) { // yes, so send a duplicate reply SZ_Clear(&net_message); // save space for the header, filled in later MSG_WriteLong(&net_message, 0); MSG_WriteByte(&net_message, CCREP_ACCEPT); dfunc.GetSocketAddr(s->socket, &newaddr); MSG_WriteLong(&net_message, dfunc.GetSocketPort(&newaddr)); *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); dfunc.Write (acceptsock, net_message.data, net_message.cursize, &clientaddr); SZ_Clear(&net_message); return NULL; } // it's somebody coming back in from a crash/disconnect // so close the old qsocket and let their retry get them back in NET_Close(s); return NULL; } } // allocate a QSocket sock = NET_NewQSocket (); if (sock == NULL) { // no room; try to let him know SZ_Clear(&net_message); // save space for the header, filled in later MSG_WriteLong(&net_message, 0); MSG_WriteByte(&net_message, CCREP_REJECT); MSG_WriteString(&net_message, "Server is full.\n"); *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); dfunc.Write (acceptsock, net_message.data, net_message.cursize, &clientaddr); SZ_Clear(&net_message); return NULL; } // allocate a network socket newsock = dfunc.OpenSocket(0); if (newsock == -1) { NET_FreeQSocket(sock); return NULL; } // connect to the client if (dfunc.Connect (newsock, &clientaddr) == -1) { dfunc.CloseSocket(newsock); NET_FreeQSocket(sock); return NULL; } // everything is allocated, just fill in the details sock->socket = newsock; sock->landriver = net_landriverlevel; sock->addr = clientaddr; strcpy(sock->address, dfunc.AddrToString(&clientaddr)); // send him back the info about the server connection he has been allocated SZ_Clear(&net_message); // save space for the header, filled in later MSG_WriteLong(&net_message, 0); MSG_WriteByte(&net_message, CCREP_ACCEPT); dfunc.GetSocketAddr(newsock, &newaddr); MSG_WriteLong(&net_message, dfunc.GetSocketPort(&newaddr)); // MSG_WriteString(&net_message, dfunc.AddrToString(&newaddr)); *((int *)net_message.data) = BigLong(NETFLAG_CTL | (net_message.cursize & NETFLAG_LENGTH_MASK)); dfunc.Write (acceptsock, net_message.data, net_message.cursize, &clientaddr); SZ_Clear(&net_message); return sock; }