|
@@ -122,6 +122,10 @@ int World::getSector(int room, float x, float z, float *floor, float *ceiling)
|
122
|
122
|
sector_t * s;
|
123
|
123
|
int sector;
|
124
|
124
|
|
|
125
|
+ assert(room >= 0);
|
|
126
|
+ assert(floor != NULL);
|
|
127
|
+ assert(ceiling != NULL);
|
|
128
|
+
|
125
|
129
|
r = mRooms[room];
|
126
|
130
|
|
127
|
131
|
if (!r)
|
|
@@ -145,67 +149,61 @@ int World::getSector(int room, float x, float z, float *floor, float *ceiling)
|
145
|
149
|
}
|
146
|
150
|
|
147
|
151
|
|
148
|
|
-int World::getSector(int room, float x, float z)
|
149
|
|
-{
|
|
152
|
+int World::getSector(int room, float x, float z) {
|
150
|
153
|
int sector;
|
151
|
154
|
room_mesh_t *r;
|
152
|
155
|
|
|
156
|
+ if ((room < 0) || (room >= mRooms.size()))
|
|
157
|
+ return -1;
|
|
158
|
+
|
153
|
159
|
r = mRooms[room];
|
154
|
160
|
|
155
|
161
|
if (!r)
|
156
|
|
- {
|
157
|
162
|
return -1;
|
158
|
|
- }
|
159
|
163
|
|
160
|
164
|
sector = (((((int)x - (int)r->pos[0]) / 1024) * r->numZSectors) +
|
161
|
165
|
(((int)z - (int)r->pos[2]) / 1024));
|
162
|
166
|
|
163
|
167
|
if (sector < 0)
|
164
|
|
- {
|
165
|
168
|
return -1;
|
166
|
|
- }
|
167
|
169
|
|
168
|
170
|
return sector;
|
169
|
171
|
}
|
170
|
172
|
|
171
|
173
|
|
172
|
|
-unsigned int World::getRoomInfo(int room)
|
173
|
|
-{
|
|
174
|
+unsigned int World::getRoomInfo(int room) {
|
174
|
175
|
room_mesh_t *r;
|
175
|
176
|
|
|
177
|
+ if ((room >= mRooms.size()) || (room < 0))
|
|
178
|
+ return 0;
|
176
|
179
|
|
177
|
180
|
r = mRooms[room];
|
178
|
181
|
|
179
|
182
|
if (!r)
|
180
|
|
- {
|
181
|
183
|
return 0;
|
182
|
|
- }
|
183
|
184
|
|
184
|
185
|
return r->flags;
|
185
|
186
|
}
|
186
|
187
|
|
187
|
188
|
|
188
|
|
-bool World::isWall(int room, int sector)
|
189
|
|
-{
|
|
189
|
+bool World::isWall(int room, int sector) {
|
190
|
190
|
room_mesh_t *r;
|
191
|
191
|
sector_t *sect;
|
192
|
192
|
|
|
193
|
+ if ((room >= mRooms.size()) || (room < 0))
|
|
194
|
+ return true;
|
193
|
195
|
|
194
|
196
|
r = mRooms[room];
|
195
|
197
|
|
196
|
|
- if (!r)
|
197
|
|
- {
|
|
198
|
+ if ((!r) || (sector >= r->sectors.size()) || (sector < 0))
|
198
|
199
|
return true;
|
199
|
|
- }
|
200
|
200
|
|
201
|
201
|
sect = r->sectors[sector];
|
202
|
202
|
|
203
|
203
|
if (!sect)
|
204
|
|
- {
|
205
|
204
|
return true;
|
206
|
|
- }
|
207
|
205
|
|
208
|
|
- return ((sector > 0) && sect->wall);
|
|
206
|
+ return ((sector > 0) && sect->wall);
|
209
|
207
|
}
|
210
|
208
|
|
211
|
209
|
|
|
@@ -465,6 +463,9 @@ void World::moveEntity(entity_t *e, char movement)
|
465
|
463
|
if (room > -1)
|
466
|
464
|
{
|
467
|
465
|
printf("Crossing from room %i to %i\n", e->room, room);
|
|
466
|
+ } else {
|
|
467
|
+
|
|
468
|
+ return;
|
468
|
469
|
}
|
469
|
470
|
}
|
470
|
471
|
|