Exemplo n.º 1
0
ForeignAgent *GoalSally::GetTarget(AiMain *ai) 
{ 
    if (m_target_id.GetVal()) { 
		
		if (!ai->m_foreigner) return NULL;
		if (!ai->m_foreigner[m_foreign_player]) return NULL;

        BSet<ForeignAgent> *vua = ai->m_foreigner[m_foreign_player]->GetVisibleUnits();
        BSetID h_id; 
        ForeignAgent *his_agent=NULL; 
        for (his_agent = vua->First(h_id); vua->Last(); his_agent =  vua->Next(h_id)) { 
            if (his_agent->GetID().GetVal() == m_target_id.GetVal()) {  
                return his_agent;
            }
		}
	}
	return NULL;
} 
Exemplo n.º 2
0
bool Config::loadSetting(const std::string &line, const std::string &name, BSet &var) const {
	size_t i = isSetting(line, name, "=");
	if(i != std::string::npos) {
		var.clear();
		var.insert(
			trim(line.substr(i))
		);
		return true;
	}
	i = isSetting(line, name, "+=");
	if(i != std::string::npos) {
		var.insert(
			trim(line.substr(i))
		);
		return true;
	}
	i = isSetting(line, name, "-=");
	if(i != std::string::npos) {
		BSet::iterator a = var.find(
			trim(line.substr(i))
		);
		if(a != var.end()) {
			var.erase(a);
		}
		return true;
	}
	return false;
}
Exemplo n.º 3
0
void GoalSally::HookUp(AiMain *ai)
{ 
    Assert(0 <= m_foreign_player); 
    Assert(m_foreign_player < k_MAX_PLAYERS); 

    Assert(ai->m_foreigner[m_foreign_player]); 

    BSet<ForeignAgent> *vc = ai->m_foreigner[m_foreign_player]->GetVisibleUnits();
    BSetID h_id; 
    ForeignAgent *him=NULL; 
    for (him = vc->First(h_id); vc->Last(); him =  vc->Next(h_id)) { 
        if (him->GetID() == m_target_id) {  
			
            return; 
        }
    }

    {
        BOOL COULD_NOT_FIND_SALLY_GOAL_TARGET=0;
        Assert(COULD_NOT_FIND_SALLY_GOAL_TARGET);
    }
}
Exemplo n.º 4
0
void GoalBombard::HookUp(AiMain *ai)
{
    Assert(0 <= m_foreign_player);
    Assert(m_foreign_player < k_MAX_PLAYERS);

    Assert(ai->m_foreigner[m_foreign_player]);

	if (!ai->m_foreigner[m_foreign_player])
		return;

	#ifdef _DEBUG

	if (m_target_type == AGENT_TYPE_ARMY)
		{
			BSet<ForeignAgent> *vc =
				ai->m_foreigner[m_foreign_player]->GetVisibleUnits();
			BSetID h_id;
			ForeignAgent *him=NULL;
			for (him = vc->First(h_id); vc->Last(); him =  vc->Next(h_id)) {
				if (him->GetID() == m_target_id) {

					return;
				}
			}
		}

	if (m_target_type == AGENT_TYPE_CITY)
		{
			BSet<ForeignCity> *vc =
				ai->m_foreigner[m_foreign_player]->GetKnownCities();
			BSetID h_id;
			ForeignCity *him=NULL;
			for (him = vc->First(h_id); vc->Last(); him =  vc->Next(h_id)) {
				if (him->GetID() == m_target_id) {

					return;
				}
			}
		}

    {
        BOOL COULD_NOT_FIND_BOMBARD_GOAL_TARGET=0;
        Assert(COULD_NOT_FIND_BOMBARD_GOAL_TARGET);
    }
	#endif _DEBUG
}
Exemplo n.º 5
0
void tree_view()
{
  VString str;
  if (dir_tree.count() == 0)
    {
    tree_load();
    if (dir_tree.count() == 0) 
      tree_rebuild();
    }
  say1( " " );
  int new_pos = tree_index( work_path );
  if ( new_pos == -1 )
    new_pos = 0;

  BSet set; /* used for searching */
  set.set_range1( 'a', 'z' );
  set.set_range1( 'A', 'Z' );
  set.set_range1( '0', '9' );
  set.set_str1( "._-~" );
  set.set_str1( "?*>[]" );
  
  ScrollPos scroll;
  scroll.set_min_max( 0, dir_tree.count()-1 );
  scroll.set_pagesize( PS+2 );
  scroll.go( new_pos );
  
  int key = 0;
  int opos = -1;
  int opage = -1;
  while( key != 27 && key != 13 && key != '-' && 
         toupper( key ) != 'Q' && toupper( key ) != 'X' && key != KEY_ALT_X )
    {
    if ( key >= 'A' && key <= 'Z' ) key = tolower( key );
    if ( key == 's' )
      {
        str = "";
        say1( "Enter search pattern: ( use TAB to advance )" );
        key = con_getch();
        while( set.in( key ) || key == 8 || key == KEY_BACKSPACE || key == 9 )
          {
          if ( key == 8 || key == KEY_BACKSPACE )
            str_trim_right( str, 1 );
          else
          if ( key != 9 )
            str_add_ch( str, key );
          say2( str );
          
          if ( dir_tree.count() == 0 ) { key = con_getch(); continue; }
          
          int z;
          if ( key == 9 )
            {
            z = scroll.pos() + 1;
            if (z > scroll.max() ) z = scroll.min();
            }
          else
            z = scroll.pos();
          int direction = 1;
          int found = 0;
          int loops = 0;
          VString s_mask = str;
          vfu_expand_mask( s_mask );
          while(1)
            {
            if ( z > scroll.max() ) z = scroll.min();
            if ( z < scroll.min() ) z = scroll.max();
            
            VString str1 = dir_tree[z];
            str_trim_right( str1, 1 );
            int j = str_rfind(str1,'/');
            if (j < 0) 
              str1 = "";
            else
              str_trim_left( str1, j+1 );
            found = ( FNMATCH( s_mask, str1 ) == 0 );
            if ( found ) break;
            z += direction;
            if ( loops++ > dir_tree.count() ) break;
            }
          if (found)
            {
            scroll.go(z);
            tree_draw_page( scroll );
            tree_draw_pos( scroll, opos );
            }
          key = con_getch();
          }
        say1( "" );
        say2( "" );
      }
    else
    switch( key )
      {
      case KEY_UP     : scroll.up(); break;
      case KEY_DOWN   : scroll.down(); break;
      case KEY_PPAGE  : scroll.ppage(); break;
      case KEY_NPAGE  : scroll.npage(); break;
      case KEY_HOME   : scroll.home(); break;
      case KEY_END    : scroll.end(); break;
      case 'r'        : tree_rebuild();
                        scroll.set_min_max( 0, dir_tree.count()-1 );
                        scroll.home();
                        say1( "Rebuild done." );
                        break;
      case 'w'        : tree_save(); break;
      case 'l'        : tree_load(); 
                        scroll.set_min_max( 0, dir_tree.count()-1 );
                        scroll.home();
                        break;
      case 'z'        : 
      case KEY_CTRL_Z :
                        str = dir_tree[scroll.pos()];
                        str_tr( str, "\\", "/" );
                        size_cache_set( str, vfu_dir_size( str ) );
                        tree_draw_page( scroll );
                        tree_draw_pos( scroll, opos );
                        say1( "Done." );
                        break;
      }
    if (opage != scroll.page()) 
      tree_draw_page( scroll );
    if (opos != scroll.pos() - scroll.page() || opage != scroll.page()) 
      tree_draw_pos( scroll, opos );
    opos = scroll.pos() - scroll.page();
    opage = scroll.page();
    key = con_getch();
    }
  if ( key == 13 )
    {
    str = dir_tree[scroll.pos()];
    str_tr( str, "\\", "/" );
    vfu_chdir( str );
    }
  do_draw = 2;
};