diff options
author | Strangerke | 2011-06-29 16:15:41 +0200 |
---|---|---|
committer | Strangerke | 2011-06-29 16:15:41 +0200 |
commit | b0c9c9122fc678074aba30068e5b36d347208e65 (patch) | |
tree | 79a99db08ec985f2e5f1e216823b1104d5b753fb /engines/sword25/util | |
parent | f2f3124246a77036f843dee2d83ad28084234ebc (diff) | |
parent | c32a3ea0d30336771bab460ecccb58c4614e6294 (diff) | |
download | scummvm-rg350-b0c9c9122fc678074aba30068e5b36d347208e65.tar.gz scummvm-rg350-b0c9c9122fc678074aba30068e5b36d347208e65.tar.bz2 scummvm-rg350-b0c9c9122fc678074aba30068e5b36d347208e65.zip |
Merge branch 'master' of github.com:scummvm/scummvm into soltys_wip2
Diffstat (limited to 'engines/sword25/util')
-rw-r--r-- | engines/sword25/util/lua/lapi.cpp | 4 | ||||
-rw-r--r-- | engines/sword25/util/lua/lauxlib.cpp | 8 | ||||
-rw-r--r-- | engines/sword25/util/lua/ldblib.cpp | 2 | ||||
-rw-r--r-- | engines/sword25/util/lua/ldebug.cpp | 2 | ||||
-rw-r--r-- | engines/sword25/util/lua/ldo.cpp | 2 | ||||
-rw-r--r-- | engines/sword25/util/lua/lgc.cpp | 4 | ||||
-rw-r--r-- | engines/sword25/util/lua/liolib.cpp | 42 | ||||
-rw-r--r-- | engines/sword25/util/lua/llex.cpp | 2 | ||||
-rw-r--r-- | engines/sword25/util/lua/llimits.h | 4 | ||||
-rw-r--r-- | engines/sword25/util/lua/loadlib.cpp | 4 | ||||
-rw-r--r-- | engines/sword25/util/lua/lobject.h | 2 | ||||
-rw-r--r-- | engines/sword25/util/lua/lopcodes.h | 10 | ||||
-rw-r--r-- | engines/sword25/util/lua/lstate.cpp | 2 | ||||
-rw-r--r-- | engines/sword25/util/lua/lstrlib.cpp | 2 | ||||
-rw-r--r-- | engines/sword25/util/lua/ltable.cpp | 14 | ||||
-rw-r--r-- | engines/sword25/util/lua/lua.h | 2 | ||||
-rw-r--r-- | engines/sword25/util/lua/lualib.h | 2 | ||||
-rw-r--r-- | engines/sword25/util/lua/lvm.cpp | 4 | ||||
-rw-r--r-- | engines/sword25/util/lua/scummvm_file.cpp | 48 | ||||
-rw-r--r-- | engines/sword25/util/lua/scummvm_file.h | 1 |
20 files changed, 92 insertions, 69 deletions
diff --git a/engines/sword25/util/lua/lapi.cpp b/engines/sword25/util/lua/lapi.cpp index 16f8460e39..ff25cfc653 100644 --- a/engines/sword25/util/lua/lapi.cpp +++ b/engines/sword25/util/lua/lapi.cpp @@ -213,7 +213,7 @@ LUA_API void lua_replace (lua_State *L, int idx) { api_checkvalidindex(L, o); if (idx == LUA_ENVIRONINDEX) { Closure *func = curr_func(L); - api_check(L, ttistable(L->top - 1)); + api_check(L, ttistable(L->top - 1)); func->c.env = hvalue(L->top - 1); luaC_barrier(L, func, L->top - 1); } @@ -773,7 +773,7 @@ LUA_API int lua_setfenv (lua_State *L, int idx) { #define checkresults(L,na,nr) \ api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na))) - + LUA_API void lua_call (lua_State *L, int nargs, int nresults) { StkId func; diff --git a/engines/sword25/util/lua/lauxlib.cpp b/engines/sword25/util/lua/lauxlib.cpp index 8978cd5613..1261777315 100644 --- a/engines/sword25/util/lua/lauxlib.cpp +++ b/engines/sword25/util/lua/lauxlib.cpp @@ -570,13 +570,13 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { } c = lf.f->getc(); - if (c == '#') { // Unix exec. file? + if (c == '#') { // Unix exec. file? lf.extraline = 1; - while ((c = lf.f->getc()) != EOF && c != '\n') ; // skip first line + while ((c = lf.f->getc()) != EOF && c != '\n') ; // skip first line if (c == '\n') c = lf.f->getc(); } - if (c == LUA_SIGNATURE[0] && filename) { // binary file? - lf.f = freopen(filename, "rb", lf.f); // reopen in binary mode + if (c == LUA_SIGNATURE[0] && filename) { // binary file? + lf.f = freopen(filename, "rb", lf.f); // reopen in binary mode if (lf.f == NULL) return errfile(L, "reopen", fnameindex); // skip eventual `#!...' while ((c = lf.f->getc()) != EOF && c != LUA_SIGNATURE[0]) ; diff --git a/engines/sword25/util/lua/ldblib.cpp b/engines/sword25/util/lua/ldblib.cpp index 4d0333b46e..618e9a843f 100644 --- a/engines/sword25/util/lua/ldblib.cpp +++ b/engines/sword25/util/lua/ldblib.cpp @@ -142,7 +142,7 @@ static int db_getinfo (lua_State *L) { treatstackoption(L, L1, "func"); return 1; /* return table */ } - + static int db_getlocal (lua_State *L) { int arg; diff --git a/engines/sword25/util/lua/ldebug.cpp b/engines/sword25/util/lua/ldebug.cpp index 0b26522b31..85c492cc77 100644 --- a/engines/sword25/util/lua/ldebug.cpp +++ b/engines/sword25/util/lua/ldebug.cpp @@ -184,7 +184,7 @@ static void collectvalidlines (lua_State *L, Closure *f) { int i; for (i=0; i<f->l.p->sizelineinfo; i++) setbvalue(luaH_setnum(L, t, lineinfo[i]), 1); - sethvalue(L, L->top, t); + sethvalue(L, L->top, t); } incr_top(L); } diff --git a/engines/sword25/util/lua/ldo.cpp b/engines/sword25/util/lua/ldo.cpp index bbcdf98b3d..49e0881a45 100644 --- a/engines/sword25/util/lua/ldo.cpp +++ b/engines/sword25/util/lua/ldo.cpp @@ -384,7 +384,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) { ** The arguments are on the stack, right after the function. ** When returns, all the results are on the stack, starting at the original ** function position. -*/ +*/ void luaD_call (lua_State *L, StkId func, int nResults) { if (++L->nCcalls >= LUAI_MAXCCALLS) { if (L->nCcalls == LUAI_MAXCCALLS) diff --git a/engines/sword25/util/lua/lgc.cpp b/engines/sword25/util/lua/lgc.cpp index 52ff72bdc9..71e581ad30 100644 --- a/engines/sword25/util/lua/lgc.cpp +++ b/engines/sword25/util/lua/lgc.cpp @@ -310,7 +310,7 @@ static l_mem propagatemark (global_State *g) { traverseproto(g, p); return sizeof(Proto) + sizeof(Instruction) * p->sizecode + sizeof(Proto *) * p->sizep + - sizeof(TValue) * p->sizek + + sizeof(TValue) * p->sizek + sizeof(int) * p->sizelineinfo + sizeof(LocVar) * p->sizelocvars + sizeof(TString *) * p->sizeupvalues; @@ -697,7 +697,7 @@ void luaC_linkupval (lua_State *L, UpVal *uv) { GCObject *o = obj2gco(uv); o->gch.next = g->rootgc; /* link upvalue into `rootgc' list */ g->rootgc = o; - if (isgray(o)) { + if (isgray(o)) { if (g->gcstate == GCSpropagate) { gray2black(o); /* closed upvalues need barrier */ luaC_barrier(L, uv, uv->v); diff --git a/engines/sword25/util/lua/liolib.cpp b/engines/sword25/util/lua/liolib.cpp index b505d1e4df..6c00de5094 100644 --- a/engines/sword25/util/lua/liolib.cpp +++ b/engines/sword25/util/lua/liolib.cpp @@ -228,7 +228,7 @@ static int g_iofile (lua_State *L, int f, const char *mode) { } lua_rawseti(L, LUA_ENVIRONINDEX, f); } - // return current value + // return current value lua_rawgeti(L, LUA_ENVIRONINDEX, f); return 1; } @@ -315,7 +315,7 @@ static int read_line (lua_State *L, Sword25::Sword25FileProxy *f) { for (;;) { size_t l; char *p = luaL_prepbuffer(&b); - if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { // eof? + if (fgets(p, LUAL_BUFFERSIZE, f) == NULL) { // eof? luaL_pushresult(&b); // close buffer return (lua_objlen(L, -1) > 0); // check whether read something } @@ -332,19 +332,19 @@ static int read_line (lua_State *L, Sword25::Sword25FileProxy *f) { static int read_chars (lua_State *L, Sword25::Sword25FileProxy *f, size_t n) { - size_t rlen; // how much to read - size_t nr; // number of chars actually read + size_t rlen; // how much to read + size_t nr; // number of chars actually read luaL_Buffer b; luaL_buffinit(L, &b); - rlen = LUAL_BUFFERSIZE; // try to read that much each time + rlen = LUAL_BUFFERSIZE; // try to read that much each time do { char *p = luaL_prepbuffer(&b); - if (rlen > n) rlen = n; // cannot read more than asked + if (rlen > n) rlen = n; // cannot read more than asked nr = fread(p, sizeof(char), rlen, f); luaL_addsize(&b, nr); - n -= nr; // still have to read `n' chars - } while (n > 0 && nr == rlen); // until end of count or eof - luaL_pushresult(&b); // close buffer + n -= nr; // still have to read `n' chars + } while (n > 0 && nr == rlen); // until end of count or eof + luaL_pushresult(&b); // close buffer return (n == 0 || lua_objlen(L, -1) > 0); } @@ -354,11 +354,11 @@ static int g_read (lua_State *L, Sword25::Sword25FileProxy *f, int first) { int success; int n; clearerr(f); - if (nargs == 0) { // no arguments? + if (nargs == 0) { // no arguments? success = read_line(L, f); - n = first+1; // to return 1 result + n = first+1; // to return 1 result } - else { // ensure stack space for all results and for auxlib's buffer + else { // ensure stack space for all results and for auxlib's buffer luaL_checkstack(L, nargs+LUA_MINSTACK, "too many arguments"); success = 1; for (n = first; nargs-- && success; n++) { @@ -370,15 +370,15 @@ static int g_read (lua_State *L, Sword25::Sword25FileProxy *f, int first) { const char *p = lua_tostring(L, n); luaL_argcheck(L, p && p[0] == '*', n, "invalid option"); switch (p[1]) { - case 'n': // number + case 'n': // number success = read_number(L, f); break; - case 'l': // line + case 'l': // line success = read_line(L, f); break; - case 'a': // file - read_chars(L, f, ~((size_t)0)); // read MAX_SIZE_T chars - success = 1; // always success + case 'a': // file + read_chars(L, f, ~((size_t)0)); // read MAX_SIZE_T chars + success = 1; // always success break; default: return luaL_argerror(L, n, "invalid format"); @@ -389,8 +389,8 @@ static int g_read (lua_State *L, Sword25::Sword25FileProxy *f, int first) { if (ferror(f)) return pushresult(L, 0, NULL); if (!success) { - lua_pop(L, 1); // remove last result - lua_pushnil(L); // push nil instead + lua_pop(L, 1); // remove last result + lua_pushnil(L); // push nil instead } return n - first; } @@ -419,8 +419,8 @@ static int io_readline (lua_State *L) { if (ferror(f)) return luaL_error(L, "%s", "LUA I/O error descriptions have been removed in ScummVM"); if (sucess) return 1; - else { // EOF - if (lua_toboolean(L, lua_upvalueindex(2))) { // generator created file? + else { // EOF + if (lua_toboolean(L, lua_upvalueindex(2))) { // generator created file? lua_settop(L, 0); lua_pushvalue(L, lua_upvalueindex(1)); aux_close(L); // close it diff --git a/engines/sword25/util/lua/llex.cpp b/engines/sword25/util/lua/llex.cpp index 4d73a6a600..b456ee2dfe 100644 --- a/engines/sword25/util/lua/llex.cpp +++ b/engines/sword25/util/lua/llex.cpp @@ -188,7 +188,7 @@ static void trydecpoint (LexState *ls, SemInfo *seminfo) { sprintf(buf, "%.1f", 1.0); ls->decpoint = '.'; for (i = 0; buf[i]; i++) { - if (!isspace(buf[i]) && !isdigit(buf[i])) { + if (!isspace(static_cast<unsigned char>(buf[i])) && !isdigit(static_cast<unsigned char>(buf[i]))) { ls->decpoint = buf[i]; break; } diff --git a/engines/sword25/util/lua/llimits.h b/engines/sword25/util/lua/llimits.h index a31ad160ad..0925231350 100644 --- a/engines/sword25/util/lua/llimits.h +++ b/engines/sword25/util/lua/llimits.h @@ -107,7 +107,7 @@ typedef lu_int32 Instruction; #ifndef lua_lock -#define lua_lock(L) ((void) 0) +#define lua_lock(L) ((void) 0) #define lua_unlock(L) ((void) 0) #endif @@ -118,7 +118,7 @@ typedef lu_int32 Instruction; /* ** macro to control inclusion of some hard tests on stack reallocation -*/ +*/ #ifndef HARDSTACKTESTS #define condhardstacktests(x) ((void)0) #else diff --git a/engines/sword25/util/lua/loadlib.cpp b/engines/sword25/util/lua/loadlib.cpp index 9795a575f5..f4cdd70a78 100644 --- a/engines/sword25/util/lua/loadlib.cpp +++ b/engines/sword25/util/lua/loadlib.cpp @@ -182,7 +182,7 @@ static int ll_require (lua_State *L) { ** 'module' function ** ======================================================= */ - + static void setfenv (lua_State *L) { lua_Debug ar; @@ -298,7 +298,7 @@ LUALIB_API int luaopen_package (lua_State *L) { lua_setfield(L, -2, "__gc"); /* create `package' table */ luaL_register(L, LUA_LOADLIBNAME, pk_funcs); -#if defined(LUA_COMPAT_LOADLIB) +#if defined(LUA_COMPAT_LOADLIB) lua_getfield(L, -1, "loadlib"); lua_setfield(L, LUA_GLOBALSINDEX, "loadlib"); #endif diff --git a/engines/sword25/util/lua/lobject.h b/engines/sword25/util/lua/lobject.h index 35aaed028a..5418a918b1 100644 --- a/engines/sword25/util/lua/lobject.h +++ b/engines/sword25/util/lua/lobject.h @@ -337,7 +337,7 @@ typedef struct Node { typedef struct Table { CommonHeader; - lu_byte flags; /* 1<<p means tagmethod(p) is not present */ + lu_byte flags; /* 1<<p means tagmethod(p) is not present */ lu_byte lsizenode; /* log2 of size of `node' array */ struct Table *metatable; TValue *array; /* array part */ diff --git a/engines/sword25/util/lua/lopcodes.h b/engines/sword25/util/lua/lopcodes.h index e1aed0f637..2f850c4365 100644 --- a/engines/sword25/util/lua/lopcodes.h +++ b/engines/sword25/util/lua/lopcodes.h @@ -186,8 +186,8 @@ OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */ OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */ OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */ -OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ -OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ +OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ +OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ @@ -197,8 +197,8 @@ OP_FORLOOP,/* A sBx R(A)+=R(A+2); if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/ OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */ -OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); - if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */ +OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); + if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */ OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */ OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/ @@ -240,7 +240,7 @@ OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ ** bits 4-5: B arg mode ** bit 6: instruction set register A ** bit 7: operator is a test -*/ +*/ enum OpArgMask { OpArgN, /* argument is not used */ diff --git a/engines/sword25/util/lua/lstate.cpp b/engines/sword25/util/lua/lstate.cpp index 495d75c8a6..e542bcbacc 100644 --- a/engines/sword25/util/lua/lstate.cpp +++ b/engines/sword25/util/lua/lstate.cpp @@ -36,7 +36,7 @@ typedef struct LG { lua_State l; global_State g; } LG; - + static void stack_init (lua_State *L1, lua_State *L) { diff --git a/engines/sword25/util/lua/lstrlib.cpp b/engines/sword25/util/lua/lstrlib.cpp index e5501b9b49..2a1b8690e2 100644 --- a/engines/sword25/util/lua/lstrlib.cpp +++ b/engines/sword25/util/lua/lstrlib.cpp @@ -635,7 +635,7 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s, lua_pushlstring(L, s, e - s); /* keep original text */ } else if (!lua_isstring(L, -1)) - luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); + luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1)); luaL_addvalue(b); /* add result to accumulator */ } diff --git a/engines/sword25/util/lua/ltable.cpp b/engines/sword25/util/lua/ltable.cpp index b2ec0e912a..45381fe673 100644 --- a/engines/sword25/util/lua/ltable.cpp +++ b/engines/sword25/util/lua/ltable.cpp @@ -48,7 +48,7 @@ #define hashpow2(t,n) (gnode(t, lmod((n), sizenode(t)))) - + #define hashstr(t,str) hashpow2(t, (str)->tsv.hash) #define hashboolean(t,p) hashpow2(t, p) @@ -303,7 +303,7 @@ static void resize (lua_State *L, Table *t, int nasize, int nhsize) { if (nasize > oldasize) /* array part must grow? */ setarrayvector(L, t, nasize); /* create new hash part with appropriate size */ - setnodevector(L, t, nhsize); + setnodevector(L, t, nhsize); if (nasize < oldasize) { /* array part must shrink? */ t->sizearray = nasize; /* re-insert elements from vanishing slice */ @@ -392,11 +392,11 @@ static Node *getfreepos (Table *t) { /* -** inserts a new key into a hash table; first, check whether key's main -** position is free. If not, check whether colliding node is in its main -** position or not: if it is not, move colliding node to an empty place and -** put new key in its main position; otherwise (colliding node is in its main -** position), new key goes to an empty position. +** inserts a new key into a hash table; first, check whether key's main +** position is free. If not, check whether colliding node is in its main +** position or not: if it is not, move colliding node to an empty place and +** put new key in its main position; otherwise (colliding node is in its main +** position), new key goes to an empty position. */ static TValue *newkey (lua_State *L, Table *t, const TValue *key) { Node *mp = mainposition(t, key); diff --git a/engines/sword25/util/lua/lua.h b/engines/sword25/util/lua/lua.h index 417cdadf8b..08ad80d70f 100644 --- a/engines/sword25/util/lua/lua.h +++ b/engines/sword25/util/lua/lua.h @@ -247,7 +247,7 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); -/* +/* ** =============================================================== ** some useful macros ** =============================================================== diff --git a/engines/sword25/util/lua/lualib.h b/engines/sword25/util/lua/lualib.h index 33d4e314c2..830f6a0894 100644 --- a/engines/sword25/util/lua/lualib.h +++ b/engines/sword25/util/lua/lualib.h @@ -41,7 +41,7 @@ LUALIB_API int (luaopen_package) (lua_State *L); /* open all previous libraries */ -LUALIB_API void (luaL_openlibs) (lua_State *L); +LUALIB_API void (luaL_openlibs) (lua_State *L); diff --git a/engines/sword25/util/lua/lvm.cpp b/engines/sword25/util/lua/lvm.cpp index fb700c20a2..d0f2198651 100644 --- a/engines/sword25/util/lua/lvm.cpp +++ b/engines/sword25/util/lua/lvm.cpp @@ -125,7 +125,7 @@ void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) { callTMres(L, val, tm, t, key); return; } - t = tm; /* else repeat with `tm' */ + t = tm; /* else repeat with `tm' */ } luaG_runerror(L, "loop in gettable"); } @@ -152,7 +152,7 @@ void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) { callTM(L, tm, t, key, val); return; } - t = tm; /* else repeat with `tm' */ + t = tm; /* else repeat with `tm' */ } luaG_runerror(L, "loop in settable"); } diff --git a/engines/sword25/util/lua/scummvm_file.cpp b/engines/sword25/util/lua/scummvm_file.cpp index 3c0377d0ee..33053a71cb 100644 --- a/engines/sword25/util/lua/scummvm_file.cpp +++ b/engines/sword25/util/lua/scummvm_file.cpp @@ -32,11 +32,30 @@ Sword25FileProxy::Sword25FileProxy(const Common::String &filename, const Common: setupConfigFile(); } +Common::String Sword25FileProxy::formatDouble(double value) { + // This is a bit hackish. The point of it is that it's important that + // we ignore the locale decimal mark and force it to be a point. If it + // would happen to be a comma instead, it seems that it's seen as two + // comma-separated integers rather than one floating-point value. Or + // something like that. + + bool negative = value < 0.0; + value = fabs(value); + double integerPart = floor(value); + double fractionalPart = (value - integerPart) * 1000000.0; + + Common::String out = Common::String::format("%.0f.%.0f", integerPart, fractionalPart); + if (negative) + out = "-" + out; + + return out; +} + void Sword25FileProxy::setupConfigFile() { - double sfxVolume = ConfMan.hasKey("sfx_volume") ? 1.0 : 1.0 * ConfMan.getInt("sfx_volume") / 255.0; - double musicVolume = ConfMan.hasKey("music_volume") ? 0.5 : 1.0 * ConfMan.getInt("music_volume") / 255.0; - double speechVolume = ConfMan.hasKey("speech_volume") ? 1.0 : 1.0 * ConfMan.getInt("speech_volume") / 255.0; - bool subtitles = ConfMan.hasKey("subtitles") ? true : ConfMan.getBool("subtitles"); + double sfxVolume = !ConfMan.hasKey("sfx_volume") ? 1.0 : 1.0 * ConfMan.getInt("sfx_volume") / 255.0; + double musicVolume = !ConfMan.hasKey("music_volume") ? 0.5 : 1.0 * ConfMan.getInt("music_volume") / 255.0; + double speechVolume = !ConfMan.hasKey("speech_volume") ? 1.0 : 1.0 * ConfMan.getInt("speech_volume") / 255.0; + bool subtitles = !ConfMan.hasKey("subtitles") ? true : ConfMan.getBool("subtitles"); _readData = Common::String::format( "GAME_LANGUAGE = \"%s\"\r\n\ @@ -45,10 +64,13 @@ MAX_MEMORY_USAGE = 256000000\r\n\ GFX_VSYNC_ACTIVE = true\r\n\ SFX_SAMPLING_RATE = 44100\r\n\ SFX_CHANNEL_COUNT = 32\r\n\ -SFX_SOUND_VOLUME = %f\r\n\ -SFX_MUSIC_VOLUME = %f\r\n\ -SFX_SPEECH_VOLUME = %f\r\n", - getLanguage().c_str(), subtitles ? "true" : "false", sfxVolume, musicVolume, speechVolume); +SFX_SOUND_VOLUME = %s\r\n\ +SFX_MUSIC_VOLUME = %s\r\n\ +SFX_SPEECH_VOLUME = %s\r\n", + getLanguage().c_str(), subtitles ? "true" : "false", + formatDouble(sfxVolume).c_str(), + formatDouble(musicVolume).c_str(), + formatDouble(speechVolume).c_str()); _readPos = 0; } @@ -76,14 +98,14 @@ size_t Sword25FileProxy::write(const char *ptr, size_t count) { // Legitimate data const char *p = strchr(ptr, '\n'); if (!p) p = ptr + strlen(ptr); - while ((*p == '\r') || (*p == '\n')) + while ((*p == '\r') || (*p == '\n')) ++p; _settings += Common::String(ptr, p - ptr); ptr = p; } - while ((*ptr == '\r') || (*ptr == '\n')) + while ((*ptr == '\r') || (*ptr == '\n')) ++ptr; } @@ -97,7 +119,7 @@ void Sword25FileProxy::writeSettings() { if ((*pSrc != '\r') && (*pSrc != '\n')) { const char *p = strchr(pSrc, '='); assert(p); - + // Get the setting name const char *pEnd = p - 1; while (*pEnd == ' ') @@ -110,10 +132,10 @@ void Sword25FileProxy::writeSettings() { ++pStart; pEnd = pStart + 1; - while ((*pEnd != '\r') && (*pEnd != '\n') && (*pEnd != '\0')) + while ((*pEnd != '\r') && (*pEnd != '\n') && (*pEnd != '\0')) ++pEnd; Common::String value(pStart + (*pStart == '"' ? 1 : 0), pEnd - pStart - (*pStart == '"' ? 2 : 0)); - + // Update the setting updateSetting(settingName, value); pSrc = pEnd; diff --git a/engines/sword25/util/lua/scummvm_file.h b/engines/sword25/util/lua/scummvm_file.h index a4cbd2a6cf..e8c468ee07 100644 --- a/engines/sword25/util/lua/scummvm_file.h +++ b/engines/sword25/util/lua/scummvm_file.h @@ -37,6 +37,7 @@ private: uint _readPos; Common::String _settings; + Common::String formatDouble(double value); void setupConfigFile(); Common::String getLanguage(); void setLanguage(const Common::String &lang); |