1
0

Updated VS2010 project files

Made monster spawning code in cWorld.cpp a bit more compact and readable
srand() is only supposed to be called once in the whole program, and it's already called in the constructor of cWorld so it doesn't have to be in cWorld::Tick()

git-svn-id: http://mc-server.googlecode.com/svn/trunk@14 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
faketruth 2011-10-26 13:27:16 +00:00
parent bcc1450ba9
commit 8e64a5d9ff
3 changed files with 203 additions and 110 deletions

View File

@ -223,17 +223,22 @@
<ItemGroup>
<ClCompile Include="..\Source\cAuthenticator.cpp" />
<ClCompile Include="..\source\cBlockingTCPLink.cpp" />
<ClCompile Include="..\source\cCavespider.cpp" />
<ClCompile Include="..\Source\cChicken.cpp" />
<ClCompile Include="..\source\cChunkLoader.cpp" />
<ClCompile Include="..\Source\cChunkMap.cpp" />
<ClCompile Include="..\source\cCow.cpp" />
<ClCompile Include="..\source\cCraftingWindow.cpp" />
<ClCompile Include="..\source\cCreeper.cpp" />
<ClCompile Include="..\source\cCriticalSection.cpp" />
<ClCompile Include="..\source\cCuboid.cpp" />
<ClCompile Include="..\source\cEnderman.cpp" />
<ClCompile Include="..\source\cEvent.cpp" />
<ClCompile Include="..\source\cFurnaceEntity.cpp" />
<ClCompile Include="..\Source\cFurnaceRecipe.cpp" />
<ClCompile Include="..\source\cFurnaceWindow.cpp" />
<ClCompile Include="..\source\cGenSettings.cpp" />
<ClCompile Include="..\source\cGhast.cpp" />
<ClCompile Include="..\Source\cGroup.cpp" />
<ClCompile Include="..\Source\cGroupManager.cpp" />
<ClCompile Include="..\Source\cHeartBeat.cpp" />
@ -244,16 +249,22 @@
<ClCompile Include="..\source\cMonsterConfig.cpp" />
<ClCompile Include="..\source\cNoise.cpp" />
<ClCompile Include="..\Source\cPawn.cpp" />
<ClCompile Include="..\source\cPig.cpp" />
<ClCompile Include="..\Source\cPluginManager.cpp" />
<ClCompile Include="..\Source\cRecipeChecker.cpp" />
<ClCompile Include="..\Source\cReferenceManager.cpp" />
<ClCompile Include="..\Source\cRoot.cpp" />
<ClCompile Include="..\Source\cSemaphore.cpp" />
<ClCompile Include="..\source\cServer.cpp" />
<ClCompile Include="..\source\cSheep.cpp" />
<ClCompile Include="..\Source\cSignEntity.cpp" />
<ClCompile Include="..\source\cSilverfish.cpp" />
<ClCompile Include="..\source\cSkeleton.cpp" />
<ClCompile Include="..\source\cSleep.cpp" />
<ClCompile Include="..\source\cSlime.cpp" />
<ClCompile Include="..\source\cSocket.cpp" />
<ClCompile Include="..\source\cSpider.cpp" />
<ClCompile Include="..\source\cSquid.cpp" />
<ClCompile Include="..\source\cStringMap.cpp" />
<ClCompile Include="..\Source\cTCPLink.cpp" />
<ClCompile Include="..\source\cThread.cpp" />
@ -263,6 +274,9 @@
<ClCompile Include="..\Source\cWebAdmin.cpp" />
<ClCompile Include="..\Source\cWebPlugin.cpp" />
<ClCompile Include="..\source\cWindow.cpp" />
<ClCompile Include="..\source\cWolf.cpp" />
<ClCompile Include="..\source\cZombie.cpp" />
<ClCompile Include="..\source\cZombiepigman.cpp" />
<ClCompile Include="..\Source\ManualBindings.cpp" />
<ClCompile Include="..\source\Matrix4f.cpp" />
<ClCompile Include="..\source\md5\md5.cpp" />
@ -333,15 +347,20 @@
<ClInclude Include="..\Source\BlockID.h" />
<ClInclude Include="..\Source\cAuthenticator.h" />
<ClInclude Include="..\source\cBlockingTCPLink.h" />
<ClInclude Include="..\source\cCavespider.h" />
<ClInclude Include="..\Source\cChicken.h" />
<ClInclude Include="..\source\cChunkLoader.h" />
<ClInclude Include="..\Source\cChunkMap.h" />
<ClInclude Include="..\source\cCow.h" />
<ClInclude Include="..\source\cCraftingWindow.h" />
<ClInclude Include="..\source\cCreeper.h" />
<ClInclude Include="..\Source\cCriticalSection.h" />
<ClInclude Include="..\source\cEnderman.h" />
<ClInclude Include="..\source\cEvent.h" />
<ClInclude Include="..\source\cFurnaceEntity.h" />
<ClInclude Include="..\Source\cFurnaceRecipe.h" />
<ClInclude Include="..\source\cFurnaceWindow.h" />
<ClInclude Include="..\source\cGhast.h" />
<ClInclude Include="..\Source\cGroup.h" />
<ClInclude Include="..\Source\cGroupManager.h" />
<ClInclude Include="..\Source\cHeartBeat.h" />
@ -353,17 +372,23 @@
<ClInclude Include="..\source\cMonsterConfig.h" />
<ClInclude Include="..\source\cNoise.h" />
<ClInclude Include="..\Source\cPawn.h" />
<ClInclude Include="..\source\cPig.h" />
<ClInclude Include="..\Source\cPluginManager.h" />
<ClInclude Include="..\Source\cRecipeChecker.h" />
<ClInclude Include="..\Source\cReferenceManager.h" />
<ClInclude Include="..\Source\cRoot.h" />
<ClInclude Include="..\Source\cSemaphore.h" />
<ClInclude Include="..\source\cServer.h" />
<ClInclude Include="..\source\cSheep.h" />
<ClInclude Include="..\Source\cSign.h" />
<ClInclude Include="..\Source\cSignEntity.h" />
<ClInclude Include="..\source\cSilverfish.h" />
<ClInclude Include="..\source\cSkeleton.h" />
<ClInclude Include="..\source\cSleep.h" />
<ClInclude Include="..\source\cSlime.h" />
<ClInclude Include="..\source\cSocket.h" />
<ClInclude Include="..\source\cSpider.h" />
<ClInclude Include="..\source\cSquid.h" />
<ClInclude Include="..\source\cStairs.h" />
<ClInclude Include="..\source\cStringMap.h" />
<ClInclude Include="..\Source\cTCPLink.h" />
@ -378,6 +403,9 @@
<ClInclude Include="..\Source\cWebPlugin.h" />
<ClInclude Include="..\source\cWindow.h" />
<ClInclude Include="..\source\cWindowOwner.h" />
<ClInclude Include="..\source\cWolf.h" />
<ClInclude Include="..\source\cZombie.h" />
<ClInclude Include="..\source\cZombiepigman.h" />
<ClInclude Include="..\source\Endianness.h" />
<ClInclude Include="..\Source\FileDefine.h" />
<ClInclude Include="..\Source\LuaFunctions.h" />

