1 /*****************************************************************************
2 * Copyright (c) 2007 Russ Adams, Sean Eubanks, Asgard Contributors
3 * This file is part of Asgard.
5 * Asgard is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * Asgard is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Asgard; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 ****************************************************************************/
20 #include "QueryGenerator.h"
24 char* QueryGenerator::staticMapObject(int boundingBoxId
)
26 std::stringstream queryStream
;
28 char* cStr
= new char[2048];
30 queryStream
<< "select ";
31 queryStream
<< "mo.MapObjectId, ";
32 queryStream
<< "mo.WC_X, ";
33 queryStream
<< "mo.WC_Y, ";
34 queryStream
<< "mo.Height, ";
35 queryStream
<< "mo.Width ";
36 queryStream
<< "from BoundingBox bb ";
37 queryStream
<< "inner join MapObject mo on mo.BoundingBoxId = bb.BoundingBoxId ";
38 queryStream
<< "where mo.BoundingBoxId = " << boundingBoxId
<< " ";
42 // Instantiation of StaticMapObjects will need to be addressed.
43 queryStream
<< " and mo.MapObjectId not in ";
44 queryStream
<< " (select MapObjectId from Container) ";
45 queryStream
<< " and mo.MapObjectId not in ";
46 queryStream
<< " (select MapObjectId from NonPlayerCharacter) ";
47 queryStream
<< " and mo.MapObjectId not in ";
48 queryStream
<< " (select MapObjectId from Tiles);";
51 query
= queryStream
.str();
52 strcpy(cStr
,query
.c_str());
56 char* QueryGenerator::nonPlayerCharacter(int boundingBoxId
)
58 std::stringstream queryStream
;
60 char* cStr
= new char[2048];
62 queryStream
<< "select ";
63 queryStream
<< "mo.MapObjectId, ";
64 queryStream
<< "mo.WC_X, ";
65 queryStream
<< "mo.WC_Y, ";
66 queryStream
<< "mo.Height, ";
67 queryStream
<< "mo.Width, ";
68 queryStream
<< "npc.Speed, ";
69 queryStream
<< "mo.BoundingBoxId ";
70 queryStream
<< "from BoundingBox bb ";
71 queryStream
<< "inner join MapObject mo on mo.BoundingBoxId = bb.BoundingBoxId ";
72 queryStream
<< "inner join NonPlayerCharacter npc on npc.MapObjectId = mo.MapObjectId ";
73 queryStream
<< "where mo.BoundingBoxId = " << boundingBoxId
<< ";";
75 query
= queryStream
.str();
77 strcpy(cStr
,query
.c_str());
81 char* QueryGenerator::nonPlayerCharacterPath(int mapObjectId
)
83 std::stringstream queryStream
;
85 char* cStr
= new char[2048];
87 queryStream
<< "select ";
88 queryStream
<< "npcp.MapObjectId, ";
89 queryStream
<< "npcp.WC_X, ";
90 queryStream
<< "npcp.WC_Y, ";
91 queryStream
<< "npcp.PathIndex ";
92 queryStream
<< "from NonPlayerCharacterPath npcp ";
93 queryStream
<< "where npcp.MapObjectId = " << mapObjectId
<< ";";
95 query
= queryStream
.str();
97 strcpy(cStr
,query
.c_str());
101 char* QueryGenerator::container(int boundingBoxId
)
103 std::stringstream queryStream
;
105 char* cStr
= new char[2048];
107 queryStream
<< "select ";
108 queryStream
<< "mo.MapObjectId, ";
109 queryStream
<< "mo.WC_X, ";
110 queryStream
<< "mo.WC_Y, ";
111 queryStream
<< "mo.Height, ";
112 queryStream
<< "mo.Width, ";
113 queryStream
<< "c.item0, ";
114 queryStream
<< "c.item1, ";
115 queryStream
<< "c.item2, ";
116 queryStream
<< "c.item3, ";
117 queryStream
<< "c.item4, ";
118 queryStream
<< "c.item5, ";
119 queryStream
<< "c.item6, ";
120 queryStream
<< "c.item7, ";
121 queryStream
<< "c.item8, ";
122 queryStream
<< "c.item9, ";
123 queryStream
<< "c.item10, ";
124 queryStream
<< "c.item11, ";
125 queryStream
<< "c.item12, ";
126 queryStream
<< "c.item13, ";
127 queryStream
<< "c.item14 ";
128 queryStream
<< "from BoundingBox bb ";
129 queryStream
<< "inner join MapObject mo on mo.BoundingBoxId = bb.BoundingBoxId ";
130 queryStream
<< "inner join Container c on c.MapObjectId = mo.MapObjectId ";
131 queryStream
<< "where bb.BoundingBoxId = " << boundingBoxId
<< ";";
133 query
= queryStream
.str();
135 strcpy(cStr
,query
.c_str());
139 char* QueryGenerator::tile(int boundingBoxId
)
141 std::stringstream queryStream
;
143 char* cStr
= new char[2048];
145 queryStream
<< "select ";
146 queryStream
<< "mo.MapObjectId, ";
147 queryStream
<< "mo.WC_X, ";
148 queryStream
<< "mo.WC_Y, ";
149 queryStream
<< "mo.Height, ";
150 queryStream
<< "mo.Width, ";
151 queryStream
<< "t.tileType ";
152 queryStream
<< "from BoundingBox bb ";
153 queryStream
<< "inner join MapObject mo on mo.BoundingBoxId = bb.BoundingBoxId ";
154 queryStream
<< "inner join Tiles t on mo.MapObjectId = t.MapObjectId ";
155 queryStream
<< "where bb.BoundingBoxId = " << boundingBoxId
<< ";";
157 query
= queryStream
.str();
159 strcpy(cStr
,query
.c_str());
163 char* QueryGenerator::hardpoint(int mapObjectId
)
165 std::stringstream queryStream
;
167 char* cStr
= new char[2048];
169 queryStream
<< "select ";
170 queryStream
<< "mo.MapObjectId, ";
171 queryStream
<< "h.RelativeX, ";
172 queryStream
<< "h.RelativeY, ";
173 queryStream
<< "h.HardpointType, ";
174 queryStream
<< "h.Width, ";
175 queryStream
<< "h.Height, ";
176 queryStream
<< "h.Radius ";
177 queryStream
<< "from MapObject mo ";
178 queryStream
<< "inner join Hardpoints h on h.MapObjectId = mo.MapObjectId ";
179 queryStream
<< "where mo.MapObjectId = " << mapObjectId
<< ";";
181 query
= queryStream
.str();
183 strcpy(cStr
,query
.c_str());