Mercurial > hg > forks > yadex
changeset 49:cf5f6ef9b713
Cosmetic cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 26 Sep 2011 04:39:04 +0300 |
parents | 42dfed6e6efb |
children | 48d4f8e3fce5 |
files | src/s_split.cc |
diffstat | 1 files changed, 30 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/s_split.cc Sun Sep 25 03:54:27 2011 +0300 +++ b/src/s_split.cc Mon Sep 26 04:39:04 2011 +0300 @@ -49,10 +49,12 @@ int curv, s, l, sd; char msg1[80], msg2[80]; -/* AYM 1998-08-09 : FIXME : I'm afraid this test is not relevant - if the sector contains subsectors. I should ask Jim (Flynn), - he did something about that in DETH. */ -/* Check if there is a sector between the two vertices (in the middle) */ + /* AYM 1998-08-09 : FIXME : I'm afraid this test is not relevant + * if the sector contains subsectors. I should ask Jim (Flynn), + * he did something about that in DETH. + */ + + /* Check if there is a sector between the two vertices (in the middle) */ Objid o; GetCurObject(o, OBJ_SECTORS, (Vertices[vertex1].x + Vertices[vertex2].x) / 2, @@ -67,9 +69,10 @@ return; } -/* Check if there is a closed path from <vertex1> to <vertex2>, - along the edge of sector <s>. To make it faster, I scan only - the set of linedefs that face sector <s>. */ + /* Check if there is a closed path from <vertex1> to <vertex2>, + * along the edge of sector <s>. To make it faster, I scan only + * the set of linedefs that face sector <s>. + */ obj_no_t *ld_numbers; int nlinedefs = linedefs_of_sector(s, ld_numbers); if (nlinedefs < 1) // Can't happen @@ -77,16 +80,17 @@ nf_bug("SplitSector: no linedef for sector %d\n", s); return; } + llist = NULL; curv = vertex1; while (curv != vertex2) { - printf("%d\n", curv); int n; for (n = 0; n < nlinedefs; n++) { if (IsSelected(llist, ld_numbers[n])) continue; // Already been there + const LDPtr ld = LineDefs + ld_numbers[n]; if (ld->start == curv && is_sidedef(ld->sidedef1) @@ -105,6 +109,7 @@ break; } } + if (n >= nlinedefs) { Beep(); @@ -122,6 +127,7 @@ delete[]ld_numbers; return; } + if (curv == vertex1) { Beep(); @@ -133,10 +139,12 @@ return; } } + delete[]ld_numbers; -/* now, the list of linedefs for the new sector is in llist */ -/* add the new sector, linedef and sidedefs */ + /* now, the list of linedefs for the new sector is in llist */ + + /* add the new sector, linedef and sidedefs */ InsertObject(OBJ_SECTORS, s, 0, 0); InsertObject(OBJ_LINEDEFS, -1, 0, 0); LineDefs[NumLineDefs - 1].start = vertex1; @@ -150,7 +158,7 @@ LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs - 2; LineDefs[NumLineDefs - 1].sidedef2 = NumSideDefs - 1; -/* bind all linedefs in llist to the new sector */ + /* bind all linedefs in llist to the new sector */ while (llist) { sd = LineDefs[llist->objnum].sidedef1; @@ -160,7 +168,7 @@ UnSelectObject(&llist, llist->objnum); } -/* second check... useful for sectors within sectors */ + /* second check... useful for sectors within sectors */ for (l = 0; l < NumLineDefs; l++) { sd = LineDefs[l].sidedef1; @@ -193,13 +201,13 @@ { SelPtr llist; int s1, s2, s3, s4; - char msg[80]; -/* check if the two linedefs are adjacent to the same sector */ + /* check if the two linedefs are adjacent to the same sector */ s1 = LineDefs[linedef1].sidedef1; s2 = LineDefs[linedef1].sidedef2; s3 = LineDefs[linedef2].sidedef1; s4 = LineDefs[linedef2].sidedef2; + if (s1 >= 0) s1 = SideDefs[s1].sector; if (s2 >= 0) @@ -208,9 +216,11 @@ s3 = SideDefs[s3].sector; if (s4 >= 0) s4 = SideDefs[s4].sector; - if ((s1 < 0 || (s1 != s3 && s1 != s4)) - && (s2 < 0 || (s2 != s3 && s2 != s4))) + + if ((s1 < 0 || (s1 != s3 && s1 != s4)) && + (s2 < 0 || (s2 != s3 && s2 != s4))) { + char msg[128]; Beep(); sprintf(msg, "Linedefs #%d and #%d are not adjacent to the same sector", @@ -218,12 +228,14 @@ Notify(-1, -1, msg, NULL); return; } -/* split the two linedefs and create two new vertices */ + + /* split the two linedefs and create two new vertices */ llist = NULL; SelectObject(&llist, linedef1); SelectObject(&llist, linedef2); SplitLineDefs(llist); ForgetSelection(&llist); -/* split the sector and create a linedef between the two vertices */ + + /* split the sector and create a linedef between the two vertices */ SplitSector(NumVertices - 1, NumVertices - 2); }