View File

@ -322,6 +322,48 @@
<Filter Include="Packets\cPacket_Ping">
<UniqueIdentifier>{b5725a7d-f912-47c7-b6f0-8efca7c0279c}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cCavespider">
<UniqueIdentifier>{e40e3231-e432-48fc-9958-d00f7486ee73}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cCow">
<UniqueIdentifier>{b07e3ca3-b50d-4c47-8ba3-c2678c0af71a}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cCreeper">
<UniqueIdentifier>{610c2aba-740a-49cc-ad03-a0613190daf8}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cEnderman">
<UniqueIdentifier>{00cab5c0-0d12-418c-b1a4-20c71db757a8}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cGhast">
<UniqueIdentifier>{0bc1c838-402d-4f7e-81a3-81d184590879}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cPig">
<UniqueIdentifier>{bfc926d1-ba9c-48ef-82c8-2e9b41b7119a}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cSheep">
<UniqueIdentifier>{43e6c131-1a12-4f06-9d71-3cf96e35eae5}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cSilverfish">
<UniqueIdentifier>{1d900af2-8976-4aae-9f6d-35c2debcc049}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cSkeleton">
<UniqueIdentifier>{eb718e91-e244-477c-81a7-1648d7b08cde}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cSlime">
<UniqueIdentifier>{420de544-79bb-4ccb-be49-eec9cf5e5a7e}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cSquid">
<UniqueIdentifier>{ee4c0e9a-7754-4b15-a2c9-abf7f6476ce7}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cWolf">
<UniqueIdentifier>{70bb6f00-107b-483f-9778-b315adbdc7c7}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cZombie">
<UniqueIdentifier>{58339a4b-e78c-48db-b4d5-8bd94fb4a9bc}</UniqueIdentifier>
</Filter>
<Filter Include="cEntity\cPawn\cMonster\cZombiepigman">
<UniqueIdentifier>{e4620b72-4739-4233-b326-47d4b5ca23d2}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\source\cServer.cpp">
@ -427,9 +469,6 @@
<ClCompile Include="..\Source\cRoot.cpp">
<Filter>cRoot</Filter>
</ClCompile>
<ClCompile Include="..\Source\cMonster.cpp">
<Filter>cEntity\cPawn\cMonster</Filter>
</ClCompile>
<ClCompile Include="..\Source\cPawn.cpp">
<Filter>cEntity\cPawn</Filter>
</ClCompile>
@ -643,6 +682,51 @@
<ClCompile Include="..\source\cSocket.cpp">
<Filter>Threading\cSocket</Filter>
</ClCompile>
<ClCompile Include="..\source\cCavespider.cpp">
<Filter>cEntity\cPawn\cMonster\cCavespider</Filter>
</ClCompile>
<ClCompile Include="..\source\cCow.cpp">
<Filter>cEntity\cPawn\cMonster\cCow</Filter>
</ClCompile>
<ClCompile Include="..\source\cCreeper.cpp">
<Filter>cEntity\cPawn\cMonster\cCreeper</Filter>
</ClCompile>
<ClCompile Include="..\source\cEnderman.cpp">
<Filter>cEntity\cPawn\cMonster\cEnderman</Filter>
</ClCompile>
<ClCompile Include="..\source\cGhast.cpp">
<Filter>cEntity\cPawn\cMonster\cGhast</Filter>
</ClCompile>
<ClCompile Include="..\Source\cMonster.cpp">
<Filter>cEntity\cPawn\cMonster</Filter>
</ClCompile>
<ClCompile Include="..\source\cPig.cpp">
<Filter>cEntity\cPawn\cMonster\cPig</Filter>
</ClCompile>
<ClCompile Include="..\source\cSheep.cpp">
<Filter>cEntity\cPawn\cMonster\cSheep</Filter>
</ClCompile>
<ClCompile Include="..\source\cSilverfish.cpp">
<Filter>cEntity\cPawn\cMonster\cSilverfish</Filter>
</ClCompile>
<ClCompile Include="..\source\cSkeleton.cpp">
<Filter>cEntity\cPawn\cMonster\cSkeleton</Filter>
</ClCompile>
<ClCompile Include="..\source\cSlime.cpp">
<Filter>cEntity\cPawn\cMonster\cSlime</Filter>
</ClCompile>
<ClCompile Include="..\source\cSquid.cpp">
<Filter>cEntity\cPawn\cMonster\cSquid</Filter>
</ClCompile>
<ClCompile Include="..\source\cWolf.cpp">
<Filter>cEntity\cPawn\cMonster\cWolf</Filter>
</ClCompile>
<ClCompile Include="..\source\cZombie.cpp">
<Filter>cEntity\cPawn\cMonster\cZombie</Filter>
</ClCompile>
<ClCompile Include="..\source\cZombiepigman.cpp">
<Filter>cEntity\cPawn\cMonster\cZombiepigman</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\source\cServer.h">
@ -780,9 +864,6 @@
<ClInclude Include="..\Source\cRoot.h">
<Filter>cRoot</Filter>
</ClInclude>
<ClInclude Include="..\Source\cMonster.h">
<Filter>cEntity\cPawn\cMonster</Filter>
</ClInclude>
<ClInclude Include="..\Source\cPawn.h">
<Filter>cEntity\cPawn</Filter>
</ClInclude>
@ -1002,6 +1083,51 @@
<ClInclude Include="..\source\packets\cPacket_Ping.h">
<Filter>Packets\cPacket_Ping</Filter>
</ClInclude>
<ClInclude Include="..\source\cCavespider.h">
<Filter>cEntity\cPawn\cMonster\cCavespider</Filter>
</ClInclude>
<ClInclude Include="..\source\cCow.h">
<Filter>cEntity\cPawn\cMonster\cCow</Filter>
</ClInclude>
<ClInclude Include="..\source\cCreeper.h">
<Filter>cEntity\cPawn\cMonster\cCreeper</Filter>
</ClInclude>
<ClInclude Include="..\source\cEnderman.h">
<Filter>cEntity\cPawn\cMonster\cEnderman</Filter>
</ClInclude>
<ClInclude Include="..\source\cGhast.h">
<Filter>cEntity\cPawn\cMonster\cGhast</Filter>
</ClInclude>
<ClInclude Include="..\Source\cMonster.h">
<Filter>cEntity\cPawn\cMonster</Filter>
</ClInclude>
<ClInclude Include="..\source\cPig.h">
<Filter>cEntity\cPawn\cMonster\cPig</Filter>
</ClInclude>
<ClInclude Include="..\source\cSheep.h">
<Filter>cEntity\cPawn\cMonster\cSheep</Filter>
</ClInclude>
<ClInclude Include="..\source\cSilverfish.h">
<Filter>cEntity\cPawn\cMonster\cSilverfish</Filter>
</ClInclude>
<ClInclude Include="..\source\cSkeleton.h">
<Filter>cEntity\cPawn\cMonster\cSkeleton</Filter>
</ClInclude>
<ClInclude Include="..\source\cSlime.h">
<Filter>cEntity\cPawn\cMonster\cSlime</Filter>
</ClInclude>
<ClInclude Include="..\source\cSquid.h">
<Filter>cEntity\cPawn\cMonster\cSquid</Filter>
</ClInclude>
<ClInclude Include="..\source\cWolf.h">
<Filter>cEntity\cPawn\cMonster\cWolf</Filter>
</ClInclude>
<ClInclude Include="..\source\cZombie.h">
<Filter>cEntity\cPawn\cMonster\cZombie</Filter>
</ClInclude>
<ClInclude Include="..\source\cZombiepigman.h">
<Filter>cEntity\cPawn\cMonster\cZombiepigman</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\source\AllToLua.pkg">

