Skip to content

Commit

Permalink
Don't hardcode the last element of RoomField enum
Browse files Browse the repository at this point in the history
The comparisons hardcoded "10", which was off by one after latest
RoomField enum extension. This change adds a one-past last element to
the enum field and uses that in the comparisons.

Fixes the _noride command.

Based on a patch by Thomas Equeter.

https://sourceforge.net/p/mmapper/patches/2/

git-svn-id: svn://svn.code.sf.net/p/mmapper/code/trunk/mmapper@218 14c008a5-6e10-0410-bf79-c100e0f1932b
  • Loading branch information
klember committed Jul 14, 2013
1 parent 1483e05 commit e5c265e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/mapdata/mapdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "mapdata.h"
#include "roomfactory.h"
#include "drawstream.h"
#include "mmapper2room.h"
#include <assert.h>

using namespace std;
Expand Down Expand Up @@ -95,7 +96,7 @@ void MapData::toggleRoomFlag(const Coordinate & pos, uint flag, uint field)
{
QMutexLocker locker(&mapLock);
Room * room = map.get(pos);
if (room && field < 10)
if (room && field < ROOMFIELD_LAST )
{
setDataChanged();
MapAction * action = new SingleRoomAction(new ModifyRoomFlags(flag, field, FMM_TOGGLE), room->getId());
Expand All @@ -107,7 +108,7 @@ bool MapData::getRoomFlag(const Coordinate & pos, uint flag, uint field)
{
QMutexLocker locker(&mapLock);
Room * room = map.get(pos);
if (room && field < 10)
if (room && field < ROOMFIELD_LAST )
{
if (ISSET((*room)[field].toUInt(), flag)) return true;
}
Expand All @@ -118,7 +119,7 @@ void MapData::setRoomField(const Coordinate & pos, uint flag, uint field)
{
QMutexLocker locker(&mapLock);
Room * room = map.get(pos);
if (room && field < 10)
if (room && field < ROOMFIELD_LAST )
{
setDataChanged();
MapAction * action = new SingleRoomAction(new UpdateRoomField(flag, field), room->getId());
Expand All @@ -130,7 +131,7 @@ uint MapData::getRoomField(const Coordinate & pos, uint field)
{
QMutexLocker locker(&mapLock);
Room * room = map.get(pos);
if (room && field < 10)
if (room && field < ROOMFIELD_LAST )
{
return (*room)[field].toUInt();
}
Expand Down
2 changes: 1 addition & 1 deletion src/mapdata/mmapper2room.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ typedef quint16 RoomMobFlags;
#define RLF_TOWER bit16
typedef quint16 RoomLoadFlags;

enum RoomField {R_NAME, R_DESC, R_TERRAINTYPE, R_DYNAMICDESC, R_NOTE, R_MOBFLAGS, R_LOADFLAGS, R_PORTABLETYPE, R_LIGHTTYPE, R_ALIGNTYPE, R_RIDABLETYPE};
enum RoomField {R_NAME, R_DESC, R_TERRAINTYPE, R_DYNAMICDESC, R_NOTE, R_MOBFLAGS, R_LOADFLAGS, R_PORTABLETYPE, R_LIGHTTYPE, R_ALIGNTYPE, R_RIDABLETYPE, ROOMFIELD_LAST};

RoomName getName(const Room * room);

Expand Down

0 comments on commit e5c265e

Please sign in to comment.