[ create a new paste ] login | about

Link: http://codepad.org/ZcYNgnCi    [ raw code | fork ]

Plain Text, pasted on Oct 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
From cdd96a2f06041e89604c97caeea951342ed1b2e1 Mon Sep 17 00:00:00 2001
From: Foghrye4 <foghrye4@gmail.com>
Date: Sat, 14 May 2016 23:05:57 +0300
Subject: [PATCH 1/2] Prevent attached player models from disappearing during
 area reload

Player models attached to e.g. boats can mysteriously dissapear if they inload due to zone-out and zone-in because child entities data is not updated when parent entity reloaded in area in client side.

This fix updates a server-side code, so server will send attached entity data to client to reinitialise then.

Fixes issue #3681
---
 src/content_cao.cpp   | 11 +++++++++++
 src/content_sao.cpp   | 18 ++++++++++++++++--
 src/genericobject.cpp | 12 ++++++++++++
 src/genericobject.h   |  5 ++++-
 4 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index d701e4f..896acac 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -1776,6 +1776,17 @@ void GenericCAO::processMessage(const std::string &data)
 			m_nametag->nametag_color = m_prop.nametag_color;
 		}
 	}
+	else if (cmd == GENERIC_CMD_SPAWN_INFANT) {
+		u16 child_id = readU16(is);
+		u8 type = readU8(is);
+
+		GenericCAO *childobj = m_env->getGenericCAO(child_id);
+		if (childobj == NULL) {
+			m_env->addActiveObject(child_id, type, deSerializeLongString(is));
+		} else {
+			childobj->initialize(deSerializeLongString(is));
+		}
+	}
 }
 
 /* \pre punchitem != NULL
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 53bf315..7618c60 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -376,7 +376,7 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
 		writeF1000(os, m_yaw);
 		writeS16(os, m_hp);
 
-		writeU8(os, 4 + m_bone_position.size()); // number of messages stuffed in here
+		writeU8(os, 4 + m_bone_position.size() + m_attachment_child_ids.size()); // number of messages stuffed in here
 		os<<serializeLongString(getPropertyPacket()); // message 1
 		os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
 		os<<serializeLongString(gob_cmd_update_animation(
@@ -385,6 +385,13 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
 			os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
 		}
 		os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
+		for (std::set<int>::const_iterator ii = m_attachment_child_ids.begin(); 
+				ii != m_attachment_child_ids.end(); ++ii) {
+			ServerActiveObject *obj = m_env->getActiveObject(*ii);
+			if(obj){
+				os<<serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(), obj->getClientInitializationData(protocol_version)));
+			}
+		}
 	}
 	else
 	{
@@ -855,7 +862,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
 		writeF1000(os, m_player->getYaw());
 		writeS16(os, getHP());
 
-		writeU8(os, 6 + m_bone_position.size()); // number of messages stuffed in here
+		writeU8(os, 6 + m_bone_position.size() + m_attachment_child_ids.size()); // number of messages stuffed in here
 		os<<serializeLongString(getPropertyPacket()); // message 1
 		os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
 		os<<serializeLongString(gob_cmd_update_animation(
@@ -868,6 +875,13 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
 				m_physics_override_jump, m_physics_override_gravity, m_physics_override_sneak,
 				m_physics_override_sneak_glitch)); // 5
 		os << serializeLongString(gob_cmd_update_nametag_attributes(m_prop.nametag_color)); // 6 (GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES) : Deprecated, for backwards compatibility only.
+		for (std::set<int>::const_iterator ii = m_attachment_child_ids.begin(); 
+				ii != m_attachment_child_ids.end(); ++ii) {
+			ServerActiveObject *obj = m_env->getActiveObject(*ii);
+			if (obj) {
+				os<<serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(), obj->getClientInitializationData(protocol_version)));
+			}
+		}
 	}
 	else
 	{
diff --git a/src/genericobject.cpp b/src/genericobject.cpp
index 368cae1..c4660cf 100644
--- a/src/genericobject.cpp
+++ b/src/genericobject.cpp
@@ -182,3 +182,15 @@ std::string gob_cmd_update_nametag_attributes(video::SColor color)
 	writeARGB8(os, color);
 	return os.str();
 }
+
+std::string gob_cmd_update_infant(u16 id, u8 type, std::string client_initialization_data)
+{
+	std::ostringstream os(std::ios::binary);
+	// command 
+	writeU8(os, GENERIC_CMD_SPAWN_INFANT);
+	// parameters
+	writeU16(os, id);
+	writeU8(os, type);
+	os<<serializeLongString(client_initialization_data);
+	return os.str();
+}
diff --git a/src/genericobject.h b/src/genericobject.h
index b925708..48e71db 100644
--- a/src/genericobject.h
+++ b/src/genericobject.h
@@ -35,7 +35,8 @@ enum GenericCMD {
 	GENERIC_CMD_SET_BONE_POSITION,
 	GENERIC_CMD_ATTACH_TO,
 	GENERIC_CMD_SET_PHYSICS_OVERRIDE,
-	GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES
+	GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES,
+	GENERIC_CMD_SPAWN_INFANT
 };
 
 #include "object_properties.h"
@@ -77,5 +78,7 @@ std::string gob_cmd_update_attachment(int parent_id, std::string bone, v3f posit
 
 std::string gob_cmd_update_nametag_attributes(video::SColor color);
 
+std::string gob_cmd_update_infant(u16 id, u8 type, std::string client_initialization_data);
+
 #endif
 

From 6711fdc7261da8b7690c2f03b1ebd1ecae985ac9 Mon Sep 17 00:00:00 2001
From: Foghrye4 <foghrye4@gmail.com>
Date: Sat, 8 Oct 2016 09:44:56 +0300
Subject: [PATCH 2/2] moving to UNORDERED_SET, code style

---
 src/content_cao.cpp | 398 ++++++++++++++++++++++++++--------------------------
 src/content_sao.cpp |  88 ++++++------
 src/content_sao.h   |   4 +-
 src/genericobject.h |   1 -
 4 files changed, 242 insertions(+), 249 deletions(-)

diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index 896acac..e1339fb 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -1477,7 +1477,7 @@ void GenericCAO::updateTextures(const std::string &mod)
 				}
 
 				buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, use_trilinear_filter);
-				buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
+			buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
 				buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
 			}
 		}
@@ -1572,220 +1572,216 @@ void GenericCAO::processMessage(const std::string &data)
 	std::istringstream is(data, std::ios::binary);
 	// command
 	u8 cmd = readU8(is);
-	if(cmd == GENERIC_CMD_SET_PROPERTIES)
-	{
-		m_prop = gob_read_set_properties(is);
-
-		m_selection_box = m_prop.collisionbox;
-		m_selection_box.MinEdge *= BS;
-		m_selection_box.MaxEdge *= BS;
-
-		m_tx_size.X = 1.0 / m_prop.spritediv.X;
-		m_tx_size.Y = 1.0 / m_prop.spritediv.Y;
-
-		if(!m_initial_tx_basepos_set){
-			m_initial_tx_basepos_set = true;
-			m_tx_basepos = m_prop.initial_sprite_basepos;
-		}
-
-		if ((m_is_player && !m_is_local_player) && m_prop.nametag == "")
-			m_prop.nametag = m_name;
-
-		expireVisuals();
-	}
-	else if(cmd == GENERIC_CMD_UPDATE_POSITION)
-	{
-		// Not sent by the server if this object is an attachment.
-		// We might however get here if the server notices the object being detached before the client.
-		m_position = readV3F1000(is);
-		m_velocity = readV3F1000(is);
-		m_acceleration = readV3F1000(is);
-		if(fabs(m_prop.automatic_rotate) < 0.001)
-			m_yaw = readF1000(is);
-		else
-			readF1000(is);
-		bool do_interpolate = readU8(is);
-		bool is_end_position = readU8(is);
-		float update_interval = readF1000(is);
-
-		// Place us a bit higher if we're physical, to not sink into
-		// the ground due to sucky collision detection...
-		if(m_prop.physical)
-			m_position += v3f(0,0.002,0);
-
-		if(getParent() != NULL) // Just in case
-			return;
-
-		if(do_interpolate)
-		{
-			if(!m_prop.physical)
-				pos_translator.update(m_position, is_end_position, update_interval);
-		} else {
-			pos_translator.init(m_position);
-		}
-		updateNodePos();
-	}
-	else if(cmd == GENERIC_CMD_SET_TEXTURE_MOD) {
-		std::string mod = deSerializeString(is);
-		updateTextures(mod);
-	}
-	else if(cmd == GENERIC_CMD_SET_SPRITE) {
-		v2s16 p = readV2S16(is);
-		int num_frames = readU16(is);
-		float framelength = readF1000(is);
-		bool select_horiz_by_yawpitch = readU8(is);
-
-		m_tx_basepos = p;
-		m_anim_num_frames = num_frames;
-		m_anim_framelength = framelength;
-		m_tx_select_horiz_by_yawpitch = select_horiz_by_yawpitch;
-
-		updateTexturePos();
-	}
-	else if(cmd == GENERIC_CMD_SET_PHYSICS_OVERRIDE) {
-		float override_speed = readF1000(is);
-		float override_jump = readF1000(is);
-		float override_gravity = readF1000(is);
-		// these are sent inverted so we get true when the server sends nothing
-		bool sneak = !readU8(is);
-		bool sneak_glitch = !readU8(is);
-
-
-		if(m_is_local_player)
-		{
-			LocalPlayer *player = m_env->getLocalPlayer();
-			player->physics_override_speed = override_speed;
-			player->physics_override_jump = override_jump;
-			player->physics_override_gravity = override_gravity;
-			player->physics_override_sneak = sneak;
-			player->physics_override_sneak_glitch = sneak_glitch;
-		}
-	}
-	else if(cmd == GENERIC_CMD_SET_ANIMATION) {
-		// TODO: change frames send as v2s32 value
-		v2f range = readV2F1000(is);
-		if (!m_is_local_player) {
-			m_animation_range = v2s32((s32)range.X, (s32)range.Y);
-			m_animation_speed = readF1000(is);
-			m_animation_blend = readF1000(is);
-			// these are sent inverted so we get true when the server sends nothing
-			m_animation_loop = !readU8(is);
-			updateAnimation();
-		} else {
-			LocalPlayer *player = m_env->getLocalPlayer();
-			if(player->last_animation == NO_ANIM)
+	switch (cmd) {
+		case GENERIC_CMD_SET_PROPERTIES:
+			m_prop = gob_read_set_properties(is);
+	
+			m_selection_box = m_prop.collisionbox;
+			m_selection_box.MinEdge *= BS;
+			m_selection_box.MaxEdge *= BS;
+	
+			m_tx_size.X = 1.0 / m_prop.spritediv.X;
+			m_tx_size.Y = 1.0 / m_prop.spritediv.Y;
+	
+			if (!m_initial_tx_basepos_set) {
+				m_initial_tx_basepos_set = true;
+				m_tx_basepos = m_prop.initial_sprite_basepos;
+			}
+	
+			if ((m_is_player && !m_is_local_player) && m_prop.nametag == "")
+				m_prop.nametag = m_name;
+
+			expireVisuals();
+			break;
+		case GENERIC_CMD_UPDATE_POSITION:
+			// Not sent by the server if this object is an attachment.
+			// We might however get here if the server notices the object being detached before the client.
+			m_position = readV3F1000(is);
+			m_velocity = readV3F1000(is);
+			m_acceleration = readV3F1000(is);
+			if (fabs(m_prop.automatic_rotate) < 0.001)
+				m_yaw = readF1000(is);
+			else
+				readF1000(is);
+			bool do_interpolate = readU8(is);
+			bool is_end_position = readU8(is);
+			float update_interval = readF1000(is);
+	
+			// Place us a bit higher if we're physical, to not sink into
+			// the ground due to sucky collision detection...
+			if (m_prop.physical)
+				m_position += v3f(0,0.002,0);
+
+			if (getParent()) // Just in case
+				return;
+
+			if (do_interpolate)
 			{
+				if (!m_prop.physical)
+					pos_translator.update(m_position, is_end_position, update_interval);
+			} else {
+				pos_translator.init(m_position);
+			}
+			updateNodePos();
+			break;
+		case GENERIC_CMD_SET_TEXTURE_MOD:
+			std::string mod = deSerializeString(is);
+			updateTextures(mod);
+			break;
+		case GENERIC_CMD_SET_SPRITE:
+			v2s16 p = readV2S16(is);
+			int num_frames = readU16(is);
+			float framelength = readF1000(is);
+			bool select_horiz_by_yawpitch = readU8(is);
+
+			m_tx_basepos = p;
+			m_anim_num_frames = num_frames;
+			m_anim_framelength = framelength;
+			m_tx_select_horiz_by_yawpitch = select_horiz_by_yawpitch;
+
+			updateTexturePos();
+			break;
+		case  GENERIC_CMD_SET_PHYSICS_OVERRIDE:
+			float override_speed = readF1000(is);
+			float override_jump = readF1000(is);
+			float override_gravity = readF1000(is);
+			// these are sent inverted so we get true when the server sends nothing
+			bool sneak = !readU8(is);
+			bool sneak_glitch = !readU8(is);
+			if (m_is_local_player) {
+				LocalPlayer *player = m_env->getLocalPlayer();
+				player->physics_override_speed = override_speed;
+				player->physics_override_jump = override_jump;
+				player->physics_override_gravity = override_gravity;
+				player->physics_override_sneak = sneak;
+				player->physics_override_sneak_glitch = sneak_glitch;
+			}
+			break;
+		case  GENERIC_CMD_SET_ANIMATION:
+			// TODO: change frames send as v2s32 value
+			v2f range = readV2F1000(is);
+			if (!m_is_local_player) {
 				m_animation_range = v2s32((s32)range.X, (s32)range.Y);
 				m_animation_speed = readF1000(is);
 				m_animation_blend = readF1000(is);
 				// these are sent inverted so we get true when the server sends nothing
 				m_animation_loop = !readU8(is);
-			}
-			// update animation only if local animations present
-			// and received animation is unknown (except idle animation)
-			bool is_known = false;
-			for (int i = 1;i<4;i++)
-			{
-				if(m_animation_range.Y == player->local_animations[i].Y)
-					is_known = true;
-			}
-			if(!is_known ||
-					(player->local_animations[1].Y + player->local_animations[2].Y < 1))
-			{
+				updateAnimation();
+			} else {
+				LocalPlayer *player = m_env->getLocalPlayer();
+				if (player->last_animation == NO_ANIM) {
+					m_animation_range = v2s32((s32)range.X, (s32)range.Y);
+					m_animation_speed = readF1000(is);
+					m_animation_blend = readF1000(is);
+					// these are sent inverted so we get true when the server sends nothing
+					m_animation_loop = !readU8(is);
+				}
+				// update animation only if local animations present
+				// and received animation is unknown (except idle animation)
+				bool is_known = false;
+				for (int i = 1; i < 4; i++) {
+					if (m_animation_range.Y == player->local_animations[i].Y)
+						is_known = true;
+				}
+				if (!is_known || (player->local_animations[1].Y + player->local_animations[2].Y < 1)) {
 					updateAnimation();
+				}
 			}
-		}
-	}
-	else if(cmd == GENERIC_CMD_SET_BONE_POSITION) {
-		std::string bone = deSerializeString(is);
-		v3f position = readV3F1000(is);
-		v3f rotation = readV3F1000(is);
-		m_bone_position[bone] = core::vector2d<v3f>(position, rotation);
-
-		updateBonePosition();
-	} else if (cmd == GENERIC_CMD_ATTACH_TO) {
-		u16 parentID = readS16(is);
-		u16 oldparent = m_env->attachement_parent_ids[getId()];
-		if (oldparent) {
-			m_children.erase(std::remove(m_children.begin(), m_children.end(),
-				getId()), m_children.end());
-		}
-		m_env->attachement_parent_ids[getId()] = parentID;
-		GenericCAO *parentobj = m_env->getGenericCAO(parentID);
-
-		if (parentobj) {
-			parentobj->m_children.push_back(getId());
-		}
-
-		m_attachment_bone = deSerializeString(is);
-		m_attachment_position = readV3F1000(is);
-		m_attachment_rotation = readV3F1000(is);
-
-		// localplayer itself can't be attached to localplayer
-		if (!m_is_local_player) {
-			m_attached_to_local = getParent() != NULL && getParent()->isLocalPlayer();
-			// Objects attached to the local player should be hidden by default
-			m_is_visible = !m_attached_to_local;
-		}
+			break;
+		case GENERIC_CMD_SET_BONE_POSITION:
+			std::string bone = deSerializeString(is);
+			v3f position = readV3F1000(is);
+			v3f rotation = readV3F1000(is);
+			m_bone_position[bone] = core::vector2d<v3f>(position, rotation);
+
+			updateBonePosition();
+			break;
+		case GENERIC_CMD_ATTACH_TO:
+			u16 parentID = readS16(is);
+			u16 oldparent = m_env->attachement_parent_ids[getId()];
+			if (oldparent) {
+				m_children.erase(std::remove(m_children.begin(), m_children.end(),
+					getId()), m_children.end());
+			}
+			m_env->attachement_parent_ids[getId()] = parentID;
+			GenericCAO *parentobj = m_env->getGenericCAO(parentID);
 
-		updateAttachments();
-	}
-	else if(cmd == GENERIC_CMD_PUNCHED) {
-		/*s16 damage =*/ readS16(is);
-		s16 result_hp = readS16(is);
+			if (parentobj) {
+				parentobj->m_children.push_back(getId());
+			}
 