View File

@ -330,26 +330,9 @@ void cWorld::Tick(float a_Dt)
m_SpawnMonsterTime = m_Time;
if( m_pState->m_Players.size() > 0 )
{
cMonster *Monster = 0;
cChicken *Chicken;
cCow *Cow;
cPig *Pig;
cSheep *Sheep;
cSquid *Squid;
cWolf *Wolf;
cSpider *Spider;
cZombie *Zombie;
cEnderman *Enderman;
cCreeper *Creeper;
cGhast *Ghast;
cCavespider *Cavespider;
cZombiepigman *Zombiepigman;
cSkeleton *Skeleton;
cSlime *Slime;
cSilverfish *Silverfish;
srand ( time(NULL) ); //added mob code
//srand ( time(NULL) ); // Only seed random ONCE! Is already done in the cWorld constructor
int dayRand = rand() % 6; //added mob code
int nightRand = rand() % 10; //added mob code
@ -363,95 +346,51 @@ void cWorld::Tick(float a_Dt)
SpawnPos += Vector3d( (double)(rand()%64)-32, (double)(rand()%64)-32, (double)(rand()%64)-32 );
char Height = GetHeight( (int)SpawnPos.x, (int)SpawnPos.z );
//cMonster* Monster = new cChicken();
if(m_WorldTime >= 12000 + 1000) {
if (nightRand == 0) { //random percent to spawn for night
Spider = new cSpider();
Spider->Initialize();
Spider->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Spider->SpawnOn( 0 );
} else if (nightRand == 1) {
Zombie = new cZombie();
Zombie->Initialize();
Zombie->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Zombie->SpawnOn( 0 );
} else if (nightRand == 2) {
Enderman = new cEnderman();
Enderman->Initialize();
Enderman->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Enderman->SpawnOn( 0 );
} else if (nightRand == 3) {
Creeper = new cCreeper();
Creeper->Initialize();
Creeper->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Creeper->SpawnOn( 0 );
} else if (nightRand == 4) {
Cavespider = new cCavespider();
Cavespider->Initialize();
Cavespider->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Cavespider->SpawnOn( 0 );
} else if (nightRand == 5) {
Ghast = new cGhast();
Ghast->Initialize();
Ghast->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Ghast->SpawnOn( 0 );
} else if (nightRand == 6) {
Zombiepigman = new cZombiepigman();
Zombiepigman->Initialize();
Zombiepigman->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Zombiepigman->SpawnOn( 0 );
} else if (nightRand == 7) {
Slime = new cSlime();
Slime->Initialize();
Slime->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Slime->SpawnOn( 0 );
} else if (nightRand == 8) {
Silverfish = new cSilverfish();
Silverfish->Initialize();
Silverfish->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Silverfish->SpawnOn( 0 );
} else if (nightRand == 9) {
Skeleton = new cSkeleton();
Skeleton->Initialize();
Skeleton->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Skeleton->SpawnOn( 0 );
} //end random percent to spawn for night
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
Chicken = new cChicken();
Chicken->Initialize();
Chicken->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Chicken->SpawnOn( 0 );
} else if (dayRand == 1) {
Cow = new cCow();
Cow->Initialize();
Cow->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Cow->SpawnOn( 0 );
} else if (dayRand == 2) {
Pig = new cPig();
Pig->Initialize();
Pig->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Pig->SpawnOn( 0 );
} else if (dayRand == 3) {
Sheep = new cSheep();
Sheep->Initialize();
Sheep->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Sheep->SpawnOn( 0 );
} else if (dayRand == 4) {
Squid = new cSquid();
Squid->Initialize();
Squid->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Squid->SpawnOn( 0 );
} else if (dayRand == 5) {
Wolf = new cWolf();
Wolf->Initialize();
Wolf->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Wolf->SpawnOn( 0 );
} //end random percent to spawn for day
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();
Monster->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
Monster->SpawnOn( 0 );
}
//Monster->TeleportTo( SpawnPos.x, (double)(Height)+2, SpawnPos.z );
//Monster->SpawnOn( 0 );
}
}
}