MCPcopy Create free account
hub / github.com/diasurgical/DevilutionX / DeltaLoadLevel

Function DeltaLoadLevel

Source/msg.cpp:2663–2784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2661}
2662
2663void DeltaLoadLevel()
2664{
2665 if (!gbIsMultiplayer)
2666 return;
2667
2668 uint8_t localLevel = GetLevelForMultiplayer(*MyPlayer);
2669 DLevel &deltaLevel = GetDeltaLevel(localLevel);
2670 if (leveltype != DTYPE_TOWN) {
2671 for (size_t i = 0; i < MaxMonsters; i++) {
2672 if (deltaLevel.monster[i].position.x == 0xFF)
2673 continue;
2674
2675 auto &monster = Monsters[i];
2676 M_ClearSquares(monster);
2677 {
2678 const WorldTilePosition position = deltaLevel.monster[i].position;
2679 monster.position.tile = position;
2680 monster.position.old = position;
2681 monster.position.future = position;
2682 if (monster.lightId != NO_LIGHT)
2683 ChangeLightXY(monster.lightId, position);
2684 }
2685 if (deltaLevel.monster[i].hitPoints != -1) {
2686 monster.hitPoints = deltaLevel.monster[i].hitPoints;
2687 monster.whoHit = deltaLevel.monster[i].mWhoHit;
2688 }
2689 if (deltaLevel.monster[i].hitPoints == 0) {
2690 M_ClearSquares(monster);
2691 if (monster.ai != MonsterAIID::Diablo) {
2692 if (monster.isUnique()) {
2693 AddCorpse(monster.position.tile, monster.corpseId, monster.direction);
2694 } else {
2695 AddCorpse(monster.position.tile, monster.type().corpseId, monster.direction);
2696 }
2697 }
2698 monster.isInvalid = true;
2699 M_UpdateRelations(monster);
2700 } else {
2701 decode_enemy(monster, deltaLevel.monster[i]._menemy);
2702 if (monster.position.tile != Point { 0, 0 } && monster.position.tile != GolemHoldingCell)
2703 dMonster[monster.position.tile.x][monster.position.tile.y] = i + 1;
2704 if (monster.type().type == MT_GOLEM) {
2705 GolumAi(monster);
2706 monster.flags |= (MFLAG_TARGETS_MONSTER | MFLAG_GOLEM);
2707 } else {
2708 M_StartStand(monster, monster.direction);
2709 }
2710 monster.activeForTicks = deltaLevel.monster[i]._mactive;
2711 }
2712 }
2713 auto localLevelIt = LocalLevels.find(localLevel);
2714 if (localLevelIt != LocalLevels.end())
2715 memcpy(AutomapView, &localLevelIt->second, sizeof(AutomapView));
2716 else
2717 memset(AutomapView, 0, sizeof(AutomapView));
2718 }
2719
2720 if (leveltype != DTYPE_TOWN) {

Callers 1

LoadGameLevelFunction · 0.85

Calls 15

GetLevelForMultiplayerFunction · 0.85
M_ClearSquaresFunction · 0.85
ChangeLightXYFunction · 0.85
AddCorpseFunction · 0.85
M_UpdateRelationsFunction · 0.85
decode_enemyFunction · 0.85
GolumAiFunction · 0.85
M_StartStandFunction · 0.85
FindObjectAtPositionFunction · 0.85
DeltaSyncOpObjectFunction · 0.85
DeltaSyncCloseObjFunction · 0.85
DeltaSyncBreakObjFunction · 0.85

Tested by

no test coverage detected