Cuberite
A lightweight, fast and extensible game server for Minecraft
Broadcaster.cpp
Go to the documentation of this file.
1 // Broadcaster.cpp
2 
3 // Implements the broadcasting functions for cWorld
4 
5 #include "Globals.h"
6 #include "World.h"
7 #include "Chunk.h"
8 #include "ClientHandle.h"
9 #include "Entities/Entity.h"
10 #include "Entities/Player.h"
12 
13 
14 
15 
16 
17 namespace
18 {
19 
24  template <typename Func>
25  void ForClientsInWorld(cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func)
26  {
27  a_World.ForEachPlayer([&](cPlayer & a_Player)
28  {
29  cClientHandle * Client = a_Player.GetClientHandle();
30  if ((Client != a_Exclude) && (Client != nullptr) && Client->IsLoggedIn() && !Client->IsDestroyed())
31  {
32  a_Func(*Client);
33  }
34  return false;
35  }
36  );
37  }
38 
39 
45  template <typename Func>
46  void ForClientsWithChunk(const cChunkCoords a_ChunkCoords, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func)
47  {
48  a_World.DoWithChunk(a_ChunkCoords.m_ChunkX, a_ChunkCoords.m_ChunkZ,
49  [&](cChunk & a_Chunk)
50  {
51  for (auto * Client : a_Chunk.GetAllClients())
52  {
53  if (Client != a_Exclude)
54  {
55  a_Func(*Client);
56  }
57  }
58  return true;
59  }
60  );
61  }
62 
63 
64 
70  template <typename Func>
71  void ForClientsWithChunkAtPos(const Vector3i a_WorldPos, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func)
72  {
73  ForClientsWithChunk(cChunkDef::BlockToChunk(a_WorldPos), a_World, a_Exclude, std::move(a_Func));
74  }
75 
76 
77 
83  template <typename Func>
84  void ForClientsWithEntity(const cEntity & a_Entity, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func)
85  {
86  cWorld::cLock Lock(a_World); // Lock world before accessing a_Entity
87  auto Chunk = a_Entity.GetParentChunk();
88  if (Chunk != nullptr)
89  {
90  for (auto * Client : Chunk->GetAllClients())
91  {
92  if (Client != a_Exclude)
93  {
94  a_Func(*Client);
95  }
96  }
97  }
98  else // Some broadcasts happen before the entity's first tick sets its ParentChunk
99  {
100  ForClientsWithChunk({ a_Entity.GetChunkX(), a_Entity.GetChunkZ() }, a_World, a_Exclude, std::move(a_Func));
101  }
102  }
103 } // namespace (anonymous)
104 
105 
106 
107 
108 
109 void cWorld::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle)
110 {
111  ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client)
112  {
113  a_Client.SendAttachEntity(a_Entity, a_Vehicle);
114  }
115  );
116 }
117 
118 
119 
120 
121 
122 void cWorld::BroadcastBlockAction(Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude)
123 {
124  ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client)
125  {
126  a_Client.SendBlockAction(a_BlockPos, static_cast<char>(a_Byte1), static_cast<char>(a_Byte2), a_BlockType);
127  }
128  );
129 }
130 
131 
132 
133 
134 
135 void cWorld::BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, Int8 a_Stage, const cClientHandle * a_Exclude)
136 {
137  ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client)
138  {
139  a_Client.SendBlockBreakAnim(a_EntityID, a_BlockPos, a_Stage);
140  }
141  );
142 }
143 
144 
145 
146 
147 
148 void cWorld::BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle * a_Exclude)
149 {
150  DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk)
151  {
152  cBlockEntity * Entity = a_Chunk.GetBlockEntity(a_BlockPos);
153  if (Entity == nullptr)
154  {
155  return false;
156  }
157 
158  for (auto * Client : a_Chunk.GetAllClients())
159  {
160  if (Client != a_Exclude)
161  {
162  Entity->SendTo(*Client);
163  }
164  }
165  return true;
166  }
167  );
168 }
169 
170 
171 
172 
173 
174 void cWorld::BroadcastBossBarUpdateHealth(const cEntity & a_Entity, UInt32 a_UniqueID, float a_FractionFilled)
175 {
176  ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client)
177  {
178  a_Client.SendBossBarUpdateHealth(a_UniqueID, a_FractionFilled);
179  }
180  );
181 }
182 
183 
184 
185 
186 
187 void cWorld::BroadcastChat(const AString & a_Message, const cClientHandle * a_Exclude, eMessageType a_ChatPrefix)
188 {
189  if ((a_ChatPrefix == mtDeath) && !ShouldBroadcastDeathMessages())
190  {
191  return;
192  }
193 
194  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
195  {
196  a_Client.SendChat(a_Message, a_ChatPrefix);
197  }
198  );
199 }
200 
201 
202 
203 
204 
205 void cWorld::BroadcastChat(const cCompositeChat & a_Message, const cClientHandle * a_Exclude)
206 {
207  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
208  {
209  a_Client.SendChat(a_Message);
210  }
211  );
212 }
213 
214 
215 
216 
217 
218 void cWorld::BroadcastCollectEntity(const cEntity & a_Collected, const cEntity & a_Collector, unsigned a_Count, const cClientHandle * a_Exclude)
219 {
220  ForClientsWithEntity(a_Collected, *this, a_Exclude, [&](cClientHandle & a_Client)
221  {
222  a_Client.SendCollectEntity(a_Collected, a_Collector, a_Count);
223  }
224  );
225 }
226 
227 
228 
229 
230 
231 void cWorld::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
232 {
233  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
234  {
235  a_Client.SendDestroyEntity(a_Entity);
236  }
237  );
238 }
239 
240 
241 
242 
243 
244 void cWorld::BroadcastDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle)
245 {
246  ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client)
247  {
248  a_Client.SendDetachEntity(a_Entity, a_PreviousVehicle);
249  }
250  );
251 }
252 
253 
254 
255 
256 
258 {
259  ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client)
260  {
261  a_Client.SendDisplayObjective(a_Objective, a_Display);
262  }
263  );
264 }
265 
266 
267 
268 
269 
270 void cWorld::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, int a_Duration, const cClientHandle * a_Exclude)
271 {
272  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
273  {
274  a_Client.SendEntityEffect(a_Entity, a_EffectID, a_Amplifier, a_Duration);
275  }
276  );
277 }
278 
279 
280 
281 
282 
283 void cWorld::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude)
284 {
285  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
286  {
287  a_Client.SendEntityEquipment(a_Entity, a_SlotNum, a_Item);
288  }
289  );
290 }
291 
292 
293 
294 
295 
296 void cWorld::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
297 {
298  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
299  {
300  a_Client.SendEntityHeadLook(a_Entity);
301  }
302  );
303 }
304 
305 
306 
307 
308 
309 void cWorld::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude)
310 {
311  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
312  {
313  a_Client.SendEntityLook(a_Entity);
314  }
315  );
316 }
317 
318 
319 
320 
321 
322 void cWorld::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude)
323 {
324  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
325  {
326  a_Client.SendEntityMetadata(a_Entity);
327  }
328  );
329 }
330 
331 
332 
333 
334 
335 void cWorld::BroadcastEntityPosition(const cEntity & a_Entity, const cClientHandle * a_Exclude)
336 {
337  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
338  {
339  a_Client.SendEntityPosition(a_Entity);
340  }
341  );
342 }
343 
344 
345 
346 
347 
349 {
350  ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client)
351  {
352  a_Client.SendEntityProperties(a_Entity);
353  }
354  );
355 }
356 
357 
358 
359 
360 
361 void cWorld::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude)
362 {
363  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
364  {
365  a_Client.SendEntityVelocity(a_Entity);
366  }
367  );
368 }
369 
370 
371 
372 
373 
374 void cWorld::BroadcastEntityAnimation(const cEntity & a_Entity, EntityAnimation a_Animation, const cClientHandle * a_Exclude)
375 {
376  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
377  {
378  a_Client.SendEntityAnimation(a_Entity, a_Animation);
379  }
380  );
381 }
382 
383 
384 
385 
386 
387 void cWorld::BroadcastLeashEntity(const cEntity & a_Entity, const cEntity & a_EntityLeashedTo)
388 {
389  ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client)
390  {
391  a_Client.SendLeashEntity(a_Entity, a_EntityLeashedTo);
392  }
393  );
394 }
395 
396 
397 
398 
399 
400 void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, const cClientHandle * a_Exclude)
401 {
402  ForClientsWithChunkAtPos(a_Src, *this, a_Exclude, [&](cClientHandle & a_Client)
403  {
404  a_Client.SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount);
405  }
406  );
407 }
408 
409 
410 
411 
412 
413 void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data, const cClientHandle * a_Exclude)
414 {
415  ForClientsWithChunkAtPos(a_Src, *this, a_Exclude, [&](cClientHandle & a_Client)
416  {
417  a_Client.SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount, a_Data);
418  }
419  );
420 }
421 
422 
423 
424 
425 
426 void cWorld::BroadcastPlayerListAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude)
427 {
428  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
429  {
430  a_Client.SendPlayerListAddPlayer(a_Player);
431  }
432  );
433 }
434 
435 
436 
437 
438 
440 {
441  ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client)
442  {
443  a_Client.SendPlayerListHeaderFooter(a_Header, a_Footer);
444  }
445  );
446 }
447 
448 
449 
450 
451 
452 void cWorld::BroadcastPlayerListRemovePlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude)
453 {
454  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
455  {
456  a_Client.SendPlayerListRemovePlayer(a_Player);
457  }
458  );
459 }
460 
461 
462 
463 
464 
465 void cWorld::BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName, const cClientHandle * a_Exclude)
466 {
467  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
468  {
469  a_Client.SendPlayerListUpdateDisplayName(a_Player, a_CustomName);
470  }
471  );
472 }
473 
474 
475 
476 
477 
478 void cWorld::BroadcastPlayerListUpdateGameMode(const cPlayer & a_Player, const cClientHandle * a_Exclude)
479 {
480  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
481  {
482  a_Client.SendPlayerListUpdateGameMode(a_Player);
483  }
484  );
485 }
486 
487 
488 
489 
490 
492 {
493  ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client)
494  {
495  a_Client.SendPlayerListUpdatePing();
496  }
497  );
498 }
499 
500 
501 
502 
503 
504 void cWorld::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude)
505 {
506  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
507  {
508  a_Client.SendRemoveEntityEffect(a_Entity, a_EffectID);
509  }
510  );
511 }
512 
513 
514 
515 
516 
517 void cWorld::BroadcastScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode)
518 {
519  ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client)
520  {
521  a_Client.SendScoreboardObjective(a_Name, a_DisplayName, a_Mode);
522  }
523  );
524 }
525 
526 
527 
528 
529 
530 void cWorld::BroadcastScoreUpdate(const AString & a_Objective, const AString & a_PlayerName, cObjective::Score a_Score, Byte a_Mode)
531 {
532  ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client)
533  {
534  a_Client.SendScoreUpdate(a_Objective, a_PlayerName, a_Score, a_Mode);
535  }
536  );
537 }
538 
539 
540 
541 
542 
543 void cWorld::BroadcastSoundEffect(const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude)
544 {
545  ForClientsWithChunkAtPos(a_Position, *this, a_Exclude, [&](cClientHandle & a_Client)
546  {
547  a_Client.SendSoundEffect(a_SoundName, a_Position, a_Volume, a_Pitch);
548  }
549  );
550 }
551 
552 
553 
554 
555 
556 void cWorld::BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle * a_Exclude)
557 {
558  ForClientsWithChunkAtPos(a_SrcPos, *this, a_Exclude, [&](cClientHandle & a_Client)
559  {
560  a_Client.SendSoundParticleEffect(a_EffectID, a_SrcPos, a_Data);
561  }
562  );
563 }
564 
565 
566 
567 
568 
569 void cWorld::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude)
570 {
571  ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client)
572  {
573  a_Entity.SpawnOn(a_Client);
574  }
575  );
576 }
577 
578 
579 
580 
581 
582 void cWorld::BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle * a_Exclude)
583 {
584  ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client)
585  {
586  a_Client.SendThunderbolt(a_BlockPos);
587  }
588  );
589 }
590 
591 
592 
593 
594 
596 {
597  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
598  {
600  }
601  );
602 }
603 
604 
605 
606 
607 
609 {
610  ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client)
611  {
612  a_Client.SendUnleashEntity(a_Entity);
613  }
614  );
615 }
616 
617 
618 
619 
620 
621 void cWorld::BroadcastWeather(eWeather a_Weather, const cClientHandle * a_Exclude)
622 {
623  ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client)
624  {
625  a_Client.SendWeather(a_Weather);
626  }
627  );
628 }
cClientHandle
Definition: ClientHandle.h:49
cWorld::BroadcastUnleashEntity
virtual void BroadcastUnleashEntity(const cEntity &a_Entity) override
Definition: Broadcaster.cpp:608
cWorld::BroadcastWeather
virtual void BroadcastWeather(eWeather a_Weather, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:621
cEntity::GetParentChunk
cChunk * GetParentChunk()
Returns the chunk responsible for ticking this entity.
Definition: Entity.h:541
cClientHandle::SendEntityMetadata
void SendEntityMetadata(const cEntity &a_Entity)
Definition: ClientHandle.cpp:2631
cClientHandle::SendEntityVelocity
void SendEntityVelocity(const cEntity &a_Entity)
Definition: ClientHandle.cpp:2658
cWorld::BroadcastBossBarUpdateHealth
virtual void BroadcastBossBarUpdateHealth(const cEntity &a_Entity, UInt32 a_UniqueID, float a_FractionFilled) override
Definition: Broadcaster.cpp:174
cCompositeChat
Container for a single chat message composed of multiple functional parts.
Definition: CompositeChat.h:33
cWorld::BroadcastLeashEntity
virtual void BroadcastLeashEntity(const cEntity &a_Entity, const cEntity &a_EntityLeashedTo) override
Definition: Broadcaster.cpp:387
cClientHandle::SendWeather
void SendWeather(eWeather a_Weather)
Definition: ClientHandle.cpp:3234
cWorld::BroadcastEntityEquipment
virtual void BroadcastEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:283
cWorld::BroadcastScoreUpdate
virtual void BroadcastScoreUpdate(const AString &a_Objective, const AString &a_Player, cObjective::Score a_Score, Byte a_Mode) override
Definition: Broadcaster.cpp:530
cWorld::BroadcastDisplayObjective
virtual void BroadcastDisplayObjective(const AString &a_Objective, cScoreboard::eDisplaySlot a_Display) override
Definition: Broadcaster.cpp:257
cClientHandle::SendAttachEntity
void SendAttachEntity(const cEntity &a_Entity, const cEntity &a_Vehicle)
Definition: ClientHandle.cpp:2236
cWorld::BroadcastPlayerListUpdateDisplayName
virtual void BroadcastPlayerListUpdateDisplayName(const cPlayer &a_Player, const AString &a_CustomName, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:465
cClientHandle::SendLeashEntity
void SendLeashEntity(const cEntity &a_Entity, const cEntity &a_EntityLeashedTo)
Definition: ClientHandle.cpp:2245
cClientHandle::SendCollectEntity
void SendCollectEntity(const cEntity &a_Collected, const cEntity &a_Collector, unsigned a_Count)
Definition: ClientHandle.cpp:2541
cWorld::GetWorldAge
virtual cTickTimeLong GetWorldAge(void) const override
Definition: World.cpp:491
cClientHandle::SendTimeUpdate
void SendTimeUpdate(cTickTimeLong a_WorldAge, cTickTimeLong a_WorldDate, bool a_DoDaylightCycle)
Definition: ClientHandle.cpp:3146
cWorld::BroadcastSoundParticleEffect
virtual void BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:556
Chunk.h
cWorld::BroadcastSpawnEntity
virtual void BroadcastSpawnEntity(cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:569
cClientHandle::SendEntityAnimation
void SendEntityAnimation(const cEntity &a_Entity, EntityAnimation a_Animation)
Definition: ClientHandle.cpp:2786
cClientHandle::SendPlayerListUpdatePing
void SendPlayerListUpdatePing()
Definition: ClientHandle.cpp:2849
mtDeath
@ mtDeath
Definition: Defines.h:361
cClientHandle::SendEntityLook
void SendEntityLook(const cEntity &a_Entity)
Definition: ClientHandle.cpp:2620
Globals.h
UInt32
unsigned int UInt32
Definition: Globals.h:154
cWorld::BroadcastTimeUpdate
virtual void BroadcastTimeUpdate(const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:595
cClientHandle::SendPlayerListAddPlayer
void SendPlayerListAddPlayer(const cPlayer &a_Player)
Definition: ClientHandle.cpp:2804
cChunkCoords::m_ChunkX
int m_ChunkX
Definition: ChunkDef.h:58
cChunkDef::BlockToChunk
static void BlockToChunk(int a_X, int a_Z, int &a_ChunkX, int &a_ChunkZ)
Converts absolute block coords to chunk coords:
Definition: ChunkDef.h:193
cClientHandle::SendBlockBreakAnim
void SendBlockBreakAnim(UInt32 a_EntityID, Vector3i a_BlockPos, char a_Stage)
Definition: ClientHandle.cpp:2272
cWorld::BroadcastPlayerListUpdateGameMode
virtual void BroadcastPlayerListUpdateGameMode(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:478
cWorld::BroadcastEntityLook
virtual void BroadcastEntityLook(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:309
cClientHandle::SendEntityProperties
void SendEntityProperties(const cEntity &a_Entity)
Definition: ClientHandle.cpp:2649
cWorld::BroadcastPlayerListRemovePlayer
virtual void BroadcastPlayerListRemovePlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:452
cWorld::IsDaylightCycleEnabled
virtual bool IsDaylightCycleEnabled(void) const
Is the daylight cycle enabled?
Definition: World.h:89
Entity.h
cClientHandle::IsDestroyed
bool IsDestroyed(void) const
Definition: ClientHandle.h:148
cClientHandle::SendBossBarUpdateHealth
void SendBossBarUpdateHealth(UInt32 a_UniqueID, float a_FractionFilled)
Definition: ClientHandle.cpp:2371
cClientHandle::SendPlayerListRemovePlayer
void SendPlayerListRemovePlayer(const cPlayer &a_Player)
Definition: ClientHandle.cpp:2822
cWorld::BroadcastSoundEffect
virtual void BroadcastSoundEffect(const AString &a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:543
cClientHandle::SendEntityEquipment
void SendEntityEquipment(const cEntity &a_Entity, short a_SlotNum, const cItem &a_Item)
Definition: ClientHandle.cpp:2600
cWorld::BroadcastPlayerListUpdatePing
virtual void BroadcastPlayerListUpdatePing() override
Definition: Broadcaster.cpp:491
cObjective::Score
int Score
Definition: Scoreboard.h:35
cClientHandle::SendSoundEffect
void SendSoundEffect(const AString &a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
Definition: ClientHandle.cpp:3064
cWorld
Definition: World.h:47
cClientHandle::SendScoreboardObjective
void SendScoreboardObjective(const AString &a_Name, const AString &a_DisplayName, Byte a_Mode)
Definition: ClientHandle.cpp:3001
cClientHandle::SendEntityPosition
void SendEntityPosition(const cEntity &a_Entity)
Definition: ClientHandle.cpp:2640
cWorld::BroadcastParticleEffect
virtual void BroadcastParticleEffect(const AString &a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:400
cEntity::GetChunkZ
int GetChunkZ(void) const
Definition: Entity.h:208
cEntity::GetChunkX
int GetChunkX(void) const
Definition: Entity.h:207
cClientHandle::SendPlayerListUpdateGameMode
void SendPlayerListUpdateGameMode(const cPlayer &a_Player)
Definition: ClientHandle.cpp:2840
cWorld::BroadcastEntityProperties
void BroadcastEntityProperties(const cEntity &a_Entity)
Definition: Broadcaster.cpp:348
EntityAnimation
EntityAnimation
Definition: Defines.h:456
cWorld::BroadcastRemoveEntityEffect
virtual void BroadcastRemoveEntityEffect(const cEntity &a_Entity, int a_EffectID, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:504
World.h
cItem
Definition: Item.h:36
eWeather
eWeather
Definition: Defines.h:159
cWorld::BroadcastPlayerListHeaderFooter
virtual void BroadcastPlayerListHeaderFooter(const cCompositeChat &a_Header, const cCompositeChat &a_Footer) override
Definition: Broadcaster.cpp:439
cWorld::BroadcastScoreboardObjective
virtual void BroadcastScoreboardObjective(const AString &a_Name, const AString &a_DisplayName, Byte a_Mode) override
Definition: Broadcaster.cpp:517
cClientHandle::SendPlayerListHeaderFooter
void SendPlayerListHeaderFooter(const cCompositeChat &a_Header, const cCompositeChat &a_Footer)
Definition: ClientHandle.cpp:2813
cClientHandle::SendScoreUpdate
void SendScoreUpdate(const AString &a_Objective, const AString &a_Player, cObjective::Score a_Score, Byte a_Mode)
Definition: ClientHandle.cpp:3010
cClientHandle::SendDetachEntity
void SendDetachEntity(const cEntity &a_Entity, const cEntity &a_PreviousVehicle)
Definition: ClientHandle.cpp:2559
cClientHandle::SendRemoveEntityEffect
void SendRemoveEntityEffect(const cEntity &a_Entity, int a_EffectID)
Definition: ClientHandle.cpp:2936
Byte
unsigned char Byte
Definition: Globals.h:158
cWorld::DoWithChunkAt
bool DoWithChunkAt(Vector3i a_BlockPos, cChunkCallback a_Callback)
Calls the callback for the chunk at the block position specified, with ChunkMapCS locked.
Definition: World.cpp:1446
BlockEntity.h
cWorld::BroadcastEntityMetadata
virtual void BroadcastEntityMetadata(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:322
cWorld::BroadcastEntityPosition
virtual void BroadcastEntityPosition(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:335
cWorld::GetWorldDate
cTickTimeLong GetWorldDate() const
Definition: World.cpp:500
cWorld::ShouldBroadcastDeathMessages
bool ShouldBroadcastDeathMessages(void) const
Definition: World.h:717
cWorld::DoWithChunk
bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback a_Callback)
Calls the callback for the chunk specified, with ChunkMapCS locked.
Definition: World.cpp:1437
BLOCKTYPE
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:41
Int8
signed char Int8
Definition: Globals.h:151
cWorld::BroadcastEntityAnimation
virtual void BroadcastEntityAnimation(const cEntity &a_Entity, EntityAnimation a_Animation, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:374
cClientHandle::SendDestroyEntity
void SendDestroyEntity(const cEntity &a_Entity)
Definition: ClientHandle.cpp:2550
ClientHandle.h
cClientHandle::SendEntityEffect
void SendEntityEffect(const cEntity &a_Entity, int a_EffectID, int a_Amplifier, int a_Duration)
Definition: ClientHandle.cpp:2591
cWorld::cLock
A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the dest...
Definition: World.h:58
cClientHandle::SendUnleashEntity
void SendUnleashEntity(const cEntity &a_Entity)
Definition: ClientHandle.cpp:2254
cWorld::BroadcastAttachEntity
virtual void BroadcastAttachEntity(const cEntity &a_Entity, const cEntity &a_Vehicle) override
Definition: Broadcaster.cpp:109
cChunk::GetAllClients
const auto & GetAllClients(void) const
Definition: Chunk.h:443
cPlayer::GetClientHandle
cClientHandle * GetClientHandle(void) const
Definition: Player.h:276
cWorld::BroadcastCollectEntity
virtual void BroadcastCollectEntity(const cEntity &a_Collected, const cEntity &a_Collector, unsigned a_Count, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:218
cEntity::SpawnOn
virtual void SpawnOn(cClientHandle &a_Client)=0
Descendants override this function to send a command to the specified client to spawn the entity on t...
cChunk
Definition: Chunk.h:35
cEntity
Definition: Entity.h:75
cChunkCoords
Definition: ChunkDef.h:55
cClientHandle::IsLoggedIn
bool IsLoggedIn(void) const
Definition: ClientHandle.h:137
cClientHandle::SendParticleEffect
void SendParticleEffect(const AString &a_ParticleName, Vector3f a_Source, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount)
Definition: ClientHandle.cpp:2759
cPlayer
Definition: Player.h:27
cClientHandle::SendEntityHeadLook
void SendEntityHeadLook(const cEntity &a_Entity)
Definition: ClientHandle.cpp:2609
cWorld::BroadcastEntityHeadLook
virtual void BroadcastEntityHeadLook(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:296
cWorld::BroadcastEntityEffect
virtual void BroadcastEntityEffect(const cEntity &a_Entity, int a_EffectID, int a_Amplifier, int a_Duration, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:270
cWorld::BroadcastBlockAction
virtual void BroadcastBlockAction(Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:122
cClientHandle::SendSoundParticleEffect
void SendSoundParticleEffect(const EffectID a_EffectID, Vector3i a_Source, int a_Data)
Definition: ClientHandle.cpp:3083
cClientHandle::SendDisplayObjective
void SendDisplayObjective(const AString &a_Objective, cScoreboard::eDisplaySlot a_Display)
Definition: ClientHandle.cpp:3019
cWorld::BroadcastChat
virtual void BroadcastChat(const AString &a_Message, const cClientHandle *a_Exclude=nullptr, eMessageType a_ChatPrefix=mtCustom) override
Definition: Broadcaster.cpp:187
eMessageType
eMessageType
Definition: Defines.h:350
cWorld::BroadcastPlayerListAddPlayer
virtual void BroadcastPlayerListAddPlayer(const cPlayer &a_Player, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:426
EffectID
EffectID
Definition: EffectID.h:5
cWorld::BroadcastBlockEntity
virtual void BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle *a_Exclude=nullptr) override
If there is a block entity at the specified coods, sends it to all clients except a_Exclude.
Definition: Broadcaster.cpp:148
cClientHandle::SendThunderbolt
void SendThunderbolt(Vector3i a_BlockPos)
Definition: ClientHandle.cpp:3128
cChunk::GetBlockEntity
cBlockEntity * GetBlockEntity(Vector3i a_AbsPos)
Returns the block entity at the specified (absolute) coords.
Definition: Chunk.cpp:1433
AString
std::string AString
Definition: StringUtils.h:11
cWorld::ForEachPlayer
virtual bool ForEachPlayer(cPlayerListCallback a_Callback) override
Calls the callback for each player in the list; returns true if all players processed,...
Definition: World.cpp:2252
Vector3
Definition: Vector3.h:10
cScoreboard::eDisplaySlot
eDisplaySlot
Definition: Scoreboard.h:203
cChunkCoords::m_ChunkZ
int m_ChunkZ
Definition: ChunkDef.h:59
cClientHandle::SendPlayerListUpdateDisplayName
void SendPlayerListUpdateDisplayName(const cPlayer &a_Player, const AString &a_CustomName)
Definition: ClientHandle.cpp:2831
cClientHandle::SendBlockAction
void SendBlockAction(Vector3i a_BlockPos, char a_Byte1, char a_Byte2, BLOCKTYPE a_BlockType)
Definition: ClientHandle.cpp:2263
cBlockEntity
Definition: BlockEntity.h:24
cClientHandle::SendChat
void SendChat(const AString &a_Message, eMessageType a_ChatPrefix, const AString &a_AdditionalData="")
Definition: ClientHandle.cpp:2389
Player.h
cWorld::BroadcastDestroyEntity
virtual void BroadcastDestroyEntity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:231
cWorld::BroadcastThunderbolt
virtual void BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:582
cWorld::BroadcastBlockBreakAnimation
virtual void BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, Int8 a_Stage, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:135
cWorld::BroadcastEntityVelocity
virtual void BroadcastEntityVelocity(const cEntity &a_Entity, const cClientHandle *a_Exclude=nullptr) override
Definition: Broadcaster.cpp:361
cWorld::BroadcastDetachEntity
virtual void BroadcastDetachEntity(const cEntity &a_Entity, const cEntity &a_PreviousVehicle) override
Definition: Broadcaster.cpp:244