Mudlet  0
Mudclient
TRoom.h
Go to the documentation of this file.
1 #ifndef MUDLET_TROOM_H
2 #define MUDLET_TROOM_H
3 
4 /***************************************************************************
5  * Copyright (C) 2012-2013 by Heiko Koehn - KoehnHeiko@googlemail.com *
6  * Copyright (C) 2014 by Ahmed Charles - acharles@outlook.com *
7  * Copyright (C) 2014-2015, 2018 by Stephen Lyons *
8  * - slysven@virginmedia.com *
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  * This program is distributed in the hope that it will be useful, *
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18  * GNU General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU General Public License *
21  * along with this program; if not, write to the *
22  * Free Software Foundation, Inc., *
23  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
24  ***************************************************************************/
25 
26 
27 #include "TMap.h"
28 
29 #include "pre_guard.h"
30 #include <QApplication>
31 #include <QColor>
32 #include <QHash>
33 #include <QMap>
34 #include <QVector3D>
35 #include "post_guard.h"
36 
37 
38 #define DIR_NORTH 1
39 #define DIR_NORTHEAST 2
40 #define DIR_NORTHWEST 3
41 #define DIR_EAST 4
42 #define DIR_WEST 5
43 #define DIR_SOUTH 6
44 #define DIR_SOUTHEAST 7
45 #define DIR_SOUTHWEST 8
46 #define DIR_UP 9
47 #define DIR_DOWN 10
48 #define DIR_IN 11
49 #define DIR_OUT 12
50 #define DIR_OTHER 13
51 
52 class XMLimport;
53 class XMLexport;
54 class TRoomDB;
55 
56 class TRoom
57 {
58  Q_DECLARE_TR_FUNCTIONS(TRoom) // Needed so we can use tr() even though TRoom is NOT derived from QObject
59 
60 public:
61  TRoom(TRoomDB* pRDB);
62  ~TRoom();
63  void setId(int);
64  bool setExit(int to, int direction);
65  int getExit(int direction);
66  QHash<int, int> getExits();
67  bool hasExit(int direction) const;
68  void setWeight(int);
69  void setExitLock(int, bool);
70  void setSpecialExitLock(int to, const QString& cmd, bool doLock);
71  bool setSpecialExitLock(const QString& cmd, bool doLock);
72  bool hasExitLock(int to);
73  bool hasSpecialExitLock(int, const QString&);
74  void removeAllSpecialExitsToRoom(int _id);
75  void setSpecialExit(int to, const QString& cmd);
76  void clearSpecialExits();
77  const QMultiMap<int, QString>& getOtherMap() const { return other; }
78  const QMap<QString, int>& getExitWeights() const { return exitWeights; }
79  void setExitWeight(const QString& cmd, int w);
80  bool hasExitWeight(const QString& cmd);
81  const bool setDoor(const QString& cmd, int doorStatus); //0=no door, 1=open door, 2=closed, 3=locked
82  int getDoor(const QString& cmd);
83  bool hasExitStub(int direction);
84  void setExitStub(int direction, bool status);
85  void calcRoomDimensions();
86  bool setArea(int, bool isToDeferAreaRelatedRecalculations = false);
87  int getExitWeight(const QString& cmd);
88 
89  int getWeight() { return weight; }
90  int getNorth() { return north; }
91  void setNorth(int id) { north = id; }
92  int getNorthwest() { return northwest; }
93  void setNorthwest(int id) { northwest = id; }
94  int getNortheast() { return northeast; }
95  void setNortheast(int id) { northeast = id; }
96  int getSouth() { return south; }
97  void setSouth(int id) { south = id; }
98  int getSouthwest() { return southwest; }
99  void setSouthwest(int id) { southwest = id; }
100  int getSoutheast() { return southeast; }
101  void setSoutheast(int id) { southeast = id; }
102  int getWest() { return west; }
103  void setWest(int id) { west = id; }
104  int getEast() { return east; }
105  void setEast(int id) { east = id; }
106  int getUp() { return up; }
107  void setUp(int id) { up = id; }
108  int getDown() { return down; }
109  void setDown(int id) { down = id; }
110  int getIn() { return in; }
111  void setIn(int id) { in = id; }
112  int getOut() { return out; }
113  void setOut(int id) { out = id; }
114  int getId() { return id; }
115  int getArea() { return area; }
116  void audit(QHash<int, int>, QHash<int, int>);
117  void auditExits(QHash<int, int>);
118  /*bool*/ void restore(QDataStream& ifs, int roomID, int version);
119  void auditExit(int&,
120  int,
121  QString,
122  QString,
123  QMap<QString, int>&,
124  QSet<int>&,
125  QSet<int>&,
126  QMap<QString, int>&,
127  QMap<QString, QList<QPointF>>&,
128  QMap<QString, QColor>&,
129  QMap<QString, Qt::PenStyle>&,
130  QMap<QString, bool>&,
131  QHash<int, int>);
132  const QString dirCodeToDisplayName(int dirCode);
133  bool hasExitOrSpecialExit(const QString&) const;
134 
135 
136  int x;
137  int y;
138  int z;
140 
141  bool isLocked;
142  qreal min_x;
143  qreal min_y;
144  qreal max_x;
145  qreal max_y;
148  QVector3D v;
149  QList<int> exitStubs; //contains a list of: exittype (according to defined values above)
150  QMap<QString, QString> userData;
151  QList<int> exitLocks;
152  QMap<QString, QList<QPointF>> customLines;
153  QMap<QString, QColor> customLinesColor;
154  QMap<QString, Qt::PenStyle> customLinesStyle;
155  QMap<QString, bool> customLinesArrow;
156  bool highlight;
160  bool rendered;
161  QMap<QString, int> doors; //0=no door 1=open 2=closed 3=locked
162 
163 
164 private:
165  int id;
166  int area;
167  int weight;
168  QMap<QString, int> exitWeights;
169  int north;
171  int east;
173  int south;
175  int west;
177  int up;
178  int down;
179  int in;
180  int out;
181 
182  // FIXME: This should be a map of String->room id because there can be multiple special exits to the same room
183  // Also, move the special exit being locked OUT of being a prefix on the
184  // QString part:
185  QMultiMap<int, QString> other; // es knnen mehrere exits zum gleichen raum verlaufen
186  //verbotene exits werden mit 0 geprefixed, offene mit 1
187 
189  friend class XMLimport;
190  friend class XMLexport;
191 };
192 
193 #endif // MUDLET_TROOM_H
QColor highlightColor
Definition: TRoom.h:157
int west
Definition: TRoom.h:175
void calcRoomDimensions()
Definition: TRoom.cpp:682
void setExitWeight(const QString &cmd, int w)
Definition: TRoom.cpp:186
int area
Definition: TRoom.h:166
bool setArea(int, bool isToDeferAreaRelatedRecalculations=false)
Definition: TRoom.cpp:243
void setOut(int id)
Definition: TRoom.h:113
int northeast
Definition: TRoom.h:170
void setWeight(int)
Definition: TRoom.cpp:176
bool hasExitOrSpecialExit(const QString &) const
Definition: TRoom.cpp:344
qreal min_x
Definition: TRoom.h:142
void clearSpecialExits()
Definition: TRoom.cpp:657
void auditExits(QHash< int, int >)
Definition: TRoom.cpp:916
int getSouthwest()
Definition: TRoom.h:98
void setUp(int id)
Definition: TRoom.h:107
int z
Definition: TRoom.h:138
const bool setDoor(const QString &cmd, int doorStatus)
Definition: TRoom.cpp:206
bool isLocked
Definition: TRoom.h:141
int weight
Definition: TRoom.h:167
QMap< QString, int > exitWeights
Definition: TRoom.h:168
int southwest
Definition: TRoom.h:174
int getUp()
Definition: TRoom.h:106
int out
Definition: TRoom.h:180
int y
Definition: TRoom.h:137
int up
Definition: TRoom.h:177
int getNortheast()
Definition: TRoom.h:94
int getIn()
Definition: TRoom.h:110
bool hasExitLock(int to)
Definition: TRoom.cpp:548
int getDown()
Definition: TRoom.h:108
bool rendered
Definition: TRoom.h:160
int getId()
Definition: TRoom.h:114
int getArea()
Definition: TRoom.h:115
QMultiMap< int, QString > other
Definition: TRoom.h:185
void setExitStub(int direction, bool status)
Definition: TRoom.cpp:134
QString mSymbol
Definition: TRoom.h:146
qreal max_y
Definition: TRoom.h:145
bool hasExitWeight(const QString &cmd)
Definition: TRoom.cpp:163
bool hasExitStub(int direction)
Definition: TRoom.cpp:125
int id
Definition: TRoom.h:165
void restore(QDataStream &ifs, int roomID, int version)
Definition: TRoom.cpp:726
int getWest()
Definition: TRoom.h:102
void setNorthwest(int id)
Definition: TRoom.h:93
int south
Definition: TRoom.h:173
int getNorth()
Definition: TRoom.h:90
void audit(QHash< int, int >, QHash< int, int >)
Definition: TRoom.cpp:906
bool hasSpecialExitLock(int, const QString &)
Definition: TRoom.cpp:554
void auditExit(int &, int, QString, QString, QMap< QString, int > &, QSet< int > &, QSet< int > &, QMap< QString, int > &, QMap< QString, QList< QPointF >> &, QMap< QString, QColor > &, QMap< QString, Qt::PenStyle > &, QMap< QString, bool > &, QHash< int, int >)
Definition: TRoom.cpp:1462
void setSouth(int id)
Definition: TRoom.h:97
void setWest(int id)
Definition: TRoom.h:103
QString name
Definition: TRoom.h:147
void setNorth(int id)
Definition: TRoom.h:91
int getWeight()
Definition: TRoom.h:89
void setIn(int id)
Definition: TRoom.h:111
void setNortheast(int id)
Definition: TRoom.h:95
QList< int > exitLocks
Definition: TRoom.h:151
bool highlight
Definition: TRoom.h:156
void setDown(int id)
Definition: TRoom.h:109
QList< int > exitStubs
Definition: TRoom.h:149
int getDoor(const QString &cmd)
Definition: TRoom.cpp:224
QMap< QString, QList< QPointF > > customLines
Definition: TRoom.h:152
QMap< QString, bool > customLinesArrow
Definition: TRoom.h:155
int east
Definition: TRoom.h:171
QMap< QString, Qt::PenStyle > customLinesStyle
Definition: TRoom.h:154
QMap< QString, QColor > customLinesColor
Definition: TRoom.h:153
int north
Definition: TRoom.h:169
int getSoutheast()
Definition: TRoom.h:100
void setId(int)
Definition: TRoom.cpp:230
int southeast
Definition: TRoom.h:172
void setExitLock(int, bool)
Definition: TRoom.cpp:470
void setEast(int id)
Definition: TRoom.h:105
int getOut()
Definition: TRoom.h:112
bool setExit(int to, int direction)
Definition: TRoom.cpp:299
int getEast()
Definition: TRoom.h:104
bool hasExit(int direction) const
Definition: TRoom.cpp:322
qreal min_y
Definition: TRoom.h:143
Definition: TRoom.h:56
void setSpecialExit(int to, const QString &cmd)
Definition: TRoom.cpp:580
int northwest
Definition: TRoom.h:176
void setSouthwest(int id)
Definition: TRoom.h:99
int down
Definition: TRoom.h:178
TRoomDB * mpRoomDB
Definition: TRoom.h:188
Q_DECLARE_TR_FUNCTIONS(TRoom) public ~TRoom()
Definition: TRoom.cpp:97
void removeAllSpecialExitsToRoom(int _id)
Definition: TRoom.cpp:664
int x
Definition: TRoom.h:136
QMap< QString, QString > userData
Definition: TRoom.h:150
int getExit(int direction)
Definition: TRoom.cpp:391
QMap< QString, int > doors
Definition: TRoom.h:161
int in
Definition: TRoom.h:179
void setSoutheast(int id)
Definition: TRoom.h:101
int getSouth()
Definition: TRoom.h:96
QHash< int, int > getExits()
Definition: TRoom.cpp:422
void setSpecialExitLock(int to, const QString &cmd, bool doLock)
Definition: TRoom.cpp:482
int getExitWeight(const QString &cmd)
Definition: TRoom.cpp:152
int getNorthwest()
Definition: TRoom.h:92
const QMap< QString, int > & getExitWeights() const
Definition: TRoom.h:78
QColor highlightColor2
Definition: TRoom.h:158
int environment
Definition: TRoom.h:139
qreal max_x
Definition: TRoom.h:144
const QString dirCodeToDisplayName(int dirCode)
Definition: TRoom.cpp:104
const QMultiMap< int, QString > & getOtherMap() const
Definition: TRoom.h:77
QVector3D v
Definition: TRoom.h:148
float highlightRadius
Definition: TRoom.h:159