Skip to content

Commit

Permalink
KOTORBASE: Extract minimap initialization to a separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
vkremianskii authored and DrMcCoy committed Feb 28, 2019
1 parent de1671d commit cfcca34
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
42 changes: 24 additions & 18 deletions src/engines/kotorbase/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,7 @@ void Module::loadModule(const Common::UString &module, const Common::UString &en
throw e;
}

int northAxis;
float mapPt1X, mapPt1Y, mapPt2X, mapPt2Y;
float worldPt1X, worldPt1Y, worldPt2X, worldPt2Y;

northAxis = _area->getNorthAxis();
_area->getMapPoint1(mapPt1X, mapPt1Y);
_area->getMapPoint2(mapPt2X, mapPt2Y);
_area->getWorldPoint1(worldPt1X, worldPt1Y);
_area->getWorldPoint2(worldPt2X, worldPt2Y);

Common::UString mapId;
if (_module.contains('_'))
mapId = _module.substr(++_module.findFirst("_"), _module.end());
else
mapId = _module.substr(_module.getPosition(3), _module.end());
_ingame->setMinimap(mapId, northAxis,
worldPt1X, worldPt1Y, worldPt2X, worldPt2Y,
mapPt1X, mapPt1Y, mapPt2X, mapPt2Y);
initMinimap();

_newModule.clear();

Expand Down Expand Up @@ -670,6 +653,29 @@ void Module::handleEvents() {
}
}

void Module::initMinimap() {
int northAxis = _area->getNorthAxis();

float mapPt1X, mapPt1Y, mapPt2X, mapPt2Y;
_area->getMapPoint1(mapPt1X, mapPt1Y);
_area->getMapPoint2(mapPt2X, mapPt2Y);

float worldPt1X, worldPt1Y, worldPt2X, worldPt2Y;
_area->getWorldPoint1(worldPt1X, worldPt1Y);
_area->getWorldPoint2(worldPt2X, worldPt2Y);

Common::UString mapId;

if (_module.contains('_'))
mapId = _module.substr(++_module.findFirst("_"), _module.end());
else
mapId = _module.substr(_module.getPosition(3), _module.end());

_ingame->setMinimap(mapId, northAxis,
worldPt1X, worldPt1Y, worldPt2X, worldPt2Y,
mapPt1X, mapPt1Y, mapPt2X, mapPt2Y);
}

void Module::updateMinimap() {
float x, y, _;
_partyController.getPartyLeader()->getPosition(x, y, _);
Expand Down
2 changes: 1 addition & 1 deletion src/engines/kotorbase/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,10 @@ class Module : public Object, public ObjectContainer {
void leaveArea();

void handleEvents();

void handleActions();
void handleHeartbeat();

void initMinimap();
void updateMinimap();
void updateSoundListener();
};
Expand Down

0 comments on commit cfcca34

Please sign in to comment.