| 3204 | */ |
| 3205 | |
| 3206 | void InsertRectangle (SHORT xpos, SHORT ypos, SHORT width, SHORT height) |
| 3207 | { |
| 3208 | SHORT sector; |
| 3209 | |
| 3210 | // are we inside a Sector? |
| 3211 | sector = GetCurObject (OBJ_SECTORS, xpos, ypos, xpos, ypos); |
| 3212 | |
| 3213 | // Setup width and position of rectangle |
| 3214 | if (width < 8) width = 8; |
| 3215 | if (height < 8) height = 8; |
| 3216 | xpos -= width / 2; |
| 3217 | ypos -= height / 2; |
| 3218 | |
| 3219 | // Insert the vertices |
| 3220 | InsertObject (OBJ_VERTEXES, -1, xpos, ypos); |
| 3221 | InsertObject (OBJ_VERTEXES, -1, xpos + width, ypos); |
| 3222 | InsertObject (OBJ_VERTEXES, -1, xpos + width, ypos + height); |
| 3223 | InsertObject (OBJ_VERTEXES, -1, xpos, ypos + height); |
| 3224 | |
| 3225 | // Insert a new sector |
| 3226 | if (sector < 0) |
| 3227 | InsertObject (OBJ_SECTORS, -1, 0, 0); |
| 3228 | |
| 3229 | // Insert the LineDefs and SideDefs 1 |
| 3230 | for (SHORT n = 0; n < 4; n++) |
| 3231 | { |
| 3232 | InsertObject (OBJ_LINEDEFS, -1, 0, 0); |
| 3233 | InsertObject (OBJ_SIDEDEFS, -1, 0, 0); |
| 3234 | LineDefs[NumLineDefs - 1].sidedef1 = NumSideDefs-1; |
| 3235 | if (sector >= 0) |
| 3236 | SideDefs[NumSideDefs - 1].sector = sector; |
| 3237 | } |
| 3238 | |
| 3239 | // Setup start and end vertices of LineDefs |
| 3240 | if (sector >= 0) |
| 3241 | { |
| 3242 | LineDef *pLD = &LineDefs[NumLineDefs - 4]; |
| 3243 | pLD->start = NumVertexes - 4; |
| 3244 | pLD->end = NumVertexes - 3; pLD++; |
| 3245 | pLD->start = NumVertexes - 3; |
| 3246 | pLD->end = NumVertexes - 2; pLD++; |
| 3247 | pLD->start = NumVertexes - 2; |
| 3248 | pLD->end = NumVertexes - 1; pLD++; |
| 3249 | pLD->start = NumVertexes - 1; |
| 3250 | pLD->end = NumVertexes - 4; |
| 3251 | } |
| 3252 | else |
| 3253 | { |
| 3254 | LineDef *pLD = &LineDefs[NumLineDefs - 4]; |
| 3255 | |
| 3256 | pLD->start = NumVertexes - 1; |
| 3257 | pLD->end = NumVertexes - 2; pLD++; |
| 3258 | pLD->start = NumVertexes - 2; |
| 3259 | pLD->end = NumVertexes - 3; pLD++; |
| 3260 | pLD->start = NumVertexes - 3; |
| 3261 | pLD->end = NumVertexes - 4; pLD++; |
| 3262 | pLD->start = NumVertexes - 4; |
| 3263 | pLD->end = NumVertexes - 1; |
no test coverage detected