MCPcopy Create free account
hub / github.com/crossuo/crossuo / AddObject

Method AddObject

src/GameObjects/MapBlock.cpp:386–434  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386CMapObject *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}

Callers 4

GetWorldItemMethod · 0.45
GetWorldCharacterMethod · 0.45
UpdateGameObjectMethod · 0.45
LoadBlockMethod · 0.45

Calls 2

GetZMethod · 0.80
IsLandObjectMethod · 0.45

Tested by

no test coverage detected