/*
    This is where the real work happens!
    Go through the field map and set the data in a new database row
*/
nsresult nsTextAddress::ProcessLine(const nsAString &aLine, nsString& errors)
{
    if (!m_fieldMap) {
        IMPORT_LOG0("*** Error, text import needs a field map\n");
        return NS_ERROR_FAILURE;
    }

    nsresult rv;

    // Wait until we get our first non-empty field, then create a new row,
    // fill in the data, then add the row to the database.
    nsCOMPtr<nsIMdbRow> newRow;
    nsAutoString   fieldVal;
    int32_t        fieldNum;
    int32_t        numFields = 0;
    bool           active;
    rv = m_fieldMap->GetMapSize(&numFields);
    for (int32_t i = 0; (i < numFields) && NS_SUCCEEDED(rv); i++) {
        active = false;
        rv = m_fieldMap->GetFieldMap(i, &fieldNum);
        if (NS_SUCCEEDED(rv))
            rv = m_fieldMap->GetFieldActive(i, &active);
        if (NS_SUCCEEDED(rv) && active) {
            if (GetField(aLine, i, fieldVal, m_delim)) {
                if (!fieldVal.IsEmpty()) {
                    if (!newRow) {
                        rv = m_database->GetNewRow(getter_AddRefs(newRow));
                        if (NS_FAILED(rv)) {
                            IMPORT_LOG0("*** Error getting new address database row\n");
                        }
                    }
                    if (newRow) {
                        rv = m_fieldMap->SetFieldValue(m_database, newRow, fieldNum, fieldVal.get());
                    }
                }
            }
            else
                break;
        }
        else if (active) {
          IMPORT_LOG1("*** Error getting field map for index %ld\n", (long) i);
        }
    }

    if (NS_SUCCEEDED(rv) && newRow)
      rv = m_database->AddCardRowToDB(newRow);

    return rv;
}
Пример #2
0
void ProcessFieldAnim(int x, int y)
{
    int oldt, t;
    TSprite *s;
    int rx, ry, drawx, drawy;
    
    t = oldt = GetField(x, y)->Terrain2;
    t = CycleF(t, 389, 390, 900, 901, 902, 903, 904, 905);
    t = CycleF(t, 391, 392, 906, 907, 908, 909, 910, 911);
    t = CycleF(t, 395, 396, 397, 912, 913, 914, 915, 916);
    t = CycleF(t, 398, 399, 400, 918, 919, 920, 921, 922);
    if (t != oldt) {
        PlaceL2(x, y, t, 1);
        s = (TSprite*)(BmpTerr2[GetField(x, y)->Terrain2]);
        if (s) {
            rx = GetRelX(x), ry = GetRelY(y);
            drawx = 28 * (rx - ry) + 28;
            drawy = 14 * (rx + ry - (GetField(x, y)->Height)) + 14;
            StartDraw(drawx - s->dx, drawy - s->dy, s->w, s->h);
            PaintUnits();
            EndDraw();
        }
    }
}
    ///////////////////////////////////////////////////////////////////////
    // Checks the validity of heart_rate_local_device_type field
    // Returns FIT_TRUE if field is valid
    ///////////////////////////////////////////////////////////////////////
    FIT_BOOL IsHeartRateLocalDeviceTypeValid() const
    {
        const Field* field = GetField(20);
        if( FIT_NULL == field )
        {
            return FIT_FALSE;
        }

        if( !CanSupportSubField( field, (FIT_UINT16) Profile::DIVE_SETTINGS_MESG_HEART_RATE_SOURCE_FIELD_HEART_RATE_LOCAL_DEVICE_TYPE ) )
        {
            return FIT_FALSE;
        }

        return field->IsValueValid(0, (FIT_UINT16) Profile::DIVE_SETTINGS_MESG_HEART_RATE_SOURCE_FIELD_HEART_RATE_LOCAL_DEVICE_TYPE);
    }
Пример #4
0
const FIT_UINT16 Profile::GetSubFieldIndex(const std::string& mesgName, const std::string& fieldName, const std::string& subFieldName)
{
   const FIELD *field = GetField(mesgName, fieldName);

   if (field == NULL)
      return FIT_SUBFIELD_INDEX_MAIN_FIELD;

   for (FIT_UINT16 i = 0; i < field->numSubFields; i++)
   {
      if (field->subFields[i].name == subFieldName)
         return i;
   }

   return FIT_SUBFIELD_INDEX_MAIN_FIELD;
}
void MainWindow::onLoadTareas()
{
    addingTarea_ = true;

    while (ui->tblTareas->rowCount())
        ui->tblTareas->removeRow(0);

    //Obtenemos las tareas
    QSqlQuery q = db_.exec("SELECT * "
                           "FROM tareas "
                           "WHERE id_categ = " + ui->comboCategoria->currentData().toString());

    while (q.next()) {
        //Añadimos la tarea a la tabla de categorias
        int rowNumber = ui->tblTareas->rowCount();
        int id = GetField(q, "id").toInt();
        ui->tblTareas->insertRow(rowNumber);

        QTableWidgetItem* item = new QTableWidgetItem(GetField(q, "name").toString());
        item->setData(Qt::UserRole, id);
        ui->tblTareas->setItem(rowNumber, 0, item);

        ui->tblTareas->setItem(rowNumber, 1, new QTableWidgetItem(GetField(q, "date").toString()));

        item = new QTableWidgetItem("");
        item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
        if (GetField(q, "done").toInt())
            item->setCheckState(Qt::Checked);
        else
            item->setCheckState(Qt::Unchecked);
        ui->tblTareas->setItem(rowNumber, 2, item);
    }
    //Activamos el sorting en la tabla de categorias
    ui->tblTareas->setSortingEnabled(true);
    addingTarea_ = false;
}
Пример #6
0
void FieldTurnEnd(int x, int y)
{
    int oldt, t;
    int anim = 1;
    
    t = oldt = GetField(x, y)->Terrain2;
    t = DegradeF(t, 401, 398, 399, 400, 918, 919, 920, 921, 922);
    t = DegradeF(t, 398, 395, 396, 397, 912, 913, 914, 915, 916);
    t = DegradeF(t, 393, 391, 392, 906, 907, 908, 909, 910, 911);
    t = DegradeF(t, 391, 389, 390, 900, 901, 902, 903, 904, 905);
    if (t != oldt) {
        if ((t == 401) || (t == 393)) anim = 0;
        PlaceL2(x, y, t, anim);
    }
}
    ///////////////////////////////////////////////////////////////////////
    // Checks the validity of analog_layout field
    // Returns FIT_TRUE if field is valid
    ///////////////////////////////////////////////////////////////////////
    FIT_BOOL IsAnalogLayoutValid() const
    {
        const Field* field = GetField(1);
        if( FIT_NULL == field )
        {
            return FIT_FALSE;
        }

        if( !CanSupportSubField( field, (FIT_UINT16) Profile::WATCHFACE_SETTINGS_MESG_LAYOUT_FIELD_ANALOG_LAYOUT ) )
        {
            return FIT_FALSE;
        }

        return field->IsValueValid(0, (FIT_UINT16) Profile::WATCHFACE_SETTINGS_MESG_LAYOUT_FIELD_ANALOG_LAYOUT);
    }
Пример #8
0
int AssignResult5 ()
{
    int i, t = 0;
    
    Base8 = GetField (B8X, B8Y) -> Unit;
    if (Base8 == NO_UNIT || Units [Base8] -> Type % BADLIFE != unBase) 
        Base8 = NO_UNIT;

    for (i = 0; i < BADLIFE; i++)
        if (Units [i] != NULL && Units [i] -> Type < unRadar) t++;
    if (t == 0) return -1; // GoodLife prohral  

    if (Base8 == NO_UNIT || Base8 < BADLIFE) return 1; // BadLife prohral
    
    return 0; // Zatim se jeste hraje
}
Пример #9
0
	const IAccess* CFrame::GetAccess( std::string _name ) const
	{
		const IAccess* result = GetFormal( _name );
		if( result != 0 ) {
			return result;
		}
		result = GetLocal( _name );
		if( result != 0 ) {
			return result;
		}
		result = GetField( _name );
		if( result != 0 ) {
			return result;
		}
		return nullptr;
	}
Пример #10
0
 // get the subtype
 string MimeHeader::GetSubType() const
 {
    string strSubType;
    MimeField *pfd = GetField(CMimeConst::ContentType());
    if (pfd != NULL)
    {
       string strType;
       pfd->GetValue(strType);
       string::size_type nSlash = strType.find('/');
       if (nSlash > 0)
          strSubType = strType.substr(nSlash+1);
    }
    else
       strSubType = "plain";
    return strSubType;
 }
Пример #11
0
void TThor::GoOverground(int over)
{
    int i;

    if (over == IsOverground) return;

    if (TimeUnits < 30) {
        if (ID < BADLIFE) Message(MSG_OUT_OF_TIME);
        return;
    }
    TimeUnits -= 30;
    IsOverground = over;
    HideHelpers();
    if (GetField(X, Y)->Visib == 2) {
        if (over) PlaySample(GetUnitSound(6), 6, EffectsVolume, GetFieldPanning(X, Y));
        else PlaySample(GetUnitSound(7), 6, EffectsVolume, GetFieldPanning(X, Y));
    }
    if (over) {
        for (i = 9; i < 16; i++) {
            ActualSprite = i;
            PaintUnit();
            SDL_Delay(iniAnimDelay2);
        }
        Orient = 3; ActualSprite = 3;
        Weapons[0]->Ammo = 8;
        TotalRockets -= 8;
        if (TotalRockets < 0) {
            Weapons[0]->Ammo += TotalRockets;
            TotalRockets = 0;
        }
        Defense[0] = -utTH_DND0,    Defense[1] -= utTH_DND1,    Defense[2] -= utTH_DND2;
    }
    else {
        Rotate(3);
        for (i = 15; i > 8; i--) {
            ActualSprite = i;
            PaintUnit();
            SDL_Delay(iniAnimDelay2);
        }
        ActualSprite = 8;
        TotalRockets += Weapons[0]->Ammo;
        Weapons[0]->Ammo = 0;
        Defense[0] += utTH_DND0,    Defense[1] += utTH_DND1,    Defense[2] += utTH_DND2;
    }
    ShowHelpers();
    PaintUnit();
}
Пример #12
0
void CDatabaseManager::RemoveField(QString *pICAO)
{
    //First remove the directory
    s_Field* lfld = new s_Field();
    GetField(*pICAO, lfld);
    QDir ldir(lfld->Path);
    ldir.cd(lfld->Path);
    QStringList lFiles;
    lFiles = ldir.entryList();
    QString fileName;
    foreach(fileName, lFiles)
    {
        QString fn(lfld->Path);
        fn.append("/");
        fn.append(fileName);
        QFile::remove(fn);
    }
Пример #13
0
int AssignResult19 ()
{
    int i, t = 0;

    Base1 = GetField (B1X, B1Y) -> Unit;
    if (Base1 == NO_UNIT || Units [Base1] -> Type % BADLIFE != unArtefactHouse) 
        Base1 = NO_UNIT;
    
    for (i = 0; i < BADLIFE; i++)
        if (Units [i] != NULL) t++;
    if (t == 0) return -1; // GoodLife prohral  
    
    if (Base1 == NO_UNIT || Base1 < BADLIFE) return 1;

    
    return 0; // Zatim se jeste hraje
}
Пример #14
0
int AssignResult8 ()
{
    int i, t = 0;

    Docks2 = GetField (D2X, D2Y) -> Unit;
    if (Docks2 == NO_UNIT || Units [Docks2] -> Type % BADLIFE != unDocks) 
        Docks2 = NO_UNIT;
    
    for (i = 0; i < BADLIFE; i++)
        if (Units [i] != NULL) t++;
    if (t == 0) return -1; // GoodLife prohral  
    
    if (Docks2 == NO_UNIT || Docks2 < BADLIFE) return 1; // BadLife prohral

    
    return 0; // Zatim se jeste hraje
}
Пример #15
0
static int luacapstone_memoperand_metaIndex(lua_State* l)
{
    sparc_op_mem* memop = *((sparc_op_mem**)lua_touserdata(l, 1));
    const char* field = lua_tostring(l, 2);

    VALIDATE_FIELD(sparc_op_mem, field);
    const sparc_op_mem_FieldInfo* fi = GetField(sparc_op_mem, field);

    if(fi->IsIntegral)
        lua_pushinteger(l, fieldValue<lua_Integer>(memop, fi));
    else
    {
        NOT_IMPLEMENTED(field);
    }

    return 1;
}
Пример #16
0
void RecConditionForm :: SetCombo(short typ)
{
	wComboField *fld = (wComboField *)GetField(E_CONDITION);
	fld->Clear();
	fld->DeleteAll();

	if (typ == 0)	// error
	{
		fld->AddString("03 - Cannot Open...");
		fld->AddString("04 - Resource...");
		fld->AddString("05 - General Failure...");
	}
	else			// warning
	{
		fld->AddString("06 - Note that...");
	}
}
Пример #17
0
//メイン関数
int main() {
    char read[100];
    int i,j;
    int line;

    srand((unsigned int)time(NULL));
    line=GetField();

    SetMan();
    while(1) {
        system("cls");
        output();
        move();
    }

    printf("end");
    return 0;
}
Пример #18
0
CString CYazOpacXMLParser::GetValue(CString name)
{
	if (name.IsEmpty() || m_Document == NULL)
		return CString("");

	CString str(_T(""));
	if (name.CompareNoCase(STR_AUTHOR) == 0) {
		str = GetField(_T("100"));
		if (str.IsEmpty())
			str = GetField(_T("700"));
	} else if (name.CompareNoCase(STR_TITLE) == 0) {
		str = GetField(_T("245"));
	} else if (name.CompareNoCase(STR_EDITION) == 0) {
		str = GetField(_T("250"));
	} else if (name.CompareNoCase(STR_SERIES) == 0) {
		str = GetField(_T("490"));
	} else if (name.CompareNoCase(STR_PUBLISHER) == 0) {
		str = GetField(_T("260"));
	} else if (name.CompareNoCase(STR_ADDRESS) == 0) {
		str = GetField(_T("490"));
	} else if (name.CompareNoCase(STR_YEAR) == 0) {
		str = GetField(_T("490"));
		int i = str.GetLength()-1;
		_TUCHAR c = str.GetAt(i--);
		while (_istdigit(c) || c == _T('-')) {
			c = str.GetAt(i--);
		}
		str = str.Mid(i);
	} else if (name.CompareNoCase(_T("ISBN")) == 0) {
		str = GetField(_T("020"));
	} else if (name.CompareNoCase(_T("Topic")) == 0) {
	} else if (name.CompareNoCase(_T("Contents")) == 0) {
	} else if (name.CompareNoCase(_T("Performer")) == 0) {
	}

	return str;
}
Пример #19
0
af::TList Scheme::GetEqvList()
{
	if(Root.IsNull())
	{
		throw NoLabelInicialisationException("Scheme: label do not inicialised.");
	}
	bool ok;
	TList eqv (GetField("EqvList",ok));

	if (ok)
	{
		EqvList = eqv;
		return EqvList;
	}
	
	SetEqvList ();

	return EqvList;
}
Пример #20
0
static int luacapstone_sparc_metaIndex(lua_State* l)
{
    cs_sparc* sparc = (*(cs_sparc**)lua_touserdata(l, 1));
    const char* field = lua_tostring(l, 2);

    VALIDATE_FIELD(cs_sparc, field);
    const cs_sparc_FieldInfo* fi = GetField(cs_sparc, field);

    if(fi->IsIntegral || fi->IsEnum)
        lua_pushinteger(l, fieldValue<lua_Integer>(sparc, fi));
    else if(fi->IsStruct)
        lua_pushcstruct(l, &(sparc->operands), &luacapstone_operandarray_metaIndex, "__sparc_operands");
    else
    {
        NOT_IMPLEMENTED(field);
    }

    return 1;
}
Пример #21
0
int AssignResult7 ()
{
    int i, t = 0;

    Base6 = GetField (B6X, B6Y) -> Unit;
    if (Base6 == NO_UNIT || Units [Base6] -> Type % BADLIFE != unBase) 
        Base6 = NO_UNIT;
    
    for (i = 0; i < BADLIFE; i++)
        if (Units [i] != NULL && Units [i] -> Type < unRadar) t++;
    if (t == 0) return -1; // GoodLife prohral  
    
    if (Base6 < BADLIFE || Base6 == NO_UNIT) {
        return 1; 
    }
        // GoodLife vyhral - obsazena nepratelska zakladna
    
    return 0; // Zatim se jeste hraje
}
Пример #22
0
// ====================================================================================================
// Call
// ====================================================================================================
void LuaManager::Call(int narg, int nresults)
{
	lua_State* L = State();

	// Traceback
	GetGlobal("debug");
	GetField("traceback");
	Remove(-2);
	int errindex = -narg - 2;
	lua_insert(L, errindex);

	// Call
	int status = lua_pcall(L, narg, nresults, errindex);
	m_bSuccess = (status == 0);

	if (!m_bSuccess)
	{
		throw luabind::error(lua->State());
	}
}
Пример #23
0
STDMETHODIMP CRegistrator::GetReceiptNumber(BSTR FirmID, LONG ReceiptType, LONG* ErrorCode, LONG* ReceiptNumber)
{
	*ErrorCode = E_SUCCESS;
	CRegistratorInfo* regInfo = m_RegistratorList.GetInfo(FirmID);
	if(regInfo)
	{
		BYTE nReceivedMessage[MESSAGE_SIZE];
		if(PassCommand(regInfo->hCommPort, (LPBYTE) "A5", (LPBYTE) "6", 1, nReceivedMessage, ErrorCode))
		{
			BYTE lpFieldData[MESSAGE_SIZE];
			if (GetField(nReceivedMessage, lpFieldData, 1))
				*ReceiptNumber = atoi((CHAR*)lpFieldData);
		}
	}
	else
		*ErrorCode = E_NOT_FOUND;


	return S_OK;
}
Пример #24
0
CString CYazOpacXMLParser::GetType()
{
	CString t = GetField(_T("008"));
	if (t.IsEmpty())
		return _T("book");
	CString sub = t.Mid(24, 3);
	if (sub.FindOneOf(_T("agnos")) != -1)
		return _T("article");
	else if (sub.FindOneOf(_T("cdefhry")) != -1)
		return _T("book");
	else if (sub.FindOneOf(_T("ltpuvw")) != -1)
		return _T("techreport");
	else if (sub.FindOneOf(_T("m")) != -1)
		return _T("phdthesis");
	else if (sub.FindOneOf(_T("z")) != -1)
		return _T("unpublished");
	else if (sub.FindOneOf(_T("ijkq")) != -1)
		return _T("misc");

	return _T("book");
}
Пример #25
0
void SelectDlg::OnInitDialog(wxInitDialogEvent& event)
{
	vtProjection proj;
	m_pLayer->GetProjection(proj);

	m_iFauxFields = 0;
	vtFeatureSet *pSet = m_pLayer->GetFeatureSet();

	OGRwkbGeometryType type = pSet->GetGeomType();
	if (type == wkbPoint || type == wkbPoint25D)
	{
		if (proj.IsGeographic())
		{
			GetField()->Append(_("X (longitude)"), (void *) 900);
			GetField()->Append(_("Y (latitude)"), (void *) 901);
		}
		else
		{
			GetField()->Append(_("X (easting)"), (void *) 900);
			GetField()->Append(_("Y (northing)"), (void *) 901);
		}
		m_iFauxFields = 2;
	}
	if (type == wkbPoint25D)
	{
		GetField()->Append(_("Z (meters)"), (void *) 902);
		m_iFauxFields = 3;
	}

	for (uint i = 0; i < pSet->NumFields(); i++)
	{
		Field *field = pSet->GetField(i);
		wxString str(field->m_name, wxConvUTF8);
		GetField()->Append(str, (void *) 0);
	}
	GetField()->SetSelection(0);

	FillValuesControl();

	m_bSetting = true;
	wxDialog::OnInitDialog(event);	// calls TransferValuesToWindow
	m_bSetting = false;
}
Пример #26
0
bool DatabaseUtils::GetSelectFields(const Fields &fields, const MediaType &mediaType, FieldList &selectFields)
{
  if (mediaType == MediaTypeNone || fields.empty())
    return false;

  Fields sortFields = fields;

  // add necessary fields to create the label
  if (mediaType == MediaTypeSong || mediaType == MediaTypeVideo || mediaType == MediaTypeVideoCollection ||
      mediaType == MediaTypeMusicVideo || mediaType == MediaTypeMovie || mediaType == MediaTypeTvShow || mediaType == MediaTypeEpisode)
    sortFields.insert(FieldTitle);
  if (mediaType == MediaTypeEpisode)
  {
    sortFields.insert(FieldSeason);
    sortFields.insert(FieldEpisodeNumber);
  }
  else if (mediaType == MediaTypeAlbum)
    sortFields.insert(FieldAlbum);
  else if (mediaType == MediaTypeSong)
    sortFields.insert(FieldTrackNumber);
  else if (mediaType == MediaTypeArtist)
    sortFields.insert(FieldArtist);

  selectFields.clear();
  for (Fields::const_iterator it = sortFields.begin(); it != sortFields.end(); ++it)
  {
    // ignore FieldLabel because it needs special handling (see further up)
    if (*it == FieldLabel)
      continue;

    if (GetField(*it, mediaType, DatabaseQueryPartSelect).empty())
    {
      CLog::Log(LOGDEBUG, "DatabaseUtils::GetSortFieldList: unknown field %d", *it);
      continue;
    }
    selectFields.push_back(*it);
  }

  return !selectFields.empty();
}
Пример #27
0
void RepairPost::expand(uint v) {
	if(v <= max_value) {
		pos++;                       //** pos dentro de "info".
		info[pos] = v+info[pos-1];   //** suma lo anterior (d-gaps)
		return;
	}
	//**  else // a non-terminal node
	uint aux1 = v-max_value-1;      //** no es un s�mbolo terminal. ==> 
	assert(BRR->IsBitSet(aux1));
	uint aux2=1;                    //** descomprimir hasta que aux2 ==0;   (mientras haya m�s 1's que 0's)
	uint rank_aux=aux1-BRR->rank(aux1)+1;
	while(aux2!=0) {
		if(BRR->IsBitSet(aux1))
			aux2++;
		else {
			aux2--;
			expand(GetField(csymb_n, bits_sn, rank_aux)); //symbols_new[rank_aux]);
			rank_aux++;
		}
		aux1++;
	}
}
Пример #28
0
void emMinesFileModel::CalcExtraData()
{
	int x, y, z, f;

	FieldCount=SizeX*SizeY*SizeZ;
	MineCount=0;
	OpenCount=0;
	MarkCount=0;
	GameWon=false;
	GameLost=false;
	for (z=0; z<SizeZ; z++) for (y=0; y<SizeY; y++) for (x=0; x<SizeX; x++) {
		f=GetField(x,y,z);
		if (f&1) {
			MineCount++;
			if (f&2) GameLost=true;
		}
		if (f&2) OpenCount++;
		if (f&4) MarkCount++;
	}
	if (!GameLost && OpenCount==FieldCount-MineCount) GameWon=true;
	ExtraDataValid=true;
}
Пример #29
0
   void 
      MimeHeader::SetUnicodeFieldValue(const AnsiString &sFieldName, const String & sFieldValue, const AnsiString & sCharset)
   {
      // Retrieve the current charset for this field.
      MimeField* pfd = GetField(sFieldName);

      if (sFieldValue.GetLength() == 0)
      {
         SetRawFieldValue(sFieldName, "", "");
         return;
      }

      AnsiString sCharsetToUse = sCharset;

      // If client hasn't specified character set, assume it's the existing one.
      if (pfd && pfd->GetCharset() && sCharsetToUse.IsEmpty())
         sCharsetToUse = pfd->GetCharset();

      // If there's no existing charset, assume it's the same as for the email.
      if (sCharsetToUse.IsEmpty())
         sCharsetToUse = GetCharset();

      if (sCharsetToUse.IsEmpty())
         sCharsetToUse = "utf-8";

      AnsiString sMBText = Charset::ToMultiByte(sFieldValue, sCharsetToUse);

      // Encode the value
      FieldCodeBase* pCoder = MimeEnvironment::CreateFieldCoder(sFieldName);
      pCoder->SetInput(sMBText, sMBText.GetLength(), true);
      pCoder->SetCharset(sCharsetToUse.c_str());

      AnsiString sEncodedValue;
      pCoder->GetOutput(sEncodedValue);

      delete pCoder;   

      SetRawFieldValue(sFieldName, sEncodedValue, sCharsetToUse);
   }
Пример #30
0
int CanAutofireOn(TUnit *unit)
{
    int i, ca, oldcw;
    TUnit *u, *su;
    
    if (!AF_Reseted) return FALSE;
    if (!AF_Map[unit->X + MapSizeX * unit->Y]) return FALSE;
    if (unit->Type % BADLIFE == unSatan) return FALSE;

    if ((AF_from == GOODLIFE) && (GetField(unit->X, unit->Y)->Visib != 2)) return FALSE;
    if ((AF_from == BADLIFE) && (GetBadlifeVisib(unit->X, unit->Y) != 2)) return FALSE;

    for (i = 0; i < UNITS_TOP; i++) 
        if (AF_Units[i]) AF_Units[i] = (Units[i] != NULL) && (Units[i]->X != -1);
    for (i = AF_from; i < AF_to; i++)
        if (AF_Units[i]) {
            u = (TUnit*)Units[i];
            ca = ChooseAttack(u, unit);
            if (ca != -1) return TRUE;
        }
    return FALSE;
}