Esempio n. 1
0
int ParserManager::SaveConfigs()
{
    std::cout << "Saving configs to 'options.ini' ..." << std::flush;

    CSimpleIni ini(false, false, false);

    if (!std::ifstream(game.CH_CONFIG_FILE.c_str()))
    {
        std::ifstream o_file(game.CH_CONFIG_FILE.c_str());
        o_file.close();
    }

    ini.LoadFile(game.CH_CONFIG_FILE.c_str());

    ini.SetLongValue("info", "Version", game.CONFIG_VERSION, NULL);

    ini.SetLongValue("global", "Mode",                  static_cast<int>(MODE),   NULL);
    ini.SetValue(    "global", "SoldatPath",            RepairPath(SOLDAT_PATH).c_str(),       NULL);
    ini.SetValue(    "global", "SoldatInterface",       INTERFACE_NAME_[0].c_str(), NULL);
//    ini.SetValue(    "global", "CruelHessianPath",      RepairPath(GAME_PATH_[1]).c_str(),       NULL);
    ini.SetValue(    "global", "CruelHessianInterface", INTERFACE_NAME_[1].c_str(), NULL);
    ini.SetBoolValue("global", "Fullscreen",       FULLSCREEN,                   NULL);
    ini.SetLongValue("global", "MaxWidth",         static_cast<int>(MAX_WIDTH),  NULL);
    ini.SetLongValue("global", "MaxHeight",        static_cast<int>(MAX_HEIGHT), NULL);
    ini.SetLongValue("global", "MaxDeep",          MAX_BPP,                      NULL);
    ini.SetLongValue("global", "SoundVolume",      static_cast<int>(SOUNDS_VOL), NULL);
    ini.SetLongValue("global", "MusicVolume",      static_cast<int>(MUSIC_VOL),  NULL);
    ini.SetLongValue("global", "AudioQuality",     AUDIO_QUAL,                   NULL);

    ini.SetValue("player", "Name",       PLAYER_NAME.c_str(),                  NULL);
    // fix SkinColor !!!!!!
    //ini.SetValue("player", "SkinColor",  game.rgb2tcolor(COLOR_SKIN).c_str(),  NULL);
    ini.SetValue("player", "SkinColor",  COLOR_SKIN_NAME.c_str(),  NULL);
    ini.SetValue("player", "ShirtColor", COLOR_SHIRT_NAME.c_str(), NULL);
    ini.SetValue("player", "HairColor",  COLOR_HAIR_NAME.c_str(),  NULL);
    ini.SetValue("player", "PantsColor", COLOR_PANTS_NAME.c_str(), NULL);
    ini.SetValue("player", "JetColor",   COLOR_JET_NAME.c_str(),   NULL);

    ini.SetLongValue("game", "TeammatchLimit",    LIMIT_TEAMMATCH,                 NULL);
    ini.SetLongValue("game", "DeathmatchLimit",   LIMIT_DEATHMATCH,                NULL);
    ini.SetLongValue("game", "PointmatchLimit",   LIMIT_POINTMATCH,                NULL);
    ini.SetLongValue("game", "RambomatchLimit",   LIMIT_RAMBOMATCH,                NULL);
    ini.SetLongValue("game", "InfiltrationLimit", LIMIT_INFILTRATION,              NULL);
    ini.SetLongValue("game", "HoldLimit",         LIMIT_HOLD,                      NULL);
    ini.SetLongValue("game", "CaptureLimit",      LIMIT_CAPTURE,                   NULL);
    ini.SetLongValue("game", "TimeLimit",         static_cast<int>(LIMIT_TIME/60), NULL);

    ini.SetLongValue("game", "RandomBots",  RANDOM_BOTS,   NULL);
    ini.SetLongValue("game", "RandomBots1", RANDOM_BOTS_1, NULL);
    ini.SetLongValue("game", "RandomBots2", RANDOM_BOTS_2, NULL);
    ini.SetLongValue("game", "RandomBots3", RANDOM_BOTS_3, NULL);
    ini.SetLongValue("game", "RandomBots4", RANDOM_BOTS_4, NULL);

    ini.SetLongValue("game", "MaxGrenades", MAX_GRENADES, NULL);

    ini.SetBoolValue("game", "ConsoleShow", CONSOLE_SHOW, NULL);
    ini.SetBoolValue("game", "Weapon1",  WEAPON[0], NULL);
    ini.SetBoolValue("game", "Weapon2",  WEAPON[1], NULL);
    ini.SetBoolValue("game", "Weapon3",  WEAPON[2], NULL);
    ini.SetBoolValue("game", "Weapon4",  WEAPON[3], NULL);
    ini.SetBoolValue("game", "Weapon5",  WEAPON[4], NULL);
    ini.SetBoolValue("game", "Weapon6",  WEAPON[5], NULL);
    ini.SetBoolValue("game", "Weapon7",  WEAPON[6], NULL);
    ini.SetBoolValue("game", "Weapon8",  WEAPON[7], NULL);
    ini.SetBoolValue("game", "Weapon9",  WEAPON[8], NULL);
    ini.SetBoolValue("game", "Weapon10", WEAPON[9], NULL);
    ini.SetBoolValue("game", "Weapon11", WEAPON[10], NULL);
    ini.SetBoolValue("game", "Weapon12", WEAPON[11], NULL);
    ini.SetBoolValue("game", "Weapon13", WEAPON[12], NULL);
    ini.SetBoolValue("game", "Weapon14", WEAPON[13], NULL);

    ini.SetBoolValue("game", "BonusBerserker", BONUSES[0], NULL);
    ini.SetBoolValue("game", "BonusCluster",   BONUSES[1], NULL);
    ini.SetBoolValue("game", "BonusFlameGod",  BONUSES[3], NULL);
    ini.SetBoolValue("game", "BonusPredator",  BONUSES[5], NULL);
    ini.SetBoolValue("game", "BonusVest",      BONUSES[6], NULL);

    ini.SetLongValue("controls", "Left",     KEY_LEFT,     NULL);
    ini.SetLongValue("controls", "Right",    KEY_RIGHT,    NULL);
    ini.SetLongValue("controls", "Jump",     KEY_UP,       NULL);
    ini.SetLongValue("controls", "Crouch",   KEY_DOWN,     NULL);
    ini.SetLongValue("controls", "Reload",   KEY_RELOAD,   NULL);
    ini.SetLongValue("controls", "Grenade",  KEY_GRENADE,  NULL);
    ini.SetLongValue("controls", "Chat",     KEY_CHAT,     NULL);
    ini.SetLongValue("controls", "TeamChat", KEY_TEAMCHAT, NULL);
    ini.SetLongValue("controls", "Change",   KEY_CHANGE,   NULL);
    ini.SetLongValue("controls", "Drop",     KEY_DROP,     NULL);

    ini.SaveFile(game.CH_CONFIG_FILE.c_str());

    std::cout << " DONE" << std::endl;

    return 0;
}
Esempio n. 2
0
void pfDetails::Update(ProjectBuildTarget* target, ProjectFile* pf)
{
    wxString sep = wxFILE_SEP_PATH;
    wxFileName tmp;

    wxFileName prjbase(target->GetParentProject()->GetBasePath());

    wxString objOut = target ? target->GetObjectOutput() : _T(".");
    wxString depsOut = target ? target->GetDepsOutput() : _T(".");

    // we must replace any macros here early because if the macros expand
    // to absolute paths (like global vars usually do), we 're gonna create
    // invalid filenames below
    Manager::Get()->GetMacrosManager()->ReplaceMacros(objOut, target);
    Manager::Get()->GetMacrosManager()->ReplaceMacros(depsOut, target);
    source_file_native = pf->relativeFilename;
    source_file_absolute_native = pf->file.GetFullPath();

    tmp = pf->GetObjName();
    FileType ft = FileTypeOf(pf->relativeFilename);

    Compiler* compiler = target
                            ? CompilerFactory::GetCompiler(target->GetCompilerID())
                            : CompilerFactory::GetDefaultCompiler();

    // support for precompiled headers
    if (target && ft == ftHeader && compiler && compiler->GetSwitches().supportsPCH)
    {
        switch (target->GetParentProject()->GetModeForPCH())
        {
            case pchSourceDir:
            {
                // if PCH is for a file called all.h, we create
                // all.h.gch/<target>_all.h.gch
                // (that's right: a directory)
                wxString new_gch = target->GetTitle() + _T('_') + pf->GetObjName();
                // make sure we 're not generating subdirs
                size_t len = new_gch.Length();
                for (size_t i = 0; i < len; ++i)
                {
                    wxChar c = new_gch[i];
                    if (c == _T('/') || c == _T('\\') || c == _T('.'))
                        new_gch[i] = _T('_');
                }

                wxFileName fn(source_file_native);
                object_file_native = fn.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR) +
                                    fn.GetName() + _T('.') + compiler->GetSwitches().PCHExtension +
                                    wxFILE_SEP_PATH +
                                    new_gch;
                object_file_flat_native = object_file_native;
                break;
            }

            case pchObjectDir:
            {
                object_file_native = objOut + sep + tmp.GetFullPath();
                object_file_flat_native = objOut + sep + tmp.GetFullName();
                break;
            }

            case pchSourceFile:
            {
                object_file_native = pf->GetObjName();
                object_file_flat_native = object_file_native;
                break;
            }
        }
    }
    else
    {
        if (pf->GetParentProject())
        {
            wxFileName fname(pf->relativeToCommonTopLevelPath);
            if (pf->generatedFiles.size())
            {
                // for files generating other files,
                // use the first generated file's "object name"
                fname.Assign(pf->generatedFiles[0]->relativeToCommonTopLevelPath);
            }
            /* NOTE: In case the source file resides in a different volume
            * than the volume where project file is,
            * then the object file will be created as follows.
            *
            * Project object output dir: C:\Foo\obj\Debug
            * Source: D:\Source\foo.cpp
            * Obj file: C:\Foo\obj\Debug\D\Source\foo.o
            */
            wxString fileVol = fname.GetVolume();
            wxString obj_file_full_path = fname.GetFullPath();
            bool diffVolume = false;

            if (platform::windows
                && (!fileVol.IsEmpty() && !fileVol.IsSameAs(prjbase.GetVolume())))
            {
                objOut += fileVol;
                obj_file_full_path = obj_file_full_path.AfterFirst(_T('\\'));
                diffVolume = true;
            }

            if (ft == ftResource || ft == ftResourceBin)
            {
                if (pf->GetParentProject()->GetExtendedObjectNamesGeneration())
                {
                    object_file_native = objOut + sep + obj_file_full_path;
                    object_file_flat_native = objOut + sep + fname.GetFullName();

                    object_file_native += FileFilters::RESOURCEBIN_DOT_EXT;
                    object_file_flat_native += FileFilters::RESOURCEBIN_DOT_EXT;
                }
                else
                {
                    fname.SetExt(FileFilters::RESOURCEBIN_EXT);
                    wxString obj_file_path = fname.GetFullPath();
                    if (diffVolume)
                        obj_file_path = obj_file_path.AfterFirst(_T('\\'));
                    object_file_native = objOut + sep + obj_file_path;
                    object_file_flat_native = objOut + sep + fname.GetFullName();
                }
            }
            else
            {
                if (pf->GetParentProject()->GetExtendedObjectNamesGeneration())
                {
                    object_file_native = objOut + sep + obj_file_full_path;
                    object_file_flat_native = objOut + sep + fname.GetFullName();

                    if (compiler)
                    {
                        object_file_native += _T('.') + compiler->GetSwitches().objectExtension;
                        object_file_flat_native += _T('.') + compiler->GetSwitches().objectExtension;
                    }
                }
                else
                {
                    if (compiler)
                        fname.SetExt(compiler->GetSwitches().objectExtension);
                    wxString obj_file_path = fname.GetFullPath();
                    if (diffVolume)
                        obj_file_path = obj_file_path.AfterFirst(_T('\\'));
                    object_file_native = objOut + sep + obj_file_path;
                    object_file_flat_native = objOut + sep + fname.GetFullName();
                }
            }
        }
    }
    wxFileName o_file(object_file_native);
    wxFileName o_file_flat(object_file_flat_native);
    o_file.MakeAbsolute(prjbase.GetFullPath());
    o_file_flat.MakeAbsolute(prjbase.GetFullPath());
    object_dir_native = o_file.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
    object_dir_flat_native = o_file_flat.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
    object_file_absolute_native = o_file.GetFullPath();
    object_file_flat_absolute_native = o_file_flat.GetFullPath();
    tmp.SetExt(_T("depend"));
    dep_file_native = depsOut + sep + tmp.GetFullPath();
    wxFileName d_file(dep_file_native);
    d_file.MakeAbsolute(prjbase.GetFullPath());
    dep_dir_native = d_file.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR);
    dep_file_absolute_native = o_file.GetFullPath();

    source_file = UnixFilename(source_file_native);
    QuoteStringIfNeeded(source_file);

    object_file = UnixFilename(object_file_native);
    QuoteStringIfNeeded(object_file);

    object_file_flat = UnixFilename(object_file_flat_native);
    QuoteStringIfNeeded(object_file_flat);

    dep_file = UnixFilename(dep_file_native);
    QuoteStringIfNeeded(dep_file);

    object_dir = UnixFilename(object_dir_native);
    QuoteStringIfNeeded(object_dir);

    object_dir_flat = UnixFilename(object_dir_flat_native);
    QuoteStringIfNeeded(object_dir_flat);

    dep_dir = UnixFilename(dep_dir_native);
    QuoteStringIfNeeded(dep_dir);

    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(object_file_native);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(object_file_flat_native);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(object_dir_native);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(object_dir_flat_native);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(object_file_absolute_native);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(object_file_flat_absolute_native);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(dep_file_native);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(dep_dir_native);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(dep_file_absolute_native);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(dep_dir);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(object_dir);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(object_dir_flat);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(dep_file);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(object_file);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(object_file_flat);
    Manager::Get()->GetMacrosManager()->ReplaceEnvVars(source_file);
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
	float *a, *b, *c;
	gmactime_t s, t;
	ecl::error err;

	assert(ecl::compileSource(kernel) == eclSuccess);

	float * orig = (float *) malloc(vecSize * sizeof(float));
	std::ifstream o_file(VECTORC);
	o_file.read((char *)orig, vecSize * sizeof(float));
	o_file.close();

	getTime(&s);
	// Alloc & init input data
	assert(ecl::malloc((void **)&a, vecSize * sizeof(float)) == eclSuccess);
	assert(ecl::malloc((void **)&b, vecSize * sizeof(float)) == eclSuccess);
	assert(ecl::malloc((void **)&c, vecSize * sizeof(float)) == eclSuccess);
	getTime(&t);
	printTime(&s, &t, "Alloc: ", "\n");

	std::ifstream a_file(VECTORA);
	std::ifstream b_file(VECTORB);

	getTime(&s);
	a_file.read((char *)a, vecSize * sizeof(float));
	a_file.close();
	b_file.read((char *)b, vecSize * sizeof(float));
	b_file.close();
	getTime(&t);
	printTime(&s, &t, "Init: ", "\n");

	// Call the kernel
	getTime(&s);
	ecl::config localSize (blockSize);
	ecl::config globalSize (vecSize / blockSize);
	if(vecSize % blockSize) globalSize.x++;
	globalSize.x *= localSize.x;

	ecl::kernel kernel("vecAdd", err);
	assert(err == eclSuccess);
