diff options
Diffstat (limited to 'engines')
91 files changed, 1193 insertions, 465 deletions
diff --git a/engines/pegasus/neighborhood/mars/mars.cpp b/engines/pegasus/neighborhood/mars/mars.cpp index 8510abc92c..34c9e3d0f8 100644 --- a/engines/pegasus/neighborhood/mars/mars.cpp +++ b/engines/pegasus/neighborhood/mars/mars.cpp @@ -128,6 +128,8 @@ void Mars::init() { _explosionCallBack.setNotification(&_neighborhoodNotification); _explosionCallBack.setCallBackFlag(kExplosionFinishedFlag); + + _weaponSelection = kNoWeapon; } void Mars::flushGameState() { diff --git a/engines/pegasus/neighborhood/mars/mars.h b/engines/pegasus/neighborhood/mars/mars.h index 9ca53a8021..0859522890 100644 --- a/engines/pegasus/neighborhood/mars/mars.h +++ b/engines/pegasus/neighborhood/mars/mars.h @@ -64,7 +64,7 @@ enum ShuttleWeaponSelection { }; class Mars : public Neighborhood { -friend class MarsTimerEvent; +friend struct MarsTimerEvent; public: Mars(InputHandler *, PegasusEngine *); virtual ~Mars(); diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 1889d53480..5ae8245e5a 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -2882,17 +2882,17 @@ bool Console::cmdDisassemble(int argc, const char **argv) { reg_t addr = NULL_REG; if (!obj) { - DebugPrintf("Not an object."); + DebugPrintf("Not an object.\n"); return true; } if (selectorId < 0) { - DebugPrintf("Not a valid selector name."); + DebugPrintf("Not a valid selector name.\n"); return true; } if (lookupSelector(_engine->_gamestate->_segMan, objAddr, selectorId, NULL, &addr) != kSelectorMethod) { - DebugPrintf("Not a method."); + DebugPrintf("Not a method.\n"); return true; } diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 002ef1ff07..4061795f82 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -31,6 +31,9 @@ #include "common/debug-channels.h" #include "common/list.h" #include "common/system.h" +#include "common/math.h" + +//#define DEBUG_MERGEPOLY namespace Sci { @@ -71,11 +74,25 @@ enum { struct FloatPoint { FloatPoint() : x(0), y(0) {} FloatPoint(float x_, float y_) : x(x_), y(y_) {} + FloatPoint(Common::Point p) : x(p.x), y(p.y) {} Common::Point toPoint() { return Common::Point((int16)(x + 0.5), (int16)(y + 0.5)); } + float operator*(const FloatPoint &p) const { + return x*p.x + y*p.y; + } + FloatPoint operator*(float l) const { + return FloatPoint(l*x, l*y); + } + FloatPoint operator-(const FloatPoint &p) const { + return FloatPoint(x-p.x, y-p.y); + } + float norm() const { + return x*x+y*y; + } + float x, y; }; @@ -135,15 +152,20 @@ public: return _head; } - void insertHead(Vertex *elm) { + void insertAtEnd(Vertex *elm) { if (_head == NULL) { elm->_next = elm->_prev = elm; + _head = elm; } else { elm->_next = _head; elm->_prev = _head->_prev; _head->_prev = elm; elm->_prev->_next = elm; } + } + + void insertHead(Vertex *elm) { + insertAtEnd(elm); _head = elm; } @@ -788,10 +810,10 @@ int PathfindingState::findNearPoint(const Common::Point &p, Polygon *polygon, Co * including the vertices themselves) * Parameters: (const Common::Point &) a, b: The line segment (a, b) * (Vertex *) vertex: The first vertex of the edge - * Returns : (int) FP_OK on success, PF_ERROR otherwise + * Returns : (int) PF_OK on success, PF_ERROR otherwise * (FloatPoint) *ret: The intersection point */ -static int intersection(const Common::Point &a, const Common::Point &b, Vertex *vertex, FloatPoint *ret) { +static int intersection(const Common::Point &a, const Common::Point &b, const Vertex *vertex, FloatPoint *ret) { // Parameters of parametric equations float s, t; // Numerator and denominator of equations @@ -1783,39 +1805,619 @@ reg_t kIntersections(EngineState *s, int argc, reg_t *argv) { } } +// ========================================================================== +// kMergePoly utility functions + +// Compute square of the distance of p to the segment a-b. +static float pointSegDistance(const Common::Point &a, const Common::Point &b, + const Common::Point &p) { + FloatPoint ba(b-a); + FloatPoint pa(p-a); + FloatPoint bp(b-p); + + // Check if the projection of p on the line a-b lies between a and b + if (ba*pa >= 0.0f && ba*bp >= 0.0f) { + // If yes, return the (squared) distance of p to the line a-b: + // translate a to origin, project p and subtract + float linedist = (ba*((ba*pa)/(ba*ba)) - pa).norm(); + + return linedist; + } else { + // If no, return the (squared) distance to either a or b, whichever + // is closest. + + // distance to a: + float adist = pa.norm(); + // distance to b: + float bdist = FloatPoint(p-b).norm(); + + return MIN(adist, bdist); + } +} + +// find intersection between edges of two polygons. +// endpoints count, except v2->_next +static bool segSegIntersect(const Vertex *v1, const Vertex *v2, Common::Point &intp) { + const Common::Point &a = v1->v; + const Common::Point &b = v1->_next->v; + const Common::Point &c = v2->v; + const Common::Point &d = v2->_next->v; + + // First handle the endpoint cases manually + + if (collinear(a, b, c) && collinear(a, b, d)) + return false; + + if (collinear(a, b, c)) { + // a, b, c collinear + // return true/c if c is between a and b + intp = c; + if (a.x != b.x) { + if ((a.x <= c.x && c.x <= b.x) || (b.x <= c.x && c.x <= a.x)) + return true; + } else { + if ((a.y <= c.y && c.y <= b.y) || (b.y <= c.y && c.y <= a.y)) + return true; + } + } + + if (collinear(a, b, d)) { + intp = d; + // a, b, d collinear + // return false/d if d is between a and b + if (a.x != b.x) { + if ((a.x <= d.x && d.x <= b.x) || (b.x <= d.x && d.x <= a.x)) + return false; + } else { + if ((a.y <= d.y && d.y <= b.y) || (b.y <= d.y && d.y <= a.y)) + return false; + } + } + + int len_dc = c.sqrDist(d); + + if (!len_dc) error("zero length edge in polygon"); + + if (pointSegDistance(c, d, a) <= 2.0f) { + intp = a; + return true; + } + + if (pointSegDistance(c, d, b) <= 2.0f) { + intp = b; + return true; + } + + // If not an endpoint, call the generic intersection function + + FloatPoint p; + if (intersection(a, b, v2, &p) == PF_OK) { + intp = p.toPoint(); + return true; + } else { + return false; + } +} + +// For intersecting polygon segments, determine if +// * the v2 edge enters polygon 1 at this intersection: positive return value +// * the v2 edge and the v1 edges are parallel: zero return value +// * the v2 edge exits polygon 1 at this intersection: negative return value +static int intersectDir(const Vertex *v1, const Vertex *v2) { + Common::Point p1 = v1->_next->v - v1->v; + Common::Point p2 = v2->_next->v - v2->v; + return (p1.x*p2.y - p2.x*p1.y); +} + +// Direction of edge in degrees from pos. x-axis, between -180 and 180 +static int edgeDir(const Vertex *v) { + Common::Point p = v->_next->v - v->v; + int deg = (int)Common::rad2deg(atan2((double)p.y, (double)p.x)); + if (deg < -180) deg += 360; + if (deg > 180) deg -= 360; + return deg; +} + +// For points p1, p2 on the polygon segment v, determine if +// * p1 lies before p2: negative return value +// * p1 and p2 are the same: zero return value +// * p1 lies after p2: positive return value +static int liesBefore(const Vertex *v, const Common::Point &p1, const Common::Point &p2) { + return v->v.sqrDist(p1) - v->v.sqrDist(p2); +} + +// Structure describing an "extension" to the work polygon following edges +// of the polygon being merged. + +// The patch begins on the point intersection1, being the intersection +// of the edges starting at indexw1/vertexw1 on the work polygon, and at +// indexp1/vertexp1 on the polygon being merged. +// It ends with the point intersection2, being the analogous intersection. +struct Patch { + unsigned int indexw1; + unsigned int indexp1; + const Vertex *vertexw1; + const Vertex *vertexp1; + Common::Point intersection1; + + unsigned int indexw2; + unsigned int indexp2; + const Vertex *vertexw2; + const Vertex *vertexp2; + Common::Point intersection2; + + bool disabled; // If true, this Patch was made superfluous by another Patch +}; + + +// Check if the given vertex on the work polygon is bypassed by this patch. +static bool isVertexCovered(const Patch &p, unsigned int wi) { + + // / v (outside) + // ---w1--1----p----w2--2---- + // ^ \ (inside) + if (wi > p.indexw1 && wi <= p.indexw2) + return true; + + // v / (outside) + // ---w2--2----p----w1--1---- + // \ ^ (inside) + if (p.indexw1 > p.indexw2 && (wi <= p.indexw2 || wi > p.indexw1)) + return true; + + // v / (outside) + // ---w1--2--1-------p----- + // w2 \ ^ (inside) + if (p.indexw1 == p.indexw2 && liesBefore(p.vertexw1, p.intersection1, p.intersection2) > 0) + return true; // This patch actually covers _all_ vertices on work + + return false; +} + +// Check if patch p1 makes patch p2 superfluous. +static bool isPatchCovered(const Patch &p1, const Patch &p2) { + + // Same exit and entry points + if (p1.intersection1 == p2.intersection1 && p1.intersection2 == p2.intersection2) + return true; + + // / * v (outside) + // ---p1w1--1----p2w1-1---p1w2--2---- + // ^ * \ (inside) + if (p1.indexw1 < p2.indexw1 && p2.indexw1 < p1.indexw2) + return true; + if (p1.indexw1 > p1.indexw2 && (p2.indexw1 > p1.indexw1 || p2.indexw1 < p1.indexw2)) + return true; + + + // / * v (outside) + // ---p1w1--11----p2w2-2---p1w2--12---- + // ^ * \ (inside) + if (p1.indexw1 < p2.indexw2 && p2.indexw2 < p1.indexw2) + return true; + if (p1.indexw1 > p1.indexw2 && (p2.indexw2 > p1.indexw1 || p2.indexw2 < p1.indexw2)) + return true; + + // Opposite of two above situations + if (p2.indexw1 < p1.indexw1 && p1.indexw1 < p2.indexw2) + return false; + if (p2.indexw1 > p2.indexw2 && (p1.indexw1 > p2.indexw1 || p1.indexw1 < p2.indexw2)) + return false; + + if (p2.indexw1 < p1.indexw2 && p1.indexw2 < p2.indexw2) + return false; + if (p2.indexw1 > p2.indexw2 && (p1.indexw2 > p2.indexw1 || p1.indexw2 < p2.indexw2)) + return false; + + + // The above checks covered the cases where one patch covers the other and + // the intersections of the patches are on different edges. + + // So, if we passed the above checks, we have to check the order of + // intersections on edges. + + + if (p1.indexw1 != p1.indexw2) { + + // / * v (outside) + // ---p1w1--11---21--------p1w2--2---- + // p2w1 ^ * \ (inside) + if (p1.indexw1 == p2.indexw1) + return (liesBefore(p1.vertexw1, p1.intersection1, p2.intersection1) < 0); + + // / * v (outside) + // ---p1w1--11---------p1w2--21---12---- + // ^ p2w1 * \ (inside) + if (p1.indexw2 == p2.indexw1) + return (liesBefore(p1.vertexw2, p1.intersection2, p2.intersection1) > 0); + + // If neither of the above, then the intervals of the polygon + // covered by patch1 and patch2 are disjoint + return false; + } + + // p1w1 == p1w2 + // Also, p1w1/p1w2 isn't strictly between p2 + + + // v / * (outside) + // ---p1w1--12--11-------p2w1-21---- + // p1w2 \ ^ * (inside) + + // v / / (outside) + // ---p1w1--12--21--11--------- + // p1w2 \ ^ ^ (inside) + // p2w1 + if (liesBefore(p1.vertexw1, p1.intersection1, p1.intersection2) > 0) + return (p1.indexw1 != p2.indexw1); + + // CHECKME: This is meaningless if p2w1 != p2w2 ?? + if (liesBefore(p2.vertexw1, p2.intersection1, p2.intersection2) > 0) + return false; + + // CHECKME: This is meaningless if p1w1 != p2w1 ?? + if (liesBefore(p2.vertexw1, p2.intersection1, p1.intersection1) <= 0) + return false; + + // CHECKME: This is meaningless if p1w2 != p2w1 ?? + if (liesBefore(p2.vertexw1, p2.intersection1, p1.intersection2) >= 0) + return false; + + return true; +} + +// Merge a single polygon into the work polygon. +// If there is an intersection between work and polygon, this function +// returns true, and replaces the vertex list of work by an extended version, +// that covers polygon. +// +// NOTE: The strategy used matches qfg1new closely, and is a bit error-prone. +// A more robust strategy would be inserting all intersection points directly +// into both vertex lists as a first pass. This would make finding the merged +// polygon a much more straightforward edge-walk, and avoid cases where SSCI's +// algorithm mixes up the order of multiple intersections on a single edge. +bool mergeSinglePolygon(Polygon &work, const Polygon &polygon) { +#ifdef DEBUG_MERGEPOLY + const Vertex *vertex; + debugN("work:"); + CLIST_FOREACH(vertex, &(work.vertices)) { + debugN(" (%d,%d) ", vertex->v.x, vertex->v.y); + } + debugN("\n"); + debugN("poly:"); + CLIST_FOREACH(vertex, &(polygon.vertices)) { + debugN(" (%d,%d) ", vertex->v.x, vertex->v.y); + } + debugN("\n"); +#endif + uint workSize = work.vertices.size(); + uint polygonSize = polygon.vertices.size(); + + int patchCount = 0; + Patch patchList[8]; + + const Vertex *workv = work.vertices._head; + const Vertex *polyv = polygon.vertices._head; + for (uint wi = 0; wi < workSize; ++wi, workv = workv->_next) { + for (uint pi = 0; pi < polygonSize; ++pi, polyv = polyv->_next) { + Common::Point intersection1; + Common::Point intersection2; + + bool intersects = segSegIntersect(workv, polyv, intersection1); + if (!intersects) + continue; + +#ifdef DEBUG_MERGEPOLY + debug("mergePoly: intersection at work %d, poly %d", wi, pi); +#endif + + if (intersectDir(workv, polyv) >= 0) + continue; + +#ifdef DEBUG_MERGEPOLY + debug("mergePoly: intersection in right direction"); +#endif + + int angle = 0; + int baseAngle = edgeDir(workv); + + // We now found the point where an edge of 'polygon' left 'work'. + // Now find the re-entry point. + + // NOTE: The order in which this searches does not always work + // properly if the correct patch would only use a single partial + // edge of poly. Because it starts at polyv->_next, it will skip + // the correct re-entry and proceed to the next. + + const Vertex *workv2; + const Vertex *polyv2 = polyv->_next; + + intersects = false; + + uint pi2, wi2; + for (pi2 = 0; pi2 < polygonSize; ++pi2, polyv2 = polyv2->_next) { + + int newAngle = edgeDir(polyv2); + + int relAngle = newAngle - baseAngle; + if (relAngle > 180) relAngle -= 360; + if (relAngle < -180) relAngle += 360; + + angle += relAngle; + baseAngle = newAngle; + + workv2 = workv; + for (wi2 = 0; wi2 < workSize; ++wi2, workv2 = workv2->_next) { + intersects = segSegIntersect(workv2, polyv2, intersection2); + if (!intersects) + continue; +#ifdef DEBUG_MERGEPOLY + debug("mergePoly: re-entry intersection at work %d, poly %d", (wi + wi2) % workSize, (pi + 1 + pi2) % polygonSize); +#endif + + if (intersectDir(workv2, polyv2) > 0) { +#ifdef DEBUG_MERGEPOLY + debug("mergePoly: re-entry intersection in right direction, angle = %d", angle); +#endif + break; // found re-entry point + } + + } + + if (intersects) + break; + + } + + if (!intersects || angle < 0) + continue; + + + if (patchCount >= 8) + error("kMergePoly: Too many patches"); + + // convert relative to absolute vertex indices + pi2 = (pi + 1 + pi2) % polygonSize; + wi2 = (wi + wi2) % workSize; + + Patch &newPatch = patchList[patchCount]; + newPatch.indexw1 = wi; + newPatch.vertexw1 = workv; + newPatch.indexp1 = pi; + newPatch.vertexp1 = polyv; + newPatch.intersection1 = intersection1; + + newPatch.indexw2 = wi2; + newPatch.vertexw2 = workv2; + newPatch.indexp2 = pi2; + newPatch.vertexp2 = polyv2; + newPatch.intersection2 = intersection2; + newPatch.disabled = false; + +#ifdef DEBUG_MERGEPOLY + debug("mergePoly: adding patch at work %d, poly %d", wi, pi); +#endif + + if (patchCount == 0) { + patchCount++; + continue; + } + + bool necessary = true; + for (int i = 0; i < patchCount; ++i) { + if (isPatchCovered(patchList[i], newPatch)) { + necessary = false; + break; + } + } + + if (!necessary) + continue; + + patchCount++; + + if (patchCount > 1) { + // check if this patch makes other patches superfluous + for (int i = 0; i < patchCount-1; ++i) + if (isPatchCovered(newPatch, patchList[i])) + patchList[i].disabled = true; + } + } + } + + + if (patchCount == 0) + return false; // nothing changed + + + // Determine merged work by doing a walk over the edges + // of work, crossing over to polygon when encountering a patch. + + Polygon output(0); + + workv = work.vertices._head; + for (uint wi = 0; wi < workSize; ++wi, workv = workv->_next) { + + bool covered = false; + for (int p = 0; p < patchCount; ++p) { + if (patchList[p].disabled) continue; + if (isVertexCovered(patchList[p], wi)) { + covered = true; + break; + } + } + + if (!covered) { + // Add vertex to output + output.vertices.insertAtEnd(new Vertex(workv->v)); + } + + + // CHECKME: Why is this the correct order in which to process + // the patches? (What if two of them start on this line segment + // in the opposite order?) + + for (int p = 0; p < patchCount; ++p) { + + const Patch &patch = patchList[p]; + if (patch.disabled) continue; + if (patch.indexw1 != wi) continue; + if (patch.intersection1 != workv->v) { + // Add intersection point to output + output.vertices.insertAtEnd(new Vertex(patch.intersection1)); + } + + // Add vertices from polygon between vertexp1 (excl) and vertexp2 (incl) + for (polyv = patch.vertexp1->_next; polyv != patch.vertexp2; polyv = polyv->_next) + output.vertices.insertAtEnd(new Vertex(polyv->v)); + + output.vertices.insertAtEnd(new Vertex(patch.vertexp2->v)); + + if (patch.intersection2 != patch.vertexp2->v) { + // Add intersection point to output + output.vertices.insertAtEnd(new Vertex(patch.intersection2)); + } + + // TODO: We could continue after the re-entry point here? + } + } + // Remove last vertex if it's the same as the first vertex + if (output.vertices._head->v == output.vertices._head->_prev->v) + output.vertices.remove(output.vertices._head->_prev); + + + // Slight hack: swap vertex lists of output and work polygons. + SWAP(output.vertices._head, work.vertices._head); + + return true; +} + + /** * This is a quite rare kernel function. An example of when it's called * is in QFG1VGA, after killing any monster. + * + * It takes a polygon, and extends it to also cover any polygons from the + * input list with which it intersects. Any of those polygons so covered + * from the input list are marked by adding 0x10 to their type field. */ reg_t kMergePoly(EngineState *s, int argc, reg_t *argv) { -#if 0 // 3 parameters: raw polygon data, polygon list, list size reg_t polygonData = argv[0]; List *list = s->_segMan->lookupList(argv[1]); - Node *node = s->_segMan->lookupNode(list->first); - // List size is not needed - Polygon *polygon; - int count = 0; + // The size of the "work" point list SSCI uses. We use a dynamic one instead + //reg_t listSize = argv[2]; + + SegmentRef pointList = s->_segMan->dereference(polygonData); + if (!pointList.isValid() || pointList.skipByte) { + warning("kMergePoly: Polygon data pointer is invalid"); + return make_reg(0, 0); + } + + Node *node; + +#ifdef DEBUG_MERGEPOLY + node = s->_segMan->lookupNode(list->first); + while (node) { + draw_polygon(s, node->value, 320, 190); + node = s->_segMan->lookupNode(node->succ); + } + Common::Point prev, first; + prev = first = readPoint(pointList, 0); + for (int i = 1; readPoint(pointList, i).x != 0x7777; i++) { + Common::Point point = readPoint(pointList, i); + draw_line(s, prev, point, 1, 320, 190); + prev = point; + } + draw_line(s, prev, first, 1, 320, 190); + // Update the whole screen + g_sci->_gfxScreen->copyToScreen(); + g_system->updateScreen(); + g_system->delayMillis(1000); +#endif + + // The work polygon which we're going to merge with the polygons in list + Polygon work(0); + + for (int i = 0; true; ++i) { + Common::Point p = readPoint(pointList, i); + if (p.x == POLY_LAST_POINT) + break; + Vertex *vertex = new Vertex(p); + work.vertices.insertAtEnd(vertex); + } + + // TODO: Check behaviour for single-vertex polygons + node = s->_segMan->lookupNode(list->first); while (node) { - polygon = convert_polygon(s, node->value); + Polygon *polygon = convert_polygon(s, node->value); if (polygon) { - count += readSelectorValue(s->_segMan, node->value, SELECTOR(size)); + // CHECKME: Confirm vertex order that convert_polygon and + // fix_vertex_order output. For now, we re-reverse the order since + // convert_polygon reads the vertices reversed, and fix up head. + polygon->vertices.reverse(); + polygon->vertices._head = polygon->vertices._head->_next; + + // Merge this polygon into the work polygon if there is an + // intersection. + bool intersected = mergeSinglePolygon(work, *polygon); + + // If so, flag it + if (intersected) { + writeSelectorValue(s->_segMan, node->value, + SELECTOR(type), polygon->type + 0x10); +#ifdef DEBUG_MERGEPOLY + debugN("Merged polygon: "); + // Iterate over edges + Vertex *vertex; + CLIST_FOREACH(vertex, &(work.vertices)) { + debugN(" (%d,%d) ", vertex->v.x, vertex->v.y); + } + debugN("\n"); +#endif + } } node = s->_segMan->lookupNode(node->succ); } -#endif - // TODO: actually merge the polygon. We return an empty polygon for now. - // In QFG1VGA, you can walk over enemy bodies after killing them, since - // this is a stub. - reg_t output = allocateOutputArray(s->_segMan, 1); + + // Allocate output array + reg_t output = allocateOutputArray(s->_segMan, work.vertices.size()+1); SegmentRef arrayRef = s->_segMan->dereference(output); - writePoint(arrayRef, 0, Common::Point(POLY_LAST_POINT, POLY_LAST_POINT)); - warning("Stub: kMergePoly"); + + // Copy work.vertices into arrayRef + Vertex *vertex; + unsigned int n = 0; + CLIST_FOREACH(vertex, &work.vertices) { + if (vertex == work.vertices._head || vertex->v != vertex->_prev->v) + writePoint(arrayRef, n++, vertex->v); + } + + writePoint(arrayRef, n, Common::Point(POLY_LAST_POINT, POLY_LAST_POINT)); + +#ifdef DEBUG_MERGEPOLY + prev = first = readPoint(arrayRef, 0); + for (int i = 1; readPoint(arrayRef, i).x != 0x7777; i++) { + Common::Point point = readPoint(arrayRef, i); + draw_line(s, prev, point, 3, 320, 190); + prev = point; + } + + draw_line(s, prev, first, 3, 320, 190); + + // Update the whole screen + g_sci->_gfxScreen->copyToScreen(); + g_system->updateScreen(); + if (!g_sci->_gfxPaint16) + g_system->delayMillis(1000); + + debug("kMergePoly done"); +#endif + return output; } diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index c22d7c7b1e..c4db0b891c 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -165,6 +165,7 @@ reg_t kReadNumber(EngineState *s, int argc, reg_t *argv) { // do clipping. In SQ4 we get the door code in here and that's even // larger than uint32! if (*source == '-') { + // FIXME: Setting result to -1 does _not_ negate the output. result = -1; source++; } diff --git a/engines/sci/engine/script.cpp b/engines/sci/engine/script.cpp index 037f4ab700..36d2841b07 100644 --- a/engines/sci/engine/script.cpp +++ b/engines/sci/engine/script.cpp @@ -144,7 +144,7 @@ void Script::load(int script_nr, ResourceManager *resMan) { _heapStart = _buf + _scriptSize; - assert(_bufSize - _scriptSize <= heap->size); + assert(_bufSize - _scriptSize >= heap->size); memcpy(_heapStart, heap->data, heap->size); } diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp index 659c13b13e..8454be514a 100644 --- a/engines/sci/engine/script_patches.cpp +++ b/engines/sci/engine/script_patches.cpp @@ -915,9 +915,53 @@ const uint16 qfg3PatchImportDialog[] = { PATCH_END }; + + +// =========================================================================== +// Patch for the Woo dialog option in Uhura's conversation. Bug #3040722 +// Problem: The Woo dialog option (0xffb5) is negative, and therefore +// treated as an option opening a submenu. This leads to uhuraTell::doChild +// being called, which calls hero::solvePuzzle and then proceeds with +// Teller::doChild to open the submenu. However, there is no actual submenu +// defined for option -75 since -75 does not show up in uhuraTell::keys. +// This will cause Teller::doChild to run out of bounds while scanning through +// uhuraTell::keys. +// Strategy: there is another conversation option in uhuraTell::doChild calling +// hero::solvePuzzle (0xfffc) which does a ret afterwards without going to +// Teller::doChild. We jump to this call of hero::solvePuzzle to get that same +// behaviour. + +const byte qfg3SignatureWooDialog[] = { + 30, + 0x67, 0x12, // pTos 12 (query) + 0x35, 0xb6, // ldi b6 + 0x1a, // eq? + 0x2f, 0x05, // bt 05 + 0x67, 0x12, // pTos 12 (query) + 0x35, 0x9b, // ldi 9b + 0x1a, // eq? + 0x31, 0x0c, // bnt 0c + 0x38, 0x97, 0x02, // pushi 0297 + 0x7a, // push2 + 0x38, 0x0c, 0x01, // pushi 010c + 0x7a, // push2 + 0x81, 0x00, // lag 00 + 0x4a, 0x08, // send 08 + 0x67, 0x12, // pTos 12 (query) + 0x35, 0xb5, // ldi b5 + 0 +}; + +const uint16 qfg3PatchWooDialog[] = { + PATCH_ADDTOOFFSET | +0x29, + 0x33, 0x11, // jmp to 0x6a2, the call to hero::solvePuzzle for 0xFFFC + PATCH_END +}; + // script, description, magic DWORD, adjust const SciScriptSignature qfg3Signatures[] = { { 944, "import dialog continuous calls", 1, PATCH_MAGICDWORD(0x2a, 0x31, 0x0b, 0x7a), -1, qfg3SignatureImportDialog, qfg3PatchImportDialog }, + { 440, "dialog crash when asking about Woo", 1, PATCH_MAGICDWORD(0x67, 0x12, 0x35, 0xb5), -26, qfg3SignatureWooDialog, qfg3PatchWooDialog }, SCI_SIGNATUREENTRY_TERMINATOR }; diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index d3abb9ff41..b2f22aa985 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -514,7 +514,7 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) { if (!objType) { debugN("End of script object (#0) encountered.\n"); - debugN("Classes: %i, Objects: %i, Export: %i,\n Var: %i (all base 10)", + debugN("Classes: %i, Objects: %i, Export: %i,\n Var: %i (all base 10)\n", objectctr[6], objectctr[1], objectctr[7], objectctr[10]); return; } @@ -527,7 +527,8 @@ void Kernel::dissectScript(int scriptNumber, Vocabulary *vocab) { _seeker += objsize; - objectctr[objType]++; + if (objType >= 0 && objType < ARRAYSIZE(objectctr)) + objectctr[objType]++; switch (objType) { case SCI_OBJ_OBJECT: diff --git a/engines/sci/graphics/ports.cpp b/engines/sci/graphics/ports.cpp index 6b4c8180bf..8acdeed763 100644 --- a/engines/sci/graphics/ports.cpp +++ b/engines/sci/graphics/ports.cpp @@ -380,17 +380,50 @@ Window *GfxPorts::addWindow(const Common::Rect &dims, const Common::Rect *restor int16 oldtop = pwnd->dims.top; int16 oldleft = pwnd->dims.left; - if (wmprect.top > pwnd->dims.top) + // WORKAROUND: We also adjust the restore rect when adjusting the window + // rect. + // SSCI does not do this. It wasn't necessary in the original interpreter, + // but it is needed for Freddy Pharkas CD. This version does not normally + // have text, but we allow this by modifying the text/speech setting + // according to what is set in the ScummVM GUI (refer to syncIngameAudioOptions() + // in sci.cpp). Since the text used in Freddy Pharkas CD is quite large in + // some cases, it ends up being offset in order to fit inside the screen, + // but the associated restore rect isn't adjusted accordingly, leading to + // artifacts being left on screen when some text boxes are removed. The + // fact that the restore rect wasn't ever adjusted doesn't make sense, and + // adjusting it shouldn't have any negative side-effects (it *should* be + // adjusted, normally, but SCI doesn't do it). The big text boxes are still + // odd-looking, because the text rect is drawn outside the text window rect, + // but at least there aren't any leftover textbox artifacts left when the + // boxes are removed. Adjusting the text window rect would require more + // invasive changes than this one, thus it's not really worth the effort + // for a feature that was not present in the original game, and its + // implementation is buggy in the first place. + // Adjusting the restore rect properly fixes bug #3575276. + + if (wmprect.top > pwnd->dims.top) { pwnd->dims.moveTo(pwnd->dims.left, wmprect.top); + if (restoreRect) + pwnd->restoreRect.moveTo(pwnd->restoreRect.left, wmprect.top); + } - if (wmprect.bottom < pwnd->dims.bottom) + if (wmprect.bottom < pwnd->dims.bottom) { pwnd->dims.moveTo(pwnd->dims.left, wmprect.bottom - pwnd->dims.bottom + pwnd->dims.top); + if (restoreRect) + pwnd->restoreRect.moveTo(pwnd->restoreRect.left, wmprect.bottom - pwnd->restoreRect.bottom + pwnd->restoreRect.top); + } - if (wmprect.right < pwnd->dims.right) + if (wmprect.right < pwnd->dims.right) { pwnd->dims.moveTo(wmprect.right + pwnd->dims.left - pwnd->dims.right, pwnd->dims.top); + if (restoreRect) + pwnd->restoreRect.moveTo(wmprect.right + pwnd->restoreRect.left - pwnd->restoreRect.right, pwnd->restoreRect.top); + } - if (wmprect.left > pwnd->dims.left) + if (wmprect.left > pwnd->dims.left) { pwnd->dims.moveTo(wmprect.left, pwnd->dims.top); + if (restoreRect) + pwnd->restoreRect.moveTo(wmprect.left, pwnd->restoreRect.top); + } pwnd->rect.moveTo(pwnd->rect.left + pwnd->dims.left - oldleft, pwnd->rect.top + pwnd->dims.top - oldtop); diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 42ae00b525..15b18ce8e6 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -876,6 +876,7 @@ void SciEngine::syncIngameAudioOptions() { if (getGameId() == GID_SQ4 || getGameId() == GID_FREDDYPHARKAS || getGameId() == GID_ECOQUEST + || getGameId() == GID_LSL6 // TODO: The following need script patches for simultaneous speech and subtitles //|| getGameId() == GID_KQ6 //|| getGameId() == GID_LAURABOW2 diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 9f18219cb7..3441e26c01 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -228,6 +228,26 @@ public: bool canLoadGameStateCurrently(); bool canSaveGameStateCurrently(); void syncSoundSettings(); + + /** + * Syncs the audio options of the ScummVM launcher (speech, subtitles or + * both) with the in-game audio options of certain CD game versions. For + * some games, this allows simultaneous playing of speech and subtitles, + * even if the original games didn't support this feature. + * + * SCI1.1 games which support simultaneous speech and subtitles: + * - EcoQuest 1 CD + * - Leisure Suit Larry 6 CD + * SCI1.1 games which don't support simultaneous speech and subtitles, + * and we add this functionality in ScummVM: + * - Space Quest 4 CD + * - Freddy Pharkas CD + * SCI1.1 games which don't support simultaneous speech and subtitles, + * and we haven't added any extra functionality in ScummVM because extra + * script patches are needed: + * - Laura Bow 2 CD + * - King's Quest 6 CD + */ void syncIngameAudioOptions(); const SciGameId &getGameId() const { return _gameId; } diff --git a/engines/sword1/control.cpp b/engines/sword1/control.cpp index 6e395116f9..7cd85dff54 100644 --- a/engines/sword1/control.cpp +++ b/engines/sword1/control.cpp @@ -541,7 +541,9 @@ void Control::setupMainPanel() { if (SwordEngine::_systemVars.controlPanelMode == CP_DEATHSCREEN) panelId = SR_DEATHPANEL; else { - if (SwordEngine::_systemVars.language <= BS1_SPANISH) + if (SwordEngine::_systemVars.realLanguage == Common::EN_USA) + panelId = SR_PANEL_AMERICAN; + else if (SwordEngine::_systemVars.language <= BS1_SPANISH) panelId = SR_PANEL_ENGLISH + SwordEngine::_systemVars.language; else panelId = SR_PANEL_ENGLISH; diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 75e8f72d9d..fa593b8df4 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -116,8 +116,9 @@ Common::Error SwordEngine::init() { _systemVars.controlPanelMode = CP_NEWGAME; _systemVars.forceRestart = false; _systemVars.wantFade = true; + _systemVars.realLanguage = Common::parseLanguage(ConfMan.get("language")); - switch (Common::parseLanguage(ConfMan.get("language"))) { + switch (_systemVars.realLanguage) { case Common::DE_DEU: _systemVars.language = BS1_GERMAN; break; @@ -138,6 +139,7 @@ Common::Error SwordEngine::init() { break; default: _systemVars.language = BS1_ENGLISH; + break; } _systemVars.showText = ConfMan.getBool("subtitles"); diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h index ccdc2d3a59..ec6555b4b3 100644 --- a/engines/sword1/sword1.h +++ b/engines/sword1/sword1.h @@ -75,6 +75,7 @@ struct SystemVars { uint8 language; bool isDemo; Common::Platform platform; + Common::Language realLanguage; }; class SwordEngine : public Engine { diff --git a/engines/toltecs/menu.cpp b/engines/toltecs/menu.cpp index c214205624..6e23ff988f 100644 --- a/engines/toltecs/menu.cpp +++ b/engines/toltecs/menu.cpp @@ -59,6 +59,7 @@ int MenuSystem::run(MenuID menuId) { _running = true; _top = 30 - _vm->_guiHeight / 2; + _needRedraw = false; // TODO: buildColorTransTable2 @@ -101,7 +102,7 @@ void MenuSystem::update() { if (_needRedraw) { //_vm->_system->copyRectToScreen(_vm->_screen->_frontScreen + 39 * 640 + 60, 640, 60, 39, 520, 247); - _vm->_system->copyRectToScreen(_vm->_screen->_frontScreen, 640, 0, 0, 640, 400); + _vm->_system->copyRectToScreen(_vm->_screen->_frontScreen, 640, 0, _top, 640, 400 - _top); //debug("redraw"); _needRedraw = false; } @@ -201,7 +202,7 @@ void MenuSystem::handleKeyDown(const Common::KeyState& kbd) { ItemID MenuSystem::findItemAt(int x, int y) { for (Common::Array<Item>::iterator iter = _items.begin(); iter != _items.end(); iter++) { - if ((*iter).rect.contains(x, y)) + if ((*iter).rect.contains(x, y - _top)) return (*iter).id; } return kItemIdNone; @@ -413,7 +414,7 @@ void MenuSystem::restoreRect(int x, int y, int w, int h) { } void MenuSystem::shadeRect(int x, int y, int w, int h, byte color1, byte color2) { - byte *src = (byte *)_background->getBasePtr(x, y); + byte *src = (byte *)_vm->_screen->_frontScreen + x + y * 640; for (int xc = 0; xc < w; xc++) { src[xc] = color2; src[xc + h * 640] = color1; diff --git a/engines/toltecs/movie.cpp b/engines/toltecs/movie.cpp index 75127d7159..35accb5d93 100644 --- a/engines/toltecs/movie.cpp +++ b/engines/toltecs/movie.cpp @@ -96,9 +96,9 @@ void MoviePlayer::playMovie(uint resIndex) { fetchAudioChunks(); - uint32 lastTime = _vm->_mixer->getSoundElapsedTime(_audioStreamHandle); byte *chunkBuffer = NULL; uint32 chunkBufferSize = 0; + uint32 frame = 0; while (_chunkCount--) { byte chunkType = _vm->_arc->readByte(); @@ -125,23 +125,23 @@ void MoviePlayer::playMovie(uint resIndex) { case kChunkFirstImage: case kChunkSubsequentImages: unpackRle(chunkBuffer, _vm->_screen->_backScreen); - // TODO: Rework this - _vm->_screen->updateShakeScreen(); _vm->_screen->_fullRefresh = true; - _vm->updateInput(); - _vm->drawScreen(); _soundChunkFramesLeft--; if (_soundChunkFramesLeft <= _framesPerSoundChunk) { fetchAudioChunks(); } - while (_vm->_mixer->getSoundElapsedTime(_audioStreamHandle) < lastTime + 111) { - g_system->delayMillis(10); + while (_vm->_mixer->getSoundElapsedTime(_audioStreamHandle) < (1000 * frame) / 9) { + if (_vm->_screen->_shakeActive && _vm->_screen->updateShakeScreen()) { + _vm->_screen->_fullRefresh = true; + } + _vm->updateInput(); + _vm->drawScreen(); + // Note: drawScreen() calls delayMillis() } - lastTime = _vm->_mixer->getSoundElapsedTime(_audioStreamHandle); - + frame++; break; case kChunkPalette: unpackPalette(chunkBuffer, moviePalette, 256, 3); diff --git a/engines/toltecs/screen.cpp b/engines/toltecs/screen.cpp index 32202ad13e..c8d6740b02 100644 --- a/engines/toltecs/screen.cpp +++ b/engines/toltecs/screen.cpp @@ -43,9 +43,11 @@ Screen::Screen(ToltecsEngine *vm) : _vm(vm) { // Screen shaking _shakeActive = false; + _shakeTime = 0; _shakeCounterInit = 0; _shakeCounter = 0; _shakePos = 0; + _shakeTime = 0; // Verb line _verbLineNum = 0; @@ -156,6 +158,7 @@ void Screen::drawGuiImage(int16 x, int16 y, uint resIndex) { void Screen::startShakeScreen(int16 shakeCounter) { _shakeActive = true; + _shakeTime = 0; _shakeCounterInit = shakeCounter; _shakeCounter = shakeCounter; _shakePos = 0; @@ -166,15 +169,19 @@ void Screen::stopShakeScreen() { _vm->_system->setShakePos(0); } -void Screen::updateShakeScreen() { - if (_shakeActive) { +bool Screen::updateShakeScreen() { + // Assume shaking happens no more often than 50 times per second + if (_shakeActive && _vm->_system->getMillis() - _shakeTime >= 20) { + _shakeTime = _vm->_system->getMillis(); _shakeCounter--; if (_shakeCounter == 0) { _shakeCounter = _shakeCounterInit; _shakePos ^= 8; _vm->_system->setShakePos(_shakePos); + return true; } } + return false; } void Screen::addStaticSprite(byte *spriteItem) { diff --git a/engines/toltecs/screen.h b/engines/toltecs/screen.h index 315e9a45c3..788cde50c6 100644 --- a/engines/toltecs/screen.h +++ b/engines/toltecs/screen.h @@ -161,7 +161,7 @@ public: void startShakeScreen(int16 shakeCounter); void stopShakeScreen(); - void updateShakeScreen(); + bool updateShakeScreen(); // Sprite list void addStaticSprite(byte *spriteItem); @@ -221,6 +221,7 @@ public: // Screen shaking bool _shakeActive; + uint32 _shakeTime; int16 _shakeCounterInit, _shakeCounter; int _shakePos; diff --git a/engines/toltecs/script.cpp b/engines/toltecs/script.cpp index 03a2b66088..5e8617bc43 100644 --- a/engines/toltecs/script.cpp +++ b/engines/toltecs/script.cpp @@ -183,10 +183,7 @@ void ScriptInterpreter::setMainScript(uint slotIndex) { } void ScriptInterpreter::runScript() { - uint32 lastScreenUpdate = 0; - while (!_vm->shouldQuit()) { - if (_vm->_movieSceneFlag) _vm->_mouseButton = 0; @@ -217,17 +214,7 @@ void ScriptInterpreter::runScript() { byte opcode = readByte(); execOpcode(opcode); - - // Update the screen at semi-regular intervals, else the mouse - // cursor will be jerky. - uint32 now = _vm->_system->getMillis(); - if (now < lastScreenUpdate || now - lastScreenUpdate > 10) { - _vm->_system->updateScreen(); - lastScreenUpdate = _vm->_system->getMillis(); - } - } - } byte ScriptInterpreter::readByte() { @@ -1094,7 +1081,9 @@ void ScriptInterpreter::sfSaveStackPtr() { } void ScriptInterpreter::sfPlayMovie() { + CursorMan.showMouse(false); _vm->_moviePlayer->playMovie(arg16(3)); + CursorMan.showMouse(true); } } // End of namespace Toltecs diff --git a/engines/toltecs/toltecs.cpp b/engines/toltecs/toltecs.cpp index 71264a69cc..9f3a10a03b 100644 --- a/engines/toltecs/toltecs.cpp +++ b/engines/toltecs/toltecs.cpp @@ -311,6 +311,7 @@ void ToltecsEngine::drawScreen() { } _system->updateScreen(); + _system->delayMillis(10); updateCamera(); } diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp index 695801ad90..1c63096e92 100644 --- a/engines/tony/tony.cpp +++ b/engines/tony/tony.cpp @@ -246,7 +246,7 @@ bool TonyEngine::loadTonyDat() { } int numVariant = in.readUint16BE(); - if (expectedLangVariant > numVariant) { + if (expectedLangVariant > numVariant - 1) { msg = Common::String::format("Font variant not present in 'tony.dat'. Get it from the ScummVM website"); GUIErrorMessage(msg); warning("%s", msg.c_str()); diff --git a/engines/tony/tony.h b/engines/tony/tony.h index d22ff247f3..332b122923 100644 --- a/engines/tony/tony.h +++ b/engines/tony/tony.h @@ -71,7 +71,7 @@ struct TonyGameDescription; #define MAX_SFX_CHANNELS 32 #define TONY_DAT_VER_MAJ 0 -#define TONY_DAT_VER_MIN 2 +#define TONY_DAT_VER_MIN 3 struct VoiceHeader { int _offset; diff --git a/engines/wintermute/ad/ad_actor.cpp b/engines/wintermute/ad/ad_actor.cpp index 074d5afdbb..d175855d1e 100644 --- a/engines/wintermute/ad/ad_actor.cpp +++ b/engines/wintermute/ad/ad_actor.cpp @@ -602,13 +602,13 @@ bool AdActor::update() { } // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->isFinished()) { _state = _nextState; _nextState = STATE_READY; _currentSprite = _animSprite; } - if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != NULL && _animSprite2->_finished) { + if (_state == STATE_PLAYING_ANIM_SET && _animSprite2 != NULL && _animSprite2->isFinished()) { _state = _nextState; _nextState = STATE_READY; _currentSprite = _animSprite2; @@ -649,7 +649,7 @@ bool AdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_TURNING_LEFT: - if (_tempSprite2 == NULL || _tempSprite2->_finished) { + if (_tempSprite2 == NULL || _tempSprite2->isFinished()) { if (_dir > 0) { _dir = (TDirection)(_dir - 1); } else { @@ -686,7 +686,7 @@ bool AdActor::update() { ////////////////////////////////////////////////////////////////////////// case STATE_TURNING_RIGHT: - if (_tempSprite2 == NULL || _tempSprite2->_finished) { + if (_tempSprite2 == NULL || _tempSprite2->isFinished()) { _dir = (TDirection)(_dir + 1); if ((int)_dir >= (int)NUM_DIRECTIONS) { @@ -753,7 +753,7 @@ bool AdActor::update() { } bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ timeIsUp)) { + if (_tempSprite2 == NULL || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { if (timeIsUp) { _sentence->finish(); _tempSprite2 = NULL; @@ -798,7 +798,7 @@ bool AdActor::update() { if (_currentSprite && !already_moved) { _currentSprite->getCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); - if (_currentSprite->_changed) { + if (_currentSprite->isChanged()) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; afterMove(); @@ -858,7 +858,7 @@ void AdActor::getNextStep() { } _currentSprite->getCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100, _zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); - if (!_currentSprite->_changed) { + if (!_currentSprite->isChanged()) { return; } @@ -1075,27 +1075,27 @@ bool AdActor::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *AdActor::scGetProperty(const char *name) { +ScValue *AdActor::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Direction ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Direction") == 0) { + if (name == "Direction") { _scValue->setInt(_dir); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Type") == 0) { + else if (name == "Type") { _scValue->setString("actor"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // TalkAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TalkAnimName") == 0) { + else if (name == "TalkAnimName") { _scValue->setString(_talkAnimName); return _scValue; } @@ -1103,7 +1103,7 @@ ScValue *AdActor::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // WalkAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkAnimName") == 0) { + else if (name == "WalkAnimName") { _scValue->setString(_walkAnimName); return _scValue; } @@ -1111,7 +1111,7 @@ ScValue *AdActor::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // IdleAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IdleAnimName") == 0) { + else if (name == "IdleAnimName") { _scValue->setString(_idleAnimName); return _scValue; } @@ -1119,7 +1119,7 @@ ScValue *AdActor::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TurnLeftAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnLeftAnimName") == 0) { + else if (name == "TurnLeftAnimName") { _scValue->setString(_turnLeftAnimName); return _scValue; } @@ -1127,7 +1127,7 @@ ScValue *AdActor::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TurnRightAnimName ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TurnRightAnimName") == 0) { + else if (name == "TurnRightAnimName") { _scValue->setString(_turnRightAnimName); return _scValue; } else { diff --git a/engines/wintermute/ad/ad_actor.h b/engines/wintermute/ad/ad_actor.h index 271e57cb85..543c9d063a 100644 --- a/engines/wintermute/ad/ad_actor.h +++ b/engines/wintermute/ad/ad_actor.h @@ -83,7 +83,7 @@ private: AdSpriteSet *getAnimByName(const Common::String &animName); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ad/ad_entity.cpp b/engines/wintermute/ad/ad_entity.cpp index 00dbc0f3c2..9af7e034ca 100644 --- a/engines/wintermute/ad/ad_entity.cpp +++ b/engines/wintermute/ad/ad_entity.cpp @@ -578,7 +578,7 @@ bool AdEntity::update() { } // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->isFinished()) { _state = STATE_READY; _currentSprite = _animSprite; } @@ -613,7 +613,7 @@ bool AdEntity::update() { } bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ timeIsUp)) { + if (_tempSprite2 == NULL || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { if (timeIsUp) { _sentence->finish(); _tempSprite2 = NULL; @@ -639,7 +639,7 @@ bool AdEntity::update() { if (_currentSprite) { _currentSprite->getCurrentFrame(_zoomable ? ((AdGame *)_gameRef)->_scene->getZoomAt(_posX, _posY) : 100); - if (_currentSprite->_changed) { + if (_currentSprite->isChanged()) { _posX += _currentSprite->_moveX; _posY += _currentSprite->_moveY; } @@ -829,13 +829,13 @@ bool AdEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *AdEntity::scGetProperty(const char *name) { +ScValue *AdEntity::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("entity"); return _scValue; } @@ -843,7 +843,7 @@ ScValue *AdEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Item ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Item") == 0) { + else if (name == "Item") { if (_item) { _scValue->setString(_item); } else { @@ -856,7 +856,7 @@ ScValue *AdEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Subtype (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtype") == 0) { + else if (name == "Subtype") { if (_subtype == ENTITY_SOUND) { _scValue->setString("sound"); } else { @@ -869,7 +869,7 @@ ScValue *AdEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // WalkToX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToX") == 0) { + else if (name == "WalkToX") { _scValue->setInt(_walkToX); return _scValue; } @@ -877,7 +877,7 @@ ScValue *AdEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // WalkToY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToY") == 0) { + else if (name == "WalkToY") { _scValue->setInt(_walkToY); return _scValue; } @@ -885,7 +885,7 @@ ScValue *AdEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // WalkToDirection ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WalkToDirection") == 0) { + else if (name == "WalkToDirection") { _scValue->setInt((int)_walkToDir); return _scValue; } @@ -893,7 +893,7 @@ ScValue *AdEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Region (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Region") == 0) { + else if (name == "Region") { if (_region) { _scValue->setNative(_region, true); } else { diff --git a/engines/wintermute/ad/ad_entity.h b/engines/wintermute/ad/ad_entity.h index 39dc133eef..415987e50a 100644 --- a/engines/wintermute/ad/ad_entity.h +++ b/engines/wintermute/ad/ad_entity.h @@ -56,7 +56,7 @@ public: TEntityType _subtype; // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ad/ad_game.cpp b/engines/wintermute/ad/ad_game.cpp index ec6c5dca31..4481b774c1 100644 --- a/engines/wintermute/ad/ad_game.cpp +++ b/engines/wintermute/ad/ad_game.cpp @@ -876,20 +876,20 @@ bool AdGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *AdGame::scGetProperty(const char *name) { +ScValue *AdGame::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("game"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scene ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scene") == 0) { + else if (name == "Scene") { if (_scene) { _scValue->setNative(_scene, true); } else { @@ -901,7 +901,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SelectedItem ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelectedItem") == 0) { + else if (name == "SelectedItem") { //if (_selectedItem) _scValue->setString(_selectedItem->_name); if (_selectedItem) { _scValue->setNative(_selectedItem, true); @@ -914,14 +914,14 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumItems ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumItems") == 0) { + else if (name == "NumItems") { return _invObject->scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// // SmartItemCursor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SmartItemCursor") == 0) { + else if (name == "SmartItemCursor") { _scValue->setBool(_smartItemCursor); return _scValue; } @@ -929,7 +929,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // InventoryVisible ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryVisible") == 0) { + else if (name == "InventoryVisible") { _scValue->setBool(_inventoryBox && _inventoryBox->_visible); return _scValue; } @@ -937,7 +937,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // InventoryScrollOffset ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryScrollOffset") == 0) { + else if (name == "InventoryScrollOffset") { if (_inventoryBox) { _scValue->setInt(_inventoryBox->_scrollOffset); } else { @@ -950,7 +950,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ResponsesVisible (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResponsesVisible") == 0) { + else if (name == "ResponsesVisible") { _scValue->setBool(_stateEx == GAME_WAITING_RESPONSE); return _scValue; } @@ -958,7 +958,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // PrevScene / PreviousScene (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PrevScene") == 0 || strcmp(name, "PreviousScene") == 0) { + else if (name == "PrevScene" || name == "PreviousScene") { if (!_prevSceneName) { _scValue->setString(""); } else { @@ -970,7 +970,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // PrevSceneFilename / PreviousSceneFilename (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PrevSceneFilename") == 0 || strcmp(name, "PreviousSceneFilename") == 0) { + else if (name == "PrevSceneFilename" || name == "PreviousSceneFilename") { if (!_prevSceneFilename) { _scValue->setString(""); } else { @@ -982,7 +982,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // LastResponse (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LastResponse") == 0) { + else if (name == "LastResponse") { if (!_responseBox || !_responseBox->_lastResponseText) { _scValue->setString(""); } else { @@ -994,7 +994,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // LastResponseOrig (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LastResponseOrig") == 0) { + else if (name == "LastResponseOrig") { if (!_responseBox || !_responseBox->_lastResponseTextOrig) { _scValue->setString(""); } else { @@ -1006,7 +1006,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // InventoryObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InventoryObject") == 0) { + else if (name == "InventoryObject") { if (_inventoryOwner == _invObject) { _scValue->setNative(this, true); } else { @@ -1019,7 +1019,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TotalNumItems ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TotalNumItems") == 0) { + else if (name == "TotalNumItems") { _scValue->setInt(_items.size()); return _scValue; } @@ -1027,7 +1027,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TalkSkipButton ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TalkSkipButton") == 0) { + else if (name == "TalkSkipButton") { _scValue->setInt(_talkSkipButton); return _scValue; } @@ -1035,7 +1035,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ChangingScene ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ChangingScene") == 0) { + else if (name == "ChangingScene") { _scValue->setBool(_scheduledScene != NULL); return _scValue; } @@ -1043,7 +1043,7 @@ ScValue *AdGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // StartupScene ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StartupScene") == 0) { + else if (name == "StartupScene") { if (!_startupScene) { _scValue->setNULL(); } else { diff --git a/engines/wintermute/ad/ad_game.h b/engines/wintermute/ad/ad_game.h index 46427331bf..81c79a3da8 100644 --- a/engines/wintermute/ad/ad_game.h +++ b/engines/wintermute/ad/ad_game.h @@ -126,7 +126,7 @@ public: bool loadItemsBuffer(byte *buffer, bool merge = false); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); bool validMouse(); diff --git a/engines/wintermute/ad/ad_item.cpp b/engines/wintermute/ad/ad_item.cpp index bad7223788..427b1c7db4 100644 --- a/engines/wintermute/ad/ad_item.cpp +++ b/engines/wintermute/ad/ad_item.cpp @@ -340,7 +340,7 @@ bool AdItem::update() { } // finished playing animation? - if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->_finished) { + if (_state == STATE_PLAYING_ANIM && _animSprite != NULL && _animSprite->isFinished()) { _state = STATE_READY; _currentSprite = _animSprite; } @@ -379,7 +379,7 @@ bool AdItem::update() { } bool timeIsUp = (_sentence->_sound && _sentence->_soundStarted && (!_sentence->_sound->isPlaying() && !_sentence->_sound->isPaused())) || (!_sentence->_sound && _sentence->_duration <= _gameRef->_timer - _sentence->_startTime); - if (_tempSprite2 == NULL || _tempSprite2->_finished || (/*_tempSprite2->_looping &&*/ timeIsUp)) { + if (_tempSprite2 == NULL || _tempSprite2->isFinished() || (/*_tempSprite2->_looping &&*/ timeIsUp)) { if (timeIsUp) { _sentence->finish(); _tempSprite2 = NULL; @@ -614,13 +614,13 @@ bool AdItem::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *AdItem::scGetProperty(const char *name) { +ScValue *AdItem::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("item"); return _scValue; } @@ -628,7 +628,7 @@ ScValue *AdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { + else if (name == "Name") { _scValue->setString(getName()); return _scValue; } @@ -636,7 +636,7 @@ ScValue *AdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // DisplayAmount ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisplayAmount") == 0) { + else if (name == "DisplayAmount") { _scValue->setBool(_displayAmount); return _scValue; } @@ -644,7 +644,7 @@ ScValue *AdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Amount ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Amount") == 0) { + else if (name == "Amount") { _scValue->setInt(_amount); return _scValue; } @@ -652,7 +652,7 @@ ScValue *AdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AmountOffsetX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountOffsetX") == 0) { + else if (name == "AmountOffsetX") { _scValue->setInt(_amountOffsetX); return _scValue; } @@ -660,7 +660,7 @@ ScValue *AdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AmountOffsetY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountOffsetY") == 0) { + else if (name == "AmountOffsetY") { _scValue->setInt(_amountOffsetY); return _scValue; } @@ -668,7 +668,7 @@ ScValue *AdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AmountAlign ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountAlign") == 0) { + else if (name == "AmountAlign") { _scValue->setInt(_amountAlign); return _scValue; } @@ -676,7 +676,7 @@ ScValue *AdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AmountString ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AmountString") == 0) { + else if (name == "AmountString") { if (!_amountString) { _scValue->setNULL(); } else { @@ -688,7 +688,7 @@ ScValue *AdItem::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // CursorCombined ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorCombined") == 0) { + else if (name == "CursorCombined") { _scValue->setBool(_cursorCombined); return _scValue; } else { diff --git a/engines/wintermute/ad/ad_item.h b/engines/wintermute/ad/ad_item.h index 6047c542c1..79978f9f72 100644 --- a/engines/wintermute/ad/ad_item.h +++ b/engines/wintermute/ad/ad_item.h @@ -51,7 +51,7 @@ public: bool loadBuffer(byte *buffer, bool complete = true); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ad/ad_layer.cpp b/engines/wintermute/ad/ad_layer.cpp index bc64b21208..209c12b7a2 100644 --- a/engines/wintermute/ad/ad_layer.cpp +++ b/engines/wintermute/ad/ad_layer.cpp @@ -376,13 +376,13 @@ bool AdLayer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *AdLayer::scGetProperty(const char *name) { +ScValue *AdLayer::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("layer"); return _scValue; } @@ -390,7 +390,7 @@ ScValue *AdLayer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumNodes (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumNodes") == 0) { + else if (name == "NumNodes") { _scValue->setInt(_nodes.size()); return _scValue; } @@ -398,7 +398,7 @@ ScValue *AdLayer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { + else if (name == "Width") { _scValue->setInt(_width); return _scValue; } @@ -406,7 +406,7 @@ ScValue *AdLayer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { + else if (name == "Height") { _scValue->setInt(_height); return _scValue; } @@ -414,7 +414,7 @@ ScValue *AdLayer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Main (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Main") == 0) { + else if (name == "Main") { _scValue->setBool(_main); return _scValue; } @@ -422,7 +422,7 @@ ScValue *AdLayer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // CloseUp ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CloseUp") == 0) { + else if (name == "CloseUp") { _scValue->setBool(_closeUp); return _scValue; } @@ -430,7 +430,7 @@ ScValue *AdLayer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { + else if (name == "Active") { _scValue->setBool(_active); return _scValue; } else { diff --git a/engines/wintermute/ad/ad_layer.h b/engines/wintermute/ad/ad_layer.h index bb5f73b13a..de65e2822f 100644 --- a/engines/wintermute/ad/ad_layer.h +++ b/engines/wintermute/ad/ad_layer.h @@ -47,7 +47,7 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ad/ad_object.cpp b/engines/wintermute/ad/ad_object.cpp index 013ce498e0..7b91daab2e 100644 --- a/engines/wintermute/ad/ad_object.cpp +++ b/engines/wintermute/ad/ad_object.cpp @@ -659,13 +659,13 @@ bool AdObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *AdObject::scGetProperty(const char *name) { +ScValue *AdObject::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("object"); return _scValue; } @@ -673,7 +673,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { + else if (name == "Active") { _scValue->setBool(_active); return _scValue; } @@ -681,7 +681,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // IgnoreItems ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IgnoreItems") == 0) { + else if (name == "IgnoreItems") { _scValue->setBool(_ignoreItems); return _scValue; } @@ -689,7 +689,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SceneIndependent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SceneIndependent") == 0) { + else if (name == "SceneIndependent") { _scValue->setBool(_sceneIndependent); return _scValue; } @@ -697,7 +697,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesWidth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesWidth") == 0) { + else if (name == "SubtitlesWidth") { _scValue->setInt(_subtitlesWidth); return _scValue; } @@ -705,7 +705,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosRelative ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosRelative") == 0) { + else if (name == "SubtitlesPosRelative") { _scValue->setBool(_subtitlesModRelative); return _scValue; } @@ -713,7 +713,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosX") == 0) { + else if (name == "SubtitlesPosX") { _scValue->setInt(_subtitlesModX); return _scValue; } @@ -721,7 +721,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosY") == 0) { + else if (name == "SubtitlesPosY") { _scValue->setInt(_subtitlesModY); return _scValue; } @@ -729,7 +729,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesPosXCenter ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesPosXCenter") == 0) { + else if (name == "SubtitlesPosXCenter") { _scValue->setBool(_subtitlesModXCenter); return _scValue; } @@ -737,7 +737,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumItems (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumItems") == 0) { + else if (name == "NumItems") { _scValue->setInt(getInventory()->_takenItems.size()); return _scValue; } @@ -745,7 +745,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ParticleEmitter (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ParticleEmitter") == 0) { + else if (name == "ParticleEmitter") { if (_partEmitter) { _scValue->setNative(_partEmitter, true); } else { @@ -758,7 +758,7 @@ ScValue *AdObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumAttachments (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumAttachments") == 0) { + else if (name == "NumAttachments") { _scValue->setInt(_attachmentsPre.size() + _attachmentsPost.size()); return _scValue; } else { diff --git a/engines/wintermute/ad/ad_object.h b/engines/wintermute/ad/ad_object.h index 8395f58cff..d1a20908e1 100644 --- a/engines/wintermute/ad/ad_object.h +++ b/engines/wintermute/ad/ad_object.h @@ -100,7 +100,7 @@ public: AdRegion *_currentRegions[MAX_NUM_REGIONS]; // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ad/ad_region.cpp b/engines/wintermute/ad/ad_region.cpp index 2b90b479bf..c9f1553c9a 100644 --- a/engines/wintermute/ad/ad_region.cpp +++ b/engines/wintermute/ad/ad_region.cpp @@ -242,13 +242,13 @@ bool AdRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *AdRegion::scGetProperty(const char *name) { +ScValue *AdRegion::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("ad region"); return _scValue; } @@ -256,7 +256,7 @@ ScValue *AdRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { + else if (name == "Name") { _scValue->setString(getName()); return _scValue; } @@ -264,7 +264,7 @@ ScValue *AdRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Blocked ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Blocked") == 0) { + else if (name == "Blocked") { _scValue->setBool(_blocked); return _scValue; } @@ -272,7 +272,7 @@ ScValue *AdRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Decoration ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { + else if (name == "Decoration") { _scValue->setBool(_decoration); return _scValue; } @@ -280,7 +280,7 @@ ScValue *AdRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Scale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { + else if (name == "Scale") { _scValue->setFloat(_zoom); return _scValue; } @@ -288,7 +288,7 @@ ScValue *AdRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { + else if (name == "AlphaColor") { _scValue->setInt((int)_alpha); return _scValue; } else { diff --git a/engines/wintermute/ad/ad_region.h b/engines/wintermute/ad/ad_region.h index a60cb9a3f2..6112900361 100644 --- a/engines/wintermute/ad/ad_region.h +++ b/engines/wintermute/ad/ad_region.h @@ -47,7 +47,7 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ad/ad_scene.cpp b/engines/wintermute/ad/ad_scene.cpp index 8c4bff02ac..8e9beca0c0 100644 --- a/engines/wintermute/ad/ad_scene.cpp +++ b/engines/wintermute/ad/ad_scene.cpp @@ -1809,13 +1809,13 @@ bool AdScene::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *AdScene::scGetProperty(const char *name) { +ScValue *AdScene::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("scene"); return _scValue; } @@ -1823,7 +1823,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumLayers (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumLayers") == 0) { + else if (name == "NumLayers") { _scValue->setInt(_layers.size()); return _scValue; } @@ -1831,7 +1831,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumWaypointGroups (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumWaypointGroups") == 0) { + else if (name == "NumWaypointGroups") { _scValue->setInt(_waypointGroups.size()); return _scValue; } @@ -1839,7 +1839,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MainLayer (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainLayer") == 0) { + else if (name == "MainLayer") { if (_mainLayer) { _scValue->setNative(_mainLayer, true); } else { @@ -1852,7 +1852,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumFreeNodes (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumFreeNodes") == 0) { + else if (name == "NumFreeNodes") { _scValue->setInt(_objects.size()); return _scValue; } @@ -1860,7 +1860,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MouseX (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { + else if (name == "MouseX") { int viewportX; getViewportOffset(&viewportX); @@ -1871,7 +1871,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MouseY (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { + else if (name == "MouseY") { int viewportY; getViewportOffset(NULL, &viewportY); @@ -1882,7 +1882,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AutoScroll ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoScroll") == 0) { + else if (name == "AutoScroll") { _scValue->setBool(_autoScroll); return _scValue; } @@ -1890,7 +1890,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // PersistentState ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PersistentState") == 0) { + else if (name == "PersistentState") { _scValue->setBool(_persistentState); return _scValue; } @@ -1898,7 +1898,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // PersistentStateSprites ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PersistentStateSprites") == 0) { + else if (name == "PersistentStateSprites") { _scValue->setBool(_persistentStateSprites); return _scValue; } @@ -1906,7 +1906,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScrollPixelsX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollPixelsX") == 0) { + else if (name == "ScrollPixelsX") { _scValue->setInt(_scrollPixelsH); return _scValue; } @@ -1914,7 +1914,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScrollPixelsY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollPixelsY") == 0) { + else if (name == "ScrollPixelsY") { _scValue->setInt(_scrollPixelsV); return _scValue; } @@ -1923,7 +1923,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScrollSpeedX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollSpeedX") == 0) { + else if (name == "ScrollSpeedX") { _scValue->setInt(_scrollTimeH); return _scValue; } @@ -1931,7 +1931,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScrollSpeedY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScrollSpeedY") == 0) { + else if (name == "ScrollSpeedY") { _scValue->setInt(_scrollTimeV); return _scValue; } @@ -1939,7 +1939,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // OffsetX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OffsetX") == 0) { + else if (name == "OffsetX") { _scValue->setInt(_offsetLeft); return _scValue; } @@ -1947,7 +1947,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // OffsetY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OffsetY") == 0) { + else if (name == "OffsetY") { _scValue->setInt(_offsetTop); return _scValue; } @@ -1955,7 +1955,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Width (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { + else if (name == "Width") { if (_mainLayer) { _scValue->setInt(_mainLayer->_width); } else { @@ -1967,7 +1967,7 @@ ScValue *AdScene::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Height (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { + else if (name == "Height") { if (_mainLayer) { _scValue->setInt(_mainLayer->_height); } else { diff --git a/engines/wintermute/ad/ad_scene.h b/engines/wintermute/ad/ad_scene.h index c9c0e413bf..3b482403b5 100644 --- a/engines/wintermute/ad/ad_scene.h +++ b/engines/wintermute/ad/ad_scene.h @@ -156,7 +156,7 @@ public: int getPointsDist(BasePoint p1, BasePoint p2, BaseObject *requester = NULL); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ad/ad_talk_holder.cpp b/engines/wintermute/ad/ad_talk_holder.cpp index 1422d8683c..cca4fdc2cb 100644 --- a/engines/wintermute/ad/ad_talk_holder.cpp +++ b/engines/wintermute/ad/ad_talk_holder.cpp @@ -334,13 +334,13 @@ bool AdTalkHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS ////////////////////////////////////////////////////////////////////////// -ScValue *AdTalkHolder::scGetProperty(const char *name) { +ScValue *AdTalkHolder::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("talk-holder"); return _scValue; } else { diff --git a/engines/wintermute/ad/ad_talk_holder.h b/engines/wintermute/ad/ad_talk_holder.h index ce10364b3d..d52ebf63c0 100644 --- a/engines/wintermute/ad/ad_talk_holder.h +++ b/engines/wintermute/ad/ad_talk_holder.h @@ -45,7 +45,7 @@ public: virtual ~AdTalkHolder(); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ad/ad_talk_node.cpp b/engines/wintermute/ad/ad_talk_node.cpp index b1bcf685f2..c909ee27ff 100644 --- a/engines/wintermute/ad/ad_talk_node.cpp +++ b/engines/wintermute/ad/ad_talk_node.cpp @@ -264,9 +264,9 @@ bool AdTalkNode::loadSprite() { bool AdTalkNode::isInTimeInterval(uint32 time, TDirection dir) { if (time >= _startTime) { if (_playToEnd) { - if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->_finished == false)) { + if ((_spriteFilename && _sprite == NULL) || (_sprite && _sprite->isFinished() == false)) { return true; - } else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->_finished == false)) { + } else if ((_spriteSetFilename && _spriteSet == NULL) || (_spriteSet && _spriteSet->getSprite(dir) && _spriteSet->getSprite(dir)->isFinished() == false)) { return true; } else { return false; diff --git a/engines/wintermute/ad/ad_waypoint_group.cpp b/engines/wintermute/ad/ad_waypoint_group.cpp index f80fa7e45d..81493ce769 100644 --- a/engines/wintermute/ad/ad_waypoint_group.cpp +++ b/engines/wintermute/ad/ad_waypoint_group.cpp @@ -206,13 +206,13 @@ bool AdWaypointGroup::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ScValue *AdWaypointGroup::scGetProperty(const char *name) { +ScValue *AdWaypointGroup::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("waypoint-group"); return _scValue; } @@ -220,7 +220,7 @@ ScValue *AdWaypointGroup::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { + else if (name == "Active") { _scValue->setBool(_active); return _scValue; } else { diff --git a/engines/wintermute/ad/ad_waypoint_group.h b/engines/wintermute/ad/ad_waypoint_group.h index 5cf6da1d1a..13d6bbadd7 100644 --- a/engines/wintermute/ad/ad_waypoint_group.h +++ b/engines/wintermute/ad/ad_waypoint_group.h @@ -49,7 +49,7 @@ public: virtual ~AdWaypointGroup(); BaseArray<BasePoint *> _points; int _editorSelectedPoint; - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); }; diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index b6f3e12b9c..2d1a7fbe48 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -29,14 +29,12 @@ #ifndef WINTERMUTE_BASE_DYNAMIC_BUFFER_H #define WINTERMUTE_BASE_DYNAMIC_BUFFER_H - #include "engines/wintermute/base/base.h" namespace Wintermute { class BaseDynamicBuffer { public: - bool _initialized; void putText(const char *fmt, ...); void putTextIndent(int indent, const char *fmt, ...); uint32 getDWORD(); @@ -48,12 +46,13 @@ public: uint32 getSize(); bool init(uint32 initSize = 0); void cleanup(); - uint32 _size; - byte *_buffer; BaseDynamicBuffer(BaseGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); virtual ~BaseDynamicBuffer(); private: + uint32 _size; + byte *_buffer; + bool _initialized; uint32 _realSize; uint32 _growBy; uint32 _initSize; diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index d3ced4aacc..116c8c963d 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -36,7 +36,6 @@ namespace Wintermute { class BaseFader : public BaseObject { public: - bool _system; uint32 getCurrentColor(); bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); @@ -47,6 +46,7 @@ public: BaseFader(BaseGame *inGame); virtual ~BaseFader(); private: + bool _system; bool _active; byte _red; byte _green; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index e1b29a3a5c..7c64144480 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -87,6 +87,12 @@ bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float return STATUS_OK; } +void BaseFrame::stopSound() { + if (_sound) { + _sound->stop(); + } +} + ////////////////////////////////////////////////////////////////////////// bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { @@ -618,7 +624,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac ////////////////////////////////////////////////////////////////////////// -ScValue *BaseFrame::scGetProperty(const char *name) { +ScValue *BaseFrame::scGetProperty(const Common::String &name) { if (!_scValue) { _scValue = new ScValue(_gameRef); } @@ -627,7 +633,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("frame"); return _scValue; } @@ -635,7 +641,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Delay") == 0) { + else if (name == "Delay") { _scValue->setInt(_delay); return _scValue; } @@ -643,7 +649,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Keyframe ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyframe") == 0) { + else if (name == "Keyframe") { _scValue->setBool(_keyframe); return _scValue; } @@ -651,7 +657,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // KillSounds ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KillSounds") == 0) { + else if (name == "KillSounds") { _scValue->setBool(_killSound); return _scValue; } @@ -659,7 +665,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MoveX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveX") == 0) { + else if (name == "MoveX") { _scValue->setInt(_moveX); return _scValue; } @@ -667,7 +673,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MoveY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveY") == 0) { + else if (name == "MoveY") { _scValue->setInt(_moveY); return _scValue; } @@ -675,7 +681,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumSubframes (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumSubframes") == 0) { + else if (name == "NumSubframes") { _scValue->setInt(_subframes.size()); return _scValue; } @@ -683,7 +689,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumEvents (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumEvents") == 0) { + else if (name == "NumEvents") { _scValue->setInt(_applyEvent.size()); return _scValue; } diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index ea5467b6fe..7c5d893e70 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -41,11 +41,10 @@ class ScStack; class BaseFrame: public BaseScriptable { public: bool _killSound; - bool _keyframe; + void stopSound(); bool oneTimeDisplay(BaseObject *owner, bool muted = false); DECLARE_PERSISTENT(BaseFrame, BaseScriptable) - BaseSound *_sound; - bool _editorExpanded; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); bool saveAsText(BaseDynamicBuffer *buffer, int indent); int _moveY; @@ -61,11 +60,14 @@ public: BaseArray<const char *> _applyEvent; // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); - +private: + bool _keyframe; + bool _editorExpanded; + BaseSound *_sound; }; } // end of namespace Wintermute diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 7b0024414e..f0b1171ca4 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -2241,27 +2241,27 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *BaseGame::scGetProperty(const char *name) { +ScValue *BaseGame::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("game"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { + else if (name == "Name") { _scValue->setString(getName()); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Hwnd (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Hwnd") == 0) { + else if (name == "Hwnd") { _scValue->setInt((int)_renderer->_window); return _scValue; } @@ -2269,7 +2269,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // CurrentTime (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentTime") == 0) { + else if (name == "CurrentTime") { _scValue->setInt((int)_timer); return _scValue; } @@ -2277,7 +2277,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // WindowsTime (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowsTime") == 0) { + else if (name == "WindowsTime") { _scValue->setInt((int)g_system->getMillis()); return _scValue; } @@ -2285,7 +2285,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // WindowedMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowedMode") == 0) { + else if (name == "WindowedMode") { _scValue->setBool(_renderer->_windowed); return _scValue; } @@ -2293,7 +2293,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MouseX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { + else if (name == "MouseX") { _scValue->setInt(_mousePos.x); return _scValue; } @@ -2301,7 +2301,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MouseY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { + else if (name == "MouseY") { _scValue->setInt(_mousePos.y); return _scValue; } @@ -2309,7 +2309,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MainObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { + else if (name == "MainObject") { _scValue->setNative(_mainObject, true); return _scValue; } @@ -2317,7 +2317,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ActiveObject (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ActiveObject") == 0) { + else if (name == "ActiveObject") { _scValue->setNative(_activeObject, true); return _scValue; } @@ -2325,7 +2325,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScreenWidth (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenWidth") == 0) { + else if (name == "ScreenWidth") { _scValue->setInt(_renderer->_width); return _scValue; } @@ -2333,7 +2333,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScreenHeight (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenHeight") == 0) { + else if (name == "ScreenHeight") { _scValue->setInt(_renderer->_height); return _scValue; } @@ -2341,7 +2341,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Interactive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Interactive") == 0) { + else if (name == "Interactive") { _scValue->setBool(_interactive); return _scValue; } @@ -2349,7 +2349,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // DebugMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DebugMode") == 0) { + else if (name == "DebugMode") { _scValue->setBool(_debugDebugMode); return _scValue; } @@ -2357,7 +2357,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SoundAvailable (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundAvailable") == 0) { + else if (name == "SoundAvailable") { _scValue->setBool(_soundMgr->_soundAvailable); return _scValue; } @@ -2365,7 +2365,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SFXVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SFXVolume") == 0) { + else if (name == "SFXVolume") { _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); return _scValue; @@ -2374,7 +2374,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SpeechVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SpeechVolume") == 0) { + else if (name == "SpeechVolume") { _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); return _scValue; @@ -2383,7 +2383,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MusicVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicVolume") == 0) { + else if (name == "MusicVolume") { _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); return _scValue; @@ -2392,7 +2392,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MasterVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MasterVolume") == 0) { + else if (name == "MasterVolume") { _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getMasterVolumePercent()); return _scValue; @@ -2401,7 +2401,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Keyboard (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyboard") == 0) { + else if (name == "Keyboard") { if (_keyboardState) { _scValue->setNative(_keyboardState, true); } else { @@ -2414,7 +2414,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Subtitles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtitles") == 0) { + else if (name == "Subtitles") { _scValue->setBool(_subtitles); return _scValue; } @@ -2422,14 +2422,14 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesSpeed ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesSpeed") == 0) { + else if (name == "SubtitlesSpeed") { _scValue->setInt(_subtitlesSpeed); return _scValue; } ////////////////////////////////////////////////////////////////////////// // VideoSubtitles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VideoSubtitles") == 0) { + else if (name == "VideoSubtitles") { _scValue->setBool(_videoSubtitles); return _scValue; } @@ -2437,7 +2437,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // FPS (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FPS") == 0) { + else if (name == "FPS") { _scValue->setInt(_fps); return _scValue; } @@ -2445,7 +2445,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AcceleratedMode / Accelerated (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { + else if (name == "AcceleratedMode" || name == "Accelerated") { _scValue->setBool(_useD3D); return _scValue; } @@ -2453,7 +2453,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TextEncoding ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextEncoding") == 0) { + else if (name == "TextEncoding") { _scValue->setInt(_textEncoding); return _scValue; } @@ -2461,7 +2461,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TextRTL ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextRTL") == 0) { + else if (name == "TextRTL") { _scValue->setBool(_textRTL); return _scValue; } @@ -2469,7 +2469,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SoundBufferSize ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundBufferSize") == 0) { + else if (name == "SoundBufferSize") { _scValue->setInt(_soundBufferSizeSec); return _scValue; } @@ -2477,7 +2477,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SuspendedRendering ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuspendedRendering") == 0) { + else if (name == "SuspendedRendering") { _scValue->setBool(_suspendedRendering); return _scValue; } @@ -2485,7 +2485,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SuppressScriptErrors ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuppressScriptErrors") == 0) { + else if (name == "SuppressScriptErrors") { _scValue->setBool(_suppressScriptErrors); return _scValue; } @@ -2494,7 +2494,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Frozen ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Frozen") == 0) { + else if (name == "Frozen") { _scValue->setBool(_state == GAME_FROZEN); return _scValue; } @@ -2502,7 +2502,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccTTSEnabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSEnabled") == 0) { + else if (name == "AccTTSEnabled") { _scValue->setBool(false); return _scValue; } @@ -2510,7 +2510,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccTTSTalk ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSTalk") == 0) { + else if (name == "AccTTSTalk") { _scValue->setBool(false); return _scValue; } @@ -2518,7 +2518,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccTTSCaptions ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSCaptions") == 0) { + else if (name == "AccTTSCaptions") { _scValue->setBool(false); return _scValue; } @@ -2526,7 +2526,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccTTSKeypress ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSKeypress") == 0) { + else if (name == "AccTTSKeypress") { _scValue->setBool(false); return _scValue; } @@ -2534,7 +2534,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccKeyboardEnabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardEnabled") == 0) { + else if (name == "AccKeyboardEnabled") { _scValue->setBool(false); return _scValue; } @@ -2542,7 +2542,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccKeyboardCursorSkip ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { + else if (name == "AccKeyboardCursorSkip") { _scValue->setBool(false); return _scValue; } @@ -2550,7 +2550,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccKeyboardPause ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardPause") == 0) { + else if (name == "AccKeyboardPause") { _scValue->setBool(false); return _scValue; } @@ -2558,7 +2558,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AutorunDisabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutorunDisabled") == 0) { + else if (name == "AutorunDisabled") { _scValue->setBool(_autorunDisabled); return _scValue; } @@ -2566,7 +2566,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SaveDirectory (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveDirectory") == 0) { + else if (name == "SaveDirectory") { AnsiString dataDir = "saves/"; // TODO: This is just to avoid telling the engine actual paths. _scValue->setString(dataDir.c_str()); return _scValue; @@ -2575,7 +2575,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AutoSaveOnExit ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveOnExit") == 0) { + else if (name == "AutoSaveOnExit") { _scValue->setBool(_autoSaveOnExit); return _scValue; } @@ -2583,7 +2583,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AutoSaveSlot ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveSlot") == 0) { + else if (name == "AutoSaveSlot") { _scValue->setInt(_autoSaveSlot); return _scValue; } @@ -2591,7 +2591,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // CursorHidden ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorHidden") == 0) { + else if (name == "CursorHidden") { _scValue->setBool(_cursorHidden); return _scValue; } @@ -2599,7 +2599,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Platform (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Platform") == 0) { + else if (name == "Platform") { _scValue->setString(BasePlatform::getPlatformName().c_str()); return _scValue; } @@ -2607,7 +2607,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // DeviceType (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeviceType") == 0) { + else if (name == "DeviceType") { _scValue->setString(getDeviceType().c_str()); return _scValue; } @@ -2615,7 +2615,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MostRecentSaveSlot") == 0) { + else if (name == "MostRecentSaveSlot") { if (!ConfMan.hasKey("most_recent_saveslot")) { _scValue->setInt(-1); } else { @@ -2627,7 +2627,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Store (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Store") == 0) { + else if (name == "Store") { _scValue->setNULL(); error("Request for a SXStore-object, which is not supported by ScummVM"); diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 8c337e82e9..0f764b3d03 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -164,7 +164,7 @@ public: virtual bool externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index fd5f2b0e1d..da7baafd2d 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -103,13 +103,13 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack * ////////////////////////////////////////////////////////////////////////// -ScValue *BaseKeyboardState::scGetProperty(const char *name) { +ScValue *BaseKeyboardState::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("keyboard"); return _scValue; } @@ -117,7 +117,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Key ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Key") == 0) { + else if (name == "Key") { if (_currentPrintable) { char key[2]; key[0] = (char)_currentCharCode; @@ -133,7 +133,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Printable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Printable") == 0) { + else if (name == "Printable") { _scValue->setBool(_currentPrintable); return _scValue; } @@ -141,7 +141,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // KeyCode ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KeyCode") == 0) { + else if (name == "KeyCode") { _scValue->setInt(_currentCharCode); return _scValue; } @@ -149,7 +149,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // IsShift ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsShift") == 0) { + else if (name == "IsShift") { _scValue->setBool(_currentShift); return _scValue; } @@ -157,7 +157,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // IsAlt ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsAlt") == 0) { + else if (name == "IsAlt") { _scValue->setBool(_currentAlt); return _scValue; } @@ -165,7 +165,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // IsControl ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsControl") == 0) { + else if (name == "IsControl") { _scValue->setBool(_currentControl); return _scValue; } else { diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h index ebc0c83ee1..dfd0efdec0 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -59,7 +59,7 @@ public: static bool isAltDown(); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index b6a6887624..eba8416485 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -531,13 +531,13 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// -ScValue *BaseObject::scGetProperty(const char *name) { +ScValue *BaseObject::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("object"); return _scValue; } @@ -545,7 +545,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { + else if (name == "Caption") { _scValue->setString(getCaption(1)); return _scValue; } @@ -553,7 +553,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { + else if (name == "X") { _scValue->setInt(_posX); return _scValue; } @@ -561,7 +561,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { + else if (name == "Y") { _scValue->setInt(_posY); return _scValue; } @@ -569,7 +569,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Height (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { + else if (name == "Height") { _scValue->setInt(getHeight()); return _scValue; } @@ -577,7 +577,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Ready (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Ready") == 0) { + else if (name == "Ready") { _scValue->setBool(_ready); return _scValue; } @@ -585,7 +585,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Movable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Movable") == 0) { + else if (name == "Movable") { _scValue->setBool(_movable); return _scValue; } @@ -593,7 +593,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Registrable/Interactive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + else if (name == "Registrable" || name == "Interactive") { _scValue->setBool(_registrable); return _scValue; } @@ -601,21 +601,21 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Zoomable/Scalable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + else if (name == "Zoomable" || name == "Scalable") { _scValue->setBool(_zoomable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotatable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotatable") == 0) { + else if (name == "Rotatable") { _scValue->setBool(_rotatable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { + else if (name == "AlphaColor") { _scValue->setInt((int)_alphaColor); return _scValue; } @@ -623,7 +623,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // BlendMode ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "BlendMode") == 0) { + else if (name == "BlendMode") { _scValue->setInt((int)_blendMode); return _scValue; } @@ -631,7 +631,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Scale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { + else if (name == "Scale") { if (_scale < 0) { _scValue->setNULL(); } else { @@ -643,7 +643,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScaleX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleX") == 0) { + else if (name == "ScaleX") { if (_scaleX < 0) { _scValue->setNULL(); } else { @@ -655,7 +655,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScaleY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleY") == 0) { + else if (name == "ScaleY") { if (_scaleY < 0) { _scValue->setNULL(); } else { @@ -667,7 +667,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // RelativeScale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeScale") == 0) { + else if (name == "RelativeScale") { _scValue->setFloat((double)_relativeScale); return _scValue; } @@ -675,7 +675,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Rotate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotate") == 0) { + else if (name == "Rotate") { if (!_rotateValid) { _scValue->setNULL(); } else { @@ -687,7 +687,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // RelativeRotate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeRotate") == 0) { + else if (name == "RelativeRotate") { _scValue->setFloat((double)_relativeRotate); return _scValue; } @@ -695,14 +695,14 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Colorable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Colorable") == 0) { + else if (name == "Colorable") { _scValue->setBool(_shadowable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // SoundPanning ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundPanning") == 0) { + else if (name == "SoundPanning") { _scValue->setBool(_autoSoundPanning); return _scValue; } @@ -710,7 +710,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SaveState ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveState") == 0) { + else if (name == "SaveState") { _scValue->setBool(_saveState); return _scValue; } @@ -718,7 +718,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NonIntMouseEvents ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NonIntMouseEvents") == 0) { + else if (name == "NonIntMouseEvents") { _scValue->setBool(_nonIntMouseEvents); return _scValue; } @@ -726,7 +726,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccCaption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccCaption") == 0) { + else if (name == "AccCaption") { _scValue->setNULL(); return _scValue; } else { diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index 34adbdb585..d7d91a25f6 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -136,7 +136,7 @@ public: public: // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h index 4fed5ffc2e..67f9613461 100644 --- a/engines/wintermute/base/base_quick_msg.h +++ b/engines/wintermute/base/base_quick_msg.h @@ -37,10 +37,10 @@ class BaseQuickMsg : public BaseClass { public: char *getText(); uint32 _startTime; - char *_text; - BaseQuickMsg(BaseGame *inGame, const char *Text); + BaseQuickMsg(BaseGame *inGame, const char *text); virtual ~BaseQuickMsg(); - +private: + char *_text; }; } // end of namespace Wintermute diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index e332ffe9ff..0bc5975e51 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -327,13 +327,13 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// -ScValue *BaseRegion::scGetProperty(const char *name) { +ScValue *BaseRegion::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("region"); return _scValue; } @@ -341,7 +341,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { + else if (name == "Name") { _scValue->setString(getName()); return _scValue; } @@ -349,7 +349,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { + else if (name == "Active") { _scValue->setBool(_active); return _scValue; } @@ -357,7 +357,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumPoints ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumPoints") == 0) { + else if (name == "NumPoints") { _scValue->setInt(_points.size()); return _scValue; } else { diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 8dd02fe928..464f25be2f 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -36,9 +36,6 @@ namespace Wintermute { class BaseRegion : public BaseObject { public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; void cleanup(); bool mimic(BaseRegion *region, float scale = 100.0f, int x = 0, int y = 0); bool getBoundingRect(Rect32 *rect); @@ -58,10 +55,14 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); +private: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; }; } // end of namespace Wintermute diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index d3e6078d43..c5d5e82f76 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -219,13 +219,13 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t ////////////////////////////////////////////////////////////////////////// -ScValue *BaseScriptHolder::scGetProperty(const char *name) { +ScValue *BaseScriptHolder::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("script_holder"); return _scValue; } @@ -233,7 +233,7 @@ ScValue *BaseScriptHolder::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { + else if (name == "Name") { _scValue->setString(getName()); return _scValue; } @@ -241,7 +241,7 @@ ScValue *BaseScriptHolder::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Filename (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Filename") == 0) { + else if (name == "Filename") { _scValue->setString(_filename); return _scValue; } else { diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index 0c3d7a1a70..5fd0dbec9c 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -59,7 +59,7 @@ public: BaseArray<ScScript *> _scripts; // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 143934402b..a2dd8b00e7 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -76,12 +76,12 @@ bool BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thi ////////////////////////////////////////////////////////////////////////// -ScValue *BaseScriptable::scGetProperty(const char *name) { +ScValue *BaseScriptable::scGetProperty(const Common::String &name) { if (!_scProp) { _scProp = new ScValue(_gameRef); } if (_scProp) { - return _scProp->getProp(name); + return _scProp->getProp(name.c_str()); // TODO: Change to Common::String } else { return NULL; } diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index b006e6e07c..fbe14fc299 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -50,7 +50,7 @@ public: // high level scripting interface virtual bool canHandleMethod(const char *eventMethod); virtual bool scSetProperty(const char *name, ScValue *value); - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); virtual void *scToMemBuffer(); diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index e2dd8bbd39..468af1bd75 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -121,6 +121,13 @@ bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, floa return display(x, y, registerOwner, zoomX, zoomY, alpha); } +bool BaseSprite::isChanged() { + return _changed; +} + +bool BaseSprite::isFinished() { + return _finished; +} ////////////////////////////////////////////////////////////////////// bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { @@ -686,13 +693,13 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// -ScValue *BaseSprite::scGetProperty(const char *name) { +ScValue *BaseSprite::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("sprite"); return _scValue; } @@ -700,7 +707,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumFrames (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumFrames") == 0) { + else if (name == "NumFrames") { _scValue->setInt(_frames.size()); return _scValue; } @@ -708,7 +715,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentFrame") == 0) { + else if (name == "CurrentFrame") { _scValue->setInt(_currentFrame); return _scValue; } @@ -716,7 +723,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { + else if (name == "PixelPerfect") { _scValue->setBool(_precise); return _scValue; } @@ -724,7 +731,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Looping ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Looping") == 0) { + else if (name == "Looping") { _scValue->setBool(_looping); return _scValue; } @@ -732,7 +739,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Owner (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Owner") == 0) { + else if (name == "Owner") { if (_owner == NULL) { _scValue->setNULL(); } else { @@ -744,7 +751,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Finished (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Finished") == 0) { + else if (name == "Finished") { _scValue->setBool(_finished); return _scValue; } @@ -752,7 +759,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Paused (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Paused") == 0) { + else if (name == "Paused") { _scValue->setBool(_paused); return _scValue; } else { @@ -804,9 +811,7 @@ const char *BaseSprite::scToString() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::killAllSounds() { for (uint32 i = 0; i < _frames.size(); i++) { - if (_frames[i]->_sound) { - _frames[i]->_sound->stop(); - } + _frames[i]->stopSound(); } return STATUS_OK; } diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index c861ca9930..1d244c3a52 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -39,36 +39,21 @@ class BaseSurface; class BaseObject; class BaseSprite: public BaseScriptHolder { public: - bool killAllSounds(); BaseSurface *getSurface(); - char *_editorBgFile; - int _editorBgOffsetX; - int _editorBgOffsetY; - int _editorBgAlpha; - bool _streamed; - bool _streamedKeepLoaded; void cleanup(); void setDefaults(); - bool _precise; DECLARE_PERSISTENT(BaseSprite, BaseScriptHolder) - bool _editorAllFrames; bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _moveY; int _moveX; bool display(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool getCurrentFrame(float zoomX = 100, float zoomY = 100); - bool _canBreak; - bool _editorMuted; - bool _continuous; void reset(); - BaseObject *_owner; - bool _changed; - bool _paused; - bool _finished; + bool isChanged(); + bool isFinished(); bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - uint32 _lastFrameTime; bool draw(int x, int y, BaseObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; @@ -79,10 +64,28 @@ public: bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); +private: + BaseObject *_owner; + bool _canBreak; + bool _changed; + bool _editorAllFrames; + char *_editorBgFile; + int _editorBgOffsetX; + int _editorBgOffsetY; + int _editorBgAlpha; + bool _editorMuted; + bool _finished; + bool _continuous; + uint32 _lastFrameTime; + bool _precise; + bool _paused; + bool _streamed; + bool _streamedKeepLoaded; + bool killAllSounds(); }; } // end of namespace Wintermute diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 2ff12e8deb..77cc522ae7 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -226,6 +226,9 @@ void BaseSubFrame::setRect(Rect32 rect) { _rect = rect; } +const char* BaseSubFrame::getSurfaceFilename() { + return _surfaceFilename; +} ////////////////////////////////////////////////////////////////////// bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { @@ -443,7 +446,7 @@ bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS ////////////////////////////////////////////////////////////////////////// -ScValue *BaseSubFrame::scGetProperty(const char *name) { +ScValue *BaseSubFrame::scGetProperty(const Common::String &name) { if (!_scValue) { _scValue = new ScValue(_gameRef); } @@ -452,7 +455,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("subframe"); return _scValue; } @@ -460,7 +463,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { + else if (name == "AlphaColor") { _scValue->setInt((int)_alpha); return _scValue; @@ -469,7 +472,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TransparentColor (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TransparentColor") == 0) { + else if (name == "TransparentColor") { _scValue->setInt((int)_transparent); return _scValue; } @@ -477,7 +480,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Is2DOnly ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is2DOnly") == 0) { + else if (name == "Is2DOnly") { _scValue->setBool(_2DOnly); return _scValue; } @@ -485,7 +488,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Is3DOnly ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is3DOnly") == 0) { + else if (name == "Is3DOnly") { _scValue->setBool(_3DOnly); return _scValue; } @@ -493,7 +496,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MirrorX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorX") == 0) { + else if (name == "MirrorX") { _scValue->setBool(_mirrorX); return _scValue; } @@ -501,7 +504,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MirrorY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorY") == 0) { + else if (name == "MirrorY") { _scValue->setBool(_mirrorY); return _scValue; } @@ -509,7 +512,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Decoration ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { + else if (name == "Decoration") { _scValue->setBool(_decoration); return _scValue; } @@ -517,7 +520,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // HotspotX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotX") == 0) { + else if (name == "HotspotX") { _scValue->setInt(_hotspotX); return _scValue; } @@ -525,7 +528,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // HotspotY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotY") == 0) { + else if (name == "HotspotY") { _scValue->setInt(_hotspotY); return _scValue; } else { diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index b174c6e5f0..c173ae69d1 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -54,6 +54,7 @@ public: bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + const char* getSurfaceFilename(); int _hotspotX; int _hotspotY; @@ -65,6 +66,7 @@ public: private: bool _wantsDefaultRect; Rect32 _rect; + char *_surfaceFilename; public: bool _cKDefault; byte _cKRed; @@ -72,7 +74,6 @@ public: byte _cKBlue; int _lifeTime; bool _keepLoaded; - char *_surfaceFilename; bool _2DOnly; bool _3DOnly; @@ -80,7 +81,7 @@ public: BaseSurface *_surface; // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 4e3fc2239e..bab4d4609e 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -604,41 +604,41 @@ bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt } ////////////////////////////////////////////////////////////////////////// -ScValue *PartEmitter::scGetProperty(const char *name) { +ScValue *PartEmitter::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("particle-emitter"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { + else if (name == "X") { _scValue->setInt(_posX); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { + else if (name == "Y") { _scValue->setInt(_posY); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { + else if (name == "Width") { _scValue->setInt(_width); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { + else if (name == "Height") { _scValue->setInt(_height); return _scValue; } @@ -646,21 +646,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Scale1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { + else if (name == "Scale1") { _scValue->setFloat(_scale1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scale2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { + else if (name == "Scale2") { _scValue->setFloat(_scale2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScaleZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { + else if (name == "ScaleZBased") { _scValue->setBool(_scaleZBased); return _scValue; } @@ -668,21 +668,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Velocity1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { + else if (name == "Velocity1") { _scValue->setFloat(_velocity1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Velocity2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { + else if (name == "Velocity2") { _scValue->setFloat(_velocity2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // VelocityZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { + else if (name == "VelocityZBased") { _scValue->setBool(_velocityZBased); return _scValue; } @@ -690,21 +690,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // LifeTime1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { + else if (name == "LifeTime1") { _scValue->setInt(_lifeTime1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTime2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { + else if (name == "LifeTime2") { _scValue->setInt(_lifeTime2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTimeZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { + else if (name == "LifeTimeZBased") { _scValue->setBool(_lifeTimeZBased); return _scValue; } @@ -712,14 +712,14 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Angle1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { + else if (name == "Angle1") { _scValue->setInt(_angle1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Angle2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { + else if (name == "Angle2") { _scValue->setInt(_angle2); return _scValue; } @@ -727,14 +727,14 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AngVelocity1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { + else if (name == "AngVelocity1") { _scValue->setFloat(_angVelocity1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AngVelocity2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { + else if (name == "AngVelocity2") { _scValue->setFloat(_angVelocity2); return _scValue; } @@ -742,14 +742,14 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Rotation1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { + else if (name == "Rotation1") { _scValue->setFloat(_rotation1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotation2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { + else if (name == "Rotation2") { _scValue->setFloat(_rotation2); return _scValue; } @@ -757,21 +757,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Alpha1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { + else if (name == "Alpha1") { _scValue->setInt(_alpha1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Alpha2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { + else if (name == "Alpha2") { _scValue->setInt(_alpha2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaTimeBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { + else if (name == "AlphaTimeBased") { _scValue->setBool(_alphaTimeBased); return _scValue; } @@ -779,14 +779,14 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MaxParticles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { + else if (name == "MaxParticles") { _scValue->setInt(_maxParticles); return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumLiveParticles (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumLiveParticles") == 0) { + else if (name == "NumLiveParticles") { int numAlive = 0; for (uint32 i = 0; i < _particles.size(); i++) { if (_particles[i] && !_particles[i]->_isDead) { @@ -800,21 +800,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // GenerationInterval ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { + else if (name == "GenerationInterval") { _scValue->setInt(_genInterval); return _scValue; } ////////////////////////////////////////////////////////////////////////// // GenerationAmount ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { + else if (name == "GenerationAmount") { _scValue->setInt(_genAmount); return _scValue; } ////////////////////////////////////////////////////////////////////////// // MaxBatches ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { + else if (name == "MaxBatches") { _scValue->setInt(_maxBatches); return _scValue; } @@ -822,14 +822,14 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // FadeInTime ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { + else if (name == "FadeInTime") { _scValue->setInt(_fadeInTime); return _scValue; } ////////////////////////////////////////////////////////////////////////// // FadeOutTime ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { + else if (name == "FadeOutTime") { _scValue->setInt(_fadeOutTime); return _scValue; } @@ -837,21 +837,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // GrowthRate1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { + else if (name == "GrowthRate1") { _scValue->setFloat(_growthRate1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // GrowthRate2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { + else if (name == "GrowthRate2") { _scValue->setFloat(_growthRate2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // ExponentialGrowth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { + else if (name == "ExponentialGrowth") { _scValue->setBool(_exponentialGrowth); return _scValue; } @@ -859,7 +859,7 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // UseRegion ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { + else if (name == "UseRegion") { _scValue->setBool(_useRegion); return _scValue; } @@ -867,7 +867,7 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // EmitEvent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { + else if (name == "EmitEvent") { if (!_emitEvent) { _scValue->setNULL(); } else { diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index 9a35cd9bbc..f2c8f139f1 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -63,7 +63,7 @@ public: BaseArray<PartForce *> _forces; // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index 5ed07f0da6..613cbd0758 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -140,13 +140,13 @@ bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *SXArray::scGetProperty(const char *name) { +ScValue *SXArray::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("array"); return _scValue; } @@ -154,7 +154,7 @@ ScValue *SXArray::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { + else if (name == "Length") { _scValue->setInt(_length); return _scValue; } @@ -164,7 +164,7 @@ ScValue *SXArray::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else { char paramName[20]; - if (validNumber(name, paramName)) { + if (validNumber(name.c_str(), paramName)) { // TODO: Change to Common::String return _values->getProp(paramName); } else { return _scValue; diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index d9805ef94f..284c547a27 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -41,7 +41,7 @@ public: SXArray(BaseGame *inGame, ScStack *stack); SXArray(BaseGame *inGame); virtual ~SXArray(); - ScValue *scGetProperty(const char *name); + ScValue *scGetProperty(const Common::String &name); bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 11eead3b9c..5aa069d0b2 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -203,13 +203,13 @@ bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *SXDate::scGetProperty(const char *name) { +ScValue *SXDate::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("date"); return _scValue; } else { @@ -224,7 +224,7 @@ bool SXDate::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name")==0){ + if (name == "Name")==0){ setName(value->getString()); return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index f6f04dd7e6..062b7c55c7 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -40,7 +40,7 @@ public: DECLARE_PERSISTENT(SXDate, BaseScriptable) SXDate(BaseGame *inGame, ScStack *Stack); virtual ~SXDate(); - ScValue *scGetProperty(const char *name); + ScValue *scGetProperty(const Common::String &name); bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 2dc385b015..a1d39c5d0a 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -640,13 +640,13 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *SXFile::scGetProperty(const char *name) { +ScValue *SXFile::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("file"); return _scValue; } @@ -654,7 +654,7 @@ ScValue *SXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Filename (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Filename") == 0) { + if (name == "Filename") { _scValue->setString(_filename); return _scValue; } @@ -662,7 +662,7 @@ ScValue *SXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Position (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Position") == 0) { + else if (name == "Position") { _scValue->setInt(getPos()); return _scValue; } @@ -670,7 +670,7 @@ ScValue *SXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Length (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { + else if (name == "Length") { _scValue->setInt(getLength()); return _scValue; } @@ -678,7 +678,7 @@ ScValue *SXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TextMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextMode") == 0) { + else if (name == "TextMode") { _scValue->setBool(_textMode); return _scValue; } @@ -686,7 +686,7 @@ ScValue *SXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccessMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccessMode") == 0) { + else if (name == "AccessMode") { _scValue->setInt(_mode); return _scValue; } else { diff --git a/engines/wintermute/base/scriptables/script_ext_file.h b/engines/wintermute/base/scriptables/script_ext_file.h index b91a53e695..f7c72fcfb3 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.h +++ b/engines/wintermute/base/scriptables/script_ext_file.h @@ -40,7 +40,7 @@ class BaseFile; class SXFile : public BaseScriptable { public: DECLARE_PERSISTENT(SXFile, BaseScriptable) - ScValue *scGetProperty(const char *name); + ScValue *scGetProperty(const Common::String &name); bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 598b80cff3..d816fbec65 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -250,13 +250,13 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *SXMath::scGetProperty(const char *name) { +ScValue *SXMath::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("math"); return _scValue; } @@ -264,7 +264,7 @@ ScValue *SXMath::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // PI ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PI") == 0) { + else if (name == "PI") { _scValue->setFloat(M_PI); return _scValue; } else { diff --git a/engines/wintermute/base/scriptables/script_ext_math.h b/engines/wintermute/base/scriptables/script_ext_math.h index f86d59fe7b..48c43ea7e8 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.h +++ b/engines/wintermute/base/scriptables/script_ext_math.h @@ -39,7 +39,7 @@ public: DECLARE_PERSISTENT(SXMath, BaseScriptable) SXMath(BaseGame *inGame); virtual ~SXMath(); - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); private: diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 5ed9bd5313..8f05b7bff6 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -447,13 +447,13 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt ////////////////////////////////////////////////////////////////////////// -ScValue *SXMemBuffer::scGetProperty(const char *name) { +ScValue *SXMemBuffer::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("membuffer"); return _scValue; } @@ -461,7 +461,7 @@ ScValue *SXMemBuffer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Size (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Size") == 0) { + if (name == "Size") { _scValue->setInt(_size); return _scValue; } else { diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h index d2662b3036..1527a323dc 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -38,7 +38,7 @@ class SXMemBuffer : public BaseScriptable { public: virtual int scCompare(BaseScriptable *Val); DECLARE_PERSISTENT(SXMemBuffer, BaseScriptable) - ScValue *scGetProperty(const char *name); + ScValue *scGetProperty(const Common::String &name); bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index 8d87a92dc1..5f7da1c2dd 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -343,20 +343,20 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *SXString::scGetProperty(const char *name) { +ScValue *SXString::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("string"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Length (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { + else if (name == "Length") { if (_gameRef->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::utf8ToWide(_string); _scValue->setInt(wstr.size()); @@ -369,7 +369,7 @@ ScValue *SXString::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Capacity") == 0) { + else if (name == "Capacity") { _scValue->setInt(_capacity); return _scValue; } else { diff --git a/engines/wintermute/base/scriptables/script_ext_string.h b/engines/wintermute/base/scriptables/script_ext_string.h index 255b9c57eb..00bffab3a9 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.h +++ b/engines/wintermute/base/scriptables/script_ext_string.h @@ -38,7 +38,7 @@ class SXString : public BaseScriptable { public: virtual int scCompare(BaseScriptable *Val); DECLARE_PERSISTENT(SXString, BaseScriptable) - ScValue *scGetProperty(const char *name); + ScValue *scGetProperty(const Common::String &name); bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); void scSetString(const char *val); diff --git a/engines/wintermute/ui/ui_button.cpp b/engines/wintermute/ui/ui_button.cpp index d4acd3019f..7967d566f9 100644 --- a/engines/wintermute/ui/ui_button.cpp +++ b/engines/wintermute/ui/ui_button.cpp @@ -1082,13 +1082,13 @@ bool UIButton::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *UIButton::scGetProperty(const char *name) { +ScValue *UIButton::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("button"); return _scValue; } @@ -1096,7 +1096,7 @@ ScValue *UIButton::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextAlign") == 0) { + else if (name == "TextAlign") { _scValue->setInt(_align); return _scValue; } @@ -1104,21 +1104,21 @@ ScValue *UIButton::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Focusable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Focusable") == 0) { + else if (name == "Focusable") { _scValue->setBool(_canFocus); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Pressed ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pressed") == 0) { + else if (name == "Pressed") { _scValue->setBool(_stayPressed); return _scValue; } ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { + else if (name == "PixelPerfect") { _scValue->setBool(_pixelPerfect); return _scValue; } else { diff --git a/engines/wintermute/ui/ui_button.h b/engines/wintermute/ui/ui_button.h index 9342f766cc..93333a2534 100644 --- a/engines/wintermute/ui/ui_button.h +++ b/engines/wintermute/ui/ui_button.h @@ -69,7 +69,7 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ui/ui_edit.cpp b/engines/wintermute/ui/ui_edit.cpp index 1352a0d942..a3283d5a01 100644 --- a/engines/wintermute/ui/ui_edit.cpp +++ b/engines/wintermute/ui/ui_edit.cpp @@ -398,13 +398,13 @@ bool UIEdit::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *UIEdit::scGetProperty(const char *name) { +ScValue *UIEdit::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("editor"); return _scValue; } @@ -412,7 +412,7 @@ ScValue *UIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SelStart ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelStart") == 0) { + else if (name == "SelStart") { _scValue->setInt(_selStart); return _scValue; } @@ -420,7 +420,7 @@ ScValue *UIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SelEnd ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SelEnd") == 0) { + else if (name == "SelEnd") { _scValue->setInt(_selEnd); return _scValue; } @@ -428,7 +428,7 @@ ScValue *UIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // CursorBlinkRate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorBlinkRate") == 0) { + else if (name == "CursorBlinkRate") { _scValue->setInt(_cursorBlinkRate); return _scValue; } @@ -436,7 +436,7 @@ ScValue *UIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // CursorChar ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorChar") == 0) { + else if (name == "CursorChar") { _scValue->setString(_cursorChar); return _scValue; } @@ -444,7 +444,7 @@ ScValue *UIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // FrameWidth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FrameWidth") == 0) { + else if (name == "FrameWidth") { _scValue->setInt(_frameWidth); return _scValue; } @@ -452,7 +452,7 @@ ScValue *UIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MaxLength ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxLength") == 0) { + else if (name == "MaxLength") { _scValue->setInt(_maxLength); return _scValue; } @@ -460,7 +460,7 @@ ScValue *UIEdit::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Text ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Text") == 0) { + else if (name == "Text") { if (_gameRef->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::ansiToWide(_text); _scValue->setString(StringUtil::wideToUtf8(wstr).c_str()); diff --git a/engines/wintermute/ui/ui_edit.h b/engines/wintermute/ui/ui_edit.h index 610629afb3..5bb31422b6 100644 --- a/engines/wintermute/ui/ui_edit.h +++ b/engines/wintermute/ui/ui_edit.h @@ -61,7 +61,7 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ui/ui_entity.cpp b/engines/wintermute/ui/ui_entity.cpp index c49cb5a240..1cb4e0926b 100644 --- a/engines/wintermute/ui/ui_entity.cpp +++ b/engines/wintermute/ui/ui_entity.cpp @@ -305,13 +305,13 @@ bool UIEntity::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *UIEntity::scGetProperty(const char *name) { +ScValue *UIEntity::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("entity container"); return _scValue; } @@ -319,7 +319,7 @@ ScValue *UIEntity::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Freezable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Freezable") == 0) { + else if (name == "Freezable") { if (_entity) { _scValue->setBool(_entity->_freezable); } else { diff --git a/engines/wintermute/ui/ui_entity.h b/engines/wintermute/ui/ui_entity.h index 3bf8068fd5..b5f4450071 100644 --- a/engines/wintermute/ui/ui_entity.h +++ b/engines/wintermute/ui/ui_entity.h @@ -48,7 +48,7 @@ public: bool setEntity(const char *filename); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ui/ui_object.cpp b/engines/wintermute/ui/ui_object.cpp index 772561247d..8e5bae993c 100644 --- a/engines/wintermute/ui/ui_object.cpp +++ b/engines/wintermute/ui/ui_object.cpp @@ -360,13 +360,13 @@ bool UIObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *UIObject::scGetProperty(const char *name) { +ScValue *UIObject::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("ui_object"); return _scValue; } @@ -374,7 +374,7 @@ ScValue *UIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { + else if (name == "Name") { _scValue->setString(getName()); return _scValue; } @@ -382,7 +382,7 @@ ScValue *UIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Parent (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Parent") == 0) { + else if (name == "Parent") { _scValue->setNative(_parent, true); return _scValue; } @@ -390,7 +390,7 @@ ScValue *UIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ParentNotify ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ParentNotify") == 0) { + else if (name == "ParentNotify") { _scValue->setBool(_parentNotify); return _scValue; } @@ -398,7 +398,7 @@ ScValue *UIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { + else if (name == "Width") { _scValue->setInt(_width); return _scValue; } @@ -406,7 +406,7 @@ ScValue *UIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { + else if (name == "Height") { _scValue->setInt(_height); return _scValue; } @@ -414,7 +414,7 @@ ScValue *UIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Visible ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Visible") == 0) { + else if (name == "Visible") { _scValue->setBool(_visible); return _scValue; } @@ -422,7 +422,7 @@ ScValue *UIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Disabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Disabled") == 0) { + else if (name == "Disabled") { _scValue->setBool(_disable); return _scValue; } @@ -430,7 +430,7 @@ ScValue *UIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Text ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Text") == 0) { + else if (name == "Text") { _scValue->setString(_text); return _scValue; } @@ -438,13 +438,13 @@ ScValue *UIObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NextSibling (RO) / PrevSibling (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NextSibling") == 0 || strcmp(name, "PrevSibling") == 0) { + else if (name == "NextSibling" || name == "PrevSibling") { _scValue->setNULL(); if (_parent && _parent->_type == UI_WINDOW) { UIWindow *win = (UIWindow *)_parent; for (uint32 i = 0; i < win->_widgets.size(); i++) { if (win->_widgets[i] == this) { - if (strcmp(name, "NextSibling") == 0) { + if (name == "NextSibling") { if (i < win->_widgets.size() - 1) { _scValue->setNative(win->_widgets[i + 1], true); } diff --git a/engines/wintermute/ui/ui_object.h b/engines/wintermute/ui/ui_object.h index 81c025d33b..ec2ea33de1 100644 --- a/engines/wintermute/ui/ui_object.h +++ b/engines/wintermute/ui/ui_object.h @@ -74,7 +74,7 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ui/ui_text.cpp b/engines/wintermute/ui/ui_text.cpp index 1844b640d0..2c10f176c7 100644 --- a/engines/wintermute/ui/ui_text.cpp +++ b/engines/wintermute/ui/ui_text.cpp @@ -431,13 +431,13 @@ bool UIText::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *UIText::scGetProperty(const char *name) { +ScValue *UIText::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("static"); return _scValue; } @@ -445,7 +445,7 @@ ScValue *UIText::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TextAlign ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextAlign") == 0) { + else if (name == "TextAlign") { _scValue->setInt(_textAlign); return _scValue; } @@ -453,7 +453,7 @@ ScValue *UIText::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // VerticalAlign ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VerticalAlign") == 0) { + else if (name == "VerticalAlign") { _scValue->setInt(_verticalAlign); return _scValue; } else { diff --git a/engines/wintermute/ui/ui_text.h b/engines/wintermute/ui/ui_text.h index d2f116b44b..da4d113500 100644 --- a/engines/wintermute/ui/ui_text.h +++ b/engines/wintermute/ui/ui_text.h @@ -49,7 +49,7 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/ui/ui_tiled_image.cpp b/engines/wintermute/ui/ui_tiled_image.cpp index 472f4a884e..2b337330c7 100644 --- a/engines/wintermute/ui/ui_tiled_image.cpp +++ b/engines/wintermute/ui/ui_tiled_image.cpp @@ -334,8 +334,8 @@ bool UITiledImage::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "TILED_IMAGE\n"); buffer->putTextIndent(indent, "{\n"); - if (_image && _image->_surfaceFilename) { - buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->_surfaceFilename); + if (_image && _image->getSurfaceFilename()) { + buffer->putTextIndent(indent + 2, "IMAGE=\"%s\"\n", _image->getSurfaceFilename()); } int h1, h2, h3; diff --git a/engines/wintermute/ui/ui_window.cpp b/engines/wintermute/ui/ui_window.cpp index 1f652bf64d..9606486efb 100644 --- a/engines/wintermute/ui/ui_window.cpp +++ b/engines/wintermute/ui/ui_window.cpp @@ -1014,13 +1014,13 @@ bool UIWindow::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *UIWindow::scGetProperty(const char *name) { +ScValue *UIWindow::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("window"); return _scValue; } @@ -1028,7 +1028,7 @@ ScValue *UIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumWidgets / NumControls (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumWidgets") == 0 || strcmp(name, "NumControls") == 0) { + else if (name == "NumWidgets" || name == "NumControls") { _scValue->setInt(_widgets.size()); return _scValue; } @@ -1036,7 +1036,7 @@ ScValue *UIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Exclusive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Exclusive") == 0) { + else if (name == "Exclusive") { _scValue->setBool(_mode == WINDOW_EXCLUSIVE); return _scValue; } @@ -1044,7 +1044,7 @@ ScValue *UIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SystemExclusive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SystemExclusive") == 0) { + else if (name == "SystemExclusive") { _scValue->setBool(_mode == WINDOW_SYSTEM_EXCLUSIVE); return _scValue; } @@ -1052,7 +1052,7 @@ ScValue *UIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Menu ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Menu") == 0) { + else if (name == "Menu") { _scValue->setBool(_isMenu); return _scValue; } @@ -1060,7 +1060,7 @@ ScValue *UIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // InGame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InGame") == 0) { + else if (name == "InGame") { _scValue->setBool(_inGame); return _scValue; } @@ -1068,7 +1068,7 @@ ScValue *UIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // PauseMusic ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseMusic") == 0) { + else if (name == "PauseMusic") { _scValue->setBool(_pauseMusic); return _scValue; } @@ -1076,7 +1076,7 @@ ScValue *UIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ClipContents ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClipContents") == 0) { + else if (name == "ClipContents") { _scValue->setBool(_clipContents); return _scValue; } @@ -1084,7 +1084,7 @@ ScValue *UIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Transparent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Transparent") == 0) { + else if (name == "Transparent") { _scValue->setBool(_transparent); return _scValue; } @@ -1092,7 +1092,7 @@ ScValue *UIWindow::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // FadeColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeColor") == 0) { + else if (name == "FadeColor") { _scValue->setInt((int)_fadeColor); return _scValue; } else { diff --git a/engines/wintermute/ui/ui_window.h b/engines/wintermute/ui/ui_window.h index cbd417a7d9..ae035c65c7 100644 --- a/engines/wintermute/ui/ui_window.h +++ b/engines/wintermute/ui/ui_window.h @@ -83,7 +83,7 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); |