Example #1
0
    Eximpl int				/* from analyse */
sol_analyse( Board* bp, int depth, Movelist* sols )
{
    /*
     * Here we know, how to call "analyse".
     * We also manage dual-suppression.
     */
    int		res;

    if( depth <= f_nodualdep ) {
	/*
	 * We ask analyse for just one move, and fill that one
	 * into the given list.
	 */
	    Move	move;
	move.m_from = NO_POS;		/* not yet filled */
	res = analyse(bp, depth, (Movelist*)0, &move, (RefuList*)0);
	sol_1move_list(&move, ANASUC(res), sols);
    }else {		/* normal, all solutions */
	res = analyse(bp, depth, sols, (Move*)0, (RefuList*)0);
	/*
	 * Now, if the resulting depth is smaller than the asked depth,
	 * we might fall below the dual suppression limit.
	 * In this case the list is to be truncated after the first move.
	 */
	if( (list_length(sols) > 1)		/* something to cut off */
	 && ANASUC(res) && (ANADEP(res) <= f_nodualdep) ) {
	    sol_1redu_list(sols);
	}
    }
    return res;
}
Example #2
0
/////////////////////////////////////////////////////////////////////////////
// TDrawView::CmECGFilter()
//
// Responds to CM_ECGFILTER message generated by the menu item or button.
/////////////////////////////////////////////////////////////////////////////
void TDrawView::CmECGFilter()
{
	const Tecg* ecg;
	ecg = DrawDoc->GetECG();
	TModule* moduleid = /*GetWindow()->*/GetModule();
	TBufFilter filtbuff;
	char far *buffer = new char[100];
	for (int line=IDS_FILT_FIRST+1 ; line < IDS_FILT_LAST ; line++)
	{
		moduleid->LoadString(line, buffer, 100);
		filtbuff.combo_filt_type.AddString(buffer);
	}
	filtbuff.combo_filt_type.Select(ecg->get_cur_filt_data().Mode-IDS_FILT_FIRST-1);
	delete buffer; // dont want to be leeking
	wsprintf(filtbuff.edit_optval, "%d", ecg->get_cur_filt_data().Opt_Val); // set initial optional value (not always used)

	TDialog *dialog = new TDlgFilter( this, IDD_FILTER, &filtbuff);

	int result = dialog->Execute();
	if (result == IDOK)
	{
		const_cast<Tecg*>(ecg)->set_cur_filt_data(filtbuff.combo_filt_type.GetSelIndex() +IDS_FILT_FIRST +1
                              , atoi(filtbuff.edit_optval));
		TAnalyse_Filter analyse(ecg);
		analyse.Set_Filter_Mode(filtbuff.combo_filt_type.GetSelIndex() +IDS_FILT_FIRST +1
										, atoi(filtbuff.edit_optval));
		analyse.Execute();
		//const_cast<Tecg*>(ecg)->AnalyseData(INVERT);
		DrawDoc->RePaintViews();
	}
}
Example #3
0
void get_index(t_atoms *atoms, const char *fnm, int ngrps,
               int isize[], atom_id *index[], char *grpnames[])
{
    char    ***gnames;
    t_blocka  *grps = NULL;
    int       *grpnr;

    snew(grpnr, ngrps);
    snew(gnames, 1);
    if (fnm != NULL)
    {
        grps = init_index(fnm, gnames);
    }
    else if (atoms)
    {
        snew(grps, 1);
        snew(grps->index, 1);
        analyse(atoms, grps, gnames, FALSE, FALSE);
    }
    else
    {
        gmx_incons("You need to supply a valid atoms structure or a valid index file name");
    }

    rd_groups(grps, *gnames, grpnames, ngrps, isize, index, grpnr);
}
Example #4
0
/////////////////////////////////////////////////////////////////////////////
// TDrawView::CmECGCalcRunMean()
//
// Responds to CM_ECGCALCRUNMEAN message generated by the menu item or button.
/////////////////////////////////////////////////////////////////////////////
void TDrawView::CmECGCalcRunMean()
{
	TBufRunMean rmbuff;
	const Tecg* ecg;
	ecg = DrawDoc->GetECG();

	rmbuff.full = (ecg->get_run_mean_calc() == TRMC_FULL);
	rmbuff.rtor = (ecg->get_run_mean_calc() == TRMC_RTR);
	rmbuff.rtorwin = (ecg->get_run_mean_calc() == TRMC_RTRWIN);
	wsprintf(rmbuff.edit_winsize, "%d", ecg->get_run_mean_winsize());

	TDialog *dialog = new TDlgRunMean( this, IDD_RUNNINGMEAN, &rmbuff);
	int result = dialog->Execute();
	if (result == IDOK)
	{
		if (rmbuff.full)
			const_cast<Tecg*>(ecg)->set_run_mean_calc( TRMC_FULL );
		else if (rmbuff.rtor)
			const_cast<Tecg*>(ecg)->set_run_mean_calc( TRMC_RTR );
		else if (rmbuff.rtorwin)
			const_cast<Tecg*>(ecg)->set_run_mean_calc( TRMC_RTRWIN );

		const_cast<Tecg*>(ecg)->set_run_mean_winsize(atoi(rmbuff.edit_winsize));

		TAnalyse_Run_Mean analyse(ecg);
		analyse.Execute();
		//const_cast<Tecg*>(ecg)->AnalyseData(CALC_RUN_MEAN_1);
		DrawDoc->RePaintViews();
	}
}
Example #5
0
int main(int argc, const char *argv[])
{
    char arr[80];
    char *p;
    int i = 0;
    shell myshell;
    while(1)
    {
        i = 0;
        printf("mysh%% ");
        fgets(arr,80,stdin);
        if(!strcmp(arr,"exit\n"))
            return 0;
        analyse(arr,&myshell);
        printf("command:\t%s\n",myshell.command);
        free(myshell.command); myshell.command = NULL;
        while(p = myshell.argument[i++])
        {
            printf("argument%d:\t%s\n",i,p);
            free(p); p = NULL;
        }
        printf("in_file:\t%s\n",myshell.in_file ? myshell.in_file : "NULL");
        free(myshell.in_file); myshell.in_file = NULL;
        printf("out_file:\t%s\n",myshell.out_file ? myshell.out_file : "NULL");
        free(myshell.out_file); myshell.out_file = NULL;
    }
    return 0;
}
Example #6
0
////////////////////////////////////////////////////////////////////////////////
//! Side effect of shared memory access
//! Side effect of shared memory access
//! @param tidx  thread id in x dimension of block
//! @param tidy  thread id in y dimension of block
//! @param tidz  thread id in z dimension of block
//! @param bdimx block size in x dimension
//! @param bdimy block size in y dimension
//! @param bdimz block size in z dimension
//! @param file  name of the source file where the access takes place
//! @param line  line in the source file where the access takes place
//! @param aname name of the array which is accessed
//! @param index index into the array
////////////////////////////////////////////////////////////////////////////////
void BankChecker::
access( unsigned int tidx, unsigned int tidy, unsigned int tidz,
        unsigned int bdimx, unsigned int bdimy, unsigned int bdimz,
        const char* file, const int line, const std::string& aname,
        const int index)
{ 
    is_active = true;

    // linearized thread id
    unsigned int ltid = getLtid( tidx, tidy, tidz, bdimx, bdimy, bdimz);

    // reset state if new warp
    if( 0 == (ltid & (warp_size - 1))) 
    {
        // double check to handle multiple shared mem accesses in one line
        if( last_ltid != 0) 
        {
            reset();
        }
    }

    AccessLocation loc( file, line, aname, ltid);
    AccessInfo info( ltid, tidx, tidy, tidz, index);
    access_data[loc][(index % warp_size)].push_back( info);

    if( 15 == (ltid & (warp_size - 1))) 
    {
        analyse( access_data. find( loc));
    }

    last_ltid = (ltid % warp_size);
}  
Example #7
0
void PRCExporter::analyse ( osg::Node *nd, prcfile *out )
{
	/// here you have found a group.
	osg::Geode *geode = dynamic_cast<osg::Geode *> ( nd );
	if ( geode )
	{
		// analyse the geode. If it isnt a geode the dynamic cast gives NULL.
		analyseGeode ( geode, out );
	}
	else
	{
		osg::Group *gp = dynamic_cast<osg::Group *> ( nd );
		if ( gp )
		{
//			osg::notify ( osg::WARN ) << "Group "<<  gp->getName() <<std::endl;
			for ( unsigned int ic=0; ic<gp->getNumChildren(); ic++ )
			{
				analyse ( gp->getChild ( ic ), out );
			}
		}
//		else
//		{
//			osg::notify ( osg::WARN ) << "Unknown node "<<  nd <<std::endl;
//		}
	}
}
Example #8
0
t_filter *init_filter(t_atoms *atoms, const char *fn, int natom_trx)
{
    t_filter *f;
    int       g, i;

    snew(f, 1);
    if (fn != NULL)
    {
        f->grps = init_index(fn, &f->grpnames);
    }
    else
    {
        snew(f->grps, 1);
        snew(f->grps->index, 1);
        analyse(atoms, f->grps, &f->grpnames, false, false);
    }
    snew(f->bDisable, f->grps->nr);
    for (g = 0; g < f->grps->nr; g++)
    {
        for (i = f->grps->index[g]; i < f->grps->index[g+1] && !f->bDisable[g]; i++)
        {
            f->bDisable[g] = (f->grps->a[i] >= natom_trx);
        }
    }

    snew(f->bShow, f->grps->nr);

    return f;
}
Example #9
0
File: nvc.c Project: rjbohnert/nvc
static int process_command(int argc, char **argv)
{
    static struct option long_options[] = {
        { "dump",    no_argument, 0, 'd' },
        { "codegen", no_argument, 0, 'c' },
        { "make",    no_argument, 0, 'm' },
        { 0, 0, 0, 0 }
    };

    opterr = 0;
    optind = 1;

    int index = 0;
    const char *spec = "aer";
    switch (getopt_long(MIN(argc, 2), argv, spec, long_options, &index)) {
    case 'a':
        return analyse(argc, argv);
    case 'e':
        return elaborate(argc, argv);
    case 'r':
        return run(argc, argv);
    case 'd':
        return dump_cmd(argc, argv);
    case 'c':
        return codegen(argc, argv);
    case 'm':
        return make_cmd(argc, argv);
    default:
        fatal("missing command, try %s --help for usage", PACKAGE);
        return EXIT_FAILURE;
    }
}
Example #10
0
void PRCExporter::analyse ( osg::Node *nd, oPRCFile *out )
{
	/// here you have found a group.
	osg::Geode *geode = dynamic_cast<osg::Geode *> ( nd );
	if ( geode )
	{
		// analyse the geode. If it isnt a geode the dynamic cast gives NULL.
		QString nam = QString::fromStdString(geode->getName());
		out->begingroup(nam.toLatin1());
		analyseGeode ( geode, out );
		out->endgroup();
	}
	else
	{
		osg::Group *gp = dynamic_cast<osg::Group *> ( nd );
		if ( gp )
		{
			QString nam = QString::fromStdString(gp->getName());
			out->begingroup(nam.toLatin1());
//			osg::notify ( osg::WARN ) << "Group "<<  gp->getName() <<std::endl;
			for ( unsigned int ic=0; ic<gp->getNumChildren(); ic++ )
			{
				analyse ( gp->getChild ( ic ), out );
			}
			out->endgroup();
		}
//		else
//		{
//			osg::notify ( osg::WARN ) << "Unknown node "<<  nd <<std::endl;
//		}
	}
}
Example #11
0
void *thread_function(void *index){
	// Thread index
	int tindex = *(int*)index;

	// Key and indexes
	AES_KEY key;
	uint8_t local_key[16];
	int i, i1, i2, i3, i4, i5;

	// Allocating text memory
	uint8_t *decrypted_text = talloc(uint8_t, LENGTH);

	// Defining cipher text and base key
	memcpy(local_key, PARTIAL_KEY, 11);

	// Defining indexes for this thread
	int begin, end;
	if(tindex == 0) begin = 33;
	else begin = 33 + (tindex * (94/NTHREADS)) + 3;
	if(tindex == NTHREADS-1) end = 126;
	else end = 33 + ((tindex+1) * (94/NTHREADS) + 2);

	// Verbosing about the range
	verbose("Thread #%d running in the range %d..%d.", tindex, begin, end);

	// Brute force
	for(i1=begin; i1<=end; i1++){
		local_key[11] = i1;
		for(i2=33; i2<=126; i2++){
			local_key[12] = i2;
			for(i3=33; i3<=126; i3++){
				local_key[13] = i3;
				for(i4=33; i4<=126; i4++){
					local_key[14] = i4;
					for(i5=33; i5<=126; i5++){
						local_key[15] = i5;
						AES_set_decrypt_key(local_key, KEYLEN, &key);
						AES_ECB_decrypt(cipher_text, decrypted_text, LENGTH, key.KEY, key.nr);
						if(analyse(decrypted_text)){
							verbose("Decrypted!");
							verbose("Thread #%d found the key.", tindex);
							printf(" - Key: ");
							for(i=0; i<KEYLEN/8; i++)
								printf("%c", local_key[i]);
							printf("\n");

							decrypt(&key, decrypted_text);
							exit(1);
						}
					}
				}
			}
		}
	}

	verbose("Thread #%d is done.", tindex);

	return;
}
Example #12
0
static void start(int* pT1, int* pT2, struct basicVal* pVal)
{
	int i;
	for (i = 1; i <= pVal->nbJ; i++)
	{
		if (i % 2 == 0)
			analyse(pT2, pT1, pVal);
		else
			analyse(pT1, pT2, pVal);

		if (pVal->nbS != 0 && i % pVal->nbS == 0)
			if (i % 2 == 0)
				output(pT1, pVal, i);
			else
				output(pT2, pVal, i);
	}
}
Example #13
0
/////////////////////////////////////////////////////////////////////////////
// TDrawView::CmECGClearAll()
//
// Responds to CM_ECGCLEARALL message generated by the menu item or button.
/////////////////////////////////////////////////////////////////////////////
void TDrawView::CmECGClearAll()
{
	const Tecg* ecg;
	ecg = DrawDoc->GetECG();
	TAnalyse_Clear_All analyse(ecg);
	analyse.Execute();
	DrawDoc->RePaintViews();
}
Example #14
0
void FrameAnalyser::analyseStack(string filename)
{
    ausgabe.open(filename.c_str(), ios::out);
    for (int var = myStack->size()-1; var > 0; var--) {
        analyse(myStack->getFrame(var));
    }
    ausgabe.close();
}
void PhotonAnalyser::analyse(const EventPtr event, PhotonCollection signalPhotons, JetCollection cleanJets, ElectronCollection signalElectrons, MuonCollection signalMuons){

	//all photons
	analyse(event);
	//signal photons
	analyse_signalPhotons(event, signalPhotons, cleanJets, signalElectrons, signalMuons);

}
/*!
 * \param[out] g     Index group structure.
 * \param[in]  top   Topology structure.
 * \param[in]  fnm   File name for the index file.
 *   Memory is automatically allocated.
 *
 * One or both of \p top or \p fnm can be NULL.
 * If \p top is NULL, an index file is required and the groups are read
 * from the file (uses Gromacs routine init_index()).
 * If \p fnm is NULL, default groups are constructed based on the
 * topology (uses Gromacs routine analyse()).
 * If both are null, the index group structure is initialized empty.
 */
