merged CiaranG's stuff again: auto-admin powers to local user, DSTACK macro -Wformat warnings
commit
07ff1da6ae
|
@ -169,7 +169,10 @@ private:
|
||||||
bool m_overflowed;
|
bool m_overflowed;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DSTACK(...)\
|
#define DSTACK(msg)\
|
||||||
|
DebugStacker __debug_stacker(msg);
|
||||||
|
|
||||||
|
#define DSTACKF(...)\
|
||||||
char __buf[DEBUG_STACK_TEXT_SIZE];\
|
char __buf[DEBUG_STACK_TEXT_SIZE];\
|
||||||
snprintf(__buf,\
|
snprintf(__buf,\
|
||||||
DEBUG_STACK_TEXT_SIZE, __VA_ARGS__);\
|
DEBUG_STACK_TEXT_SIZE, __VA_ARGS__);\
|
||||||
|
|
|
@ -3830,7 +3830,7 @@ MapChunk* ServerMap::generateChunk(v2s16 chunkpos1,
|
||||||
|
|
||||||
ServerMapSector * ServerMap::createSector(v2s16 p2d)
|
ServerMapSector * ServerMap::createSector(v2s16 p2d)
|
||||||
{
|
{
|
||||||
DSTACK("%s: p2d=(%d,%d)",
|
DSTACKF("%s: p2d=(%d,%d)",
|
||||||
__FUNCTION_NAME,
|
__FUNCTION_NAME,
|
||||||
p2d.X, p2d.Y);
|
p2d.X, p2d.Y);
|
||||||
|
|
||||||
|
@ -3982,7 +3982,7 @@ MapBlock * ServerMap::generateBlock(
|
||||||
core::map<v3s16, MapBlock*> &lighting_invalidated_blocks
|
core::map<v3s16, MapBlock*> &lighting_invalidated_blocks
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DSTACK("%s: p=(%d,%d,%d)",
|
DSTACKF("%s: p=(%d,%d,%d)",
|
||||||
__FUNCTION_NAME,
|
__FUNCTION_NAME,
|
||||||
p.X, p.Y, p.Z);
|
p.X, p.Y, p.Z);
|
||||||
|
|
||||||
|
@ -4618,7 +4618,7 @@ continue_generating:
|
||||||
|
|
||||||
MapBlock * ServerMap::createBlock(v3s16 p)
|
MapBlock * ServerMap::createBlock(v3s16 p)
|
||||||
{
|
{
|
||||||
DSTACK("%s: p=(%d,%d,%d)",
|
DSTACKF("%s: p=(%d,%d,%d)",
|
||||||
__FUNCTION_NAME, p.X, p.Y, p.Z);
|
__FUNCTION_NAME, p.X, p.Y, p.Z);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -4682,7 +4682,7 @@ MapBlock * ServerMap::emergeBlock(
|
||||||
core::map<v3s16, MapBlock*> &lighting_invalidated_blocks
|
core::map<v3s16, MapBlock*> &lighting_invalidated_blocks
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DSTACK("%s: p=(%d,%d,%d), only_from_disk=%d",
|
DSTACKF("%s: p=(%d,%d,%d), only_from_disk=%d",
|
||||||
__FUNCTION_NAME,
|
__FUNCTION_NAME,
|
||||||
p.X, p.Y, p.Z, only_from_disk);
|
p.X, p.Y, p.Z, only_from_disk);
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ v3f MovingObject::getAbsoluteShowPos()
|
||||||
|
|
||||||
void MovingObject::move(float dtime, v3f acceleration)
|
void MovingObject::move(float dtime, v3f acceleration)
|
||||||
{
|
{
|
||||||
DSTACK("%s: typeid=%i, pos=(%f,%f,%f), speed=(%f,%f,%f)"
|
DSTACKF("%s: typeid=%i, pos=(%f,%f,%f), speed=(%f,%f,%f)"
|
||||||
", dtime=%f, acc=(%f,%f,%f)",
|
", dtime=%f, acc=(%f,%f,%f)",
|
||||||
__FUNCTION_NAME,
|
__FUNCTION_NAME,
|
||||||
getTypeId(),
|
getTypeId(),
|
||||||
|
@ -755,7 +755,7 @@ void MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio)
|
||||||
core::map<s16, bool> ids_to_delete;
|
core::map<s16, bool> ids_to_delete;
|
||||||
|
|
||||||
{
|
{
|
||||||
DSTACK("%s: stepping objects", __FUNCTION_NAME);
|
DSTACKF("%s: stepping objects", __FUNCTION_NAME);
|
||||||
|
|
||||||
for(core::map<s16, MapBlockObject*>::Iterator
|
for(core::map<s16, MapBlockObject*>::Iterator
|
||||||
i = m_objects.getIterator();
|
i = m_objects.getIterator();
|
||||||
|
@ -763,7 +763,7 @@ void MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio)
|
||||||
{
|
{
|
||||||
MapBlockObject *obj = i.getNode()->getValue();
|
MapBlockObject *obj = i.getNode()->getValue();
|
||||||
|
|
||||||
DSTACK("%s: stepping object type %i", __FUNCTION_NAME,
|
DSTACKF("%s: stepping object type %i", __FUNCTION_NAME,
|
||||||
obj->getTypeId());
|
obj->getTypeId());
|
||||||
|
|
||||||
if(server)
|
if(server)
|
||||||
|
@ -791,7 +791,7 @@ void MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
DSTACK("%s: deleting objects", __FUNCTION_NAME);
|
DSTACKF("%s: deleting objects", __FUNCTION_NAME);
|
||||||
|
|
||||||
// Delete objects in delete queue
|
// Delete objects in delete queue
|
||||||
for(core::map<s16, bool>::Iterator
|
for(core::map<s16, bool>::Iterator
|
||||||
|
@ -815,7 +815,7 @@ void MapBlockObjectList::step(float dtime, bool server, u32 daynight_ratio)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
{
|
{
|
||||||
DSTACK("%s: object wrap loop", __FUNCTION_NAME);
|
DSTACKF("%s: object wrap loop", __FUNCTION_NAME);
|
||||||
|
|
||||||
for(core::map<s16, MapBlockObject*>::Iterator
|
for(core::map<s16, MapBlockObject*>::Iterator
|
||||||
i = m_objects.getIterator();
|
i = m_objects.getIterator();
|
||||||
|
|
|
@ -2870,12 +2870,18 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
|
||||||
|
|
||||||
message = message.substr(commandprefix.size());
|
message = message.substr(commandprefix.size());
|
||||||
|
|
||||||
|
// Local player gets all privileges regardless of
|
||||||
|
// what's set on their account.
|
||||||
|
u64 privs = player->privs;
|
||||||
|
if(g_settings.get("name") == player->getName())
|
||||||
|
privs = PRIV_ALL;
|
||||||
|
|
||||||
ServerCommandContext *ctx = new ServerCommandContext(
|
ServerCommandContext *ctx = new ServerCommandContext(
|
||||||
str_split(message, L' '),
|
str_split(message, L' '),
|
||||||
this,
|
this,
|
||||||
&m_env,
|
&m_env,
|
||||||
player
|
player,
|
||||||
);
|
privs);
|
||||||
|
|
||||||
line += processServerCommand(ctx);
|
line += processServerCommand(ctx);
|
||||||
send_to_sender = ctx->flags & 1;
|
send_to_sender = ctx->flags & 1;
|
||||||
|
|
|
@ -33,11 +33,13 @@ void cmd_privs(std::wostringstream &os,
|
||||||
{
|
{
|
||||||
if(ctx->parms.size() == 1)
|
if(ctx->parms.size() == 1)
|
||||||
{
|
{
|
||||||
|
// Show our own real privs, without any adjustments
|
||||||
|
// made for admin status
|
||||||
os<<L"-!- " + privsToString(ctx->player->privs);
|
os<<L"-!- " + privsToString(ctx->player->privs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ctx->player->privs & PRIV_PRIVS) == 0)
|
if((ctx->privs & PRIV_PRIVS) == 0)
|
||||||
{
|
{
|
||||||
os<<L"-!- You don't have permission to do that";
|
os<<L"-!- You don't have permission to do that";
|
||||||
return;
|
return;
|
||||||
|
@ -62,7 +64,7 @@ void cmd_grantrevoke(std::wostringstream &os,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ctx->player->privs & PRIV_PRIVS) == 0)
|
if((ctx->privs & PRIV_PRIVS) == 0)
|
||||||
{
|
{
|
||||||
os<<L"-!- You don't have permission to do that";
|
os<<L"-!- You don't have permission to do that";
|
||||||
return;
|
return;
|
||||||
|
@ -100,7 +102,7 @@ void cmd_time(std::wostringstream &os,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((ctx->player->privs & PRIV_SETTIME) ==0)
|
if((ctx->privs & PRIV_SETTIME) ==0)
|
||||||
{
|
{
|
||||||
os<<L"-!- You don't have permission to do that";
|
os<<L"-!- You don't have permission to do that";
|
||||||
return;
|
return;
|
||||||
|
@ -114,7 +116,7 @@ void cmd_time(std::wostringstream &os,
|
||||||
void cmd_shutdown(std::wostringstream &os,
|
void cmd_shutdown(std::wostringstream &os,
|
||||||
ServerCommandContext *ctx)
|
ServerCommandContext *ctx)
|
||||||
{
|
{
|
||||||
if((ctx->player->privs & PRIV_SERVER) ==0)
|
if((ctx->privs & PRIV_SERVER) ==0)
|
||||||
{
|
{
|
||||||
os<<L"-!- You don't have permission to do that";
|
os<<L"-!- You don't have permission to do that";
|
||||||
return;
|
return;
|
||||||
|
@ -131,7 +133,7 @@ void cmd_shutdown(std::wostringstream &os,
|
||||||
void cmd_setting(std::wostringstream &os,
|
void cmd_setting(std::wostringstream &os,
|
||||||
ServerCommandContext *ctx)
|
ServerCommandContext *ctx)
|
||||||
{
|
{
|
||||||
if((ctx->player->privs & PRIV_SERVER) ==0)
|
if((ctx->privs & PRIV_SERVER) ==0)
|
||||||
{
|
{
|
||||||
os<<L"-!- You don't have permission to do that";
|
os<<L"-!- You don't have permission to do that";
|
||||||
return;
|
return;
|
||||||
|
@ -145,7 +147,7 @@ void cmd_setting(std::wostringstream &os,
|
||||||
void cmd_teleport(std::wostringstream &os,
|
void cmd_teleport(std::wostringstream &os,
|
||||||
ServerCommandContext *ctx)
|
ServerCommandContext *ctx)
|
||||||
{
|
{
|
||||||
if((ctx->player->privs & PRIV_TELEPORT) ==0)
|
if((ctx->privs & PRIV_TELEPORT) ==0)
|
||||||
{
|
{
|
||||||
os<<L"-!- You don't have permission to do that";
|
os<<L"-!- You don't have permission to do that";
|
||||||
return;
|
return;
|
||||||
|
@ -178,7 +180,7 @@ std::wstring processServerCommand(ServerCommandContext *ctx)
|
||||||
std::wostringstream os(std::ios_base::binary);
|
std::wostringstream os(std::ios_base::binary);
|
||||||
ctx->flags = 1; // Default, unless we change it.
|
ctx->flags = 1; // Default, unless we change it.
|
||||||
|
|
||||||
u64 privs = ctx->player->privs;
|
u64 privs = ctx->privs;
|
||||||
|
|
||||||
if(ctx->parms.size() == 0 || ctx->parms[0] == L"help")
|
if(ctx->parms.size() == 0 || ctx->parms[0] == L"help")
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,14 +34,18 @@ struct ServerCommandContext
|
||||||
Server* server;
|
Server* server;
|
||||||
ServerEnvironment *env;
|
ServerEnvironment *env;
|
||||||
Player* player;
|
Player* player;
|
||||||
|
// Effective privs for the player, which may be different to their
|
||||||
|
// stored ones - e.g. if they are named in the config as an admin.
|
||||||
|
u64 privs;
|
||||||
u32 flags;
|
u32 flags;
|
||||||
|
|
||||||
ServerCommandContext(
|
ServerCommandContext(
|
||||||
std::vector<std::wstring> parms,
|
std::vector<std::wstring> parms,
|
||||||
Server* server,
|
Server* server,
|
||||||
ServerEnvironment *env,
|
ServerEnvironment *env,
|
||||||
Player* player)
|
Player* player,
|
||||||
: parms(parms), server(server), env(env), player(player)
|
u64 privs)
|
||||||
|
: parms(parms), server(server), env(env), player(player), privs(privs)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue