Skip to content

Commit

Permalink
TITANIC: Cleanup of class handling in PET Rooms tab
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Nov 6, 2016
1 parent 0f17c9d commit d8d11ba
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions engines/titanic/pet_control/pet_rooms.cpp
Expand Up @@ -67,7 +67,7 @@ bool CPetRooms::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
if (!_glyphItem.contains(getGlyphPos(), msg->_mousePos))
return false;

_glyphItem.MouseButtonDownMsg(msg->_mousePos);
_glyphItem.selectGlyph(getGlyphPos(), msg->_mousePos);
return true;
}

Expand Down Expand Up @@ -335,7 +335,7 @@ bool CPetRooms::changeLocationClass(PassengerClass newClassNum) {
if (!glyph)
return 0;

glyph->changeLocation(newClassNum);
glyph->changeClass(newClassNum);
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions engines/titanic/pet_control/pet_rooms_glyphs.cpp
Expand Up @@ -102,7 +102,7 @@ void CPetRoomsGlyph::drawAt(CScreenManager *screenManager, const Point &pt, bool
}

void CPetRoomsGlyph::selectGlyph(const Point &topLeft, const Point &pt) {
if (isAssigned()) {
if (!isAssigned()) {
bool isShiftPressed = g_vm->_window->getSpecialButtons() & MK_SHIFT;

if (isShiftPressed) {
Expand Down Expand Up @@ -183,9 +183,9 @@ void CPetRoomsGlyph::loadFlags(SimpleFile *file, int val) {
}
}

void CPetRoomsGlyph::changeLocation(int newClassNum) {
void CPetRoomsGlyph::changeClass(PassengerClass newClassNum) {
CRoomFlags roomFlags(_roomFlags);
roomFlags.changeLocation(newClassNum);
roomFlags.changeClass(newClassNum);
_roomFlags = roomFlags.get();
}

Expand Down
6 changes: 5 additions & 1 deletion engines/titanic/pet_control/pet_rooms_glyphs.h
Expand Up @@ -25,6 +25,7 @@

#include "titanic/pet_control/pet_glyphs.h"
#include "titanic/support/simple_file.h"
#include "titanic/game_location.h"

namespace Titanic {

Expand Down Expand Up @@ -119,7 +120,10 @@ class CPetRoomsGlyph : public CPetGlyph {
*/
void setMode(RoomGlyphMode mode) { _mode = mode; }

void changeLocation(int newClassNum);
/**
* Change the current class
*/
void changeClass(PassengerClass newClassNum);

/**
* Returns true if the room is either currently or previously assigned
Expand Down
12 changes: 6 additions & 6 deletions engines/titanic/room_flags.cpp
Expand Up @@ -369,7 +369,7 @@ CString CRoomFlags::getSuccUBusRoomName() const {
return CString();
}

void CRoomFlags::changeLocation(int action) {
void CRoomFlags::changeClass(PassengerClass newClassNum) {
uint floorNum = getFloorNum();
uint roomNum = getRoomNum();
uint elevatorNum = getElevatorNum();
Expand Down Expand Up @@ -407,23 +407,23 @@ void CRoomFlags::changeLocation(int action) {
}

// Perform action to change room or floor
switch (action) {
case 1:
switch (newClassNum) {
case FIRST_CLASS:
if (--roomNum < v12)
roomNum = v12;
break;

case 2:
case SECOND_CLASS:
if (++roomNum > v13)
roomNum = v13;
break;

case 3:
case THIRD_CLASS:
if (--floorNum < v10)
floorNum = v10;
break;

case 4:
case UNCHECKED:
if (++floorNum > v11)
floorNum = v11;
}
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/room_flags.h
Expand Up @@ -201,7 +201,7 @@ class CRoomFlags {
/**
* Change the passenger class
*/
void changeLocation(int action);
void changeClass(PassengerClass newClassNum);

/**
* Sets a random destination in the flags
Expand Down

0 comments on commit d8d11ba

Please sign in to comment.