MCPcopy Create free account
hub / github.com/Meridian59/Meridian59 / GetCurObject

Function GetCurObject

roomedit/source/objects.cpp:187–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185*/
186
187SHORT GetCurObject (int objtype, SHORT x0, SHORT y0, SHORT x1, SHORT y1)
188{
189 SHORT n, m, cur, curx;
190 SHORT lx0, ly0, lx1, ly1;
191 SHORT midx, midy;
192 ULONG dist, r, mindist;
193 long x, y;
194 SHORT xc, yc;
195
196 cur = -1;
197 if (x1 < x0)
198 {
199 n = x0; x0 = x1; x1 = n;
200 }
201 if (y1 < y0)
202 {
203 n = y0; y0 = y1; y1 = n;
204 }
205
206 switch (objtype)
207 {
208 case OBJ_THINGS:
209 mindist = ULONG_MAX;
210 xc = (x0 + x1) / 2;
211 yc = (y0 + y1) / 2;
212 for (n = 0; n < NumThings; n++)
213 {
214 x = xc - Things[ n].xpos;
215 y = yc - Things[ n].ypos;
216 r = GetThingRadius (Things[ n].type) + 2;
217 // Keep a reasonnable radius size
218 if ( r * MUL_SCALE < 4 ) r = 4 * DIV_SCALE;
219 dist = x * x + y * y;
220 r = r * r;
221 if ( dist <= r && dist <= mindist)
222 {
223 mindist = dist;
224 cur = n;
225 // break;
226 }
227 }
228 break;
229
230 case OBJ_VERTEXES:
231 for (n = 0; n < NumVertexes; n++)
232 if (Vertexes[ n].x >= x0 && Vertexes[ n].x <= x1 &&
233 Vertexes[ n].y >= y0 && Vertexes[ n].y <= y1)
234 {
235 cur = n;
236 break;
237 }
238 break;
239
240 case OBJ_LINEDEFS:
241 for (n = 0; n < NumLineDefs; n++)
242 {
243 if (IsLineDefInside( n, x0, y0, x1, y1))
244 {

Callers 8

SplitSectorFunction · 0.85
GoToObjectFunction · 0.85
InsertRectangleFunction · 0.85
InsertPolygonFunction · 0.85
EvMouseMoveMethod · 0.85
EvLButtonDownMethod · 0.85
EvLButtonDblClkMethod · 0.85
EvRButtonDownMethod · 0.85

Calls 2

GetThingRadiusFunction · 0.85
IsLineDefInsideFunction · 0.85

Tested by

no test coverage detected