Mercurial > hg > forks > yadex
comparison src/s_lift.cc @ 107:20aa5a515896
Reformat one line /* */ comments to //
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 06 Oct 2014 12:42:55 +0300 |
parents | 2f1ecc1c5f72 |
children |
comparison
equal
deleted
inserted
replaced
106:093497110727 | 107:20aa5a515896 |
---|---|
38 | 38 |
39 /* | 39 /* |
40 turn a Sector into a lift: change the linedefs and sidedefs | 40 turn a Sector into a lift: change the linedefs and sidedefs |
41 */ | 41 */ |
42 | 42 |
43 void MakeLiftFromSector(int sector) /* SWAP! */ | 43 void MakeLiftFromSector(int sector) // SWAP! |
44 { | 44 { |
45 int sd1, sd2; | 45 int sd1, sd2; |
46 int n, s, tag; | 46 int n, s, tag; |
47 SelPtr ldok, ldflip, ld1s; | 47 SelPtr ldok, ldflip, ld1s; |
48 SelPtr sect, curs; | 48 SelPtr sect, curs; |
50 | 50 |
51 ldok = NULL; | 51 ldok = NULL; |
52 ldflip = NULL; | 52 ldflip = NULL; |
53 ld1s = NULL; | 53 ld1s = NULL; |
54 sect = NULL; | 54 sect = NULL; |
55 /* build lists of linedefs that border the Sector */ | 55 // build lists of linedefs that border the Sector |
56 for (n = 0; n < NumLineDefs; n++) | 56 for (n = 0; n < NumLineDefs; n++) |
57 { | 57 { |
58 sd1 = LineDefs[n].sidedef1; | 58 sd1 = LineDefs[n].sidedef1; |
59 sd2 = LineDefs[n].sidedef2; | 59 sd2 = LineDefs[n].sidedef2; |
60 if (sd1 >= 0 && sd2 >= 0) | 60 if (sd1 >= 0 && sd2 >= 0) |
61 { | 61 { |
62 if (SideDefs[sd2].sector == sector) | 62 if (SideDefs[sd2].sector == sector) |
63 { | 63 { |
64 SelectObject(&ldok, n); /* already ok */ | 64 SelectObject(&ldok, n); // already ok |
65 s = SideDefs[sd1].sector; | 65 s = SideDefs[sd1].sector; |
66 if (s != sector && !IsSelected(sect, s)) | 66 if (s != sector && !IsSelected(sect, s)) |
67 SelectObject(§, s); | 67 SelectObject(§, s); |
68 } | 68 } |
69 if (SideDefs[sd1].sector == sector) | 69 if (SideDefs[sd1].sector == sector) |
70 { | 70 { |
71 SelectObject(&ldflip, n); /* will be flipped */ | 71 SelectObject(&ldflip, n); // will be flipped |
72 s = SideDefs[sd2].sector; | 72 s = SideDefs[sd2].sector; |
73 if (s != sector && !IsSelected(sect, s)) | 73 if (s != sector && !IsSelected(sect, s)) |
74 SelectObject(§, s); | 74 SelectObject(§, s); |
75 } | 75 } |
76 } | 76 } |
77 else if (sd1 >= 0 && sd2 < 0) | 77 else if (sd1 >= 0 && sd2 < 0) |
78 { | 78 { |
79 if (SideDefs[sd1].sector == sector) | 79 if (SideDefs[sd1].sector == sector) |
80 SelectObject(&ld1s, n); /* wall (one-sided) */ | 80 SelectObject(&ld1s, n); // wall (one-sided) |
81 } | 81 } |
82 } | 82 } |
83 /* there must be a way to go on the lift... */ | 83 // there must be a way to go on the lift... |
84 if (sect == NULL) | 84 if (sect == NULL) |
85 { | 85 { |
86 Beep(); | 86 Beep(); |
87 Notify(-1, -1, | 87 Notify(-1, -1, |
88 "The lift must be connected to at least one other Sector.", | 88 "The lift must be connected to at least one other Sector.", |
90 ForgetSelection(&ldok); | 90 ForgetSelection(&ldok); |
91 ForgetSelection(&ldflip); | 91 ForgetSelection(&ldflip); |
92 ForgetSelection(&ld1s); | 92 ForgetSelection(&ld1s); |
93 return; | 93 return; |
94 } | 94 } |
95 /* flip the linedefs that have the wrong orientation */ | 95 // flip the linedefs that have the wrong orientation |
96 if (ldflip != NULL) | 96 if (ldflip != NULL) |
97 FlipLineDefs(ldflip, 1); | 97 FlipLineDefs(ldflip, 1); |
98 /* merge the two selection lists */ | 98 // merge the two selection lists |
99 while (ldflip != NULL) | 99 while (ldflip != NULL) |
100 { | 100 { |
101 if (!IsSelected(ldok, ldflip->objnum)) | 101 if (!IsSelected(ldok, ldflip->objnum)) |
102 SelectObject(&ldok, ldflip->objnum); | 102 SelectObject(&ldok, ldflip->objnum); |
103 UnSelectObject(&ldflip, ldflip->objnum); | 103 UnSelectObject(&ldflip, ldflip->objnum); |
104 } | 104 } |
105 | 105 |
106 /* find a free tag number */ | 106 // find a free tag number |
107 tag = FindFreeTag(); | 107 tag = FindFreeTag(); |
108 | 108 |
109 /* find the minimum and maximum altitudes */ | 109 // find the minimum and maximum altitudes |
110 minh = 32767; | 110 minh = 32767; |
111 maxh = -32767; | 111 maxh = -32767; |
112 for (curs = sect; curs; curs = curs->next) | 112 for (curs = sect; curs; curs = curs->next) |
113 { | 113 { |
114 if (Sectors[curs->objnum].floorh < minh) | 114 if (Sectors[curs->objnum].floorh < minh) |
116 if (Sectors[curs->objnum].floorh > maxh) | 116 if (Sectors[curs->objnum].floorh > maxh) |
117 maxh = Sectors[curs->objnum].floorh; | 117 maxh = Sectors[curs->objnum].floorh; |
118 } | 118 } |
119 ForgetSelection(§); | 119 ForgetSelection(§); |
120 | 120 |
121 /* change the lift's floor height if necessary */ | 121 // change the lift's floor height if necessary |
122 if (Sectors[sector].floorh < maxh) | 122 if (Sectors[sector].floorh < maxh) |
123 Sectors[sector].floorh = maxh; | 123 Sectors[sector].floorh = maxh; |
124 | 124 |
125 /* change the lift's ceiling height if necessary */ | 125 // change the lift's ceiling height if necessary |
126 if (Sectors[sector].ceilh < maxh + DOOM_PLAYER_HEIGHT) | 126 if (Sectors[sector].ceilh < maxh + DOOM_PLAYER_HEIGHT) |
127 Sectors[sector].ceilh = maxh + DOOM_PLAYER_HEIGHT; | 127 Sectors[sector].ceilh = maxh + DOOM_PLAYER_HEIGHT; |
128 | 128 |
129 /* assign the new tag number to the lift */ | 129 // assign the new tag number to the lift |
130 Sectors[sector].tag = tag; | 130 Sectors[sector].tag = tag; |
131 | 131 |
132 /* change the linedefs and sidedefs */ | 132 // change the linedefs and sidedefs |
133 while (ldok != NULL) | 133 while (ldok != NULL) |
134 { | 134 { |
135 /* give the "lower lift" type and flags to the linedef */ | 135 // give the "lower lift" type and flags to the linedef |
136 n = ldok->objnum; | 136 n = ldok->objnum; |
137 LineDefs[n].type = 62; /* lower lift (switch) */ | 137 LineDefs[n].type = 62; // lower lift (switch) |
138 LineDefs[n].flags = 0x04; | 138 LineDefs[n].flags = 0x04; |
139 LineDefs[n].tag = tag; | 139 LineDefs[n].tag = tag; |
140 sd1 = LineDefs[n].sidedef1; /* outside */ | 140 sd1 = LineDefs[n].sidedef1; // outside |
141 sd2 = LineDefs[n].sidedef2; /* inside */ | 141 sd2 = LineDefs[n].sidedef2; // inside |
142 /* adjust the textures for the sidedef visible from the outside */ | 142 // adjust the textures for the sidedef visible from the outside |
143 if (strncmp(SideDefs[sd1].tex3, "-", WAD_TEX_NAME)) | 143 if (strncmp(SideDefs[sd1].tex3, "-", WAD_TEX_NAME)) |
144 { | 144 { |
145 if (!strncmp(SideDefs[sd1].tex2, "-", WAD_TEX_NAME)) | 145 if (!strncmp(SideDefs[sd1].tex2, "-", WAD_TEX_NAME)) |
146 strncpy(SideDefs[sd1].tex2, SideDefs[sd1].tex3, WAD_TEX_NAME); | 146 strncpy(SideDefs[sd1].tex2, SideDefs[sd1].tex3, WAD_TEX_NAME); |
147 strncpy(SideDefs[sd1].tex3, "-", WAD_TEX_NAME); | 147 strncpy(SideDefs[sd1].tex3, "-", WAD_TEX_NAME); |
148 } | 148 } |
149 if (!strncmp(SideDefs[sd1].tex2, "-", WAD_TEX_NAME)) | 149 if (!strncmp(SideDefs[sd1].tex2, "-", WAD_TEX_NAME)) |
150 strncpy(SideDefs[sd1].tex2, "SHAWN2", WAD_TEX_NAME); | 150 strncpy(SideDefs[sd1].tex2, "SHAWN2", WAD_TEX_NAME); |
151 /* adjust the textures for the sidedef visible from the lift */ | 151 // adjust the textures for the sidedef visible from the lift |
152 strncpy(SideDefs[sd2].tex3, "-", WAD_TEX_NAME); | 152 strncpy(SideDefs[sd2].tex3, "-", WAD_TEX_NAME); |
153 s = SideDefs[sd1].sector; | 153 s = SideDefs[sd1].sector; |
154 if (Sectors[s].floorh > minh) | 154 if (Sectors[s].floorh > minh) |
155 { | 155 { |
156 if (strncmp(SideDefs[sd2].tex3, "-", WAD_TEX_NAME)) | 156 if (strncmp(SideDefs[sd2].tex3, "-", WAD_TEX_NAME)) |
166 else | 166 else |
167 { | 167 { |
168 strncpy(SideDefs[sd2].tex2, "-", WAD_TEX_NAME); | 168 strncpy(SideDefs[sd2].tex2, "-", WAD_TEX_NAME); |
169 } | 169 } |
170 strncpy(SideDefs[sd2].tex3, "-", WAD_TEX_NAME); | 170 strncpy(SideDefs[sd2].tex3, "-", WAD_TEX_NAME); |
171 /* if the ceiling of the sector is lower than that of the lift */ | 171 // if the ceiling of the sector is lower than that of the lift |
172 if (Sectors[s].ceilh < Sectors[sector].ceilh) | 172 if (Sectors[s].ceilh < Sectors[sector].ceilh) |
173 { | 173 { |
174 if (strncmp(SideDefs[sd2].tex1, "-", WAD_TEX_NAME)) | 174 if (strncmp(SideDefs[sd2].tex1, "-", WAD_TEX_NAME)) |
175 strncpy(SideDefs[sd2].tex1, cfg.def.upper_texture, | 175 strncpy(SideDefs[sd2].tex1, cfg.def.upper_texture, |
176 WAD_TEX_NAME); | 176 WAD_TEX_NAME); |
177 } | 177 } |
178 /* if the floor of the sector is above the lift */ | 178 // if the floor of the sector is above the lift |
179 if (Sectors[s].floorh >= Sectors[sector].floorh) | 179 if (Sectors[s].floorh >= Sectors[sector].floorh) |
180 { | 180 { |
181 LineDefs[n].type = 88; /* lower lift (walk through) */ | 181 LineDefs[n].type = 88; // lower lift (walk through) |
182 /* flip it, just for fun */ | 182 // flip it, just for fun |
183 curs = NULL; | 183 curs = NULL; |
184 SelectObject(&curs, n); | 184 SelectObject(&curs, n); |
185 FlipLineDefs(curs, 1); | 185 FlipLineDefs(curs, 1); |
186 ForgetSelection(&curs); | 186 ForgetSelection(&curs); |
187 } | 187 } |
188 /* done with this linedef */ | 188 // done with this linedef |
189 UnSelectObject(&ldok, n); | 189 UnSelectObject(&ldok, n); |
190 } | 190 } |
191 | 191 |
192 while (ld1s != NULL) | 192 while (ld1s != NULL) |
193 { | 193 { |
194 /* these are the lift walls (one-sided) */ | 194 // these are the lift walls (one-sided) |
195 n = ld1s->objnum; | 195 n = ld1s->objnum; |
196 LineDefs[n].flags = 0x01; | 196 LineDefs[n].flags = 0x01; |
197 sd1 = LineDefs[n].sidedef1; | 197 sd1 = LineDefs[n].sidedef1; |
198 /* adjust the textures for the sidedef */ | 198 // adjust the textures for the sidedef |
199 if (!strncmp(SideDefs[sd1].tex3, "-", WAD_TEX_NAME)) | 199 if (!strncmp(SideDefs[sd1].tex3, "-", WAD_TEX_NAME)) |
200 strncpy(SideDefs[sd1].tex3, cfg.def.middle_texture, WAD_TEX_NAME); | 200 strncpy(SideDefs[sd1].tex3, cfg.def.middle_texture, WAD_TEX_NAME); |
201 strncpy(SideDefs[sd1].tex1, "-", WAD_TEX_NAME); | 201 strncpy(SideDefs[sd1].tex1, "-", WAD_TEX_NAME); |
202 strncpy(SideDefs[sd1].tex2, "-", WAD_TEX_NAME); | 202 strncpy(SideDefs[sd1].tex2, "-", WAD_TEX_NAME); |
203 UnSelectObject(&ld1s, n); | 203 UnSelectObject(&ld1s, n); |