Borderstones always have valid owners.
(but what happens when clan is removed?!)
This commit is contained in:
parent
7adcebc137
commit
adbd11e4ed
@ -901,7 +901,7 @@ void Map::updateLighting(core::map<v3s16, MapBlock*> & a_blocks,
|
||||
/*
|
||||
*/
|
||||
void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
||||
core::map<v3s16, MapBlock*> &modified_blocks, std::string &player_name)
|
||||
core::map<v3s16, MapBlock*> &modified_blocks, std::string &player_name,NodeMetadata *initial_metadata)
|
||||
{
|
||||
/*PrintInfo(m_dout);
|
||||
m_dout<<DTIME<<"Map::addNodeAndUpdate(): p=("
|
||||
@ -909,6 +909,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
||||
|
||||
//j
|
||||
//one block may have only one border stone
|
||||
//this check is duplicated at Server::ProcessData, to prevent setting block owner and removing borderstone from inventory - but aborting borderstone placement.
|
||||
if(n.getContent() == CONTENT_BORDERSTONE)
|
||||
{
|
||||
MapBlock * block = getBlockNoCreate(getNodeBlockPos(p));
|
||||
@ -1030,7 +1031,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
||||
Add intial metadata
|
||||
*/
|
||||
|
||||
NodeMetadata *meta_proto = content_features(n).initial_metadata;
|
||||
NodeMetadata *meta_proto = initial_metadata ? initial_metadata : content_features(n).initial_metadata;
|
||||
if(meta_proto)
|
||||
{
|
||||
NodeMetadata *meta = meta_proto->clone();
|
||||
|
@ -209,7 +209,8 @@ public:
|
||||
These handle lighting but not faces.
|
||||
*/
|
||||
void addNodeAndUpdate(v3s16 p, MapNode n,
|
||||
core::map<v3s16, MapBlock*> &modified_blocks, std::string &player_name);
|
||||
core::map<v3s16, MapBlock*> &modified_blocks, std::string &player_name,
|
||||
NodeMetadata *initial_metadata=NULL);
|
||||
void removeNodeAndUpdate(v3s16 p,
|
||||
core::map<v3s16, MapBlock*> &modified_blocks);
|
||||
|
||||
|
@ -41,6 +41,7 @@ Player::Player():
|
||||
hp(20),
|
||||
peer_id(PEER_ID_INEXISTENT),
|
||||
clanOwner(0),
|
||||
lastClan(0),
|
||||
m_selected_item(0),
|
||||
m_pitch(0),
|
||||
m_yaw(0),
|
||||
|
@ -172,6 +172,7 @@ public:
|
||||
u16 clanOwner;
|
||||
bool canModify(const ClansManager* clansManager, Map* map, MapBlock* block, MapNode* node, v3s16* nodepos) const;
|
||||
v3f lastTeleportPos; //server: remember position player teleported to, to let him move away.
|
||||
u16 lastClan; //server: remember last clan put into borderstone
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -2787,11 +2787,46 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
return;
|
||||
}
|
||||
|
||||
MaterialItem *mitem = (MaterialItem*)item;
|
||||
|
||||
NodeMetadata *initial_metadata=NULL;
|
||||
u16 newowner=0;
|
||||
// Only allow borderstone if player already belongs to some clan
|
||||
if(mitem->getMaterial() == CONTENT_BORDERSTONE)
|
||||
{ if(player->lastClan && player->clans.find(player->lastClan) == player->clans.end())
|
||||
player->lastClan=0; // was invalid (no longer member?)
|
||||
if(!player->lastClan)
|
||||
{ if(player->clanOwner)
|
||||
player->lastClan=player->clanOwner;
|
||||
else
|
||||
if(!player->clans.empty())
|
||||
player->lastClan=*player->clans.begin();
|
||||
}
|
||||
if(!player->lastClan)
|
||||
{
|
||||
actionstream<<player->getName()<<" failed to put borderstone"<<std::endl;
|
||||
try{
|
||||
SendChatMessage(peer_id,L"Server: You need to join or create a clan to use borderstones.");
|
||||
}
|
||||
catch(con::PeerNotFoundException &e)
|
||||
{}
|
||||
return;
|
||||
}
|
||||
actionstream<<player->getName()<<" will put cornerstone for clan "
|
||||
<<player->lastClan
|
||||
<<" ["<<m_env.clansManager.clanNameNoEx(player->lastClan)<<"]"<<std::endl;
|
||||
MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(getNodeBlockPos(p_over));
|
||||
assert(block != NULL);
|
||||
if(block->getOwner()) return; //already has owner!
|
||||
|
||||
newowner=player->lastClan;
|
||||
initial_metadata=new SignNodeMetadata("Property of "+m_env.clansManager.clanNameNoEx(player->lastClan));
|
||||
}
|
||||
|
||||
// Reset build time counter
|
||||
getClient(peer_id)->m_time_from_building = 0.0;
|
||||
|
||||
// Create node data
|
||||
MaterialItem *mitem = (MaterialItem*)item;
|
||||
MapNode n;
|
||||
n.setContent(mitem->getMaterial());
|
||||
|
||||
@ -2855,7 +2890,22 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
MapEditEventIgnorer ign(&m_ignore_map_edit_events);
|
||||
|
||||
std::string p_name = std::string(player->getName());
|
||||
m_env.getMap().addNodeAndUpdate(p_over, n, modified_blocks, p_name);
|
||||
m_env.getMap().addNodeAndUpdate(p_over, n, modified_blocks, p_name, initial_metadata);
|
||||
if(initial_metadata) delete initial_metadata;
|
||||
if(newowner)
|
||||
{
|
||||
MapBlock *block = m_env.getMap().getBlockNoCreateNoEx(getNodeBlockPos(p_over));
|
||||
assert(block != NULL);
|
||||
block->setOwner(newowner);
|
||||
// force update for all clients
|
||||
for(core::map<u16, RemoteClient*>::Iterator
|
||||
i = m_clients.getIterator();
|
||||
i.atEnd()==false; i++)
|
||||
{
|
||||
RemoteClient *client = i.getNode()->getValue();
|
||||
if(client) client->SetBlockNotSent(getNodeBlockPos(p_over));
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
Set blocks not sent to far players
|
||||
@ -3061,25 +3111,30 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||
}
|
||||
u16 clan = (u16)i_clan;*/
|
||||
|
||||
bool nullclan = false;
|
||||
if(clanName == "#" || clanName == "" || clanName == "nobody") nullclan = true;
|
||||
// bool nullclan = false;
|
||||
// if(clanName == "#" || clanName == "" || clanName == "nobody") nullclan = true;
|
||||
|
||||
u16 clan = 0;
|
||||
if(!nullclan){
|
||||
// if(!nullclan){
|
||||
clan = m_env.clansManager.clanId(clanName);
|
||||
if(!clan){
|
||||
derr_server<<"Wrong clan name"<<std::endl;
|
||||
try{
|
||||
SendChatMessage(peer_id,L"Server: You are not member of that clan.");
|
||||
}
|
||||
catch(con::PeerNotFoundException &e)
|
||||
{}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
//player must be in this clan or clan is null
|
||||
if(clan && player->clans.find(clan) == player->clans.end())
|
||||
return;
|
||||
|
||||
block->setOwner(clan);
|
||||
if(clan) text = "Property of " + clanName;
|
||||
else text = "Property of nobody";
|
||||
player->lastClan=clan;
|
||||
text = "Property of " + m_env.clansManager.clanNameNoEx(clan);
|
||||
} else if( node.getContent() == CONTENT_TELEPORT ){
|
||||
|
||||
//j teleport
|
||||
|
Loading…
x
Reference in New Issue
Block a user