Subversion Repositories eduke32

Rev

Rev 8694 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8694 Rev 8767
1
//-------------------------------------------------------------------------
1
//-------------------------------------------------------------------------
2
/*
2
/*
3
Copyright (C) 1996, 2005 - 3D Realms Entertainment
3
Copyright (C) 1996, 2005 - 3D Realms Entertainment
4

4

5
This file is NOT part of Shadow Warrior version 1.2
5
This file is NOT part of Shadow Warrior version 1.2
6
However, it is either an older version of a file that is, or is
6
However, it is either an older version of a file that is, or is
7
some test code written during the development of Shadow Warrior.
7
some test code written during the development of Shadow Warrior.
8
This file is provided purely for educational interest.
8
This file is provided purely for educational interest.
9

9

10
Shadow Warrior is free software; you can redistribute it and/or
10
Shadow Warrior is free software; you can redistribute it and/or
11
modify it under the terms of the GNU General Public License
11
modify it under the terms of the GNU General Public License
12
as published by the Free Software Foundation; either version 2
12
as published by the Free Software Foundation; either version 2
13
of the License, or (at your option) any later version.
13
of the License, or (at your option) any later version.
14

14

15
This program is distributed in the hope that it will be useful,
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18

18

19
See the GNU General Public License for more details.
19
See the GNU General Public License for more details.
20

20

21
You should have received a copy of the GNU General Public License
21
You should have received a copy of the GNU General Public License
22
along with this program; if not, write to the Free Software
22
along with this program; if not, write to the Free Software
23
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
23
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24

24

25
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
25
Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
26
*/
26
*/
27
//-------------------------------------------------------------------------
27
//-------------------------------------------------------------------------
28
28
29
#include "build.h"
29
#include "build.h"
30
#include "editor.h"
30
#include "editor.h"
31
31
32
#include "keys.h"
32
#include "keys.h"
33
#include "names2.h"
33
#include "names2.h"
34
#include "game.h"
34
#include "game.h"
35
35
36
36
37
extern int qsetmode;
37
extern int qsetmode;
38
38
39
SWBOOL FindCeilingView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum);
39
SWBOOL FindCeilingView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum);
40
SWBOOL FindFloorView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum);
40
SWBOOL FindFloorView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum);
41
short ViewSectorInScene(short cursectnum, short level);
41
short ViewSectorInScene(short cursectnum, short level);
42
void Message(const char *string, char color);
42
void Message(const char *string, char color);
43
43
44
44
45
void
45
void
46
_Assert(const char *expr, const char *strFile, unsigned uLine)
46
_Assert(const char *expr, const char *strFile, unsigned uLine)
47
{
47
{
48
    printf(ds, "Assertion failed: %s %s, line %u\n", expr, strFile, uLine);
48
    printf(ds, "Assertion failed: %s %s, line %u\n", expr, strFile, uLine);
49
    //DSPRINTF(ds, "Assertion failed: %s %s, line %u", expr, strFile, uLine);
49
    //DSPRINTF(ds, "Assertion failed: %s %s, line %u", expr, strFile, uLine);
50
    MONO_PRINT(ds);
50
    MONO_PRINT(ds);
51
    exit(0);
51
    exit(0);
52
}
52
}
53
53
54
////////////////////////////////////////////////////////////////////
54
////////////////////////////////////////////////////////////////////
55
//
55
//
56
// FLOOR ABOVE FLOOR
56
// FLOOR ABOVE FLOOR
57
//
57
//
58
////////////////////////////////////////////////////////////////////
58
////////////////////////////////////////////////////////////////////
59
59
60
60
61
#define ZMAX 400
61
#define ZMAX 400
62
typedef struct
62
typedef struct
63
{
63
{
64
    int32_t zval[ZMAX];
64
    int32_t zval[ZMAX];
65
    int16_t sectnum[ZMAX];
65
    int16_t sectnum[ZMAX];
66
    int16_t pic[ZMAX];
66
    int16_t pic[ZMAX];
67
    int16_t slope[ZMAX];
67
    int16_t slope[ZMAX];
68
    int16_t zcount;
68
    int16_t zcount;
69
} SAVE, *SAVEp;
69
} SAVE, *SAVEp;
70
70
71
SAVE save;
71
SAVE save;
72
72
73
SWBOOL FAF_DebugView = 0;
-
 
74
SWBOOL FAFon = 0;
73
SWBOOL FAFon = 0;
75
SWBOOL FAF_DontMoveSectors = FALSE;
74
SWBOOL FAF_DontMoveSectors = FALSE;
76
75
77
short bak_searchsector, bak_searchwall, bak_searchstat;
76
short bak_searchsector, bak_searchwall, bak_searchstat;
78
extern short searchsector, searchwall, searchstat, searchit;
77
extern short searchsector, searchwall, searchstat, searchit;
79
78
80
void SetupBuildFAF(void);
79
void SetupBuildFAF(void);
81
void ResetBuildFAF(void);
80
void ResetBuildFAF(void);
82
81
83
void ToggleFAF(void)
82
void ToggleFAF(void)
84
{
83
{
85
    if (keystatus[KEYSC_3])
84
    if (keystatus[KEYSC_3])
86
    {
85
    {
87
        keystatus[KEYSC_3] = FALSE;
86
        keystatus[KEYSC_3] = FALSE;
88
87
89
        FLIP(FAFon, 1);
88
        FLIP(FAFon, 1);
90
        if (FAFon)
89
        if (FAFon)
91
        {
90
        {
92
            SetupBuildFAF();
91
            SetupBuildFAF();
93
        }
92
        }
94
        else
93
        else
95
        {
94
        {
96
            ResetBuildFAF();
95
            ResetBuildFAF();
97
        }
96
        }
98
    }
97
    }
99
98
100
    if (FAFon && qsetmode == 200)
99
    if (FAFon && qsetmode == 200)
101
    {
100
    {
102
        DrawOverlapRoom(pos.x, pos.y, pos.z, ang, horiz, cursectnum);
101
        DrawOverlapRoom(pos.x, pos.y, pos.z, ang, horiz, cursectnum);
103
102
104
        // make it so that you can edit both areas in 3D
103
        // make it so that you can edit both areas in 3D
105
        // back up vars after the first drawrooms
104
        // back up vars after the first drawrooms
106
        bak_searchsector = searchsector;
105
        bak_searchsector = searchsector;
107
        bak_searchwall = searchwall;
106
        bak_searchwall = searchwall;
108
        bak_searchstat = searchstat;
107
        bak_searchstat = searchstat;
109
        searchit = 2;
108
        searchit = 2;
110
    }
109
    }
111
110
112
    if (FAFon && qsetmode == 200 && keystatus[KEYSC_4])
111
    if (FAFon && qsetmode == 200 && keystatus[KEYSC_4])
113
    {
112
    {
114
        short match;
113
        short match;
115
        int tx,ty,tz;
114
        int tx,ty,tz;
116
        short tsectnum;
115
        short tsectnum;
117
        keystatus[KEYSC_4] = FALSE;
116
        keystatus[KEYSC_4] = FALSE;
118
117
119
        tx = pos.x;
118
        tx = pos.x;
120
        ty = pos.y;
119
        ty = pos.y;
121
        tz = pos.z;
120
        tz = pos.z;
122
        tsectnum = cursectnum;
121
        tsectnum = cursectnum;
123
122
124
        save.zcount = 0;
123
        save.zcount = 0;
125
124
126
        if (sector[cursectnum].ceilingpicnum == FAF_MIRROR_PIC)
125
        if (sector[cursectnum].ceilingpicnum == FAF_MIRROR_PIC)
127
        {
126
        {
128
            match = ViewSectorInScene(tsectnum, VIEW_LEVEL1);
127
            match = ViewSectorInScene(tsectnum, VIEW_LEVEL1);
129
128
130
            FAF_DontMoveSectors = TRUE;
129
            FAF_DontMoveSectors = TRUE;
131
            FindCeilingView(match, &tx, &ty, tz, &tsectnum);
130
            FindCeilingView(match, &tx, &ty, tz, &tsectnum);
132
            FAF_DontMoveSectors = FALSE;
131
            FAF_DontMoveSectors = FALSE;
133
132
134
            pos.x = tx;
133
            pos.x = tx;
135
            pos.y = ty;
134
            pos.y = ty;
136
            cursectnum = tsectnum;
135
            cursectnum = tsectnum;
137
            pos.z = sector[cursectnum].floorz - Z(20);
136
            pos.z = sector[cursectnum].floorz - Z(20);
138
        }
137
        }
139
        else if (sector[cursectnum].floorpicnum == FAF_MIRROR_PIC)
138
        else if (sector[cursectnum].floorpicnum == FAF_MIRROR_PIC)
140
        {
139
        {
141
            match = ViewSectorInScene(tsectnum, VIEW_LEVEL2);
140
            match = ViewSectorInScene(tsectnum, VIEW_LEVEL2);
142
141
143
            FAF_DontMoveSectors = TRUE;
142
            FAF_DontMoveSectors = TRUE;
144
            FindFloorView(match, &tx, &ty, tz, &tsectnum);
143
            FindFloorView(match, &tx, &ty, tz, &tsectnum);
145
            FAF_DontMoveSectors = FALSE;
144
            FAF_DontMoveSectors = FALSE;
146
145
147
            pos.x = tx;
146
            pos.x = tx;
148
            pos.y = ty;
147
            pos.y = ty;
149
            cursectnum = tsectnum;
148
            cursectnum = tsectnum;
150
            pos.z = sector[cursectnum].ceilingz + Z(20);
149
            pos.z = sector[cursectnum].ceilingz + Z(20);
151
        }
150
        }
152
    }
151
    }
153
152
154
153
155
}
154
}
156
155
157
156
158
void FAF_AfterDrawRooms(void)
157
void FAF_AfterDrawRooms(void)
159
{
158
{
160
    // make it so that you can edit both areas in 3D
159
    // make it so that you can edit both areas in 3D
161
    // if your cursor is in the FAF_MIRROR_PIC area use the vars from the first
160
    // if your cursor is in the FAF_MIRROR_PIC area use the vars from the first
162
    // drawrooms instead
161
    // drawrooms instead
163
    if ((searchstat == 1 && sector[searchsector].ceilingpicnum == FAF_MIRROR_PIC) ||
162
    if ((searchstat == 1 && sector[searchsector].ceilingpicnum == FAF_MIRROR_PIC) ||
164
        (searchstat == 2 && sector[searchsector].floorpicnum == FAF_MIRROR_PIC))
163
        (searchstat == 2 && sector[searchsector].floorpicnum == FAF_MIRROR_PIC))
165
    {
164
    {
166
        searchsector = bak_searchsector;
165
        searchsector = bak_searchsector;
167
        searchwall = bak_searchwall;
166
        searchwall = bak_searchwall;
168
        searchstat = bak_searchstat;
167
        searchstat = bak_searchstat;
169
    }
168
    }
170
}
169
}
171
170
172
void
171
void
173
SetupBuildFAF(void)
172
SetupBuildFAF(void)
174
{
173
{
175
    short i, nexti;
174
    short i, nexti;
176
    SPRITEp sp;
175
    SPRITEp sp;
177
    short SpriteNum, NextSprite;
176
    short SpriteNum, NextSprite;
178
    // move every sprite to the correct list
177
    // move every sprite to the correct list
179
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_DEFAULT], SpriteNum, NextSprite)
178
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_DEFAULT], SpriteNum, NextSprite)
180
    {
179
    {
181
        sp = &sprite[SpriteNum];
180
        sp = &sprite[SpriteNum];
182
181
183
        if (sp->picnum != ST1)
182
        if (sp->picnum != ST1)
184
            continue;
183
            continue;
185
184
186
        switch (sp->hitag)
185
        switch (sp->hitag)
187
        {
186
        {
188
        case VIEW_THRU_CEILING:
187
        case VIEW_THRU_CEILING:
189
        case VIEW_THRU_FLOOR:
188
        case VIEW_THRU_FLOOR:
190
        {
189
        {
191
            int i,nexti;
190
            int i,nexti;
192
            // make sure there is only one set per level of these
191
            // make sure there is only one set per level of these
193
            TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
192
            TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
194
            {
193
            {
195
                if (sprite[i].hitag == sp->hitag && sprite[i].lotag == sp->lotag)
194
                if (sprite[i].hitag == sp->hitag && sprite[i].lotag == sp->lotag)
196
                {
195
                {
197
                    sprintf(ds,"Two VIEW_THRU_ tags with same match found on level\n1: x %d, y %d \n2: x %d, y %d", TrackerCast(sp->x), TrackerCast(sp->y), TrackerCast(sprite[i].x), TrackerCast(sprite[i].y));
196
                    sprintf(ds,"Two VIEW_THRU_ tags with same match found on level\n1: x %d, y %d \n2: x %d, y %d", TrackerCast(sp->x), TrackerCast(sp->y), TrackerCast(sprite[i].x), TrackerCast(sprite[i].y));
198
                    Message(ds,0);
197
                    Message(ds,0);
199
                }
198
                }
200
            }
199
            }
201
200
202
            changespritestat(SpriteNum, STAT_FAF);
201
            changespritestat(SpriteNum, STAT_FAF);
203
            break;
202
            break;
204
        }
203
        }
205
204
206
        case VIEW_LEVEL1:
205
        case VIEW_LEVEL1:
207
        case VIEW_LEVEL2:
206
        case VIEW_LEVEL2:
208
        case VIEW_LEVEL3:
207
        case VIEW_LEVEL3:
209
        case VIEW_LEVEL4:
208
        case VIEW_LEVEL4:
210
        case VIEW_LEVEL5:
209
        case VIEW_LEVEL5:
211
        case VIEW_LEVEL6:
210
        case VIEW_LEVEL6:
212
        {
211
        {
213
            changespritestat(SpriteNum, STAT_FAF);
212
            changespritestat(SpriteNum, STAT_FAF);
214
            break;
213
            break;
215
        }
214
        }
216
        }
215
        }
217
    }
216
    }
