예제 #1
0
void writeinitcfg()
{
    stream *f = openutf8file("init.cfg", "w");
    if(!f) return;
    f->printf("// automatically written on exit, DO NOT MODIFY\n// modify settings in game\n");
    extern int fullscreen;
    f->printf("fullscreen %d\n", fullscreen);
    f->printf("scr_w %d\n", scr_w);
    f->printf("scr_h %d\n", scr_h);
    f->printf("colorbits %d\n", colorbits);
    f->printf("depthbits %d\n", depthbits);
    f->printf("stencilbits %d\n", stencilbits);
    f->printf("fsaa %d\n", fsaa);
    f->printf("vsync %d\n", vsync);
    extern int useshaders, shaderprecision, forceglsl;
    f->printf("shaders %d\n", useshaders);
    f->printf("shaderprecision %d\n", shaderprecision);
    f->printf("forceglsl %d\n", forceglsl);
    extern int soundmono, soundchans, soundbufferlen, soundfreq;
    f->printf("soundmono %d\n", soundmono);
    f->printf("soundchans %d\n", soundchans);
    f->printf("soundbufferlen %d\n", soundbufferlen);
    f->printf("soundfreq %d\n", soundfreq);
    f->printf("verbose %d\n", verbose);
    delete f;
}
예제 #2
0
void init()
{
#ifndef ENABLE_IPS
    return;
#endif //!ENABLE_IPS

    execfile(CFG_FILE, false);
    log = openutf8file(LOG_FILE, "ab");

    if (!log)
        conoutf(CON_WARN, "couldn't open %s for writing", LOG_FILE);
}
예제 #3
0
파일: main.cpp 프로젝트: rspeele/tersafari
void writeinitcfg()
{
    stream *f = openutf8file("init.cfg", "w");
    if(!f) return;
    f->printf("// automatically written on exit, DO NOT MODIFY\n// modify settings in game\n");
    extern int fullscreen;
    f->printf("fullscreen %d\n", fullscreen);
    f->printf("scr_w %d\n", scr_w);
    f->printf("scr_h %d\n", scr_h);
    extern int sound, soundchans, soundfreq, soundbufferlen;
    f->printf("sound %d\n", sound);
    f->printf("soundchans %d\n", soundchans);
    f->printf("soundfreq %d\n", soundfreq);
    f->printf("soundbufferlen %d\n", soundbufferlen);
    delete f;
}
예제 #4
0
void deinit()
{
#ifndef ENABLE_IPS
    return;
#endif //!ENABLE_IPS

    vector<network::ipaddr<ipignore*>* > ipaddresses;
    ips.getallips(ipaddresses);

    stream *f = openutf8file(CFG_FILE, "wb");

    if (!f)
    {
        conoutf(CON_WARN, "couldn't open %s for writing", CFG_FILE);

        if (log)
            delete log;

        return;
    }

    f->printf("// automatically written on exit\n");

    loopv(ipaddresses)
    {
        auto ipaddr = ipaddresses[i];
        string ipstr;
        ipignore *ipignoredata = (ipignore*)ipaddr->data;
        strtool buf1, buf2;

        ipaddr->ip.print(ipstr);
        f->printf("ipignore %s %s %u %d\n",
                  escapecubescriptstring(ipstr, buf1),
                  escapecubescriptstring(ipignoredata->reason, buf2),
                  ipignoredata->hits, (int)ipignoredata->lasthit);
    }

    delete f;

    if (log)
        delete log;
}
예제 #5
0
파일: main.cpp 프로젝트: Blarget2/OF-Engine
void writeinitcfg()
{
    stream *f = openutf8file("init.lua", "w");
    if(!f) return;
    f->printf("-- automatically written on exit, DO NOT MODIFY\n-- modify settings in game\n");
    extern int fullscreen, shaderprecision, glineardepth, sound, soundchans, soundfreq, soundbufferlen;
    f->printf("EVAR.fullscreen = %d\n", fullscreen);
    f->printf("EVAR.scr_w = %d\n", scr_w);
    f->printf("EVAR.scr_h = %d\n", scr_h);
    f->printf("EVAR.colorbits = %d\n", colorbits);
    f->printf("EVAR.depthbits = %d\n", depthbits);
    f->printf("EVAR.stencilbits = %d\n", stencilbits);
    f->printf("EVAR.fsaa = %d\n", fsaa);
    f->printf("EVAR.vsync = %d\n", vsync);
    f->printf("EVAR.shaderprecision = %d\n", shaderprecision);
    f->printf("EVAR.glineardepth = %d\n", glineardepth);
    f->printf("EVAR.sound = %d\n", sound);
    f->printf("EVAR.soundchans = %d\n", soundchans);
    f->printf("EVAR.soundfreq = %d\n", soundfreq);
    f->printf("EVAR.soundbufferlen = %d\n", soundbufferlen);
    delete f;
}
예제 #6
0
    void writecfg(const char *name)
    {
        stream *f = openutf8file(path(name && name[0] ? name : game::savedconfig(), true), "w");
        if(!f) return;

        f->printf("-- automatically written on exit, DO NOT MODIFY\n");
        f->printf("-- delete this file to have %s overwrite these settings\n", game::defaultconfig());
        f->printf("-- modify settings in game, or put settings in %s to override anything\n\n", game::autoexec());
        f->printf("-- configuration file version\n");
        f->printf("if OF_CFG_VERSION ~= %i then return nil end\n\n", OF_CFG_VERSION);
        f->printf("-- engine variables\n");

        for (varsys::Variable_Map::cit it = varsys::variables->begin(); it != varsys::variables->end(); ++it)
        {
            varsys::Variable *v = it->second;
            /* do not write aliases here! */
            if ((v->flags()&varsys::FLAG_ALIAS)   != 0) continue;
            if ((v->flags()&varsys::FLAG_PERSIST) != 0) switch (v->type())
            {
                case varsys::TYPE_I: f->printf("EVAR.%s = %d\n", v->name(), varsys::get_int(v)); break;
                case varsys::TYPE_F: f->printf("EVAR.%s = %f\n", v->name(), varsys::get_float(v)); break;
                case varsys::TYPE_S:
                {
                    const char *str = varsys::get_string(v);
                    if (!str) continue;
                    f->printf("EVAR.%s = \"", v->name());
                    size_t len = strlen(str);
                    for (size_t sz = 0; sz < len; ++sz)
                    {
                        switch (str[sz])
                        {
                            case '\n': f->write("^n", 2); break;
                            case '\t': f->write("^t", 2); break;
                            case '\f': f->write("^f", 2); break;
                            case '"': f->write("^\"", 2); break;
                            default: f->putchar(str[sz]); break;
                        }
                    }
                    f->printf("\"\n");
                    break;
                }
            }
        }
        f->printf("\n");
        f->printf("-- binds\n");
        writebinds(f);
        f->printf("\n");

        f->printf("-- aliases\n");
        f->printf("local was_persisting = var.persist_vars(true)\n");
        for (varsys::Variable_Map::cit it = varsys::variables->begin(); it != varsys::variables->end(); ++it)
        {
            varsys::Variable *v = it->second;
            if ((v->flags()&varsys::FLAG_ALIAS) != 0 && (v->flags()&varsys::FLAG_PERSIST) != 0) switch (v->type())
            {
                case varsys::TYPE_I: f->printf("var.new(\"%s\", EAPI.VAR_I, %d)\n", v->name(), varsys::get_int(v)); break;
                case varsys::TYPE_F: f->printf("var.new(\"%s\", EAPI.VAR_F, %f)\n", v->name(), varsys::get_float(v)); break;
                case varsys::TYPE_S:
                {
                    const char *str = varsys::get_string(v);
                    if (strstr(v->name(), "new_entity_gui_field") || !str) continue;
                    f->printf("var.new(\"%s\", EAPI.VAR_S, \"", v->name());
                    size_t len = strlen(str);
                    for (size_t sz = 0; sz < len; ++sz)
                    {
                        switch (str[sz])
                        {
                            case '\n': f->write("^n", 2); break;
                            case '\t': f->write("^t", 2); break;
                            case '\f': f->write("^f", 2); break;
                            case '"': f->write("^\"", 2); break;
                            default: f->putchar(str[sz]); break;
                        }
                    }
                    f->printf("\")\n");
                    break;
                }
            }
        }
        f->printf("var.persist_vars(was_persisting)\n");
        f->printf("\nOF_CFG_VERSION_PASSED = true\n");
        delete f;
    }