Last active
December 26, 2020 04:09
-
-
Save Aviator-Coding/13be0dff1ba57a1a9f30b202f57a7ceb to your computer and use it in GitHub Desktop.
Revisions
-
Aviator-Coding renamed this gist
Dec 26, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Aviator-Coding renamed this gist
Dec 26, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Aviator-Coding created this gist
Dec 26, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,82 @@ # Bed Roll Debugging ## Server: ExplosionServer can be called from ``` BlockCarExplode.cs BlockCarExplodeLoot.cs BlockMine.cs BlockProjectileMoveScript.cs BlockTNT.cs EntityCar.cs EntityVehicle.cs EntityZombieCop.Clients ItemClassTimeBomb.cs NetpackageExplosionIntiate.cs ``` GameManager.ExplosionServer() Explosion will Trigger GameManager.cs->Explode() At the end of the function it will call ``` SingletonMonoBehaviour<ConnectionManager>.Instance.SendPackage(NetPackageManager.GetPackage<NetPackageExplosionClient>().Setup(_clrIdx, _worldPos, _rotation, _explosionData.ParticleIndex, _explosionData.BlastPower, (float)_explosionData.EntityRadius, this.tempExplPositions), true, -1, -1, -1, -1); ``` If you check ConnectionManager.SendPackage() you will see that this explosion Package will be send to all Clients this is important to note here since this is the reason everyone on the Server gets the BedBug ## Client: Client Receives Explosion message from Server It will process it with NetPackageExplosionClient.cs->Read() NetPackageExplosionClient.cs->ProcessPackage() This will later call the Explosion Client Function in the GameManager _world.GetGameManager().ExplosionClient(this.clrIdx, this.center, this.rotation, this.expType, this.blastPower, (float)this.blastRadius, this.explosionChanges); ExplosionClients will call the Block explosionChanges GameManager->ChangeBlocks(null, _explosionChanges); Important is the null here it will not pass an instigator ID into the Function Call In the ChangeBlocks Function we check if the ID is null and if it is we assign the LocalPlayersID to it. Just to recap in our case we just send an explosion package to every Client currently playing on the Server and everyone of these clients will use its own local ID for the up comming Block change There is one thing i am not sure about in the blockchange is about the if (bvOld.type != blockChangeInfo.blockValue.type) this should not be true in case of taking just damage however it must pass it. We then use our LocalID assign it to Entity Alive and update our SpawnPoint. ``` EntityAlive entityAlive = entity as EntityAlive; if (entityAlive) { if (block is BlockSleepingBag) { NavObjectManager.Instance.UnRegisterNavObjectByOwnerEntity(entityAlive, "sleeping_bag"); entityAlive.SpawnPoints.Set(blockChangeInfo.pos); } else { this.persistentPlayers.SpawnPointRemoved(blockChangeInfo.pos); } flag = true; } ``` This is the Reason all Spawn points from every Player will be the same since the Block Position send to all persistentPlayers is the same and every Player uses its localPlayer ID to update the Spawnpoint. Side note so every Null Value passed into a blockChange can cause this. So there are multiple flaws 1. Why do we send the Explosion to everyone on the Server and not just the Person inside the same Chunk 2. We also have to make that we don't pass null into the change Block function if every client just uses its local ID After farther Investigation since the null parsed into the BlockChange is causing this there is one more function which does pass a static null as an ID into the BlockChange GameManager.SetBlocksRPC() // This is also send the Block Change to all Clients currently on the Server ``` Prefab.cs ItemActionReplaceBlock.cs BlockTools.cs BlockToolSelection.cs ``` This above can also be another trigger for the Bedbug if the block targeted is a Bedroll or a bed