fix NULL pointer access on ~Area
[Tsunagari.git] / src / world.h
blobda3429449b81e02a02ccae259cbf73629db1d63a
1 /******************************
2 ** Tsunagari Tile Engine **
3 ** world.h **
4 ** Copyright 2011 OmegaSDG **
5 ******************************/
7 #ifndef WORLD_H
8 #define WORLD_H
10 #include <string>
11 #include <vector>
13 #include "common.h"
15 namespace Gosu {
16 class Button;
19 class Area;
20 class Entity;
21 class Resourcer;
22 class GameWindow;
24 //! World Class
25 /*!
26 This class is conceptually the main class of the Tsunagari Tile Engine.
28 class World
30 public:
31 static World* getWorld();
33 //! World Constructor
34 World(Resourcer* rc, GameWindow* w);
36 //! World Destructor
37 ~World();
39 //! World Initializer
40 bool init();
42 //! Gosu Callback
43 void buttonDown(const Gosu::Button btn);
45 //! Gosu Callback
46 void draw();
48 //! Gosu Callback
49 bool needsRedraw() const;
51 //! Gosu Callback
52 void update();
54 bool loadArea(const std::string& areaName, coord_t playerPos);
56 private:
57 bool processDescriptor();
59 Resourcer* rc;
60 GameWindow* wnd;
61 Area* area;
62 Entity* player;
64 //! WorldTypeLocality XML Storage Enum
65 /*!
66 Stores the World locality type. Options are "local" (singleplayer),
67 or "network" (multiplayer).
69 enum WorldTypeLocality {
70 LOCAL,
71 NETWORK
74 //! WorldTypeMovement XML Storage Enum
75 /*!
76 Stores the World movement type. Options are "turn" (roguelike),
77 "tile" (yume nikki), or "notile" (zeldalike).
79 enum WorldTypeMovement {
80 TURN,
81 TILE,
82 NOTILE
85 //! WorldEntry XML Storage Struct
86 /*!
87 Stores the World's entry point data. Includes the start
88 Area, and starting coordinates.
90 struct WorldEntry {
91 std::string area;
92 coord_t coords;
95 //! WorldValues XML Storage Struct
96 /*!
97 Main XML storage struct for World.
99 struct WorldValues {
100 std::string name;
101 std::string author;
102 std::string playersprite;
103 WorldTypeLocality locality;
104 WorldTypeMovement movement;
105 WorldEntry entry;
106 std::vector<std::string> scripts;
107 } xml;
110 #endif