#ifndef __GXX_EXPERIMENTAL_CXX0X__
	err = kernel.setArg(0, c);
	assert(err == eclSuccess);
	err = kernel.setArg(1, a);
	assert(err == eclSuccess);
	err = kernel.setArg(2, b);
	assert(err == eclSuccess);
	err = kernel.setArg(3, vecSize);
	assert(err == eclSuccess);
	err = kernel.callNDRange(globalSize, localSize);
	assert(err == eclSuccess);
#else
	assert(kernel(c, a, b, vecSize)(globalSize, localSize) == eclSuccess);
#endif
	getTime(&t);
	printTime(&s, &t, "Run: ", "\n");

	getTime(&s);
	float error = 0.f;
	for(unsigned i = 0; i < vecSize; i++) {
		error += orig[i] - (c[i]);
	}
	getTime(&t);
	printTime(&s, &t, "Check: ", "\n");

	getTime(&s);
	std::ofstream c_file("vectorC_shared");
	c_file.write((char *)c, vecSize * sizeof(float));
	c_file.close();
	getTime(&t);
	printTime(&s, &t, "Write: ", "\n");

	getTime(&s);
	ecl::free(a);
	ecl::free(b);
	ecl::free(c);
	getTime(&t);
	printTime(&s, &t, "Free: ", "\n");

	return error != 0;
}