1
0

You can now run multiple worlds by defining them in settings.ini . However there's no way to change worlds on the fly yet

Players are now stored in separate folder /players instead of in the world folder (!so move the folder!)
Fixed a memory leak/error in cPickup.cpp
Multiple worlds are stored in cRoot
cClientHandle lists are taken out of cWorld and now stored in cServer
Worlds now have names to distinguish them by
Some functions in the Core plugin now distinguish between worlds

git-svn-id: http://mc-server.googlecode.com/svn/trunk@40 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
faketruth
2011-11-01 21:57:08 +00:00
parent 4c4e9867eb
commit b5b920deda
18 changed files with 482 additions and 167 deletions

View File

@@ -15,6 +15,7 @@
#include "cItem.h"
#include "cTracer.h"
#include "cRoot.h"
#include "cMakeDir.h"
#include "packets/cPacket_NamedEntitySpawn.h"
#include "packets/cPacket_EntityLook.h"
@@ -86,13 +87,16 @@ cPlayer::cPlayer(cClientHandle* a_Client, const char* a_PlayerName)
if( !LoadFromDisk() )
{
m_Inventory->Clear();
SetPosX( cRoot::Get()->GetWorld()->GetSpawnX() ); // TODO - Get from the correct world?
SetPosY( cRoot::Get()->GetWorld()->GetSpawnY() );
SetPosZ( cRoot::Get()->GetWorld()->GetSpawnZ() );
SetPosX( cRoot::Get()->GetDefaultWorld()->GetSpawnX() );
SetPosY( cRoot::Get()->GetDefaultWorld()->GetSpawnY() );
SetPosZ( cRoot::Get()->GetDefaultWorld()->GetSpawnZ() );
}
}
//MoveToCorrectChunk();
cRoot::Get()->GetWorld()->AddPlayer( this ); // TODO - Add to correct world? Or get rid of this?
void cPlayer::Initialize( cWorld* a_World )
{
cPawn::Initialize( a_World );
GetWorld()->AddPlayer( this );
}
cPlayer::~cPlayer(void)
@@ -618,7 +622,7 @@ void cPlayer::TossItem( bool a_bDraggingItem, int a_Amount /* = 1 */ )
}
}
bool cPlayer::LoadFromDisk()
bool cPlayer::LoadFromDisk() // TODO - This should also get/set/whatever the correct world for this player
{
cIniFile IniFile("users.ini");
if( IniFile.ReadFile() )
@@ -653,7 +657,7 @@ bool cPlayer::LoadFromDisk()
}
char SourceFile[128];
sprintf_s(SourceFile, 128, "world/player/%s.json", m_pState->PlayerName.c_str() );
sprintf_s(SourceFile, 128, "players/%s.json", m_pState->PlayerName.c_str() );
FILE* f;
#ifdef _WIN32
@@ -696,7 +700,7 @@ bool cPlayer::LoadFromDisk()
m_Rot->z = (float)JSON_PlayerRotation[(unsigned int)2].asDouble();
}
m_Health = root.get("health", 0 ).asInt();
m_Health = (short)root.get("health", 0 ).asInt();
m_Inventory->LoadFromJson(root["inventory"]);
return true;
@@ -706,21 +710,7 @@ bool cPlayer::LoadFromDisk()
bool cPlayer::SaveToDisk()
{
#ifdef _WIN32
{ // Make sure some folders exist
SECURITY_ATTRIBUTES Attrib;
Attrib.nLength = sizeof(SECURITY_ATTRIBUTES);
Attrib.lpSecurityDescriptor = NULL;
Attrib.bInheritHandle = false;
::CreateDirectory("world", &Attrib);
::CreateDirectory("world/player", &Attrib);
}
#else
{
mkdir("world", S_IRWXU | S_IRWXG | S_IRWXO);
mkdir("world/player", S_IRWXU | S_IRWXG | S_IRWXO);
}
#endif
cMakeDir::MakeDir("players");
// create the JSON data
Json::Value JSON_PlayerPosition;
@@ -746,7 +736,7 @@ bool cPlayer::SaveToDisk()
std::string JsonData = writer.write( root );
char SourceFile[128];
sprintf_s(SourceFile, 128, "world/player/%s.json", m_pState->PlayerName.c_str() );
sprintf_s(SourceFile, 128, "players/%s.json", m_pState->PlayerName.c_str() );
FILE* f;
#ifdef _WIN32