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
;
29 queryStream
<< "select ";
30 queryStream
<< "mo.MapObjectId, ";
31 queryStream
<< "mo.WC_X, ";
32 queryStream
<< "mo.WC_Y, ";
33 queryStream
<< "mo.Height, ";
34 queryStream
<< "mo.Width ";
35 queryStream
<< "from MapObject mo ";
36 queryStream
<< "inner join BoundingBox bb on bb.BoundingBoxId = mo.BoundingBoxId ";
37 queryStream
<< "where mo.BoundingBoxId = " << boundingBoxId
<< "; ";
39 query
= queryStream
.str();
41 return const_cast<char*>(query
.c_str());
44 char* QueryGenerator::nonPlayerCharacter(int boundingBoxId
)
46 std::stringstream queryStream
;
49 queryStream
<< "select ";
50 queryStream
<< "mo.MapObjectId, ";
51 queryStream
<< "mo.WC_X, ";
52 queryStream
<< "mo.WC_Y, ";
53 queryStream
<< "mo.Height, ";
54 queryStream
<< "mo.Width, ";
55 queryStream
<< "npc.Speed, ";
56 queryStream
<< "mo.BoundingBoxId ";
57 queryStream
<< "from NonPlayerCharacter npc, MapObject mo ";
58 queryStream
<< "inner join BoundingBox bb on bb.BoundingBoxId = mo.BoundingBoxId ";
59 queryStream
<< "where mo.BoundingBoxId = " << boundingBoxId
<< ";";
61 query
= queryStream
.str();
63 return const_cast<char*>(query
.c_str());
66 char* QueryGenerator::nonPlayerCharacterPath(int mapObjectId
)
68 std::stringstream queryStream
;
71 queryStream
<< "select ";
72 queryStream
<< "npcp.MapObjectId, ";
73 queryStream
<< "npcp.WC_X, ";
74 queryStream
<< "npcp.WC_Y, ";
75 queryStream
<< "npcp.PathIndex ";
76 queryStream
<< "from NonPlayerCharacterPath npcp ";
77 queryStream
<< "where npcp.MapObjectId = " << mapObjectId
<< ";";
79 query
= queryStream
.str();
81 return const_cast<char*>(query
.c_str());
84 char* QueryGenerator::container(int boundingBoxId
)
86 std::stringstream queryStream
;
89 queryStream
<< "select ";
90 queryStream
<< "mo.MapObjectId, ";
91 queryStream
<< "mo.WC_X, ";
92 queryStream
<< "mo.WC_Y, ";
93 queryStream
<< "mo.Height, ";
94 queryStream
<< "mo.Width, ";
95 queryStream
<< "c.item0, ";
96 queryStream
<< "c.item1, ";
97 queryStream
<< "c.item2, ";
98 queryStream
<< "c.item3, ";
99 queryStream
<< "c.item4, ";
100 queryStream
<< "c.item5, ";
101 queryStream
<< "c.item6, ";
102 queryStream
<< "c.item7, ";
103 queryStream
<< "c.item8, ";
104 queryStream
<< "c.item9, ";
105 queryStream
<< "c.item10, ";
106 queryStream
<< "c.item11, ";
107 queryStream
<< "c.item12, ";
108 queryStream
<< "c.item13, ";
109 queryStream
<< "c.item14 ";
110 queryStream
<< "from Container c, BoundingBox bb ";
111 queryStream
<< "inner join MapObject mo on mo.MapObjectId = c.MapObjectId ";
112 queryStream
<< "on mo.BoundingBoxId = bb.BoundingBoxId ";
113 queryStream
<< "where bb.BoundingBoxId = " << boundingBoxId
<< ";";
115 query
= queryStream
.str();
117 return const_cast<char*>(query
.c_str());
120 char* QueryGenerator::tile(int boundingBoxId
)
122 std::stringstream queryStream
;
125 queryStream
<< "select ";
126 queryStream
<< "mo.MapObjectId, ";
127 queryStream
<< "mo.WC_X, ";
128 queryStream
<< "mo.WC_Y, ";
129 queryStream
<< "mo.Height, ";
130 queryStream
<< "mo.Width, ";
131 queryStream
<< "t.tileType ";
132 queryStream
<< "from MapObject mo, BoundingBox bb ";
133 queryStream
<< "inner join Tiles t on mo.MapObjectId = t.MapObjectId ";
134 queryStream
<< "where bb.BoundingBoxId = " << boundingBoxId
<< ";";
136 query
= queryStream
.str();
138 return const_cast<char*>(query
.c_str());
141 char* QueryGenerator::hardpoint(int mapObjectId
)
143 std::stringstream queryStream
;
146 queryStream
<< "select ";
147 queryStream
<< "mo.MapObjectId, ";
148 queryStream
<< "h.RelativeX, ";
149 queryStream
<< "h.RelativeY, ";
150 queryStream
<< "h.HardpointType, ";
151 queryStream
<< "h.Width, ";
152 queryStream
<< "h.Height, ";
153 queryStream
<< "h.Radius ";
154 queryStream
<< "from MapObject mo, Hardpoints h ";
155 queryStream
<< "where mo.MapObjectId = " << mapObjectId
<< ";";
157 query
= queryStream
.str();
159 return const_cast<char*>(query
.c_str());