diff options
author | Filippos Karapetis | 2019-05-27 14:41:54 +0300 |
---|---|---|
committer | Filippos Karapetis | 2019-05-27 14:53:41 +0300 |
commit | 9da3d22703a0dc230d505e9839c3e33cc313b403 (patch) | |
tree | ace8fe6b3c9a5f6c0170745902e7048f0d67aec4 /engines/sci/engine | |
parent | 87e13a50488fea398885eae8c46e01898a9fe41f (diff) | |
download | scummvm-rg350-9da3d22703a0dc230d505e9839c3e33cc313b403.tar.gz scummvm-rg350-9da3d22703a0dc230d505e9839c3e33cc313b403.tar.bz2 scummvm-rg350-9da3d22703a0dc230d505e9839c3e33cc313b403.zip |
SCI: Fix MSVC warnings
- Remove unused parameters
- Initialize potentially uninitialized variables
- Use Common::String instead of a fixed buffer
- Remove redundant parentheses
- Change float suffix to be uppercase
- Fix spacing
- Fix integer left shifts with boolean variables
- Fix potential division by zero
- Fix missing breaks
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/kpathing.cpp | 42 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 9 |
2 files changed, 33 insertions, 18 deletions
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 3177fbdd07..afa743b4b6 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -825,10 +825,10 @@ int PathfindingState::findNearPoint(const Common::Point &p, Polygon *polygon, Co u = ((p.x - p1.x) * (p2.x - p1.x) + (p.y - p1.y) * (p2.y - p1.y)) / (float)p1.sqrDist(p2); // Clip to edge - if (u < 0.0f) - u = 0.0f; - if (u > 1.0f) - u = 1.0f; + if (u < 0.0F) + u = 0.0F; + if (u > 1.0F) + u = 1.0F; new_point.x = p1.x + u * (p2.x - p1.x); new_point.y = p1.y + u * (p2.y - p1.y); @@ -1022,6 +1022,9 @@ static Common::Point *fixup_start_point(PathfindingState *s, const Common::Point if (start != *new_start) s->_prependPoint = new Common::Point(start); } + break; + default: + break; } ++it; @@ -1079,6 +1082,9 @@ static Common::Point *fixup_end_point(PathfindingState *s, const Common::Point & if ((type == POLY_NEAREST_ACCESS) && (end != *new_end)) s->_appendPoint = new Common::Point(end); } + break; + default: + break; } ++it; @@ -1499,8 +1505,10 @@ static reg_t output_path(PathfindingState *p, EngineState *s) { int offset = 0; - if (p->_prependPoint) - writePoint(arrayRef, offset++, *p->_prependPoint); + if (p->_prependPoint) { + writePoint(arrayRef, offset, *p->_prependPoint); + offset++; + } vertex = p->vertex_end; for (int i = path_len - 1; i >= 0; i--) { @@ -1820,8 +1828,8 @@ reg_t kIntersections(EngineState *s, int argc, reg_t *argv) { // If intersection point lies on both the query line segment and the poly // line segment, add it to the output - if (((PointInRect(Common::Point(intersectionX, intersectionY), pSourceX, pSourceY, pDestX, pDestY)) - && PointInRect(Common::Point(intersectionX, intersectionY), qSourceX, qSourceY, qDestX, qDestY))) { + if (PointInRect(Common::Point(intersectionX, intersectionY), pSourceX, pSourceY, pDestX, pDestY) + && PointInRect(Common::Point(intersectionX, intersectionY), qSourceX, qSourceY, qDestX, qDestY)) { outBuf[outCount * 3] = make_reg(0, intersectionX); outBuf[outCount * 3 + 1] = make_reg(0, intersectionY); outBuf[outCount * 3 + 2] = make_reg(0, curIndex); @@ -1878,7 +1886,7 @@ static float pointSegDistance(const Common::Point &a, const Common::Point &b, 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 (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(); @@ -1940,12 +1948,12 @@ static bool segSegIntersect(const Vertex *v1, const Vertex *v2, Common::Point &i if (!len_dc) error("zero length edge in polygon"); - if (pointSegDistance(c, d, a) <= 2.0f) { + if (pointSegDistance(c, d, a) <= 2.0F) { intp = a; return true; } - if (pointSegDistance(c, d, b) <= 2.0f) { + if (pointSegDistance(c, d, b) <= 2.0F) { intp = b; return true; } @@ -1968,7 +1976,7 @@ static bool segSegIntersect(const Vertex *v1, const Vertex *v2, Common::Point &i 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); + return (p1.x * p2.y - p2.x * p1.y); } // Direction of edge in degrees from pos. x-axis, between -180 and 180 @@ -2191,12 +2199,12 @@ bool mergeSinglePolygon(Polygon &work, const Polygon &polygon) { // 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 *workv2 = workv; const Vertex *polyv2 = polyv->_next; intersects = false; - uint pi2, wi2; + uint pi2, wi2 = 0; for (pi2 = 0; pi2 < polygonSize; ++pi2, polyv2 = polyv2->_next) { int newAngle = edgeDir(polyv2); @@ -2457,8 +2465,10 @@ reg_t kMergePoly(EngineState *s, int argc, reg_t *argv) { Vertex *vertex; uint32 n = 0; CLIST_FOREACH(vertex, &work.vertices) { - if (vertex == work.vertices._head || vertex->v != vertex->_prev->v) - writePoint(arrayRef, n++, vertex->v); + if (vertex == work.vertices._head || vertex->v != vertex->_prev->v) { + writePoint(arrayRef, n, vertex->v); + n++; + } } writePoint(arrayRef, n, Common::Point(POLY_LAST_POINT, POLY_LAST_POINT)); diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 2bb58d4ff2..bf6372bf8e 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -370,6 +370,8 @@ reg_t disassemble(EngineState *s, reg_t pos, const Object *obj, bool printBWTag, case kSelectorNone: debugN("INVALID"); break; + default: + break; } } @@ -938,6 +940,8 @@ void debugSelectorCall(reg_t send_obj, Selector selector, int argc, StackPtr arg } } break; + default: + break; } // switch } @@ -1039,7 +1043,7 @@ void logKernelCall(const KernelFunction *kernelCall, const KernelSubFunction *ke // TODO: Any other segment types which could // use special handling? - if (kernelCall->function == kSaid) { + if (kernelCall->function == &kSaid) { SegmentRef saidSpec = s->_segMan->dereference(argv[parmNr]); if (saidSpec.isRaw) { debugN(" ('"); @@ -1085,7 +1089,8 @@ void logBacktrace() { switch (call.type) { case EXEC_STACK_TYPE_CALL: // Normal function if (call.type == EXEC_STACK_TYPE_CALL) - con->debugPrintf(" %x: script %d - ", i, s->_segMan->getScript(call.addr.pc.getSegment())->getScriptNumber()); + con->debugPrintf(" %x: script %d - ", i, s->_segMan->getScript(call.addr.pc.getSegment())->getScriptNumber()); + if (call.debugSelector != -1) { con->debugPrintf("%s::%s(", objname, g_sci->getKernel()->getSelectorName(call.debugSelector).c_str()); } else if (call.debugExportId != -1) { |