void
gmx_ana_indexgrps_init(gmx_ana_indexgrps_t **g, t_topology *top,
                       const char *fnm)
{
    t_blocka *block = NULL;
    char    **names = NULL;

    if (fnm)
    {
        block = init_index(fnm, &names);
    }
    else if (top)
    {
        block = new_blocka();
        analyse(&top->atoms, block, &names, FALSE, FALSE);
    }
    else
    {
        *g = new gmx_ana_indexgrps_t(0);
        return;
    }

    try
    {
        *g = new gmx_ana_indexgrps_t(block->nr);
        for (int i = 0; i < block->nr; ++i)
        {
            gmx_ana_index_t *grp = &(*g)->g[i];

            grp->isize = block->index[i+1] - block->index[i];
            snew(grp->index, grp->isize);
            for (int j = 0; j < grp->isize; ++j)
            {
                grp->index[j] = block->a[block->index[i]+j];
            }
            grp->nalloc_index = grp->isize;
            (*g)->names.push_back(names[i]);
        }
    }
    catch (...)
    {
        for (int i = 0; i < block->nr; ++i)
        {
            sfree(names[i]);
        }
        sfree(names);
        done_blocka(block);
        sfree(block);
        throw;
    }
    for (int i = 0; i < block->nr; ++i)
    {
        sfree(names[i]);
    }
    sfree(names);
    done_blocka(block);
    sfree(block);
}
Example #17
0
File: guess.c Project: MrBadge/enca
/**
 * enca_analyse_const:
 * @analyser: An analyser initialized for some language.
 * @buffer: Buffer to be analysed.
 * @size: Size of @buffer.
 *
 * Analyses @buffer and finds its encoding.
 *
 * The @buffer is checked for 8bit encodings of language for which @analyser
 * was initialized and for multibyte encodings, mostly independent on language
 * (unless disabled with enca_set_multibyte()).
 *
 * This function never modifies @buffer (can be even used with string literal
 * @buffer) at the expense it's generally slower than enca_analyse().
 *
 * Returns: Encoding of @buffer.  When charset part of return value is
 *          #ENCA_CS_UNKNOWN, encoding was not determined.  Check
 *          enca_errno() for reason.
 **/
