keep the players directory celan
This commit is contained in:
parent
21b26ff396
commit
5e7b3bd8f7
|
@ -87,11 +87,9 @@ video::IImage* SGUITTGlyph::createGlyphImage(const FT_Bitmap& bits, video::IVide
|
|||
const u32 image_pitch = image->getPitch() / sizeof(u16);
|
||||
u16* image_data = (u16*)image->lock();
|
||||
u8* glyph_data = bits.buffer;
|
||||
for (s32 y = 0; y < bits.rows; ++y)
|
||||
{
|
||||
for (u32 y = 0; y < bits.rows; ++y) {
|
||||
u16* row = image_data;
|
||||
for (s32 x = 0; x < bits.width; ++x)
|
||||
{
|
||||
for (u32 x = 0; x < bits.width; ++x) {
|
||||
// Monochrome bitmaps store 8 pixels per byte. The left-most pixel is the bit 0x80.
|
||||
// So, we go through the data each bit at a time.
|
||||
if ((glyph_data[y * bits.pitch + (x / 8)] & (0x80 >> (x % 8))) != 0)
|
||||
|
@ -116,11 +114,9 @@ video::IImage* SGUITTGlyph::createGlyphImage(const FT_Bitmap& bits, video::IVide
|
|||
const u32 image_pitch = image->getPitch() / sizeof(u32);
|
||||
u32* image_data = (u32*)image->lock();
|
||||
u8* glyph_data = bits.buffer;
|
||||
for (s32 y = 0; y < bits.rows; ++y)
|
||||
{
|
||||
for (u32 y = 0; y < bits.rows; ++y) {
|
||||
u8* row = glyph_data;
|
||||
for (s32 x = 0; x < bits.width; ++x)
|
||||
{
|
||||
for (u32 x = 0; x < bits.width; ++x) {
|
||||
image_data[y * image_pitch + x] |= static_cast<u32>(255.0f * (static_cast<float>(*row++) / gray_count)) << 24;
|
||||
//data[y * image_pitch + x] |= ((u32)(*bitsdata++) << 24);
|
||||
}
|
||||
|
@ -460,7 +456,7 @@ CGUITTGlyphPage* CGUITTFont::getLastGlyphPage() const
|
|||
CGUITTGlyphPage* CGUITTFont::createGlyphPage(const u8& pixel_mode)
|
||||
{
|
||||
CGUITTGlyphPage* page = 0;
|
||||
|
||||
|
||||
// Name of our page.
|
||||
io::path name("TTFontGlyphPage_");
|
||||
name += tt_face->family_name;
|
||||
|
|
|
@ -301,23 +301,19 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
|||
core::map<Player*, bool> saved_players;
|
||||
|
||||
std::vector<fs::DirListNode> player_files = fs::GetDirListing(players_path);
|
||||
for(u32 i=0; i<player_files.size(); i++)
|
||||
{
|
||||
if(player_files[i].dir)
|
||||
for (u32 i=0; i<player_files.size(); i++) {
|
||||
if (player_files[i].dir)
|
||||
continue;
|
||||
|
||||
// Full path to this file
|
||||
std::string path = players_path + "/" + player_files[i].name;
|
||||
|
||||
//infostream<<"Checking player file "<<path<<std::endl;
|
||||
|
||||
// Load player to see what is its name
|
||||
ServerRemotePlayer testplayer;
|
||||
{
|
||||
// Open file and deserialize
|
||||
std::ifstream is(path.c_str(), std::ios_base::binary);
|
||||
if(is.good() == false)
|
||||
{
|
||||
if (is.good() == false) {
|
||||
infostream<<"Failed to read "<<path<<std::endl;
|
||||
continue;
|
||||
}
|
||||
|
@ -329,9 +325,8 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
|||
// Search for the player
|
||||
std::string playername = testplayer.getName();
|
||||
Player *player = getPlayer(playername.c_str());
|
||||
if(player == NULL)
|
||||
{
|
||||
infostream<<"Didn't find matching player, ignoring file "<<path<<std::endl;
|
||||
if (player == NULL) {
|
||||
fs::RecursiveDelete(path);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -341,8 +336,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
|||
{
|
||||
// Open file and serialize
|
||||
std::ofstream os(path.c_str(), std::ios_base::binary);
|
||||
if(os.good() == false)
|
||||
{
|
||||
if (os.good() == false) {
|
||||
infostream<<"Failed to overwrite "<<path<<std::endl;
|
||||
continue;
|
||||
}
|
||||
|
@ -351,41 +345,29 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
|||
}
|
||||
}
|
||||
|
||||
for(core::list<Player*>::Iterator i = m_players.begin();
|
||||
i != m_players.end(); i++)
|
||||
{
|
||||
for (core::list<Player*>::Iterator i = m_players.begin(); i != m_players.end(); i++) {
|
||||
Player *player = *i;
|
||||
if(saved_players.find(player) != NULL)
|
||||
{
|
||||
/*infostream<<"Player "<<player->getName()
|
||||
<<" was already saved."<<std::endl;*/
|
||||
if (saved_players.find(player) != NULL)
|
||||
continue;
|
||||
}
|
||||
std::string playername = player->getName();
|
||||
// Don't save unnamed player
|
||||
if(playername == "")
|
||||
{
|
||||
//infostream<<"Not saving unnamed player."<<std::endl;
|
||||
if (playername == "")
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
Find a sane filename
|
||||
*/
|
||||
if(string_allowed(playername, PLAYERNAME_ALLOWED_CHARS) == false)
|
||||
if (string_allowed(playername, PLAYERNAME_ALLOWED_CHARS) == false)
|
||||
playername = "player";
|
||||
std::string path = players_path + "/" + playername;
|
||||
bool found = false;
|
||||
for(u32 i=0; i<1000; i++)
|
||||
{
|
||||
if(fs::PathExists(path) == false)
|
||||
{
|
||||
for (u32 i=0; i<1000; i++) {
|
||||
if (fs::PathExists(path) == false) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
path = players_path + "/" + playername + itos(i);
|
||||
}
|
||||
if(found == false)
|
||||
{
|
||||
if (found == false) {
|
||||
infostream<<"Didn't find free file for player"<<std::endl;
|
||||
continue;
|
||||
}
|
||||
|
@ -395,8 +377,7 @@ void ServerEnvironment::serializePlayers(const std::string &savedir)
|
|||
<<path<<std::endl;*/
|
||||
// Open file and serialize
|
||||
std::ofstream os(path.c_str(), std::ios_base::binary);
|
||||
if(os.good() == false)
|
||||
{
|
||||
if (os.good() == false) {
|
||||
infostream<<"Failed to overwrite "<<path<<std::endl;
|
||||
continue;
|
||||
}
|
||||
|
@ -437,7 +418,7 @@ void ServerEnvironment::deSerializePlayers(const std::string &savedir)
|
|||
}
|
||||
|
||||
if (!string_allowed(testplayer.getName(), PLAYERNAME_ALLOWED_CHARS)) {
|
||||
infostream<<"Not loading player with invalid name: "<<testplayer.getName()<<std::endl;
|
||||
fs::RecursiveDelete(path);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue