| 2199 | */ |
| 2200 | |
| 2201 | void SplitSector (SHORT vertex1, SHORT vertex2) |
| 2202 | { |
| 2203 | SelPtr llist; |
| 2204 | SHORT curv, s, l, sd; |
| 2205 | char msg1[ 80], msg2[ 80]; |
| 2206 | |
| 2207 | /* check if there is a Sector between the two Vertices (in the middle) */ |
| 2208 | s = GetCurObject( OBJ_SECTORS, Vertexes[ vertex1].x, Vertexes[ vertex1].y, Vertexes[ vertex2].x, Vertexes[ vertex2].y); |
| 2209 | if (s < 0) |
| 2210 | { |
| 2211 | Beep(); |
| 2212 | Notify ("There is no Sector between Vertex #%d and Vertex #%d", vertex1, vertex2); |
| 2213 | return; |
| 2214 | } |
| 2215 | /* check if there is a closed path from vertex1 to vertex2, along the edge of the Sector s */ |
| 2216 | // ObjectsNeeded( OBJ_LINEDEFS, OBJ_SIDEDEFS, 0); |
| 2217 | llist = NULL; |
| 2218 | curv = vertex1; |
| 2219 | while (curv != vertex2) |
| 2220 | { |
| 2221 | for (l = 0; l < NumLineDefs; l++) |
| 2222 | { |
| 2223 | sd = LineDefs[ l].sidedef1; |
| 2224 | if (sd >= 0 && SideDefs[ sd].sector == s && LineDefs[ l].start == curv) |
| 2225 | { |
| 2226 | curv = LineDefs[ l].end; |
| 2227 | SelectObject( &llist, l); |
| 2228 | break; |
| 2229 | } |
| 2230 | sd = LineDefs[ l].sidedef2; |
| 2231 | if (sd >= 0 && SideDefs[ sd].sector == s && LineDefs[ l].end == curv) |
| 2232 | { |
| 2233 | curv = LineDefs[ l].start; |
| 2234 | SelectObject( &llist, l); |
| 2235 | break; |
| 2236 | } |
| 2237 | } |
| 2238 | if (l >= NumLineDefs) |
| 2239 | { |
| 2240 | Beep(); |
| 2241 | wsprintf( msg1, "Cannot find a closed path from Vertex #%d to Vertex #%d", vertex1, vertex2); |
| 2242 | if (curv == vertex1) |
| 2243 | wsprintf( msg2, "There is no SideDef starting from Vertex #%d on Sector #%d", vertex1, s); |
| 2244 | else |
| 2245 | wsprintf( msg2, "Check if Sector #%d is closed (cannot go past Vertex #%d)", s, curv); |
| 2246 | Notify("%s.\n %s", msg1, msg2); |
| 2247 | ForgetSelection( &llist); |
| 2248 | return; |
| 2249 | } |
| 2250 | if (curv == vertex1) |
| 2251 | { |
| 2252 | Beep(); |
| 2253 | Notify("Vertex #%d is not on the same Sector (#%d) as Vertex #%d", |
| 2254 | vertex2, s, vertex1); |
| 2255 | ForgetSelection( &llist); |
| 2256 | return; |
| 2257 | } |
| 2258 | } |
no test coverage detected