|
@@ -1,6 +1,6 @@
|
1
|
1
|
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
|
2
|
2
|
/*================================================================
|
3
|
|
- *
|
|
3
|
+ *
|
4
|
4
|
* Project : OpenRaider
|
5
|
5
|
* Author : Terry 'Mongoose' Hendrix II
|
6
|
6
|
* Website : http://www.westga.edu/~stu7440/
|
|
@@ -10,10 +10,10 @@
|
10
|
10
|
* Comments: The game world ( model )
|
11
|
11
|
*
|
12
|
12
|
*
|
13
|
|
- * This file was generated using Mongoose's C++
|
|
13
|
+ * This file was generated using Mongoose's C++
|
14
|
14
|
* template generator script. <stu7440@westga.edu>
|
15
|
|
- *
|
16
|
|
- *-- History -------------------------------------------------
|
|
15
|
+ *
|
|
16
|
+ *-- History -------------------------------------------------
|
17
|
17
|
*
|
18
|
18
|
* 2002.12.16:
|
19
|
19
|
* Mongoose - Created
|
|
@@ -66,7 +66,7 @@ int World::getRoomByLocation(int index, float x, float y, float z)
|
66
|
66
|
return index;
|
67
|
67
|
}
|
68
|
68
|
}
|
69
|
|
-
|
|
69
|
+
|
70
|
70
|
return getRoomByLocation(x, y, z);
|
71
|
71
|
}
|
72
|
72
|
|
|
@@ -80,17 +80,17 @@ int World::getRoomByLocation(float x, float y, float z)
|
80
|
80
|
for (mRooms.start(); mRooms.forward(); mRooms.next())
|
81
|
81
|
{
|
82
|
82
|
room = mRooms.current();
|
83
|
|
-
|
|
83
|
+
|
84
|
84
|
if (!room)
|
85
|
85
|
continue;
|
86
|
86
|
|
87
|
87
|
if (x > room->bbox_min[0] && x < room->bbox_max[0] &&
|
88
|
88
|
z > room->bbox_min[2] && z < room->bbox_max[2])
|
89
|
|
- {
|
|
89
|
+ {
|
90
|
90
|
// This room contains current position
|
91
|
91
|
if (y > room->bbox_min[1] && y < room->bbox_max[1])
|
92
|
92
|
return mRooms.getCurrentIndex();
|
93
|
|
-
|
|
93
|
+
|
94
|
94
|
// This room is above or below current position
|
95
|
95
|
hop = mRooms.getCurrentIndex();
|
96
|
96
|
}
|
|
@@ -104,7 +104,7 @@ int World::getRoomByLocation(float x, float y, float z)
|
104
|
104
|
}
|
105
|
105
|
|
106
|
106
|
|
107
|
|
-int World::getAdjoiningRoom(int index,
|
|
107
|
+int World::getAdjoiningRoom(int index,
|
108
|
108
|
float x, float y, float z,
|
109
|
109
|
float x2, float y2, float z2)
|
110
|
110
|
{
|
|
@@ -118,14 +118,14 @@ int World::getAdjoiningRoom(int index,
|
118
|
118
|
|
119
|
119
|
if (room)
|
120
|
120
|
{
|
121
|
|
- for (room->portals.start(); room->portals.forward();
|
|
121
|
+ for (room->portals.start(); room->portals.forward();
|
122
|
122
|
room->portals.next())
|
123
|
123
|
{
|
124
|
124
|
portal = room->portals.current();
|
125
|
|
-
|
|
125
|
+
|
126
|
126
|
if (!portal)
|
127
|
127
|
continue;
|
128
|
|
-
|
|
128
|
+
|
129
|
129
|
if (helIntersectionLineAndPolygon(intersect, p1, p2, 4,
|
130
|
130
|
portal->vertices))
|
131
|
131
|
{
|
|
@@ -146,11 +146,11 @@ int World::getSector(int room, float x, float z, float *floor, float *ceiling)
|
146
|
146
|
|
147
|
147
|
|
148
|
148
|
r = mRooms[room];
|
149
|
|
-
|
|
149
|
+
|
150
|
150
|
if (!r)
|
151
|
151
|
return -1;
|
152
|
152
|
|
153
|
|
- sector = (((((int)x - (int)r->pos[0]) / 1024) * r->numZSectors) +
|
|
153
|
+ sector = (((((int)x - (int)r->pos[0]) / 1024) * r->numZSectors) +
|
154
|
154
|
(((int)z - (int)r->pos[2]) / 1024));
|
155
|
155
|
|
156
|
156
|
if (sector > -1)
|
|
@@ -169,7 +169,7 @@ int World::getSector(int room, float x, float z, float *floor, float *ceiling)
|
169
|
169
|
|
170
|
170
|
|
171
|
171
|
int World::getSector(int room, float x, float z)
|
172
|
|
-{
|
|
172
|
+{
|
173
|
173
|
int sector;
|
174
|
174
|
room_mesh_t *r;
|
175
|
175
|
|
|
@@ -181,7 +181,7 @@ int World::getSector(int room, float x, float z)
|
181
|
181
|
return -1;
|
182
|
182
|
}
|
183
|
183
|
|
184
|
|
- sector = (((((int)x - (int)r->pos[0]) / 1024) * r->numZSectors) +
|
|
184
|
+ sector = (((((int)x - (int)r->pos[0]) / 1024) * r->numZSectors) +
|
185
|
185
|
(((int)z - (int)r->pos[2]) / 1024));
|
186
|
186
|
|
187
|
187
|
if (sector < 0)
|
|
@@ -247,7 +247,7 @@ bool World::getHeightAtPosition(int index, float x, float *y, float z)
|
247
|
247
|
return false;
|
248
|
248
|
}
|
249
|
249
|
|
250
|
|
- // Mongoose 2002.08.14, It's 0302 - give me a fucking break --
|
|
250
|
+ // Mongoose 2002.08.14, It's 0302 - give me a fucking break --
|
251
|
251
|
// this works albeit poorly =)
|
252
|
252
|
for (i = 0; (int)i < room->num_boxes; ++i)
|
253
|
253
|
{
|
|
@@ -467,7 +467,7 @@ void World::moveEntity(entity_t *e, char movement)
|
467
|
467
|
{
|
468
|
468
|
#define ADJ_ROOM_CHECK
|
469
|
469
|
#ifdef ADJ_ROOM_CHECK
|
470
|
|
- room = getAdjoiningRoom(e->room,
|
|
470
|
+ room = getAdjoiningRoom(e->room,
|
471
|
471
|
e->pos[0], e->pos[1], e->pos[2],
|
472
|
472
|
x, y, z);
|
473
|
473
|
#else
|
|
@@ -491,7 +491,7 @@ void World::moveEntity(entity_t *e, char movement)
|
491
|
491
|
roomFlags = getRoomInfo(room);
|
492
|
492
|
sector = getSector(room, x, z, &floor, &ceiling);
|
493
|
493
|
wall = isWall(room, sector);
|
494
|
|
-
|
|
494
|
+
|
495
|
495
|
// If you're underwater you may want to swim =)
|
496
|
496
|
// ...if you're worldMoveType_walkNoSwim, you better hope it's shallow
|
497
|
497
|
if (roomFlags & roomFlag_underWater && e->moveType == worldMoveType_walk)
|
|
@@ -503,14 +503,14 @@ void World::moveEntity(entity_t *e, char movement)
|
503
|
503
|
if (!(roomFlags & roomFlag_underWater) && e->moveType == worldMoveType_swim)
|
504
|
504
|
{
|
505
|
505
|
e->moveType = worldMoveType_walk;
|
506
|
|
- }
|
|
506
|
+ }
|
507
|
507
|
|
508
|
|
- // Mongoose 2002.09.02, Add check for room -> room transition
|
|
508
|
+ // Mongoose 2002.09.02, Add check for room -> room transition
|
509
|
509
|
// ( Only allow by movement between rooms by using portals )
|
510
|
|
- if ((e->moveType == worldMoveType_noClipping ||
|
511
|
|
- e->moveType == worldMoveType_fly ||
|
512
|
|
- e->moveType == worldMoveType_swim) ||
|
513
|
|
- room > -1 && !wall)
|
|
510
|
+ if (((e->moveType == worldMoveType_noClipping) ||
|
|
511
|
+ (e->moveType == worldMoveType_fly) ||
|
|
512
|
+ (e->moveType == worldMoveType_swim)) ||
|
|
513
|
+ ((room > -1) && (!wall)))
|
514
|
514
|
{
|
515
|
515
|
e->room = room;
|
516
|
516
|
|
|
@@ -576,7 +576,7 @@ void World::moveEntity(entity_t *e, char movement)
|
576
|
576
|
// This is to force false gravity, by making camera stay on ground
|
577
|
577
|
e->pos[1] = h; //roomFloor->bbox_min[1];
|
578
|
578
|
|
579
|
|
- // Check for camera below terrian and correct
|
|
579
|
+ // Check for camera below terrian and correct
|
580
|
580
|
if (e->pos[1] < h - camHeight)
|
581
|
581
|
{
|
582
|
582
|
e->pos[1] = h - camHeight;
|
|
@@ -637,7 +637,7 @@ void World::clear()
|
637
|
637
|
for (mRooms.start(); mRooms.forward(); mRooms.next())
|
638
|
638
|
{
|
639
|
639
|
room = mRooms.current();
|
640
|
|
-
|
|
640
|
+
|
641
|
641
|
if (room)
|
642
|
642
|
{
|
643
|
643
|
room->portals.erase();
|
|
@@ -657,7 +657,7 @@ void World::clear()
|
657
|
657
|
if (!mesh)
|
658
|
658
|
continue;
|
659
|
659
|
|
660
|
|
- for (mesh->texturedTriangles.start();
|
|
660
|
+ for (mesh->texturedTriangles.start();
|
661
|
661
|
mesh->texturedTriangles.forward();
|
662
|
662
|
mesh->texturedTriangles.next())
|
663
|
663
|
{
|
|
@@ -672,7 +672,7 @@ void World::clear()
|
672
|
672
|
delete mesh->coloredTriangles.current();
|
673
|
673
|
}
|
674
|
674
|
|
675
|
|
- for (mesh->texturedRectangles.start();
|
|
675
|
+ for (mesh->texturedRectangles.start();
|
676
|
676
|
mesh->texturedRectangles.forward();
|
677
|
677
|
mesh->texturedRectangles.next())
|
678
|
678
|
{
|
|
@@ -704,7 +704,7 @@ void World::clear()
|
704
|
704
|
for (mSprites.start(); mSprites.forward(); mSprites.next())
|
705
|
705
|
{
|
706
|
706
|
sprite = mSprites.current();
|
707
|
|
-
|
|
707
|
+
|
708
|
708
|
if (!sprite)
|
709
|
709
|
continue;
|
710
|
710
|
|
|
@@ -719,12 +719,12 @@ void World::clear()
|
719
|
719
|
for (mModels.start(); mModels.forward(); mModels.next())
|
720
|
720
|
{
|
721
|
721
|
model = mModels.current();
|
722
|
|
-
|
|
722
|
+
|
723
|
723
|
if (!model)
|
724
|
724
|
continue;
|
725
|
725
|
|
726
|
726
|
// No smart pointers, so skip if deleted once =)
|
727
|
|
- if (!cache.SearchKey(model) == UINT_MAX)
|
|
727
|
+ if (!cache.SearchKey(model))
|
728
|
728
|
{
|
729
|
729
|
cache.Add(model);
|
730
|
730
|
}
|
|
@@ -733,7 +733,7 @@ void World::clear()
|
733
|
733
|
continue;
|
734
|
734
|
}
|
735
|
735
|
|
736
|
|
- for (model->animation.start(); model->animation.forward();
|
|
736
|
+ for (model->animation.start(); model->animation.forward();
|
737
|
737
|
model->animation.next())
|
738
|
738
|
{
|
739
|
739
|
animation = model->animation.current();
|
|
@@ -741,7 +741,7 @@ void World::clear()
|
741
|
741
|
if (!animation)
|
742
|
742
|
continue;
|
743
|
743
|
|
744
|
|
- for (animation->frame.start(); animation->frame.forward();
|
|
744
|
+ for (animation->frame.start(); animation->frame.forward();
|
745
|
745
|
animation->frame.next())
|
746
|
746
|
{
|
747
|
747
|
boneframe = animation->frame.current();
|
|
@@ -749,20 +749,20 @@ void World::clear()
|
749
|
749
|
if (!boneframe)
|
750
|
750
|
continue;
|
751
|
751
|
|
752
|
|
- for (boneframe->tag.start(); boneframe->tag.forward();
|
|
752
|
+ for (boneframe->tag.start(); boneframe->tag.forward();
|
753
|
753
|
boneframe->tag.next())
|
754
|
754
|
{
|
755
|
755
|
tag = boneframe->tag.current();
|
756
|
|
-
|
|
756
|
+
|
757
|
757
|
if (!tag)
|
758
|
758
|
continue;
|
759
|
759
|
|
760
|
760
|
delete tag;
|
761
|
|
- }
|
|
761
|
+ }
|
762
|
762
|
|
763
|
763
|
delete boneframe;
|
764
|
764
|
}
|
765
|
|
-
|
|
765
|
+
|
766
|
766
|
delete animation;
|
767
|
767
|
}
|
768
|
768
|
|