| 1430 | */ |
| 1431 | |
| 1432 | BOOL MoveObjectsToCoords (int objtype, SelPtr obj, SHORT newx, SHORT newy, |
| 1433 | SHORT grid) |
| 1434 | { |
| 1435 | SHORT n; |
| 1436 | SHORT dx, dy; |
| 1437 | SelPtr cur, vertices; |
| 1438 | static SHORT refx, refy; /* previous position */ |
| 1439 | |
| 1440 | // Snap to grid |
| 1441 | if (grid > 0) |
| 1442 | { |
| 1443 | newx = (newx + grid / 2) & ~(grid - 1); |
| 1444 | newy = (newy + grid / 2) & ~(grid - 1); |
| 1445 | } |
| 1446 | |
| 1447 | /* only update the reference point? */ |
| 1448 | if (obj == NULL) |
| 1449 | { |
| 1450 | refx = newx; |
| 1451 | refy = newy; |
| 1452 | return TRUE; |
| 1453 | } |
| 1454 | |
| 1455 | /* compute the displacement */ |
| 1456 | dx = newx - refx; |
| 1457 | dy = newy - refy; |
| 1458 | /* nothing to do? */ |
| 1459 | if (dx == 0 && dy == 0) |
| 1460 | return FALSE; |
| 1461 | |
| 1462 | /* move the object(s) */ |
| 1463 | switch (objtype) |
| 1464 | { |
| 1465 | case OBJ_THINGS: |
| 1466 | for (cur = obj; cur; cur = cur->next) |
| 1467 | { |
| 1468 | assert (cur->objnum >= 0 && cur->objnum < NumThings); |
| 1469 | Thing *pThing = &Things[cur->objnum]; |
| 1470 | pThing->xpos += dx; |
| 1471 | pThing->ypos += dy; |
| 1472 | if (pThing->type == kodEntrance) |
| 1473 | { |
| 1474 | // pThing->id = SetEntrance(RoomID, pThing->id, pThing->xpos, pThing->ypos, pThing->angle, pThing->comment); |
| 1475 | } |
| 1476 | } |
| 1477 | refx = newx; |
| 1478 | refy = newy; |
| 1479 | MadeChanges = TRUE; |
| 1480 | break; |
| 1481 | |
| 1482 | case OBJ_VERTEXES: |
| 1483 | for (cur = obj; cur; cur = cur->next) |
| 1484 | { |
| 1485 | assert_vnum(cur->objnum); |
| 1486 | Vertex *pVertex = &Vertexes[cur->objnum]; |
| 1487 | |
| 1488 | pVertex->x += dx; |
| 1489 | pVertex->y += dy; |
no test coverage detected