-		// Use this instead of the send damage to not interfere with prediction
-		s16 damage = m_hp - result_hp;
+			m_attachment_bone = deSerializeString(is);
+			m_attachment_position = readV3F1000(is);
+			m_attachment_rotation = readV3F1000(is);
+	
+			// localplayer itself can't be attached to localplayer
+			if (!m_is_local_player) {
+				m_attached_to_local = getParent() != NULL && getParent()->isLocalPlayer();
+				// Objects attached to the local player should be hidden by default
+				m_is_visible = !m_attached_to_local;
+			}
 
-		m_hp = result_hp;
+			updateAttachments();
+			break;
+		case GENERIC_CMD_PUNCHED:
+			/*s16 damage =*/ readS16(is);
+			s16 result_hp = readS16(is);
+
+			// Use this instead of the send damage to not interfere with prediction
+			s16 damage = m_hp - result_hp;
+
+			m_hp = result_hp;
+
+			if (damage > 0) {
+				if (m_hp <= 0) {
+					// TODO: Execute defined fast response
+					// As there is no definition, make a smoke puff
+					ClientSimpleObject *simple = createSmokePuff(
+							m_smgr, m_env, m_position,
+							m_prop.visual_size * BS);
+					m_env->addSimpleObject(simple);
+				} else {
+					// TODO: Execute defined fast response
+					// Flashing shall suffice as there is no definition
+					m_reset_textures_timer = 0.05;
+					if(damage >= 2)
+						m_reset_textures_timer += 0.05 * damage;
+					updateTextures("^[brighten");
+				}
+			}
+			break;
+		case GENERIC_CMD_UPDATE_ARMOR_GROUPS:
+			m_armor_groups.clear();
+			int armor_groups_size = readU16(is);
+			for (int i = 0; i < armor_groups_size; i++) {
+				std::string name = deSerializeString(is);
+				int rating = readS16(is);
+				m_armor_groups[name] = rating;
+			}
+			break;
+		case GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES:
+			// Deprecated, for backwards compatibility only.
+			readU8(is); // version
+			m_prop.nametag_color = readARGB8(is);
+			if (m_nametag) {
+				m_nametag->nametag_color = m_prop.nametag_color;
+			}
+			break;
+		case GENERIC_CMD_SPAWN_INFANT:
+			u16 child_id = readU16(is);
+			u8 type = readU8(is);
 
-		if (damage > 0)
-		{
-			if (m_hp <= 0)
-			{
-				// TODO: Execute defined fast response
-				// As there is no definition, make a smoke puff
-				ClientSimpleObject *simple = createSmokePuff(
-						m_smgr, m_env, m_position,
-						m_prop.visual_size * BS);
-				m_env->addSimpleObject(simple);
+			if (GenericCAO *childobj = m_env->getGenericCAO(child_id)) {
+				childobj->initialize(deSerializeLongString(is));
 			} else {
-				// TODO: Execute defined fast response
-				// Flashing shall suffice as there is no definition
-				m_reset_textures_timer = 0.05;
-				if(damage >= 2)
-					m_reset_textures_timer += 0.05 * damage;
-				updateTextures("^[brighten");
+				m_env->addActiveObject(child_id, type, deSerializeLongString(is));
 			}
-		}
-	}
-	else if(cmd == GENERIC_CMD_UPDATE_ARMOR_GROUPS) {
-		m_armor_groups.clear();
-		int armor_groups_size = readU16(is);
-		for(int i=0; i<armor_groups_size; i++)
-		{
-			std::string name = deSerializeString(is);
-			int rating = readS16(is);
-			m_armor_groups[name] = rating;
-		}
-	} else if (cmd == GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES) {
-		// Deprecated, for backwards compatibility only.
-		readU8(is); // version
-		m_prop.nametag_color = readARGB8(is);
-		if (m_nametag != NULL) {
-			m_nametag->nametag_color = m_prop.nametag_color;
-		}
-	}
-	else if (cmd == GENERIC_CMD_SPAWN_INFANT) {
-		u16 child_id = readU16(is);
-		u8 type = readU8(is);
-
-		GenericCAO *childobj = m_env->getGenericCAO(child_id);
-		if (childobj == NULL) {
-			m_env->addActiveObject(child_id, type, deSerializeLongString(is));
-		} else {
-			childobj->initialize(deSerializeLongString(is));
-		}
+			break;
+		default:
+			warningstream<<FUNCTION_NAME
+				<<": unknown command or outdated client \""
+				<<cmd<<std::endl;
+			break
 	}
 }
 
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index 7618c60..0dfece9 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -9,7 +9,7 @@ the Free Software Foundation; either version 2.1 of the License, or
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU Lesser General Public License for more details.
 
 You should have received a copy of the GNU Lesser General Public License along
