xoreos  0.0.5
area.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/scopedptr.h"
26 #include "src/common/util.h"
27 #include "src/common/error.h"
28 #include "src/common/readstream.h"
29 #include "src/common/maths.h"
30 
31 #include "src/aurora/resman.h"
32 #include "src/aurora/gff3file.h"
33 #include "src/aurora/2dafile.h"
34 #include "src/aurora/2dareg.h"
35 
36 #include "src/graphics/graphics.h"
38 
40 
41 #include "src/sound/sound.h"
42 
44 
45 #include "src/engines/kotor/area.h"
46 #include "src/engines/kotor/room.h"
50 #include "src/engines/kotor/door.h"
55 
56 namespace Engines {
57 
58 namespace KotOR {
59 
61  : distance(0.0f),
62  pitch(0.0f),
63  height(0.0f) {
64 }
65 
66 Area::Area(Module &module, const Common::UString &resRef)
68  _module(&module),
69  _resRef(resRef),
70  _visible(false),
71  _activeObject(0),
72  _highlightAll(false),
73  _triggersVisible(false),
74  _activeTrigger(0),
75  _walkmeshInvisible(true) {
76 
77  try {
78  load();
79  } catch (...) {
80  clear();
81  throw;
82  }
83 
84  // Tell the module that we exist
85  _module->addObject(*this);
86 }
87 
89  _module->removeObject(*this);
90 
91  hide();
92 
93  removeFocus();
94 
95  clear();
96 }
97 
98 void Area::load() {
99  loadLYT(); // Room layout
100  loadVIS(); // Room visibilities
101 
102  loadRooms();
103 
104  Aurora::GFF3File are(_resRef, Aurora::kFileTypeARE, MKTAG('A', 'R', 'E', ' '));
105  loadARE(are.getTopLevel());
106 
107  Aurora::GFF3File git(_resRef, Aurora::kFileTypeGIT, MKTAG('G', 'I', 'T', ' '));
108  loadGIT(git.getTopLevel());
109 }
110 
111 void Area::clear() {
112  for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
113  _module->removeObject(**o);
114 
115  _objects.clear();
116  _creatures.clear();
117  _rooms.clear();
118  _triggers.clear();
119  _situatedObjects.clear();
120  _activeTrigger = 0;
121 }
122 
124  return _musicDayTrack;
125 }
126 
128  return _musicNightTrack;
129 }
130 
132  return _musicBattleTrack;
133 }
134 
136  _musicDayTrack = track;
137  _musicDay = TwoDAReg.get2DA("ambientmusic").getRow(track).getString("Resource");
138 }
139 
141  _musicNightTrack = track;
142  _musicNight = TwoDAReg.get2DA("ambientmusic").getRow(track).getString("Resource");
143 }
144 
146  _musicBattleTrack = track;
147 
149  const Aurora::TwoDAFile &ambientMusic = TwoDAReg.get2DA("ambientmusic");
150 
151  // Normal battle music
152  _musicBattle = ambientMusic.getRow(_musicBattleTrack).getString("Resource");
153 
154  // Battle stingers
155  Common::UString stinger[3];
156  stinger[0] = ambientMusic.getRow(_musicBattleTrack).getString("Stinger1");
157  stinger[1] = ambientMusic.getRow(_musicBattleTrack).getString("Stinger2");
158  stinger[2] = ambientMusic.getRow(_musicBattleTrack).getString("Stinger3");
159 
160  _musicBattleStinger.clear();
161  for (int i = 0; i < 3; i++)
162  if (!stinger[i].empty())
163  _musicBattleStinger.push_back(stinger[i]);
164  }
165 }
166 
170 }
171 
173  SoundMan.stopChannel(_ambientMusic);
174 }
175 
177  SoundMan.stopChannel(_ambientSound);
178 }
179 
182 
183  // TODO: Area::playAmbientMusic(): Day/Night
184  if (music.empty())
185  music = _musicDay;
186 
187  if (music.empty())
188  return;
189 
191 }
192 
195 
196  // TODO: Area::playAmbientSound(): Day/Night
197  if (sound.empty())
198  sound = _ambientDay;
199 
200  if (sound.empty())
201  return;
202 
204 }
205 
207  return _northAxis;
208 }
209 
210 void Area::getMapPoint1(float &x, float &y) {
211  x = _mapPt1X;
212  y = _mapPt1Y;
213 }
214 
215 void Area::getMapPoint2(float &x, float &y) {
216  x = _mapPt2X;
217  y = _mapPt2Y;
218 }
219 
220 void Area::getWorldPoint1(float &x, float &y) {
221  x = _worldPt1X;
222  y = _worldPt1Y;
223 }
224 
225 void Area::getWorldPoint2(float &x, float &y) {
226  x = _worldPt2X;
227  y = _worldPt2Y;
228 }
229 
230 void Area::show() {
231  if (_visible)
232  return;
233 
234  GfxMan.lockFrame();
235 
236  // Show rooms
237  for (RoomList::iterator r = _rooms.begin(); r != _rooms.end(); ++r)
238  (*r)->show();
239 
240  // Show objects
241  for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
242  (*o)->show();
243 
244  GfxMan.unlockFrame();
245 
246  // Play music and sound
249 
250  _visible = true;
251 }
252 
253 void Area::hide() {
254  if (!_visible)
255  return;
256 
257  removeFocus();
258 
259  stopSound();
260 
261  GfxMan.lockFrame();
262 
263  // Hide objects
264  for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
265  (*o)->hide();
266 
267  // Hide rooms
268  for (RoomList::iterator r = _rooms.begin(); r != _rooms.end(); ++r)
269  (*r)->hide();
270 
271  GfxMan.unlockFrame();
272 
273  _visible = false;
274 }
275 
277  try {
279  if (!lyt)
280  throw Common::Exception("No such LYT");
281 
282  _lyt.load(*lyt);
283 
284  } catch (Common::Exception &e) {
285  e.add("Failed loading LYT \"%s\"", _resRef.c_str());
286  throw;
287  }
288 }
289 
291  try {
293  if (!vis)
294  throw Common::Exception("No such VIS");
295 
296  _vis.load(*vis);
297 
298  } catch (Common::Exception &e) {
299  e.add("Failed loading VIS \"%s\"", _resRef.c_str());
300  throw;
301  }
302 }
303 
305  // Tag
306  _tag = are.getString("Tag");
307 
308  // Name
309  _name = are.getString("Name");
310 
311  // Minimap data
312  const Aurora::GFF3Struct &map = are.getStruct("Map");
313  _mapPt1X = map.getDouble("MapPt1X");
314  _mapPt1Y = map.getDouble("MapPt1Y");
315  _mapPt2X = map.getDouble("MapPt2X");
316  _mapPt2Y = map.getDouble("MapPt2Y");
317  _worldPt1X = map.getDouble("WorldPt1X");
318  _worldPt1Y = map.getDouble("WorldPt1Y");
319  _worldPt2X = map.getDouble("WorldPt2X");
320  _worldPt2Y = map.getDouble("WorldPt2Y");
321  _northAxis = map.getSint("NorthAxis");
322 
323  // Camera style
324  loadCameraStyle(are.getUint("CameraStyle"));
325 
326  // Scripts
327  readScripts(are);
328 }
329 
331  const Aurora::TwoDAFile &tda = TwoDAReg.get2DA("camerastyle");
332  const Aurora::TwoDARow &row = tda.getRow(id);
333  _cameraStyle.distance = row.getFloat("distance");
334  _cameraStyle.pitch = row.getFloat("pitch");
335  _cameraStyle.height = row.getFloat("height");
336 }
337 
339  if (git.hasField("AreaProperties"))
340  loadProperties(git.getStruct("AreaProperties"));
341 
342  if (git.hasField("WaypointList"))
343  loadWaypoints(git.getList("WaypointList"));
344 
345  if (git.hasField("Placeable List"))
346  loadPlaceables(git.getList("Placeable List"));
347 
348  if (git.hasField("Door List"))
349  loadDoors(git.getList("Door List"));
350 
351  if (git.hasField("Creature List"))
352  loadCreatures(git.getList("Creature List"));
353 
354  if (git.hasField("SoundList"))
355  loadSounds(git.getList("SoundList"));
356 
357  if (git.hasField("TriggerList"))
358  loadTriggers(git.getList("TriggerList"));
359 }
360 
362  // Ambient sound
363 
364  const Aurora::TwoDAFile &ambientSound = TwoDAReg.get2DA("ambientsound");
365 
366  uint32 ambientDay = props.getUint("AmbientSndDay" , Aurora::kStrRefInvalid);
367  uint32 ambientNight = props.getUint("AmbientSndNight", Aurora::kStrRefInvalid);
368 
369  _ambientDay = ambientSound.getRow(ambientDay ).getString("Resource");
370  _ambientNight = ambientSound.getRow(ambientNight).getString("Resource");
371 
372  uint32 ambientDayVol = CLIP<uint32>(props.getUint("AmbientSndDayVol" , 127), 0, 127);
373  uint32 ambientNightVol = CLIP<uint32>(props.getUint("AmbientSndNightVol", 127), 0, 127);
374 
375  _ambientDayVol = 1.25f * (1.0f - (1.0f / powf(5.0f, ambientDayVol / 127.0f)));
376  _ambientNightVol = 1.25f * (1.0f - (1.0f / powf(5.0f, ambientNightVol / 127.0f)));
377 
378  // TODO: PresetInstance0 - PresetInstance7
379 
380 
381  // Ambient music
382 
383  setMusicDayTrack (props.getUint("MusicDay" , Aurora::kStrRefInvalid));
384  setMusicNightTrack(props.getUint("MusicNight" , Aurora::kStrRefInvalid));
385 
386  // Battle music
387 
388  setMusicBattleTrack(props.getUint("MusicBattle", Aurora::kStrRefInvalid));
389 }
390 
392  const Aurora::LYTFile::RoomArray &rooms = _lyt.getRooms();
393  for (Aurora::LYTFile::RoomArray::const_iterator r = rooms.begin(); r != rooms.end(); ++r) {
394  _rooms.push_back(new Room(r->model, r->x, r->y, r->z));
395  }
396 }
397 
399  _objects.push_back(&object);
400  _module->addObject(object);
401 
402  if (!object.isStatic()) {
403  const std::list<uint32> &ids = object.getIDs();
404 
405  for (std::list<uint32>::const_iterator id = ids.begin(); id != ids.end(); ++id)
406  _objectMap.insert(std::make_pair(*id, &object));
407  }
408 
409  notifyObjectMoved(object);
410 }
411 
413  for (Aurora::GFF3List::const_iterator w = list.begin(); w != list.end(); ++w) {
414  Waypoint *waypoint = new Waypoint(**w);
415 
416  loadObject(*waypoint);
417  }
418 }
419 
421  for (Aurora::GFF3List::const_iterator p = list.begin(); p != list.end(); ++p) {
422  Placeable *placeable = new Placeable(**p);
423 
424  loadObject(*placeable);
425  _situatedObjects.push_back(placeable);
426  }
427 }
428 
430  for (Aurora::GFF3List::const_iterator d = list.begin(); d != list.end(); ++d) {
431  Door *door = new Door(*_module, **d);
432 
433  loadObject(*door);
434  _situatedObjects.push_back(door);
435  }
436 }
437 
439  for (Aurora::GFF3List::const_iterator c = list.begin(); c != list.end(); ++c) {
440  Creature *creature = new Creature(**c);
441 
442  loadObject(*creature);
443  _creatures.push_back(creature);
444  }
445 }
446 
448  for (Aurora::GFF3List::const_iterator t = list.begin(); t != list.end(); ++t) {
449  Trigger *trigger = new Trigger(**t);
450 
451  loadObject(*trigger);
452  _triggers.push_back(trigger);
453  }
454 }
455 
457  for (Aurora::GFF3List::const_iterator c = list.begin(); c != list.end(); ++c) {
458  SoundObject *soundObject = new SoundObject(**c);
459 
460  loadObject(*soundObject);
461  }
462 }
463 
464 void Area::addEvent(const Events::Event &event) {
465  _eventQueue.push_back(event);
466 }
467 
469  bool hasMove = false;
470  for (std::list<Events::Event>::const_iterator e = _eventQueue.begin();
471  e != _eventQueue.end(); ++e) {
472 
473  if (e->type == Events::kEventMouseMove) { // Moving the mouse
474  hasMove = true;
475  } else if (e->type == Events::kEventMouseUp) { // Clicking
476  if (e->button.button == SDL_BUTTON_LMASK) {
477  checkActive(e->button.x, e->button.y);
478  click(e->button.x, e->button.y);
479  }
480  } else if (e->type == Events::kEventKeyDown) { // Holding down TAB
481  if (e->key.keysym.sym == SDLK_TAB)
482  highlightAll(true);
483  } else if (e->type == Events::kEventKeyUp) { // Releasing TAB
484  if (e->key.keysym.sym == SDLK_TAB)
485  highlightAll(false);
486  }
487  }
488 
489  _eventQueue.clear();
490 
491  if (hasMove)
492  checkActive();
493 }
494 
496  const Graphics::Renderable *obj = GfxMan.getObjectAt(x, y);
497  if (!obj)
498  return 0;
499 
500  ObjectMap::iterator o = _objectMap.find(obj->getID());
501  if (o == _objectMap.end())
502  return 0;
503 
504  return o->second;
505 }
506 
508  if (object == _activeObject)
509  return;
510 
511  if (_activeObject)
512  _activeObject->leave();
513 
514  _activeObject = object;
515 
516  if (_activeObject)
517  _activeObject->enter();
518 }
519 
520 void Area::checkActive(int x, int y) {
521  if (_highlightAll)
522  return;
523 
525 
526  if ((x < 0) || (y < 0))
527  CursorMan.getPosition(x, y);
528 
529  setActive(getObjectAt(x, y));
530 }
531 
532 void Area::click(int x, int y) {
534 
535  KotOR::Object *o = getObjectAt(x, y);
536  if (!o)
537  return;
538 
539  o->click(_module->getPC());
540  _module->clickObject(o);
541 }
542 
543 void Area::highlightAll(bool enabled) {
544  if (_highlightAll == enabled)
545  return;
546 
547  _highlightAll = enabled;
548 
549  for (ObjectMap::iterator o = _objectMap.begin(); o != _objectMap.end(); ++o)
550  if (o->second->isClickable())
551  o->second->highlight(enabled);
552 }
553 
555  if (_activeObject)
556  _activeObject->leave();
557 
558  _activeObject = 0;
559 }
560 
562  checkActive();
563 }
564 
565 float Area::evaluateElevation(Object *object, float x, float y, bool doHighlight) {
566  Room *room = object->getRoom();
567 
568  float result = room ? room->evaluateElevation(x, y, doHighlight) : FLT_MIN;
569  if (result != FLT_MIN)
570  return result;
571 
572  if (room && doHighlight)
573  room->disableWalkmeshHighlight();
574 
575  for (RoomList::iterator r = _rooms.begin();
576  r != _rooms.end(); ++r) {
577  if (*r != room) {
578  result = (*r)->evaluateElevation(x, y, doHighlight);
579  if (result != FLT_MIN)
580  break;
581  }
582  }
583 
584  return result;
585 }
586 
587 bool Area::testCollision(const glm::vec3 &orig, const glm::vec3 &dest) const {
588  for (std::list<Situated *>::const_iterator s = _situatedObjects.begin();
589  s != _situatedObjects.end(); ++s) {
590  if ((*s)->testCollision(orig, dest))
591  return true;
592  }
593  return false;
594 }
595 
598 
599  for (RoomList::iterator r = _rooms.begin();
600  r != _rooms.end(); ++r) {
601  (*r)->setWalkmeshInvisible(_walkmeshInvisible);
602  }
603 
604  for (std::list<Situated *>::iterator s = _situatedObjects.begin();
605  s != _situatedObjects.end(); ++s) {
606  (*s)->setWalkmeshInvisible(_walkmeshInvisible);
607  }
608 }
609 
612  for (std::vector<Trigger *>::const_iterator it = _triggers.begin();
613  it != _triggers.end();
614  ++it) {
615  (*it)->setVisible(_triggersVisible);
616  }
617 }
618 
619 void Area::evaluateTriggers(float x, float y) {
620  Trigger *trigger = 0;
621 
622  for (std::vector<Trigger *>::iterator it = _triggers.begin();
623  it != _triggers.end();
624  ++it) {
625  Trigger *t = *it;
626  if (t->contains(x, y)) {
627  trigger = t;
628  break;
629  }
630  }
631 
632  if (_activeTrigger != trigger) {
633  if (_activeTrigger)
635  _activeTrigger = trigger;
636  if (_activeTrigger)
638  }
639 }
640 
642  GfxMan.pauseAnimations();
643 
644  for (RoomList::iterator r = _rooms.begin();
645  r != _rooms.end(); ++r) {
646  if (!(*r)->isVisible())
647  (*r)->show();
648  }
649 
650  for (ObjectList::iterator o = _objects.begin();
651  o != _objects.end(); ++o) {
652  if (!(*o)->isVisible())
653  (*o)->show();
654  }
655 
656  GfxMan.resumeAnimations();
657 }
658 
660  float x, y, z;
661  o.getPosition(x, y, z);
662  o.setRoom(getRoomAt(x, y));
663 }
664 
666  Creature *pc = _module->getPC();
667 
668  const Room *prevPCRoom = pc->getRoom();
669  notifyObjectMoved(*pc);
670  const Room *pcRoom = pc->getRoom();
671 
672  if (pcRoom == prevPCRoom)
673  return;
674 
675  std::vector<Common::UString> visRooms;
676  if (pcRoom) {
677  visRooms.push_back(pcRoom->getResRef());
678 
679  const std::vector<Common::UString> va = _vis.getVisibilityArray(pcRoom->getResRef());
680  for (std::vector<Common::UString>::const_iterator v = va.begin();
681  v != va.end(); ++v) {
682  Common::UString lcResRef(v->toLower());
683  if (std::find(visRooms.begin(), visRooms.end(), lcResRef) == visRooms.end())
684  visRooms.push_back(lcResRef);
685  }
686  }
687 
688  GfxMan.pauseAnimations();
689 
690  for (RoomList::iterator r = _rooms.begin();
691  r != _rooms.end(); ++r) {
692  bool visible = std::find(visRooms.begin(), visRooms.end(), (*r)->getResRef()) != visRooms.end();
693  if (visible) {
694  if (!(*r)->isVisible())
695  (*r)->show();
696  } else if ((*r)->isVisible())
697  (*r)->hide();
698  }
699 
700  for (ObjectList::iterator o = _objects.begin();
701  o != _objects.end(); ++o) {
702  const Room *objRoom = (*o)->getRoom();
703  bool visible = objRoom && objRoom->isVisible();
704  if (visible) {
705  if (!(*o)->isVisible())
706  (*o)->show();
707  } else if ((*o)->isVisible())
708  (*o)->hideSoft();
709  }
710 
711  GfxMan.resumeAnimations();
712 }
713 
714 void Area::getCameraStyle(float &distance, float &pitch, float &height) const {
715  distance = _cameraStyle.distance;
716  pitch = _cameraStyle.pitch;
717  height = _cameraStyle.height;
718 }
719 
720 const std::vector<Common::UString> &Area::getRoomsVisibleFrom(const Common::UString &room) const {
721  return _vis.getVisibilityArray(room);
722 }
723 
725  return _activeObject;
726 }
727 
729  for (ObjectList::iterator o = _objects.begin();
730  o != _objects.end(); ++o) {
731  if ((*o)->getTag().stricmp(tag) == 0)
732  return *o;
733  }
734  return 0;
735 }
736 
738  for (std::vector<Creature *>::iterator c = _creatures.begin();
739  c != _creatures.end(); ++c) {
740  ActionExecutor::executeActions(**c, *this, dt);
741  }
742 }
743 
745  std::vector<Creature *>::iterator crit = std::find(_creatures.begin(), _creatures.end(), object);
746  if (crit != _creatures.end())
747  _creatures.erase(crit);
748 
749  std::vector<Trigger *>::iterator tit = std::find(_triggers.begin(), _triggers.end(), object);
750  if (tit != _triggers.end())
751  _triggers.erase(tit);
752 
753  std::list<Situated *>::iterator soit = std::find(_situatedObjects.begin(), _situatedObjects.end(), object);
754  if (soit != _situatedObjects.end())
755  _situatedObjects.erase(soit);
756 
757  if (object == _activeTrigger)
758  _activeTrigger = 0;
759 
760  if (!object->isStatic()) {
761  const std::list<uint32> &ids = object->getIDs();
762 
763  for (std::list<uint32>::const_iterator id = ids.begin(); id != ids.end(); ++id)
764  _objectMap.erase(*id);
765  }
766 
767  _module->removeObject(*object);
768  _objects.remove(object);
769 }
770 
771 Room *Area::getRoomAt(float x, float y) const {
772  for (RoomList::const_iterator r = _rooms.begin();
773  r != _rooms.end(); ++r) {
774  if ((*r)->evaluateElevation(x, y) != FLT_MIN)
775  return *r;
776  }
777  return 0;
778 }
779 
780 } // End of namespace KotOR
781 
782 } // End of namespace Engines
void loadSounds(const Aurora::GFF3List &list)
Definition: area.cpp:456
Common::UString _musicDay
Music that plays by day.
Definition: area.h:178
A creature in a Star Wars: Knights of the Old Republic area.
int64 getSint(const Common::UString &field, int64 def=0) const
Definition: gff3file.cpp:473
Class to hold the two-dimensional array of a 2DA file.
Definition: 2dafile.h:124
Handling version V3.2/V3.3 of BioWare&#39;s GFFs (generic file format).
#define ResMan
Shortcut for accessing the sound manager.
Definition: resman.h:557
void notifyCameraMoved()
Definition: area.cpp:561
void stopAmbientSound()
Stop the ambient sound.
Definition: area.cpp:176
void loadCameraStyle(uint32 id)
Definition: area.cpp:330
const std::vector< Common::UString > & getRoomsVisibleFrom(const Common::UString &room) const
Definition: area.cpp:720
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like &#39;DATA&#39;, to ensure portability.
Definition: endianness.h:140
std::vector< Creature * > _creatures
Definition: area.h:205
KotOR::Object * getObjectByTag(const Common::UString &tag)
Definition: area.cpp:728
void add(const char *s,...) GCC_PRINTF(2
Definition: error.cpp:58
void playAmbientMusic(Common::UString music="")
Play the specified music (or the area&#39;s default) as ambient music.
Definition: area.cpp:180
The global graphics manager.
A waypoint in a Star Wars: Knights of the Old Republic area.
void processEventQueue()
Process the current event queue.
Definition: area.cpp:468
const Common::UString & getString(size_t column) const
Return the contents of a cell as a string.
Definition: 2dafile.cpp:59
void loadPlaceables(const Aurora::GFF3List &list)
Definition: area.cpp:420
A class holding an UTF-8 string.
Definition: ustring.h:48
uint32 _musicDayTrack
Music track ID that plays by day.
Definition: area.h:174
Aurora::VISFile _vis
The area&#39;s inter-room visibility description.
Definition: area.h:198
A room within a Star Wars: Knights of the Old Republic area.
void toggleWalkmesh()
Definition: area.cpp:596
void playAmbientSound(Common::UString sound="")
Play the specified sound (or the area&#39;s default) as ambient sound.
Definition: area.cpp:193
Fake value for an area object.
Definition: types.h:50
bool hasField(const Common::UString &field) const
Does this specific field exist?
Definition: gff3file.cpp:400
void loadObject(KotOR::Object &object)
Definition: area.cpp:398
Mathematical helpers.
float _worldPt1X
Definition: area.h:190
void getMapPoint1(float &x, float &y)
Get the first map point.
Definition: area.cpp:210
Common::Mutex _mutex
Mutex securing access to the area.
Definition: area.h:214
Area(Module &module, const Common::UString &resRef)
Definition: area.cpp:66
An ingame sound in kotor.
Common::UString _musicNight
Music that plays by night.
Definition: area.h:179
RoomList _rooms
All rooms in the area.
Definition: area.h:200
Common::UString _resRef
The area&#39;s resref (resource ID).
Definition: area.h:168
const GFF3Struct & getTopLevel() const
Returns the top-level struct.
Definition: gff3file.cpp:91
uint64 getUint(const Common::UString &field, uint64 def=0) const
Definition: gff3file.cpp:436
void getCameraStyle(float &distance, float &pitch, float &height) const
Definition: area.cpp:714
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:135
float evaluateElevation(float x, float y, bool highlight=false)
Definition: room.cpp:64
Area data, room layout.
Definition: types.h:176
ObjectMap _objectMap
Map of all non-static objects in the area.
Definition: area.h:203
Creature action executor for Star Wars: Knights of the Old Republic.
void loadWaypoints(const Aurora::GFF3List &list)
Definition: area.cpp:412
void loadDoors(const Aurora::GFF3List &list)
Definition: area.cpp:429
bool isStatic() const
Is the object static (not manipulable at all)?
Definition: object.cpp:122
const std::vector< Common::UString > & getVisibilityArray(const Common::UString &room) const
Return the visibility array for a given room.
Definition: visfile.cpp:118
Mouse was moved.
Definition: types.h:48
Exception that provides a stack of explanations.
Definition: error.h:36
A simple scoped smart pointer template.
void showAllRooms()
&#39;—
Definition: area.cpp:641
SDL_Event Event
Definition: types.h:42
void load(Common::SeekableReadStream &vis)
Load a VIS file.
Definition: visfile.cpp:45
Keyboard key was pressed.
Definition: types.h:46
Trigger in a Star Wars: Knights of the Old Republic area.
void disableWalkmeshHighlight()
Definition: room.cpp:74
Mouse button was released.
Definition: types.h:50
bool testCollision(const glm::vec3 &orig, const glm::vec3 &dest) const
Definition: area.cpp:587
bool _walkmeshInvisible
Definition: area.h:223
Basic exceptions to throw.
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
uint32 _musicBattleTrack
Music track ID that plays in battle.
Definition: area.h:176
void highlightAll(bool enabled)
Definition: area.cpp:543
void processCreaturesActions(float dt)
Definition: area.cpp:737
Module * _module
The module this area is in.
Definition: area.h:166
const RoomArray & getRooms() const
Get all rooms in this layout.
Definition: lytfile.cpp:202
void getWorldPoint1(float &x, float &y)
Get the first world point.
Definition: area.cpp:220
void hide()
Hide the object&#39;s model(s).
Definition: area.cpp:253
Utility templates and functions.
Common::UString _name
The object&#39;s display name.
Definition: object.h:142
void removeFocus()
Forcibly remove the focus from the currently highlighted object.
Definition: area.cpp:554
Room * getRoom()
Get a room the object is in.
Definition: object.cpp:175
Sound::ChannelHandle _ambientMusic
Sound handle of the currently playing music.
Definition: area.h:195
Common::UString getResRef() const
Definition: room.cpp:60
double getDouble(const Common::UString &field, double def=0.0) const
Definition: gff3file.cpp:514
Handling BioWare&#39;s 2DAs (two-dimensional array).
void evaluateTriggers(float x, float y)
Definition: area.cpp:619
CameraStyle _cameraStyle
&#39;—
Definition: area.h:222
void setMusicBattleTrack(uint32 track)
Set the music track ID playing in battle.
Definition: area.cpp:145
void loadGIT(const Aurora::GFF3Struct &git)
Definition: area.cpp:338
A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Da...
Definition: gff3file.h:85
A door in a Star Wars: Knights of the Old Republic area.
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:172
static const uint32 kStrRefInvalid
Definition: types.h:444
std::vector< Room > RoomArray
Definition: lytfile.h:78
Room * getRoomAt(float x, float y) const
Definition: area.cpp:771
The global sound manager, handling all sound output.
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
#define TwoDAReg
Shortcut for accessing the 2da registry.
Definition: 2dareg.h:101
bool runScript(Script script, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
Definition: container.cpp:158
uint32 _musicNightTrack
Music track ID that plays by night.
Definition: area.h:175
bool _triggersVisible
Definition: area.h:218
bool isVisible() const
Definition: room.cpp:94
const std::list< uint32 > & getIDs() const
Return the object&#39;s model IDs.
Definition: object.cpp:134
#define SoundMan
Shortcut for accessing the sound manager.
Definition: sound.h:293
void stopSound()
Stop all sounds.
Definition: area.cpp:167
StackException Exception
Definition: error.h:59
The global 2DA registry.
Common::UString _ambientNight
Ambient sound that plays by night.
Definition: area.h:172
void setActive(KotOR::Object *object)
Definition: area.cpp:507
float _worldPt2X
Definition: area.h:190
KotOR::Object * getActiveObject()
Definition: area.cpp:724
#define CursorMan
Shortcut for accessing the cursor manager.
Definition: cursorman.h:129
Aurora::LYTFile _lyt
The area&#39;s layout description.
Definition: area.h:197
Basic reading stream interfaces.
bool _highlightAll
Are we currently highlighting all objects?
Definition: area.h:210
The context holding a Star Wars: Knights of the Old Republic area.
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
Convenience class that locks a mutex on creation and unlocks it on destruction.
Definition: mutex.h:71
bool _visible
Is the area currently visible?
Definition: area.h:188
A placeable in a Star Wars: Knights of the Old Republic area.
The Aurora cursor manager.
KotOR::Object * getObjectAt(int x, int y)
Definition: area.cpp:495
Sound::ChannelHandle _ambientSound
Sound handle of the currently playing sound.
Definition: area.h:194
Sound::ChannelHandle playSound(const Common::UString &sound, Sound::SoundType soundType, bool loop, float volume, bool pitchVariance)
Play this sound resource.
Definition: util.cpp:81
virtual void enter()
The cursor entered the object.
Definition: object.cpp:183
void getMapPoint2(float &x, float &y)
Get the second map point.
Definition: area.cpp:215
uint32 getMusicBattleTrack() const
Return the music track ID playing in battle.
Definition: area.cpp:131
An object that can be displayed by the graphics manager.
Definition: renderable.h:42
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
Definition: area.cpp:464
const GFF3List & getList(const Common::UString &field) const
Definition: gff3file.cpp:741
void toggleTriggers()
.— Triggers
Definition: area.cpp:610
uint32 getID() const
Get the object&#39;s unique ID.
Definition: renderable.cpp:86
virtual bool click(Object *triggerer=0)
The object was clicked.
Definition: object.cpp:192
const TwoDARow & getRow(size_t row) const
Get a row.
Definition: 2dafile.cpp:421
Dynamic area data, GFF.
Definition: types.h:89
void notifyPCMoved()
Definition: area.cpp:665
void remove(const typename std::list< T *>::value_type &val)
Definition: ptrlist.h:94
void loadTriggers(const Aurora::GFF3List &list)
Definition: area.cpp:447
void clear()
Definition: ptrlist.h:47
int getNorthAxis()
Get the north axis id.
Definition: area.cpp:206
A struct within a GFF3.
Definition: gff3file.h:164
std::list< Events::Event > _eventQueue
The event queue.
Definition: area.h:212
float _ambientNightVol
Night ambient sound volume.
Definition: area.h:186
uint32_t uint32
Definition: types.h:204
float evaluateElevation(Object *object, float x, float y, bool doHighlight=true)
Definition: area.cpp:565
const GFF3Struct & getStruct(const Common::UString &field) const
Definition: gff3file.cpp:728
virtual void leave()
The cursor left the object.
Definition: object.cpp:186
Trigger * _activeTrigger
Definition: area.h:219
void show()
Show the object&#39;s model(s).
Definition: area.cpp:230
Common::UString _tag
Definition: object.h:56
Static area data, GFF.
Definition: types.h:81
void click(int x, int y)
Definition: area.cpp:532
std::vector< Common::UString > _musicBattleStinger
Battle music stingers.
Definition: area.h:183
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:123
KotOR::Object * _activeObject
The currently active (highlighted) object.
Definition: area.h:208
float _worldPt1Y
Definition: area.h:190
#define FLT_MIN
Definition: maths.h:43
void removeObject(KotOR::Object *object)
Definition: area.cpp:744
std::vector< Trigger * > _triggers
.— Triggers
Definition: area.h:217
Common::UString getString(const Common::UString &field, const Common::UString &def="") const
Definition: gff3file.cpp:527
Sound effect.
Definition: types.h:45
Generic Aurora engines utility functions.
void setRoom(Room *room)
Set a room the object is in.
Definition: object.cpp:179
float _worldPt2Y
Definition: area.h:190
void readScripts(const Aurora::GFF3Struct &gff, bool clear=true)
Definition: container.cpp:134
void loadCreatures(const Aurora::GFF3List &list)
Definition: area.cpp:438
The context needed to run a Star Wars: Knights of the Old Republic module.
ObjectList _objects
List of all objects in the area.
Definition: area.h:202
virtual void getPosition(float &x, float &y, float &z) const
Return the object&#39;s position within its area.
Definition: object.cpp:138
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:127
A row within a 2DA file.
Definition: 2dafile.h:61
void getWorldPoint2(float &x, float &y)
Get the second world point.
Definition: area.cpp:225
float _ambientDayVol
Day ambient sound volume.
Definition: area.h:185
Keyboard key was released.
Definition: types.h:47
void load(Common::SeekableReadStream &lyt)
Load a LYT file.
Definition: lytfile.cpp:56
Common::UString _ambientDay
Ambient sound that plays by day.
Definition: area.h:171
Common::UString _musicBattle
Music that plays in battle.
Definition: area.h:180
void clickObject(Object *object)
Open the inventory of a container.
Definition: module.cpp:498
An object that can be displayed by the graphics manager.
void removeObject(KotOR::Object &object)
Remove an object from this container.
void loadProperties(const Aurora::GFF3Struct &props)
Definition: area.cpp:361
void notifyObjectMoved(Object &o)
Definition: area.cpp:659
void addObject(KotOR::Object &object)
Add an object to this container.
#define GfxMan
Shortcut for accessing the graphics manager.
Definition: graphics.h:299
void loadARE(const Aurora::GFF3Struct &are)
Definition: area.cpp:304
The global resource manager for Aurora resources.
static void executeActions(Creature &creature, Area &area, float dt)
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:140
void checkActive(int x=-1, int y=-1)
Definition: area.cpp:520
std::list< Situated * > _situatedObjects
Definition: area.h:224
float getFloat(size_t column) const
Return the contents of a cell as a float.
Definition: 2dafile.cpp:91
Creature * getPC()
Return the currently playing PC.
Definition: module.cpp:181
Area data, room visibilities.
Definition: types.h:177
bool contains(float x, float y) const
Definition: trigger.cpp:51