| 124 | } |
| 125 | |
| 126 | void AILocker::LockPosition(Vector3Val pos, float radius, bool soldier, float size) |
| 127 | { |
| 128 | int LockRange = toIntCeil(radius * InvOperItemGrid); |
| 129 | if (LockRange < 0) |
| 130 | { |
| 131 | LockRange = 0; |
| 132 | } |
| 133 | |
| 134 | int xx, x = toIntFloor(pos.X() * InvOperItemGrid); |
| 135 | int zz, z = toIntFloor(pos.Z() * InvOperItemGrid); |
| 136 | for (xx = -LockRange; xx <= LockRange; xx++) |
| 137 | { |
| 138 | for (zz = -LockRange; zz <= LockRange; zz++) |
| 139 | { |
| 140 | float xr = (x + xx + 0.5f) * OperItemGrid - pos.X(); |
| 141 | float zr = (z + zz + 0.5f) * OperItemGrid - pos.Z(); |
| 142 | if (xr * xr + zr * zr < radius * radius || xx == 0 && zz == 0) |
| 143 | { |
| 144 | LockItem(x + xx, z + zz, true); |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | AI_ERROR(GRoadNet); |
| 150 | x = toIntFloor(pos.X() * InvLandGrid); |
| 151 | z = toIntFloor(pos.Z() * InvLandGrid); |
| 152 | // lock road item if vehicle is inside "boundingSphere" + size |
| 153 | for (zz = z - 1; zz <= z + 1; zz++) |
| 154 | { |
| 155 | for (xx = x - 1; xx <= x + 1; xx++) |
| 156 | { |
| 157 | if (!InRange(xx, zz)) |
| 158 | { |
| 159 | continue; |
| 160 | } |
| 161 | RoadList& roadList = GRoadNet->GetRoadList(xx, zz); |
| 162 | int i; |
| 163 | for (i = 0; i < roadList.Size(); i++) |
| 164 | { |
| 165 | RoadLink* item = roadList[i]; |
| 166 | if (item->IsInside(pos, size)) |
| 167 | { |
| 168 | item->Lock(); |
| 169 | _roads.Add(item); |
| 170 | } |
| 171 | } |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | if (soldier) |
| 176 | { |
| 177 | // this is not clear - pos is AimingPosition, we need position on surface |
| 178 | Vector3 realPos = pos - Vector3(0, 1, 0); |
| 179 | |
| 180 | // lock position in house |
| 181 | int xMin, xMax, zMin, zMax; |
| 182 | ObjRadiusRectangle(xMin, xMax, zMin, zMax, pos, pos, 50); |
| 183 | for (int x = xMin; x <= xMax; x++) |
nothing calls this directly
no test coverage detected