EncaEncoding
enca_analyse_const(EncaAnalyserState *analyser,
                   const unsigned char *buffer,
                   size_t size)
{
  assert(analyser != NULL);
  analyser->options.const_buffer = 1;
  return analyse(analyser, (unsigned char *)buffer, size);
}
Example #18
0
/////////////////////////////////////////////////////////////////////////////
// TDrawView::CmECGRThresh()
//
// Responds to CM_ECGRTHRESH message generated by the menu item or button.
/////////////////////////////////////////////////////////////////////////////
void TDrawView::CmECGRThresh()
{
	const Tecg* ecg;
	ecg = DrawDoc->GetECG();
	TAnalyse_R_Thresh analyse(ecg);
	analyse.Execute();
	//const_cast<Tecg*>(ecg)->AnalyseData(R_THRESH);
	DrawDoc->RePaintViews();
}
Example #19
0
/////////////////////////////////////////////////////////////////////////////
// TDrawView::CmECGRChange()
//
// Responds to CM_ECGRCHANGE message generated by the menu item or button.
/////////////////////////////////////////////////////////////////////////////
void TDrawView::CmECGRChange()
{
	const Tecg* ecg;
	ecg = DrawDoc->GetECG();
	TAnalyse_R_Change analyse(ecg);
	analyse.Execute();
  	//const_cast<Tecg*>(ecg)->AnalyseData(R_CHANGE);
	DrawDoc->RePaintViews();
}
Example #20
0
/////////////////////////////////////////////////////////////////////////////
// TDrawView::CmECGSCalc()
//
// Responds to CM_ECGSCALC message generated by the menu item or button.
/////////////////////////////////////////////////////////////////////////////
void TDrawView::CmECGSCalc()
{
	const Tecg* ecg;
	ecg = DrawDoc->GetECG();
	TAnalyse_S_Calc_1 analyse(ecg);
	analyse.Execute();
	//const_cast<Tecg*>(ecg)->AnalyseData(S_CALC_1);
	DrawDoc->RePaintViews();
}
Example #21
0
File: guess.c Project: MrBadge/enca
/**
 * enca_analyse:
 * @analyser: An analyser initialized for some language.
 * @buffer: Buffer to be analysed.
 * @size: Size of @buffer.
 *
 * Analyses @buffer and finds its encoding.
 *
 * The @buffer is checked for 8bit encodings of language for which @analyser
 * was initialized and for multibyte encodings, mostly independent on language
 * (unless disabled with enca_set_multibyte()).
 *
 * The contents of @buffer may be (and probably will be) modified during the
 * analyse.  Use enca_analyse_const() instead if this discomforts you.
 *
 * Returns: Encoding of @buffer.  When charset part of return value is
 *          #ENCA_CS_UNKNOWN, encoding was not determined.  Check
 *          enca_errno() for reason.
 **/
