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
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "BlockID.h"
#include "cWorld.h"
#include "cRedstone.h"
#include "cChunk.h"
#include "cClientHandle.h"
#include "cPickup.h"
#include "cBlockToPickup.h"
#include "cPlayer.h"
#include "cServer.h"
#include "cItem.h"
#include "cRoot.h"
#include "../iniFile/iniFile.h"
#include "cChunkMap.h"
#include "cSimulatorManager.h"
#include "cWaterSimulator.h"
#include "cLavaSimulator.h"
#include "cFireSimulator.h"
#include "cSandSimulator.h"
#include "cChicken.h"
#include "cSpider.h"
#include "cCow.h" //cow
#include "cSquid.h" //Squid
#include "cWolf.h" //wolf
#include "cSlime.h" //slime
#include "cSkeleton.h" //Skeleton
#include "cSilverfish.h" //Silverfish
#include "cPig.h" //pig
#include "cSheep.h" //sheep
#include "cZombie.h" //zombie
#include "cEnderman.h" //enderman
#include "cCreeper.h" //creeper
#include "cCavespider.h" //cavespider
#include "cGhast.h" //Ghast
#include "cZombiepigman.h" //Zombiepigman
#include "cGenSettings.h"
#include "cMakeDir.h"
#include "cChunkGenerator.h"
#include "MersenneTwister.h"
#include "cWorldGenerator_Test.h"
#include "cTracer.h"
#include "packets/cPacket_TimeUpdate.h"
#include "packets/cPacket_NewInvalidState.h"
#include "packets/cPacket_Thunderbolt.h"
#include "Vector3d.h"
#include <time.h>
#include "tolua++.h"
#ifndef _WIN32
#include <stdlib.h>
#endif
/// Up to this many m_SpreadQueue elements are handled each world tick
const int MAX_LIGHTING_SPREAD_PER_TICK = 10;
float cWorld::m_Time = 0.f;
char g_BlockLightValue[128];
char g_BlockSpreadLightFalloff[128];
bool g_BlockTransparent[128];
bool g_BlockOneHitDig[128];
bool g_BlockPistonBreakable[128];
#define RECI_RAND_MAX (1.f/RAND_MAX)
inline float fRadRand( float a_Radius )
{
MTRand r1;
return ((float)r1.rand() * RECI_RAND_MAX)*a_Radius - a_Radius*0.5f;
}
cWorld* cWorld::GetWorld()
{
LOGWARN("WARNING: Using deprecated function cWorld::GetWorld() use cRoot::Get()->GetWorld() instead!");
return cRoot::Get()->GetWorld();
}
cWorld::~cWorld()
{
{
cCSLock Lock(m_CSEntities);
while( m_AllEntities.begin() != m_AllEntities.end() )
{
cEntity* Entity = *m_AllEntities.begin();
m_AllEntities.remove( Entity );
if ( !Entity->IsDestroyed() )
{
Entity->Destroy();
}
delete Entity;
}
}
delete m_SimulatorManager;
delete m_SandSimulator;
delete m_WaterSimulator;
delete m_LavaSimulator;
delete m_FireSimulator;
m_Generator.Stop();
UnloadUnusedChunks();
m_Storage.WaitForFinish();
delete m_ChunkMap;
}
cWorld::cWorld( const AString & a_WorldName )
: m_SpawnMonsterTime( 0.f )
, m_RSList ( 0 )
, m_Weather ( 0 )
{
LOG("cWorld::cWorld(%s)", a_WorldName.c_str());
m_WorldName = a_WorldName;
cMakeDir::MakeDir(m_WorldName.c_str());
MTRand r1;
m_SpawnX = (double)((r1.randInt()%1000)-500);
m_SpawnY = 128;
m_SpawnZ = (double)((r1.randInt()%1000)-500);
m_WorldSeed = r1.randInt();
m_GameMode = 0;
AString GeneratorName;
AString StorageSchema;
cIniFile IniFile( m_WorldName + "/world.ini");
if( IniFile.ReadFile() )
{
m_SpawnX = IniFile.GetValueF("SpawnPosition", "X", m_SpawnX );
m_SpawnY = IniFile.GetValueF("SpawnPosition", "Y", m_SpawnY );
m_SpawnZ = IniFile.GetValueF("SpawnPosition", "Z", m_SpawnZ );
m_WorldSeed = IniFile.GetValueI("Seed", "Seed", m_WorldSeed );
m_GameMode = IniFile.GetValueI("GameMode", "GameMode", m_GameMode );
GeneratorName = IniFile.GetValue("Generator", "GeneratorName", "Default");
StorageSchema = IniFile.GetValue("Storage", "Schema", "Default");
}
else
{
IniFile.SetValueF("SpawnPosition", "X", m_SpawnX );
IniFile.SetValueF("SpawnPosition", "Y", m_SpawnY );
IniFile.SetValueF("SpawnPosition", "Z", m_SpawnZ );
IniFile.SetValueI("Seed", "Seed", m_WorldSeed );
IniFile.SetValueI("GameMode", "GameMode", m_GameMode );
IniFile.SetValue("Generator", "GeneratorName", "Default" );
if( !IniFile.WriteFile() )
{
LOG("WARNING: Could not write to %s/world.ini", a_WorldName.c_str());
}
}
LOGINFO("Seed: %i", m_WorldSeed );
m_Storage.Start(this, StorageSchema);
m_Generator.Start(this, GeneratorName);
cIniFile GenSettings("terrain.ini");
if( GenSettings.ReadFile() )
{
#define READ_INI_TERRAIN_VAL( var, type ) cGenSettings::var = (type)GenSettings.GetValueF("Terrain", #var, cGenSettings::var )
READ_INI_TERRAIN_VAL( HeightFreq1, float );
READ_INI_TERRAIN_VAL( HeightFreq2, float );
READ_INI_TERRAIN_VAL( HeightFreq3, float );
READ_INI_TERRAIN_VAL( HeightAmp1, float );
READ_INI_TERRAIN_VAL( HeightAmp2, float );
READ_INI_TERRAIN_VAL( HeightAmp3, float );
}
else
{
#define SET_INI_TERRAIN_VAL( var ) GenSettings.SetValueF("Terrain", #var, cGenSettings::var )
SET_INI_TERRAIN_VAL( HeightFreq1 );
SET_INI_TERRAIN_VAL( HeightFreq2 );
SET_INI_TERRAIN_VAL( HeightFreq3 );
SET_INI_TERRAIN_VAL( HeightAmp1 );
SET_INI_TERRAIN_VAL( HeightAmp2 );
SET_INI_TERRAIN_VAL( HeightAmp3 );
GenSettings.WriteFile();
}
m_bAnimals = true;
m_SpawnMonsterRate = 10;
cIniFile IniFile2("settings.ini");
if( IniFile2.ReadFile() )
{
m_bAnimals = IniFile2.GetValueB("Monsters", "AnimalsOn", true );
m_SpawnMonsterRate = (float)IniFile2.GetValueF("Monsters", "AnimalSpawnInterval", 10 );
SetMaxPlayers(IniFile2.GetValueI("Server", "MaxPlayers", 9001));
m_Description = IniFile2.GetValue("Server", "Description", "MCServer! - It's OVER 9000!").c_str();
}
m_ChunkMap = new cChunkMap(this );
m_Time = 0;
m_WorldTimeFraction = 0.f;
m_WorldTime = 0;
m_LastSave = 0;
m_LastUnload = 0;
//Simulators:
m_WaterSimulator = new cWaterSimulator( this );
m_LavaSimulator = new cLavaSimulator( this );
m_SandSimulator = new cSandSimulator(this);
m_FireSimulator = new cFireSimulator(this);
m_SimulatorManager = new cSimulatorManager();
m_SimulatorManager->RegisterSimulator(m_WaterSimulator, 6);
m_SimulatorManager->RegisterSimulator(m_LavaSimulator, 12);
m_SimulatorManager->RegisterSimulator(m_SandSimulator, 1);
m_SimulatorManager->RegisterSimulator(m_FireSimulator, 10);
memset( g_BlockLightValue, 0x0, 128 );
memset( g_BlockSpreadLightFalloff, 0xf, 128 ); // 0xf means total falloff
memset( g_BlockTransparent, 0x0, 128 );
memset( g_BlockOneHitDig, 0x0, 128 );
memset( g_BlockPistonBreakable, 0x0, 128 );
// Emissive blocks
g_BlockLightValue[ E_BLOCK_TORCH ] = 14;
g_BlockLightValue[ E_BLOCK_FIRE ] = 15;
g_BlockLightValue[ E_BLOCK_LAVA ] = 15;
g_BlockLightValue[ E_BLOCK_STATIONARY_LAVA ] = 15;
g_BlockLightValue[ E_BLOCK_GLOWSTONE ] = 15;
// Spread blocks
g_BlockSpreadLightFalloff[ E_BLOCK_AIR ] = 1;
g_BlockSpreadLightFalloff[ E_BLOCK_TORCH ] = 1;
g_BlockSpreadLightFalloff[ E_BLOCK_FIRE ] = 1;
g_BlockSpreadLightFalloff[ E_BLOCK_LAVA ] = 1;
g_BlockSpreadLightFalloff[ E_BLOCK_STATIONARY_LAVA ] = 1;
g_BlockSpreadLightFalloff[ E_BLOCK_WATER ] = 4; // Light in water dissapears faster
g_BlockSpreadLightFalloff[ E_BLOCK_STATIONARY_WATER ] = 4;
g_BlockSpreadLightFalloff[ E_BLOCK_LEAVES ] = 1;
g_BlockSpreadLightFalloff[ E_BLOCK_GLASS ] = 1;
g_BlockSpreadLightFalloff[ E_BLOCK_GLOWSTONE ] = 1;
g_BlockSpreadLightFalloff[ E_BLOCK_SIGN_POST ] = 1;
g_BlockSpreadLightFalloff[ E_BLOCK_WALLSIGN ] = 1;
// Transparent blocks
g_BlockTransparent[ E_BLOCK_AIR ] = true;
g_BlockTransparent[ E_BLOCK_GLASS ] = true;
g_BlockTransparent[ E_BLOCK_FIRE ] = true;
g_BlockTransparent[ E_BLOCK_ICE ] = true;
g_BlockTransparent[ E_BLOCK_TORCH ] = true;
g_BlockTransparent[ E_BLOCK_SIGN_POST ] = true;
g_BlockTransparent[ E_BLOCK_WALLSIGN ] = true;
// One hit break blocks
g_BlockOneHitDig[ E_BLOCK_SAPLING ] = true;
g_BlockOneHitDig[ E_BLOCK_YELLOW_FLOWER ] = true;
g_BlockOneHitDig[ E_BLOCK_RED_ROSE ] = true;
g_BlockOneHitDig[ E_BLOCK_BROWN_MUSHROOM ] = true;
g_BlockOneHitDig[ E_BLOCK_RED_MUSHROOM ] = true;
g_BlockOneHitDig[ E_BLOCK_TNT ] = true;
g_BlockOneHitDig[ E_BLOCK_TORCH ] = true;
g_BlockOneHitDig[ E_BLOCK_REDSTONE_WIRE ] = true;
g_BlockOneHitDig[ E_BLOCK_CROPS ] = true;
g_BlockOneHitDig[ E_BLOCK_REDSTONE_TORCH_OFF ] = true;
g_BlockOneHitDig[ E_BLOCK_REDSTONE_TORCH_ON ] = true;
g_BlockOneHitDig[ E_BLOCK_REEDS ] = true;
g_BlockOneHitDig[ E_BLOCK_REDSTONE_WIRE ] = true;
g_BlockOneHitDig[ E_BLOCK_REDSTONE_REPEATER_OFF ] = true;
g_BlockOneHitDig[ E_BLOCK_REDSTONE_REPEATER_ON ] = true;
g_BlockOneHitDig[ E_BLOCK_LOCKED_CHEST ] = true;
g_BlockOneHitDig [ E_BLOCK_FIRE ] = true;
// Blocks that breaks when pushed by piston
g_BlockPistonBreakable[ E_BLOCK_AIR ] = true;
g_BlockPistonBreakable[ E_BLOCK_STATIONARY_WATER ] = false; //This gave pistons the ability to drop water :D
g_BlockPistonBreakable[ E_BLOCK_WATER ] = false;
g_BlockPistonBreakable[ E_BLOCK_STATIONARY_LAVA ] = false;
g_BlockPistonBreakable[ E_BLOCK_LAVA ] = false;
g_BlockPistonBreakable[ E_BLOCK_BED ] = true;
g_BlockPistonBreakable[ E_BLOCK_COBWEB ] = true;
g_BlockPistonBreakable[ E_BLOCK_TALL_GRASS ] = true;
g_BlockPistonBreakable[ E_BLOCK_YELLOW_FLOWER ] = true;
g_BlockPistonBreakable[ E_BLOCK_BROWN_MUSHROOM ] = true;
g_BlockPistonBreakable[ E_BLOCK_RED_ROSE ] = true;
g_BlockPistonBreakable[ E_BLOCK_RED_MUSHROOM ] = true;
g_BlockPistonBreakable[ E_BLOCK_DEAD_BUSH ] = true;
g_BlockPistonBreakable[ E_BLOCK_TORCH ] = true;
g_BlockPistonBreakable[ E_BLOCK_FIRE ] = true;
g_BlockPistonBreakable[ E_BLOCK_REDSTONE_WIRE ] = true;
g_BlockPistonBreakable[ E_BLOCK_CROPS ] = true;
g_BlockPistonBreakable[ E_BLOCK_LADDER ] = true;
g_BlockPistonBreakable[ E_BLOCK_WOODEN_DOOR ] = true;
g_BlockPistonBreakable[ E_BLOCK_IRON_DOOR ] = true;
g_BlockPistonBreakable[ E_BLOCK_LEVER ] = true;
g_BlockPistonBreakable[ E_BLOCK_STONE_BUTTON ] = true;
g_BlockPistonBreakable[ E_BLOCK_REDSTONE_TORCH_ON ] = true;
g_BlockPistonBreakable[ E_BLOCK_REDSTONE_TORCH_OFF ]= true;
g_BlockPistonBreakable[ E_BLOCK_SNOW ] = true;
g_BlockPistonBreakable[ E_BLOCK_REEDS ] = true;
g_BlockPistonBreakable[ E_BLOCK_PUMPKIN_STEM ] = true;
g_BlockPistonBreakable[ E_BLOCK_MELON_STEM ] = true;
g_BlockPistonBreakable[ E_BLOCK_MELON ] = true;
g_BlockPistonBreakable[ E_BLOCK_PUMPKIN ] = true;
g_BlockPistonBreakable[ E_BLOCK_JACK_O_LANTERN ] = true;
g_BlockPistonBreakable[ E_BLOCK_VINES ] = true;
g_BlockPistonBreakable[ E_BLOCK_STONE_PRESSURE_PLATE ] = true;
g_BlockPistonBreakable[ E_BLOCK_WOODEN_PRESSURE_PLATE ] = true;
}
void cWorld::SetWeather( int Weather )
{
if (Weather == 2) { //thunder storm
m_Weather = 2;
cPacket_NewInvalidState WeatherPacket;
WeatherPacket.m_Reason = 1; //begin rain
Broadcast ( WeatherPacket );
CastThunderbolt ( 0, 0, 0 ); //start thunderstorm with a lightning strike at 0, 0, 0. >:D
}
if (Weather == 1) { //rainstorm
m_Weather = 1;
cPacket_NewInvalidState WeatherPacket;
WeatherPacket.m_Reason = 1; //begin rain
Broadcast ( WeatherPacket );
}
if (Weather == 0) { //sunny
m_Weather = 0;
cPacket_NewInvalidState WeatherPacket;
WeatherPacket.m_Reason = 2; //stop rain
Broadcast ( WeatherPacket );
}
}
void cWorld::CastThunderbolt ( int X, int Y, int Z )
{
cPacket_Thunderbolt ThunderboltPacket;
ThunderboltPacket.m_xLBPos = X;
ThunderboltPacket.m_yLBPos = Y;
ThunderboltPacket.m_zLBPos = Z;
Broadcast( ThunderboltPacket );
}
void cWorld::InitializeSpawn()
{
int ChunkX = 0, ChunkY = 0, ChunkZ = 0;
BlockToChunk( (int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ, ChunkX, ChunkY, ChunkZ );
int ViewDist = 20; // Always prepare an area 20 chunks across, no matter what the actual cClientHandle::VIEWDISTANCE is
LOG("Preparing spawn area in world \"%s\"", m_WorldName.c_str());
for (int x = 0; x < ViewDist; x++)
{
for (int z = 0; z < ViewDist; z++)
{
GetChunk( x + ChunkX-(ViewDist - 1) / 2, 0, z + ChunkZ-(ViewDist - 1) / 2 ); // Queue the chunk in the generator / loader
}
}
// TODO: Wait for the generator to finish generating these chunks
}
void cWorld::Tick(float a_Dt)
{
m_Time += a_Dt / 1000.f;
CurrentTick++;
bool bSendTime = false;
m_WorldTimeFraction += a_Dt / 1000.f;
while ( m_WorldTimeFraction > 1.f )
{
m_WorldTimeFraction -= 1.f;
m_WorldTime += 20;
bSendTime = true;
}
m_WorldTime %= 24000; // 24000 units in a day
if ( bSendTime )
{
Broadcast( cPacket_TimeUpdate( (m_WorldTime) ) );
}
{
cCSLock Lock(m_CSEntities);
for (cEntityList::iterator itr = m_AllEntities.begin(); itr != m_AllEntities.end();)
{
if ((*itr)->IsDestroyed())
{
LOG("Destroying entity #%i", (*itr)->GetUniqueID());
cEntity * RemoveMe = *itr;
itr = m_AllEntities.erase( itr );
m_RemoveEntityQueue.push_back( RemoveMe );
continue;
}
(*itr)->Tick(a_Dt);
itr++;
}
}
{
cCSLock Lock(m_CSLighting);
if (m_SpreadQueue.size() >= 50 )
{
LOGWARN("cWorld: Lots of lighting to do! Still %i chunks left!", m_SpreadQueue.size() );
}
int TimesSpreaded = 0;
while ( !m_SpreadQueue.empty() && TimesSpreaded < MAX_LIGHTING_SPREAD_PER_TICK ) // Do not choke the tick thread
{
cChunkPtr & Chunk = *m_SpreadQueue.begin();
//LOG("Spreading: %p", Chunk );
Chunk->SpreadLight( Chunk->pGetSkyLight() );
Chunk->SpreadLight( Chunk->pGetLight() );
m_SpreadQueue.pop_front();
TimesSpreaded++;
}
}
m_ChunkMap->Tick(a_Dt, m_TickRand);
GetSimulatorManager()->Simulate(a_Dt);
TickWeather(a_Dt);
// Asynchronously set blocks
FastSetBlockList FastSetBlockQueueCopy;
{
cCSLock Lock(m_CSFastSetBlock);
FastSetBlockQueueCopy = m_FastSetBlockQueue;
m_FastSetBlockQueue.clear();
}
for ( FastSetBlockList::iterator itr = FastSetBlockQueueCopy.begin(); itr != FastSetBlockQueueCopy.end(); ++itr )
{
sSetBlockData & SetBlockData = *itr;
FastSetBlock( SetBlockData.x, SetBlockData.y, SetBlockData.z, SetBlockData.BlockID, SetBlockData.BlockMeta ); // If unable to set block, it's added to FastSetBlockQueue again
}
if( m_Time - m_LastSave > 60 * 5 ) // Save each 5 minutes
{
SaveAllChunks();
}
if( m_Time - m_LastUnload > 10 ) // Unload every 10 seconds
{
UnloadUnusedChunks();
}
// Delete entities queued for removal:
for (cEntityList::iterator itr = m_RemoveEntityQueue.begin(); itr != m_RemoveEntityQueue.end(); ++itr)
{
delete *itr;
}
m_RemoveEntityQueue.clear();
TickSpawnMobs(a_Dt);
std::vector<int> m_RSList_copy(m_RSList);
m_RSList.clear();
std::vector<int>::const_iterator cii; // FIXME - Please rename this variable, WTF is cii??? Use human readable variable names or common abbreviations (i, idx, itr, iter)
for(cii=m_RSList_copy.begin(); cii!=m_RSList_copy.end();)
{
int tempX = *cii;cii++;
int tempY = *cii;cii++;
int tempZ = *cii;cii++;
int state = *cii;cii++;
if ( (state == 11111) && ( (int)GetBlock( tempX, tempY, tempZ ) == E_BLOCK_REDSTONE_TORCH_OFF ) )
{
FastSetBlock( tempX, tempY, tempZ, E_BLOCK_REDSTONE_TORCH_ON, (int)GetBlockMeta( tempX, tempY, tempZ ) );
cRedstone Redstone(this);
Redstone.ChangeRedstone( tempX, tempY, tempZ, true );
}
else if ( (state == 00000) && ( (int)GetBlock( tempX, tempY, tempZ ) == E_BLOCK_REDSTONE_TORCH_ON ) )
{
FastSetBlock( tempX, tempY, tempZ, E_BLOCK_REDSTONE_TORCH_OFF, (int)GetBlockMeta( tempX, tempY, tempZ ) );
cRedstone Redstone(this);
Redstone.ChangeRedstone( tempX, tempY, tempZ, false );
}
}
m_RSList_copy.erase(m_RSList_copy.begin(),m_RSList_copy.end());
}
void cWorld::TickWeather(float a_Dt)
{
if ( GetWeather() == 0 ) // if sunny
{
if( CurrentTick % 19 == 0 ) //every 20 ticks random weather
{
unsigned randWeather = (m_TickRand.randInt() % 10000);
if (randWeather == 0)
{
LOG("Starting Rainstorm!");
SetWeather ( 1 );
}
else if (randWeather == 1)
{
LOG("Starting Thunderstorm!");
SetWeather ( 2 );
}
}
}
if ( GetWeather() != 0 ) // if raining or thunderstorm
{
if ( CurrentTick % 19 == 0 ) // every 20 ticks random weather
{
unsigned randWeather = (m_TickRand.randInt() % 4999);
if (randWeather == 0) //2% chance per second
{
LOG("Back to sunny!");
SetWeather ( 0 );
}
else if ( (randWeather > 4000) && (GetWeather() != 2) ) // random chance for rainstorm to turn into thunderstorm.
{
LOG("Starting Thunderstorm!");
SetWeather ( 2 );
}
}
}
if ( GetWeather() == 2 ) // if thunderstorm
{
if (m_TickRand.randInt() % 199 == 0) // 0.5% chance per tick of thunderbolt
{
CastThunderbolt ( 0, 0, 0 ); // todo: find random possitions near players to cast thunderbolts.
}
}
}
void cWorld::TickSpawnMobs(float a_Dt)
{
if (!m_bAnimals || (m_Time - m_SpawnMonsterTime <= m_SpawnMonsterRate))
{
return;
}
m_SpawnMonsterTime = m_Time;
Vector3d SpawnPos;
{
cCSLock Lock(m_CSPlayers);
if ( m_Players.size() <= 0)
{
return;
}
int RandomPlayerIdx = m_TickRand.randInt() & m_Players.size();
cPlayerList::iterator itr = m_Players.begin();
for( int i = 1; i < RandomPlayerIdx; i++ )
{
itr++;
}
SpawnPos = (*itr)->GetPosition();
}
cMonster * Monster = NULL;
int dayRand = m_TickRand.randInt() % 6;
int nightRand = m_TickRand.randInt() % 10;
SpawnPos += Vector3d( (double)(m_TickRand.randInt() % 64) - 32, (double)(m_TickRand.randInt() % 64) - 32, (double)(m_TickRand.randInt() % 64) - 32 );
char Height = GetHeight( (int)SpawnPos.x, (int)SpawnPos.z );
if (m_WorldTime >= 12000 + 1000)
{
if (nightRand == 0) //random percent to spawn for night
Monster = new cSpider();
else if (nightRand == 1)
Monster = new cZombie();
else if (nightRand == 2)
Monster = new cEnderman();
else if (nightRand == 3)
Monster = new cCreeper();
else if (nightRand == 4)
Monster = new cCavespider();
else if (nightRand == 5)
Monster = new cGhast();
else if (nightRand == 6)
Monster = new cZombiepigman();
else if (nightRand == 7)
Monster = new cSlime();
else if (nightRand == 8)
Monster = new cSilverfish();
else if (nightRand == 9)
Monster = new cSkeleton();
//end random percent to spawn for night
}
else
{
if (dayRand == 0) //random percent to spawn for day
Monster = new cChicken();
else if (dayRand == 1)
Monster = new cCow();
else if (dayRand == 2)
Monster = new cPig();
else if (dayRand == 3)
Monster = new cSheep();
else if (dayRand == 4)
Monster = new cSquid();
else if (dayRand == 5)
Monster = new cWolf();
//end random percent to spawn for day
}
if( Monster )
{
Monster->Initialize( this );
Monster->TeleportTo( SpawnPos.x, (double)(Height) + 2, SpawnPos.z );
Monster->SpawnOn(0);
}
}
void cWorld::GrowTree( int a_X, int a_Y, int a_Z )
{
// new tree code, looks much better
// with help from seanj
// converted from php to lua then lua to c++
// build trunk
MTRand r1;
int trunk = r1.randInt() % (7 - 5 + 1) + 5;
for (int i = 0; i < trunk; i++)
{
if( GetBlock( a_X, a_Y + i, a_Z ) == E_BLOCK_AIR )
FastSetBlock( a_X, a_Y + i, a_Z, E_BLOCK_LOG, 0 );
}
// build tree
for (int j = 0; j < trunk; j++) {
int radius = trunk - j;
if (radius < 4) {
if (radius > 2) {
radius = 2;
}
for (int i = a_X - radius; i <= a_X + radius; i++) {
for (int k = a_Z-radius; k <= a_Z + radius; k++) {
// small chance to be missing a block to add a little random
if (k != a_Z || i != a_X && (r1.randInt() % 100 + 1) > 20) {
if( GetBlock( i, a_Y + j, k ) == E_BLOCK_AIR )
FastSetBlock(i, a_Y+j, k, E_BLOCK_LEAVES, 0 );
}
else {
//if( m_BlockType[ MakeIndex(i, TopY+j, k) ] == E_BLOCK_AIR )
// m_BlockType[ MakeIndex(i, TopY+j, k) ] = E_BLOCK_LEAVES;
}
}
}
if( GetBlock( a_X, a_Y+j, a_Z ) == E_BLOCK_AIR )
FastSetBlock( a_X, a_Y+j, a_Z, E_BLOCK_LOG, 0 );
}
}
// do the top
if( GetBlock( a_X+1, a_Y+trunk, a_Z ) == E_BLOCK_AIR )
FastSetBlock( a_X+1, a_Y+trunk, a_Z, E_BLOCK_LEAVES, 0 );
if( GetBlock( a_X-1, a_Y+trunk, a_Z ) == E_BLOCK_AIR )
FastSetBlock( a_X-1, a_Y+trunk, a_Z, E_BLOCK_LEAVES, 0 );
if( GetBlock( a_X, a_Y+trunk, a_Z+1 ) == E_BLOCK_AIR )
FastSetBlock( a_X, a_Y+trunk, a_Z+1, E_BLOCK_LEAVES, 0 );
if( GetBlock( a_X, a_Y+trunk, a_Z-1 ) == E_BLOCK_AIR )
FastSetBlock( a_X, a_Y+trunk, a_Z-1, E_BLOCK_LEAVES, 0 );
if( GetBlock( a_X, a_Y+trunk, a_Z ) == E_BLOCK_AIR )
FastSetBlock( a_X, a_Y+trunk, a_Z, E_BLOCK_LEAVES, 0 );
// end new tree code
}
void cWorld::UnloadUnusedChunks()
{
m_LastUnload = m_Time;
m_ChunkMap->UnloadUnusedChunks();
}
cChunkPtr cWorld::GetChunkOfBlock( int a_X, int a_Y, int a_Z )
{
int ChunkX, ChunkY, ChunkZ;
AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
return GetChunk( ChunkX, ChunkY, ChunkZ );
}
void cWorld::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
{
int ChunkX, ChunkY, ChunkZ, X = a_X, Y = a_Y, Z = a_Z;
AbsoluteToRelative( X, Y, Z, ChunkX, ChunkY, ChunkZ );
cChunkPtr Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
if ( Chunk->IsValid() )
{
Chunk->SetBlock(X, Y, Z, a_BlockType, a_BlockMeta );
this->GetSimulatorManager()->WakeUp(a_X, a_Y, a_Z);
}
// The chunk is not yet initialized, so it's probably far away from all players, no need to store this Meta change
}
void cWorld::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
{
int ChunkX, ChunkY, ChunkZ, X = a_X, Y = a_Y, Z = a_Z;
AbsoluteToRelative( X, Y, Z, ChunkX, ChunkY, ChunkZ );
cChunkPtr Chunk = GetChunkNoGen( ChunkX, ChunkY, ChunkZ );
if (Chunk->IsValid())
{
Chunk->FastSetBlock(X, Y, Z, a_BlockType, a_BlockMeta );
return;
}
// Unable to set block right now, try again later
cCSLock Lock(m_CSFastSetBlock);
m_FastSetBlockQueue.push_back( sSetBlockData( a_X, a_Y, a_Z, a_BlockType, a_BlockMeta ) );
}
char cWorld::GetBlock(int a_X, int a_Y, int a_Z)
{
int ChunkX, ChunkY, ChunkZ;
AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
cChunkPtr Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
if ( Chunk->IsValid() )
{
return Chunk->GetBlock(a_X, a_Y, a_Z);
}
return 0;
}
char cWorld::GetBlockMeta( int a_X, int a_Y, int a_Z )
{
int ChunkX, ChunkY, ChunkZ;
AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
cChunkPtr Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
if ( Chunk->IsValid() )
{
return Chunk->GetLight( Chunk->pGetMeta(), a_X, a_Y, a_Z );
}
return 0;
}
void cWorld::SetBlockMeta( int a_X, int a_Y, int a_Z, char a_MetaData )
{
int ChunkX, ChunkY, ChunkZ;
AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
cChunkPtr Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
if ( Chunk->IsValid() )
{
Chunk->SetLight( Chunk->pGetMeta(), a_X, a_Y, a_Z, a_MetaData );
Chunk->SendBlockTo( a_X, a_Y, a_Z, NULL );
}
// The chunk is not yet initialized, so it's probably far away from all players, no need to store this Meta change
}
bool cWorld::DigBlock( int a_X, int a_Y, int a_Z, cItem & a_PickupItem )
{
int PosX = a_X, PosY = a_Y, PosZ = a_Z, ChunkX, ChunkY, ChunkZ;
AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkY, ChunkZ );
cChunkPtr DestChunk = GetChunk( ChunkX, ChunkY, ChunkZ );
if (DestChunk->IsValid())
{
DestChunk->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, 0 );
GetSimulatorManager()->WakeUp(a_X, a_Y, a_Z);
if ( !a_PickupItem.IsEmpty() )
{
cPickup * Pickup = new cPickup( a_X * 32 + 16 + (int)fRadRand(16.f), a_Y * 32 + 16 + (int)fRadRand(16.f), a_Z * 32 + 16 + (int)fRadRand(16.f), a_PickupItem );
Pickup->Initialize( this );
}
}
return true;
}
void cWorld::SendBlockTo( int a_X, int a_Y, int a_Z, cPlayer * a_Player )
{
int ChunkX, ChunkY, ChunkZ;
AbsoluteToRelative( a_X, a_Y, a_Z, ChunkX, ChunkY, ChunkZ );
cChunkPtr Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
if (Chunk->IsValid())
{
Chunk->SendBlockTo( a_X, a_Y, a_Z, a_Player->GetClientHandle() );
}
}
// TODO: This interface is dangerous!
cBlockEntity * cWorld::GetBlockEntity( int a_X, int a_Y, int a_Z )
{
int PosX = a_X, PosY = a_Y, PosZ = a_Z, ChunkX, ChunkY, ChunkZ;
AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkY, ChunkZ );
cChunkPtr Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
if (Chunk->IsValid())
{
// TODO: return Chunk->GetBlockEntity( a_X, a_Y, a_Z );
}
return NULL;
}
char cWorld::GetHeight( int a_X, int a_Z )
{
int PosX = a_X, PosY = 0, PosZ = a_Z, ChunkX, ChunkY, ChunkZ;
AbsoluteToRelative( PosX, PosY, PosZ, ChunkX, ChunkY, ChunkZ );
cChunkPtr Chunk = GetChunk( ChunkX, ChunkY, ChunkZ );
if ( Chunk->IsValid())
{
return Chunk->GetHeight( PosX, PosZ );
}
return 0;
}
const double & cWorld::GetSpawnY(void)
{
m_SpawnY = (double)GetHeight( (int)m_SpawnX, (int)m_SpawnZ ) + 1.6f; // +1.6f eye height
return m_SpawnY;
}
void cWorld::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude)
{
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
if (((*itr)->GetClientHandle() == a_Exclude) || !(*itr)->GetClientHandle()->IsLoggedIn() )
{
continue;
}
(*itr)->GetClientHandle()->Send( a_Packet );
}
}
void cWorld::BroadcastToChunkOfBlock(int a_X, int a_Y, int a_Z, cPacket * a_Packet, cClientHandle * a_Exclude)
{
m_ChunkMap->BroadcastToChunkOfBlock(a_X, a_Y, a_Z, a_Packet, a_Exclude);
}
void cWorld::MarkChunkDirty (int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
m_ChunkMap->MarkChunkDirty (a_ChunkX, a_ChunkY, a_ChunkZ);
}
void cWorld::MarkChunkSaving(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
m_ChunkMap->MarkChunkSaving(a_ChunkX, a_ChunkY, a_ChunkZ);
}
void cWorld::MarkChunkSaved (int a_ChunkX, int a_ChunkY, int a_ChunkZ)
{
m_ChunkMap->MarkChunkSaved (a_ChunkX, a_ChunkY, a_ChunkZ);
}
void cWorld::ChunkDataLoaded(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities)
{
m_ChunkMap->ChunkDataLoaded(a_ChunkX, a_ChunkY, a_ChunkZ, a_BlockData, a_Entities, a_BlockEntities);
}
void cWorld::SetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities)
{
m_ChunkMap->SetChunkData(a_ChunkX, a_ChunkY, a_ChunkZ, a_BlockData, a_Entities, a_BlockEntities);
}
void cWorld::GetChunkData(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cChunkDataCallback * a_Callback)
{
m_ChunkMap->GetChunkData(a_ChunkX, a_ChunkY, a_ChunkZ, a_Callback);
}
bool cWorld::IsChunkValid(int a_ChunkX, int a_ChunkY, int a_ChunkZ) const
{
return m_ChunkMap->IsChunkValid(a_ChunkX, a_ChunkY, a_ChunkZ);
}
bool cWorld::HasChunkAnyClients(int a_ChunkX, int a_ChunkY, int a_ChunkZ) const
{
return m_ChunkMap->HasChunkAnyClients(a_ChunkX, a_ChunkY, a_ChunkZ);
}
void cWorld::SetMaxPlayers(int iMax)
{
m_MaxPlayers = MAX_PLAYERS;
if (iMax > 0 && iMax < MAX_PLAYERS)
{
m_MaxPlayers = iMax;
}
}
void cWorld::AddPlayer( cPlayer* a_Player )
{
cCSLock Lock(m_CSPlayers);
m_Players.remove( a_Player ); // Make sure the player is registered only once
m_Players.push_back( a_Player );
}
void cWorld::RemovePlayer( cPlayer* a_Player )
{
cCSLock Lock(m_CSPlayers);
m_Players.remove( a_Player );
}
bool cWorld::ForEachPlayer(cPlayerListCallback & a_Callback)
{
// Calls the callback for each player in the list
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
if (a_Callback.Item(*itr))
{
return false;
}
} // for itr - m_Players[]
return true;
}
// TODO: This interface is dangerous!
cPlayer* cWorld::GetPlayer( const char* a_PlayerName )
{
cPlayer* BestMatch = 0;
unsigned int MatchedLetters = 0;
unsigned int NumMatches = 0;
bool bPerfectMatch = false;
unsigned int NameLength = strlen( a_PlayerName );
cCSLock Lock(m_CSPlayers);
for (cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); itr++ )
{
std::string Name = (*itr)->GetName();
if( NameLength > Name.length() ) continue; // Definitely not a match
for (unsigned int i = 0; i < NameLength; i++)
{
char c1 = (char)toupper( a_PlayerName[i] );
char c2 = (char)toupper( Name[i] );
if( c1 == c2 )
{
if( i+1 > MatchedLetters )
{
MatchedLetters = i+1;
BestMatch = *itr;
}
if( i+1 == NameLength )
{
NumMatches++;
if( NameLength == Name.length() )
{
bPerfectMatch = true;
break;
}
}
}
else
{
if( BestMatch == *itr ) BestMatch = 0;
break;
}
if( bPerfectMatch )
break;
}
}
if ( NumMatches == 1 )
{
return BestMatch;
}
// More than one matches, so it's undefined. Return NULL instead
return NULL;
}
cPlayer * cWorld::FindClosestPlayer(const Vector3f & a_Pos, float a_SightLimit)
{
cTracer LineOfSight(this);
float ClosestDistance = a_SightLimit;
cPlayer* ClosestPlayer = NULL;
cCSLock Lock(m_CSPlayers);
for (cPlayerList::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
Vector3f Pos = (*itr)->GetPosition();
float Distance = (Pos - a_Pos).Length();
if (Distance <= a_SightLimit)
{
if (!LineOfSight.Trace(a_Pos,(Pos - a_Pos),(int)(Pos - a_Pos).Length()))
{
if (Distance < ClosestDistance)
{
ClosestDistance = Distance;
ClosestPlayer = *itr;
}
}
}
}
return ClosestPlayer;
}
void cWorld::SendPlayerList(cPlayer * a_DestPlayer)
{
// Sends the playerlist to a_DestPlayer
cCSLock Lock(m_CSPlayers);
for ( cPlayerList::iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
{
if (((*itr)->GetClientHandle() != NULL) && !((*itr)->GetClientHandle()->IsDestroyed()))
{
cPacket_PlayerListItem PlayerListItem((*itr)->GetColor() + (*itr)->GetName(), true, (*itr)->GetClientHandle()->GetPing());
a_DestPlayer->GetClientHandle()->Send( PlayerListItem );
}
}
}
bool cWorld::DoWithEntity( int a_UniqueID, cEntityCallback & a_Callback )
{
cCSLock Lock(m_CSEntities);
for (cEntityList::iterator itr = m_AllEntities.begin(); itr != m_AllEntities.end(); ++itr )
{
if( (*itr)->GetUniqueID() == a_UniqueID )
{
return a_Callback.Item(*itr);
}
} // for itr - m_AllEntities[]
return false;
}
void cWorld::RemoveEntityFromChunk(cEntity * a_Entity)
{
cChunkPtr Chunk = GetChunkOfBlock((int)(a_Entity->GetPosX()), (int)(a_Entity->GetPosY()), (int)(a_Entity->GetPosZ()));
Chunk->RemoveEntity(a_Entity);
}
void cWorld::SaveAllChunks()
{
LOG("Saving all chunks...");
m_LastSave = m_Time;
m_ChunkMap->SaveAllChunks();
LOG("Done saving chunks");
}
void cWorld::ReSpreadLighting( const cChunkPtr & a_Chunk )
{
cCSLock Lock(m_CSLighting);
m_SpreadQueue.remove( a_Chunk );
m_SpreadQueue.push_back( a_Chunk );
}
void cWorld::RemoveSpread( const cChunkPtr & a_Chunk )
{
cCSLock Lock(m_CSLighting);
m_SpreadQueue.remove( a_Chunk );
}
/************************************************************************/
/* Get and set */
/************************************************************************/
// void cWorld::AddClient( cClientHandle* a_Client )
// {
// m_m_Clients.push_back( a_Client );
// }
// cWorld::ClientList & cWorld::GetClients()
// {
// return m_m_Clients;
// }
void cWorld::AddEntity( cEntity* a_Entity )
{
cCSLock Lock(m_CSEntities);
m_AllEntities.push_back( a_Entity );
}
unsigned int cWorld::GetNumPlayers()
{
cCSLock Lock(m_CSPlayers);
return m_Players.size();
}
int cWorld::GetNumChunks(void) const
{
return m_ChunkMap->GetNumChunks();
}
|