Subversion Repositories eduke32

Rev

Rev 5198 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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