]> icculus.org git repositories - btb/d2x.git/blob - main/editor/eglobal.c
Fix crash if Num_walls=0
[btb/d2x.git] / main / editor / eglobal.c
1 /* $Id: eglobal.c,v 1.4 2005-01-25 21:44:24 schaffner Exp $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Globals for editor.
18  *
19  */
20
21 #ifdef RCS
22 static char rcsid[] = "$Id: eglobal.c,v 1.4 2005-01-25 21:44:24 schaffner Exp $";
23 #endif
24
25 #ifdef HAVE_CONFIG_H
26 #include "conf.h"
27 #endif
28
29 #include <stdlib.h>
30 #include "inferno.h"
31 #include "segment.h"
32 #include "editor.h"
33
34 // Global pointer to current vertices, right now always Vertices.  Set in create_new_mine.
35 // segment New_segment;  // segment which can be added to the mine. // replaced by a macro
36 segment *Cursegp;        // Pointer to current segment in mine.
37 int Curside;             // Side index in 0..MAX_SIDES_PER_SEGMENT of active side.
38 int Curedge;             // Current edge on current side, in 0..3
39 int Curvert;             // Current vertex on current side, in 0..3
40 int AttachSide = WFRONT; // Side on segment to attach.
41 segment *Markedsegp;     // Marked segment, used in conjunction with *Cursegp to form joints.
42 int Markedside;          // Marked side on Markedsegp.
43
44 int Draw_all_segments;   // Set to 1 means draw_world draws all segments in Segments, else draw only connected segments
45
46 sbyte Vertex_active[MAX_VERTICES]; // !0 means vertex is in use, 0 means not in use.
47
48 int N_selected_segs = 0;  // Number of segments found at Selected_segs
49 short Selected_segs[MAX_SELECTED_SEGS]; // List of segment numbers currently selected
50
51 int N_warning_segs = 0;   // Number of segments warning-worthy, such as a concave segment
52 short Warning_segs[MAX_WARNING_SEGS]; // List of segment numbers currently selected
53
54 int N_found_segs = 0;    // Number of segments found with last shift-mouse-click
55 short Found_segs[MAX_FOUND_SEGS]; // List of warning-worthy segments
56
57 int Show_axes_flag = 0; // 0 = don't show, !0 = do show coordinate axes in *Cursegp orientation
58
59 sbyte Been_visited[MAX_SEGMENTS]; // List of segments visited in a recursive search, if element n set, segment n done been visited
60
61 // Variables global to this editor.c and the k?????.c files.
62 uint        Update_flags = UF_ALL;  //force total redraw
63 int         Funky_chase_mode = 0;
64 vms_angvec  Seg_orientation = {0,0,0};
65 vms_vector  Seg_scale = {F1_0*20,F1_0*20,F1_0*20};
66 int         mine_changed = 0;
67 int         ModeFlag;
68 editor_view *current_view;
69
70 int         SegSizeMode = 1; // Mode = 0/1 = not/is legal to move bound vertices, 
71
72 //the view for the different windows.
73 editor_view LargeView = {0,1, NULL, i2f(100),{{f1_0,0,0},{0,f1_0,0},{0,0,f1_0}},f1_0};
74 #if ORTHO_VIEWS
75 editor_view TopView   = {1,1, NULL, i2f(100),{{f1_0,0,0},{0,0,-f1_0},{0,f1_0,0}},f1_0};
76 editor_view FrontView = {2,1, NULL, i2f(100),{{f1_0,0,0},{0,f1_0,0},{0,0,f1_0}},f1_0};
77 editor_view RightView = {3,1, NULL, i2f(100),{{0,0,f1_0},{0,f1_0,0},{f1_0,0,0}},f1_0};
78 #endif
79
80
81 editor_view *Views[] = {&LargeView,
82 #if ORTHO_VIEWS
83         &TopView,&FrontView,&RightView
84 #endif
85         };
86
87 int N_views = (sizeof(Views) / sizeof(*Views));
88
89 int     Lock_view_to_cursegp = 1;               // !0 means whenever cursegp changes, view it
90
91 int     Num_tilings = 1;                                        // Number of tilings per wall
92
93 short Cur_object_index = -1;
94
95 // The current robot type
96 int Cur_robot_type = 0;
97
98 //      !0 if a degenerate segment has been found.
99 int     Degenerate_segment_found=0;
100