EncaEncoding
enca_analyse(EncaAnalyser analyser,
             unsigned char *buffer,
             size_t size)
{
  assert(analyser != NULL);
  analyser->options.const_buffer = 0;
  return analyse(analyser, buffer, size);
}
Example #22
0
/////////////////////////////////////////////////////////////////////////////
// TDrawView::CmECGQCalc2()
//
// Responds to CM_ECGQCALC2 message generated by the menu item or button.
/////////////////////////////////////////////////////////////////////////////
void TDrawView::CmECGQCalc2()
{
	const Tecg* ecg;
	ecg = DrawDoc->GetECG();
	TAnalyse_Q_Calc_2 analyse(ecg);
	analyse.Execute();
	//const_cast<Tecg*>(ecg)->AnalyseData(Q_CALC_2);
	DrawDoc->RePaintViews();
}
Example #23
0
/////////////////////////////////////////////////////////////////////////////
// TDrawView::CmECGGoodBad()
//
// Responds to CM_ECGGOODBAD message generated by the menu item or button.
/////////////////////////////////////////////////////////////////////////////
void TDrawView::CmECGGoodBad()
{
	const Tecg* ecg;
	ecg = DrawDoc->GetECG();
	TAnalyse_Good_Or_Bad analyse(ecg);
	analyse.Execute();
	//const_cast<Tecg*>(ecg)->AnalyseData(GOOD_OR_BAD_1);
	DrawDoc->RePaintViews();
}
Example #24
0
void ScopeConsistencyChecker::checkConsistent(IHqlExpression * root, const HqlExprArray & _activeTables)
{
    ForEachItemIn(i, _activeTables)
        activeTables.append(OLINK(_activeTables.item(i)));
    if (root->isDataset())
        pushScope();
    analyse(root, 0);
    if (root->isDataset())
        popScope();
}
Example #25
0
static COMMAND_FUNC( danal )
{
	Trial_Class *tcp;

	tcp = PICK_TRIAL_CLASS("");

	if( tcp == NULL ) return;
	if( no_data(QSP_ARG  "danal") ) return;

	analyse(QSP_ARG  tcp);
	longout(QSP_ARG  tcp);
}
Example #26
0
void PRCExporter::convertFile ( QString fileName, PageItem_OSGFrame *frame )
{
	if ( !fileName.isEmpty() )
	{
		if ( frame->loadedModel )
		{
			prcfile oPRC ( fileName.toStdString() );
			analyse ( frame->loadedModel.get(), &oPRC );
			oPRC.finish();
		}
	}
}
Example #27
0
Type ASTClosure::analyse(SemanticAnalyser *analyser, const TypeExpectation &expectation) {
    function_->setOwningType(analyser->function()->owningType());
    function_->setFunctionType(analyser->function()->functionType());

    auto closureAnalyser = SemanticAnalyser(function_, std::make_unique<CapturingSemanticScoper>(analyser->scoper()));
    closureAnalyser.analyse();
    captures_ = dynamic_cast<CapturingSemanticScoper&>(closureAnalyser.scoper()).captures();
    if (closureAnalyser.pathAnalyser().hasPotentially(PathAnalyserIncident::UsedSelf)) {
        captureSelf_ = true;
    }
    return function_->type();
}
Example #28
0
/////////////////////////////////////////////////////////////////////////////
// TDrawView::CmECGInvert()
//
// Responds to CM_ECGINVERT message generated by the menu item or button.
/////////////////////////////////////////////////////////////////////////////
void TDrawView::CmECGInvert()
{
	if ( MessageBox("Are you sure?", "Invert ECG", MB_YESNO) == IDYES)
	{
		const Tecg* ecg;
		ecg = DrawDoc->GetECG();
		TAnalyse_Invert analyse(ecg);
		analyse.Execute();
		//const_cast<Tecg*>(ecg)->AnalyseData(INVERT);
		DrawDoc->RePaintViews();
	}
}
Example #29
0
	void UnitManager::gather_all_build_data()
	{
		animsList.clear();
		VFS::Instance()->getDirlist("anims\\*", animsList);				// GAF-like directories
		VFS::Instance()->getFilelist("anims\\*.gaf", animsList);		// normal GAF files
		name2gaf.clear();

		// Cherche un fichier pouvant contenir des informations sur l'unité unit_name
		for (int i = 0; i < nb_unit; ++i)
		{
			String name;
			for(int n = 1 ; VFS::Instance()->fileExists(name = String(ta3dSideData.guis_dir) << unit_type[i]->Unitname << n << ".gui") ; ++n)
				analyse(name, i);
		}

		// Fill build menus with information parsed from the sidedata.tdf file
		TDFParser sidedata_parser(String(ta3dSideData.gamedata_dir) << "sidedata.tdf", false, true);
		for (int i = 0 ; i < nb_unit; ++i)
		{
			int n = 1;
			while(!sidedata_parser.pullAsString(ToLower(String("canbuild.") << unit_type[i]->Unitname << ".canbuild" << n ) ).empty())  n++;

			n--;
			String canbuild = sidedata_parser.pullAsString(ToLower(String("canbuild.") << unit_type[i]->Unitname << ".canbuild" << n ) );
			while (n > 0)
			{
				int idx = get_unit_index( canbuild );
				if (idx >= 0 && idx < nb_unit)
				{
					if (!unit_type[i]->canBuild(idx))		// Check if it's already in the list
					{
						GLuint tex = loadBuildPic( String("anims\\") << canbuild << "_gadget", canbuild);
						if (!tex && !unit_type[idx]->glpic && unit_type[idx]->unitpic)
						{
							unit_type[idx]->glpic = gfx->make_texture(unit_type[idx]->unitpic, FILTER_LINEAR, true);
							SDL_FreeSurface(unit_type[idx]->unitpic);
							unit_type[idx]->unitpic = NULL;
							gfx->set_texture_format(gfx->defaultTextureFormat_RGB());
						}
						if (unit_type[idx]->glpic || tex)
						{
							const int px = ((n - 1) & 1) * 64;
							const int py = 155 + (((n - 1) >> 1) % 3) * 64;
							const int p = (n - 1)  / 6;
							unit_type[i]->AddUnitBuild(idx, px, py, 64, 64, p, tex);
						}
						else
						{	LOG_DEBUG("unit '" << canbuild << "' picture not found in build menu for unit '" << unit_type[i]->Unitname << "'");	}
					}
				}
				else
				{	LOG_DEBUG("unit '" << canbuild << "' not found (" << __FILE__ << " l." << __LINE__ << ')');	}
Example #30
0
int swap_replica(int irep, int jrep) {

    Replica *prepi,*prepj;
    Slice *swaptrial, h;
    int i,pathlen,ABexchOK,ireptype,jreptype,type;
    //double  aux;

    prepi = replica[irep];
    prepj = replica[jrep];

    path.block_stats[path.initial_state-1][prepi->index].mcacc[1].tries++;

    if(path.fixedbias==0) {
        prepi->dos += state[path.initial_state-1].scalefactor;
    }
  
    if (jrep<0) {
        return 0;
    }

    if ( (irep==0) || (jrep==0) ) {
        return swap_replica_0(irep, jrep);
    }

    if (( irep==path.nreplica-1 ) && ( jrep==path.nreplica )) {
        return 0;
    }
    
    if ( jrep>path.nreplica-1 ) {
        return 0;
    }

    //aux = prepi->dos - prepj->dos;
 
    if ( RandomNumber() > exp(prepi->dos - prepj->dos) ) {
        return 0; 
    }
 
    type =analyse(slice, prepj, path.nslices, path.initial_state);
    if (type==0) {
        return 0;
    }

    prepj->pathlen =prepi->pathlen;
    prepj->type =  prepi->type;
    SWAP(replica[irep]->swapindex,replica[jrep]->swapindex,i);
    path.current_replica=jrep;

    path.block_stats[path.initial_state-1][prepi->index].mcacc[1].acc++;

    return 1;
}