Skip to content

Commit

Permalink
SCUMM: Simplify clampCameraPos() using CLIP
Browse files Browse the repository at this point in the history
  • Loading branch information
bonki committed May 7, 2018
1 parent aabd5b2 commit 48406bb
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions engines/scumm/camera.cpp
Expand Up @@ -25,6 +25,8 @@
#include "scumm/charset.h"
#include "scumm/scumm_v7.h"

#include "common/util.h"

namespace Scumm {

void ScummEngine::setCameraAtEx(int at) {
Expand Down Expand Up @@ -85,17 +87,8 @@ void ScummEngine::setCameraFollows(Actor *a, bool setCamera) {
}

void ScummEngine::clampCameraPos(Common::Point *pt) {
if (pt->x < VAR(VAR_CAMERA_MIN_X))
pt->x = (short) VAR(VAR_CAMERA_MIN_X);

if (pt->x > VAR(VAR_CAMERA_MAX_X))
pt->x = (short) VAR(VAR_CAMERA_MAX_X);

if (pt->y < VAR(VAR_CAMERA_MIN_Y))
pt->y = (short) VAR(VAR_CAMERA_MIN_Y);

if (pt->y > VAR(VAR_CAMERA_MAX_Y))
pt->y = (short) VAR(VAR_CAMERA_MAX_Y);
pt->x = CLIP<short>(pt->x, VAR(VAR_CAMERA_MIN_X), VAR(VAR_CAMERA_MAX_X));
pt->y = CLIP<short>(pt->y, VAR(VAR_CAMERA_MIN_Y), VAR(VAR_CAMERA_MAX_Y));
}

void ScummEngine::moveCamera() {
Expand Down

0 comments on commit 48406bb

Please sign in to comment.