@@ -204,8 +204,8 @@ ServerActiveObject* LuaEntitySAO::create(ServerEnvironment *env, v3f pos,
 		}
 	}
 	// create object
-	infostream<<"LuaEntitySAO::create(name=\""<<name<<"\" state=\""
-			<<state<<"\")"<<std::endl;
+	infostream << "LuaEntitySAO::create(name=\"" << name << "\" state=\""
+			<< state << "\")" << std::endl;
 	LuaEntitySAO *sao = new LuaEntitySAO(env, pos, name, state);
 	sao->m_hp = hp;
 	sao->m_velocity = velocity;
@@ -369,7 +369,7 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
 	if(protocol_version >= 14)
 	{
 		writeU8(os, 1); // version
-		os<<serializeString(""); // name
+		os << serializeString(""); // name
 		writeU8(os, 0); // is_player
 		writeS16(os, getId()); //id
 		writeV3F1000(os, m_base_position);
@@ -377,33 +377,32 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
 		writeS16(os, m_hp);
 
 		writeU8(os, 4 + m_bone_position.size() + m_attachment_child_ids.size()); // number of messages stuffed in here
-		os<<serializeLongString(getPropertyPacket()); // message 1
-		os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
-		os<<serializeLongString(gob_cmd_update_animation(
+		os << serializeLongString(getPropertyPacket()); // message 1
+		os << serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
+		os << serializeLongString(gob_cmd_update_animation(
 			m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3
 		for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
-			os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
+			os << serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
 		}
-		os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
-		for (std::set<int>::const_iterator ii = m_attachment_child_ids.begin(); 
+		os << serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
+		for (UNORDERED_SET<int>::const_iterator ii = m_attachment_child_ids.begin(); 
 				ii != m_attachment_child_ids.end(); ++ii) {
-			ServerActiveObject *obj = m_env->getActiveObject(*ii);
-			if(obj){
-				os<<serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(), obj->getClientInitializationData(protocol_version)));
+			if (ServerActiveObject *obj = m_env->getActiveObject(*ii)) {
+				os << serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(), obj->getClientInitializationData(protocol_version)));
 			}
 		}
 	}
 	else
 	{
 		writeU8(os, 0); // version
-		os<<serializeString(""); // name
+		os << serializeString(""); // name
 		writeU8(os, 0); // is_player
 		writeV3F1000(os, m_base_position);
 		writeF1000(os, m_yaw);
 		writeS16(os, m_hp);
 		writeU8(os, 2); // number of messages stuffed in here
-		os<<serializeLongString(getPropertyPacket()); // message 1
-		os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
+		os << serializeLongString(getPropertyPacket()); // message 1
+		os << serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
 	}
 
 	// return result
@@ -412,19 +411,19 @@ std::string LuaEntitySAO::getClientInitializationData(u16 protocol_version)
 
 std::string LuaEntitySAO::getStaticData()
 {
-	verbosestream<<FUNCTION_NAME<<std::endl;
+	verbosestream << FUNCTION_NAME << std::endl;
 	std::ostringstream os(std::ios::binary);
 	// version
 	writeU8(os, 1);
 	// name
-	os<<serializeString(m_init_name);
+	os << serializeString(m_init_name);
 	// state
 	if(m_registered){
 		std::string state = m_env->getScriptIface()->
 			luaentity_GetStaticdata(m_id);
-		os<<serializeLongString(state);
+		os << serializeLongString(state);
 	} else {
-		os<<serializeLongString(m_init_state);
+		os << serializeLongString(m_init_state);
 	}
 	// hp
 	writeS16(os, m_hp);
@@ -524,11 +523,11 @@ float LuaEntitySAO::getMinimumSavedMovement()
 std::string LuaEntitySAO::getDescription()
 {
 	std::ostringstream os(std::ios::binary);
-	os<<"LuaEntitySAO at (";
-	os<<(m_base_position.X/BS)<<",";
-	os<<(m_base_position.Y/BS)<<",";
-	os<<(m_base_position.Z/BS);
-	os<<")";
+	os << "LuaEntitySAO at (";
+	os << (m_base_position.X/BS) << ",";
+	os << (m_base_position.Y/BS) << ",";
+	os << (m_base_position.Z/BS);
+	os << ")";
 	return os.str();
 }
 
@@ -619,7 +618,7 @@ void LuaEntitySAO::removeAttachmentChild(int child_id)
 	m_attachment_child_ids.erase(child_id);
 }
 
-std::set<int> LuaEntitySAO::getAttachmentChildIds()
+UNORDERED_SET<int> LuaEntitySAO::getAttachmentChildIds()
 {
 	return m_attachment_child_ids;
 }
@@ -855,7 +854,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
 	if(protocol_version >= 15)
 	{
 		writeU8(os, 1); // version
-		os<<serializeString(m_player->getName()); // name
+		os << serializeString(m_player->getName()); // name
 		writeU8(os, 1); // is_player
 		writeS16(os, getId()); //id
 		writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0));