218
217
219
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
218
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
220
    {
219
    {
221
        sp = &sprite[i];
220
        sp = &sprite[i];
222
221
223
        if (sector[sp->sectnum].ceilingpicnum == FAF_PLACE_MIRROR_PIC)
222
        if (sector[sp->sectnum].ceilingpicnum == FAF_PLACE_MIRROR_PIC)
224
        {
223
        {
225
            sector[sp->sectnum].ceilingpicnum = FAF_MIRROR_PIC;
224
            sector[sp->sectnum].ceilingpicnum = FAF_MIRROR_PIC;
226
            if (sector[sp->sectnum].floorz == sector[sp->sectnum].ceilingz)
225
            if (sector[sp->sectnum].floorz == sector[sp->sectnum].ceilingz)
227
            {
226
            {
228
                sprintf(ds, "Mirror used for non-connect area. Use tile 342. Sect %d, x %d, y %d\n", TrackerCast(sp->sectnum), TrackerCast(wall[sector[sp->sectnum].wallptr].x), TrackerCast(wall[sector[sp->sectnum].wallptr].y));
227
                sprintf(ds, "Mirror used for non-connect area. Use tile 342. Sect %d, x %d, y %d\n", TrackerCast(sp->sectnum), TrackerCast(wall[sector[sp->sectnum].wallptr].x), TrackerCast(wall[sector[sp->sectnum].wallptr].y));
229
                Message(ds,0);
228
                Message(ds,0);
230
            }
229
            }
231
        }
230
        }
232
231
233
        if (sector[sp->sectnum].floorpicnum == FAF_PLACE_MIRROR_PIC)
232
        if (sector[sp->sectnum].floorpicnum == FAF_PLACE_MIRROR_PIC)
234
        {
233
        {
235
            sector[sp->sectnum].floorpicnum = FAF_MIRROR_PIC;
234
            sector[sp->sectnum].floorpicnum = FAF_MIRROR_PIC;
236
            if (sector[sp->sectnum].floorz == sector[sp->sectnum].ceilingz)
235
            if (sector[sp->sectnum].floorz == sector[sp->sectnum].ceilingz)
237
            {
236
            {
238
                sprintf(ds, "Mirror used for non-connect area. Use tile 342. Sect %d, x %d, y %d\n", TrackerCast(sp->sectnum), TrackerCast(wall[sector[sp->sectnum].wallptr].x), TrackerCast(wall[sector[sp->sectnum].wallptr].y));
237
                sprintf(ds, "Mirror used for non-connect area. Use tile 342. Sect %d, x %d, y %d\n", TrackerCast(sp->sectnum), TrackerCast(wall[sector[sp->sectnum].wallptr].x), TrackerCast(wall[sector[sp->sectnum].wallptr].y));
239
                Message(ds,0);
238
                Message(ds,0);
240
            }
239
            }
241
        }
240
        }
242
241
243
        if (sector[sp->sectnum].ceilingpicnum == FAF_PLACE_MIRROR_PIC+1)
242
        if (sector[sp->sectnum].ceilingpicnum == FAF_PLACE_MIRROR_PIC+1)
244
            sector[sp->sectnum].ceilingpicnum = FAF_MIRROR_PIC+1;
243
            sector[sp->sectnum].ceilingpicnum = FAF_MIRROR_PIC+1;
245
244
246
        if (sector[sp->sectnum].floorpicnum == FAF_PLACE_MIRROR_PIC+1)
245
        if (sector[sp->sectnum].floorpicnum == FAF_PLACE_MIRROR_PIC+1)
247
            sector[sp->sectnum].floorpicnum = FAF_MIRROR_PIC+1;
246
            sector[sp->sectnum].floorpicnum = FAF_MIRROR_PIC+1;
248
    }
247
    }
249
248
250
249
251
    for (i = 0; i < numwalls; i++)
250
    for (i = 0; i < numwalls; i++)
