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

Method Init

src/Managers/MapManager.cpp:387–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

385}
386
387void CMapManager::Init(bool delayed)
388{
389 if (g_Player == nullptr)
390 {
391 return;
392 }
393
394 int map = GetActualMap();
395 if (!delayed)
396 {
397 if (m_Blocks != nullptr)
398 {
399 ClearUsedBlocks();
400 delete[] m_Blocks;
401 m_Blocks = nullptr;
402 }
403
404 MaxBlockIndex = g_MapBlockSize[map].Width * g_MapBlockSize[map].Height;
405 m_Blocks = new CMapBlock *[MaxBlockIndex];
406 memset(&m_Blocks[0], 0, sizeof(CMapBlock *) * MaxBlockIndex);
407 ClearBlockAccess();
408 PatchesCount = 0;
409 memset(&m_MapPatchCount[0], 0, sizeof(m_MapPatchCount));
410 memset(&m_StaticPatchCount[0], 0, sizeof(m_StaticPatchCount));
411 }
412
413 const int XY_Offset = 30; //70;
414 int minBlockX = (g_Player->GetX() - XY_Offset) / 8 - 1;
415 int minBlockY = (g_Player->GetY() - XY_Offset) / 8 - 1;
416 int maxBlockX = ((g_Player->GetX() + XY_Offset) / 8) + 1;
417 int maxBlockY = ((g_Player->GetY() + XY_Offset) / 8) + 1;
418
419 if (minBlockX < 0)
420 {
421 minBlockX = 0;
422 }
423
424 if (minBlockY < 0)
425 {
426 minBlockY = 0;
427 }
428
429 if (maxBlockX >= g_MapBlockSize[map].Width)
430 {
431 maxBlockX = g_MapBlockSize[map].Width - 1;
432 }
433
434 if (maxBlockY >= g_MapBlockSize[map].Height)
435 {
436 maxBlockY = g_MapBlockSize[map].Height - 1;
437 }
438
439 uint32_t ticks = g_Ticks;
440 uint32_t maxDelay = g_FrameDelay[WINDOW_ACTIVE] / 2;
441 for (int i = minBlockX; i <= maxBlockX; i++)
442 {
443 uint32_t index = i * g_MapBlockSize[map].Height;
444 for (int j = minBlockY; j <= maxBlockY; j++)

Callers 4

PACKET_HANDLERFunction · 0.45
AddGumpMethod · 0.45
GenerateABaseMethod · 0.45
GenerateWBaseMethod · 0.45

Calls 2

GetYMethod · 0.80
GetXMethod · 0.45

Tested by

no test coverage detected