summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-11-16 23:06:12 +0100
committerfaketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-11-16 23:06:12 +0100
commit8ad774790267b7fc76e187a122e37e44dd222e64 (patch)
tree54b969accc23bcabd5b0724e369872d5f67d644d
parentFixed boolean comparison. (diff)
downloadcuberite-8ad774790267b7fc76e187a122e37e44dd222e64.tar
cuberite-8ad774790267b7fc76e187a122e37e44dd222e64.tar.gz
cuberite-8ad774790267b7fc76e187a122e37e44dd222e64.tar.bz2
cuberite-8ad774790267b7fc76e187a122e37e44dd222e64.tar.lz
cuberite-8ad774790267b7fc76e187a122e37e44dd222e64.tar.xz
cuberite-8ad774790267b7fc76e187a122e37e44dd222e64.tar.zst
cuberite-8ad774790267b7fc76e187a122e37e44dd222e64.zip
Diffstat (limited to '')
-rw-r--r--source/GroupManager.cpp78
-rw-r--r--source/Root.cpp18
-rw-r--r--source/World.cpp2
-rw-r--r--source/WorldStorage/FastNBT.cpp9
-rw-r--r--source/WorldStorage/WSSAnvil.cpp2
5 files changed, 65 insertions, 44 deletions
diff --git a/source/GroupManager.cpp b/source/GroupManager.cpp
index 98357ffa9..912f1196c 100644
--- a/source/GroupManager.cpp
+++ b/source/GroupManager.cpp
@@ -39,53 +39,59 @@ cGroupManager::cGroupManager()
{
LOG("-- Loading Groups --");
cIniFile IniFile("groups.ini");
- if( IniFile.ReadFile() )
+ if (!IniFile.ReadFile())
{
- unsigned int NumKeys = IniFile.GetNumKeys();
- for( unsigned int i = 0; i < NumKeys; i++ )
- {
- std::string KeyName = IniFile.GetKeyName( i );
- cGroup* Group = GetGroup( KeyName.c_str() );
+ LOGINFO("groups.ini inaccessible, using groups.example.ini for defaults!");
+ IniFile.Path("groups.example.ini");
+ IniFile.ReadFile();
+ IniFile.Path("groups.ini");
+ IniFile.WriteFile();
+ }
- LOG("Loading group: %s", KeyName.c_str() );
+ unsigned int NumKeys = IniFile.GetNumKeys();
+ for( unsigned int i = 0; i < NumKeys; i++ )
+ {
+ std::string KeyName = IniFile.GetKeyName( i );
+ cGroup* Group = GetGroup( KeyName.c_str() );
- Group->SetName( KeyName );
- char Color = IniFile.GetValue( KeyName, "Color", "-" )[0];
- if( Color != '-' )
- Group->SetColor( cChatColor::MakeColor(Color) );
- else
- Group->SetColor( cChatColor::White );
+ LOG("Loading group: %s", KeyName.c_str() );
- std::string Commands = IniFile.GetValue( KeyName, "Commands", "" );
- if( Commands.size() > 0 )
+ Group->SetName( KeyName );
+ char Color = IniFile.GetValue( KeyName, "Color", "-" )[0];
+ if( Color != '-' )
+ Group->SetColor( cChatColor::MakeColor(Color) );
+ else
+ Group->SetColor( cChatColor::White );
+
+ std::string Commands = IniFile.GetValue( KeyName, "Commands", "" );
+ if( Commands.size() > 0 )
+ {
+ AStringVector Split = StringSplit( Commands, "," );
+ for( unsigned int i = 0; i < Split.size(); i++)
{
- AStringVector Split = StringSplit( Commands, "," );
- for( unsigned int i = 0; i < Split.size(); i++)
- {
- Group->AddCommand( Split[i] );
- //LOG("%s", Split[i].c_str() );
- }
+ Group->AddCommand( Split[i] );
+ //LOG("%s", Split[i].c_str() );
}
+ }
- std::string Permissions = IniFile.GetValue( KeyName, "Permissions", "" );
- if( Permissions.size() > 0 )
+ std::string Permissions = IniFile.GetValue( KeyName, "Permissions", "" );
+ if( Permissions.size() > 0 )
+ {
+ AStringVector Split = StringSplit( Permissions, "," );
+ for( unsigned int i = 0; i < Split.size(); i++)
{
- AStringVector Split = StringSplit( Permissions, "," );
- for( unsigned int i = 0; i < Split.size(); i++)
- {
- Group->AddPermission( Split[i] );
- LOGINFO("Permission: %s", Split[i].c_str() );
- }
+ Group->AddPermission( Split[i] );
+ LOGINFO("Permission: %s", Split[i].c_str() );
}
+ }
- std::string Groups = IniFile.GetValue( KeyName, "Inherits", "" );
- if( Groups.size() > 0 )
+ std::string Groups = IniFile.GetValue( KeyName, "Inherits", "" );
+ if( Groups.size() > 0 )
+ {
+ AStringVector Split = StringSplit( Groups, "," );
+ for( unsigned int i = 0; i < Split.size(); i++)
{
- AStringVector Split = StringSplit( Groups, "," );
- for( unsigned int i = 0; i < Split.size(); i++)
- {
- Group->InheritFrom( GetGroup( Split[i].c_str() ) );
- }
+ Group->InheritFrom( GetGroup( Split[i].c_str() ) );
}
}
}
diff --git a/source/Root.cpp b/source/Root.cpp
index 52a0f46ce..1ec7f0e59 100644
--- a/source/Root.cpp
+++ b/source/Root.cpp
@@ -125,13 +125,19 @@ void cRoot::Start(void)
IniFile.WriteFile();
cIniFile WebIniFile("webadmin.ini");
- if( WebIniFile.ReadFile() )
+ if (!WebIniFile.ReadFile())
{
- if (WebIniFile.GetValueB("WebAdmin", "Enabled", false ))
- {
- LOG("Creating WebAdmin...");
- m_WebAdmin = new cWebAdmin(8080);
- }
+ LOGINFO("webadmin.ini inaccessible, using webadmin.example.ini for defaults!");
+ WebIniFile.Path("webadmin.example.ini");
+ WebIniFile.ReadFile();
+ WebIniFile.Path("webadmin.ini");
+ WebIniFile.WriteFile();
+ }
+
+ if (WebIniFile.GetValueB("WebAdmin", "Enabled", false ))
+ {
+ LOG("Creating WebAdmin...");
+ m_WebAdmin = new cWebAdmin(8080);
}
LOG("Loading settings...");
diff --git a/source/World.cpp b/source/World.cpp
index 210fe30a0..6bb78a16c 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -366,7 +366,7 @@ void cWorld::InitializeSpawn(void)
BlockToChunk( (int)m_SpawnX, (int)m_SpawnY, (int)m_SpawnZ, ChunkX, ChunkY, ChunkZ );
// For the debugging builds, don't make the server build too much world upon start:
- #ifdef _DEBUG
+ #if defined(_DEBUG) || defined(ANDROID_NDK)
int ViewDist = 9;
#else
int ViewDist = 20; // Always prepare an area 20 chunks across, no matter what the actual cClientHandle::VIEWDISTANCE is
diff --git a/source/WorldStorage/FastNBT.cpp b/source/WorldStorage/FastNBT.cpp
index 397df036e..a81be9a89 100644
--- a/source/WorldStorage/FastNBT.cpp
+++ b/source/WorldStorage/FastNBT.cpp
@@ -503,17 +503,26 @@ void cFastNBTWriter::AddIntArray(const AString & a_Name, const int * a_Value, si
TagCommon(a_Name, TAG_IntArray);
Int32 len = htonl(a_NumElements);
m_Result.append((const char *)&len, 4);
+#if defined(ANDROID_NDK)
+ for (size_t i = 0; i < a_NumElements; i++)
+ {
+ int Element = htonl(a_Value[i]);
+ m_Result.append((const char *)&Element, 4);
+ }
+#else
int * Elements = (int *)(m_Result.data() + m_Result.size());
m_Result.append(a_NumElements * 4, (char)0);
for (size_t i = 0; i < a_NumElements; i++)
{
Elements[i] = htonl(a_Value[i]);
}
+#endif
}
+
void cFastNBTWriter::Finish(void)
{
ASSERT(m_CurrentStack == 0);
diff --git a/source/WorldStorage/WSSAnvil.cpp b/source/WorldStorage/WSSAnvil.cpp
index e588f53e7..e30b3c409 100644
--- a/source/WorldStorage/WSSAnvil.cpp
+++ b/source/WorldStorage/WSSAnvil.cpp
@@ -272,7 +272,7 @@ cWSSAnvil::cWSSAnvil(cWorld * a_World) :
ASSERT(TestParse.IsValid());
#endif // _DEBUG
- gzFile gz = gzopen(fnam.c_str(), "wb");
+ gzFile gz = gzopen((FILE_IO_PREFIX + fnam).c_str(), "wb");
if (gz != NULL)
{
gzwrite(gz, Writer.GetResult().data(), Writer.GetResult().size());