| 332 | } |
| 333 | |
| 334 | int SensorList::UpdateCell(SensorRowID r, SensorColID c) |
| 335 | { |
| 336 | SensorRow& row = _rows[r]; |
| 337 | Person* fromDriver = row._vehicle; |
| 338 | if (!fromDriver) |
| 339 | { |
| 340 | return 0; |
| 341 | } |
| 342 | SensorCol& col = _cols[c]; |
| 343 | EntityAI* to = col._vehicle; |
| 344 | if (!to) |
| 345 | { |
| 346 | return 0; |
| 347 | } |
| 348 | // |
| 349 | AIUnit* fromUnit = fromDriver->CommanderUnit(); |
| 350 | if (!fromUnit) |
| 351 | { |
| 352 | return 0; |
| 353 | } |
| 354 | |
| 355 | EntityAI* from = fromUnit->GetVehicle(); |
| 356 | |
| 357 | // update single |
| 358 | SensorUpdate& info = row._info[c]; |
| 359 | if (from == to) |
| 360 | { |
| 361 | info.SetVisibility1(); |
| 362 | info.SetLastVisible(Glob.time); |
| 363 | info.rowPos = from->Position(); |
| 364 | info.colPos = to->Position(); |
| 365 | info.time = Glob.time; |
| 366 | return 0; |
| 367 | } |
| 368 | float dist2 = from->Position().Distance2(to->Position()); |
| 369 | float irRange = from->GetType()->GetIRScanRange(); |
| 370 | if (!to->GetType()->GetIRTarget()) |
| 371 | { |
| 372 | irRange = 0; |
| 373 | } |
| 374 | float sensorLimit = floatMax(irRange, TACTICAL_VISIBILITY); |
| 375 | if (dist2 < Square(sensorLimit)) |
| 376 | { |
| 377 | float defValue = 0; |
| 378 | float unimportance = Unimportance(from, to, defValue); |
| 379 | |
| 380 | // unimportant: assume default value |
| 381 | if (unimportance > 1e5) |
| 382 | { |
| 383 | info.SetVisibility(defValue); |
| 384 | info.rowPos = from->Position(); |
| 385 | info.colPos = to->Position(); |
| 386 | info.time = Glob.time - 30; |
| 387 | if (defValue >= 0.02f) |
| 388 | { |
| 389 | info.SetLastVisible(Glob.time); |
| 390 | } |
| 391 | // set time in past |
nothing calls this directly
no test coverage detected