mirror of
https://github.com/moparisthebest/minetest
synced 2025-01-11 05:38:01 -05:00
Fix usage of destroyed mutex
Also fix a memory leak Fix overloaded virtual warning in Player::move() Remove some trailing whitespace
This commit is contained in:
parent
699e066bea
commit
b4247dff2e
@ -453,41 +453,43 @@ void ServerEnvironment::savePlayer(const std::string &playername)
|
|||||||
|
|
||||||
Player *ServerEnvironment::loadPlayer(const std::string &playername)
|
Player *ServerEnvironment::loadPlayer(const std::string &playername)
|
||||||
{
|
{
|
||||||
std::string players_path = m_path_world + DIR_DELIM "players" DIR_DELIM;
|
|
||||||
|
|
||||||
RemotePlayer *player = static_cast<RemotePlayer*>(getPlayer(playername.c_str()));
|
|
||||||
bool newplayer = false;
|
bool newplayer = false;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
std::string players_path = m_path_world + DIR_DELIM "players" DIR_DELIM;
|
||||||
|
std::string path = players_path + playername;
|
||||||
|
|
||||||
|
RemotePlayer *player = static_cast<RemotePlayer *>(getPlayer(playername.c_str()));
|
||||||
if (!player) {
|
if (!player) {
|
||||||
player = new RemotePlayer(m_gamedef, playername.c_str());
|
player = new RemotePlayer(m_gamedef, "");
|
||||||
newplayer = true;
|
newplayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemotePlayer testplayer(m_gamedef, "");
|
|
||||||
std::string path = players_path + playername;
|
|
||||||
for (u32 i = 0; i < PLAYER_FILE_ALTERNATE_TRIES; i++) {
|
for (u32 i = 0; i < PLAYER_FILE_ALTERNATE_TRIES; i++) {
|
||||||
// Open file and deserialize
|
//// Open file and deserialize
|
||||||
std::ifstream is(path.c_str(), std::ios_base::binary);
|
std::ifstream is(path.c_str(), std::ios_base::binary);
|
||||||
if (!is.good()) {
|
if (!is.good())
|
||||||
return NULL;
|
continue;
|
||||||
}
|
player->deSerialize(is, path);
|
||||||
testplayer.deSerialize(is, path);
|
|
||||||
is.close();
|
is.close();
|
||||||
if (testplayer.getName() == playername) {
|
|
||||||
*player = testplayer;
|
if (player->getName() == playername) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = players_path + playername + itos(i);
|
path = players_path + playername + itos(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
infostream << "Player file for player " << playername
|
infostream << "Player file for player " << playername
|
||||||
<< " not found" << std::endl;
|
<< " not found" << std::endl;
|
||||||
|
if (newplayer)
|
||||||
|
delete player;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (newplayer) {
|
|
||||||
|
if (newplayer)
|
||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
}
|
|
||||||
player->setModified(false);
|
player->setModified(false);
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,9 @@ class PlayerSAO;
|
|||||||
struct HudElement;
|
struct HudElement;
|
||||||
class Environment;
|
class Environment;
|
||||||
|
|
||||||
|
// IMPORTANT:
|
||||||
|
// Do *not* perform an assignment or copy operation on a Player or
|
||||||
|
// RemotePlayer object! This will copy the lock held for HUD synchronization
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -102,7 +105,7 @@ public:
|
|||||||
virtual void move(f32 dtime, Environment *env, f32 pos_max_d)
|
virtual void move(f32 dtime, Environment *env, f32 pos_max_d)
|
||||||
{}
|
{}
|
||||||
virtual void move(f32 dtime, Environment *env, f32 pos_max_d,
|
virtual void move(f32 dtime, Environment *env, f32 pos_max_d,
|
||||||
std::list<CollisionInfo> *collision_info)
|
std::vector<CollisionInfo> *collision_info)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
v3f getSpeed()
|
v3f getSpeed()
|
||||||
|
Loading…
Reference in New Issue
Block a user