@@ -863,37 +862,36 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
 		writeS16(os, getHP());
 
 		writeU8(os, 6 + m_bone_position.size() + m_attachment_child_ids.size()); // number of messages stuffed in here
-		os<<serializeLongString(getPropertyPacket()); // message 1
-		os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
-		os<<serializeLongString(gob_cmd_update_animation(
+		os << serializeLongString(getPropertyPacket()); // message 1
+		os << serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
+		os << serializeLongString(gob_cmd_update_animation(
 			m_animation_range, m_animation_speed, m_animation_blend, m_animation_loop)); // 3
 		for(std::map<std::string, core::vector2d<v3f> >::const_iterator ii = m_bone_position.begin(); ii != m_bone_position.end(); ++ii){
-			os<<serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
+			os << serializeLongString(gob_cmd_update_bone_position((*ii).first, (*ii).second.X, (*ii).second.Y)); // m_bone_position.size
 		}
-		os<<serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
-		os<<serializeLongString(gob_cmd_update_physics_override(m_physics_override_speed,
+		os << serializeLongString(gob_cmd_update_attachment(m_attachment_parent_id, m_attachment_bone, m_attachment_position, m_attachment_rotation)); // 4
+		os << serializeLongString(gob_cmd_update_physics_override(m_physics_override_speed,
 				m_physics_override_jump, m_physics_override_gravity, m_physics_override_sneak,
 				m_physics_override_sneak_glitch)); // 5
 		os << serializeLongString(gob_cmd_update_nametag_attributes(m_prop.nametag_color)); // 6 (GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES) : Deprecated, for backwards compatibility only.
-		for (std::set<int>::const_iterator ii = m_attachment_child_ids.begin(); 
+		for (UNORDERED_SET<int>::const_iterator ii = m_attachment_child_ids.begin(); 
 				ii != m_attachment_child_ids.end(); ++ii) {
-			ServerActiveObject *obj = m_env->getActiveObject(*ii);
-			if (obj) {
-				os<<serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(), obj->getClientInitializationData(protocol_version)));
+			if (ServerActiveObject *obj = m_env->getActiveObject(*ii)) {
+				os << serializeLongString(gob_cmd_update_infant(*ii, obj->getSendType(), obj->getClientInitializationData(protocol_version)));
 			}
 		}
 	}
 	else
 	{
 		writeU8(os, 0); // version
-		os<<serializeString(m_player->getName()); // name
+		os << serializeString(m_player->getName()); // name
 		writeU8(os, 1); // is_player
 		writeV3F1000(os, m_player->getPosition() + v3f(0,BS*1,0));
 		writeF1000(os, m_player->getYaw());
 		writeS16(os, getHP());
 		writeU8(os, 2); // number of messages stuffed in here
-		os<<serializeLongString(getPropertyPacket()); // message 1
-		os<<serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
+		os << serializeLongString(getPropertyPacket()); // message 1
+		os << serializeLongString(gob_cmd_update_armor_groups(m_armor_groups)); // 2
 	}
 
 	// return result
@@ -939,7 +937,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
 		((Server*)m_env->getGameDef())->SendMovePlayer(m_peer_id);
 	}
 
-	//dstream<<"PlayerSAO::step: dtime: "<<dtime<<std::endl;
+	//dstream << "PlayerSAO::step: dtime: "<<dtime<<std::endl;
 
 	// Set lag pool maximums based on estimated lag
 	const float LAG_POOL_MIN = 5.0;
@@ -1271,7 +1269,7 @@ void PlayerSAO::removeAttachmentChild(int child_id)
 	m_attachment_child_ids.erase(child_id);
 }
 
-std::set<int> PlayerSAO::getAttachmentChildIds()
+UNORDERED_SET<int> PlayerSAO::getAttachmentChildIds()
 {
 	return m_attachment_child_ids;
 }
@@ -1378,9 +1376,9 @@ bool PlayerSAO::checkMovementCheat()
 		if(m_move_pool.grab(required_time)){
 			m_last_good_position = m_player->getPosition();
 		} else {
-			actionstream<<"Player "<<m_player->getName()
-					<<" moved too fast; resetting position"
-					<<std::endl;
+			actionstream << "Player " << m_player->getName()
+					 << " moved too fast; resetting position"
+					 << std::endl;
 			m_player->setPosition(m_last_good_position);
 			cheated = true;
 		}
diff --git a/src/content_sao.h b/src/content_sao.h
index 44d40d3..8d5a3cb 100644
--- a/src/content_sao.h
+++ b/src/content_sao.h
@@ -116,7 +116,7 @@ class LuaEntitySAO : public ServerActiveObject
 	bool m_bone_position_sent;
 
 	int m_attachment_parent_id;
-	std::set<int> m_attachment_child_ids;
+	UNORDERED_SET<int> m_attachment_child_ids;
 	std::string m_attachment_bone;
 	v3f m_attachment_position;
 	v3f m_attachment_rotation;
@@ -325,7 +325,7 @@ class PlayerSAO : public ServerActiveObject
 	bool m_bone_position_sent;
 
 	int m_attachment_parent_id;
-	std::set<int> m_attachment_child_ids;
+	UNORDERED_SET<int> m_attachment_child_ids;
 	std::string m_attachment_bone;
 	v3f m_attachment_position;
 	v3f m_attachment_rotation;
diff --git a/src/genericobject.h b/src/genericobject.h
index 48e71db..11e4c10 100644
--- a/src/genericobject.h
+++ b/src/genericobject.h
@@ -81,4 +81,3 @@ std::string gob_cmd_update_nametag_attributes(video::SColor color);
 std::string gob_cmd_update_infant(u16 id, u8 type, std::string client_initialization_data);
 
 #endif
-



Create a new paste based on this one


Comments: