Exemple #1
0
//---------------------------------------------------------------------------
// TVPInitializeBaseSystems
//---------------------------------------------------------------------------
void TVPInitializeBaseSystems()
{
	// set system archive delimiter
	tTJSVariant v;
	if(TVPGetCommandLine(TJS_W("-arcdelim"), &v))
		TVPArchiveDelimiter = ttstr(v)[0];

	// set default current directory
	{
		char drive[MAXDRIVE];
		char dir[MAXDIR];
		fnsplit(_argv[0], drive, dir, NULL, NULL);
		ttstr curdir(ttstr(drive)  + ttstr(dir));
		if(curdir.GetLastChar() != TJS_W('\\')) curdir += TJS_W('\\');
		TVPSetCurrentDirectory(curdir);
	}

	// load message map file
	bool load_msgmap = GetSystemSecurityOption("disablemsgmap") == 0;

	if(load_msgmap)
	{
		const tjs_char name_msgmap [] = TJS_W("msgmap.tjs");
		if(TVPIsExistentStorage(name_msgmap))
			TVPExecuteStorage(name_msgmap, NULL, false, TJS_W(""));
	}
}
Exemple #2
0
static int spawn_daemon(void) {
	char statd_path[SMALL_BUF];
	char *dir;
	pid_t childpid;

	if ((childpid = fork()) == -1){
		perror("fork");
		return -1;
	}

	if (childpid == 0){

		//send SIGHUP to us when parent dies
		if (prctl(PR_SET_PDEATHSIG, SIGHUP) < 0){ //Linux only
			perror("setting up daemon deathsig");
		}

		dir = curdir();
		snprintf(statd_path, SMALL_BUF, "%s/statd",dir);
		free(dir);

		execlp(statd_path,statd_path,NULL);
		exit(0);
	} else {
		return 0;
	}
}
Exemple #3
0
int CTestApplication::Run(void)
{
    const CArgs & args (GetArgs());

    if(args["mklds"]) {

        // create LDS DB and exit
        string fa_dir (args["mklds"].AsString());
        if(! CDirEntry::IsAbsolutePath(fa_dir)) {
            string curdir  (CDir::GetCwd());
            const char sep (CDirEntry::GetPathSeparator());
            const size_t curdirsize (curdir.size());
            if(curdirsize && curdir[curdirsize-1] != sep) {
                curdir += sep;
            }
            fa_dir = curdir + fa_dir;
        }
        const string lds_db_dir (GetLdsDbDir(fa_dir));
        CLDS_Manager ldsmgr (fa_dir, lds_db_dir, kSplignLdsDb);
        ldsmgr.Index(CLDS_Manager::eRecurseSubDirs,
                     CLDS_Manager::eNoControlSum);
        return 0;
    }
    
    // use LDS DB
    CRef<CObjectManager> objmgr (CObjectManager::GetInstance());

    const string fasta_dir (args["ldsdir"].AsString());
    const string ldsdb_dir (GetLdsDbDir(fasta_dir));
    CLDS_Database* ldsdb (new CLDS_Database(ldsdb_dir, kSplignLdsDb));
    ldsdb->Open();
    CLDS_DataLoader::RegisterInObjectManager(*objmgr, *ldsdb,
                                             CObjectManager::eDefault);
    CRef<CScope> scope(new CScope(*objmgr));
    scope->AddDefaults();

    for (size_t n = 1; n <= args.GetNExtra(); ++n) {
        CSeq_id seqid1 (args[n].AsString());
        cout << "The length of " << seqid1.GetSeqIdString() << " is:\t"
            << sequence::GetLength(seqid1, scope.GetNonNullPointer())
            << endl;
    }

    return 0;
}
Exemple #4
0
Fichier : eo.c Projet : linehan/eo
/**
 * eo_init 
 * ```````
 * Initialize a pump in the current working directory.
 * 
 * Returns nothing.
 */
