summaryrefslogtreecommitdiffstats
path: root/source/cWorld.cpp
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-11-01 22:57:08 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-11-01 22:57:08 +0100
commitb5b920dedaa62302795b0b8f3db84a0650d236e0 (patch)
treef46d1ec70d6519fff2a75f45c08fe37bf4b5538c /source/cWorld.cpp
parentforogt to update all of cPlayer.cpp for player based gamemode. (diff)
downloadcuberite-b5b920dedaa62302795b0b8f3db84a0650d236e0.tar
cuberite-b5b920dedaa62302795b0b8f3db84a0650d236e0.tar.gz
cuberite-b5b920dedaa62302795b0b8f3db84a0650d236e0.tar.bz2
cuberite-b5b920dedaa62302795b0b8f3db84a0650d236e0.tar.lz
cuberite-b5b920dedaa62302795b0b8f3db84a0650d236e0.tar.xz
cuberite-b5b920dedaa62302795b0b8f3db84a0650d236e0.tar.zst
cuberite-b5b920dedaa62302795b0b8f3db84a0650d236e0.zip
Diffstat (limited to 'source/cWorld.cpp')
-rw-r--r--source/cWorld.cpp68
1 files changed, 32 insertions, 36 deletions
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 29115d15e..3d85fc0fb 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -30,6 +30,7 @@
#include "cGhast.h" //Ghast
#include "cZombiepigman.h" //Zombiepigman
#include "cGenSettings.h"
+#include "cMakeDir.h"
#include "packets/cPacket_TimeUpdate.h"
@@ -42,7 +43,7 @@
#ifndef _WIN32
#include <stdlib.h>
-#include <sys/stat.h> // for mkdir
+//#include <sys/stat.h> // for mkdir
#include <sys/types.h>
#endif
@@ -70,6 +71,8 @@ struct cWorld::sWorldState
std::vector< unsigned int > m_ChunkBuffer;
cWorld::ChunkList m_SpreadQueue;
+
+ std::string WorldName;
};
cWorld* cWorld::GetWorld()
@@ -100,25 +103,14 @@ cWorld::~cWorld()
delete m_pState;
}
-cWorld::cWorld()
+cWorld::cWorld( const char* a_WorldName )
: m_pState( new sWorldState )
, m_SpawnMonsterTime( 0.f )
{
- LOG("cWorld::cWorld()");
+ LOG("cWorld::cWorld(%s)", a_WorldName);
+ m_pState->WorldName = a_WorldName;
-#ifdef _WIN32
- {
- SECURITY_ATTRIBUTES Attrib;
- Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
- Attrib.lpSecurityDescriptor = NULL;
- Attrib.bInheritHandle = false;
- ::CreateDirectory("world", &Attrib);
- }
-#else
- {
- mkdir("world", S_IRWXU | S_IRWXG | S_IRWXO);
- }
-#endif
+ cMakeDir::MakeDir(m_pState->WorldName.c_str());
srand( (unsigned int) time(0) );
m_SpawnX = (double)((rand()%10000)-5000);
@@ -126,7 +118,7 @@ cWorld::cWorld()
m_SpawnZ = (double)((rand()%10000)-5000);
m_WorldSeed = rand();
- cIniFile IniFile("world/world.ini");
+ cIniFile IniFile( m_pState->WorldName + "/world.ini");
if( IniFile.ReadFile() )
{
m_SpawnX = IniFile.GetValueF("SpawnPosition", "X", m_SpawnX );
@@ -142,7 +134,7 @@ cWorld::cWorld()
IniFile.SetValueI("Seed", "Seed", m_WorldSeed );
if( !IniFile.WriteFile() )
{
- LOG("WARNING: Could not write to world/world.ini");
+ LOG("WARNING: Could not write to %s/world.ini", a_WorldName);
}
}
LOGINFO("Seed: %i", m_WorldSeed );
@@ -184,7 +176,7 @@ cWorld::cWorld()
m_Time = 0;
m_WorldTimeFraction = 0.f;
m_WorldTime = 0;
- m_GameMode = 1;
+ m_GameMode = 0;
m_LastSave = 0;
m_LastUnload = 0;
m_ClientHandleCriticalSection = new cCriticalSection();
@@ -696,15 +688,15 @@ cEntity* cWorld::GetEntity( int a_UniqueID )
return 0;
}
-void cWorld::RemoveClient( cClientHandle* a_Client )
-{
- m_pState->m_Clients.remove( a_Client );
- if( a_Client )
- {
- delete a_Client;
- a_Client = 0;
- }
-}
+// void cWorld::RemoveClient( cClientHandle* a_Client )
+// {
+// m_pState->m_Clients.remove( a_Client );
+// if( a_Client )
+// {
+// delete a_Client;
+// a_Client = 0;
+// }
+// }
void cWorld::RemoveEntity( cEntity* a_Entity )
{
@@ -783,14 +775,14 @@ void cWorld::RemoveSpread( cChunk* a_Chunk )
/************************************************************************/
/* Get and set */
/************************************************************************/
-void cWorld::AddClient( cClientHandle* a_Client )
-{
- m_pState->m_Clients.push_back( a_Client );
-}
-cWorld::ClientList & cWorld::GetClients()
-{
- return m_pState->m_Clients;
-}
+// void cWorld::AddClient( cClientHandle* a_Client )
+// {
+// m_pState->m_Clients.push_back( a_Client );
+// }
+// cWorld::ClientList & cWorld::GetClients()
+// {
+// return m_pState->m_Clients;
+// }
cWorld::EntityList & cWorld::GetEntities()
{
return m_pState->m_AllEntities;
@@ -812,3 +804,7 @@ void cWorld::AddToRemoveEntityQueue( cEntity & a_Entity )
m_pState->m_AllEntities.remove( &a_Entity);
m_pState->m_RemoveEntityQueue.push_back( &a_Entity );
}
+const char* cWorld::GetName()
+{
+ return m_pState->WorldName.c_str();
+} \ No newline at end of file