| 1516 | VAR(groupvariables, 0, 4, 10); |
| 1517 | |
| 1518 | void writecfg() |
| 1519 | { |
| 1520 | filerotate("config/saved", "cfg", CONFIGROTATEMAX); // keep five old config sets |
| 1521 | stream *f = openfile(path("config/saved.cfg", true), "w"); |
| 1522 | if(!f) return; |
| 1523 | f->printf("// automatically written on exit, DO NOT MODIFY\n// delete this file to have defaults.cfg overwrite these settings\n// modify settings in game, or put settings in autoexec.cfg to override anything\n\n"); |
| 1524 | f->printf("// basic settings\n\n"); |
| 1525 | f->printf("name %s\n", escapestring(player1->name, false)); |
| 1526 | f->printf("skin_cla %d\nskin_rvsf %d\n", player1->skin(TEAM_CLA), player1->skin(TEAM_RVSF)); |
| 1527 | for(int i = CROSSHAIR_DEFAULT; i < CROSSHAIR_NUM; i++) if(crosshairs[i] && crosshairs[i] != notexture) |
| 1528 | { |
| 1529 | f->printf("loadcrosshair %s %s\n", crosshairnames[i], behindpath(crosshairs[i]->name)); |
| 1530 | } |
| 1531 | extern int lowfps, highfps; |
| 1532 | f->printf("fpsrange %d %d\n", lowfps, highfps); |
| 1533 | if(curfont && curfont->name) f->printf("setfont %s\n", curfont->name); |
| 1534 | f->printf("\n"); |
| 1535 | audiomgr.writesoundconfig(f); |
| 1536 | f->printf("\n"); |
| 1537 | f->printf("// crosshairs for each weapon\n\nlooplist [\n"); |
| 1538 | loopi(NUMGUNS) f->printf(" %-7s %s\n", gunnames[i], crosshairs[i] && crosshairs[i] != notexture ? behindpath(crosshairs[i]->name) : "\"\""); |
| 1539 | f->printf("] [ w cc ] [ loadcrosshair $w $cc ]\n"); |
| 1540 | f->printf("\n\n// client variables (unchanged default values %s)\n", omitunchangeddefaults ? "omitted" : "commented out"); |
| 1541 | vector<ident *> sids; |
| 1542 | enumerate(*idents, ident, id, |
| 1543 | if(id.persist) switch(id.type) |
| 1544 | { |
| 1545 | case ID_VAR: |
| 1546 | case ID_FVAR: |
| 1547 | case ID_SVAR: |
| 1548 | sids.add(&id); |
| 1549 | break; |
| 1550 | } |
| 1551 | ); |
| 1552 | sids.sort(sortident); |
| 1553 | const char *rep = ""; |
| 1554 | int repn = 0; |
| 1555 | bool lastdef = false, curdef; |
| 1556 | loopv(sids) |
| 1557 | { |
| 1558 | ident &id = *sids[i]; |
| 1559 | curdef = (id.type == ID_VAR && *id.storage.i == id.defaultval) || (id.type == ID_FVAR && *id.storage.f == id.defaultvalf); |
| 1560 | if(curdef && omitunchangeddefaults) continue; |
| 1561 | f->printf("%s", !strncmp(rep, id.name, curdef ? 1 : 3) && ++repn < groupvariables && lastdef == curdef ? " ; " : (repn = 0, "\n")); |
| 1562 | rep = id.name; |
| 1563 | lastdef = curdef; |
| 1564 | if(curdef && repn == 0) f->printf("// "); |
| 1565 | switch(id.type) |
| 1566 | { |
| 1567 | case ID_VAR: f->printf("%s %d", id.name, *id.storage.i); break; |
| 1568 | case ID_FVAR: f->printf("%s %s", id.name, floatstr(*id.storage.f)); break; |
| 1569 | case ID_SVAR: f->printf("%s %s", id.name, escapestring(*id.storage.s, false)); break; |
| 1570 | } |
| 1571 | if(!groupvariables) |
| 1572 | { |
| 1573 | if(id.type == ID_VAR) f->printf(" // min: %d, max: %d, def: %d", id.minval, id.maxval, id.defaultval); |
| 1574 | if(id.type == ID_FVAR) f->printf(" // min: %s, max: %s, def: %s", floatstr(id.minvalf), floatstr(id.maxvalf), floatstr(id.defaultvalf)); |
| 1575 | const char *doc = docgetdesc(id.name); |
no test coverage detected