void eo_init(void)
{
        struct pumpconfig_t config;
        unsigned long salt;
        char hex[65];

        if (is_pump(ENV.cwd)) 
                bye("pump exists");

        make_pump(ENV.cwd);

        salt = mt_random();
        sha256gen(hex, &salt);

        slcpy(config.name, curdir(), LINESIZE);
        slcpy(config.desc, "Default description", LINESIZE);
        slcpy(config.base, scwd(), LINESIZE);
        slcpy(config.sha2, hex, LINESIZE);
        slcpy(config.link, "/foo/bar/bazscript.qux", LINESIZE);
        slcpy(config.wait, "0", LINESIZE);

        write_config(&config, ENV.config);
}
Exemple #5
0
void Ant::step(float deltaTime)
{
    if ((this->dest - this->pos).Length() < dlen * 0.1f)
    {
#if 0
        int dx = rand() % (dMaxlen * 2 + 1) - dMaxlen;
        int dy = rand() % (dMaxlen * 2 + 1) - dMaxlen;
        if (dx > 0) dx += (int)dlen; else dx -= (int)dlen;
        if (dy > 0) dy += (int)dlen; else dy -= (int)dlen;
        this->dest = hgeVector(pos.x + dx, pos.y + dy);
#else
        int x = int((pos.x - border.left) / dlen + 0.5) * dlen + border.left;
        int y = int((pos.y - border.top) / dlen + 0.5) * dlen + border.top;
        hgeVector curDestPos = this->carryCake ? MainGameState::GetInstance()->getAntLairPos() : MainGameState::GetInstance()->getCakePos();
        //curDestPos.x > x
        if (rand() % 3)
        {
            int r = rand() % 3;
            if (r & 1)
            {
                if (curDestPos.x > x)
                    x += dlen;
                else if (curDestPos.x < x)
                    x -= dlen;
            }
            if (r & 2)
            {
                if (curDestPos.y > y)
                    y += dlen;
                else if (curDestPos.y < y)
                    y -= dlen;
            }
        }
        else
        {
            int r = rand() % 8;
            if (r >= 4) r ++;
            if (r % 3 == 0)
                x -= dlen;
            else if (r % 3 == 2)
                x += dlen;
            if (r / 3 == 0)
                y -= dlen;
            else if (r / 3 == 2)
                y += dlen;
        }
        this->dest = hgeVector(x, y);
#endif
        if (this->dest.x < border.left)
            this->dest.x = border.left;
        if (this->dest.x > border.right)
            this->dest.x = border.right;
        if (this->dest.y < border.top)
            this->dest.y = border.top;
        if (this->dest.y > border.bottom)
            this->dest.y = border.bottom;
    }

    if (this->carryCake)
    {
        // Óе°¸â£¬ËÍ»ØÒÏѨ
        if (MainGameState::GetInstance()->putCake(this->pos))
        {
            this->carryCake = false;
        }
    }
    else
    {
        // È¡µÃµ°¸â
        if (MainGameState::GetInstance()->getCake(this->pos))
        {
            this->carryCake = true;
            this->hp = min(this->getMaxHp(), this->getMaxHp() / 2 + this->hp);
        }
    }

    hgeVector curdir(0, -1);
    hgeVector oldPos = this->pos; 
    curdir.Rotate(this->angle);
    hgeVector destdir = *(this->dest - this->pos).Normalize();
    float offangle = curdir.Angle(&destdir);
    if (curdir.x * destdir.y - curdir.y * destdir.x < 0)
        offangle = -offangle;
    this->angle += offangle * 0.05f;
    this->pos += 60 * deltaTime * curdir * this->getSpeed() * min(1, 0.1 / abs(offangle));// * (1 - 2 * sqrt(abs(offangle)));

    if (this->pos.x < border.left)
        this->pos.x = border.left;
    if (this->pos.x > border.right)
        this->pos.x = border.right;
    if (this->pos.y < border.top)
        this->pos.y = border.top;
    if (this->pos.y > border.bottom)
        this->pos.y = border.bottom;

    this->moveMeter += (oldPos - this->pos).Length();
    this->applyDamageEffect();
}