| 384 | } |
| 385 | |
| 386 | CMapObject *CMapBlock::AddObject(CMapObject *obj, int x, int y) |
| 387 | { |
| 388 | if (Block[x][y] != nullptr) |
| 389 | { |
| 390 | CMapObject *item = Block[x][y]; |
| 391 | while (item != nullptr) |
| 392 | { |
| 393 | if (!item->IsLandObject() && item->GetZ() > obj->GetZ()) |
| 394 | { |
| 395 | if (item->m_Prev != nullptr) |
| 396 | { |
| 397 | item = (CMapObject *)item->m_Prev; |
| 398 | break; |
| 399 | } |
| 400 | |
| 401 | m_Items = obj; |
| 402 | obj->m_Prev = nullptr; |
| 403 | obj->m_Next = item; |
| 404 | item->m_Prev = obj; |
| 405 | AddRender(obj, x, y); |
| 406 | return obj; |
| 407 | } |
| 408 | if (item->m_Next == nullptr) |
| 409 | { |
| 410 | break; |
| 411 | } |
| 412 | item = (CMapObject *)item->m_Next; |
| 413 | } |
| 414 | assert(item != nullptr); |
| 415 | CMapObject *next = (CMapObject *)item->m_Next; |
| 416 | item->m_Next = obj; |
| 417 | obj->m_Next = next; |
| 418 | obj->m_Prev = item; |
| 419 | if (next != nullptr) |
| 420 | { |
| 421 | next->m_Prev = obj; |
| 422 | } |
| 423 | AddRender(obj, x, y); |
| 424 | } |
| 425 | else |
| 426 | { |
| 427 | Block[x][y] = obj; |
| 428 | obj->m_Next = nullptr; |
| 429 | obj->m_Prev = nullptr; |
| 430 | obj->m_NextXY = nullptr; |
| 431 | obj->m_PrevXY = nullptr; |
| 432 | } |
| 433 | return obj; |
| 434 | } |
no test coverage detected