Пример #1
0
void CNetRender::SetClient(QString address, int portNo)
{
	DeleteServer();
	deviceType = netRender_CLIENT;
	status = netRender_NEW;
	this->address = address;
	this->portNo = portNo;
	ResetMessage(&msgFromServer);
	clientSocket = new QTcpSocket(this);

	reconnectTimer = new QTimer;
	reconnectTimer->setInterval(1000);
	connect(reconnectTimer, SIGNAL(timeout()), this, SLOT(TryServerConnect()));
	connect(clientSocket, SIGNAL(disconnected()), this, SLOT(ServerDisconnected()));
	connect(clientSocket, SIGNAL(readyRead()), this, SLOT(ReceiveFromServer()));

	reconnectTimer->start();
	WriteLog("NetRender - Client Setup, link to server: " + address + ", port: " + QString::number(portNo));
	emit NotifyStatus();

	if(systemData.noGui)
	{
		QTextStream out(stdout);
		out << "NetRender - Client Setup, link to server: " + address + ", port: " + QString::number(portNo) + "\n";
	}
}
Пример #2
0
void MainExitServer()
{
	lprintf("ExitServer terminating server\n");
	
	ExitAsyncConnections();
	
	CloseAllSessions(); /* gotta do this before anything, cause it uses kod, accounts */
	
	CloseDefaultChannels();
	
	ResetLoadMotd();
	ResetLoadBof();
	
	ResetTable();
	ResetBufferPool();
	ResetSysTimer();
	ResetDLlist();
	ResetNameID();
	ResetAccount();
	ResetUser();
	ResetString();
	ResetRoomData();
	ResetResource();
	ResetTimer();
	ResetList();
	ResetObject();
	ResetMessage();
	ResetClass();
	
	ResetConfig();
	
	DeleteAllBlocks();
}
Пример #3
0
static	void
SessionThread(
	void	*para)
{
	SessionCtrl *ctrl;
	GHashTable *hash;
ENTER_FUNC;
	workq = NewQueue();
	hash = NewNameHash();
	RecParserInit();
	while (TRUE) {
		ctrl = (SessionCtrl *)DeQueue(workq);
		switch (ctrl->type) {
		case SESSION_CONTROL_INSERT:
			InsertSession(hash,ctrl);
			break;
		case SESSION_CONTROL_UPDATE:
			UpdateSession(hash,ctrl);
			break;
		case SESSION_CONTROL_DELETE:
			DeleteSession(hash,ctrl);
			break;
		case SESSION_CONTROL_LOOKUP:
			LookupSession(hash,ctrl);
			break;
		case SESSION_CONTROL_GET_SESSION_NUM:
			GetSessionNum(hash,ctrl);
			break;
		case SESSION_CONTROL_GET_DATA:
			GetData(hash,ctrl);
			break;
		case SESSION_CONTROL_GET_MESSAGE:
			GetMessage(hash,ctrl);
			break;
		case SESSION_CONTROL_RESET_MESSAGE:
			ResetMessage(hash,ctrl);
			break;
		case SESSION_CONTROL_SET_MESSAGE:
			SetMessage(hash,ctrl);
			break;
		case SESSION_CONTROL_SET_MESSAGE_ALL:
			SetMessageAll(hash,ctrl);
			break;
		case SESSION_CONTROL_GET_DATA_ALL:
			GetDataAll(hash,ctrl);
			break;
		}
		EnQueue(ctrl->waitq,ctrl);
	}
	pthread_exit(NULL);
LEAVE_FUNC;
}
Пример #4
0
void InterfaceReloadSystem()
{
	EnterServerLock();
	
	lprintf("InterfaceReloadSystem reloading system\n");
	
	PauseTimers();
	
	SendBlakodBeginSystemEvent(SYSEVENT_RELOAD_SYSTEM);
	
	GarbageCollect();
	SaveAll();
	
	ResetAdminConstants();
	ResetUser();
	ResetString();
	ResetRoomData();
	ResetLoadMotd();
	ResetLoadBof();
	ResetDLlist();
	ResetNameID();
	ResetResource();
	ResetTimer();
	ResetList();
	ResetObject();
	ResetMessage();
	ResetClass();
	
	LoadMotd();
	LoadBof();
	LoadRsc();
	
	LoadKodbase();
	
	UpdateSecurityRedbook();
	
	LoadAdminConstants();
	/* can't reload accounts because sessions have pointers to accounts */
	if (!LoadAllButAccount()) 
		eprintf("InterfaceReloadSystem couldn't load game.  You are dead.\n");
	
	AllocateParseClientListNodes(); /* it needs a list to send to users */
	AddBuiltInDLlist();
	
	SendBlakodEndSystemEvent(SYSEVENT_RELOAD_SYSTEM);
	
	UnpauseTimers();
	
	LeaveServerLock();
}
void WXMSearchReplaceDialog::WxButtonCountClick(wxCommandEvent& event)
{
	ResetMessage();

	if (g_active_wxmedit == nullptr)
		return;

	int count = 0;
	wxString text;
	m_FindText->GetText(text, true);

	if(text.Len()>0)
	{
		m_RecentFindText->AddItemToHistory(text);

		wxInt64 from = 0, to = 0;
		wxFileOffset rangeFrom = -1, rangeTo = -1;
		if(WxCheckBoxSearchInSelection->IsChecked())
		{
			if(!StrToInt64(WxEditFrom->GetValue(), from))
			{
				ShowMessage(_("The value of 'From' is incorrect."), SMT_WARNING);
				return;
			}
			if(!StrToInt64(WxEditTo->GetValue(), to))
			{
				ShowMessage(_("The value of 'To' is incorrect."), SMT_WARNING);
				return;
			}

			rangeTo = to;
			rangeFrom = from;
		}

		wxm::WXMSearcher* searcher = g_active_wxmedit->Searcher(WxCheckBoxFindHex->GetValue(), WxCheckBoxRegex->GetValue());
		searcher->SetOption(WxCheckBoxCaseSensitive->GetValue(), WxCheckBoxWholeWord->GetValue());

		count = searcher->FindAll(text, false, nullptr, nullptr, rangeFrom, rangeTo);
	}

	if(count >= 0)
	{
		wxString msg;
		msg.Printf(_("'%s' was found %d times."), text.c_str(), count);
		ShowMessage(msg, SMT_NOTICE);
	}
}
void WXMSearchReplaceDialog::WxButtonReplaceAllClick(wxCommandEvent& event)
{
	ResetMessage();

	if( g_active_wxmedit == nullptr)
		return;

	wxString text;
	m_FindText->GetText(text, true);

	if(WxCheckBoxFindHex->GetValue())
		text.Trim();

	if(text.Len()>0)
	{
		wxString reptext;
		m_ReplaceText->GetText(reptext, true);

		m_RecentFindText->AddItemToHistory(text);

		if(reptext.Len()>0)
		{
			m_RecentReplaceText->AddItemToHistory(reptext);
		}

		wxInt64 from = 0, to = 0;
		wxFileOffset rangeFrom = -1, rangeTo = -1;
		if(WxCheckBoxSearchInSelection->IsChecked())
		{
			if(!StrToInt64(WxEditFrom->GetValue(), from))
			{
				ShowMessage(_("The value of 'From' is incorrect."), SMT_WARNING);
				return;
			}
			if(!StrToInt64(WxEditTo->GetValue(), to))
			{
				ShowMessage(_("The value of 'To' is incorrect."), SMT_WARNING);
				return;
			}

			rangeTo = to;
			rangeFrom = from;
		}

		int count=0;
		wxm::WXMSearcher* searcher = g_active_wxmedit->Searcher(WxCheckBoxFindHex->GetValue(), WxCheckBoxRegex->GetValue());
		searcher->SetOption(WxCheckBoxCaseSensitive->GetValue(), WxCheckBoxWholeWord->GetValue());

		count = searcher->ReplaceAll(text, reptext, nullptr, nullptr, rangeFrom, rangeTo);

		if(count>=0)
		{
			wxString msg;
			if(count==0)
				ShowMessage(_("Cannot find any matched string."), SMT_WARNING);
			else
				ShowMessage(wxString::Format(_("%d string(s) were replaced."), count), SMT_NOTICE);
		}

		m_FindText->SetFocus();
	}
}
void WXMSearchReplaceDialog::WxButtonReplaceClick(wxCommandEvent& event)
{
	ResetMessage();

	if (g_active_wxmedit == nullptr)
		return;

	wxString text;
	m_FindText->GetText(text, true);

	if(WxCheckBoxFindHex->GetValue())
		text.Trim();

	if(text.Len() <= 0)
		return;

	wxString reptext;
	m_ReplaceText->GetText(reptext, true);

	m_RecentFindText->AddItemToHistory(text);

	if(reptext.Len()>0)
	{
		m_RecentReplaceText->AddItemToHistory(reptext);
	}

	wxString msg_selection_end(_("End of selection reached, replace from beginning."));
	wxString msg_file_end(_("End of file reached, replace from beginning."));

	wxInt64 from = 0, to = 0;
	wxFileOffset rangeFrom = -1, rangeTo = -1;
	wxFileOffset caretpos = g_active_wxmedit->GetCaretPosition();
	if(WxCheckBoxSearchInSelection->IsChecked())
	{
		if(!StrToInt64(WxEditFrom->GetValue(), from))
		{
			ShowMessage(_("The value of 'From' is incorrect."), SMT_WARNING);
			return;
		}
		if(!StrToInt64(WxEditTo->GetValue(), to))
		{
			ShowMessage(_("The value of 'To' is incorrect."), SMT_WARNING);
			return;
		}

		rangeTo = to;
		if (caretpos <= from || caretpos > to)
		{
			rangeFrom = from;
		}
		else if (caretpos==to && WxCheckBoxWrapAround->IsChecked())
		{
			ShowMessage(msg_selection_end);
			rangeFrom = from;
		}
	}

	MadReplaceResult ret=RR_EXPR_ERROR;

	wxm::WXMSearcher* searcher = g_active_wxmedit->Searcher(WxCheckBoxFindHex->GetValue(), WxCheckBoxRegex->GetValue());
	searcher->SetOption(WxCheckBoxCaseSensitive->GetValue(), WxCheckBoxWholeWord->GetValue());
	for (;;)
	{
		ret = searcher->ReplaceOnce(text, reptext, rangeFrom, rangeTo);

		if ((ret==RR_REP_NNEXT || ret==RR_NREP_NNEXT) &&
			WxCheckBoxWrapAround->IsChecked() && rangeTo != caretpos)
		{
			bool in_selection = WxCheckBoxSearchInSelection->IsChecked();

			ShowMessage(in_selection? msg_selection_end: msg_file_end);

			rangeTo = caretpos;
			rangeFrom = in_selection? from : 0;
			continue;
		}

		break;
	}

	switch(ret)
	{
	case RR_REP_NNEXT:
		{
			ShowMessage(_("Cannot find the matched string. Replace is finished."), SMT_NOTICE);
			m_FindText->SetFocus();
		}
		break;
	case RR_NREP_NNEXT:
		{
			ShowMessage(_("Cannot find the matched string."), SMT_WARNING);
			m_FindText->SetFocus();
		}
		break;
	case RR_REP_NEXT:
	case RR_NREP_NEXT:
		if(WxCheckBoxMoveFocus->GetValue())
		{
			((wxFrame*)wxTheApp->GetTopWindow())->Raise();
			g_active_wxmedit->SetFocus();
		}
		break;
	default:
		break;
	}
}
void WXMSearchReplaceDialog::WxButtonFindPrevClick(wxCommandEvent& event)
{
	ResetMessage();

	if (g_active_wxmedit == nullptr)
		return;

	wxString text;
	m_FindText->GetText(text, true);

	if(WxCheckBoxFindHex->GetValue())
		text.Trim();

	if(text.Len()>0)
	{
		m_RecentFindText->AddItemToHistory(text);

		MadSearchResult sr;
		wxFileOffset selbeg = g_active_wxmedit->GetSelectionBeginPos();
		wxFileOffset caretpos = g_active_wxmedit->GetCaretPosition();

		wxString msg_selection_begin(_("Beginning of selection reached, search from end."));
		wxString msg_file_begin(_("Beginning of file reached, search from end."));

		wxInt64 from = 0, to = 0;
		wxFileOffset rangeFrom = -1, rangeTo = -1;
		if(WxCheckBoxSearchInSelection->IsChecked())
		{
			if(!StrToInt64(WxEditFrom->GetValue(), from))
			{
				ShowMessage(_("The value of 'From' is incorrect."), SMT_WARNING);
				return;
			}
			if(!StrToInt64(WxEditTo->GetValue(), to))
			{
				ShowMessage(_("The value of 'To' is incorrect."), SMT_WARNING);
				return;
			}

			rangeFrom = from;
			if (caretpos < from || caretpos >= to)
			{
				rangeTo = to;
			}
			else if (caretpos==from && WxCheckBoxWrapAround->IsChecked())
			{
				ShowMessage(msg_selection_begin);
				rangeTo = to;
			}
		}

		wxm::WXMSearcher* searcher = g_active_wxmedit->Searcher(WxCheckBoxFindHex->GetValue(), WxCheckBoxRegex->GetValue());
		searcher->SetOption(WxCheckBoxCaseSensitive->GetValue(), WxCheckBoxWholeWord->GetValue());
		for (;;)
		{
			sr = searcher->FindPrevious(text, rangeTo, rangeFrom);

			if(sr!=SR_NO)
			{
				if(sr == SR_YES && g_active_wxmedit->GetCaretPosition() == selbeg)
				{
					selbeg = -1;
					continue;
				}
				break;
			}

			if (WxCheckBoxWrapAround->IsChecked() && rangeFrom != caretpos)
			{
				bool in_selection = WxCheckBoxSearchInSelection->IsChecked();

				ShowMessage(in_selection? msg_selection_begin: msg_file_begin);

				rangeTo = in_selection? to: g_active_wxmedit->GetFileSize();
				rangeFrom = caretpos;
				continue;
			}

			wxString msg(_("Cannot find the matched string."));
			ShowMessage(msg, SMT_WARNING);
			break;
		}
	}

	if(WxCheckBoxMoveFocus->GetValue())
	{
		((wxFrame*)wxTheApp->GetTopWindow())->Raise();
		g_active_wxmedit->SetFocus();
	}
}