forked from oerkki/voxelands
make /ban work on players that are not connected
This commit is contained in:
parent
8df27552c4
commit
4b0027d909
|
@ -2200,7 +2200,7 @@ void craft_set_creative_inventory(Player *player)
|
|||
CONTENT_COTTON,
|
||||
CONTENT_CHEST,
|
||||
CONTENT_FURNACE,
|
||||
CONTENT_SIGN_WALL,
|
||||
CONTENT_SIGN,
|
||||
CONTENT_LAVASOURCE,
|
||||
CONTENT_WOOD,
|
||||
CONTENT_LADDER,
|
||||
|
|
|
@ -184,7 +184,8 @@ public:
|
|||
class ServerRemotePlayer : public Player
|
||||
{
|
||||
public:
|
||||
ServerRemotePlayer()
|
||||
ServerRemotePlayer():
|
||||
m_addr("")
|
||||
{
|
||||
}
|
||||
virtual ~ServerRemotePlayer()
|
||||
|
@ -200,7 +201,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
void setAddress(std::string addr) {m_addr = addr;}
|
||||
std::string getAddress() {return m_addr;}
|
||||
|
||||
private:
|
||||
std::string m_addr;
|
||||
};
|
||||
|
||||
#ifndef SERVER
|
||||
|
|
|
@ -2024,6 +2024,11 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
|||
<<": failed to emerge player"<<std::endl;
|
||||
return;
|
||||
}
|
||||
{
|
||||
Address address = getPeerAddress(peer_id);
|
||||
std::string ip_string = address.serializeString();
|
||||
((ServerRemotePlayer*)player)->setAddress(ip_string);
|
||||
}
|
||||
|
||||
/*
|
||||
Answer with a TOCLIENT_INIT
|
||||
|
|
|
@ -261,7 +261,17 @@ void cmd_banunban(std::wostringstream &os, ServerCommandContext *ctx)
|
|||
actionstream<<ctx->player->getName()<<" bans "
|
||||
<<player->getName()<<" / "<<ip_string<<std::endl;
|
||||
} catch(con::PeerNotFoundException){
|
||||
dstream<<__FUNCTION_NAME<<": peer was not found"<<std::endl;
|
||||
std::string ip_string = ((ServerRemotePlayer*)player)->getAddress();
|
||||
if (ip_string != "") {
|
||||
ctx->server->setIpBanned(ip_string, player->getName());
|
||||
os<<L"-!- Banned "<<narrow_to_wide(ip_string)<<L"|"
|
||||
<<narrow_to_wide(player->getName());
|
||||
|
||||
actionstream<<ctx->player->getName()<<" bans "
|
||||
<<player->getName()<<" / "<<ip_string<<std::endl;
|
||||
}else{
|
||||
dstream<<__FUNCTION_NAME<<": peer was not found"<<std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue