Exemplo n.º 1
0
void ChatPanel::SetChannel( Channel* chan )
{
	ASSERT_LOGIC( this, _T( "this==null" ) );
	ASSERT_LOGIC( m_type == CPT_Channel, _T( "Not of type channel" ) );

	if (( chan == 0 ) && ( m_channel != 0 ) ) {
		// causes weird crash.
		StatusMessage( _( "Chat closed." ) );

		m_channel->uidata.panel = 0;
	}
	if ( m_show_nick_list && (m_nicklist != 0) ) {
		m_nicklist->ClearUsers();
	}

	if ( chan != 0 ) {
		chan->uidata.panel = this;
//		m_chat_log.SetTarget( sett().GetDefaultServer(), chan->GetName() );
	}
	m_channel = chan;

	//set back to false so when we rejoin this channel SetTopic doesn;t update the chan icon
	if ( !m_channel )
		m_topic_set = false;
}
Exemplo n.º 2
0
void ChatPanel::SetChannel(Channel* chan)
{
	ASSERT_LOGIC(this, "this==null");
	ASSERT_LOGIC(m_type == CPT_Channel, "Not of type channel");

	if ((chan == 0) && (m_channel != 0)) {
		m_channel->uidata.panel = 0;
	}
	if (m_nicklist != nullptr) {
		m_nicklist->ClearUsers();
		UpdateUserCountLabel();
	}

	if (chan != 0) {
		chan->uidata.panel = this;
		if (chan != m_channel) {
			SetLogFile(TowxString(chan->GetName()));
		}
	}
	m_channel = chan;

	//set back to false so when we rejoin this channel SetTopic doesn;t update the chan icon
	if (!m_channel)
		m_topic_set = false;
}
Exemplo n.º 3
0
int NickListCtrl::CompareUserStatus(DataType user1, DataType user2)
{

	ASSERT_LOGIC(user1 != 0, "user1 = 0");
	ASSERT_LOGIC(user2 != 0, "user2 = 0");

	int u1 = 0, u2 = 0;

	if (user1->GetStatus().bot)
		u1 += 1000;
	if (user2->GetStatus().bot)
		u2 += 1000;
	if (user1->GetStatus().moderator)
		u1 += 100;
	if (user2->GetStatus().moderator)
		u2 += 100;
	if (user1->GetStatus().in_game)
		u1 += -10;
	if (user2->GetStatus().in_game)
		u2 += -10;

	// inverse the order
	if (u1 < u2)
		return -1;
	if (u1 > u2)
		return 1;

	return 0;
}
Exemplo n.º 4
0
UnitSyncMap SpringUnitSync::GetMapEx( const wxString& mapname )
{
  wxLogDebugFunc( _T("") );
  int i = GetMapIndex( mapname );
  ASSERT_LOGIC( i >= 0, _T("Map does not exist") );
  return GetMapEx( i );
}
Exemplo n.º 5
0
void IServer::_RemoveChannel(const std::string& name)
{
    Channel* c = &m_channels.GetChannel(name);
    m_channels.RemoveChannel(name);
    ASSERT_LOGIC(c != 0, "IServer::_RemoveChannel(\"" + name + "\"): GetChannel returned NULL pointer");
    delete c;
}
Exemplo n.º 6
0
void IServer::_RemoveBattle(const int& id)
{
    IBattle* b = &battles_iter->GetBattle(id);
    m_battles.RemoveBattle(id);
    ASSERT_LOGIC(b != 0, "IServer::_RemoveBattle(): GetBattle returned NULL pointer");
    delete b;
}
Exemplo n.º 7
0
//! @brief Open a new chat tab with a private chat
//!
//! @param nick The user to whom the chatwindow should be opened to
void MainWindow::OpenPrivateChat(const User& user, bool doFocus)
{
	ASSERT_LOGIC(m_chat_tab != 0, "m_chat_tab");
	m_func_tabs->SetSelection(PAGE_CHAT);
	ChatPanel* cp = m_chat_tab->AddChatPanel(user);
	if (doFocus)
		cp->FocusInputBox();
}
Exemplo n.º 8
0
bool DataList::Rename(const std::string& old_name, const std::string& new_name)
{
    // check that new name is not used up.
    if (nodes.find(BA::to_lower_copy(new_name)) != nodes.end())
        return false;
    nodes_iterator i = nodes.find(BA::to_lower_copy(old_name));
    if (i == nodes.end())
        return false;
    PNode node = i->second;

    ASSERT_LOGIC(node.Ok(), "Internal TDF tree consistency (1)");
    ASSERT_LOGIC(node->Name().Lower() == old_name.Lower(), "Internal TDF tree consistency (2)");

    node->name = BA::to_lower_copy(new_name);
    nodes.erase(i);
    bool inserted = nodes.insert(std::pair<std::string, PNode>(BA::to_lower_copy(node->name), node)).second;
    ASSERT_LOGIC(inserted, "DataList::Rename failed");
    return inserted;
}
Exemplo n.º 9
0
void IBattle::SetHostMap(const std::string& _mapname, const std::string& _hash)
{
	ASSERT_LOGIC(!_mapname.empty(), _T("Battle with empty map name!"));
	const std::string mapname(_mapname);
	const std::string hash(_hash);
	if ( mapname != m_host_map.name || hash != m_host_map.hash ) {
		m_map_loaded = false;
		m_host_map.name = mapname;
		m_host_map.hash = hash;
	}
}
Exemplo n.º 10
0
void IBattle::SetLocalMap(const std::string& mapname)
{
	ASSERT_LOGIC(!mapname.empty(), _T("Battle with empty map name!"));
	LSL::UnitsyncMap map = LSL::usync().GetMap(mapname);
	if ( map.name != m_local_map.name || map.hash != m_local_map.hash ) {
		m_local_map = map;
		m_map_loaded = true;
		if ( IsFounderMe() ) {// save all rects infos
			//TODO
		}
	}
}
Exemplo n.º 11
0
void SocketEvents::OnSocketEvent(wxSocketEvent& event)
{
  Socket* sock = (Socket*)event.GetClientData();
  try
  {
  ASSERT_LOGIC( sock != 0, _T("sock = 0") );
  } catch (...) { return; }

  if ( event.GetSocketEvent() == wxSOCKET_INPUT ) {
    m_net_class.OnDataReceived( sock );
  } else if ( event.GetSocketEvent() == wxSOCKET_LOST ) {
    m_net_class.OnDisconnected( sock );
  } else if ( event.GetSocketEvent() == wxSOCKET_CONNECTION ) {
    m_net_class.OnConnected( sock );
  } else {
    try
    {
    ASSERT_LOGIC( false, _T("Unknown socket event."));
    } catch (...) { return; };
  }
}
Exemplo n.º 12
0
wxBitmap& IconsCollection::GetFractionBmp(const std::string& modName, int fractionId) {

	wxASSERT(-1 < fractionId);
	wxASSERT(modName.empty() == false);

	if (!LSL::usync().GameExists(modName)){
		// game doesn't exist, dl needed?!
		return BMP_EMPTY;
	}

	const auto sides = LSL::usync().GetSides(modName);

	//This can happen whenever in time, so must be caught in release build too
	if (sides.empty()) {
		wxLogWarning("IconsCollection::GetFractionBmp(): sides.empty()");
		return BMP_EMPTY;
	}
	ASSERT_LOGIC(fractionId < static_cast<int>(sides.size()), "LSL::usync().GetSides() < fractionID!");

	std::string sideName;

	sideName = sides[fractionId];

	const std::string cacheString = modName + "_" + sideName;

	//Check if image already in cache
	if (m_cachedFractionBmps.find(cacheString) != m_cachedFractionBmps.end()) {
		return m_cachedFractionBmps[cacheString];
	//Create one and add to cache
	} else {
		try {
			const LSL::UnitsyncImage img = LSL::usync().GetSidePicture(modName, sideName);
			m_cachedFractionBmps[cacheString] = img.wxbitmap();
		} catch (...) {
		//unitsync can fail!
			ASSERT_LOGIC(false, "LSL::usync().GetSidePicture() failed!");
		}
		return m_cachedFractionBmps[cacheString];
	}
}
Exemplo n.º 13
0
void BattleListTab::OnListJoin(wxListEvent& event)
{
	try {
		ASSERT_LOGIC(m_battle_list != 0, "m_battle_list = 0");
	} catch (...) {
		return;
	}
	if (event.GetIndex() < 0)
		return;

	int id = m_battle_list->GetSelectedData()->GetBattleId();
	DoJoin(serverSelector().GetServer().battles_iter->GetBattle(id));
}
Exemplo n.º 14
0
/// find by name. unused.
PNode DataList::Find(const std::string& str)
{
    if (str == "..")
        return Parent();
    if (str == ".")
        return this;
    nodes_iterator i = nodes.find(BA::to_lower_copy(str));
    if (i != nodes.end()) {
        ASSERT_LOGIC(BA::to_lower_copy(i->second->Name()) == BA::to_lower_copy(str), "Internal TDF tree consistency (3)");
        return i->second;
    }
    return NULL;
}
Exemplo n.º 15
0
void SimpleServerEvents::OnBattleAddBot( int battleid, const wxString& nick, UserBattleStatus status )
{
    wxLogDebugFunc( _T("") );
    try
    {
        Battle& battle = m_serv.GetBattle( battleid );
        battle.OnBotAdded( nick, status );
        User& bot = battle.GetUser( nick );
        ASSERT_LOGIC( &bot != 0, _T("Bot null after add.") );
//        ui().OnUserJoinedBattle( battle, bot );
    }
    catch (assert_exception) {}
}
Exemplo n.º 16
0
void BattleListTab::OnJoin( wxCommandEvent& /*unused*/ )
{
	try
	{
		ASSERT_LOGIC( m_battle_list != 0, _T( "m_battle_list = 0" ) );
	} catch ( ... ) {
		return;
	}

	if ( m_battle_list->GetSelectedIndex() < 0 ) return;

	int id = m_battle_list->GetSelectedData()->GetBattleId();
	DoJoin( serverSelector().GetServer().battles_iter->GetBattle( id ) );
}
Exemplo n.º 17
0
void BattleListTab::OnJoin(wxCommandEvent& /*unused*/)
{
	try {
		ASSERT_LOGIC(m_battle_list != 0, "m_battle_list = 0");
	} catch (...) {
		return;
	}

	if (m_battle_list->GetSelectedIndex() < 0)
		return;
	const IBattle* battle = m_battle_list->GetSelectedData();
	assert(battle != NULL);
	const int id = battle->GetBattleId();
	DoJoin(serverSelector().GetServer().battles_iter->GetBattle(id));
}
Exemplo n.º 18
0
void ChatPanel::SetServer(IServer* serv)
{
	ASSERT_LOGIC(m_type == CPT_Server, "Not of type server");
	if (m_nicklist != nullptr) {
		m_nicklist->ClearUsers();
		UpdateUserCountLabel();
	}
	if (serv != 0) {
		SetLogFile(_T("server"));
		serv->uidata.panel = this;
		if (m_server != nullptr) {
			m_server->uidata.panel = 0;
		}
		m_server = serv;
	}
}
Exemplo n.º 19
0
void SimpleServerEvents::OnNewUser( const wxString& nick, const wxString& country, int cpu, const wxString& id )
{
    wxLogDebugFunc( _T("") );
	try {
        ASSERT_LOGIC( !m_serv.UserExists( nick ), _T("New user from server, but already exists!") );
    }
	catch (...) {
        return;
    }

	User& user = m_serv._AddUser( nick );
	user.SetCountry( country );
	user.SetCpu( cpu );
	user.SetID( id );
//	ui().OnUserOnline( user );
}
Exemplo n.º 20
0
void SinglePlayerTab::OnAddBot(wxCommandEvent& /*unused*/)
{
	AddBotDialog dlg(this, m_battle, true);
	if (dlg.ShowModal() == wxID_OK) {
		UserBattleStatus bs;
		bs.owner = m_battle.GetMe().GetNick();
		bs.aishortname = STD_STRING(dlg.GetAIShortName());
		bs.airawname = STD_STRING(dlg.GetAiRawName());
		bs.aiversion = STD_STRING(dlg.GetAIVersion());
		bs.aitype = dlg.GetAIType();
		bs.team = m_battle.GetFreeTeam();
		bs.ally = m_battle.GetFreeAlly();
		bs.colour = m_battle.GetNewColour();
		User& bot = m_battle.OnBotAdded(STD_STRING(dlg.GetNick()), bs);
		ASSERT_LOGIC(&bot != 0, "bot == 0");
		m_minimap->UpdateMinimap();
	}
}
Exemplo n.º 21
0
wxBitmap& IconsCollection::GetFractionBmp(const std::string& gameName, size_t fractionId)
{

	if (gameName.empty() || !LSL::usync().GameExists(gameName)) {
		wxLogWarning("SideIcon %zu for game %s not found!", fractionId, gameName.c_str());
		// game doesn't exist, dl needed?!
		return BMP_EMPTY;
	}

	const auto sides = LSL::usync().GetSides(gameName);

	//This can happen whenever in time, so must be caught in release build too
	if (sides.empty()) {
		wxLogWarning("IconsCollection::GetFractionBmp(): sides.empty()");
		return BMP_EMPTY;
	}

	if (fractionId >= sides.size()) {
		wxLogWarning("Invalid side requested: %s:%d", gameName.c_str(), fractionId);
		return BMP_EMPTY;
	}

	std::string sideName;

	sideName = sides[fractionId];

	const std::string cacheString = gameName + "_" + sideName;

	//Check if image already in cache
	if (m_cachedFractionBmps.find(cacheString) != m_cachedFractionBmps.end()) {
		return m_cachedFractionBmps[cacheString];
		//Create one and add to cache
	} else {
		try {
			const LSL::UnitsyncImage img = LSL::usync().GetSidePicture(gameName, sideName);
			m_cachedFractionBmps[cacheString] = img.wxbitmap();
		} catch (...) {
			//unitsync can fail!
			ASSERT_LOGIC(false, "LSL::usync().GetSidePicture() failed!");
		}
		return m_cachedFractionBmps[cacheString];
	}
}
Exemplo n.º 22
0
void ChatPanel::SetUser( const User* usr )
{
	ASSERT_LOGIC( m_type == CPT_User, _T( "Not of type user" ) );

	if (( usr == 0 ) && ( m_user != 0 ) )
	{
	  StatusMessage( _( "Chat closed." ) );
	  m_user->uidata.panel = 0;
	  m_chan_opts_button->SetBitmapLabel( icons().GetBitmap(icons().ICON_EMPTY) );
	}
	else if ( usr != 0 ) usr->uidata.panel = this;
	m_user = usr;
	if ( m_user )
	{
		m_chan_opts_button->SetBitmapLabel( icons().GetBitmap(icons().GetUserListStateIcon(m_user->GetStatus(),false, m_user->GetBattle() != 0 ) ) );
	}
//	if ( m_user )
//        m_chat_log.SetTarget( sett().GetDefaultServer(), usr->GetNick() );
}
Exemplo n.º 23
0
void ServerEvents::OnNewUser( const wxString& nick, const wxString& country, int cpu, const wxString& id )
{
    wxLogDebugFunc( _T("") );
    try
    {
        ASSERT_LOGIC( !m_serv.UserExists( nick ), _T("New user from server, but already exists!") );
    }
    catch (...)
    {
        return;
    }
    User& user = m_serv._AddUser( nick );
    if ( useractions().DoActionOnUser( UserActions::ActNotifLogin, nick ) )
        actNotifBox( SL_MAIN_ICON, nick + _(" is online") );
    user.SetCountry( country );
    user.SetCpu( cpu );
		user.SetID( id );
    ui().OnUserOnline( user );
}
Exemplo n.º 24
0
void ChatPanel::SetUser(const User* usr)
{
	ASSERT_LOGIC(m_type == CPT_User, "Not of type user");

	if (usr == NULL) {
		if (m_user != NULL) {
			m_user->uidata.panel = 0;
			if (m_chan_opts_button != NULL) {
				m_chan_opts_button->SetBitmapLabel(icons().GetBitmap(icons().ICON_EMPTY));
			}
		}
	} else {
		usr->uidata.panel = this;
		if (m_chan_opts_button != NULL) {
			const wxBitmap icon = icons().GetBitmap(icons().GetUserListStateIcon(usr->GetStatus(), false, usr->GetBattle() != 0));
			m_chan_opts_button->SetBitmapLabel(icon);
		}
	}
	m_user = usr;
}
Exemplo n.º 25
0
void ChatPanel::SetUser(User* usr)
{
	ASSERT_LOGIC(m_type == CPT_User, "Not of type user");

	if (usr == NULL) {
		if (m_user != NULL) {
			m_user->panel = nullptr;
			if (m_chan_opts_button != NULL) {
				m_chan_opts_button->SetBitmapLabel(IconsCollection::Instance()->BMP_EMPTY);
			}
		}
	} else {
		usr->panel = this;
		if (m_chan_opts_button != NULL) {
			const wxBitmap icon = IconsCollection::Instance()->GetUserListStateIcon(usr->GetStatus(), false, usr->GetBattle() != 0);
			m_chan_opts_button->SetBitmapLabel(icon);
		}
	}
	m_user = usr;
}
Exemplo n.º 26
0
void ChatPanel::SetServer( Server* serv )
{
	ASSERT_LOGIC( m_type == CPT_Server, _T( "Not of type server" ) );
	if (( serv == 0 ) && ( m_server != 0 ) ){
	  StatusMessage( _( "Chat closed." ) );
	  m_server->uidata.panel = 0;
	  if ( m_nicklist ) {
		  m_nicklist->StopTimer();
		  m_nicklist->Clear();
	  }
	}
	else if ( serv != 0 ){
	   serv->uidata.panel = this;
	   if ( m_nicklist )
		   m_nicklist->StartTimer();
	}
	m_server = serv;

//	if ( m_server ){
//	  m_chat_log.SetTarget( sett().GetDefaultServer(), _( "_SERVER" ) );
//	}
}
Exemplo n.º 27
0
ChatPanel& BattleRoomTab::GetChatPanel()
{
	slLogDebugFunc("");
	ASSERT_LOGIC(m_chat != 0, "m_chat = 0");
	return *m_chat;
}
Exemplo n.º 28
0
BattleroomListCtrl& BattleRoomTab::GetPlayersListCtrl()
{
	ASSERT_LOGIC(m_players != 0, "m_players = 0");
	return *m_players;
}
Exemplo n.º 29
0
//! @brief Open a new chat tab with a channel chat
//!
//! @param channel The channel name
//! @note This does NOT join the chatt.
//! @sa Server::JoinChannel OpenPrivateChat
void MainWindow::OpenChannelChat(Channel& channel, bool doFocus)
{
	ASSERT_LOGIC(m_chat_tab != 0, "m_chat_tab");
	m_chat_tab->AddChatPanel(channel, doFocus);
}
Exemplo n.º 30
0
ChatPanel& MainChatTab::ServerChat()
{
	ASSERT_LOGIC(m_server_chat != 0, "m_server_chat = 0");
	return *m_server_chat;
}