252
    {
251
    {
253
        if (wall[i].picnum == FAF_PLACE_MIRROR_PIC)
252
        if (wall[i].picnum == FAF_PLACE_MIRROR_PIC)
254
            wall[i].picnum = FAF_MIRROR_PIC;
253
            wall[i].picnum = FAF_MIRROR_PIC;
255
254
256
        if (wall[i].picnum == FAF_PLACE_MIRROR_PIC+1)
255
        if (wall[i].picnum == FAF_PLACE_MIRROR_PIC+1)
257
            wall[i].picnum = FAF_MIRROR_PIC+1;
256
            wall[i].picnum = FAF_MIRROR_PIC+1;
258
    }
257
    }
259
258
260
#if 0
259
#if 0
261
    // check ceiling and floor heights
260
    // check ceiling and floor heights
262
    SPRITEp vc_sp,vf_sp,vl_sp;
261
    SPRITEp vc_sp,vf_sp,vl_sp;
263
    short vc,nextvc,vf,nextvf,l,nextl;
262
    short vc,nextvc,vf,nextvf,l,nextl;
264
    int zdiff;
263
    int zdiff;
265
264
266
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], vc, nextvc)
265
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], vc, nextvc)
267
    {
266
    {
268
        vc_sp = &sprite[vc];
267
        vc_sp = &sprite[vc];
269
268
270
        if (vc_sp->hitag == VIEW_THRU_CEILING)
269
        if (vc_sp->hitag == VIEW_THRU_CEILING)
271
        {
270
        {
272
            TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], vf, nextvf)
271
            TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], vf, nextvf)
273
            {
272
            {
274
                vf_sp = &sprite[vf];
273
                vf_sp = &sprite[vf];
275
274
276
                if (vf_sp->hitag == VIEW_THRU_FLOOR && vf_sp->lotag == vc_sp->lotag)
275
                if (vf_sp->hitag == VIEW_THRU_FLOOR && vf_sp->lotag == vc_sp->lotag)
277
                {
276
                {
278
                    zdiff = labs(sector[vc_sp->sectnum].ceilingz - sector[vf_sp->sectnum].floorz);
277
                    zdiff = labs(sector[vc_sp->sectnum].ceilingz - sector[vf_sp->sectnum].floorz);
279
278
280
                    //DSPRINTF(ds,"zdiff %d",zdiff);
279
                    //DSPRINTF(ds,"zdiff %d",zdiff);
281
                    MONO_PRINT(ds);
280
                    MONO_PRINT(ds);
282
281
283
                    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], l, nextl)
282
                    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], l, nextl)
284
                    {
283
                    {
285
                        vl_sp = &sprite[l];
284
                        vl_sp = &sprite[l];
286
285
287
                        if (vl_sp->hitag == VIEW_LEVEL1)
286
                        if (vl_sp->hitag == VIEW_LEVEL1)
288
                        {
287
                        {
289
                            if (sector[vl_sp->sectnum].ceilingz < sector[vc_sp->sectnum].ceilingz + zdiff)
288
                            if (sector[vl_sp->sectnum].ceilingz < sector[vc_sp->sectnum].ceilingz + zdiff)
290
                            {
289
                            {
291
                                sprintf(ds,"Sector %d (x %d, y %d) ceiling z to close to VIEW_THRU_CEILING z",
290
                                sprintf(ds,"Sector %d (x %d, y %d) ceiling z to close to VIEW_THRU_CEILING z",
292
                                        vl_sp->sectnum, wall[sector[vl_sp->sectnum].wallptr].x, wall[sector[vl_sp->sectnum].wallptr].y);
291
                                        vl_sp->sectnum, wall[sector[vl_sp->sectnum].wallptr].x, wall[sector[vl_sp->sectnum].wallptr].y);
293
                                Message(ds,0);
292
                                Message(ds,0);
294
                            }
293
                            }
295
                        }
294
                        }
296
                        else if (vl_sp->hitag == VIEW_LEVEL2)
295
                        else if (vl_sp->hitag == VIEW_LEVEL2)
297
                        {
296
                        {
298
                            if (sector[vl_sp->sectnum].floorz > sector[vf_sp->sectnum].floorz + zdiff)
297
                            if (sector[vl_sp->sectnum].floorz > sector[vf_sp->sectnum].floorz + zdiff)
299
                            {
298
                            {
300
                                sprintf(ds,"Sector %d (x %d, y %d)floor z to close to VIEW_THRU_FLOOR z",
299
                                sprintf(ds,"Sector %d (x %d, y %d)floor z to close to VIEW_THRU_FLOOR z",
301
                                        vl_sp->sectnum, wall[sector[vl_sp->sectnum].wallptr].x, wall[sector[vl_sp->sectnum].wallptr].y);
300
                                        vl_sp->sectnum, wall[sector[vl_sp->sectnum].wallptr].x, wall[sector[vl_sp->sectnum].wallptr].y);
302
                                Message(ds,0);
301
                                Message(ds,0);
303
                            }
302
                            }
304
                        }
303
                        }
305
                    }
304
                    }
306
                }
305
                }
307
            }
306
            }
308
        }
307
        }
309
    }
308
    }
310
#endif
309
#endif
311
310
312
}
311
}
313
312
314
void
313
void
315
ResetBuildFAF(void)
314
ResetBuildFAF(void)
316
{
315
{
317
    short i, nexti;
316
    short i, nexti;
318
    SPRITEp sp;
317
    SPRITEp sp;
319
318
320
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
319
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
321
    {
320
    {
322
        sp = &sprite[i];
321
        sp = &sprite[i];
323
322
324
        if (sector[sp->sectnum].ceilingpicnum == FAF_MIRROR_PIC)
323
        if (sector[sp->sectnum].ceilingpicnum == FAF_MIRROR_PIC)
325
            sector[sp->sectnum].ceilingpicnum = FAF_PLACE_MIRROR_PIC;
324
            sector[sp->sectnum].ceilingpicnum = FAF_PLACE_MIRROR_PIC;
326
325
327
        if (sector[sp->sectnum].floorpicnum == FAF_MIRROR_PIC)
326
        if (sector[sp->sectnum].floorpicnum == FAF_MIRROR_PIC)
328
            sector[sp->sectnum].floorpicnum = FAF_PLACE_MIRROR_PIC;
327
            sector[sp->sectnum].floorpicnum = FAF_PLACE_MIRROR_PIC;
329
328
330
        if (sector[sp->sectnum].ceilingpicnum == FAF_MIRROR_PIC+1)
329
        if (sector[sp->sectnum].ceilingpicnum == FAF_MIRROR_PIC+1)
331
            sector[sp->sectnum].ceilingpicnum = FAF_PLACE_MIRROR_PIC+1;
330
            sector[sp->sectnum].ceilingpicnum = FAF_PLACE_MIRROR_PIC+1;
332
331
333
        if (sector[sp->sectnum].floorpicnum == FAF_MIRROR_PIC+1)
332
        if (sector[sp->sectnum].floorpicnum == FAF_MIRROR_PIC+1)
334
            sector[sp->sectnum].floorpicnum = FAF_PLACE_MIRROR_PIC+1;
333
            sector[sp->sectnum].floorpicnum = FAF_PLACE_MIRROR_PIC+1;
335
    }
334
    }
336
335
337
    for (i = 0; i < numwalls; i++)
336
    for (i = 0; i < numwalls; i++)
338
    {
337
    {
339
        if (wall[i].picnum == FAF_MIRROR_PIC)
338
        if (wall[i].picnum == FAF_MIRROR_PIC)
340
            wall[i].picnum = FAF_PLACE_MIRROR_PIC;
339
            wall[i].picnum = FAF_PLACE_MIRROR_PIC;
341
340
342
        if (wall[i].picnum == FAF_MIRROR_PIC+1)
341
        if (wall[i].picnum == FAF_MIRROR_PIC+1)
343
            wall[i].picnum = FAF_PLACE_MIRROR_PIC+1;
342
            wall[i].picnum = FAF_PLACE_MIRROR_PIC+1;
344
    }
343
    }
345
344
346
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
345
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
347
    {
346
    {
348
        changespritestat(i, STAT_DEFAULT);
347
        changespritestat(i, STAT_DEFAULT);
349
    }
348
    }
350
}
349
}
351
350
352
351
353
SWBOOL
352
SWBOOL
354
PicInView(short tile_num, SWBOOL reset)
353
PicInView(short tile_num, SWBOOL reset)
355
{
354
{
356
    if (TEST(gotpic[tile_num >> 3], 1 << (tile_num & 7)))
355
    if (TEST(gotpic[tile_num >> 3], 1 << (tile_num & 7)))
357
    {
356
    {
358
        if (reset)
357
        if (reset)
359
            RESET(gotpic[tile_num >> 3], 1 << (tile_num & 7));
358
            RESET(gotpic[tile_num >> 3], 1 << (tile_num & 7));
360
359
361
        return TRUE;
360
        return TRUE;
362
    }
361
    }
363
362
364
    return FALSE;
363
    return FALSE;
365
}
364
}
366
365
367
void
366
void
368
GetUpperLowerSector(short match, int x, int y, short *upper, short *lower)
367
GetUpperLowerSector(short match, int x, int y, short *upper, short *lower)
369
{
368
{
370
    int i;
369
    int i;
371
    short sectorlist[16];
370
    short sectorlist[16];
372
    short sln = 0;
371
    short sln = 0;
373
    short SpriteNum, Next;
372
    short SpriteNum, Next;
374
    SPRITEp sp;
373
    SPRITEp sp;
375
374
376
    // didn't find it yet so test ALL sectors
375
    // didn't find it yet so test ALL sectors
377
    if (sln < 2)
376
    if (sln < 2)
378
    {
377
    {
379
        sln = 0;
378
        sln = 0;
380
        for (i = numsectors - 1; i >= 0; i--)
379
        for (i = numsectors - 1; i >= 0; i--)
381
        {
380
        {
382
            if (inside(x, y, (short) i) == 1)
381
            if (inside(x, y, (short) i) == 1)
383
            {
382
            {
384
                SWBOOL found = FALSE;
383
                SWBOOL found = FALSE;
385
384
386
                TRAVERSE_SPRITE_SECT(headspritesect[i], SpriteNum, Next)
385
                TRAVERSE_SPRITE_SECT(headspritesect[i], SpriteNum, Next)
387
                {
386
                {
388
                    sp = &sprite[SpriteNum];
387
                    sp = &sprite[SpriteNum];
389
388
390
                    if (sp->statnum == STAT_FAF &&
389
                    if (sp->statnum == STAT_FAF &&
391
                        (sp->hitag >= VIEW_LEVEL1 && sp->hitag <= VIEW_LEVEL6)
390
                        (sp->hitag >= VIEW_LEVEL1 && sp->hitag <= VIEW_LEVEL6)
392
                        && sp->lotag == match)
391
                        && sp->lotag == match)
393
                    {
392
                    {
394
                        found = TRUE;
393
                        found = TRUE;
395
                    }
394
                    }
396
                }
395
                }
397
396
398
                if (!found)
397
                if (!found)
399
                    continue;
398
                    continue;
400
399
401
                if (sln < (int)SIZ(sectorlist))
400
                if (sln < (int)SIZ(sectorlist))
402
                    sectorlist[sln] = i;
401
                    sectorlist[sln] = i;
403
                sln++;
402
                sln++;
404
            }
403
            }
405
        }
404
        }
406
    }
405
    }
407
406
408
    if (sln == 0)
407
    if (sln == 0)
409
    {
408
    {
410
        *upper = -1;
409
        *upper = -1;
411
        *lower = -1;
410
        *lower = -1;
412
        return;
411
        return;
413
    }
412
    }
414
    // Map rooms have NOT been dragged on top of each other
413
    // Map rooms have NOT been dragged on top of each other
415
    else if (sln == 1)
414
    else if (sln == 1)
416
    {
415
    {
417
        *lower = sectorlist[0];
416
        *lower = sectorlist[0];
418
        *upper = sectorlist[0];
417
        *upper = sectorlist[0];
419
        return;
418
        return;
420
    }
419
    }
421
    // Map rooms HAVE been dragged on top of each other
420
    // Map rooms HAVE been dragged on top of each other
422
    else if (sln > 2)
421
    else if (sln > 2)
423
    {
422
    {
424
        // try again moving the x,y pos around until you only get two sectors
423
        // try again moving the x,y pos around until you only get two sectors
425
        GetUpperLowerSector(match, x - 1, y, upper, lower);
424
        GetUpperLowerSector(match, x - 1, y, upper, lower);
426
    }
425
    }
427
    else if (sln == 2)
426
    else if (sln == 2)
428
    {
427
    {
429
        if (sector[sectorlist[0]].floorz < sector[sectorlist[1]].floorz)
428
        if (sector[sectorlist[0]].floorz < sector[sectorlist[1]].floorz)
430
        {
429
        {
431
            // swap
430
            // swap
432
            // make sectorlist[0] the LOW sector
431
            // make sectorlist[0] the LOW sector
433
            short hold;
432
            short hold;
434
433
435
            hold = sectorlist[0];
434
            hold = sectorlist[0];
436
            sectorlist[0] = sectorlist[1];
435
            sectorlist[0] = sectorlist[1];
437
            sectorlist[1] = hold;
436
            sectorlist[1] = hold;
438
        }
437
        }
439
438
440
        *lower = sectorlist[0];
439
        *lower = sectorlist[0];
441
        *upper = sectorlist[1];
440
        *upper = sectorlist[1];
442
    }
441
    }
443
}
442
}
444
443
445
SWBOOL
444
SWBOOL
446
FindCeilingView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum)
445
FindCeilingView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum)
447
{
446
{
448
    int xoff = 0;
447
    int xoff = 0;
449
    int yoff = 0;
448
    int yoff = 0;
450
    short i, nexti;
449
    short i, nexti;
451
    SPRITEp sp = NULL;
450
    SPRITEp sp = NULL;
452
    int pix_diff;
451
    int pix_diff;
453
    int newz;
452
    int newz;
454
453
455
    save.zcount = 0;
454
    save.zcount = 0;
456
455
457
    // Search Stat List For closest ceiling view sprite
456
    // Search Stat List For closest ceiling view sprite
458
    // Get the match, xoff, yoff from this point
457
    // Get the match, xoff, yoff from this point
459
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
458
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
460
    {
459
    {
461
        sp = &sprite[i];
460
        sp = &sprite[i];
462
461
463
        if (sp->hitag == VIEW_THRU_CEILING && sp->lotag == match)
462
        if (sp->hitag == VIEW_THRU_CEILING && sp->lotag == match)
464
        {
463
        {
465
            xoff = *x - sp->x;
464
            xoff = *x - sp->x;
466
            yoff = *y - sp->y;
465
            yoff = *y - sp->y;
467
466
468
            break;
467
            break;
469
        }
468
        }
470
    }
469
    }
471
470
472
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
471
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
473
    {
472
    {
474
        sp = &sprite[i];
473
        sp = &sprite[i];
475
474
476
        if (sp->lotag == match)
475
        if (sp->lotag == match)
477
        {
476
        {
478
            // determine x,y position
477
            // determine x,y position
479
            if (sp->hitag == VIEW_THRU_FLOOR)
478
            if (sp->hitag == VIEW_THRU_FLOOR)
480
            {
479
            {
481
                short upper, lower;
480
                short upper, lower;
482
481
483
                *x = sp->x + xoff;
482
                *x = sp->x + xoff;
484
                *y = sp->y + yoff;
483
                *y = sp->y + yoff;
485
484
486
                // get new sector
485
                // get new sector
487
                GetUpperLowerSector(match, *x, *y, &upper, &lower);
486
                GetUpperLowerSector(match, *x, *y, &upper, &lower);
488
                *sectnum = upper;
487
                *sectnum = upper;
489
                break;
488
                break;
490
            }
489
            }
491
        }
490
        }
492
    }
491
    }
493
492
494
    if (*sectnum < 0)
493
    if (*sectnum < 0)
495
        return FALSE;
494
        return FALSE;
496
495
497
    ASSERT(sp);
496
    ASSERT(sp);
498
    ASSERT(sp->hitag == VIEW_THRU_FLOOR);
497
    ASSERT(sp->hitag == VIEW_THRU_FLOOR);
499
498
500
    if (FAF_DontMoveSectors)
499
    if (FAF_DontMoveSectors)
501
        return TRUE;
500
        return TRUE;
502
501
503
    pix_diff = labs(z - sector[sp->sectnum].floorz) >> 8;
502
    pix_diff = labs(z - sector[sp->sectnum].floorz) >> 8;
504
    newz = sector[sp->sectnum].floorz + ((pix_diff / 128) + 1) * Z(128);
503
    newz = sector[sp->sectnum].floorz + ((pix_diff / 128) + 1) * Z(128);
505
504
506
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
505
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
507
    {
506
    {
508
        sp = &sprite[i];
507
        sp = &sprite[i];
509
508
510
        if (sp->lotag == match)
509
        if (sp->lotag == match)
511
        {
510
        {
512
            // move lower levels ceilings up for the correct view
511
            // move lower levels ceilings up for the correct view
513
            if (sp->hitag == VIEW_LEVEL2)
512
            if (sp->hitag == VIEW_LEVEL2)
514
            {
513
            {
515
                // save it off
514
                // save it off
516
                save.sectnum[save.zcount] = sp->sectnum;
515
                save.sectnum[save.zcount] = sp->sectnum;
517
                save.zval[save.zcount] = sector[sp->sectnum].floorz;
516
                save.zval[save.zcount] = sector[sp->sectnum].floorz;
518
                save.pic[save.zcount] = sector[sp->sectnum].floorpicnum;
517
                save.pic[save.zcount] = sector[sp->sectnum].floorpicnum;
519
                save.slope[save.zcount] = sector[sp->sectnum].floorheinum;
518
                save.slope[save.zcount] = sector[sp->sectnum].floorheinum;
520
519
521
                sector[sp->sectnum].floorz = newz;
520
                sector[sp->sectnum].floorz = newz;
522
                sector[sp->sectnum].floorpicnum = FAF_MIRROR_PIC+1;
521
                sector[sp->sectnum].floorpicnum = FAF_MIRROR_PIC+1;
523
                sector[sp->sectnum].floorheinum = 0;
522
                sector[sp->sectnum].floorheinum = 0;
524
523
525
                save.zcount++;
524
                save.zcount++;
526
                ASSERT(save.zcount < ZMAX);
525
                ASSERT(save.zcount < ZMAX);
527
            }
526
            }
528
        }
527
        }
529
    }
528
    }
530
529
531
    return TRUE;
530
    return TRUE;
532
}
531
}
533
532
534
SWBOOL
533
SWBOOL
535
FindFloorView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum)
534
FindFloorView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum)
536
{
535
{
537
    int xoff = 0;
536
    int xoff = 0;
538
    int yoff = 0;
537
    int yoff = 0;
539
    short i, nexti;
538
    short i, nexti;
540
    SPRITEp sp = NULL;
539
    SPRITEp sp = NULL;
541
    int newz;
540
    int newz;
542
    int pix_diff;
541
    int pix_diff;
543
542
544
    save.zcount = 0;
543
    save.zcount = 0;
545
544
546
    // Search Stat List For closest ceiling view sprite
545
    // Search Stat List For closest ceiling view sprite
547
    // Get the match, xoff, yoff from this point
546
    // Get the match, xoff, yoff from this point
548
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
547
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
549
    {
548
    {
550
        sp = &sprite[i];
549
        sp = &sprite[i];
551
550
552
        if (sp->hitag == VIEW_THRU_FLOOR && sp->lotag == match)
551
        if (sp->hitag == VIEW_THRU_FLOOR && sp->lotag == match)
553
        {
552
        {
554
            xoff = *x - sp->x;
553
            xoff = *x - sp->x;
555
            yoff = *y - sp->y;
554
            yoff = *y - sp->y;
556
555
557
            break;
556
            break;
558
        }
557
        }
559
    }
558
    }
560
559
561
560
562
561
563
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
562
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
564
    {
563
    {
565
        sp = &sprite[i];
564
        sp = &sprite[i];
566
565
567
        if (sp->lotag == match)
566
        if (sp->lotag == match)
568
        {
567
        {
569
            // determine x,y position
568
            // determine x,y position
570
            if (sp->hitag == VIEW_THRU_CEILING)
569
            if (sp->hitag == VIEW_THRU_CEILING)
571
            {
570
            {
572
                short upper, lower;
571
                short upper, lower;
573
572
574
                *x = sp->x + xoff;
573
                *x = sp->x + xoff;
575
                *y = sp->y + yoff;
574
                *y = sp->y + yoff;
576
575
577
                // get new sector
576
                // get new sector
578
                GetUpperLowerSector(match, *x, *y, &upper, &lower);
577
                GetUpperLowerSector(match, *x, *y, &upper, &lower);
579
                *sectnum = lower;
578
                *sectnum = lower;
580
                break;
579
                break;
581
            }
580
            }
582
        }
581
        }
583
    }
582
    }
584
583
585
    if (*sectnum < 0)
584
    if (*sectnum < 0)
586
        return FALSE;
585
        return FALSE;
587
586
588
    ASSERT(sp);
587
    ASSERT(sp);
589
    ASSERT(sp->hitag == VIEW_THRU_CEILING);
588
    ASSERT(sp->hitag == VIEW_THRU_CEILING);
590
589
591
    if (FAF_DontMoveSectors)
590
    if (FAF_DontMoveSectors)
592
        return TRUE;
591
        return TRUE;
593
592
594
    // move ceiling multiple of 128 so that the wall tile will line up
593
    // move ceiling multiple of 128 so that the wall tile will line up
595
    pix_diff = labs(z - sector[sp->sectnum].ceilingz) >> 8;
594
    pix_diff = labs(z - sector[sp->sectnum].ceilingz) >> 8;
596
    newz = sector[sp->sectnum].ceilingz - ((pix_diff / 128) + 1) * Z(128);
595
    newz = sector[sp->sectnum].ceilingz - ((pix_diff / 128) + 1) * Z(128);
597
596
598
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
597
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
599
    {
598
    {
600
        sp = &sprite[i];
599
        sp = &sprite[i];
601
600
602
        if (sp->lotag == match)
601
        if (sp->lotag == match)
603
        {
602
        {
604
            // move upper levels floors down for the correct view
603
            // move upper levels floors down for the correct view
605
            if (sp->hitag == VIEW_LEVEL1)
604
            if (sp->hitag == VIEW_LEVEL1)
606
            {
605
            {
607
                // save it off
606
                // save it off
608
                save.sectnum[save.zcount] = sp->sectnum;
607
                save.sectnum[save.zcount] = sp->sectnum;
609
                save.zval[save.zcount] = sector[sp->sectnum].ceilingz;
608
                save.zval[save.zcount] = sector[sp->sectnum].ceilingz;
610
                save.pic[save.zcount] = sector[sp->sectnum].ceilingpicnum;
609
                save.pic[save.zcount] = sector[sp->sectnum].ceilingpicnum;
611
                save.slope[save.zcount] = sector[sp->sectnum].ceilingheinum;
610
                save.slope[save.zcount] = sector[sp->sectnum].ceilingheinum;
612
611
613
                sector[sp->sectnum].ceilingz = newz;
612
                sector[sp->sectnum].ceilingz = newz;
614
613
615
                sector[sp->sectnum].ceilingpicnum = FAF_MIRROR_PIC+1;
614
                sector[sp->sectnum].ceilingpicnum = FAF_MIRROR_PIC+1;
616
                sector[sp->sectnum].ceilingheinum = 0;
615
                sector[sp->sectnum].ceilingheinum = 0;
617
616
618
                save.zcount++;
617
                save.zcount++;
619
                ASSERT(save.zcount < ZMAX);
618
                ASSERT(save.zcount < ZMAX);
620
            }
619
            }
621
        }
620
        }
622
    }
621
    }
623
622
624
    return TRUE;
623
    return TRUE;
625
}
624
}
626
625
627
SWBOOL
626
SWBOOL
628
SectorInScene(short tile_num)
627
SectorInScene(short tile_num)
629
{
628
{
630
    if (TEST(gotsector[tile_num >> 3], 1 << (tile_num & 7)))
629
    if (TEST(gotsector[tile_num >> 3], 1 << (tile_num & 7)))
631
    {
630
    {
632
        RESET(gotsector[tile_num >> 3], 1 << (tile_num & 7));
631
        RESET(gotsector[tile_num >> 3], 1 << (tile_num & 7));
633
        return TRUE;
632
        return TRUE;
634
    }
633
    }
635
634
636
    return FALSE;
635
    return FALSE;
637
}
636
}
638
637
639
short
638
short
640
ViewSectorInScene(short cursectnum, short level)
639
ViewSectorInScene(short cursectnum, short level)
641
{
640
{
642
    int i, nexti;
641
    int i, nexti;
643
    SPRITEp sp;
642
    SPRITEp sp;
644
    short match;
643
    short match;
645
644
646
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
645
    TRAVERSE_SPRITE_STAT(headspritestat[STAT_FAF], i, nexti)
647
    {
646
    {
648
        sp = &sprite[i];
647
        sp = &sprite[i];
649
648
650
        if (sp->hitag == level)
649
        if (sp->hitag == level)
651
        {
650
        {
652
            if (cursectnum == sp->sectnum)
651
            if (cursectnum == sp->sectnum)
653
            {
652
            {
654
                // ignore case if sprite is pointing up
653
                // ignore case if sprite is pointing up
655
                if (sp->ang == 1536)
654
                if (sp->ang == 1536)
656
                    continue;
655
                    continue;
657
656
658
                // only gets to here is sprite is pointing down
657
                // only gets to here is sprite is pointing down
659
                // found a potential match
658
                // found a potential match
660
                match = sp->lotag;
659
                match = sp->lotag;
661
660
662
                return match;
661
                return match;
663
            }
662
            }
664
        }
663
        }
665
    }
664
    }
666
665
667
    return -1;
666
    return -1;
668
}
667
}
669
668
670
void
669
void
671
DrawOverlapRoom(int tx, int ty, int tz, short tang, int thoriz, short tsectnum)
670
DrawOverlapRoom(int tx, int ty, int tz, short tang, int thoriz, short tsectnum)
672
{
671
{
673
    short i;
672
    short i;
674
    short match;
673
    short match;
675
674
676
    save.zcount = 0;
675
    save.zcount = 0;
677
676
678
    match = ViewSectorInScene(tsectnum, VIEW_LEVEL1);
677
    match = ViewSectorInScene(tsectnum, VIEW_LEVEL1);
679
    if (match != -1)
678
    if (match != -1)
680
    {
679
    {
681
        FindCeilingView(match, &tx, &ty, tz, &tsectnum);
680
        FindCeilingView(match, &tx, &ty, tz, &tsectnum);
682
681
683
        if (tsectnum < 0)
682
        if (tsectnum < 0)
684
        {
683
        {
685
            sprintf(ds,"COULD NOT FIND TAGGED LEVEL2 SECTOR FROM X %d, Y %d, SECTNUM %d.",pos.x,pos.y,cursectnum);
684
            sprintf(ds,"COULD NOT FIND TAGGED LEVEL2 SECTOR FROM X %d, Y %d, SECTNUM %d.",pos.x,pos.y,cursectnum);
686
            Message(ds, 0);
685
            Message(ds, 0);
687
            return;
686
            return;
688
        }
687
        }
689
688
690
        drawrooms(tx, ty, tz, tang, thoriz, tsectnum);
689
        drawrooms(tx, ty, tz, tang, thoriz, tsectnum);
691
        renderDrawMasks();
690
        renderDrawMasks();
692
691
693
        // reset Z's
692
        // reset Z's
694
        for (i = 0; i < save.zcount; i++)
693
        for (i = 0; i < save.zcount; i++)
695
        {
694
        {
696
            sector[save.sectnum[i]].floorz = save.zval[i];
695
            sector[save.sectnum[i]].floorz = save.zval[i];
697
            sector[save.sectnum[i]].floorpicnum = save.pic[i];
696
            sector[save.sectnum[i]].floorpicnum = save.pic[i];
698
            sector[save.sectnum[i]].floorheinum = save.slope[i];
697
            sector[save.sectnum[i]].floorheinum = save.slope[i];
699
        }
698
        }
700
    }
699
    }
701
    else
700
    else
702
    {
701
    {
703
        match = ViewSectorInScene(tsectnum, VIEW_LEVEL2);
702
        match = ViewSectorInScene(tsectnum, VIEW_LEVEL2);
704
        if (match != -1)
703
        if (match != -1)
705
        {
704
        {
706
            FindFloorView(match, &tx, &ty, tz, &tsectnum);
705
            FindFloorView(match, &tx, &ty, tz, &tsectnum);
707
706
708
            if (tsectnum < 0)
707
            if (tsectnum < 0)
709
            {
708
            {
710
                sprintf(ds,"COULD NOT FIND TAGGED LEVEL1 SECTOR FROM X %d, Y %d, SECTNUM %d.",pos.x,pos.y,cursectnum);
709
                sprintf(ds,"COULD NOT FIND TAGGED LEVEL1 SECTOR FROM X %d, Y %d, SECTNUM %d.",pos.x,pos.y,cursectnum);
711
                Message(ds, 0);
710
                Message(ds, 0);
712
                return;
711
                return;
713
            }
712
            }
714
713
715
            drawrooms(tx, ty, tz, tang, thoriz, tsectnum);
714
            drawrooms(tx, ty, tz, tang, thoriz, tsectnum);
716
            renderDrawMasks();
715
            renderDrawMasks();
717
716
718
            // reset Z's
717
            // reset Z's
719
            for (i = 0; i < save.zcount; i++)
718
            for (i = 0; i < save.zcount; i++)
720
            {
719
            {
721
                sector[save.sectnum[i]].ceilingz = save.zval[i];
720
                sector[save.sectnum[i]].ceilingz = save.zval[i];
722
                sector[save.sectnum[i]].ceilingpicnum = save.pic[i];
721
                sector[save.sectnum[i]].ceilingpicnum = save.pic[i];
723
                sector[save.sectnum[i]].ceilingheinum = save.slope[i];
722
                sector[save.sectnum[i]].ceilingheinum = save.slope[i];
724
            }
723
            }
725
        }
724
        }
726
    }
725
    }
727
}
726
}
728
 
727